@swan-admin/swan-ai-measurements 1.1.44 → 1.1.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.1.44",
3
+ "version": "1.1.45",
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
- import WS from "ws";
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 WebSocketClient(`${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.AUTH}`);
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 = () => {
@@ -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
- let WebSocketClient: any;
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 WebSocketClient(url);
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
- let WebSocketClient: any;
7
- if (typeof window !== 'undefined' && window.WebSocket) {
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 WebSocketClient(url);
176
+ this.#tryOnSocketRef = new WebSocket(url);
182
177
  if(this.#tryOnSocketRef){
183
178
  this.#tryOnSocketRef.onopen = async () => {
184
179
  onOpen?.();