@studiolambda/query 1.1.1 → 1.3.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/dist/query.cjs +1 -1
- package/dist/query.cjs.map +1 -1
- package/dist/query.js +129 -124
- package/dist/query.js.map +1 -1
- package/dist/query_react.cjs +1 -1
- package/dist/query_react.cjs.map +1 -1
- package/dist/query_react.js +225 -192
- package/dist/query_react.js.map +1 -1
- package/dist/src/query/options.d.ts +44 -10
- package/dist/src/react/_internal.d.ts +1 -0
- package/dist/src/react/components/QueryPrefetch.d.ts +7 -0
- package/dist/src/react/components/QueryPrefetchTags.d.ts +9 -0
- package/dist/src/react/hooks/useQueryPrefetch.d.ts +2 -0
- package/dist/src/react/index.d.ts +3 -0
- package/package.json +43 -26
package/dist/query_react.js
CHANGED
|
@@ -1,308 +1,341 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { createQuery as
|
|
4
|
-
const
|
|
1
|
+
import { createContext as L, useDebugValue as v, use as A, useMemo as s, useCallback as K, useState as E, useEffect as O, useTransition as sn, useRef as cn } from "react";
|
|
2
|
+
import { jsx as j, jsxs as an, Fragment as fn } from "react/jsx-runtime";
|
|
3
|
+
import { createQuery as ln } from "./query.js";
|
|
4
|
+
const N = L({
|
|
5
5
|
query: void 0,
|
|
6
6
|
clearOnForget: void 0,
|
|
7
7
|
ignoreTransitionContext: void 0
|
|
8
8
|
});
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function V() {
|
|
10
|
+
return v("useQueryContext"), A(N);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
const { query:
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
12
|
+
function M(n) {
|
|
13
|
+
v("useQueryInstance");
|
|
14
|
+
const { query: r } = V(), { query: t } = n ?? {};
|
|
15
|
+
function e() {
|
|
16
|
+
const o = t ?? r;
|
|
17
|
+
if (!o)
|
|
18
18
|
throw new Error(
|
|
19
19
|
"No query instance was found. Please provide one via the resource options or the query context."
|
|
20
20
|
);
|
|
21
|
-
return
|
|
21
|
+
return o;
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return s(e, [t, r]);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
25
|
+
function dn(n, r) {
|
|
26
|
+
v("useQueryActions");
|
|
27
27
|
const {
|
|
28
|
-
expiration:
|
|
29
|
-
fetcher:
|
|
30
|
-
stale:
|
|
28
|
+
expiration: t,
|
|
29
|
+
fetcher: e,
|
|
30
|
+
stale: o,
|
|
31
31
|
removeOnError: u,
|
|
32
|
-
fresh:
|
|
33
|
-
} =
|
|
34
|
-
function
|
|
35
|
-
return
|
|
36
|
-
stale:
|
|
37
|
-
expiration:
|
|
38
|
-
fetcher:
|
|
32
|
+
fresh: i
|
|
33
|
+
} = r ?? {}, { query: a, mutate: l, forget: c } = M(r);
|
|
34
|
+
function g(f) {
|
|
35
|
+
return a(n, {
|
|
36
|
+
stale: o ?? !1,
|
|
37
|
+
expiration: t,
|
|
38
|
+
fetcher: e,
|
|
39
39
|
removeOnError: u,
|
|
40
|
-
fresh:
|
|
41
|
-
...
|
|
40
|
+
fresh: i,
|
|
41
|
+
...f
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const b = K(g, [
|
|
45
|
+
a,
|
|
46
46
|
n,
|
|
47
|
-
e,
|
|
48
47
|
t,
|
|
49
|
-
|
|
48
|
+
e,
|
|
49
|
+
o,
|
|
50
50
|
u,
|
|
51
|
-
|
|
51
|
+
i
|
|
52
52
|
]);
|
|
53
|
-
function
|
|
54
|
-
return
|
|
53
|
+
function T(f, y) {
|
|
54
|
+
return l(n, f, y);
|
|
55
55
|
}
|
|
56
|
-
const m =
|
|
57
|
-
async function
|
|
58
|
-
await
|
|
56
|
+
const m = K(T, [l, n]);
|
|
57
|
+
async function Q() {
|
|
58
|
+
await c(n);
|
|
59
59
|
}
|
|
60
|
-
const h =
|
|
60
|
+
const h = K(Q, [c, n]);
|
|
61
61
|
function H() {
|
|
62
|
-
return { refetch:
|
|
62
|
+
return { refetch: b, mutate: m, forget: h };
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return s(H, [b, m, h]);
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
const { expiration:
|
|
69
|
-
function
|
|
70
|
-
if (Date.now() >=
|
|
71
|
-
|
|
66
|
+
function gn(n, r) {
|
|
67
|
+
v("useQueryStatus");
|
|
68
|
+
const { expiration: t, subscribe: e } = M(r), [o, u] = E(t(n) ?? /* @__PURE__ */ new Date()), [i, a] = E(Date.now() > o.getTime()), [l, c] = E(!1), [g, b] = E(!1);
|
|
69
|
+
function T() {
|
|
70
|
+
if (Date.now() >= o.getTime()) {
|
|
71
|
+
a(!0);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
a(!1);
|
|
75
75
|
function h() {
|
|
76
|
-
|
|
76
|
+
a(!0);
|
|
77
77
|
}
|
|
78
|
-
const H = setTimeout(h,
|
|
78
|
+
const H = setTimeout(h, o.getTime() - Date.now());
|
|
79
79
|
return function() {
|
|
80
80
|
clearTimeout(H);
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
O(T, [o]);
|
|
84
84
|
function m() {
|
|
85
85
|
function h() {
|
|
86
|
-
|
|
86
|
+
b(!0);
|
|
87
87
|
}
|
|
88
88
|
function H() {
|
|
89
|
-
|
|
89
|
+
b(!1), u(t(n) ?? /* @__PURE__ */ new Date());
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
u(
|
|
91
|
+
function f() {
|
|
92
|
+
u(t(n) ?? /* @__PURE__ */ new Date());
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
u(
|
|
94
|
+
function y() {
|
|
95
|
+
u(t(n) ?? /* @__PURE__ */ new Date()), c(!1);
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
u(
|
|
97
|
+
function p() {
|
|
98
|
+
u(t(n) ?? /* @__PURE__ */ new Date());
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
100
|
+
function P() {
|
|
101
|
+
c(!0);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
103
|
+
function w() {
|
|
104
|
+
c(!1), b(!1);
|
|
105
105
|
}
|
|
106
|
-
const
|
|
106
|
+
const D = e(n, "mutating", h), d = e(n, "mutated", H), q = e(n, "hydrated", f), F = e(n, "resolved", y), I = e(n, "forgotten", p), S = e(n, "refetching", P), R = e(n, "error", w);
|
|
107
107
|
return function() {
|
|
108
|
-
|
|
108
|
+
D(), d(), q(), F(), I(), S(), R();
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
function
|
|
113
|
-
return { expiresAt:
|
|
111
|
+
O(m, [n, e, t, u]);
|
|
112
|
+
function Q() {
|
|
113
|
+
return { expiresAt: o, isExpired: i, isRefetching: l, isMutating: g };
|
|
114
114
|
}
|
|
115
|
-
return
|
|
115
|
+
return s(Q, [o, i, l, g]);
|
|
116
116
|
}
|
|
117
|
-
const
|
|
117
|
+
const z = L({
|
|
118
118
|
isPending: void 0,
|
|
119
119
|
startTransition: void 0
|
|
120
120
|
});
|
|
121
|
-
function
|
|
122
|
-
return
|
|
121
|
+
function bn() {
|
|
122
|
+
return v("useQueryTransitionContext"), A(z);
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
const { clearOnForget:
|
|
127
|
-
clearOnForget:
|
|
124
|
+
function hn(n, r) {
|
|
125
|
+
v("useQueryBasic");
|
|
126
|
+
const { clearOnForget: t, ignoreTransitionContext: e } = V(), {
|
|
127
|
+
clearOnForget: o,
|
|
128
128
|
ignoreTransitionContext: u,
|
|
129
|
-
expiration:
|
|
130
|
-
fetcher:
|
|
131
|
-
stale:
|
|
132
|
-
removeOnError:
|
|
133
|
-
fresh:
|
|
134
|
-
} =
|
|
135
|
-
function
|
|
136
|
-
return u ??
|
|
129
|
+
expiration: i,
|
|
130
|
+
fetcher: a,
|
|
131
|
+
stale: l,
|
|
132
|
+
removeOnError: c,
|
|
133
|
+
fresh: g
|
|
134
|
+
} = r ?? {}, { isPending: b, startTransition: T } = bn(), [m, Q] = sn(), { query: h, expiration: H, subscribe: f } = M(r);
|
|
135
|
+
function y() {
|
|
136
|
+
return u ?? e ?? !1;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const p = s(y, [
|
|
139
139
|
u,
|
|
140
|
-
|
|
140
|
+
e
|
|
141
141
|
]);
|
|
142
|
-
function
|
|
143
|
-
return
|
|
142
|
+
function P() {
|
|
143
|
+
return p ? m : b ?? m;
|
|
144
144
|
}
|
|
145
|
-
const
|
|
146
|
-
|
|
145
|
+
const w = s(P, [
|
|
146
|
+
b,
|
|
147
147
|
m,
|
|
148
|
-
|
|
148
|
+
p
|
|
149
149
|
]);
|
|
150
|
-
function
|
|
151
|
-
return
|
|
150
|
+
function D() {
|
|
151
|
+
return p ? Q : T ?? Q;
|
|
152
152
|
}
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
const d = s(D, [
|
|
154
|
+
T,
|
|
155
|
+
Q,
|
|
156
|
+
p
|
|
157
157
|
]);
|
|
158
|
-
function I() {
|
|
159
|
-
return r ?? e ?? !1;
|
|
160
|
-
}
|
|
161
|
-
const O = a(I, [r, e]);
|
|
162
158
|
function q() {
|
|
159
|
+
return o ?? t ?? !1;
|
|
160
|
+
}
|
|
161
|
+
const F = s(q, [o, t]);
|
|
162
|
+
function I() {
|
|
163
163
|
return h(n, {
|
|
164
|
-
expiration:
|
|
165
|
-
fetcher:
|
|
166
|
-
stale:
|
|
167
|
-
removeOnError:
|
|
168
|
-
fresh:
|
|
164
|
+
expiration: i,
|
|
165
|
+
fetcher: a,
|
|
166
|
+
stale: l,
|
|
167
|
+
removeOnError: c,
|
|
168
|
+
fresh: g
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const S = s(I, [
|
|
172
172
|
h,
|
|
173
173
|
n,
|
|
174
|
-
f,
|
|
175
174
|
i,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
175
|
+
a,
|
|
176
|
+
l,
|
|
177
|
+
c,
|
|
178
|
+
g
|
|
179
|
+
]), [R, C] = E(A(S));
|
|
180
|
+
function U() {
|
|
181
|
+
function X(x) {
|
|
182
|
+
d(function() {
|
|
183
|
+
C(x.detail);
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
|
|
186
|
+
function Y(x) {
|
|
187
|
+
d(async function() {
|
|
188
188
|
const B = await x.detail;
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
d(function() {
|
|
190
|
+
C(B);
|
|
191
191
|
});
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
function Z(x) {
|
|
195
|
+
d(function() {
|
|
196
|
+
C(x.detail);
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
function _(x) {
|
|
200
|
+
d(function() {
|
|
201
|
+
C(x.detail);
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
|
|
204
|
+
function $(x) {
|
|
205
|
+
d(async function() {
|
|
206
206
|
const B = await x.detail;
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
d(function() {
|
|
208
|
+
C(B);
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
212
|
+
function k() {
|
|
213
|
+
F && d(async function() {
|
|
214
214
|
const x = await h(n, {
|
|
215
|
-
expiration:
|
|
216
|
-
fetcher:
|
|
217
|
-
stale:
|
|
218
|
-
removeOnError:
|
|
219
|
-
fresh:
|
|
215
|
+
expiration: i,
|
|
216
|
+
fetcher: a,
|
|
217
|
+
stale: l,
|
|
218
|
+
removeOnError: c,
|
|
219
|
+
fresh: g
|
|
220
220
|
});
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
d(function() {
|
|
222
|
+
C(x);
|
|
223
223
|
});
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
|
-
const
|
|
226
|
+
const nn = f(n, "resolved", X), tn = f(n, "mutating", Y), en = f(n, "mutated", Z), rn = f(n, "hydrated", _), on = f(n, "refetching", $), un = f(n, "forgotten", k);
|
|
227
227
|
return function() {
|
|
228
|
-
|
|
228
|
+
nn(), tn(), en(), rn(), on(), un();
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
|
-
|
|
231
|
+
O(U, [
|
|
232
232
|
h,
|
|
233
233
|
H,
|
|
234
|
-
c,
|
|
235
|
-
n,
|
|
236
|
-
O,
|
|
237
234
|
f,
|
|
235
|
+
n,
|
|
236
|
+
F,
|
|
238
237
|
i,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
238
|
+
a,
|
|
239
|
+
l,
|
|
240
|
+
c,
|
|
241
|
+
g,
|
|
242
|
+
d
|
|
243
243
|
]);
|
|
244
|
-
function
|
|
245
|
-
return { data:
|
|
244
|
+
function W() {
|
|
245
|
+
return { data: R, isPending: w };
|
|
246
246
|
}
|
|
247
|
-
return
|
|
247
|
+
return s(W, [R, w]);
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
const
|
|
249
|
+
function Hn(n, r) {
|
|
250
|
+
v("useQuery");
|
|
251
|
+
const t = hn(n, r), e = dn(n, r), o = gn(n, r);
|
|
252
252
|
function u() {
|
|
253
|
-
return { ...
|
|
253
|
+
return { ...t, ...e, ...o };
|
|
254
254
|
}
|
|
255
|
-
return
|
|
255
|
+
return s(u, [t, e, o]);
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function xn(n, r) {
|
|
258
|
+
return n.length !== r.length ? !1 : n.every((t, e) => t === r[e]);
|
|
259
|
+
}
|
|
260
|
+
function G(n) {
|
|
261
|
+
const r = cn([]);
|
|
262
|
+
function t() {
|
|
263
|
+
return xn(r.current, n) || (r.current = n), r.current;
|
|
264
|
+
}
|
|
265
|
+
return s(t, [n]);
|
|
266
|
+
}
|
|
267
|
+
function J(n, r) {
|
|
268
|
+
v("useQueryPrefetch");
|
|
269
|
+
const t = G(n), { query: e } = M(r);
|
|
270
|
+
s(() => t.map((o) => e(o)), [e, t]);
|
|
271
|
+
}
|
|
272
|
+
function Tn({
|
|
258
273
|
children: n,
|
|
259
|
-
clearOnForget:
|
|
260
|
-
ignoreTransitionContext:
|
|
261
|
-
query:
|
|
274
|
+
clearOnForget: r,
|
|
275
|
+
ignoreTransitionContext: t,
|
|
276
|
+
query: e
|
|
262
277
|
}) {
|
|
263
|
-
function
|
|
264
|
-
return
|
|
278
|
+
function o() {
|
|
279
|
+
return e ?? ln();
|
|
265
280
|
}
|
|
266
|
-
const u =
|
|
267
|
-
function
|
|
281
|
+
const u = s(o, [e]);
|
|
282
|
+
function i() {
|
|
268
283
|
if (u.broadcast()) {
|
|
269
|
-
const
|
|
284
|
+
const b = u.subscribeBroadcast();
|
|
270
285
|
return function() {
|
|
271
|
-
|
|
286
|
+
b();
|
|
272
287
|
};
|
|
273
288
|
}
|
|
274
|
-
const
|
|
275
|
-
u.configure({ broadcast:
|
|
276
|
-
const
|
|
289
|
+
const c = new BroadcastChannel("query");
|
|
290
|
+
u.configure({ broadcast: c });
|
|
291
|
+
const g = u.subscribeBroadcast();
|
|
277
292
|
return function() {
|
|
278
|
-
|
|
293
|
+
g(), c.close();
|
|
279
294
|
};
|
|
280
295
|
}
|
|
281
|
-
|
|
282
|
-
function
|
|
283
|
-
return { query:
|
|
296
|
+
O(i, [u]);
|
|
297
|
+
function a() {
|
|
298
|
+
return { query: e, clearOnForget: r, ignoreTransitionContext: t };
|
|
284
299
|
}
|
|
285
|
-
const
|
|
286
|
-
return /* @__PURE__ */ N
|
|
300
|
+
const l = s(a, [e, r, t]);
|
|
301
|
+
return /* @__PURE__ */ j(N, { value: l, children: n });
|
|
287
302
|
}
|
|
288
|
-
function
|
|
289
|
-
function
|
|
290
|
-
return { startTransition:
|
|
303
|
+
function pn({ children: n, startTransition: r, isPending: t }) {
|
|
304
|
+
function e() {
|
|
305
|
+
return { startTransition: r, isPending: t };
|
|
291
306
|
}
|
|
292
|
-
const
|
|
293
|
-
return /* @__PURE__ */
|
|
307
|
+
const o = s(e, [r, t]);
|
|
308
|
+
return /* @__PURE__ */ j(z, { value: o, children: n });
|
|
309
|
+
}
|
|
310
|
+
function Cn({ keys: n, query: r, children: t }) {
|
|
311
|
+
return J(n, { query: r }), t;
|
|
312
|
+
}
|
|
313
|
+
function yn({ keys: n, children: r, ...t }) {
|
|
314
|
+
J(n, t);
|
|
315
|
+
const e = G(n);
|
|
316
|
+
function o() {
|
|
317
|
+
return e.map((i) => /* @__PURE__ */ j("link", { rel: "preload", href: i, as: "fetch", ...t }));
|
|
318
|
+
}
|
|
319
|
+
const u = s(o, [e, t]);
|
|
320
|
+
return /* @__PURE__ */ an(fn, { children: [
|
|
321
|
+
u,
|
|
322
|
+
r
|
|
323
|
+
] });
|
|
294
324
|
}
|
|
295
325
|
export {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
326
|
+
N as Context,
|
|
327
|
+
Cn as QueryPrefetch,
|
|
328
|
+
yn as QueryPrefetchTags,
|
|
329
|
+
Tn as QueryProvider,
|
|
330
|
+
pn as QueryTransition,
|
|
331
|
+
z as TransitionContext,
|
|
332
|
+
Hn as useQuery,
|
|
333
|
+
dn as useQueryActions,
|
|
334
|
+
hn as useQueryBasic,
|
|
335
|
+
V as useQueryContext,
|
|
336
|
+
M as useQueryInstance,
|
|
337
|
+
J as useQueryPrefetch,
|
|
338
|
+
gn as useQueryStatus,
|
|
339
|
+
bn as useQueryTransitionContext
|
|
307
340
|
};
|
|
308
341
|
//# sourceMappingURL=query_react.js.map
|