urfu-ui-kit-react 2.1.2 → 2.1.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/dist/components/Calendar/MaskedDateInput.d.ts.map +1 -1
- package/dist/components/Icon/Icon.d.ts.map +1 -1
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/dev/index.js +336 -336
- package/dist/hooks/useAnchoredPosition.d.ts +12 -0
- package/dist/hooks/useAnchoredPosition.d.ts.map +1 -1
- package/dist/hooks/useSelectEngine.d.ts.map +1 -1
- package/dist/style-no-fonts.css +1 -1
- package/dist/style.css +1 -1
- package/dist/style.layer.css +7 -7
- package/dist/style.shell.css +2 -2
- package/dist/urfu-ui-kit-react.js +4678 -4637
- package/package.json +3 -3
package/dist/dev/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { useSyncExternalStore as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
4
|
-
let
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useSyncExternalStore as Ht } from "react";
|
|
2
|
+
let I = [], jt = 1;
|
|
3
|
+
const K = /* @__PURE__ */ new Set();
|
|
4
|
+
let O = !1;
|
|
5
|
+
function J() {
|
|
6
|
+
O || (O = !0, setTimeout(() => {
|
|
7
|
+
O = !1, K.forEach((t) => t());
|
|
8
8
|
}, 16));
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const o = Date.now(), r = { id:
|
|
12
|
-
|
|
10
|
+
function Ut(t, e, n) {
|
|
11
|
+
const o = Date.now(), r = { id: jt++, service: t, method: e.toUpperCase(), path: n, status: "pending", duration: null, endedAt: null, faked: !1 };
|
|
12
|
+
I = [...I.slice(-49), r], J();
|
|
13
13
|
let a = !1;
|
|
14
14
|
return (s, i) => {
|
|
15
|
-
a || (a = !0, r.status = s, r.faked = i, r.endedAt = Date.now(), r.duration = r.endedAt - o,
|
|
15
|
+
a || (a = !0, r.status = s, r.faked = i, r.endedAt = Date.now(), r.duration = r.endedAt - o, J());
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return [...
|
|
18
|
+
function nt() {
|
|
19
|
+
return [...I].reverse();
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
21
|
+
function ft() {
|
|
22
|
+
I = [], O = !1, J();
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
26
|
-
|
|
24
|
+
function Nt(t) {
|
|
25
|
+
return K.add(t), () => {
|
|
26
|
+
K.delete(t);
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
let
|
|
31
|
-
const
|
|
32
|
-
let
|
|
33
|
-
const
|
|
34
|
-
function
|
|
29
|
+
const pt = "urfu-ui-kit:dev:", x = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Set();
|
|
30
|
+
let ht;
|
|
31
|
+
const bt = (t) => `${pt}${t}`, _t = ["offline", "network", "slow"];
|
|
32
|
+
let L = null;
|
|
33
|
+
const q = /* @__PURE__ */ new Set();
|
|
34
|
+
function Wt() {
|
|
35
35
|
let t;
|
|
36
36
|
try {
|
|
37
37
|
t = new URLSearchParams(window.location.search).get("dev");
|
|
@@ -40,13 +40,13 @@ function _t() {
|
|
|
40
40
|
}
|
|
41
41
|
if (t !== null) {
|
|
42
42
|
if (t === "off") {
|
|
43
|
-
|
|
43
|
+
L = null;
|
|
44
44
|
try {
|
|
45
|
-
Object.keys(localStorage).filter((e) => e.startsWith(
|
|
45
|
+
Object.keys(localStorage).filter((e) => e.startsWith(pt)).forEach((e) => localStorage.removeItem(e));
|
|
46
46
|
} catch {
|
|
47
47
|
}
|
|
48
48
|
} else
|
|
49
|
-
|
|
49
|
+
L = t.split(",").map((e) => e.trim()).filter(Boolean), q.clear();
|
|
50
50
|
try {
|
|
51
51
|
const e = new URL(window.location.href);
|
|
52
52
|
e.searchParams.delete("dev"), window.history.replaceState(window.history.state, "", e.href);
|
|
@@ -54,17 +54,17 @@ function _t() {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function Wt(t) {
|
|
58
|
-
return [...Nt, ...t.builtins ?? [], ...(t.groups ?? []).flatMap((e) => e.items.map((n) => n.id))];
|
|
59
|
-
}
|
|
60
57
|
function Bt(t) {
|
|
61
|
-
|
|
62
|
-
const e = new Set(Wt(t.config)), n = E.filter((o) => e.has(o));
|
|
63
|
-
n.length && (I.add(t.config.service), t.state = { ...t.state, faults: n }, N(t.config.service, t.state));
|
|
58
|
+
return [..._t, ...t.builtins ?? [], ...(t.groups ?? []).flatMap((e) => e.items.map((n) => n.id))];
|
|
64
59
|
}
|
|
65
60
|
function Kt(t) {
|
|
61
|
+
if (!L || q.has(t.config.service)) return;
|
|
62
|
+
const e = new Set(Bt(t.config)), n = L.filter((o) => e.has(o));
|
|
63
|
+
n.length && (q.add(t.config.service), t.state = { ...t.state, faults: n }, _(t.config.service, t.state));
|
|
64
|
+
}
|
|
65
|
+
function Jt(t) {
|
|
66
66
|
try {
|
|
67
|
-
const e = JSON.parse(localStorage.getItem(
|
|
67
|
+
const e = JSON.parse(localStorage.getItem(bt(t)) ?? "null");
|
|
68
68
|
return {
|
|
69
69
|
faults: Array.isArray(e == null ? void 0 : e.faults) ? e.faults.filter((n) => typeof n == "string") : [],
|
|
70
70
|
rules: Array.isArray(e == null ? void 0 : e.rules) ? e.rules : [],
|
|
@@ -74,145 +74,145 @@ function Kt(t) {
|
|
|
74
74
|
return { faults: [], rules: [] };
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function _(t, e) {
|
|
78
78
|
try {
|
|
79
|
-
localStorage.setItem(
|
|
79
|
+
localStorage.setItem(bt(t), JSON.stringify(e));
|
|
80
80
|
} catch {
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
t && (
|
|
83
|
+
function Xt(t) {
|
|
84
|
+
t && (ht = t);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
return
|
|
86
|
+
function Vt() {
|
|
87
|
+
return ht;
|
|
88
88
|
}
|
|
89
89
|
function Zt(t, e) {
|
|
90
|
-
const n = { config: t, state:
|
|
91
|
-
return
|
|
90
|
+
const n = { config: t, state: Jt(t.service), kit: e };
|
|
91
|
+
return Kt(n), x.set(t.service, n), D(), n;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
93
|
+
function Gt(t) {
|
|
94
|
+
x.delete(t), x.size || (L = null, q.clear()), D();
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
return [...
|
|
96
|
+
function m() {
|
|
97
|
+
return [...x.values()];
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
return t ?
|
|
99
|
+
function Yt(t) {
|
|
100
|
+
return t ? x.get(t) : x.values().next().value;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
104
|
-
|
|
102
|
+
function gt(t) {
|
|
103
|
+
return X.add(t), () => {
|
|
104
|
+
X.delete(t);
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
107
|
+
function D() {
|
|
108
|
+
X.forEach((t) => t());
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
t.state = e,
|
|
110
|
+
function W(t, e) {
|
|
111
|
+
t.state = e, _(t.config.service, e), D();
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function Qt(t, e, n) {
|
|
114
114
|
const o = t.state.faults.filter((r) => r !== e);
|
|
115
|
-
|
|
115
|
+
W(t, { ...t.state, faults: n ? [...o, e] : o });
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function te(t, e) {
|
|
118
118
|
const n = `rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
119
|
-
|
|
119
|
+
W(t, { ...t.state, rules: [...t.state.rules, { ...e, id: n, enabled: !0 }] });
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
121
|
+
function ee(t, e, n) {
|
|
122
|
+
W(t, { ...t.state, rules: t.state.rules.map((o) => o.id === e ? { ...o, enabled: n } : o) });
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
|
|
124
|
+
function ne(t, e) {
|
|
125
|
+
W(t, { ...t.state, rules: t.state.rules.filter((n) => n.id !== e) });
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
|
|
129
|
-
t.state = { faults: [], rules: [], ...t.state.launcher ? { launcher: t.state.launcher } : {} },
|
|
130
|
-
}),
|
|
127
|
+
function oe() {
|
|
128
|
+
x.forEach((t) => {
|
|
129
|
+
t.state = { faults: [], rules: [], ...t.state.launcher ? { launcher: t.state.launcher } : {} }, _(t.config.service, t.state);
|
|
130
|
+
}), D();
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function z(t) {
|
|
133
133
|
return t.state.faults.length + t.state.rules.filter((e) => e.enabled).length;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function ae(t) {
|
|
136
136
|
return t.state.launcher ?? t.config.launcher ?? "visible";
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
e.state = { ...e.state, launcher: t },
|
|
141
|
-
}),
|
|
142
|
-
}
|
|
143
|
-
const
|
|
144
|
-
let
|
|
145
|
-
const
|
|
146
|
-
let
|
|
147
|
-
const
|
|
138
|
+
function at(t) {
|
|
139
|
+
x.forEach((e) => {
|
|
140
|
+
e.state = { ...e.state, launcher: t }, _(e.config.service, e.state);
|
|
141
|
+
}), D();
|
|
142
|
+
}
|
|
143
|
+
const re = 1e4, rt = 200, T = ".u-error-screen, .u-notification-fail, .u-notification-warning, .u-offline-banner-offline";
|
|
144
|
+
let F = [], se = 1;
|
|
145
|
+
const V = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new Set();
|
|
146
|
+
let y = null;
|
|
147
|
+
const $ = (t) => {
|
|
148
148
|
const e = (t ?? "").replace(/\s+/g, " ").trim();
|
|
149
|
-
return e.length >
|
|
150
|
-
},
|
|
151
|
-
function
|
|
149
|
+
return e.length > rt ? `${e.slice(0, rt - 1)}…` : e;
|
|
150
|
+
}, ie = (t) => t.status === "network" || typeof t.status == "number" && t.status >= 400;
|
|
151
|
+
function le(t, e) {
|
|
152
152
|
var i;
|
|
153
|
-
const n =
|
|
153
|
+
const n = m().map((f) => f.config.service), o = (i = e.closest("[data-name]")) == null ? void 0 : i.getAttribute("data-name"), r = o && n.includes(o) ? o : null, a = nt().find((f) => ie(f) && f.endedAt !== null && t - f.endedAt <= re && (!r || f.service === r));
|
|
154
154
|
if (!a) return;
|
|
155
155
|
const s = `${a.method} ${a.path} → ${a.status === "network" ? "сеть" : a.status}`;
|
|
156
156
|
return n.length > 1 ? `${a.service}: ${s}` : s;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function ce(t) {
|
|
159
159
|
var o, r, a;
|
|
160
160
|
if (t.classList.contains("u-error-screen"))
|
|
161
161
|
return {
|
|
162
162
|
kind: "screen",
|
|
163
163
|
// Код — в data-error-code на корне заглушки: крупный код рисуется не у всех вариантов (forbidden, serverError).
|
|
164
164
|
// .u-error-screen-code — для разметки кита до появления атрибута.
|
|
165
|
-
code:
|
|
166
|
-
title:
|
|
167
|
-
text:
|
|
165
|
+
code: $(t.dataset.errorCode || ((o = t.querySelector(".u-error-screen-code")) == null ? void 0 : o.textContent)) || void 0,
|
|
166
|
+
title: $((r = t.querySelector(".u-error-screen-title")) == null ? void 0 : r.textContent) || $(t.getAttribute("aria-label")) || "Заглушка",
|
|
167
|
+
text: $((a = t.querySelector(".u-error-screen-description")) == null ? void 0 : a.textContent) || void 0
|
|
168
168
|
};
|
|
169
169
|
if (t.classList.contains("u-offline-banner-offline"))
|
|
170
|
-
return { kind: "offline", title:
|
|
170
|
+
return { kind: "offline", title: $(t.textContent) || "Нет связи" };
|
|
171
171
|
const e = t.classList.contains("u-notification-fail") ? "fail" : "warning", n = t.querySelector(".u-notification-content") ?? t;
|
|
172
|
-
return { kind: "notification", variant: e, title:
|
|
172
|
+
return { kind: "notification", variant: e, title: $(n.textContent) || "Уведомление" };
|
|
173
173
|
}
|
|
174
|
-
function
|
|
175
|
-
if (!t.isConnected || !t.matches(
|
|
176
|
-
const e =
|
|
174
|
+
function st(t) {
|
|
175
|
+
if (!t.isConnected || !t.matches(T)) return;
|
|
176
|
+
const e = ce(t);
|
|
177
177
|
if (!e) return;
|
|
178
178
|
const n = JSON.stringify(e);
|
|
179
|
-
if (
|
|
180
|
-
|
|
179
|
+
if (V.get(t) === n) return;
|
|
180
|
+
V.set(t, n);
|
|
181
181
|
const o = Date.now();
|
|
182
|
-
|
|
182
|
+
F = [...F.slice(-29), { id: se++, at: o, ...e, cause: le(o, t) }], H.forEach((r) => r());
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
t instanceof Element && (t.matches(
|
|
184
|
+
function ue(t, e) {
|
|
185
|
+
t instanceof Element && (t.matches(T) && e.push(t), t.querySelectorAll(T).forEach((n) => e.push(n)));
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
187
|
+
function de() {
|
|
188
|
+
y || typeof MutationObserver > "u" || (y = new MutationObserver((t) => {
|
|
189
189
|
const e = [];
|
|
190
190
|
t.forEach((n) => {
|
|
191
191
|
if (n.type === "childList") {
|
|
192
|
-
n.addedNodes.forEach((r) =>
|
|
192
|
+
n.addedNodes.forEach((r) => ue(r, e));
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
195
|
const o = n.target;
|
|
196
|
-
o.matches(
|
|
197
|
-
}), e.length && setTimeout(() => e.forEach(
|
|
198
|
-
}),
|
|
196
|
+
o.matches(T) ? e.push(o) : V.delete(o);
|
|
197
|
+
}), e.length && setTimeout(() => e.forEach(st), 0);
|
|
198
|
+
}), y.observe(document.documentElement, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["data-error-code", "class"] }), document.querySelectorAll(T).forEach(st));
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
|
|
200
|
+
function fe() {
|
|
201
|
+
y == null || y.disconnect(), y = null;
|
|
202
202
|
}
|
|
203
203
|
function Z() {
|
|
204
|
-
return [...
|
|
204
|
+
return [...F].reverse();
|
|
205
205
|
}
|
|
206
|
-
function
|
|
207
|
-
|
|
206
|
+
function vt() {
|
|
207
|
+
F = [], H.forEach((t) => t());
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
return
|
|
211
|
-
|
|
209
|
+
function pe(t) {
|
|
210
|
+
return H.add(t), () => {
|
|
211
|
+
H.delete(t);
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
function
|
|
214
|
+
const mt = 4e3, he = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
215
|
+
function be(t, e) {
|
|
216
216
|
let n;
|
|
217
217
|
try {
|
|
218
218
|
n = new URL(t, window.location.href).pathname;
|
|
@@ -225,16 +225,16 @@ function he(t, e) {
|
|
|
225
225
|
const a = n.slice(r + o.length);
|
|
226
226
|
return a.startsWith("/") || a === "" ? a || "/" : null;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function ge(t, e) {
|
|
229
229
|
const n = (s) => s.split("/").filter(Boolean), o = n(t.trim()), r = n(e), a = (s, i) => s === o.length ? i === r.length : o[s] === "**" ? a(s + 1, i) || i < r.length && a(s, i + 1) : i === r.length ? !1 : (o[s] === "*" || o[s] === r[i]) && a(s + 1, i + 1);
|
|
230
230
|
return a(0, 0);
|
|
231
231
|
}
|
|
232
|
-
function
|
|
232
|
+
function ve(t, e) {
|
|
233
233
|
var o;
|
|
234
234
|
const n = (o = t.method) == null ? void 0 : o.trim().toUpperCase();
|
|
235
|
-
return !n || n === "*" ? !0 : n === "WRITE" ? !
|
|
235
|
+
return !n || n === "*" ? !0 : n === "WRITE" ? !he.has(e) : n === e;
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function me(t, e) {
|
|
238
238
|
return t.html ? {
|
|
239
239
|
kind: "response",
|
|
240
240
|
delay: e,
|
|
@@ -249,121 +249,121 @@ function ve(t, e) {
|
|
|
249
249
|
body: JSON.stringify({ statusCode: t.status, message: t.message ?? `Сбой из dev-панели: ${t.status}` })
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function we(t) {
|
|
253
253
|
const e = new Set(t.state.faults);
|
|
254
254
|
return [...(t.config.groups ?? []).flatMap((o) => o.items).filter((o) => e.has(o.id)).flatMap((o) => [].concat(o.request ?? [])), ...t.state.rules.filter((o) => o.enabled)];
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
for (const e of
|
|
258
|
-
const n =
|
|
256
|
+
function wt(t) {
|
|
257
|
+
for (const e of m()) {
|
|
258
|
+
const n = be(t, e.config.apiBase);
|
|
259
259
|
if (n !== null) return { entry: e, path: n };
|
|
260
260
|
}
|
|
261
261
|
return null;
|
|
262
262
|
}
|
|
263
|
-
function
|
|
264
|
-
const o = n.toUpperCase(), r = new Set(t.state.faults), a = r.has("slow") ?
|
|
263
|
+
function xt({ entry: t, path: e }, n) {
|
|
264
|
+
const o = n.toUpperCase(), r = new Set(t.state.faults), a = r.has("slow") ? mt : 0;
|
|
265
265
|
if (r.has("offline") || r.has("network")) return { kind: "network", delay: a };
|
|
266
|
-
const s =
|
|
267
|
-
return s ?
|
|
266
|
+
const s = we(t).find((i) => ve(i, o) && ge(i.path, e));
|
|
267
|
+
return s ? me(s, a) : a ? { kind: "pass", delay: a } : null;
|
|
268
268
|
}
|
|
269
|
-
const
|
|
270
|
-
function
|
|
269
|
+
const yt = (t, e) => Ut(t.entry.config.service, e, t.path), G = (t) => t.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
270
|
+
function xe(t, e) {
|
|
271
271
|
return new Promise((n, o) => {
|
|
272
272
|
if (e != null && e.aborted) {
|
|
273
|
-
o(
|
|
273
|
+
o(G(e));
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
276
|
const r = setTimeout(n, t);
|
|
277
277
|
e == null || e.addEventListener("abort", () => {
|
|
278
|
-
clearTimeout(r), o(
|
|
278
|
+
clearTimeout(r), o(G(e));
|
|
279
279
|
}, { once: !0 });
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
function
|
|
282
|
+
const $t = /* @__PURE__ */ new Set([204, 205, 304]), R = /* @__PURE__ */ new WeakSet();
|
|
283
|
+
function ye(t) {
|
|
284
284
|
if (typeof window > "u") return;
|
|
285
285
|
const e = t ?? window;
|
|
286
|
-
|
|
286
|
+
R.has(e) || (R.add(e), $e(e)), typeof XMLHttpRequest < "u" && !R.has(XMLHttpRequest.prototype) && (R.add(XMLHttpRequest.prototype), Se());
|
|
287
287
|
}
|
|
288
|
-
function
|
|
288
|
+
function $e(t) {
|
|
289
289
|
var n;
|
|
290
290
|
const e = (n = t.fetch) == null ? void 0 : n.bind(t);
|
|
291
291
|
e && (t.fetch = async (o, r) => {
|
|
292
|
-
const a = typeof o == "object" && "url" in o ? o : null, s =
|
|
292
|
+
const a = typeof o == "object" && "url" in o ? o : null, s = wt(a ? a.url : String(o));
|
|
293
293
|
if (!s) return e(o, r);
|
|
294
|
-
const i = (r == null ? void 0 : r.method) ?? (a == null ? void 0 : a.method) ?? "GET", f =
|
|
294
|
+
const i = (r == null ? void 0 : r.method) ?? (a == null ? void 0 : a.method) ?? "GET", f = yt(s, i), u = xt(s, i), p = (r == null ? void 0 : r.signal) ?? (a == null ? void 0 : a.signal);
|
|
295
295
|
try {
|
|
296
|
-
if (u != null && u.delay && await
|
|
296
|
+
if (u != null && u.delay && await xe(u.delay, p), p != null && p.aborted) throw G(p);
|
|
297
297
|
if ((u == null ? void 0 : u.kind) === "network")
|
|
298
298
|
throw f("network", !0), new TypeError("Failed to fetch");
|
|
299
299
|
if ((u == null ? void 0 : u.kind) === "response")
|
|
300
|
-
return f(u.status, !0), new Response(
|
|
300
|
+
return f(u.status, !0), new Response($t.has(u.status) ? null : u.body, {
|
|
301
301
|
status: u.status,
|
|
302
302
|
headers: { "Content-Type": u.contentType }
|
|
303
303
|
});
|
|
304
|
-
const
|
|
305
|
-
return f(
|
|
306
|
-
} catch (
|
|
307
|
-
throw f(p != null && p.aborted ? "abort" : "network", !1),
|
|
304
|
+
const w = await e(o, r);
|
|
305
|
+
return f(w.status, !1), w;
|
|
306
|
+
} catch (w) {
|
|
307
|
+
throw f(p != null && p.aborted ? "abort" : "network", !1), w;
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
-
const
|
|
312
|
-
function
|
|
311
|
+
const it = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), ke = ["readyState", "responseURL", "status", "statusText", "responseText", "response", "getAllResponseHeaders", "getResponseHeader"];
|
|
312
|
+
function Se() {
|
|
313
313
|
const t = XMLHttpRequest.prototype, e = t.open, n = t.send, o = t.abort;
|
|
314
314
|
t.open = function(a, s, ...i) {
|
|
315
|
-
|
|
315
|
+
ct(this), ke.forEach((f) => {
|
|
316
316
|
Reflect.deleteProperty(this, f);
|
|
317
|
-
}),
|
|
317
|
+
}), it.set(this, { method: a, url: String(s) }), e.call(this, a, s, ...i);
|
|
318
318
|
}, t.send = function(a) {
|
|
319
|
-
const s =
|
|
319
|
+
const s = it.get(this), i = s ? wt(s.url) : null;
|
|
320
320
|
if (!s || !i) {
|
|
321
321
|
n.call(this, a);
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
|
-
const f =
|
|
325
|
-
|
|
326
|
-
const u =
|
|
324
|
+
const f = yt(i, s.method);
|
|
325
|
+
lt.set(this, f);
|
|
326
|
+
const u = xt(i, s.method), p = () => {
|
|
327
327
|
this.addEventListener("abort", () => f("abort", !1), { once: !0 }), this.addEventListener("loadend", () => f(this.status || "network", !1), { once: !0 }), n.call(this, a);
|
|
328
328
|
};
|
|
329
329
|
if (!u) {
|
|
330
330
|
p();
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
|
-
|
|
334
|
-
if (
|
|
333
|
+
j.set(this, setTimeout(() => {
|
|
334
|
+
if (j.delete(this), u.kind === "pass") {
|
|
335
335
|
p();
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
|
-
f(u.kind === "network" ? "network" : u.status, !0),
|
|
338
|
+
f(u.kind === "network" ? "network" : u.status, !0), Ee(this, u, s.url);
|
|
339
339
|
}, u.delay));
|
|
340
340
|
}, t.abort = function() {
|
|
341
341
|
var s;
|
|
342
|
-
if (!
|
|
342
|
+
if (!ct(this)) {
|
|
343
343
|
o.call(this);
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
|
-
(s =
|
|
347
|
-
const a =
|
|
348
|
-
a("readyState", 4), a("status", 0),
|
|
346
|
+
(s = lt.get(this)) == null || s("abort", !1);
|
|
347
|
+
const a = kt(this);
|
|
348
|
+
a("readyState", 4), a("status", 0), Y(this, ["readystatechange", "abort", "loadend"]), a("readyState", 0);
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
|
-
function
|
|
352
|
-
const e =
|
|
353
|
-
return e === void 0 ? !1 : (clearTimeout(e),
|
|
351
|
+
function ct(t) {
|
|
352
|
+
const e = j.get(t);
|
|
353
|
+
return e === void 0 ? !1 : (clearTimeout(e), j.delete(t), !0);
|
|
354
354
|
}
|
|
355
|
-
const
|
|
355
|
+
const kt = (t) => (e, n) => {
|
|
356
356
|
Object.defineProperty(t, e, { configurable: !0, get: () => n });
|
|
357
|
-
},
|
|
357
|
+
}, Y = (t, e) => {
|
|
358
358
|
e.forEach((n) => t.dispatchEvent(new ProgressEvent(n)));
|
|
359
359
|
};
|
|
360
|
-
function
|
|
361
|
-
const o =
|
|
360
|
+
function Ee(t, e, n) {
|
|
361
|
+
const o = kt(t);
|
|
362
362
|
if (o("readyState", 4), o("responseURL", n), e.kind === "network") {
|
|
363
|
-
o("status", 0), o("statusText", ""),
|
|
363
|
+
o("status", 0), o("statusText", ""), Y(t, ["readystatechange", "error", "loadend"]);
|
|
364
364
|
return;
|
|
365
365
|
}
|
|
366
|
-
const r =
|
|
366
|
+
const r = $t.has(e.status) ? "" : e.body;
|
|
367
367
|
let a = r;
|
|
368
368
|
if (t.responseType === "json")
|
|
369
369
|
try {
|
|
@@ -377,30 +377,30 @@ function Se(t, e, n) {
|
|
|
377
377
|
Object.defineProperty(t, "getAllResponseHeaders", { configurable: !0, value: () => s }), Object.defineProperty(t, "getResponseHeader", {
|
|
378
378
|
configurable: !0,
|
|
379
379
|
value: (i) => i.toLowerCase() === "content-type" ? e.contentType : null
|
|
380
|
-
}),
|
|
380
|
+
}), Y(t, ["readystatechange", "load", "loadend"]);
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function ot(t) {
|
|
383
383
|
try {
|
|
384
384
|
t ? Reflect.deleteProperty(navigator, "onLine") : Object.defineProperty(navigator, "onLine", { configurable: !0, get: () => !1 }), window.dispatchEvent(new Event(t ? "online" : "offline"));
|
|
385
385
|
} catch {
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
function
|
|
389
|
-
const t =
|
|
390
|
-
|
|
388
|
+
function St() {
|
|
389
|
+
const t = m().some((e) => e.state.faults.includes("offline"));
|
|
390
|
+
oe(), ft(), vt(), t && ot(!0);
|
|
391
391
|
}
|
|
392
|
-
const
|
|
392
|
+
const Le = {
|
|
393
393
|
title: "Сеть",
|
|
394
394
|
items: [
|
|
395
395
|
{ id: "offline", label: "Офлайн браузера", hint: "Полоса «Нет связи», запросы к API падают" },
|
|
396
396
|
{ id: "network", label: "Обрыв соединения", hint: "Сеть есть, а сервер не отвечает" },
|
|
397
|
-
{ id: "slow", label: "Медленные ответы", hint: `Задержка ${
|
|
397
|
+
{ id: "slow", label: "Медленные ответы", hint: `Задержка ${mt / 1e3} с на запросы к API` }
|
|
398
398
|
]
|
|
399
|
-
},
|
|
399
|
+
}, Te = {
|
|
400
400
|
authFail: { label: "Сбой входа", hint: "После перезагрузки сервис рисует заглушку входа" },
|
|
401
401
|
crashApp: { label: "Падение приложения", hint: "Ошибка рендера над каркасом сервиса" },
|
|
402
402
|
crashPage: { label: "Падение страницы", hint: "Каждая открытая страница падает, пока флаг включён" }
|
|
403
|
-
},
|
|
403
|
+
}, Q = [["", "Любой"], ["GET", "GET"], ["write", "Запись"], ["POST", "POST"], ["PUT", "PUT"], ["PATCH", "PATCH"], ["DELETE", "DELETE"]], Ae = [400, 401, 403, 404, 409, 422, 429, 500, 502, 503, 504], d = (t) => String(t ?? "").replace(/[&<>"']/g, (e) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[e]), Ce = '<svg viewBox="0 0 36 36" fill="none" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M28 0L20 16H36L28 0ZM28 5.11101L23.6984 13.7143H32.3016L28 5.11101Z" fill="#3BA68C"/><path fill-rule="evenodd" clip-rule="evenodd" d="M9 33.7143C12.1559 33.7143 14.7143 31.1559 14.7143 28C14.7143 24.8441 12.1559 22.2857 9 22.2857C5.84409 22.2857 3.28571 24.8441 3.28571 28C3.28571 31.1559 5.84409 33.7143 9 33.7143ZM9 36C13.4183 36 17 32.4183 17 28C17 23.5817 13.4183 20 9 20C4.58172 20 1 23.5817 1 28C1 32.4183 4.58172 36 9 36Z" fill="#E54B6A"/><path fill-rule="evenodd" clip-rule="evenodd" d="M33.7143 22.2857H22.2857V33.7143H33.7143V22.2857ZM20 20V36H36V20H20Z" fill="#1E4391"/><path fill-rule="evenodd" clip-rule="evenodd" d="M12.0593 4.9091L9 0L5.94073 4.9091L0 6.11146L4.05 10.3478L3.43769 16L9 13.7091L14.5623 16L13.95 10.3478L18 6.11146L12.0593 4.9091ZM14.0262 7.31822L10.7085 6.64674L9 3.90515L7.29149 6.64674L3.97378 7.31822L6.23558 9.68408L5.89362 12.8407L9 11.5613L12.1064 12.8407L11.7644 9.68408L14.0262 7.31822Z" fill="#E98446"/></svg>', Me = `
|
|
404
404
|
:host { all: initial; }
|
|
405
405
|
* { box-sizing: border-box; }
|
|
406
406
|
.root { --p: #1e4391; --p-soft: #e8eef9; --fg: #222; --muted: #6b7280; --line: #d9dee8; --bg: #fff; --soft: #f5f7fb;
|
|
@@ -491,46 +491,46 @@ dd { margin: 0; font-family: Consolas, monospace; font-size: 12px; overflow-wrap
|
|
|
491
491
|
.panel ~ .pill { display: none; }
|
|
492
492
|
}
|
|
493
493
|
@media (prefers-reduced-motion: reduce) { .switch::after, .pill .label { transition: none; } }
|
|
494
|
-
`,
|
|
495
|
-
let
|
|
496
|
-
const
|
|
497
|
-
function
|
|
498
|
-
const t =
|
|
494
|
+
`, De = 6e3;
|
|
495
|
+
let tt, h = null, c = null, S = null, k = null, b = null, A = !1, E = !1;
|
|
496
|
+
const Et = { open: !1, tab: "faults", search: "", service: void 0, hint: "" }, l = { ...Et };
|
|
497
|
+
function P() {
|
|
498
|
+
const t = m();
|
|
499
499
|
return t.find((e) => e.config.service === l.service) ?? t[0];
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
const e = (t.config.builtins ?? []).map((n) => ({ id: n, ...
|
|
501
|
+
function Lt(t) {
|
|
502
|
+
const e = (t.config.builtins ?? []).map((n) => ({ id: n, ...Te[n] }));
|
|
503
503
|
return [
|
|
504
504
|
...e.length ? [{ title: "Весь сервис", items: e }] : [],
|
|
505
|
-
|
|
505
|
+
Le,
|
|
506
506
|
...t.config.groups ?? []
|
|
507
507
|
];
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function Pe(t, e) {
|
|
510
510
|
var n;
|
|
511
|
-
return ((n =
|
|
511
|
+
return ((n = Lt(t).flatMap((o) => o.items).find((o) => o.id === e)) == null ? void 0 : n.label) ?? e;
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function Tt(t) {
|
|
514
514
|
return [
|
|
515
|
-
...t.state.faults.map((e) =>
|
|
515
|
+
...t.state.faults.map((e) => Pe(t, e)),
|
|
516
516
|
...t.state.rules.filter((e) => e.enabled).map((e) => `${e.path} → ${e.status}`)
|
|
517
517
|
];
|
|
518
518
|
}
|
|
519
|
-
function
|
|
519
|
+
function Re(t, e, n, o) {
|
|
520
520
|
const r = t % 100, a = t % 10;
|
|
521
521
|
return r >= 11 && r <= 14 ? o : a === 1 ? e : a >= 2 && a <= 4 ? n : o;
|
|
522
522
|
}
|
|
523
|
-
const
|
|
524
|
-
function
|
|
525
|
-
const e = new Set(t.state.faults), n =
|
|
526
|
-
const s = a.items.filter((i) =>
|
|
523
|
+
const ut = (t) => !l.search || t.toLowerCase().includes(l.search.toLowerCase());
|
|
524
|
+
function Oe(t) {
|
|
525
|
+
const e = new Set(t.state.faults), n = Lt(t).map((a) => {
|
|
526
|
+
const s = a.items.filter((i) => ut(`${i.label} ${i.hint ?? ""} ${i.id}`));
|
|
527
527
|
return s.length ? `<div><div class="group-title">${d(a.title)}</div>${s.map((i) => `
|
|
528
528
|
<label class="row"><span class="text">${d(i.label)}${i.hint ? `<small>${d(i.hint)}</small>` : ""}</span>
|
|
529
529
|
<input class="switch" type="checkbox" role="switch" data-fault="${d(i.id)}" ${e.has(i.id) ? "checked" : ""}
|
|
530
530
|
aria-label="${d(i.label)}"></label>`).join("")}</div>` : "";
|
|
531
|
-
}).join(""), o = t.state.rules.filter((a) =>
|
|
531
|
+
}).join(""), o = t.state.rules.filter((a) => ut(`${a.method ?? ""} ${a.path} ${a.status}`)), r = (a) => {
|
|
532
532
|
var s;
|
|
533
|
-
return ((s =
|
|
533
|
+
return ((s = Q.find(([i]) => i === (a ?? ""))) == null ? void 0 : s[1]) ?? a;
|
|
534
534
|
};
|
|
535
535
|
return `
|
|
536
536
|
<input class="search" type="search" data-search placeholder="Поиск: 503, офлайн, роли…" aria-label="Поиск по сценариям" value="${d(l.search)}">
|
|
@@ -541,20 +541,20 @@ function Re(t) {
|
|
|
541
541
|
aria-label="${d(`${a.path} → ${a.status}`)}">
|
|
542
542
|
<button class="remove" type="button" data-remove="${d(a.id)}" aria-label="Удалить правило">×</button></div>`).join("")}
|
|
543
543
|
<form class="add" data-add>
|
|
544
|
-
<select name="method" aria-label="Метод">${
|
|
544
|
+
<select name="method" aria-label="Метод">${Q.map(([a, s]) => `<option value="${a}">${s}</option>`).join("")}</select>
|
|
545
545
|
<input name="path" required placeholder="/assets/*" aria-label="Путь после ${d(t.config.apiBase ?? "адреса сайта")}">
|
|
546
|
-
<select name="status" aria-label="Код ответа">${
|
|
546
|
+
<select name="status" aria-label="Код ответа">${Ae.map((a) => `<option${a === 503 ? " selected" : ""}>${a}</option>`).join("")}</select>
|
|
547
547
|
<button class="btn primary" type="submit">Добавить</button>
|
|
548
548
|
</form>
|
|
549
549
|
</div>`;
|
|
550
550
|
}
|
|
551
|
-
function
|
|
551
|
+
function Ie() {
|
|
552
552
|
const t = document.documentElement.getAttribute("data-u-viewport");
|
|
553
553
|
return t || (window.matchMedia("(max-width: 576px)").matches ? "mobile" : window.matchMedia("(max-width: 900px)").matches ? "tablet" : "desktop");
|
|
554
554
|
}
|
|
555
|
-
function
|
|
555
|
+
function qe(t) {
|
|
556
556
|
var i, f, u;
|
|
557
|
-
const e = document.documentElement, n = getComputedStyle(e).getPropertyValue("--u-unit").trim(), o = t.kit ??
|
|
557
|
+
const e = document.documentElement, n = getComputedStyle(e).getPropertyValue("--u-unit").trim(), o = t.kit ?? Vt();
|
|
558
558
|
let r = "—";
|
|
559
559
|
try {
|
|
560
560
|
const p = (f = (i = t.config).user) == null ? void 0 : f.call(i);
|
|
@@ -562,9 +562,9 @@ function Ie(t) {
|
|
|
562
562
|
} catch {
|
|
563
563
|
r = "не удалось прочитать";
|
|
564
564
|
}
|
|
565
|
-
const a =
|
|
565
|
+
const a = Tt(t);
|
|
566
566
|
return `<dl>${[
|
|
567
|
-
["Ширина", `${window.innerWidth} px · ${
|
|
567
|
+
["Ширина", `${window.innerWidth} px · ${Ie()}`],
|
|
568
568
|
["Шкала", `${e.getAttribute("data-u-responsive") ?? "legacy"}${n ? ` · --u-unit ${n}` : ""}`],
|
|
569
569
|
["Кит", o ? `${o.name} ${o.version}` : "—"],
|
|
570
570
|
["Сервис", [t.config.service, t.config.version].filter(Boolean).join(" ")],
|
|
@@ -574,104 +574,104 @@ function Ie(t) {
|
|
|
574
574
|
["Сеть", navigator.onLine ? "онлайн" : "офлайн"],
|
|
575
575
|
["Пользователь", r],
|
|
576
576
|
["Включено", a.length ? a.join("; ") : "ничего"]
|
|
577
|
-
].map(([p,
|
|
577
|
+
].map(([p, w]) => `<dt>${d(p)}</dt><dd>${d(w)}</dd>`).join("")}</dl>`;
|
|
578
578
|
}
|
|
579
|
-
function
|
|
579
|
+
function v() {
|
|
580
580
|
if (!c) return;
|
|
581
|
-
const t =
|
|
581
|
+
const t = P();
|
|
582
582
|
if (!t) {
|
|
583
583
|
c.innerHTML = "";
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
|
-
const e =
|
|
586
|
+
const e = m().flatMap(Tt), n = e.length, o = n ? `Dev · ${n === 1 ? e[0] : `${n} ${Re(n, "сбой", "сбоя", "сбоев")}`}` : "Dev", r = m(), a = r.every((g) => ae(g) === "hidden"), s = !a || n > 0, i = r.length > 1 ? `<select data-service aria-label="Сервис">${r.map((g) => `<option value="${d(g.config.service)}"${g === t ? " selected" : ""}>Dev · ${d(g.config.service)}</option>`).join("")}</select>` : `Dev · ${d(t.config.service)}`, f = l.open ? `
|
|
587
587
|
<section class="panel${s ? "" : " alone"}" role="region" aria-label="Панель разработки">
|
|
588
588
|
<div class="head"><span class="title">${i}</span>
|
|
589
589
|
<button class="reset" type="button" data-reset>Сбросить всё</button>
|
|
590
590
|
<button class="close" type="button" data-close aria-label="Свернуть панель">×</button></div>
|
|
591
591
|
<div class="escape">Без панели: адрес с ?dev=off · открыть и закрыть: Ctrl+Alt+D</div>
|
|
592
592
|
<div class="tabs" role="tablist">
|
|
593
|
-
<button class="tab" type="button" role="tab" data-tab="faults" aria-selected="${l.tab === "faults"}">Сбои${
|
|
593
|
+
<button class="tab" type="button" role="tab" data-tab="faults" aria-selected="${l.tab === "faults"}">Сбои${z(t) ? ` · ${z(t)}` : ""}</button>
|
|
594
594
|
<button class="tab" type="button" role="tab" data-tab="requests" aria-selected="${l.tab === "requests"}">Запросы</button>
|
|
595
595
|
<button class="tab" type="button" role="tab" data-tab="errors" aria-selected="${l.tab === "errors"}">Ошибки${Z().length ? ` · ${Z().length}` : ""}</button>
|
|
596
596
|
<button class="tab" type="button" role="tab" data-tab="view" aria-selected="${l.tab === "view"}">Смотреть</button>
|
|
597
597
|
</div>
|
|
598
|
-
<div class="body">${l.tab === "faults" ?
|
|
598
|
+
<div class="body">${l.tab === "faults" ? Oe(t) : l.tab === "requests" ? Mt(t) : l.tab === "errors" ? Ue() : qe(t)}</div>
|
|
599
599
|
${l.hint ? `<div class="note" role="status">${d(l.hint)}</div>` : ""}
|
|
600
600
|
<div class="foot">
|
|
601
601
|
${t.config.onRefetch ? '<button class="btn" type="button" data-refetch>Перезапросить данные</button>' : ""}
|
|
602
602
|
<button class="btn" type="button" data-reload>Перезагрузить</button>
|
|
603
|
-
${r.some((
|
|
603
|
+
${r.some((g) => g.state.faults.length) ? '<button class="btn" type="button" data-share>Ссылка на сбои</button>' : ""}
|
|
604
604
|
<button class="btn" type="button" data-launcher="${a ? "visible" : "hidden"}">${a ? "Показывать кнопку" : "Скрыть кнопку"}</button>
|
|
605
605
|
</div>
|
|
606
|
-
</section>` : "", u = c.activeElement, p =
|
|
607
|
-
|
|
608
|
-
const
|
|
606
|
+
</section>` : "", u = c.activeElement, p = At(u), w = (u == null ? void 0 : u.dataset.search) !== void 0 ? u.selectionStart : null, It = et ?? We();
|
|
607
|
+
et = null;
|
|
608
|
+
const qt = [
|
|
609
609
|
e.length ? `Включено: ${e.join(", ")}` : "Панель разработки (Ctrl+Alt+D)",
|
|
610
610
|
a ? "Кнопка скрыта и видна, пока включены сбои" : ""
|
|
611
|
-
].filter(Boolean).join(". "),
|
|
611
|
+
].filter(Boolean).join(". "), zt = s ? `
|
|
612
612
|
<button class="pill${n ? " on" : ""}" type="button" data-toggle aria-expanded="${l.open}"
|
|
613
|
-
title="${d(
|
|
614
|
-
if (c.innerHTML = `<style>${
|
|
615
|
-
const
|
|
616
|
-
|
|
613
|
+
title="${d(qt)}"><span class="logo">${Ce}</span><span class="label">${d(o)}</span></button>` : "", Ft = l.hint && !l.open ? `<div class="hint" role="status">${d(l.hint)}</div>` : "";
|
|
614
|
+
if (c.innerHTML = `<style>${Me}</style><div class="root">${f}${zt}${Ft}</div>`, Be(It), p) {
|
|
615
|
+
const g = c.querySelector(p);
|
|
616
|
+
g == null || g.focus(), g instanceof HTMLInputElement && w !== null && g.setSelectionRange(w, w);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
const
|
|
620
|
-
function
|
|
619
|
+
const ze = ["search", "fault", "rule", "tab", "service", "reset", "close", "toggle", "ruleFrom", "clearJournal"];
|
|
620
|
+
function At(t) {
|
|
621
621
|
if (!t) return null;
|
|
622
622
|
const e = t.getAttribute("name");
|
|
623
623
|
if (e && t.closest("[data-add]")) return `[data-add] [name="${e}"]`;
|
|
624
|
-
const n =
|
|
624
|
+
const n = ze.find((a) => t.dataset[a] !== void 0);
|
|
625
625
|
if (!n) return null;
|
|
626
626
|
const o = t.dataset[n], r = `data-${n.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`)}`;
|
|
627
627
|
return o ? `[${r}="${o.replace(/["\\]/g, "\\$&")}"]` : `[${r}]`;
|
|
628
628
|
}
|
|
629
|
-
const
|
|
630
|
-
let
|
|
631
|
-
const
|
|
632
|
-
function
|
|
633
|
-
const e =
|
|
629
|
+
const Ct = ["method", "path", "status"];
|
|
630
|
+
let et = null;
|
|
631
|
+
const Fe = { network: "сеть", abort: "отмена", pending: "…" };
|
|
632
|
+
function Mt(t) {
|
|
633
|
+
const e = nt().filter((n) => n.service === t.config.service);
|
|
634
634
|
return e.length ? `<div class="requests-head"><span>Последние ${e.length}, новые сверху</span>
|
|
635
635
|
<button class="btn" type="button" data-clear-journal>Очистить</button></div>
|
|
636
636
|
<div class="requests">${e.map((n) => {
|
|
637
|
-
const o = typeof n.status == "number" ? String(n.status) :
|
|
637
|
+
const o = typeof n.status == "number" ? String(n.status) : Fe[n.status], r = n.status === "network" || typeof n.status == "number" && n.status >= 400, a = [n.duration === null ? "" : `${n.duration} мс`, n.faked ? "подменён панелью" : ""].filter(Boolean).join(" · ");
|
|
638
638
|
return `<div class="req"><span>${d(n.method)}</span>
|
|
639
639
|
<span class="path">${d(n.path)}${a ? `<small>${d(a)}</small>` : ""}</span>
|
|
640
640
|
<span class="status${r ? " bad" : ""}">${d(o)}</span>
|
|
641
641
|
<button class="btn" type="button" data-rule-from="${n.id}" title="Ответ на этот адрес — в «Ответах сервера»">Правило</button></div>`;
|
|
642
642
|
}).join("")}</div>` : '<div class="empty">Запросов к API пока не было. Журнал помнит последние 50 и очищается при перезагрузке.</div>';
|
|
643
643
|
}
|
|
644
|
-
const
|
|
644
|
+
const He = {
|
|
645
645
|
screen: "Заглушка",
|
|
646
646
|
fail: "Уведомление об ошибке",
|
|
647
647
|
warning: "Предупреждение",
|
|
648
648
|
offline: "Нет связи"
|
|
649
|
-
},
|
|
650
|
-
function
|
|
649
|
+
}, je = (t) => He[t.kind === "notification" ? t.variant ?? "fail" : t.kind];
|
|
650
|
+
function Ue() {
|
|
651
651
|
const t = Z();
|
|
652
652
|
return t.length ? `<div class="requests-head"><span>Последние ${t.length}, новые сверху</span>
|
|
653
653
|
<button class="btn" type="button" data-clear-shown>Очистить</button></div>
|
|
654
654
|
<div>${t.map((e) => `<div class="shown">
|
|
655
|
-
<div class="shown-head"><span class="kind${e.variant === "warning" ? " warning" : ""}">${d(
|
|
655
|
+
<div class="shown-head"><span class="kind${e.variant === "warning" ? " warning" : ""}">${d(je(e))}${e.code ? ` · ${d(e.code)}` : ""}</span>
|
|
656
656
|
<time>${d(new Date(e.at).toLocaleTimeString("ru-RU"))}</time></div>
|
|
657
657
|
<div class="shown-title">${d(e.title)}</div>
|
|
658
658
|
${e.text ? `<small>${d(e.text)}</small>` : ""}
|
|
659
659
|
<div class="cause">${e.cause ? `← ${d(e.cause)}` : "<small>Неудачных запросов к API перед показом не было</small>"}</div>
|
|
660
660
|
</div>`).join("")}</div>` : '<div class="empty">Ошибок пользователю пока не показывали. Здесь появятся заглушки, уведомления об ошибке и полоса «Нет связи» — с причиной из запросов к API.</div>';
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function Ne(t) {
|
|
663
663
|
var o;
|
|
664
|
-
const e =
|
|
664
|
+
const e = nt().find((r) => String(r.id) === String(t));
|
|
665
665
|
if (!e) return;
|
|
666
|
-
|
|
666
|
+
et = { method: Q.some(([r]) => r === e.method) ? e.method : "", path: e.path, status: "503" }, l.tab = "faults", l.search = "", v(), (o = c == null ? void 0 : c.querySelector('[data-add] [name="status"]')) == null || o.focus();
|
|
667
667
|
}
|
|
668
|
-
function
|
|
669
|
-
const t = [...new Set(
|
|
668
|
+
function _e() {
|
|
669
|
+
const t = [...new Set(m().flatMap((i) => i.state.faults))], e = new URL(window.location.href);
|
|
670
670
|
e.searchParams.set("dev", t.join(","));
|
|
671
|
-
const n = e.href.replace(/%2C/gi, ","), r =
|
|
672
|
-
|
|
671
|
+
const n = e.href.replace(/%2C/gi, ","), r = m().some((i) => i.state.rules.some((f) => f.enabled)) ? " Свои правила «адрес → код» в неё не входят." : "", a = () => {
|
|
672
|
+
C(`Ссылка скопирована.${r}`), v();
|
|
673
673
|
}, s = () => {
|
|
674
|
-
|
|
674
|
+
C(`Ссылка: ${n}${r}`), v();
|
|
675
675
|
};
|
|
676
676
|
try {
|
|
677
677
|
navigator.clipboard.writeText(n).then(a, s);
|
|
@@ -679,101 +679,101 @@ function Ne() {
|
|
|
679
679
|
s();
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
|
-
function
|
|
682
|
+
function We() {
|
|
683
683
|
const t = c == null ? void 0 : c.querySelector("[data-add]");
|
|
684
|
-
return t ? Object.fromEntries(
|
|
684
|
+
return t ? Object.fromEntries(Ct.map((e) => {
|
|
685
685
|
var n;
|
|
686
686
|
return [e, ((n = t.elements.namedItem(e)) == null ? void 0 : n.value) ?? ""];
|
|
687
687
|
})) : null;
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function Be(t) {
|
|
690
690
|
const e = c == null ? void 0 : c.querySelector("[data-add]");
|
|
691
|
-
!e || !t ||
|
|
691
|
+
!e || !t || Ct.forEach((n) => {
|
|
692
692
|
const o = e.elements.namedItem(n);
|
|
693
693
|
o && (o.value = t[n]);
|
|
694
694
|
});
|
|
695
695
|
}
|
|
696
|
-
function
|
|
696
|
+
function Ke(t) {
|
|
697
697
|
if (!t) {
|
|
698
|
-
|
|
698
|
+
C(""), at("visible");
|
|
699
699
|
return;
|
|
700
700
|
}
|
|
701
701
|
l.open = !1;
|
|
702
|
-
const e =
|
|
703
|
-
|
|
702
|
+
const e = m().some((n) => z(n) > 0);
|
|
703
|
+
C(`Кнопка Dev скрыта${e ? " и видна, пока включены сбои" : ""}. Панель: Ctrl+Alt+D`), at("hidden");
|
|
704
704
|
}
|
|
705
|
-
function
|
|
706
|
-
clearTimeout(
|
|
707
|
-
l.hint = "",
|
|
708
|
-
},
|
|
705
|
+
function C(t) {
|
|
706
|
+
clearTimeout(tt), l.hint = t, t && (tt = setTimeout(() => {
|
|
707
|
+
l.hint = "", v();
|
|
708
|
+
}, De));
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function U(t = !l.open) {
|
|
711
711
|
var e, n;
|
|
712
|
-
t &&
|
|
712
|
+
t && C(""), l.open = t, v(), t ? (e = c == null ? void 0 : c.querySelector("[data-search], [data-tab]")) == null || e.focus() : (n = c == null ? void 0 : c.querySelector("[data-toggle]")) == null || n.focus();
|
|
713
713
|
}
|
|
714
|
-
function
|
|
714
|
+
function Je(t) {
|
|
715
715
|
var o, r, a, s;
|
|
716
|
-
const e = t.target, n =
|
|
716
|
+
const e = t.target, n = P();
|
|
717
717
|
if (n)
|
|
718
|
-
if (e.closest("[data-toggle]"))
|
|
719
|
-
else if (e.closest("[data-close]"))
|
|
718
|
+
if (e.closest("[data-toggle]")) U();
|
|
719
|
+
else if (e.closest("[data-close]")) U(!1);
|
|
720
720
|
else if (e.closest("[data-reset]"))
|
|
721
|
-
|
|
721
|
+
St(), (r = (o = n.config).onRefetch) == null || r.call(o);
|
|
722
722
|
else if (e.closest("[data-reload]")) window.location.reload();
|
|
723
|
-
else if (e.closest("[data-rule-from]"))
|
|
723
|
+
else if (e.closest("[data-rule-from]")) Ne(Number(e.closest("[data-rule-from]").dataset.ruleFrom));
|
|
724
724
|
else if (e.closest("[data-clear-journal]"))
|
|
725
|
-
|
|
726
|
-
else if (e.closest("[data-clear-shown]"))
|
|
727
|
-
else if (e.closest("[data-share]"))
|
|
728
|
-
else if (e.closest("[data-launcher]"))
|
|
725
|
+
ft(), v();
|
|
726
|
+
else if (e.closest("[data-clear-shown]")) vt();
|
|
727
|
+
else if (e.closest("[data-share]")) _e();
|
|
728
|
+
else if (e.closest("[data-launcher]")) Ke(e.closest("[data-launcher]").dataset.launcher === "hidden");
|
|
729
729
|
else if (e.closest("[data-refetch]")) (s = (a = n.config).onRefetch) == null || s.call(a);
|
|
730
730
|
else if (e.closest("[data-tab]")) {
|
|
731
731
|
const i = e.closest("[data-tab]").dataset.tab;
|
|
732
|
-
l.tab = i === "view" || i === "requests" || i === "errors" ? i : "faults",
|
|
733
|
-
} else e.closest("[data-remove]") &&
|
|
732
|
+
l.tab = i === "view" || i === "requests" || i === "errors" ? i : "faults", v();
|
|
733
|
+
} else e.closest("[data-remove]") && ne(n, e.closest("[data-remove]").dataset.remove);
|
|
734
734
|
}
|
|
735
|
-
function
|
|
736
|
-
const e = t.target, n =
|
|
735
|
+
function Xe(t) {
|
|
736
|
+
const e = t.target, n = P();
|
|
737
737
|
if (n)
|
|
738
738
|
if (e.dataset.fault) {
|
|
739
739
|
const o = e.checked;
|
|
740
|
-
|
|
741
|
-
} else e.dataset.rule ?
|
|
740
|
+
Qt(n, e.dataset.fault, o), e.dataset.fault === "offline" && ot(!o);
|
|
741
|
+
} else e.dataset.rule ? ee(n, e.dataset.rule, e.checked) : e.dataset.service !== void 0 && (l.service = e.value, v());
|
|
742
742
|
}
|
|
743
|
-
function
|
|
743
|
+
function Ve(t) {
|
|
744
744
|
const e = t.target;
|
|
745
|
-
e.dataset.search !== void 0 && (l.search = e.value,
|
|
745
|
+
e.dataset.search !== void 0 && (l.search = e.value, v());
|
|
746
746
|
}
|
|
747
747
|
function Ze(t) {
|
|
748
748
|
const e = t.target;
|
|
749
749
|
if (e.dataset.add === void 0) return;
|
|
750
750
|
t.preventDefault();
|
|
751
|
-
const n =
|
|
752
|
-
!n || !r || (e.reset(),
|
|
751
|
+
const n = P(), o = new FormData(e), r = String(o.get("path") ?? "").trim();
|
|
752
|
+
!n || !r || (e.reset(), te(n, {
|
|
753
753
|
method: String(o.get("method") ?? "") || void 0,
|
|
754
754
|
path: r.startsWith("/") ? r : `/${r}`,
|
|
755
755
|
status: Number(o.get("status")) || 500,
|
|
756
756
|
html: Number(o.get("status")) === 502 || void 0
|
|
757
757
|
}));
|
|
758
758
|
}
|
|
759
|
-
function
|
|
760
|
-
t.ctrlKey && t.altKey && t.code === "KeyD" ? (t.preventDefault(),
|
|
759
|
+
function Dt(t) {
|
|
760
|
+
t.ctrlKey && t.altKey && t.code === "KeyD" ? (t.preventDefault(), U()) : t.key === "Escape" && l.open && h && t.composedPath().includes(h) && (t.preventDefault(), t.stopPropagation(), U(!1));
|
|
761
761
|
}
|
|
762
|
-
function
|
|
762
|
+
function Ge() {
|
|
763
763
|
if (h || typeof document > "u") return;
|
|
764
|
-
h = document.createElement("div"), h.id = "urfu-ui-kit-dev", h.setAttribute("data-urfu-ui-kit-dev", ""), c = h.attachShadow({ mode: "open" }), c.addEventListener("click",
|
|
765
|
-
(!(h != null && h.isConnected) || o.some((r) => r.type === "attributes")) &&
|
|
766
|
-
}),
|
|
767
|
-
const t =
|
|
768
|
-
c.addEventListener("pointerdown",
|
|
769
|
-
const n =
|
|
770
|
-
l.open &&
|
|
764
|
+
h = document.createElement("div"), h.id = "urfu-ui-kit-dev", h.setAttribute("data-urfu-ui-kit-dev", ""), c = h.attachShadow({ mode: "open" }), c.addEventListener("click", Je), c.addEventListener("change", Xe), c.addEventListener("input", Ve), c.addEventListener("submit", Ze), b = document.defaultView ?? window, b.addEventListener("keydown", Dt, !0), dt(), k = new MutationObserver((o) => {
|
|
765
|
+
(!(h != null && h.isConnected) || o.some((r) => r.type === "attributes")) && dt();
|
|
766
|
+
}), k.observe(document.documentElement, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["open"] }), l.open = m().some((o) => z(o) > 0);
|
|
767
|
+
const t = gt(v), e = Nt(Pt);
|
|
768
|
+
c.addEventListener("pointerdown", Qe), b.addEventListener("pointerup", N, !0), b.addEventListener("pointercancel", N, !0);
|
|
769
|
+
const n = pe(() => {
|
|
770
|
+
l.open && v();
|
|
771
771
|
});
|
|
772
|
-
|
|
773
|
-
t(), e(), n(),
|
|
774
|
-
},
|
|
772
|
+
de(), S = () => {
|
|
773
|
+
t(), e(), n(), fe();
|
|
774
|
+
}, v();
|
|
775
775
|
}
|
|
776
|
-
function
|
|
776
|
+
function Ye() {
|
|
777
777
|
try {
|
|
778
778
|
const t = document.querySelectorAll("dialog:modal");
|
|
779
779
|
return t[t.length - 1] ?? null;
|
|
@@ -781,94 +781,94 @@ function Ge() {
|
|
|
781
781
|
return null;
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function dt() {
|
|
785
785
|
if (!h) return;
|
|
786
|
-
const t =
|
|
786
|
+
const t = Ye() ?? document.documentElement;
|
|
787
787
|
h.parentNode !== t && t.appendChild(h);
|
|
788
788
|
}
|
|
789
|
-
function
|
|
789
|
+
function Pt() {
|
|
790
790
|
var r;
|
|
791
791
|
if (!l.open || l.tab !== "requests") {
|
|
792
|
-
|
|
792
|
+
E = !1;
|
|
793
793
|
return;
|
|
794
794
|
}
|
|
795
|
-
if (
|
|
796
|
-
|
|
795
|
+
if (A) {
|
|
796
|
+
E = !0;
|
|
797
797
|
return;
|
|
798
798
|
}
|
|
799
|
-
|
|
800
|
-
const t = c == null ? void 0 : c.querySelector(".body"), e =
|
|
799
|
+
E = !1;
|
|
800
|
+
const t = c == null ? void 0 : c.querySelector(".body"), e = P();
|
|
801
801
|
if (!c || !t || !e) {
|
|
802
|
-
|
|
802
|
+
v();
|
|
803
803
|
return;
|
|
804
804
|
}
|
|
805
|
-
const n = c.activeElement, o = n && t.contains(n) ?
|
|
806
|
-
t.innerHTML =
|
|
805
|
+
const n = c.activeElement, o = n && t.contains(n) ? At(n) : null;
|
|
806
|
+
t.innerHTML = Mt(e), o && ((r = t.querySelector(o)) == null || r.focus());
|
|
807
807
|
}
|
|
808
|
-
function
|
|
809
|
-
|
|
808
|
+
function Qe() {
|
|
809
|
+
A = !0;
|
|
810
810
|
}
|
|
811
|
-
function
|
|
812
|
-
|
|
811
|
+
function N() {
|
|
812
|
+
A && (A = !1, E && setTimeout(Pt, 0));
|
|
813
813
|
}
|
|
814
|
-
function
|
|
815
|
-
|
|
814
|
+
function tn() {
|
|
815
|
+
S == null || S(), S = null, k == null || k.disconnect(), k = null, b == null || b.removeEventListener("keydown", Dt, !0), b == null || b.removeEventListener("pointerup", N, !0), b == null || b.removeEventListener("pointercancel", N, !0), b = null, A = !1, E = !1, clearTimeout(tt), h == null || h.remove(), h = null, c = null, Object.assign(l, Et);
|
|
816
816
|
}
|
|
817
|
-
const
|
|
817
|
+
const Rt = Symbol.for("urfu-ui-kit.dev-panel"), M = {
|
|
818
818
|
version: 1,
|
|
819
819
|
mount(t, e, n) {
|
|
820
|
-
return
|
|
821
|
-
|
|
820
|
+
return Wt(), Xt(e), Zt(t, e).state.faults.includes("offline") && ot(!1), ye(n), Ge(), () => {
|
|
821
|
+
Gt(t.service), m().length || tn();
|
|
822
822
|
};
|
|
823
823
|
},
|
|
824
824
|
isFault: (t, e) => {
|
|
825
825
|
var n;
|
|
826
|
-
return ((n =
|
|
826
|
+
return ((n = Yt(e)) == null ? void 0 : n.state.faults.includes(t)) ?? !1;
|
|
827
827
|
},
|
|
828
|
-
subscribe:
|
|
829
|
-
reset:
|
|
830
|
-
},
|
|
831
|
-
function
|
|
828
|
+
subscribe: gt,
|
|
829
|
+
reset: St
|
|
830
|
+
}, Ot = () => typeof document > "u" ? null : document.defaultView;
|
|
831
|
+
function B() {
|
|
832
832
|
var e;
|
|
833
|
-
const t = (e =
|
|
833
|
+
const t = (e = Ot()) == null ? void 0 : e[Rt];
|
|
834
834
|
return t && typeof t.version == "number" && t.version >= 1 ? t : null;
|
|
835
835
|
}
|
|
836
|
-
function
|
|
837
|
-
const t =
|
|
836
|
+
function en() {
|
|
837
|
+
const t = B();
|
|
838
838
|
if (t) return t;
|
|
839
|
-
const e =
|
|
840
|
-
return e && (e[
|
|
839
|
+
const e = Ot();
|
|
840
|
+
return e && (e[Rt] = M), M;
|
|
841
841
|
}
|
|
842
|
-
function
|
|
842
|
+
function nn(t, e) {
|
|
843
843
|
return typeof window > "u" ? () => {
|
|
844
|
-
} :
|
|
844
|
+
} : en().mount(t, e, window);
|
|
845
845
|
}
|
|
846
|
-
function
|
|
847
|
-
return (
|
|
846
|
+
function on(t, e) {
|
|
847
|
+
return (B() ?? M).isFault(t, e);
|
|
848
848
|
}
|
|
849
|
-
function
|
|
850
|
-
return (
|
|
849
|
+
function an(t) {
|
|
850
|
+
return (B() ?? M).subscribe(t);
|
|
851
851
|
}
|
|
852
|
-
function
|
|
853
|
-
(
|
|
852
|
+
function cn() {
|
|
853
|
+
(B() ?? M).reset();
|
|
854
854
|
}
|
|
855
|
-
const
|
|
856
|
-
function
|
|
857
|
-
return
|
|
855
|
+
const rn = () => "2.1.3";
|
|
856
|
+
function un(t) {
|
|
857
|
+
return nn(t, { name: "urfu-ui-kit-react", version: rn() });
|
|
858
858
|
}
|
|
859
|
-
function
|
|
860
|
-
return
|
|
859
|
+
function sn(t, e) {
|
|
860
|
+
return Ht(an, () => on(t, e), () => !1);
|
|
861
861
|
}
|
|
862
|
-
function
|
|
863
|
-
if (
|
|
862
|
+
function dn({ scope: t, service: e }) {
|
|
863
|
+
if (sn(t === "app" ? "crashApp" : "crashPage", e)) throw new Error(`Сбой из dev-панели: падение ${t === "app" ? "приложения" : "страницы"}`);
|
|
864
864
|
return null;
|
|
865
865
|
}
|
|
866
866
|
export {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
867
|
+
dn as DevCrashProbe,
|
|
868
|
+
on as isDevFault,
|
|
869
|
+
ge as matchPath,
|
|
870
|
+
un as mountDevPanel,
|
|
871
|
+
cn as resetDevFaults,
|
|
872
|
+
an as subscribeDevFaults,
|
|
873
|
+
sn as useDevFault
|
|
874
874
|
};
|