@plitzi/sdk-shared 0.36.1 → 0.37.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.
@@ -1,241 +1,236 @@
1
1
  import { StyleVariableCategory as e } from "../types/StyleTypes.mjs";
2
- import { z as t } from "zod";
2
+ import { STYLE_STATES as t } from "../style/styleStates.mjs";
3
+ import { z as n } from "zod";
3
4
  //#region src/network/spaceEvents.ts
4
- var n = (e) => typeof e == "object" && !!e && !Array.isArray(e), r = t.custom((e) => n(e) && typeof e.id == "string", { message: "expected an element with an id" }), i = t.array(r), a = t.custom((e) => n(e) && Array.isArray(e.flat), { message: "expected a schema whose `flat` is a list of elements" }), o = t.custom((e) => n(e) && typeof e.id == "string", { message: "expected a page folder with an id" }), s = t.custom((e) => n(e) && typeof e.name == "string", { message: "expected a variable with a name" }), c = t.custom(n, { message: "expected a style attributes object" }), l = t.custom((e) => n(e) && typeof e.family == "string" && typeof e.source == "string", { message: "expected a font with a family and a source" }), u = t.custom((e) => typeof e == "string" || typeof e == "number" || n(e), { message: "expected a style variable value" }), d = t.enum([
5
+ var r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = n.custom((e) => r(e) && typeof e.id == "string", { message: "expected an element with an id" }), a = n.array(i), o = n.custom((e) => r(e) && Array.isArray(e.flat), { message: "expected a schema whose `flat` is a list of elements" }), s = n.custom((e) => r(e) && typeof e.id == "string", { message: "expected a page folder with an id" }), c = n.custom((e) => r(e) && typeof e.name == "string", { message: "expected a variable with a name" }), l = n.custom(r, { message: "expected a style attributes object" }), u = n.custom((e) => r(e) && typeof e.family == "string" && typeof e.source == "string", { message: "expected a font with a family and a source" }), d = n.custom((e) => typeof e == "string" || typeof e == "number" || r(e), { message: "expected a style variable value" }), f = n.enum([
5
6
  "desktop",
6
7
  "tablet",
7
8
  "mobile"
8
- ]), f = t.custom((e) => typeof e == "string", { message: "expected a drop position" }), p = t.custom((e) => typeof e == "string", { message: "expected a style category" }), m = t.enum([
9
+ ]), p = n.custom((e) => typeof e == "string", { message: "expected a drop position" }), m = n.custom((e) => typeof e == "string", { message: "expected a style category" }), h = n.enum([
9
10
  "class",
10
11
  "element",
11
12
  "id"
12
- ]), h = t.enum([
13
- "hover",
14
- "active",
15
- "focus",
16
- "disabled",
17
- "checked",
18
- "visited"
19
- ]), g = t.enum(e), _ = t.object({
20
- componentType: t.string().optional(),
21
- styleSelector: t.string().optional(),
22
- styleState: h.optional(),
23
- styleVariant: t.string().optional()
24
- }), v = _.extend({ styleSelector: t.string() }), y = { contextId: t.string() }, b = t.object({ variable: s }), x = t.object({
25
- displayMode: d,
26
- selector: t.string(),
27
- category: g,
28
- name: t.string(),
29
- value: u
30
- }), S = t.object({
31
- displayMode: d,
32
- selector: t.string(),
33
- category: g,
34
- name: t.string()
35
- }), C = t.object({
36
- category: g,
37
- name: t.string(),
38
- value: u
39
- }), w = {
40
- SPACE_UPDATED: t.object({ schema: a }),
41
- STYLE_UPDATED: t.object({
42
- platform: t.custom(n),
43
- variables: t.custom(n),
44
- cache: t.string()
45
- }),
46
- SPACE_ADD_PAGE: t.object({ page: r }),
47
- SPACE_UPDATE_PAGE: t.object({ page: r }),
48
- SPACE_SET_HOME_PAGE: t.object({ page: r }),
49
- SPACE_REMOVE_PAGE: t.object({ pageId: t.string() }),
50
- SPACE_ADD_PAGE_FOLDER: t.object({ pageFolder: o }),
51
- SPACE_UPDATE_PAGE_FOLDER: t.object({ pageFolder: o }),
52
- SPACE_REMOVE_PAGE_FOLDER: t.object({ pageFolderId: t.string() }),
53
- SPACE_ADD_VARIABLE: b,
54
- SPACE_UPDATE_VARIABLE: b,
55
- SPACE_REMOVE_VARIABLE: t.object({ name: t.string() }),
56
- SPACE_ADD_ELEMENT: t.object({
57
- element: r,
58
- dropPosition: f,
59
- to: t.string(),
60
- initialItems: i.optional(),
61
- variables: t.array(s).optional()
62
- }),
63
- SPACE_UPDATE_ELEMENT: t.object({ element: r }),
64
- SPACE_RENAME_ELEMENT: t.object({
65
- elementId: t.string(),
66
- id: t.string()
67
- }),
68
- SPACE_UPDATE_ELEMENTS: t.object({ elements: i }),
69
- SPACE_REMOVE_ELEMENT: t.object({ elementId: t.string() }),
70
- SPACE_MOVE_ELEMENT: t.object({
71
- from: t.string(),
72
- to: t.string(),
73
- elementId: t.string(),
74
- dropPosition: f
75
- }),
76
- SPACE_CLONE_ELEMENT: t.object({
77
- to: t.string(),
78
- element: r,
79
- dropPosition: f,
80
- initialItems: i
81
- }),
82
- SPACE_ADD_TEMPLATE: t.object({
83
- element: r,
84
- style: t.custom(n),
85
- to: t.string(),
86
- dropPosition: f,
87
- initialItems: i.optional(),
88
- variables: t.array(s).optional()
89
- }),
90
- SPACE_UPDATE_SETTINGS: t.object({
91
- path: t.string(),
92
- value: t.union([
93
- t.string(),
94
- t.number(),
95
- t.boolean()
13
+ ]), g = n.enum(t), _ = n.enum(e), v = n.object({
14
+ componentType: n.string().optional(),
15
+ styleSelector: n.string().optional(),
16
+ styleState: g.optional(),
17
+ styleVariant: n.string().optional(),
18
+ styleAncestor: n.string().optional()
19
+ }), y = v.extend({ styleSelector: n.string() }), b = { contextId: n.string() }, x = n.object({ variable: c }), S = n.object({
20
+ displayMode: f,
21
+ selector: n.string(),
22
+ category: _,
23
+ name: n.string(),
24
+ value: d
25
+ }), C = n.object({
26
+ displayMode: f,
27
+ selector: n.string(),
28
+ category: _,
29
+ name: n.string()
30
+ }), w = n.object({
31
+ category: _,
32
+ name: n.string(),
33
+ value: d
34
+ }), T = {
35
+ SPACE_UPDATED: n.object({ schema: o }),
36
+ STYLE_UPDATED: n.object({
37
+ platform: n.custom(r),
38
+ variables: n.custom(r),
39
+ cache: n.string()
40
+ }),
41
+ SPACE_ADD_PAGE: n.object({ page: i }),
42
+ SPACE_UPDATE_PAGE: n.object({ page: i }),
43
+ SPACE_SET_HOME_PAGE: n.object({ page: i }),
44
+ SPACE_REMOVE_PAGE: n.object({ pageId: n.string() }),
45
+ SPACE_ADD_PAGE_FOLDER: n.object({ pageFolder: s }),
46
+ SPACE_UPDATE_PAGE_FOLDER: n.object({ pageFolder: s }),
47
+ SPACE_REMOVE_PAGE_FOLDER: n.object({ pageFolderId: n.string() }),
48
+ SPACE_ADD_VARIABLE: x,
49
+ SPACE_UPDATE_VARIABLE: x,
50
+ SPACE_REMOVE_VARIABLE: n.object({ name: n.string() }),
51
+ SPACE_ADD_ELEMENT: n.object({
52
+ element: i,
53
+ dropPosition: p,
54
+ to: n.string(),
55
+ initialItems: a.optional(),
56
+ variables: n.array(c).optional()
57
+ }),
58
+ SPACE_UPDATE_ELEMENT: n.object({ element: i }),
59
+ SPACE_RENAME_ELEMENT: n.object({
60
+ elementId: n.string(),
61
+ id: n.string()
62
+ }),
63
+ SPACE_UPDATE_ELEMENTS: n.object({ elements: a }),
64
+ SPACE_REMOVE_ELEMENT: n.object({ elementId: n.string() }),
65
+ SPACE_MOVE_ELEMENT: n.object({
66
+ from: n.string(),
67
+ to: n.string(),
68
+ elementId: n.string(),
69
+ dropPosition: p
70
+ }),
71
+ SPACE_CLONE_ELEMENT: n.object({
72
+ to: n.string(),
73
+ element: i,
74
+ dropPosition: p,
75
+ initialItems: a
76
+ }),
77
+ SPACE_ADD_TEMPLATE: n.object({
78
+ element: i,
79
+ style: n.custom(r),
80
+ to: n.string(),
81
+ dropPosition: p,
82
+ initialItems: a.optional(),
83
+ variables: n.array(c).optional()
84
+ }),
85
+ SPACE_UPDATE_SETTINGS: n.object({
86
+ path: n.string(),
87
+ value: n.union([
88
+ n.string(),
89
+ n.number(),
90
+ n.boolean()
96
91
  ])
97
92
  }),
98
- STYLE_ADD_SELECTOR: t.object({
99
- displayMode: d,
100
- selector: t.string(),
101
- path: p.optional(),
102
- type: m,
103
- style: c.optional(),
104
- params: _
105
- }),
106
- STYLE_UPDATE_SELECTOR: t.object({
107
- displayMode: d,
108
- selector: t.string(),
109
- path: p.optional(),
110
- style: c.optional(),
93
+ STYLE_ADD_SELECTOR: n.object({
94
+ displayMode: f,
95
+ selector: n.string(),
96
+ path: m.optional(),
97
+ type: h,
98
+ style: l.optional(),
111
99
  params: v
112
100
  }),
113
- STYLE_REMOVE_SELECTOR: t.object({
114
- displayMode: d,
115
- selector: t.string()
116
- }),
117
- STYLE_REMOVE_SELECTORS: t.object({
118
- displayMode: d,
119
- selectors: t.array(t.string())
120
- }),
121
- STYLE_ADD_SELECTOR_VARIABLE: x,
122
- STYLE_UPDATE_SELECTOR_VARIABLE: x,
123
- STYLE_REMOVE_SELECTOR_VARIABLE: S,
124
- STYLE_ADD_VARIABLE: C,
125
- STYLE_UPDATE_VARIABLE: C,
126
- STYLE_REMOVE_VARIABLE: t.object({
127
- category: g,
128
- name: t.string()
129
- }),
130
- STYLE_UPDATE_SETTINGS: t.object({
131
- path: t.string(),
132
- value: t.string()
133
- }),
134
- STYLE_ADD_FONT: t.object({ font: l }),
135
- STYLE_UPDATE_FONT: t.object({
136
- family: t.string(),
137
- font: l
138
- }),
139
- STYLE_REMOVE_FONT: t.object({ family: t.string() }),
140
- SEGMENT_ADD_ELEMENT: t.object({
141
- ...y,
142
- element: r,
143
- dropPosition: f,
144
- to: t.string(),
145
- initialItems: i.optional(),
146
- variables: t.array(s).optional()
147
- }),
148
- SEGMENT_UPDATE_ELEMENT: t.object({
149
- ...y,
150
- element: r
151
- }),
152
- SEGMENT_RENAME_ELEMENT: t.object({
153
- ...y,
154
- elementId: t.string(),
155
- id: t.string()
156
- }),
157
- SEGMENT_UPDATE_ELEMENTS: t.object({
158
- ...y,
159
- elements: i
160
- }),
161
- SEGMENT_REMOVE_ELEMENT: t.object({
162
- ...y,
163
- elementId: t.string()
164
- }),
165
- SEGMENT_MOVE_ELEMENT: t.object({
166
- ...y,
167
- elementId: t.string(),
168
- from: t.string(),
169
- to: t.string(),
170
- dropPosition: f
171
- }),
172
- SEGMENT_CLONE_ELEMENT: t.object({
173
- ...y,
174
- element: r,
175
- dropPosition: f,
176
- to: t.string(),
177
- initialItems: i.optional()
178
- }),
179
- SEGMENT_ADD_TEMPLATE: t.object({
180
- ...y,
181
- element: r,
182
- style: t.custom(n),
183
- to: t.string(),
184
- dropPosition: f,
185
- initialItems: i.optional(),
186
- variables: t.array(s).optional()
187
- }),
188
- SEGMENT_SPACE_ADD_VARIABLE: t.object({
189
- ...y,
190
- variable: s
191
- }),
192
- SEGMENT_SPACE_UPDATE_VARIABLE: t.object({
193
- ...y,
194
- variable: s
195
- }),
196
- SEGMENT_SPACE_REMOVE_VARIABLE: t.object({
197
- ...y,
198
- variable: t.object({ name: t.string() })
199
- }),
200
- SEGMENT_STYLE_ADD_SELECTOR: t.object({
201
- ...y,
202
- displayMode: d,
203
- selector: t.string(),
204
- type: m,
205
- path: p.optional(),
206
- style: c.optional(),
207
- params: _
208
- }),
209
- SEGMENT_STYLE_UPDATE_SELECTOR: t.object({
210
- ...y,
211
- displayMode: d,
212
- selector: t.string(),
213
- path: p.optional(),
214
- style: c.optional(),
101
+ STYLE_UPDATE_SELECTOR: n.object({
102
+ displayMode: f,
103
+ selector: n.string(),
104
+ path: m.optional(),
105
+ style: l.optional(),
106
+ params: y
107
+ }),
108
+ STYLE_REMOVE_SELECTOR: n.object({
109
+ displayMode: f,
110
+ selector: n.string()
111
+ }),
112
+ STYLE_REMOVE_SELECTORS: n.object({
113
+ displayMode: f,
114
+ selectors: n.array(n.string())
115
+ }),
116
+ STYLE_ADD_SELECTOR_VARIABLE: S,
117
+ STYLE_UPDATE_SELECTOR_VARIABLE: S,
118
+ STYLE_REMOVE_SELECTOR_VARIABLE: C,
119
+ STYLE_ADD_VARIABLE: w,
120
+ STYLE_UPDATE_VARIABLE: w,
121
+ STYLE_REMOVE_VARIABLE: n.object({
122
+ category: _,
123
+ name: n.string()
124
+ }),
125
+ STYLE_UPDATE_SETTINGS: n.object({
126
+ path: n.string(),
127
+ value: n.string()
128
+ }),
129
+ STYLE_ADD_FONT: n.object({ font: u }),
130
+ STYLE_UPDATE_FONT: n.object({
131
+ family: n.string(),
132
+ font: u
133
+ }),
134
+ STYLE_REMOVE_FONT: n.object({ family: n.string() }),
135
+ SEGMENT_ADD_ELEMENT: n.object({
136
+ ...b,
137
+ element: i,
138
+ dropPosition: p,
139
+ to: n.string(),
140
+ initialItems: a.optional(),
141
+ variables: n.array(c).optional()
142
+ }),
143
+ SEGMENT_UPDATE_ELEMENT: n.object({
144
+ ...b,
145
+ element: i
146
+ }),
147
+ SEGMENT_RENAME_ELEMENT: n.object({
148
+ ...b,
149
+ elementId: n.string(),
150
+ id: n.string()
151
+ }),
152
+ SEGMENT_UPDATE_ELEMENTS: n.object({
153
+ ...b,
154
+ elements: a
155
+ }),
156
+ SEGMENT_REMOVE_ELEMENT: n.object({
157
+ ...b,
158
+ elementId: n.string()
159
+ }),
160
+ SEGMENT_MOVE_ELEMENT: n.object({
161
+ ...b,
162
+ elementId: n.string(),
163
+ from: n.string(),
164
+ to: n.string(),
165
+ dropPosition: p
166
+ }),
167
+ SEGMENT_CLONE_ELEMENT: n.object({
168
+ ...b,
169
+ element: i,
170
+ dropPosition: p,
171
+ to: n.string(),
172
+ initialItems: a.optional()
173
+ }),
174
+ SEGMENT_ADD_TEMPLATE: n.object({
175
+ ...b,
176
+ element: i,
177
+ style: n.custom(r),
178
+ to: n.string(),
179
+ dropPosition: p,
180
+ initialItems: a.optional(),
181
+ variables: n.array(c).optional()
182
+ }),
183
+ SEGMENT_SPACE_ADD_VARIABLE: n.object({
184
+ ...b,
185
+ variable: c
186
+ }),
187
+ SEGMENT_SPACE_UPDATE_VARIABLE: n.object({
188
+ ...b,
189
+ variable: c
190
+ }),
191
+ SEGMENT_SPACE_REMOVE_VARIABLE: n.object({
192
+ ...b,
193
+ variable: n.object({ name: n.string() })
194
+ }),
195
+ SEGMENT_STYLE_ADD_SELECTOR: n.object({
196
+ ...b,
197
+ displayMode: f,
198
+ selector: n.string(),
199
+ type: h,
200
+ path: m.optional(),
201
+ style: l.optional(),
215
202
  params: v
216
203
  }),
217
- SEGMENT_STYLE_REMOVE_SELECTOR: t.object({
218
- ...y,
219
- displayMode: d,
220
- selector: t.string()
221
- }),
222
- SEGMENT_STYLE_REMOVE_SELECTORS: t.object({
223
- ...y,
224
- displayMode: d,
225
- selectors: t.array(t.string())
226
- }),
227
- SEGMENT_STYLE_ADD_SELECTOR_VARIABLE: x.extend(y),
228
- SEGMENT_STYLE_UPDATE_SELECTOR_VARIABLE: x.extend(y),
229
- SEGMENT_STYLE_REMOVE_SELECTOR_VARIABLE: S.extend(y),
230
- SEGMENT_STYLE_ADD_VARIABLE: C.extend(y),
231
- SEGMENT_STYLE_UPDATE_VARIABLE: C.extend(y),
232
- SEGMENT_STYLE_REMOVE_VARIABLE: t.object({
233
- ...y,
234
- category: g,
235
- name: t.string()
204
+ SEGMENT_STYLE_UPDATE_SELECTOR: n.object({
205
+ ...b,
206
+ displayMode: f,
207
+ selector: n.string(),
208
+ path: m.optional(),
209
+ style: l.optional(),
210
+ params: y
211
+ }),
212
+ SEGMENT_STYLE_REMOVE_SELECTOR: n.object({
213
+ ...b,
214
+ displayMode: f,
215
+ selector: n.string()
216
+ }),
217
+ SEGMENT_STYLE_REMOVE_SELECTORS: n.object({
218
+ ...b,
219
+ displayMode: f,
220
+ selectors: n.array(n.string())
221
+ }),
222
+ SEGMENT_STYLE_ADD_SELECTOR_VARIABLE: S.extend(b),
223
+ SEGMENT_STYLE_UPDATE_SELECTOR_VARIABLE: S.extend(b),
224
+ SEGMENT_STYLE_REMOVE_SELECTOR_VARIABLE: C.extend(b),
225
+ SEGMENT_STYLE_ADD_VARIABLE: w.extend(b),
226
+ SEGMENT_STYLE_UPDATE_VARIABLE: w.extend(b),
227
+ SEGMENT_STYLE_REMOVE_VARIABLE: n.object({
228
+ ...b,
229
+ category: _,
230
+ name: n.string()
236
231
  })
237
- }, T = Object.fromEntries(Object.keys(w).map((e) => [e, e])), E = (e, t) => {
238
- let n = w[e];
232
+ }, E = Object.fromEntries(Object.keys(T).map((e) => [e, e])), D = (e, t) => {
233
+ let n = T[e];
239
234
  if (!n) return {
240
235
  ok: !1,
241
236
  issues: [{
@@ -256,4 +251,4 @@ var n = (e) => typeof e == "object" && !!e && !Array.isArray(e), r = t.custom((e
256
251
  };
257
252
  };
258
253
  //#endregion
259
- export { T as SpaceEvents, T as default, w as spaceEventSchemas, E as validateSpaceEvent };
254
+ export { E as SpaceEvents, E as default, T as spaceEventSchemas, D as validateSpaceEvent };
@@ -24,12 +24,22 @@ export type QueriesState = {
24
24
  };
25
25
  export type QueryObserverOptions<T> = {
26
26
  meta: QueryMeta;
27
- fetcher: () => Promise<T>;
27
+ /** Given the signal of the request it is making, so an answer nobody can still read is not waited for. */
28
+ fetcher: (signal: AbortSignal) => Promise<T>;
28
29
  /** How long an answer counts as current, in milliseconds. `0` asks again on every mount. */
29
30
  staleTime: number;
30
31
  /** An answer this rejects is shown but never trusted: the next observer to mount asks again. */
31
32
  isCacheable?: (data: T) => boolean;
32
33
  };
34
+ /**
35
+ * What is keeping a query, for the devtools: a query nobody renders is not a leak, it is the grace period doing its
36
+ * job — but that is only obvious if the panel can say so, and offer to end it.
37
+ */
38
+ export type QueryUsage = {
39
+ observers: number;
40
+ holds: number;
41
+ collectAt?: number;
42
+ };
33
43
  /**
34
44
  * One path segment per key.
35
45
  *
@@ -65,6 +75,17 @@ export declare class QueryCache {
65
75
  getEntry(key: string): QueryEntry | undefined;
66
76
  /** Whether `key` has been answered in this session — every answer is written with a TTL, even a distrusted one. */
67
77
  hasAnswer(key: string): boolean;
78
+ /** Who is keeping `key` alive, and when it would be forgotten if nobody else asked for it. */
79
+ usage(key: string): QueryUsage | undefined;
80
+ /**
81
+ * Forgets `key` now: the answer, the grace period and the request still out for it.
82
+ *
83
+ * The grace period is what keeps an answer around for somebody coming back, and there is no reason to wait it out
84
+ * when a reader knows they will not — a devtools panel clearing what a page stopped using, a flow dropping what a
85
+ * sign-out made meaningless. A query something still renders is left alone: dropping what is on screen leaves it
86
+ * with nothing and nothing to ask again, since the observer that would ask is already attached.
87
+ */
88
+ remove(key: string): boolean;
68
89
  /**
69
90
  * Keeps `key` from being collected for as long as the returned function is not called, and for `gcTime` after.
70
91
  * The latest reader's `gcTime` is the one kept.
@@ -93,8 +114,24 @@ export declare class QueryCache {
93
114
  *
94
115
  * Invalidating would not do: a stale query still SHOWS what it holds until the new answer lands, and what it holds
95
116
  * belongs to the previous visitor. The epoch makes a request still in flight from before land nowhere.
117
+ *
118
+ * `refetch` is what becomes of the queries still on screen. As somebody else, they are asked again, so the page in
119
+ * front of the new person is theirs. As NOBODY it is a sign-out, and there is no one to ask on behalf of: asking
120
+ * anyway was one refusal per provider still mounted, each reported as a failed session, for a page already on its
121
+ * way to the guest view.
122
+ */
123
+ reset({ refetch }?: {
124
+ refetch?: boolean;
125
+ }): Promise<void>;
126
+ /**
127
+ * Holding nothing and asking for nothing — the state a query is left in when the answers are forgotten and nobody
128
+ * asks again.
129
+ *
130
+ * Without it the entry is simply gone, and a reader takes that for "about to be asked": it renders as loading for
131
+ * as long as it stays mounted, because the observer that would ask is already attached and nothing re-runs it.
132
+ * Written with no life at all, so the next mount asks.
96
133
  */
97
- reset(): Promise<void>;
134
+ private markUnasked;
98
135
  /**
99
136
  * Expiring the path is the invalidation: {@link onExpired} does the rest, for this call and for anybody else who
100
137
  * expires a query's path — the dev-tools' "Expire" included. A query that has never answered has no record to
@@ -25,6 +25,18 @@ var t = 3e5, n = (e) => {
25
25
  hasAnswer(e) {
26
26
  return this.getEntry(e) !== void 0 && this.store.getFreshness(r(e)) !== void 0;
27
27
  }
28
+ usage(e) {
29
+ let t = this.runtimes.get(n(e));
30
+ return t && {
31
+ observers: t.observers.size,
32
+ holds: t.holds,
33
+ collectAt: t.collectAt
34
+ };
35
+ }
36
+ remove(e) {
37
+ let t = this.runtimes.get(n(e));
38
+ return !t || t.observers.size > 0 || t.holds > 0 ? !1 : (this.cancelGc(t), this.collect(t), !0);
39
+ }
28
40
  hold(e, n = t) {
29
41
  let r = this.ensure(e);
30
42
  return r.gcTime = n, r.holds++, this.cancelGc(r), () => {
@@ -69,12 +81,23 @@ var t = 3e5, n = (e) => {
69
81
  }) || t.push(this.invalidateOne(n));
70
82
  }), Promise.all(t).then(() => void 0);
71
83
  }
72
- reset() {
73
- this.epochValue++, this.runtimes.forEach((e) => {
74
- e.version++, e.inFlight = void 0;
75
- }), this.store.setState("entries", {});
76
- let e = [];
77
- return this.runtimes.forEach((t) => e.push(this.fetchActive(t))), Promise.all(e).then(() => void 0);
84
+ reset({ refetch: e = !0 } = {}) {
85
+ if (this.epochValue++, this.runtimes.forEach((e) => {
86
+ e.version++, e.inFlight = void 0, e.controller?.abort(), e.controller = void 0;
87
+ }), this.store.setState("entries", {}), !e) return this.runtimes.forEach((e) => this.markUnasked(e)), Promise.resolve();
88
+ let t = [];
89
+ return this.runtimes.forEach((e) => t.push(this.fetchActive(e))), Promise.all(t).then(() => void 0);
90
+ }
91
+ markUnasked(e) {
92
+ let t = e.observers.values().next();
93
+ if (t.done) return;
94
+ let n = {
95
+ key: e.key,
96
+ url: t.value.meta.url,
97
+ tags: [...e.tags],
98
+ isFetching: !1
99
+ };
100
+ this.store.setState(r(e.key), n, { ttl: 0 });
78
101
  }
79
102
  invalidateOne(e) {
80
103
  return this.store.expire(r(e.key)).length === 0 && e.version++, this.fetchActive(e);
@@ -100,7 +123,7 @@ var t = 3e5, n = (e) => {
100
123
  });
101
124
  let c = this.epochValue, l = e.version, u = (r) => {
102
125
  if (c !== this.epochValue || this.runtimes.get(n(i)) !== e) return Promise.resolve();
103
- e.inFlight = void 0;
126
+ e.inFlight = void 0, e.controller = void 0;
104
127
  let u = l !== e.version;
105
128
  if ("error" in r) {
106
129
  let e = this.getEntry(i);
@@ -123,8 +146,8 @@ var t = 3e5, n = (e) => {
123
146
  }, { ttl: n ? this.ttlOf(e, t) : 0 });
124
147
  }
125
148
  return u ? this.fetchActive(e) : Promise.resolve();
126
- };
127
- return e.inFlight = t.fetcher().then((e) => u({ data: e }), (e) => u({ error: e })), e.inFlight;
149
+ }, d = new AbortController();
150
+ return e.controller = d, e.inFlight = t.fetcher(d.signal).then((e) => u({ data: e }), (e) => u({ error: e })), e.inFlight;
128
151
  }
129
152
  ttlOf(e, t) {
130
153
  let n = e.observers.size > 0 ? Infinity : t.staleTime;
@@ -146,7 +169,7 @@ var t = 3e5, n = (e) => {
146
169
  }), i;
147
170
  }
148
171
  cancelGc(e) {
149
- clearTimeout(e.gcTimer), e.gcTimer = void 0;
172
+ clearTimeout(e.gcTimer), e.gcTimer = void 0, e.collectAt = void 0;
150
173
  }
151
174
  scheduleGc(e) {
152
175
  if (!(e.holds > 0 || e.observers.size > 0)) {
@@ -154,12 +177,12 @@ var t = 3e5, n = (e) => {
154
177
  this.collect(e);
155
178
  return;
156
179
  }
157
- e.gcTimer = setTimeout(() => this.collect(e), e.gcTime);
180
+ e.collectAt = Date.now() + e.gcTime, e.gcTimer = setTimeout(() => this.collect(e), e.gcTime);
158
181
  }
159
182
  }
160
183
  collect(e) {
161
184
  let t = n(e.key);
162
- this.runtimes.get(t) === e && e.holds === 0 && e.observers.size === 0 && (this.runtimes.delete(t), this.store.setState(r(e.key), void 0, { unmount: !0 }));
185
+ this.runtimes.get(t) === e && e.holds === 0 && e.observers.size === 0 && (this.runtimes.delete(t), e.controller?.abort(), this.store.setState(r(e.key), void 0, { unmount: !0 }));
163
186
  }
164
187
  }, a = new i();
165
188
  //#endregion
@@ -3,7 +3,7 @@ export type UseQueryOptions<T> = {
3
3
  /** What identifies the answer. Without one the hook is inert: it reads, holds and asks for nothing. */
4
4
  key: string | undefined;
5
5
  meta: QueryMeta;
6
- fetcher: () => Promise<T>;
6
+ fetcher: (signal: AbortSignal) => Promise<T>;
7
7
  enabled?: boolean;
8
8
  /** How long an answer counts as current, in milliseconds. */
9
9
  staleTime: number;
@@ -18,7 +18,7 @@ var { useStore: s } = o(), c = ({ key: o, meta: c, fetcher: l, enabled: u = !0,
18
18
  tags: x ? x.split("\0") : []
19
19
  },
20
20
  staleTime: d,
21
- fetcher: () => v.current(),
21
+ fetcher: (e) => v.current(e),
22
22
  isCacheable: (e) => y.current?.(e) ?? !0
23
23
  });
24
24
  }, [
@@ -1,5 +1,6 @@
1
1
  import { default as SchemaContext } from './SchemaContext';
2
2
  export * from './schemaConstants';
3
3
  export * from './SchemaContext';
4
+ export * from './layoutChain';
4
5
  export * from './serverElements';
5
6
  export { SchemaContext };