@tma.js/bridge 2.1.0 → 2.1.2
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/README.md +1 -1
- package/dist/dts/env/mockTelegramEnv.d.ts +4 -1
- 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 +441 -419
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,406 +1,415 @@
|
|
|
1
|
-
import { is as L, looseObject as
|
|
2
|
-
import { throwifyFpFn as
|
|
3
|
-
import { createLogger as
|
|
4
|
-
import { BetterPromise as
|
|
5
|
-
import { CancelledError as
|
|
6
|
-
import { parseLaunchParamsQueryFp as
|
|
7
|
-
import { errorClass as
|
|
8
|
-
import { signal as
|
|
9
|
-
import
|
|
10
|
-
function
|
|
1
|
+
import { is as L, looseObject as f, function as Z, nullish as v, boolean as z, number as G, string as b, optional as V, unknown as ke, parse as C, any as Se } from "valibot";
|
|
2
|
+
import { throwifyFpFn as S, getStorageValue as Te, setStorageValue as ee, createLogger as $e, throwifyAnyEither as W, createCbCollector as Ae, BetterTaskEither as Me } from "@tma.js/toolkit";
|
|
3
|
+
import { createLogger as pr, deepSnakeToCamelObjKeys as _r } from "@tma.js/toolkit";
|
|
4
|
+
import { BetterPromise as te, TimeoutError as Ce } from "better-promises";
|
|
5
|
+
import { CancelledError as lr, TimeoutError as mr } from "better-promises";
|
|
6
|
+
import { parseLaunchParamsQueryFp as re, themeParams as Le, pipeJsonToSchema as ne, miniAppsMessage as oe, serializeLaunchParamsQuery as We, parseLaunchParamsQuery as Fe } from "@tma.js/transformers";
|
|
7
|
+
import { errorClass as E, errorClassWithData as qe } from "error-kid";
|
|
8
|
+
import { signal as P, computed as ae } from "@tma.js/signals";
|
|
9
|
+
import Oe from "mitt";
|
|
10
|
+
function se(e) {
|
|
11
11
|
return L(
|
|
12
|
-
|
|
12
|
+
f({ TelegramWebviewProxy: f({ postEvent: Z() }) }),
|
|
13
13
|
e
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function ie() {
|
|
17
17
|
try {
|
|
18
18
|
return window.self !== window.top;
|
|
19
19
|
} catch {
|
|
20
20
|
return !0;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
if (
|
|
25
|
-
(o || !(n in
|
|
26
|
-
return e.concat(o || Array.prototype.slice.call(
|
|
23
|
+
var Re = function(e, t, r) {
|
|
24
|
+
if (r || arguments.length === 2) for (var n = 0, a = t.length, o; n < a; n++)
|
|
25
|
+
(o || !(n in t)) && (o || (o = Array.prototype.slice.call(t, 0, n)), o[n] = t[n]);
|
|
26
|
+
return e.concat(o || Array.prototype.slice.call(t));
|
|
27
27
|
};
|
|
28
|
-
function
|
|
28
|
+
function Ue(e) {
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function x(e, t, r, n, a, o, s, i, c) {
|
|
32
32
|
switch (arguments.length) {
|
|
33
33
|
case 1:
|
|
34
34
|
return e;
|
|
35
35
|
case 2:
|
|
36
36
|
return function() {
|
|
37
|
-
return
|
|
37
|
+
return t(e.apply(this, arguments));
|
|
38
38
|
};
|
|
39
39
|
case 3:
|
|
40
40
|
return function() {
|
|
41
|
-
return t(
|
|
41
|
+
return r(t(e.apply(this, arguments)));
|
|
42
42
|
};
|
|
43
43
|
case 4:
|
|
44
44
|
return function() {
|
|
45
|
-
return n(t(
|
|
45
|
+
return n(r(t(e.apply(this, arguments))));
|
|
46
46
|
};
|
|
47
47
|
case 5:
|
|
48
48
|
return function() {
|
|
49
|
-
return a(n(t(
|
|
49
|
+
return a(n(r(t(e.apply(this, arguments)))));
|
|
50
50
|
};
|
|
51
51
|
case 6:
|
|
52
52
|
return function() {
|
|
53
|
-
return o(a(n(t(
|
|
53
|
+
return o(a(n(r(t(e.apply(this, arguments))))));
|
|
54
54
|
};
|
|
55
55
|
case 7:
|
|
56
56
|
return function() {
|
|
57
|
-
return
|
|
57
|
+
return s(o(a(n(r(t(e.apply(this, arguments)))))));
|
|
58
58
|
};
|
|
59
59
|
case 8:
|
|
60
60
|
return function() {
|
|
61
|
-
return s(
|
|
61
|
+
return i(s(o(a(n(r(t(e.apply(this, arguments))))))));
|
|
62
62
|
};
|
|
63
63
|
case 9:
|
|
64
64
|
return function() {
|
|
65
|
-
return
|
|
65
|
+
return c(i(s(o(a(n(r(t(e.apply(this, arguments)))))))));
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function l(e, t, r, n, a, o, s, i, c) {
|
|
70
70
|
switch (arguments.length) {
|
|
71
71
|
case 1:
|
|
72
72
|
return e;
|
|
73
73
|
case 2:
|
|
74
|
-
return
|
|
74
|
+
return t(e);
|
|
75
75
|
case 3:
|
|
76
|
-
return t(
|
|
76
|
+
return r(t(e));
|
|
77
77
|
case 4:
|
|
78
|
-
return n(t(
|
|
78
|
+
return n(r(t(e)));
|
|
79
79
|
case 5:
|
|
80
|
-
return a(n(t(
|
|
80
|
+
return a(n(r(t(e))));
|
|
81
81
|
case 6:
|
|
82
|
-
return o(a(n(t(
|
|
82
|
+
return o(a(n(r(t(e)))));
|
|
83
83
|
case 7:
|
|
84
|
-
return
|
|
84
|
+
return s(o(a(n(r(t(e))))));
|
|
85
85
|
case 8:
|
|
86
|
-
return s(
|
|
86
|
+
return i(s(o(a(n(r(t(e)))))));
|
|
87
87
|
case 9:
|
|
88
|
-
return
|
|
88
|
+
return c(i(s(o(a(n(r(t(e))))))));
|
|
89
89
|
default: {
|
|
90
|
-
for (var
|
|
91
|
-
|
|
92
|
-
return
|
|
90
|
+
for (var u = arguments[0], p = 1; p < arguments.length; p++)
|
|
91
|
+
u = arguments[p](u);
|
|
92
|
+
return u;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
var
|
|
97
|
-
var
|
|
96
|
+
var T = function(e, t) {
|
|
97
|
+
var r = typeof e == "number" ? function(n) {
|
|
98
98
|
return n.length >= e;
|
|
99
99
|
} : e;
|
|
100
100
|
return function() {
|
|
101
101
|
var n = Array.from(arguments);
|
|
102
|
-
return
|
|
103
|
-
return
|
|
102
|
+
return r(arguments) ? t.apply(this, n) : function(a) {
|
|
103
|
+
return t.apply(void 0, Re([a], n, !1));
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
|
-
},
|
|
106
|
+
}, Ie = { _tag: "None" }, je = function(e) {
|
|
107
107
|
return { _tag: "Some", value: e };
|
|
108
|
-
},
|
|
108
|
+
}, ze = function(e) {
|
|
109
109
|
return e._tag === "Left";
|
|
110
|
-
},
|
|
110
|
+
}, Ge = function(e) {
|
|
111
111
|
return { _tag: "Left", left: e };
|
|
112
|
-
},
|
|
112
|
+
}, Ve = function(e) {
|
|
113
113
|
return { _tag: "Right", right: e };
|
|
114
|
-
},
|
|
115
|
-
return
|
|
116
|
-
}),
|
|
117
|
-
return function(
|
|
118
|
-
return
|
|
114
|
+
}, m = Ge, _ = Ve, ue = /* @__PURE__ */ T(2, function(e, t) {
|
|
115
|
+
return d(e) ? e : t(e.right);
|
|
116
|
+
}), Be = function(e) {
|
|
117
|
+
return function(t) {
|
|
118
|
+
return d(t) ? t : _(e(t.right));
|
|
119
119
|
};
|
|
120
|
-
},
|
|
120
|
+
}, De = function(e, t) {
|
|
121
121
|
return function(r) {
|
|
122
|
-
return
|
|
122
|
+
return d(r) ? m(e(r.left)) : _(t(r.right));
|
|
123
123
|
};
|
|
124
|
-
},
|
|
124
|
+
}, Ne = function(e) {
|
|
125
125
|
return function(t) {
|
|
126
|
-
return
|
|
126
|
+
return d(t) ? m(e(t.left)) : t;
|
|
127
|
+
};
|
|
128
|
+
}, d = ze, ce = function(e, t) {
|
|
129
|
+
return function(r) {
|
|
130
|
+
return d(r) ? e(r.left) : t(r.right);
|
|
127
131
|
};
|
|
128
|
-
},
|
|
132
|
+
}, Je = ce, F = ce, Qe = F, q = function(e, t) {
|
|
129
133
|
try {
|
|
130
134
|
return _(e());
|
|
131
|
-
} catch (
|
|
132
|
-
return
|
|
135
|
+
} catch (r) {
|
|
136
|
+
return m(t(r));
|
|
133
137
|
}
|
|
134
|
-
},
|
|
138
|
+
}, He = ue, Ke = ue, Ye = Ie, Xe = je, Ze = function(e) {
|
|
135
139
|
return e._tag === "None";
|
|
136
|
-
},
|
|
137
|
-
return function(
|
|
138
|
-
return
|
|
140
|
+
}, et = function(e, t) {
|
|
141
|
+
return function(r) {
|
|
142
|
+
return Ze(r) ? e() : t(r.value);
|
|
139
143
|
};
|
|
140
|
-
},
|
|
141
|
-
function
|
|
142
|
-
return
|
|
144
|
+
}, tt = et;
|
|
145
|
+
function rt(e) {
|
|
146
|
+
return x(_, e.of);
|
|
143
147
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
148
|
+
function nt(e) {
|
|
149
|
+
return x(m, e.of);
|
|
146
150
|
}
|
|
147
|
-
function
|
|
148
|
-
return function(
|
|
149
|
-
return e.chain(
|
|
150
|
-
return
|
|
151
|
+
function ot(e) {
|
|
152
|
+
return function(t, r) {
|
|
153
|
+
return e.chain(t, function(n) {
|
|
154
|
+
return d(n) ? e.of(n) : r(n.right);
|
|
151
155
|
});
|
|
152
156
|
};
|
|
153
157
|
}
|
|
154
|
-
function
|
|
155
|
-
return function(r,
|
|
158
|
+
function at(e) {
|
|
159
|
+
return function(t, r, n) {
|
|
160
|
+
return e.map(t, De(r, n));
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function st(e) {
|
|
164
|
+
return function(t, r) {
|
|
156
165
|
return function(n) {
|
|
157
|
-
return e.map(n, F(
|
|
166
|
+
return e.map(n, F(t, r));
|
|
158
167
|
};
|
|
159
168
|
};
|
|
160
169
|
}
|
|
161
|
-
var
|
|
162
|
-
return
|
|
163
|
-
},
|
|
164
|
-
return
|
|
165
|
-
},
|
|
166
|
-
return function(
|
|
170
|
+
var pe = function(e, t) {
|
|
171
|
+
return l(e, ut(t));
|
|
172
|
+
}, it = function(e, t) {
|
|
173
|
+
return l(e, ct(t));
|
|
174
|
+
}, ut = function(e) {
|
|
175
|
+
return function(t) {
|
|
167
176
|
return function() {
|
|
168
|
-
return Promise.resolve().then(
|
|
177
|
+
return Promise.resolve().then(t).then(e);
|
|
169
178
|
};
|
|
170
179
|
};
|
|
171
|
-
},
|
|
172
|
-
return function(
|
|
180
|
+
}, ct = function(e) {
|
|
181
|
+
return function(t) {
|
|
173
182
|
return function() {
|
|
174
|
-
return Promise.all([Promise.resolve().then(
|
|
175
|
-
var n =
|
|
183
|
+
return Promise.all([Promise.resolve().then(t), Promise.resolve().then(e)]).then(function(r) {
|
|
184
|
+
var n = r[0], a = r[1];
|
|
176
185
|
return n(a);
|
|
177
186
|
});
|
|
178
187
|
};
|
|
179
188
|
};
|
|
180
|
-
},
|
|
189
|
+
}, _e = function(e) {
|
|
181
190
|
return function() {
|
|
182
191
|
return Promise.resolve(e);
|
|
183
192
|
};
|
|
184
|
-
},
|
|
193
|
+
}, pt = /* @__PURE__ */ T(2, function(e, t) {
|
|
185
194
|
return function() {
|
|
186
|
-
return Promise.resolve().then(e).then(function(
|
|
187
|
-
return r
|
|
195
|
+
return Promise.resolve().then(e).then(function(r) {
|
|
196
|
+
return t(r)();
|
|
188
197
|
});
|
|
189
198
|
};
|
|
190
|
-
}),
|
|
191
|
-
URI:
|
|
192
|
-
map:
|
|
193
|
-
},
|
|
194
|
-
of:
|
|
195
|
-
},
|
|
196
|
-
URI:
|
|
197
|
-
map:
|
|
198
|
-
of:
|
|
199
|
-
ap:
|
|
200
|
-
chain:
|
|
201
|
-
},
|
|
202
|
-
class
|
|
203
|
-
`Method "${
|
|
199
|
+
}), fe = "Task", le = {
|
|
200
|
+
URI: fe,
|
|
201
|
+
map: pe
|
|
202
|
+
}, me = {
|
|
203
|
+
of: _e
|
|
204
|
+
}, _t = {
|
|
205
|
+
URI: fe,
|
|
206
|
+
map: pe,
|
|
207
|
+
of: _e,
|
|
208
|
+
ap: it,
|
|
209
|
+
chain: pt
|
|
210
|
+
}, ft = /* @__PURE__ */ nt(me), we = /* @__PURE__ */ rt(me), he = /* @__PURE__ */ st(le), lt = /* @__PURE__ */ T(3, at(le)), ge = /* @__PURE__ */ T(2, ot(_t)), mt = ge, wt = ge;
|
|
211
|
+
class ht extends E("MethodUnsupportedError", (t, r) => [
|
|
212
|
+
`Method "${t}" is unsupported in Mini Apps version ${r}`
|
|
204
213
|
]) {
|
|
205
214
|
}
|
|
206
|
-
class
|
|
207
|
-
`Parameter "${
|
|
215
|
+
class gt extends E("MethodParameterUnsupportedError", (t, r, n) => [
|
|
216
|
+
`Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
|
|
208
217
|
]) {
|
|
209
218
|
}
|
|
210
|
-
class
|
|
219
|
+
class dt extends qe(
|
|
211
220
|
"LaunchParamsRetrieveError",
|
|
212
|
-
(
|
|
213
|
-
(
|
|
221
|
+
(t) => ({ errors: t }),
|
|
222
|
+
(t) => [
|
|
214
223
|
[
|
|
215
224
|
"Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?",
|
|
216
225
|
"📖 Refer to docs for more information:",
|
|
217
226
|
"https://docs.telegram-mini-apps.com/packages/tma-js-bridge/environment",
|
|
218
227
|
"",
|
|
219
228
|
"Collected errors:",
|
|
220
|
-
...
|
|
229
|
+
...t.map(({ source: r, error: n }) => `Source: ${r} / ${n instanceof Error ? n.message : String(n)}`)
|
|
221
230
|
].join(`
|
|
222
231
|
`)
|
|
223
232
|
]
|
|
224
233
|
) {
|
|
225
234
|
}
|
|
226
|
-
class
|
|
227
|
-
`Invalid value for launch params: ${
|
|
228
|
-
{ cause:
|
|
235
|
+
class vt extends E("InvalidLaunchParamsError", (t, r) => [
|
|
236
|
+
`Invalid value for launch params: ${t}`,
|
|
237
|
+
{ cause: r }
|
|
229
238
|
]) {
|
|
230
239
|
}
|
|
231
|
-
class
|
|
240
|
+
class bt extends E("UnknownEnvError") {
|
|
232
241
|
}
|
|
233
|
-
class
|
|
242
|
+
class yt extends E(
|
|
234
243
|
"InvokeCustomMethodError",
|
|
235
|
-
(
|
|
244
|
+
(t) => [`Server returned error: ${t}`]
|
|
236
245
|
) {
|
|
237
246
|
}
|
|
238
|
-
const
|
|
239
|
-
function
|
|
247
|
+
const B = "launchParams";
|
|
248
|
+
function D(e) {
|
|
240
249
|
return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
|
|
241
250
|
}
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
return
|
|
245
|
-
})),
|
|
246
|
-
|
|
247
|
-
|
|
251
|
+
const Et = x($, He(re)), Nt = S(Et), Pt = x($, Be((e) => {
|
|
252
|
+
const t = new URLSearchParams(e).get("tgWebAppData");
|
|
253
|
+
return t ? Xe(t) : Ye;
|
|
254
|
+
})), Jt = x(
|
|
255
|
+
Pt,
|
|
256
|
+
Qe((e) => {
|
|
248
257
|
throw e;
|
|
249
258
|
}, (e) => e),
|
|
250
|
-
|
|
259
|
+
tt(() => {
|
|
251
260
|
}, (e) => e)
|
|
252
261
|
);
|
|
253
|
-
function
|
|
262
|
+
function $() {
|
|
254
263
|
const e = [];
|
|
255
|
-
for (const [
|
|
264
|
+
for (const [t, r] of [
|
|
256
265
|
// Try to retrieve launch parameters from the current location. This method
|
|
257
266
|
// can return nothing in case, location was changed, and then the page was
|
|
258
267
|
// reloaded.
|
|
259
|
-
[() =>
|
|
268
|
+
[() => D(window.location.href), "window.location.href"],
|
|
260
269
|
// Then, try using the lower level API - window.performance.
|
|
261
270
|
[() => {
|
|
262
271
|
const n = performance.getEntriesByType("navigation")[0];
|
|
263
|
-
return n &&
|
|
272
|
+
return n && D(n.name);
|
|
264
273
|
}, "performance navigation entries"],
|
|
265
274
|
// Finally, try using the session storage.
|
|
266
|
-
[() =>
|
|
275
|
+
[() => Te(B), "local storage"]
|
|
267
276
|
]) {
|
|
268
|
-
const n =
|
|
277
|
+
const n = t();
|
|
269
278
|
if (!n) {
|
|
270
|
-
e.push({ source:
|
|
279
|
+
e.push({ source: r, error: new Error("Source is empty") });
|
|
271
280
|
continue;
|
|
272
281
|
}
|
|
273
|
-
const a =
|
|
274
|
-
|
|
275
|
-
|
|
282
|
+
const a = l(
|
|
283
|
+
re(n),
|
|
284
|
+
Je((o) => o, () => !0)
|
|
276
285
|
);
|
|
277
286
|
if (typeof a != "boolean") {
|
|
278
|
-
e.push({ source:
|
|
287
|
+
e.push({ source: r, error: a });
|
|
279
288
|
continue;
|
|
280
289
|
}
|
|
281
|
-
return
|
|
290
|
+
return ee(B, n), _(n);
|
|
282
291
|
}
|
|
283
|
-
return
|
|
284
|
-
}
|
|
285
|
-
const
|
|
286
|
-
function
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const p =
|
|
293
|
-
if (p >= 0 && (n.off(o,
|
|
294
|
-
const
|
|
295
|
-
|
|
292
|
+
return m(new dt(e));
|
|
293
|
+
}
|
|
294
|
+
const Qt = S($);
|
|
295
|
+
function xt(e, t) {
|
|
296
|
+
const r = /* @__PURE__ */ new Map(), n = Oe(), a = (o, s, i = !1) => {
|
|
297
|
+
const c = r.get(o) || /* @__PURE__ */ new Map();
|
|
298
|
+
r.set(o, c);
|
|
299
|
+
const u = c.get(s) || [];
|
|
300
|
+
c.set(s, u);
|
|
301
|
+
const p = u.findIndex((w) => w[1] === i);
|
|
302
|
+
if (p >= 0 && (n.off(o, u[p][0]), u.splice(p, 1), !u.length && (c.delete(s), !c.size))) {
|
|
303
|
+
const w = r.size;
|
|
304
|
+
r.delete(o), w && !r.size && t();
|
|
296
305
|
}
|
|
297
306
|
};
|
|
298
307
|
return {
|
|
299
|
-
on(o,
|
|
300
|
-
!
|
|
301
|
-
const
|
|
302
|
-
a(o,
|
|
303
|
-
},
|
|
304
|
-
|
|
308
|
+
on(o, s, i) {
|
|
309
|
+
!r.size && e();
|
|
310
|
+
const c = () => {
|
|
311
|
+
a(o, s, i);
|
|
312
|
+
}, u = (...g) => {
|
|
313
|
+
i && c(), o === "*" ? s({ name: g[0], payload: g[1] }) : s(...g);
|
|
305
314
|
};
|
|
306
|
-
n.on(o,
|
|
307
|
-
const p =
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
return p.set(
|
|
315
|
+
n.on(o, u);
|
|
316
|
+
const p = r.get(o) || /* @__PURE__ */ new Map();
|
|
317
|
+
r.set(o, p);
|
|
318
|
+
const w = p.get(s) || [];
|
|
319
|
+
return p.set(s, w), w.push([u, i || !1]), c;
|
|
311
320
|
},
|
|
312
321
|
off: a,
|
|
313
322
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
314
323
|
emit: n.emit,
|
|
315
324
|
clear() {
|
|
316
|
-
const o =
|
|
317
|
-
n.all.clear(),
|
|
325
|
+
const o = r.size;
|
|
326
|
+
n.all.clear(), r.clear(), o && t();
|
|
318
327
|
}
|
|
319
328
|
};
|
|
320
329
|
}
|
|
321
|
-
function A(e,
|
|
330
|
+
function A(e, t) {
|
|
322
331
|
window.dispatchEvent(new MessageEvent("message", {
|
|
323
|
-
data: JSON.stringify({ eventType: e, eventData:
|
|
332
|
+
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
324
333
|
// We specify this kind of source here in order to allow the package's "on" function to
|
|
325
334
|
// capture it. The reason is this function always checks the event source and relies on
|
|
326
335
|
// it to be the parent window.
|
|
327
336
|
source: window.parent
|
|
328
337
|
}));
|
|
329
338
|
}
|
|
330
|
-
function
|
|
331
|
-
const n = [
|
|
339
|
+
function M(e, t, r) {
|
|
340
|
+
const n = [r], a = e[t];
|
|
332
341
|
typeof a == "function" && n.push(a);
|
|
333
|
-
const o = (...
|
|
334
|
-
n.forEach((
|
|
335
|
-
},
|
|
336
|
-
o(...
|
|
342
|
+
const o = (...i) => {
|
|
343
|
+
n.forEach((c) => c(...i));
|
|
344
|
+
}, s = Object.assign((...i) => {
|
|
345
|
+
o(...i);
|
|
337
346
|
}, {
|
|
338
347
|
// Unwraps the composer.
|
|
339
348
|
unwrap() {
|
|
340
|
-
const { length:
|
|
341
|
-
if (
|
|
342
|
-
delete e[
|
|
349
|
+
const { length: i } = n;
|
|
350
|
+
if (i === 1) {
|
|
351
|
+
delete e[t];
|
|
343
352
|
return;
|
|
344
353
|
}
|
|
345
|
-
if (
|
|
346
|
-
|
|
354
|
+
if (i === 2) {
|
|
355
|
+
J(e, t, n[1]);
|
|
347
356
|
return;
|
|
348
357
|
}
|
|
349
|
-
n.unshift(1),
|
|
358
|
+
n.unshift(1), J(e, t, o);
|
|
350
359
|
}
|
|
351
360
|
});
|
|
352
|
-
|
|
361
|
+
de(
|
|
353
362
|
e,
|
|
354
|
-
|
|
355
|
-
() =>
|
|
356
|
-
(
|
|
363
|
+
t,
|
|
364
|
+
() => s,
|
|
365
|
+
(i) => n.push(i)
|
|
357
366
|
);
|
|
358
367
|
}
|
|
359
|
-
function
|
|
360
|
-
const
|
|
361
|
-
|
|
368
|
+
function N(e, t) {
|
|
369
|
+
const r = e[t];
|
|
370
|
+
de(e, t, () => r, (n) => {
|
|
362
371
|
Object.entries(n).forEach(([a, o]) => {
|
|
363
|
-
|
|
372
|
+
r[a] = o;
|
|
364
373
|
});
|
|
365
374
|
});
|
|
366
375
|
}
|
|
367
|
-
function
|
|
368
|
-
Object.defineProperty(e,
|
|
376
|
+
function de(e, t, r, n) {
|
|
377
|
+
Object.defineProperty(e, t, {
|
|
369
378
|
enumerable: !0,
|
|
370
379
|
configurable: !0,
|
|
371
|
-
get:
|
|
380
|
+
get: r,
|
|
372
381
|
set: n
|
|
373
382
|
});
|
|
374
383
|
}
|
|
375
|
-
function
|
|
376
|
-
Object.defineProperty(e,
|
|
384
|
+
function J(e, t, r) {
|
|
385
|
+
Object.defineProperty(e, t, {
|
|
377
386
|
enumerable: !0,
|
|
378
387
|
configurable: !0,
|
|
379
388
|
writable: !0,
|
|
380
|
-
value:
|
|
389
|
+
value: r
|
|
381
390
|
});
|
|
382
391
|
}
|
|
383
|
-
const
|
|
384
|
-
clipboard_text_received:
|
|
385
|
-
req_id:
|
|
386
|
-
data:
|
|
392
|
+
const kt = {
|
|
393
|
+
clipboard_text_received: f({
|
|
394
|
+
req_id: b(),
|
|
395
|
+
data: v(b())
|
|
387
396
|
}),
|
|
388
|
-
custom_method_invoked:
|
|
389
|
-
req_id:
|
|
390
|
-
result:
|
|
391
|
-
error:
|
|
397
|
+
custom_method_invoked: f({
|
|
398
|
+
req_id: b(),
|
|
399
|
+
result: V(ke()),
|
|
400
|
+
error: V(b())
|
|
392
401
|
}),
|
|
393
|
-
popup_closed:
|
|
394
|
-
|
|
402
|
+
popup_closed: v(
|
|
403
|
+
f({ button_id: v(b(), () => {
|
|
395
404
|
}) }),
|
|
396
405
|
{}
|
|
397
406
|
),
|
|
398
|
-
viewport_changed:
|
|
399
|
-
|
|
400
|
-
height:
|
|
401
|
-
width:
|
|
402
|
-
is_state_stable:
|
|
403
|
-
is_expanded:
|
|
407
|
+
viewport_changed: v(
|
|
408
|
+
f({
|
|
409
|
+
height: G(),
|
|
410
|
+
width: v(G(), () => window.innerWidth),
|
|
411
|
+
is_state_stable: z(),
|
|
412
|
+
is_expanded: z()
|
|
404
413
|
}),
|
|
405
414
|
// TODO: At the moment, macOS has a bug with the invalid event payload - it is always equal to
|
|
406
415
|
// null. Leaving this default value until the bug is fixed.
|
|
@@ -410,46 +419,46 @@ const vr = {
|
|
|
410
419
|
is_expanded: !0
|
|
411
420
|
})
|
|
412
421
|
),
|
|
413
|
-
theme_changed:
|
|
414
|
-
theme_params:
|
|
422
|
+
theme_changed: f({
|
|
423
|
+
theme_params: Le()
|
|
415
424
|
})
|
|
416
425
|
};
|
|
417
|
-
function
|
|
426
|
+
function Q(e) {
|
|
418
427
|
if (e.source !== window.parent)
|
|
419
428
|
return;
|
|
420
|
-
let
|
|
429
|
+
let t;
|
|
421
430
|
try {
|
|
422
|
-
|
|
431
|
+
t = C(ne(oe()), e.data);
|
|
423
432
|
} catch {
|
|
424
433
|
return;
|
|
425
434
|
}
|
|
426
|
-
const { eventType:
|
|
435
|
+
const { eventType: r, eventData: n } = t, a = kt[r];
|
|
427
436
|
let o;
|
|
428
437
|
try {
|
|
429
|
-
o = a ?
|
|
430
|
-
} catch (
|
|
431
|
-
return
|
|
438
|
+
o = a ? C(a, n) : n;
|
|
439
|
+
} catch (s) {
|
|
440
|
+
return h().forceError(
|
|
432
441
|
[
|
|
433
|
-
`An error occurred processing the "${
|
|
442
|
+
`An error occurred processing the "${r}" event from the Telegram application.`,
|
|
434
443
|
"Please, file an issue here:",
|
|
435
|
-
"https://github.com/Telegram-Mini-Apps/
|
|
444
|
+
"https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"
|
|
436
445
|
].join(`
|
|
437
446
|
`),
|
|
438
|
-
|
|
439
|
-
|
|
447
|
+
t,
|
|
448
|
+
s
|
|
440
449
|
);
|
|
441
450
|
}
|
|
442
|
-
|
|
451
|
+
Tt(r, o);
|
|
443
452
|
}
|
|
444
453
|
const {
|
|
445
|
-
on:
|
|
446
|
-
off:
|
|
447
|
-
emit:
|
|
448
|
-
clear:
|
|
449
|
-
} =
|
|
454
|
+
on: ve,
|
|
455
|
+
off: St,
|
|
456
|
+
emit: Tt,
|
|
457
|
+
clear: $t
|
|
458
|
+
} = xt(
|
|
450
459
|
() => {
|
|
451
460
|
const e = window;
|
|
452
|
-
!e.TelegramGameProxy && (e.TelegramGameProxy = {}),
|
|
461
|
+
!e.TelegramGameProxy && (e.TelegramGameProxy = {}), M(e.TelegramGameProxy, "receiveEvent", A), N(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), M(e.Telegram.WebView, "receiveEvent", A), N(e.Telegram, "WebView"), M(e, "TelegramGameProxy_receiveEvent", A), window.addEventListener("message", Q);
|
|
453
462
|
},
|
|
454
463
|
() => {
|
|
455
464
|
[
|
|
@@ -457,143 +466,153 @@ const {
|
|
|
457
466
|
["TelegramGameProxy", "receiveEvent"],
|
|
458
467
|
["Telegram", "WebView", "receiveEvent"]
|
|
459
468
|
].forEach((e) => {
|
|
460
|
-
const
|
|
461
|
-
let
|
|
469
|
+
const t = window;
|
|
470
|
+
let r = [void 0, t];
|
|
462
471
|
for (const o of e)
|
|
463
|
-
if (
|
|
472
|
+
if (r = [r[1], r[1][o]], !r[1])
|
|
464
473
|
return;
|
|
465
|
-
const [n, a] =
|
|
466
|
-
"unwrap" in a && (a.unwrap(), n && n !==
|
|
467
|
-
}), window.removeEventListener("message",
|
|
474
|
+
const [n, a] = r;
|
|
475
|
+
"unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
|
|
476
|
+
}), window.removeEventListener("message", Q);
|
|
468
477
|
}
|
|
469
|
-
),
|
|
470
|
-
|
|
471
|
-
},
|
|
472
|
-
function
|
|
473
|
-
e !==
|
|
478
|
+
), k = P(!1), O = P("https://web.telegram.org"), At = (e) => {
|
|
479
|
+
h().log("Event received:", e);
|
|
480
|
+
}, be = ae(k);
|
|
481
|
+
function Ht(e) {
|
|
482
|
+
e !== k() && (k.set(e), (e ? ve : St)("*", At));
|
|
474
483
|
}
|
|
475
|
-
const
|
|
476
|
-
function
|
|
477
|
-
O.set(e),
|
|
484
|
+
const ye = ae(O);
|
|
485
|
+
function Kt(e) {
|
|
486
|
+
O.set(e), h().log("New target origin set", e);
|
|
478
487
|
}
|
|
479
|
-
const
|
|
488
|
+
const y = P((...e) => {
|
|
480
489
|
window.parent.postMessage(...e);
|
|
481
|
-
}),
|
|
490
|
+
}), h = P($e("Bridge", {
|
|
482
491
|
bgColor: "#9147ff",
|
|
483
492
|
textColor: "white",
|
|
484
|
-
shouldLog:
|
|
493
|
+
shouldLog: be
|
|
485
494
|
}));
|
|
486
|
-
function
|
|
487
|
-
|
|
495
|
+
function Yt() {
|
|
496
|
+
$t(), [y, O, ye, k, be, h].forEach((e) => {
|
|
488
497
|
e.unsubAll(), "reset" in e && e.reset();
|
|
489
498
|
});
|
|
490
499
|
}
|
|
491
|
-
const
|
|
492
|
-
function
|
|
493
|
-
|
|
500
|
+
const Mt = (...e) => y()(...e);
|
|
501
|
+
function Ct(e, t) {
|
|
502
|
+
l(
|
|
494
503
|
R(
|
|
495
504
|
// @ts-expect-error It's ok, TS can't determine a specific override.
|
|
496
505
|
e,
|
|
497
|
-
|
|
506
|
+
t
|
|
498
507
|
),
|
|
499
|
-
|
|
500
|
-
throw
|
|
508
|
+
Ne((r) => {
|
|
509
|
+
throw r;
|
|
501
510
|
})
|
|
502
511
|
);
|
|
503
512
|
}
|
|
504
|
-
function R(e,
|
|
505
|
-
|
|
506
|
-
const
|
|
507
|
-
return
|
|
513
|
+
function R(e, t) {
|
|
514
|
+
h().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
|
|
515
|
+
const r = window, n = JSON.stringify({ eventType: e, eventData: t });
|
|
516
|
+
return ie() ? (Mt(n, ye()), _(void 0)) : se(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), _(void 0)) : L(f({ external: f({ notify: Z() }) }), r) ? (r.external.notify(n), _(void 0)) : m(new bt());
|
|
508
517
|
}
|
|
509
|
-
function U(e,
|
|
518
|
+
function U(e, t, r = {}) {
|
|
510
519
|
const {
|
|
511
520
|
// If no capture function was passed, we capture the first compatible event.
|
|
512
521
|
capture: n = () => !0,
|
|
513
522
|
postEvent: a = R
|
|
514
|
-
} =
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
523
|
+
} = r, o = P(), [s, i] = Ae();
|
|
524
|
+
(Array.isArray(t) ? t : [t]).forEach((u) => {
|
|
525
|
+
s(
|
|
526
|
+
ve(u, (p) => {
|
|
527
|
+
(Array.isArray(t) ? n({ event: u, payload: p }) : n(p)) && o.set([p]);
|
|
528
|
+
})
|
|
529
|
+
);
|
|
530
|
+
});
|
|
531
|
+
const c = (u) => (i(), u);
|
|
532
|
+
return l(
|
|
533
|
+
async () => a(e, r.params),
|
|
534
|
+
wt(() => Me((u, p, w) => {
|
|
535
|
+
const g = o();
|
|
536
|
+
if (g)
|
|
537
|
+
return u(g[0]);
|
|
538
|
+
const I = (j) => {
|
|
539
|
+
j && u(j[0]);
|
|
540
|
+
}, xe = () => {
|
|
541
|
+
o.unsub(I);
|
|
542
|
+
};
|
|
543
|
+
o.sub(I), w.on("finalized", xe);
|
|
544
|
+
}, r)),
|
|
545
|
+
lt(c, c)
|
|
527
546
|
);
|
|
528
547
|
}
|
|
529
|
-
function
|
|
530
|
-
const { postEvent: n } =
|
|
531
|
-
return
|
|
548
|
+
function Xt(e, t, r) {
|
|
549
|
+
const { postEvent: n } = r || {};
|
|
550
|
+
return W(
|
|
532
551
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
533
|
-
U(e,
|
|
534
|
-
...
|
|
552
|
+
U(e, t, {
|
|
553
|
+
...r,
|
|
535
554
|
postEvent: n ? (...a) => {
|
|
536
555
|
try {
|
|
537
556
|
return n(...a), _(void 0);
|
|
538
557
|
} catch (o) {
|
|
539
|
-
return
|
|
558
|
+
return m(o);
|
|
540
559
|
}
|
|
541
560
|
} : R
|
|
542
561
|
})
|
|
543
562
|
);
|
|
544
563
|
}
|
|
545
|
-
function
|
|
546
|
-
const
|
|
564
|
+
function Zt(e, t) {
|
|
565
|
+
const r = Lt(
|
|
547
566
|
// @ts-expect-error TS doesn't get what override we are going to use.
|
|
548
567
|
e,
|
|
549
|
-
|
|
568
|
+
t
|
|
550
569
|
);
|
|
551
|
-
return typeof
|
|
570
|
+
return typeof r == "function" ? te.fn(() => W(r)) : r;
|
|
552
571
|
}
|
|
553
|
-
function
|
|
554
|
-
const
|
|
572
|
+
function Lt(e, t) {
|
|
573
|
+
const r = se(window);
|
|
555
574
|
if (!e)
|
|
556
|
-
return
|
|
557
|
-
if (
|
|
558
|
-
return
|
|
559
|
-
const { timeout: n = 100 } =
|
|
560
|
-
return
|
|
561
|
-
U("web_app_request_theme", "theme_changed", { ...
|
|
562
|
-
|
|
563
|
-
(a) =>
|
|
575
|
+
return r || l($(), F(() => !1, () => !0));
|
|
576
|
+
if (r)
|
|
577
|
+
return we(!0);
|
|
578
|
+
const { timeout: n = 100 } = t || {};
|
|
579
|
+
return l(
|
|
580
|
+
U("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
|
|
581
|
+
he(
|
|
582
|
+
(a) => Ce.is(a) ? _(!1) : m(a),
|
|
564
583
|
() => _(!0)
|
|
565
584
|
)
|
|
566
585
|
);
|
|
567
586
|
}
|
|
568
|
-
function
|
|
587
|
+
function er({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
569
588
|
if (e) {
|
|
570
589
|
const o = typeof e == "string" || e instanceof URLSearchParams ? e.toString() : (
|
|
571
590
|
// Here we have to trick serializeLaunchParamsQuery into thinking, it serializes a valid
|
|
572
591
|
// value. We are doing it because we are working with tgWebAppData presented as a
|
|
573
592
|
// string, not an object as serializeLaunchParamsQuery requires.
|
|
574
|
-
|
|
593
|
+
We({ ...e, tgWebAppData: void 0 }) + (e.tgWebAppData ? `&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}` : "")
|
|
575
594
|
);
|
|
576
595
|
try {
|
|
577
|
-
|
|
578
|
-
} catch (
|
|
579
|
-
throw new
|
|
596
|
+
Fe(o);
|
|
597
|
+
} catch (s) {
|
|
598
|
+
throw new vt(o, s);
|
|
580
599
|
}
|
|
581
|
-
|
|
600
|
+
ee("launchParams", o);
|
|
582
601
|
}
|
|
583
|
-
if (
|
|
584
|
-
if (!
|
|
602
|
+
if (ie()) {
|
|
603
|
+
if (!t)
|
|
585
604
|
return;
|
|
586
|
-
|
|
587
|
-
const o =
|
|
588
|
-
|
|
589
|
-
const [
|
|
590
|
-
o(...
|
|
605
|
+
r && y.reset();
|
|
606
|
+
const o = y();
|
|
607
|
+
y.set((...s) => {
|
|
608
|
+
const [i] = s, c = () => {
|
|
609
|
+
o(...s);
|
|
591
610
|
};
|
|
592
611
|
try {
|
|
593
|
-
const
|
|
594
|
-
|
|
612
|
+
const u = C(ne(oe()), i);
|
|
613
|
+
t({ name: u.eventType, params: u.eventData }, c);
|
|
595
614
|
} catch {
|
|
596
|
-
|
|
615
|
+
c();
|
|
597
616
|
}
|
|
598
617
|
});
|
|
599
618
|
return;
|
|
@@ -602,30 +621,33 @@ function Qr({ launchParams: e, onEvent: r, resetPostMessage: t } = {}) {
|
|
|
602
621
|
});
|
|
603
622
|
window.TelegramWebviewProxy = {
|
|
604
623
|
...n,
|
|
605
|
-
postEvent(o,
|
|
606
|
-
const
|
|
607
|
-
a(o,
|
|
624
|
+
postEvent(o, s) {
|
|
625
|
+
const i = () => {
|
|
626
|
+
a(o, s);
|
|
608
627
|
};
|
|
609
|
-
|
|
628
|
+
t ? t({
|
|
629
|
+
name: o,
|
|
630
|
+
params: s ? JSON.parse(s) : void 0
|
|
631
|
+
}, i) : i();
|
|
610
632
|
}
|
|
611
|
-
},
|
|
633
|
+
}, h().log("Environment was mocked by the mockTelegramEnv function");
|
|
612
634
|
}
|
|
613
|
-
function
|
|
614
|
-
return ({ req_id:
|
|
635
|
+
function Wt(e) {
|
|
636
|
+
return ({ req_id: t }) => t === e;
|
|
615
637
|
}
|
|
616
|
-
function
|
|
638
|
+
function H(e) {
|
|
617
639
|
return e.split(".").map(Number);
|
|
618
640
|
}
|
|
619
|
-
function
|
|
620
|
-
const
|
|
641
|
+
function Ft(e, t) {
|
|
642
|
+
const r = H(e), n = H(t), a = Math.max(r.length, n.length);
|
|
621
643
|
for (let o = 0; o < a; o += 1) {
|
|
622
|
-
const
|
|
623
|
-
if (
|
|
624
|
-
return
|
|
644
|
+
const s = r[o] || 0, i = n[o] || 0;
|
|
645
|
+
if (s !== i)
|
|
646
|
+
return s > i ? 1 : -1;
|
|
625
647
|
}
|
|
626
648
|
return 0;
|
|
627
649
|
}
|
|
628
|
-
const
|
|
650
|
+
const K = {
|
|
629
651
|
"6.0": [
|
|
630
652
|
"iframe_ready",
|
|
631
653
|
"iframe_will_reload",
|
|
@@ -713,40 +735,40 @@ const Q = {
|
|
|
713
735
|
],
|
|
714
736
|
9.1: ["web_app_hide_keyboard"]
|
|
715
737
|
};
|
|
716
|
-
function
|
|
717
|
-
return Object.keys(
|
|
738
|
+
function Y(e, t) {
|
|
739
|
+
return Object.keys(K).find((n) => K[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
|
|
718
740
|
}
|
|
719
|
-
function
|
|
720
|
-
const n =
|
|
741
|
+
function X(e, t, r) {
|
|
742
|
+
const n = r ? Y(
|
|
721
743
|
e,
|
|
722
|
-
|
|
723
|
-
) :
|
|
724
|
-
return n ?
|
|
725
|
-
}
|
|
726
|
-
function
|
|
727
|
-
const
|
|
728
|
-
const { method: a, version: o } = n,
|
|
729
|
-
if (
|
|
730
|
-
throw
|
|
731
|
-
return
|
|
744
|
+
t
|
|
745
|
+
) : Y(e);
|
|
746
|
+
return n ? Ft(n, r || t) <= 0 : !1;
|
|
747
|
+
}
|
|
748
|
+
function tr(e, t = "strict") {
|
|
749
|
+
const r = typeof t == "function" ? t : (n) => {
|
|
750
|
+
const { method: a, version: o } = n, s = "param" in n ? new gt(a, n.param, o) : new ht(a, o);
|
|
751
|
+
if (t === "strict")
|
|
752
|
+
throw s;
|
|
753
|
+
return h().forceWarn(s.message);
|
|
732
754
|
};
|
|
733
|
-
return (n, a) =>
|
|
755
|
+
return (n, a) => X(n, e) ? n === "web_app_set_header_color" && L(f({ color: Se() }), a) && !X(n, "color", e) ? r({ version: e, method: n, param: "color" }) : Ct(n, a) : r({ version: e, method: n });
|
|
734
756
|
}
|
|
735
|
-
function
|
|
736
|
-
return
|
|
757
|
+
function qt(e, t, r, n) {
|
|
758
|
+
return l(
|
|
737
759
|
U("web_app_invoke_custom_method", "custom_method_invoked", {
|
|
738
760
|
...n || {},
|
|
739
|
-
params: { method: e, params:
|
|
740
|
-
capture:
|
|
761
|
+
params: { method: e, params: t, req_id: r },
|
|
762
|
+
capture: Wt(r)
|
|
741
763
|
}),
|
|
742
|
-
|
|
764
|
+
mt(({ result: a, error: o }) => o ? ft(new yt(o)) : we(a))
|
|
743
765
|
);
|
|
744
766
|
}
|
|
745
|
-
function
|
|
746
|
-
return
|
|
767
|
+
function rr(e, t, r, n) {
|
|
768
|
+
return te.fn(() => l(
|
|
747
769
|
// @ts-expect-error TypeScript is unable to determine required override.
|
|
748
|
-
|
|
749
|
-
|
|
770
|
+
qt(e, t, r, n),
|
|
771
|
+
he(
|
|
750
772
|
(a) => {
|
|
751
773
|
throw a;
|
|
752
774
|
},
|
|
@@ -754,103 +776,103 @@ function Kr(e, r, t, n) {
|
|
|
754
776
|
)
|
|
755
777
|
)());
|
|
756
778
|
}
|
|
757
|
-
function
|
|
758
|
-
Object.hasOwn || (Object.hasOwn = function(e,
|
|
759
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
779
|
+
function nr() {
|
|
780
|
+
Object.hasOwn || (Object.hasOwn = function(e, t) {
|
|
781
|
+
return Object.prototype.hasOwnProperty.call(e, t);
|
|
760
782
|
});
|
|
761
783
|
}
|
|
762
|
-
function
|
|
784
|
+
function Ee(e) {
|
|
763
785
|
return q(() => decodeURIComponent(
|
|
764
|
-
atob(e).replace(/-/g, "+").replace(/_/g, "/").split("").map((
|
|
765
|
-
), (
|
|
786
|
+
atob(e).replace(/-/g, "+").replace(/_/g, "/").split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
787
|
+
), (t) => t);
|
|
766
788
|
}
|
|
767
|
-
const
|
|
768
|
-
function
|
|
789
|
+
const or = S(Ee);
|
|
790
|
+
function Pe(e) {
|
|
769
791
|
return btoa(
|
|
770
|
-
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (
|
|
792
|
+
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
|
|
771
793
|
).replace(/\+/g, "-").replace(/\//g, "_");
|
|
772
794
|
}
|
|
773
|
-
var
|
|
795
|
+
var Ot = function(e) {
|
|
774
796
|
return q(function() {
|
|
775
797
|
return JSON.parse(e);
|
|
776
|
-
},
|
|
798
|
+
}, Ue);
|
|
777
799
|
};
|
|
778
|
-
function
|
|
779
|
-
const
|
|
780
|
-
return
|
|
781
|
-
}
|
|
782
|
-
const
|
|
783
|
-
function
|
|
784
|
-
return
|
|
785
|
-
|
|
800
|
+
function Rt(e) {
|
|
801
|
+
const t = Pe(typeof e == "string" ? e : JSON.stringify(e));
|
|
802
|
+
return t.length > 512 ? m(new Error("Value is too long for start parameter")) : _(t);
|
|
803
|
+
}
|
|
804
|
+
const ar = S(Rt);
|
|
805
|
+
function sr(e, t) {
|
|
806
|
+
return W(
|
|
807
|
+
Ut(
|
|
786
808
|
e,
|
|
787
809
|
// @ts-expect-error TypeScript is unable to detect a correct override.
|
|
788
|
-
typeof
|
|
810
|
+
typeof t == "function" ? (r) => q(() => t(r), (n) => n) : t
|
|
789
811
|
)
|
|
790
812
|
);
|
|
791
813
|
}
|
|
792
|
-
function
|
|
793
|
-
return
|
|
794
|
-
|
|
795
|
-
|
|
814
|
+
function Ut(e, t) {
|
|
815
|
+
return l(
|
|
816
|
+
Ee(e),
|
|
817
|
+
Ke((r) => t ? typeof t == "function" ? t(r) : Ot(r) : _(r))
|
|
796
818
|
);
|
|
797
819
|
}
|
|
798
|
-
function
|
|
799
|
-
return
|
|
820
|
+
function ir(e) {
|
|
821
|
+
return Pe(e).length <= 512;
|
|
800
822
|
}
|
|
801
823
|
export {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
824
|
+
lr as CancelledError,
|
|
825
|
+
vt as InvalidLaunchParamsError,
|
|
826
|
+
yt as InvokeCustomMethodFailedError,
|
|
827
|
+
dt as LaunchParamsRetrieveError,
|
|
828
|
+
gt as MethodParameterUnsupportedError,
|
|
829
|
+
ht as MethodUnsupportedError,
|
|
830
|
+
mr as TimeoutError,
|
|
831
|
+
bt as UnknownEnvError,
|
|
832
|
+
nr as applyPolyfills,
|
|
833
|
+
Wt as captureSameReq,
|
|
834
|
+
Ft as compareVersions,
|
|
835
|
+
pr as createLogger,
|
|
836
|
+
tr as createPostEvent,
|
|
837
|
+
ar as createStartParam,
|
|
838
|
+
Rt as createStartParamFp,
|
|
839
|
+
be as debug,
|
|
840
|
+
or as decodeBase64Url,
|
|
841
|
+
Ee as decodeBase64UrlFp,
|
|
842
|
+
sr as decodeStartParam,
|
|
843
|
+
Ut as decodeStartParamFp,
|
|
844
|
+
_r as deepSnakeToCamelObjKeys,
|
|
823
845
|
A as emitEvent,
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
846
|
+
Pe as encodeBase64Url,
|
|
847
|
+
Y as getReleaseVersion,
|
|
848
|
+
se as hasWebviewProxy,
|
|
849
|
+
rr as invokeCustomMethod,
|
|
850
|
+
qt as invokeCustomMethodFp,
|
|
851
|
+
ie as isIframe,
|
|
852
|
+
ir as isSafeToCreateStartParam,
|
|
853
|
+
Zt as isTMA,
|
|
854
|
+
Lt as isTMAFp,
|
|
855
|
+
h as logger,
|
|
856
|
+
er as mockTelegramEnv,
|
|
857
|
+
St as off,
|
|
858
|
+
$t as offAll,
|
|
859
|
+
ve as on,
|
|
860
|
+
Ct as postEvent,
|
|
839
861
|
R as postEventFp,
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
862
|
+
Mt as postMessage,
|
|
863
|
+
y as postMessageImpl,
|
|
864
|
+
Xt as request,
|
|
843
865
|
U as requestFp,
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
866
|
+
Yt as resetGlobals,
|
|
867
|
+
Nt as retrieveLaunchParams,
|
|
868
|
+
Et as retrieveLaunchParamsFp,
|
|
869
|
+
Jt as retrieveRawInitData,
|
|
870
|
+
Pt as retrieveRawInitDataFp,
|
|
871
|
+
Qt as retrieveRawLaunchParams,
|
|
872
|
+
$ as retrieveRawLaunchParamsFp,
|
|
873
|
+
Ht as setDebug,
|
|
874
|
+
Kt as setTargetOrigin,
|
|
875
|
+
X as supports,
|
|
876
|
+
ye as targetOrigin
|
|
855
877
|
};
|
|
856
878
|
//# sourceMappingURL=index.js.map
|