@swan-admin/swan-ai-measurements 1.1.93 → 1.1.95
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.js +7 -5
- package/dist/measurement.js +6 -4
- package/package.json +1 -1
- package/src/measurement.ts +5 -4
package/dist/esm/measurement.js
CHANGED
|
@@ -96,7 +96,7 @@ _Measurement_socketRefs = new WeakMap(), _Measurement_waitingTimers = new WeakMa
|
|
|
96
96
|
}, (__classPrivateFieldGet(this, _Measurement_pollingCounts, "f")[key] || 1) * 5000);
|
|
97
97
|
}, _Measurement_getMeasurementsCheck = function _Measurement_getMeasurementsCheck(options, key) {
|
|
98
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
var _a;
|
|
99
|
+
var _a, _b;
|
|
100
100
|
const { scanId, onSuccess, onError } = options;
|
|
101
101
|
try {
|
|
102
102
|
const res = yield this.getMeasurementResult(scanId);
|
|
@@ -104,6 +104,11 @@ _Measurement_socketRefs = new WeakMap(), _Measurement_waitingTimers = new WeakMa
|
|
|
104
104
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res.data);
|
|
105
105
|
clearInterval(__classPrivateFieldGet(this, _Measurement_pollingTimers, "f")[key]);
|
|
106
106
|
}
|
|
107
|
+
else if ((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.failureReason) {
|
|
108
|
+
__classPrivateFieldGet(this, _Measurement_pollingCounts, "f")[key] = 1;
|
|
109
|
+
clearInterval(__classPrivateFieldGet(this, _Measurement_pollingTimers, "f")[key]);
|
|
110
|
+
onError === null || onError === void 0 ? void 0 : onError({ scanStatus: "failed", message: res.data.failureReason, isMeasured: false });
|
|
111
|
+
}
|
|
107
112
|
else {
|
|
108
113
|
if ((__classPrivateFieldGet(this, _Measurement_pollingCounts, "f")[key] || 1) < 8) {
|
|
109
114
|
__classPrivateFieldGet(this, _Measurement_pollingCounts, "f")[key] = (__classPrivateFieldGet(this, _Measurement_pollingCounts, "f")[key] || 1) + 1;
|
|
@@ -141,12 +146,9 @@ _Measurement_socketRefs = new WeakMap(), _Measurement_waitingTimers = new WeakMa
|
|
|
141
146
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
142
147
|
}
|
|
143
148
|
else {
|
|
144
|
-
clearTimeout(__classPrivateFieldGet(this, _Measurement_waitingTimers, "f")[key]);
|
|
145
149
|
onError === null || onError === void 0 ? void 0 : onError(data);
|
|
146
150
|
}
|
|
147
|
-
|
|
148
|
-
clearTimeout(__classPrivateFieldGet(this, _Measurement_waitingTimers, "f")[key]);
|
|
149
|
-
}
|
|
151
|
+
clearTimeout(__classPrivateFieldGet(this, _Measurement_waitingTimers, "f")[key]);
|
|
150
152
|
};
|
|
151
153
|
socket.onclose = () => onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
152
154
|
socket.onerror = () => {
|
package/dist/measurement.js
CHANGED
|
@@ -76,6 +76,11 @@ class Measurement {
|
|
|
76
76
|
onSuccess?.(res.data);
|
|
77
77
|
clearInterval(this.#pollingTimers[key]);
|
|
78
78
|
}
|
|
79
|
+
else if (res?.data?.failureReason) {
|
|
80
|
+
this.#pollingCounts[key] = 1;
|
|
81
|
+
clearInterval(this.#pollingTimers[key]);
|
|
82
|
+
onError?.({ scanStatus: "failed", message: res.data.failureReason, isMeasured: false });
|
|
83
|
+
}
|
|
79
84
|
else {
|
|
80
85
|
if ((this.#pollingCounts[key] || 1) < 8) {
|
|
81
86
|
this.#pollingCounts[key] = (this.#pollingCounts[key] || 1) + 1;
|
|
@@ -127,12 +132,9 @@ class Measurement {
|
|
|
127
132
|
onSuccess?.(data);
|
|
128
133
|
}
|
|
129
134
|
else {
|
|
130
|
-
clearTimeout(this.#waitingTimers[key]);
|
|
131
135
|
onError?.(data);
|
|
132
136
|
}
|
|
133
|
-
|
|
134
|
-
clearTimeout(this.#waitingTimers[key]);
|
|
135
|
-
}
|
|
137
|
+
clearTimeout(this.#waitingTimers[key]);
|
|
136
138
|
};
|
|
137
139
|
socket.onclose = () => onClose?.();
|
|
138
140
|
socket.onerror = () => {
|
package/package.json
CHANGED
package/src/measurement.ts
CHANGED
|
@@ -122,6 +122,10 @@ class Measurement {
|
|
|
122
122
|
if (res?.data && res?.data?.isMeasured === true) {
|
|
123
123
|
onSuccess?.(res.data);
|
|
124
124
|
clearInterval(this.#pollingTimers[key]!);
|
|
125
|
+
} else if (res?.data?.failureReason) {
|
|
126
|
+
this.#pollingCounts[key] = 1;
|
|
127
|
+
clearInterval(this.#pollingTimers[key]!);
|
|
128
|
+
onError?.({ scanStatus: "failed", message: res.data.failureReason, isMeasured: false });
|
|
125
129
|
} else {
|
|
126
130
|
if ((this.#pollingCounts[key] || 1) < 8) {
|
|
127
131
|
this.#pollingCounts[key] = (this.#pollingCounts[key] || 1) + 1;
|
|
@@ -175,12 +179,9 @@ class Measurement {
|
|
|
175
179
|
if (data?.code === 200 && data?.scanStatus === "success") {
|
|
176
180
|
onSuccess?.(data);
|
|
177
181
|
} else {
|
|
178
|
-
clearTimeout(this.#waitingTimers[key]!);
|
|
179
182
|
onError?.(data);
|
|
180
183
|
}
|
|
181
|
-
|
|
182
|
-
clearTimeout(this.#waitingTimers[key]!);
|
|
183
|
-
}
|
|
184
|
+
clearTimeout(this.#waitingTimers[key]!);
|
|
184
185
|
};
|
|
185
186
|
|
|
186
187
|
socket.onclose = () => onClose?.();
|