@tma.js/bridge 2.0.0 → 2.0.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/dist/dts/base64-url.d.ts +1 -1
- package/dist/dts/launch-params.d.ts +2 -2
- package/dist/dts/start-param.d.ts +1 -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 +250 -246
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { is as F, looseObject as
|
|
2
|
-
import { BetterPromise as k, TimeoutError as
|
|
3
|
-
import { CancelledError as
|
|
4
|
-
import { eitherFnToSimple as S, getStorageValue as
|
|
5
|
-
import { createLogger as
|
|
6
|
-
import { parseLaunchParamsQueryFp as
|
|
7
|
-
import { errorClass as y, errorClassWithData as
|
|
8
|
-
import { signal as T, computed as
|
|
9
|
-
import
|
|
10
|
-
function
|
|
1
|
+
import { is as F, looseObject as m, function as Z, nullish as d, boolean as D, number as N, string as v, optional as J, unknown as Pe, parse as W, any as xe } from "valibot";
|
|
2
|
+
import { BetterPromise as k, TimeoutError as ke } from "better-promises";
|
|
3
|
+
import { CancelledError as cr, TimeoutError as ur } from "better-promises";
|
|
4
|
+
import { eitherFnToSimple as S, getStorageValue as Se, setStorageValue as V, createLogger as Te, createCbCollector as $e, eitherGet as Ae } from "@tma.js/toolkit";
|
|
5
|
+
import { createLogger as _r, deepSnakeToCamelObjKeys as fr } from "@tma.js/toolkit";
|
|
6
|
+
import { parseLaunchParamsQueryFp as ee, themeParams as Me, pipeJsonToSchema as te, miniAppsMessage as re, serializeLaunchParamsQuery as Le, parseLaunchParamsQuery as Ce } from "@tma.js/transformers";
|
|
7
|
+
import { errorClass as y, errorClassWithData as qe } from "error-kid";
|
|
8
|
+
import { signal as T, computed as ne } from "@tma.js/signals";
|
|
9
|
+
import We from "mitt";
|
|
10
|
+
function ae(e) {
|
|
11
11
|
return F(
|
|
12
|
-
|
|
12
|
+
m({ TelegramWebviewProxy: m({ postEvent: Z() }) }),
|
|
13
13
|
e
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function oe() {
|
|
17
17
|
try {
|
|
18
18
|
return window.self !== window.top;
|
|
19
19
|
} catch {
|
|
20
20
|
return !0;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
var
|
|
23
|
+
var Fe = function(e, t, r) {
|
|
24
24
|
if (r || arguments.length === 2) for (var n = 0, o = t.length, a; n < o; n++)
|
|
25
25
|
(a || !(n in t)) && (a || (a = Array.prototype.slice.call(t, 0, n)), a[n] = t[n]);
|
|
26
26
|
return e.concat(a || Array.prototype.slice.call(t));
|
|
27
27
|
};
|
|
28
|
-
function
|
|
28
|
+
function Re(e) {
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
31
|
function E(e, t, r, n, o, a, i, c, u) {
|
|
@@ -93,82 +93,87 @@ function l(e, t, r, n, o, a, i, c, u) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
var
|
|
96
|
+
var $ = function(e, t) {
|
|
97
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
102
|
return r(arguments) ? t.apply(this, n) : function(o) {
|
|
103
|
-
return t.apply(void 0,
|
|
103
|
+
return t.apply(void 0, Fe([o], n, !1));
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
|
-
},
|
|
106
|
+
}, Ue = { _tag: "None" }, Ie = function(e) {
|
|
107
107
|
return { _tag: "Some", value: e };
|
|
108
|
-
},
|
|
108
|
+
}, je = function(e) {
|
|
109
109
|
return e._tag === "Left";
|
|
110
|
-
}, oe = function(e) {
|
|
111
|
-
return { _tag: "Left", left: e };
|
|
112
110
|
}, se = function(e) {
|
|
111
|
+
return { _tag: "Left", left: e };
|
|
112
|
+
}, ie = function(e) {
|
|
113
113
|
return { _tag: "Right", right: e };
|
|
114
|
-
},
|
|
114
|
+
}, g = se, f = ie, ce = /* @__PURE__ */ $(2, function(e, t) {
|
|
115
115
|
return P(e) ? e : t(e.right);
|
|
116
|
-
}),
|
|
116
|
+
}), Ge = function(e) {
|
|
117
117
|
return function(t) {
|
|
118
118
|
return P(t) ? t : f(e(t.right));
|
|
119
119
|
};
|
|
120
|
-
},
|
|
120
|
+
}, ue = function(e) {
|
|
121
121
|
return function(t) {
|
|
122
|
-
return P(t) ?
|
|
122
|
+
return P(t) ? g(e(t.left)) : t;
|
|
123
123
|
};
|
|
124
|
-
}, P =
|
|
124
|
+
}, P = je, pe = function(e, t) {
|
|
125
125
|
return function(r) {
|
|
126
126
|
return P(r) ? e(r.left) : t(r.right);
|
|
127
127
|
};
|
|
128
|
-
},
|
|
128
|
+
}, ze = pe, R = pe, De = R, U = function(e, t) {
|
|
129
129
|
try {
|
|
130
130
|
return f(e());
|
|
131
131
|
} catch (r) {
|
|
132
|
-
return
|
|
132
|
+
return g(t(r));
|
|
133
133
|
}
|
|
134
|
-
},
|
|
134
|
+
}, Ne = ce, Je = ce, Be = Ue, Oe = Ie, Qe = function(e) {
|
|
135
135
|
return e._tag === "None";
|
|
136
|
-
},
|
|
136
|
+
}, He = function(e, t) {
|
|
137
137
|
return function(r) {
|
|
138
|
-
return
|
|
138
|
+
return Qe(r) ? e() : t(r.value);
|
|
139
139
|
};
|
|
140
|
-
},
|
|
141
|
-
function Ke(e) {
|
|
142
|
-
return E(f, e.of);
|
|
143
|
-
}
|
|
140
|
+
}, Ke = He;
|
|
144
141
|
function Ye(e) {
|
|
145
|
-
return E(
|
|
142
|
+
return E(f, e.of);
|
|
146
143
|
}
|
|
147
144
|
function Xe(e) {
|
|
145
|
+
return E(g, e.of);
|
|
146
|
+
}
|
|
147
|
+
function Ze(e) {
|
|
148
148
|
return function(t, r) {
|
|
149
149
|
return e.chain(t, function(n) {
|
|
150
150
|
return P(n) ? e.of(n) : r(n.right);
|
|
151
151
|
});
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Ve(e) {
|
|
155
|
+
return function(t, r) {
|
|
156
|
+
return e.map(t, ue(r));
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function et(e) {
|
|
155
160
|
return function(t, r) {
|
|
156
161
|
return function(n) {
|
|
157
|
-
return e.map(n,
|
|
162
|
+
return e.map(n, R(t, r));
|
|
158
163
|
};
|
|
159
164
|
};
|
|
160
165
|
}
|
|
161
|
-
var
|
|
162
|
-
return l(e,
|
|
163
|
-
},
|
|
164
|
-
return l(e,
|
|
165
|
-
},
|
|
166
|
+
var _e = function(e, t) {
|
|
167
|
+
return l(e, rt(t));
|
|
168
|
+
}, tt = function(e, t) {
|
|
169
|
+
return l(e, nt(t));
|
|
170
|
+
}, rt = function(e) {
|
|
166
171
|
return function(t) {
|
|
167
172
|
return function() {
|
|
168
173
|
return Promise.resolve().then(t).then(e);
|
|
169
174
|
};
|
|
170
175
|
};
|
|
171
|
-
},
|
|
176
|
+
}, nt = function(e) {
|
|
172
177
|
return function(t) {
|
|
173
178
|
return function() {
|
|
174
179
|
return Promise.all([Promise.resolve().then(t), Promise.resolve().then(e)]).then(function(r) {
|
|
@@ -177,28 +182,28 @@ var ue = function(e, t) {
|
|
|
177
182
|
});
|
|
178
183
|
};
|
|
179
184
|
};
|
|
180
|
-
},
|
|
185
|
+
}, I = function(e) {
|
|
181
186
|
return function() {
|
|
182
187
|
return Promise.resolve(e);
|
|
183
188
|
};
|
|
184
|
-
},
|
|
189
|
+
}, at = /* @__PURE__ */ $(2, function(e, t) {
|
|
185
190
|
return function() {
|
|
186
191
|
return Promise.resolve().then(e).then(function(r) {
|
|
187
192
|
return t(r)();
|
|
188
193
|
});
|
|
189
194
|
};
|
|
190
|
-
}),
|
|
191
|
-
URI:
|
|
192
|
-
map:
|
|
193
|
-
},
|
|
194
|
-
of:
|
|
195
|
-
},
|
|
196
|
-
URI:
|
|
197
|
-
map:
|
|
198
|
-
of:
|
|
199
|
-
ap:
|
|
200
|
-
chain:
|
|
201
|
-
},
|
|
195
|
+
}), fe = "Task", le = {
|
|
196
|
+
URI: fe,
|
|
197
|
+
map: _e
|
|
198
|
+
}, we = {
|
|
199
|
+
of: I
|
|
200
|
+
}, ot = {
|
|
201
|
+
URI: fe,
|
|
202
|
+
map: _e,
|
|
203
|
+
of: I,
|
|
204
|
+
ap: tt,
|
|
205
|
+
chain: at
|
|
206
|
+
}, st = function(e, t, r, n) {
|
|
202
207
|
function o(a) {
|
|
203
208
|
return a instanceof r ? a : new r(function(i) {
|
|
204
209
|
i(a);
|
|
@@ -224,7 +229,7 @@ var ue = function(e, t) {
|
|
|
224
229
|
}
|
|
225
230
|
s((n = n.apply(e, t || [])).next());
|
|
226
231
|
});
|
|
227
|
-
},
|
|
232
|
+
}, it = function(e, t) {
|
|
228
233
|
var r = { label: 0, sent: function() {
|
|
229
234
|
if (a[0] & 1) throw a[1];
|
|
230
235
|
return a[1];
|
|
@@ -283,18 +288,18 @@ var ue = function(e, t) {
|
|
|
283
288
|
if (s[0] & 5) throw s[1];
|
|
284
289
|
return { value: s[0] ? s[1] : void 0, done: !0 };
|
|
285
290
|
}
|
|
286
|
-
},
|
|
291
|
+
}, ct = /* @__PURE__ */ Xe(we), me = /* @__PURE__ */ Ye(we), ut = I, A = /* @__PURE__ */ et(le), pt = function(e, t) {
|
|
287
292
|
return function() {
|
|
288
|
-
return
|
|
293
|
+
return st(void 0, void 0, void 0, function() {
|
|
289
294
|
var r;
|
|
290
|
-
return
|
|
295
|
+
return it(this, function(n) {
|
|
291
296
|
switch (n.label) {
|
|
292
297
|
case 0:
|
|
293
|
-
return n.trys.push([0, 2, , 3]), [4, e().then(
|
|
298
|
+
return n.trys.push([0, 2, , 3]), [4, e().then(ie)];
|
|
294
299
|
case 1:
|
|
295
300
|
return [2, n.sent()];
|
|
296
301
|
case 2:
|
|
297
|
-
return r = n.sent(), [2,
|
|
302
|
+
return r = n.sent(), [2, se(t(r))];
|
|
298
303
|
case 3:
|
|
299
304
|
return [
|
|
300
305
|
2
|
|
@@ -304,16 +309,16 @@ var ue = function(e, t) {
|
|
|
304
309
|
});
|
|
305
310
|
});
|
|
306
311
|
};
|
|
307
|
-
},
|
|
308
|
-
class
|
|
312
|
+
}, _t = /* @__PURE__ */ $(2, Ve(le)), ft = _t, lt = /* @__PURE__ */ $(2, Ze(ot)), ge = lt;
|
|
313
|
+
class wt extends y("MethodUnsupportedError", (t, r) => [
|
|
309
314
|
`Method "${t}" is unsupported in Mini Apps version ${r}`
|
|
310
315
|
]) {
|
|
311
316
|
}
|
|
312
|
-
class
|
|
317
|
+
class mt extends y("MethodParameterUnsupportedError", (t, r, n) => [
|
|
313
318
|
`Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
|
|
314
319
|
]) {
|
|
315
320
|
}
|
|
316
|
-
class
|
|
321
|
+
class gt extends qe(
|
|
317
322
|
"LaunchParamsRetrieveError",
|
|
318
323
|
(t) => ({ errors: t }),
|
|
319
324
|
(t) => [
|
|
@@ -329,31 +334,31 @@ class ft extends Le(
|
|
|
329
334
|
]
|
|
330
335
|
) {
|
|
331
336
|
}
|
|
332
|
-
class
|
|
337
|
+
class ht extends y("InvalidLaunchParamsError", (t, r) => [
|
|
333
338
|
`Invalid value for launch params: ${t}`,
|
|
334
339
|
{ cause: r }
|
|
335
340
|
]) {
|
|
336
341
|
}
|
|
337
|
-
class
|
|
342
|
+
class dt extends y("UnknownEnvError") {
|
|
338
343
|
}
|
|
339
|
-
class
|
|
344
|
+
class vt extends y(
|
|
340
345
|
"InvokeCustomMethodError",
|
|
341
346
|
(t) => [`Server returned error: ${t}`]
|
|
342
347
|
) {
|
|
343
348
|
}
|
|
344
|
-
const
|
|
345
|
-
function
|
|
349
|
+
const B = "launchParams";
|
|
350
|
+
function O(e) {
|
|
346
351
|
return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
|
|
347
352
|
}
|
|
348
|
-
const
|
|
353
|
+
const bt = E(M, Ne(ee)), Jt = S(bt), yt = E(M, Ge((e) => {
|
|
349
354
|
const t = new URLSearchParams(e).get("tgWebAppData");
|
|
350
|
-
return t ?
|
|
351
|
-
})),
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
return t ? Oe(t) : Be;
|
|
356
|
+
})), Bt = E(
|
|
357
|
+
yt,
|
|
358
|
+
De((e) => {
|
|
354
359
|
throw e;
|
|
355
360
|
}, (e) => e),
|
|
356
|
-
|
|
361
|
+
Ke(() => {
|
|
357
362
|
}, (e) => e)
|
|
358
363
|
);
|
|
359
364
|
function M() {
|
|
@@ -362,14 +367,14 @@ function M() {
|
|
|
362
367
|
// Try to retrieve launch parameters from the current location. This method
|
|
363
368
|
// can return nothing in case, location was changed, and then the page was
|
|
364
369
|
// reloaded.
|
|
365
|
-
[() =>
|
|
370
|
+
[() => O(window.location.href), "window.location.href"],
|
|
366
371
|
// Then, try using the lower level API - window.performance.
|
|
367
372
|
[() => {
|
|
368
373
|
const n = performance.getEntriesByType("navigation")[0];
|
|
369
|
-
return n &&
|
|
374
|
+
return n && O(n.name);
|
|
370
375
|
}, "performance navigation entries"],
|
|
371
376
|
// Finally, try using the session storage.
|
|
372
|
-
[() =>
|
|
377
|
+
[() => Se(B), "local storage"]
|
|
373
378
|
]) {
|
|
374
379
|
const n = t();
|
|
375
380
|
if (!n) {
|
|
@@ -377,20 +382,20 @@ function M() {
|
|
|
377
382
|
continue;
|
|
378
383
|
}
|
|
379
384
|
const o = l(
|
|
380
|
-
|
|
381
|
-
|
|
385
|
+
ee(n),
|
|
386
|
+
ze((a) => a, () => !0)
|
|
382
387
|
);
|
|
383
388
|
if (typeof o != "boolean") {
|
|
384
389
|
e.push({ source: r, error: o });
|
|
385
390
|
continue;
|
|
386
391
|
}
|
|
387
|
-
return
|
|
392
|
+
return V(B, n), f(n);
|
|
388
393
|
}
|
|
389
|
-
return
|
|
394
|
+
return g(new gt(e));
|
|
390
395
|
}
|
|
391
|
-
const
|
|
392
|
-
function
|
|
393
|
-
const r = /* @__PURE__ */ new Map(), n =
|
|
396
|
+
const Ot = S(M);
|
|
397
|
+
function Et(e, t) {
|
|
398
|
+
const r = /* @__PURE__ */ new Map(), n = We(), o = (a, i, c = !1) => {
|
|
394
399
|
const u = r.get(a) || /* @__PURE__ */ new Map();
|
|
395
400
|
r.set(a, u);
|
|
396
401
|
const s = u.get(i) || [];
|
|
@@ -449,28 +454,28 @@ function q(e, t, r) {
|
|
|
449
454
|
return;
|
|
450
455
|
}
|
|
451
456
|
if (c === 2) {
|
|
452
|
-
|
|
457
|
+
H(e, t, n[1]);
|
|
453
458
|
return;
|
|
454
459
|
}
|
|
455
|
-
n.unshift(1),
|
|
460
|
+
n.unshift(1), H(e, t, a);
|
|
456
461
|
}
|
|
457
462
|
});
|
|
458
|
-
|
|
463
|
+
he(
|
|
459
464
|
e,
|
|
460
465
|
t,
|
|
461
466
|
() => i,
|
|
462
467
|
(c) => n.push(c)
|
|
463
468
|
);
|
|
464
469
|
}
|
|
465
|
-
function
|
|
470
|
+
function Q(e, t) {
|
|
466
471
|
const r = e[t];
|
|
467
|
-
|
|
472
|
+
he(e, t, () => r, (n) => {
|
|
468
473
|
Object.entries(n).forEach(([o, a]) => {
|
|
469
474
|
r[o] = a;
|
|
470
475
|
});
|
|
471
476
|
});
|
|
472
477
|
}
|
|
473
|
-
function
|
|
478
|
+
function he(e, t, r, n) {
|
|
474
479
|
Object.defineProperty(e, t, {
|
|
475
480
|
enumerable: !0,
|
|
476
481
|
configurable: !0,
|
|
@@ -478,7 +483,7 @@ function ge(e, t, r, n) {
|
|
|
478
483
|
set: n
|
|
479
484
|
});
|
|
480
485
|
}
|
|
481
|
-
function
|
|
486
|
+
function H(e, t, r) {
|
|
482
487
|
Object.defineProperty(e, t, {
|
|
483
488
|
enumerable: !0,
|
|
484
489
|
configurable: !0,
|
|
@@ -486,27 +491,27 @@ function Q(e, t, r) {
|
|
|
486
491
|
value: r
|
|
487
492
|
});
|
|
488
493
|
}
|
|
489
|
-
const
|
|
490
|
-
clipboard_text_received:
|
|
494
|
+
const Pt = {
|
|
495
|
+
clipboard_text_received: m({
|
|
491
496
|
req_id: v(),
|
|
492
497
|
data: d(v())
|
|
493
498
|
}),
|
|
494
|
-
custom_method_invoked:
|
|
499
|
+
custom_method_invoked: m({
|
|
495
500
|
req_id: v(),
|
|
496
|
-
result:
|
|
497
|
-
error:
|
|
501
|
+
result: J(Pe()),
|
|
502
|
+
error: J(v())
|
|
498
503
|
}),
|
|
499
504
|
popup_closed: d(
|
|
500
|
-
|
|
505
|
+
m({ button_id: d(v(), () => {
|
|
501
506
|
}) }),
|
|
502
507
|
{}
|
|
503
508
|
),
|
|
504
509
|
viewport_changed: d(
|
|
505
|
-
|
|
506
|
-
height:
|
|
507
|
-
width: d(
|
|
508
|
-
is_state_stable:
|
|
509
|
-
is_expanded:
|
|
510
|
+
m({
|
|
511
|
+
height: N(),
|
|
512
|
+
width: d(N(), () => window.innerWidth),
|
|
513
|
+
is_state_stable: D(),
|
|
514
|
+
is_expanded: D()
|
|
510
515
|
}),
|
|
511
516
|
// TODO: At the moment, macOS has a bug with the invalid event payload - it is always equal to
|
|
512
517
|
// null. Leaving this default value until the bug is fixed.
|
|
@@ -516,20 +521,20 @@ const vt = {
|
|
|
516
521
|
is_expanded: !0
|
|
517
522
|
})
|
|
518
523
|
),
|
|
519
|
-
theme_changed:
|
|
520
|
-
theme_params:
|
|
524
|
+
theme_changed: m({
|
|
525
|
+
theme_params: Me()
|
|
521
526
|
})
|
|
522
527
|
};
|
|
523
|
-
function
|
|
528
|
+
function K(e) {
|
|
524
529
|
if (e.source !== window.parent)
|
|
525
530
|
return;
|
|
526
531
|
let t;
|
|
527
532
|
try {
|
|
528
|
-
t = W(
|
|
533
|
+
t = W(te(re()), e.data);
|
|
529
534
|
} catch {
|
|
530
535
|
return;
|
|
531
536
|
}
|
|
532
|
-
const { eventType: r, eventData: n } = t, o =
|
|
537
|
+
const { eventType: r, eventData: n } = t, o = Pt[r];
|
|
533
538
|
let a;
|
|
534
539
|
try {
|
|
535
540
|
a = o ? W(o, n) : n;
|
|
@@ -545,17 +550,17 @@ function H(e) {
|
|
|
545
550
|
i
|
|
546
551
|
);
|
|
547
552
|
}
|
|
548
|
-
|
|
553
|
+
kt(r, a);
|
|
549
554
|
}
|
|
550
555
|
const {
|
|
551
|
-
on:
|
|
552
|
-
off:
|
|
553
|
-
emit:
|
|
554
|
-
clear:
|
|
555
|
-
} =
|
|
556
|
+
on: de,
|
|
557
|
+
off: xt,
|
|
558
|
+
emit: kt,
|
|
559
|
+
clear: St
|
|
560
|
+
} = Et(
|
|
556
561
|
() => {
|
|
557
562
|
const e = window;
|
|
558
|
-
!e.TelegramGameProxy && (e.TelegramGameProxy = {}), q(e.TelegramGameProxy, "receiveEvent", C),
|
|
563
|
+
!e.TelegramGameProxy && (e.TelegramGameProxy = {}), q(e.TelegramGameProxy, "receiveEvent", C), Q(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), q(e.Telegram.WebView, "receiveEvent", C), Q(e.Telegram, "WebView"), q(e, "TelegramGameProxy_receiveEvent", C), window.addEventListener("message", K);
|
|
559
564
|
},
|
|
560
565
|
() => {
|
|
561
566
|
[
|
|
@@ -570,84 +575,83 @@ const {
|
|
|
570
575
|
return;
|
|
571
576
|
const [n, o] = r;
|
|
572
577
|
"unwrap" in o && (o.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
|
|
573
|
-
}), window.removeEventListener("message",
|
|
578
|
+
}), window.removeEventListener("message", K);
|
|
574
579
|
}
|
|
575
|
-
), x = T(!1),
|
|
580
|
+
), x = T(!1), j = T("https://web.telegram.org"), Tt = (e) => {
|
|
576
581
|
h().log("Event received:", e);
|
|
577
|
-
},
|
|
578
|
-
function
|
|
579
|
-
e !== x() && (x.set(e), (e ?
|
|
582
|
+
}, ve = ne(x);
|
|
583
|
+
function Qt(e) {
|
|
584
|
+
e !== x() && (x.set(e), (e ? de : xt)("*", Tt));
|
|
580
585
|
}
|
|
581
|
-
const
|
|
582
|
-
function
|
|
583
|
-
|
|
586
|
+
const be = ne(j);
|
|
587
|
+
function Ht(e) {
|
|
588
|
+
j.set(e), h().log("New target origin set", e);
|
|
584
589
|
}
|
|
585
590
|
const b = T((...e) => {
|
|
586
591
|
window.parent.postMessage(...e);
|
|
587
|
-
}), h = T(
|
|
592
|
+
}), h = T(Te("Bridge", {
|
|
588
593
|
bgColor: "#9147ff",
|
|
589
594
|
textColor: "white",
|
|
590
|
-
shouldLog:
|
|
595
|
+
shouldLog: ve
|
|
591
596
|
}));
|
|
592
|
-
function
|
|
593
|
-
|
|
597
|
+
function Kt() {
|
|
598
|
+
St(), [b, j, be, x, ve, h].forEach((e) => {
|
|
594
599
|
e.unsubAll(), "reset" in e && e.reset();
|
|
595
600
|
});
|
|
596
601
|
}
|
|
597
|
-
const
|
|
598
|
-
function
|
|
602
|
+
const $t = (...e) => b()(...e);
|
|
603
|
+
function At(e, t) {
|
|
599
604
|
l(
|
|
600
|
-
|
|
605
|
+
G(
|
|
601
606
|
// @ts-expect-error It's ok, TS can't determine a specific override.
|
|
602
607
|
e,
|
|
603
608
|
t
|
|
604
609
|
),
|
|
605
|
-
|
|
610
|
+
ue((r) => {
|
|
606
611
|
throw r;
|
|
607
612
|
})
|
|
608
613
|
);
|
|
609
614
|
}
|
|
610
|
-
function
|
|
615
|
+
function G(e, t) {
|
|
611
616
|
h().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
|
|
612
617
|
const r = window, n = JSON.stringify({ eventType: e, eventData: t });
|
|
613
|
-
return
|
|
618
|
+
return oe() ? ($t(n, be()), f(void 0)) : ae(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), f(void 0)) : F(m({ external: m({ notify: Z() }) }), r) ? (r.external.notify(n), f(void 0)) : g(new dt());
|
|
614
619
|
}
|
|
615
|
-
function
|
|
620
|
+
function z(e, t, r) {
|
|
616
621
|
r || (r = {});
|
|
617
622
|
const {
|
|
618
623
|
// If no capture function was passed, we capture the first compatible event.
|
|
619
624
|
capture: n = () => !0,
|
|
620
|
-
postEvent: o =
|
|
621
|
-
} = r, [a, i] =
|
|
625
|
+
postEvent: o = G
|
|
626
|
+
} = r, [a, i] = $e(), c = new k((u) => {
|
|
622
627
|
(Array.isArray(t) ? t : [t]).forEach((s) => {
|
|
623
628
|
a(
|
|
624
|
-
|
|
629
|
+
de(s, (p) => {
|
|
625
630
|
(Array.isArray(t) ? n({ event: s, payload: p }) : n(p)) && u(p);
|
|
626
631
|
})
|
|
627
632
|
);
|
|
628
633
|
});
|
|
629
634
|
}, r).finally(i);
|
|
630
635
|
return l(
|
|
631
|
-
o(e, r.params),
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
)
|
|
636
|
+
ut(o(e, r.params)),
|
|
637
|
+
ft((u) => (c.catch(() => {
|
|
638
|
+
}).cancel(), u)),
|
|
639
|
+
ge(() => pt(() => c, (u) => u))
|
|
636
640
|
);
|
|
637
641
|
}
|
|
638
|
-
function
|
|
642
|
+
function Yt(e, t, r) {
|
|
639
643
|
const { postEvent: n } = r || {};
|
|
640
644
|
return k.fn(() => l(
|
|
641
645
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
642
|
-
|
|
646
|
+
z(e, t, {
|
|
643
647
|
...r,
|
|
644
648
|
postEvent: n ? (...o) => {
|
|
645
649
|
try {
|
|
646
650
|
return n(...o), f(void 0);
|
|
647
651
|
} catch (a) {
|
|
648
|
-
return
|
|
652
|
+
return g(a);
|
|
649
653
|
}
|
|
650
|
-
} :
|
|
654
|
+
} : G
|
|
651
655
|
}),
|
|
652
656
|
A(
|
|
653
657
|
(o) => {
|
|
@@ -657,8 +661,8 @@ function Ot(e, t, r) {
|
|
|
657
661
|
)
|
|
658
662
|
)());
|
|
659
663
|
}
|
|
660
|
-
function
|
|
661
|
-
const r =
|
|
664
|
+
function Xt(e, t) {
|
|
665
|
+
const r = Mt(
|
|
662
666
|
// @ts-expect-error TS doesn't get what override we are going to use.
|
|
663
667
|
e,
|
|
664
668
|
t
|
|
@@ -670,37 +674,37 @@ function Qt(e, t) {
|
|
|
670
674
|
(n) => n
|
|
671
675
|
))()) : r;
|
|
672
676
|
}
|
|
673
|
-
function
|
|
674
|
-
const r =
|
|
677
|
+
function Mt(e, t) {
|
|
678
|
+
const r = ae(window);
|
|
675
679
|
if (!e)
|
|
676
|
-
return r || l(M(),
|
|
680
|
+
return r || l(M(), R(() => !1, () => !0));
|
|
677
681
|
if (r)
|
|
678
|
-
return
|
|
682
|
+
return me(!0);
|
|
679
683
|
const { timeout: n = 100 } = t || {};
|
|
680
684
|
return l(
|
|
681
|
-
|
|
685
|
+
z("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
|
|
682
686
|
A(
|
|
683
|
-
(o) =>
|
|
687
|
+
(o) => ke.is(o) ? f(!1) : g(o),
|
|
684
688
|
() => f(!0)
|
|
685
689
|
)
|
|
686
690
|
);
|
|
687
691
|
}
|
|
688
|
-
function
|
|
692
|
+
function Zt({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
689
693
|
if (e) {
|
|
690
694
|
const a = typeof e == "string" || e instanceof URLSearchParams ? e.toString() : (
|
|
691
695
|
// Here we have to trick serializeLaunchParamsQuery into thinking, it serializes a valid
|
|
692
696
|
// value. We are doing it because we are working with tgWebAppData presented as a
|
|
693
697
|
// string, not an object as serializeLaunchParamsQuery requires.
|
|
694
|
-
|
|
698
|
+
Le({ ...e, tgWebAppData: void 0 }) + (e.tgWebAppData ? `&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}` : "")
|
|
695
699
|
);
|
|
696
700
|
try {
|
|
697
|
-
|
|
701
|
+
Ce(a);
|
|
698
702
|
} catch (i) {
|
|
699
|
-
throw new
|
|
703
|
+
throw new ht(a, i);
|
|
700
704
|
}
|
|
701
|
-
|
|
705
|
+
V("launchParams", a);
|
|
702
706
|
}
|
|
703
|
-
if (
|
|
707
|
+
if (oe()) {
|
|
704
708
|
if (!t)
|
|
705
709
|
return;
|
|
706
710
|
r && b.reset();
|
|
@@ -710,7 +714,7 @@ function Ht({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
710
714
|
a(...i);
|
|
711
715
|
};
|
|
712
716
|
try {
|
|
713
|
-
const s = W(
|
|
717
|
+
const s = W(te(re()), c);
|
|
714
718
|
t([s.eventType, s.eventData], u);
|
|
715
719
|
} catch {
|
|
716
720
|
u();
|
|
@@ -730,14 +734,14 @@ function Ht({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
730
734
|
}
|
|
731
735
|
}, h().log("Environment was mocked by the mockTelegramEnv function");
|
|
732
736
|
}
|
|
733
|
-
function
|
|
737
|
+
function Lt(e) {
|
|
734
738
|
return ({ req_id: t }) => t === e;
|
|
735
739
|
}
|
|
736
|
-
function
|
|
740
|
+
function Y(e) {
|
|
737
741
|
return e.split(".").map(Number);
|
|
738
742
|
}
|
|
739
|
-
function
|
|
740
|
-
const r =
|
|
743
|
+
function Ct(e, t) {
|
|
744
|
+
const r = Y(e), n = Y(t), o = Math.max(r.length, n.length);
|
|
741
745
|
for (let a = 0; a < o; a += 1) {
|
|
742
746
|
const i = r[a] || 0, c = n[a] || 0;
|
|
743
747
|
if (i !== c)
|
|
@@ -746,9 +750,9 @@ function $t(e, t) {
|
|
|
746
750
|
return 0;
|
|
747
751
|
}
|
|
748
752
|
function _(e, t) {
|
|
749
|
-
return
|
|
753
|
+
return Ct(e, t) <= 0;
|
|
750
754
|
}
|
|
751
|
-
function
|
|
755
|
+
function X(e, t, r) {
|
|
752
756
|
if (typeof r == "string") {
|
|
753
757
|
if (e === "web_app_open_link") {
|
|
754
758
|
if (t === "try_instant_view")
|
|
@@ -845,29 +849,29 @@ function Y(e, t, r) {
|
|
|
845
849
|
].includes(e);
|
|
846
850
|
}
|
|
847
851
|
}
|
|
848
|
-
function
|
|
852
|
+
function Vt(e, t = "strict") {
|
|
849
853
|
const r = typeof t == "function" ? t : (n) => {
|
|
850
|
-
const { method: o, version: a } = n, i = "param" in n ? new
|
|
854
|
+
const { method: o, version: a } = n, i = "param" in n ? new mt(o, n.param, a) : new wt(o, a);
|
|
851
855
|
if (t === "strict")
|
|
852
856
|
throw i;
|
|
853
857
|
return h().forceWarn(i.message);
|
|
854
858
|
};
|
|
855
|
-
return (n, o) =>
|
|
859
|
+
return (n, o) => X(n, e) ? n === "web_app_set_header_color" && F(m({ color: xe() }), o) && !X(n, "color", e) ? r({ version: e, method: n, param: "color" }) : At(n, o) : r({ version: e, method: n });
|
|
856
860
|
}
|
|
857
|
-
function
|
|
861
|
+
function qt(e, t, r, n) {
|
|
858
862
|
return l(
|
|
859
|
-
|
|
863
|
+
z("web_app_invoke_custom_method", "custom_method_invoked", {
|
|
860
864
|
...n || {},
|
|
861
865
|
params: { method: e, params: t, req_id: r },
|
|
862
|
-
capture:
|
|
866
|
+
capture: Lt(r)
|
|
863
867
|
}),
|
|
864
|
-
|
|
868
|
+
ge(({ result: o, error: a }) => a ? ct(new vt(a)) : me(o))
|
|
865
869
|
);
|
|
866
870
|
}
|
|
867
|
-
function
|
|
871
|
+
function er(e, t, r, n) {
|
|
868
872
|
return k.fn(() => l(
|
|
869
873
|
// @ts-expect-error TypeScript is unable to determine required override.
|
|
870
|
-
|
|
874
|
+
qt(e, t, r, n),
|
|
871
875
|
A(
|
|
872
876
|
(o) => {
|
|
873
877
|
throw o;
|
|
@@ -876,102 +880,102 @@ function Yt(e, t, r, n) {
|
|
|
876
880
|
)
|
|
877
881
|
)());
|
|
878
882
|
}
|
|
879
|
-
function
|
|
883
|
+
function tr() {
|
|
880
884
|
Object.hasOwn || (Object.hasOwn = function(e, t) {
|
|
881
885
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
882
886
|
});
|
|
883
887
|
}
|
|
884
|
-
function
|
|
888
|
+
function ye(e) {
|
|
885
889
|
return U(() => decodeURIComponent(
|
|
886
890
|
atob(e).replace(/-/g, "+").replace(/_/g, "/").split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
887
891
|
), (t) => t);
|
|
888
892
|
}
|
|
889
|
-
const
|
|
890
|
-
function
|
|
893
|
+
const rr = S(ye);
|
|
894
|
+
function Ee(e) {
|
|
891
895
|
return btoa(
|
|
892
896
|
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
|
|
893
897
|
).replace(/\+/g, "-").replace(/\//g, "_");
|
|
894
898
|
}
|
|
895
|
-
var
|
|
899
|
+
var Wt = function(e) {
|
|
896
900
|
return U(function() {
|
|
897
901
|
return JSON.parse(e);
|
|
898
|
-
},
|
|
902
|
+
}, Re);
|
|
899
903
|
};
|
|
900
|
-
function
|
|
901
|
-
const t =
|
|
902
|
-
return t.length > 512 ?
|
|
903
|
-
}
|
|
904
|
-
const
|
|
905
|
-
function
|
|
906
|
-
return
|
|
907
|
-
|
|
904
|
+
function Ft(e) {
|
|
905
|
+
const t = Ee(typeof e == "string" ? e : JSON.stringify(e));
|
|
906
|
+
return t.length > 512 ? g(new Error("Value is too long for start parameter")) : f(t);
|
|
907
|
+
}
|
|
908
|
+
const nr = S(Ft);
|
|
909
|
+
function ar(e, t) {
|
|
910
|
+
return Ae(
|
|
911
|
+
Rt(
|
|
908
912
|
e,
|
|
909
913
|
// @ts-expect-error TypeScript is unable to detect a correct override.
|
|
910
914
|
typeof t == "function" ? (r) => U(() => t(r), (n) => n) : t
|
|
911
915
|
)
|
|
912
916
|
);
|
|
913
917
|
}
|
|
914
|
-
function
|
|
918
|
+
function Rt(e, t) {
|
|
915
919
|
return l(
|
|
916
|
-
|
|
917
|
-
|
|
920
|
+
ye(e),
|
|
921
|
+
Je((r) => t ? typeof t == "function" ? t(r) : Wt(r) : f(r))
|
|
918
922
|
);
|
|
919
923
|
}
|
|
920
|
-
function
|
|
921
|
-
return
|
|
924
|
+
function or(e) {
|
|
925
|
+
return Ee(e).length <= 512;
|
|
922
926
|
}
|
|
923
927
|
export {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
928
|
+
cr as CancelledError,
|
|
929
|
+
ht as InvalidLaunchParamsError,
|
|
930
|
+
vt as InvokeCustomMethodFailedError,
|
|
931
|
+
gt as LaunchParamsRetrieveError,
|
|
932
|
+
mt as MethodParameterUnsupportedError,
|
|
933
|
+
wt as MethodUnsupportedError,
|
|
934
|
+
ur as TimeoutError,
|
|
935
|
+
dt as UnknownEnvError,
|
|
936
|
+
tr as applyPolyfills,
|
|
937
|
+
Lt as captureSameReq,
|
|
938
|
+
Ct as compareVersions,
|
|
939
|
+
_r as createLogger,
|
|
940
|
+
Vt as createPostEvent,
|
|
941
|
+
nr as createStartParam,
|
|
942
|
+
Ft as createStartParamFp,
|
|
943
|
+
ve as debug,
|
|
944
|
+
rr as decodeBase64Url,
|
|
945
|
+
ye as decodeBase64UrlFp,
|
|
946
|
+
ar as decodeStartParam,
|
|
947
|
+
Rt as decodeStartParamFp,
|
|
948
|
+
fr as deepSnakeToCamelObjKeys,
|
|
945
949
|
C as emitEvent,
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
950
|
+
Ee as encodeBase64Url,
|
|
951
|
+
ae as hasWebviewProxy,
|
|
952
|
+
er as invokeCustomMethod,
|
|
953
|
+
qt as invokeCustomMethodFp,
|
|
954
|
+
oe as isIframe,
|
|
955
|
+
or as isSafeToCreateStartParam,
|
|
956
|
+
Xt as isTMA,
|
|
957
|
+
Mt as isTMAFp,
|
|
954
958
|
h as logger,
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
959
|
+
Zt as mockTelegramEnv,
|
|
960
|
+
xt as off,
|
|
961
|
+
St as offAll,
|
|
962
|
+
de as on,
|
|
963
|
+
At as postEvent,
|
|
964
|
+
G as postEventFp,
|
|
965
|
+
$t as postMessage,
|
|
962
966
|
b as postMessageImpl,
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
967
|
+
Yt as request,
|
|
968
|
+
z as requestFp,
|
|
969
|
+
Kt as resetGlobals,
|
|
970
|
+
Jt as retrieveLaunchParams,
|
|
971
|
+
bt as retrieveLaunchParamsFp,
|
|
972
|
+
Bt as retrieveRawInitData,
|
|
973
|
+
yt as retrieveRawInitDataFp,
|
|
974
|
+
Ot as retrieveRawLaunchParams,
|
|
971
975
|
M as retrieveRawLaunchParamsFp,
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
+
Qt as setDebug,
|
|
977
|
+
Ht as setTargetOrigin,
|
|
978
|
+
X as supports,
|
|
979
|
+
be as targetOrigin
|
|
976
980
|
};
|
|
977
981
|
//# sourceMappingURL=index.js.map
|