@sylwellsoftware/glue 0.8.0 → 0.9.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 +59 -8
- package/dist/emitters/liveQuery.d.ts +20 -0
- package/dist/emitters/liveQuery.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +256 -225
- package/dist/index.js.map +1 -1
- package/dist/queryhandling/endpoints.d.ts +2 -1
- package/dist/queryhandling/endpoints.d.ts.map +1 -1
- package/package.json +11 -9
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (t, r, e) =>
|
|
4
|
-
let
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var H = (t, r, e) => r in t ? U(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
|
+
var n = (t, r, e) => H(t, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
let F = 1;
|
|
5
5
|
class b {
|
|
6
6
|
constructor(r = {}) {
|
|
7
7
|
n(this, "id");
|
|
@@ -18,9 +18,9 @@ class b {
|
|
|
18
18
|
var s;
|
|
19
19
|
if (r == null || typeof r != "object" || Array.isArray(r))
|
|
20
20
|
throw new TypeError("EventBubble options must be an object");
|
|
21
|
-
this.id = `event-${
|
|
21
|
+
this.id = `event-${F++}`, this.timestamp = r.timestamp ?? Date.now(), this.purpose = r.purpose ?? "unspecified", this.cause = r.cause ?? null, this.value = r.value, this.parent = r.parent ?? null, this.parentBubble = this.parent;
|
|
22
22
|
const e = r.owner;
|
|
23
|
-
this.ownerType = e == null ? null :
|
|
23
|
+
this.ownerType = e == null ? null : _(e) ?? typeof e, B(e) && typeof WeakRef == "function" ? (this.ownerRef = new WeakRef(e), this.strongOwner = void 0) : (this.ownerRef = null, this.strongOwner = e), (s = this.parent) == null || s.registerChild(this);
|
|
24
24
|
}
|
|
25
25
|
get owner() {
|
|
26
26
|
var r;
|
|
@@ -35,7 +35,7 @@ class b {
|
|
|
35
35
|
function B(t) {
|
|
36
36
|
return typeof t == "object" && t !== null || typeof t == "function";
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function _(t) {
|
|
39
39
|
const r = Reflect.get(t, "constructor");
|
|
40
40
|
if (r == null || typeof r != "object" && typeof r != "function")
|
|
41
41
|
return;
|
|
@@ -70,23 +70,23 @@ const w = Object.freeze({
|
|
|
70
70
|
get subscriberCount() {
|
|
71
71
|
return m.size;
|
|
72
72
|
}
|
|
73
|
-
}),
|
|
73
|
+
}), a = Object.freeze({
|
|
74
74
|
Error: "error",
|
|
75
75
|
Loading: "loading",
|
|
76
76
|
Initial: "initial",
|
|
77
77
|
Ready: "ready"
|
|
78
78
|
}), S = /* @__PURE__ */ new Map([
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
79
|
+
[a.Ready, 1],
|
|
80
|
+
[a.Initial, 2],
|
|
81
|
+
[a.Loading, 3],
|
|
82
|
+
[a.Error, 4]
|
|
83
83
|
]);
|
|
84
|
-
function
|
|
85
|
-
let r =
|
|
84
|
+
function T(t) {
|
|
85
|
+
let r = a.Ready;
|
|
86
86
|
for (const e of t) {
|
|
87
87
|
if (!S.has(e))
|
|
88
88
|
throw new TypeError(`Unknown fetch state: ${String(e)}`);
|
|
89
|
-
if ((S.get(e) ?? 0) > (S.get(r) ?? 0) && (r = e), r ===
|
|
89
|
+
if ((S.get(e) ?? 0) > (S.get(r) ?? 0) && (r = e), r === a.Error) break;
|
|
90
90
|
}
|
|
91
91
|
return r;
|
|
92
92
|
}
|
|
@@ -103,7 +103,7 @@ class g {
|
|
|
103
103
|
n(this, "trace");
|
|
104
104
|
if (e == null || typeof e != "object" || Array.isArray(e))
|
|
105
105
|
throw new TypeError("Emitter options must be an object");
|
|
106
|
-
if (this.value = r, this.fetchState = e.fetchState ??
|
|
106
|
+
if (this.value = r, this.fetchState = e.fetchState ?? a.Ready, this.error = e.error ?? null, this.equals = e.equals ?? Object.is, this.owner = e.owner, this.purpose = e.purpose ?? this.constructor.name, this.trace = e.trace ?? !1, typeof this.equals != "function")
|
|
107
107
|
throw new TypeError("Emitter equals option must be a function");
|
|
108
108
|
R(this.fetchState);
|
|
109
109
|
}
|
|
@@ -113,14 +113,14 @@ class g {
|
|
|
113
113
|
throw new TypeError("subscribe requires a function");
|
|
114
114
|
if (e == null || typeof e != "object" || Array.isArray(e))
|
|
115
115
|
throw new TypeError("subscribe options must be an object");
|
|
116
|
-
const { emitCurrent: s = !0, parentEvent:
|
|
116
|
+
const { emitCurrent: s = !0, parentEvent: o = null } = e;
|
|
117
117
|
if (this.subscribers.add(r), s) {
|
|
118
|
-
const
|
|
119
|
-
r(this.notification(
|
|
118
|
+
const c = this.createEvent("subscribed", o, this.value);
|
|
119
|
+
r(this.notification(c));
|
|
120
120
|
}
|
|
121
|
-
let
|
|
121
|
+
let i = !0;
|
|
122
122
|
return () => {
|
|
123
|
-
|
|
123
|
+
i && (i = !1, this.subscribers.delete(r));
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
subscribeFutureValues(r) {
|
|
@@ -143,7 +143,7 @@ class g {
|
|
|
143
143
|
}
|
|
144
144
|
map(r, e = {}) {
|
|
145
145
|
if (typeof r != "function") throw new TypeError("map requires a function");
|
|
146
|
-
return new
|
|
146
|
+
return new x(
|
|
147
147
|
[this],
|
|
148
148
|
([s]) => r(s),
|
|
149
149
|
{
|
|
@@ -156,11 +156,11 @@ class g {
|
|
|
156
156
|
}
|
|
157
157
|
mapEach(r, e = {}) {
|
|
158
158
|
if (typeof r != "function") throw new TypeError("mapEach requires a function");
|
|
159
|
-
return new
|
|
159
|
+
return new x([this], ([s]) => {
|
|
160
160
|
if (s == null) return s;
|
|
161
161
|
if (!Array.isArray(s))
|
|
162
162
|
throw new TypeError("mapEach source value must be an array");
|
|
163
|
-
return s.map((
|
|
163
|
+
return s.map((i, c) => i == null ? i : r(i, c));
|
|
164
164
|
}, {
|
|
165
165
|
...e,
|
|
166
166
|
purpose: e.purpose ?? `${this.purpose}:mapEach`
|
|
@@ -184,47 +184,47 @@ class g {
|
|
|
184
184
|
}
|
|
185
185
|
setSnapshot(r = {}) {
|
|
186
186
|
if (this.isDisposed) return !1;
|
|
187
|
-
const e = Object.hasOwn(r, "value") ? r.value : this.value, s = r.fetchState ?? this.fetchState,
|
|
188
|
-
if (R(s), !(!this.equals(this.value, e) || this.fetchState !== s || !Object.is(this.error,
|
|
189
|
-
this.value = e, this.fetchState = s, this.error =
|
|
190
|
-
const
|
|
191
|
-
return this.notify(
|
|
187
|
+
const e = Object.hasOwn(r, "value") ? r.value : this.value, s = r.fetchState ?? this.fetchState, o = Object.hasOwn(r, "error") ? r.error : this.error, i = r.cause ?? "state changed", c = r.parentEvent ?? null;
|
|
188
|
+
if (R(s), !(!this.equals(this.value, e) || this.fetchState !== s || !Object.is(this.error, o))) return !1;
|
|
189
|
+
this.value = e, this.fetchState = s, this.error = o;
|
|
190
|
+
const u = this.createEvent(i, c, e);
|
|
191
|
+
return this.notify(u), !0;
|
|
192
192
|
}
|
|
193
193
|
createEvent(r, e = null, s = this.value) {
|
|
194
194
|
if (!this.trace && !e && !w.hasSubscribers) return null;
|
|
195
|
-
const
|
|
195
|
+
const o = new b({
|
|
196
196
|
owner: this.owner ?? this,
|
|
197
197
|
purpose: this.purpose,
|
|
198
198
|
value: s,
|
|
199
199
|
cause: r,
|
|
200
200
|
parent: e
|
|
201
201
|
});
|
|
202
|
-
return e || w.emit(
|
|
202
|
+
return e || w.emit(o), o;
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
class
|
|
206
|
-
constructor(e, s,
|
|
207
|
-
const { computeFetchState:
|
|
205
|
+
class x extends g {
|
|
206
|
+
constructor(e, s, o = {}) {
|
|
207
|
+
const { computeFetchState: i = T, ...c } = o;
|
|
208
208
|
super(void 0, {
|
|
209
|
-
...
|
|
210
|
-
fetchState:
|
|
209
|
+
...c,
|
|
210
|
+
fetchState: a.Initial,
|
|
211
211
|
error: null
|
|
212
212
|
});
|
|
213
213
|
n(this, "sources");
|
|
214
214
|
n(this, "sourceUnsubscribers", []);
|
|
215
215
|
n(this, "compute");
|
|
216
216
|
n(this, "computeFetchState");
|
|
217
|
-
this.sources = [], this.compute = s, this.computeFetchState =
|
|
217
|
+
this.sources = [], this.compute = s, this.computeFetchState = i, this.setSourcesAndCompute(e, s, { notify: !1 });
|
|
218
218
|
}
|
|
219
|
-
setSourcesAndCompute(e, s = this.compute,
|
|
219
|
+
setSourcesAndCompute(e, s = this.compute, o = {}) {
|
|
220
220
|
if (this.isDisposed) throw new Error("Cannot update a disposed derived emitter");
|
|
221
|
-
if (!Array.isArray(e) || e.some((
|
|
221
|
+
if (!Array.isArray(e) || e.some((i) => !k(i)))
|
|
222
222
|
throw new TypeError("DerivedEmitter sources must be an array of emitters");
|
|
223
223
|
if (typeof s != "function")
|
|
224
224
|
throw new TypeError("DerivedEmitter compute must be a function");
|
|
225
225
|
return this.releaseSources(), this.sources = [...e], this.compute = s, this.sourceUnsubscribers = this.sources.map(
|
|
226
|
-
(
|
|
227
|
-
), this.recompute(
|
|
226
|
+
(i) => i.subscribe(({ event: c }) => this.recompute(c), { emitCurrent: !1 })
|
|
227
|
+
), this.recompute(o.parentEvent ?? null, o.notify ?? !0), this;
|
|
228
228
|
}
|
|
229
229
|
dispose() {
|
|
230
230
|
this.isDisposed || (this.releaseSources(), super.dispose());
|
|
@@ -234,21 +234,21 @@ class D extends g {
|
|
|
234
234
|
this.sourceUnsubscribers = [];
|
|
235
235
|
}
|
|
236
236
|
recompute(e = null, s = !0) {
|
|
237
|
-
const
|
|
238
|
-
let
|
|
237
|
+
const o = this.sources.map((d) => d.get()), i = this.sources.map((d) => d.getFetchState()), c = this.sources.map((d, v) => ({ sourceIndex: v, error: d.getError() })).filter((d) => d.error != null);
|
|
238
|
+
let f, u = null;
|
|
239
239
|
try {
|
|
240
|
-
|
|
240
|
+
f = this.compute(o);
|
|
241
241
|
} catch (d) {
|
|
242
|
-
|
|
242
|
+
u = d, f = void 0;
|
|
243
243
|
}
|
|
244
|
-
const
|
|
245
|
-
let l = this.computeFetchState(
|
|
246
|
-
if (R(l), (
|
|
247
|
-
this.value =
|
|
244
|
+
const h = u == null ? c : [...c, { sourceIndex: null, error: u }], p = $(this.error, h);
|
|
245
|
+
let l = this.computeFetchState(i);
|
|
246
|
+
if (R(l), (u != null || c.length > 0) && (l = a.Error), !s) {
|
|
247
|
+
this.value = f, this.fetchState = l, this.error = p;
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
250
|
this.setSnapshot({
|
|
251
|
-
value:
|
|
251
|
+
value: f,
|
|
252
252
|
fetchState: l,
|
|
253
253
|
error: p,
|
|
254
254
|
cause: "derived source changed",
|
|
@@ -256,28 +256,28 @@ class D extends g {
|
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function $(t, r) {
|
|
260
260
|
return r.length === 0 ? null : t != null && t.length === r.length && t.every((e, s) => {
|
|
261
|
-
var
|
|
262
|
-
return e.sourceIndex === ((
|
|
261
|
+
var o, i;
|
|
262
|
+
return e.sourceIndex === ((o = r[s]) == null ? void 0 : o.sourceIndex) && Object.is(e.error, (i = r[s]) == null ? void 0 : i.error);
|
|
263
263
|
}) ? t : Object.freeze(r.map((e) => Object.freeze(e)));
|
|
264
264
|
}
|
|
265
265
|
function k(t) {
|
|
266
266
|
return (typeof t != "object" || t === null) && typeof t != "function" ? !1 : typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "getFetchState") == "function" && typeof Reflect.get(t, "getError") == "function" && typeof Reflect.get(t, "subscribe") == "function";
|
|
267
267
|
}
|
|
268
268
|
function R(t) {
|
|
269
|
-
|
|
269
|
+
T([t]);
|
|
270
270
|
}
|
|
271
|
-
class
|
|
271
|
+
class z extends g {
|
|
272
272
|
constructor(r, e = {}) {
|
|
273
273
|
super(r, e);
|
|
274
274
|
}
|
|
275
|
-
setWithState(r, e =
|
|
276
|
-
const
|
|
277
|
-
return this.setSnapshot({ value: r, fetchState: e, error: s, cause:
|
|
275
|
+
setWithState(r, e = a.Ready, s = null, o = null) {
|
|
276
|
+
const i = o instanceof b ? o : null, c = i ? "set called" : o ?? "set called";
|
|
277
|
+
return this.setSnapshot({ value: r, fetchState: e, error: s, cause: c, parentEvent: i });
|
|
278
278
|
}
|
|
279
279
|
set(r, e = null) {
|
|
280
|
-
return this.setWithState(r,
|
|
280
|
+
return this.setWithState(r, a.Ready, null, e);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
class M extends Error {
|
|
@@ -285,25 +285,25 @@ class M extends Error {
|
|
|
285
285
|
super("AsyncCommand is already running"), this.name = "AsyncCommandConcurrencyError";
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
class
|
|
288
|
+
class pe extends g {
|
|
289
289
|
constructor(e) {
|
|
290
290
|
N(e);
|
|
291
291
|
const {
|
|
292
292
|
execute: s,
|
|
293
|
-
concurrency:
|
|
294
|
-
mapError:
|
|
295
|
-
owner:
|
|
296
|
-
purpose:
|
|
297
|
-
trace:
|
|
293
|
+
concurrency: o = "ignore",
|
|
294
|
+
mapError: i = (h) => h,
|
|
295
|
+
owner: c,
|
|
296
|
+
purpose: f = "async command",
|
|
297
|
+
trace: u
|
|
298
298
|
} = e;
|
|
299
|
-
if (W(
|
|
299
|
+
if (W(o), typeof i != "function")
|
|
300
300
|
throw new TypeError("AsyncCommand mapError must be a function");
|
|
301
301
|
super(void 0, {
|
|
302
|
-
fetchState:
|
|
302
|
+
fetchState: a.Initial,
|
|
303
303
|
error: null,
|
|
304
|
-
owner:
|
|
305
|
-
purpose:
|
|
306
|
-
...
|
|
304
|
+
owner: c,
|
|
305
|
+
purpose: f,
|
|
306
|
+
...u === void 0 ? {} : { trace: u }
|
|
307
307
|
});
|
|
308
308
|
n(this, "execute");
|
|
309
309
|
n(this, "concurrency");
|
|
@@ -316,10 +316,10 @@ class fe extends g {
|
|
|
316
316
|
n(this, "hasSuccessfulValue", !1);
|
|
317
317
|
/** Exposed for deterministic tests; consumers should use run()/abort(). */
|
|
318
318
|
n(this, "_activeRequest", null);
|
|
319
|
-
this.execute = s, this.concurrency =
|
|
320
|
-
owner:
|
|
321
|
-
purpose: `${
|
|
322
|
-
...
|
|
319
|
+
this.execute = s, this.concurrency = o, this.mapError = i, this.runningEmitter = new z(!1, {
|
|
320
|
+
owner: c ?? this,
|
|
321
|
+
purpose: `${f}:running`,
|
|
322
|
+
...u === void 0 ? {} : { trace: u }
|
|
323
323
|
}), this.isRunning = this.runningEmitter;
|
|
324
324
|
}
|
|
325
325
|
run(e, s = "command run") {
|
|
@@ -331,51 +331,51 @@ class fe extends g {
|
|
|
331
331
|
return Promise.reject(new M());
|
|
332
332
|
(p = this.abortController) == null || p.abort();
|
|
333
333
|
}
|
|
334
|
-
const
|
|
335
|
-
this.abortController =
|
|
336
|
-
const
|
|
334
|
+
const o = ++this.requestId, i = G();
|
|
335
|
+
this.abortController = i;
|
|
336
|
+
const c = s instanceof b ? s : null, f = c ? "parent command requested" : s;
|
|
337
337
|
this.setSnapshot({
|
|
338
338
|
value: this.lastSuccessfulValue,
|
|
339
|
-
fetchState:
|
|
339
|
+
fetchState: a.Loading,
|
|
340
340
|
error: null,
|
|
341
|
-
cause:
|
|
342
|
-
parentEvent:
|
|
341
|
+
cause: f,
|
|
342
|
+
parentEvent: c
|
|
343
343
|
});
|
|
344
|
-
const
|
|
345
|
-
this.runningEmitter.set(!0,
|
|
346
|
-
const
|
|
347
|
-
signal:
|
|
348
|
-
event:
|
|
344
|
+
const u = this.createEvent("command execute", c, e);
|
|
345
|
+
this.runningEmitter.set(!0, u ?? f);
|
|
346
|
+
const h = Promise.resolve().then(() => this.execute(e, {
|
|
347
|
+
signal: i.signal,
|
|
348
|
+
event: u
|
|
349
349
|
})).then((l) => {
|
|
350
|
-
if (this.isCurrentRequest(
|
|
350
|
+
if (this.isCurrentRequest(o, i))
|
|
351
351
|
return this.lastSuccessfulValue = l, this.hasSuccessfulValue = !0, this.setSnapshot({
|
|
352
352
|
value: l,
|
|
353
|
-
fetchState:
|
|
353
|
+
fetchState: a.Ready,
|
|
354
354
|
error: null,
|
|
355
355
|
cause: "command succeeded",
|
|
356
|
-
parentEvent:
|
|
356
|
+
parentEvent: u
|
|
357
357
|
}), l;
|
|
358
358
|
}).catch((l) => {
|
|
359
|
-
this.isCurrentRequest(
|
|
359
|
+
this.isCurrentRequest(o, i) && this.setSnapshot({
|
|
360
360
|
value: this.lastSuccessfulValue,
|
|
361
|
-
fetchState:
|
|
361
|
+
fetchState: a.Error,
|
|
362
362
|
error: this.mapCommandError(l),
|
|
363
363
|
cause: "command failed",
|
|
364
|
-
parentEvent:
|
|
364
|
+
parentEvent: u
|
|
365
365
|
});
|
|
366
366
|
}).finally(() => {
|
|
367
|
-
this.isCurrentRequest(
|
|
367
|
+
this.isCurrentRequest(o, i) && (this.abortController = null, this._activeRequest = null, this.runningEmitter.set(!1, u ?? "command settled"));
|
|
368
368
|
});
|
|
369
|
-
return this._activeRequest =
|
|
369
|
+
return this._activeRequest = h, h;
|
|
370
370
|
}
|
|
371
371
|
abort(e = "command aborted") {
|
|
372
372
|
if (this.isDisposed || this.abortController == null) return !1;
|
|
373
|
-
const s = e instanceof b ? e : null,
|
|
374
|
-
return this.requestId += 1, this.abortController.abort(), this.abortController = null, this._activeRequest = null, this.runningEmitter.set(!1, s ??
|
|
373
|
+
const s = e instanceof b ? e : null, o = s ? "parent command aborted" : e;
|
|
374
|
+
return this.requestId += 1, this.abortController.abort(), this.abortController = null, this._activeRequest = null, this.runningEmitter.set(!1, s ?? o), this.setSnapshot({
|
|
375
375
|
value: this.lastSuccessfulValue,
|
|
376
|
-
fetchState: this.hasSuccessfulValue ?
|
|
376
|
+
fetchState: this.hasSuccessfulValue ? a.Ready : a.Initial,
|
|
377
377
|
error: null,
|
|
378
|
-
cause:
|
|
378
|
+
cause: o,
|
|
379
379
|
parentEvent: s
|
|
380
380
|
}), !0;
|
|
381
381
|
}
|
|
@@ -385,7 +385,7 @@ class fe extends g {
|
|
|
385
385
|
const s = e instanceof b ? e : null;
|
|
386
386
|
this.setSnapshot({
|
|
387
387
|
value: void 0,
|
|
388
|
-
fetchState:
|
|
388
|
+
fetchState: a.Initial,
|
|
389
389
|
error: null,
|
|
390
390
|
cause: s ? "parent command reset" : e,
|
|
391
391
|
parentEvent: s
|
|
@@ -422,36 +422,40 @@ function G() {
|
|
|
422
422
|
throw new Error("AsyncCommand requires AbortController in this runtime");
|
|
423
423
|
return new t();
|
|
424
424
|
}
|
|
425
|
-
class
|
|
425
|
+
class D extends g {
|
|
426
426
|
constructor(e) {
|
|
427
427
|
if (e == null || typeof e != "object" || Array.isArray(e))
|
|
428
428
|
throw new TypeError("LiveQuery options must be an object");
|
|
429
429
|
const {
|
|
430
430
|
handler: s,
|
|
431
|
-
args:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
431
|
+
args: o = {},
|
|
432
|
+
execution: i,
|
|
433
|
+
autoFetch: c = !0,
|
|
434
|
+
keepPreviousValue: f = !0,
|
|
435
|
+
polling: u,
|
|
436
|
+
owner: h,
|
|
437
|
+
purpose: p = "live query",
|
|
438
|
+
trace: l
|
|
438
439
|
} = e;
|
|
439
440
|
if (s == null || typeof s.fetch != "function")
|
|
440
441
|
throw new TypeError("LiveQuery handler must implement fetch()");
|
|
441
|
-
|
|
442
|
+
Y(o), u != null && K(u), X(i, e.autoFetch, u);
|
|
442
443
|
super(void 0, {
|
|
443
|
-
fetchState:
|
|
444
|
+
fetchState: a.Initial,
|
|
444
445
|
error: null,
|
|
445
|
-
owner:
|
|
446
|
-
purpose:
|
|
447
|
-
...
|
|
446
|
+
owner: h,
|
|
447
|
+
purpose: p,
|
|
448
|
+
...l === void 0 ? {} : { trace: l }
|
|
448
449
|
});
|
|
449
450
|
n(this, "handler");
|
|
450
451
|
n(this, "args");
|
|
451
452
|
n(this, "keepPreviousValue");
|
|
453
|
+
n(this, "execution");
|
|
452
454
|
n(this, "lastSuccessfulValue");
|
|
453
455
|
n(this, "hasSuccessfulValue", !1);
|
|
454
|
-
n(this, "
|
|
456
|
+
n(this, "automaticTriggersInitialized", !1);
|
|
457
|
+
n(this, "activated");
|
|
458
|
+
n(this, "argumentUnsubscribers", []);
|
|
455
459
|
n(this, "pollingUnsubscribers", []);
|
|
456
460
|
n(this, "polling");
|
|
457
461
|
n(this, "pollingScheduler");
|
|
@@ -460,56 +464,68 @@ class I extends g {
|
|
|
460
464
|
n(this, "abortController", null);
|
|
461
465
|
/** Exposed for deterministic tests; consumers should use refresh()/retry(). */
|
|
462
466
|
n(this, "_activeRequest", null);
|
|
463
|
-
this.handler = s, this.args = { ...
|
|
464
|
-
(l) => l.subscribe(({ event: d }) => {
|
|
465
|
-
this.refresh(d);
|
|
466
|
-
}, { emitCurrent: !1 })
|
|
467
|
-
), a != null && this.initializePolling(a), o && (this._activeRequest = this.refresh("initial fetch")), this.scheduleNextPoll();
|
|
467
|
+
this.handler = s, this.args = { ...o }, this.keepPreviousValue = f, this.execution = i ?? null, this.activated = i !== "deferred", this.polling = u, this.pollingScheduler = (u == null ? void 0 : u.scheduler) ?? J, this.lastSuccessfulValue = void 0, i !== "deferred" && i !== "explicit" && this.initializeAutomaticTriggers(), (i === "immediate" || i == null && c) && (this._activeRequest = this.executeRequest("initial fetch")), this.scheduleNextPoll();
|
|
468
468
|
}
|
|
469
469
|
get argumentValues() {
|
|
470
470
|
return Object.fromEntries(
|
|
471
471
|
Object.entries(this.args).map(([e, s]) => [e, s.get()])
|
|
472
472
|
);
|
|
473
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Activates a deferred query exactly once. Concurrent callers share the
|
|
476
|
+
* first request; later calls return the current value without reloading.
|
|
477
|
+
*/
|
|
478
|
+
activate(e = "query activated") {
|
|
479
|
+
if (this.isDisposed) return Promise.resolve(void 0);
|
|
480
|
+
if (this.execution === "explicit")
|
|
481
|
+
return Promise.reject(new Error("Explicit LiveQuery execution cannot be activated"));
|
|
482
|
+
if (this.activated)
|
|
483
|
+
return this._activeRequest ?? Promise.resolve(this.get());
|
|
484
|
+
this.activated = !0, this.initializeAutomaticTriggers();
|
|
485
|
+
const s = this.executeRequest(e);
|
|
486
|
+
return this.scheduleNextPoll(), s;
|
|
487
|
+
}
|
|
474
488
|
refresh(e = "refresh") {
|
|
489
|
+
return this.isDisposed ? Promise.resolve(void 0) : this.activated ? this.executeRequest(e) : this.activate(e);
|
|
490
|
+
}
|
|
491
|
+
executeRequest(e) {
|
|
475
492
|
var p;
|
|
476
|
-
if (this.isDisposed) return Promise.resolve(void 0);
|
|
477
493
|
const s = ++this.requestId;
|
|
478
494
|
(p = this.abortController) == null || p.abort();
|
|
479
|
-
const
|
|
480
|
-
this.abortController =
|
|
481
|
-
const
|
|
495
|
+
const o = Z();
|
|
496
|
+
this.abortController = o;
|
|
497
|
+
const i = e instanceof b ? e : null, c = i ? "query arguments changed" : e, f = this.keepPreviousValue ? this.lastSuccessfulValue : void 0;
|
|
482
498
|
this.setSnapshot({
|
|
483
|
-
value:
|
|
484
|
-
fetchState:
|
|
499
|
+
value: f,
|
|
500
|
+
fetchState: a.Loading,
|
|
485
501
|
error: null,
|
|
486
|
-
cause:
|
|
487
|
-
parentEvent:
|
|
502
|
+
cause: c,
|
|
503
|
+
parentEvent: i
|
|
488
504
|
});
|
|
489
|
-
const
|
|
490
|
-
signal:
|
|
491
|
-
event:
|
|
505
|
+
const u = this.createEvent("query fetch", i, this.argumentValues), h = Promise.resolve().then(() => this.handler.fetch(this.argumentValues, {
|
|
506
|
+
signal: o.signal,
|
|
507
|
+
event: u
|
|
492
508
|
})).then((l) => {
|
|
493
|
-
if (this.isCurrentRequest(s,
|
|
509
|
+
if (this.isCurrentRequest(s, o))
|
|
494
510
|
return this.lastSuccessfulValue = l, this.hasSuccessfulValue = !0, this.setSnapshot({
|
|
495
511
|
value: l,
|
|
496
|
-
fetchState:
|
|
512
|
+
fetchState: a.Ready,
|
|
497
513
|
error: null,
|
|
498
514
|
cause: "query succeeded",
|
|
499
|
-
parentEvent:
|
|
515
|
+
parentEvent: u
|
|
500
516
|
}), l;
|
|
501
517
|
}).catch((l) => {
|
|
502
|
-
!this.isCurrentRequest(s,
|
|
518
|
+
!this.isCurrentRequest(s, o) || ee(l) || this.setSnapshot({
|
|
503
519
|
value: this.keepPreviousValue ? this.lastSuccessfulValue : void 0,
|
|
504
|
-
fetchState:
|
|
520
|
+
fetchState: a.Error,
|
|
505
521
|
error: l,
|
|
506
522
|
cause: "query failed",
|
|
507
|
-
parentEvent:
|
|
523
|
+
parentEvent: u
|
|
508
524
|
});
|
|
509
525
|
}).finally(() => {
|
|
510
|
-
this.isCurrentRequest(s,
|
|
526
|
+
this.isCurrentRequest(s, o) && (this.abortController = null, this._activeRequest = null);
|
|
511
527
|
});
|
|
512
|
-
return this._activeRequest =
|
|
528
|
+
return this._activeRequest = h, h;
|
|
513
529
|
}
|
|
514
530
|
retry(e = "retry") {
|
|
515
531
|
return this.refresh(e);
|
|
@@ -520,7 +536,7 @@ class I extends g {
|
|
|
520
536
|
const s = e instanceof b ? e : null;
|
|
521
537
|
this.setSnapshot({
|
|
522
538
|
value: this.hasSuccessfulValue ? this.lastSuccessfulValue : void 0,
|
|
523
|
-
fetchState: this.hasSuccessfulValue ?
|
|
539
|
+
fetchState: this.hasSuccessfulValue ? a.Ready : a.Initial,
|
|
524
540
|
error: null,
|
|
525
541
|
cause: s == null ? e : "query aborted",
|
|
526
542
|
parentEvent: s
|
|
@@ -536,14 +552,21 @@ class I extends g {
|
|
|
536
552
|
this.pollingUnsubscribers = [], super.dispose();
|
|
537
553
|
}
|
|
538
554
|
}
|
|
555
|
+
initializeAutomaticTriggers() {
|
|
556
|
+
this.automaticTriggersInitialized || this.execution === "explicit" || (this.automaticTriggersInitialized = !0, this.argumentUnsubscribers = Object.values(this.args).map(
|
|
557
|
+
(e) => e.subscribe(({ event: s }) => {
|
|
558
|
+
this.refresh(s);
|
|
559
|
+
}, { emitCurrent: !1 })
|
|
560
|
+
), this.polling != null && this.initializePolling(this.polling));
|
|
561
|
+
}
|
|
539
562
|
initializePolling(e) {
|
|
540
563
|
for (const s of [e.intervalMs, e.enabled])
|
|
541
|
-
|
|
564
|
+
j(s) && this.pollingUnsubscribers.push(s.subscribe(() => {
|
|
542
565
|
q(y(e.intervalMs)), Q(y(e.enabled, !0)), this.cancelScheduledPoll(), this.scheduleNextPoll();
|
|
543
566
|
}, { emitCurrent: !1 }));
|
|
544
567
|
}
|
|
545
568
|
scheduleNextPoll() {
|
|
546
|
-
if (this.isDisposed || this.polling == null || this.pollingHandle != null || !y(this.polling.enabled, !0)) return;
|
|
569
|
+
if (this.isDisposed || !this.automaticTriggersInitialized || this.polling == null || this.pollingHandle != null || !y(this.polling.enabled, !0)) return;
|
|
547
570
|
const e = y(this.polling.intervalMs);
|
|
548
571
|
q(e), this.pollingHandle = this.pollingScheduler.schedule(() => {
|
|
549
572
|
this.pollingHandle = null, this.scheduleNextPoll(), this._activeRequest == null && this.refresh("poll");
|
|
@@ -568,21 +591,29 @@ const J = {
|
|
|
568
591
|
typeof r == "function" && Reflect.apply(r, globalThis, [t]);
|
|
569
592
|
}
|
|
570
593
|
};
|
|
571
|
-
function
|
|
594
|
+
function j(t) {
|
|
572
595
|
return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "subscribe") == "function";
|
|
573
596
|
}
|
|
574
|
-
function
|
|
575
|
-
if (typeof t != "number" && typeof t != "boolean" && !
|
|
597
|
+
function I(t, r) {
|
|
598
|
+
if (typeof t != "number" && typeof t != "boolean" && !j(t))
|
|
576
599
|
throw new TypeError(`LiveQuery polling ${r} must be a value or emitter`);
|
|
577
600
|
}
|
|
578
601
|
function K(t) {
|
|
579
602
|
if (t == null || typeof t != "object" || Array.isArray(t))
|
|
580
603
|
throw new TypeError("LiveQuery polling options must be an object");
|
|
581
|
-
if (
|
|
604
|
+
if (I(t.intervalMs, "intervalMs"), t.enabled !== void 0 && I(t.enabled, "enabled"), q(y(t.intervalMs)), Q(y(t.enabled, !0)), t.scheduler != null && (typeof t.scheduler.schedule != "function" || typeof t.scheduler.cancel != "function"))
|
|
582
605
|
throw new TypeError("LiveQuery polling scheduler must implement schedule() and cancel()");
|
|
583
606
|
}
|
|
607
|
+
function X(t, r, e) {
|
|
608
|
+
if (t !== void 0 && t !== "immediate" && t !== "deferred" && t !== "explicit")
|
|
609
|
+
throw new TypeError("LiveQuery execution must be immediate, deferred, or explicit");
|
|
610
|
+
if (t !== void 0 && r !== void 0)
|
|
611
|
+
throw new TypeError("LiveQuery execution and autoFetch are mutually exclusive");
|
|
612
|
+
if (t === "explicit" && e !== void 0)
|
|
613
|
+
throw new TypeError("Explicit LiveQuery execution does not support polling");
|
|
614
|
+
}
|
|
584
615
|
function y(t, r) {
|
|
585
|
-
return t === void 0 ? r :
|
|
616
|
+
return t === void 0 ? r : j(t) ? t.get() : t;
|
|
586
617
|
}
|
|
587
618
|
function q(t) {
|
|
588
619
|
if (!Number.isFinite(t) || t <= 0)
|
|
@@ -592,42 +623,42 @@ function Q(t) {
|
|
|
592
623
|
if (typeof t != "boolean")
|
|
593
624
|
throw new TypeError("LiveQuery polling enabled must be a boolean");
|
|
594
625
|
}
|
|
595
|
-
function
|
|
626
|
+
function Y(t) {
|
|
596
627
|
if (t == null || typeof t != "object" || Array.isArray(t))
|
|
597
628
|
throw new TypeError("LiveQuery args must be a named record of emitters");
|
|
598
629
|
for (const [r, e] of Object.entries(t))
|
|
599
630
|
if (e == null || typeof Reflect.get(e, "get") != "function" || typeof Reflect.get(e, "subscribe") != "function")
|
|
600
631
|
throw new TypeError(`LiveQuery argument ${r} must be an emitter`);
|
|
601
632
|
}
|
|
602
|
-
function
|
|
633
|
+
function Z() {
|
|
603
634
|
const t = Reflect.get(globalThis, "AbortController");
|
|
604
635
|
if (typeof t != "function")
|
|
605
636
|
throw new Error("LiveQuery requires AbortController in this runtime");
|
|
606
637
|
return new t();
|
|
607
638
|
}
|
|
608
|
-
function
|
|
639
|
+
function ee(t) {
|
|
609
640
|
return t instanceof Error && t.name === "AbortError";
|
|
610
641
|
}
|
|
611
|
-
class
|
|
612
|
-
constructor(e, s,
|
|
642
|
+
class de extends z {
|
|
643
|
+
constructor(e, s, o = {}) {
|
|
613
644
|
if (typeof e != "string" || e.length === 0)
|
|
614
645
|
throw new TypeError("QueryArg name must be a non-empty string");
|
|
615
646
|
if (s == null || typeof s.get != "function" || typeof s.subscribe != "function")
|
|
616
647
|
throw new TypeError("QueryArg source must be an emitter");
|
|
617
648
|
super(s.get(), {
|
|
618
|
-
...
|
|
649
|
+
...o,
|
|
619
650
|
fetchState: s.getFetchState(),
|
|
620
651
|
error: s.getError(),
|
|
621
|
-
purpose:
|
|
652
|
+
purpose: o.purpose ?? `query argument: ${e}`
|
|
622
653
|
});
|
|
623
654
|
n(this, "name");
|
|
624
655
|
n(this, "sourceUnsubscribe");
|
|
625
|
-
this.name = e, this.sourceUnsubscribe = s.subscribe((
|
|
656
|
+
this.name = e, this.sourceUnsubscribe = s.subscribe((i) => {
|
|
626
657
|
this.setWithState(
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
658
|
+
i.value,
|
|
659
|
+
i.fetchState,
|
|
660
|
+
i.error,
|
|
661
|
+
i.event
|
|
631
662
|
);
|
|
632
663
|
}, { emitCurrent: !1 });
|
|
633
664
|
}
|
|
@@ -636,19 +667,19 @@ class pe extends U {
|
|
|
636
667
|
this.isDisposed || ((e = this.sourceUnsubscribe) == null || e.call(this), this.sourceUnsubscribe = null, super.dispose());
|
|
637
668
|
}
|
|
638
669
|
}
|
|
639
|
-
class
|
|
670
|
+
class te {
|
|
640
671
|
fetch(r, e = {}) {
|
|
641
672
|
throw new Error("fetch() must be implemented");
|
|
642
673
|
}
|
|
643
674
|
}
|
|
644
|
-
class
|
|
675
|
+
class re extends Error {
|
|
645
676
|
constructor(e) {
|
|
646
677
|
super(`HTTP ${e ?? "unknown"}`);
|
|
647
678
|
n(this, "status");
|
|
648
679
|
this.name = "HttpError", this.status = e;
|
|
649
680
|
}
|
|
650
681
|
}
|
|
651
|
-
class
|
|
682
|
+
class se extends te {
|
|
652
683
|
constructor(e) {
|
|
653
684
|
super();
|
|
654
685
|
n(this, "url");
|
|
@@ -662,7 +693,7 @@ class re extends ee {
|
|
|
662
693
|
throw new TypeError("RestQueryHandler requires a URL or options object");
|
|
663
694
|
if (typeof s.url != "string" || s.url.length === 0)
|
|
664
695
|
throw new TypeError("RestQueryHandler url must be a non-empty string");
|
|
665
|
-
if (this.url = s.url, this.baseUrl = s.baseUrl ??
|
|
696
|
+
if (this.url = s.url, this.baseUrl = s.baseUrl ?? oe(), this.fetchImplementation = s.fetch ?? ue(), this.serialize = s.serialize ?? ne, this.parseResult = s.parseResult, this.trace = s.trace ?? !1, typeof this.fetchImplementation != "function")
|
|
666
697
|
throw new TypeError("RestQueryHandler requires an injected fetch implementation");
|
|
667
698
|
if (typeof this.serialize != "function")
|
|
668
699
|
throw new TypeError("RestQueryHandler serialize must be a function");
|
|
@@ -672,27 +703,27 @@ class re extends ee {
|
|
|
672
703
|
async fetch(e, s = {}) {
|
|
673
704
|
if (e == null || typeof e != "object" || Array.isArray(e))
|
|
674
705
|
throw new TypeError("REST query args must be a named record");
|
|
675
|
-
const
|
|
676
|
-
if (!(
|
|
706
|
+
const o = ie(this.url, this.baseUrl), i = this.serialize(o, e) ?? o, c = O();
|
|
707
|
+
if (!(i instanceof c))
|
|
677
708
|
throw new TypeError("REST serializer must mutate or return a URL");
|
|
678
|
-
const
|
|
679
|
-
if (this.trace ||
|
|
709
|
+
const f = s.event ?? null;
|
|
710
|
+
if (this.trace || f || w.hasSubscribers) {
|
|
680
711
|
const l = new b({
|
|
681
712
|
owner: this,
|
|
682
713
|
purpose: "REST fetch",
|
|
683
|
-
value:
|
|
714
|
+
value: i.toString(),
|
|
684
715
|
cause: "fetch called",
|
|
685
|
-
parent:
|
|
716
|
+
parent: f
|
|
686
717
|
});
|
|
687
|
-
|
|
718
|
+
f || w.emit(l);
|
|
688
719
|
}
|
|
689
|
-
const
|
|
690
|
-
if (!(
|
|
691
|
-
const p = await
|
|
720
|
+
const u = s.signal === void 0 ? {} : { signal: s.signal }, h = await this.fetchImplementation(i.toString(), u);
|
|
721
|
+
if (!(h != null && h.ok)) throw new re(h == null ? void 0 : h.status);
|
|
722
|
+
const p = await h.json();
|
|
692
723
|
return this.parseResult == null ? p : this.parseResult(p);
|
|
693
724
|
}
|
|
694
725
|
}
|
|
695
|
-
function
|
|
726
|
+
function ne(t, r) {
|
|
696
727
|
for (const [e, s] of Object.entries(r))
|
|
697
728
|
L(t.searchParams, e, s);
|
|
698
729
|
return t;
|
|
@@ -714,8 +745,8 @@ function L(t, r, e) {
|
|
|
714
745
|
t.append(r, String(e));
|
|
715
746
|
}
|
|
716
747
|
}
|
|
717
|
-
function
|
|
718
|
-
const e =
|
|
748
|
+
function ie(t, r) {
|
|
749
|
+
const e = O();
|
|
719
750
|
try {
|
|
720
751
|
return new e(t);
|
|
721
752
|
} catch (s) {
|
|
@@ -724,23 +755,23 @@ function ne(t, r) {
|
|
|
724
755
|
return new e(t, r);
|
|
725
756
|
}
|
|
726
757
|
}
|
|
727
|
-
function
|
|
758
|
+
function O() {
|
|
728
759
|
const t = Reflect.get(globalThis, "URL");
|
|
729
760
|
if (typeof t != "function")
|
|
730
761
|
throw new Error("RestQueryHandler requires URL in this runtime");
|
|
731
762
|
return t;
|
|
732
763
|
}
|
|
733
|
-
function
|
|
764
|
+
function oe() {
|
|
734
765
|
const t = Reflect.get(globalThis, "location");
|
|
735
766
|
if (t == null || typeof t != "object" && typeof t != "function")
|
|
736
767
|
return;
|
|
737
768
|
const r = Reflect.get(t, "href");
|
|
738
769
|
return typeof r == "string" ? r : void 0;
|
|
739
770
|
}
|
|
740
|
-
function
|
|
771
|
+
function ue() {
|
|
741
772
|
return Reflect.get(globalThis, "fetch");
|
|
742
773
|
}
|
|
743
|
-
class
|
|
774
|
+
class ce {
|
|
744
775
|
constructor(r) {
|
|
745
776
|
n(this, "handler");
|
|
746
777
|
n(this, "queryOptions");
|
|
@@ -752,7 +783,7 @@ class ue {
|
|
|
752
783
|
E(e), this.handler = r.handler, this.queryOptions = Object.freeze({ ...e }), Object.freeze(this);
|
|
753
784
|
}
|
|
754
785
|
open(r, e = {}) {
|
|
755
|
-
return A(r), E(e), new
|
|
786
|
+
return A(r), E(e), new D({
|
|
756
787
|
handler: this.handler,
|
|
757
788
|
args: r,
|
|
758
789
|
...this.queryOptions,
|
|
@@ -760,20 +791,20 @@ class ue {
|
|
|
760
791
|
});
|
|
761
792
|
}
|
|
762
793
|
}
|
|
763
|
-
function
|
|
764
|
-
return new
|
|
794
|
+
function be(t) {
|
|
795
|
+
return new ce(t);
|
|
765
796
|
}
|
|
766
|
-
class
|
|
797
|
+
class le {
|
|
767
798
|
constructor(r) {
|
|
768
799
|
n(this, "handler");
|
|
769
800
|
n(this, "queryOptions");
|
|
770
801
|
if (r == null || typeof r != "object" || Array.isArray(r))
|
|
771
802
|
throw new TypeError("RestEndpoint options must be an object");
|
|
772
803
|
const { query: e = {}, ...s } = r;
|
|
773
|
-
E(e, "RestEndpoint query options"), this.handler = new
|
|
804
|
+
E(e, "RestEndpoint query options"), this.handler = new se(s), this.queryOptions = Object.freeze({ ...e }), Object.freeze(this);
|
|
774
805
|
}
|
|
775
806
|
open(r, e = {}) {
|
|
776
|
-
return A(r), E(e), new
|
|
807
|
+
return A(r), E(e), new D({
|
|
777
808
|
handler: this.handler,
|
|
778
809
|
args: r,
|
|
779
810
|
...this.queryOptions,
|
|
@@ -781,10 +812,10 @@ class ce {
|
|
|
781
812
|
});
|
|
782
813
|
}
|
|
783
814
|
}
|
|
784
|
-
function
|
|
785
|
-
return new
|
|
815
|
+
function ye(t) {
|
|
816
|
+
return new le(t);
|
|
786
817
|
}
|
|
787
|
-
class
|
|
818
|
+
class ae {
|
|
788
819
|
constructor(r) {
|
|
789
820
|
n(this, "apply");
|
|
790
821
|
n(this, "purpose");
|
|
@@ -795,26 +826,26 @@ class le {
|
|
|
795
826
|
this.apply = r.apply, this.purpose = r.purpose ?? "derived endpoint", Object.freeze(this);
|
|
796
827
|
}
|
|
797
828
|
open(r) {
|
|
798
|
-
return new
|
|
829
|
+
return new he({
|
|
799
830
|
...r,
|
|
800
831
|
apply: this.apply,
|
|
801
832
|
purpose: r.purpose ?? this.purpose
|
|
802
833
|
});
|
|
803
834
|
}
|
|
804
835
|
}
|
|
805
|
-
function
|
|
806
|
-
return new
|
|
836
|
+
function me(t) {
|
|
837
|
+
return new ae(t);
|
|
807
838
|
}
|
|
808
|
-
class
|
|
839
|
+
class he extends g {
|
|
809
840
|
constructor(e) {
|
|
810
841
|
if (e == null || typeof e != "object" || Array.isArray(e))
|
|
811
842
|
throw new TypeError("DerivedLiveResult options must be an object");
|
|
812
|
-
if (A(e.args), !
|
|
843
|
+
if (A(e.args), !P(e.source))
|
|
813
844
|
throw new TypeError("DerivedLiveResult source must be an emitter");
|
|
814
845
|
if (typeof e.apply != "function")
|
|
815
846
|
throw new TypeError("DerivedLiveResult apply must be a function");
|
|
816
847
|
super(void 0, {
|
|
817
|
-
fetchState:
|
|
848
|
+
fetchState: a.Initial,
|
|
818
849
|
error: null,
|
|
819
850
|
owner: e.owner,
|
|
820
851
|
...e.purpose === void 0 ? {} : { purpose: e.purpose },
|
|
@@ -830,8 +861,8 @@ class ae extends g {
|
|
|
830
861
|
this.source,
|
|
831
862
|
...Object.values(this.args)
|
|
832
863
|
];
|
|
833
|
-
this.unsubscribers = s.map((
|
|
834
|
-
this.recompute(
|
|
864
|
+
this.unsubscribers = s.map((o) => o.subscribe(({ event: i }) => {
|
|
865
|
+
this.recompute(i);
|
|
835
866
|
}, { emitCurrent: !1 })), this.recompute(null, !1);
|
|
836
867
|
}
|
|
837
868
|
dispose() {
|
|
@@ -842,31 +873,31 @@ class ae extends g {
|
|
|
842
873
|
}
|
|
843
874
|
recompute(e, s = !0) {
|
|
844
875
|
var p;
|
|
845
|
-
const
|
|
876
|
+
const o = [
|
|
846
877
|
this.source,
|
|
847
878
|
...Object.values(this.args)
|
|
848
|
-
],
|
|
849
|
-
let
|
|
850
|
-
|
|
879
|
+
], i = ((p = o.find((l) => l.getError() != null)) == null ? void 0 : p.getError()) ?? null;
|
|
880
|
+
let c = T(
|
|
881
|
+
o.map((l) => l.getFetchState())
|
|
851
882
|
);
|
|
852
|
-
const
|
|
853
|
-
let
|
|
883
|
+
const f = this.source.get();
|
|
884
|
+
let u = this.lastSuccessfulValue, h = i;
|
|
854
885
|
try {
|
|
855
886
|
const l = Object.fromEntries(
|
|
856
887
|
Object.entries(this.args).map(([d, v]) => [d, v.get()])
|
|
857
888
|
);
|
|
858
|
-
|
|
889
|
+
u = this.apply(f, l), this.lastSuccessfulValue = u;
|
|
859
890
|
} catch (l) {
|
|
860
|
-
|
|
891
|
+
h = l, c = a.Error;
|
|
861
892
|
}
|
|
862
|
-
if (
|
|
863
|
-
this.value =
|
|
893
|
+
if (i != null && (h = i, c = a.Error), !s) {
|
|
894
|
+
this.value = u, this.fetchState = c, this.error = h;
|
|
864
895
|
return;
|
|
865
896
|
}
|
|
866
897
|
this.setSnapshot({
|
|
867
|
-
value:
|
|
868
|
-
fetchState:
|
|
869
|
-
error:
|
|
898
|
+
value: u,
|
|
899
|
+
fetchState: c,
|
|
900
|
+
error: h,
|
|
870
901
|
cause: "derived endpoint source changed",
|
|
871
902
|
parentEvent: e
|
|
872
903
|
});
|
|
@@ -880,33 +911,33 @@ function A(t) {
|
|
|
880
911
|
if (t == null || typeof t != "object" || Array.isArray(t))
|
|
881
912
|
throw new TypeError("Endpoint args must be a named record of emitters");
|
|
882
913
|
for (const [r, e] of Object.entries(t))
|
|
883
|
-
if (!
|
|
914
|
+
if (!P(e))
|
|
884
915
|
throw new TypeError(`Endpoint argument ${r} must be an emitter`);
|
|
885
916
|
}
|
|
886
|
-
function
|
|
917
|
+
function P(t) {
|
|
887
918
|
return t != null && (typeof t == "object" || typeof t == "function") && typeof Reflect.get(t, "get") == "function" && typeof Reflect.get(t, "getFetchState") == "function" && typeof Reflect.get(t, "getError") == "function" && typeof Reflect.get(t, "subscribe") == "function";
|
|
888
919
|
}
|
|
889
920
|
export {
|
|
890
|
-
|
|
921
|
+
pe as AsyncCommand,
|
|
891
922
|
M as AsyncCommandConcurrencyError,
|
|
892
923
|
g as BaseEmitter,
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
924
|
+
x as DerivedEmitter,
|
|
925
|
+
ae as DerivedEndpoint,
|
|
926
|
+
he as DerivedLiveResult,
|
|
927
|
+
z as Emitter,
|
|
897
928
|
b as EventBubble,
|
|
898
929
|
w as EventBus,
|
|
899
|
-
|
|
930
|
+
a as FetchState,
|
|
900
931
|
S as FetchStateValues,
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
932
|
+
D as LiveQuery,
|
|
933
|
+
de as QueryArg,
|
|
934
|
+
ce as QueryEndpoint,
|
|
935
|
+
te as QueryHandler,
|
|
936
|
+
le as RestEndpoint,
|
|
937
|
+
se as RestQueryHandler,
|
|
938
|
+
T as combineFetchStates,
|
|
939
|
+
me as derivedEndpoint,
|
|
940
|
+
be as queryEndpoint,
|
|
941
|
+
ye as restEndpoint
|
|
911
942
|
};
|
|
912
943
|
//# sourceMappingURL=index.js.map
|