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