@odynn/awayz-flights 0.2.10 → 0.2.11
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.
|
@@ -95,13 +95,13 @@ function de(n, t) {
|
|
|
95
95
|
const p = Object.assign({}, r);
|
|
96
96
|
p.accept || (p.accept = j);
|
|
97
97
|
let m;
|
|
98
|
-
function
|
|
98
|
+
function C() {
|
|
99
99
|
m.abort(), document.hidden || T();
|
|
100
100
|
}
|
|
101
|
-
a || document.addEventListener("visibilitychange",
|
|
101
|
+
a || document.addEventListener("visibilitychange", C);
|
|
102
102
|
let F = ce, R = 0;
|
|
103
103
|
function S() {
|
|
104
|
-
document.removeEventListener("visibilitychange",
|
|
104
|
+
document.removeEventListener("visibilitychange", C), window.clearTimeout(R), m.abort();
|
|
105
105
|
}
|
|
106
106
|
o == null || o.addEventListener("abort", () => {
|
|
107
107
|
S(), g();
|
|
@@ -111,16 +111,16 @@ function de(n, t) {
|
|
|
111
111
|
var v;
|
|
112
112
|
m = new AbortController();
|
|
113
113
|
try {
|
|
114
|
-
const
|
|
115
|
-
await P(
|
|
114
|
+
const O = await H(n, Object.assign(Object.assign({}, b), { headers: p, signal: m.signal }));
|
|
115
|
+
await P(O), await oe(O.body, se(ae((h) => {
|
|
116
116
|
h ? p[z] = h : delete p[z];
|
|
117
117
|
}, (h) => {
|
|
118
118
|
F = h;
|
|
119
119
|
}, w))), c == null || c(), S(), g();
|
|
120
|
-
} catch (
|
|
120
|
+
} catch (O) {
|
|
121
121
|
if (!m.signal.aborted)
|
|
122
122
|
try {
|
|
123
|
-
const h = (v = u == null ? void 0 : u(
|
|
123
|
+
const h = (v = u == null ? void 0 : u(O)) !== null && v !== void 0 ? v : F;
|
|
124
124
|
window.clearTimeout(R), R = window.setTimeout(T, h);
|
|
125
125
|
} catch (h) {
|
|
126
126
|
S(), _(h);
|
|
@@ -152,7 +152,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
152
152
|
setOutboundResults: _,
|
|
153
153
|
partialOfferRequestId: p,
|
|
154
154
|
setPartialOfferRequestId: m
|
|
155
|
-
} = te(),
|
|
155
|
+
} = te(), C = ({
|
|
156
156
|
data: e,
|
|
157
157
|
inbound: f
|
|
158
158
|
}) => {
|
|
@@ -202,7 +202,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
202
202
|
console.log("oh lol, it didn't work");
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
C({ data: d }), i && m(i);
|
|
206
206
|
},
|
|
207
207
|
onError: (e) => {
|
|
208
208
|
console.error("Error in outbound flight search:", e);
|
|
@@ -225,7 +225,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
225
225
|
},
|
|
226
226
|
onSuccess: (e) => {
|
|
227
227
|
const { success: f, data: d } = e;
|
|
228
|
-
f &&
|
|
228
|
+
f && C({
|
|
229
229
|
data: d.offers,
|
|
230
230
|
inbound: !0
|
|
231
231
|
});
|
|
@@ -238,7 +238,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
238
238
|
}
|
|
239
239
|
}), {
|
|
240
240
|
mutate: v,
|
|
241
|
-
status:
|
|
241
|
+
status: O,
|
|
242
242
|
error: h
|
|
243
243
|
} = M({
|
|
244
244
|
mutationFn: async (e) => {
|
|
@@ -275,7 +275,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
275
275
|
});
|
|
276
276
|
let i = [], k = 0;
|
|
277
277
|
U = new AbortController(), a.current = setTimeout(() => {
|
|
278
|
-
|
|
278
|
+
y();
|
|
279
279
|
}, (((Y = t == null ? void 0 : t.flightsConfig) == null ? void 0 : Y.streamTimeoutTotalSeconds) || fe) * 1e3), de(re() + d, {
|
|
280
280
|
headers: {
|
|
281
281
|
"Content-Type": "application/json",
|
|
@@ -286,29 +286,29 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
286
286
|
signal: U.signal,
|
|
287
287
|
onmessage(N) {
|
|
288
288
|
try {
|
|
289
|
-
const
|
|
290
|
-
if (
|
|
289
|
+
const E = K(JSON.parse(N.data));
|
|
290
|
+
if (E.success === !1)
|
|
291
291
|
return;
|
|
292
|
-
if (
|
|
293
|
-
|
|
292
|
+
if (E.close === !0) {
|
|
293
|
+
y();
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
E.flights && (k = 0, i = [...i, ...E.flights], C({
|
|
297
297
|
data: i
|
|
298
|
-
})),
|
|
299
|
-
} catch (
|
|
300
|
-
console.error("Error parsing message:",
|
|
298
|
+
})), E.ping && (k++, k >= t.flightsConfig.streamTimeoutPingCount && y());
|
|
299
|
+
} catch (E) {
|
|
300
|
+
console.error("Error parsing message:", E), y();
|
|
301
301
|
}
|
|
302
302
|
},
|
|
303
303
|
onerror(N) {
|
|
304
|
-
throw console.error("EventSource error:", N),
|
|
304
|
+
throw console.error("EventSource error:", N), y(), N;
|
|
305
305
|
},
|
|
306
306
|
onclose() {
|
|
307
|
-
|
|
307
|
+
y();
|
|
308
308
|
},
|
|
309
309
|
keepalive: !1
|
|
310
310
|
});
|
|
311
|
-
},
|
|
311
|
+
}, y = () => {
|
|
312
312
|
U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [I.SEARCH_LIMIT] });
|
|
313
313
|
};
|
|
314
314
|
return {
|
|
@@ -323,7 +323,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
323
323
|
* @type {boolean}
|
|
324
324
|
* @default false
|
|
325
325
|
*/
|
|
326
|
-
loadingFares:
|
|
326
|
+
loadingFares: O === "pending",
|
|
327
327
|
outboundError: S,
|
|
328
328
|
inboundError: T,
|
|
329
329
|
roundTripFaresError: h,
|
|
@@ -339,7 +339,7 @@ const fe = 3 * 60 * 1e3, G = (n) => {
|
|
|
339
339
|
* @param {ISearchFlightArgs} args - The search arguments
|
|
340
340
|
*/
|
|
341
341
|
searchOutboundFlights: async (e) => {
|
|
342
|
-
switch (G(e), _([]), e.paymentType) {
|
|
342
|
+
switch (G(e), _([]), y(), e.paymentType) {
|
|
343
343
|
default:
|
|
344
344
|
case A.CASH_AND_MILES:
|
|
345
345
|
x(e);
|