@tma.js/bridge 2.2.3 → 2.2.5

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