@nivaro/react 0.3.8 → 0.3.9
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/full.css +1 -1
- package/dist/hooks/replayUploadQueue.js +107 -93
- package/dist/hooks/useSessionRecorder.js +103 -101
- package/dist/index.d.ts +46 -1
- package/dist/index.js +300 -292
- package/dist/shared/components/CollectionBrowserView.js +318 -318
- package/dist/shared/components/DataTable.js +230 -223
- package/dist/shared/components/QueryTable.js +49 -49
- package/dist/shared/components/chat/ChatPanel.js +288 -287
- package/dist/shared/components/panels/CommentPanel.js +237 -236
- package/dist/shared/components/profile/usePersonPresence.js +42 -37
- package/dist/shared/lib/presence-live.js +54 -0
- package/dist/shared/lib/presence-state.js +39 -31
- package/dist/shared/lib/request-gate.js +120 -102
- package/dist/shared/lib/rum.js +45 -36
- package/dist/shared/lib/signed-out.js +114 -0
- package/dist/shared/lib/socket-realtime.js +19 -17
- package/dist/shared/lib/use-online-users.js +11 -10
- package/dist/shared/lib/worker-socket.js +89 -79
- package/package.json +1 -1
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
import { useQueryClient as
|
|
2
|
-
import { useNivaroClient as
|
|
3
|
-
import { get as
|
|
4
|
-
import { useLiveEvent as
|
|
5
|
-
import {
|
|
1
|
+
import { useQueryClient as y, useQuery as u } from "@tanstack/react-query";
|
|
2
|
+
import { useNivaroClient as a } from "../../context.js";
|
|
3
|
+
import { get as g } from "../../lib/commands.js";
|
|
4
|
+
import { useLiveEvent as h } from "../../lib/live.js";
|
|
5
|
+
import { usePresenceOnlinePoll as f } from "../../lib/presence-live.js";
|
|
6
|
+
import { presenceChangeTouches as P, prettyPagePath as m } from "../../lib/presence-state.js";
|
|
6
7
|
import { PERSON_PROFILE_KEY as d } from "./types.js";
|
|
7
|
-
function
|
|
8
|
-
var
|
|
9
|
-
const
|
|
10
|
-
|
|
8
|
+
function K(n) {
|
|
9
|
+
var t, o;
|
|
10
|
+
const l = a(), s = y();
|
|
11
|
+
h(
|
|
11
12
|
"presence:changed",
|
|
12
13
|
() => {
|
|
13
|
-
|
|
14
|
+
s.invalidateQueries(
|
|
15
|
+
{ queryKey: [d, n] },
|
|
16
|
+
{ cancelRefetch: !1 }
|
|
17
|
+
);
|
|
14
18
|
},
|
|
15
19
|
{
|
|
16
|
-
enabled: !!
|
|
17
|
-
debounceMs:
|
|
20
|
+
enabled: !!n,
|
|
21
|
+
debounceMs: 1e3,
|
|
18
22
|
includeOwn: !0,
|
|
19
|
-
|
|
23
|
+
// Coalesced server events list every changed id (`user_ids`); older ones carry `user_id`.
|
|
24
|
+
match: (i) => P(i, n)
|
|
20
25
|
}
|
|
21
26
|
);
|
|
22
|
-
const { data: e } =
|
|
27
|
+
const c = f(15e3, !!n), { data: e } = u({
|
|
23
28
|
queryKey: ["presence-online"],
|
|
24
|
-
queryFn: () =>
|
|
25
|
-
|
|
29
|
+
queryFn: () => l.request(
|
|
30
|
+
g("/presence/online")
|
|
26
31
|
),
|
|
27
|
-
enabled: !!
|
|
28
|
-
refetchInterval:
|
|
32
|
+
enabled: !!n,
|
|
33
|
+
refetchInterval: c,
|
|
29
34
|
staleTime: 5e3
|
|
30
|
-
}),
|
|
31
|
-
(
|
|
32
|
-
),
|
|
33
|
-
return { page:
|
|
35
|
+
}), r = (t = e == null ? void 0 : e.data) == null ? void 0 : t.find(
|
|
36
|
+
(i) => String(i.user_id).toUpperCase() === String(n ?? "").toUpperCase()
|
|
37
|
+
), p = (((o = e == null ? void 0 : e.config) == null ? void 0 : o.fields) ?? ["role", "page"]).includes("page");
|
|
38
|
+
return { page: r && p ? r.page ?? m(r.current_path) : null };
|
|
34
39
|
}
|
|
35
|
-
function
|
|
36
|
-
var
|
|
37
|
-
const
|
|
40
|
+
function O(n, l) {
|
|
41
|
+
var t, o;
|
|
42
|
+
const s = a(), c = f(15e3, l && !!n), { data: e } = u({
|
|
38
43
|
queryKey: ["presence-online"],
|
|
39
|
-
queryFn: () =>
|
|
40
|
-
enabled:
|
|
41
|
-
refetchInterval:
|
|
44
|
+
queryFn: () => s.request(g("/presence/online")),
|
|
45
|
+
enabled: l && !!n,
|
|
46
|
+
refetchInterval: c,
|
|
42
47
|
staleTime: 5e3
|
|
43
|
-
}),
|
|
44
|
-
(
|
|
48
|
+
}), r = (t = e == null ? void 0 : e.data) == null ? void 0 : t.find(
|
|
49
|
+
(i) => String(i.user_id).toUpperCase() === String(n ?? "").toUpperCase()
|
|
45
50
|
);
|
|
46
|
-
if (!
|
|
47
|
-
const
|
|
51
|
+
if (!r) return { word: null, page: null, minutes: null };
|
|
52
|
+
const p = (((o = e == null ? void 0 : e.config) == null ? void 0 : o.fields) ?? ["role", "page"]).includes("page");
|
|
48
53
|
return {
|
|
49
|
-
word:
|
|
50
|
-
page:
|
|
51
|
-
minutes:
|
|
54
|
+
word: r.away ? "away" : r.is_idle ? "idle" : "online",
|
|
55
|
+
page: p ? r.page ?? m(r.current_path) : null,
|
|
56
|
+
minutes: r.idle_minutes ?? null
|
|
52
57
|
};
|
|
53
58
|
}
|
|
54
59
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
O as useCardPresence,
|
|
61
|
+
K as usePersonPresence
|
|
57
62
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useQueryClient as d } from "@tanstack/react-query";
|
|
2
|
+
import { useEffect as E } from "react";
|
|
3
|
+
import { LIVE_WINDOW_EVENT as c } from "./live.js";
|
|
4
|
+
import { useLiveRefetchInterval as p } from "./live-queries.js";
|
|
5
|
+
import { useOptionalRealtime as w } from "./realtime.js";
|
|
6
|
+
const L = ["presence-online"], _ = 1e3, v = 6e4, f = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function a(n, t) {
|
|
8
|
+
t.timer || (t.timer = setTimeout(() => {
|
|
9
|
+
t.timer = null, n.invalidateQueries({ queryKey: [...L] }, { cancelRefetch: !1 });
|
|
10
|
+
}, _));
|
|
11
|
+
}
|
|
12
|
+
function P(n, t) {
|
|
13
|
+
var u;
|
|
14
|
+
let r = f.get(n);
|
|
15
|
+
if (!r) {
|
|
16
|
+
const i = {
|
|
17
|
+
refs: 0,
|
|
18
|
+
adapter: null,
|
|
19
|
+
offAdapter: null,
|
|
20
|
+
offWindow: () => {
|
|
21
|
+
},
|
|
22
|
+
timer: null
|
|
23
|
+
}, l = (m) => {
|
|
24
|
+
const o = m.detail;
|
|
25
|
+
(o == null ? void 0 : o.event) === "presence:changed" && a(n, i);
|
|
26
|
+
};
|
|
27
|
+
typeof window < "u" && (window.addEventListener(c, l), i.offWindow = () => window.removeEventListener(c, l)), r = i, f.set(n, r);
|
|
28
|
+
}
|
|
29
|
+
const e = r;
|
|
30
|
+
e.refs++, t && e.adapter !== t && ((u = e.offAdapter) == null || u.call(e), e.adapter = t, e.offAdapter = t.on("presence:changed", () => a(n, e)));
|
|
31
|
+
let s = !1;
|
|
32
|
+
return () => {
|
|
33
|
+
var i;
|
|
34
|
+
s || (s = !0, e.refs--, !(e.refs > 0) && ((i = e.offAdapter) == null || i.call(e), e.offWindow(), e.timer && clearTimeout(e.timer), f.delete(n)));
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function N(n = !0) {
|
|
38
|
+
const t = d(), r = w();
|
|
39
|
+
E(() => {
|
|
40
|
+
if (n)
|
|
41
|
+
return P(t, r);
|
|
42
|
+
}, [t, r, n]);
|
|
43
|
+
}
|
|
44
|
+
function S(n, t = !0) {
|
|
45
|
+
return N(t), p(t ? n : !1, { safetyMs: v });
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
L as PRESENCE_ONLINE_KEY,
|
|
49
|
+
v as PRESENCE_POLL_BACKSTOP_MS,
|
|
50
|
+
_ as PRESENCE_REFETCH_DELAY_MS,
|
|
51
|
+
P as acquirePresenceListener,
|
|
52
|
+
N as usePresenceOnlineLive,
|
|
53
|
+
S as usePresenceOnlinePoll
|
|
54
|
+
};
|
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
return
|
|
1
|
+
function m(t) {
|
|
2
|
+
const n = Math.max(0, Math.floor(t.minutes)), e = n >= 60 ? `${Math.floor(n / 60)}h ${n % 60}m` : `${n}m`;
|
|
3
|
+
return t.label ? `stuck on ${t.label} for ${e}` : `stuck for ${e}`;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
if (!
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
const e = /* @__PURE__ */ new Set(["records", "collections", "p"]), o =
|
|
10
|
-
return o.length === 0 ? "Home" : o.map((
|
|
5
|
+
function $(t) {
|
|
6
|
+
if (!t) return null;
|
|
7
|
+
const n = t.split("?")[0].split("/").filter(Boolean);
|
|
8
|
+
if (n.length === 0) return "Home";
|
|
9
|
+
const e = /* @__PURE__ */ new Set(["records", "collections", "p"]), o = n.filter((r) => !e.has(r));
|
|
10
|
+
return o.length === 0 ? "Home" : o.map((r, s) => s === 0 ? r.replace(/[-_]/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) : r).join(" › ");
|
|
11
11
|
}
|
|
12
12
|
const a = /* @__PURE__ */ new Set(["API", "admin"]);
|
|
13
|
-
function d(
|
|
14
|
-
if (!
|
|
15
|
-
const
|
|
16
|
-
let s = null;
|
|
17
|
-
c && c[2] !== "new" && o && (s = o(c[1], encodeURIComponent(c[2])));
|
|
18
|
-
const i = (e == null ? void 0 : e.replace(/\/$/, "")) ?? "";
|
|
13
|
+
function d(t, n, e, o, r) {
|
|
14
|
+
if (!t || !t.startsWith("/") || t.startsWith("//") || /[\\\s]/.test(t)) return null;
|
|
15
|
+
const s = t.split("#")[0], l = /^\/(?:records|collections)\/([A-Za-z0-9_]+)\/([^/?#]+)/.exec(s);
|
|
19
16
|
let u = null;
|
|
17
|
+
l && l[2] !== "new" && o && (u = o(l[1], encodeURIComponent(l[2])));
|
|
18
|
+
const i = (e == null ? void 0 : e.replace(/\/$/, "")) ?? "";
|
|
19
|
+
let c = null;
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
c = i && r ? new URL(i, r).origin : null;
|
|
22
22
|
} catch {
|
|
23
|
-
|
|
23
|
+
c = null;
|
|
24
24
|
}
|
|
25
|
-
const f = !!
|
|
26
|
-
return
|
|
25
|
+
const f = !!c && c === r;
|
|
26
|
+
return u || (n && a.has(n) ? u = f ? s : i ? `${i}${s}` : null : u = f ? null : s), p(u, r, c);
|
|
27
27
|
}
|
|
28
|
-
function p(
|
|
29
|
-
if (!
|
|
28
|
+
function p(t, n, e) {
|
|
29
|
+
if (!t || !n) return null;
|
|
30
30
|
try {
|
|
31
|
-
const o = new URL(
|
|
32
|
-
return o.protocol !== "http:" && o.protocol !== "https:" ? null : o.origin ===
|
|
31
|
+
const o = new URL(t, n);
|
|
32
|
+
return o.protocol !== "http:" && o.protocol !== "https:" ? null : o.origin === n || o.origin === e ? t : null;
|
|
33
33
|
} catch {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return /^https?:\/\//i.test(
|
|
37
|
+
function g(t, n) {
|
|
38
|
+
return /^https?:\/\//i.test(t) ? t : `${typeof window > "u" ? "" : window.location.origin}${t}`;
|
|
39
|
+
}
|
|
40
|
+
function h(t) {
|
|
41
|
+
return t.online ? t.away ? "away" : (t.idle_minutes ?? 0) >= 5 ? "idle" : "online" : "offline";
|
|
39
42
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
43
|
+
function y(t, n) {
|
|
44
|
+
if (!n) return !1;
|
|
45
|
+
const e = t ?? {};
|
|
46
|
+
if (e.many === !0) return !0;
|
|
47
|
+
const o = String(n).toUpperCase();
|
|
48
|
+
return Array.isArray(e.user_ids) && e.user_ids.some((r) => String(r).toUpperCase() === o) ? !0 : String(e.user_id ?? "").toUpperCase() === o;
|
|
42
49
|
}
|
|
43
50
|
export {
|
|
44
|
-
|
|
51
|
+
g as fullHref,
|
|
52
|
+
y as presenceChangeTouches,
|
|
45
53
|
d as presencePlaceHref,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
h as presenceWord,
|
|
55
|
+
$ as prettyPagePath,
|
|
56
|
+
m as stuckText
|
|
49
57
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { noteOwnWriteFromCommand as
|
|
1
|
+
import { noteOwnWriteFromCommand as C } from "./own-writes.js";
|
|
2
|
+
import { noteCredentialChanged as z, isIdentityRead as D, claimIdentityCall as M, signedOutError as $, noteSignedIn as Z, isSignedOutError as U, noteUnauthorized as x } from "./signed-out.js";
|
|
2
3
|
function q(t) {
|
|
3
4
|
if (!t || typeof t != "object") return "";
|
|
4
5
|
const s = Object.entries(t).filter(([, o]) => o != null).map(([o, u]) => [o, String(u)]).sort(([o], [u]) => o < u ? -1 : o > u ? 1 : 0);
|
|
5
6
|
return s.length ? new URLSearchParams(s).toString() : "";
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
+
function P(t) {
|
|
8
9
|
const s = (t._method ?? "GET").toUpperCase(), o = s === "GET" || t._body === void 0 ? "" : JSON.stringify(t._body);
|
|
9
10
|
return `${s} ${t._path ?? ""} ${q(t._params)} ${o}`;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function A(t) {
|
|
12
13
|
return (t._method ?? "GET").toUpperCase() === "GET";
|
|
13
14
|
}
|
|
14
|
-
const
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
const I = /^\/(widgets-internal\/[^/]+\/render|items\/[^/]+\/[^/]+\/child-summary|items\/[^/]+\/auto-id-preview|config-conformance\/record\/.+\/check|pipelines\/instance\/[^/]+\/owners\/batch|addendums\/summary|at-risk\/evaluate|record-views\/.+\/touch)$/;
|
|
16
|
+
function H(t) {
|
|
17
|
+
return A(t) ? !0 : (t._method ?? "GET").toUpperCase() !== "POST" ? !1 : I.test((t._path ?? "").split("?")[0]);
|
|
17
18
|
}
|
|
18
19
|
function T(t) {
|
|
19
20
|
if (t == null || typeof t != "object") return t;
|
|
@@ -23,11 +24,11 @@ function T(t) {
|
|
|
23
24
|
return t;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
return t[
|
|
27
|
+
const j = Symbol("nivaro.coalesced");
|
|
28
|
+
function B(t) {
|
|
29
|
+
return t[j] === !0;
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
+
const O = 20, F = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, W = /* @__PURE__ */ new Set(["aggregate", "export", "distinct", "resolve-paths", "batch-read"]), K = /* @__PURE__ */ new Set([
|
|
31
32
|
"fields",
|
|
32
33
|
"filter",
|
|
33
34
|
"sort",
|
|
@@ -40,32 +41,32 @@ const C = 20, D = /^\/items\/([A-Za-z_][A-Za-z0-9_]*)(?:\/([^/?#]+))?$/, I = /*
|
|
|
40
41
|
"conditions",
|
|
41
42
|
"labels"
|
|
42
43
|
]);
|
|
43
|
-
function
|
|
44
|
+
function Y(t) {
|
|
44
45
|
const s = t;
|
|
45
46
|
if ((s._method ?? "GET").toUpperCase() !== "GET") return null;
|
|
46
|
-
const o =
|
|
47
|
+
const o = F.exec(s._path ?? "");
|
|
47
48
|
if (!o) return null;
|
|
48
49
|
const [, u, d] = o;
|
|
49
|
-
if (d !== void 0 &&
|
|
50
|
-
const m = s._params ?? {},
|
|
50
|
+
if (d !== void 0 && W.has(d)) return null;
|
|
51
|
+
const m = s._params ?? {}, a = {};
|
|
51
52
|
for (const [r, c] of Object.entries(m))
|
|
52
53
|
if (c !== void 0) {
|
|
53
|
-
if (!
|
|
54
|
-
|
|
54
|
+
if (!K.has(r)) return null;
|
|
55
|
+
a[r] = c;
|
|
55
56
|
}
|
|
56
|
-
return d === void 0 ? { collection: u, query:
|
|
57
|
+
return d === void 0 ? { collection: u, query: a } : { collection: u, id: d, query: a };
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function J(t) {
|
|
59
60
|
let s = [], o;
|
|
60
|
-
const u = (
|
|
61
|
-
if (
|
|
61
|
+
const u = (a) => t.request(a.command).then(a.resolve, a.reject), d = async (a) => {
|
|
62
|
+
if (a.length === 1) return u(a[0]);
|
|
62
63
|
let r;
|
|
63
64
|
try {
|
|
64
65
|
const c = await t.request({
|
|
65
66
|
_method: "POST",
|
|
66
67
|
_path: "/items/batch-read",
|
|
67
68
|
_body: {
|
|
68
|
-
reads:
|
|
69
|
+
reads: a.map((n, e) => ({
|
|
69
70
|
key: String(e),
|
|
70
71
|
collection: n.read.collection,
|
|
71
72
|
...n.read.id !== void 0 ? { id: n.read.id } : {},
|
|
@@ -77,7 +78,7 @@ function Z(t) {
|
|
|
77
78
|
} catch {
|
|
78
79
|
r = void 0;
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
a.forEach((c, n) => {
|
|
81
82
|
const e = r == null ? void 0 : r[n];
|
|
82
83
|
if ((e == null ? void 0 : e.status) !== 200 || e === void 0) {
|
|
83
84
|
u(c);
|
|
@@ -87,36 +88,36 @@ function Z(t) {
|
|
|
87
88
|
});
|
|
88
89
|
}, m = () => {
|
|
89
90
|
o = void 0;
|
|
90
|
-
const
|
|
91
|
+
const a = s;
|
|
91
92
|
s = [];
|
|
92
|
-
for (let r = 0; r <
|
|
93
|
-
d(
|
|
93
|
+
for (let r = 0; r < a.length; r += O)
|
|
94
|
+
d(a.slice(r, r + O));
|
|
94
95
|
};
|
|
95
|
-
return (
|
|
96
|
+
return (a, r) => new Promise((c, n) => {
|
|
96
97
|
s.push({
|
|
97
98
|
read: r,
|
|
98
|
-
command:
|
|
99
|
+
command: a,
|
|
99
100
|
resolve: c,
|
|
100
101
|
reject: n
|
|
101
102
|
}), o === void 0 && (o = setTimeout(m, 0));
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
105
|
+
const b = 50, Q = 10, V = /^\/collections\/([A-Za-z_][A-Za-z0-9_-]{0,127})$/;
|
|
106
|
+
function X(t) {
|
|
106
107
|
const s = t;
|
|
107
108
|
if ((s._method ?? "GET").toUpperCase() !== "GET" || q(s._params) !== "") return null;
|
|
108
|
-
const o =
|
|
109
|
+
const o = V.exec(s._path ?? "");
|
|
109
110
|
return o ? o[1] : null;
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
+
function ee() {
|
|
112
113
|
return Object.assign(new Error("Not found"), { status: 404, response: { error: "Not found" } });
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
+
function te(t) {
|
|
115
116
|
let s = !0, o = [], u;
|
|
116
117
|
const d = (r) => t.request(r.command).then(r.resolve, r.reject), m = async (r) => {
|
|
117
|
-
const c = [...new Set(r.map((
|
|
118
|
+
const c = [...new Set(r.map((i) => i.name))];
|
|
118
119
|
if (c.length === 1 || !s) {
|
|
119
|
-
for (const
|
|
120
|
+
for (const i of r) d(i);
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
123
|
let n;
|
|
@@ -126,11 +127,11 @@ function F(t) {
|
|
|
126
127
|
_path: "/collections",
|
|
127
128
|
_params: { names: c.join(",") }
|
|
128
129
|
});
|
|
129
|
-
} catch (
|
|
130
|
-
const h =
|
|
130
|
+
} catch (i) {
|
|
131
|
+
const h = i == null ? void 0 : i.status;
|
|
131
132
|
if (h === 400 || h === 404 || h === 405) s = !1;
|
|
132
133
|
else if (h === 429 || h !== void 0 && h >= 500) {
|
|
133
|
-
for (const p of r) p.reject(
|
|
134
|
+
for (const p of r) p.reject(i);
|
|
134
135
|
return;
|
|
135
136
|
}
|
|
136
137
|
n = void 0;
|
|
@@ -138,13 +139,13 @@ function F(t) {
|
|
|
138
139
|
const e = n == null ? void 0 : n.data;
|
|
139
140
|
if (!e || typeof e != "object" || Array.isArray(e)) {
|
|
140
141
|
Array.isArray(e) && (s = !1);
|
|
141
|
-
for (const
|
|
142
|
+
for (const i of r) d(i);
|
|
142
143
|
return;
|
|
143
144
|
}
|
|
144
145
|
const l = e, f = new Set(Array.isArray(n == null ? void 0 : n.missing) ? n.missing : []);
|
|
145
|
-
for (const
|
|
146
|
-
Object.hasOwn(l,
|
|
147
|
-
},
|
|
146
|
+
for (const i of r)
|
|
147
|
+
Object.hasOwn(l, i.name) ? i.resolve({ data: T(l[i.name]) }) : f.has(i.name) ? i.reject(ee()) : d(i);
|
|
148
|
+
}, a = () => {
|
|
148
149
|
u = void 0;
|
|
149
150
|
const r = o;
|
|
150
151
|
o = [];
|
|
@@ -152,8 +153,8 @@ function F(t) {
|
|
|
152
153
|
for (const e of r) {
|
|
153
154
|
let l = n.get(e.name);
|
|
154
155
|
if (!l) {
|
|
155
|
-
const f = c[c.length - 1],
|
|
156
|
-
l = f &&
|
|
156
|
+
const f = c[c.length - 1], i = f ? new Set(f.map((h) => h.name)).size : b;
|
|
157
|
+
l = f && i < b ? f : [], l !== f && c.push(l), n.set(e.name, l);
|
|
157
158
|
}
|
|
158
159
|
l.push(e);
|
|
159
160
|
}
|
|
@@ -165,108 +166,125 @@ function F(t) {
|
|
|
165
166
|
command: r,
|
|
166
167
|
resolve: n,
|
|
167
168
|
reject: e
|
|
168
|
-
}), u === void 0 && (u = setTimeout(
|
|
169
|
+
}), u === void 0 && (u = setTimeout(a, Q));
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
|
-
const R = 3e3,
|
|
172
|
-
function
|
|
172
|
+
const R = 3e3, ne = /^\/(collections\/[A-Za-z_][A-Za-z0-9_-]*|field-config\/[A-Za-z_][A-Za-z0-9_-]*|collection-layouts(\/active|\/summary\/[A-Za-z_][A-Za-z0-9_-]*)?|chat\/room-types|users\/me)$/, se = /^\/(record-views|item-locks|drafts|presence|rum|comments|notifications|tasks|field-rules\/evaluate|chat\/(?!room-types)|field-config\/[^/]+\/(evaluate-visibility|evaluate-defaults|evaluate-lock|cascade|project)$|items\/(?!nivaro_|directus_)[^/]+|users\/cards$|files\/verify$)/;
|
|
173
|
+
function oe(t) {
|
|
173
174
|
const s = (t._path ?? "").split("?")[0];
|
|
174
|
-
return (t._method ?? "GET").toUpperCase() === "POST" &&
|
|
175
|
+
return (t._method ?? "GET").toUpperCase() === "POST" && I.test(s) ? !0 : se.test(s);
|
|
175
176
|
}
|
|
176
|
-
function
|
|
177
|
+
function re(t) {
|
|
177
178
|
const s = t;
|
|
178
|
-
if (!
|
|
179
|
+
if (!A(s) || !ne.test(s._path ?? "")) return !1;
|
|
179
180
|
const o = s._params;
|
|
180
181
|
return !(o && o.item != null && /^\/collection-layouts\/active$/.test(s._path ?? ""));
|
|
181
182
|
}
|
|
182
|
-
let
|
|
183
|
-
function
|
|
184
|
-
|
|
183
|
+
let y = 0;
|
|
184
|
+
function k() {
|
|
185
|
+
y++;
|
|
185
186
|
}
|
|
186
|
-
function
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
function G(t, s) {
|
|
188
|
+
return t.then(
|
|
189
|
+
(o) => (s && Z(), o),
|
|
190
|
+
(o) => {
|
|
191
|
+
throw U(o, s) && x(s), o;
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function le(t, s = {}) {
|
|
196
|
+
if (B(t)) return t;
|
|
197
|
+
const o = /* @__PURE__ */ new Map(), u = s.batchReads ? J(t) : null, d = s.batchCollections === !1 ? null : te(t), m = /* @__PURE__ */ new Map();
|
|
198
|
+
let a = y;
|
|
190
199
|
const r = (n, e, l) => {
|
|
191
|
-
if (e !==
|
|
192
|
-
|
|
200
|
+
if (e !== y) return;
|
|
201
|
+
a !== y && (m.clear(), a = y);
|
|
193
202
|
const f = Date.now();
|
|
194
|
-
for (const [
|
|
203
|
+
for (const [i, h] of m) f - h.at >= R && m.delete(i);
|
|
195
204
|
m.set(n, { at: f, epoch: e, value: l });
|
|
196
205
|
}, c = (n) => {
|
|
197
206
|
const e = n;
|
|
198
|
-
if (!
|
|
199
|
-
|
|
200
|
-
const _ = !
|
|
201
|
-
_ &&
|
|
202
|
-
const w = t.request(n);
|
|
203
|
-
return (_ ? w.finally(
|
|
207
|
+
if (!A(e)) {
|
|
208
|
+
C(e._method, e._path, e._body);
|
|
209
|
+
const _ = !oe(e);
|
|
210
|
+
_ && k();
|
|
211
|
+
const w = G(t.request(n), !1);
|
|
212
|
+
return (_ ? w.finally(k) : w).then((S) => (C(e._method, e._path, e._body, S), S));
|
|
204
213
|
}
|
|
205
|
-
const l =
|
|
214
|
+
const l = P(e), f = re(e);
|
|
206
215
|
if (f) {
|
|
207
216
|
const _ = m.get(l);
|
|
208
|
-
if (_ && _.epoch ===
|
|
217
|
+
if (_ && _.epoch === y && Date.now() - _.at < R)
|
|
209
218
|
return Promise.resolve(T(_.value));
|
|
210
219
|
}
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
213
|
-
const h =
|
|
214
|
-
|
|
220
|
+
const i = o.get(l);
|
|
221
|
+
if (i) return i.then(T);
|
|
222
|
+
const h = D(e._method, e._path, e._params);
|
|
223
|
+
if (h && !M()) return Promise.reject($());
|
|
224
|
+
const p = u ? Y(e) : null, E = !p && d ? X(e) : null, L = G(
|
|
225
|
+
p && u ? u(n, p) : E && d ? d(n, E) : t.request(n),
|
|
226
|
+
h
|
|
227
|
+
), N = y, g = L.then((_) => (f && r(l, N, T(_)), _)).finally(() => {
|
|
228
|
+
o.get(l) === g && o.delete(l);
|
|
215
229
|
});
|
|
216
|
-
return o.set(l,
|
|
230
|
+
return o.set(l, g), g;
|
|
217
231
|
};
|
|
218
232
|
return new Proxy(t, {
|
|
219
233
|
get(n, e, l) {
|
|
220
234
|
if (e === "request") return c;
|
|
221
|
-
if (e ===
|
|
235
|
+
if (e === j) return !0;
|
|
236
|
+
if (e === "setToken" && typeof n.setToken == "function")
|
|
237
|
+
return (i) => {
|
|
238
|
+
n.setToken(i), z();
|
|
239
|
+
};
|
|
222
240
|
const f = Reflect.get(n, e, l);
|
|
223
241
|
return typeof f == "function" ? f.bind(n) : f;
|
|
224
242
|
}
|
|
225
243
|
});
|
|
226
244
|
}
|
|
227
|
-
const
|
|
228
|
-
function
|
|
229
|
-
for (const t of [...
|
|
245
|
+
const ie = /^\/(item-locks|drafts|auth)\b/, v = /* @__PURE__ */ new Set();
|
|
246
|
+
function ae() {
|
|
247
|
+
for (const t of [...v]) t();
|
|
230
248
|
}
|
|
231
|
-
function
|
|
249
|
+
function fe(t) {
|
|
232
250
|
return t.subscribe((s) => {
|
|
233
|
-
s.type === "observerAdded" && s.query.state.fetchStatus === "fetching" &&
|
|
251
|
+
s.type === "observerAdded" && s.query.state.fetchStatus === "fetching" && v.size !== 0 && ae();
|
|
234
252
|
});
|
|
235
253
|
}
|
|
236
|
-
function
|
|
254
|
+
function de(t, s = {}) {
|
|
237
255
|
let o = s.open ?? !0, u;
|
|
238
256
|
const d = /* @__PURE__ */ new Map(), m = () => {
|
|
239
257
|
const n = [...d.values()];
|
|
240
258
|
d.clear();
|
|
241
259
|
for (const e of n) e.release();
|
|
242
|
-
},
|
|
243
|
-
|
|
260
|
+
}, a = () => {
|
|
261
|
+
v.delete(a), m();
|
|
244
262
|
}, r = (n) => {
|
|
245
263
|
const e = n;
|
|
246
|
-
if (o || !
|
|
247
|
-
const l =
|
|
264
|
+
if (o || !H(e) || ie.test(e._path ?? "")) return t.request(n);
|
|
265
|
+
const l = P(e), f = d.get(l);
|
|
248
266
|
if (f) return f.promise.then(T);
|
|
249
|
-
let
|
|
267
|
+
let i = () => {
|
|
250
268
|
};
|
|
251
|
-
const p = new Promise((
|
|
252
|
-
|
|
269
|
+
const p = new Promise((E) => {
|
|
270
|
+
i = E;
|
|
253
271
|
}).then(() => t.request(n));
|
|
254
|
-
return d.set(l, { promise: p, release:
|
|
272
|
+
return d.set(l, { promise: p, release: i }), v.add(a), p;
|
|
255
273
|
};
|
|
256
274
|
return new Proxy(t, {
|
|
257
275
|
get(n, e, l) {
|
|
258
276
|
if (e === "request") return r;
|
|
259
277
|
if (e === "open") return o;
|
|
260
278
|
if (e === "setOpen")
|
|
261
|
-
return (
|
|
279
|
+
return (i) => {
|
|
262
280
|
u !== void 0 && (clearTimeout(u), u = void 0);
|
|
263
281
|
const h = o;
|
|
264
|
-
o =
|
|
282
|
+
o = i, i && !h && (v.delete(a), m());
|
|
265
283
|
};
|
|
266
284
|
if (e === "dispose")
|
|
267
285
|
return () => {
|
|
268
286
|
u === void 0 && (u = setTimeout(() => {
|
|
269
|
-
u = void 0, o = !0,
|
|
287
|
+
u = void 0, o = !0, v.delete(a), m();
|
|
270
288
|
}, 0));
|
|
271
289
|
};
|
|
272
290
|
const f = Reflect.get(n, e, l);
|
|
@@ -275,17 +293,17 @@ function ne(t, s = {}) {
|
|
|
275
293
|
});
|
|
276
294
|
}
|
|
277
295
|
export {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
296
|
+
O as BATCH_READ_LIMIT,
|
|
297
|
+
b as COLLECTION_BATCH_LIMIT,
|
|
298
|
+
Q as COLLECTION_BATCH_WINDOW_MS,
|
|
281
299
|
R as SETTLED_READ_MS,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
300
|
+
X as batchableCollectionMeta,
|
|
301
|
+
Y as batchableRead,
|
|
302
|
+
de as createGatedClient,
|
|
303
|
+
k as forgetSettledReads,
|
|
304
|
+
B as isCoalesced,
|
|
305
|
+
re as isSettledRead,
|
|
306
|
+
ae as releaseGatedReads,
|
|
307
|
+
fe as releaseGatedReadsOnSharedFetch,
|
|
308
|
+
le as withGetCoalescing
|
|
291
309
|
};
|