@vbotma/bridge 2.2.4 → 2.2.6
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.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 +23 -23
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { is as L, looseObject as m, function as Y, nullish as v, boolean as j, number as U, string as E, optional as I, unknown as me, parse as
|
|
1
|
+
import { is as L, looseObject as m, function as Y, nullish as v, boolean as j, number as U, string as E, optional as I, unknown as me, parse as W, any as we } from "valibot";
|
|
2
2
|
import { throwifyFpFn as A, getStorageValue as de, setStorageValue as X, createLogger as be, throwifyAnyEither as C, createCbCollector as Z, BetterTaskEither as ee } from "@vbotma/toolkit";
|
|
3
3
|
import { createLogger as yt, deepSnakeToCamelObjKeys as vt } from "@vbotma/toolkit";
|
|
4
4
|
import { BetterPromise as te, TimeoutError as he } from "better-promises";
|
|
@@ -61,14 +61,14 @@ const $ = "launchParams";
|
|
|
61
61
|
function z(e) {
|
|
62
62
|
return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Ve() {
|
|
65
65
|
return l.pipe(
|
|
66
66
|
M(),
|
|
67
67
|
c.chainW(re)
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
|
-
const tt = A(
|
|
71
|
-
function
|
|
70
|
+
const tt = A(Ve);
|
|
71
|
+
function Be() {
|
|
72
72
|
return l.pipe(
|
|
73
73
|
M(),
|
|
74
74
|
c.map((e) => {
|
|
@@ -79,7 +79,7 @@ function Ve() {
|
|
|
79
79
|
}
|
|
80
80
|
function rt() {
|
|
81
81
|
return l.pipe(
|
|
82
|
-
|
|
82
|
+
Be(),
|
|
83
83
|
c.fold((e) => {
|
|
84
84
|
throw e;
|
|
85
85
|
}, (e) => e),
|
|
@@ -120,7 +120,7 @@ function M() {
|
|
|
120
120
|
return c.left(new Ae(e));
|
|
121
121
|
}
|
|
122
122
|
const nt = A(M);
|
|
123
|
-
function
|
|
123
|
+
function qe(e, t) {
|
|
124
124
|
const r = /* @__PURE__ */ new Map(), n = ke(), a = (o, s, p = !1) => {
|
|
125
125
|
const _ = r.get(o) || /* @__PURE__ */ new Map();
|
|
126
126
|
r.set(o, _);
|
|
@@ -155,7 +155,7 @@ function We(e, t) {
|
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function B(e, t) {
|
|
159
159
|
window.dispatchEvent(new MessageEvent("message", {
|
|
160
160
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
161
161
|
// We specify this kind of source here in order to allow the package's "on" function to
|
|
@@ -164,11 +164,11 @@ function V(e, t) {
|
|
|
164
164
|
source: window.parent
|
|
165
165
|
}));
|
|
166
166
|
}
|
|
167
|
-
const S = h(!1), T = h("https://web.telegram.org"),
|
|
167
|
+
const S = h(!1), T = h("https://web.telegram.org"), We = (e) => {
|
|
168
168
|
b().log("Event received:", e);
|
|
169
169
|
}, ce = ae(S);
|
|
170
170
|
function ot(e) {
|
|
171
|
-
e !== S() && (S.set(e), (e ? O : Le)("*",
|
|
171
|
+
e !== S() && (S.set(e), (e ? O : Le)("*", We));
|
|
172
172
|
}
|
|
173
173
|
const _e = ae(T);
|
|
174
174
|
function at(e) {
|
|
@@ -186,7 +186,7 @@ function st() {
|
|
|
186
186
|
e.unsubAll(), "reset" in e && e.reset();
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function q(e, t, r) {
|
|
190
190
|
const n = [r], a = e[t];
|
|
191
191
|
typeof a == "function" && n.push(a);
|
|
192
192
|
const o = (...p) => {
|
|
@@ -278,14 +278,14 @@ function J(e) {
|
|
|
278
278
|
return;
|
|
279
279
|
let t;
|
|
280
280
|
try {
|
|
281
|
-
t =
|
|
281
|
+
t = W(ne(oe()), e.data);
|
|
282
282
|
} catch {
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
const { eventType: r, eventData: n } = t, a = Fe[r];
|
|
286
286
|
let o;
|
|
287
287
|
try {
|
|
288
|
-
o = a ?
|
|
288
|
+
o = a ? W(a, n) : n;
|
|
289
289
|
} catch (s) {
|
|
290
290
|
return b().forceError(
|
|
291
291
|
[
|
|
@@ -305,16 +305,16 @@ const {
|
|
|
305
305
|
off: Le,
|
|
306
306
|
emit: Te,
|
|
307
307
|
clear: Oe
|
|
308
|
-
} =
|
|
308
|
+
} = qe(
|
|
309
309
|
() => {
|
|
310
310
|
const e = window;
|
|
311
|
-
!e.TelegramGameProxy && (e.TelegramGameProxy = {}),
|
|
311
|
+
!e.TelegramGameProxy && (e.TelegramGameProxy = {}), q(e.TelegramGameProxy, "receiveEvent", B), G(e, "TelegramGameProxy"), !e.VBot && (e.VBot = {}), !e.VBot.WebView && (e.VBot.WebView = {}), q(e.VBot.WebView, "receiveEvent", B), G(e.VBot, "WebView"), q(e, "TelegramGameProxy_receiveEvent", B), window.addEventListener("message", J);
|
|
312
312
|
},
|
|
313
313
|
() => {
|
|
314
314
|
[
|
|
315
315
|
["TelegramGameProxy_receiveEvent"],
|
|
316
316
|
["TelegramGameProxy", "receiveEvent"],
|
|
317
|
-
["
|
|
317
|
+
["VBot", "WebView", "receiveEvent"]
|
|
318
318
|
].forEach((e) => {
|
|
319
319
|
const t = window;
|
|
320
320
|
let r = [void 0, t];
|
|
@@ -368,10 +368,10 @@ function R(e, t, r = {}) {
|
|
|
368
368
|
return i(d[0]);
|
|
369
369
|
const g = (y) => {
|
|
370
370
|
y && i(y[0]);
|
|
371
|
-
},
|
|
371
|
+
}, V = () => {
|
|
372
372
|
o.unsub(g);
|
|
373
373
|
};
|
|
374
|
-
o.sub(g), f.on("finalized",
|
|
374
|
+
o.sub(g), f.on("finalized", V);
|
|
375
375
|
}, r)),
|
|
376
376
|
w.mapBoth(_, _)
|
|
377
377
|
);
|
|
@@ -440,7 +440,7 @@ function ct({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
|
440
440
|
o(...s);
|
|
441
441
|
};
|
|
442
442
|
try {
|
|
443
|
-
const i =
|
|
443
|
+
const i = W(ne(oe()), p);
|
|
444
444
|
t({ name: i.eventType, params: i.eventData }, _);
|
|
445
445
|
} catch {
|
|
446
446
|
_();
|
|
@@ -633,10 +633,10 @@ function Ge(e, t, r = {}) {
|
|
|
633
633
|
return i(d[0]);
|
|
634
634
|
const g = (y) => {
|
|
635
635
|
y && i(y[0]);
|
|
636
|
-
},
|
|
636
|
+
}, V = () => {
|
|
637
637
|
o.unsub(g);
|
|
638
638
|
};
|
|
639
|
-
o.sub(g), f.on("finalized",
|
|
639
|
+
o.sub(g), f.on("finalized", V);
|
|
640
640
|
}, r)),
|
|
641
641
|
w.mapBoth(_, _)
|
|
642
642
|
);
|
|
@@ -720,7 +720,7 @@ export {
|
|
|
720
720
|
dt as decodeStartParam,
|
|
721
721
|
Je as decodeStartParamFp,
|
|
722
722
|
vt as deepSnakeToCamelObjKeys,
|
|
723
|
-
|
|
723
|
+
B as emitEvent,
|
|
724
724
|
le as encodeBase64Url,
|
|
725
725
|
Q as getReleaseVersion,
|
|
726
726
|
se as hasWebviewProxy,
|
|
@@ -745,9 +745,9 @@ export {
|
|
|
745
745
|
Ge as requestFp,
|
|
746
746
|
st as resetGlobals,
|
|
747
747
|
tt as retrieveLaunchParams,
|
|
748
|
-
|
|
748
|
+
Ve as retrieveLaunchParamsFp,
|
|
749
749
|
rt as retrieveRawInitData,
|
|
750
|
-
|
|
750
|
+
Be as retrieveRawInitDataFp,
|
|
751
751
|
nt as retrieveRawLaunchParams,
|
|
752
752
|
M as retrieveRawLaunchParamsFp,
|
|
753
753
|
ot as setDebug,
|