@rtsdk/topia 0.0.26 → 0.0.27

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 CHANGED
@@ -39737,7 +39737,7 @@ const {
39737
39737
  * assetId: "exampleAsset",
39738
39738
  * interactiveNonce: "exampleNonce"
39739
39739
  * interactivePublicKey: "examplePublicKey",
39740
- * playerId: 1,
39740
+ * visitorId: 1,
39741
39741
  * url: "https://topia.io",
39742
39742
  * }
39743
39743
  * const topia = await new Topia({
@@ -40547,7 +40547,7 @@ var _User_assetsMap, _User_scenesMap, _User_worldsMap;
40547
40547
  *
40548
40548
  * @usage
40549
40549
  * ```ts
40550
- * await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", playerId: 1 });
40550
+ * await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", visitorId: 1 });
40551
40551
  * ```
40552
40552
  */
40553
40553
  class User extends SDKController {
@@ -40684,9 +40684,12 @@ class Visitor extends User {
40684
40684
  return __awaiter(this, void 0, void 0, function* () {
40685
40685
  try {
40686
40686
  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.playerId) === this.id) {
40687
+ if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.visitorId) === this.id) {
40688
40688
  Object.assign(this, response.data);
40689
40689
  }
40690
+ else if (response.data[this.id]) {
40691
+ Object.assign(this, response.data[this.id]);
40692
+ }
40690
40693
  else {
40691
40694
  throw "This visitor is not active";
40692
40695
  }
@@ -40760,7 +40763,7 @@ class WorldActivity extends SDKController {
40760
40763
  // create temp map and then update private property only once
40761
40764
  const tempVisitorsMap = {};
40762
40765
  for (const id in response.data) {
40763
- tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].playerId, this.urlSlug, {
40766
+ tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].visitorId, this.urlSlug, {
40764
40767
  attributes: response.data[id],
40765
40768
  });
40766
40769
  }
package/dist/index.js CHANGED
@@ -39735,7 +39735,7 @@ const {
39735
39735
  * assetId: "exampleAsset",
39736
39736
  * interactiveNonce: "exampleNonce"
39737
39737
  * interactivePublicKey: "examplePublicKey",
39738
- * playerId: 1,
39738
+ * visitorId: 1,
39739
39739
  * url: "https://topia.io",
39740
39740
  * }
39741
39741
  * const topia = await new Topia({
@@ -40545,7 +40545,7 @@ var _User_assetsMap, _User_scenesMap, _User_worldsMap;
40545
40545
  *
40546
40546
  * @usage
40547
40547
  * ```ts
40548
- * await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", playerId: 1 });
40548
+ * await new User(topia, { interactiveNonce: "exampleNonce", interactivePublicKey: "examplePublicKey", visitorId: 1 });
40549
40549
  * ```
40550
40550
  */
40551
40551
  class User extends SDKController {
@@ -40682,9 +40682,12 @@ class Visitor extends User {
40682
40682
  return __awaiter(this, void 0, void 0, function* () {
40683
40683
  try {
40684
40684
  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.playerId) === this.id) {
40685
+ if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.visitorId) === this.id) {
40686
40686
  Object.assign(this, response.data);
40687
40687
  }
40688
+ else if (response.data[this.id]) {
40689
+ Object.assign(this, response.data[this.id]);
40690
+ }
40688
40691
  else {
40689
40692
  throw "This visitor is not active";
40690
40693
  }
@@ -40758,7 +40761,7 @@ class WorldActivity extends SDKController {
40758
40761
  // create temp map and then update private property only once
40759
40762
  const tempVisitorsMap = {};
40760
40763
  for (const id in response.data) {
40761
- tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].playerId, this.urlSlug, {
40764
+ tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].visitorId, this.urlSlug, {
40762
40765
  attributes: response.data[id],
40763
40766
  });
40764
40767
  }
@@ -1,5 +1,5 @@
1
1
  export const visitor = {
2
- playerId: 1,
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
- playerId: 1,
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
- playerId: 2,
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
- * playerId: 1,
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", playerId: 1 });
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.playerId) === this.id) {
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
  }
@@ -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].playerId, this.urlSlug, {
56
+ tempVisitorsMap[id] = new Visitor(this.topia, response.data[id].visitorId, this.urlSlug, {
56
57
  attributes: response.data[id],
57
58
  });
58
59
  }
@@ -17,6 +17,7 @@ describe("Asset Class", () => {
17
17
  topia = new Topia({
18
18
  apiDomain,
19
19
  apiKey: "exampleKey",
20
+ apiProtocol: "https",
20
21
  interactiveKey: "key",
21
22
  interactiveSecret: "secret",
22
23
  });
@@ -22,6 +22,7 @@ describe("DroppedAsset Class", () => {
22
22
  topia = new Topia({
23
23
  apiDomain,
24
24
  apiKey: "key",
25
+ apiProtocol: "https",
25
26
  });
26
27
  mock = new MockAdapter(topia.axios);
27
28
  DroppedAsset = new DroppedAssetFactory(topia);
@@ -18,6 +18,7 @@ describe("Scene Class", () => {
18
18
  topia = new Topia({
19
19
  apiDomain,
20
20
  apiKey: "exampleKey",
21
+ apiProtocol: "https",
21
22
  interactiveKey: "key",
22
23
  interactiveSecret: "secret",
23
24
  });
@@ -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.playerId;
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);
@@ -18,6 +18,7 @@ describe("World Class", () => {
18
18
  topia = new Topia({
19
19
  apiDomain: "api.topia.io",
20
20
  apiKey: "key",
21
+ apiProtocol: "https",
21
22
  });
22
23
  mock = new MockAdapter(topia.axios);
23
24
  World = new WorldFactory(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"].playerId, urlSlug, { attributes: visitors["1"] });
54
- const v2 = new Visitor(topia, visitors["2"].playerId, urlSlug, { attributes: 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
@@ -56,5 +56,5 @@
56
56
  "local-publish": "yarn build && yalc publish --push --no-scripts"
57
57
  },
58
58
  "type": "module",
59
- "version": "0.0.26"
59
+ "version": "0.0.27"
60
60
  }