@mywallpaper/addon-sdk 2.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mywallpaper/addon-sdk",
3
- "version": "2.13.0",
3
+ "version": "2.14.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",
@@ -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
@@ -852,8 +866,67 @@
852
866
  dynamicSettingsOptions.delete(settingKey)
853
867
  send('SETTINGS_OPTIONS_RESET', { settingKey: settingKey })
854
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
+ }
855
928
  }
856
929
  }
857
930
 
858
- console.warn('[MyWallpaper] SDK v2.13.0 ready:', layerId)
931
+ console.warn('[MyWallpaper] SDK v2.14.0 ready:', layerId)
859
932
  })()