From 326fcf26a6aabec5eb1aadfb182a06d544cd100e Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Thu, 30 Apr 2026 06:34:28 -0400 Subject: [PATCH 1/3] Patch Stoplight mosaic storage fallback --- patches/@stoplight+mosaic+1.53.4.patch | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 patches/@stoplight+mosaic+1.53.4.patch diff --git a/patches/@stoplight+mosaic+1.53.4.patch b/patches/@stoplight+mosaic+1.53.4.patch new file mode 100644 index 0000000000..9ea7e665a1 --- /dev/null +++ b/patches/@stoplight+mosaic+1.53.4.patch @@ -0,0 +1,62 @@ +diff --git a/node_modules/@stoplight/mosaic/core.esm.js b/node_modules/@stoplight/mosaic/core.esm.js +index 1d4db8c..8b07522 100644 +--- a/node_modules/@stoplight/mosaic/core.esm.js ++++ b/node_modules/@stoplight/mosaic/core.esm.js +@@ -5645,6 +5645,9 @@ const memoryStorage = { + getItem: name => memoryDb[name], + setItem: (name, value) => { + memoryDb[name] = value; ++ }, ++ removeItem: name => { ++ delete memoryDb[name]; + } + }; + +@@ -5655,6 +5658,7 @@ const defaultMode = () => { + return JSON.parse(localStorage.getItem(THEME_STORAGE_KEY)).mode; + } catch (_a) {} + ++ if (typeof document === 'undefined') return DEFAULT_THEME_MODE; + const dataTheme = document.documentElement.getAttribute('data-theme'); + if (dataTheme) return dataTheme; + return DEFAULT_THEME_MODE; +@@ -5736,7 +5740,7 @@ const useThemeStore = create(persist(set => ({ + }), { + name: THEME_STORAGE_KEY, + version: 0, +- getStorage: () => typeof localStorage === 'undefined' ? memoryStorage : localStorage, ++ getStorage: () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage, + // only remember the desired mode + serialize: ({ + state, +diff --git a/node_modules/@stoplight/mosaic/core.umd.js b/node_modules/@stoplight/mosaic/core.umd.js +index 6a21eba..a4c2cec 100644 +--- a/node_modules/@stoplight/mosaic/core.umd.js ++++ b/node_modules/@stoplight/mosaic/core.umd.js +@@ -5683,6 +5683,9 @@ + getItem: name => memoryDb[name], + setItem: (name, value) => { + memoryDb[name] = value; ++ }, ++ removeItem: name => { ++ delete memoryDb[name]; + } + }; + +@@ -5693,6 +5696,7 @@ + return JSON.parse(localStorage.getItem(THEME_STORAGE_KEY)).mode; + } catch (_a) {} + ++ if (typeof document === 'undefined') return DEFAULT_THEME_MODE; + const dataTheme = document.documentElement.getAttribute('data-theme'); + if (dataTheme) return dataTheme; + return DEFAULT_THEME_MODE; +@@ -5774,7 +5778,7 @@ + }), { + name: THEME_STORAGE_KEY, + version: 0, +- getStorage: () => typeof localStorage === 'undefined' ? memoryStorage : localStorage, ++ getStorage: () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage, + // only remember the desired mode + serialize: ({ + state, From fe0cdac37358ea0dfc31d91dd45707671c5e1211 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Thu, 30 Apr 2026 07:15:27 -0400 Subject: [PATCH 2/3] Align Mosaic theme storage fallback --- patches/@stoplight+mosaic+1.53.4.patch | 32 ++++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/patches/@stoplight+mosaic+1.53.4.patch b/patches/@stoplight+mosaic+1.53.4.patch index 9ea7e665a1..082349206a 100644 --- a/patches/@stoplight+mosaic+1.53.4.patch +++ b/patches/@stoplight+mosaic+1.53.4.patch @@ -2,7 +2,7 @@ diff --git a/node_modules/@stoplight/mosaic/core.esm.js b/node_modules/@stopligh index 1d4db8c..8b07522 100644 --- a/node_modules/@stoplight/mosaic/core.esm.js +++ b/node_modules/@stoplight/mosaic/core.esm.js -@@ -5645,6 +5645,9 @@ const memoryStorage = { +@@ -5645,17 +5645,20 @@ const memoryStorage = { getItem: name => memoryDb[name], setItem: (name, value) => { memoryDb[name] = value; @@ -12,20 +12,26 @@ index 1d4db8c..8b07522 100644 } }; -@@ -5655,6 +5658,7 @@ const defaultMode = () => { - return JSON.parse(localStorage.getItem(THEME_STORAGE_KEY)).mode; + const defaultMode = () => { +- if (typeof localStorage === 'undefined') return DEFAULT_THEME_MODE; +- + try { +- return JSON.parse(localStorage.getItem(THEME_STORAGE_KEY)).mode; ++ return JSON.parse(getThemeStorage().getItem(THEME_STORAGE_KEY)).mode; } catch (_a) {} + if (typeof document === 'undefined') return DEFAULT_THEME_MODE; const dataTheme = document.documentElement.getAttribute('data-theme'); if (dataTheme) return dataTheme; return DEFAULT_THEME_MODE; -@@ -5736,7 +5740,7 @@ const useThemeStore = create(persist(set => ({ + }; ++const getThemeStorage = () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage; +@@ -5736,7 +5739,7 @@ const useThemeStore = create(persist(set => ({ }), { name: THEME_STORAGE_KEY, version: 0, - getStorage: () => typeof localStorage === 'undefined' ? memoryStorage : localStorage, -+ getStorage: () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage, ++ getStorage: getThemeStorage, // only remember the desired mode serialize: ({ state, @@ -33,7 +39,7 @@ diff --git a/node_modules/@stoplight/mosaic/core.umd.js b/node_modules/@stopligh index 6a21eba..a4c2cec 100644 --- a/node_modules/@stoplight/mosaic/core.umd.js +++ b/node_modules/@stoplight/mosaic/core.umd.js -@@ -5683,6 +5683,9 @@ +@@ -5683,17 +5683,20 @@ getItem: name => memoryDb[name], setItem: (name, value) => { memoryDb[name] = value; @@ -43,20 +49,26 @@ index 6a21eba..a4c2cec 100644 } }; -@@ -5693,6 +5696,7 @@ - return JSON.parse(localStorage.getItem(THEME_STORAGE_KEY)).mode; + const defaultMode = () => { +- if (typeof localStorage === 'undefined') return DEFAULT_THEME_MODE; +- + try { +- return JSON.parse(localStorage.getItem(THEME_STORAGE_KEY)).mode; ++ return JSON.parse(getThemeStorage().getItem(THEME_STORAGE_KEY)).mode; } catch (_a) {} + if (typeof document === 'undefined') return DEFAULT_THEME_MODE; const dataTheme = document.documentElement.getAttribute('data-theme'); if (dataTheme) return dataTheme; return DEFAULT_THEME_MODE; -@@ -5774,7 +5778,7 @@ + }; ++ const getThemeStorage = () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage; +@@ -5774,7 +5777,7 @@ }), { name: THEME_STORAGE_KEY, version: 0, - getStorage: () => typeof localStorage === 'undefined' ? memoryStorage : localStorage, -+ getStorage: () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage, ++ getStorage: getThemeStorage, // only remember the desired mode serialize: ({ state, From e2f2e6b1561d5dda35e91ad37b4709c83a69e425 Mon Sep 17 00:00:00 2001 From: "john.xlm" <60260750+JFWooten4@users.noreply.github.com> Date: Thu, 30 Apr 2026 07:21:29 -0400 Subject: [PATCH 3/3] Define Mosaic theme storage helper before use Move getThemeStorage above defaultMode so defaultMode cannot reference the const helper before it is initialized. This keeps the storage-backend alignment fix while avoiding a fragile declaration order in the patched Mosaic bundles. --- patches/@stoplight+mosaic+1.53.4.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/@stoplight+mosaic+1.53.4.patch b/patches/@stoplight+mosaic+1.53.4.patch index 082349206a..962ce81318 100644 --- a/patches/@stoplight+mosaic+1.53.4.patch +++ b/patches/@stoplight+mosaic+1.53.4.patch @@ -12,6 +12,7 @@ index 1d4db8c..8b07522 100644 } }; ++const getThemeStorage = () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage; const defaultMode = () => { - if (typeof localStorage === 'undefined') return DEFAULT_THEME_MODE; - @@ -25,7 +26,6 @@ index 1d4db8c..8b07522 100644 if (dataTheme) return dataTheme; return DEFAULT_THEME_MODE; }; -+const getThemeStorage = () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage; @@ -5736,7 +5739,7 @@ const useThemeStore = create(persist(set => ({ }), { name: THEME_STORAGE_KEY, @@ -49,6 +49,7 @@ index 6a21eba..a4c2cec 100644 } }; ++ const getThemeStorage = () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage; const defaultMode = () => { - if (typeof localStorage === 'undefined') return DEFAULT_THEME_MODE; - @@ -62,7 +63,6 @@ index 6a21eba..a4c2cec 100644 if (dataTheme) return dataTheme; return DEFAULT_THEME_MODE; }; -+ const getThemeStorage = () => typeof localStorage === 'undefined' || typeof localStorage.removeItem !== 'function' ? memoryStorage : localStorage; @@ -5774,7 +5777,7 @@ }), { name: THEME_STORAGE_KEY,