@swan-admin/swan-ai-measurements 1.1.65 → 1.1.67
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/constants.d.ts +0 -1
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/measurement.d.ts +1 -0
- package/dist/esm/measurement.js +4 -2
- package/dist/measurement.d.ts +1 -0
- package/dist/measurement.js +4 -2
- package/package.json +1 -1
- package/src/constants.ts +0 -1
- package/src/measurement.ts +5 -2
package/dist/constants.d.ts
CHANGED
package/dist/esm/constants.d.ts
CHANGED
package/dist/esm/measurement.js
CHANGED
|
@@ -50,7 +50,7 @@ class Measurement {
|
|
|
50
50
|
return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Measurement_stagingUrl, "f") })}${API_ENDPOINTS.RECOMMENDATION}/scan/${scanId}/shop/${shopDomain}/product/${productName}`, { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Measurement_accessKey, "f") } });
|
|
51
51
|
}
|
|
52
52
|
handleMeasurementSocket(options) {
|
|
53
|
-
const { scanId, onError, onSuccess, onClose, onOpen } = options;
|
|
53
|
+
const { scanId, onError, onSuccess, onClose, onOpen, isFallback = true } = options;
|
|
54
54
|
if (!checkParameters(scanId)) {
|
|
55
55
|
throw new Error(REQUIRED_MESSAGE);
|
|
56
56
|
}
|
|
@@ -60,7 +60,9 @@ class Measurement {
|
|
|
60
60
|
__classPrivateFieldSet(this, _Measurement_measurementSocketRef, new WebSocket(url), "f");
|
|
61
61
|
__classPrivateFieldGet(this, _Measurement_measurementSocketRef, "f").onopen = () => {
|
|
62
62
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
63
|
-
|
|
63
|
+
if (isFallback) {
|
|
64
|
+
__classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_handleTimeOut).call(this, { scanId, onSuccess, onError });
|
|
65
|
+
}
|
|
64
66
|
};
|
|
65
67
|
__classPrivateFieldGet(this, _Measurement_measurementSocketRef, "f").onmessage = (event) => {
|
|
66
68
|
const data = JSON.parse(event.data);
|
package/dist/measurement.d.ts
CHANGED
package/dist/measurement.js
CHANGED
|
@@ -87,7 +87,7 @@ class Measurement {
|
|
|
87
87
|
}, 2 * 60000);
|
|
88
88
|
}
|
|
89
89
|
handleMeasurementSocket(options) {
|
|
90
|
-
const { scanId, onError, onSuccess, onClose, onOpen } = options;
|
|
90
|
+
const { scanId, onError, onSuccess, onClose, onOpen, isFallback = true } = options;
|
|
91
91
|
if (!(0, utils_js_1.checkParameters)(scanId)) {
|
|
92
92
|
throw new Error(constants_js_1.REQUIRED_MESSAGE);
|
|
93
93
|
}
|
|
@@ -97,7 +97,9 @@ class Measurement {
|
|
|
97
97
|
this.#measurementSocketRef = new WebSocket(url);
|
|
98
98
|
this.#measurementSocketRef.onopen = () => {
|
|
99
99
|
onOpen?.();
|
|
100
|
-
|
|
100
|
+
if (isFallback) {
|
|
101
|
+
this.#handleTimeOut({ scanId, onSuccess, onError });
|
|
102
|
+
}
|
|
101
103
|
};
|
|
102
104
|
this.#measurementSocketRef.onmessage = (event) => {
|
|
103
105
|
const data = JSON.parse(event.data);
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/measurement.ts
CHANGED
|
@@ -13,6 +13,7 @@ interface MeasurementSocketOptions {
|
|
|
13
13
|
onSuccess?: (data: any) => void;
|
|
14
14
|
onClose?: () => void;
|
|
15
15
|
onOpen?: () => void;
|
|
16
|
+
isFallback?:boolean
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
interface GetMeasurementsCheckOptions {
|
|
@@ -129,7 +130,7 @@ class Measurement {
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
handleMeasurementSocket(options: MeasurementSocketOptions): void {
|
|
132
|
-
const { scanId, onError, onSuccess, onClose, onOpen } = options;
|
|
133
|
+
const { scanId, onError, onSuccess, onClose, onOpen,isFallback=true } = options;
|
|
133
134
|
|
|
134
135
|
if (!checkParameters(scanId)) {
|
|
135
136
|
throw new Error(REQUIRED_MESSAGE);
|
|
@@ -141,7 +142,9 @@ class Measurement {
|
|
|
141
142
|
this.#measurementSocketRef = new WebSocket(url);
|
|
142
143
|
this.#measurementSocketRef.onopen = () => {
|
|
143
144
|
onOpen?.();
|
|
144
|
-
|
|
145
|
+
if (isFallback) {
|
|
146
|
+
this.#handleTimeOut({ scanId, onSuccess, onError });
|
|
147
|
+
}
|
|
145
148
|
};
|
|
146
149
|
|
|
147
150
|
this.#measurementSocketRef.onmessage = (event: MessageEvent) => {
|