@mywallpaper/addon-sdk 2.11.1 → 2.12.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 +29 -1
- package/dist/index.d.mts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/manifest.d.mts +24 -0
- package/dist/manifest.d.ts +24 -0
- package/package.json +1 -1
- package/src/runtime/addon-client.js +29 -0
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.
|
|
51
|
+
"sdkVersion": "2.12.0",
|
|
52
52
|
"description": "A cool widget for your desktop",
|
|
53
53
|
"author": "Your Name",
|
|
54
54
|
"capabilities": {
|
|
@@ -226,6 +226,34 @@ api.onSettingsChange((settings, changedKeys) => {
|
|
|
226
226
|
})
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
+
##### `onButtonClick(settingKey, callback)` / `offButtonClick(settingKey)`
|
|
230
|
+
|
|
231
|
+
Handle button setting clicks.
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
// Register a handler for a button setting
|
|
235
|
+
api.onButtonClick('resetButton', () => {
|
|
236
|
+
resetToDefaults()
|
|
237
|
+
console.log('Reset clicked!')
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
// Remove the handler when no longer needed
|
|
241
|
+
api.offButtonClick('resetButton')
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
With manifest:
|
|
245
|
+
|
|
246
|
+
```json
|
|
247
|
+
{
|
|
248
|
+
"settings": {
|
|
249
|
+
"resetButton": {
|
|
250
|
+
"type": "button",
|
|
251
|
+
"buttonLabel": "Reset to Defaults"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
229
257
|
##### `onEvent(event, callback)` / `offEvent(event, callback)`
|
|
230
258
|
|
|
231
259
|
Subscribe/unsubscribe to system events.
|
package/dist/index.d.mts
CHANGED
|
@@ -476,6 +476,30 @@ interface MyWallpaperAPI {
|
|
|
476
476
|
* @param callback - Function called with new settings and changed keys
|
|
477
477
|
*/
|
|
478
478
|
onSettingsChange(callback: SettingsCallback): void;
|
|
479
|
+
/**
|
|
480
|
+
* Register a callback for when a button setting is clicked.
|
|
481
|
+
* Buttons are defined in manifest.json with `type: "button"`.
|
|
482
|
+
*
|
|
483
|
+
* @param settingKey - The button's setting key from manifest
|
|
484
|
+
* @param callback - Function called when the button is clicked
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```typescript
|
|
488
|
+
* // manifest.json:
|
|
489
|
+
* // "refreshButton": { "type": "button", "label": "Refresh", "buttonLabel": "Refresh Now" }
|
|
490
|
+
*
|
|
491
|
+
* api.onButtonClick('refreshButton', () => {
|
|
492
|
+
* console.log('Refresh button clicked!')
|
|
493
|
+
* fetchLatestData()
|
|
494
|
+
* })
|
|
495
|
+
* ```
|
|
496
|
+
*/
|
|
497
|
+
onButtonClick(settingKey: string, callback: () => void): void;
|
|
498
|
+
/**
|
|
499
|
+
* Unregister a button click callback.
|
|
500
|
+
* @param settingKey - The button's setting key
|
|
501
|
+
*/
|
|
502
|
+
offButtonClick(settingKey: string): void;
|
|
479
503
|
/**
|
|
480
504
|
* Subscribe to a system event.
|
|
481
505
|
* @param event - Event type to subscribe to
|
package/dist/index.d.ts
CHANGED
|
@@ -476,6 +476,30 @@ interface MyWallpaperAPI {
|
|
|
476
476
|
* @param callback - Function called with new settings and changed keys
|
|
477
477
|
*/
|
|
478
478
|
onSettingsChange(callback: SettingsCallback): void;
|
|
479
|
+
/**
|
|
480
|
+
* Register a callback for when a button setting is clicked.
|
|
481
|
+
* Buttons are defined in manifest.json with `type: "button"`.
|
|
482
|
+
*
|
|
483
|
+
* @param settingKey - The button's setting key from manifest
|
|
484
|
+
* @param callback - Function called when the button is clicked
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```typescript
|
|
488
|
+
* // manifest.json:
|
|
489
|
+
* // "refreshButton": { "type": "button", "label": "Refresh", "buttonLabel": "Refresh Now" }
|
|
490
|
+
*
|
|
491
|
+
* api.onButtonClick('refreshButton', () => {
|
|
492
|
+
* console.log('Refresh button clicked!')
|
|
493
|
+
* fetchLatestData()
|
|
494
|
+
* })
|
|
495
|
+
* ```
|
|
496
|
+
*/
|
|
497
|
+
onButtonClick(settingKey: string, callback: () => void): void;
|
|
498
|
+
/**
|
|
499
|
+
* Unregister a button click callback.
|
|
500
|
+
* @param settingKey - The button's setting key
|
|
501
|
+
*/
|
|
502
|
+
offButtonClick(settingKey: string): void;
|
|
479
503
|
/**
|
|
480
504
|
* Subscribe to a system event.
|
|
481
505
|
* @param event - Event type to subscribe to
|
package/dist/manifest.d.mts
CHANGED
|
@@ -461,6 +461,30 @@ interface MyWallpaperAPI {
|
|
|
461
461
|
* @param callback - Function called with new settings and changed keys
|
|
462
462
|
*/
|
|
463
463
|
onSettingsChange(callback: SettingsCallback): void;
|
|
464
|
+
/**
|
|
465
|
+
* Register a callback for when a button setting is clicked.
|
|
466
|
+
* Buttons are defined in manifest.json with `type: "button"`.
|
|
467
|
+
*
|
|
468
|
+
* @param settingKey - The button's setting key from manifest
|
|
469
|
+
* @param callback - Function called when the button is clicked
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* // manifest.json:
|
|
474
|
+
* // "refreshButton": { "type": "button", "label": "Refresh", "buttonLabel": "Refresh Now" }
|
|
475
|
+
*
|
|
476
|
+
* api.onButtonClick('refreshButton', () => {
|
|
477
|
+
* console.log('Refresh button clicked!')
|
|
478
|
+
* fetchLatestData()
|
|
479
|
+
* })
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
onButtonClick(settingKey: string, callback: () => void): void;
|
|
483
|
+
/**
|
|
484
|
+
* Unregister a button click callback.
|
|
485
|
+
* @param settingKey - The button's setting key
|
|
486
|
+
*/
|
|
487
|
+
offButtonClick(settingKey: string): void;
|
|
464
488
|
/**
|
|
465
489
|
* Subscribe to a system event.
|
|
466
490
|
* @param event - Event type to subscribe to
|
package/dist/manifest.d.ts
CHANGED
|
@@ -461,6 +461,30 @@ interface MyWallpaperAPI {
|
|
|
461
461
|
* @param callback - Function called with new settings and changed keys
|
|
462
462
|
*/
|
|
463
463
|
onSettingsChange(callback: SettingsCallback): void;
|
|
464
|
+
/**
|
|
465
|
+
* Register a callback for when a button setting is clicked.
|
|
466
|
+
* Buttons are defined in manifest.json with `type: "button"`.
|
|
467
|
+
*
|
|
468
|
+
* @param settingKey - The button's setting key from manifest
|
|
469
|
+
* @param callback - Function called when the button is clicked
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* // manifest.json:
|
|
474
|
+
* // "refreshButton": { "type": "button", "label": "Refresh", "buttonLabel": "Refresh Now" }
|
|
475
|
+
*
|
|
476
|
+
* api.onButtonClick('refreshButton', () => {
|
|
477
|
+
* console.log('Refresh button clicked!')
|
|
478
|
+
* fetchLatestData()
|
|
479
|
+
* })
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
onButtonClick(settingKey: string, callback: () => void): void;
|
|
483
|
+
/**
|
|
484
|
+
* Unregister a button click callback.
|
|
485
|
+
* @param settingKey - The button's setting key
|
|
486
|
+
*/
|
|
487
|
+
offButtonClick(settingKey: string): void;
|
|
464
488
|
/**
|
|
465
489
|
* Subscribe to a system event.
|
|
466
490
|
* @param event - Event type to subscribe to
|
package/package.json
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
var pendingNetworkAccess = new Map() // For on-demand domain permission requests
|
|
33
33
|
var grantedBlobUrls = new Map() // settingKey -> blobUrl
|
|
34
34
|
var dynamicSettingsOptions = new Map() // settingKey -> options[] (dynamic options from widget)
|
|
35
|
+
var buttonCallbacks = new Map() // settingKey -> callback function for button clicks
|
|
35
36
|
|
|
36
37
|
// Audio state (synced from host)
|
|
37
38
|
var audioState = {
|
|
@@ -250,6 +251,15 @@
|
|
|
250
251
|
try { cb(audioState) } catch (err) { console.error('[MyWallpaper] Audio callback error:', err) }
|
|
251
252
|
})
|
|
252
253
|
break
|
|
254
|
+
|
|
255
|
+
case 'BUTTON_CLICK':
|
|
256
|
+
// Handle button click from settings panel
|
|
257
|
+
var btnKey = d.payload.settingKey
|
|
258
|
+
var btnCb = buttonCallbacks.get(btnKey)
|
|
259
|
+
if (btnCb) {
|
|
260
|
+
try { btnCb() } catch (err) { console.error('[MyWallpaper] Button callback error:', err) }
|
|
261
|
+
}
|
|
262
|
+
break
|
|
253
263
|
}
|
|
254
264
|
}
|
|
255
265
|
|
|
@@ -420,6 +430,25 @@
|
|
|
420
430
|
|
|
421
431
|
onSettingsChange: function (fn) { if (typeof fn === 'function') settingsCallbacks.push(fn) },
|
|
422
432
|
|
|
433
|
+
/**
|
|
434
|
+
* Register a callback for a button click in settings panel
|
|
435
|
+
* @param {string} settingKey - The button's setting key from manifest
|
|
436
|
+
* @param {function} callback - Function called when button is clicked
|
|
437
|
+
*/
|
|
438
|
+
onButtonClick: function (settingKey, callback) {
|
|
439
|
+
if (typeof settingKey === 'string' && typeof callback === 'function') {
|
|
440
|
+
buttonCallbacks.set(settingKey, callback)
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Unregister a button click callback
|
|
446
|
+
* @param {string} settingKey - The button's setting key
|
|
447
|
+
*/
|
|
448
|
+
offButtonClick: function (settingKey) {
|
|
449
|
+
buttonCallbacks.delete(settingKey)
|
|
450
|
+
},
|
|
451
|
+
|
|
423
452
|
onEvent: function (event, fn) {
|
|
424
453
|
if (typeof fn !== 'function') return
|
|
425
454
|
if (!eventCallbacks.has(event)) eventCallbacks.set(event, new Set())
|