@photon-os/sdk 0.4.2 → 0.4.3
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/lib/CoreServices/Apps/PhotonApp.d.ts +1 -1
- package/lib/CoreServices/Apps/PhotonApp.js +20 -8
- package/lib/SecondLife/PhotonTool.d.ts +1 -0
- package/lib/SecondLife/PhotonTool.js +5 -0
- package/lib/SecondLife/SecondLifeIdentity.d.ts +2 -1
- package/lib/SecondLife/SecondLifeIdentity.js +23 -2
- package/lib/SystemMessaging/SecondLIfeMessagingListener.js +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import PhotonAppMode from "./PhotonAppMode";
|
|
2
2
|
declare class PhotonApp {
|
|
3
3
|
static appId: string;
|
|
4
|
-
static bootstrap(appId: string, appMode?: PhotonAppMode): void
|
|
4
|
+
static bootstrap(appId: string, appMode?: PhotonAppMode): Promise<void>;
|
|
5
5
|
}
|
|
6
6
|
export default PhotonApp;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const EventManager_1 = require("../../SystemEvents/EventManager");
|
|
4
13
|
const __1 = require("../..");
|
|
@@ -8,14 +17,17 @@ const SecondLifeProxy_1 = require("../../SecondLife/SecondLifeProxy");
|
|
|
8
17
|
const SecondLifeIdentity_1 = require("../../SecondLife/SecondLifeIdentity");
|
|
9
18
|
class PhotonApp {
|
|
10
19
|
static bootstrap(appId, appMode = PhotonAppMode_1.default.App) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
PhotonApp.appId = appId;
|
|
22
|
+
const messageBroker = new __1.MessageBroker();
|
|
23
|
+
const key = SecondLifeIdentity_1.default.getKeyFromQueryString();
|
|
24
|
+
messageBroker.registerListener(new __1.SecondLifeMessagingListener(`${appId}__${key}`, SecondLifeProxy_1.default.socket));
|
|
25
|
+
messageBroker.registerListener(new BrowserMessageListener_1.default());
|
|
26
|
+
messageBroker.registerTarget(new __1.BrowserMessagingTarget("os", appMode === PhotonAppMode_1.default.App ? window.parent : window));
|
|
27
|
+
__1.MessageBroker.setDefault(messageBroker);
|
|
28
|
+
const eventManager = new EventManager_1.default();
|
|
29
|
+
EventManager_1.default.setDefault(eventManager);
|
|
30
|
+
});
|
|
19
31
|
}
|
|
20
32
|
}
|
|
21
33
|
exports.default = PhotonApp;
|
|
@@ -25,6 +25,7 @@ declare class PhotonTool {
|
|
|
25
25
|
ownerSay(message: string): Promise<void>;
|
|
26
26
|
chat(volume: ChatVolume, channel: number, message: string): Promise<void>;
|
|
27
27
|
sensor(options?: SensorOptions): Promise<any>;
|
|
28
|
+
giveInventoryItem(inventoryItemName: string, recipientUuid: string): Promise<void>;
|
|
28
29
|
invokeCommand(command: string): void;
|
|
29
30
|
static getPhotonTool(): Promise<PhotonTool>;
|
|
30
31
|
static isPhotonToolConnected(): Promise<boolean>;
|
|
@@ -68,6 +68,11 @@ class PhotonTool {
|
|
|
68
68
|
return results;
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
giveInventoryItem(inventoryItemName, recipientUuid) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
yield __1.MessageBroker.defaultMessageBroker.invoke(this.device.target, "pt_Inventory", "giveInventory", [inventoryItemName, recipientUuid]);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
71
76
|
invokeCommand(command) {
|
|
72
77
|
__1.MessageBroker.defaultMessageBroker.invoke(this.device.target, "pt_Legacy", "invokeCommand", [command]);
|
|
73
78
|
}
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const __1 = require("..");
|
|
3
13
|
class SecondLifeIdentity {
|
|
4
|
-
static
|
|
14
|
+
static getKeyFromQueryString() {
|
|
15
|
+
if (window.parent !== window) {
|
|
16
|
+
throw new Error("Unable to fetch key from query string within an app frame. Did you mean to call SecondLifeIdentity.getKey() instead?");
|
|
17
|
+
}
|
|
5
18
|
const urlParams = new URLSearchParams(window.location.search);
|
|
6
|
-
return urlParams.get(
|
|
19
|
+
return urlParams.get("key");
|
|
20
|
+
}
|
|
21
|
+
static getKey() {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (window.parent === window) {
|
|
24
|
+
throw new Error("To fetch the user's key outside of an app frame, use SecondLifeIdentity.getKeyFromQueryString() instead.");
|
|
25
|
+
}
|
|
26
|
+
return yield __1.MessageBroker.defaultMessageBroker.invoke(__1.MessageBroker.defaultMessageBroker.getTargetById("os"), "os_SecondLifeIdentity", "getKey");
|
|
27
|
+
});
|
|
7
28
|
}
|
|
8
29
|
}
|
|
9
30
|
exports.default = SecondLifeIdentity;
|
|
@@ -13,7 +13,7 @@ class SecondLifeMessagingListener extends events_1.EventEmitter {
|
|
|
13
13
|
subscribe(broker) {
|
|
14
14
|
this.socket.emit("ident", {
|
|
15
15
|
id: this.senderId,
|
|
16
|
-
owner: SecondLifeIdentity_1.default.
|
|
16
|
+
owner: SecondLifeIdentity_1.default.getKeyFromQueryString(),
|
|
17
17
|
});
|
|
18
18
|
this.socket.on("invoke", this.messageEventHandler.bind(this));
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@photon-os/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"@types/node": "^14.0.13",
|
|
18
18
|
"@types/socket.io-client": "^1.4.33",
|
|
19
19
|
"@types/uuid": "^8.0.0",
|
|
20
|
-
"tsc-watch": "^
|
|
20
|
+
"tsc-watch": "^4.2.8",
|
|
21
21
|
"typedoc": "^0.17.7",
|
|
22
22
|
"typescript": "^3.9.5"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"socket.io-client": "^2.
|
|
26
|
-
"uuid": "^
|
|
25
|
+
"socket.io-client": "^2.3.0",
|
|
26
|
+
"uuid": "^8.1.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {}
|
|
29
29
|
}
|