@photon-os/sdk 1.0.0-alpha.0 → 1.0.0-alpha.2

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.mjs CHANGED
@@ -1174,6 +1174,28 @@ var require_pm_rpc_min = __commonJS({
1174
1174
  // src/framework/OS.ts
1175
1175
  var pmrpc = __toESM(require_pm_rpc_min());
1176
1176
 
1177
+ // src/framework/AccountManager.ts
1178
+ var AccountManager = class {
1179
+ constructor(os) {
1180
+ this.os = os;
1181
+ }
1182
+ /** Get all Second Life accounts linked to the current user */
1183
+ async getLinkedSecondLifeAccounts() {
1184
+ const api2 = await this.os.getRPCAPI();
1185
+ return await api2.accounts_getLinkedSecondLifeAccounts();
1186
+ }
1187
+ /** Unlink a Second Life account from the current user */
1188
+ async unlinkSecondLifeAccount(avatarUuid) {
1189
+ const api2 = await this.os.getRPCAPI();
1190
+ await api2.accounts_unlinkSecondLifeAccount(avatarUuid);
1191
+ }
1192
+ /** Generate a linking code for connecting a Second Life account */
1193
+ async generateLinkingCode() {
1194
+ const api2 = await this.os.getRPCAPI();
1195
+ return await api2.accounts_generateLinkingCode();
1196
+ }
1197
+ };
1198
+
1177
1199
  // src/framework/AppManager.ts
1178
1200
  var AppManager = class {
1179
1201
  constructor(os) {
@@ -1197,6 +1219,63 @@ var AppManager = class {
1197
1219
  }
1198
1220
  };
1199
1221
 
1222
+ // src/framework/DeviceManager.ts
1223
+ var DeviceManager = class {
1224
+ constructor(os) {
1225
+ this.messageCallbacks = /* @__PURE__ */ new Set();
1226
+ this.subscribed = false;
1227
+ this.os = os;
1228
+ }
1229
+ /** Get all registered Second Life devices for the current user */
1230
+ async getRegisteredDevices() {
1231
+ const api2 = await this.os.getRPCAPI();
1232
+ return await api2.devices_getRegistered();
1233
+ }
1234
+ /** Send a message to a registered device */
1235
+ async sendMessage(deviceId, type, payload = {}) {
1236
+ const api2 = await this.os.getRPCAPI();
1237
+ return await api2.devices_sendMessage(deviceId, type, payload);
1238
+ }
1239
+ /** Unregister a device */
1240
+ async unregisterDevice(deviceId) {
1241
+ const api2 = await this.os.getRPCAPI();
1242
+ await api2.devices_unregister(deviceId);
1243
+ }
1244
+ /** Subscribe to messages from all registered devices */
1245
+ subscribeToMessages(callback) {
1246
+ this.messageCallbacks.add(callback);
1247
+ if (!this.subscribed) {
1248
+ this.startSubscription();
1249
+ }
1250
+ return () => {
1251
+ this.messageCallbacks.delete(callback);
1252
+ if (this.messageCallbacks.size === 0 && this.subscribed) {
1253
+ this.stopSubscription();
1254
+ }
1255
+ };
1256
+ }
1257
+ /** Internal: Start the message subscription via RPC */
1258
+ async startSubscription() {
1259
+ const api2 = await this.os.getRPCAPI();
1260
+ await api2.devices_subscribe((message) => {
1261
+ for (const callback of this.messageCallbacks) {
1262
+ try {
1263
+ callback(message);
1264
+ } catch (error) {
1265
+ console.error("Error in device message callback:", error);
1266
+ }
1267
+ }
1268
+ });
1269
+ this.subscribed = true;
1270
+ }
1271
+ /** Internal: Stop the message subscription */
1272
+ async stopSubscription() {
1273
+ const api2 = await this.os.getRPCAPI();
1274
+ await api2.devices_unsubscribe();
1275
+ this.subscribed = false;
1276
+ }
1277
+ };
1278
+
1200
1279
  // src/framework/PreferencesManager.ts
1201
1280
  var PreferencesManager = class {
1202
1281
  constructor(os) {
@@ -1266,7 +1345,9 @@ var UserManager = class {
1266
1345
  var OS = class {
1267
1346
  constructor(config = { target: window.parent }) {
1268
1347
  this.config = config;
1348
+ this.accounts = new AccountManager(this);
1269
1349
  this.apps = new AppManager(this);
1350
+ this.devices = new DeviceManager(this);
1270
1351
  this.prefs = new PreferencesManager(this);
1271
1352
  this.user = new UserManager(this);
1272
1353
  }