@rtsdk/topia 0.0.26 → 0.0.28
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.cjs +9 -4
- package/dist/index.js +9 -4
- package/dist/src/__mocks__/visitors.js +3 -3
- package/dist/src/controllers/SDKController.js +1 -1
- package/dist/src/controllers/User.js +1 -1
- package/dist/src/controllers/Visitor.js +4 -1
- package/dist/src/controllers/World.js +2 -0
- package/dist/src/controllers/WorldActivity.js +2 -1
- package/dist/src/controllers/__tests__/asset.test.js +1 -0
- package/dist/src/controllers/__tests__/droppedAsset.test.js +1 -0
- package/dist/src/controllers/__tests__/scene.test.js +1 -0
- package/dist/src/controllers/__tests__/user.test.js +2 -1
- package/dist/src/controllers/__tests__/visitor.test.js +2 -1
- package/dist/src/controllers/__tests__/world.test.js +1 -0
- package/dist/src/controllers/__tests__/worldActivity.test.js +3 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39737,7 +39737,7 @@ const {
|
|
|
39737
39737
|
* assetId: "exampleAsset",
|
|
39738
39738
|
* interactiveNonce: "exampleNonce"
|
|
39739
39739
|
* interactivePublicKey: "examplePublicKey",
|
|
39740
|
-
*
|
|
39740
|
+
* visitorId: 1,
|
|
39741
39741
|
* url: "https://topia.io",
|
|
39742
39742
|
* }
|
|
39743
39743
|
* const topia = await new Topia({
|
|
@@ -40417,6 +40417,7 @@ class World extends SDKController {
|
|
|
40417
40417
|
// tempDroppedAssetsMap[id] = createDroppedAsset(this.apiKey, response.data[id], this.urlSlug);
|
|
40418
40418
|
tempDroppedAssetsMap[index] = new DroppedAsset(this.topia, response.data[index].id, this.urlSlug, {
|
|
40419
40419
|
attributes: response.data[index],
|
|
40420
|
+
credentials: this.credentials,
|
|
40420
40421
|
});
|
|
40421
40422
|
}
|
|
40422
40423
|
__classPrivateFieldSet(this, _World_droppedAssetsMap, tempDroppedAssetsMap, "f");
|
|
@@ -40445,6 +40446,7 @@ class World extends SDKController {
|
|
|
40445
40446
|
for (const asset of response.data.assets) {
|
|
40446
40447
|
droppedAssets.push(new DroppedAsset(this.topia, asset.id, this.urlSlug, {
|
|
40447
40448
|
attributes: asset,
|
|
40449
|
+
credentials: this.credentials,
|
|
40448
40450
|
}));
|
|
40449
40451
|
}
|
|
40450
40452
|
return droppedAssets;
|
|
@@ -40547,7 +40549,7 @@ var _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
40547
40549
|
*
|
|
40548
40550
|
* @usage
|
|
40549
40551
|
* ```ts
|
|
40550
|
-
* await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey",
|
|
40552
|
+
* await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", visitorId: 1 });
|
|
40551
40553
|
* ```
|
|
40552
40554
|
*/
|
|
40553
40555
|
class User extends SDKController {
|
|
@@ -40684,9 +40686,12 @@ class Visitor extends User {
|
|
|
40684
40686
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40685
40687
|
try {
|
|
40686
40688
|
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
|
|
40687
|
-
if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.
|
|
40689
|
+
if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.visitorId) === this.id) {
|
|
40688
40690
|
Object.assign(this, response.data);
|
|
40689
40691
|
}
|
|
40692
|
+
else if (response.data[this.id]) {
|
|
40693
|
+
Object.assign(this, response.data[this.id]);
|
|
40694
|
+
}
|
|
40690
40695
|
else {
|
|
40691
40696
|
throw "This visitor is not active";
|
|
40692
40697
|
}
|
|
@@ -40760,7 +40765,7 @@ class WorldActivity extends SDKController {
|
|
|
40760
40765
|
// create temp map and then update private property only once
|
|
40761
40766
|
const tempVisitorsMap = {};
|
|
40762
40767
|
for (const id in response.data) {
|
|
40763
|
-
tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].
|
|
40768
|
+
tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].visitorId, this.urlSlug, {
|
|
40764
40769
|
attributes: response.data[id],
|
|
40765
40770
|
});
|
|
40766
40771
|
}
|
package/dist/index.js
CHANGED
|
@@ -39735,7 +39735,7 @@ const {
|
|
|
39735
39735
|
* assetId: "exampleAsset",
|
|
39736
39736
|
* interactiveNonce: "exampleNonce"
|
|
39737
39737
|
* interactivePublicKey: "examplePublicKey",
|
|
39738
|
-
*
|
|
39738
|
+
* visitorId: 1,
|
|
39739
39739
|
* url: "https://topia.io",
|
|
39740
39740
|
* }
|
|
39741
39741
|
* const topia = await new Topia({
|
|
@@ -40415,6 +40415,7 @@ class World extends SDKController {
|
|
|
40415
40415
|
// tempDroppedAssetsMap[id] = createDroppedAsset(this.apiKey, response.data[id], this.urlSlug);
|
|
40416
40416
|
tempDroppedAssetsMap[index] = new DroppedAsset(this.topia, response.data[index].id, this.urlSlug, {
|
|
40417
40417
|
attributes: response.data[index],
|
|
40418
|
+
credentials: this.credentials,
|
|
40418
40419
|
});
|
|
40419
40420
|
}
|
|
40420
40421
|
__classPrivateFieldSet(this, _World_droppedAssetsMap, tempDroppedAssetsMap, "f");
|
|
@@ -40443,6 +40444,7 @@ class World extends SDKController {
|
|
|
40443
40444
|
for (const asset of response.data.assets) {
|
|
40444
40445
|
droppedAssets.push(new DroppedAsset(this.topia, asset.id, this.urlSlug, {
|
|
40445
40446
|
attributes: asset,
|
|
40447
|
+
credentials: this.credentials,
|
|
40446
40448
|
}));
|
|
40447
40449
|
}
|
|
40448
40450
|
return droppedAssets;
|
|
@@ -40545,7 +40547,7 @@ var _User_assetsMap, _User_scenesMap, _User_worldsMap;
|
|
|
40545
40547
|
*
|
|
40546
40548
|
* @usage
|
|
40547
40549
|
* ```ts
|
|
40548
|
-
* await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey",
|
|
40550
|
+
* await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", visitorId: 1 });
|
|
40549
40551
|
* ```
|
|
40550
40552
|
*/
|
|
40551
40553
|
class User extends SDKController {
|
|
@@ -40682,9 +40684,12 @@ class Visitor extends User {
|
|
|
40682
40684
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40683
40685
|
try {
|
|
40684
40686
|
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
|
|
40685
|
-
if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.
|
|
40687
|
+
if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.visitorId) === this.id) {
|
|
40686
40688
|
Object.assign(this, response.data);
|
|
40687
40689
|
}
|
|
40690
|
+
else if (response.data[this.id]) {
|
|
40691
|
+
Object.assign(this, response.data[this.id]);
|
|
40692
|
+
}
|
|
40688
40693
|
else {
|
|
40689
40694
|
throw "This visitor is not active";
|
|
40690
40695
|
}
|
|
@@ -40758,7 +40763,7 @@ class WorldActivity extends SDKController {
|
|
|
40758
40763
|
// create temp map and then update private property only once
|
|
40759
40764
|
const tempVisitorsMap = {};
|
|
40760
40765
|
for (const id in response.data) {
|
|
40761
|
-
tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].
|
|
40766
|
+
tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].visitorId, this.urlSlug, {
|
|
40762
40767
|
attributes: response.data[id],
|
|
40763
40768
|
});
|
|
40764
40769
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const visitor = {
|
|
2
|
-
|
|
2
|
+
visitorId: 1,
|
|
3
3
|
color: "0x7AD3BA",
|
|
4
4
|
moveTo: {
|
|
5
5
|
x: -1458,
|
|
@@ -27,7 +27,7 @@ export const visitor = {
|
|
|
27
27
|
};
|
|
28
28
|
export const visitors = {
|
|
29
29
|
"1": {
|
|
30
|
-
|
|
30
|
+
visitorId: 1,
|
|
31
31
|
color: "0x7AD3BA",
|
|
32
32
|
moveTo: {
|
|
33
33
|
x: -1458,
|
|
@@ -54,7 +54,7 @@ export const visitors = {
|
|
|
54
54
|
isRecordingBot: false,
|
|
55
55
|
},
|
|
56
56
|
"2": {
|
|
57
|
-
|
|
57
|
+
visitorId: 2,
|
|
58
58
|
color: "0xA0D2A7",
|
|
59
59
|
moveTo: {
|
|
60
60
|
x: -1504,
|
|
@@ -11,7 +11,7 @@ import { AxiosError } from "axios";
|
|
|
11
11
|
* assetId: "exampleAsset",
|
|
12
12
|
* interactiveNonce: "exampleNonce"
|
|
13
13
|
* interactivePublicKey: "examplePublicKey",
|
|
14
|
-
*
|
|
14
|
+
* visitorId: 1,
|
|
15
15
|
* url: "https://topia.io",
|
|
16
16
|
* }
|
|
17
17
|
* const topia = await new Topia({
|
|
@@ -30,7 +30,7 @@ import { World } from "controllers/World";
|
|
|
30
30
|
*
|
|
31
31
|
* @usage
|
|
32
32
|
* ```ts
|
|
33
|
-
* await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey",
|
|
33
|
+
* await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", visitorId: 1 });
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
export class User extends SDKController {
|
|
@@ -41,9 +41,12 @@ export class Visitor extends User {
|
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
try {
|
|
43
43
|
const response = yield this.topiaPublicApi().get(`/world/${this.urlSlug}/visitors/${this.id}`, this.requestOptions);
|
|
44
|
-
if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.
|
|
44
|
+
if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.visitorId) === this.id) {
|
|
45
45
|
Object.assign(this, response.data);
|
|
46
46
|
}
|
|
47
|
+
else if (response.data[this.id]) {
|
|
48
|
+
Object.assign(this, response.data[this.id]);
|
|
49
|
+
}
|
|
47
50
|
else {
|
|
48
51
|
throw "This visitor is not active";
|
|
49
52
|
}
|
|
@@ -130,6 +130,7 @@ export class World extends SDKController {
|
|
|
130
130
|
// tempDroppedAssetsMap[id] = createDroppedAsset(this.apiKey, response.data[id], this.urlSlug);
|
|
131
131
|
tempDroppedAssetsMap[index] = new DroppedAsset(this.topia, response.data[index].id, this.urlSlug, {
|
|
132
132
|
attributes: response.data[index],
|
|
133
|
+
credentials: this.credentials,
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
136
|
__classPrivateFieldSet(this, _World_droppedAssetsMap, tempDroppedAssetsMap, "f");
|
|
@@ -158,6 +159,7 @@ export class World extends SDKController {
|
|
|
158
159
|
for (const asset of response.data.assets) {
|
|
159
160
|
droppedAssets.push(new DroppedAsset(this.topia, asset.id, this.urlSlug, {
|
|
160
161
|
attributes: asset,
|
|
162
|
+
credentials: this.credentials,
|
|
161
163
|
}));
|
|
162
164
|
}
|
|
163
165
|
return droppedAssets;
|
|
@@ -19,6 +19,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
19
19
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
20
|
};
|
|
21
21
|
var _WorldActivity_visitorsMap;
|
|
22
|
+
// controllers
|
|
22
23
|
import { SDKController } from "controllers/SDKController";
|
|
23
24
|
import { Visitor } from "controllers/Visitor";
|
|
24
25
|
// utils
|
|
@@ -52,7 +53,7 @@ export class WorldActivity extends SDKController {
|
|
|
52
53
|
// create temp map and then update private property only once
|
|
53
54
|
const tempVisitorsMap = {};
|
|
54
55
|
for (const id in response.data) {
|
|
55
|
-
tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].
|
|
56
|
+
tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].visitorId, this.urlSlug, {
|
|
56
57
|
attributes: response.data[id],
|
|
57
58
|
});
|
|
58
59
|
}
|
|
@@ -11,13 +11,14 @@ import MockAdapter from "axios-mock-adapter";
|
|
|
11
11
|
import { droppedAssets, scenes, worlds } from "__mocks__";
|
|
12
12
|
import { Topia } from "controllers";
|
|
13
13
|
import { UserFactory } from "factories";
|
|
14
|
-
const apiDomain = "api.topia.io";
|
|
14
|
+
const apiDomain = "api-stage.topia.io";
|
|
15
15
|
describe("User Class", () => {
|
|
16
16
|
let mock, testUser, topia, User;
|
|
17
17
|
beforeEach(() => {
|
|
18
18
|
topia = new Topia({
|
|
19
19
|
apiDomain,
|
|
20
20
|
apiKey: "key",
|
|
21
|
+
apiProtocol: "https",
|
|
21
22
|
});
|
|
22
23
|
mock = new MockAdapter(topia.axios);
|
|
23
24
|
User = new UserFactory(topia);
|
|
@@ -12,7 +12,7 @@ import { visitor } from "__mocks__";
|
|
|
12
12
|
import { Topia } from "controllers";
|
|
13
13
|
import { VisitorFactory } from "factories";
|
|
14
14
|
const apiDomain = "api.topia.io";
|
|
15
|
-
const id = visitor.
|
|
15
|
+
const id = visitor.visitorId;
|
|
16
16
|
const urlSlug = "exampleWorld";
|
|
17
17
|
describe("Visitor Class", () => {
|
|
18
18
|
let mock, testVisitor, topia, Visitor;
|
|
@@ -20,6 +20,7 @@ describe("Visitor Class", () => {
|
|
|
20
20
|
topia = new Topia({
|
|
21
21
|
apiDomain,
|
|
22
22
|
apiKey: "key",
|
|
23
|
+
apiProtocol: "https",
|
|
23
24
|
});
|
|
24
25
|
mock = new MockAdapter(topia.axios);
|
|
25
26
|
Visitor = new VisitorFactory(topia);
|
|
@@ -19,6 +19,7 @@ describe("WorldActivity Class", () => {
|
|
|
19
19
|
topia = new Topia({
|
|
20
20
|
apiDomain: "api.topia.io",
|
|
21
21
|
apiKey: "key",
|
|
22
|
+
apiProtocol: "https",
|
|
22
23
|
});
|
|
23
24
|
mock = new MockAdapter(topia.axios);
|
|
24
25
|
WorldActivity = new WorldActivityFactory(topia);
|
|
@@ -50,8 +51,8 @@ describe("WorldActivity Class", () => {
|
|
|
50
51
|
it("should move a list of visitors to uniquely specified coordinates", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
52
|
mock.onPut(`${BASE_URL}/visitors/1/move`).reply(200);
|
|
52
53
|
mock.onPut(`${BASE_URL}/visitors/2/move`).reply(200);
|
|
53
|
-
const v1 = new Visitor(topia, visitors["1"].
|
|
54
|
-
const v2 = new Visitor(topia, visitors["2"].
|
|
54
|
+
const v1 = new Visitor(topia, visitors["1"].visitorId, urlSlug, { attributes: visitors["1"] });
|
|
55
|
+
const v2 = new Visitor(topia, visitors["2"].visitorId, urlSlug, { attributes: visitors["2"] });
|
|
55
56
|
const testVisitors = [
|
|
56
57
|
{ visitorObj: v1, shouldTeleportVisitor: true, x: 0, y: 0 },
|
|
57
58
|
{ visitorObj: v2, shouldTeleportVisitor: false, x: 100, y: 100 },
|
package/package.json
CHANGED