@rtsdk/topia 0.0.7 → 0.0.8

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.
@@ -0,0 +1,2 @@
1
+ export * from "./visitors";
2
+ export * from "./worlds";
@@ -0,0 +1,56 @@
1
+ export var visitors = {
2
+ "798": {
3
+ playerId: 798,
4
+ color: "0x7AD3BA",
5
+ moveTo: {
6
+ x: -1458,
7
+ y: -351
8
+ },
9
+ moveFrom: null,
10
+ username: "Lina",
11
+ sitting: false,
12
+ gestureType: 0,
13
+ performer: false,
14
+ performerNear: false,
15
+ shareScreen: false,
16
+ isBackground: false,
17
+ muted: true,
18
+ hidden: true,
19
+ newId: null,
20
+ displayName: "",
21
+ movedOn: null,
22
+ lastUpdate: 1669915215216,
23
+ isMobile: false,
24
+ token: "a92863e4-c21c-4270-a7ed-cdee2574e3ec",
25
+ isAdmin: false,
26
+ isRecording: false,
27
+ isRecordingBot: false
28
+ },
29
+ "799": {
30
+ playerId: 799,
31
+ color: "0xA0D2A7",
32
+ moveTo: {
33
+ x: -1504,
34
+ y: -260
35
+ },
36
+ moveFrom: null,
37
+ username: "Definitely Not Lina",
38
+ sitting: false,
39
+ gestureType: 0,
40
+ performer: false,
41
+ performerNear: false,
42
+ shareScreen: false,
43
+ isBackground: false,
44
+ muted: true,
45
+ hidden: true,
46
+ newId: null,
47
+ displayName: "",
48
+ movedOn: null,
49
+ lastUpdate: 1669915214590,
50
+ isMobile: false,
51
+ token: "23fecaae-6b55-4e98-9e0c-6f869bb19463",
52
+ isAdmin: false,
53
+ isRecording: false,
54
+ isRecordingBot: false
55
+ }
56
+ };
@@ -0,0 +1,51 @@
1
+ var baseImageURL = "https://firebasestorage.googleapis.com/v0/b/topia-ba1c8.appspot.com/o/heroImages%";
2
+ export var worlds = [
3
+ {
4
+ description: "This is the a welcome lobby that anybody can enter to learn more about Topia.",
5
+ name: "Welcome",
6
+ heroImage: "".concat(baseImageURL, "2Fwelcome_banner.png?alt=media&token=548e1515-205e-4ef0-a0ca-bc4cc39c4f40"),
7
+ urlSlug: "welcome"
8
+ },
9
+ {
10
+ background: null,
11
+ created: {
12
+ _seconds: 1605310924,
13
+ _nanoseconds: 165000000
14
+ },
15
+ controls: {
16
+ isShowingCurrentGuests: true,
17
+ hideShareScreen: false,
18
+ isZoneConversationHidden: false,
19
+ allowUserToTurnOnNotifications: true,
20
+ isPeerConversationHidden: false,
21
+ disableHideVideo: false,
22
+ isWorldConversationHidden: false,
23
+ allowUsersToTurnOnNotifications: true,
24
+ allowMuteAll: true,
25
+ isMobileDisabled: false
26
+ },
27
+ description: "A place to play, test, create scenes, and more!",
28
+ enforceWhitelistOnLogin: false,
29
+ forceAuthOnLogin: true,
30
+ height: 3096,
31
+ heroImage: "https://firebasestorage.googleapis.com/v0/b/topia-ba1c8.appspot.com/o/heroImages%2F2OB4pQL4b6ReyRfh6TOVJlx8vDz2-lina-1632521548284.png?alt=media&token=b95f15ac-f598-438e-95e8-4c048ec091a7",
32
+ mapExists: true,
33
+ name: "Lina's World",
34
+ redirectTo: null,
35
+ spawnPosition: {
36
+ radius: 100,
37
+ y: -348,
38
+ x: -1448
39
+ },
40
+ tileBackgroundEverywhere: null,
41
+ useTopiaPassword: false,
42
+ width: 4096
43
+ },
44
+ {
45
+ alt: "descriptive text for screen reader",
46
+ description: "Donec ullamcorper nulla non metus auctor fringilla. Donec ullamcorper nulla non metus auctor fringilla. Donec ullamcorper nulla non metus auctor fringilla",
47
+ name: "World Name that goes on for days",
48
+ heroImage: "https://bit.ly/2QdnMge",
49
+ urlSlug: "world-name-that-goes-on-forever-because-it-free"
50
+ },
51
+ ];
@@ -7,65 +7,116 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
10
37
  import axios from "axios";
11
- const API_URL = "https://api.topia.io/api";
12
- class World {
13
- constructor(apiKey, urlSlug) {
38
+ var API_URL = "https://api.topia.io/api";
39
+ var World = /** @class */ (function () {
40
+ function World(apiKey, urlSlug) {
14
41
  this.apiKey = apiKey;
15
42
  this.urlSlug = urlSlug;
16
43
  }
17
- fetchDetails() {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- return new Promise((resolve, reject) => {
20
- axios
21
- .get(`${API_URL}/world/${this.urlSlug}/world-details`, {
22
- headers: { Authorization: this.apiKey },
23
- })
24
- .then((response) => {
25
- console.log("🚀 ~ file: World.ts ~ line 21 ~ World ~ .then ~ response", response);
26
- resolve(response.data);
27
- })
28
- .catch(reject);
44
+ World.prototype.fetchDetails = function () {
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var _this = this;
47
+ return __generator(this, function (_a) {
48
+ return [2 /*return*/, new Promise(function (resolve, reject) {
49
+ axios
50
+ .get("".concat(API_URL, "/world/").concat(_this.urlSlug, "/world-details"), {
51
+ headers: { Authorization: _this.apiKey }
52
+ })
53
+ .then(function (response) {
54
+ resolve(response.data);
55
+ })["catch"](reject);
56
+ })];
29
57
  });
30
58
  });
31
- }
32
- fetchVisitors() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- return new Promise((resolve, reject) => {
35
- axios
36
- .get(`${API_URL}/world/${this.urlSlug}/visitors`, {
37
- headers: { Authorization: this.apiKey },
38
- })
39
- .then((response) => {
40
- console.log("🚀 ~ file: World.ts ~ line 35 ~ World ~ .then ~ response", response);
41
- resolve(response.data);
42
- })
43
- .catch(reject);
59
+ };
60
+ World.prototype.fetchVisitors = function () {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ var _this = this;
63
+ return __generator(this, function (_a) {
64
+ return [2 /*return*/, new Promise(function (resolve, reject) {
65
+ axios
66
+ .get("".concat(API_URL, "/world/").concat(_this.urlSlug, "/visitors"), {
67
+ headers: { Authorization: _this.apiKey }
68
+ })
69
+ .then(function (response) {
70
+ resolve(response.data);
71
+ })["catch"](reject);
72
+ })];
44
73
  });
45
74
  });
46
- }
47
- moveVisitor(visitor) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- return new Promise((resolve, reject) => {
50
- const requestOptions = {
51
- headers: { Authorization: this.apiKey },
52
- body: {
53
- moveTo: {
54
- x: visitor.coordinates.x,
55
- y: visitor.coordinates.y,
56
- },
57
- teleport: true,
58
- },
59
- };
60
- axios
61
- .put(`${API_URL}/world/${this.urlSlug}/visitors/${visitor.visitorId}/move`, requestOptions)
62
- .then((response) => {
63
- console.log("🚀 ~ file: World.ts ~ line 49 ~ World ~ .then ~ response", response);
64
- resolve(response.data);
65
- })
66
- .catch(reject);
75
+ };
76
+ World.prototype.moveVisitors = function (visitors) {
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var allPromises, outcomes;
79
+ var _this = this;
80
+ return __generator(this, function (_a) {
81
+ switch (_a.label) {
82
+ case 0:
83
+ allPromises = [];
84
+ visitors.map(function (visitor) { return __awaiter(_this, void 0, void 0, function () {
85
+ var promise;
86
+ var _this = this;
87
+ return __generator(this, function (_a) {
88
+ promise = new Promise(function (resolve, reject) {
89
+ var requestOptions = {
90
+ headers: { Authorization: _this.apiKey },
91
+ body: {
92
+ moveTo: {
93
+ x: visitor.coordinates.x,
94
+ y: visitor.coordinates.y
95
+ },
96
+ teleport: true
97
+ }
98
+ };
99
+ axios
100
+ .put("".concat(API_URL, "/world/").concat(_this.urlSlug, "/visitors/").concat(visitor.id, "/move"), requestOptions)
101
+ .then(function (response) {
102
+ resolve(response.data);
103
+ })["catch"](reject);
104
+ });
105
+ allPromises.push(promise);
106
+ return [2 /*return*/];
107
+ });
108
+ }); });
109
+ return [4 /*yield*/, Promise.allSettled(allPromises)];
110
+ case 1:
111
+ outcomes = _a.sent();
112
+ // const succeeded = outcomes.filter((o) => o.status === "fulfilled");
113
+ // const failed = outcomes.filter((o) => o.status === "rejected");
114
+ return [2 /*return*/, outcomes];
115
+ }
67
116
  });
68
117
  });
69
- }
70
- }
118
+ };
119
+ return World;
120
+ }());
71
121
  export { World };
122
+ export default World;
@@ -0,0 +1,111 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { visitors, worlds } from "../../__mocks__";
38
+ import { World } from "../../controllers";
39
+ afterEach(function () {
40
+ jest.resetAllMocks();
41
+ });
42
+ describe("get world details", function () {
43
+ it("should return details of a world", function () { return __awaiter(void 0, void 0, void 0, function () {
44
+ var testWorld, mockDetails;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, new World("key", "lina")];
48
+ case 1:
49
+ testWorld = _a.sent();
50
+ testWorld.fetchDetails = jest.fn().mockReturnValue(worlds[1]);
51
+ return [4 /*yield*/, testWorld.fetchDetails()];
52
+ case 2:
53
+ mockDetails = _a.sent();
54
+ expect(testWorld.fetchDetails).toHaveBeenCalled();
55
+ expect(mockDetails).toBeDefined();
56
+ return [2 /*return*/];
57
+ }
58
+ });
59
+ }); });
60
+ });
61
+ describe("get and move visitors", function () {
62
+ it("should return a list of current visitors for a given world", function () { return __awaiter(void 0, void 0, void 0, function () {
63
+ var testWorld, mockVisitors;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0: return [4 /*yield*/, new World("key", "lina")];
67
+ case 1:
68
+ testWorld = _a.sent();
69
+ testWorld.fetchVisitors = jest.fn().mockReturnValue(visitors);
70
+ return [4 /*yield*/, testWorld.fetchVisitors()];
71
+ case 2:
72
+ mockVisitors = _a.sent();
73
+ expect(testWorld.fetchVisitors).toHaveBeenCalled();
74
+ expect(mockVisitors).toBeDefined();
75
+ return [2 /*return*/];
76
+ }
77
+ });
78
+ }); });
79
+ it("should move a visitor to specified coordinates", function () { return __awaiter(void 0, void 0, void 0, function () {
80
+ var testWorld, visitors;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0: return [4 /*yield*/, new World("key", "lina")];
84
+ case 1:
85
+ testWorld = _a.sent();
86
+ testWorld.moveVisitors = jest.fn();
87
+ visitors = [
88
+ {
89
+ id: "1",
90
+ coordinates: {
91
+ x: 100,
92
+ y: 100
93
+ }
94
+ },
95
+ {
96
+ id: "2",
97
+ coordinates: {
98
+ x: 200,
99
+ y: 200
100
+ }
101
+ },
102
+ ];
103
+ return [4 /*yield*/, testWorld.moveVisitors(visitors)];
104
+ case 2:
105
+ _a.sent();
106
+ expect(testWorld.moveVisitors).toHaveBeenCalled();
107
+ return [2 /*return*/];
108
+ }
109
+ });
110
+ }); });
111
+ });
@@ -0,0 +1 @@
1
+ export { World } from "./World";
package/dist/index.js CHANGED
@@ -1,17 +1,15 @@
1
- 'use strict';
2
-
3
- var require$$1 = require('util');
4
- var stream = require('stream');
5
- var require$$1$1 = require('path');
6
- var require$$3 = require('http');
7
- var require$$4 = require('https');
8
- var require$$0$1 = require('url');
9
- var require$$6 = require('fs');
10
- var require$$4$1 = require('assert');
11
- var require$$1$2 = require('tty');
12
- var require$$0$2 = require('os');
13
- var zlib = require('zlib');
14
- var EventEmitter = require('events');
1
+ import require$$1 from 'util';
2
+ import stream from 'stream';
3
+ import require$$1$1 from 'path';
4
+ import require$$3 from 'http';
5
+ import require$$4 from 'https';
6
+ import require$$0$1 from 'url';
7
+ import require$$6 from 'fs';
8
+ import require$$4$1 from 'assert';
9
+ import require$$1$2 from 'tty';
10
+ import require$$0$2 from 'os';
11
+ import zlib from 'zlib';
12
+ import EventEmitter from 'events';
15
13
 
16
14
  /******************************************************************************
17
15
  Copyright (c) Microsoft Corporation.
@@ -36,6 +34,34 @@ function __awaiter(thisArg, _arguments, P, generator) {
36
34
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
37
35
  step((generator = generator.apply(thisArg, _arguments || [])).next());
38
36
  });
37
+ }
38
+
39
+ function __generator(thisArg, body) {
40
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
41
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
42
+ function verb(n) { return function (v) { return step([n, v]); }; }
43
+ function step(op) {
44
+ if (f) throw new TypeError("Generator is already executing.");
45
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
46
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
47
+ if (y = 0, t) op = [op[0] & 2, t.value];
48
+ switch (op[0]) {
49
+ case 0: case 1: t = op; break;
50
+ case 4: _.label++; return { value: op[1], done: false };
51
+ case 5: _.label++; y = op[1]; op = [0]; continue;
52
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
53
+ default:
54
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
55
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
56
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
57
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
58
+ if (t[2]) _.ops.pop();
59
+ _.trys.pop(); continue;
60
+ }
61
+ op = body.call(thisArg, _);
62
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
63
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
64
+ }
39
65
  }
40
66
 
41
67
  function bind(fn, thisArg) {
@@ -17838,65 +17864,88 @@ axios.formToJSON = thing => {
17838
17864
  return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
17839
17865
  };
17840
17866
 
17841
- const API_URL = "https://api.topia.io/api";
17842
- class World {
17843
- constructor(apiKey, urlSlug) {
17867
+ var API_URL = "https://api.topia.io/api";
17868
+ var World = /** @class */ (function () {
17869
+ function World(apiKey, urlSlug) {
17844
17870
  this.apiKey = apiKey;
17845
17871
  this.urlSlug = urlSlug;
17846
17872
  }
17847
- fetchDetails() {
17848
- return __awaiter(this, void 0, void 0, function* () {
17849
- return new Promise((resolve, reject) => {
17850
- axios
17851
- .get(`${API_URL}/world/${this.urlSlug}/world-details`, {
17852
- headers: { Authorization: this.apiKey },
17853
- })
17854
- .then((response) => {
17855
- console.log("🚀 ~ file: World.ts ~ line 21 ~ World ~ .then ~ response", response);
17856
- resolve(response.data);
17857
- })
17858
- .catch(reject);
17873
+ World.prototype.fetchDetails = function () {
17874
+ return __awaiter(this, void 0, void 0, function () {
17875
+ var _this = this;
17876
+ return __generator(this, function (_a) {
17877
+ return [2 /*return*/, new Promise(function (resolve, reject) {
17878
+ axios
17879
+ .get("".concat(API_URL, "/world/").concat(_this.urlSlug, "/world-details"), {
17880
+ headers: { Authorization: _this.apiKey }
17881
+ })
17882
+ .then(function (response) {
17883
+ resolve(response.data);
17884
+ })["catch"](reject);
17885
+ })];
17859
17886
  });
17860
17887
  });
17861
- }
17862
- fetchVisitors() {
17863
- return __awaiter(this, void 0, void 0, function* () {
17864
- return new Promise((resolve, reject) => {
17865
- axios
17866
- .get(`${API_URL}/world/${this.urlSlug}/visitors`, {
17867
- headers: { Authorization: this.apiKey },
17868
- })
17869
- .then((response) => {
17870
- console.log("🚀 ~ file: World.ts ~ line 35 ~ World ~ .then ~ response", response);
17871
- resolve(response.data);
17872
- })
17873
- .catch(reject);
17888
+ };
17889
+ World.prototype.fetchVisitors = function () {
17890
+ return __awaiter(this, void 0, void 0, function () {
17891
+ var _this = this;
17892
+ return __generator(this, function (_a) {
17893
+ return [2 /*return*/, new Promise(function (resolve, reject) {
17894
+ axios
17895
+ .get("".concat(API_URL, "/world/").concat(_this.urlSlug, "/visitors"), {
17896
+ headers: { Authorization: _this.apiKey }
17897
+ })
17898
+ .then(function (response) {
17899
+ resolve(response.data);
17900
+ })["catch"](reject);
17901
+ })];
17874
17902
  });
17875
17903
  });
17876
- }
17877
- moveVisitor(visitor) {
17878
- return __awaiter(this, void 0, void 0, function* () {
17879
- return new Promise((resolve, reject) => {
17880
- const requestOptions = {
17881
- headers: { Authorization: this.apiKey },
17882
- body: {
17883
- moveTo: {
17884
- x: visitor.coordinates.x,
17885
- y: visitor.coordinates.y,
17886
- },
17887
- teleport: true,
17888
- },
17889
- };
17890
- axios
17891
- .put(`${API_URL}/world/${this.urlSlug}/visitors/${visitor.visitorId}/move`, requestOptions)
17892
- .then((response) => {
17893
- console.log("🚀 ~ file: World.ts ~ line 49 ~ World ~ .then ~ response", response);
17894
- resolve(response.data);
17895
- })
17896
- .catch(reject);
17904
+ };
17905
+ World.prototype.moveVisitors = function (visitors) {
17906
+ return __awaiter(this, void 0, void 0, function () {
17907
+ var allPromises, outcomes;
17908
+ var _this = this;
17909
+ return __generator(this, function (_a) {
17910
+ switch (_a.label) {
17911
+ case 0:
17912
+ allPromises = [];
17913
+ visitors.map(function (visitor) { return __awaiter(_this, void 0, void 0, function () {
17914
+ var promise;
17915
+ var _this = this;
17916
+ return __generator(this, function (_a) {
17917
+ promise = new Promise(function (resolve, reject) {
17918
+ var requestOptions = {
17919
+ headers: { Authorization: _this.apiKey },
17920
+ body: {
17921
+ moveTo: {
17922
+ x: visitor.coordinates.x,
17923
+ y: visitor.coordinates.y
17924
+ },
17925
+ teleport: true
17926
+ }
17927
+ };
17928
+ axios
17929
+ .put("".concat(API_URL, "/world/").concat(_this.urlSlug, "/visitors/").concat(visitor.id, "/move"), requestOptions)
17930
+ .then(function (response) {
17931
+ resolve(response.data);
17932
+ })["catch"](reject);
17933
+ });
17934
+ allPromises.push(promise);
17935
+ return [2 /*return*/];
17936
+ });
17937
+ }); });
17938
+ return [4 /*yield*/, Promise.allSettled(allPromises)];
17939
+ case 1:
17940
+ outcomes = _a.sent();
17941
+ // const succeeded = outcomes.filter((o) => o.status === "fulfilled");
17942
+ // const failed = outcomes.filter((o) => o.status === "rejected");
17943
+ return [2 /*return*/, outcomes];
17944
+ }
17897
17945
  });
17898
17946
  });
17899
- }
17900
- }
17947
+ };
17948
+ return World;
17949
+ }());
17901
17950
 
17902
- exports.World = World;
17951
+ export { World };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -5,6 +5,7 @@
5
5
  },
6
6
  "description": "MC Javascript SDK - Topia Client Library",
7
7
  "devDependencies": {
8
+ "@rollup/plugin-alias": "^4.0.2",
8
9
  "@rollup/plugin-commonjs": "^23.0.2",
9
10
  "@rollup/plugin-json": "^5.0.1",
10
11
  "@rollup/plugin-node-resolve": "^15.0.1",
@@ -45,9 +46,9 @@
45
46
  "build": "tsc && rollup -c",
46
47
  "test": "ENV=testing jest --watchAll=false",
47
48
  "lint": "eslint \"src/**\"",
48
- "publish": "npm publish",
49
- "local-publish": "yarn build && yalc publish --push"
49
+ "pkg": "npm publish",
50
+ "local-publish": "yarn build && yalc publish --push --no-scripts"
50
51
  },
51
52
  "type": "module",
52
- "version": "0.0.7"
53
+ "version": "0.0.8"
53
54
  }
@@ -1,19 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { World } from ".";
11
- const API_KEY = "c3e68f35-2b03-42ab-8946-e9a78dd92f57";
12
- describe("get world details", () => {
13
- it("should return details of a world", () => __awaiter(void 0, void 0, void 0, function* () {
14
- const myWorld = new World(API_KEY, "lina");
15
- const details = myWorld.fetchDetails();
16
- console.log("🚀 ~ file: index.test.ts ~ line 7 ~ it ~ details", details);
17
- // expect(result).toBeDefined();
18
- }));
19
- });