88} from "./constants" ;
99import { IS_CLIENT } from "./utils/constants" ;
1010import { readLocalStorage , saveLocalStorage } from "./utils/helpers" ;
11+ import { getSafeArea } from "./utils/safe-area" ;
1112import type { Corner , WidgetConfig , WidgetSettings } from "./widget/types" ;
1213import type { CollapsedPosition } from "./widget/types" ;
1314
@@ -16,8 +17,10 @@ export const signalRefWidget = /* @__PURE__ */ signal<HTMLDivElement | null>(
1617 null
1718) ;
1819
19- export const defaultWidgetConfig = {
20- corner : "bottom-right" as Corner ,
20+ // Use the raw SAFE_AREA constant (not getSafeArea()) here: this runs at
21+ // module-init time, before any user has called scan() with options.
22+ export const getDefaultWidgetConfig = ( ) : WidgetConfig => ( {
23+ corner : "bottom-right" satisfies Corner ,
2124 dimensions : {
2225 isFullWidth : false ,
2326 isFullHeight : false ,
@@ -35,30 +38,36 @@ export const defaultWidgetConfig = {
3538 componentsTree : {
3639 width : MIN_CONTAINER_WIDTH ,
3740 } ,
38- } as WidgetConfig ;
41+ } ) ;
42+
43+ // Deprecated alias kept for one minor version to avoid breaking downstream
44+ // imports of the pre-refactor `defaultWidgetConfig` const.
45+ /** @deprecated use {@link getDefaultWidgetConfig} */
46+ export const defaultWidgetConfig : WidgetConfig = getDefaultWidgetConfig ( ) ;
3947
4048export const getInitialWidgetConfig = ( ) : WidgetConfig => {
49+ const defaults = getDefaultWidgetConfig ( ) ;
4150 const stored = readLocalStorage < WidgetSettings > ( LOCALSTORAGE_KEY ) ;
4251 if ( ! stored ) {
4352 saveLocalStorage ( LOCALSTORAGE_KEY , {
44- corner : defaultWidgetConfig . corner ,
45- dimensions : defaultWidgetConfig . dimensions ,
46- lastDimensions : defaultWidgetConfig . lastDimensions ,
47- componentsTree : defaultWidgetConfig . componentsTree ,
53+ corner : defaults . corner ,
54+ dimensions : defaults . dimensions ,
55+ lastDimensions : defaults . lastDimensions ,
56+ componentsTree : defaults . componentsTree ,
4857 } ) ;
4958
50- return defaultWidgetConfig ;
59+ return defaults ;
5160 }
5261
5362 return {
54- corner : stored . corner ?? defaultWidgetConfig . corner ,
55- dimensions : stored . dimensions ?? defaultWidgetConfig . dimensions ,
63+ corner : stored . corner ?? defaults . corner ,
64+ dimensions : stored . dimensions ?? defaults . dimensions ,
5665
5766 lastDimensions :
5867 stored . lastDimensions ??
5968 stored . dimensions ??
60- defaultWidgetConfig . lastDimensions ,
61- componentsTree : stored . componentsTree ?? defaultWidgetConfig . componentsTree ,
69+ defaults . lastDimensions ,
70+ componentsTree : stored . componentsTree ?? defaults . componentsTree ,
6271 } ;
6372} ;
6473
@@ -69,12 +78,13 @@ export const updateDimensions = (): void => {
6978
7079 const { dimensions } = signalWidget . value ;
7180 const { width, height, position } = dimensions ;
81+ const safeArea = getSafeArea ( ) ;
7282
7383 signalWidget . value = {
7484 ...signalWidget . value ,
7585 dimensions : {
76- isFullWidth : width >= window . innerWidth - SAFE_AREA * 2 ,
77- isFullHeight : height >= window . innerHeight - SAFE_AREA * 2 ,
86+ isFullWidth : width >= window . innerWidth - safeArea . left - safeArea . right ,
87+ isFullHeight : height >= window . innerHeight - safeArea . top - safeArea . bottom ,
7888 width,
7989 height,
8090 position,
0 commit comments