@mywallpaper/addon-sdk 2.12.0 → 2.13.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/README.md CHANGED
@@ -48,7 +48,7 @@ my-addon/
48
48
  {
49
49
  "name": "My Awesome Addon",
50
50
  "version": "1.0.0",
51
- "sdkVersion": "2.12.0",
51
+ "sdkVersion": "2.13.0",
52
52
  "description": "A cool widget for your desktop",
53
53
  "author": "Your Name",
54
54
  "capabilities": {
package/dist/index.d.mts CHANGED
@@ -955,6 +955,37 @@ interface SettingOption {
955
955
  * ```
956
956
  */
957
957
  interface SettingsAPI {
958
+ /**
959
+ * Update a single setting value from the addon.
960
+ * This syncs the value back to the host UI and persists it.
961
+ *
962
+ * @param settingKey - The setting key to update
963
+ * @param value - The new value
964
+ *
965
+ * @example
966
+ * ```typescript
967
+ * // Update a color setting after randomization
968
+ * api.settings.setValue('primaryColor', '#ff0000')
969
+ * ```
970
+ */
971
+ setValue(settingKey: string, value: unknown): void;
972
+ /**
973
+ * Update multiple setting values at once.
974
+ * This syncs all values back to the host UI and persists them.
975
+ *
976
+ * @param values - Object with settingKey -> value pairs
977
+ *
978
+ * @example
979
+ * ```typescript
980
+ * // Update multiple colors after randomization
981
+ * api.settings.setValues({
982
+ * primaryColor: '#ff0000',
983
+ * secondaryColor: '#00ff00',
984
+ * backgroundColor: '#0000ff'
985
+ * })
986
+ * ```
987
+ */
988
+ setValues(values: Record<string, unknown>): void;
958
989
  /**
959
990
  * Update the options for a select-type setting.
960
991
  * The new options replace existing ones from the manifest.
package/dist/index.d.ts CHANGED
@@ -955,6 +955,37 @@ interface SettingOption {
955
955
  * ```
956
956
  */
957
957
  interface SettingsAPI {
958
+ /**
959
+ * Update a single setting value from the addon.
960
+ * This syncs the value back to the host UI and persists it.
961
+ *
962
+ * @param settingKey - The setting key to update
963
+ * @param value - The new value
964
+ *
965
+ * @example
966
+ * ```typescript
967
+ * // Update a color setting after randomization
968
+ * api.settings.setValue('primaryColor', '#ff0000')
969
+ * ```
970
+ */
971
+ setValue(settingKey: string, value: unknown): void;
972
+ /**
973
+ * Update multiple setting values at once.
974
+ * This syncs all values back to the host UI and persists them.
975
+ *
976
+ * @param values - Object with settingKey -> value pairs
977
+ *
978
+ * @example
979
+ * ```typescript
980
+ * // Update multiple colors after randomization
981
+ * api.settings.setValues({
982
+ * primaryColor: '#ff0000',
983
+ * secondaryColor: '#00ff00',
984
+ * backgroundColor: '#0000ff'
985
+ * })
986
+ * ```
987
+ */
988
+ setValues(values: Record<string, unknown>): void;
958
989
  /**
959
990
  * Update the options for a select-type setting.
960
991
  * The new options replace existing ones from the manifest.
@@ -936,6 +936,37 @@ interface SettingOption {
936
936
  * ```
937
937
  */
938
938
  interface SettingsAPI {
939
+ /**
940
+ * Update a single setting value from the addon.
941
+ * This syncs the value back to the host UI and persists it.
942
+ *
943
+ * @param settingKey - The setting key to update
944
+ * @param value - The new value
945
+ *
946
+ * @example
947
+ * ```typescript
948
+ * // Update a color setting after randomization
949
+ * api.settings.setValue('primaryColor', '#ff0000')
950
+ * ```
951
+ */
952
+ setValue(settingKey: string, value: unknown): void;
953
+ /**
954
+ * Update multiple setting values at once.
955
+ * This syncs all values back to the host UI and persists them.
956
+ *
957
+ * @param values - Object with settingKey -> value pairs
958
+ *
959
+ * @example
960
+ * ```typescript
961
+ * // Update multiple colors after randomization
962
+ * api.settings.setValues({
963
+ * primaryColor: '#ff0000',
964
+ * secondaryColor: '#00ff00',
965
+ * backgroundColor: '#0000ff'
966
+ * })
967
+ * ```
968
+ */
969
+ setValues(values: Record<string, unknown>): void;
939
970
  /**
940
971
  * Update the options for a select-type setting.
941
972
  * The new options replace existing ones from the manifest.
@@ -936,6 +936,37 @@ interface SettingOption {
936
936
  * ```
937
937
  */
938
938
  interface SettingsAPI {
939
+ /**
940
+ * Update a single setting value from the addon.
941
+ * This syncs the value back to the host UI and persists it.
942
+ *
943
+ * @param settingKey - The setting key to update
944
+ * @param value - The new value
945
+ *
946
+ * @example
947
+ * ```typescript
948
+ * // Update a color setting after randomization
949
+ * api.settings.setValue('primaryColor', '#ff0000')
950
+ * ```
951
+ */
952
+ setValue(settingKey: string, value: unknown): void;
953
+ /**
954
+ * Update multiple setting values at once.
955
+ * This syncs all values back to the host UI and persists them.
956
+ *
957
+ * @param values - Object with settingKey -> value pairs
958
+ *
959
+ * @example
960
+ * ```typescript
961
+ * // Update multiple colors after randomization
962
+ * api.settings.setValues({
963
+ * primaryColor: '#ff0000',
964
+ * secondaryColor: '#00ff00',
965
+ * backgroundColor: '#0000ff'
966
+ * })
967
+ * ```
968
+ */
969
+ setValues(values: Record<string, unknown>): void;
939
970
  /**
940
971
  * Update the options for a select-type setting.
941
972
  * The new options replace existing ones from the manifest.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mywallpaper/addon-sdk",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "SDK for building MyWallpaper addons - TypeScript types, manifest validation, and utilities",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -426,7 +426,7 @@
426
426
  window.MyWallpaper = {
427
427
  get config() { return config },
428
428
  layerId: layerId,
429
- version: '2.11.0',
429
+ version: '2.13.0',
430
430
 
431
431
  onSettingsChange: function (fn) { if (typeof fn === 'function') settingsCallbacks.push(fn) },
432
432
 
@@ -470,7 +470,7 @@
470
470
  isReady = true
471
471
  opts = opts || {}
472
472
  send('ADDON_READY', {
473
- version: '2.11.0',
473
+ version: '2.13.0',
474
474
  capabilities: opts.capabilities || [],
475
475
  subscribedEvents: opts.subscribedEvents || []
476
476
  })
@@ -761,6 +761,42 @@
761
761
  * })))
762
762
  */
763
763
  settings: {
764
+ /**
765
+ * Update a setting value from the addon
766
+ * This syncs the value back to the host UI and persists it
767
+ * @param {string} settingKey - The setting key to update
768
+ * @param {*} value - The new value
769
+ */
770
+ setValue: function (settingKey, value) {
771
+ if (!settingKey || typeof settingKey !== 'string') {
772
+ console.error('[MyWallpaper] settings.setValue: settingKey is required')
773
+ return
774
+ }
775
+ // Update local config immediately
776
+ config[settingKey] = value
777
+ // Send to host to update UI and persist
778
+ send('SETTINGS_VALUE_UPDATE', { settingKey: settingKey, value: value })
779
+ },
780
+
781
+ /**
782
+ * Update multiple setting values at once
783
+ * @param {Record<string, *>} values - Object with settingKey -> value pairs
784
+ */
785
+ setValues: function (values) {
786
+ if (!values || typeof values !== 'object') {
787
+ console.error('[MyWallpaper] settings.setValues: values object is required')
788
+ return
789
+ }
790
+ // Update local config immediately
791
+ for (var key in values) {
792
+ if (Object.prototype.hasOwnProperty.call(values, key)) {
793
+ config[key] = values[key]
794
+ }
795
+ }
796
+ // Send to host to update UI and persist
797
+ send('SETTINGS_VALUES_UPDATE', { values: values })
798
+ },
799
+
764
800
  /**
765
801
  * Update the options for a select-type setting
766
802
  * @param {string} settingKey - The setting key to update
@@ -819,5 +855,5 @@
819
855
  }
820
856
  }
821
857
 
822
- console.warn('[MyWallpaper] SDK v2.11.0 ready:', layerId)
858
+ console.warn('[MyWallpaper] SDK v2.13.0 ready:', layerId)
823
859
  })()