@swan-admin/swan-ai-measurements 1.1.14 → 1.1.16
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/esm/fileUpload.js +153 -189
- package/dist/esm/poseDetection.js +2 -6
- package/dist/poseDetection.js +2 -6
- package/package.json +1 -1
- package/src/poseDetection.ts +3 -7
package/Readme.md
CHANGED
package/dist/esm/fileUpload.js
CHANGED
|
@@ -1,51 +1,23 @@
|
|
|
1
|
-
var __awaiter =
|
|
2
|
-
|
|
3
|
-
function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) {
|
|
5
|
-
return value instanceof P
|
|
6
|
-
? value
|
|
7
|
-
: new P(function (resolve) {
|
|
8
|
-
resolve(value);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
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); }); }
|
|
11
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
reject(e);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function rejected(value) {
|
|
20
|
-
try {
|
|
21
|
-
step(generator["throw"](value));
|
|
22
|
-
} catch (e) {
|
|
23
|
-
reject(e);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function step(result) {
|
|
27
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
28
|
-
}
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
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());
|
|
30
8
|
});
|
|
31
|
-
|
|
32
|
-
var __classPrivateFieldSet =
|
|
33
|
-
(this && this.__classPrivateFieldSet) ||
|
|
34
|
-
function (receiver, state, value, kind, f) {
|
|
9
|
+
};
|
|
10
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
35
11
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
36
12
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
37
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var __classPrivateFieldGet =
|
|
42
|
-
(this && this.__classPrivateFieldGet) ||
|
|
43
|
-
function (receiver, state, kind, f) {
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
+
};
|
|
16
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
44
17
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
45
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
46
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
18
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
47
19
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
48
|
-
|
|
20
|
+
};
|
|
49
21
|
var _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_stagingUrl;
|
|
50
22
|
import axios from "axios";
|
|
51
23
|
import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, FILE_UPLOAD_ENDPOINT, APP_AUTH_BASE_URL } from "./constants.js";
|
|
@@ -53,155 +25,147 @@ import { addScanType, checkMetaDataValue, checkParameters, fetchData, getFileChu
|
|
|
53
25
|
import Uppy from "@uppy/core";
|
|
54
26
|
import AwsS3Multipart from "@uppy/aws-s3-multipart";
|
|
55
27
|
class FileUpload {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
28
|
+
constructor(accessKey, stagingUrl = false) {
|
|
29
|
+
_FileUpload_uppyIns.set(this, void 0);
|
|
30
|
+
_FileUpload_accessKey.set(this, void 0);
|
|
31
|
+
_FileUpload_stagingUrl.set(this, void 0);
|
|
32
|
+
__classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
|
|
33
|
+
__classPrivateFieldSet(this, _FileUpload_stagingUrl, stagingUrl, "f");
|
|
34
|
+
}
|
|
35
|
+
uploadFileFrontend(_a) {
|
|
36
|
+
return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
|
|
37
|
+
if (!checkParameters(file, arrayMetaData, scanId)) {
|
|
38
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
39
|
+
}
|
|
40
|
+
if (!checkMetaDataValue(arrayMetaData)) {
|
|
41
|
+
throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
|
|
42
|
+
}
|
|
43
|
+
arrayMetaData = addScanType(arrayMetaData, scanId);
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
|
|
46
|
+
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
|
|
47
|
+
}
|
|
48
|
+
__classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy({ autoProceed: true }), "f");
|
|
49
|
+
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart, {
|
|
50
|
+
limit: 10,
|
|
51
|
+
retryDelays: [0, 1000, 3000, 5000],
|
|
52
|
+
companionUrl: getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f") }),
|
|
53
|
+
getChunkSize: () => 5 * 1024 * 1024,
|
|
54
|
+
createMultipartUpload: (file) => {
|
|
55
|
+
const objectKey = `${scanId}.${file.extension}`;
|
|
56
|
+
return fetchData({
|
|
57
|
+
path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
|
|
58
|
+
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
59
|
+
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
60
|
+
body: {
|
|
61
|
+
objectKey,
|
|
62
|
+
contentType: file.type,
|
|
63
|
+
objectMetadata: arrayMetaData,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
completeMultipartUpload: (file, { uploadId, key, parts }) => fetchData({
|
|
68
|
+
path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
|
|
69
|
+
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
70
|
+
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
71
|
+
body: {
|
|
72
|
+
uploadId,
|
|
73
|
+
objectKey: key,
|
|
74
|
+
parts,
|
|
75
|
+
originalFileName: file.name,
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
signPart: (file, partData) => fetchData({
|
|
79
|
+
path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
|
|
80
|
+
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
81
|
+
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
82
|
+
body: {
|
|
83
|
+
objectKey: partData.key,
|
|
84
|
+
uploadId: partData.uploadId,
|
|
85
|
+
partNumber: partData.partNumber,
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
});
|
|
89
|
+
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").addFile({
|
|
90
|
+
source: "manual",
|
|
91
|
+
name: file.name,
|
|
92
|
+
type: file.type,
|
|
93
|
+
data: file,
|
|
94
|
+
});
|
|
95
|
+
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-error", (file, error, response) => {
|
|
96
|
+
reject(error);
|
|
97
|
+
});
|
|
98
|
+
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-success", () => {
|
|
99
|
+
resolve({ message: "file uploaded successfully" });
|
|
100
|
+
});
|
|
101
|
+
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("complete", (result) => {
|
|
102
|
+
if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
|
|
103
|
+
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
93
106
|
});
|
|
94
|
-
},
|
|
95
|
-
completeMultipartUpload: (file, { uploadId, key, parts }) =>
|
|
96
|
-
fetchData({
|
|
97
|
-
path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
|
|
98
|
-
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
99
|
-
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
100
|
-
body: {
|
|
101
|
-
uploadId,
|
|
102
|
-
objectKey: key,
|
|
103
|
-
parts,
|
|
104
|
-
originalFileName: file.name,
|
|
105
|
-
},
|
|
106
|
-
}),
|
|
107
|
-
signPart: (file, partData) =>
|
|
108
|
-
fetchData({
|
|
109
|
-
path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
|
|
110
|
-
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
111
|
-
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
112
|
-
body: {
|
|
113
|
-
objectKey: partData.key,
|
|
114
|
-
uploadId: partData.uploadId,
|
|
115
|
-
partNumber: partData.partNumber,
|
|
116
|
-
},
|
|
117
|
-
}),
|
|
118
|
-
});
|
|
119
|
-
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").addFile({
|
|
120
|
-
source: "manual",
|
|
121
|
-
name: file.name,
|
|
122
|
-
type: file.type,
|
|
123
|
-
data: file,
|
|
124
|
-
});
|
|
125
|
-
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-error", (file, error, response) => {
|
|
126
|
-
reject(error);
|
|
127
|
-
});
|
|
128
|
-
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-success", () => {
|
|
129
|
-
resolve({ message: "file uploaded successfully" });
|
|
130
|
-
});
|
|
131
|
-
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("complete", (result) => {
|
|
132
|
-
if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
|
|
133
|
-
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
|
|
134
|
-
}
|
|
135
107
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (!checkParameters(file, arrayMetaData, scanId)) {
|
|
142
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
143
|
-
}
|
|
144
|
-
if (!checkMetaDataValue(arrayMetaData)) {
|
|
145
|
-
throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
|
|
146
|
-
}
|
|
147
|
-
arrayMetaData = addScanType(arrayMetaData, scanId);
|
|
148
|
-
return new Promise((resolve, reject) =>
|
|
149
|
-
__awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
var _b;
|
|
151
|
-
try {
|
|
152
|
-
const res = yield fetchData({
|
|
153
|
-
path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
|
|
154
|
-
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
155
|
-
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
156
|
-
body: {
|
|
157
|
-
objectKey: file.name,
|
|
158
|
-
contentType: file.type,
|
|
159
|
-
objectMetadata: arrayMetaData,
|
|
160
|
-
},
|
|
161
|
-
throwError: true,
|
|
162
|
-
});
|
|
163
|
-
const totalChunks = getFileChunks(file);
|
|
164
|
-
const parts = [];
|
|
165
|
-
for (let i = 0; i < totalChunks.length; i++) {
|
|
166
|
-
const data = yield fetchData({
|
|
167
|
-
path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
|
|
168
|
-
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
169
|
-
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
170
|
-
body: {
|
|
171
|
-
objectKey: res === null || res === void 0 ? void 0 : res.key,
|
|
172
|
-
uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
|
|
173
|
-
partNumber: i + 1,
|
|
174
|
-
},
|
|
175
|
-
throwError: true,
|
|
176
|
-
});
|
|
177
|
-
const val = yield axios.put(data === null || data === void 0 ? void 0 : data.url, totalChunks[i], {
|
|
178
|
-
headers: { "Content-Type": file.type, "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") },
|
|
179
|
-
});
|
|
180
|
-
parts.push({
|
|
181
|
-
PartNumber: i + 1,
|
|
182
|
-
ETag: (_b = val === null || val === void 0 ? void 0 : val.headers) === null || _b === void 0 ? void 0 : _b.etag,
|
|
183
|
-
});
|
|
108
|
+
}
|
|
109
|
+
uploadFile(_a) {
|
|
110
|
+
return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
|
|
111
|
+
if (!checkParameters(file, arrayMetaData, scanId)) {
|
|
112
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
184
113
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
114
|
+
if (!checkMetaDataValue(arrayMetaData)) {
|
|
115
|
+
throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
|
|
116
|
+
}
|
|
117
|
+
arrayMetaData = addScanType(arrayMetaData, scanId);
|
|
118
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
var _b;
|
|
120
|
+
try {
|
|
121
|
+
const res = yield fetchData({
|
|
122
|
+
path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
|
|
123
|
+
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
124
|
+
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
125
|
+
body: {
|
|
126
|
+
objectKey: file.name,
|
|
127
|
+
contentType: file.type,
|
|
128
|
+
objectMetadata: arrayMetaData,
|
|
129
|
+
},
|
|
130
|
+
throwError: true,
|
|
131
|
+
});
|
|
132
|
+
const totalChunks = getFileChunks(file);
|
|
133
|
+
const parts = [];
|
|
134
|
+
for (let i = 0; i < totalChunks.length; i++) {
|
|
135
|
+
const data = yield fetchData({
|
|
136
|
+
path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
|
|
137
|
+
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
138
|
+
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
139
|
+
body: {
|
|
140
|
+
objectKey: res === null || res === void 0 ? void 0 : res.key,
|
|
141
|
+
uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
|
|
142
|
+
partNumber: i + 1,
|
|
143
|
+
},
|
|
144
|
+
throwError: true,
|
|
145
|
+
});
|
|
146
|
+
const val = yield axios.put(data === null || data === void 0 ? void 0 : data.url, totalChunks[i], { headers: { "Content-Type": file.type, "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") } });
|
|
147
|
+
parts.push({ PartNumber: i + 1, ETag: (_b = val === null || val === void 0 ? void 0 : val.headers) === null || _b === void 0 ? void 0 : _b.etag });
|
|
148
|
+
}
|
|
149
|
+
const completeValue = yield fetchData({
|
|
150
|
+
path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
|
|
151
|
+
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
152
|
+
stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
|
|
153
|
+
body: {
|
|
154
|
+
uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
|
|
155
|
+
objectKey: res === null || res === void 0 ? void 0 : res.key,
|
|
156
|
+
parts,
|
|
157
|
+
originalFileName: file.name,
|
|
158
|
+
},
|
|
159
|
+
throwError: true,
|
|
160
|
+
});
|
|
161
|
+
resolve({ message: "successfully uploaded", data: completeValue });
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
reject(error);
|
|
165
|
+
}
|
|
166
|
+
}));
|
|
167
|
+
});
|
|
168
|
+
}
|
|
205
169
|
}
|
|
206
|
-
|
|
170
|
+
_FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _FileUpload_stagingUrl = new WeakMap();
|
|
207
171
|
export default FileUpload;
|
|
@@ -23,11 +23,7 @@ class PoseDetection {
|
|
|
23
23
|
}
|
|
24
24
|
connect() {
|
|
25
25
|
return new Promise((resolve, reject) => {
|
|
26
|
-
__classPrivateFieldSet(this, _PoseDetection_socketRef, io(getUrl({ urlName: APP_POSE_DETECTION_WEBSOCKET_URL, stagingUrl: __classPrivateFieldGet(this, _PoseDetection_stagingUrl, "f") }),
|
|
27
|
-
auth: {
|
|
28
|
-
token: __classPrivateFieldGet(this, _PoseDetection_accessKey, "f"),
|
|
29
|
-
},
|
|
30
|
-
}), "f");
|
|
26
|
+
__classPrivateFieldSet(this, _PoseDetection_socketRef, io(getUrl({ urlName: APP_POSE_DETECTION_WEBSOCKET_URL, stagingUrl: __classPrivateFieldGet(this, _PoseDetection_stagingUrl, "f") })), "f");
|
|
31
27
|
__classPrivateFieldGet(this, _PoseDetection_socketRef, "f").on("connect", () => {
|
|
32
28
|
var _a;
|
|
33
29
|
const socketId = (_a = __classPrivateFieldGet(this, _PoseDetection_socketRef, "f")) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -35,7 +31,7 @@ class PoseDetection {
|
|
|
35
31
|
resolve(socketId);
|
|
36
32
|
}
|
|
37
33
|
else {
|
|
38
|
-
reject(
|
|
34
|
+
reject("Failed to obtain socket ID.");
|
|
39
35
|
}
|
|
40
36
|
});
|
|
41
37
|
__classPrivateFieldGet(this, _PoseDetection_socketRef, "f").on("connect_error", (err) => {
|
package/dist/poseDetection.js
CHANGED
|
@@ -13,18 +13,14 @@ class PoseDetection {
|
|
|
13
13
|
}
|
|
14
14
|
connect() {
|
|
15
15
|
return new Promise((resolve, reject) => {
|
|
16
|
-
this.#socketRef = (0, socket_io_client_1.io)((0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_POSE_DETECTION_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })
|
|
17
|
-
auth: {
|
|
18
|
-
token: this.#accessKey,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
16
|
+
this.#socketRef = (0, socket_io_client_1.io)((0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_POSE_DETECTION_WEBSOCKET_URL, stagingUrl: this.#stagingUrl }));
|
|
21
17
|
this.#socketRef.on("connect", () => {
|
|
22
18
|
const socketId = this.#socketRef?.id;
|
|
23
19
|
if (socketId) {
|
|
24
20
|
resolve(socketId);
|
|
25
21
|
}
|
|
26
22
|
else {
|
|
27
|
-
reject(
|
|
23
|
+
reject("Failed to obtain socket ID.");
|
|
28
24
|
}
|
|
29
25
|
});
|
|
30
26
|
this.#socketRef.on("connect_error", (err) => {
|
package/package.json
CHANGED
package/src/poseDetection.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { io, Socket } from "socket.io-client";
|
|
|
2
2
|
import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants.js";
|
|
3
3
|
import { getUrl } from "./utils.js";
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
interface VideoEmitOptions {
|
|
6
7
|
image: string;
|
|
7
8
|
scanId: string;
|
|
@@ -20,18 +21,13 @@ class PoseDetection {
|
|
|
20
21
|
|
|
21
22
|
connect(): Promise<string> {
|
|
22
23
|
return new Promise((resolve, reject) => {
|
|
23
|
-
this.#socketRef = io(getUrl({ urlName: APP_POSE_DETECTION_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })
|
|
24
|
-
auth: {
|
|
25
|
-
token: this.#accessKey,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
24
|
+
this.#socketRef = io(getUrl({ urlName: APP_POSE_DETECTION_WEBSOCKET_URL, stagingUrl: this.#stagingUrl }));
|
|
29
25
|
this.#socketRef.on("connect", () => {
|
|
30
26
|
const socketId = this.#socketRef?.id;
|
|
31
27
|
if (socketId) {
|
|
32
28
|
resolve(socketId);
|
|
33
29
|
} else {
|
|
34
|
-
reject(
|
|
30
|
+
reject("Failed to obtain socket ID.");
|
|
35
31
|
}
|
|
36
32
|
});
|
|
37
33
|
|