@mywallpaper/addon-sdk 2.12.0 → 2.14.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 +1 -1
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/manifest.d.mts +31 -0
- package/dist/manifest.d.ts +31 -0
- package/package.json +1 -1
- package/src/runtime/addon-client.js +112 -3
package/README.md
CHANGED
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.
|
package/dist/manifest.d.mts
CHANGED
|
@@ -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/dist/manifest.d.ts
CHANGED
|
@@ -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
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
var pendingOAuthScopes = new Map()
|
|
31
31
|
var pendingFileAccess = new Map()
|
|
32
32
|
var pendingNetworkAccess = new Map() // For on-demand domain permission requests
|
|
33
|
+
var pendingSystem = new Map() // requestId -> { resolve, reject } for system API
|
|
33
34
|
var grantedBlobUrls = new Map() // settingKey -> blobUrl
|
|
34
35
|
var dynamicSettingsOptions = new Map() // settingKey -> options[] (dynamic options from widget)
|
|
35
36
|
var buttonCallbacks = new Map() // settingKey -> callback function for button clicks
|
|
@@ -244,6 +245,19 @@
|
|
|
244
245
|
}
|
|
245
246
|
break
|
|
246
247
|
|
|
248
|
+
case 'SYSTEM_RESPONSE':
|
|
249
|
+
// Handle system API response (openPath, etc.)
|
|
250
|
+
var sysOp = pendingSystem.get(d.payload.requestId)
|
|
251
|
+
if (sysOp) {
|
|
252
|
+
pendingSystem.delete(d.payload.requestId)
|
|
253
|
+
if (d.payload.success) {
|
|
254
|
+
sysOp.resolve({ success: true })
|
|
255
|
+
} else {
|
|
256
|
+
sysOp.reject(new Error(d.payload.error || 'System operation failed'))
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
break
|
|
260
|
+
|
|
247
261
|
case 'AUDIO_STATE':
|
|
248
262
|
// Sync audio state from host
|
|
249
263
|
audioState = d.payload || d
|
|
@@ -426,7 +440,7 @@
|
|
|
426
440
|
window.MyWallpaper = {
|
|
427
441
|
get config() { return config },
|
|
428
442
|
layerId: layerId,
|
|
429
|
-
version: '2.
|
|
443
|
+
version: '2.13.0',
|
|
430
444
|
|
|
431
445
|
onSettingsChange: function (fn) { if (typeof fn === 'function') settingsCallbacks.push(fn) },
|
|
432
446
|
|
|
@@ -470,7 +484,7 @@
|
|
|
470
484
|
isReady = true
|
|
471
485
|
opts = opts || {}
|
|
472
486
|
send('ADDON_READY', {
|
|
473
|
-
version: '2.
|
|
487
|
+
version: '2.13.0',
|
|
474
488
|
capabilities: opts.capabilities || [],
|
|
475
489
|
subscribedEvents: opts.subscribedEvents || []
|
|
476
490
|
})
|
|
@@ -761,6 +775,42 @@
|
|
|
761
775
|
* })))
|
|
762
776
|
*/
|
|
763
777
|
settings: {
|
|
778
|
+
/**
|
|
779
|
+
* Update a setting value from the addon
|
|
780
|
+
* This syncs the value back to the host UI and persists it
|
|
781
|
+
* @param {string} settingKey - The setting key to update
|
|
782
|
+
* @param {*} value - The new value
|
|
783
|
+
*/
|
|
784
|
+
setValue: function (settingKey, value) {
|
|
785
|
+
if (!settingKey || typeof settingKey !== 'string') {
|
|
786
|
+
console.error('[MyWallpaper] settings.setValue: settingKey is required')
|
|
787
|
+
return
|
|
788
|
+
}
|
|
789
|
+
// Update local config immediately
|
|
790
|
+
config[settingKey] = value
|
|
791
|
+
// Send to host to update UI and persist
|
|
792
|
+
send('SETTINGS_VALUE_UPDATE', { settingKey: settingKey, value: value })
|
|
793
|
+
},
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Update multiple setting values at once
|
|
797
|
+
* @param {Record<string, *>} values - Object with settingKey -> value pairs
|
|
798
|
+
*/
|
|
799
|
+
setValues: function (values) {
|
|
800
|
+
if (!values || typeof values !== 'object') {
|
|
801
|
+
console.error('[MyWallpaper] settings.setValues: values object is required')
|
|
802
|
+
return
|
|
803
|
+
}
|
|
804
|
+
// Update local config immediately
|
|
805
|
+
for (var key in values) {
|
|
806
|
+
if (Object.prototype.hasOwnProperty.call(values, key)) {
|
|
807
|
+
config[key] = values[key]
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
// Send to host to update UI and persist
|
|
811
|
+
send('SETTINGS_VALUES_UPDATE', { values: values })
|
|
812
|
+
},
|
|
813
|
+
|
|
764
814
|
/**
|
|
765
815
|
* Update the options for a select-type setting
|
|
766
816
|
* @param {string} settingKey - The setting key to update
|
|
@@ -816,8 +866,67 @@
|
|
|
816
866
|
dynamicSettingsOptions.delete(settingKey)
|
|
817
867
|
send('SETTINGS_OPTIONS_RESET', { settingKey: settingKey })
|
|
818
868
|
}
|
|
869
|
+
},
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* System API - Interact with the host operating system
|
|
873
|
+
* Allows opening URLs, files, folders, and applications
|
|
874
|
+
*
|
|
875
|
+
* Requires 'system' permission in manifest:
|
|
876
|
+
* { "permissions": { "system": { "openPath": true } } }
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* // Open a URL
|
|
880
|
+
* await MyWallpaper.system.openPath('https://github.com')
|
|
881
|
+
*
|
|
882
|
+
* // Open a folder in file explorer
|
|
883
|
+
* await MyWallpaper.system.openPath('/home/user/Documents', { type: 'folder' })
|
|
884
|
+
*
|
|
885
|
+
* // Open an app via protocol handler
|
|
886
|
+
* await MyWallpaper.system.openPath('spotify://open')
|
|
887
|
+
*/
|
|
888
|
+
system: {
|
|
889
|
+
/**
|
|
890
|
+
* Open a URL, file, folder, or application
|
|
891
|
+
*
|
|
892
|
+
* @param {string} path - The path to open:
|
|
893
|
+
* - URL: https://example.com
|
|
894
|
+
* - File: /path/to/file.pdf (executes with default app)
|
|
895
|
+
* - Folder: /path/to/folder (opens in file explorer)
|
|
896
|
+
* - Protocol: spotify://, discord://, vscode:// (opens app)
|
|
897
|
+
* @param {object} options - Optional configuration
|
|
898
|
+
* @param {string} options.type - Force type: 'auto'|'url'|'file'|'folder'|'protocol'
|
|
899
|
+
* @returns {Promise<{success: true}>} Resolves when operation completes
|
|
900
|
+
* @throws {Error} If operation fails or permission denied
|
|
901
|
+
*/
|
|
902
|
+
openPath: function (path, options) {
|
|
903
|
+
return new Promise(function (resolve, reject) {
|
|
904
|
+
if (!path || typeof path !== 'string') {
|
|
905
|
+
reject(new Error('path is required and must be a string'))
|
|
906
|
+
return
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
var id = Date.now() + '-' + Math.random().toString(36).slice(2)
|
|
910
|
+
pendingSystem.set(id, { resolve: resolve, reject: reject })
|
|
911
|
+
|
|
912
|
+
// Timeout after 10 seconds
|
|
913
|
+
setTimeout(function () {
|
|
914
|
+
if (pendingSystem.has(id)) {
|
|
915
|
+
pendingSystem.delete(id)
|
|
916
|
+
reject(new Error('System operation timeout'))
|
|
917
|
+
}
|
|
918
|
+
}, 10000)
|
|
919
|
+
|
|
920
|
+
options = options || {}
|
|
921
|
+
send('SYSTEM_OPEN_PATH', {
|
|
922
|
+
path: path,
|
|
923
|
+
type: options.type || 'auto',
|
|
924
|
+
requestId: id
|
|
925
|
+
})
|
|
926
|
+
})
|
|
927
|
+
}
|
|
819
928
|
}
|
|
820
929
|
}
|
|
821
930
|
|
|
822
|
-
console.warn('[MyWallpaper] SDK v2.
|
|
931
|
+
console.warn('[MyWallpaper] SDK v2.14.0 ready:', layerId)
|
|
823
932
|
})()
|