@swan-admin/swan-ai-measurements 1.1.44 → 1.1.46
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/auth.js +1 -10
- package/dist/esm/auth.js +1 -10
- package/dist/esm/measurement.js +1 -9
- package/dist/esm/tryOn.js +1 -9
- package/dist/measurement.js +1 -9
- package/dist/tryOn.js +1 -9
- package/package.json +2 -3
- package/src/auth.ts +2 -10
- package/src/measurement.ts +2 -8
- package/src/tryOn.ts +3 -8
package/dist/auth.js
CHANGED
|
@@ -6,15 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const constants_js_1 = require("./constants.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
|
-
const ws_1 = __importDefault(require("ws"));
|
|
10
|
-
// Conditionally import ws for Node.js
|
|
11
|
-
let WebSocketClient;
|
|
12
|
-
if (typeof window !== "undefined" && window.WebSocket) {
|
|
13
|
-
WebSocketClient = window.WebSocket;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
WebSocketClient = ws_1.default;
|
|
17
|
-
}
|
|
18
9
|
class Auth {
|
|
19
10
|
#socketRef;
|
|
20
11
|
#accessKey;
|
|
@@ -64,7 +55,7 @@ class Auth {
|
|
|
64
55
|
}
|
|
65
56
|
if (this.#socketRef)
|
|
66
57
|
this.#socketRef.close();
|
|
67
|
-
this.#socketRef = new
|
|
58
|
+
this.#socketRef = new WebSocket(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_BASE_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.AUTH}`);
|
|
68
59
|
const detailObj = { email, scanId };
|
|
69
60
|
if (this.#socketRef) {
|
|
70
61
|
this.#socketRef.onopen = () => {
|
package/dist/esm/auth.js
CHANGED
|
@@ -13,15 +13,6 @@ var _Auth_socketRef, _Auth_accessKey, _Auth_stagingUrl;
|
|
|
13
13
|
import axios from "axios";
|
|
14
14
|
import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
|
|
15
15
|
import { checkParameters, getUrl } from "./utils.js";
|
|
16
|
-
import WS from "ws";
|
|
17
|
-
// Conditionally import ws for Node.js
|
|
18
|
-
let WebSocketClient;
|
|
19
|
-
if (typeof window !== "undefined" && window.WebSocket) {
|
|
20
|
-
WebSocketClient = window.WebSocket;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
WebSocketClient = WS;
|
|
24
|
-
}
|
|
25
16
|
class Auth {
|
|
26
17
|
constructor(accessKey, stagingUrl = false) {
|
|
27
18
|
_Auth_socketRef.set(this, void 0);
|
|
@@ -71,7 +62,7 @@ class Auth {
|
|
|
71
62
|
}
|
|
72
63
|
if (__classPrivateFieldGet(this, _Auth_socketRef, "f"))
|
|
73
64
|
__classPrivateFieldGet(this, _Auth_socketRef, "f").close();
|
|
74
|
-
__classPrivateFieldSet(this, _Auth_socketRef, new
|
|
65
|
+
__classPrivateFieldSet(this, _Auth_socketRef, new WebSocket(`${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, stagingUrl: __classPrivateFieldGet(this, _Auth_stagingUrl, "f") })}${API_ENDPOINTS.AUTH}`), "f");
|
|
75
66
|
const detailObj = { email, scanId };
|
|
76
67
|
if (__classPrivateFieldGet(this, _Auth_socketRef, "f")) {
|
|
77
68
|
__classPrivateFieldGet(this, _Auth_socketRef, "f").onopen = () => {
|
package/dist/esm/measurement.js
CHANGED
|
@@ -22,14 +22,6 @@ var _Measurement_instances, _Measurement_tryOnSocketRef, _Measurement_measuremen
|
|
|
22
22
|
import axios from "axios";
|
|
23
23
|
import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
|
|
24
24
|
import { checkParameters, getUrl } from "./utils.js";
|
|
25
|
-
import WS from "ws";
|
|
26
|
-
let WebSocketClient;
|
|
27
|
-
if (typeof window !== 'undefined' && window.WebSocket) {
|
|
28
|
-
WebSocketClient = window.WebSocket;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
WebSocketClient = WS;
|
|
32
|
-
}
|
|
33
25
|
class Measurement {
|
|
34
26
|
constructor(accessKey, stagingUrl = false) {
|
|
35
27
|
_Measurement_instances.add(this);
|
|
@@ -76,7 +68,7 @@ class Measurement {
|
|
|
76
68
|
urlName: APP_BASE_WEBSOCKET_URL,
|
|
77
69
|
stagingUrl: __classPrivateFieldGet(this, _Measurement_stagingUrl, "f"),
|
|
78
70
|
})}/develop?store_url=${shopDomain}&product_name=${productName}&scan_id=${scanId}`;
|
|
79
|
-
__classPrivateFieldSet(this, _Measurement_tryOnSocketRef, new
|
|
71
|
+
__classPrivateFieldSet(this, _Measurement_tryOnSocketRef, new WebSocket(url), "f");
|
|
80
72
|
if (__classPrivateFieldGet(this, _Measurement_tryOnSocketRef, "f")) {
|
|
81
73
|
__classPrivateFieldGet(this, _Measurement_tryOnSocketRef, "f").onopen = () => {
|
|
82
74
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
package/dist/esm/tryOn.js
CHANGED
|
@@ -22,14 +22,6 @@ var _TryOn_instances, _TryOn_tryOnSocketRef, _TryOn_timerWaitingRef, _TryOn_acce
|
|
|
22
22
|
import axios from "axios";
|
|
23
23
|
import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_ERROR_MESSAGE_INVALID_EMAIL, REQUIRED_MESSAGE } from "./constants.js";
|
|
24
24
|
import { checkParameters, getUrl, isValidEmail } from "./utils.js";
|
|
25
|
-
import WS from "ws";
|
|
26
|
-
let WebSocketClient;
|
|
27
|
-
if (typeof window !== 'undefined' && window.WebSocket) {
|
|
28
|
-
WebSocketClient = window.WebSocket;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
WebSocketClient = WS;
|
|
32
|
-
}
|
|
33
25
|
class TryOn {
|
|
34
26
|
constructor(accessKey, stagingUrl = false) {
|
|
35
27
|
_TryOn_instances.add(this);
|
|
@@ -59,7 +51,7 @@ class TryOn {
|
|
|
59
51
|
}
|
|
60
52
|
__classPrivateFieldGet(this, _TryOn_disconnectSocket, "f").call(this);
|
|
61
53
|
const url = `${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, stagingUrl: __classPrivateFieldGet(this, _TryOn_stagingUrl, "f") })}${API_ENDPOINTS.TRY_ON}?tryonId=${tryonId}`;
|
|
62
|
-
__classPrivateFieldSet(this, _TryOn_tryOnSocketRef, new
|
|
54
|
+
__classPrivateFieldSet(this, _TryOn_tryOnSocketRef, new WebSocket(url), "f");
|
|
63
55
|
if (__classPrivateFieldGet(this, _TryOn_tryOnSocketRef, "f")) {
|
|
64
56
|
__classPrivateFieldGet(this, _TryOn_tryOnSocketRef, "f").onopen = () => __awaiter(this, void 0, void 0, function* () {
|
|
65
57
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
package/dist/measurement.js
CHANGED
|
@@ -6,14 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const constants_js_1 = require("./constants.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
|
-
const ws_1 = __importDefault(require("ws"));
|
|
10
|
-
let WebSocketClient;
|
|
11
|
-
if (typeof window !== 'undefined' && window.WebSocket) {
|
|
12
|
-
WebSocketClient = window.WebSocket;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
WebSocketClient = ws_1.default;
|
|
16
|
-
}
|
|
17
9
|
class Measurement {
|
|
18
10
|
#tryOnSocketRef = null;
|
|
19
11
|
#measurementSocketRef = null;
|
|
@@ -58,7 +50,7 @@ class Measurement {
|
|
|
58
50
|
urlName: constants_js_1.APP_BASE_WEBSOCKET_URL,
|
|
59
51
|
stagingUrl: this.#stagingUrl,
|
|
60
52
|
})}/develop?store_url=${shopDomain}&product_name=${productName}&scan_id=${scanId}`;
|
|
61
|
-
this.#tryOnSocketRef = new
|
|
53
|
+
this.#tryOnSocketRef = new WebSocket(url);
|
|
62
54
|
if (this.#tryOnSocketRef) {
|
|
63
55
|
this.#tryOnSocketRef.onopen = () => {
|
|
64
56
|
onOpen?.();
|
package/dist/tryOn.js
CHANGED
|
@@ -6,14 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const constants_js_1 = require("./constants.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
|
-
const ws_1 = __importDefault(require("ws"));
|
|
10
|
-
let WebSocketClient;
|
|
11
|
-
if (typeof window !== 'undefined' && window.WebSocket) {
|
|
12
|
-
WebSocketClient = window.WebSocket;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
WebSocketClient = ws_1.default;
|
|
16
|
-
}
|
|
17
9
|
class TryOn {
|
|
18
10
|
#tryOnSocketRef = null;
|
|
19
11
|
#timerWaitingRef = null;
|
|
@@ -126,7 +118,7 @@ class TryOn {
|
|
|
126
118
|
}
|
|
127
119
|
this.#disconnectSocket();
|
|
128
120
|
const url = `${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_BASE_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.TRY_ON}?tryonId=${tryonId}`;
|
|
129
|
-
this.#tryOnSocketRef = new
|
|
121
|
+
this.#tryOnSocketRef = new WebSocket(url);
|
|
130
122
|
if (this.#tryOnSocketRef) {
|
|
131
123
|
this.#tryOnSocketRef.onopen = async () => {
|
|
132
124
|
onOpen?.();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-admin/swan-ai-measurements",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.46",
|
|
4
4
|
"description": "provides ai measurement suggestion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
"socket.io": "^4.7.5",
|
|
22
22
|
"socket.io-client": "^4.7.5",
|
|
23
23
|
"tslib": "^2.6.2",
|
|
24
|
-
"typescript": "^5.4.5"
|
|
25
|
-
"ws": "^8.18.0"
|
|
24
|
+
"typescript": "^5.4.5"
|
|
26
25
|
},
|
|
27
26
|
"scripts": {
|
|
28
27
|
"start": "nodemon dist/index.js",
|
package/src/auth.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import axios, { AxiosResponse } from "axios";
|
|
2
2
|
import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
|
|
3
3
|
import { checkParameters, getUrl } from "./utils.js";
|
|
4
|
-
|
|
5
|
-
// Conditionally import ws for Node.js
|
|
6
|
-
let WebSocketClient: any;
|
|
7
|
-
if (typeof window !== "undefined" && window.WebSocket) {
|
|
8
|
-
WebSocketClient = window.WebSocket;
|
|
9
|
-
} else {
|
|
10
|
-
|
|
11
|
-
WebSocketClient = WS;
|
|
12
|
-
}
|
|
4
|
+
|
|
13
5
|
|
|
14
6
|
interface RegisterUserParams {
|
|
15
7
|
email: string;
|
|
@@ -101,7 +93,7 @@ export default class Auth {
|
|
|
101
93
|
}
|
|
102
94
|
if (this.#socketRef) this.#socketRef.close();
|
|
103
95
|
|
|
104
|
-
this.#socketRef = new
|
|
96
|
+
this.#socketRef = new WebSocket(`${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.AUTH}`);
|
|
105
97
|
const detailObj: AuthSocketDetail = { email, scanId };
|
|
106
98
|
if (this.#socketRef) {
|
|
107
99
|
this.#socketRef.onopen = () => {
|
package/src/measurement.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import axios, { AxiosResponse } from "axios";
|
|
2
2
|
import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
|
|
3
3
|
import { checkParameters, getUrl } from "./utils.js";
|
|
4
|
-
import WS from "ws";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
if (typeof window !== 'undefined' && window.WebSocket) {
|
|
8
|
-
WebSocketClient = window.WebSocket;
|
|
9
|
-
} else {
|
|
10
|
-
WebSocketClient = WS;
|
|
11
|
-
}
|
|
5
|
+
|
|
12
6
|
interface TryOnSocketOptions {
|
|
13
7
|
shopDomain: string;
|
|
14
8
|
scanId: string;
|
|
@@ -108,7 +102,7 @@ class Measurement {
|
|
|
108
102
|
urlName: APP_BASE_WEBSOCKET_URL,
|
|
109
103
|
stagingUrl: this.#stagingUrl,
|
|
110
104
|
})}/develop?store_url=${shopDomain}&product_name=${productName}&scan_id=${scanId}`;
|
|
111
|
-
this.#tryOnSocketRef = new
|
|
105
|
+
this.#tryOnSocketRef = new WebSocket(url);
|
|
112
106
|
if (this.#tryOnSocketRef) {
|
|
113
107
|
this.#tryOnSocketRef.onopen = () => {
|
|
114
108
|
onOpen?.();
|
package/src/tryOn.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import axios, { AxiosResponse } from "axios";
|
|
2
2
|
import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_ERROR_MESSAGE_INVALID_EMAIL, REQUIRED_MESSAGE } from "./constants.js";
|
|
3
3
|
import { checkParameters, getUrl, isValidEmail } from "./utils.js";
|
|
4
|
-
import WS from "ws";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
WebSocketClient = window.WebSocket;
|
|
9
|
-
} else {
|
|
10
|
-
WebSocketClient = WS;
|
|
11
|
-
}
|
|
5
|
+
|
|
6
|
+
|
|
12
7
|
|
|
13
8
|
interface UploadFileParams {
|
|
14
9
|
files: File[];
|
|
@@ -178,7 +173,7 @@ class TryOn {
|
|
|
178
173
|
}
|
|
179
174
|
this.#disconnectSocket();
|
|
180
175
|
const url = `${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON}?tryonId=${tryonId}`;
|
|
181
|
-
this.#tryOnSocketRef = new
|
|
176
|
+
this.#tryOnSocketRef = new WebSocket(url);
|
|
182
177
|
if(this.#tryOnSocketRef){
|
|
183
178
|
this.#tryOnSocketRef.onopen = async () => {
|
|
184
179
|
onOpen?.();
|