@tma.js/transformers 1.0.1 → 1.1.1
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/parsers.d.ts +4 -4
- package/dist/dts/pipes.d.ts +1 -2
- package/dist/dts/rgb.d.ts +39 -12
- package/dist/dts/transformers.d.ts +16 -4
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +220 -144
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,192 +1,268 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { throwifyFpFn as g } from "@tma.js/toolkit";
|
|
2
|
+
import { pipe as c, string as n, check as S, transform as p, union as A, instance as D, parse as L, looseObject as l, optional as i, number as w, boolean as m, integer as N, date as O, record as I, is as U, unknown as z } from "valibot";
|
|
3
|
+
function E(t, r, e, u, a, s, o, R, J) {
|
|
4
|
+
switch (arguments.length) {
|
|
5
|
+
case 1:
|
|
6
|
+
return t;
|
|
7
|
+
case 2:
|
|
8
|
+
return r(t);
|
|
9
|
+
case 3:
|
|
10
|
+
return e(r(t));
|
|
11
|
+
case 4:
|
|
12
|
+
return u(e(r(t)));
|
|
13
|
+
case 5:
|
|
14
|
+
return a(u(e(r(t))));
|
|
15
|
+
case 6:
|
|
16
|
+
return s(a(u(e(r(t)))));
|
|
17
|
+
case 7:
|
|
18
|
+
return o(s(a(u(e(r(t))))));
|
|
19
|
+
case 8:
|
|
20
|
+
return R(o(s(a(u(e(r(t)))))));
|
|
21
|
+
case 9:
|
|
22
|
+
return J(R(o(s(a(u(e(r(t))))))));
|
|
23
|
+
default: {
|
|
24
|
+
for (var y = arguments[0], _ = 1; _ < arguments.length; _++)
|
|
25
|
+
y = arguments[_](y);
|
|
26
|
+
return y;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
var V = function(t) {
|
|
31
|
+
return t._tag === "Left";
|
|
32
|
+
}, q = function(t) {
|
|
4
33
|
return { _tag: "Left", left: t };
|
|
5
|
-
},
|
|
34
|
+
}, v = function(t) {
|
|
6
35
|
return { _tag: "Right", right: t };
|
|
7
|
-
},
|
|
36
|
+
}, Q = q, f = v, x = function(t) {
|
|
37
|
+
return function(r) {
|
|
38
|
+
return j(r) ? r : f(t(r.right));
|
|
39
|
+
};
|
|
40
|
+
}, j = V, G = function(t, r) {
|
|
8
41
|
try {
|
|
9
|
-
return
|
|
10
|
-
} catch (
|
|
11
|
-
return
|
|
42
|
+
return f(t());
|
|
43
|
+
} catch (e) {
|
|
44
|
+
return Q(r(e));
|
|
12
45
|
}
|
|
13
46
|
};
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
return new URLSearchParams(
|
|
18
|
-
const
|
|
19
|
-
Array.isArray(
|
|
20
|
-
}),
|
|
21
|
-
}
|
|
47
|
+
function M(t) {
|
|
48
|
+
const r = (e) => {
|
|
49
|
+
const u = {};
|
|
50
|
+
return new URLSearchParams(e).forEach((a, s) => {
|
|
51
|
+
const o = u[s];
|
|
52
|
+
Array.isArray(o) ? o.push(a) : o === void 0 ? u[s] = a : u[s] = [o, a];
|
|
53
|
+
}), L(t, u);
|
|
54
|
+
};
|
|
55
|
+
return c(
|
|
56
|
+
A([n(), D(URLSearchParams)]),
|
|
57
|
+
S((e) => {
|
|
58
|
+
try {
|
|
59
|
+
return r(e), !0;
|
|
60
|
+
} catch {
|
|
61
|
+
return !1;
|
|
62
|
+
}
|
|
63
|
+
}, "The value doesn't match required schema"),
|
|
64
|
+
p(r)
|
|
65
|
+
);
|
|
22
66
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
67
|
+
function H(t) {
|
|
68
|
+
return c(
|
|
69
|
+
n(),
|
|
70
|
+
S((r) => {
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(r), !0;
|
|
73
|
+
} catch {
|
|
74
|
+
return !1;
|
|
75
|
+
}
|
|
76
|
+
}, "Input is not a valid JSON value"),
|
|
77
|
+
p(JSON.parse),
|
|
78
|
+
t
|
|
79
|
+
);
|
|
25
80
|
}
|
|
26
|
-
function
|
|
27
|
-
return c(
|
|
81
|
+
function h(t) {
|
|
82
|
+
return c(n(), H(t));
|
|
28
83
|
}
|
|
29
|
-
function
|
|
84
|
+
function W(t) {
|
|
30
85
|
return c(
|
|
31
|
-
|
|
32
|
-
|
|
86
|
+
A([n(), D(URLSearchParams)]),
|
|
87
|
+
M(t)
|
|
33
88
|
);
|
|
34
89
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
90
|
+
function d(t) {
|
|
91
|
+
return (r) => t.test(r);
|
|
92
|
+
}
|
|
93
|
+
const K = d(/^#[\da-f]{3}$/i), X = d(/^#[\da-f]{4}$/i), Y = d(/^#[\da-f]{6}$/i), Z = d(/^#[\da-f]{8}$/i);
|
|
94
|
+
function k(t) {
|
|
95
|
+
return [Y, Z, K, X].some((r) => r(t));
|
|
96
|
+
}
|
|
97
|
+
function $(t) {
|
|
98
|
+
let r = "#";
|
|
99
|
+
for (let e = 0; e < t.length - 1; e += 1)
|
|
100
|
+
r += t[1 + e].repeat(2);
|
|
101
|
+
return r;
|
|
102
|
+
}
|
|
103
|
+
function b(t) {
|
|
104
|
+
const r = t.replace(/\s/g, "").toLowerCase();
|
|
105
|
+
if (/^#[\da-f]{3}$/i.test(r))
|
|
106
|
+
return f($(r.toLowerCase() + "f"));
|
|
107
|
+
if (/^#[\da-f]{4}$/i.test(r))
|
|
108
|
+
return f($(r.toLowerCase()));
|
|
109
|
+
if (/^#[\da-f]{6}$/i.test(r))
|
|
110
|
+
return f(r.toLowerCase() + "ff");
|
|
111
|
+
if (/^#[\da-f]{8}$/i.test(r))
|
|
112
|
+
return f(r.toLowerCase());
|
|
113
|
+
const e = r.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || r.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\)$/);
|
|
114
|
+
return e ? f(
|
|
115
|
+
e.slice(1).reduce(
|
|
116
|
+
(u, a) => u + parseInt(a, 10).toString(16).padStart(2, "0"),
|
|
117
|
+
"#"
|
|
118
|
+
).padEnd(9, "f")
|
|
119
|
+
) : Q(new Error(`Value "${t}" does not satisfy any of known RGB formats.`));
|
|
120
|
+
}
|
|
121
|
+
function tt(t) {
|
|
122
|
+
return E(
|
|
123
|
+
b(t),
|
|
124
|
+
x((r) => r.slice(0, 7))
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const ct = g(tt), ft = g(b);
|
|
128
|
+
function rt() {
|
|
129
|
+
return l({
|
|
130
|
+
id: w(),
|
|
131
|
+
photo_url: i(n()),
|
|
132
|
+
type: n(),
|
|
133
|
+
title: n(),
|
|
134
|
+
username: i(n())
|
|
64
135
|
});
|
|
65
136
|
}
|
|
66
|
-
function
|
|
67
|
-
return
|
|
68
|
-
added_to_attachment_menu:
|
|
69
|
-
allows_write_to_pm:
|
|
70
|
-
first_name:
|
|
71
|
-
id:
|
|
72
|
-
is_bot:
|
|
73
|
-
is_premium:
|
|
74
|
-
last_name:
|
|
75
|
-
language_code:
|
|
76
|
-
photo_url:
|
|
77
|
-
username:
|
|
137
|
+
function P() {
|
|
138
|
+
return l({
|
|
139
|
+
added_to_attachment_menu: i(m()),
|
|
140
|
+
allows_write_to_pm: i(m()),
|
|
141
|
+
first_name: n(),
|
|
142
|
+
id: w(),
|
|
143
|
+
is_bot: i(m()),
|
|
144
|
+
is_premium: i(m()),
|
|
145
|
+
last_name: i(n()),
|
|
146
|
+
language_code: i(n()),
|
|
147
|
+
photo_url: i(n()),
|
|
148
|
+
username: i(n())
|
|
78
149
|
});
|
|
79
150
|
}
|
|
80
|
-
function
|
|
81
|
-
return
|
|
151
|
+
function et() {
|
|
152
|
+
return l({
|
|
82
153
|
auth_date: c(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
154
|
+
n(),
|
|
155
|
+
p((t) => new Date(Number(t) * 1e3)),
|
|
156
|
+
O()
|
|
86
157
|
),
|
|
87
|
-
can_send_after:
|
|
88
|
-
chat:
|
|
89
|
-
chat_type:
|
|
90
|
-
chat_instance:
|
|
91
|
-
hash:
|
|
92
|
-
query_id:
|
|
93
|
-
receiver:
|
|
94
|
-
start_param:
|
|
95
|
-
signature:
|
|
96
|
-
user:
|
|
158
|
+
can_send_after: i(c(n(), p(Number), N())),
|
|
159
|
+
chat: i(h(rt())),
|
|
160
|
+
chat_type: i(n()),
|
|
161
|
+
chat_instance: i(n()),
|
|
162
|
+
hash: n(),
|
|
163
|
+
query_id: i(n()),
|
|
164
|
+
receiver: i(h(P())),
|
|
165
|
+
start_param: i(n()),
|
|
166
|
+
signature: n(),
|
|
167
|
+
user: i(h(P()))
|
|
97
168
|
});
|
|
98
169
|
}
|
|
99
|
-
function
|
|
100
|
-
return
|
|
170
|
+
function F() {
|
|
171
|
+
return W(et());
|
|
101
172
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
104
|
-
|
|
173
|
+
function B() {
|
|
174
|
+
return I(
|
|
175
|
+
n(),
|
|
105
176
|
c(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
177
|
+
A([n(), w()]),
|
|
178
|
+
p((t) => typeof t == "number" ? `#${(t & 16777215).toString(16).padStart(6, "0")}` : t),
|
|
179
|
+
S(k)
|
|
109
180
|
)
|
|
110
181
|
);
|
|
111
182
|
}
|
|
112
|
-
function
|
|
113
|
-
const t =
|
|
114
|
-
return
|
|
183
|
+
function nt() {
|
|
184
|
+
const t = i(c(n(), p((r) => r === "1")));
|
|
185
|
+
return l({
|
|
115
186
|
tgWebAppBotInline: t,
|
|
116
|
-
tgWebAppData:
|
|
117
|
-
tgWebAppDefaultColors:
|
|
187
|
+
tgWebAppData: i(F()),
|
|
188
|
+
tgWebAppDefaultColors: i(h(B())),
|
|
118
189
|
tgWebAppFullscreen: t,
|
|
119
|
-
tgWebAppPlatform:
|
|
190
|
+
tgWebAppPlatform: n(),
|
|
120
191
|
tgWebAppShowSettings: t,
|
|
121
|
-
tgWebAppStartParam:
|
|
122
|
-
tgWebAppThemeParams:
|
|
123
|
-
tgWebAppVersion:
|
|
192
|
+
tgWebAppStartParam: i(n()),
|
|
193
|
+
tgWebAppThemeParams: h(B()),
|
|
194
|
+
tgWebAppVersion: n()
|
|
124
195
|
});
|
|
125
196
|
}
|
|
126
|
-
function
|
|
127
|
-
return
|
|
197
|
+
function T() {
|
|
198
|
+
return W(nt());
|
|
128
199
|
}
|
|
129
|
-
function
|
|
200
|
+
function pt(t) {
|
|
130
201
|
try {
|
|
131
|
-
return
|
|
202
|
+
return U(T(), t);
|
|
132
203
|
} catch {
|
|
133
204
|
return !1;
|
|
134
205
|
}
|
|
135
206
|
}
|
|
136
|
-
function
|
|
137
|
-
return
|
|
138
|
-
eventType:
|
|
139
|
-
eventData:
|
|
207
|
+
function ht() {
|
|
208
|
+
return l({
|
|
209
|
+
eventType: n(),
|
|
210
|
+
eventData: i(z())
|
|
140
211
|
});
|
|
141
212
|
}
|
|
142
|
-
function
|
|
143
|
-
return
|
|
144
|
-
() =>
|
|
145
|
-
(
|
|
213
|
+
function at(t) {
|
|
214
|
+
return G(
|
|
215
|
+
() => L(F(), t),
|
|
216
|
+
(r) => r
|
|
146
217
|
);
|
|
147
218
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
150
|
-
() =>
|
|
151
|
-
(
|
|
219
|
+
function it(t) {
|
|
220
|
+
return G(
|
|
221
|
+
() => L(T(), t),
|
|
222
|
+
(r) => r
|
|
152
223
|
);
|
|
153
224
|
}
|
|
154
|
-
const
|
|
155
|
-
function
|
|
156
|
-
return
|
|
157
|
-
Object.entries(t).reduce((
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
]),
|
|
225
|
+
const lt = g(at), mt = g(it);
|
|
226
|
+
function C(t, r) {
|
|
227
|
+
return r || (r = (e, u) => JSON.stringify(u)), new URLSearchParams(
|
|
228
|
+
Object.entries(t).reduce((e, [u, a]) => (Array.isArray(a) ? e.push(...a.map((s) => [u, String(s)])) : a != null && e.push([
|
|
229
|
+
u,
|
|
230
|
+
a instanceof Date ? (a.getTime() / 1e3 | 0).toString() : typeof a == "string" || typeof a == "number" ? String(a) : typeof a == "boolean" ? a ? "1" : "0" : r(u, a)
|
|
231
|
+
]), e), [])
|
|
161
232
|
).toString();
|
|
162
233
|
}
|
|
163
|
-
function
|
|
164
|
-
return
|
|
234
|
+
function ut(t) {
|
|
235
|
+
return C(t);
|
|
165
236
|
}
|
|
166
|
-
function
|
|
167
|
-
return
|
|
237
|
+
function gt(t) {
|
|
238
|
+
return C(t, (r, e) => r === "tgWebAppData" ? ut(e) : JSON.stringify(e));
|
|
168
239
|
}
|
|
169
240
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
241
|
+
et as initData,
|
|
242
|
+
rt as initDataChat,
|
|
243
|
+
F as initDataQuery,
|
|
244
|
+
P as initDataUser,
|
|
245
|
+
k as isAnyRGB,
|
|
246
|
+
pt as isLaunchParamsQuery,
|
|
247
|
+
Y as isRGB,
|
|
248
|
+
Z as isRGBA,
|
|
249
|
+
X as isRGBAShort,
|
|
250
|
+
K as isRGBShort,
|
|
251
|
+
nt as launchParams,
|
|
252
|
+
T as launchParamsQuery,
|
|
253
|
+
ht as miniAppsMessage,
|
|
254
|
+
lt as parseInitDataQuery,
|
|
255
|
+
at as parseInitDataQueryFp,
|
|
256
|
+
mt as parseLaunchParamsQuery,
|
|
257
|
+
it as parseLaunchParamsQueryFp,
|
|
258
|
+
h as pipeJsonToSchema,
|
|
259
|
+
W as pipeQueryToSchema,
|
|
260
|
+
ut as serializeInitDataQuery,
|
|
261
|
+
gt as serializeLaunchParamsQuery,
|
|
262
|
+
B as themeParams,
|
|
263
|
+
ct as toRGB,
|
|
264
|
+
tt as toRGBFp,
|
|
265
|
+
ft as toRGBFull,
|
|
266
|
+
b as toRGBFullFp
|
|
191
267
|
};
|
|
192
268
|
//# sourceMappingURL=index.js.map
|