From c5adbdcea9d68f8d55ffe35707e7bd3f6e6d1c79 Mon Sep 17 00:00:00 2001
From: Steven Vandevelde
Date: Fri, 11 Sep 2026 18:48:02 +0200
Subject: [PATCH] fix: old references and facet data migration
---
deno.jsonc | 2 +-
src/common/loader.js | 16 ++++++++++++++--
src/common/tiles.js | 2 +-
src/facets/data/file-manager/facet.js | 2 +-
src/facets/data/sources/index.html | 2 +-
src/facets/themes/blur-classic/facet/index.html | 2 +-
src/facets/themes/blur-pocket/facet/index.html | 2 +-
src/facets/themes/blur/browser/element.js | 2 +-
src/facets/themes/blur/facet/index.html | 2 +-
src/facets/themes/winamp/facet/index.html | 4 ++--
src/facets/themes/winamp/winamp/element.js | 2 +-
11 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/deno.jsonc b/deno.jsonc
index a4767072..6210dd86 100644
--- a/deno.jsonc
+++ b/deno.jsonc
@@ -1,6 +1,6 @@
{
"name": "@toko/diffuse",
- "version": "4.0.0-alpha.2",
+ "version": "4.0.0-alpha.3",
"license": "FSL-1.1-MIT",
"vendor": true,
"imports": {
diff --git a/src/common/loader.js b/src/common/loader.js
index 15a00a09..05964d2a 100644
--- a/src/common/loader.js
+++ b/src/common/loader.js
@@ -15,6 +15,7 @@ import {
parseCar,
resolveRoot,
rewriteCssImports,
+ rewriteLegacyURIPath,
rewriteModuleImports,
tileResourceEntries,
} from "./tiles.js";
@@ -206,6 +207,14 @@ export async function ensureHTML(item) {
* resources map and blocks. Handles inline tiles (a `resources` map plus a
* `blocks` map) and `.tile` CARs referenced by `uri`.
*
+ * Stale `diffuse://` bundle paths pointing at a loose `index.html` (leftover
+ * from before the build packaged every facet into an `index.tile` CAR) are
+ * rewritten to the `.tile` path first, so pre-tile links, bookmarks, and
+ * stored URIs that escaped migration still resolve to the tile instead of
+ * falling back to a loose-file fetch (which would inject the facet HTML
+ * without tile resource linking — its absolute `/facet.js`/`/facet.css`
+ * references then resolve against the deployment root and 404).
+ *
* @param {{ uri?: string; resources?: unknown; blocks?: Record }} item
* @returns {Promise}
*/
@@ -218,8 +227,11 @@ async function materializeTile(item) {
return { html: root.html, cid: root.cid, resources, blocks };
}
- if (item.uri?.endsWith(".tile")) {
- return await loadTileURI(item.uri);
+ const uri = typeof item.uri === "string"
+ ? rewriteLegacyURIPath({ uri: item.uri }).uri
+ : item.uri;
+ if (uri?.endsWith(".tile")) {
+ return await loadTileURI(uri);
}
return undefined;
diff --git a/src/common/tiles.js b/src/common/tiles.js
index c24cf9e2..b211aab3 100644
--- a/src/common/tiles.js
+++ b/src/common/tiles.js
@@ -797,7 +797,7 @@ export function tileFromFiles(files) {
* untouched.
*
* @param {Record} record
- * @returns {Record}
+ * @returns {Record & { uri?: string }}
*
* @example Rewrites a stale bundle html path to its tile
* ```js
diff --git a/src/facets/data/file-manager/facet.js b/src/facets/data/file-manager/facet.js
index 0a3f0597..81c72508 100644
--- a/src/facets/data/file-manager/facet.js
+++ b/src/facets/data/file-manager/facet.js
@@ -237,7 +237,7 @@ const { setLocalItems, setRemoteItems, setError } = setup({
- Got music stored elsewhere, or don't want Diffuse to manage your music? There's a bunch more options to connect to with just read-only access.
+ Got music stored elsewhere, or don't want Diffuse to manage your music? There's a bunch more options to connect to with just read-only access.
`,
diff --git a/src/facets/data/sources/index.html b/src/facets/data/sources/index.html
index de64248b..a98fa150 100644
--- a/src/facets/data/sources/index.html
+++ b/src/facets/data/sources/index.html
@@ -25,7 +25,7 @@
(on by default), otherwise click the button below.
-
+
Add a source
diff --git a/src/facets/themes/blur-classic/facet/index.html b/src/facets/themes/blur-classic/facet/index.html
index 722c172d..874caeb0 100644
--- a/src/facets/themes/blur-classic/facet/index.html
+++ b/src/facets/themes/blur-classic/facet/index.html
@@ -14,7 +14,7 @@