@ottocode/web-sdk 0.1.252 → 0.1.253
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/components/index.js +43 -8
- package/dist/components/index.js.map +4 -4
- package/dist/components/settings/SettingsSidebar.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/index.js.map +3 -3
- package/dist/hooks/usePreferences.d.ts.map +1 -1
- package/dist/index.js +43 -8
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
package/dist/components/index.js
CHANGED
|
@@ -1806,6 +1806,9 @@ function applyFontFamily(fontFamily) {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
document.documentElement.style.setProperty("--otto-font-family", cssFontFamily(fontFamily));
|
|
1808
1808
|
document.documentElement.dataset.ottoFontFamily = fontFamily;
|
|
1809
|
+
if (window.self !== window.top) {
|
|
1810
|
+
window.parent.postMessage({ type: "otto-font-family-changed", fontFamily }, "*");
|
|
1811
|
+
}
|
|
1809
1812
|
}
|
|
1810
1813
|
function resolveInitialPreferences() {
|
|
1811
1814
|
if (typeof window === "undefined") {
|
|
@@ -21638,6 +21641,32 @@ var COMMON_SYSTEM_FONTS = [
|
|
|
21638
21641
|
"Ubuntu",
|
|
21639
21642
|
"Verdana"
|
|
21640
21643
|
];
|
|
21644
|
+
function requestDesktopSystemFonts() {
|
|
21645
|
+
if (typeof window === "undefined" || window.self === window.top) {
|
|
21646
|
+
return Promise.resolve(null);
|
|
21647
|
+
}
|
|
21648
|
+
return new Promise((resolve, reject) => {
|
|
21649
|
+
const requestId = crypto.randomUUID();
|
|
21650
|
+
const timeout = window.setTimeout(() => {
|
|
21651
|
+
window.removeEventListener("message", handleMessage);
|
|
21652
|
+
resolve(null);
|
|
21653
|
+
}, 3000);
|
|
21654
|
+
function handleMessage(event) {
|
|
21655
|
+
if (event.data?.type !== "otto-system-fonts-result" || event.data.requestId !== requestId) {
|
|
21656
|
+
return;
|
|
21657
|
+
}
|
|
21658
|
+
window.clearTimeout(timeout);
|
|
21659
|
+
window.removeEventListener("message", handleMessage);
|
|
21660
|
+
if (event.data.error) {
|
|
21661
|
+
reject(new Error(event.data.error));
|
|
21662
|
+
return;
|
|
21663
|
+
}
|
|
21664
|
+
resolve(event.data.fonts ?? null);
|
|
21665
|
+
}
|
|
21666
|
+
window.addEventListener("message", handleMessage);
|
|
21667
|
+
window.parent.postMessage({ type: "otto-list-system-fonts", requestId }, "*");
|
|
21668
|
+
});
|
|
21669
|
+
}
|
|
21641
21670
|
var SettingsSection = memo31(function SettingsSection2({
|
|
21642
21671
|
title,
|
|
21643
21672
|
icon,
|
|
@@ -21805,6 +21834,7 @@ var FontPickerRow = memo31(function FontPickerRow2({
|
|
|
21805
21834
|
const [isLoadingFonts, setIsLoadingFonts] = useState39(false);
|
|
21806
21835
|
const [fontError, setFontError] = useState39(null);
|
|
21807
21836
|
const canQueryLocalFonts = typeof window !== "undefined" && typeof window.queryLocalFonts === "function";
|
|
21837
|
+
const canRequestDesktopFonts = typeof window !== "undefined" && window.self !== window.top;
|
|
21808
21838
|
const fontOptions = useMemo22(() => {
|
|
21809
21839
|
return Array.from(new Set([value, ...localFonts, ...COMMON_SYSTEM_FONTS].filter(Boolean))).sort((a, b) => a.localeCompare(b));
|
|
21810
21840
|
}, [localFonts, value]);
|
|
@@ -21818,15 +21848,20 @@ var FontPickerRow = memo31(function FontPickerRow2({
|
|
|
21818
21848
|
if (isLoadingFonts || localFonts.length > 0)
|
|
21819
21849
|
return;
|
|
21820
21850
|
const queryLocalFonts = window.queryLocalFonts;
|
|
21821
|
-
if (!queryLocalFonts) {
|
|
21822
|
-
setFontError("Local font access is not supported in this browser");
|
|
21823
|
-
return;
|
|
21824
|
-
}
|
|
21825
21851
|
setIsLoadingFonts(true);
|
|
21826
21852
|
setFontError(null);
|
|
21827
21853
|
try {
|
|
21828
|
-
|
|
21829
|
-
|
|
21854
|
+
if (queryLocalFonts) {
|
|
21855
|
+
const fonts = await queryLocalFonts();
|
|
21856
|
+
setLocalFonts(Array.from(new Set(fonts.map((font) => font.family).filter(Boolean))));
|
|
21857
|
+
return;
|
|
21858
|
+
}
|
|
21859
|
+
const desktopFonts = await requestDesktopSystemFonts();
|
|
21860
|
+
if (desktopFonts?.length) {
|
|
21861
|
+
setLocalFonts(desktopFonts);
|
|
21862
|
+
return;
|
|
21863
|
+
}
|
|
21864
|
+
setFontError("Local font access is not supported in this browser");
|
|
21830
21865
|
} catch (error) {
|
|
21831
21866
|
setFontError(error instanceof Error ? error.message : "Unable to load local fonts");
|
|
21832
21867
|
} finally {
|
|
@@ -21906,7 +21941,7 @@ var FontPickerRow = memo31(function FontPickerRow2({
|
|
|
21906
21941
|
}),
|
|
21907
21942
|
/* @__PURE__ */ jsx88("div", {
|
|
21908
21943
|
className: "border-t border-border px-3 py-2 text-xs text-muted-foreground",
|
|
21909
|
-
children: isLoadingFonts ? "Loading local fonts..." : fontError ? fontError : localFonts.length > 0 ? `${localFonts.length} local fonts found` : canQueryLocalFonts ? "Choose a font or allow local font access if prompted" : "Showing common system fonts"
|
|
21944
|
+
children: isLoadingFonts ? "Loading local fonts..." : fontError ? fontError : localFonts.length > 0 ? `${localFonts.length} local fonts found` : canQueryLocalFonts ? "Choose a font or allow local font access if prompted" : canRequestDesktopFonts ? "Loading desktop system fonts if available" : "Showing common system fonts"
|
|
21910
21945
|
})
|
|
21911
21946
|
]
|
|
21912
21947
|
})
|
|
@@ -27491,4 +27526,4 @@ export {
|
|
|
27491
27526
|
AssistantMessageGroup
|
|
27492
27527
|
};
|
|
27493
27528
|
|
|
27494
|
-
//# debugId=
|
|
27529
|
+
//# debugId=211D9BCBB0C8D95664756E2164756E21
|