@swan-admin/swan-ai-measurements 1.1.85 → 1.1.87
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/esm/measurement.d.ts +1 -0
- package/dist/esm/measurement.js +2 -1
- package/dist/esm/tryOn.d.ts +1 -1
- package/dist/esm/tryOn.js +2 -6
- package/dist/measurement.d.ts +1 -0
- package/dist/measurement.js +2 -1
- package/dist/tryOn.d.ts +1 -1
- package/dist/tryOn.js +2 -6
- package/package.json +1 -1
- package/src/measurement.ts +3 -1
- package/src/tryOn.ts +2 -6
package/dist/esm/measurement.js
CHANGED
|
@@ -117,10 +117,11 @@ _Measurement_socketRefs = new WeakMap(), _Measurement_waitingTimers = new WeakMa
|
|
|
117
117
|
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
|
-
}, _Measurement_handleSocket = function _Measurement_handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId, delay }) {
|
|
120
|
+
}, _Measurement_handleSocket = function _Measurement_handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId, delay, onPreopen }) {
|
|
121
121
|
const key = isFallback ? `measurement-${scanId}` : `faceScan-${faceScanId}`;
|
|
122
122
|
setTimeout(() => {
|
|
123
123
|
__classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_disconnectSocket).call(this, key);
|
|
124
|
+
onPreopen === null || onPreopen === void 0 ? void 0 : onPreopen();
|
|
124
125
|
const url = `${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, urlType: __classPrivateFieldGet(this, _Measurement_urlType, "f") })}${API_ENDPOINTS.SCANNING}?${paramsKey}=${scanId || faceScanId}`;
|
|
125
126
|
const socket = new WebSocket(url);
|
|
126
127
|
__classPrivateFieldGet(this, _Measurement_socketRefs, "f")[key] = socket;
|
package/dist/esm/tryOn.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare class TryOn {
|
|
|
50
50
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
51
51
|
handleTryOnWebSocket: ({ tryonId, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
52
52
|
handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token, requestedTryonViews }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
53
|
-
getShareLink(tryonId: string): Promise<AxiosResponse<any
|
|
53
|
+
getShareLink(tryonId: string, token: string): Promise<AxiosResponse<any>>;
|
|
54
54
|
getTryOnResult: ({ tryonId }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
55
55
|
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
|
|
56
56
|
}
|
package/dist/esm/tryOn.js
CHANGED
|
@@ -89,13 +89,9 @@ class TryOn {
|
|
|
89
89
|
};
|
|
90
90
|
socket.onclose = () => {
|
|
91
91
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
92
|
-
// this.#disconnectSocket(tryonId);
|
|
93
92
|
};
|
|
94
93
|
socket.onerror = (event) => {
|
|
95
94
|
onError === null || onError === void 0 ? void 0 : onError(event);
|
|
96
|
-
// const timer = this.#timerMap.get(tryonId);
|
|
97
|
-
// if (timer) clearTimeout(timer);
|
|
98
|
-
// this.#timerMap.delete(tryonId);
|
|
99
95
|
};
|
|
100
96
|
};
|
|
101
97
|
_TryOn_handleGetTryOnResult.set(this, (_a) => __awaiter(this, [_a], void 0, function* ({ onSuccess, onError, tryonId }) {
|
|
@@ -196,9 +192,9 @@ class TryOn {
|
|
|
196
192
|
headers,
|
|
197
193
|
});
|
|
198
194
|
}
|
|
199
|
-
getShareLink(tryonId) {
|
|
195
|
+
getShareLink(tryonId, token) {
|
|
200
196
|
return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _TryOn_urlType, "f") })}${API_ENDPOINTS.TRY_ON_SHARE}`, { tryonId }, {
|
|
201
|
-
headers: { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") },
|
|
197
|
+
headers: Object.assign({ "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") }, (token ? { Authorization: `Bearer ${token}` } : {})),
|
|
202
198
|
});
|
|
203
199
|
}
|
|
204
200
|
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }) {
|
package/dist/measurement.d.ts
CHANGED
package/dist/measurement.js
CHANGED
|
@@ -99,10 +99,11 @@ class Measurement {
|
|
|
99
99
|
}
|
|
100
100
|
this.#handleSocket({ onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false, delay: 1000 });
|
|
101
101
|
}
|
|
102
|
-
#handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId, delay }) {
|
|
102
|
+
#handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId, delay, onPreopen }) {
|
|
103
103
|
const key = isFallback ? `measurement-${scanId}` : `faceScan-${faceScanId}`;
|
|
104
104
|
setTimeout(() => {
|
|
105
105
|
this.#disconnectSocket(key);
|
|
106
|
+
onPreopen?.();
|
|
106
107
|
const url = `${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_BASE_WEBSOCKET_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.SCANNING}?${paramsKey}=${scanId || faceScanId}`;
|
|
107
108
|
const socket = new WebSocket(url);
|
|
108
109
|
this.#socketRefs[key] = socket;
|
package/dist/tryOn.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare class TryOn {
|
|
|
50
50
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
51
51
|
handleTryOnWebSocket: ({ tryonId, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
52
52
|
handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token, requestedTryonViews }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
53
|
-
getShareLink(tryonId: string): Promise<AxiosResponse<any
|
|
53
|
+
getShareLink(tryonId: string, token: string): Promise<AxiosResponse<any>>;
|
|
54
54
|
getTryOnResult: ({ tryonId }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
55
55
|
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
|
|
56
56
|
}
|
package/dist/tryOn.js
CHANGED
|
@@ -157,13 +157,9 @@ class TryOn {
|
|
|
157
157
|
};
|
|
158
158
|
socket.onclose = () => {
|
|
159
159
|
onClose?.();
|
|
160
|
-
// this.#disconnectSocket(tryonId);
|
|
161
160
|
};
|
|
162
161
|
socket.onerror = (event) => {
|
|
163
162
|
onError?.(event);
|
|
164
|
-
// const timer = this.#timerMap.get(tryonId);
|
|
165
|
-
// if (timer) clearTimeout(timer);
|
|
166
|
-
// this.#timerMap.delete(tryonId);
|
|
167
163
|
};
|
|
168
164
|
};
|
|
169
165
|
handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token, requestedTryonViews }) {
|
|
@@ -198,9 +194,9 @@ class TryOn {
|
|
|
198
194
|
onError?.(error);
|
|
199
195
|
}
|
|
200
196
|
};
|
|
201
|
-
getShareLink(tryonId) {
|
|
197
|
+
getShareLink(tryonId, token) {
|
|
202
198
|
return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.TRY_ON_SHARE}`, { tryonId }, {
|
|
203
|
-
headers: { "X-Api-Key": this.#accessKey },
|
|
199
|
+
headers: { "X-Api-Key": this.#accessKey, ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
|
204
200
|
});
|
|
205
201
|
}
|
|
206
202
|
getTryOnResult = ({ tryonId }) => {
|
package/package.json
CHANGED
package/src/measurement.ts
CHANGED
|
@@ -13,6 +13,7 @@ interface Callbacks {
|
|
|
13
13
|
onSuccess?: (data: any) => void;
|
|
14
14
|
onClose?: () => void;
|
|
15
15
|
onOpen?: () => void;
|
|
16
|
+
onPreopen?: () => void;
|
|
16
17
|
}
|
|
17
18
|
interface MeasurementSocketOptions extends Callbacks {
|
|
18
19
|
scanId: string;
|
|
@@ -144,10 +145,11 @@ class Measurement {
|
|
|
144
145
|
this.#handleSocket({ onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false, delay: 1000 });
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
#handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId, delay }: HandleSocket) {
|
|
148
|
+
#handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId, delay, onPreopen }: HandleSocket) {
|
|
148
149
|
const key = isFallback ? `measurement-${scanId}` : `faceScan-${faceScanId}`;
|
|
149
150
|
setTimeout(() => {
|
|
150
151
|
this.#disconnectSocket(key);
|
|
152
|
+
onPreopen?.()
|
|
151
153
|
const url = `${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, urlType: this.#urlType })}${API_ENDPOINTS.SCANNING}?${paramsKey}=${scanId || faceScanId}`;
|
|
152
154
|
const socket = new WebSocket(url);
|
|
153
155
|
this.#socketRefs[key] = socket;
|
package/src/tryOn.ts
CHANGED
|
@@ -222,14 +222,10 @@ class TryOn {
|
|
|
222
222
|
|
|
223
223
|
socket.onclose = () => {
|
|
224
224
|
onClose?.();
|
|
225
|
-
// this.#disconnectSocket(tryonId);
|
|
226
225
|
};
|
|
227
226
|
|
|
228
227
|
socket.onerror = (event) => {
|
|
229
228
|
onError?.(event);
|
|
230
|
-
// const timer = this.#timerMap.get(tryonId);
|
|
231
|
-
// if (timer) clearTimeout(timer);
|
|
232
|
-
// this.#timerMap.delete(tryonId);
|
|
233
229
|
};
|
|
234
230
|
};
|
|
235
231
|
|
|
@@ -268,12 +264,12 @@ class TryOn {
|
|
|
268
264
|
}
|
|
269
265
|
};
|
|
270
266
|
|
|
271
|
-
getShareLink(tryonId: string) {
|
|
267
|
+
getShareLink(tryonId: string,token:string): Promise<AxiosResponse<any>> {
|
|
272
268
|
return axios.post(
|
|
273
269
|
`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: this.#urlType })}${API_ENDPOINTS.TRY_ON_SHARE}`,
|
|
274
270
|
{ tryonId },
|
|
275
271
|
{
|
|
276
|
-
headers: { "X-Api-Key": this.#accessKey },
|
|
272
|
+
headers: { "X-Api-Key": this.#accessKey, ...(token ? { Authorization: `Bearer ${token}` } : {}) },
|
|
277
273
|
},
|
|
278
274
|
);
|
|
279
275
|
}
|