@swan-admin/swan-ai-measurements 1.1.92 → 1.1.94
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 +1 -0
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/measurement.js +7 -2
- package/dist/measurement.js +6 -1
- package/package.json +1 -1
- package/src/measurement.ts +5 -1
package/dist/constants.d.ts
CHANGED
package/dist/esm/constants.d.ts
CHANGED
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;
|
|
@@ -137,7 +142,7 @@ _Measurement_socketRefs = new WeakMap(), _Measurement_waitingTimers = new WeakMa
|
|
|
137
142
|
};
|
|
138
143
|
socket.onmessage = (event) => {
|
|
139
144
|
const data = JSON.parse(event.data);
|
|
140
|
-
if ((data === null || data === void 0 ? void 0 : data.code) === 200 && (data === null || data === void 0 ? void 0 : data.scanStatus) === "success") {
|
|
145
|
+
if ((data === null || data === void 0 ? void 0 : data.code) === 200 && (data === null || data === void 0 ? void 0 : data.scanStatus) === "success" && (data === null || data === void 0 ? void 0 : data.isMeasured) === true) {
|
|
141
146
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
142
147
|
}
|
|
143
148
|
else {
|
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;
|
|
@@ -123,7 +128,7 @@ class Measurement {
|
|
|
123
128
|
};
|
|
124
129
|
socket.onmessage = (event) => {
|
|
125
130
|
const data = JSON.parse(event.data);
|
|
126
|
-
if (data?.code === 200 && data?.scanStatus === "success") {
|
|
131
|
+
if (data?.code === 200 && data?.scanStatus === "success" && data?.isMeasured === true) {
|
|
127
132
|
onSuccess?.(data);
|
|
128
133
|
}
|
|
129
134
|
else {
|
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;
|
|
@@ -172,7 +176,7 @@ class Measurement {
|
|
|
172
176
|
|
|
173
177
|
socket.onmessage = (event: MessageEvent) => {
|
|
174
178
|
const data = JSON.parse(event.data);
|
|
175
|
-
if (data?.code === 200 && data?.scanStatus === "success") {
|
|
179
|
+
if (data?.code === 200 && data?.scanStatus === "success" && data?.isMeasured === true) {
|
|
176
180
|
onSuccess?.(data);
|
|
177
181
|
} else {
|
|
178
182
|
clearTimeout(this.#waitingTimers[key]!);
|