@tma.js/bridge 2.2.3 → 2.2.5
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/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +183 -173
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { createLogger as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import * as T from "valibot";
|
|
2
|
+
import { looseObject as d, nullish as v, boolean as I, number as $, string as E, optional as z, unknown as me, parse as L, is as Y, function as we, any as de } from "valibot";
|
|
3
|
+
import { throwifyFpFn as A, getStorageValue as ge, setStorageValue as X, createLogger as be, throwifyAnyEither as C, createCbCollector as Z, BetterTaskEither as ee } from "@tma.js/toolkit";
|
|
4
|
+
import { createLogger as vt, deepSnakeToCamelObjKeys as Et } from "@tma.js/toolkit";
|
|
5
|
+
import { BetterPromise as te, TimeoutError as he } from "better-promises";
|
|
6
|
+
import { CancelledError as xt, TimeoutError as kt } from "better-promises";
|
|
7
|
+
import { function as f, either as c, option as j, taskEither as m, json as ye } from "fp-ts";
|
|
8
|
+
import { errorClassWithData as ve, errorClass as x } from "error-kid";
|
|
9
|
+
import { parseLaunchParamsQueryFp as re, themeParams as Ee, pipeJsonToSchema as ne, miniAppsMessage as oe, serializeLaunchParamsQuery as Pe, parseLaunchParamsQuery as xe } from "@tma.js/transformers";
|
|
9
10
|
import { signal as b, computed as ae } from "@tma.js/signals";
|
|
10
11
|
import ke from "mitt";
|
|
11
12
|
function se(e) {
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
e
|
|
13
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && T.is(
|
|
14
|
+
T.looseObject({ TelegramWebviewProxy: T.looseObject({ postEvent: T.function() }) }),
|
|
15
|
+
{ TelegramWebviewProxy: e.TelegramWebviewProxy }
|
|
15
16
|
);
|
|
16
17
|
}
|
|
17
18
|
function ie() {
|
|
@@ -21,18 +22,24 @@ function ie() {
|
|
|
21
22
|
return !0;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
class
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
class Te extends (/* @__PURE__ */ x({
|
|
26
|
+
name: "MethodUnsupportedError",
|
|
27
|
+
super: (t, r) => [
|
|
28
|
+
`Method "${t}" is unsupported in Mini Apps version ${r}`
|
|
29
|
+
]
|
|
30
|
+
})) {
|
|
27
31
|
}
|
|
28
|
-
class Se extends (/* @__PURE__ */
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
class Se extends (/* @__PURE__ */ x({
|
|
33
|
+
name: "MethodParameterUnsupportedError",
|
|
34
|
+
super: (t, r, n) => [
|
|
35
|
+
`Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
|
|
36
|
+
]
|
|
37
|
+
})) {
|
|
31
38
|
}
|
|
32
|
-
class
|
|
33
|
-
"LaunchParamsRetrieveError",
|
|
34
|
-
(t) => ({ errors: t }),
|
|
35
|
-
(t) => [
|
|
39
|
+
class Ae extends (/* @__PURE__ */ ve({
|
|
40
|
+
name: "LaunchParamsRetrieveError",
|
|
41
|
+
data: (t) => ({ errors: t }),
|
|
42
|
+
super: (t) => [
|
|
36
43
|
[
|
|
37
44
|
"Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?",
|
|
38
45
|
"📖 Refer to docs for more information:",
|
|
@@ -43,51 +50,54 @@ class Te extends (/* @__PURE__ */ ye(
|
|
|
43
50
|
].join(`
|
|
44
51
|
`)
|
|
45
52
|
]
|
|
46
|
-
)) {
|
|
53
|
+
})) {
|
|
47
54
|
}
|
|
48
|
-
class
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
class Ce extends (/* @__PURE__ */ x({
|
|
56
|
+
name: "InvalidLaunchParamsError",
|
|
57
|
+
super: (t, r) => [
|
|
58
|
+
`Invalid value for launch params: ${t}`,
|
|
59
|
+
{ cause: r }
|
|
60
|
+
]
|
|
61
|
+
})) {
|
|
52
62
|
}
|
|
53
|
-
class pe extends (/* @__PURE__ */
|
|
63
|
+
class pe extends (/* @__PURE__ */ x({ name: "UnknownEnvError" })) {
|
|
54
64
|
}
|
|
55
|
-
class
|
|
56
|
-
"InvokeCustomMethodError",
|
|
57
|
-
(t) => [`Server returned error: ${t}`]
|
|
58
|
-
)) {
|
|
65
|
+
class Me extends (/* @__PURE__ */ x({
|
|
66
|
+
name: "InvokeCustomMethodError",
|
|
67
|
+
super: (t) => [`Server returned error: ${t}`]
|
|
68
|
+
})) {
|
|
59
69
|
}
|
|
60
70
|
const V = "launchParams";
|
|
61
71
|
function B(e) {
|
|
62
72
|
return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
|
|
63
73
|
}
|
|
64
|
-
function
|
|
74
|
+
function We() {
|
|
65
75
|
return f.pipe(
|
|
66
|
-
|
|
76
|
+
M(),
|
|
67
77
|
c.chainW(re)
|
|
68
78
|
);
|
|
69
79
|
}
|
|
70
|
-
const
|
|
80
|
+
const rt = A(We);
|
|
71
81
|
function qe() {
|
|
72
82
|
return f.pipe(
|
|
73
|
-
|
|
83
|
+
M(),
|
|
74
84
|
c.map((e) => {
|
|
75
85
|
const t = new URLSearchParams(e).get("tgWebAppData");
|
|
76
|
-
return t ?
|
|
86
|
+
return t ? j.some(t) : j.none;
|
|
77
87
|
})
|
|
78
88
|
);
|
|
79
89
|
}
|
|
80
|
-
function
|
|
90
|
+
function nt() {
|
|
81
91
|
return f.pipe(
|
|
82
92
|
qe(),
|
|
83
93
|
c.fold((e) => {
|
|
84
94
|
throw e;
|
|
85
95
|
}, (e) => e),
|
|
86
|
-
|
|
96
|
+
j.match(() => {
|
|
87
97
|
}, (e) => e)
|
|
88
98
|
);
|
|
89
99
|
}
|
|
90
|
-
function
|
|
100
|
+
function M() {
|
|
91
101
|
const e = [];
|
|
92
102
|
for (const [t, r] of [
|
|
93
103
|
// Try to retrieve launch parameters from the current location. This method
|
|
@@ -100,7 +110,7 @@ function C() {
|
|
|
100
110
|
return n && B(n.name);
|
|
101
111
|
}, "performance navigation entries"],
|
|
102
112
|
// Finally, try using the session storage.
|
|
103
|
-
[() =>
|
|
113
|
+
[() => ge(V), "local storage"]
|
|
104
114
|
]) {
|
|
105
115
|
const n = t();
|
|
106
116
|
if (!n) {
|
|
@@ -117,10 +127,10 @@ function C() {
|
|
|
117
127
|
}
|
|
118
128
|
return X(V, n), c.right(n);
|
|
119
129
|
}
|
|
120
|
-
return c.left(new
|
|
130
|
+
return c.left(new Ae(e));
|
|
121
131
|
}
|
|
122
|
-
const
|
|
123
|
-
function
|
|
132
|
+
const ot = A(M);
|
|
133
|
+
function Fe(e, t) {
|
|
124
134
|
const r = /* @__PURE__ */ new Map(), n = ke(), a = (o, s, p = !1) => {
|
|
125
135
|
const _ = r.get(o) || /* @__PURE__ */ new Map();
|
|
126
136
|
r.set(o, _);
|
|
@@ -137,8 +147,8 @@ function We(e, t) {
|
|
|
137
147
|
!r.size && e();
|
|
138
148
|
const _ = () => {
|
|
139
149
|
a(o, s, p);
|
|
140
|
-
}, i = (...
|
|
141
|
-
p && _(), o === "*" ? s({ name:
|
|
150
|
+
}, i = (...w) => {
|
|
151
|
+
p && _(), o === "*" ? s({ name: w[0], payload: w[1] }) : s(...w);
|
|
142
152
|
};
|
|
143
153
|
n.on(o, i);
|
|
144
154
|
const u = r.get(o) || /* @__PURE__ */ new Map();
|
|
@@ -164,29 +174,29 @@ function q(e, t) {
|
|
|
164
174
|
source: window.parent
|
|
165
175
|
}));
|
|
166
176
|
}
|
|
167
|
-
const S = b(!1),
|
|
177
|
+
const S = b(!1), O = b("https://web.telegram.org"), Le = (e) => {
|
|
168
178
|
g().log("Event received:", e);
|
|
169
179
|
}, ce = ae(S);
|
|
170
|
-
function ot(e) {
|
|
171
|
-
e !== S() && (S.set(e), (e ? j : Oe)("*", Fe));
|
|
172
|
-
}
|
|
173
|
-
const _e = ae(R);
|
|
174
180
|
function at(e) {
|
|
175
|
-
|
|
181
|
+
e !== S() && (S.set(e), (e ? R : Oe)("*", Le));
|
|
182
|
+
}
|
|
183
|
+
const _e = ae(O);
|
|
184
|
+
function st(e) {
|
|
185
|
+
O.set(e), g().log("New target origin set", e);
|
|
176
186
|
}
|
|
177
187
|
const P = b((...e) => {
|
|
178
188
|
window.parent.postMessage(...e);
|
|
179
|
-
}), g = b(
|
|
189
|
+
}), g = b(be("Bridge", {
|
|
180
190
|
bgColor: "#9147ff",
|
|
181
191
|
textColor: "white",
|
|
182
192
|
shouldLog: ce
|
|
183
193
|
}));
|
|
184
|
-
function
|
|
185
|
-
|
|
194
|
+
function it() {
|
|
195
|
+
Ue(), [P, O, _e, S, ce, g].forEach((e) => {
|
|
186
196
|
e.unsubAll(), "reset" in e && e.reset();
|
|
187
197
|
});
|
|
188
198
|
}
|
|
189
|
-
function
|
|
199
|
+
function F(e, t, r) {
|
|
190
200
|
const n = [r], a = e[t];
|
|
191
201
|
typeof a == "function" && n.push(a);
|
|
192
202
|
const o = (...p) => {
|
|
@@ -239,23 +249,23 @@ function D(e, t, r) {
|
|
|
239
249
|
value: r
|
|
240
250
|
});
|
|
241
251
|
}
|
|
242
|
-
const
|
|
243
|
-
clipboard_text_received:
|
|
252
|
+
const je = {
|
|
253
|
+
clipboard_text_received: d({
|
|
244
254
|
req_id: E(),
|
|
245
255
|
data: v(E())
|
|
246
256
|
}),
|
|
247
|
-
custom_method_invoked:
|
|
257
|
+
custom_method_invoked: d({
|
|
248
258
|
req_id: E(),
|
|
249
259
|
result: z(me()),
|
|
250
260
|
error: z(E())
|
|
251
261
|
}),
|
|
252
262
|
popup_closed: v(
|
|
253
|
-
|
|
263
|
+
d({ button_id: v(E(), () => {
|
|
254
264
|
}) }),
|
|
255
265
|
{}
|
|
256
266
|
),
|
|
257
267
|
viewport_changed: v(
|
|
258
|
-
|
|
268
|
+
d({
|
|
259
269
|
height: $(),
|
|
260
270
|
width: v($(), () => window.innerWidth),
|
|
261
271
|
is_state_stable: I(),
|
|
@@ -269,8 +279,8 @@ const Le = {
|
|
|
269
279
|
is_expanded: !0
|
|
270
280
|
})
|
|
271
281
|
),
|
|
272
|
-
theme_changed:
|
|
273
|
-
theme_params:
|
|
282
|
+
theme_changed: d({
|
|
283
|
+
theme_params: Ee()
|
|
274
284
|
})
|
|
275
285
|
};
|
|
276
286
|
function J(e) {
|
|
@@ -278,14 +288,14 @@ function J(e) {
|
|
|
278
288
|
return;
|
|
279
289
|
let t;
|
|
280
290
|
try {
|
|
281
|
-
t =
|
|
291
|
+
t = L(ne(oe()), e.data);
|
|
282
292
|
} catch {
|
|
283
293
|
return;
|
|
284
294
|
}
|
|
285
|
-
const { eventType: r, eventData: n } = t, a =
|
|
295
|
+
const { eventType: r, eventData: n } = t, a = je[r];
|
|
286
296
|
let o;
|
|
287
297
|
try {
|
|
288
|
-
o = a ?
|
|
298
|
+
o = a ? L(a, n) : n;
|
|
289
299
|
} catch (s) {
|
|
290
300
|
return g().forceError(
|
|
291
301
|
[
|
|
@@ -301,14 +311,14 @@ function J(e) {
|
|
|
301
311
|
Re(r, o);
|
|
302
312
|
}
|
|
303
313
|
const {
|
|
304
|
-
on:
|
|
314
|
+
on: R,
|
|
305
315
|
off: Oe,
|
|
306
316
|
emit: Re,
|
|
307
|
-
clear:
|
|
308
|
-
} =
|
|
317
|
+
clear: Ue
|
|
318
|
+
} = Fe(
|
|
309
319
|
() => {
|
|
310
320
|
const e = window;
|
|
311
|
-
!e.TelegramGameProxy && (e.TelegramGameProxy = {}),
|
|
321
|
+
!e.TelegramGameProxy && (e.TelegramGameProxy = {}), F(e.TelegramGameProxy, "receiveEvent", q), G(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), F(e.Telegram.WebView, "receiveEvent", q), G(e.Telegram, "WebView"), F(e, "TelegramGameProxy_receiveEvent", q), window.addEventListener("message", J);
|
|
312
322
|
},
|
|
313
323
|
() => {
|
|
314
324
|
[
|
|
@@ -325,10 +335,10 @@ const {
|
|
|
325
335
|
"unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
|
|
326
336
|
}), window.removeEventListener("message", J);
|
|
327
337
|
}
|
|
328
|
-
),
|
|
329
|
-
function
|
|
338
|
+
), Ie = (...e) => P()(...e);
|
|
339
|
+
function $e(e, t) {
|
|
330
340
|
f.pipe(
|
|
331
|
-
|
|
341
|
+
k(
|
|
332
342
|
// @ts-expect-error It's ok, TS can't determine a specific override.
|
|
333
343
|
e,
|
|
334
344
|
t
|
|
@@ -338,20 +348,20 @@ function Ie(e, t) {
|
|
|
338
348
|
})
|
|
339
349
|
);
|
|
340
350
|
}
|
|
341
|
-
function
|
|
351
|
+
function k(e, t) {
|
|
342
352
|
g().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
|
|
343
353
|
const r = window, n = JSON.stringify({ eventType: e, eventData: t });
|
|
344
|
-
return ie() ? (
|
|
354
|
+
return ie() ? (Ie(n, _e()), c.right(void 0)) : se(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : Y(d({ external: d({ notify: we() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new pe());
|
|
345
355
|
}
|
|
346
356
|
function U(e, t, r = {}) {
|
|
347
357
|
const {
|
|
348
358
|
// If no capture function was passed, we capture the first compatible event.
|
|
349
359
|
capture: n = () => !0,
|
|
350
|
-
postEvent: a =
|
|
360
|
+
postEvent: a = k
|
|
351
361
|
} = r, o = b(), [s, p] = Z();
|
|
352
362
|
(Array.isArray(t) ? t : [t]).forEach((i) => {
|
|
353
363
|
s(
|
|
354
|
-
|
|
364
|
+
R(i, (u) => {
|
|
355
365
|
const l = Array.isArray(t);
|
|
356
366
|
n(l ? { event: i, payload: u } : u) && o.set([
|
|
357
367
|
l ? { event: i, payload: u } : u
|
|
@@ -362,23 +372,23 @@ function U(e, t, r = {}) {
|
|
|
362
372
|
const _ = (i) => (p(), i);
|
|
363
373
|
return f.pipe(
|
|
364
374
|
async () => a(e, r.params),
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
return i(
|
|
375
|
+
m.chainW(() => ee((i, u, l) => {
|
|
376
|
+
const w = o();
|
|
377
|
+
if (w)
|
|
378
|
+
return i(w[0]);
|
|
369
379
|
const h = (y) => {
|
|
370
380
|
y && i(y[0]);
|
|
371
|
-
},
|
|
381
|
+
}, W = () => {
|
|
372
382
|
o.unsub(h);
|
|
373
383
|
};
|
|
374
|
-
o.sub(h), l.on("finalized",
|
|
384
|
+
o.sub(h), l.on("finalized", W);
|
|
375
385
|
}, r)),
|
|
376
|
-
|
|
386
|
+
m.mapBoth(_, _)
|
|
377
387
|
);
|
|
378
388
|
}
|
|
379
|
-
function
|
|
389
|
+
function pt(e, t, r) {
|
|
380
390
|
const { postEvent: n } = r || {};
|
|
381
|
-
return
|
|
391
|
+
return C(
|
|
382
392
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
383
393
|
U(e, t, {
|
|
384
394
|
...r,
|
|
@@ -388,45 +398,45 @@ function it(e, t, r) {
|
|
|
388
398
|
} catch (o) {
|
|
389
399
|
return c.left(o);
|
|
390
400
|
}
|
|
391
|
-
} :
|
|
401
|
+
} : k
|
|
392
402
|
})
|
|
393
403
|
);
|
|
394
404
|
}
|
|
395
|
-
function
|
|
396
|
-
const r =
|
|
405
|
+
function ct(e, t) {
|
|
406
|
+
const r = ze(
|
|
397
407
|
// @ts-expect-error TS doesn't get what override we are going to use.
|
|
398
408
|
e,
|
|
399
409
|
t
|
|
400
410
|
);
|
|
401
|
-
return typeof r == "function" ? te.fn(() =>
|
|
411
|
+
return typeof r == "function" ? te.fn(() => C(r)) : r;
|
|
402
412
|
}
|
|
403
|
-
function
|
|
413
|
+
function ze(e, t) {
|
|
404
414
|
const r = se(window);
|
|
405
415
|
if (!e)
|
|
406
|
-
return r || f.pipe(
|
|
416
|
+
return r || f.pipe(M(), c.match(() => !1, () => !0));
|
|
407
417
|
if (r)
|
|
408
|
-
return
|
|
418
|
+
return m.right(!0);
|
|
409
419
|
const { timeout: n = 100 } = t || {};
|
|
410
420
|
return f.pipe(
|
|
411
421
|
U("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
|
|
412
|
-
|
|
413
|
-
(a) =>
|
|
422
|
+
m.match(
|
|
423
|
+
(a) => he.is(a) || pe.is(a) ? c.right(!1) : c.left(a),
|
|
414
424
|
() => c.right(!0)
|
|
415
425
|
)
|
|
416
426
|
);
|
|
417
427
|
}
|
|
418
|
-
function
|
|
428
|
+
function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
419
429
|
if (e) {
|
|
420
430
|
const o = typeof e == "string" || e instanceof URLSearchParams ? e.toString() : (
|
|
421
431
|
// Here we have to trick serializeLaunchParamsQuery into thinking, it serializes a valid
|
|
422
432
|
// value. We are doing it because we are working with tgWebAppData presented as a
|
|
423
433
|
// string, not an object as serializeLaunchParamsQuery requires.
|
|
424
|
-
|
|
434
|
+
Pe({ ...e, tgWebAppData: void 0 }) + (e.tgWebAppData ? `&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}` : "")
|
|
425
435
|
);
|
|
426
436
|
try {
|
|
427
|
-
|
|
437
|
+
xe(o);
|
|
428
438
|
} catch (s) {
|
|
429
|
-
throw new
|
|
439
|
+
throw new Ce(o, s);
|
|
430
440
|
}
|
|
431
441
|
X("launchParams", o);
|
|
432
442
|
}
|
|
@@ -440,7 +450,7 @@ function ct({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
440
450
|
o(...s);
|
|
441
451
|
};
|
|
442
452
|
try {
|
|
443
|
-
const i =
|
|
453
|
+
const i = L(ne(oe()), p);
|
|
444
454
|
t({ name: i.eventType, params: i.eventData }, _);
|
|
445
455
|
} catch {
|
|
446
456
|
_();
|
|
@@ -463,7 +473,7 @@ function ct({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
463
473
|
}
|
|
464
474
|
}, g().log("Environment was mocked by the mockTelegramEnv function");
|
|
465
475
|
}
|
|
466
|
-
function
|
|
476
|
+
function Ve(e) {
|
|
467
477
|
return ({ req_id: t }) => t === e;
|
|
468
478
|
}
|
|
469
479
|
const N = {
|
|
@@ -560,7 +570,7 @@ function Q(e, t) {
|
|
|
560
570
|
function H(e) {
|
|
561
571
|
return e.split(".").map(Number);
|
|
562
572
|
}
|
|
563
|
-
function
|
|
573
|
+
function Be(e, t) {
|
|
564
574
|
const r = H(e), n = H(t), a = Math.max(r.length, n.length);
|
|
565
575
|
for (let o = 0; o < a; o += 1) {
|
|
566
576
|
const s = r[o] || 0, p = n[o] || 0;
|
|
@@ -574,32 +584,32 @@ function K(e, t, r) {
|
|
|
574
584
|
e,
|
|
575
585
|
t
|
|
576
586
|
) : Q(e);
|
|
577
|
-
return n ?
|
|
587
|
+
return n ? Be(n, r || t) <= 0 : !1;
|
|
578
588
|
}
|
|
579
|
-
function
|
|
589
|
+
function ut(e, t = "strict") {
|
|
580
590
|
const r = typeof t == "function" ? t : (n) => {
|
|
581
|
-
const { method: a, version: o } = n, s = "param" in n ? new Se(a, n.param, o) : new
|
|
591
|
+
const { method: a, version: o } = n, s = "param" in n ? new Se(a, n.param, o) : new Te(a, o);
|
|
582
592
|
if (t === "strict")
|
|
583
593
|
throw s;
|
|
584
594
|
return g().forceWarn(s.message);
|
|
585
595
|
};
|
|
586
|
-
return (n, a) => K(n, e) ? n === "web_app_set_header_color" &&
|
|
596
|
+
return (n, a) => K(n, e) ? n === "web_app_set_header_color" && Y(d({ color: de() }), a) && !K(n, "color", e) ? r({ version: e, method: n, param: "color" }) : $e(n, a) : r({ version: e, method: n });
|
|
587
597
|
}
|
|
588
|
-
function
|
|
598
|
+
function Ge(e, t, r, n) {
|
|
589
599
|
return f.pipe(
|
|
590
600
|
U("web_app_invoke_custom_method", "custom_method_invoked", {
|
|
591
601
|
...n || {},
|
|
592
602
|
params: { method: e, params: t, req_id: r },
|
|
593
|
-
capture:
|
|
603
|
+
capture: Ve(r)
|
|
594
604
|
}),
|
|
595
|
-
|
|
605
|
+
m.chain(({ result: a, error: o }) => o ? m.left(new Me(o)) : m.right(a))
|
|
596
606
|
);
|
|
597
607
|
}
|
|
598
|
-
function
|
|
608
|
+
function lt(e, t, r, n) {
|
|
599
609
|
return te.fn(() => f.pipe(
|
|
600
610
|
// @ts-expect-error TypeScript is unable to determine required override.
|
|
601
|
-
|
|
602
|
-
|
|
611
|
+
Ge(e, t, r, n),
|
|
612
|
+
m.match(
|
|
603
613
|
(a) => {
|
|
604
614
|
throw a;
|
|
605
615
|
},
|
|
@@ -607,15 +617,15 @@ function ut(e, t, r, n) {
|
|
|
607
617
|
)
|
|
608
618
|
)());
|
|
609
619
|
}
|
|
610
|
-
function
|
|
620
|
+
function De(e, t, r = {}) {
|
|
611
621
|
const {
|
|
612
622
|
// If no capture function was passed, we capture the first compatible event.
|
|
613
623
|
capture: n = () => !0,
|
|
614
|
-
postEvent: a =
|
|
624
|
+
postEvent: a = k
|
|
615
625
|
} = r, o = b(), [s, p] = Z();
|
|
616
626
|
(Array.isArray(t) ? t : [t]).forEach((i) => {
|
|
617
627
|
s(
|
|
618
|
-
|
|
628
|
+
R(i, (u) => {
|
|
619
629
|
(Array.isArray(t) ? n({ event: i, payload: u }) : n(u)) && o.set([u]);
|
|
620
630
|
})
|
|
621
631
|
);
|
|
@@ -623,25 +633,25 @@ function Ge(e, t, r = {}) {
|
|
|
623
633
|
const _ = (i) => (p(), i);
|
|
624
634
|
return f.pipe(
|
|
625
635
|
async () => a(e, r.params),
|
|
626
|
-
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
629
|
-
return i(
|
|
636
|
+
m.chainW(() => ee((i, u, l) => {
|
|
637
|
+
const w = o();
|
|
638
|
+
if (w)
|
|
639
|
+
return i(w[0]);
|
|
630
640
|
const h = (y) => {
|
|
631
641
|
y && i(y[0]);
|
|
632
|
-
},
|
|
642
|
+
}, W = () => {
|
|
633
643
|
o.unsub(h);
|
|
634
644
|
};
|
|
635
|
-
o.sub(h), l.on("finalized",
|
|
645
|
+
o.sub(h), l.on("finalized", W);
|
|
636
646
|
}, r)),
|
|
637
|
-
|
|
647
|
+
m.mapBoth(_, _)
|
|
638
648
|
);
|
|
639
649
|
}
|
|
640
|
-
function
|
|
650
|
+
function ft(e, t, r) {
|
|
641
651
|
const { postEvent: n } = r || {};
|
|
642
|
-
return
|
|
652
|
+
return C(
|
|
643
653
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
644
|
-
|
|
654
|
+
De(e, t, {
|
|
645
655
|
...r,
|
|
646
656
|
postEvent: n ? (...a) => {
|
|
647
657
|
try {
|
|
@@ -649,11 +659,11 @@ function lt(e, t, r) {
|
|
|
649
659
|
} catch (o) {
|
|
650
660
|
return c.left(o);
|
|
651
661
|
}
|
|
652
|
-
} :
|
|
662
|
+
} : k
|
|
653
663
|
})
|
|
654
664
|
);
|
|
655
665
|
}
|
|
656
|
-
function
|
|
666
|
+
function mt() {
|
|
657
667
|
Object.hasOwn || (Object.hasOwn = function(e, t) {
|
|
658
668
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
659
669
|
});
|
|
@@ -665,89 +675,89 @@ function le(e) {
|
|
|
665
675
|
).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
666
676
|
), (t) => t);
|
|
667
677
|
}
|
|
668
|
-
const
|
|
678
|
+
const wt = A(le);
|
|
669
679
|
function fe(e) {
|
|
670
680
|
return btoa(
|
|
671
681
|
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
|
|
672
682
|
).replace(/\+/g, "-").replace(/\//g, "_");
|
|
673
683
|
}
|
|
674
|
-
function
|
|
684
|
+
function Je(e) {
|
|
675
685
|
const t = fe(typeof e == "string" ? e : JSON.stringify(e));
|
|
676
686
|
return t.length > 512 ? c.left(new Error("Value is too long for start parameter")) : c.right(t);
|
|
677
687
|
}
|
|
678
|
-
const
|
|
679
|
-
function
|
|
680
|
-
return
|
|
681
|
-
|
|
688
|
+
const dt = A(Je);
|
|
689
|
+
function gt(e, t) {
|
|
690
|
+
return C(
|
|
691
|
+
Ne(
|
|
682
692
|
e,
|
|
683
693
|
// @ts-expect-error TypeScript is unable to detect a correct override.
|
|
684
694
|
typeof t == "function" ? (r) => c.tryCatch(() => t(r), (n) => n) : t
|
|
685
695
|
)
|
|
686
696
|
);
|
|
687
697
|
}
|
|
688
|
-
function
|
|
698
|
+
function Ne(e, t) {
|
|
689
699
|
return f.pipe(
|
|
690
700
|
le(e),
|
|
691
|
-
c.chain((r) => t ? typeof t == "function" ? t(r) :
|
|
701
|
+
c.chain((r) => t ? typeof t == "function" ? t(r) : ye.parse(r) : c.right(r))
|
|
692
702
|
);
|
|
693
703
|
}
|
|
694
|
-
function
|
|
704
|
+
function bt(e) {
|
|
695
705
|
return fe(e).length <= 512;
|
|
696
706
|
}
|
|
697
707
|
export {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
708
|
+
xt as CancelledError,
|
|
709
|
+
Ce as InvalidLaunchParamsError,
|
|
710
|
+
Me as InvokeCustomMethodFailedError,
|
|
711
|
+
Ae as LaunchParamsRetrieveError,
|
|
702
712
|
Se as MethodParameterUnsupportedError,
|
|
703
|
-
|
|
713
|
+
Te as MethodUnsupportedError,
|
|
704
714
|
kt as TimeoutError,
|
|
705
715
|
pe as UnknownEnvError,
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
716
|
+
mt as applyPolyfills,
|
|
717
|
+
Ve as captureSameReq,
|
|
718
|
+
Be as compareVersions,
|
|
719
|
+
vt as createLogger,
|
|
720
|
+
ut as createPostEvent,
|
|
721
|
+
dt as createStartParam,
|
|
722
|
+
Je as createStartParamFp,
|
|
713
723
|
ce as debug,
|
|
714
|
-
|
|
724
|
+
wt as decodeBase64Url,
|
|
715
725
|
le as decodeBase64UrlFp,
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
726
|
+
gt as decodeStartParam,
|
|
727
|
+
Ne as decodeStartParamFp,
|
|
728
|
+
Et as deepSnakeToCamelObjKeys,
|
|
719
729
|
q as emitEvent,
|
|
720
730
|
fe as encodeBase64Url,
|
|
721
731
|
Q as getReleaseVersion,
|
|
722
732
|
se as hasWebviewProxy,
|
|
723
|
-
|
|
724
|
-
|
|
733
|
+
lt as invokeCustomMethod,
|
|
734
|
+
Ge as invokeCustomMethodFp,
|
|
725
735
|
ie as isIframe,
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
736
|
+
bt as isSafeToCreateStartParam,
|
|
737
|
+
ct as isTMA,
|
|
738
|
+
ze as isTMAFp,
|
|
729
739
|
g as logger,
|
|
730
|
-
|
|
740
|
+
_t as mockTelegramEnv,
|
|
731
741
|
Oe as off,
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
742
|
+
Ue as offAll,
|
|
743
|
+
R as on,
|
|
744
|
+
$e as postEvent,
|
|
745
|
+
k as postEventFp,
|
|
746
|
+
Ie as postMessage,
|
|
737
747
|
P as postMessageImpl,
|
|
738
|
-
|
|
739
|
-
|
|
748
|
+
ft as request,
|
|
749
|
+
pt as request2,
|
|
740
750
|
U as request2Fp,
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
751
|
+
De as requestFp,
|
|
752
|
+
it as resetGlobals,
|
|
753
|
+
rt as retrieveLaunchParams,
|
|
754
|
+
We as retrieveLaunchParamsFp,
|
|
755
|
+
nt as retrieveRawInitData,
|
|
746
756
|
qe as retrieveRawInitDataFp,
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
757
|
+
ot as retrieveRawLaunchParams,
|
|
758
|
+
M as retrieveRawLaunchParamsFp,
|
|
759
|
+
at as setDebug,
|
|
760
|
+
st as setTargetOrigin,
|
|
751
761
|
K as supports,
|
|
752
762
|
_e as targetOrigin
|
|
753
763
|
};
|