@fluid-app/portal-sdk 0.1.429 → 0.1.430
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/dist/index.cjs +31 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -3
- package/dist/index.mjs.map +1 -1
- package/dist/shell/AppShell.d.ts.map +1 -1
- package/dist/shell/__tests__/native-theme-bridge.test.d.ts +2 -0
- package/dist/shell/__tests__/native-theme-bridge.test.d.ts.map +1 -0
- package/dist/shell/native-theme-bridge.d.ts +32 -0
- package/dist/shell/native-theme-bridge.d.ts.map +1 -0
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -2023,6 +2023,29 @@ var AppShellErrorBoundary = class extends react.Component {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
};
|
|
2025
2025
|
//#endregion
|
|
2026
|
+
//#region src/shell/native-theme-bridge.ts
|
|
2027
|
+
const PORTAL_NATIVE_THEME_MESSAGE_TYPE = "fluid.portal.theme";
|
|
2028
|
+
function colorToSrgbHex(color) {
|
|
2029
|
+
const srgb = color.to("srgb");
|
|
2030
|
+
srgb.alpha = 1;
|
|
2031
|
+
return srgb.toString({ format: "hex" });
|
|
2032
|
+
}
|
|
2033
|
+
function createPortalNativeThemeMessage({ resolvedTheme, mode }) {
|
|
2034
|
+
return {
|
|
2035
|
+
type: PORTAL_NATIVE_THEME_MESSAGE_TYPE,
|
|
2036
|
+
version: 1,
|
|
2037
|
+
payload: {
|
|
2038
|
+
themeId: resolvedTheme.id,
|
|
2039
|
+
mode,
|
|
2040
|
+
colors: { muted: colorToSrgbHex(resolvedTheme[mode].muted.base) }
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
2044
|
+
function postPortalNativeThemeMessage(message) {
|
|
2045
|
+
if (typeof window === "undefined") return;
|
|
2046
|
+
window.ReactNativeWebView?.postMessage(JSON.stringify(message));
|
|
2047
|
+
}
|
|
2048
|
+
//#endregion
|
|
2026
2049
|
//#region src/shell/SdkLogoutButton.tsx
|
|
2027
2050
|
/**
|
|
2028
2051
|
* Sidebar footer slot. Renders Theme toggle + Log out.
|
|
@@ -2227,9 +2250,14 @@ function AppShell({ appData: appDataProp, navigation: navigationProp, customPage
|
|
|
2227
2250
|
const metaEl = meta;
|
|
2228
2251
|
const theme = resolvedTheme;
|
|
2229
2252
|
function update(prefersDark) {
|
|
2230
|
-
const
|
|
2231
|
-
|
|
2232
|
-
|
|
2253
|
+
const nativeThemeMessage = createPortalNativeThemeMessage({
|
|
2254
|
+
resolvedTheme: theme,
|
|
2255
|
+
mode: themeMode === "auto" ? prefersDark ? "dark" : "light" : themeMode
|
|
2256
|
+
});
|
|
2257
|
+
const mutedColor = nativeThemeMessage.payload.colors.muted;
|
|
2258
|
+
metaEl.content = mutedColor;
|
|
2259
|
+
document.body.style.backgroundColor = mutedColor;
|
|
2260
|
+
postPortalNativeThemeMessage(nativeThemeMessage);
|
|
2233
2261
|
}
|
|
2234
2262
|
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
2235
2263
|
update(mql.matches);
|