@vbotma/bridge 2.3.0 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/dts/env/mockVBotEnv.d.ts +2 -2
- package/dist/dts/env/setLaunchParams.d.ts +2 -2
- package/dist/dts/events/emitEvent.d.ts +3 -3
- package/dist/dts/events/types/events.d.ts +2 -2
- package/dist/dts/globals.d.ts +3 -3
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/methods/postMessage.d.ts +1 -1
- package/dist/dts/methods/types/methods.d.ts +14 -18
- 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 +185 -186
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { is as O, looseObject as
|
|
2
|
-
import { throwifyFpFn as
|
|
3
|
-
import { createLogger as
|
|
1
|
+
import { is as O, looseObject as d, function as ne, nullish as P, boolean as G, number as T, string as x, optional as H, unknown as ge, parse as V, 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 Bt, deepSnakeToCamelObjKeys as St } from "@vbotma/toolkit";
|
|
4
4
|
import { BetterPromise as se, TimeoutError as Pe } from "better-promises";
|
|
5
|
-
import { CancelledError as
|
|
6
|
-
import { function as
|
|
7
|
-
import { errorClassWithData as
|
|
8
|
-
import { parseLaunchParamsQueryFp as ie, themeParams as
|
|
5
|
+
import { CancelledError as Vt, TimeoutError as Wt } from "better-promises";
|
|
6
|
+
import { function as w, either as c, option as F, taskEither as l, json as xe } from "fp-ts";
|
|
7
|
+
import { errorClassWithData as Be, errorClass as B } from "error-kid";
|
|
8
|
+
import { parseLaunchParamsQueryFp as ie, themeParams as Se, pipeJsonToSchema as U, miniAppsMessage as I, serializeLaunchParamsQuery as pe, parseLaunchParamsQuery as ce } from "@vbotma/transformers";
|
|
9
9
|
import { signal as y, computed as _e } from "@vbotma/signals";
|
|
10
|
-
import
|
|
10
|
+
import ke from "mitt";
|
|
11
11
|
function ue(e) {
|
|
12
12
|
return O(
|
|
13
|
-
|
|
13
|
+
d({ VBotWebviewProxy: d({ postEvent: ne() }) }),
|
|
14
14
|
e
|
|
15
15
|
);
|
|
16
16
|
}
|
|
@@ -21,18 +21,18 @@ function j() {
|
|
|
21
21
|
return !0;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
class
|
|
24
|
+
class Ve extends (/* @__PURE__ */ B(
|
|
25
25
|
"MethodUnsupportedError",
|
|
26
26
|
(t, r) => [
|
|
27
27
|
`Method "${t}" is unsupported in Mini Apps version ${r}`
|
|
28
28
|
]
|
|
29
29
|
)) {
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class We extends (/* @__PURE__ */ B("MethodParameterUnsupportedError", (t, r, n) => [
|
|
32
32
|
`Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
|
|
33
33
|
])) {
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class Ce extends (/* @__PURE__ */ Be(
|
|
36
36
|
"LaunchParamsRetrieveError",
|
|
37
37
|
(t) => ({ errors: t }),
|
|
38
38
|
(t) => [
|
|
@@ -46,7 +46,7 @@ class Ae extends (/* @__PURE__ */ Se(
|
|
|
46
46
|
]
|
|
47
47
|
)) {
|
|
48
48
|
}
|
|
49
|
-
class fe extends (/* @__PURE__ */
|
|
49
|
+
class fe extends (/* @__PURE__ */ B(
|
|
50
50
|
"InvalidLaunchParamsError",
|
|
51
51
|
(t, r) => [
|
|
52
52
|
`Invalid value for launch params: ${t}`,
|
|
@@ -54,9 +54,9 @@ class fe extends (/* @__PURE__ */ S(
|
|
|
54
54
|
]
|
|
55
55
|
)) {
|
|
56
56
|
}
|
|
57
|
-
class
|
|
57
|
+
class we extends (/* @__PURE__ */ B("UnknownEnvError")) {
|
|
58
58
|
}
|
|
59
|
-
class
|
|
59
|
+
class Ae extends (/* @__PURE__ */ B(
|
|
60
60
|
"InvokeCustomMethodError",
|
|
61
61
|
(t) => [`Server returned error: ${t}`]
|
|
62
62
|
)) {
|
|
@@ -66,14 +66,14 @@ function Q(e) {
|
|
|
66
66
|
return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
|
|
67
67
|
}
|
|
68
68
|
function Le() {
|
|
69
|
-
return
|
|
69
|
+
return w.pipe(
|
|
70
70
|
L(),
|
|
71
71
|
c.chainW(ie)
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
|
-
const rt =
|
|
74
|
+
const rt = C(Le);
|
|
75
75
|
function Me() {
|
|
76
|
-
return
|
|
76
|
+
return w.pipe(
|
|
77
77
|
L(),
|
|
78
78
|
c.map((e) => {
|
|
79
79
|
const t = new URLSearchParams(e).get("vbWebAppData");
|
|
@@ -82,7 +82,7 @@ function Me() {
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
function nt() {
|
|
85
|
-
return
|
|
85
|
+
return w.pipe(
|
|
86
86
|
Me(),
|
|
87
87
|
c.fold((e) => {
|
|
88
88
|
throw e;
|
|
@@ -111,7 +111,7 @@ function L() {
|
|
|
111
111
|
e.push({ source: r, error: new Error("Source is empty") });
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
|
-
const a =
|
|
114
|
+
const a = w.pipe(
|
|
115
115
|
ie(n),
|
|
116
116
|
c.foldW((o) => o, () => !0)
|
|
117
117
|
);
|
|
@@ -121,11 +121,11 @@ function L() {
|
|
|
121
121
|
}
|
|
122
122
|
return R(N, n), c.right(n);
|
|
123
123
|
}
|
|
124
|
-
return c.left(new
|
|
124
|
+
return c.left(new Ce(e));
|
|
125
125
|
}
|
|
126
|
-
const ot =
|
|
127
|
-
function
|
|
128
|
-
const r = /* @__PURE__ */ new Map(), n =
|
|
126
|
+
const ot = C(L);
|
|
127
|
+
function $(e, t) {
|
|
128
|
+
const r = /* @__PURE__ */ new Map(), n = ke(), 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) || [];
|
|
@@ -141,8 +141,8 @@ function I(e, t) {
|
|
|
141
141
|
!r.size && e();
|
|
142
142
|
const _ = () => {
|
|
143
143
|
a(o, s, i);
|
|
144
|
-
}, p = (...
|
|
145
|
-
i && _(), o === "*" ? s({ name:
|
|
144
|
+
}, p = (...b) => {
|
|
145
|
+
i && _(), o === "*" ? s({ name: b[0], payload: b[1] }) : s(...b);
|
|
146
146
|
};
|
|
147
147
|
n.on(o, p);
|
|
148
148
|
const u = r.get(o) || /* @__PURE__ */ new Map();
|
|
@@ -159,7 +159,7 @@ function I(e, t) {
|
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function k(e, t) {
|
|
163
163
|
window.dispatchEvent(new MessageEvent("message", {
|
|
164
164
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
165
165
|
// We specify this kind of source here in order to allow the package's "on" function to
|
|
@@ -168,25 +168,25 @@ function W(e, t) {
|
|
|
168
168
|
source: window.parent
|
|
169
169
|
}));
|
|
170
170
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
},
|
|
171
|
+
const W = y(!1), z = y("https://web.vbot.org"), qe = (e) => {
|
|
172
|
+
g().log("Event received:", e);
|
|
173
|
+
}, de = _e(W);
|
|
174
174
|
function at(e) {
|
|
175
|
-
e !==
|
|
175
|
+
e !== W() && (W.set(e), (e ? D : Oe)("*", qe));
|
|
176
176
|
}
|
|
177
|
-
const
|
|
177
|
+
const le = _e(z);
|
|
178
178
|
function st(e) {
|
|
179
|
-
|
|
179
|
+
z.set(e), g().log("New target origin set", e);
|
|
180
180
|
}
|
|
181
|
-
const
|
|
181
|
+
const m = y((...e) => {
|
|
182
182
|
window.parent.postMessage(...e);
|
|
183
|
-
}),
|
|
183
|
+
}), g = y(Ee("Bridge", {
|
|
184
184
|
bgColor: "#9147ff",
|
|
185
185
|
textColor: "white",
|
|
186
|
-
shouldLog:
|
|
186
|
+
shouldLog: de
|
|
187
187
|
}));
|
|
188
188
|
function it() {
|
|
189
|
-
|
|
189
|
+
Ue(), [m, z, le, W, de, g].forEach((e) => {
|
|
190
190
|
e.unsubAll(), "reset" in e && e.reset();
|
|
191
191
|
});
|
|
192
192
|
}
|
|
@@ -212,7 +212,7 @@ function q(e, t, r) {
|
|
|
212
212
|
n.unshift(1), Y(e, t, o);
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
|
-
|
|
215
|
+
be(
|
|
216
216
|
e,
|
|
217
217
|
t,
|
|
218
218
|
() => s,
|
|
@@ -221,13 +221,13 @@ function q(e, t, r) {
|
|
|
221
221
|
}
|
|
222
222
|
function K(e, t) {
|
|
223
223
|
const r = e[t];
|
|
224
|
-
|
|
224
|
+
be(e, t, () => r, (n) => {
|
|
225
225
|
Object.entries(n).forEach(([a, o]) => {
|
|
226
226
|
r[a] = o;
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function be(e, t, r, n) {
|
|
231
231
|
Object.defineProperty(e, t, {
|
|
232
232
|
enumerable: !0,
|
|
233
233
|
configurable: !0,
|
|
@@ -244,26 +244,26 @@ function Y(e, t, r) {
|
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
const Fe = {
|
|
247
|
-
clipboard_text_received:
|
|
247
|
+
clipboard_text_received: d({
|
|
248
248
|
req_id: x(),
|
|
249
249
|
data: P(x())
|
|
250
250
|
}),
|
|
251
|
-
custom_method_invoked:
|
|
251
|
+
custom_method_invoked: d({
|
|
252
252
|
req_id: x(),
|
|
253
|
-
result: H(
|
|
253
|
+
result: H(ge()),
|
|
254
254
|
error: H(x())
|
|
255
255
|
}),
|
|
256
256
|
popup_closed: P(
|
|
257
|
-
|
|
257
|
+
d({ button_id: P(x(), () => {
|
|
258
258
|
}) }),
|
|
259
259
|
{}
|
|
260
260
|
),
|
|
261
261
|
viewport_changed: P(
|
|
262
|
-
|
|
263
|
-
height:
|
|
264
|
-
width: P(
|
|
265
|
-
is_state_stable:
|
|
266
|
-
is_expanded:
|
|
262
|
+
d({
|
|
263
|
+
height: T(),
|
|
264
|
+
width: P(T(), () => window.innerWidth),
|
|
265
|
+
is_state_stable: G(),
|
|
266
|
+
is_expanded: G()
|
|
267
267
|
}),
|
|
268
268
|
// TODO: At the moment, macOS has a bug with the invalid event payload - it is always equal to
|
|
269
269
|
// null. Leaving this default value until the bug is fixed.
|
|
@@ -273,8 +273,8 @@ const Fe = {
|
|
|
273
273
|
is_expanded: !0
|
|
274
274
|
})
|
|
275
275
|
),
|
|
276
|
-
theme_changed:
|
|
277
|
-
theme_params:
|
|
276
|
+
theme_changed: d({
|
|
277
|
+
theme_params: Se()
|
|
278
278
|
})
|
|
279
279
|
};
|
|
280
280
|
function X(e) {
|
|
@@ -282,20 +282,19 @@ function X(e) {
|
|
|
282
282
|
return;
|
|
283
283
|
let t;
|
|
284
284
|
try {
|
|
285
|
-
t =
|
|
285
|
+
t = V(U(I()), 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 ?
|
|
292
|
+
o = a ? V(a, n) : n;
|
|
293
293
|
} catch (s) {
|
|
294
|
-
return
|
|
294
|
+
return g().forceError(
|
|
295
295
|
[
|
|
296
296
|
`An error occurred processing the "${r}" event from the VBot application.`,
|
|
297
|
-
"Please, file an issue here:"
|
|
298
|
-
"https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"
|
|
297
|
+
"Please, file an issue here:"
|
|
299
298
|
].join(`
|
|
300
299
|
`),
|
|
301
300
|
t,
|
|
@@ -305,19 +304,19 @@ function X(e) {
|
|
|
305
304
|
Re(r, o);
|
|
306
305
|
}
|
|
307
306
|
const {
|
|
308
|
-
on:
|
|
307
|
+
on: D,
|
|
309
308
|
off: Oe,
|
|
310
309
|
emit: Re,
|
|
311
|
-
clear:
|
|
312
|
-
} =
|
|
310
|
+
clear: Ue
|
|
311
|
+
} = $(
|
|
313
312
|
() => {
|
|
314
313
|
const e = window;
|
|
315
|
-
!e.
|
|
314
|
+
!e.VBotGameProxy && (e.VBotGameProxy = {}), q(e.VBotGameProxy, "receiveEvent", k), K(e, "VBotGameProxy"), !e.VBot && (e.VBot = {}), !e.VBot.WebView && (e.VBot.WebView = {}), q(e.VBot.WebView, "receiveEvent", k), K(e.VBot, "WebView"), q(e, "VBotGameProxy_receiveEvent", k), window.addEventListener("message", X);
|
|
316
315
|
},
|
|
317
316
|
() => {
|
|
318
317
|
[
|
|
319
|
-
["
|
|
320
|
-
["
|
|
318
|
+
["VBotGameProxy_receiveEvent"],
|
|
319
|
+
["VBotGameProxy", "receiveEvent"],
|
|
321
320
|
["VBot", "WebView", "receiveEvent"]
|
|
322
321
|
].forEach((e) => {
|
|
323
322
|
const t = window;
|
|
@@ -329,10 +328,10 @@ const {
|
|
|
329
328
|
"unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
|
|
330
329
|
}), window.removeEventListener("message", X);
|
|
331
330
|
}
|
|
332
|
-
),
|
|
331
|
+
), Ie = (...e) => m()(...e);
|
|
333
332
|
function je(e, t) {
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
w.pipe(
|
|
334
|
+
S(
|
|
336
335
|
// @ts-expect-error It's ok, TS can't determine a specific override.
|
|
337
336
|
e,
|
|
338
337
|
t
|
|
@@ -342,20 +341,20 @@ function je(e, t) {
|
|
|
342
341
|
})
|
|
343
342
|
);
|
|
344
343
|
}
|
|
345
|
-
function
|
|
346
|
-
|
|
344
|
+
function S(e, t) {
|
|
345
|
+
g().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
|
|
347
346
|
const r = window, n = JSON.stringify({ eventType: e, eventData: t });
|
|
348
|
-
return j() ? (
|
|
347
|
+
return j() ? (Ie(n, le()), c.right(void 0)) : ue(r) ? (r.VBotWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : O(d({ external: d({ notify: ne() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new we());
|
|
349
348
|
}
|
|
350
|
-
function
|
|
349
|
+
function J(e, t, r = {}) {
|
|
351
350
|
const {
|
|
352
351
|
// If no capture function was passed, we capture the first compatible event.
|
|
353
352
|
capture: n = () => !0,
|
|
354
|
-
postEvent: a =
|
|
353
|
+
postEvent: a = S
|
|
355
354
|
} = r, o = y(), [s, i] = oe();
|
|
356
355
|
(Array.isArray(t) ? t : [t]).forEach((p) => {
|
|
357
356
|
s(
|
|
358
|
-
|
|
357
|
+
D(p, (u) => {
|
|
359
358
|
const f = Array.isArray(t);
|
|
360
359
|
n(f ? { event: p, payload: u } : u) && o.set([
|
|
361
360
|
f ? { event: p, payload: u } : u
|
|
@@ -364,12 +363,12 @@ function D(e, t, r = {}) {
|
|
|
364
363
|
);
|
|
365
364
|
});
|
|
366
365
|
const _ = (p) => (i(), p);
|
|
367
|
-
return
|
|
366
|
+
return w.pipe(
|
|
368
367
|
async () => a(e, r.params),
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
if (
|
|
372
|
-
return p(
|
|
368
|
+
l.chainW(() => ae((p, u, f) => {
|
|
369
|
+
const b = o();
|
|
370
|
+
if (b)
|
|
371
|
+
return p(b[0]);
|
|
373
372
|
const v = (E) => {
|
|
374
373
|
E && p(E[0]);
|
|
375
374
|
}, M = () => {
|
|
@@ -377,14 +376,14 @@ function D(e, t, r = {}) {
|
|
|
377
376
|
};
|
|
378
377
|
o.sub(v), f.on("finalized", M);
|
|
379
378
|
}, r)),
|
|
380
|
-
|
|
379
|
+
l.mapBoth(_, _)
|
|
381
380
|
);
|
|
382
381
|
}
|
|
383
382
|
function pt(e, t, r) {
|
|
384
383
|
const { postEvent: n } = r || {};
|
|
385
|
-
return
|
|
384
|
+
return A(
|
|
386
385
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
387
|
-
|
|
386
|
+
J(e, t, {
|
|
388
387
|
...r,
|
|
389
388
|
postEvent: n ? (...a) => {
|
|
390
389
|
try {
|
|
@@ -392,29 +391,29 @@ function pt(e, t, r) {
|
|
|
392
391
|
} catch (o) {
|
|
393
392
|
return c.left(o);
|
|
394
393
|
}
|
|
395
|
-
} :
|
|
394
|
+
} : S
|
|
396
395
|
})
|
|
397
396
|
);
|
|
398
397
|
}
|
|
399
398
|
function ct(e, t) {
|
|
400
|
-
const r =
|
|
399
|
+
const r = $e(
|
|
401
400
|
// @ts-expect-error TS doesn't get what override we are going to use.
|
|
402
401
|
e,
|
|
403
402
|
t
|
|
404
403
|
);
|
|
405
|
-
return typeof r == "function" ? se.fn(() =>
|
|
404
|
+
return typeof r == "function" ? se.fn(() => A(r)) : r;
|
|
406
405
|
}
|
|
407
|
-
function
|
|
406
|
+
function $e(e, t) {
|
|
408
407
|
const r = ue(window);
|
|
409
408
|
if (!e)
|
|
410
|
-
return r ||
|
|
409
|
+
return r || w.pipe(L(), c.match(() => !1, () => !0));
|
|
411
410
|
if (r)
|
|
412
|
-
return
|
|
411
|
+
return l.right(!0);
|
|
413
412
|
const { timeout: n = 100 } = t || {};
|
|
414
|
-
return
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
(a) => Pe.is(a) ||
|
|
413
|
+
return w.pipe(
|
|
414
|
+
J("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
|
|
415
|
+
l.match(
|
|
416
|
+
(a) => Pe.is(a) || we.is(a) ? c.right(!1) : c.left(a),
|
|
418
417
|
() => c.right(!0)
|
|
419
418
|
)
|
|
420
419
|
);
|
|
@@ -437,14 +436,14 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
437
436
|
if (j()) {
|
|
438
437
|
if (!t)
|
|
439
438
|
return;
|
|
440
|
-
r &&
|
|
441
|
-
const o =
|
|
442
|
-
|
|
439
|
+
r && m.reset();
|
|
440
|
+
const o = m();
|
|
441
|
+
m.set((...s) => {
|
|
443
442
|
const [i] = s, _ = () => {
|
|
444
443
|
o(...s);
|
|
445
444
|
};
|
|
446
445
|
try {
|
|
447
|
-
const p =
|
|
446
|
+
const p = V(U(I()), i);
|
|
448
447
|
t({ name: p.eventType, params: p.eventData }, _);
|
|
449
448
|
} catch {
|
|
450
449
|
_();
|
|
@@ -465,7 +464,7 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
465
464
|
params: s ? JSON.parse(s) : void 0
|
|
466
465
|
}, i) : i();
|
|
467
466
|
}
|
|
468
|
-
},
|
|
467
|
+
}, g().log("Environment was mocked by the mockVBotEnv function");
|
|
469
468
|
}
|
|
470
469
|
function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
471
470
|
if (e) {
|
|
@@ -485,14 +484,14 @@ function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
485
484
|
if (j()) {
|
|
486
485
|
if (!t)
|
|
487
486
|
return;
|
|
488
|
-
r &&
|
|
489
|
-
const o =
|
|
490
|
-
|
|
487
|
+
r && m.reset();
|
|
488
|
+
const o = m();
|
|
489
|
+
m.set((...s) => {
|
|
491
490
|
const [i] = s, _ = () => {
|
|
492
491
|
o(...s);
|
|
493
492
|
};
|
|
494
493
|
try {
|
|
495
|
-
const p =
|
|
494
|
+
const p = V(U(I()), i);
|
|
496
495
|
t({ name: p.eventType, params: p.eventData }, _);
|
|
497
496
|
} catch {
|
|
498
497
|
_();
|
|
@@ -513,7 +512,7 @@ function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
513
512
|
params: s ? JSON.parse(s) : void 0
|
|
514
513
|
}, i) : i();
|
|
515
514
|
}
|
|
516
|
-
},
|
|
515
|
+
}, g().log("Launch params are injected by the setLaunchParams function");
|
|
517
516
|
}
|
|
518
517
|
function ft(e, t = "*") {
|
|
519
518
|
const r = (o) => {
|
|
@@ -523,7 +522,7 @@ function ft(e, t = "*") {
|
|
|
523
522
|
n.emit(i, _);
|
|
524
523
|
} catch {
|
|
525
524
|
}
|
|
526
|
-
}, n =
|
|
525
|
+
}, n = $(
|
|
527
526
|
() => {
|
|
528
527
|
window.addEventListener("message", r);
|
|
529
528
|
},
|
|
@@ -541,13 +540,13 @@ function ft(e, t = "*") {
|
|
|
541
540
|
},
|
|
542
541
|
// We need to override clear to also remove the window listener
|
|
543
542
|
clear: () => {
|
|
544
|
-
n.clear(),
|
|
543
|
+
n.clear(), h === a && (h = void 0);
|
|
545
544
|
}
|
|
546
545
|
};
|
|
547
|
-
return
|
|
546
|
+
return h = a, a;
|
|
548
547
|
}
|
|
549
|
-
function
|
|
550
|
-
const e =
|
|
548
|
+
function wt() {
|
|
549
|
+
const e = $(
|
|
551
550
|
() => {
|
|
552
551
|
},
|
|
553
552
|
() => {
|
|
@@ -555,11 +554,11 @@ function lt() {
|
|
|
555
554
|
), t = {
|
|
556
555
|
...e,
|
|
557
556
|
send: (r, n) => {
|
|
558
|
-
|
|
557
|
+
k(r, n);
|
|
559
558
|
},
|
|
560
559
|
clear: () => {
|
|
561
560
|
var r;
|
|
562
|
-
e.clear(),
|
|
561
|
+
e.clear(), h === t && (h = void 0), (r = window.VBotWebviewProxy) != null && r.__isWebComponentProxy && delete window.VBotWebviewProxy;
|
|
563
562
|
}
|
|
564
563
|
};
|
|
565
564
|
return window.VBotWebviewProxy = {
|
|
@@ -573,15 +572,15 @@ function lt() {
|
|
|
573
572
|
}
|
|
574
573
|
e.emit(r, a);
|
|
575
574
|
}
|
|
576
|
-
},
|
|
575
|
+
}, h = t, t;
|
|
577
576
|
}
|
|
578
|
-
let
|
|
579
|
-
function
|
|
580
|
-
if (!
|
|
577
|
+
let h;
|
|
578
|
+
function dt() {
|
|
579
|
+
if (!h)
|
|
581
580
|
throw new Error("HostBridge not initialized. Call defineHostBridge() or defineWebComponentBridge() first.");
|
|
582
|
-
return
|
|
581
|
+
return h;
|
|
583
582
|
}
|
|
584
|
-
function
|
|
583
|
+
function ze(e) {
|
|
585
584
|
return ({ req_id: t }) => t === e;
|
|
586
585
|
}
|
|
587
586
|
const Z = {
|
|
@@ -599,7 +598,7 @@ const Z = {
|
|
|
599
598
|
"web_app_setup_closing_behavior"
|
|
600
599
|
],
|
|
601
600
|
6.1: [
|
|
602
|
-
"
|
|
601
|
+
"web_app_open_vb_link",
|
|
603
602
|
"web_app_open_invoice",
|
|
604
603
|
"web_app_setup_back_button",
|
|
605
604
|
"web_app_set_background_color",
|
|
@@ -682,7 +681,7 @@ function ee(e, t) {
|
|
|
682
681
|
function te(e) {
|
|
683
682
|
return e.split(".").map(Number);
|
|
684
683
|
}
|
|
685
|
-
function
|
|
684
|
+
function De(e, t) {
|
|
686
685
|
const r = te(e), n = te(t), a = Math.max(r.length, n.length);
|
|
687
686
|
for (let o = 0; o < a; o += 1) {
|
|
688
687
|
const s = r[o] || 0, i = n[o] || 0;
|
|
@@ -696,32 +695,32 @@ function re(e, t, r) {
|
|
|
696
695
|
e,
|
|
697
696
|
t
|
|
698
697
|
) : ee(e);
|
|
699
|
-
return n ?
|
|
698
|
+
return n ? De(n, r || t) <= 0 : !1;
|
|
700
699
|
}
|
|
701
|
-
function
|
|
700
|
+
function lt(e, t = "strict") {
|
|
702
701
|
const r = typeof t == "function" ? t : (n) => {
|
|
703
|
-
const { method: a, version: o } = n, s = "param" in n ? new
|
|
702
|
+
const { method: a, version: o } = n, s = "param" in n ? new We(a, n.param, o) : new Ve(a, o);
|
|
704
703
|
if (t === "strict")
|
|
705
704
|
throw s;
|
|
706
|
-
return
|
|
705
|
+
return g().forceWarn(s.message);
|
|
707
706
|
};
|
|
708
|
-
return ((n, a) => re(n, e) ? n === "web_app_set_header_color" && O(
|
|
707
|
+
return ((n, a) => re(n, e) ? n === "web_app_set_header_color" && O(d({ color: ye() }), a) && !re(n, "color", e) ? r({ version: e, method: n, param: "color" }) : je(n, a) : r({ version: e, method: n }));
|
|
709
708
|
}
|
|
710
|
-
function
|
|
711
|
-
return
|
|
712
|
-
|
|
709
|
+
function Je(e, t, r, n) {
|
|
710
|
+
return w.pipe(
|
|
711
|
+
J("web_app_invoke_custom_method", "custom_method_invoked", {
|
|
713
712
|
...n || {},
|
|
714
713
|
params: { method: e, params: t, req_id: r },
|
|
715
|
-
capture:
|
|
714
|
+
capture: ze(r)
|
|
716
715
|
}),
|
|
717
|
-
|
|
716
|
+
l.chain(({ result: a, error: o }) => o ? l.left(new Ae(o)) : l.right(a))
|
|
718
717
|
);
|
|
719
718
|
}
|
|
720
|
-
function
|
|
721
|
-
return se.fn(() =>
|
|
719
|
+
function bt(e, t, r, n) {
|
|
720
|
+
return se.fn(() => w.pipe(
|
|
722
721
|
// @ts-expect-error TypeScript is unable to determine required override.
|
|
723
|
-
|
|
724
|
-
|
|
722
|
+
Je(e, t, r, n),
|
|
723
|
+
l.match(
|
|
725
724
|
(a) => {
|
|
726
725
|
throw a;
|
|
727
726
|
},
|
|
@@ -729,26 +728,26 @@ function mt(e, t, r, n) {
|
|
|
729
728
|
)
|
|
730
729
|
)());
|
|
731
730
|
}
|
|
732
|
-
function
|
|
731
|
+
function Ge(e, t, r = {}) {
|
|
733
732
|
const {
|
|
734
733
|
// If no capture function was passed, we capture the first compatible event.
|
|
735
734
|
capture: n = () => !0,
|
|
736
|
-
postEvent: a =
|
|
735
|
+
postEvent: a = S
|
|
737
736
|
} = r, o = y(), [s, i] = oe();
|
|
738
737
|
(Array.isArray(t) ? t : [t]).forEach((p) => {
|
|
739
738
|
s(
|
|
740
|
-
|
|
739
|
+
D(p, (u) => {
|
|
741
740
|
(Array.isArray(t) ? n({ event: p, payload: u }) : n(u)) && o.set([u]);
|
|
742
741
|
})
|
|
743
742
|
);
|
|
744
743
|
});
|
|
745
744
|
const _ = (p) => (i(), p);
|
|
746
|
-
return
|
|
745
|
+
return w.pipe(
|
|
747
746
|
async () => a(e, r.params),
|
|
748
|
-
|
|
749
|
-
const
|
|
750
|
-
if (
|
|
751
|
-
return p(
|
|
747
|
+
l.chainW(() => ae((p, u, f) => {
|
|
748
|
+
const b = o();
|
|
749
|
+
if (b)
|
|
750
|
+
return p(b[0]);
|
|
752
751
|
const v = (E) => {
|
|
753
752
|
E && p(E[0]);
|
|
754
753
|
}, M = () => {
|
|
@@ -756,14 +755,14 @@ function Je(e, t, r = {}) {
|
|
|
756
755
|
};
|
|
757
756
|
o.sub(v), f.on("finalized", M);
|
|
758
757
|
}, r)),
|
|
759
|
-
|
|
758
|
+
l.mapBoth(_, _)
|
|
760
759
|
);
|
|
761
760
|
}
|
|
762
|
-
function
|
|
761
|
+
function mt(e, t, r) {
|
|
763
762
|
const { postEvent: n } = r || {};
|
|
764
|
-
return
|
|
763
|
+
return A(
|
|
765
764
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
766
|
-
|
|
765
|
+
Ge(e, t, {
|
|
767
766
|
...r,
|
|
768
767
|
postEvent: n ? (...a) => {
|
|
769
768
|
try {
|
|
@@ -771,35 +770,35 @@ function bt(e, t, r) {
|
|
|
771
770
|
} catch (o) {
|
|
772
771
|
return c.left(o);
|
|
773
772
|
}
|
|
774
|
-
} :
|
|
773
|
+
} : S
|
|
775
774
|
})
|
|
776
775
|
);
|
|
777
776
|
}
|
|
778
|
-
function
|
|
777
|
+
function ht() {
|
|
779
778
|
Object.hasOwn || (Object.hasOwn = function(e, t) {
|
|
780
779
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
781
780
|
});
|
|
782
781
|
}
|
|
783
|
-
function
|
|
782
|
+
function me(e) {
|
|
784
783
|
return c.tryCatch(() => decodeURIComponent(
|
|
785
784
|
atob(
|
|
786
785
|
e.replace(/-/g, "+").replace(/_/g, "/")
|
|
787
786
|
).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
788
787
|
), (t) => t);
|
|
789
788
|
}
|
|
790
|
-
const
|
|
791
|
-
function
|
|
789
|
+
const gt = C(me);
|
|
790
|
+
function he(e) {
|
|
792
791
|
return btoa(
|
|
793
792
|
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
|
|
794
793
|
).replace(/\+/g, "-").replace(/\//g, "_");
|
|
795
794
|
}
|
|
796
|
-
function
|
|
797
|
-
const t =
|
|
795
|
+
function Te(e) {
|
|
796
|
+
const t = he(typeof e == "string" ? e : JSON.stringify(e));
|
|
798
797
|
return t.length > 512 ? c.left(new Error("Value is too long for start parameter")) : c.right(t);
|
|
799
798
|
}
|
|
800
|
-
const yt =
|
|
799
|
+
const yt = C(Te);
|
|
801
800
|
function vt(e, t) {
|
|
802
|
-
return
|
|
801
|
+
return A(
|
|
803
802
|
He(
|
|
804
803
|
e,
|
|
805
804
|
// @ts-expect-error TypeScript is unable to detect a correct override.
|
|
@@ -808,62 +807,62 @@ function vt(e, t) {
|
|
|
808
807
|
);
|
|
809
808
|
}
|
|
810
809
|
function He(e, t) {
|
|
811
|
-
return
|
|
812
|
-
|
|
810
|
+
return w.pipe(
|
|
811
|
+
me(e),
|
|
813
812
|
c.chain((r) => t ? typeof t == "function" ? t(r) : xe.parse(r) : c.right(r))
|
|
814
813
|
);
|
|
815
814
|
}
|
|
816
815
|
function Et(e) {
|
|
817
|
-
return
|
|
816
|
+
return he(e).length <= 512;
|
|
818
817
|
}
|
|
819
818
|
export {
|
|
820
|
-
|
|
819
|
+
Vt as CancelledError,
|
|
821
820
|
fe as InvalidLaunchParamsError,
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
821
|
+
Ae as InvokeCustomMethodFailedError,
|
|
822
|
+
Ce as LaunchParamsRetrieveError,
|
|
823
|
+
We as MethodParameterUnsupportedError,
|
|
824
|
+
Ve as MethodUnsupportedError,
|
|
825
|
+
Wt as TimeoutError,
|
|
826
|
+
we as UnknownEnvError,
|
|
827
|
+
ht as applyPolyfills,
|
|
828
|
+
ze as captureSameReq,
|
|
829
|
+
De as compareVersions,
|
|
830
|
+
Bt as createLogger,
|
|
831
|
+
lt as createPostEvent,
|
|
833
832
|
yt as createStartParam,
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
833
|
+
Te as createStartParamFp,
|
|
834
|
+
de as debug,
|
|
835
|
+
gt as decodeBase64Url,
|
|
836
|
+
me as decodeBase64UrlFp,
|
|
838
837
|
vt as decodeStartParam,
|
|
839
838
|
He as decodeStartParamFp,
|
|
840
|
-
|
|
839
|
+
St as deepSnakeToCamelObjKeys,
|
|
841
840
|
ft as defineHostBridge,
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
841
|
+
wt as defineWebComponentBridge,
|
|
842
|
+
k as emitEvent,
|
|
843
|
+
he as encodeBase64Url,
|
|
844
|
+
dt as getHostBridge,
|
|
846
845
|
ee as getReleaseVersion,
|
|
847
846
|
ue as hasWebviewProxy,
|
|
848
|
-
|
|
849
|
-
|
|
847
|
+
bt as invokeCustomMethod,
|
|
848
|
+
Je as invokeCustomMethodFp,
|
|
850
849
|
j as isIframe,
|
|
851
850
|
Et as isSafeToCreateStartParam,
|
|
852
851
|
ct as isVBma,
|
|
853
|
-
|
|
854
|
-
|
|
852
|
+
$e as isVBmaFp,
|
|
853
|
+
g as logger,
|
|
855
854
|
_t as mockVBotEnv,
|
|
856
855
|
Oe as off,
|
|
857
|
-
|
|
858
|
-
|
|
856
|
+
Ue as offAll,
|
|
857
|
+
D as on,
|
|
859
858
|
je as postEvent,
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
859
|
+
S as postEventFp,
|
|
860
|
+
Ie as postMessage,
|
|
861
|
+
m as postMessageImpl,
|
|
862
|
+
mt as request,
|
|
864
863
|
pt as request2,
|
|
865
|
-
|
|
866
|
-
|
|
864
|
+
J as request2Fp,
|
|
865
|
+
Ge as requestFp,
|
|
867
866
|
it as resetGlobals,
|
|
868
867
|
rt as retrieveLaunchParams,
|
|
869
868
|
Le as retrieveLaunchParamsFp,
|
|
@@ -875,6 +874,6 @@ export {
|
|
|
875
874
|
ut as setLaunchParams,
|
|
876
875
|
st as setTargetOrigin,
|
|
877
876
|
re as supports,
|
|
878
|
-
|
|
877
|
+
le as targetOrigin
|
|
879
878
|
};
|
|
880
879
|
//# sourceMappingURL=index.js.map
|