kosmio 0.1.0
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 +37 -0
- package/dist/KosmioThemeProvider-DzH5uTqT.js +145 -0
- package/dist/LanguageContext-DlN7MgUs.js +161 -0
- package/dist/MobileRouteTransition-C16D4K5c.js +124 -0
- package/dist/NativeBackButtonHandler-CcLHewdm.js +105 -0
- package/dist/OfflineSyncContext-CRwPM5kh.js +34 -0
- package/dist/ViewportContext-z-ZwlTIZ.js +214 -0
- package/dist/app.js +123 -0
- package/dist/classNames-CcykAxZN.js +6 -0
- package/dist/context.js +16 -0
- package/dist/core.js +55 -0
- package/dist/formRegistry-Lvs6aL14.js +3468 -0
- package/dist/i18n.js +9 -0
- package/dist/index.js +185 -0
- package/dist/localizedRouter-BjT5yIzl.js +721 -0
- package/dist/offlineWriteQueue-C31IjyB_.js +275 -0
- package/dist/permissions.js +181 -0
- package/dist/platform.js +11 -0
- package/dist/queryClient-ZtNrT-lA.js +27 -0
- package/dist/shortcuts-n31uRPcv.js +147 -0
- package/dist/styles.css +1 -0
- package/dist/styles.js +1 -0
- package/dist/systemBars-C3QiEL7z.js +136 -0
- package/dist/theme.js +8 -0
- package/dist/ui.js +88 -0
- package/package.json +84 -0
- package/types/app.d.ts +98 -0
- package/types/context.d.ts +110 -0
- package/types/core.d.ts +210 -0
- package/types/global.d.ts +1 -0
- package/types/i18n.d.ts +79 -0
- package/types/index.d.ts +8 -0
- package/types/permissions.d.ts +61 -0
- package/types/platform.d.ts +71 -0
- package/types/theme.d.ts +67 -0
- package/types/ui.d.ts +875 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
let K = "kosmio:offline-write-queue:v1";
|
|
2
|
+
const g = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Map(), W = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
3
|
+
let A = !1, d = !1, y = !1, c = null, S = 1500, T = async () => "anonymous:no-tenant", v = null, h = null;
|
|
4
|
+
function L() {
|
|
5
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
6
|
+
}
|
|
7
|
+
function N() {
|
|
8
|
+
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
9
|
+
}
|
|
10
|
+
function b(e) {
|
|
11
|
+
return encodeURIComponent(String(e ?? "").trim() || "default");
|
|
12
|
+
}
|
|
13
|
+
function m(e) {
|
|
14
|
+
return String(e ?? "").trim().toUpperCase();
|
|
15
|
+
}
|
|
16
|
+
function k(e) {
|
|
17
|
+
if (!e) return;
|
|
18
|
+
const n = typeof e.toJSON == "function" ? e.toJSON() : e;
|
|
19
|
+
if (!n || typeof n != "object") return;
|
|
20
|
+
const t = {};
|
|
21
|
+
for (const [r, u] of Object.entries(n))
|
|
22
|
+
(u == null || ["string", "number", "boolean"].includes(typeof u)) && (t[r] = u);
|
|
23
|
+
return Object.keys(t).length ? t : void 0;
|
|
24
|
+
}
|
|
25
|
+
function B(e = {}) {
|
|
26
|
+
const n = {}, t = k(e.headers);
|
|
27
|
+
t && (n.headers = t);
|
|
28
|
+
for (const r of ["timeout", "withCredentials", "responseType", "skipAuthRefresh"])
|
|
29
|
+
e[r] !== void 0 && (n[r] = e[r]);
|
|
30
|
+
return n;
|
|
31
|
+
}
|
|
32
|
+
function D(e) {
|
|
33
|
+
return ["POST", "PUT", "PATCH"].includes(m(e));
|
|
34
|
+
}
|
|
35
|
+
function H(e) {
|
|
36
|
+
return e?.offlineQueue === !1;
|
|
37
|
+
}
|
|
38
|
+
function E(e) {
|
|
39
|
+
return e ? e.response ? !1 : typeof navigator < "u" && navigator.onLine === !1 ? !0 : ["ERR_NETWORK", "ECONNABORTED"].includes(String(e.code ?? "")) : !1;
|
|
40
|
+
}
|
|
41
|
+
function $(e) {
|
|
42
|
+
return W.has(Number(e));
|
|
43
|
+
}
|
|
44
|
+
function _(e, n) {
|
|
45
|
+
return `${K}:${b(e)}:${b(n)}`;
|
|
46
|
+
}
|
|
47
|
+
function C(e) {
|
|
48
|
+
const n = q.get(e);
|
|
49
|
+
return Array.isArray(n) ? n : [];
|
|
50
|
+
}
|
|
51
|
+
function x(e, n) {
|
|
52
|
+
q.set(e, Array.isArray(n) ? n : []);
|
|
53
|
+
}
|
|
54
|
+
function Q(e) {
|
|
55
|
+
if (typeof window > "u") return C(e);
|
|
56
|
+
try {
|
|
57
|
+
const n = window.localStorage.getItem(e);
|
|
58
|
+
if (!n) return [];
|
|
59
|
+
const t = JSON.parse(n);
|
|
60
|
+
return Array.isArray(t) ? t : [];
|
|
61
|
+
} catch {
|
|
62
|
+
return C(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function f(e, n) {
|
|
66
|
+
const t = Array.isArray(n) ? n : [];
|
|
67
|
+
if (x(e, t), a(), typeof window > "u") return !0;
|
|
68
|
+
try {
|
|
69
|
+
return window.localStorage.setItem(e, JSON.stringify(t)), !0;
|
|
70
|
+
} catch {
|
|
71
|
+
return !1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function j(e) {
|
|
75
|
+
const n = String(e?.url ?? ""), t = m(e?.method);
|
|
76
|
+
if (!["POST", "PUT", "PATCH"].includes(t)) return null;
|
|
77
|
+
const r = n.match(/^(.*)\/(archive|unarchive)\/?$/i);
|
|
78
|
+
return r ? { archiveResourceKey: r[1], archiveAction: r[2].toLowerCase() } : null;
|
|
79
|
+
}
|
|
80
|
+
function z({ clientKey: e, scopeKey: n, requestConfig: t, reason: r }) {
|
|
81
|
+
const u = j(t);
|
|
82
|
+
return {
|
|
83
|
+
id: N(),
|
|
84
|
+
clientKey: e,
|
|
85
|
+
scopeKey: n,
|
|
86
|
+
createdAt: L(),
|
|
87
|
+
retryCount: 0,
|
|
88
|
+
reason: r,
|
|
89
|
+
request: {
|
|
90
|
+
method: m(t.method),
|
|
91
|
+
url: t.url,
|
|
92
|
+
data: t.data,
|
|
93
|
+
config: B(t)
|
|
94
|
+
},
|
|
95
|
+
archiveAction: u?.archiveAction ?? null,
|
|
96
|
+
archiveResourceKey: u?.archiveResourceKey ?? null
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function J(e, n) {
|
|
100
|
+
const t = Array.isArray(e) ? [...e] : [];
|
|
101
|
+
if (!n?.archiveResourceKey || !n?.archiveAction)
|
|
102
|
+
return t.push(n), { queue: t, queued: !0, canceled: !1 };
|
|
103
|
+
const u = t.filter((i) => i?.archiveResourceKey === n.archiveResourceKey).some(
|
|
104
|
+
(i) => i?.archiveAction && i.archiveAction !== n.archiveAction
|
|
105
|
+
), o = t.filter((i) => i?.archiveResourceKey !== n.archiveResourceKey);
|
|
106
|
+
return u ? { queue: o, queued: !1, canceled: !0 } : (o.push(n), { queue: o, queued: !0, canceled: !1 });
|
|
107
|
+
}
|
|
108
|
+
async function I() {
|
|
109
|
+
try {
|
|
110
|
+
return String(await T() || "anonymous:no-tenant");
|
|
111
|
+
} catch {
|
|
112
|
+
return "anonymous:no-tenant";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function w(e) {
|
|
116
|
+
return e?.queueKey ?? e?.ax?.defaults?.baseURL ?? "default";
|
|
117
|
+
}
|
|
118
|
+
function O(e, n) {
|
|
119
|
+
return _(w(e), n);
|
|
120
|
+
}
|
|
121
|
+
function F(e) {
|
|
122
|
+
if (!e) return 0;
|
|
123
|
+
let n = 0;
|
|
124
|
+
for (const t of g.values())
|
|
125
|
+
n += Q(O(t, e)).length;
|
|
126
|
+
return n;
|
|
127
|
+
}
|
|
128
|
+
function Y() {
|
|
129
|
+
return typeof navigator > "u" ? !0 : navigator.onLine !== !1;
|
|
130
|
+
}
|
|
131
|
+
function a() {
|
|
132
|
+
for (const e of p)
|
|
133
|
+
try {
|
|
134
|
+
e();
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function V(e) {
|
|
139
|
+
const n = String(e ?? "anonymous:no-tenant"), t = F(n), r = {
|
|
140
|
+
isOnline: Y(),
|
|
141
|
+
isSyncing: d,
|
|
142
|
+
pendingSyncCount: t,
|
|
143
|
+
hasPendingSync: t > 0
|
|
144
|
+
}, u = R.get(n);
|
|
145
|
+
return u && u.isOnline === r.isOnline && u.isSyncing === r.isSyncing && u.pendingSyncCount === r.pendingSyncCount && u.hasPendingSync === r.hasPendingSync ? u : (R.set(n, r), r);
|
|
146
|
+
}
|
|
147
|
+
function G() {
|
|
148
|
+
if (c) return;
|
|
149
|
+
c = setTimeout(() => {
|
|
150
|
+
c = null, s();
|
|
151
|
+
}, S), S = Math.min(S * 2, 6e4), a();
|
|
152
|
+
}
|
|
153
|
+
function X() {
|
|
154
|
+
S = 1500, c && (clearTimeout(c), c = null);
|
|
155
|
+
}
|
|
156
|
+
async function Z(e, n) {
|
|
157
|
+
const t = O(e, n), r = Q(t);
|
|
158
|
+
if (!r.length) return { applied: 0, retryScheduled: !1 };
|
|
159
|
+
let u = 0;
|
|
160
|
+
const o = [...r];
|
|
161
|
+
for (; o.length > 0; ) {
|
|
162
|
+
const i = o[0];
|
|
163
|
+
try {
|
|
164
|
+
if (!P(i.request)) {
|
|
165
|
+
o.shift(), f(t, o);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
await e.ax.request({
|
|
169
|
+
...i.request.config,
|
|
170
|
+
method: i.request.method,
|
|
171
|
+
url: i.request.url,
|
|
172
|
+
data: i.request.data
|
|
173
|
+
}), o.shift(), u += 1, f(t, o);
|
|
174
|
+
} catch (l) {
|
|
175
|
+
if (E(l) || $(l?.response?.status))
|
|
176
|
+
return i.retryCount = (i.retryCount ?? 0) + 1, f(t, o), G(), { applied: u, retryScheduled: !0 };
|
|
177
|
+
o.shift(), f(t, o);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return f(t, o), { applied: u, retryScheduled: !1 };
|
|
181
|
+
}
|
|
182
|
+
async function ee() {
|
|
183
|
+
const e = await I();
|
|
184
|
+
let n = 0;
|
|
185
|
+
for (const t of g.values()) {
|
|
186
|
+
const r = await Z(t, e);
|
|
187
|
+
if (n += r.applied, r.retryScheduled) break;
|
|
188
|
+
}
|
|
189
|
+
return n > 0 && typeof v == "function" && v(), a(), n;
|
|
190
|
+
}
|
|
191
|
+
async function ne() {
|
|
192
|
+
if (d) {
|
|
193
|
+
y = !0;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
d = !0, a();
|
|
197
|
+
try {
|
|
198
|
+
do
|
|
199
|
+
y = !1, await ee() > 0 && X();
|
|
200
|
+
while (y);
|
|
201
|
+
} finally {
|
|
202
|
+
d = !1, a();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function te() {
|
|
206
|
+
a(), s();
|
|
207
|
+
}
|
|
208
|
+
function re() {
|
|
209
|
+
a();
|
|
210
|
+
}
|
|
211
|
+
function ue() {
|
|
212
|
+
typeof document < "u" && document.visibilityState === "visible" && s();
|
|
213
|
+
}
|
|
214
|
+
function ie(e) {
|
|
215
|
+
e?.isActive && s();
|
|
216
|
+
}
|
|
217
|
+
function oe(e = {}) {
|
|
218
|
+
typeof e.storagePrefix == "string" && e.storagePrefix.trim() && (K = e.storagePrefix.trim()), typeof e.resolveScopeKey == "function" && (T = e.resolveScopeKey), typeof e.invalidateQueries == "function" && (v = e.invalidateQueries), e.appStateAdapter !== void 0 && (h = e.appStateAdapter);
|
|
219
|
+
}
|
|
220
|
+
function ae(e) {
|
|
221
|
+
if (!e) return e;
|
|
222
|
+
const n = w(e);
|
|
223
|
+
return e.queueKey = n, g.set(n, e), a(), e;
|
|
224
|
+
}
|
|
225
|
+
function fe(e) {
|
|
226
|
+
return ["queued", "canceled"].includes(String(e?.offlineQueueStatus ?? ""));
|
|
227
|
+
}
|
|
228
|
+
function ce(e) {
|
|
229
|
+
return String(e?.offlineQueueStatus ?? "") === "queued";
|
|
230
|
+
}
|
|
231
|
+
function se(e) {
|
|
232
|
+
return String(e?.offlineQueueStatus ?? "") === "canceled";
|
|
233
|
+
}
|
|
234
|
+
function P(e) {
|
|
235
|
+
return D(e?.method) && !H(e);
|
|
236
|
+
}
|
|
237
|
+
function le({ userId: e, tenantId: n } = {}) {
|
|
238
|
+
const t = String(e ?? "").trim() || "anonymous", r = String(n ?? "").trim() || "no-tenant";
|
|
239
|
+
return `${t}:${r}`;
|
|
240
|
+
}
|
|
241
|
+
function de(e) {
|
|
242
|
+
return V(e);
|
|
243
|
+
}
|
|
244
|
+
function ye(e) {
|
|
245
|
+
return typeof e != "function" ? () => {
|
|
246
|
+
} : (p.add(e), () => p.delete(e));
|
|
247
|
+
}
|
|
248
|
+
async function Se(e, n, t = "offline") {
|
|
249
|
+
const r = await I(), u = O(e, r), o = Q(u), i = z({ clientKey: w(e), scopeKey: r, requestConfig: n, reason: t }), { queue: l, queued: M, canceled: U } = J(o, i);
|
|
250
|
+
return f(u, l), s(), U ? { offlineQueueStatus: "canceled", offlineQueueReason: "archive_canceled", offlineQueueScope: r } : M ? { offlineQueueStatus: "queued", offlineQueueId: i.id, offlineQueueScope: r } : { offlineQueueStatus: "canceled", offlineQueueReason: "deduped", offlineQueueScope: r };
|
|
251
|
+
}
|
|
252
|
+
function he(e, n) {
|
|
253
|
+
return P(n) ? typeof navigator < "u" && navigator.onLine === !1 ? !0 : E(e) : !1;
|
|
254
|
+
}
|
|
255
|
+
function s() {
|
|
256
|
+
y = !0, ne();
|
|
257
|
+
}
|
|
258
|
+
function pe() {
|
|
259
|
+
A || typeof window > "u" || (A = !0, window.addEventListener("online", te), window.addEventListener("offline", re), typeof document < "u" && document.addEventListener("visibilitychange", ue), h && typeof h.addListener == "function" && h.addListener("appStateChange", ie), s());
|
|
260
|
+
}
|
|
261
|
+
export {
|
|
262
|
+
de as a,
|
|
263
|
+
fe as b,
|
|
264
|
+
oe as c,
|
|
265
|
+
ce as d,
|
|
266
|
+
Se as e,
|
|
267
|
+
P as f,
|
|
268
|
+
le as g,
|
|
269
|
+
s as h,
|
|
270
|
+
se as i,
|
|
271
|
+
pe as j,
|
|
272
|
+
ye as k,
|
|
273
|
+
ae as r,
|
|
274
|
+
he as s
|
|
275
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { useMemo as k } from "react";
|
|
2
|
+
function u(e) {
|
|
3
|
+
if (!e || typeof e != "object" || Object.isFrozen(e))
|
|
4
|
+
return e;
|
|
5
|
+
Object.freeze(e);
|
|
6
|
+
for (const t of Object.values(e))
|
|
7
|
+
u(t);
|
|
8
|
+
return e;
|
|
9
|
+
}
|
|
10
|
+
function R(e, t) {
|
|
11
|
+
return Number(e?.[t] ?? 0);
|
|
12
|
+
}
|
|
13
|
+
function j(e) {
|
|
14
|
+
return !!(e && typeof e == "object" && ("allow" in e || "minRole" in e || "minPlan" in e || "limit" in e || "limits" in e));
|
|
15
|
+
}
|
|
16
|
+
function O(e, t) {
|
|
17
|
+
return t === !1 || t == null ? null : t === !0 || typeof t == "string" ? {
|
|
18
|
+
usageKey: e,
|
|
19
|
+
limitKey: t === !0 ? e : t,
|
|
20
|
+
byPlan: null
|
|
21
|
+
} : typeof t != "object" ? null : {
|
|
22
|
+
usageKey: t.usageKey ?? e,
|
|
23
|
+
limitKey: t.limitKey ?? e,
|
|
24
|
+
byPlan: t.byPlan ?? t.plans ?? null
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function F(e) {
|
|
28
|
+
const t = [];
|
|
29
|
+
if (e?.limit) {
|
|
30
|
+
const n = e.limit.limitKey ?? e.limit.usageKey ?? "default", i = O(n, e.limit);
|
|
31
|
+
i && t.push(i);
|
|
32
|
+
}
|
|
33
|
+
if (!e?.limits || typeof e.limits != "object")
|
|
34
|
+
return t;
|
|
35
|
+
for (const [n, i] of Object.entries(e.limits)) {
|
|
36
|
+
const r = O(n, i);
|
|
37
|
+
r && t.push(r);
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
function I(e, t, n) {
|
|
42
|
+
return n.byPlan && typeof n.byPlan == "object" ? n.byPlan[t] : e?.[t]?.[n.limitKey];
|
|
43
|
+
}
|
|
44
|
+
function J(e, t, n, i) {
|
|
45
|
+
if (!i)
|
|
46
|
+
return !0;
|
|
47
|
+
const r = I(e, t, i);
|
|
48
|
+
if (r === 1 / 0)
|
|
49
|
+
return !0;
|
|
50
|
+
const o = Number(r);
|
|
51
|
+
return Number.isFinite(o) ? Number(n?.[i.usageKey] ?? 0) < o : !1;
|
|
52
|
+
}
|
|
53
|
+
function M(e) {
|
|
54
|
+
return !e || typeof e != "object" ? [] : e;
|
|
55
|
+
}
|
|
56
|
+
function N(e, t, n) {
|
|
57
|
+
if (!e || typeof e != "object")
|
|
58
|
+
return e;
|
|
59
|
+
if (j(e))
|
|
60
|
+
return n(e, t);
|
|
61
|
+
const i = {};
|
|
62
|
+
for (const [r, o] of Object.entries(e))
|
|
63
|
+
i[r] = N(o, t, n);
|
|
64
|
+
return i;
|
|
65
|
+
}
|
|
66
|
+
function U(e) {
|
|
67
|
+
return Array.isArray(e) ? e.map(String).filter(Boolean) : String(e ?? "").split(".").map((t) => t.trim()).filter(Boolean);
|
|
68
|
+
}
|
|
69
|
+
function f(e) {
|
|
70
|
+
if (!e || typeof e != "object")
|
|
71
|
+
return e;
|
|
72
|
+
if (Array.isArray(e))
|
|
73
|
+
return e.map(f);
|
|
74
|
+
const t = {};
|
|
75
|
+
for (const [n, i] of Object.entries(e))
|
|
76
|
+
t[n] = f(i);
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
79
|
+
function z(e, t) {
|
|
80
|
+
const n = f(e) ?? {};
|
|
81
|
+
for (const [i, r] of Object.entries(t ?? {})) {
|
|
82
|
+
const o = n[i];
|
|
83
|
+
if (o && r && typeof o == "object" && typeof r == "object" && !j(o) && !j(r) && !Array.isArray(o) && !Array.isArray(r)) {
|
|
84
|
+
n[i] = z(o, r);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
n[i] = f(r);
|
|
88
|
+
}
|
|
89
|
+
return n;
|
|
90
|
+
}
|
|
91
|
+
function q(e = {}) {
|
|
92
|
+
return u({ ...e });
|
|
93
|
+
}
|
|
94
|
+
function D(e, t = {}, n = {}) {
|
|
95
|
+
return u({
|
|
96
|
+
usageKey: e,
|
|
97
|
+
limitKey: n.limitKey ?? e,
|
|
98
|
+
byPlan: { ...t }
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function a(e = {}) {
|
|
102
|
+
return u({ ...e });
|
|
103
|
+
}
|
|
104
|
+
function E(e, t = {}) {
|
|
105
|
+
const n = U(e);
|
|
106
|
+
if (!n.length)
|
|
107
|
+
return a(t);
|
|
108
|
+
const i = {};
|
|
109
|
+
let r = i;
|
|
110
|
+
for (const o of n.slice(0, -1))
|
|
111
|
+
r[o] = {}, r = r[o];
|
|
112
|
+
return r[n.at(-1)] = f(t), a(i);
|
|
113
|
+
}
|
|
114
|
+
function G(...e) {
|
|
115
|
+
return a(
|
|
116
|
+
e.reduce((t, n) => z(t, n), {})
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function V(e = {}) {
|
|
120
|
+
return u(M({ ...e }));
|
|
121
|
+
}
|
|
122
|
+
function H({
|
|
123
|
+
roles: e = {},
|
|
124
|
+
plans: t = {},
|
|
125
|
+
planLimits: n = {},
|
|
126
|
+
permissions: i = {},
|
|
127
|
+
defaults: r = {}
|
|
128
|
+
} = {}) {
|
|
129
|
+
const o = u({ ...e }), y = u({ ...t }), g = V(n), K = a(i), S = r.role ?? "guest", h = r.plan ?? "free", b = r.usage ?? {};
|
|
130
|
+
function p(s) {
|
|
131
|
+
return R(o, s);
|
|
132
|
+
}
|
|
133
|
+
function P(s) {
|
|
134
|
+
return R(y, s);
|
|
135
|
+
}
|
|
136
|
+
function A(s, c = {}) {
|
|
137
|
+
if (!s)
|
|
138
|
+
return !1;
|
|
139
|
+
if (s.allow === !0)
|
|
140
|
+
return !0;
|
|
141
|
+
if (s.allow === !1)
|
|
142
|
+
return !1;
|
|
143
|
+
const l = c.role ?? S, m = c.plan ?? h, w = c.usage ?? b;
|
|
144
|
+
if (s.minRole && p(l) < p(s.minRole) || s.minPlan && P(m) < P(s.minPlan))
|
|
145
|
+
return !1;
|
|
146
|
+
for (const T of F(s))
|
|
147
|
+
if (!J(g, m, w, T))
|
|
148
|
+
return !1;
|
|
149
|
+
return !0;
|
|
150
|
+
}
|
|
151
|
+
function L(s = {}) {
|
|
152
|
+
return N(K, s, A);
|
|
153
|
+
}
|
|
154
|
+
function B(s, c, l = b) {
|
|
155
|
+
const m = JSON.stringify(l ?? b);
|
|
156
|
+
return k(
|
|
157
|
+
() => L({ role: s, plan: c, usage: l }),
|
|
158
|
+
[s, c, m]
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return u({
|
|
162
|
+
roles: o,
|
|
163
|
+
plans: y,
|
|
164
|
+
planLimits: g,
|
|
165
|
+
permissions: K,
|
|
166
|
+
canAccess: A,
|
|
167
|
+
getRoleLevel: p,
|
|
168
|
+
getPlanLevel: P,
|
|
169
|
+
resolvePermissions: L,
|
|
170
|
+
usePermissions: B
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
export {
|
|
174
|
+
q as createAccessRule,
|
|
175
|
+
a as createPermissionRules,
|
|
176
|
+
E as createPermissionScope,
|
|
177
|
+
H as createPermissionSystem,
|
|
178
|
+
V as createPlanLimits,
|
|
179
|
+
D as limitByPlan,
|
|
180
|
+
G as mergePermissionRules
|
|
181
|
+
};
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { A as r, D as t, a as o, c as s, b as A, m as T } from "./systemBars-C3QiEL7z.js";
|
|
2
|
+
import { N as m } from "./NativeBackButtonHandler-CcLHewdm.js";
|
|
3
|
+
export {
|
|
4
|
+
r as AppUrlListener,
|
|
5
|
+
t as DEFAULT_THEME_NAVIGATION_BAR_COLORS,
|
|
6
|
+
o as DEFAULT_THEME_STATUS_BAR_COLORS,
|
|
7
|
+
m as NativeBackButtonHandler,
|
|
8
|
+
s as createPlatformRuntime,
|
|
9
|
+
A as createSystemBarsController,
|
|
10
|
+
T as mapAppUrlToRoute
|
|
11
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { QueryClient as n } from "@tanstack/react-query";
|
|
2
|
+
function u(e = {}) {
|
|
3
|
+
return new n({
|
|
4
|
+
defaultOptions: {
|
|
5
|
+
queries: {
|
|
6
|
+
gcTime: 300 * 1e3,
|
|
7
|
+
refetchOnWindowFocus: !1,
|
|
8
|
+
retry: (t, s) => {
|
|
9
|
+
const r = s?.response?.status;
|
|
10
|
+
return [401, 403, 404].includes(r) ? !1 : t < 1;
|
|
11
|
+
},
|
|
12
|
+
staleTime: 30 * 1e3,
|
|
13
|
+
...e?.defaultOptions?.queries
|
|
14
|
+
},
|
|
15
|
+
mutations: {
|
|
16
|
+
retry: !1,
|
|
17
|
+
...e?.defaultOptions?.mutations
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
...e
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const a = u();
|
|
24
|
+
export {
|
|
25
|
+
u as c,
|
|
26
|
+
a as q
|
|
27
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
function y(t, e, r) {
|
|
2
|
+
return Math.min(Math.max(t, e), r);
|
|
3
|
+
}
|
|
4
|
+
function u(t, e = 50, r = 1e3) {
|
|
5
|
+
return `${y(t * e, 0, r)}ms`;
|
|
6
|
+
}
|
|
7
|
+
function d(t = 0, e = 50, r = 1e3) {
|
|
8
|
+
return {
|
|
9
|
+
"--kosmio-motion-delay": u(t, e, r)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const a = {
|
|
13
|
+
duration: {
|
|
14
|
+
veryFast: 0.1,
|
|
15
|
+
fast: 0.2,
|
|
16
|
+
normal: 0.3,
|
|
17
|
+
slow: 0.4,
|
|
18
|
+
verySlow: 0.5
|
|
19
|
+
},
|
|
20
|
+
ease: {
|
|
21
|
+
standard: [0.2, 0, 0, 1],
|
|
22
|
+
enter: [0, 0, 0.2, 1],
|
|
23
|
+
exit: [0.4, 0, 1, 1],
|
|
24
|
+
linear: [0, 0, 1, 1]
|
|
25
|
+
},
|
|
26
|
+
stagger: {
|
|
27
|
+
list: 0.025
|
|
28
|
+
},
|
|
29
|
+
transition: {
|
|
30
|
+
enter: (t = {}) => ({
|
|
31
|
+
duration: a.duration.normal,
|
|
32
|
+
ease: a.ease.enter,
|
|
33
|
+
...t
|
|
34
|
+
}),
|
|
35
|
+
move: (t = {}) => ({
|
|
36
|
+
duration: a.duration.normal,
|
|
37
|
+
ease: a.ease.standard,
|
|
38
|
+
...t
|
|
39
|
+
}),
|
|
40
|
+
exit: (t = {}) => ({
|
|
41
|
+
duration: a.duration.fast,
|
|
42
|
+
ease: a.ease.standard,
|
|
43
|
+
...t
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
appear: {
|
|
47
|
+
row: {
|
|
48
|
+
from: { opacity: 0, y: 6 },
|
|
49
|
+
to: { opacity: 1, y: 0 },
|
|
50
|
+
duration: "normal",
|
|
51
|
+
ease: "enter",
|
|
52
|
+
stagger: "list"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
css: {
|
|
56
|
+
ms: (t) => {
|
|
57
|
+
const e = typeof t == "number" ? t : a.duration[t] ?? a.duration.normal;
|
|
58
|
+
return `${Math.round(e * 1e3)}ms`;
|
|
59
|
+
},
|
|
60
|
+
bezier: (t) => `cubic-bezier(${(a.ease[t] ?? a.ease.standard).join(",")})`,
|
|
61
|
+
transition: ({
|
|
62
|
+
props: t = ["transform"],
|
|
63
|
+
dur: e = "fast",
|
|
64
|
+
ease: r = "standard",
|
|
65
|
+
delay: n = 0
|
|
66
|
+
} = {}) => {
|
|
67
|
+
const o = a.css.ms(e), i = a.css.bezier(r), l = typeof n == "number" ? `${n}ms` : n;
|
|
68
|
+
return t.map((c) => `${c} ${o} ${i} ${l}`).join(", ");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
function p({ index: t = 0, preset: e = a.appear.row } = {}) {
|
|
73
|
+
const r = a.duration[e.duration], n = t * a.stagger[e.stagger];
|
|
74
|
+
return {
|
|
75
|
+
"--motion-row-delay": a.css.ms(n),
|
|
76
|
+
opacity: 0,
|
|
77
|
+
animationName: "motion-row-appear",
|
|
78
|
+
animationDuration: a.css.ms(r),
|
|
79
|
+
animationDelay: a.css.ms(n),
|
|
80
|
+
animationTimingFunction: a.css.bezier(e.ease),
|
|
81
|
+
animationFillMode: "forwards",
|
|
82
|
+
willChange: "transform, opacity"
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const K = {
|
|
86
|
+
fadeUp: {
|
|
87
|
+
hidden: { opacity: 0, y: 8 },
|
|
88
|
+
show: { opacity: 1, y: 0, transition: a.transition.enter() },
|
|
89
|
+
exit: { opacity: 0, y: 6, transition: a.transition.exit() }
|
|
90
|
+
},
|
|
91
|
+
pop: {
|
|
92
|
+
hidden: { opacity: 0, y: 8, scale: 0.98 },
|
|
93
|
+
show: { opacity: 1, y: 0, scale: 1, transition: a.transition.enter() },
|
|
94
|
+
exit: { opacity: 0, y: 6, scale: 0.99, transition: a.transition.exit() }
|
|
95
|
+
},
|
|
96
|
+
list: {
|
|
97
|
+
hidden: {},
|
|
98
|
+
show: {
|
|
99
|
+
transition: { staggerChildren: a.stagger.list }
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
listItem: {
|
|
103
|
+
hidden: { opacity: 0, y: 6 },
|
|
104
|
+
show: { opacity: 1, y: 0, transition: a.transition.enter({ duration: a.duration.fast }) }
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function f(t) {
|
|
108
|
+
if (!t) return !1;
|
|
109
|
+
const e = t.tagName?.toLowerCase();
|
|
110
|
+
return !!(t.isContentEditable || e === "input" || e === "textarea" || e === "select");
|
|
111
|
+
}
|
|
112
|
+
const g = f;
|
|
113
|
+
function s(t = "") {
|
|
114
|
+
const e = String(t).trim().toLowerCase();
|
|
115
|
+
return e === "del" ? "delete" : e === "return" ? "enter" : e === "esc" ? "escape" : e;
|
|
116
|
+
}
|
|
117
|
+
function m(t) {
|
|
118
|
+
const e = t?.keys ?? t?.key ?? t?.shortcut;
|
|
119
|
+
return e == null ? [] : (Array.isArray(e) ? e : [e]).flatMap((n) => String(n).split("/")).map((n) => s(n)).filter(Boolean);
|
|
120
|
+
}
|
|
121
|
+
function w(t, e) {
|
|
122
|
+
const r = m(e);
|
|
123
|
+
if (!r.length) return !1;
|
|
124
|
+
const n = s(t.key);
|
|
125
|
+
return !(!r.includes(n) || "ctrlKey" in e && !!e.ctrlKey != !!t.ctrlKey || "metaKey" in e && !!e.metaKey != !!t.metaKey || "altKey" in e && !!e.altKey != !!t.altKey || "shiftKey" in e && !!e.shiftKey != !!t.shiftKey || !("ctrlKey" in e) && t.ctrlKey || !("metaKey" in e) && t.metaKey || !("altKey" in e) && t.altKey);
|
|
126
|
+
}
|
|
127
|
+
function h(t) {
|
|
128
|
+
const e = String(t).toLowerCase().split("+").map((r) => r.trim()).filter(Boolean);
|
|
129
|
+
return function(n) {
|
|
130
|
+
const o = n.key?.toLowerCase();
|
|
131
|
+
return e.every((i) => i === "mod" ? n.metaKey || n.ctrlKey : i === "ctrl" || i === "control" ? n.ctrlKey : i === "meta" || i === "cmd" ? n.metaKey : i === "shift" ? n.shiftKey : i === "alt" || i === "option" ? n.altKey : i === o);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
h as a,
|
|
136
|
+
u as b,
|
|
137
|
+
y as c,
|
|
138
|
+
g as d,
|
|
139
|
+
d as g,
|
|
140
|
+
f as i,
|
|
141
|
+
a as m,
|
|
142
|
+
s as n,
|
|
143
|
+
m as p,
|
|
144
|
+
p as r,
|
|
145
|
+
w as s,
|
|
146
|
+
K as v
|
|
147
|
+
};
|