@rtsdk/topia 0.11.10 → 0.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 +1 -1
- package/dist/index.cjs +226 -46
- package/dist/index.d.ts +133 -7
- package/dist/index.js +225 -47
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ Topia offers a robust SDK and API that allows anyone to build custom apps or int
|
|
|
48
48
|
- [Github](https://github.com/metaversecloud-com/sdk-quest)
|
|
49
49
|
- [Demo](https://topia.io/quest-prod)
|
|
50
50
|
|
|
51
|
-
Questions, comments, or have something exciting to share with the Topia team? Reach out to [
|
|
51
|
+
Questions, comments, or have something exciting to share with the Topia team? Reach out to [apps@topia.io](mailto:apps@topia.io)!
|
|
52
52
|
<br/>
|
|
53
53
|
|
|
54
54
|
## Authorization
|
package/dist/index.cjs
CHANGED
|
@@ -39637,7 +39637,7 @@ const {
|
|
|
39637
39637
|
*/
|
|
39638
39638
|
class SDKController {
|
|
39639
39639
|
constructor(topia, credentials = {}) {
|
|
39640
|
-
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, } = credentials;
|
|
39640
|
+
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, iframeId = null, gameEngineId = null, } = credentials;
|
|
39641
39641
|
this.topia = topia;
|
|
39642
39642
|
this.credentials = credentials;
|
|
39643
39643
|
this.requestOptions = {};
|
|
@@ -39657,6 +39657,12 @@ class SDKController {
|
|
|
39657
39657
|
if (apiKey) {
|
|
39658
39658
|
headers.Authorization = apiKey;
|
|
39659
39659
|
}
|
|
39660
|
+
if (iframeId) {
|
|
39661
|
+
headers.iframeId = iframeId;
|
|
39662
|
+
}
|
|
39663
|
+
if (gameEngineId) {
|
|
39664
|
+
headers.gameEngineId = gameEngineId;
|
|
39665
|
+
}
|
|
39660
39666
|
this.requestOptions = { headers };
|
|
39661
39667
|
}
|
|
39662
39668
|
catch (error) {
|
|
@@ -39717,7 +39723,7 @@ class SDKController {
|
|
|
39717
39723
|
*/
|
|
39718
39724
|
class Asset extends SDKController {
|
|
39719
39725
|
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
39720
|
-
var _a, _b, _c, _d, _e
|
|
39726
|
+
var _a, _b, _c, _d, _e;
|
|
39721
39727
|
// assetId and urlSlug should only be used when Asset is extended by DroppedAsset
|
|
39722
39728
|
super(topia, {
|
|
39723
39729
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
@@ -39727,7 +39733,6 @@ class Asset extends SDKController {
|
|
|
39727
39733
|
visitorId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.visitorId,
|
|
39728
39734
|
});
|
|
39729
39735
|
this.id = id;
|
|
39730
|
-
this.urlSlug = (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.urlSlug;
|
|
39731
39736
|
Object.assign(this, options.attributes);
|
|
39732
39737
|
}
|
|
39733
39738
|
/**
|
|
@@ -39743,7 +39748,8 @@ class Asset extends SDKController {
|
|
|
39743
39748
|
fetchAssetById() {
|
|
39744
39749
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39745
39750
|
try {
|
|
39746
|
-
const response = yield this.topiaPublicApi().get(`/assets/${this.
|
|
39751
|
+
const response = yield this.topiaPublicApi().get(`/assets/${this.id}`, this.requestOptions);
|
|
39752
|
+
Object.assign(this, response.data);
|
|
39747
39753
|
return response.data;
|
|
39748
39754
|
}
|
|
39749
39755
|
catch (error) {
|
|
@@ -39751,6 +39757,44 @@ class Asset extends SDKController {
|
|
|
39751
39757
|
}
|
|
39752
39758
|
});
|
|
39753
39759
|
}
|
|
39760
|
+
/**
|
|
39761
|
+
* @summary
|
|
39762
|
+
* Updates platform asset details.
|
|
39763
|
+
*
|
|
39764
|
+
* @usage
|
|
39765
|
+
* ```ts
|
|
39766
|
+
* await asset.updateAsset({
|
|
39767
|
+
* assetName: "exampleAsset",
|
|
39768
|
+
* bottomLayerURL: null,
|
|
39769
|
+
* creatorTags: { "decorations": true },
|
|
39770
|
+
* isPublic: true,
|
|
39771
|
+
* shouldUploadImages: true,
|
|
39772
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
39773
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
39774
|
+
* });
|
|
39775
|
+
* const { assetName } = asset;
|
|
39776
|
+
* ```
|
|
39777
|
+
*/
|
|
39778
|
+
updateAsset({ assetName, bottomLayerURL, creatorTags, isPublic, shouldUploadImages, tagJson, topLayerURL, }) {
|
|
39779
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39780
|
+
const params = {
|
|
39781
|
+
assetName,
|
|
39782
|
+
bottomLayerURL,
|
|
39783
|
+
creatorTags,
|
|
39784
|
+
isPublic,
|
|
39785
|
+
shouldUploadImages,
|
|
39786
|
+
tagJson,
|
|
39787
|
+
topLayerURL,
|
|
39788
|
+
};
|
|
39789
|
+
try {
|
|
39790
|
+
const response = yield this.topiaPublicApi().put(`/assets/${this.id}`, params, this.requestOptions);
|
|
39791
|
+
Object.assign(this, response.data);
|
|
39792
|
+
}
|
|
39793
|
+
catch (error) {
|
|
39794
|
+
throw this.errorHandler({ error, params, sdkMethod: "Asset.updateAsset" });
|
|
39795
|
+
}
|
|
39796
|
+
});
|
|
39797
|
+
}
|
|
39754
39798
|
}
|
|
39755
39799
|
|
|
39756
39800
|
var _DroppedAsset_updateDroppedAsset;
|
|
@@ -40395,6 +40439,44 @@ const scatterVisitors = (original, scatterBy) => {
|
|
|
40395
40439
|
return Math.floor(Math.random() * (max - min) + min);
|
|
40396
40440
|
};
|
|
40397
40441
|
|
|
40442
|
+
/**
|
|
40443
|
+
* @summary
|
|
40444
|
+
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
40445
|
+
*
|
|
40446
|
+
* @usage
|
|
40447
|
+
* ```ts
|
|
40448
|
+
* const topia = await new Topia({
|
|
40449
|
+
* apiDomain: "api.topia.io",
|
|
40450
|
+
* apiKey: "exampleKey",
|
|
40451
|
+
* interactiveKey: "key",
|
|
40452
|
+
* interactiveSecret: "secret",
|
|
40453
|
+
* });
|
|
40454
|
+
* ```
|
|
40455
|
+
*/
|
|
40456
|
+
class Topia {
|
|
40457
|
+
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, mcAuthorizationKey, }) {
|
|
40458
|
+
getBrowserWarning();
|
|
40459
|
+
this.apiDomain = apiDomain || "api.topia.io";
|
|
40460
|
+
this.apiKey = apiKey;
|
|
40461
|
+
this.apiProtocol = apiProtocol || "https";
|
|
40462
|
+
this.interactiveSecret = interactiveSecret;
|
|
40463
|
+
const headers = {
|
|
40464
|
+
"ApplicationId": "sdk-js-topia",
|
|
40465
|
+
"Content-Type": "application/json",
|
|
40466
|
+
};
|
|
40467
|
+
if (apiKey)
|
|
40468
|
+
headers.Authorization = apiKey;
|
|
40469
|
+
if (interactiveKey)
|
|
40470
|
+
headers.PublicKey = interactiveKey;
|
|
40471
|
+
if (mcAuthorizationKey)
|
|
40472
|
+
headers.MCAuthorizationKey = mcAuthorizationKey;
|
|
40473
|
+
this.axios = axios.create({
|
|
40474
|
+
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
40475
|
+
headers,
|
|
40476
|
+
});
|
|
40477
|
+
}
|
|
40478
|
+
}
|
|
40479
|
+
|
|
40398
40480
|
var _World_droppedAssetsMap;
|
|
40399
40481
|
/**
|
|
40400
40482
|
* @summary
|
|
@@ -40922,6 +41004,7 @@ class World extends SDKController {
|
|
|
40922
41004
|
* ```
|
|
40923
41005
|
*/
|
|
40924
41006
|
triggerParticle({ id, name, duration = 10, position = { x: 1, y: 1 }, }) {
|
|
41007
|
+
var _a;
|
|
40925
41008
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40926
41009
|
if (!id && !name)
|
|
40927
41010
|
throw "A particle name is required.";
|
|
@@ -40929,8 +41012,10 @@ class World extends SDKController {
|
|
|
40929
41012
|
let particleId = id;
|
|
40930
41013
|
if (name) {
|
|
40931
41014
|
const response = yield this.topiaPublicApi().get(`/particles?name=${name}`, this.requestOptions);
|
|
40932
|
-
particleId = response.data[0].id;
|
|
41015
|
+
particleId = (_a = response === null || response === void 0 ? void 0 : response.data[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
40933
41016
|
}
|
|
41017
|
+
if (!particleId)
|
|
41018
|
+
return "No particleId found.";
|
|
40934
41019
|
const result = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/particles`, { particleId, position, duration }, this.requestOptions);
|
|
40935
41020
|
return result;
|
|
40936
41021
|
}
|
|
@@ -41047,13 +41132,15 @@ var _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
41047
41132
|
*/
|
|
41048
41133
|
class User extends SDKController {
|
|
41049
41134
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
41050
|
-
var _a, _b, _c, _d;
|
|
41135
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41051
41136
|
super(topia, {
|
|
41052
41137
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
41053
41138
|
interactiveNonce: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.interactiveNonce,
|
|
41054
41139
|
profileId: options === null || options === void 0 ? void 0 : options.profileId,
|
|
41055
41140
|
urlSlug: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.urlSlug,
|
|
41056
41141
|
visitorId: (_d = options === null || options === void 0 ? void 0 : options.credentials) === null || _d === void 0 ? void 0 : _d.visitorId,
|
|
41142
|
+
iframeId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.iframeId,
|
|
41143
|
+
gameEngineId: (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.gameEngineId,
|
|
41057
41144
|
});
|
|
41058
41145
|
_User_adminWorldsMap.set(this, void 0);
|
|
41059
41146
|
_User_assetsMap.set(this, void 0);
|
|
@@ -41819,6 +41906,7 @@ class Visitor extends User {
|
|
|
41819
41906
|
* ```
|
|
41820
41907
|
*/
|
|
41821
41908
|
triggerParticle({ id, name, duration = 10, }) {
|
|
41909
|
+
var _a;
|
|
41822
41910
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41823
41911
|
if (!id && !name)
|
|
41824
41912
|
throw "A particle name is required.";
|
|
@@ -41826,8 +41914,10 @@ class Visitor extends User {
|
|
|
41826
41914
|
let particleId = id;
|
|
41827
41915
|
if (name) {
|
|
41828
41916
|
const response = yield this.topiaPublicApi().get(`/particles?name=${name}`, this.requestOptions);
|
|
41829
|
-
particleId = response.data[0].id;
|
|
41917
|
+
particleId = (_a = response === null || response === void 0 ? void 0 : response.data[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
41830
41918
|
}
|
|
41919
|
+
if (!particleId)
|
|
41920
|
+
return "No particleId found.";
|
|
41831
41921
|
const result = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/particles`, { particleId, position: { x: 1, y: 1 }, duration, followPlayerId: this.id }, this.requestOptions);
|
|
41832
41922
|
return result;
|
|
41833
41923
|
}
|
|
@@ -41953,6 +42043,75 @@ class Visitor extends User {
|
|
|
41953
42043
|
}
|
|
41954
42044
|
});
|
|
41955
42045
|
}
|
|
42046
|
+
/**
|
|
42047
|
+
* @summary
|
|
42048
|
+
* Setup signal to visitor
|
|
42049
|
+
*
|
|
42050
|
+
* @usage
|
|
42051
|
+
* ```ts
|
|
42052
|
+
* await visitor.sendSignalToVisitor(iceServers);
|
|
42053
|
+
* ```
|
|
42054
|
+
*/
|
|
42055
|
+
sendSignalToVisitor(signal) {
|
|
42056
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42057
|
+
try {
|
|
42058
|
+
const response = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/send-signal-to-visitor`, { signal }, this.requestOptions);
|
|
42059
|
+
return response.data;
|
|
42060
|
+
}
|
|
42061
|
+
catch (error) {
|
|
42062
|
+
throw this.errorHandler({
|
|
42063
|
+
error,
|
|
42064
|
+
params: { signal },
|
|
42065
|
+
sdkMethod: "Visitor.sendSignalToVisitor",
|
|
42066
|
+
});
|
|
42067
|
+
}
|
|
42068
|
+
});
|
|
42069
|
+
}
|
|
42070
|
+
}
|
|
42071
|
+
|
|
42072
|
+
/**
|
|
42073
|
+
* @summary
|
|
42074
|
+
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
42075
|
+
*
|
|
42076
|
+
* @usage
|
|
42077
|
+
* ```ts
|
|
42078
|
+
* await new WebRTCConnector(topia, {
|
|
42079
|
+
* credentials: { interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
|
|
42080
|
+
* });
|
|
42081
|
+
* ```
|
|
42082
|
+
*/
|
|
42083
|
+
class WebRTCConnector extends SDKController {
|
|
42084
|
+
constructor(topia, urlSlug, options = { twilioConfig: {}, credentials: {} }) {
|
|
42085
|
+
var _a, _b, _c;
|
|
42086
|
+
super(topia, {
|
|
42087
|
+
interactiveNonce: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.interactiveNonce,
|
|
42088
|
+
urlSlug: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.urlSlug,
|
|
42089
|
+
visitorId: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.visitorId,
|
|
42090
|
+
});
|
|
42091
|
+
this.twilioConfig = options === null || options === void 0 ? void 0 : options.twilioConfig;
|
|
42092
|
+
this.urlSlug = urlSlug;
|
|
42093
|
+
}
|
|
42094
|
+
/**
|
|
42095
|
+
* @summary
|
|
42096
|
+
* Get twilio
|
|
42097
|
+
*
|
|
42098
|
+
* @usage
|
|
42099
|
+
* ```ts
|
|
42100
|
+
* await webRTCConnector.getTwilioConfig();
|
|
42101
|
+
* ```
|
|
42102
|
+
*/
|
|
42103
|
+
getTwilioConfig() {
|
|
42104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42105
|
+
try {
|
|
42106
|
+
const response = yield this.topiaPublicApi().get(`/webrtc/twilio-config`, this.requestOptions);
|
|
42107
|
+
this.twilioConfig = response.data.twilioConfig;
|
|
42108
|
+
return response.data;
|
|
42109
|
+
}
|
|
42110
|
+
catch (error) {
|
|
42111
|
+
throw this.errorHandler({ error, sdkMethod: "WebRTCConnector.getTwilioConfig" });
|
|
42112
|
+
}
|
|
42113
|
+
});
|
|
42114
|
+
}
|
|
41956
42115
|
}
|
|
41957
42116
|
|
|
41958
42117
|
var _WorldActivity_visitorsMap;
|
|
@@ -42132,52 +42291,15 @@ class WorldActivity extends SDKController {
|
|
|
42132
42291
|
}
|
|
42133
42292
|
_WorldActivity_visitorsMap = new WeakMap();
|
|
42134
42293
|
|
|
42135
|
-
/**
|
|
42136
|
-
* @summary
|
|
42137
|
-
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
42138
|
-
*
|
|
42139
|
-
* @usage
|
|
42140
|
-
* ```ts
|
|
42141
|
-
* const topia = await new Topia({
|
|
42142
|
-
* apiDomain: "api.topia.io",
|
|
42143
|
-
* apiKey: "exampleKey",
|
|
42144
|
-
* interactiveKey: "key",
|
|
42145
|
-
* interactiveSecret: "secret",
|
|
42146
|
-
* });
|
|
42147
|
-
* ```
|
|
42148
|
-
*/
|
|
42149
|
-
class Topia {
|
|
42150
|
-
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, }) {
|
|
42151
|
-
getBrowserWarning();
|
|
42152
|
-
this.apiDomain = apiDomain || "api.topia.io";
|
|
42153
|
-
this.apiKey = apiKey;
|
|
42154
|
-
this.apiProtocol = apiProtocol || "https";
|
|
42155
|
-
this.interactiveSecret = interactiveSecret;
|
|
42156
|
-
const headers = {
|
|
42157
|
-
"ApplicationId": "sdk-js-topia",
|
|
42158
|
-
"Content-Type": "application/json",
|
|
42159
|
-
};
|
|
42160
|
-
if (apiKey)
|
|
42161
|
-
headers.Authorization = apiKey;
|
|
42162
|
-
if (interactiveKey)
|
|
42163
|
-
headers.PublicKey = interactiveKey;
|
|
42164
|
-
this.axios = axios.create({
|
|
42165
|
-
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
42166
|
-
headers,
|
|
42167
|
-
});
|
|
42168
|
-
}
|
|
42169
|
-
}
|
|
42170
|
-
|
|
42171
42294
|
/**
|
|
42172
42295
|
* @usage
|
|
42173
42296
|
* ```ts
|
|
42174
42297
|
* const Asset = new AssetFactory(myTopiaInstance);
|
|
42175
42298
|
* ```
|
|
42176
42299
|
*/
|
|
42177
|
-
class AssetFactory {
|
|
42300
|
+
class AssetFactory extends SDKController {
|
|
42178
42301
|
constructor(topia) {
|
|
42179
|
-
|
|
42180
|
-
this.create;
|
|
42302
|
+
super(topia);
|
|
42181
42303
|
}
|
|
42182
42304
|
/**
|
|
42183
42305
|
* @summary
|
|
@@ -42191,6 +42313,38 @@ class AssetFactory {
|
|
|
42191
42313
|
create(id, options) {
|
|
42192
42314
|
return new Asset(this.topia, id, options);
|
|
42193
42315
|
}
|
|
42316
|
+
/**
|
|
42317
|
+
* @summary
|
|
42318
|
+
* Upload a new Asset and return a new instance of Asset class.
|
|
42319
|
+
*
|
|
42320
|
+
* @usage
|
|
42321
|
+
* ```
|
|
42322
|
+
* const assetPayload = {
|
|
42323
|
+
* assetName: "exampleAssetName"
|
|
42324
|
+
* bottomLayerURL: "https://example.bottomLayerURL"
|
|
42325
|
+
* creatorTags: { "decorations": true },
|
|
42326
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
42327
|
+
* isPublic: true,
|
|
42328
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
42329
|
+
* }
|
|
42330
|
+
* const asset = await Asset.upload(assetPayload, apiKey);
|
|
42331
|
+
* ```
|
|
42332
|
+
*/
|
|
42333
|
+
upload(assetPayload, apiKey) {
|
|
42334
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42335
|
+
try {
|
|
42336
|
+
if (!apiKey)
|
|
42337
|
+
throw "A valid API Key is required.";
|
|
42338
|
+
const headers = { Authorization: apiKey };
|
|
42339
|
+
const response = yield this.topiaPublicApi().post("/assets", assetPayload, { headers });
|
|
42340
|
+
const { assetId, asset } = response.data;
|
|
42341
|
+
return new Asset(this.topia, assetId, { attributes: asset });
|
|
42342
|
+
}
|
|
42343
|
+
catch (error) {
|
|
42344
|
+
throw this.errorHandler({ error, params: assetPayload, sdkMethod: "AssetFactory.upload" });
|
|
42345
|
+
}
|
|
42346
|
+
});
|
|
42347
|
+
}
|
|
42194
42348
|
}
|
|
42195
42349
|
|
|
42196
42350
|
/**
|
|
@@ -42425,6 +42579,30 @@ class VisitorFactory {
|
|
|
42425
42579
|
}
|
|
42426
42580
|
}
|
|
42427
42581
|
|
|
42582
|
+
/**
|
|
42583
|
+
* @usage
|
|
42584
|
+
* ```ts
|
|
42585
|
+
* const WebRTCConnector = new WebRTCConnectorFactory(myTopiaInstance);
|
|
42586
|
+
* ```
|
|
42587
|
+
*/
|
|
42588
|
+
class WebRTCConnectorFactory {
|
|
42589
|
+
constructor(topia) {
|
|
42590
|
+
this.topia = topia;
|
|
42591
|
+
}
|
|
42592
|
+
/**
|
|
42593
|
+
* @summary
|
|
42594
|
+
* Instantiate a new instance of WebRTCConnector class.
|
|
42595
|
+
*
|
|
42596
|
+
* @usage
|
|
42597
|
+
* ```
|
|
42598
|
+
* const userInstance = await WebRTCConnector.create({ credentials: { interactiveNonce, interactivePublicKey, urlSlug, visitorId }, twilioConfig: {} });
|
|
42599
|
+
* ```
|
|
42600
|
+
*/
|
|
42601
|
+
create(urlSlug, options) {
|
|
42602
|
+
return new WebRTCConnector(this.topia, urlSlug, options);
|
|
42603
|
+
}
|
|
42604
|
+
}
|
|
42605
|
+
|
|
42428
42606
|
/**
|
|
42429
42607
|
* @usage
|
|
42430
42608
|
* ```ts
|
|
@@ -42541,6 +42719,8 @@ exports.User = User;
|
|
|
42541
42719
|
exports.UserFactory = UserFactory;
|
|
42542
42720
|
exports.Visitor = Visitor;
|
|
42543
42721
|
exports.VisitorFactory = VisitorFactory;
|
|
42722
|
+
exports.WebRTCConnector = WebRTCConnector;
|
|
42723
|
+
exports.WebRTCConnectorFactory = WebRTCConnectorFactory;
|
|
42544
42724
|
exports.World = World;
|
|
42545
42725
|
exports.WorldActivity = WorldActivity;
|
|
42546
42726
|
exports.WorldActivityFactory = WorldActivityFactory;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,17 @@ type AnalyticType = {
|
|
|
10
10
|
urlSlug?: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
type AssetType = {
|
|
14
|
+
assetName: string;
|
|
15
|
+
bottomLayerURL: string;
|
|
16
|
+
creatorTags: {
|
|
17
|
+
[key: string]: boolean;
|
|
18
|
+
};
|
|
19
|
+
tagJson: string;
|
|
20
|
+
isPublic: true;
|
|
21
|
+
topLayerURL: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
13
24
|
declare enum DroppedAssetClickType {
|
|
14
25
|
NONE = "none",
|
|
15
26
|
LINK = "link",
|
|
@@ -30,6 +41,8 @@ type InteractiveCredentials = {
|
|
|
30
41
|
profileId?: string | null;
|
|
31
42
|
urlSlug?: string;
|
|
32
43
|
visitorId?: number;
|
|
44
|
+
iframeId?: string;
|
|
45
|
+
gameEngineId?: string;
|
|
33
46
|
};
|
|
34
47
|
|
|
35
48
|
type AssetOptions = {
|
|
@@ -708,7 +721,7 @@ declare class World extends SDKController implements WorldInterface {
|
|
|
708
721
|
name?: string;
|
|
709
722
|
duration?: number;
|
|
710
723
|
position?: object;
|
|
711
|
-
}): Promise<object | ResponseType$1>;
|
|
724
|
+
}): Promise<object | ResponseType$1 | string>;
|
|
712
725
|
/**
|
|
713
726
|
* @summary
|
|
714
727
|
* Retrieves the data object for a world. Must have valid interactive credentials from a visitor in the world.
|
|
@@ -1296,7 +1309,7 @@ declare class Visitor extends User implements VisitorInterface {
|
|
|
1296
1309
|
id?: string;
|
|
1297
1310
|
name?: string;
|
|
1298
1311
|
duration?: number;
|
|
1299
|
-
}): Promise<object | ResponseType$1>;
|
|
1312
|
+
}): Promise<object | ResponseType$1 | string>;
|
|
1300
1313
|
/**
|
|
1301
1314
|
* @summary
|
|
1302
1315
|
* Retrieves the data object for a visitor.
|
|
@@ -1375,6 +1388,18 @@ declare class Visitor extends User implements VisitorInterface {
|
|
|
1375
1388
|
* ```
|
|
1376
1389
|
*/
|
|
1377
1390
|
updatePublicKeyAnalytics(analytics?: AnalyticType[]): Promise<void | ResponseType$1>;
|
|
1391
|
+
/**
|
|
1392
|
+
* @summary
|
|
1393
|
+
* Setup signal to visitor
|
|
1394
|
+
*
|
|
1395
|
+
* @usage
|
|
1396
|
+
* ```ts
|
|
1397
|
+
* await visitor.sendSignalToVisitor(iceServers);
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
sendSignalToVisitor(signal: any): Promise<void | (ResponseType$1 & {
|
|
1401
|
+
answerSignal: any;
|
|
1402
|
+
})>;
|
|
1378
1403
|
}
|
|
1379
1404
|
|
|
1380
1405
|
type VisitorType = {
|
|
@@ -1702,6 +1727,14 @@ interface WebhookInterface {
|
|
|
1702
1727
|
urlSlug: string;
|
|
1703
1728
|
}
|
|
1704
1729
|
|
|
1730
|
+
interface WebRTCConnectorInterface {
|
|
1731
|
+
getTwilioConfig(): Promise<void | ResponseType$1>;
|
|
1732
|
+
}
|
|
1733
|
+
interface WebRTCConnectorOptionalInterface {
|
|
1734
|
+
credentials?: InteractiveCredentials;
|
|
1735
|
+
twilioConfig?: object;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1705
1738
|
interface WorldActivityOptionalInterface {
|
|
1706
1739
|
credentials?: InteractiveCredentials;
|
|
1707
1740
|
}
|
|
@@ -1790,12 +1823,14 @@ declare class Topia implements TopiaInterface {
|
|
|
1790
1823
|
apiProtocol?: string;
|
|
1791
1824
|
interactiveKey?: string;
|
|
1792
1825
|
interactiveSecret?: jwt.Secret;
|
|
1793
|
-
|
|
1826
|
+
mcAuthorizationKey?: string;
|
|
1827
|
+
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, mcAuthorizationKey, }: {
|
|
1794
1828
|
apiDomain?: string;
|
|
1795
1829
|
apiKey?: string;
|
|
1796
1830
|
apiProtocol?: string;
|
|
1797
1831
|
interactiveKey?: string;
|
|
1798
1832
|
interactiveSecret?: jwt.Secret;
|
|
1833
|
+
mcAuthorizationKey?: string;
|
|
1799
1834
|
});
|
|
1800
1835
|
}
|
|
1801
1836
|
|
|
@@ -1861,7 +1896,6 @@ declare abstract class SDKController implements SDKInterface {
|
|
|
1861
1896
|
*/
|
|
1862
1897
|
declare class Asset extends SDKController implements AssetInterface {
|
|
1863
1898
|
readonly id?: string;
|
|
1864
|
-
urlSlug?: string;
|
|
1865
1899
|
constructor(topia: Topia, id: string, options?: AssetOptionalInterface);
|
|
1866
1900
|
/**
|
|
1867
1901
|
* @summary
|
|
@@ -1874,6 +1908,60 @@ declare class Asset extends SDKController implements AssetInterface {
|
|
|
1874
1908
|
* ```
|
|
1875
1909
|
*/
|
|
1876
1910
|
fetchAssetById(): Promise<object | ResponseType$1>;
|
|
1911
|
+
/**
|
|
1912
|
+
* @summary
|
|
1913
|
+
* Updates platform asset details.
|
|
1914
|
+
*
|
|
1915
|
+
* @usage
|
|
1916
|
+
* ```ts
|
|
1917
|
+
* await asset.updateAsset({
|
|
1918
|
+
* assetName: "exampleAsset",
|
|
1919
|
+
* bottomLayerURL: null,
|
|
1920
|
+
* creatorTags: { "decorations": true },
|
|
1921
|
+
* isPublic: true,
|
|
1922
|
+
* shouldUploadImages: true,
|
|
1923
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
1924
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
1925
|
+
* });
|
|
1926
|
+
* const { assetName } = asset;
|
|
1927
|
+
* ```
|
|
1928
|
+
*/
|
|
1929
|
+
updateAsset({ assetName, bottomLayerURL, creatorTags, isPublic, shouldUploadImages, tagJson, topLayerURL, }: {
|
|
1930
|
+
assetName: string;
|
|
1931
|
+
bottomLayerURL?: string;
|
|
1932
|
+
creatorTags: object;
|
|
1933
|
+
isPublic: boolean;
|
|
1934
|
+
shouldUploadImages?: boolean;
|
|
1935
|
+
tagJson: string;
|
|
1936
|
+
topLayerURL?: string;
|
|
1937
|
+
}): Promise<void | ResponseType$1>;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* @summary
|
|
1942
|
+
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
1943
|
+
*
|
|
1944
|
+
* @usage
|
|
1945
|
+
* ```ts
|
|
1946
|
+
* await new WebRTCConnector(topia, {
|
|
1947
|
+
* credentials: { interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
|
|
1948
|
+
* });
|
|
1949
|
+
* ```
|
|
1950
|
+
*/
|
|
1951
|
+
declare class WebRTCConnector extends SDKController implements WebRTCConnectorInterface {
|
|
1952
|
+
twilioConfig?: object | null | undefined;
|
|
1953
|
+
urlSlug: string;
|
|
1954
|
+
constructor(topia: Topia, urlSlug: string, options?: WebRTCConnectorOptionalInterface);
|
|
1955
|
+
/**
|
|
1956
|
+
* @summary
|
|
1957
|
+
* Get twilio
|
|
1958
|
+
*
|
|
1959
|
+
* @usage
|
|
1960
|
+
* ```ts
|
|
1961
|
+
* await webRTCConnector.getTwilioConfig();
|
|
1962
|
+
* ```
|
|
1963
|
+
*/
|
|
1964
|
+
getTwilioConfig(): Promise<void | ResponseType$1>;
|
|
1877
1965
|
}
|
|
1878
1966
|
|
|
1879
1967
|
/**
|
|
@@ -1980,8 +2068,7 @@ declare class WorldActivity extends SDKController {
|
|
|
1980
2068
|
* const Asset = new AssetFactory(myTopiaInstance);
|
|
1981
2069
|
* ```
|
|
1982
2070
|
*/
|
|
1983
|
-
declare class AssetFactory {
|
|
1984
|
-
topia: Topia;
|
|
2071
|
+
declare class AssetFactory extends SDKController {
|
|
1985
2072
|
constructor(topia: Topia);
|
|
1986
2073
|
/**
|
|
1987
2074
|
* @summary
|
|
@@ -1993,6 +2080,24 @@ declare class AssetFactory {
|
|
|
1993
2080
|
* ```
|
|
1994
2081
|
*/
|
|
1995
2082
|
create(id: string, options?: AssetOptionalInterface): Asset;
|
|
2083
|
+
/**
|
|
2084
|
+
* @summary
|
|
2085
|
+
* Upload a new Asset and return a new instance of Asset class.
|
|
2086
|
+
*
|
|
2087
|
+
* @usage
|
|
2088
|
+
* ```
|
|
2089
|
+
* const assetPayload = {
|
|
2090
|
+
* assetName: "exampleAssetName"
|
|
2091
|
+
* bottomLayerURL: "https://example.bottomLayerURL"
|
|
2092
|
+
* creatorTags: { "decorations": true },
|
|
2093
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
2094
|
+
* isPublic: true,
|
|
2095
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
2096
|
+
* }
|
|
2097
|
+
* const asset = await Asset.upload(assetPayload, apiKey);
|
|
2098
|
+
* ```
|
|
2099
|
+
*/
|
|
2100
|
+
upload(assetPayload: AssetType, apiKey: string): Promise<Asset>;
|
|
1996
2101
|
}
|
|
1997
2102
|
|
|
1998
2103
|
/**
|
|
@@ -2163,6 +2268,27 @@ declare class VisitorFactory {
|
|
|
2163
2268
|
get(id: number, urlSlug: string, options?: VisitorOptionalInterface): Promise<Visitor>;
|
|
2164
2269
|
}
|
|
2165
2270
|
|
|
2271
|
+
/**
|
|
2272
|
+
* @usage
|
|
2273
|
+
* ```ts
|
|
2274
|
+
* const WebRTCConnector = new WebRTCConnectorFactory(myTopiaInstance);
|
|
2275
|
+
* ```
|
|
2276
|
+
*/
|
|
2277
|
+
declare class WebRTCConnectorFactory {
|
|
2278
|
+
topia: Topia;
|
|
2279
|
+
constructor(topia: Topia);
|
|
2280
|
+
/**
|
|
2281
|
+
* @summary
|
|
2282
|
+
* Instantiate a new instance of WebRTCConnector class.
|
|
2283
|
+
*
|
|
2284
|
+
* @usage
|
|
2285
|
+
* ```
|
|
2286
|
+
* const userInstance = await WebRTCConnector.create({ credentials: { interactiveNonce, interactivePublicKey, urlSlug, visitorId }, twilioConfig: {} });
|
|
2287
|
+
* ```
|
|
2288
|
+
*/
|
|
2289
|
+
create(urlSlug: string, options?: WebRTCConnectorOptionalInterface): WebRTCConnector;
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2166
2292
|
/**
|
|
2167
2293
|
* @usage
|
|
2168
2294
|
* ```ts
|
|
@@ -2220,4 +2346,4 @@ declare class WorldFactory extends SDKController {
|
|
|
2220
2346
|
}>;
|
|
2221
2347
|
}
|
|
2222
2348
|
|
|
2223
|
-
export { Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetMediaType, DroppedAssetOptionalInterface, DroppedAssetOptions, FireToastInterface, InteractiveCredentials, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, ResponseType$1 as ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
|
|
2349
|
+
export { Asset, AssetFactory, AssetInterface, AssetOptionalInterface, AssetOptions, AssetType, DroppedAsset, DroppedAssetClickType, DroppedAssetFactory, DroppedAssetInterface, DroppedAssetMediaType, DroppedAssetOptionalInterface, DroppedAssetOptions, FireToastInterface, InteractiveCredentials, MoveAllVisitorsInterface, MoveVisitorInterface, OpenIframeInterface, ResponseType$1 as ResponseType, SDKController, SDKInterface, Scene, SceneFactory, SceneInterface, SceneOptionalInterface, Topia, TopiaInterface, UpdateBroadcastInterface, UpdateClickTypeInterface, UpdateMediaTypeInterface, UpdatePrivateZoneInterface, User, UserFactory, UserInterface, UserOptionalInterface, UserOptions, Visitor, VisitorFactory, VisitorInterface, VisitorOptionalInterface, VisitorOptions, VisitorType, VisitorsToMoveArrayType, VisitorsToMoveType, WebRTCConnector, WebRTCConnectorFactory, WebRTCConnectorInterface, WebRTCConnectorOptionalInterface, WebhookInterface, World, WorldActivity, WorldActivityFactory, WorldActivityOptionalInterface, WorldDetailsInterface, WorldFactory, WorldInterface, WorldOptionalInterface, WorldOptions, WorldWebhooksInterface };
|
package/dist/index.js
CHANGED
|
@@ -39635,7 +39635,7 @@ const {
|
|
|
39635
39635
|
*/
|
|
39636
39636
|
class SDKController {
|
|
39637
39637
|
constructor(topia, credentials = {}) {
|
|
39638
|
-
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, } = credentials;
|
|
39638
|
+
const { apiKey = null, assetId = null, interactiveNonce = null, profileId = null, urlSlug = null, visitorId = null, iframeId = null, gameEngineId = null, } = credentials;
|
|
39639
39639
|
this.topia = topia;
|
|
39640
39640
|
this.credentials = credentials;
|
|
39641
39641
|
this.requestOptions = {};
|
|
@@ -39655,6 +39655,12 @@ class SDKController {
|
|
|
39655
39655
|
if (apiKey) {
|
|
39656
39656
|
headers.Authorization = apiKey;
|
|
39657
39657
|
}
|
|
39658
|
+
if (iframeId) {
|
|
39659
|
+
headers.iframeId = iframeId;
|
|
39660
|
+
}
|
|
39661
|
+
if (gameEngineId) {
|
|
39662
|
+
headers.gameEngineId = gameEngineId;
|
|
39663
|
+
}
|
|
39658
39664
|
this.requestOptions = { headers };
|
|
39659
39665
|
}
|
|
39660
39666
|
catch (error) {
|
|
@@ -39715,7 +39721,7 @@ class SDKController {
|
|
|
39715
39721
|
*/
|
|
39716
39722
|
class Asset extends SDKController {
|
|
39717
39723
|
constructor(topia, id, options = { attributes: {}, credentials: {} }) {
|
|
39718
|
-
var _a, _b, _c, _d, _e
|
|
39724
|
+
var _a, _b, _c, _d, _e;
|
|
39719
39725
|
// assetId and urlSlug should only be used when Asset is extended by DroppedAsset
|
|
39720
39726
|
super(topia, {
|
|
39721
39727
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
@@ -39725,7 +39731,6 @@ class Asset extends SDKController {
|
|
|
39725
39731
|
visitorId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.visitorId,
|
|
39726
39732
|
});
|
|
39727
39733
|
this.id = id;
|
|
39728
|
-
this.urlSlug = (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.urlSlug;
|
|
39729
39734
|
Object.assign(this, options.attributes);
|
|
39730
39735
|
}
|
|
39731
39736
|
/**
|
|
@@ -39741,7 +39746,8 @@ class Asset extends SDKController {
|
|
|
39741
39746
|
fetchAssetById() {
|
|
39742
39747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39743
39748
|
try {
|
|
39744
|
-
const response = yield this.topiaPublicApi().get(`/assets/${this.
|
|
39749
|
+
const response = yield this.topiaPublicApi().get(`/assets/${this.id}`, this.requestOptions);
|
|
39750
|
+
Object.assign(this, response.data);
|
|
39745
39751
|
return response.data;
|
|
39746
39752
|
}
|
|
39747
39753
|
catch (error) {
|
|
@@ -39749,6 +39755,44 @@ class Asset extends SDKController {
|
|
|
39749
39755
|
}
|
|
39750
39756
|
});
|
|
39751
39757
|
}
|
|
39758
|
+
/**
|
|
39759
|
+
* @summary
|
|
39760
|
+
* Updates platform asset details.
|
|
39761
|
+
*
|
|
39762
|
+
* @usage
|
|
39763
|
+
* ```ts
|
|
39764
|
+
* await asset.updateAsset({
|
|
39765
|
+
* assetName: "exampleAsset",
|
|
39766
|
+
* bottomLayerURL: null,
|
|
39767
|
+
* creatorTags: { "decorations": true },
|
|
39768
|
+
* isPublic: true,
|
|
39769
|
+
* shouldUploadImages: true,
|
|
39770
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
39771
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
39772
|
+
* });
|
|
39773
|
+
* const { assetName } = asset;
|
|
39774
|
+
* ```
|
|
39775
|
+
*/
|
|
39776
|
+
updateAsset({ assetName, bottomLayerURL, creatorTags, isPublic, shouldUploadImages, tagJson, topLayerURL, }) {
|
|
39777
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39778
|
+
const params = {
|
|
39779
|
+
assetName,
|
|
39780
|
+
bottomLayerURL,
|
|
39781
|
+
creatorTags,
|
|
39782
|
+
isPublic,
|
|
39783
|
+
shouldUploadImages,
|
|
39784
|
+
tagJson,
|
|
39785
|
+
topLayerURL,
|
|
39786
|
+
};
|
|
39787
|
+
try {
|
|
39788
|
+
const response = yield this.topiaPublicApi().put(`/assets/${this.id}`, params, this.requestOptions);
|
|
39789
|
+
Object.assign(this, response.data);
|
|
39790
|
+
}
|
|
39791
|
+
catch (error) {
|
|
39792
|
+
throw this.errorHandler({ error, params, sdkMethod: "Asset.updateAsset" });
|
|
39793
|
+
}
|
|
39794
|
+
});
|
|
39795
|
+
}
|
|
39752
39796
|
}
|
|
39753
39797
|
|
|
39754
39798
|
var _DroppedAsset_updateDroppedAsset;
|
|
@@ -40393,6 +40437,44 @@ const scatterVisitors = (original, scatterBy) => {
|
|
|
40393
40437
|
return Math.floor(Math.random() * (max - min) + min);
|
|
40394
40438
|
};
|
|
40395
40439
|
|
|
40440
|
+
/**
|
|
40441
|
+
* @summary
|
|
40442
|
+
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
40443
|
+
*
|
|
40444
|
+
* @usage
|
|
40445
|
+
* ```ts
|
|
40446
|
+
* const topia = await new Topia({
|
|
40447
|
+
* apiDomain: "api.topia.io",
|
|
40448
|
+
* apiKey: "exampleKey",
|
|
40449
|
+
* interactiveKey: "key",
|
|
40450
|
+
* interactiveSecret: "secret",
|
|
40451
|
+
* });
|
|
40452
|
+
* ```
|
|
40453
|
+
*/
|
|
40454
|
+
class Topia {
|
|
40455
|
+
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, mcAuthorizationKey, }) {
|
|
40456
|
+
getBrowserWarning();
|
|
40457
|
+
this.apiDomain = apiDomain || "api.topia.io";
|
|
40458
|
+
this.apiKey = apiKey;
|
|
40459
|
+
this.apiProtocol = apiProtocol || "https";
|
|
40460
|
+
this.interactiveSecret = interactiveSecret;
|
|
40461
|
+
const headers = {
|
|
40462
|
+
"ApplicationId": "sdk-js-topia",
|
|
40463
|
+
"Content-Type": "application/json",
|
|
40464
|
+
};
|
|
40465
|
+
if (apiKey)
|
|
40466
|
+
headers.Authorization = apiKey;
|
|
40467
|
+
if (interactiveKey)
|
|
40468
|
+
headers.PublicKey = interactiveKey;
|
|
40469
|
+
if (mcAuthorizationKey)
|
|
40470
|
+
headers.MCAuthorizationKey = mcAuthorizationKey;
|
|
40471
|
+
this.axios = axios.create({
|
|
40472
|
+
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
40473
|
+
headers,
|
|
40474
|
+
});
|
|
40475
|
+
}
|
|
40476
|
+
}
|
|
40477
|
+
|
|
40396
40478
|
var _World_droppedAssetsMap;
|
|
40397
40479
|
/**
|
|
40398
40480
|
* @summary
|
|
@@ -40920,6 +41002,7 @@ class World extends SDKController {
|
|
|
40920
41002
|
* ```
|
|
40921
41003
|
*/
|
|
40922
41004
|
triggerParticle({ id, name, duration = 10, position = { x: 1, y: 1 }, }) {
|
|
41005
|
+
var _a;
|
|
40923
41006
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40924
41007
|
if (!id && !name)
|
|
40925
41008
|
throw "A particle name is required.";
|
|
@@ -40927,8 +41010,10 @@ class World extends SDKController {
|
|
|
40927
41010
|
let particleId = id;
|
|
40928
41011
|
if (name) {
|
|
40929
41012
|
const response = yield this.topiaPublicApi().get(`/particles?name=${name}`, this.requestOptions);
|
|
40930
|
-
particleId = response.data[0].id;
|
|
41013
|
+
particleId = (_a = response === null || response === void 0 ? void 0 : response.data[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
40931
41014
|
}
|
|
41015
|
+
if (!particleId)
|
|
41016
|
+
return "No particleId found.";
|
|
40932
41017
|
const result = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/particles`, { particleId, position, duration }, this.requestOptions);
|
|
40933
41018
|
return result;
|
|
40934
41019
|
}
|
|
@@ -41045,13 +41130,15 @@ var _User_adminWorldsMap, _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
41045
41130
|
*/
|
|
41046
41131
|
class User extends SDKController {
|
|
41047
41132
|
constructor(topia, options = { profileId: null, credentials: {} }) {
|
|
41048
|
-
var _a, _b, _c, _d;
|
|
41133
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41049
41134
|
super(topia, {
|
|
41050
41135
|
apiKey: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.apiKey,
|
|
41051
41136
|
interactiveNonce: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.interactiveNonce,
|
|
41052
41137
|
profileId: options === null || options === void 0 ? void 0 : options.profileId,
|
|
41053
41138
|
urlSlug: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.urlSlug,
|
|
41054
41139
|
visitorId: (_d = options === null || options === void 0 ? void 0 : options.credentials) === null || _d === void 0 ? void 0 : _d.visitorId,
|
|
41140
|
+
iframeId: (_e = options === null || options === void 0 ? void 0 : options.credentials) === null || _e === void 0 ? void 0 : _e.iframeId,
|
|
41141
|
+
gameEngineId: (_f = options === null || options === void 0 ? void 0 : options.credentials) === null || _f === void 0 ? void 0 : _f.gameEngineId,
|
|
41055
41142
|
});
|
|
41056
41143
|
_User_adminWorldsMap.set(this, void 0);
|
|
41057
41144
|
_User_assetsMap.set(this, void 0);
|
|
@@ -41817,6 +41904,7 @@ class Visitor extends User {
|
|
|
41817
41904
|
* ```
|
|
41818
41905
|
*/
|
|
41819
41906
|
triggerParticle({ id, name, duration = 10, }) {
|
|
41907
|
+
var _a;
|
|
41820
41908
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41821
41909
|
if (!id && !name)
|
|
41822
41910
|
throw "A particle name is required.";
|
|
@@ -41824,8 +41912,10 @@ class Visitor extends User {
|
|
|
41824
41912
|
let particleId = id;
|
|
41825
41913
|
if (name) {
|
|
41826
41914
|
const response = yield this.topiaPublicApi().get(`/particles?name=${name}`, this.requestOptions);
|
|
41827
|
-
particleId = response.data[0].id;
|
|
41915
|
+
particleId = (_a = response === null || response === void 0 ? void 0 : response.data[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
41828
41916
|
}
|
|
41917
|
+
if (!particleId)
|
|
41918
|
+
return "No particleId found.";
|
|
41829
41919
|
const result = yield this.topiaPublicApi().post(`/world/${this.urlSlug}/particles`, { particleId, position: { x: 1, y: 1 }, duration, followPlayerId: this.id }, this.requestOptions);
|
|
41830
41920
|
return result;
|
|
41831
41921
|
}
|
|
@@ -41951,6 +42041,75 @@ class Visitor extends User {
|
|
|
41951
42041
|
}
|
|
41952
42042
|
});
|
|
41953
42043
|
}
|
|
42044
|
+
/**
|
|
42045
|
+
* @summary
|
|
42046
|
+
* Setup signal to visitor
|
|
42047
|
+
*
|
|
42048
|
+
* @usage
|
|
42049
|
+
* ```ts
|
|
42050
|
+
* await visitor.sendSignalToVisitor(iceServers);
|
|
42051
|
+
* ```
|
|
42052
|
+
*/
|
|
42053
|
+
sendSignalToVisitor(signal) {
|
|
42054
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42055
|
+
try {
|
|
42056
|
+
const response = yield this.topiaPublicApi().put(`/world/${this.urlSlug}/visitors/${this.id}/send-signal-to-visitor`, { signal }, this.requestOptions);
|
|
42057
|
+
return response.data;
|
|
42058
|
+
}
|
|
42059
|
+
catch (error) {
|
|
42060
|
+
throw this.errorHandler({
|
|
42061
|
+
error,
|
|
42062
|
+
params: { signal },
|
|
42063
|
+
sdkMethod: "Visitor.sendSignalToVisitor",
|
|
42064
|
+
});
|
|
42065
|
+
}
|
|
42066
|
+
});
|
|
42067
|
+
}
|
|
42068
|
+
}
|
|
42069
|
+
|
|
42070
|
+
/**
|
|
42071
|
+
* @summary
|
|
42072
|
+
* Create an instance of WebRTCConnector class with optional session credentials.
|
|
42073
|
+
*
|
|
42074
|
+
* @usage
|
|
42075
|
+
* ```ts
|
|
42076
|
+
* await new WebRTCConnector(topia, {
|
|
42077
|
+
* credentials: { interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
|
|
42078
|
+
* });
|
|
42079
|
+
* ```
|
|
42080
|
+
*/
|
|
42081
|
+
class WebRTCConnector extends SDKController {
|
|
42082
|
+
constructor(topia, urlSlug, options = { twilioConfig: {}, credentials: {} }) {
|
|
42083
|
+
var _a, _b, _c;
|
|
42084
|
+
super(topia, {
|
|
42085
|
+
interactiveNonce: (_a = options === null || options === void 0 ? void 0 : options.credentials) === null || _a === void 0 ? void 0 : _a.interactiveNonce,
|
|
42086
|
+
urlSlug: (_b = options === null || options === void 0 ? void 0 : options.credentials) === null || _b === void 0 ? void 0 : _b.urlSlug,
|
|
42087
|
+
visitorId: (_c = options === null || options === void 0 ? void 0 : options.credentials) === null || _c === void 0 ? void 0 : _c.visitorId,
|
|
42088
|
+
});
|
|
42089
|
+
this.twilioConfig = options === null || options === void 0 ? void 0 : options.twilioConfig;
|
|
42090
|
+
this.urlSlug = urlSlug;
|
|
42091
|
+
}
|
|
42092
|
+
/**
|
|
42093
|
+
* @summary
|
|
42094
|
+
* Get twilio
|
|
42095
|
+
*
|
|
42096
|
+
* @usage
|
|
42097
|
+
* ```ts
|
|
42098
|
+
* await webRTCConnector.getTwilioConfig();
|
|
42099
|
+
* ```
|
|
42100
|
+
*/
|
|
42101
|
+
getTwilioConfig() {
|
|
42102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42103
|
+
try {
|
|
42104
|
+
const response = yield this.topiaPublicApi().get(`/webrtc/twilio-config`, this.requestOptions);
|
|
42105
|
+
this.twilioConfig = response.data.twilioConfig;
|
|
42106
|
+
return response.data;
|
|
42107
|
+
}
|
|
42108
|
+
catch (error) {
|
|
42109
|
+
throw this.errorHandler({ error, sdkMethod: "WebRTCConnector.getTwilioConfig" });
|
|
42110
|
+
}
|
|
42111
|
+
});
|
|
42112
|
+
}
|
|
41954
42113
|
}
|
|
41955
42114
|
|
|
41956
42115
|
var _WorldActivity_visitorsMap;
|
|
@@ -42130,52 +42289,15 @@ class WorldActivity extends SDKController {
|
|
|
42130
42289
|
}
|
|
42131
42290
|
_WorldActivity_visitorsMap = new WeakMap();
|
|
42132
42291
|
|
|
42133
|
-
/**
|
|
42134
|
-
* @summary
|
|
42135
|
-
* Create a single instance of Topia axios used for all calls to the public API in all classes
|
|
42136
|
-
*
|
|
42137
|
-
* @usage
|
|
42138
|
-
* ```ts
|
|
42139
|
-
* const topia = await new Topia({
|
|
42140
|
-
* apiDomain: "api.topia.io",
|
|
42141
|
-
* apiKey: "exampleKey",
|
|
42142
|
-
* interactiveKey: "key",
|
|
42143
|
-
* interactiveSecret: "secret",
|
|
42144
|
-
* });
|
|
42145
|
-
* ```
|
|
42146
|
-
*/
|
|
42147
|
-
class Topia {
|
|
42148
|
-
constructor({ apiDomain, apiKey, apiProtocol, interactiveKey, interactiveSecret, }) {
|
|
42149
|
-
getBrowserWarning();
|
|
42150
|
-
this.apiDomain = apiDomain || "api.topia.io";
|
|
42151
|
-
this.apiKey = apiKey;
|
|
42152
|
-
this.apiProtocol = apiProtocol || "https";
|
|
42153
|
-
this.interactiveSecret = interactiveSecret;
|
|
42154
|
-
const headers = {
|
|
42155
|
-
"ApplicationId": "sdk-js-topia",
|
|
42156
|
-
"Content-Type": "application/json",
|
|
42157
|
-
};
|
|
42158
|
-
if (apiKey)
|
|
42159
|
-
headers.Authorization = apiKey;
|
|
42160
|
-
if (interactiveKey)
|
|
42161
|
-
headers.PublicKey = interactiveKey;
|
|
42162
|
-
this.axios = axios.create({
|
|
42163
|
-
baseURL: `${this.apiProtocol}://${this.apiDomain}/api/v1`,
|
|
42164
|
-
headers,
|
|
42165
|
-
});
|
|
42166
|
-
}
|
|
42167
|
-
}
|
|
42168
|
-
|
|
42169
42292
|
/**
|
|
42170
42293
|
* @usage
|
|
42171
42294
|
* ```ts
|
|
42172
42295
|
* const Asset = new AssetFactory(myTopiaInstance);
|
|
42173
42296
|
* ```
|
|
42174
42297
|
*/
|
|
42175
|
-
class AssetFactory {
|
|
42298
|
+
class AssetFactory extends SDKController {
|
|
42176
42299
|
constructor(topia) {
|
|
42177
|
-
|
|
42178
|
-
this.create;
|
|
42300
|
+
super(topia);
|
|
42179
42301
|
}
|
|
42180
42302
|
/**
|
|
42181
42303
|
* @summary
|
|
@@ -42189,6 +42311,38 @@ class AssetFactory {
|
|
|
42189
42311
|
create(id, options) {
|
|
42190
42312
|
return new Asset(this.topia, id, options);
|
|
42191
42313
|
}
|
|
42314
|
+
/**
|
|
42315
|
+
* @summary
|
|
42316
|
+
* Upload a new Asset and return a new instance of Asset class.
|
|
42317
|
+
*
|
|
42318
|
+
* @usage
|
|
42319
|
+
* ```
|
|
42320
|
+
* const assetPayload = {
|
|
42321
|
+
* assetName: "exampleAssetName"
|
|
42322
|
+
* bottomLayerURL: "https://example.bottomLayerURL"
|
|
42323
|
+
* creatorTags: { "decorations": true },
|
|
42324
|
+
* tagJson: "[{"label":"decorations","value":"decorations"}]",
|
|
42325
|
+
* isPublic: true,
|
|
42326
|
+
* topLayerURL: "https://example.topLayerURL"
|
|
42327
|
+
* }
|
|
42328
|
+
* const asset = await Asset.upload(assetPayload, apiKey);
|
|
42329
|
+
* ```
|
|
42330
|
+
*/
|
|
42331
|
+
upload(assetPayload, apiKey) {
|
|
42332
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42333
|
+
try {
|
|
42334
|
+
if (!apiKey)
|
|
42335
|
+
throw "A valid API Key is required.";
|
|
42336
|
+
const headers = { Authorization: apiKey };
|
|
42337
|
+
const response = yield this.topiaPublicApi().post("/assets", assetPayload, { headers });
|
|
42338
|
+
const { assetId, asset } = response.data;
|
|
42339
|
+
return new Asset(this.topia, assetId, { attributes: asset });
|
|
42340
|
+
}
|
|
42341
|
+
catch (error) {
|
|
42342
|
+
throw this.errorHandler({ error, params: assetPayload, sdkMethod: "AssetFactory.upload" });
|
|
42343
|
+
}
|
|
42344
|
+
});
|
|
42345
|
+
}
|
|
42192
42346
|
}
|
|
42193
42347
|
|
|
42194
42348
|
/**
|
|
@@ -42423,6 +42577,30 @@ class VisitorFactory {
|
|
|
42423
42577
|
}
|
|
42424
42578
|
}
|
|
42425
42579
|
|
|
42580
|
+
/**
|
|
42581
|
+
* @usage
|
|
42582
|
+
* ```ts
|
|
42583
|
+
* const WebRTCConnector = new WebRTCConnectorFactory(myTopiaInstance);
|
|
42584
|
+
* ```
|
|
42585
|
+
*/
|
|
42586
|
+
class WebRTCConnectorFactory {
|
|
42587
|
+
constructor(topia) {
|
|
42588
|
+
this.topia = topia;
|
|
42589
|
+
}
|
|
42590
|
+
/**
|
|
42591
|
+
* @summary
|
|
42592
|
+
* Instantiate a new instance of WebRTCConnector class.
|
|
42593
|
+
*
|
|
42594
|
+
* @usage
|
|
42595
|
+
* ```
|
|
42596
|
+
* const userInstance = await WebRTCConnector.create({ credentials: { interactiveNonce, interactivePublicKey, urlSlug, visitorId }, twilioConfig: {} });
|
|
42597
|
+
* ```
|
|
42598
|
+
*/
|
|
42599
|
+
create(urlSlug, options) {
|
|
42600
|
+
return new WebRTCConnector(this.topia, urlSlug, options);
|
|
42601
|
+
}
|
|
42602
|
+
}
|
|
42603
|
+
|
|
42426
42604
|
/**
|
|
42427
42605
|
* @usage
|
|
42428
42606
|
* ```ts
|
|
@@ -42527,4 +42705,4 @@ process.on("uncaughtException", function (err) {
|
|
|
42527
42705
|
process.exit(1);
|
|
42528
42706
|
});
|
|
42529
42707
|
|
|
42530
|
-
export { Asset, AssetFactory, DroppedAsset, DroppedAssetFactory, SDKController, Scene, SceneFactory, Topia, User, UserFactory, Visitor, VisitorFactory, World, WorldActivity, WorldActivityFactory, WorldFactory };
|
|
42708
|
+
export { Asset, AssetFactory, DroppedAsset, DroppedAssetFactory, SDKController, Scene, SceneFactory, Topia, User, UserFactory, Visitor, VisitorFactory, WebRTCConnector, WebRTCConnectorFactory, World, WorldActivity, WorldActivityFactory, WorldFactory };
|
package/package.json
CHANGED
|
@@ -56,8 +56,9 @@
|
|
|
56
56
|
"lint": "eslint \"src/**\"",
|
|
57
57
|
"docs": "typedoc",
|
|
58
58
|
"pkg": "yarn && yarn build && yarn docs && npm publish",
|
|
59
|
-
"
|
|
59
|
+
"yalc-publish": "yarn build && yalc publish",
|
|
60
|
+
"yalc-push": "yarn build && yalc publish --push --dev --no-scripts"
|
|
60
61
|
},
|
|
61
62
|
"type": "module",
|
|
62
|
-
"version": "0.
|
|
63
|
+
"version": "0.12.00"
|
|
63
64
|
}
|