@vbotma/bridge 2.2.9 → 2.2.10

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,16 +1,16 @@
1
- import { is as O, looseObject as w, function as re, nullish as E, boolean as D, number as G, string as P, optional as J, unknown as ge, parse as A, any as ye } from "valibot";
2
- import { throwifyFpFn as W, getStorageValue as ve, setStorageValue as R, createLogger as Ee, throwifyAnyEither as C, createCbCollector as ne, BetterTaskEither as oe } from "@vbotma/toolkit";
3
- import { createLogger as xt, deepSnakeToCamelObjKeys as St } from "@vbotma/toolkit";
4
- import { BetterPromise as ae, TimeoutError as Pe } from "better-promises";
5
- import { CancelledError as At, TimeoutError as Bt } from "better-promises";
1
+ import { is as O, looseObject as w, function as ne, nullish as P, boolean as D, number as G, string as x, optional as N, unknown as he, parse as W, any as ye } from "valibot";
2
+ import { throwifyFpFn as C, getStorageValue as ve, setStorageValue as R, createLogger as Ee, throwifyAnyEither as A, createCbCollector as oe, BetterTaskEither as ae } from "@vbotma/toolkit";
3
+ import { createLogger as St, deepSnakeToCamelObjKeys as kt } from "@vbotma/toolkit";
4
+ import { BetterPromise as se, TimeoutError as Pe } from "better-promises";
5
+ import { CancelledError as Bt, TimeoutError as Ct } from "better-promises";
6
6
  import { function as l, either as c, option as F, taskEither as d, json as xe } from "fp-ts";
7
7
  import { errorClassWithData as Se, errorClass as S } from "error-kid";
8
- import { parseLaunchParamsQueryFp as se, themeParams as ke, pipeJsonToSchema as T, miniAppsMessage as U, serializeLaunchParamsQuery as ie, parseLaunchParamsQuery as pe } from "@vbotma/transformers";
9
- import { signal as g, computed as ce } from "@vbotma/signals";
10
- import Ae from "mitt";
11
- function _e(e) {
8
+ import { parseLaunchParamsQueryFp as ie, themeParams as ke, pipeJsonToSchema as T, miniAppsMessage as U, serializeLaunchParamsQuery as pe, parseLaunchParamsQuery as ce } from "@vbotma/transformers";
9
+ import { signal as y, computed as _e } from "@vbotma/signals";
10
+ import We from "mitt";
11
+ function ue(e) {
12
12
  return O(
13
- w({ VBotWebviewProxy: w({ postEvent: re() }) }),
13
+ w({ VBotWebviewProxy: w({ postEvent: ne() }) }),
14
14
  e
15
15
  );
16
16
  }
@@ -28,11 +28,11 @@ class Be extends (/* @__PURE__ */ S(
28
28
  ]
29
29
  )) {
30
30
  }
31
- class We extends (/* @__PURE__ */ S("MethodParameterUnsupportedError", (t, r, n) => [
31
+ class Ce extends (/* @__PURE__ */ S("MethodParameterUnsupportedError", (t, r, n) => [
32
32
  `Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
33
33
  ])) {
34
34
  }
35
- class Ce extends (/* @__PURE__ */ Se(
35
+ class Ae extends (/* @__PURE__ */ Se(
36
36
  "LaunchParamsRetrieveError",
37
37
  (t) => ({ errors: t }),
38
38
  (t) => [
@@ -46,7 +46,7 @@ class Ce extends (/* @__PURE__ */ Se(
46
46
  ]
47
47
  )) {
48
48
  }
49
- class ue extends (/* @__PURE__ */ S(
49
+ class fe extends (/* @__PURE__ */ S(
50
50
  "InvalidLaunchParamsError",
51
51
  (t, r) => [
52
52
  `Invalid value for launch params: ${t}`,
@@ -54,7 +54,7 @@ class ue extends (/* @__PURE__ */ S(
54
54
  ]
55
55
  )) {
56
56
  }
57
- class fe extends (/* @__PURE__ */ S("UnknownEnvError")) {
57
+ class le extends (/* @__PURE__ */ S("UnknownEnvError")) {
58
58
  }
59
59
  class Ve extends (/* @__PURE__ */ S(
60
60
  "InvokeCustomMethodError",
@@ -62,16 +62,16 @@ class Ve extends (/* @__PURE__ */ S(
62
62
  )) {
63
63
  }
64
64
  const H = "launchParams";
65
- function N(e) {
65
+ function Q(e) {
66
66
  return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
67
67
  }
68
68
  function Le() {
69
69
  return l.pipe(
70
70
  V(),
71
- c.chainW(se)
71
+ c.chainW(ie)
72
72
  );
73
73
  }
74
- const rt = W(Le);
74
+ const rt = C(Le);
75
75
  function Me() {
76
76
  return l.pipe(
77
77
  V(),
@@ -97,11 +97,11 @@ function V() {
97
97
  // Try to retrieve launch parameters from the current location. This method
98
98
  // can return nothing in case, location was changed, and then the page was
99
99
  // reloaded.
100
- [() => N(window.location.href), "window.location.href"],
100
+ [() => Q(window.location.href), "window.location.href"],
101
101
  // Then, try using the lower level API - window.performance.
102
102
  [() => {
103
103
  const n = performance.getEntriesByType("navigation")[0];
104
- return n && N(n.name);
104
+ return n && Q(n.name);
105
105
  }, "performance navigation entries"],
106
106
  // Finally, try using the session storage.
107
107
  [() => ve(H), "local storage"]
@@ -112,7 +112,7 @@ function V() {
112
112
  continue;
113
113
  }
114
114
  const a = l.pipe(
115
- se(n),
115
+ ie(n),
116
116
  c.foldW((o) => o, () => !0)
117
117
  );
118
118
  if (typeof a != "boolean") {
@@ -121,11 +121,11 @@ function V() {
121
121
  }
122
122
  return R(H, n), c.right(n);
123
123
  }
124
- return c.left(new Ce(e));
124
+ return c.left(new Ae(e));
125
125
  }
126
- const ot = W(V);
127
- function le(e, t) {
128
- const r = /* @__PURE__ */ new Map(), n = Ae(), a = (o, s, i = !1) => {
126
+ const ot = C(V);
127
+ function I(e, t) {
128
+ const r = /* @__PURE__ */ new Map(), n = We(), a = (o, s, i = !1) => {
129
129
  const _ = r.get(o) || /* @__PURE__ */ new Map();
130
130
  r.set(o, _);
131
131
  const p = _.get(s) || [];
@@ -168,25 +168,25 @@ function M(e, t) {
168
168
  source: window.parent
169
169
  }));
170
170
  }
171
- const B = g(!1), I = g("https://web.telegram.org"), qe = (e) => {
171
+ const B = y(!1), $ = y("https://web.telegram.org"), qe = (e) => {
172
172
  h().log("Event received:", e);
173
- }, we = ce(B);
173
+ }, we = _e(B);
174
174
  function at(e) {
175
- e !== B() && (B.set(e), (e ? $ : Oe)("*", qe));
175
+ e !== B() && (B.set(e), (e ? z : Oe)("*", qe));
176
176
  }
177
- const de = ce(I);
177
+ const de = _e($);
178
178
  function st(e) {
179
- I.set(e), h().log("New target origin set", e);
179
+ $.set(e), h().log("New target origin set", e);
180
180
  }
181
- const b = g((...e) => {
181
+ const b = y((...e) => {
182
182
  window.parent.postMessage(...e);
183
- }), h = g(Ee("Bridge", {
183
+ }), h = y(Ee("Bridge", {
184
184
  bgColor: "#9147ff",
185
185
  textColor: "white",
186
186
  shouldLog: we
187
187
  }));
188
188
  function it() {
189
- Te(), [b, I, de, B, we, h].forEach((e) => {
189
+ Te(), [b, $, de, B, we, h].forEach((e) => {
190
190
  e.unsubAll(), "reset" in e && e.reset();
191
191
  });
192
192
  }
@@ -206,10 +206,10 @@ function q(e, t, r) {
206
206
  return;
207
207
  }
208
208
  if (i === 2) {
209
- K(e, t, n[1]);
209
+ Y(e, t, n[1]);
210
210
  return;
211
211
  }
212
- n.unshift(1), K(e, t, o);
212
+ n.unshift(1), Y(e, t, o);
213
213
  }
214
214
  });
215
215
  me(
@@ -219,7 +219,7 @@ function q(e, t, r) {
219
219
  (i) => n.push(i)
220
220
  );
221
221
  }
222
- function Q(e, t) {
222
+ function K(e, t) {
223
223
  const r = e[t];
224
224
  me(e, t, () => r, (n) => {
225
225
  Object.entries(n).forEach(([a, o]) => {
@@ -235,7 +235,7 @@ function me(e, t, r, n) {
235
235
  set: n
236
236
  });
237
237
  }
238
- function K(e, t, r) {
238
+ function Y(e, t, r) {
239
239
  Object.defineProperty(e, t, {
240
240
  enumerable: !0,
241
241
  configurable: !0,
@@ -245,23 +245,23 @@ function K(e, t, r) {
245
245
  }
246
246
  const Fe = {
247
247
  clipboard_text_received: w({
248
- req_id: P(),
249
- data: E(P())
248
+ req_id: x(),
249
+ data: P(x())
250
250
  }),
251
251
  custom_method_invoked: w({
252
- req_id: P(),
253
- result: J(ge()),
254
- error: J(P())
252
+ req_id: x(),
253
+ result: N(he()),
254
+ error: N(x())
255
255
  }),
256
- popup_closed: E(
257
- w({ button_id: E(P(), () => {
256
+ popup_closed: P(
257
+ w({ button_id: P(x(), () => {
258
258
  }) }),
259
259
  {}
260
260
  ),
261
- viewport_changed: E(
261
+ viewport_changed: P(
262
262
  w({
263
263
  height: G(),
264
- width: E(G(), () => window.innerWidth),
264
+ width: P(G(), () => window.innerWidth),
265
265
  is_state_stable: D(),
266
266
  is_expanded: D()
267
267
  }),
@@ -277,19 +277,19 @@ const Fe = {
277
277
  theme_params: ke()
278
278
  })
279
279
  };
280
- function Y(e) {
280
+ function X(e) {
281
281
  if (e.source !== window.parent)
282
282
  return;
283
283
  let t;
284
284
  try {
285
- t = A(T(U()), e.data);
285
+ t = W(T(U()), e.data);
286
286
  } catch {
287
287
  return;
288
288
  }
289
289
  const { eventType: r, eventData: n } = t, a = Fe[r];
290
290
  let o;
291
291
  try {
292
- o = a ? A(a, n) : n;
292
+ o = a ? W(a, n) : n;
293
293
  } catch (s) {
294
294
  return h().forceError(
295
295
  [
@@ -305,14 +305,14 @@ function Y(e) {
305
305
  Re(r, o);
306
306
  }
307
307
  const {
308
- on: $,
308
+ on: z,
309
309
  off: Oe,
310
310
  emit: Re,
311
311
  clear: Te
312
- } = le(
312
+ } = I(
313
313
  () => {
314
314
  const e = window;
315
- !e.TelegramGameProxy && (e.TelegramGameProxy = {}), q(e.TelegramGameProxy, "receiveEvent", M), Q(e, "TelegramGameProxy"), !e.VBot && (e.VBot = {}), !e.VBot.WebView && (e.VBot.WebView = {}), q(e.VBot.WebView, "receiveEvent", M), Q(e.VBot, "WebView"), q(e, "TelegramGameProxy_receiveEvent", M), window.addEventListener("message", Y);
315
+ !e.TelegramGameProxy && (e.TelegramGameProxy = {}), q(e.TelegramGameProxy, "receiveEvent", M), K(e, "TelegramGameProxy"), !e.VBot && (e.VBot = {}), !e.VBot.WebView && (e.VBot.WebView = {}), q(e.VBot.WebView, "receiveEvent", M), K(e.VBot, "WebView"), q(e, "TelegramGameProxy_receiveEvent", M), window.addEventListener("message", X);
316
316
  },
317
317
  () => {
318
318
  [
@@ -327,7 +327,7 @@ const {
327
327
  return;
328
328
  const [n, a] = r;
329
329
  "unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
330
- }), window.removeEventListener("message", Y);
330
+ }), window.removeEventListener("message", X);
331
331
  }
332
332
  ), Ue = (...e) => b()(...e);
333
333
  function je(e, t) {
@@ -345,17 +345,17 @@ function je(e, t) {
345
345
  function k(e, t) {
346
346
  h().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
347
347
  const r = window, n = JSON.stringify({ eventType: e, eventData: t });
348
- return j() ? (Ue(n, de()), c.right(void 0)) : _e(r) ? (r.VBotWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : O(w({ external: w({ notify: re() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new fe());
348
+ return j() ? (Ue(n, de()), c.right(void 0)) : ue(r) ? (r.VBotWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : O(w({ external: w({ notify: ne() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new le());
349
349
  }
350
- function z(e, t, r = {}) {
350
+ function J(e, t, r = {}) {
351
351
  const {
352
352
  // If no capture function was passed, we capture the first compatible event.
353
353
  capture: n = () => !0,
354
354
  postEvent: a = k
355
- } = r, o = g(), [s, i] = ne();
355
+ } = r, o = y(), [s, i] = oe();
356
356
  (Array.isArray(t) ? t : [t]).forEach((p) => {
357
357
  s(
358
- $(p, (u) => {
358
+ z(p, (u) => {
359
359
  const f = Array.isArray(t);
360
360
  n(f ? { event: p, payload: u } : u) && o.set([
361
361
  f ? { event: p, payload: u } : u
@@ -366,25 +366,25 @@ function z(e, t, r = {}) {
366
366
  const _ = (p) => (i(), p);
367
367
  return l.pipe(
368
368
  async () => a(e, r.params),
369
- d.chainW(() => oe((p, u, f) => {
369
+ d.chainW(() => ae((p, u, f) => {
370
370
  const m = o();
371
371
  if (m)
372
372
  return p(m[0]);
373
- const y = (v) => {
374
- v && p(v[0]);
373
+ const v = (E) => {
374
+ E && p(E[0]);
375
375
  }, L = () => {
376
- o.unsub(y);
376
+ o.unsub(v);
377
377
  };
378
- o.sub(y), f.on("finalized", L);
378
+ o.sub(v), f.on("finalized", L);
379
379
  }, r)),
380
380
  d.mapBoth(_, _)
381
381
  );
382
382
  }
383
383
  function pt(e, t, r) {
384
384
  const { postEvent: n } = r || {};
385
- return C(
385
+ return A(
386
386
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
387
- z(e, t, {
387
+ J(e, t, {
388
388
  ...r,
389
389
  postEvent: n ? (...a) => {
390
390
  try {
@@ -402,19 +402,19 @@ function ct(e, t) {
402
402
  e,
403
403
  t
404
404
  );
405
- return typeof r == "function" ? ae.fn(() => C(r)) : r;
405
+ return typeof r == "function" ? se.fn(() => A(r)) : r;
406
406
  }
407
407
  function Ie(e, t) {
408
- const r = _e(window);
408
+ const r = ue(window);
409
409
  if (!e)
410
410
  return r || l.pipe(V(), c.match(() => !1, () => !0));
411
411
  if (r)
412
412
  return d.right(!0);
413
413
  const { timeout: n = 100 } = t || {};
414
414
  return l.pipe(
415
- z("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
415
+ J("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
416
416
  d.match(
417
- (a) => Pe.is(a) || fe.is(a) ? c.right(!1) : c.left(a),
417
+ (a) => Pe.is(a) || le.is(a) ? c.right(!1) : c.left(a),
418
418
  () => c.right(!0)
419
419
  )
420
420
  );
@@ -425,12 +425,12 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
425
425
  // Here we have to trick serializeLaunchParamsQuery into thinking, it serializes a valid
426
426
  // value. We are doing it because we are working with vbWebAppData presented as a
427
427
  // string, not an object as serializeLaunchParamsQuery requires.
428
- ie({ ...e, vbWebAppData: void 0 }) + (e.vbWebAppData ? `&vbWebAppData=${encodeURIComponent(e.vbWebAppData.toString())}` : "")
428
+ pe({ ...e, vbWebAppData: void 0 }) + (e.vbWebAppData ? `&vbWebAppData=${encodeURIComponent(e.vbWebAppData.toString())}` : "")
429
429
  );
430
430
  try {
431
- pe(o);
431
+ ce(o);
432
432
  } catch (s) {
433
- throw new ue(o, s);
433
+ throw new fe(o, s);
434
434
  }
435
435
  R("launchParams", o);
436
436
  }
@@ -444,7 +444,7 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
444
444
  o(...s);
445
445
  };
446
446
  try {
447
- const p = A(T(U()), i);
447
+ const p = W(T(U()), i);
448
448
  t({ name: p.eventType, params: p.eventData }, _);
449
449
  } catch {
450
450
  _();
@@ -473,12 +473,12 @@ function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
473
473
  // Here we have to trick serializeLaunchParamsQuery into thinking, it serializes a valid
474
474
  // value. We are doing it because we are working with vbWebAppData presented as a
475
475
  // string, not an object as serializeLaunchParamsQuery requires.
476
- ie({ ...e, vbWebAppData: void 0 }) + (e.vbWebAppData ? `&vbWebAppData=${encodeURIComponent(e.vbWebAppData.toString())}` : "")
476
+ pe({ ...e, vbWebAppData: void 0 }) + (e.vbWebAppData ? `&vbWebAppData=${encodeURIComponent(e.vbWebAppData.toString())}` : "")
477
477
  );
478
478
  try {
479
- pe(o);
479
+ ce(o);
480
480
  } catch (s) {
481
- throw new ue(o, s);
481
+ throw new fe(o, s);
482
482
  }
483
483
  R("launchParams", o);
484
484
  }
@@ -492,7 +492,7 @@ function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
492
492
  o(...s);
493
493
  };
494
494
  try {
495
- const p = A(T(U()), i);
495
+ const p = W(T(U()), i);
496
496
  t({ name: p.eventType, params: p.eventData }, _);
497
497
  } catch {
498
498
  _();
@@ -523,7 +523,7 @@ function ft(e, t = "*") {
523
523
  n.emit(i, _);
524
524
  } catch {
525
525
  }
526
- }, n = le(
526
+ }, n = I(
527
527
  () => {
528
528
  window.addEventListener("message", r);
529
529
  },
@@ -541,21 +541,51 @@ function ft(e, t = "*") {
541
541
  },
542
542
  // We need to override clear to also remove the window listener
543
543
  clear: () => {
544
- n.clear(), x === a && (x = void 0);
544
+ n.clear(), g === a && (g = void 0);
545
545
  }
546
546
  };
547
- return x = a, a;
547
+ return g = a, a;
548
548
  }
549
- let x;
550
549
  function lt() {
551
- if (!x)
552
- throw new Error("HostBridge not initialized. Call defineHostBridge() first.");
553
- return x;
550
+ const e = I(
551
+ () => {
552
+ },
553
+ () => {
554
+ }
555
+ ), t = {
556
+ ...e,
557
+ send: (r, n) => {
558
+ const a = JSON.stringify({ eventType: r, eventData: n });
559
+ window.postMessage(a, window.location.origin || "*");
560
+ },
561
+ clear: () => {
562
+ var r;
563
+ e.clear(), g === t && (g = void 0), (r = window.VBotWebviewProxy) != null && r.__isWebComponentProxy && delete window.VBotWebviewProxy;
564
+ }
565
+ };
566
+ return window.VBotWebviewProxy = {
567
+ __isWebComponentProxy: !0,
568
+ postEvent(r, n) {
569
+ let a;
570
+ try {
571
+ a = n ? JSON.parse(n) : void 0;
572
+ } catch {
573
+ a = n;
574
+ }
575
+ e.emit(r, a);
576
+ }
577
+ }, g = t, t;
578
+ }
579
+ let g;
580
+ function wt() {
581
+ if (!g)
582
+ throw new Error("HostBridge not initialized. Call defineHostBridge() or defineWebComponentBridge() first.");
583
+ return g;
554
584
  }
555
585
  function $e(e) {
556
586
  return ({ req_id: t }) => t === e;
557
587
  }
558
- const X = {
588
+ const Z = {
559
589
  "6.0": [
560
590
  "iframe_ready",
561
591
  "iframe_will_reload",
@@ -647,14 +677,14 @@ const X = {
647
677
  "web_app_finish_refresh"
648
678
  ]
649
679
  };
650
- function Z(e, t) {
651
- return Object.keys(X).find((n) => X[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
680
+ function ee(e, t) {
681
+ return Object.keys(Z).find((n) => Z[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
652
682
  }
653
- function ee(e) {
683
+ function te(e) {
654
684
  return e.split(".").map(Number);
655
685
  }
656
686
  function ze(e, t) {
657
- const r = ee(e), n = ee(t), a = Math.max(r.length, n.length);
687
+ const r = te(e), n = te(t), a = Math.max(r.length, n.length);
658
688
  for (let o = 0; o < a; o += 1) {
659
689
  const s = r[o] || 0, i = n[o] || 0;
660
690
  if (s !== i)
@@ -662,25 +692,25 @@ function ze(e, t) {
662
692
  }
663
693
  return 0;
664
694
  }
665
- function te(e, t, r) {
666
- const n = r ? Z(
695
+ function re(e, t, r) {
696
+ const n = r ? ee(
667
697
  e,
668
698
  t
669
- ) : Z(e);
699
+ ) : ee(e);
670
700
  return n ? ze(n, r || t) <= 0 : !1;
671
701
  }
672
- function wt(e, t = "strict") {
702
+ function dt(e, t = "strict") {
673
703
  const r = typeof t == "function" ? t : (n) => {
674
- const { method: a, version: o } = n, s = "param" in n ? new We(a, n.param, o) : new Be(a, o);
704
+ const { method: a, version: o } = n, s = "param" in n ? new Ce(a, n.param, o) : new Be(a, o);
675
705
  if (t === "strict")
676
706
  throw s;
677
707
  return h().forceWarn(s.message);
678
708
  };
679
- return ((n, a) => te(n, e) ? n === "web_app_set_header_color" && O(w({ color: ye() }), a) && !te(n, "color", e) ? r({ version: e, method: n, param: "color" }) : je(n, a) : r({ version: e, method: n }));
709
+ return ((n, a) => re(n, e) ? n === "web_app_set_header_color" && O(w({ color: ye() }), a) && !re(n, "color", e) ? r({ version: e, method: n, param: "color" }) : je(n, a) : r({ version: e, method: n }));
680
710
  }
681
- function De(e, t, r, n) {
711
+ function Je(e, t, r, n) {
682
712
  return l.pipe(
683
- z("web_app_invoke_custom_method", "custom_method_invoked", {
713
+ J("web_app_invoke_custom_method", "custom_method_invoked", {
684
714
  ...n || {},
685
715
  params: { method: e, params: t, req_id: r },
686
716
  capture: $e(r)
@@ -688,10 +718,10 @@ function De(e, t, r, n) {
688
718
  d.chain(({ result: a, error: o }) => o ? d.left(new Ve(o)) : d.right(a))
689
719
  );
690
720
  }
691
- function dt(e, t, r, n) {
692
- return ae.fn(() => l.pipe(
721
+ function mt(e, t, r, n) {
722
+ return se.fn(() => l.pipe(
693
723
  // @ts-expect-error TypeScript is unable to determine required override.
694
- De(e, t, r, n),
724
+ Je(e, t, r, n),
695
725
  d.match(
696
726
  (a) => {
697
727
  throw a;
@@ -700,15 +730,15 @@ function dt(e, t, r, n) {
700
730
  )
701
731
  )());
702
732
  }
703
- function Ge(e, t, r = {}) {
733
+ function De(e, t, r = {}) {
704
734
  const {
705
735
  // If no capture function was passed, we capture the first compatible event.
706
736
  capture: n = () => !0,
707
737
  postEvent: a = k
708
- } = r, o = g(), [s, i] = ne();
738
+ } = r, o = y(), [s, i] = oe();
709
739
  (Array.isArray(t) ? t : [t]).forEach((p) => {
710
740
  s(
711
- $(p, (u) => {
741
+ z(p, (u) => {
712
742
  (Array.isArray(t) ? n({ event: p, payload: u }) : n(u)) && o.set([u]);
713
743
  })
714
744
  );
@@ -716,25 +746,25 @@ function Ge(e, t, r = {}) {
716
746
  const _ = (p) => (i(), p);
717
747
  return l.pipe(
718
748
  async () => a(e, r.params),
719
- d.chainW(() => oe((p, u, f) => {
749
+ d.chainW(() => ae((p, u, f) => {
720
750
  const m = o();
721
751
  if (m)
722
752
  return p(m[0]);
723
- const y = (v) => {
724
- v && p(v[0]);
753
+ const v = (E) => {
754
+ E && p(E[0]);
725
755
  }, L = () => {
726
- o.unsub(y);
756
+ o.unsub(v);
727
757
  };
728
- o.sub(y), f.on("finalized", L);
758
+ o.sub(v), f.on("finalized", L);
729
759
  }, r)),
730
760
  d.mapBoth(_, _)
731
761
  );
732
762
  }
733
- function mt(e, t, r) {
763
+ function bt(e, t, r) {
734
764
  const { postEvent: n } = r || {};
735
- return C(
765
+ return A(
736
766
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
737
- Ge(e, t, {
767
+ De(e, t, {
738
768
  ...r,
739
769
  postEvent: n ? (...a) => {
740
770
  try {
@@ -746,7 +776,7 @@ function mt(e, t, r) {
746
776
  })
747
777
  );
748
778
  }
749
- function bt() {
779
+ function gt() {
750
780
  Object.hasOwn || (Object.hasOwn = function(e, t) {
751
781
  return Object.prototype.hasOwnProperty.call(e, t);
752
782
  });
@@ -758,82 +788,83 @@ function be(e) {
758
788
  ).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
759
789
  ), (t) => t);
760
790
  }
761
- const ht = W(be);
762
- function he(e) {
791
+ const ht = C(be);
792
+ function ge(e) {
763
793
  return btoa(
764
794
  encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
765
795
  ).replace(/\+/g, "-").replace(/\//g, "_");
766
796
  }
767
- function Je(e) {
768
- const t = he(typeof e == "string" ? e : JSON.stringify(e));
797
+ function Ge(e) {
798
+ const t = ge(typeof e == "string" ? e : JSON.stringify(e));
769
799
  return t.length > 512 ? c.left(new Error("Value is too long for start parameter")) : c.right(t);
770
800
  }
771
- const gt = W(Je);
772
- function yt(e, t) {
773
- return C(
774
- He(
801
+ const yt = C(Ge);
802
+ function vt(e, t) {
803
+ return A(
804
+ Ne(
775
805
  e,
776
806
  // @ts-expect-error TypeScript is unable to detect a correct override.
777
807
  typeof t == "function" ? (r) => c.tryCatch(() => t(r), (n) => n) : t
778
808
  )
779
809
  );
780
810
  }
781
- function He(e, t) {
811
+ function Ne(e, t) {
782
812
  return l.pipe(
783
813
  be(e),
784
814
  c.chain((r) => t ? typeof t == "function" ? t(r) : xe.parse(r) : c.right(r))
785
815
  );
786
816
  }
787
- function vt(e) {
788
- return he(e).length <= 512;
817
+ function Et(e) {
818
+ return ge(e).length <= 512;
789
819
  }
790
820
  export {
791
- At as CancelledError,
792
- ue as InvalidLaunchParamsError,
821
+ Bt as CancelledError,
822
+ fe as InvalidLaunchParamsError,
793
823
  Ve as InvokeCustomMethodFailedError,
794
- Ce as LaunchParamsRetrieveError,
795
- We as MethodParameterUnsupportedError,
824
+ Ae as LaunchParamsRetrieveError,
825
+ Ce as MethodParameterUnsupportedError,
796
826
  Be as MethodUnsupportedError,
797
- Bt as TimeoutError,
798
- fe as UnknownEnvError,
799
- bt as applyPolyfills,
827
+ Ct as TimeoutError,
828
+ le as UnknownEnvError,
829
+ gt as applyPolyfills,
800
830
  $e as captureSameReq,
801
831
  ze as compareVersions,
802
- xt as createLogger,
803
- wt as createPostEvent,
804
- gt as createStartParam,
805
- Je as createStartParamFp,
832
+ St as createLogger,
833
+ dt as createPostEvent,
834
+ yt as createStartParam,
835
+ Ge as createStartParamFp,
806
836
  we as debug,
807
837
  ht as decodeBase64Url,
808
838
  be as decodeBase64UrlFp,
809
- yt as decodeStartParam,
810
- He as decodeStartParamFp,
811
- St as deepSnakeToCamelObjKeys,
839
+ vt as decodeStartParam,
840
+ Ne as decodeStartParamFp,
841
+ kt as deepSnakeToCamelObjKeys,
812
842
  ft as defineHostBridge,
843
+ lt as defineWebComponentBridge,
813
844
  M as emitEvent,
814
- he as encodeBase64Url,
815
- lt as getHostBridge,
816
- Z as getReleaseVersion,
817
- _e as hasWebviewProxy,
818
- dt as invokeCustomMethod,
819
- De as invokeCustomMethodFp,
845
+ ge as encodeBase64Url,
846
+ wt as getHostBridge,
847
+ ee as getReleaseVersion,
848
+ ue as hasWebviewProxy,
849
+ mt as invokeCustomMethod,
850
+ Je as invokeCustomMethodFp,
820
851
  j as isIframe,
821
- vt as isSafeToCreateStartParam,
852
+ Et as isSafeToCreateStartParam,
822
853
  ct as isVBma,
823
854
  Ie as isVBmaFp,
824
855
  h as logger,
825
856
  _t as mockVBotEnv,
826
857
  Oe as off,
827
858
  Te as offAll,
828
- $ as on,
859
+ z as on,
829
860
  je as postEvent,
830
861
  k as postEventFp,
831
862
  Ue as postMessage,
832
863
  b as postMessageImpl,
833
- mt as request,
864
+ bt as request,
834
865
  pt as request2,
835
- z as request2Fp,
836
- Ge as requestFp,
866
+ J as request2Fp,
867
+ De as requestFp,
837
868
  it as resetGlobals,
838
869
  rt as retrieveLaunchParams,
839
870
  Le as retrieveLaunchParamsFp,
@@ -844,7 +875,7 @@ export {
844
875
  at as setDebug,
845
876
  ut as setLaunchParams,
846
877
  st as setTargetOrigin,
847
- te as supports,
878
+ re as supports,
848
879
  de as targetOrigin
849
880
  };
850
881
  //# sourceMappingURL=index.js.map