@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.d.mts +88 -1
- package/dist/index.d.ts +88 -1
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -12,6 +12,37 @@ type RunningAppInstance = {
|
|
|
12
12
|
isInBackground: boolean;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
/** A registered Second Life device */
|
|
16
|
+
interface SLDevice {
|
|
17
|
+
id: string;
|
|
18
|
+
objectKey: string;
|
|
19
|
+
objectName: string;
|
|
20
|
+
regionName?: string;
|
|
21
|
+
isOnline: boolean;
|
|
22
|
+
lastHeartbeatAt: Date;
|
|
23
|
+
registeredAt: Date;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** A message received from a Second Life device */
|
|
27
|
+
interface DeviceMessage {
|
|
28
|
+
deviceId: string;
|
|
29
|
+
objectKey: string;
|
|
30
|
+
objectName: string;
|
|
31
|
+
type: string;
|
|
32
|
+
payload: Record<string, unknown>;
|
|
33
|
+
timestamp: Date;
|
|
34
|
+
}
|
|
35
|
+
/** Result of sending a message to a device */
|
|
36
|
+
interface SendMessageResult {
|
|
37
|
+
success: boolean;
|
|
38
|
+
error?: string;
|
|
39
|
+
deviceOffline?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Callback for receiving device messages */
|
|
42
|
+
type DeviceMessageCallback = (message: DeviceMessage) => void;
|
|
43
|
+
/** Function to unsubscribe from device messages */
|
|
44
|
+
type Unsubscribe = () => void;
|
|
45
|
+
|
|
15
46
|
/**
|
|
16
47
|
* Value types supported for preferences.
|
|
17
48
|
* Stored as JSONB in the database.
|
|
@@ -20,6 +51,18 @@ type PreferenceValue = string | number | boolean | null | PreferenceValue[] | {
|
|
|
20
51
|
[key: string]: PreferenceValue;
|
|
21
52
|
};
|
|
22
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Represents a linked Second Life account visible to apps via the SDK.
|
|
56
|
+
*/
|
|
57
|
+
type SecondLifeAccount = {
|
|
58
|
+
/** Second Life avatar UUID (key) */
|
|
59
|
+
avatarUuid: string;
|
|
60
|
+
/** Second Life avatar display name */
|
|
61
|
+
avatarName: string;
|
|
62
|
+
/** When the account was linked (ISO 8601 timestamp) */
|
|
63
|
+
linkedAt: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
23
66
|
/**
|
|
24
67
|
* Represents the authenticated user visible to apps via the SDK.
|
|
25
68
|
* This is a read-only, minimal representation.
|
|
@@ -36,6 +79,10 @@ type AppLaunchResult = {
|
|
|
36
79
|
error: Error | null;
|
|
37
80
|
app: AppDefinition;
|
|
38
81
|
};
|
|
82
|
+
type LinkingCode = {
|
|
83
|
+
code: string;
|
|
84
|
+
expiresAt: string;
|
|
85
|
+
};
|
|
39
86
|
type OperatingSystemAPI = {
|
|
40
87
|
system_homeButton: () => Promise<void>;
|
|
41
88
|
apps_getInstalledApps: () => Promise<AppDefinition[]>;
|
|
@@ -50,8 +97,27 @@ type OperatingSystemAPI = {
|
|
|
50
97
|
prefs_getShared: (key: string) => Promise<PreferenceValue>;
|
|
51
98
|
prefs_setShared: (key: string, value: PreferenceValue) => Promise<void>;
|
|
52
99
|
prefs_deleteShared: (key: string) => Promise<void>;
|
|
100
|
+
accounts_getLinkedSecondLifeAccounts: () => Promise<SecondLifeAccount[]>;
|
|
101
|
+
accounts_unlinkSecondLifeAccount: (avatarUuid: string) => Promise<void>;
|
|
102
|
+
accounts_generateLinkingCode: () => Promise<LinkingCode>;
|
|
103
|
+
devices_getRegistered: () => Promise<SLDevice[]>;
|
|
104
|
+
devices_sendMessage: (deviceId: string, type: string, payload: Record<string, unknown>) => Promise<SendMessageResult>;
|
|
105
|
+
devices_unregister: (deviceId: string) => Promise<void>;
|
|
106
|
+
devices_subscribe: (callback: (message: DeviceMessage) => void) => Promise<void>;
|
|
107
|
+
devices_unsubscribe: () => Promise<void>;
|
|
53
108
|
};
|
|
54
109
|
|
|
110
|
+
declare class AccountManager {
|
|
111
|
+
private os;
|
|
112
|
+
constructor(os: OS);
|
|
113
|
+
/** Get all Second Life accounts linked to the current user */
|
|
114
|
+
getLinkedSecondLifeAccounts(): Promise<SecondLifeAccount[]>;
|
|
115
|
+
/** Unlink a Second Life account from the current user */
|
|
116
|
+
unlinkSecondLifeAccount(avatarUuid: string): Promise<void>;
|
|
117
|
+
/** Generate a linking code for connecting a Second Life account */
|
|
118
|
+
generateLinkingCode(): Promise<LinkingCode>;
|
|
119
|
+
}
|
|
120
|
+
|
|
55
121
|
declare class AppManager {
|
|
56
122
|
private os;
|
|
57
123
|
constructor(os: OS);
|
|
@@ -61,6 +127,25 @@ declare class AppManager {
|
|
|
61
127
|
requestAppUninstall(app: AppDefinition): Promise<void>;
|
|
62
128
|
}
|
|
63
129
|
|
|
130
|
+
declare class DeviceManager {
|
|
131
|
+
private os;
|
|
132
|
+
private messageCallbacks;
|
|
133
|
+
private subscribed;
|
|
134
|
+
constructor(os: OS);
|
|
135
|
+
/** Get all registered Second Life devices for the current user */
|
|
136
|
+
getRegisteredDevices(): Promise<SLDevice[]>;
|
|
137
|
+
/** Send a message to a registered device */
|
|
138
|
+
sendMessage(deviceId: string, type: string, payload?: Record<string, unknown>): Promise<SendMessageResult>;
|
|
139
|
+
/** Unregister a device */
|
|
140
|
+
unregisterDevice(deviceId: string): Promise<void>;
|
|
141
|
+
/** Subscribe to messages from all registered devices */
|
|
142
|
+
subscribeToMessages(callback: DeviceMessageCallback): Unsubscribe;
|
|
143
|
+
/** Internal: Start the message subscription via RPC */
|
|
144
|
+
private startSubscription;
|
|
145
|
+
/** Internal: Stop the message subscription */
|
|
146
|
+
private stopSubscription;
|
|
147
|
+
}
|
|
148
|
+
|
|
64
149
|
/**
|
|
65
150
|
* Manages user preferences for apps.
|
|
66
151
|
*
|
|
@@ -111,7 +196,9 @@ type OSConfig = {
|
|
|
111
196
|
target: Window;
|
|
112
197
|
};
|
|
113
198
|
declare class OS {
|
|
199
|
+
accounts: AccountManager;
|
|
114
200
|
apps: AppManager;
|
|
201
|
+
devices: DeviceManager;
|
|
115
202
|
prefs: PreferencesManager;
|
|
116
203
|
user: UserManager;
|
|
117
204
|
private config;
|
|
@@ -122,4 +209,4 @@ declare class OS {
|
|
|
122
209
|
|
|
123
210
|
declare const VERSION = "1.0.0";
|
|
124
211
|
|
|
125
|
-
export { type AppBundleId, type AppDefinition, type AppLaunchResult, OS, type OSConfig, type OperatingSystemAPI, type PhotonUser, type PreferenceValue, type RunningAppInstance, VERSION };
|
|
212
|
+
export { type AppBundleId, type AppDefinition, type AppLaunchResult, type DeviceMessage, type DeviceMessageCallback, type LinkingCode, OS, type OSConfig, type OperatingSystemAPI, type PhotonUser, type PreferenceValue, type RunningAppInstance, type SLDevice, type SecondLifeAccount, type SendMessageResult, type Unsubscribe, VERSION };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,37 @@ type RunningAppInstance = {
|
|
|
12
12
|
isInBackground: boolean;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
/** A registered Second Life device */
|
|
16
|
+
interface SLDevice {
|
|
17
|
+
id: string;
|
|
18
|
+
objectKey: string;
|
|
19
|
+
objectName: string;
|
|
20
|
+
regionName?: string;
|
|
21
|
+
isOnline: boolean;
|
|
22
|
+
lastHeartbeatAt: Date;
|
|
23
|
+
registeredAt: Date;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** A message received from a Second Life device */
|
|
27
|
+
interface DeviceMessage {
|
|
28
|
+
deviceId: string;
|
|
29
|
+
objectKey: string;
|
|
30
|
+
objectName: string;
|
|
31
|
+
type: string;
|
|
32
|
+
payload: Record<string, unknown>;
|
|
33
|
+
timestamp: Date;
|
|
34
|
+
}
|
|
35
|
+
/** Result of sending a message to a device */
|
|
36
|
+
interface SendMessageResult {
|
|
37
|
+
success: boolean;
|
|
38
|
+
error?: string;
|
|
39
|
+
deviceOffline?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Callback for receiving device messages */
|
|
42
|
+
type DeviceMessageCallback = (message: DeviceMessage) => void;
|
|
43
|
+
/** Function to unsubscribe from device messages */
|
|
44
|
+
type Unsubscribe = () => void;
|
|
45
|
+
|
|
15
46
|
/**
|
|
16
47
|
* Value types supported for preferences.
|
|
17
48
|
* Stored as JSONB in the database.
|
|
@@ -20,6 +51,18 @@ type PreferenceValue = string | number | boolean | null | PreferenceValue[] | {
|
|
|
20
51
|
[key: string]: PreferenceValue;
|
|
21
52
|
};
|
|
22
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Represents a linked Second Life account visible to apps via the SDK.
|
|
56
|
+
*/
|
|
57
|
+
type SecondLifeAccount = {
|
|
58
|
+
/** Second Life avatar UUID (key) */
|
|
59
|
+
avatarUuid: string;
|
|
60
|
+
/** Second Life avatar display name */
|
|
61
|
+
avatarName: string;
|
|
62
|
+
/** When the account was linked (ISO 8601 timestamp) */
|
|
63
|
+
linkedAt: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
23
66
|
/**
|
|
24
67
|
* Represents the authenticated user visible to apps via the SDK.
|
|
25
68
|
* This is a read-only, minimal representation.
|
|
@@ -36,6 +79,10 @@ type AppLaunchResult = {
|
|
|
36
79
|
error: Error | null;
|
|
37
80
|
app: AppDefinition;
|
|
38
81
|
};
|
|
82
|
+
type LinkingCode = {
|
|
83
|
+
code: string;
|
|
84
|
+
expiresAt: string;
|
|
85
|
+
};
|
|
39
86
|
type OperatingSystemAPI = {
|
|
40
87
|
system_homeButton: () => Promise<void>;
|
|
41
88
|
apps_getInstalledApps: () => Promise<AppDefinition[]>;
|
|
@@ -50,8 +97,27 @@ type OperatingSystemAPI = {
|
|
|
50
97
|
prefs_getShared: (key: string) => Promise<PreferenceValue>;
|
|
51
98
|
prefs_setShared: (key: string, value: PreferenceValue) => Promise<void>;
|
|
52
99
|
prefs_deleteShared: (key: string) => Promise<void>;
|
|
100
|
+
accounts_getLinkedSecondLifeAccounts: () => Promise<SecondLifeAccount[]>;
|
|
101
|
+
accounts_unlinkSecondLifeAccount: (avatarUuid: string) => Promise<void>;
|
|
102
|
+
accounts_generateLinkingCode: () => Promise<LinkingCode>;
|
|
103
|
+
devices_getRegistered: () => Promise<SLDevice[]>;
|
|
104
|
+
devices_sendMessage: (deviceId: string, type: string, payload: Record<string, unknown>) => Promise<SendMessageResult>;
|
|
105
|
+
devices_unregister: (deviceId: string) => Promise<void>;
|
|
106
|
+
devices_subscribe: (callback: (message: DeviceMessage) => void) => Promise<void>;
|
|
107
|
+
devices_unsubscribe: () => Promise<void>;
|
|
53
108
|
};
|
|
54
109
|
|
|
110
|
+
declare class AccountManager {
|
|
111
|
+
private os;
|
|
112
|
+
constructor(os: OS);
|
|
113
|
+
/** Get all Second Life accounts linked to the current user */
|
|
114
|
+
getLinkedSecondLifeAccounts(): Promise<SecondLifeAccount[]>;
|
|
115
|
+
/** Unlink a Second Life account from the current user */
|
|
116
|
+
unlinkSecondLifeAccount(avatarUuid: string): Promise<void>;
|
|
117
|
+
/** Generate a linking code for connecting a Second Life account */
|
|
118
|
+
generateLinkingCode(): Promise<LinkingCode>;
|
|
119
|
+
}
|
|
120
|
+
|
|
55
121
|
declare class AppManager {
|
|
56
122
|
private os;
|
|
57
123
|
constructor(os: OS);
|
|
@@ -61,6 +127,25 @@ declare class AppManager {
|
|
|
61
127
|
requestAppUninstall(app: AppDefinition): Promise<void>;
|
|
62
128
|
}
|
|
63
129
|
|
|
130
|
+
declare class DeviceManager {
|
|
131
|
+
private os;
|
|
132
|
+
private messageCallbacks;
|
|
133
|
+
private subscribed;
|
|
134
|
+
constructor(os: OS);
|
|
135
|
+
/** Get all registered Second Life devices for the current user */
|
|
136
|
+
getRegisteredDevices(): Promise<SLDevice[]>;
|
|
137
|
+
/** Send a message to a registered device */
|
|
138
|
+
sendMessage(deviceId: string, type: string, payload?: Record<string, unknown>): Promise<SendMessageResult>;
|
|
139
|
+
/** Unregister a device */
|
|
140
|
+
unregisterDevice(deviceId: string): Promise<void>;
|
|
141
|
+
/** Subscribe to messages from all registered devices */
|
|
142
|
+
subscribeToMessages(callback: DeviceMessageCallback): Unsubscribe;
|
|
143
|
+
/** Internal: Start the message subscription via RPC */
|
|
144
|
+
private startSubscription;
|
|
145
|
+
/** Internal: Stop the message subscription */
|
|
146
|
+
private stopSubscription;
|
|
147
|
+
}
|
|
148
|
+
|
|
64
149
|
/**
|
|
65
150
|
* Manages user preferences for apps.
|
|
66
151
|
*
|
|
@@ -111,7 +196,9 @@ type OSConfig = {
|
|
|
111
196
|
target: Window;
|
|
112
197
|
};
|
|
113
198
|
declare class OS {
|
|
199
|
+
accounts: AccountManager;
|
|
114
200
|
apps: AppManager;
|
|
201
|
+
devices: DeviceManager;
|
|
115
202
|
prefs: PreferencesManager;
|
|
116
203
|
user: UserManager;
|
|
117
204
|
private config;
|
|
@@ -122,4 +209,4 @@ declare class OS {
|
|
|
122
209
|
|
|
123
210
|
declare const VERSION = "1.0.0";
|
|
124
211
|
|
|
125
|
-
export { type AppBundleId, type AppDefinition, type AppLaunchResult, OS, type OSConfig, type OperatingSystemAPI, type PhotonUser, type PreferenceValue, type RunningAppInstance, VERSION };
|
|
212
|
+
export { type AppBundleId, type AppDefinition, type AppLaunchResult, type DeviceMessage, type DeviceMessageCallback, type LinkingCode, OS, type OSConfig, type OperatingSystemAPI, type PhotonUser, type PreferenceValue, type RunningAppInstance, type SLDevice, type SecondLifeAccount, type SendMessageResult, type Unsubscribe, VERSION };
|
package/dist/index.js
CHANGED
|
@@ -1188,6 +1188,28 @@ module.exports = __toCommonJS(index_exports);
|
|
|
1188
1188
|
// src/framework/OS.ts
|
|
1189
1189
|
var pmrpc = __toESM(require_pm_rpc_min());
|
|
1190
1190
|
|
|
1191
|
+
// src/framework/AccountManager.ts
|
|
1192
|
+
var AccountManager = class {
|
|
1193
|
+
constructor(os) {
|
|
1194
|
+
this.os = os;
|
|
1195
|
+
}
|
|
1196
|
+
/** Get all Second Life accounts linked to the current user */
|
|
1197
|
+
async getLinkedSecondLifeAccounts() {
|
|
1198
|
+
const api2 = await this.os.getRPCAPI();
|
|
1199
|
+
return await api2.accounts_getLinkedSecondLifeAccounts();
|
|
1200
|
+
}
|
|
1201
|
+
/** Unlink a Second Life account from the current user */
|
|
1202
|
+
async unlinkSecondLifeAccount(avatarUuid) {
|
|
1203
|
+
const api2 = await this.os.getRPCAPI();
|
|
1204
|
+
await api2.accounts_unlinkSecondLifeAccount(avatarUuid);
|
|
1205
|
+
}
|
|
1206
|
+
/** Generate a linking code for connecting a Second Life account */
|
|
1207
|
+
async generateLinkingCode() {
|
|
1208
|
+
const api2 = await this.os.getRPCAPI();
|
|
1209
|
+
return await api2.accounts_generateLinkingCode();
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1191
1213
|
// src/framework/AppManager.ts
|
|
1192
1214
|
var AppManager = class {
|
|
1193
1215
|
constructor(os) {
|
|
@@ -1211,6 +1233,63 @@ var AppManager = class {
|
|
|
1211
1233
|
}
|
|
1212
1234
|
};
|
|
1213
1235
|
|
|
1236
|
+
// src/framework/DeviceManager.ts
|
|
1237
|
+
var DeviceManager = class {
|
|
1238
|
+
constructor(os) {
|
|
1239
|
+
this.messageCallbacks = /* @__PURE__ */ new Set();
|
|
1240
|
+
this.subscribed = false;
|
|
1241
|
+
this.os = os;
|
|
1242
|
+
}
|
|
1243
|
+
/** Get all registered Second Life devices for the current user */
|
|
1244
|
+
async getRegisteredDevices() {
|
|
1245
|
+
const api2 = await this.os.getRPCAPI();
|
|
1246
|
+
return await api2.devices_getRegistered();
|
|
1247
|
+
}
|
|
1248
|
+
/** Send a message to a registered device */
|
|
1249
|
+
async sendMessage(deviceId, type, payload = {}) {
|
|
1250
|
+
const api2 = await this.os.getRPCAPI();
|
|
1251
|
+
return await api2.devices_sendMessage(deviceId, type, payload);
|
|
1252
|
+
}
|
|
1253
|
+
/** Unregister a device */
|
|
1254
|
+
async unregisterDevice(deviceId) {
|
|
1255
|
+
const api2 = await this.os.getRPCAPI();
|
|
1256
|
+
await api2.devices_unregister(deviceId);
|
|
1257
|
+
}
|
|
1258
|
+
/** Subscribe to messages from all registered devices */
|
|
1259
|
+
subscribeToMessages(callback) {
|
|
1260
|
+
this.messageCallbacks.add(callback);
|
|
1261
|
+
if (!this.subscribed) {
|
|
1262
|
+
this.startSubscription();
|
|
1263
|
+
}
|
|
1264
|
+
return () => {
|
|
1265
|
+
this.messageCallbacks.delete(callback);
|
|
1266
|
+
if (this.messageCallbacks.size === 0 && this.subscribed) {
|
|
1267
|
+
this.stopSubscription();
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
/** Internal: Start the message subscription via RPC */
|
|
1272
|
+
async startSubscription() {
|
|
1273
|
+
const api2 = await this.os.getRPCAPI();
|
|
1274
|
+
await api2.devices_subscribe((message) => {
|
|
1275
|
+
for (const callback of this.messageCallbacks) {
|
|
1276
|
+
try {
|
|
1277
|
+
callback(message);
|
|
1278
|
+
} catch (error) {
|
|
1279
|
+
console.error("Error in device message callback:", error);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
this.subscribed = true;
|
|
1284
|
+
}
|
|
1285
|
+
/** Internal: Stop the message subscription */
|
|
1286
|
+
async stopSubscription() {
|
|
1287
|
+
const api2 = await this.os.getRPCAPI();
|
|
1288
|
+
await api2.devices_unsubscribe();
|
|
1289
|
+
this.subscribed = false;
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1214
1293
|
// src/framework/PreferencesManager.ts
|
|
1215
1294
|
var PreferencesManager = class {
|
|
1216
1295
|
constructor(os) {
|
|
@@ -1280,7 +1359,9 @@ var UserManager = class {
|
|
|
1280
1359
|
var OS = class {
|
|
1281
1360
|
constructor(config = { target: window.parent }) {
|
|
1282
1361
|
this.config = config;
|
|
1362
|
+
this.accounts = new AccountManager(this);
|
|
1283
1363
|
this.apps = new AppManager(this);
|
|
1364
|
+
this.devices = new DeviceManager(this);
|
|
1284
1365
|
this.prefs = new PreferencesManager(this);
|
|
1285
1366
|
this.user = new UserManager(this);
|
|
1286
1367
|
}
|