@mywallpaper/addon-sdk 2.9.0 → 2.10.0
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.d.mts +95 -0
- package/dist/index.d.ts +95 -0
- package/dist/manifest.d.mts +95 -0
- package/dist/manifest.d.ts +95 -0
- package/package.json +1 -1
- package/src/runtime/addon-client.js +71 -0
package/dist/index.d.mts
CHANGED
|
@@ -603,6 +603,21 @@ interface MyWallpaperAPI {
|
|
|
603
603
|
* ```
|
|
604
604
|
*/
|
|
605
605
|
audio: AudioAPI;
|
|
606
|
+
/**
|
|
607
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
608
|
+
* Allows widgets to populate dropdowns based on external data.
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* // After loading font CSS, update the font family dropdown
|
|
613
|
+
* const fonts = parseFontFaces(cssContent)
|
|
614
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
615
|
+
* label: f.family,
|
|
616
|
+
* value: f.family
|
|
617
|
+
* })))
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
settings: SettingsAPI;
|
|
606
621
|
/**
|
|
607
622
|
* File Access API for requesting access to user-uploaded files.
|
|
608
623
|
* Files are not sent automatically - the addon must request access.
|
|
@@ -870,6 +885,86 @@ interface AudioAPI {
|
|
|
870
885
|
*/
|
|
871
886
|
onStateChange(callback: (state: AudioState) => void): () => void;
|
|
872
887
|
}
|
|
888
|
+
/**
|
|
889
|
+
* A setting option for select/dropdown fields.
|
|
890
|
+
*/
|
|
891
|
+
interface SettingOption {
|
|
892
|
+
/** Display label shown to user */
|
|
893
|
+
label: string;
|
|
894
|
+
/** Value stored when selected */
|
|
895
|
+
value: string | number | boolean;
|
|
896
|
+
/** Optional description */
|
|
897
|
+
description?: string;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
901
|
+
* Access via `window.MyWallpaper.settings`
|
|
902
|
+
*
|
|
903
|
+
* **Why this exists:**
|
|
904
|
+
* Some widgets need to populate setting options dynamically based on
|
|
905
|
+
* external data (e.g., font families from a CSS file, available themes
|
|
906
|
+
* from an API, etc.). This API allows widgets to modify their own
|
|
907
|
+
* setting options after loading.
|
|
908
|
+
*
|
|
909
|
+
* **Important:**
|
|
910
|
+
* - Only works for settings declared in manifest.json
|
|
911
|
+
* - Only 'select' type settings can have their options updated
|
|
912
|
+
* - Changes are session-only (manifest defines the defaults)
|
|
913
|
+
*
|
|
914
|
+
* @example
|
|
915
|
+
* ```typescript
|
|
916
|
+
* const api = window.MyWallpaper
|
|
917
|
+
*
|
|
918
|
+
* // After fetching a font CSS, parse available fonts and update dropdown
|
|
919
|
+
* const fonts = parseFontFaces(cssContent)
|
|
920
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
921
|
+
* label: f.family,
|
|
922
|
+
* value: f.family
|
|
923
|
+
* })))
|
|
924
|
+
*
|
|
925
|
+
* // Update multiple settings at once
|
|
926
|
+
* api.settings.updateOptions('fontWeight', [
|
|
927
|
+
* { label: 'Light', value: '300' },
|
|
928
|
+
* { label: 'Regular', value: '400' },
|
|
929
|
+
* { label: 'Bold', value: '700' }
|
|
930
|
+
* ])
|
|
931
|
+
* ```
|
|
932
|
+
*/
|
|
933
|
+
interface SettingsAPI {
|
|
934
|
+
/**
|
|
935
|
+
* Update the options for a select-type setting.
|
|
936
|
+
* The new options replace existing ones from the manifest.
|
|
937
|
+
*
|
|
938
|
+
* @param settingKey - The setting key to update (must be a 'select' type)
|
|
939
|
+
* @param options - Array of new options
|
|
940
|
+
* @param defaultValue - Optional new default value
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```typescript
|
|
944
|
+
* // Update font family options based on loaded CSS
|
|
945
|
+
* api.settings.updateOptions('customFontFamily', [
|
|
946
|
+
* { label: 'Roboto', value: 'Roboto' },
|
|
947
|
+
* { label: 'Open Sans', value: 'Open Sans' },
|
|
948
|
+
* { label: 'Lato', value: 'Lato' }
|
|
949
|
+
* ], 'Roboto')
|
|
950
|
+
* ```
|
|
951
|
+
*/
|
|
952
|
+
updateOptions(settingKey: string, options: SettingOption[], defaultValue?: string | number | boolean): void;
|
|
953
|
+
/**
|
|
954
|
+
* Get the current options for a setting.
|
|
955
|
+
* Returns the dynamic options if set, otherwise the manifest defaults.
|
|
956
|
+
*
|
|
957
|
+
* @param settingKey - The setting key to get options for
|
|
958
|
+
* @returns Array of options or undefined if not a select setting
|
|
959
|
+
*/
|
|
960
|
+
getOptions(settingKey: string): SettingOption[] | undefined;
|
|
961
|
+
/**
|
|
962
|
+
* Reset a setting's options back to the manifest defaults.
|
|
963
|
+
*
|
|
964
|
+
* @param settingKey - The setting key to reset
|
|
965
|
+
*/
|
|
966
|
+
resetOptions(settingKey: string): void;
|
|
967
|
+
}
|
|
873
968
|
/**
|
|
874
969
|
* Generic addon values (settings configuration).
|
|
875
970
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -603,6 +603,21 @@ interface MyWallpaperAPI {
|
|
|
603
603
|
* ```
|
|
604
604
|
*/
|
|
605
605
|
audio: AudioAPI;
|
|
606
|
+
/**
|
|
607
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
608
|
+
* Allows widgets to populate dropdowns based on external data.
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* // After loading font CSS, update the font family dropdown
|
|
613
|
+
* const fonts = parseFontFaces(cssContent)
|
|
614
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
615
|
+
* label: f.family,
|
|
616
|
+
* value: f.family
|
|
617
|
+
* })))
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
settings: SettingsAPI;
|
|
606
621
|
/**
|
|
607
622
|
* File Access API for requesting access to user-uploaded files.
|
|
608
623
|
* Files are not sent automatically - the addon must request access.
|
|
@@ -870,6 +885,86 @@ interface AudioAPI {
|
|
|
870
885
|
*/
|
|
871
886
|
onStateChange(callback: (state: AudioState) => void): () => void;
|
|
872
887
|
}
|
|
888
|
+
/**
|
|
889
|
+
* A setting option for select/dropdown fields.
|
|
890
|
+
*/
|
|
891
|
+
interface SettingOption {
|
|
892
|
+
/** Display label shown to user */
|
|
893
|
+
label: string;
|
|
894
|
+
/** Value stored when selected */
|
|
895
|
+
value: string | number | boolean;
|
|
896
|
+
/** Optional description */
|
|
897
|
+
description?: string;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
901
|
+
* Access via `window.MyWallpaper.settings`
|
|
902
|
+
*
|
|
903
|
+
* **Why this exists:**
|
|
904
|
+
* Some widgets need to populate setting options dynamically based on
|
|
905
|
+
* external data (e.g., font families from a CSS file, available themes
|
|
906
|
+
* from an API, etc.). This API allows widgets to modify their own
|
|
907
|
+
* setting options after loading.
|
|
908
|
+
*
|
|
909
|
+
* **Important:**
|
|
910
|
+
* - Only works for settings declared in manifest.json
|
|
911
|
+
* - Only 'select' type settings can have their options updated
|
|
912
|
+
* - Changes are session-only (manifest defines the defaults)
|
|
913
|
+
*
|
|
914
|
+
* @example
|
|
915
|
+
* ```typescript
|
|
916
|
+
* const api = window.MyWallpaper
|
|
917
|
+
*
|
|
918
|
+
* // After fetching a font CSS, parse available fonts and update dropdown
|
|
919
|
+
* const fonts = parseFontFaces(cssContent)
|
|
920
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
921
|
+
* label: f.family,
|
|
922
|
+
* value: f.family
|
|
923
|
+
* })))
|
|
924
|
+
*
|
|
925
|
+
* // Update multiple settings at once
|
|
926
|
+
* api.settings.updateOptions('fontWeight', [
|
|
927
|
+
* { label: 'Light', value: '300' },
|
|
928
|
+
* { label: 'Regular', value: '400' },
|
|
929
|
+
* { label: 'Bold', value: '700' }
|
|
930
|
+
* ])
|
|
931
|
+
* ```
|
|
932
|
+
*/
|
|
933
|
+
interface SettingsAPI {
|
|
934
|
+
/**
|
|
935
|
+
* Update the options for a select-type setting.
|
|
936
|
+
* The new options replace existing ones from the manifest.
|
|
937
|
+
*
|
|
938
|
+
* @param settingKey - The setting key to update (must be a 'select' type)
|
|
939
|
+
* @param options - Array of new options
|
|
940
|
+
* @param defaultValue - Optional new default value
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```typescript
|
|
944
|
+
* // Update font family options based on loaded CSS
|
|
945
|
+
* api.settings.updateOptions('customFontFamily', [
|
|
946
|
+
* { label: 'Roboto', value: 'Roboto' },
|
|
947
|
+
* { label: 'Open Sans', value: 'Open Sans' },
|
|
948
|
+
* { label: 'Lato', value: 'Lato' }
|
|
949
|
+
* ], 'Roboto')
|
|
950
|
+
* ```
|
|
951
|
+
*/
|
|
952
|
+
updateOptions(settingKey: string, options: SettingOption[], defaultValue?: string | number | boolean): void;
|
|
953
|
+
/**
|
|
954
|
+
* Get the current options for a setting.
|
|
955
|
+
* Returns the dynamic options if set, otherwise the manifest defaults.
|
|
956
|
+
*
|
|
957
|
+
* @param settingKey - The setting key to get options for
|
|
958
|
+
* @returns Array of options or undefined if not a select setting
|
|
959
|
+
*/
|
|
960
|
+
getOptions(settingKey: string): SettingOption[] | undefined;
|
|
961
|
+
/**
|
|
962
|
+
* Reset a setting's options back to the manifest defaults.
|
|
963
|
+
*
|
|
964
|
+
* @param settingKey - The setting key to reset
|
|
965
|
+
*/
|
|
966
|
+
resetOptions(settingKey: string): void;
|
|
967
|
+
}
|
|
873
968
|
/**
|
|
874
969
|
* Generic addon values (settings configuration).
|
|
875
970
|
*/
|
package/dist/manifest.d.mts
CHANGED
|
@@ -588,6 +588,21 @@ interface MyWallpaperAPI {
|
|
|
588
588
|
* ```
|
|
589
589
|
*/
|
|
590
590
|
audio: AudioAPI;
|
|
591
|
+
/**
|
|
592
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
593
|
+
* Allows widgets to populate dropdowns based on external data.
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```typescript
|
|
597
|
+
* // After loading font CSS, update the font family dropdown
|
|
598
|
+
* const fonts = parseFontFaces(cssContent)
|
|
599
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
600
|
+
* label: f.family,
|
|
601
|
+
* value: f.family
|
|
602
|
+
* })))
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
settings: SettingsAPI;
|
|
591
606
|
/**
|
|
592
607
|
* File Access API for requesting access to user-uploaded files.
|
|
593
608
|
* Files are not sent automatically - the addon must request access.
|
|
@@ -851,6 +866,86 @@ interface AudioAPI {
|
|
|
851
866
|
*/
|
|
852
867
|
onStateChange(callback: (state: AudioState) => void): () => void;
|
|
853
868
|
}
|
|
869
|
+
/**
|
|
870
|
+
* A setting option for select/dropdown fields.
|
|
871
|
+
*/
|
|
872
|
+
interface SettingOption {
|
|
873
|
+
/** Display label shown to user */
|
|
874
|
+
label: string;
|
|
875
|
+
/** Value stored when selected */
|
|
876
|
+
value: string | number | boolean;
|
|
877
|
+
/** Optional description */
|
|
878
|
+
description?: string;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
882
|
+
* Access via `window.MyWallpaper.settings`
|
|
883
|
+
*
|
|
884
|
+
* **Why this exists:**
|
|
885
|
+
* Some widgets need to populate setting options dynamically based on
|
|
886
|
+
* external data (e.g., font families from a CSS file, available themes
|
|
887
|
+
* from an API, etc.). This API allows widgets to modify their own
|
|
888
|
+
* setting options after loading.
|
|
889
|
+
*
|
|
890
|
+
* **Important:**
|
|
891
|
+
* - Only works for settings declared in manifest.json
|
|
892
|
+
* - Only 'select' type settings can have their options updated
|
|
893
|
+
* - Changes are session-only (manifest defines the defaults)
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```typescript
|
|
897
|
+
* const api = window.MyWallpaper
|
|
898
|
+
*
|
|
899
|
+
* // After fetching a font CSS, parse available fonts and update dropdown
|
|
900
|
+
* const fonts = parseFontFaces(cssContent)
|
|
901
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
902
|
+
* label: f.family,
|
|
903
|
+
* value: f.family
|
|
904
|
+
* })))
|
|
905
|
+
*
|
|
906
|
+
* // Update multiple settings at once
|
|
907
|
+
* api.settings.updateOptions('fontWeight', [
|
|
908
|
+
* { label: 'Light', value: '300' },
|
|
909
|
+
* { label: 'Regular', value: '400' },
|
|
910
|
+
* { label: 'Bold', value: '700' }
|
|
911
|
+
* ])
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
interface SettingsAPI {
|
|
915
|
+
/**
|
|
916
|
+
* Update the options for a select-type setting.
|
|
917
|
+
* The new options replace existing ones from the manifest.
|
|
918
|
+
*
|
|
919
|
+
* @param settingKey - The setting key to update (must be a 'select' type)
|
|
920
|
+
* @param options - Array of new options
|
|
921
|
+
* @param defaultValue - Optional new default value
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```typescript
|
|
925
|
+
* // Update font family options based on loaded CSS
|
|
926
|
+
* api.settings.updateOptions('customFontFamily', [
|
|
927
|
+
* { label: 'Roboto', value: 'Roboto' },
|
|
928
|
+
* { label: 'Open Sans', value: 'Open Sans' },
|
|
929
|
+
* { label: 'Lato', value: 'Lato' }
|
|
930
|
+
* ], 'Roboto')
|
|
931
|
+
* ```
|
|
932
|
+
*/
|
|
933
|
+
updateOptions(settingKey: string, options: SettingOption[], defaultValue?: string | number | boolean): void;
|
|
934
|
+
/**
|
|
935
|
+
* Get the current options for a setting.
|
|
936
|
+
* Returns the dynamic options if set, otherwise the manifest defaults.
|
|
937
|
+
*
|
|
938
|
+
* @param settingKey - The setting key to get options for
|
|
939
|
+
* @returns Array of options or undefined if not a select setting
|
|
940
|
+
*/
|
|
941
|
+
getOptions(settingKey: string): SettingOption[] | undefined;
|
|
942
|
+
/**
|
|
943
|
+
* Reset a setting's options back to the manifest defaults.
|
|
944
|
+
*
|
|
945
|
+
* @param settingKey - The setting key to reset
|
|
946
|
+
*/
|
|
947
|
+
resetOptions(settingKey: string): void;
|
|
948
|
+
}
|
|
854
949
|
|
|
855
950
|
/**
|
|
856
951
|
* @mywallpaper/addon-sdk - Manifest Schema & Validation
|
package/dist/manifest.d.ts
CHANGED
|
@@ -588,6 +588,21 @@ interface MyWallpaperAPI {
|
|
|
588
588
|
* ```
|
|
589
589
|
*/
|
|
590
590
|
audio: AudioAPI;
|
|
591
|
+
/**
|
|
592
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
593
|
+
* Allows widgets to populate dropdowns based on external data.
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```typescript
|
|
597
|
+
* // After loading font CSS, update the font family dropdown
|
|
598
|
+
* const fonts = parseFontFaces(cssContent)
|
|
599
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
600
|
+
* label: f.family,
|
|
601
|
+
* value: f.family
|
|
602
|
+
* })))
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
settings: SettingsAPI;
|
|
591
606
|
/**
|
|
592
607
|
* File Access API for requesting access to user-uploaded files.
|
|
593
608
|
* Files are not sent automatically - the addon must request access.
|
|
@@ -851,6 +866,86 @@ interface AudioAPI {
|
|
|
851
866
|
*/
|
|
852
867
|
onStateChange(callback: (state: AudioState) => void): () => void;
|
|
853
868
|
}
|
|
869
|
+
/**
|
|
870
|
+
* A setting option for select/dropdown fields.
|
|
871
|
+
*/
|
|
872
|
+
interface SettingOption {
|
|
873
|
+
/** Display label shown to user */
|
|
874
|
+
label: string;
|
|
875
|
+
/** Value stored when selected */
|
|
876
|
+
value: string | number | boolean;
|
|
877
|
+
/** Optional description */
|
|
878
|
+
description?: string;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Settings API for dynamically modifying setting options at runtime.
|
|
882
|
+
* Access via `window.MyWallpaper.settings`
|
|
883
|
+
*
|
|
884
|
+
* **Why this exists:**
|
|
885
|
+
* Some widgets need to populate setting options dynamically based on
|
|
886
|
+
* external data (e.g., font families from a CSS file, available themes
|
|
887
|
+
* from an API, etc.). This API allows widgets to modify their own
|
|
888
|
+
* setting options after loading.
|
|
889
|
+
*
|
|
890
|
+
* **Important:**
|
|
891
|
+
* - Only works for settings declared in manifest.json
|
|
892
|
+
* - Only 'select' type settings can have their options updated
|
|
893
|
+
* - Changes are session-only (manifest defines the defaults)
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```typescript
|
|
897
|
+
* const api = window.MyWallpaper
|
|
898
|
+
*
|
|
899
|
+
* // After fetching a font CSS, parse available fonts and update dropdown
|
|
900
|
+
* const fonts = parseFontFaces(cssContent)
|
|
901
|
+
* api.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
902
|
+
* label: f.family,
|
|
903
|
+
* value: f.family
|
|
904
|
+
* })))
|
|
905
|
+
*
|
|
906
|
+
* // Update multiple settings at once
|
|
907
|
+
* api.settings.updateOptions('fontWeight', [
|
|
908
|
+
* { label: 'Light', value: '300' },
|
|
909
|
+
* { label: 'Regular', value: '400' },
|
|
910
|
+
* { label: 'Bold', value: '700' }
|
|
911
|
+
* ])
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
interface SettingsAPI {
|
|
915
|
+
/**
|
|
916
|
+
* Update the options for a select-type setting.
|
|
917
|
+
* The new options replace existing ones from the manifest.
|
|
918
|
+
*
|
|
919
|
+
* @param settingKey - The setting key to update (must be a 'select' type)
|
|
920
|
+
* @param options - Array of new options
|
|
921
|
+
* @param defaultValue - Optional new default value
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```typescript
|
|
925
|
+
* // Update font family options based on loaded CSS
|
|
926
|
+
* api.settings.updateOptions('customFontFamily', [
|
|
927
|
+
* { label: 'Roboto', value: 'Roboto' },
|
|
928
|
+
* { label: 'Open Sans', value: 'Open Sans' },
|
|
929
|
+
* { label: 'Lato', value: 'Lato' }
|
|
930
|
+
* ], 'Roboto')
|
|
931
|
+
* ```
|
|
932
|
+
*/
|
|
933
|
+
updateOptions(settingKey: string, options: SettingOption[], defaultValue?: string | number | boolean): void;
|
|
934
|
+
/**
|
|
935
|
+
* Get the current options for a setting.
|
|
936
|
+
* Returns the dynamic options if set, otherwise the manifest defaults.
|
|
937
|
+
*
|
|
938
|
+
* @param settingKey - The setting key to get options for
|
|
939
|
+
* @returns Array of options or undefined if not a select setting
|
|
940
|
+
*/
|
|
941
|
+
getOptions(settingKey: string): SettingOption[] | undefined;
|
|
942
|
+
/**
|
|
943
|
+
* Reset a setting's options back to the manifest defaults.
|
|
944
|
+
*
|
|
945
|
+
* @param settingKey - The setting key to reset
|
|
946
|
+
*/
|
|
947
|
+
resetOptions(settingKey: string): void;
|
|
948
|
+
}
|
|
854
949
|
|
|
855
950
|
/**
|
|
856
951
|
* @mywallpaper/addon-sdk - Manifest Schema & Validation
|
package/package.json
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
var pendingFileAccess = new Map()
|
|
32
32
|
var pendingNetworkAccess = new Map() // For on-demand domain permission requests
|
|
33
33
|
var grantedBlobUrls = new Map() // settingKey -> blobUrl
|
|
34
|
+
var dynamicSettingsOptions = new Map() // settingKey -> options[] (dynamic options from widget)
|
|
34
35
|
|
|
35
36
|
// Audio state (synced from host)
|
|
36
37
|
var audioState = {
|
|
@@ -714,6 +715,76 @@
|
|
|
714
715
|
callback(audioState)
|
|
715
716
|
return function () { audioCallbacks.delete(callback) }
|
|
716
717
|
}
|
|
718
|
+
},
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Settings API - Dynamically modify setting options at runtime
|
|
722
|
+
* Allows widgets to populate dropdowns based on external data
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* // After fetching a font CSS, parse available fonts and update dropdown
|
|
726
|
+
* const fonts = parseFontFaces(cssContent)
|
|
727
|
+
* MyWallpaper.settings.updateOptions('fontFamily', fonts.map(f => ({
|
|
728
|
+
* label: f.family,
|
|
729
|
+
* value: f.family
|
|
730
|
+
* })))
|
|
731
|
+
*/
|
|
732
|
+
settings: {
|
|
733
|
+
/**
|
|
734
|
+
* Update the options for a select-type setting
|
|
735
|
+
* @param {string} settingKey - The setting key to update
|
|
736
|
+
* @param {Array<{label: string, value: string|number|boolean, description?: string}>} options - New options
|
|
737
|
+
* @param {string|number|boolean} defaultValue - Optional new default value
|
|
738
|
+
*/
|
|
739
|
+
updateOptions: function (settingKey, options, defaultValue) {
|
|
740
|
+
if (!settingKey || typeof settingKey !== 'string') {
|
|
741
|
+
console.error('[MyWallpaper] settings.updateOptions: settingKey is required')
|
|
742
|
+
return
|
|
743
|
+
}
|
|
744
|
+
if (!Array.isArray(options)) {
|
|
745
|
+
console.error('[MyWallpaper] settings.updateOptions: options must be an array')
|
|
746
|
+
return
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// Validate options format
|
|
750
|
+
var validOptions = options.filter(function (opt) {
|
|
751
|
+
return opt && typeof opt === 'object' && typeof opt.label === 'string' && opt.value !== undefined
|
|
752
|
+
})
|
|
753
|
+
|
|
754
|
+
if (validOptions.length === 0) {
|
|
755
|
+
console.warn('[MyWallpaper] settings.updateOptions: no valid options provided')
|
|
756
|
+
return
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// Store locally for getOptions()
|
|
760
|
+
dynamicSettingsOptions.set(settingKey, validOptions)
|
|
761
|
+
|
|
762
|
+
// Send to host to update the settings panel
|
|
763
|
+
send('SETTINGS_OPTIONS_UPDATE', {
|
|
764
|
+
settingKey: settingKey,
|
|
765
|
+
options: validOptions,
|
|
766
|
+
defaultValue: defaultValue
|
|
767
|
+
})
|
|
768
|
+
},
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Get the current options for a setting
|
|
772
|
+
* Returns dynamic options if set, otherwise undefined
|
|
773
|
+
* @param {string} settingKey - The setting key
|
|
774
|
+
* @returns {Array|undefined} The options array or undefined
|
|
775
|
+
*/
|
|
776
|
+
getOptions: function (settingKey) {
|
|
777
|
+
return dynamicSettingsOptions.get(settingKey)
|
|
778
|
+
},
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Reset a setting's options back to the manifest defaults
|
|
782
|
+
* @param {string} settingKey - The setting key to reset
|
|
783
|
+
*/
|
|
784
|
+
resetOptions: function (settingKey) {
|
|
785
|
+
dynamicSettingsOptions.delete(settingKey)
|
|
786
|
+
send('SETTINGS_OPTIONS_RESET', { settingKey: settingKey })
|
|
787
|
+
}
|
|
717
788
|
}
|
|
718
789
|
}
|
|
719
790
|
|