@coasys/ad4m 0.13.1-staging.5 → 0.13.1-staging.7
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/lib/index.cjs +1518 -739
- package/lib/index.js +1515 -740
- package/lib/src/Ad4mClient.d.ts +9 -0
- package/lib/src/Ad4mClient.js +17 -2
- package/lib/src/agent/Agent.d.ts +5 -1
- package/lib/src/agent/Agent.js +3 -0
- package/lib/src/agent/AgentClient.d.ts +3 -0
- package/lib/src/agent/AgentClient.js +3 -0
- package/lib/src/agent/AgentStatus.d.ts +2 -0
- package/lib/src/agent/AgentStatus.js +2 -0
- package/lib/src/apiClient.d.ts +73 -0
- package/lib/src/apiClient.js +269 -13
- package/lib/src/generated/api/AgentStatus.d.ts +5 -0
- package/lib/src/generated/api/AgentWithIdentity.d.ts +14 -0
- package/lib/src/generated/api/AgentWithIdentity.js +1 -0
- package/lib/src/generated/api/BotView.d.ts +7 -0
- package/lib/src/generated/api/BotView.js +2 -0
- package/lib/src/generated/api/ClaimOfferParams.d.ts +13 -0
- package/lib/src/generated/api/ClaimOfferParams.js +2 -0
- package/lib/src/generated/api/ClaimOfferResult.d.ts +14 -0
- package/lib/src/generated/api/ClaimOfferResult.js +1 -0
- package/lib/src/generated/api/ClaimView.d.ts +11 -0
- package/lib/src/generated/api/ClaimView.js +2 -0
- package/lib/src/generated/api/CosignInceptParams.d.ts +10 -0
- package/lib/src/generated/api/CosignInceptParams.js +1 -0
- package/lib/src/generated/api/DeviceView.d.ts +17 -0
- package/lib/src/generated/api/DeviceView.js +1 -0
- package/lib/src/generated/api/DidBotScope.d.ts +7 -0
- package/lib/src/generated/api/DidBotScope.js +2 -0
- package/lib/src/generated/api/DidDocument.d.ts +16 -0
- package/lib/src/generated/api/DidDocument.js +1 -0
- package/lib/src/generated/api/DidDocumentMetadata.d.ts +18 -0
- package/lib/src/generated/api/DidDocumentMetadata.js +2 -0
- package/lib/src/generated/api/DidResolutionMetadata.d.ts +51 -0
- package/lib/src/generated/api/DidResolutionMetadata.js +1 -0
- package/lib/src/generated/api/DidResolutionResult.d.ts +16 -0
- package/lib/src/generated/api/DidResolutionResult.js +1 -0
- package/lib/src/generated/api/DidVerificationMethod.d.ts +17 -0
- package/lib/src/generated/api/DidVerificationMethod.js +1 -0
- package/lib/src/generated/api/Events.d.ts +2 -0
- package/lib/src/generated/api/ForkRecord.d.ts +11 -0
- package/lib/src/generated/api/ForkRecord.js +2 -0
- package/lib/src/generated/api/IdentityForkEvent.d.ts +10 -0
- package/lib/src/generated/api/IdentityForkEvent.js +2 -0
- package/lib/src/generated/api/IdentityLog.d.ts +18 -0
- package/lib/src/generated/api/IdentityLog.js +1 -0
- package/lib/src/generated/api/IdentityStatus.d.ts +48 -0
- package/lib/src/generated/api/IdentityStatus.js +1 -0
- package/lib/src/generated/api/JoinStatus.d.ts +10 -0
- package/lib/src/generated/api/JoinStatus.js +2 -0
- package/lib/src/generated/api/JoinStatusParams.d.ts +6 -0
- package/lib/src/generated/api/JoinStatusParams.js +2 -0
- package/lib/src/generated/api/LogParams.d.ts +17 -0
- package/lib/src/generated/api/LogParams.js +2 -0
- package/lib/src/generated/api/Offer.d.ts +14 -0
- package/lib/src/generated/api/Offer.js +1 -0
- package/lib/src/generated/api/OfferKind.d.ts +4 -0
- package/lib/src/generated/api/OfferKind.js +2 -0
- package/lib/src/generated/api/OfferListing.d.ts +9 -0
- package/lib/src/generated/api/OfferListing.js +1 -0
- package/lib/src/generated/api/OfferOpened.d.ts +6 -0
- package/lib/src/generated/api/OfferOpened.js +2 -0
- package/lib/src/generated/api/OfferState.d.ts +21 -0
- package/lib/src/generated/api/OfferState.js +1 -0
- package/lib/src/generated/api/OffersParams.d.ts +11 -0
- package/lib/src/generated/api/OffersParams.js +1 -0
- package/lib/src/generated/api/OpenOfferParams.d.ts +7 -0
- package/lib/src/generated/api/OpenOfferParams.js +1 -0
- package/lib/src/generated/api/PublishParams.d.ts +11 -0
- package/lib/src/generated/api/PublishParams.js +1 -0
- package/lib/src/generated/api/RequestBody.d.ts +15 -0
- package/lib/src/generated/api/RequestBody.js +2 -0
- package/lib/src/generated/api/ResetLogParams.d.ts +9 -0
- package/lib/src/generated/api/ResetLogParams.js +2 -0
- package/lib/src/generated/api/ResolveParams.d.ts +18 -0
- package/lib/src/generated/api/ResolveParams.js +2 -0
- package/lib/src/generated/api/RpcMethods.d.ts +68 -1
- package/lib/src/generated/api/RpcMethods.js +6 -0
- package/lib/src/generated/api/SignedBy.d.ts +8 -0
- package/lib/src/generated/api/SignedBy.js +2 -0
- package/lib/src/generated/api/SignedHead.d.ts +14 -0
- package/lib/src/generated/api/SignedHead.js +2 -0
- package/lib/src/generated/api/SignedOffer.d.ts +10 -0
- package/lib/src/generated/api/SignedOffer.js +1 -0
- package/lib/src/generated/api/SignedRequest.d.ts +8 -0
- package/lib/src/generated/api/SignedRequest.js +1 -0
- package/lib/src/generated/api/SkippedSource.d.ts +7 -0
- package/lib/src/generated/api/SkippedSource.js +2 -0
- package/lib/src/generated/api/StoreBehind.d.ts +13 -0
- package/lib/src/generated/api/StoreBehind.js +2 -0
- package/lib/src/generated/api/StoreInfo.d.ts +15 -0
- package/lib/src/generated/api/StoreInfo.js +2 -0
- package/lib/src/generated/api/index.d.ts +38 -0
- package/lib/src/identity/IdentityClient.d.ts +70 -0
- package/lib/src/identity/IdentityClient.js +97 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/model/Ad4mModel.d.ts +11 -0
- package/lib/src/model/Ad4mModel.js +28 -14
- package/lib/src/model/ModelQueryBuilder.d.ts +2 -0
- package/lib/src/model/ModelQueryBuilder.js +36 -57
- package/lib/src/neighbourhood/MeshManager.d.ts +24 -0
- package/lib/src/neighbourhood/MeshManager.js +42 -1
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +10 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.js +16 -0
- package/lib/src/neighbourhood/Session.js +2 -0
- package/lib/src/neighbourhood/SfuManager.d.ts +30 -3
- package/lib/src/neighbourhood/SfuManager.js +78 -41
- package/lib/src/perspectives/FlowInstance.js +6 -4
- package/lib/src/perspectives/LiveQuery.d.ts +40 -4
- package/lib/src/perspectives/LiveQuery.js +94 -10
- package/lib/src/perspectives/PerspectiveClient.d.ts +4 -2
- package/lib/src/perspectives/PerspectiveClient.js +6 -4
- package/lib/src/perspectives/PerspectiveProxy.d.ts +15 -3
- package/lib/src/perspectives/PerspectiveProxy.js +33 -16
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +35 -2
- package/lib/src/perspectives/WakerSubscriptionManager.js +93 -9
- package/lib/src/shacl/SHACLFlow.d.ts +5 -3
- package/lib/src/shacl/SHACLFlow.js +121 -5
- package/package.json +2 -2
- package/src/Ad4mClient.test.ts +64 -4
- package/src/Ad4mClient.ts +17 -0
- package/src/agent/Agent.ts +9 -1
- package/src/agent/AgentClient.ts +5 -1
- package/src/agent/AgentStatus.ts +4 -0
- package/src/apiClient.test.ts +769 -3
- package/src/apiClient.ts +268 -13
- package/src/generated/api/AgentStatus.ts +6 -1
- package/src/generated/api/AgentWithIdentity.ts +12 -0
- package/src/generated/api/BotView.ts +6 -0
- package/src/generated/api/ClaimOfferParams.ts +14 -0
- package/src/generated/api/ClaimOfferResult.ts +11 -0
- package/src/generated/api/ClaimView.ts +6 -0
- package/src/generated/api/CosignInceptParams.ts +11 -0
- package/src/generated/api/DeviceView.ts +12 -0
- package/src/generated/api/DidBotScope.ts +6 -0
- package/src/generated/api/DidDocument.ts +8 -0
- package/src/generated/api/DidDocumentMetadata.ts +19 -0
- package/src/generated/api/DidResolutionMetadata.ts +52 -0
- package/src/generated/api/DidResolutionResult.ts +13 -0
- package/src/generated/api/DidVerificationMethod.ts +15 -0
- package/src/generated/api/Events.ts +2 -0
- package/src/generated/api/ForkRecord.ts +9 -0
- package/src/generated/api/IdentityForkEvent.ts +7 -0
- package/src/generated/api/IdentityLog.ts +17 -0
- package/src/generated/api/IdentityStatus.ts +49 -0
- package/src/generated/api/JoinStatus.ts +7 -0
- package/src/generated/api/JoinStatusParams.ts +6 -0
- package/src/generated/api/LogParams.ts +18 -0
- package/src/generated/api/Offer.ts +8 -0
- package/src/generated/api/OfferKind.ts +6 -0
- package/src/generated/api/OfferListing.ts +8 -0
- package/src/generated/api/OfferOpened.ts +6 -0
- package/src/generated/api/OfferState.ts +7 -0
- package/src/generated/api/OffersParams.ts +11 -0
- package/src/generated/api/OpenOfferParams.ts +7 -0
- package/src/generated/api/PublishParams.ts +12 -0
- package/src/generated/api/RequestBody.ts +7 -0
- package/src/generated/api/ResetLogParams.ts +10 -0
- package/src/generated/api/ResolveParams.ts +19 -0
- package/src/generated/api/RpcMethods.ts +38 -1
- package/src/generated/api/SignedBy.ts +6 -0
- package/src/generated/api/SignedHead.ts +10 -0
- package/src/generated/api/SignedOffer.ts +8 -0
- package/src/generated/api/SignedRequest.ts +7 -0
- package/src/generated/api/SkippedSource.ts +6 -0
- package/src/generated/api/StoreBehind.ts +14 -0
- package/src/generated/api/StoreInfo.ts +16 -0
- package/src/generated/api/index.ts +39 -0
- package/src/identity/IdentityClient.ts +111 -0
- package/src/index.ts +1 -0
- package/src/model/Ad4mModel.test.ts +128 -364
- package/src/model/Ad4mModel.ts +27 -18
- package/src/model/ModelQueryBuilder.ts +39 -59
- package/src/model/write-round-trips.test.ts +324 -0
- package/src/neighbourhood/MeshManager.test.ts +87 -0
- package/src/neighbourhood/MeshManager.ts +50 -1
- package/src/neighbourhood/NeighbourhoodClient.test.ts +27 -0
- package/src/neighbourhood/NeighbourhoodClient.ts +19 -0
- package/src/neighbourhood/Session.test.ts +5 -0
- package/src/neighbourhood/Session.ts +2 -0
- package/src/neighbourhood/SfuManager.test.ts +293 -0
- package/src/neighbourhood/SfuManager.ts +92 -45
- package/src/perspectives/FlowInstance.ts +6 -4
- package/src/perspectives/LiveQuery.test.ts +173 -1
- package/src/perspectives/LiveQuery.ts +110 -10
- package/src/perspectives/PerspectiveClient.ts +6 -4
- package/src/perspectives/PerspectiveProxy.test.ts +24 -2
- package/src/perspectives/PerspectiveProxy.ts +35 -16
- package/src/perspectives/WakerSubscriptionManager.test.ts +225 -1
- package/src/perspectives/WakerSubscriptionManager.ts +97 -10
- package/src/shacl/SHACLFlow.test.ts +221 -0
- package/src/shacl/SHACLFlow.ts +121 -5
package/lib/index.cjs
CHANGED
|
@@ -40,6 +40,12 @@ const READ_METHODS = new Set([
|
|
|
40
40
|
"hosting.info",
|
|
41
41
|
"hosting.wallet",
|
|
42
42
|
"hosting.walletHistory",
|
|
43
|
+
"identity.devices",
|
|
44
|
+
"identity.joinStatus",
|
|
45
|
+
"identity.log",
|
|
46
|
+
"identity.offers",
|
|
47
|
+
"identity.resolve",
|
|
48
|
+
"identity.status",
|
|
43
49
|
"language.all",
|
|
44
50
|
"language.get",
|
|
45
51
|
"language.meta",
|
|
@@ -133,6 +139,40 @@ const MAX_RECONNECT_DELAY_MS = 30000;
|
|
|
133
139
|
* MAX_WATCH_RETRIES times in a row. */
|
|
134
140
|
const WATCH_RETRY_DELAY_MS = 1000;
|
|
135
141
|
const MAX_WATCH_RETRIES = 5;
|
|
142
|
+
/** An open socket sends a ping this often, and must deliver some message
|
|
143
|
+
* (the pong will do) within an interval of the first ping it left
|
|
144
|
+
* unanswered. After a network switch a socket can stay OPEN for minutes with
|
|
145
|
+
* no close event, since no FIN or RST ever arrives; this notices it within
|
|
146
|
+
* two intervals. */
|
|
147
|
+
const PING_INTERVAL_MS = 10000;
|
|
148
|
+
/** The slowest link a socket is given time for. The executor reads a ping
|
|
149
|
+
* only after the frames sent before it, so a ping left unanswered counts as
|
|
150
|
+
* silence only once everything the socket sent before that ping could have
|
|
151
|
+
* crossed this link and PONG_RETURN_MS more have passed, if that takes longer
|
|
152
|
+
* than PING_INTERVAL_MS. Messages that come in meanwhile do not shorten this:
|
|
153
|
+
* they say nothing about how far an upload has got. */
|
|
154
|
+
const SLOWEST_LINK_BYTES_PER_MS = 16; // 16 kB/s
|
|
155
|
+
/** How long a pong gets to come back after its ping could have been read
|
|
156
|
+
* behind a large write. Shorter than PING_INTERVAL_MS, so the few ms a small
|
|
157
|
+
* frame adds before a ping on an idle socket never cost a ping interval. */
|
|
158
|
+
const PONG_RETURN_MS = 5000;
|
|
159
|
+
/** How long `checkConnection` waits for the open socket to say anything
|
|
160
|
+
* after its ping. If a large write sent before it may still be on the way,
|
|
161
|
+
* the wait lasts until that write could have crossed, as for the periodic
|
|
162
|
+
* ping, and half of this more for the pong. On a working path the pong is
|
|
163
|
+
* one round trip away. */
|
|
164
|
+
const CHECK_CONNECTION_DEADLINE_MS = 2000;
|
|
165
|
+
/** The bytes `text` takes as UTF-8, as a WebSocket text frame sends it. */
|
|
166
|
+
function utf8Length(text) {
|
|
167
|
+
let bytes = text.length;
|
|
168
|
+
for (let i = 0; i < text.length; i++) {
|
|
169
|
+
const unit = text.charCodeAt(i);
|
|
170
|
+
// A surrogate is half of a 4-byte pair: 2 units, 2 extra bytes.
|
|
171
|
+
if (unit >= 0x80)
|
|
172
|
+
bytes += unit < 0x800 || (unit >= 0xd800 && unit <= 0xdfff) ? 1 : 2;
|
|
173
|
+
}
|
|
174
|
+
return bytes;
|
|
175
|
+
}
|
|
136
176
|
let _idCounter = 0;
|
|
137
177
|
function nextId() {
|
|
138
178
|
return String(++_idCounter);
|
|
@@ -167,6 +207,16 @@ class ApiClient {
|
|
|
167
207
|
this._wsReconnectTimer = null;
|
|
168
208
|
this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
169
209
|
this._wsPingTimer = null;
|
|
210
|
+
/** When the open socket was first pinged since it last delivered a message; null while none is unanswered. */
|
|
211
|
+
this._wsPingedAt = null;
|
|
212
|
+
/** When that ping could have reached the executor, which reads it only after what the socket sent before it. */
|
|
213
|
+
this._wsPingArrivesBy = 0;
|
|
214
|
+
/** When everything the open socket sent so far could have crossed a SLOWEST_LINK_BYTES_PER_MS link.
|
|
215
|
+
* A message from the socket does not move it back: hearing from the executor says nothing
|
|
216
|
+
* about how much of a large upload has reached it. */
|
|
217
|
+
this._wsSentBy = 0;
|
|
218
|
+
/** A `checkConnection` probe waiting for the open socket to say anything; null when none. */
|
|
219
|
+
this._wsProbeTimer = null;
|
|
170
220
|
// The executor sends a socket only the events it asked for (`events.watch`).
|
|
171
221
|
// What the executor has for the open socket, as sent; a new socket has `{}`.
|
|
172
222
|
this._watching = '{}';
|
|
@@ -176,6 +226,20 @@ class ApiClient {
|
|
|
176
226
|
this._watchSent = Promise.resolve();
|
|
177
227
|
this._watchRetries = 0;
|
|
178
228
|
this._watchRetryTimer = null;
|
|
229
|
+
this._networkCallbacks = new Set();
|
|
230
|
+
/** Removes the network-change listeners; null while not listening. */
|
|
231
|
+
this._unlistenNetwork = null;
|
|
232
|
+
/** A network change waits for its socket to open, then tells `onNetworkChange`. */
|
|
233
|
+
this._networkChanged = false;
|
|
234
|
+
/** The socket dialled for the last network change. */
|
|
235
|
+
this._networkDial = null;
|
|
236
|
+
this._wakeListening = false;
|
|
237
|
+
/** `online` always; `visibilitychange` only when the page became visible. */
|
|
238
|
+
this._onWake = (event) => {
|
|
239
|
+
if (event.type === 'visibilitychange' && typeof document !== 'undefined' && document.visibilityState !== 'visible')
|
|
240
|
+
return;
|
|
241
|
+
this.reconnectNow();
|
|
242
|
+
};
|
|
179
243
|
this.baseUrl = baseUrl;
|
|
180
244
|
this.token = token;
|
|
181
245
|
this._webSocketImpl = webSocketImpl;
|
|
@@ -199,6 +263,10 @@ class ApiClient {
|
|
|
199
263
|
return;
|
|
200
264
|
if (this._authFailed !== null)
|
|
201
265
|
throw new RpcError(401, this._authFailed);
|
|
266
|
+
this._listenForNetworkChanges();
|
|
267
|
+
// A dial ends any wait for one: a call or subscriber that dials during the backoff
|
|
268
|
+
// leaves no timer behind to swallow the retry after this socket's own drop.
|
|
269
|
+
this._cancelReconnect();
|
|
202
270
|
const WsImpl = this._webSocketImpl ?? globalThis.WebSocket;
|
|
203
271
|
const ws = new WsImpl(this._getWsUrl());
|
|
204
272
|
this._ws = ws;
|
|
@@ -223,6 +291,10 @@ class ApiClient {
|
|
|
223
291
|
// Only watchApplied() awaits this; a close before open is not an error otherwise.
|
|
224
292
|
this._wsOpen.catch(() => { });
|
|
225
293
|
ws.onmessage = (event) => {
|
|
294
|
+
if (this._ws === ws) {
|
|
295
|
+
this._wsPingedAt = null;
|
|
296
|
+
this._endProbe();
|
|
297
|
+
}
|
|
226
298
|
let parsed;
|
|
227
299
|
try {
|
|
228
300
|
parsed = JSON.parse(event.data);
|
|
@@ -248,7 +320,8 @@ class ApiClient {
|
|
|
248
320
|
this._failAuth(rpcError.body);
|
|
249
321
|
return;
|
|
250
322
|
}
|
|
251
|
-
|
|
323
|
+
// A dropped socket's events are not this client's any more: its successor watches again.
|
|
324
|
+
if (parsed.type === 'pong' || this._ws !== ws)
|
|
252
325
|
return;
|
|
253
326
|
const perspective = parsed.perspectiveUuid;
|
|
254
327
|
const regs = this._handlers.get(parsed.type);
|
|
@@ -271,14 +344,14 @@ class ApiClient {
|
|
|
271
344
|
if (this._ws !== ws)
|
|
272
345
|
return;
|
|
273
346
|
this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
274
|
-
this._startPing();
|
|
347
|
+
this._startPing(ws);
|
|
275
348
|
// The watch goes out before the queued calls, so the events they cause reach listeners.
|
|
276
349
|
this._watching = '{}';
|
|
277
350
|
this._watchRetries = 0;
|
|
278
351
|
this._flushWatch();
|
|
279
352
|
for (const pending of this._pendingCalls.values()) {
|
|
280
353
|
if (!pending.sent) {
|
|
281
|
-
|
|
354
|
+
this._send(ws, pending.message);
|
|
282
355
|
pending.sent = true;
|
|
283
356
|
}
|
|
284
357
|
}
|
|
@@ -293,6 +366,70 @@ class ApiClient {
|
|
|
293
366
|
}
|
|
294
367
|
}
|
|
295
368
|
this._hasConnectedOnce = true;
|
|
369
|
+
if (this._networkChanged) {
|
|
370
|
+
this._networkChanged = false;
|
|
371
|
+
this._notifyNetworkChange();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Hear of network changes where the platform says so: `online` on the
|
|
376
|
+
* global object (browsers, Deno) redials at once, and `change` on
|
|
377
|
+
* `navigator.connection` (Chromium) runs `checkConnection`. Elsewhere,
|
|
378
|
+
* e.g. Node, nothing is heard and the ping deadline notices a dead
|
|
379
|
+
* socket on its own.
|
|
380
|
+
*/
|
|
381
|
+
_listenForNetworkChanges() {
|
|
382
|
+
if (this._unlistenNetwork)
|
|
383
|
+
return;
|
|
384
|
+
const handler = () => this._onNetworkChange();
|
|
385
|
+
const removers = [];
|
|
386
|
+
const target = globalThis;
|
|
387
|
+
if (typeof target.addEventListener === 'function') {
|
|
388
|
+
target.addEventListener('online', handler);
|
|
389
|
+
removers.push(() => target.removeEventListener?.('online', handler));
|
|
390
|
+
}
|
|
391
|
+
const connection = globalThis.navigator?.connection;
|
|
392
|
+
if (typeof connection?.addEventListener === 'function') {
|
|
393
|
+
// `change` also fires when Chromium's downlink or rtt estimate
|
|
394
|
+
// moves, as a busy call makes it do: probe rather than drop.
|
|
395
|
+
const probe = () => this.checkConnection();
|
|
396
|
+
connection.addEventListener('change', probe);
|
|
397
|
+
removers.push(() => connection.removeEventListener?.('change', probe));
|
|
398
|
+
}
|
|
399
|
+
this._unlistenNetwork = () => { for (const remove of removers)
|
|
400
|
+
remove(); };
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The network changed: the open socket most likely runs over a path that
|
|
404
|
+
* is gone, and nothing would say so before the ping deadline. Drop it as
|
|
405
|
+
* a silent socket is dropped and dial the next one now, without backoff.
|
|
406
|
+
* `onNetworkChange` callbacks fire once that socket opens.
|
|
407
|
+
*/
|
|
408
|
+
_onNetworkChange() {
|
|
409
|
+
if (this._authFailed !== null)
|
|
410
|
+
return;
|
|
411
|
+
const ws = this._ws;
|
|
412
|
+
// A socket dialled for an earlier change is on the new network already.
|
|
413
|
+
if (ws && ws === this._networkDial && ws.readyState === 0 /* CONNECTING */)
|
|
414
|
+
return;
|
|
415
|
+
if (ws) {
|
|
416
|
+
console.info('Network changed; reconnecting the WebSocket');
|
|
417
|
+
this._onClose(ws);
|
|
418
|
+
ws.close();
|
|
419
|
+
}
|
|
420
|
+
this._cancelReconnect();
|
|
421
|
+
this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
422
|
+
if (this._handlers.size === 0 && this._pendingCalls.size === 0) {
|
|
423
|
+
this._notifyNetworkChange();
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
this._networkChanged = true;
|
|
427
|
+
this._ensureWs();
|
|
428
|
+
this._networkDial = this._ws;
|
|
429
|
+
}
|
|
430
|
+
_notifyNetworkChange() {
|
|
431
|
+
for (const cb of [...this._networkCallbacks])
|
|
432
|
+
callSafely(cb, 'Error in network-change callback:');
|
|
296
433
|
}
|
|
297
434
|
/** `reason` is set when the executor asked to try again later; calls that fail carry it. */
|
|
298
435
|
_onClose(ws, reason) {
|
|
@@ -329,19 +466,56 @@ class ApiClient {
|
|
|
329
466
|
for (const cb of [...this._authFailedCallbacks])
|
|
330
467
|
callSafely(cb, 'Error in auth-failed callback:', reason);
|
|
331
468
|
}
|
|
332
|
-
_startPing() {
|
|
469
|
+
_startPing(ws) {
|
|
333
470
|
this._stopPing();
|
|
471
|
+
this._wsPingedAt = null;
|
|
472
|
+
this._wsSentBy = 0;
|
|
334
473
|
this._wsPingTimer = setInterval(() => {
|
|
335
|
-
if (this._ws
|
|
336
|
-
|
|
474
|
+
if (this._ws !== ws)
|
|
475
|
+
return;
|
|
476
|
+
// A probe has its own, shorter deadline and decides for this ping.
|
|
477
|
+
if (this._wsProbeTimer)
|
|
478
|
+
return;
|
|
479
|
+
const ping = JSON.stringify({ type: 'ping' });
|
|
480
|
+
if (this._wsPingedAt === null) {
|
|
481
|
+
this._wsPingedAt = performance.now();
|
|
482
|
+
this._send(ws, ping);
|
|
483
|
+
this._wsPingArrivesBy = this._wsSentBy;
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (performance.now() >= Math.max(this._wsPingedAt + PING_INTERVAL_MS, this._wsPingArrivesBy + PONG_RETURN_MS)) {
|
|
487
|
+
this._dropSilentSocket(ws);
|
|
488
|
+
return;
|
|
337
489
|
}
|
|
338
|
-
|
|
490
|
+
this._send(ws, ping);
|
|
491
|
+
}, PING_INTERVAL_MS);
|
|
492
|
+
}
|
|
493
|
+
/** Send on `ws`, counting how long what the open socket sent could take to cross the slowest link. */
|
|
494
|
+
_send(ws, text) {
|
|
495
|
+
if (this._ws === ws)
|
|
496
|
+
this._wsSentBy = Math.max(this._wsSentBy, performance.now()) + utf8Length(text) / SLOWEST_LINK_BYTES_PER_MS;
|
|
497
|
+
ws.send(text);
|
|
498
|
+
}
|
|
499
|
+
/** The socket answered nothing for a whole ping interval: treat it as
|
|
500
|
+
* closed now. Its close event can take minutes on a dead connection,
|
|
501
|
+
* since the close frame gets no answer either; `_onClose` ignores it then. */
|
|
502
|
+
_dropSilentSocket(ws) {
|
|
503
|
+
console.warn(`WebSocket silent for ${performance.now() - (this._wsPingedAt ?? performance.now())} ms after a ping; reconnecting`);
|
|
504
|
+
this._onClose(ws);
|
|
505
|
+
ws.close();
|
|
339
506
|
}
|
|
340
507
|
_stopPing() {
|
|
341
508
|
if (this._wsPingTimer) {
|
|
342
509
|
clearInterval(this._wsPingTimer);
|
|
343
510
|
this._wsPingTimer = null;
|
|
344
511
|
}
|
|
512
|
+
this._endProbe();
|
|
513
|
+
}
|
|
514
|
+
_endProbe() {
|
|
515
|
+
if (this._wsProbeTimer) {
|
|
516
|
+
clearTimeout(this._wsProbeTimer);
|
|
517
|
+
this._wsProbeTimer = null;
|
|
518
|
+
}
|
|
345
519
|
}
|
|
346
520
|
_scheduleReconnect() {
|
|
347
521
|
if (this._wsReconnectTimer || this._authFailed !== null)
|
|
@@ -350,8 +524,54 @@ class ApiClient {
|
|
|
350
524
|
this._wsReconnectDelay = Math.min(this._wsReconnectDelay * 2, MAX_RECONNECT_DELAY_MS);
|
|
351
525
|
this._wsReconnectTimer = setTimeout(() => {
|
|
352
526
|
this._wsReconnectTimer = null;
|
|
527
|
+
this._listenForWake(false);
|
|
353
528
|
this._ensureWs();
|
|
354
529
|
}, delay);
|
|
530
|
+
this._listenForWake(true);
|
|
531
|
+
}
|
|
532
|
+
/** End the wait for the next dial, if one is pending, without dialling. */
|
|
533
|
+
_cancelReconnect() {
|
|
534
|
+
if (this._wsReconnectTimer) {
|
|
535
|
+
clearTimeout(this._wsReconnectTimer);
|
|
536
|
+
this._wsReconnectTimer = null;
|
|
537
|
+
}
|
|
538
|
+
this._listenForWake(false);
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Dial now if the client is waiting out its reconnect backoff (up to 30 s)
|
|
542
|
+
* instead of letting the wait run out. For the moments the host knows the
|
|
543
|
+
* executor may be reachable again: an executor it restarted is up, the
|
|
544
|
+
* device woke. In a browser the client does this itself on `online` and when
|
|
545
|
+
* the page becomes visible. Does nothing while a socket is open or
|
|
546
|
+
* connecting, after `closeAll()` with nothing to reconnect, or once the
|
|
547
|
+
* executor refused the token.
|
|
548
|
+
*/
|
|
549
|
+
reconnectNow() {
|
|
550
|
+
if (!this._wsReconnectTimer || this._ws || this._authFailed !== null)
|
|
551
|
+
return;
|
|
552
|
+
this._cancelReconnect();
|
|
553
|
+
// The executor is likely back, so a failure now starts the backoff over.
|
|
554
|
+
this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
555
|
+
this._ensureWs();
|
|
556
|
+
}
|
|
557
|
+
/** Listen for `online` and `visibilitychange` exactly while a reconnect
|
|
558
|
+
* timer is pending. Outside a browser (no `window`) it registers nothing. */
|
|
559
|
+
_listenForWake(on) {
|
|
560
|
+
if (on === this._wakeListening)
|
|
561
|
+
return;
|
|
562
|
+
const win = typeof window !== 'undefined' ? window : undefined;
|
|
563
|
+
if (typeof win?.addEventListener !== 'function')
|
|
564
|
+
return;
|
|
565
|
+
const doc = typeof document !== 'undefined' && typeof document.addEventListener === 'function' ? document : undefined;
|
|
566
|
+
this._wakeListening = on;
|
|
567
|
+
if (on) {
|
|
568
|
+
win.addEventListener('online', this._onWake);
|
|
569
|
+
doc?.addEventListener('visibilitychange', this._onWake);
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
win.removeEventListener('online', this._onWake);
|
|
573
|
+
doc?.removeEventListener('visibilitychange', this._onWake);
|
|
574
|
+
}
|
|
355
575
|
}
|
|
356
576
|
// ── RPC call method ─────────────────────────────────────────────────────
|
|
357
577
|
/**
|
|
@@ -397,7 +617,7 @@ class ApiClient {
|
|
|
397
617
|
}, timeoutMs);
|
|
398
618
|
const onAbort = () => {
|
|
399
619
|
if (pending.sent && this._ws?.readyState === 1 /* OPEN */) {
|
|
400
|
-
this._ws
|
|
620
|
+
this._send(this._ws, JSON.stringify({ id: nextId(), type: 'request.cancel', params: { targetId: id } }));
|
|
401
621
|
}
|
|
402
622
|
settle(() => reject(new DOMException('Aborted', 'AbortError')));
|
|
403
623
|
};
|
|
@@ -420,7 +640,7 @@ class ApiClient {
|
|
|
420
640
|
return;
|
|
421
641
|
}
|
|
422
642
|
if (this._ws.readyState === 1 /* OPEN */) {
|
|
423
|
-
this._ws
|
|
643
|
+
this._send(this._ws, message);
|
|
424
644
|
pending.sent = true;
|
|
425
645
|
}
|
|
426
646
|
});
|
|
@@ -541,10 +761,7 @@ class ApiClient {
|
|
|
541
761
|
clearTimeout(this._watchRetryTimer);
|
|
542
762
|
this._watchRetryTimer = null;
|
|
543
763
|
}
|
|
544
|
-
|
|
545
|
-
clearTimeout(this._wsReconnectTimer);
|
|
546
|
-
this._wsReconnectTimer = null;
|
|
547
|
-
}
|
|
764
|
+
this._cancelReconnect();
|
|
548
765
|
const ws = this._ws;
|
|
549
766
|
this._ws = null;
|
|
550
767
|
this._wsOpen = null;
|
|
@@ -557,6 +774,46 @@ class ApiClient {
|
|
|
557
774
|
this._reconnectCallbacks.add(callback);
|
|
558
775
|
return () => { this._reconnectCallbacks.delete(callback); };
|
|
559
776
|
}
|
|
777
|
+
/** Register a callback that fires after the network changed (`online`,
|
|
778
|
+
* or a socket that failed `checkConnection`), once the socket dialled for the
|
|
779
|
+
* new network is open and its event watch sent. Calls made from it go
|
|
780
|
+
* out on that socket. Returns an unsubscribe function. */
|
|
781
|
+
onNetworkChange(callback) {
|
|
782
|
+
this._networkCallbacks.add(callback);
|
|
783
|
+
this._listenForNetworkChanges();
|
|
784
|
+
return () => { this._networkCallbacks.delete(callback); };
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Check the open socket now rather than at the next ping: send a ping,
|
|
788
|
+
* and if nothing at all arrives on that socket within `deadlineMs`,
|
|
789
|
+
* treat it as a network change (drop it, dial the next one at once,
|
|
790
|
+
* `onNetworkChange` callbacks fire when it opens). Any message keeps it.
|
|
791
|
+
* For a caller that has seen its network path break, e.g. ICE going
|
|
792
|
+
* disconnected, where the platform fired no `online` event. Without an
|
|
793
|
+
* open socket, or while a check runs, this does nothing.
|
|
794
|
+
*/
|
|
795
|
+
checkConnection(deadlineMs = CHECK_CONNECTION_DEADLINE_MS) {
|
|
796
|
+
const ws = this._ws;
|
|
797
|
+
if (!ws || ws.readyState !== 1 /* OPEN */ || this._wsProbeTimer)
|
|
798
|
+
return;
|
|
799
|
+
const first = this._wsPingedAt === null;
|
|
800
|
+
if (first)
|
|
801
|
+
this._wsPingedAt = performance.now();
|
|
802
|
+
this._send(ws, JSON.stringify({ type: 'ping' }));
|
|
803
|
+
if (first)
|
|
804
|
+
this._wsPingArrivesBy = this._wsSentBy;
|
|
805
|
+
// Any message from the socket ends the probe (`onmessage` → `_endProbe`).
|
|
806
|
+
// The ping reaches the executor only after what was sent before it,
|
|
807
|
+
// and its pong gets half the deadline to come back after that.
|
|
808
|
+
const wait = Math.max(deadlineMs, this._wsSentBy - performance.now() + deadlineMs / 2);
|
|
809
|
+
this._wsProbeTimer = setTimeout(() => {
|
|
810
|
+
this._wsProbeTimer = null;
|
|
811
|
+
if (this._ws !== ws)
|
|
812
|
+
return;
|
|
813
|
+
console.warn(`WebSocket silent for ${wait} ms after a check; reconnecting`);
|
|
814
|
+
this._onNetworkChange();
|
|
815
|
+
}, wait);
|
|
816
|
+
}
|
|
560
817
|
/** Register a callback that fires once when the executor refuses this
|
|
561
818
|
* client's token: a 401 reply, or a socket closed with code 1008. Every
|
|
562
819
|
* call then fails with a 401 `RpcError` and the client does not reconnect;
|
|
@@ -574,6 +831,11 @@ class ApiClient {
|
|
|
574
831
|
this._handlers.clear();
|
|
575
832
|
this._reconnectCallbacks.clear();
|
|
576
833
|
this._authFailedCallbacks.clear();
|
|
834
|
+
this._networkCallbacks.clear();
|
|
835
|
+
this._unlistenNetwork?.();
|
|
836
|
+
this._unlistenNetwork = null;
|
|
837
|
+
this._networkChanged = false;
|
|
838
|
+
this._networkDial = null;
|
|
577
839
|
// A reused client must not fire onReconnect on its next first open.
|
|
578
840
|
this._hasConnectedOnce = false;
|
|
579
841
|
}
|
|
@@ -835,6 +1097,9 @@ class Agent {
|
|
|
835
1097
|
static fromWire(wire) {
|
|
836
1098
|
const agent = new Agent(wire.did, Perspective.fromWire(wire.perspective));
|
|
837
1099
|
agent.directMessageLanguage = wire.directMessageLanguage;
|
|
1100
|
+
if ("identity" in wire && wire.identity) {
|
|
1101
|
+
agent.identity = wire.identity;
|
|
1102
|
+
}
|
|
838
1103
|
return agent;
|
|
839
1104
|
}
|
|
840
1105
|
}
|
|
@@ -990,6 +1255,8 @@ class AgentStatus {
|
|
|
990
1255
|
this.didDocument = obj.didDocument;
|
|
991
1256
|
//@ts-ignore
|
|
992
1257
|
this.error = obj.error;
|
|
1258
|
+
//@ts-ignore
|
|
1259
|
+
this.identity = obj.identity ?? null;
|
|
993
1260
|
}
|
|
994
1261
|
else {
|
|
995
1262
|
this.isInitialized = false;
|
|
@@ -1011,13 +1278,13 @@ class AgentStatus {
|
|
|
1011
1278
|
* never need try/catch around cache operations
|
|
1012
1279
|
* - Tree-shakeable: import only what you need
|
|
1013
1280
|
*/
|
|
1014
|
-
var __classPrivateFieldSet$
|
|
1281
|
+
var __classPrivateFieldSet$e = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1015
1282
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1016
1283
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1017
1284
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1018
1285
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1019
1286
|
};
|
|
1020
|
-
var __classPrivateFieldGet$
|
|
1287
|
+
var __classPrivateFieldGet$e = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1021
1288
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1022
1289
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1023
1290
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -1031,15 +1298,15 @@ class IDBCache {
|
|
|
1031
1298
|
_IDBCache_storeName.set(this, void 0);
|
|
1032
1299
|
_IDBCache_dbPromise.set(this, null);
|
|
1033
1300
|
_IDBCache_version.set(this, 1);
|
|
1034
|
-
__classPrivateFieldSet$
|
|
1035
|
-
__classPrivateFieldSet$
|
|
1301
|
+
__classPrivateFieldSet$e(this, _IDBCache_dbName, dbName, "f");
|
|
1302
|
+
__classPrivateFieldSet$e(this, _IDBCache_storeName, storeName, "f");
|
|
1036
1303
|
}
|
|
1037
1304
|
async get(key) {
|
|
1038
1305
|
try {
|
|
1039
|
-
const db = await __classPrivateFieldGet$
|
|
1306
|
+
const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
1040
1307
|
return new Promise((resolve) => {
|
|
1041
|
-
const tx = db.transaction(__classPrivateFieldGet$
|
|
1042
|
-
const store = tx.objectStore(__classPrivateFieldGet$
|
|
1308
|
+
const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readonly');
|
|
1309
|
+
const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
|
|
1043
1310
|
const req = store.get(key);
|
|
1044
1311
|
req.onsuccess = () => resolve(req.result ?? undefined);
|
|
1045
1312
|
req.onerror = () => resolve(undefined);
|
|
@@ -1051,10 +1318,10 @@ class IDBCache {
|
|
|
1051
1318
|
}
|
|
1052
1319
|
async put(key, value) {
|
|
1053
1320
|
try {
|
|
1054
|
-
const db = await __classPrivateFieldGet$
|
|
1321
|
+
const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
1055
1322
|
return new Promise((resolve) => {
|
|
1056
|
-
const tx = db.transaction(__classPrivateFieldGet$
|
|
1057
|
-
const store = tx.objectStore(__classPrivateFieldGet$
|
|
1323
|
+
const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readwrite');
|
|
1324
|
+
const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
|
|
1058
1325
|
store.put(value, key);
|
|
1059
1326
|
tx.oncomplete = () => resolve();
|
|
1060
1327
|
tx.onerror = () => resolve(); // fire-and-forget
|
|
@@ -1066,10 +1333,10 @@ class IDBCache {
|
|
|
1066
1333
|
}
|
|
1067
1334
|
async delete(key) {
|
|
1068
1335
|
try {
|
|
1069
|
-
const db = await __classPrivateFieldGet$
|
|
1336
|
+
const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
1070
1337
|
return new Promise((resolve) => {
|
|
1071
|
-
const tx = db.transaction(__classPrivateFieldGet$
|
|
1072
|
-
const store = tx.objectStore(__classPrivateFieldGet$
|
|
1338
|
+
const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readwrite');
|
|
1339
|
+
const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
|
|
1073
1340
|
store.delete(key);
|
|
1074
1341
|
tx.oncomplete = () => resolve();
|
|
1075
1342
|
tx.onerror = () => resolve();
|
|
@@ -1081,10 +1348,10 @@ class IDBCache {
|
|
|
1081
1348
|
}
|
|
1082
1349
|
async clear() {
|
|
1083
1350
|
try {
|
|
1084
|
-
const db = await __classPrivateFieldGet$
|
|
1351
|
+
const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
1085
1352
|
return new Promise((resolve) => {
|
|
1086
|
-
const tx = db.transaction(__classPrivateFieldGet$
|
|
1087
|
-
const store = tx.objectStore(__classPrivateFieldGet$
|
|
1353
|
+
const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readwrite');
|
|
1354
|
+
const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
|
|
1088
1355
|
store.clear();
|
|
1089
1356
|
tx.oncomplete = () => resolve();
|
|
1090
1357
|
tx.onerror = () => resolve();
|
|
@@ -1096,10 +1363,10 @@ class IDBCache {
|
|
|
1096
1363
|
}
|
|
1097
1364
|
}
|
|
1098
1365
|
_IDBCache_dbName = new WeakMap(), _IDBCache_storeName = new WeakMap(), _IDBCache_dbPromise = new WeakMap(), _IDBCache_version = new WeakMap(), _IDBCache_instances = new WeakSet(), _IDBCache_open = function _IDBCache_open() {
|
|
1099
|
-
if (!__classPrivateFieldGet$
|
|
1100
|
-
__classPrivateFieldSet$
|
|
1101
|
-
const storeName = __classPrivateFieldGet$
|
|
1102
|
-
const req = indexedDB.open(__classPrivateFieldGet$
|
|
1366
|
+
if (!__classPrivateFieldGet$e(this, _IDBCache_dbPromise, "f")) {
|
|
1367
|
+
__classPrivateFieldSet$e(this, _IDBCache_dbPromise, new Promise((resolve, reject) => {
|
|
1368
|
+
const storeName = __classPrivateFieldGet$e(this, _IDBCache_storeName, "f");
|
|
1369
|
+
const req = indexedDB.open(__classPrivateFieldGet$e(this, _IDBCache_dbName, "f"), __classPrivateFieldGet$e(this, _IDBCache_version, "f"));
|
|
1103
1370
|
req.onupgradeneeded = () => {
|
|
1104
1371
|
const db = req.result;
|
|
1105
1372
|
if (!db.objectStoreNames.contains(storeName)) {
|
|
@@ -1110,7 +1377,7 @@ _IDBCache_dbName = new WeakMap(), _IDBCache_storeName = new WeakMap(), _IDBCache
|
|
|
1110
1377
|
req.onerror = () => reject(req.error);
|
|
1111
1378
|
}), "f");
|
|
1112
1379
|
}
|
|
1113
|
-
return __classPrivateFieldGet$
|
|
1380
|
+
return __classPrivateFieldGet$e(this, _IDBCache_dbPromise, "f");
|
|
1114
1381
|
};
|
|
1115
1382
|
// ── NullCache (no-op fallback for Node.js) ───────────────────────────
|
|
1116
1383
|
class NullCache {
|
|
@@ -1138,13 +1405,13 @@ function createPersistentCache(dbName, storeName) {
|
|
|
1138
1405
|
return new NullCache();
|
|
1139
1406
|
}
|
|
1140
1407
|
|
|
1141
|
-
var __classPrivateFieldSet$
|
|
1408
|
+
var __classPrivateFieldSet$d = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1142
1409
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1143
1410
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1144
1411
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1145
1412
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1146
1413
|
};
|
|
1147
|
-
var __classPrivateFieldGet$
|
|
1414
|
+
var __classPrivateFieldGet$d = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1148
1415
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1149
1416
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1150
1417
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -1166,47 +1433,50 @@ class AgentClient {
|
|
|
1166
1433
|
// Self-DID for event-driven invalidation (no TTL for own profile)
|
|
1167
1434
|
_AgentClient_selfDid.set(this, null);
|
|
1168
1435
|
_AgentClient_onAgentUpdated.set(this, (event) => {
|
|
1169
|
-
__classPrivateFieldGet$
|
|
1436
|
+
__classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, Agent.fromWire(event.agent));
|
|
1170
1437
|
});
|
|
1171
|
-
__classPrivateFieldSet$
|
|
1172
|
-
__classPrivateFieldSet$
|
|
1438
|
+
__classPrivateFieldSet$d(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
1439
|
+
__classPrivateFieldSet$d(this, _AgentClient_persistent, createPersistentCache('ad4m-agent-cache', 'agents'), "f");
|
|
1173
1440
|
}
|
|
1174
1441
|
async me() {
|
|
1175
|
-
const agentObject = toAgent(await __classPrivateFieldGet$
|
|
1442
|
+
const agentObject = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.get', {}));
|
|
1176
1443
|
// Auto-set selfDid so event-driven cache invalidation works
|
|
1177
1444
|
// without requiring apps to call setSelfDid() manually
|
|
1178
|
-
if (agentObject.did && !__classPrivateFieldGet$
|
|
1179
|
-
__classPrivateFieldSet$
|
|
1445
|
+
if (agentObject.did && !__classPrivateFieldGet$d(this, _AgentClient_selfDid, "f")) {
|
|
1446
|
+
__classPrivateFieldSet$d(this, _AgentClient_selfDid, agentObject.did, "f");
|
|
1180
1447
|
}
|
|
1181
1448
|
return agentObject;
|
|
1182
1449
|
}
|
|
1183
1450
|
async status() {
|
|
1184
|
-
const agentStatus = await __classPrivateFieldGet$
|
|
1451
|
+
const agentStatus = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.status', {});
|
|
1185
1452
|
return new AgentStatus(agentStatus);
|
|
1186
1453
|
}
|
|
1454
|
+
/** Creates the agent's keys and DID on first run. The executor refuses (409)
|
|
1455
|
+
* an agent that is already initialised — {@link unlock} it instead; a second
|
|
1456
|
+
* `generate` never replaces the existing keys and DID. */
|
|
1187
1457
|
async generate(passphrase, options) {
|
|
1188
|
-
const result = await __classPrivateFieldGet$
|
|
1458
|
+
const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.generate', { passphrase }, options);
|
|
1189
1459
|
return new AgentStatus(result);
|
|
1190
1460
|
}
|
|
1191
1461
|
async import(args) {
|
|
1192
|
-
const result = await __classPrivateFieldGet$
|
|
1462
|
+
const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.import', { ...args });
|
|
1193
1463
|
return new AgentStatus(result);
|
|
1194
1464
|
}
|
|
1195
1465
|
async lock(passphrase) {
|
|
1196
|
-
const result = await __classPrivateFieldGet$
|
|
1466
|
+
const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.lock', { passphrase });
|
|
1197
1467
|
return new AgentStatus(result);
|
|
1198
1468
|
}
|
|
1199
1469
|
async unlock(passphrase, holochain = true, options) {
|
|
1200
|
-
const result = await __classPrivateFieldGet$
|
|
1470
|
+
const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.unlock', { passphrase, holochain }, options);
|
|
1201
1471
|
return new AgentStatus(result);
|
|
1202
1472
|
}
|
|
1203
1473
|
async byDID(did) {
|
|
1204
1474
|
// agent-updated events keep cached entries fresh (the self-DID entry has no TTL).
|
|
1205
|
-
__classPrivateFieldGet$
|
|
1475
|
+
__classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
|
|
1206
1476
|
const now = Date.now();
|
|
1207
|
-
const cached = __classPrivateFieldGet$
|
|
1477
|
+
const cached = __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").get(did);
|
|
1208
1478
|
if (cached) {
|
|
1209
|
-
const isSelf = did === __classPrivateFieldGet$
|
|
1479
|
+
const isSelf = did === __classPrivateFieldGet$d(this, _AgentClient_selfDid, "f");
|
|
1210
1480
|
// Self-DID: L1 always valid (event-driven invalidation)
|
|
1211
1481
|
// Remote DID: L1 valid within TTL
|
|
1212
1482
|
if (isSelf || (now - cached.ts) < AgentClient.REMOTE_AGENT_TTL_MS) {
|
|
@@ -1216,21 +1486,21 @@ class AgentClient {
|
|
|
1216
1486
|
// Deduplicate: store the promise immediately so concurrent calls share one RPC
|
|
1217
1487
|
const promise = (async () => {
|
|
1218
1488
|
// L2: check persistent cache before network
|
|
1219
|
-
const entry = await __classPrivateFieldGet$
|
|
1489
|
+
const entry = await __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").get(did);
|
|
1220
1490
|
// entry.agent may be undefined for pre-TTL cache entries (migration) — treat as expired
|
|
1221
1491
|
if (entry?.agent && (now - (entry.ts ?? 0)) < AgentClient.REMOTE_AGENT_TTL_L2_MS) {
|
|
1222
1492
|
return entry.agent;
|
|
1223
1493
|
}
|
|
1224
1494
|
// L3: network fetch
|
|
1225
|
-
const result = toAgent(await __classPrivateFieldGet$
|
|
1226
|
-
__classPrivateFieldGet$
|
|
1495
|
+
const result = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.byDid', { did }));
|
|
1496
|
+
__classPrivateFieldGet$d(this, _AgentClient_persistent, "f").put(did, { agent: result, ts: Date.now() }); // fire-and-forget write to L2
|
|
1227
1497
|
return result;
|
|
1228
1498
|
})();
|
|
1229
|
-
__classPrivateFieldGet$
|
|
1499
|
+
__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
|
|
1230
1500
|
// Clean up on failure so next call retries
|
|
1231
1501
|
promise.catch(() => {
|
|
1232
|
-
if (__classPrivateFieldGet$
|
|
1233
|
-
__classPrivateFieldGet$
|
|
1502
|
+
if (__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
|
|
1503
|
+
__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").delete(did);
|
|
1234
1504
|
}
|
|
1235
1505
|
});
|
|
1236
1506
|
return promise;
|
|
@@ -1240,21 +1510,21 @@ class AgentClient {
|
|
|
1240
1510
|
* The self-DID receives event-driven invalidation and is never TTL-expired.
|
|
1241
1511
|
*/
|
|
1242
1512
|
setSelfDid(did) {
|
|
1243
|
-
__classPrivateFieldSet$
|
|
1513
|
+
__classPrivateFieldSet$d(this, _AgentClient_selfDid, did, "f");
|
|
1244
1514
|
}
|
|
1245
1515
|
/**
|
|
1246
1516
|
* Invalidate a specific DID's cache entry in both L1 and L2.
|
|
1247
1517
|
*/
|
|
1248
1518
|
invalidateByDid(did) {
|
|
1249
|
-
__classPrivateFieldGet$
|
|
1250
|
-
__classPrivateFieldGet$
|
|
1519
|
+
__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").delete(did);
|
|
1520
|
+
__classPrivateFieldGet$d(this, _AgentClient_persistent, "f").delete(did); // fire-and-forget
|
|
1251
1521
|
}
|
|
1252
1522
|
/**
|
|
1253
1523
|
* Clear the entire L1 (memory) byDID cache.
|
|
1254
1524
|
* L2 (IndexedDB) is preserved — agent data remains valid across sessions.
|
|
1255
1525
|
*/
|
|
1256
1526
|
clearByDidCache() {
|
|
1257
|
-
__classPrivateFieldGet$
|
|
1527
|
+
__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").clear();
|
|
1258
1528
|
}
|
|
1259
1529
|
async updatePublicPerspective(perspective) {
|
|
1260
1530
|
// Send only the signed fields: the public perspective carries no link status.
|
|
@@ -1266,36 +1536,36 @@ class AgentClient {
|
|
|
1266
1536
|
proof: { key: proof.key, signature: proof.signature, valid: proof.valid, invalid: proof.invalid },
|
|
1267
1537
|
})),
|
|
1268
1538
|
};
|
|
1269
|
-
const agent = toAgent(await __classPrivateFieldGet$
|
|
1539
|
+
const agent = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { publicPerspective }));
|
|
1270
1540
|
// Immediately update byDID cache so subsequent byDID() calls
|
|
1271
1541
|
// return fresh data without waiting for the agent-updated event
|
|
1272
|
-
__classPrivateFieldGet$
|
|
1542
|
+
__classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
|
|
1273
1543
|
return agent;
|
|
1274
1544
|
}
|
|
1275
1545
|
async mutatePublicPerspective({ additions, removals }) {
|
|
1276
|
-
const added = additions.length > 0 ? await __classPrivateFieldGet$
|
|
1546
|
+
const added = additions.length > 0 ? await __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_signLinks).call(this, additions) : [];
|
|
1277
1547
|
const { perspective } = await this.me();
|
|
1278
1548
|
const kept = (perspective?.links ?? []).filter(link => !removals.some(r => linkEqual(link, r)));
|
|
1279
1549
|
return this.updatePublicPerspective({ links: [...kept, ...added] });
|
|
1280
1550
|
}
|
|
1281
1551
|
async updateDirectMessageLanguage(directMessageLanguage) {
|
|
1282
|
-
const agent = toAgent(await __classPrivateFieldGet$
|
|
1552
|
+
const agent = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { dmLanguage: directMessageLanguage }));
|
|
1283
1553
|
// Immediately update byDID cache so subsequent byDID() calls
|
|
1284
1554
|
// return fresh data without waiting for the agent-updated event
|
|
1285
|
-
__classPrivateFieldGet$
|
|
1555
|
+
__classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
|
|
1286
1556
|
return agent;
|
|
1287
1557
|
}
|
|
1288
1558
|
async addEntanglementProofs(proofs) {
|
|
1289
|
-
return __classPrivateFieldGet$
|
|
1559
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.addEntanglementProofs', { proofs });
|
|
1290
1560
|
}
|
|
1291
1561
|
async deleteEntanglementProofs(proofs) {
|
|
1292
|
-
return __classPrivateFieldGet$
|
|
1562
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.deleteEntanglementProofs', { proofs });
|
|
1293
1563
|
}
|
|
1294
1564
|
async getEntanglementProofs() {
|
|
1295
|
-
return __classPrivateFieldGet$
|
|
1565
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.getEntanglementProofs', {});
|
|
1296
1566
|
}
|
|
1297
1567
|
async entanglementProofPreFlight(deviceKey, deviceKeyType) {
|
|
1298
|
-
return __classPrivateFieldGet$
|
|
1568
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.entanglementProofPreflight', { deviceKey, deviceKeyType });
|
|
1299
1569
|
}
|
|
1300
1570
|
/**
|
|
1301
1571
|
* Asks the executor for a capability token. `agent` names the agent the token will act
|
|
@@ -1305,45 +1575,45 @@ class AgentClient {
|
|
|
1305
1575
|
* six-digit code.
|
|
1306
1576
|
*/
|
|
1307
1577
|
async requestCapability(authInfo, agent) {
|
|
1308
|
-
return __classPrivateFieldGet$
|
|
1578
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.requestCapability', agent === undefined ? { authInfo } : { authInfo, agent });
|
|
1309
1579
|
}
|
|
1310
1580
|
async permitCapability(auth) {
|
|
1311
|
-
return __classPrivateFieldGet$
|
|
1581
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.permitCapability', { auth });
|
|
1312
1582
|
}
|
|
1313
1583
|
async generateJwt(requestId, rand) {
|
|
1314
|
-
return __classPrivateFieldGet$
|
|
1584
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.generateJwt', { requestId, rand });
|
|
1315
1585
|
}
|
|
1316
1586
|
async getApps() {
|
|
1317
|
-
return __classPrivateFieldGet$
|
|
1587
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.getApps', {});
|
|
1318
1588
|
}
|
|
1319
1589
|
async removeApp(requestId) {
|
|
1320
|
-
return __classPrivateFieldGet$
|
|
1590
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.removeApp', { id: requestId });
|
|
1321
1591
|
}
|
|
1322
1592
|
async revokeToken(requestId) {
|
|
1323
|
-
return __classPrivateFieldGet$
|
|
1593
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.revokeToken', { token: requestId });
|
|
1324
1594
|
}
|
|
1325
1595
|
async isLocked() {
|
|
1326
|
-
return __classPrivateFieldGet$
|
|
1596
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.isLocked', {});
|
|
1327
1597
|
}
|
|
1328
1598
|
async signMessage(message) {
|
|
1329
|
-
return __classPrivateFieldGet$
|
|
1599
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.sign', { message });
|
|
1330
1600
|
}
|
|
1331
1601
|
// Multi-user methods
|
|
1332
1602
|
async createUser(email, password) {
|
|
1333
|
-
return __classPrivateFieldGet$
|
|
1603
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.create', { email, password });
|
|
1334
1604
|
}
|
|
1335
1605
|
async loginUser(email, password) {
|
|
1336
|
-
return __classPrivateFieldGet$
|
|
1606
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.login', { email, password });
|
|
1337
1607
|
}
|
|
1338
1608
|
async requestLoginVerification(email, appInfo) {
|
|
1339
|
-
return __classPrivateFieldGet$
|
|
1609
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.requestVerification', { email, appInfo });
|
|
1340
1610
|
}
|
|
1341
1611
|
async verifyEmailCode(email, code, verificationType) {
|
|
1342
|
-
return __classPrivateFieldGet$
|
|
1612
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.verifyEmail', { email, code, verificationType });
|
|
1343
1613
|
}
|
|
1344
1614
|
/** Revokes this client's user token. The executor then closes the client's sockets. */
|
|
1345
1615
|
async logout() {
|
|
1346
|
-
return __classPrivateFieldGet$
|
|
1616
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.logout', {});
|
|
1347
1617
|
}
|
|
1348
1618
|
/**
|
|
1349
1619
|
* Revokes every token of a user issued up to now, this client's own included, and closes
|
|
@@ -1351,43 +1621,43 @@ class AgentClient {
|
|
|
1351
1621
|
* user. Needs AGENT_UPDATE, which a login holds. Tokens from a later login work.
|
|
1352
1622
|
*/
|
|
1353
1623
|
async revokeAllSessions(email) {
|
|
1354
|
-
return __classPrivateFieldGet$
|
|
1624
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.revokeAllSessions', email === undefined ? {} : { email });
|
|
1355
1625
|
}
|
|
1356
1626
|
// Hosting methods
|
|
1357
1627
|
async hostingUserInfo() {
|
|
1358
|
-
const info = (await __classPrivateFieldGet$
|
|
1628
|
+
const info = (await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('hosting.info', {})).userInfo ?? {
|
|
1359
1629
|
email: '', credits: null, hotWalletAddress: null, freeAccess: false,
|
|
1360
1630
|
};
|
|
1361
1631
|
return new HostingUserInfo(info.email, info.freeAccess ? 'unlimited' : String(info.credits ?? 0), info.hotWalletAddress || undefined, !!info.freeAccess);
|
|
1362
1632
|
}
|
|
1363
1633
|
async computeLog(since, limit, userEmail) {
|
|
1364
|
-
return __classPrivateFieldGet$
|
|
1634
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('runtime.computeLog', { since, limit, userEmail });
|
|
1365
1635
|
}
|
|
1366
1636
|
async setHotWalletAddress(address) {
|
|
1367
|
-
return __classPrivateFieldGet$
|
|
1637
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('hosting.setHotWallet', { address });
|
|
1368
1638
|
}
|
|
1369
1639
|
async requestPayment(amountHOT) {
|
|
1370
|
-
return __classPrivateFieldGet$
|
|
1640
|
+
return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('hosting.requestPayment', { amountHOT });
|
|
1371
1641
|
}
|
|
1372
1642
|
}
|
|
1373
1643
|
_AgentClient_apiClient = new WeakMap(), _AgentClient_memCache = new WeakMap(), _AgentClient_persistent = new WeakMap(), _AgentClient_selfDid = new WeakMap(), _AgentClient_onAgentUpdated = new WeakMap(), _AgentClient_instances = new WeakSet(), _AgentClient_cacheAgent = function _AgentClient_cacheAgent(agent) {
|
|
1374
1644
|
if (!agent.did)
|
|
1375
1645
|
return;
|
|
1376
|
-
__classPrivateFieldGet$
|
|
1377
|
-
__classPrivateFieldGet$
|
|
1378
|
-
__classPrivateFieldGet$
|
|
1646
|
+
__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").set(agent.did, { promise: Promise.resolve(agent), ts: Date.now() });
|
|
1647
|
+
__classPrivateFieldGet$d(this, _AgentClient_persistent, "f").put(agent.did, { agent, ts: Date.now() }); // fire-and-forget
|
|
1648
|
+
__classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
|
|
1379
1649
|
}, _AgentClient_signLinks =
|
|
1380
1650
|
/** Has the executor sign `links` as this agent, in a throwaway perspective. */
|
|
1381
1651
|
async function _AgentClient_signLinks(links) {
|
|
1382
|
-
const { uuid } = await __classPrivateFieldGet$
|
|
1652
|
+
const { uuid } = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('perspective.create', { name: 'Agent Perspective Proxy' });
|
|
1383
1653
|
try {
|
|
1384
|
-
return (await __classPrivateFieldGet$
|
|
1654
|
+
return (await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status: 'SHARED' })).map(LinkExpression.fromWire);
|
|
1385
1655
|
}
|
|
1386
1656
|
finally {
|
|
1387
|
-
await __classPrivateFieldGet$
|
|
1657
|
+
await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('perspective.remove', { uuid });
|
|
1388
1658
|
}
|
|
1389
1659
|
}, _AgentClient_listen = function _AgentClient_listen() {
|
|
1390
|
-
__classPrivateFieldGet$
|
|
1660
|
+
__classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").on('agent-updated', __classPrivateFieldGet$d(this, _AgentClient_onAgentUpdated, "f"));
|
|
1391
1661
|
};
|
|
1392
1662
|
/** TTL for remote (non-self) agent profiles in L1 cache (ms). */
|
|
1393
1663
|
AgentClient.REMOTE_AGENT_TTL_MS = 5 * 60000; // 5 minutes
|
|
@@ -1395,13 +1665,13 @@ AgentClient.REMOTE_AGENT_TTL_MS = 5 * 60000; // 5 minutes
|
|
|
1395
1665
|
* After this window any restart triggers a fresh network fetch. */
|
|
1396
1666
|
AgentClient.REMOTE_AGENT_TTL_L2_MS = 5 * 60000; // 5 minutes
|
|
1397
1667
|
|
|
1398
|
-
var __classPrivateFieldSet$
|
|
1668
|
+
var __classPrivateFieldSet$c = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1399
1669
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1400
1670
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1401
1671
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1402
1672
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1403
1673
|
};
|
|
1404
|
-
var __classPrivateFieldGet$
|
|
1674
|
+
var __classPrivateFieldGet$c = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1405
1675
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1406
1676
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1407
1677
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -1410,34 +1680,34 @@ var _LanguageClient_apiClient;
|
|
|
1410
1680
|
class LanguageClient {
|
|
1411
1681
|
constructor(baseUrl, token, sharedApiClient) {
|
|
1412
1682
|
_LanguageClient_apiClient.set(this, void 0);
|
|
1413
|
-
__classPrivateFieldSet$
|
|
1683
|
+
__classPrivateFieldSet$c(this, _LanguageClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
1414
1684
|
}
|
|
1415
1685
|
async byAddress(address) {
|
|
1416
|
-
return __classPrivateFieldGet$
|
|
1686
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.get', { address });
|
|
1417
1687
|
}
|
|
1418
1688
|
async byFilter(filter) {
|
|
1419
|
-
return __classPrivateFieldGet$
|
|
1689
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.all', { filter });
|
|
1420
1690
|
}
|
|
1421
1691
|
async all() {
|
|
1422
|
-
return __classPrivateFieldGet$
|
|
1692
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.all', {});
|
|
1423
1693
|
}
|
|
1424
1694
|
async writeSettings(languageAddress, settings) {
|
|
1425
|
-
return __classPrivateFieldGet$
|
|
1695
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.writeSettings', { address: languageAddress, settings });
|
|
1426
1696
|
}
|
|
1427
1697
|
async applyTemplateAndPublish(sourceLanguageHash, templateData, options) {
|
|
1428
|
-
return __classPrivateFieldGet$
|
|
1698
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.applyTemplate', { sourceLanguageHash, templateData }, options);
|
|
1429
1699
|
}
|
|
1430
1700
|
async publish(languagePath, languageMeta, options) {
|
|
1431
|
-
return __classPrivateFieldGet$
|
|
1701
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.publish', { languagePath, languageMeta }, options);
|
|
1432
1702
|
}
|
|
1433
1703
|
async meta(address) {
|
|
1434
|
-
return __classPrivateFieldGet$
|
|
1704
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.meta', { address });
|
|
1435
1705
|
}
|
|
1436
1706
|
async source(address) {
|
|
1437
|
-
return __classPrivateFieldGet$
|
|
1707
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.source', { address });
|
|
1438
1708
|
}
|
|
1439
1709
|
async remove(address) {
|
|
1440
|
-
return __classPrivateFieldGet$
|
|
1710
|
+
return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.remove', { address });
|
|
1441
1711
|
}
|
|
1442
1712
|
}
|
|
1443
1713
|
_LanguageClient_apiClient = new WeakMap();
|
|
@@ -1489,13 +1759,13 @@ function neighbourhoodExpressionFromWire(wire) {
|
|
|
1489
1759
|
return new NeighbourhoodExpression(wire.author, wire.timestamp, new Neighbourhood(wire.data.linkLanguage, meta), wire.proof);
|
|
1490
1760
|
}
|
|
1491
1761
|
|
|
1492
|
-
var __classPrivateFieldSet$
|
|
1762
|
+
var __classPrivateFieldSet$b = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
1493
1763
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1494
1764
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1495
1765
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1496
1766
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1497
1767
|
};
|
|
1498
|
-
var __classPrivateFieldGet$
|
|
1768
|
+
var __classPrivateFieldGet$b = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
1499
1769
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1500
1770
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1501
1771
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -1506,59 +1776,59 @@ class NeighbourhoodClient {
|
|
|
1506
1776
|
_NeighbourhoodClient_apiClient.set(this, void 0);
|
|
1507
1777
|
_NeighbourhoodClient_signalHandlers.set(this, new Map());
|
|
1508
1778
|
_NeighbourhoodClient_signalUnsubscribers.set(this, new Map());
|
|
1509
|
-
__classPrivateFieldSet$
|
|
1779
|
+
__classPrivateFieldSet$b(this, _NeighbourhoodClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
1510
1780
|
}
|
|
1511
1781
|
async publishFromPerspective(perspectiveUUID, linkLanguage, meta, options) {
|
|
1512
|
-
return __classPrivateFieldGet$
|
|
1782
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.publish', {
|
|
1513
1783
|
perspectiveUuid: perspectiveUUID, linkLanguage, meta: Perspective.toWire(meta)
|
|
1514
1784
|
}, options);
|
|
1515
1785
|
}
|
|
1516
1786
|
async joinFromUrl(url, options) {
|
|
1517
|
-
return PerspectiveHandle.fromWire(await __classPrivateFieldGet$
|
|
1787
|
+
return PerspectiveHandle.fromWire(await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.join', { url }, options));
|
|
1518
1788
|
}
|
|
1519
1789
|
async otherAgents(perspectiveUUID) {
|
|
1520
|
-
return __classPrivateFieldGet$
|
|
1790
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.otherAgents', { uuid: perspectiveUUID });
|
|
1521
1791
|
}
|
|
1522
1792
|
async hasTelepresenceAdapter(perspectiveUUID) {
|
|
1523
|
-
return __classPrivateFieldGet$
|
|
1793
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.hasTelepresence', { uuid: perspectiveUUID });
|
|
1524
1794
|
}
|
|
1525
1795
|
async onlineAgents(perspectiveUUID) {
|
|
1526
|
-
const agents = await __classPrivateFieldGet$
|
|
1796
|
+
const agents = await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.onlineAgents', { uuid: perspectiveUUID });
|
|
1527
1797
|
return agents.map(({ did, status }) => ({ did, status: PerspectiveExpression.fromWire(status) }));
|
|
1528
1798
|
}
|
|
1529
1799
|
/** The caller's own online status, as it last set it on this executor, or `null`. */
|
|
1530
1800
|
async ownOnlineStatus(perspectiveUUID) {
|
|
1531
|
-
const status = await __classPrivateFieldGet$
|
|
1801
|
+
const status = await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.ownOnlineStatus', { uuid: perspectiveUUID });
|
|
1532
1802
|
return status ? PerspectiveExpression.fromWire(status) : null;
|
|
1533
1803
|
}
|
|
1534
1804
|
async setOnlineStatus(perspectiveUUID, status) {
|
|
1535
|
-
return __classPrivateFieldGet$
|
|
1805
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status: Perspective.toWire(status) });
|
|
1536
1806
|
}
|
|
1537
1807
|
async setOnlineStatusU(perspectiveUUID, status) {
|
|
1538
|
-
return __classPrivateFieldGet$
|
|
1808
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status, signed: false });
|
|
1539
1809
|
}
|
|
1540
1810
|
async sendSignal(perspectiveUUID, remoteAgentDid, payload) {
|
|
1541
|
-
return __classPrivateFieldGet$
|
|
1811
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendSignal', {
|
|
1542
1812
|
uuid: perspectiveUUID, remoteAgentDid, payload: Perspective.toWire(payload)
|
|
1543
1813
|
});
|
|
1544
1814
|
}
|
|
1545
1815
|
async sendSignalU(perspectiveUUID, remoteAgentDid, payload) {
|
|
1546
|
-
return __classPrivateFieldGet$
|
|
1816
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendSignal', {
|
|
1547
1817
|
uuid: perspectiveUUID, remoteAgentDid, payload, signed: false
|
|
1548
1818
|
});
|
|
1549
1819
|
}
|
|
1550
1820
|
async sendBroadcast(perspectiveUUID, payload, loopback = false) {
|
|
1551
|
-
return __classPrivateFieldGet$
|
|
1821
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendBroadcast', {
|
|
1552
1822
|
uuid: perspectiveUUID, payload: Perspective.toWire(payload), loopback
|
|
1553
1823
|
});
|
|
1554
1824
|
}
|
|
1555
1825
|
async sendBroadcastU(perspectiveUUID, payload, loopback = false) {
|
|
1556
|
-
return __classPrivateFieldGet$
|
|
1826
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendBroadcast', {
|
|
1557
1827
|
uuid: perspectiveUUID, payload, loopback, signed: false
|
|
1558
1828
|
});
|
|
1559
1829
|
}
|
|
1560
1830
|
dispatchSignal(perspectiveUUID, signal) {
|
|
1561
|
-
const handlers = __classPrivateFieldGet$
|
|
1831
|
+
const handlers = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
1562
1832
|
if (handlers) {
|
|
1563
1833
|
for (const handler of handlers) {
|
|
1564
1834
|
try {
|
|
@@ -1571,15 +1841,15 @@ class NeighbourhoodClient {
|
|
|
1571
1841
|
}
|
|
1572
1842
|
}
|
|
1573
1843
|
async subscribeToSignals(perspectiveUUID) {
|
|
1574
|
-
const unsub = __classPrivateFieldGet$
|
|
1575
|
-
__classPrivateFieldGet$
|
|
1576
|
-
await __classPrivateFieldGet$
|
|
1844
|
+
const unsub = __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on('signal', (event) => this.dispatchSignal(perspectiveUUID, PerspectiveExpression.fromWire(event.signal)), { perspective: perspectiveUUID });
|
|
1845
|
+
__classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").set(perspectiveUUID, unsub);
|
|
1846
|
+
await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").watchApplied();
|
|
1577
1847
|
}
|
|
1578
1848
|
async addSignalHandler(perspectiveUUID, handler) {
|
|
1579
|
-
let handlersForPerspective = __classPrivateFieldGet$
|
|
1849
|
+
let handlersForPerspective = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
1580
1850
|
if (!handlersForPerspective) {
|
|
1581
1851
|
handlersForPerspective = [];
|
|
1582
|
-
__classPrivateFieldGet$
|
|
1852
|
+
__classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
|
|
1583
1853
|
handlersForPerspective.push(handler);
|
|
1584
1854
|
await this.subscribeToSignals(perspectiveUUID);
|
|
1585
1855
|
}
|
|
@@ -1588,18 +1858,18 @@ class NeighbourhoodClient {
|
|
|
1588
1858
|
}
|
|
1589
1859
|
}
|
|
1590
1860
|
removeSignalHandler(perspectiveUUID, handler) {
|
|
1591
|
-
const handlersForPerspective = __classPrivateFieldGet$
|
|
1861
|
+
const handlersForPerspective = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
|
|
1592
1862
|
if (handlersForPerspective) {
|
|
1593
1863
|
const index = handlersForPerspective.indexOf(handler);
|
|
1594
1864
|
if (index > -1) {
|
|
1595
1865
|
handlersForPerspective.splice(index, 1);
|
|
1596
1866
|
}
|
|
1597
1867
|
if (handlersForPerspective.length === 0) {
|
|
1598
|
-
__classPrivateFieldGet$
|
|
1599
|
-
const unsub = __classPrivateFieldGet$
|
|
1868
|
+
__classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
|
|
1869
|
+
const unsub = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").get(perspectiveUUID);
|
|
1600
1870
|
if (unsub) {
|
|
1601
1871
|
unsub();
|
|
1602
|
-
__classPrivateFieldGet$
|
|
1872
|
+
__classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").delete(perspectiveUUID);
|
|
1603
1873
|
}
|
|
1604
1874
|
}
|
|
1605
1875
|
}
|
|
@@ -1612,49 +1882,65 @@ class NeighbourhoodClient {
|
|
|
1612
1882
|
// structured `CallSessionInfo` (SDP answer + optional cascade
|
|
1613
1883
|
// redirect + stream mapping).
|
|
1614
1884
|
async sfuStartRoom(neighbourhoodUrl, roomName) {
|
|
1615
|
-
return __classPrivateFieldGet$
|
|
1885
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.startRoom", { neighbourhoodUrl, roomName });
|
|
1616
1886
|
}
|
|
1617
1887
|
async sfuStopRoom(neighbourhoodUrl, roomName) {
|
|
1618
|
-
return __classPrivateFieldGet$
|
|
1888
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.stopRoom", { neighbourhoodUrl, roomName });
|
|
1619
1889
|
}
|
|
1620
1890
|
async sfuListRooms() {
|
|
1621
|
-
return __classPrivateFieldGet$
|
|
1891
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.listRooms", {});
|
|
1622
1892
|
}
|
|
1623
1893
|
async sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer) {
|
|
1624
|
-
return __classPrivateFieldGet$
|
|
1894
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callJoin", {
|
|
1625
1895
|
neighbourhoodUrl,
|
|
1626
1896
|
roomName,
|
|
1627
1897
|
sdpOffer,
|
|
1628
1898
|
});
|
|
1629
1899
|
}
|
|
1630
1900
|
async sfuCallLeave(neighbourhoodUrl, roomName) {
|
|
1631
|
-
return __classPrivateFieldGet$
|
|
1901
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callLeave", { neighbourhoodUrl, roomName });
|
|
1632
1902
|
}
|
|
1633
1903
|
async sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference) {
|
|
1634
|
-
return __classPrivateFieldGet$
|
|
1904
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callSetQualityPreference", {
|
|
1635
1905
|
neighbourhoodUrl,
|
|
1636
1906
|
roomName,
|
|
1637
1907
|
preference,
|
|
1638
1908
|
});
|
|
1639
1909
|
}
|
|
1640
1910
|
async sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
|
|
1641
|
-
return __classPrivateFieldGet$
|
|
1911
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callAnswerServerOffer", {
|
|
1642
1912
|
neighbourhoodUrl,
|
|
1643
1913
|
roomName,
|
|
1644
1914
|
sdpAnswer,
|
|
1645
1915
|
});
|
|
1646
1916
|
}
|
|
1917
|
+
/** Ask the SFU to restart ICE on this agent's call connection. The offer
|
|
1918
|
+
* arrives as an `sfu-call-renegotiation-offer` event; answer it with
|
|
1919
|
+
* {@link sfuCallAnswerServerOffer}. */
|
|
1920
|
+
async sfuCallRestartIce(neighbourhoodUrl, roomName) {
|
|
1921
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callRestartIce", { neighbourhoodUrl, roomName });
|
|
1922
|
+
}
|
|
1923
|
+
/** Fires after a network change, once the client's socket is back on
|
|
1924
|
+
* the new network. See {@link ApiClient.onNetworkChange}. */
|
|
1925
|
+
onNetworkChange(callback) {
|
|
1926
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").onNetworkChange(callback);
|
|
1927
|
+
}
|
|
1928
|
+
/** Check the client's socket now: one that says nothing within a
|
|
1929
|
+
* deadline is treated as a network change. See {@link ApiClient.checkConnection}. */
|
|
1930
|
+
checkConnection() {
|
|
1931
|
+
__classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").checkConnection();
|
|
1932
|
+
}
|
|
1647
1933
|
async sfuGetConfig(neighbourhoodUrl) {
|
|
1648
|
-
return __classPrivateFieldGet$
|
|
1934
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.getConfig", { neighbourhoodUrl });
|
|
1649
1935
|
}
|
|
1650
1936
|
async sfuSetConfig(neighbourhoodUrl, config) {
|
|
1651
|
-
return __classPrivateFieldGet$
|
|
1937
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.setConfig", { neighbourhoodUrl, config });
|
|
1652
1938
|
}
|
|
1653
1939
|
async sfuPeerForNeighbourhood(neighbourhoodUrl) {
|
|
1654
|
-
return __classPrivateFieldGet$
|
|
1940
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeerForNeighbourhood", { neighbourhoodUrl });
|
|
1655
1941
|
}
|
|
1656
1942
|
async sfuPeersForNeighbourhood(neighbourhoodUrl) {
|
|
1657
|
-
return __classPrivateFieldGet$
|
|
1943
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeersForNeighbourhood", { neighbourhoodUrl });
|
|
1658
1944
|
}
|
|
1659
1945
|
// ── Trickle ICE ───────────────────────────────────────────────────
|
|
1660
1946
|
/**
|
|
@@ -1666,7 +1952,7 @@ class NeighbourhoodClient {
|
|
|
1666
1952
|
* networks).
|
|
1667
1953
|
*/
|
|
1668
1954
|
async sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate) {
|
|
1669
|
-
return __classPrivateFieldGet$
|
|
1955
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.addIceCandidate", {
|
|
1670
1956
|
neighbourhoodUrl,
|
|
1671
1957
|
roomName,
|
|
1672
1958
|
candidate,
|
|
@@ -1679,7 +1965,7 @@ class NeighbourhoodClient {
|
|
|
1679
1965
|
* publishes it as an `sfu-data` event.
|
|
1680
1966
|
*/
|
|
1681
1967
|
async sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
|
|
1682
|
-
return __classPrivateFieldGet$
|
|
1968
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sendData", {
|
|
1683
1969
|
neighbourhoodUrl,
|
|
1684
1970
|
roomName,
|
|
1685
1971
|
channelLabel,
|
|
@@ -1695,11 +1981,11 @@ class NeighbourhoodClient {
|
|
|
1695
1981
|
subscribeSfuDataChannel(callback) {
|
|
1696
1982
|
// A fresh handler per call: `on` merges a repeated handler, and
|
|
1697
1983
|
// each subscription must own its unsubscribe.
|
|
1698
|
-
return __classPrivateFieldGet$
|
|
1984
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-data", (message) => callback(message));
|
|
1699
1985
|
}
|
|
1700
1986
|
/** Subscribe to the rosters of the call rooms this agent is in: who is in each, whenever that changes. */
|
|
1701
1987
|
subscribeSfuRoomRoster(callback) {
|
|
1702
|
-
return __classPrivateFieldGet$
|
|
1988
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-room-roster", (roster) => callback(roster));
|
|
1703
1989
|
}
|
|
1704
1990
|
/**
|
|
1705
1991
|
* Subscribe to server-pushed SFU SDP renegotiation offers. The
|
|
@@ -1713,7 +1999,7 @@ class NeighbourhoodClient {
|
|
|
1713
1999
|
* Returns an unsubscribe function.
|
|
1714
2000
|
*/
|
|
1715
2001
|
subscribeSfuCallRenegotiationOffer(targetDid, callback) {
|
|
1716
|
-
return __classPrivateFieldGet$
|
|
2002
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-call-renegotiation-offer", (event) => {
|
|
1717
2003
|
if (event.targetDid !== targetDid)
|
|
1718
2004
|
return;
|
|
1719
2005
|
callback({
|
|
@@ -1732,7 +2018,7 @@ class NeighbourhoodClient {
|
|
|
1732
2018
|
* node. Returns an unsubscribe function.
|
|
1733
2019
|
*/
|
|
1734
2020
|
subscribeSfuMigrateEvent(targetDid, callback) {
|
|
1735
|
-
return __classPrivateFieldGet$
|
|
2021
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-migrate", (event) => {
|
|
1736
2022
|
if (event.targetDid !== targetDid)
|
|
1737
2023
|
return;
|
|
1738
2024
|
callback({
|
|
@@ -1752,12 +2038,12 @@ class NeighbourhoodClient {
|
|
|
1752
2038
|
* @param perspectiveId The neighbourhood's perspective handle UUID.
|
|
1753
2039
|
*/
|
|
1754
2040
|
async sfuServesAllMembers(perspectiveId) {
|
|
1755
|
-
return __classPrivateFieldGet$
|
|
2041
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.servesAllMembers", { uuid: perspectiveId });
|
|
1756
2042
|
}
|
|
1757
2043
|
// ── SFU diagnostic / test-harness endpoints ────────────────────────
|
|
1758
2044
|
/** The calling agent's own DID — the user's, for a user token. */
|
|
1759
2045
|
async callerDid() {
|
|
1760
|
-
return (await __classPrivateFieldGet$
|
|
2046
|
+
return (await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("agent.status", {})).did;
|
|
1761
2047
|
}
|
|
1762
2048
|
/**
|
|
1763
2049
|
* Read-only: SFU service status including public reachability.
|
|
@@ -1766,7 +2052,7 @@ class NeighbourhoodClient {
|
|
|
1766
2052
|
* determine its reachability (unknown).
|
|
1767
2053
|
*/
|
|
1768
2054
|
async sfuStatus() {
|
|
1769
|
-
return __classPrivateFieldGet$
|
|
2055
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.status", {});
|
|
1770
2056
|
}
|
|
1771
2057
|
/**
|
|
1772
2058
|
* Read-only: how many SFU↔SFU pipe transports are fully established,
|
|
@@ -1774,14 +2060,14 @@ class NeighbourhoodClient {
|
|
|
1774
2060
|
* assertions.
|
|
1775
2061
|
*/
|
|
1776
2062
|
async sfuCascadeStatus() {
|
|
1777
|
-
return __classPrivateFieldGet$
|
|
2063
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.cascadeStatus", {});
|
|
1778
2064
|
}
|
|
1779
2065
|
/**
|
|
1780
2066
|
* Read-only: per-participant quality preferences the SFU event loop
|
|
1781
2067
|
* currently holds. Returns `[{participantId, preference}, ...]`.
|
|
1782
2068
|
*/
|
|
1783
2069
|
async sfuQualityPreferences() {
|
|
1784
|
-
return __classPrivateFieldGet$
|
|
2070
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.qualityPreferences", {});
|
|
1785
2071
|
}
|
|
1786
2072
|
/**
|
|
1787
2073
|
* Register a DID as a neighbourhood member on this executor.
|
|
@@ -1790,7 +2076,7 @@ class NeighbourhoodClient {
|
|
|
1790
2076
|
* deployments.
|
|
1791
2077
|
*/
|
|
1792
2078
|
async sfuEnsureMembership(neighbourhoodUrl, did) {
|
|
1793
|
-
return __classPrivateFieldGet$
|
|
2079
|
+
return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.ensureMembership", {
|
|
1794
2080
|
neighbourhoodUrl,
|
|
1795
2081
|
did,
|
|
1796
2082
|
});
|
|
@@ -1842,10 +2128,17 @@ class SfuManager {
|
|
|
1842
2128
|
this.qualityPreference = null;
|
|
1843
2129
|
/** Server offers waiting to be applied, in arrival order, one at a time. */
|
|
1844
2130
|
this.offerQueue = Promise.resolve();
|
|
2131
|
+
/** The last server offer answered. The executor sends an unanswered
|
|
2132
|
+
* restart offer again when asked twice; one that was answered meanwhile
|
|
2133
|
+
* must not be answered again, or that answer lands on its next offer. */
|
|
2134
|
+
this.answeredOffer = null;
|
|
1845
2135
|
this.renegotiationUnsubscribe = null;
|
|
1846
2136
|
this.rosterUnsubscribe = null;
|
|
1847
2137
|
this.dataChannelUnsubscribe = null;
|
|
1848
|
-
this
|
|
2138
|
+
/** An ICE restart is in flight until this fires: ICE going disconnected
|
|
2139
|
+
* again joins it, a network change replaces it. */
|
|
2140
|
+
this.restartTimer = null;
|
|
2141
|
+
this.networkUnsubscribe = null;
|
|
1849
2142
|
/** Running while the room's roster leaves this agent out: see `noticeRoster`. */
|
|
1850
2143
|
this.unlistedTimer = null;
|
|
1851
2144
|
this.neighbourhood = neighbourhood;
|
|
@@ -1900,6 +2193,7 @@ class SfuManager {
|
|
|
1900
2193
|
}
|
|
1901
2194
|
console.info(`SFU: connection failed, reconnecting (${this.reconnectAttempts}/${SfuManager.MAX_RECONNECTS})`);
|
|
1902
2195
|
this.reconnecting = true;
|
|
2196
|
+
this.endRestart();
|
|
1903
2197
|
try {
|
|
1904
2198
|
const deadline = Date.now() + SfuManager.REJOIN_WINDOW_MS;
|
|
1905
2199
|
for (let delay = 1000;; delay = Math.min(delay * 2, 10000)) {
|
|
@@ -1942,6 +2236,38 @@ class SfuManager {
|
|
|
1942
2236
|
this.reconnecting = false;
|
|
1943
2237
|
}
|
|
1944
2238
|
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Repair the connection in place: the SFU offers new ICE credentials
|
|
2241
|
+
* (`sfuCallRestartIce`), the offer is answered like any server offer,
|
|
2242
|
+
* and the browser gathers candidates on whatever network it has now.
|
|
2243
|
+
* DTLS, tracks and the room slot stay. If the connection is not back
|
|
2244
|
+
* within `RESTART_TIMEOUT_MS`, the call is rebuilt. One restart at a
|
|
2245
|
+
* time: a call while one is in flight does nothing.
|
|
2246
|
+
*/
|
|
2247
|
+
restartIce(pc) {
|
|
2248
|
+
if (this.restartTimer || this.reconnecting || this.state.peerConnection !== pc)
|
|
2249
|
+
return;
|
|
2250
|
+
console.info("SFU: restarting ICE");
|
|
2251
|
+
this.restartTimer = setTimeout(() => {
|
|
2252
|
+
this.restartTimer = null;
|
|
2253
|
+
if (this.state.peerConnection !== pc)
|
|
2254
|
+
return;
|
|
2255
|
+
if (pc.iceConnectionState === "connected" || pc.iceConnectionState === "completed")
|
|
2256
|
+
return;
|
|
2257
|
+
void this.reconnect();
|
|
2258
|
+
}, SfuManager.RESTART_TIMEOUT_MS);
|
|
2259
|
+
// A refusal (an executor without the method, or one that lost this
|
|
2260
|
+
// session) leaves the decision to the timeout: a blip may still heal.
|
|
2261
|
+
this.neighbourhood.sfuCallRestartIce(this.neighbourhoodUrl, this.roomId).catch((err) => {
|
|
2262
|
+
console.warn("SFU: ICE restart refused:", err);
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
endRestart() {
|
|
2266
|
+
if (this.restartTimer) {
|
|
2267
|
+
clearTimeout(this.restartTimer);
|
|
2268
|
+
this.restartTimer = null;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
1945
2271
|
on(event, callback) {
|
|
1946
2272
|
if (!this.callbacks.has(event)) {
|
|
1947
2273
|
this.callbacks.set(event, []);
|
|
@@ -1980,48 +2306,45 @@ class SfuManager {
|
|
|
1980
2306
|
this.state.localStream = localStream;
|
|
1981
2307
|
const pc = new RTCPeerConnection({ iceServers: this.iceServers });
|
|
1982
2308
|
this.state.peerConnection = pc;
|
|
1983
|
-
// ICE state monitoring for
|
|
1984
|
-
//
|
|
1985
|
-
//
|
|
1986
|
-
// dropping the peer, and a rebuild only follows once the server
|
|
1987
|
-
// would have dropped it anyway. "failed" reconnects at once.
|
|
2309
|
+
// ICE state monitoring for recovery. "disconnected" (a route change,
|
|
2310
|
+
// a network switch, a blip) restarts ICE on this connection at once;
|
|
2311
|
+
// "failed" rebuilds the call at once.
|
|
1988
2312
|
pc.oniceconnectionstatechange = () => {
|
|
1989
2313
|
if (this.state.peerConnection !== pc)
|
|
1990
2314
|
return; // superseded
|
|
1991
2315
|
if (pc.iceConnectionState === "failed") {
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
this.disconnectedTimer = null;
|
|
1995
|
-
}
|
|
1996
|
-
this.reconnect();
|
|
2316
|
+
this.endRestart();
|
|
2317
|
+
void this.reconnect();
|
|
1997
2318
|
}
|
|
1998
2319
|
else if (pc.iceConnectionState === "disconnected") {
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
// and still disconnected.
|
|
2004
|
-
if (this.state.peerConnection === pc &&
|
|
2005
|
-
pc.iceConnectionState === "disconnected") {
|
|
2006
|
-
this.reconnect();
|
|
2007
|
-
}
|
|
2008
|
-
}, SfuManager.DISCONNECT_GRACE_MS);
|
|
2009
|
-
}
|
|
2320
|
+
// The path may be gone with no `online` event; the restart
|
|
2321
|
+
// needs a live socket, and a dead one is redialled in seconds.
|
|
2322
|
+
this.neighbourhood.checkConnection();
|
|
2323
|
+
this.restartIce(pc);
|
|
2010
2324
|
}
|
|
2011
|
-
else
|
|
2012
|
-
|
|
2013
|
-
//
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
pc.iceConnectionState === "completed") {
|
|
2017
|
-
this.reconnectAttempts = 0;
|
|
2018
|
-
}
|
|
2019
|
-
if (this.disconnectedTimer) {
|
|
2020
|
-
clearTimeout(this.disconnectedTimer);
|
|
2021
|
-
this.disconnectedTimer = null;
|
|
2022
|
-
}
|
|
2325
|
+
else if (pc.iceConnectionState === "connected" ||
|
|
2326
|
+
pc.iceConnectionState === "completed") {
|
|
2327
|
+
// A working path ends a restart and a run of reconnects.
|
|
2328
|
+
this.reconnectAttempts = 0;
|
|
2329
|
+
this.endRestart();
|
|
2023
2330
|
}
|
|
2024
2331
|
};
|
|
2332
|
+
// A network change: the path ICE uses is likely gone, though ICE may
|
|
2333
|
+
// not have noticed yet. Restart it now, on the socket the change
|
|
2334
|
+
// reconnected, with its own timeout. If a restart's offer is still
|
|
2335
|
+
// unanswered (it went out over the old network and may never have
|
|
2336
|
+
// arrived), the executor sends it again and, once it is answered,
|
|
2337
|
+
// restarts again for this network. Listened to once per call, not
|
|
2338
|
+
// per rebuild.
|
|
2339
|
+
if (!this.networkUnsubscribe) {
|
|
2340
|
+
this.networkUnsubscribe = this.neighbourhood.onNetworkChange(() => {
|
|
2341
|
+
const current = this.state.peerConnection;
|
|
2342
|
+
if (!current || this.reconnecting)
|
|
2343
|
+
return;
|
|
2344
|
+
this.endRestart();
|
|
2345
|
+
this.restartIce(current);
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2025
2348
|
// Both kinds of local media, send-only, declared now whether or not a
|
|
2026
2349
|
// track exists yet: the SFU only ever receives on these sections, and a
|
|
2027
2350
|
// camera or screen started later replaces an empty track with no
|
|
@@ -2210,7 +2533,7 @@ class SfuManager {
|
|
|
2210
2533
|
}
|
|
2211
2534
|
/** Apply one server offer to `pc` and answer it, unless `pc` is no longer the call's. */
|
|
2212
2535
|
async applyServerOffer(pc, event) {
|
|
2213
|
-
if (this.state.peerConnection !== pc)
|
|
2536
|
+
if (this.state.peerConnection !== pc || event.sdpOffer === this.answeredOffer)
|
|
2214
2537
|
return;
|
|
2215
2538
|
// The mapping first: the tracks this offer adds arrive while it is applied.
|
|
2216
2539
|
for (const entry of event.trackMapping ?? []) {
|
|
@@ -2220,6 +2543,7 @@ class SfuManager {
|
|
|
2220
2543
|
await pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(event.sdpOffer)));
|
|
2221
2544
|
await pc.setLocalDescription(await pc.createAnswer());
|
|
2222
2545
|
await this.neighbourhood.sfuCallAnswerServerOffer(this.neighbourhoodUrl, event.roomName, JSON.stringify(pc.localDescription));
|
|
2546
|
+
this.answeredOffer = event.sdpOffer;
|
|
2223
2547
|
}
|
|
2224
2548
|
catch (err) {
|
|
2225
2549
|
if (this.state.peerConnection !== pc)
|
|
@@ -2280,10 +2604,9 @@ class SfuManager {
|
|
|
2280
2604
|
async leave() {
|
|
2281
2605
|
this.generation++;
|
|
2282
2606
|
this.releaseServerEvents();
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
}
|
|
2607
|
+
this.endRestart();
|
|
2608
|
+
this.networkUnsubscribe?.();
|
|
2609
|
+
this.networkUnsubscribe = null;
|
|
2287
2610
|
this.senders.clear();
|
|
2288
2611
|
this.replacedTracks.clear();
|
|
2289
2612
|
this.qualityPreference = null;
|
|
@@ -2414,8 +2737,8 @@ class SfuManager {
|
|
|
2414
2737
|
SfuManager.MAX_RECONNECTS = 3;
|
|
2415
2738
|
/** How long one rebuild keeps retrying a join the executor cannot take yet. */
|
|
2416
2739
|
SfuManager.REJOIN_WINDOW_MS = 120000;
|
|
2417
|
-
/** How long ICE
|
|
2418
|
-
SfuManager.
|
|
2740
|
+
/** How long an ICE restart has to bring the connection back before a rebuild. */
|
|
2741
|
+
SfuManager.RESTART_TIMEOUT_MS = 5000;
|
|
2419
2742
|
/** How long the roster may leave this agent out before the call is rebuilt. */
|
|
2420
2743
|
SfuManager.UNLISTED_GRACE_MS = 3000;
|
|
2421
2744
|
|
|
@@ -2727,6 +3050,7 @@ class MeshManager {
|
|
|
2727
3050
|
* Cleared only when a renegotiation is answered.
|
|
2728
3051
|
*/
|
|
2729
3052
|
this.renegotiationRepairs = new Map();
|
|
3053
|
+
this.unwatchNetwork = null;
|
|
2730
3054
|
this.channel = options.channel;
|
|
2731
3055
|
this.callId = options.callId;
|
|
2732
3056
|
this.selfId = options.selfId;
|
|
@@ -2740,6 +3064,8 @@ class MeshManager {
|
|
|
2740
3064
|
?? ((configuration) => new RTCPeerConnection(configuration));
|
|
2741
3065
|
this.now = options.now ?? (() => Date.now());
|
|
2742
3066
|
this.sweepMs = options.sweepMs ?? SWEEP_INTERVAL_MS;
|
|
3067
|
+
this.onNetworkChange = options.onNetworkChange;
|
|
3068
|
+
this.checkConnection = options.checkConnection;
|
|
2743
3069
|
}
|
|
2744
3070
|
// ── Events ──────────────────────────────────────────────────────
|
|
2745
3071
|
on(event, callback) {
|
|
@@ -2842,6 +3168,7 @@ class MeshManager {
|
|
|
2842
3168
|
this.publish({ v: CALL_PROTOCOL_VERSION, call: this.callId, warm: true });
|
|
2843
3169
|
if (this.sweepMs > 0)
|
|
2844
3170
|
this.sweep = setInterval(() => this.tick(), this.sweepMs);
|
|
3171
|
+
this.unwatchNetwork = this.onNetworkChange?.(() => this.restartAll()) ?? null;
|
|
2845
3172
|
}
|
|
2846
3173
|
async leave() {
|
|
2847
3174
|
this.closed = true;
|
|
@@ -2849,6 +3176,8 @@ class MeshManager {
|
|
|
2849
3176
|
clearInterval(this.sweep);
|
|
2850
3177
|
this.sweep = null;
|
|
2851
3178
|
}
|
|
3179
|
+
this.unwatchNetwork?.();
|
|
3180
|
+
this.unwatchNetwork = null;
|
|
2852
3181
|
this.unwatchPublish?.();
|
|
2853
3182
|
this.unwatchPublish = null;
|
|
2854
3183
|
if (this.channelUnsubscribe) {
|
|
@@ -3164,8 +3493,10 @@ class MeshManager {
|
|
|
3164
3493
|
if (slot.offerDeferred && pc.signalingState === "stable")
|
|
3165
3494
|
void negotiate();
|
|
3166
3495
|
}
|
|
3167
|
-
if (state === "disconnected" && !slot.disconnectedAt)
|
|
3496
|
+
if (state === "disconnected" && !slot.disconnectedAt) {
|
|
3168
3497
|
slot.disconnectedAt = this.now();
|
|
3498
|
+
this.checkConnection?.();
|
|
3499
|
+
}
|
|
3169
3500
|
if (state === "connected" || state === "failed")
|
|
3170
3501
|
slot.disconnectedAt = 0;
|
|
3171
3502
|
this.emit("peer-state", peerId, state);
|
|
@@ -3503,6 +3834,39 @@ class MeshManager {
|
|
|
3503
3834
|
slot.attempts = attempts - 1;
|
|
3504
3835
|
this.rebuild(peerId, { announce: true, rung: "rebuild" });
|
|
3505
3836
|
}
|
|
3837
|
+
/**
|
|
3838
|
+
* The network changed: every pair's path is likely gone, though ICE has
|
|
3839
|
+
* noticed on none yet. Each negotiated pair takes the ladder's first rung
|
|
3840
|
+
* now, all at once — an ICE restart is one offer per pair, and waiting
|
|
3841
|
+
* for each to time out costs seconds of silence. Pairs still negotiating
|
|
3842
|
+
* have nothing to restart; the sweep keeps looking after them.
|
|
3843
|
+
*
|
|
3844
|
+
* It skips the sweep's guards (`outstanding`, one pair per sweep) on
|
|
3845
|
+
* purpose. They stop the sweep reading a slow send as a lost one and
|
|
3846
|
+
* escalating every pair at once. Here nothing is judged lost, and the
|
|
3847
|
+
* rung is the first one: one offer per pair, each to a different peer.
|
|
3848
|
+
* A restart offer that is lost falls to the sweep, guards and all.
|
|
3849
|
+
*/
|
|
3850
|
+
restartAll() {
|
|
3851
|
+
if (this.closed)
|
|
3852
|
+
return;
|
|
3853
|
+
const at = this.now();
|
|
3854
|
+
for (const [peerId, slot] of this.slots) {
|
|
3855
|
+
if (!slot.remoteReady || typeof slot.pc.restartIce !== "function")
|
|
3856
|
+
continue;
|
|
3857
|
+
// Spaced from the sweep's next rung, but not charged to the pair's
|
|
3858
|
+
// budget: a network change judges no pair lost.
|
|
3859
|
+
slot.lastAttempt = at;
|
|
3860
|
+
try {
|
|
3861
|
+
slot.pc.restartIce();
|
|
3862
|
+
this.emit("peer-recovery", peerId, { rung: "ice-restart", attempts: slot.attempts });
|
|
3863
|
+
}
|
|
3864
|
+
catch (error) {
|
|
3865
|
+
this.fail(`restarting ice with ${peerId}`, error);
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
this.lastRepairAt = at;
|
|
3869
|
+
}
|
|
3506
3870
|
/** Whether this pair has been given long enough, and whether it is this side's turn to act. */
|
|
3507
3871
|
dueForRepair(peerId, slot, at) {
|
|
3508
3872
|
const state = slot.pc.connectionState;
|
|
@@ -3804,6 +4168,8 @@ function createSession(config) {
|
|
|
3804
4168
|
callId: roomId,
|
|
3805
4169
|
selfId: agentDid,
|
|
3806
4170
|
...(meshIce.length > 0 ? { iceServers: meshIce } : {}),
|
|
4171
|
+
onNetworkChange: (cb) => api.onNetworkChange(cb),
|
|
4172
|
+
checkConnection: () => api.checkConnection(),
|
|
3807
4173
|
});
|
|
3808
4174
|
meshManager = mesh;
|
|
3809
4175
|
wireMeshEvents(mesh);
|
|
@@ -3975,13 +4341,13 @@ function createSession(config) {
|
|
|
3975
4341
|
return session;
|
|
3976
4342
|
}
|
|
3977
4343
|
|
|
3978
|
-
var __classPrivateFieldSet$
|
|
4344
|
+
var __classPrivateFieldSet$a = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3979
4345
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3980
4346
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
3981
4347
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3982
4348
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
3983
4349
|
};
|
|
3984
|
-
var __classPrivateFieldGet$
|
|
4350
|
+
var __classPrivateFieldGet$a = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3985
4351
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3986
4352
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
3987
4353
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -3997,9 +4363,9 @@ class NeighbourhoodProxy {
|
|
|
3997
4363
|
);
|
|
3998
4364
|
/** Cached SFU status — fetched once per proxy lifetime. */
|
|
3999
4365
|
_NeighbourhoodProxy_sfuStatusCache.set(this, null);
|
|
4000
|
-
__classPrivateFieldSet$
|
|
4001
|
-
__classPrivateFieldSet$
|
|
4002
|
-
__classPrivateFieldSet$
|
|
4366
|
+
__classPrivateFieldSet$a(this, _NeighbourhoodProxy_client, client, "f");
|
|
4367
|
+
__classPrivateFieldSet$a(this, _NeighbourhoodProxy_pID, pID, "f");
|
|
4368
|
+
__classPrivateFieldSet$a(this, _NeighbourhoodProxy_agentDid, agentDid, "f");
|
|
4003
4369
|
}
|
|
4004
4370
|
// ── Telepresence ────────────────────────────────────────────────────
|
|
4005
4371
|
//
|
|
@@ -4007,51 +4373,51 @@ class NeighbourhoodProxy {
|
|
|
4007
4373
|
// Routes through the neighbourhood's link language.
|
|
4008
4374
|
/** List DIDs of agents who have joined this neighbourhood. */
|
|
4009
4375
|
async otherAgents() {
|
|
4010
|
-
return await __classPrivateFieldGet$
|
|
4376
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
|
|
4011
4377
|
}
|
|
4012
4378
|
/** Check whether the neighbourhood's link language supports telepresence. */
|
|
4013
4379
|
async hasTelepresenceAdapter() {
|
|
4014
|
-
return await __classPrivateFieldGet$
|
|
4380
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
|
|
4015
4381
|
}
|
|
4016
4382
|
/** List agents currently online in this neighbourhood. */
|
|
4017
4383
|
async onlineAgents() {
|
|
4018
|
-
return await __classPrivateFieldGet$
|
|
4384
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
|
|
4019
4385
|
}
|
|
4020
4386
|
/** This agent's own online status, as it last set it on this executor, or `null`. */
|
|
4021
4387
|
async ownOnlineStatus() {
|
|
4022
|
-
return await __classPrivateFieldGet$
|
|
4388
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").ownOnlineStatus(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
|
|
4023
4389
|
}
|
|
4024
4390
|
/** Set this agent's online status with a signed perspective payload. */
|
|
4025
4391
|
async setOnlineStatus(status) {
|
|
4026
|
-
return await __classPrivateFieldGet$
|
|
4392
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), status);
|
|
4027
4393
|
}
|
|
4028
4394
|
/** Set this agent's online status with an unsigned perspective payload. */
|
|
4029
4395
|
async setOnlineStatusU(status) {
|
|
4030
|
-
return await __classPrivateFieldGet$
|
|
4396
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), status);
|
|
4031
4397
|
}
|
|
4032
4398
|
/** Send a signed signal to a specific remote agent via the link language. */
|
|
4033
4399
|
async sendSignal(remoteAgentDid, payload) {
|
|
4034
|
-
return await __classPrivateFieldGet$
|
|
4400
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
|
|
4035
4401
|
}
|
|
4036
4402
|
/** Send an unsigned signal to a specific remote agent via the link language. */
|
|
4037
4403
|
async sendSignalU(remoteAgentDid, payload) {
|
|
4038
|
-
return await __classPrivateFieldGet$
|
|
4404
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
|
|
4039
4405
|
}
|
|
4040
4406
|
/** Broadcast a signed signal to all agents in the neighbourhood. */
|
|
4041
4407
|
async sendBroadcast(payload, loopback = false) {
|
|
4042
|
-
return await __classPrivateFieldGet$
|
|
4408
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
4043
4409
|
}
|
|
4044
4410
|
/** Broadcast an unsigned signal to all agents in the neighbourhood. */
|
|
4045
4411
|
async sendBroadcastU(payload, loopback = false) {
|
|
4046
|
-
return await __classPrivateFieldGet$
|
|
4412
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
4047
4413
|
}
|
|
4048
4414
|
/** Register a handler for incoming telepresence signals. */
|
|
4049
4415
|
async addSignalHandler(handler) {
|
|
4050
|
-
await __classPrivateFieldGet$
|
|
4416
|
+
await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), handler);
|
|
4051
4417
|
}
|
|
4052
4418
|
/** Remove a previously registered signal handler. */
|
|
4053
4419
|
removeSignalHandler(handler) {
|
|
4054
|
-
__classPrivateFieldGet$
|
|
4420
|
+
__classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), handler);
|
|
4055
4421
|
}
|
|
4056
4422
|
// ── Sessions ────────────────────────────────────────────────────────
|
|
4057
4423
|
//
|
|
@@ -4060,7 +4426,7 @@ class NeighbourhoodProxy {
|
|
|
4060
4426
|
// cascade redirects, and failover internally.
|
|
4061
4427
|
/** Active sessions in this neighbourhood. Destroyed sessions remove themselves. */
|
|
4062
4428
|
get sessions() {
|
|
4063
|
-
return __classPrivateFieldGet$
|
|
4429
|
+
return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f");
|
|
4064
4430
|
}
|
|
4065
4431
|
/**
|
|
4066
4432
|
* Create a WebRTC media session. Call `session.join(localStream)` to connect.
|
|
@@ -4072,16 +4438,16 @@ class NeighbourhoodProxy {
|
|
|
4072
4438
|
async createSession(roomName, options) {
|
|
4073
4439
|
// `perspective.getNeighbourhoodProxy()` builds the proxy without a DID; the session needs
|
|
4074
4440
|
// the caller's own, so ask the executor once.
|
|
4075
|
-
if (!__classPrivateFieldGet$
|
|
4076
|
-
__classPrivateFieldSet$
|
|
4441
|
+
if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f")) {
|
|
4442
|
+
__classPrivateFieldSet$a(this, _NeighbourhoodProxy_agentDid, (await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").callerDid()) ?? "", "f");
|
|
4077
4443
|
}
|
|
4078
|
-
if (!__classPrivateFieldGet$
|
|
4444
|
+
if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f")) {
|
|
4079
4445
|
throw new Error("Cannot create a call session: the executor reports no agent DID");
|
|
4080
4446
|
}
|
|
4081
4447
|
// Fetch SFU status once — reachability only changes at executor restart.
|
|
4082
|
-
if (!__classPrivateFieldGet$
|
|
4448
|
+
if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_sfuStatusCache, "f")) {
|
|
4083
4449
|
try {
|
|
4084
|
-
__classPrivateFieldSet$
|
|
4450
|
+
__classPrivateFieldSet$a(this, _NeighbourhoodProxy_sfuStatusCache, await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStatus(), "f");
|
|
4085
4451
|
}
|
|
4086
4452
|
catch {
|
|
4087
4453
|
// Non-fatal — session works without SFU advertisement.
|
|
@@ -4089,29 +4455,29 @@ class NeighbourhoodProxy {
|
|
|
4089
4455
|
}
|
|
4090
4456
|
const proxy = this;
|
|
4091
4457
|
const session = createSession({
|
|
4092
|
-
api: __classPrivateFieldGet$
|
|
4458
|
+
api: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f"),
|
|
4093
4459
|
roomId: roomName,
|
|
4094
|
-
agentDid: __classPrivateFieldGet$
|
|
4460
|
+
agentDid: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f"),
|
|
4095
4461
|
neighbourhoodUrl: options?.neighbourhoodUrl ?? "",
|
|
4096
4462
|
topology: options?.topology ?? "auto",
|
|
4097
4463
|
sfuConfig: options?.sfuConfig,
|
|
4098
4464
|
iceServers: options?.iceServers,
|
|
4099
|
-
localSfuStatus: __classPrivateFieldGet$
|
|
4100
|
-
sfuServesAllMembers: () => __classPrivateFieldGet$
|
|
4465
|
+
localSfuStatus: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sfuStatusCache, "f") ?? undefined,
|
|
4466
|
+
sfuServesAllMembers: () => __classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_client, "f").sfuServesAllMembers(__classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_pID, "f")),
|
|
4101
4467
|
// Mesh needs a signalling channel and presence callbacks.
|
|
4102
4468
|
// SFU ignores these — they remain unused when the resolved
|
|
4103
4469
|
// topology selects the SFU path.
|
|
4104
|
-
channel: createTelepresenceChannel(proxy, __classPrivateFieldGet$
|
|
4470
|
+
channel: createTelepresenceChannel(proxy, __classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_agentDid, "f")),
|
|
4105
4471
|
ownOnlineStatus: () => proxy.ownOnlineStatus(),
|
|
4106
4472
|
setOnlineStatus: (status) => proxy.setOnlineStatusU(status),
|
|
4107
4473
|
onlineAgents: () => proxy.onlineAgents(),
|
|
4108
4474
|
});
|
|
4109
|
-
__classPrivateFieldGet$
|
|
4475
|
+
__classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").push(session);
|
|
4110
4476
|
session.on("state-changed", (state) => {
|
|
4111
4477
|
if (state === "closed") {
|
|
4112
|
-
const idx = __classPrivateFieldGet$
|
|
4478
|
+
const idx = __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").indexOf(session);
|
|
4113
4479
|
if (idx !== -1)
|
|
4114
|
-
__classPrivateFieldGet$
|
|
4480
|
+
__classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").splice(idx, 1);
|
|
4115
4481
|
}
|
|
4116
4482
|
});
|
|
4117
4483
|
return session;
|
|
@@ -4123,37 +4489,37 @@ class NeighbourhoodProxy {
|
|
|
4123
4489
|
// not per-neighbourhood, and the URL is owned by the consumer (Flux's
|
|
4124
4490
|
// call context, the WE UI, etc).
|
|
4125
4491
|
async sfuConfig(neighbourhoodUrl) {
|
|
4126
|
-
return await __classPrivateFieldGet$
|
|
4492
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuGetConfig(neighbourhoodUrl);
|
|
4127
4493
|
}
|
|
4128
4494
|
async setSfuConfig(neighbourhoodUrl, config) {
|
|
4129
|
-
return await __classPrivateFieldGet$
|
|
4495
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuSetConfig(neighbourhoodUrl, config);
|
|
4130
4496
|
}
|
|
4131
4497
|
async sfuPeer(neighbourhoodUrl) {
|
|
4132
|
-
return await __classPrivateFieldGet$
|
|
4498
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuPeerForNeighbourhood(neighbourhoodUrl);
|
|
4133
4499
|
}
|
|
4134
4500
|
async sfuPeers(neighbourhoodUrl) {
|
|
4135
|
-
return await __classPrivateFieldGet$
|
|
4501
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuPeersForNeighbourhood(neighbourhoodUrl);
|
|
4136
4502
|
}
|
|
4137
4503
|
async sfuStartRoom(neighbourhoodUrl, roomName) {
|
|
4138
|
-
return await __classPrivateFieldGet$
|
|
4504
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStartRoom(neighbourhoodUrl, roomName);
|
|
4139
4505
|
}
|
|
4140
4506
|
async sfuStopRoom(neighbourhoodUrl, roomName) {
|
|
4141
|
-
return await __classPrivateFieldGet$
|
|
4507
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStopRoom(neighbourhoodUrl, roomName);
|
|
4142
4508
|
}
|
|
4143
4509
|
async sfuListRooms() {
|
|
4144
|
-
return await __classPrivateFieldGet$
|
|
4510
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuListRooms();
|
|
4145
4511
|
}
|
|
4146
4512
|
async callJoin(neighbourhoodUrl, roomName, sdpOffer) {
|
|
4147
|
-
return await __classPrivateFieldGet$
|
|
4513
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer);
|
|
4148
4514
|
}
|
|
4149
4515
|
async callLeave(neighbourhoodUrl, roomName) {
|
|
4150
|
-
return await __classPrivateFieldGet$
|
|
4516
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallLeave(neighbourhoodUrl, roomName);
|
|
4151
4517
|
}
|
|
4152
4518
|
async callSetQualityPreference(neighbourhoodUrl, roomName, preference) {
|
|
4153
|
-
return await __classPrivateFieldGet$
|
|
4519
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference);
|
|
4154
4520
|
}
|
|
4155
4521
|
async callAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
|
|
4156
|
-
return await __classPrivateFieldGet$
|
|
4522
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer);
|
|
4157
4523
|
}
|
|
4158
4524
|
/**
|
|
4159
4525
|
* Subscribe to server-pushed renegotiation offers for `targetDid`.
|
|
@@ -4162,35 +4528,35 @@ class NeighbourhoodProxy {
|
|
|
4162
4528
|
* underlying mechanism.
|
|
4163
4529
|
*/
|
|
4164
4530
|
subscribeCallRenegotiationOffer(targetDid, callback) {
|
|
4165
|
-
return __classPrivateFieldGet$
|
|
4531
|
+
return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuCallRenegotiationOffer(targetDid, callback);
|
|
4166
4532
|
}
|
|
4167
4533
|
/**
|
|
4168
4534
|
* Subscribe to cascade rebalance migration events for `targetDid`.
|
|
4169
4535
|
* Returns an unsubscribe function.
|
|
4170
4536
|
*/
|
|
4171
4537
|
subscribeMigrateEvent(targetDid, callback) {
|
|
4172
|
-
return __classPrivateFieldGet$
|
|
4538
|
+
return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuMigrateEvent(targetDid, callback);
|
|
4173
4539
|
}
|
|
4174
4540
|
// ── SFU trickle ICE ─────────────────────────────────────────────────
|
|
4175
4541
|
async addIceCandidate(neighbourhoodUrl, roomName, candidate) {
|
|
4176
|
-
return await __classPrivateFieldGet$
|
|
4542
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate);
|
|
4177
4543
|
}
|
|
4178
4544
|
// ── SFU data channel relay ────────────────────────────────────────
|
|
4179
4545
|
async sendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
|
|
4180
|
-
return await __classPrivateFieldGet$
|
|
4546
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary);
|
|
4181
4547
|
}
|
|
4182
4548
|
subscribeDataChannel(callback) {
|
|
4183
|
-
return __classPrivateFieldGet$
|
|
4549
|
+
return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuDataChannel(callback);
|
|
4184
4550
|
}
|
|
4185
4551
|
// ── SFU diagnostic / test-harness ──────────────────────────────────
|
|
4186
4552
|
async sfuCascadeStatus() {
|
|
4187
|
-
return await __classPrivateFieldGet$
|
|
4553
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCascadeStatus();
|
|
4188
4554
|
}
|
|
4189
4555
|
async sfuQualityPreferences() {
|
|
4190
|
-
return await __classPrivateFieldGet$
|
|
4556
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuQualityPreferences();
|
|
4191
4557
|
}
|
|
4192
4558
|
async sfuEnsureMembership(neighbourhoodUrl, did) {
|
|
4193
|
-
return await __classPrivateFieldGet$
|
|
4559
|
+
return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuEnsureMembership(neighbourhoodUrl, did);
|
|
4194
4560
|
}
|
|
4195
4561
|
}
|
|
4196
4562
|
_NeighbourhoodProxy_client = new WeakMap(), _NeighbourhoodProxy_pID = new WeakMap(), _NeighbourhoodProxy_agentDid = new WeakMap(), _NeighbourhoodProxy_sessions = new WeakMap(), _NeighbourhoodProxy_sfuStatusCache = new WeakMap();
|
|
@@ -4235,13 +4601,13 @@ class LinkQuery {
|
|
|
4235
4601
|
}
|
|
4236
4602
|
}
|
|
4237
4603
|
|
|
4238
|
-
var __classPrivateFieldSet$
|
|
4604
|
+
var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
4239
4605
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4240
4606
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4241
4607
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
4242
4608
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
4243
4609
|
};
|
|
4244
|
-
var __classPrivateFieldGet$
|
|
4610
|
+
var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
4245
4611
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4246
4612
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4247
4613
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -4262,44 +4628,44 @@ class Literal {
|
|
|
4262
4628
|
if (url.startsWith("literal://"))
|
|
4263
4629
|
throw new Error("literal:// format is no longer supported. Use literal: instead.");
|
|
4264
4630
|
const l = new Literal();
|
|
4265
|
-
__classPrivateFieldSet$
|
|
4631
|
+
__classPrivateFieldSet$9(l, _Literal_url, url, "f");
|
|
4266
4632
|
return l;
|
|
4267
4633
|
}
|
|
4268
4634
|
static from(literal) {
|
|
4269
4635
|
const l = new Literal();
|
|
4270
|
-
__classPrivateFieldSet$
|
|
4636
|
+
__classPrivateFieldSet$9(l, _Literal_literal, literal, "f");
|
|
4271
4637
|
return l;
|
|
4272
4638
|
}
|
|
4273
4639
|
toUrl() {
|
|
4274
|
-
if (__classPrivateFieldGet$
|
|
4275
|
-
return __classPrivateFieldGet$
|
|
4276
|
-
if (__classPrivateFieldGet$
|
|
4640
|
+
if (__classPrivateFieldGet$9(this, _Literal_url, "f") && __classPrivateFieldGet$9(this, _Literal_literal, "f") === undefined)
|
|
4641
|
+
return __classPrivateFieldGet$9(this, _Literal_url, "f");
|
|
4642
|
+
if (__classPrivateFieldGet$9(this, _Literal_literal, "f") === undefined)
|
|
4277
4643
|
throw new Error("Can't turn empty Literal into URL");
|
|
4278
4644
|
let encoded;
|
|
4279
|
-
switch (typeof __classPrivateFieldGet$
|
|
4645
|
+
switch (typeof __classPrivateFieldGet$9(this, _Literal_literal, "f")) {
|
|
4280
4646
|
case 'string':
|
|
4281
|
-
encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$
|
|
4647
|
+
encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
|
|
4282
4648
|
break;
|
|
4283
4649
|
case 'number':
|
|
4284
|
-
encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$
|
|
4650
|
+
encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
|
|
4285
4651
|
break;
|
|
4286
4652
|
case 'boolean':
|
|
4287
|
-
encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$
|
|
4653
|
+
encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
|
|
4288
4654
|
break;
|
|
4289
4655
|
case 'object':
|
|
4290
|
-
encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$
|
|
4656
|
+
encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$9(this, _Literal_literal, "f")))}`;
|
|
4291
4657
|
break;
|
|
4292
4658
|
}
|
|
4293
4659
|
return `literal:${encoded}`;
|
|
4294
4660
|
}
|
|
4295
4661
|
get() {
|
|
4296
|
-
if (__classPrivateFieldGet$
|
|
4297
|
-
return __classPrivateFieldGet$
|
|
4298
|
-
if (!__classPrivateFieldGet$
|
|
4662
|
+
if (__classPrivateFieldGet$9(this, _Literal_literal, "f") !== undefined)
|
|
4663
|
+
return __classPrivateFieldGet$9(this, _Literal_literal, "f");
|
|
4664
|
+
if (!__classPrivateFieldGet$9(this, _Literal_url, "f"))
|
|
4299
4665
|
throw new Error("Can't render empty Literal");
|
|
4300
|
-
if (!__classPrivateFieldGet$
|
|
4666
|
+
if (!__classPrivateFieldGet$9(this, _Literal_url, "f").startsWith("literal:"))
|
|
4301
4667
|
throw new Error("Can't render Literal from non-literal URL");
|
|
4302
|
-
const body = __classPrivateFieldGet$
|
|
4668
|
+
const body = __classPrivateFieldGet$9(this, _Literal_url, "f").substring(8);
|
|
4303
4669
|
if (body.startsWith("string:")) {
|
|
4304
4670
|
return decodeURIComponent(body.substring(7));
|
|
4305
4671
|
}
|
|
@@ -6682,18 +7048,30 @@ function queryCacheSize() {
|
|
|
6682
7048
|
return cache.size;
|
|
6683
7049
|
}
|
|
6684
7050
|
|
|
6685
|
-
var __classPrivateFieldSet$
|
|
7051
|
+
var __classPrivateFieldSet$8 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
6686
7052
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
6687
7053
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
6688
7054
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6689
7055
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6690
7056
|
};
|
|
6691
|
-
var __classPrivateFieldGet$
|
|
7057
|
+
var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
6692
7058
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
6693
7059
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
6694
7060
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6695
7061
|
};
|
|
6696
|
-
var _LiveQuery_instances, _LiveQuery_client, _LiveQuery_uuid, _LiveQuery_open, _LiveQuery_onResult, _LiveQuery_id, _LiveQuery_revision, _LiveQuery_result, _LiveQuery_started, _LiveQuery_disposed, _LiveQuery_generation, _LiveQuery_latest, _LiveQuery_buffer, _LiveQuery_unlisten, _LiveQuery_unreconnect, _LiveQuery_start, _LiveQuery_replace, _LiveQuery_receive, _LiveQuery_resync;
|
|
7062
|
+
var _LiveQuery_instances, _LiveQuery_client, _LiveQuery_uuid, _LiveQuery_open, _LiveQuery_onResult, _LiveQuery_id, _LiveQuery_revision, _LiveQuery_result, _LiveQuery_started, _LiveQuery_disposed, _LiveQuery_generation, _LiveQuery_latest, _LiveQuery_buffer, _LiveQuery_unlisten, _LiveQuery_unreconnect, _LiveQuery_opening, _LiveQuery_retryTimer, _LiveQuery_reopening, _LiveQuery_statusListeners, _LiveQuery_start, _LiveQuery_reopen, _LiveQuery_clearRetry, _LiveQuery_emit, _LiveQuery_replace, _LiveQuery_receive, _LiveQuery_resync;
|
|
7063
|
+
/** Delay before the first retry of a failed re-open; it doubles per failure. */
|
|
7064
|
+
const REOPEN_BASE_DELAY_MS = 1000;
|
|
7065
|
+
/** Longest delay between two re-open attempts. */
|
|
7066
|
+
const REOPEN_MAX_DELAY_MS = 60000;
|
|
7067
|
+
/** The delay before re-open attempt `failures + 1`: between half and all of
|
|
7068
|
+
* `REOPEN_BASE_DELAY_MS * 2^(failures - 1)`, capped at
|
|
7069
|
+
* `REOPEN_MAX_DELAY_MS`. The random half spreads the clients of a restarted
|
|
7070
|
+
* executor apart. */
|
|
7071
|
+
function reopenDelay(failures, random = Math.random) {
|
|
7072
|
+
const ceiling = Math.min(REOPEN_BASE_DELAY_MS * 2 ** Math.max(0, failures - 1), REOPEN_MAX_DELAY_MS);
|
|
7073
|
+
return ceiling / 2 + random() * ceiling / 2;
|
|
7074
|
+
}
|
|
6697
7075
|
/** Apply one update to the last result. Query rows are a multiset: added rows are appended.
|
|
6698
7076
|
* Throws when the update names an instance that neither the last result nor
|
|
6699
7077
|
* the update holds: the last result was wrong, and the caller must resync. */
|
|
@@ -6730,10 +7108,14 @@ function applyUpdate(result, update) {
|
|
|
6730
7108
|
* One live query on the executor. Holds the last result, applies each update
|
|
6731
7109
|
* to it, calls `resyncSubscription` when a revision is missing, and opens a
|
|
6732
7110
|
* new subscription after a reconnect (the executor ends a socket's
|
|
6733
|
-
* subscriptions when it closes).
|
|
6734
|
-
*
|
|
7111
|
+
* subscriptions when it closes). A re-open that fails (the executor is
|
|
7112
|
+
* still loading the perspective after a restart) is retried with backoff
|
|
7113
|
+
* until it succeeds or the query is disposed; `onStatus` listeners hear
|
|
7114
|
+
* about it (#1595). `onResult` gets every result after the first; `start()`
|
|
7115
|
+
* returns the first.
|
|
6735
7116
|
*/
|
|
6736
7117
|
class LiveQuery {
|
|
7118
|
+
/** `open` subscribes on the executor; aborting its signal cancels the call. */
|
|
6737
7119
|
constructor(client, uuid, open, onResult) {
|
|
6738
7120
|
_LiveQuery_instances.add(this);
|
|
6739
7121
|
_LiveQuery_client.set(this, void 0);
|
|
@@ -6751,107 +7133,250 @@ class LiveQuery {
|
|
|
6751
7133
|
_LiveQuery_buffer.set(this, null);
|
|
6752
7134
|
_LiveQuery_unlisten.set(this, void 0);
|
|
6753
7135
|
_LiveQuery_unreconnect.set(this, void 0);
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
7136
|
+
// Aborts the subscribe call still in flight, for `dispose({ cancelOpening })`.
|
|
7137
|
+
_LiveQuery_opening.set(this, void 0);
|
|
7138
|
+
_LiveQuery_retryTimer.set(this, void 0);
|
|
7139
|
+
_LiveQuery_reopening.set(this, false);
|
|
7140
|
+
_LiveQuery_statusListeners.set(this, new Set()
|
|
7141
|
+
/** `open` subscribes on the executor; aborting its signal cancels the call. */
|
|
7142
|
+
);
|
|
7143
|
+
__classPrivateFieldSet$8(this, _LiveQuery_client, client, "f");
|
|
7144
|
+
__classPrivateFieldSet$8(this, _LiveQuery_uuid, uuid, "f");
|
|
7145
|
+
__classPrivateFieldSet$8(this, _LiveQuery_open, open, "f");
|
|
7146
|
+
__classPrivateFieldSet$8(this, _LiveQuery_onResult, onResult, "f");
|
|
7147
|
+
__classPrivateFieldSet$8(this, _LiveQuery_unlisten, client.onQueryUpdate(update => __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update)), "f");
|
|
7148
|
+
__classPrivateFieldSet$8(this, _LiveQuery_unreconnect, client.onReconnect(() => __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this)), "f");
|
|
7149
|
+
}
|
|
7150
|
+
get id() { return __classPrivateFieldGet$8(this, _LiveQuery_id, "f"); }
|
|
7151
|
+
get result() { return __classPrivateFieldGet$8(this, _LiveQuery_result, "f"); }
|
|
7152
|
+
/** Whether a re-open failed and the query is waiting to retry it. */
|
|
7153
|
+
get reopening() { return __classPrivateFieldGet$8(this, _LiveQuery_reopening, "f"); }
|
|
7154
|
+
/** Call `listener` on each failed re-open and when a re-open succeeds
|
|
7155
|
+
* after one failed. Returns a remover. */
|
|
7156
|
+
onStatus(listener) {
|
|
7157
|
+
__classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").add(listener);
|
|
7158
|
+
return () => __classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").delete(listener);
|
|
6762
7159
|
}
|
|
6763
|
-
get id() { return __classPrivateFieldGet$7(this, _LiveQuery_id, "f"); }
|
|
6764
|
-
get result() { return __classPrivateFieldGet$7(this, _LiveQuery_result, "f"); }
|
|
6765
7160
|
/** Open the subscription (again) and return its initial result. A start
|
|
6766
7161
|
* that a newer one overtakes resolves with the newer one's result. */
|
|
6767
7162
|
start() {
|
|
6768
7163
|
var _a;
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
7164
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
|
|
7165
|
+
__classPrivateFieldSet$8(this, _LiveQuery_latest, __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_start).call(this, __classPrivateFieldSet$8(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"), ++_a), "f")), "f");
|
|
7166
|
+
return __classPrivateFieldGet$8(this, _LiveQuery_latest, "f");
|
|
7167
|
+
}
|
|
7168
|
+
/** End the subscription. With `cancelOpening`, a subscribe call still in
|
|
7169
|
+
* flight is cancelled too, so the executor stops computing a first result
|
|
7170
|
+
* nobody waits for (#1595); the pending `start()` then rejects instead of
|
|
7171
|
+
* resolving with that result. */
|
|
7172
|
+
dispose(options = {}) {
|
|
6773
7173
|
var _a;
|
|
6774
|
-
__classPrivateFieldSet$
|
|
6775
|
-
__classPrivateFieldSet$
|
|
6776
|
-
__classPrivateFieldGet$
|
|
6777
|
-
__classPrivateFieldGet$
|
|
6778
|
-
|
|
6779
|
-
|
|
7174
|
+
__classPrivateFieldSet$8(this, _LiveQuery_disposed, true, "f");
|
|
7175
|
+
__classPrivateFieldSet$8(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"), _a++, _a), "f");
|
|
7176
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
|
|
7177
|
+
__classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").clear();
|
|
7178
|
+
__classPrivateFieldGet$8(this, _LiveQuery_unlisten, "f").call(this);
|
|
7179
|
+
__classPrivateFieldGet$8(this, _LiveQuery_unreconnect, "f").call(this);
|
|
7180
|
+
if (options.cancelOpening)
|
|
7181
|
+
__classPrivateFieldGet$8(this, _LiveQuery_opening, "f")?.abort();
|
|
7182
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_id, "f"))
|
|
7183
|
+
__classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), __classPrivateFieldGet$8(this, _LiveQuery_id, "f")).catch(() => { });
|
|
6780
7184
|
}
|
|
6781
7185
|
}
|
|
6782
|
-
_LiveQuery_client = new WeakMap(), _LiveQuery_uuid = new WeakMap(), _LiveQuery_open = new WeakMap(), _LiveQuery_onResult = new WeakMap(), _LiveQuery_id = new WeakMap(), _LiveQuery_revision = new WeakMap(), _LiveQuery_result = new WeakMap(), _LiveQuery_started = new WeakMap(), _LiveQuery_disposed = new WeakMap(), _LiveQuery_generation = new WeakMap(), _LiveQuery_latest = new WeakMap(), _LiveQuery_buffer = new WeakMap(), _LiveQuery_unlisten = new WeakMap(), _LiveQuery_unreconnect = new WeakMap(), _LiveQuery_instances = new WeakSet(), _LiveQuery_start = async function _LiveQuery_start(generation) {
|
|
6783
|
-
__classPrivateFieldSet$
|
|
7186
|
+
_LiveQuery_client = new WeakMap(), _LiveQuery_uuid = new WeakMap(), _LiveQuery_open = new WeakMap(), _LiveQuery_onResult = new WeakMap(), _LiveQuery_id = new WeakMap(), _LiveQuery_revision = new WeakMap(), _LiveQuery_result = new WeakMap(), _LiveQuery_started = new WeakMap(), _LiveQuery_disposed = new WeakMap(), _LiveQuery_generation = new WeakMap(), _LiveQuery_latest = new WeakMap(), _LiveQuery_buffer = new WeakMap(), _LiveQuery_unlisten = new WeakMap(), _LiveQuery_unreconnect = new WeakMap(), _LiveQuery_opening = new WeakMap(), _LiveQuery_retryTimer = new WeakMap(), _LiveQuery_reopening = new WeakMap(), _LiveQuery_statusListeners = new WeakMap(), _LiveQuery_instances = new WeakSet(), _LiveQuery_start = async function _LiveQuery_start(generation) {
|
|
7187
|
+
__classPrivateFieldSet$8(this, _LiveQuery_buffer, [], "f");
|
|
7188
|
+
const opening = new AbortController();
|
|
7189
|
+
__classPrivateFieldSet$8(this, _LiveQuery_opening, opening, "f");
|
|
6784
7190
|
let subscribed;
|
|
6785
7191
|
try {
|
|
6786
|
-
subscribed = await __classPrivateFieldGet$
|
|
7192
|
+
subscribed = await __classPrivateFieldGet$8(this, _LiveQuery_open, "f").call(this, opening.signal);
|
|
6787
7193
|
}
|
|
6788
7194
|
catch (e) {
|
|
6789
|
-
if (generation === __classPrivateFieldGet$
|
|
6790
|
-
__classPrivateFieldSet$
|
|
7195
|
+
if (generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
|
|
7196
|
+
__classPrivateFieldSet$8(this, _LiveQuery_buffer, null, "f");
|
|
6791
7197
|
throw e;
|
|
6792
7198
|
}
|
|
6793
|
-
|
|
6794
|
-
|
|
7199
|
+
finally {
|
|
7200
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_opening, "f") === opening)
|
|
7201
|
+
__classPrivateFieldSet$8(this, _LiveQuery_opening, undefined, "f");
|
|
7202
|
+
}
|
|
7203
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f")) {
|
|
7204
|
+
__classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), subscribed.subscriptionId).catch(() => { });
|
|
6795
7205
|
// Disposed while opening (e.g. a newer subscribe() on the same
|
|
6796
7206
|
// builder): the caller still gets the snapshot that was read.
|
|
6797
|
-
return __classPrivateFieldGet$
|
|
7207
|
+
return __classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") ? (__classPrivateFieldGet$8(this, _LiveQuery_result, "f") ?? subscribed.result) : __classPrivateFieldGet$8(this, _LiveQuery_latest, "f");
|
|
7208
|
+
}
|
|
7209
|
+
__classPrivateFieldSet$8(this, _LiveQuery_id, subscribed.subscriptionId, "f");
|
|
7210
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, subscribed.revision, subscribed.result);
|
|
7211
|
+
return __classPrivateFieldGet$8(this, _LiveQuery_result, "f");
|
|
7212
|
+
}, _LiveQuery_reopen = function _LiveQuery_reopen(failures = 0) {
|
|
7213
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f"))
|
|
7214
|
+
return;
|
|
7215
|
+
const reopened = this.start();
|
|
7216
|
+
const generation = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f");
|
|
7217
|
+
reopened.then(() => {
|
|
7218
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f") || !__classPrivateFieldGet$8(this, _LiveQuery_reopening, "f"))
|
|
7219
|
+
return;
|
|
7220
|
+
__classPrivateFieldSet$8(this, _LiveQuery_reopening, false, "f");
|
|
7221
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: 'open' });
|
|
7222
|
+
}, error => {
|
|
7223
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
|
|
7224
|
+
return;
|
|
7225
|
+
const retryInMs = reopenDelay(failures + 1);
|
|
7226
|
+
console.error(`Error re-opening live query (attempt ${failures + 1}), retrying in ${Math.round(retryInMs)}ms:`, error);
|
|
7227
|
+
__classPrivateFieldSet$8(this, _LiveQuery_reopening, true, "f");
|
|
7228
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: 'reopening', error, retryInMs });
|
|
7229
|
+
const timer = setTimeout(() => {
|
|
7230
|
+
__classPrivateFieldSet$8(this, _LiveQuery_retryTimer, undefined, "f");
|
|
7231
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this, failures + 1);
|
|
7232
|
+
}, retryInMs);
|
|
7233
|
+
// Node: a pending retry must not keep the process alive.
|
|
7234
|
+
if (typeof timer?.unref === 'function')
|
|
7235
|
+
timer.unref();
|
|
7236
|
+
__classPrivateFieldSet$8(this, _LiveQuery_retryTimer, timer, "f");
|
|
7237
|
+
});
|
|
7238
|
+
}, _LiveQuery_clearRetry = function _LiveQuery_clearRetry() {
|
|
7239
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_retryTimer, "f") === undefined)
|
|
7240
|
+
return;
|
|
7241
|
+
clearTimeout(__classPrivateFieldGet$8(this, _LiveQuery_retryTimer, "f"));
|
|
7242
|
+
__classPrivateFieldSet$8(this, _LiveQuery_retryTimer, undefined, "f");
|
|
7243
|
+
}, _LiveQuery_emit = function _LiveQuery_emit(status) {
|
|
7244
|
+
for (const listener of [...__classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f")]) {
|
|
7245
|
+
try {
|
|
7246
|
+
listener(status);
|
|
7247
|
+
}
|
|
7248
|
+
catch (e) {
|
|
7249
|
+
console.error('Error in live query status listener:', e);
|
|
7250
|
+
}
|
|
6798
7251
|
}
|
|
6799
|
-
__classPrivateFieldSet$7(this, _LiveQuery_id, subscribed.subscriptionId, "f");
|
|
6800
|
-
__classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, subscribed.revision, subscribed.result);
|
|
6801
|
-
return __classPrivateFieldGet$7(this, _LiveQuery_result, "f");
|
|
6802
7252
|
}, _LiveQuery_replace = function _LiveQuery_replace(revision, result) {
|
|
6803
|
-
__classPrivateFieldSet$
|
|
6804
|
-
__classPrivateFieldSet$
|
|
6805
|
-
const buffered = __classPrivateFieldGet$
|
|
6806
|
-
__classPrivateFieldSet$
|
|
6807
|
-
if (__classPrivateFieldGet$
|
|
6808
|
-
__classPrivateFieldGet$
|
|
6809
|
-
__classPrivateFieldSet$
|
|
7253
|
+
__classPrivateFieldSet$8(this, _LiveQuery_revision, revision, "f");
|
|
7254
|
+
__classPrivateFieldSet$8(this, _LiveQuery_result, result, "f");
|
|
7255
|
+
const buffered = __classPrivateFieldGet$8(this, _LiveQuery_buffer, "f") ?? [];
|
|
7256
|
+
__classPrivateFieldSet$8(this, _LiveQuery_buffer, null, "f");
|
|
7257
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_started, "f"))
|
|
7258
|
+
__classPrivateFieldGet$8(this, _LiveQuery_onResult, "f").call(this, result);
|
|
7259
|
+
__classPrivateFieldSet$8(this, _LiveQuery_started, true, "f");
|
|
6810
7260
|
for (const update of buffered)
|
|
6811
|
-
__classPrivateFieldGet$
|
|
7261
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update);
|
|
6812
7262
|
}, _LiveQuery_receive = function _LiveQuery_receive(update) {
|
|
6813
|
-
if (__classPrivateFieldGet$
|
|
6814
|
-
__classPrivateFieldGet$
|
|
7263
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_buffer, "f")) {
|
|
7264
|
+
__classPrivateFieldGet$8(this, _LiveQuery_buffer, "f").push(update);
|
|
6815
7265
|
return;
|
|
6816
7266
|
}
|
|
6817
7267
|
if ('lagged' in update) {
|
|
6818
|
-
if (__classPrivateFieldGet$
|
|
6819
|
-
__classPrivateFieldGet$
|
|
7268
|
+
if (__classPrivateFieldGet$8(this, _LiveQuery_id, "f"))
|
|
7269
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
|
|
6820
7270
|
return;
|
|
6821
7271
|
}
|
|
6822
|
-
if (update.subscriptionId !== __classPrivateFieldGet$
|
|
7272
|
+
if (update.subscriptionId !== __classPrivateFieldGet$8(this, _LiveQuery_id, "f") || update.revision <= __classPrivateFieldGet$8(this, _LiveQuery_revision, "f"))
|
|
6823
7273
|
return;
|
|
6824
|
-
if (update.revision !== __classPrivateFieldGet$
|
|
6825
|
-
__classPrivateFieldGet$
|
|
7274
|
+
if (update.revision !== __classPrivateFieldGet$8(this, _LiveQuery_revision, "f") + 1) {
|
|
7275
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
|
|
6826
7276
|
return;
|
|
6827
7277
|
}
|
|
6828
7278
|
let result;
|
|
6829
7279
|
try {
|
|
6830
|
-
result = applyUpdate(__classPrivateFieldGet$
|
|
7280
|
+
result = applyUpdate(__classPrivateFieldGet$8(this, _LiveQuery_result, "f"), update);
|
|
6831
7281
|
}
|
|
6832
7282
|
catch {
|
|
6833
|
-
__classPrivateFieldGet$
|
|
7283
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
|
|
6834
7284
|
return;
|
|
6835
7285
|
}
|
|
6836
|
-
__classPrivateFieldSet$
|
|
6837
|
-
__classPrivateFieldSet$
|
|
6838
|
-
__classPrivateFieldGet$
|
|
7286
|
+
__classPrivateFieldSet$8(this, _LiveQuery_revision, update.revision, "f");
|
|
7287
|
+
__classPrivateFieldSet$8(this, _LiveQuery_result, result, "f");
|
|
7288
|
+
__classPrivateFieldGet$8(this, _LiveQuery_onResult, "f").call(this, __classPrivateFieldGet$8(this, _LiveQuery_result, "f"));
|
|
6839
7289
|
}, _LiveQuery_resync = function _LiveQuery_resync() {
|
|
6840
|
-
const generation = __classPrivateFieldGet$
|
|
6841
|
-
const id = __classPrivateFieldGet$
|
|
6842
|
-
__classPrivateFieldSet$
|
|
6843
|
-
__classPrivateFieldGet$
|
|
6844
|
-
if (!__classPrivateFieldGet$
|
|
6845
|
-
__classPrivateFieldGet$
|
|
7290
|
+
const generation = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f");
|
|
7291
|
+
const id = __classPrivateFieldGet$8(this, _LiveQuery_id, "f");
|
|
7292
|
+
__classPrivateFieldSet$8(this, _LiveQuery_buffer, [], "f");
|
|
7293
|
+
__classPrivateFieldGet$8(this, _LiveQuery_client, "f").resyncSubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), id).then(({ revision, result }) => {
|
|
7294
|
+
if (!__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
|
|
7295
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, revision, result);
|
|
6846
7296
|
}, () => {
|
|
6847
7297
|
// Replace the subscription with a new one.
|
|
6848
|
-
if (!__classPrivateFieldGet$
|
|
6849
|
-
__classPrivateFieldGet$
|
|
6850
|
-
this
|
|
7298
|
+
if (!__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f")) {
|
|
7299
|
+
__classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), id).catch(() => { });
|
|
7300
|
+
__classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this);
|
|
6851
7301
|
}
|
|
6852
7302
|
});
|
|
6853
7303
|
};
|
|
6854
7304
|
|
|
7305
|
+
/**
|
|
7306
|
+
* Compare two strings by Unicode code point, ascending. This is the order
|
|
7307
|
+
* Rust's `String::cmp` produces (UTF-8 bytes sort in code-point order), so
|
|
7308
|
+
* a sort keyed on it here and in `rust-executor` agrees for every name, not
|
|
7309
|
+
* only ASCII. `<` on JS strings compares UTF-16 code units instead, which
|
|
7310
|
+
* puts U+E000–U+FFFF after the supplementary planes.
|
|
7311
|
+
*
|
|
7312
|
+
* Used by `fromLinks` to break state-value ties (#1202).
|
|
7313
|
+
*/
|
|
7314
|
+
function compareCodePoints(a, b) {
|
|
7315
|
+
const as = Array.from(a);
|
|
7316
|
+
const bs = Array.from(b);
|
|
7317
|
+
const n = Math.min(as.length, bs.length);
|
|
7318
|
+
for (let i = 0; i < n; i++) {
|
|
7319
|
+
const d = as[i].codePointAt(0) - bs[i].codePointAt(0);
|
|
7320
|
+
if (d !== 0)
|
|
7321
|
+
return d;
|
|
7322
|
+
}
|
|
7323
|
+
return as.length - bs.length;
|
|
7324
|
+
}
|
|
7325
|
+
/**
|
|
7326
|
+
* Decode a state's `stateValue` link target into the number the state sort
|
|
7327
|
+
* keys on. **One grammar, shared verbatim with `decode_state_value` in
|
|
7328
|
+
* `rust-executor/src/perspectives/shacl_parser.rs`; a change to one is a
|
|
7329
|
+
* change to both**, and the `state value decoder matches rust` test here and
|
|
7330
|
+
* `state_value_decoder_matches_ts` there hold the two to the same answers.
|
|
7331
|
+
*
|
|
7332
|
+
* Not `Literal.fromUrl(target).get()`: that is `parseFloat`, which reads
|
|
7333
|
+
* `1abc` as 1 and `inf` as NaN, while Rust's `str::parse::<f64>` does the
|
|
7334
|
+
* reverse — so before #1202 the two runtimes could decode the same links to
|
|
7335
|
+
* different values and pick different initial states. The grammar:
|
|
7336
|
+
*
|
|
7337
|
+
* 1. The target must be a `literal:number:` literal. Anything else is NaN.
|
|
7338
|
+
* 2. The payload is percent-decoded: `Literal.toUrl` writes `1e21` as
|
|
7339
|
+
* `1e%2B21`. A payload that does not decode is NaN.
|
|
7340
|
+
* 3. A plain decimal — `[+-]?([0-9]+.?[0-9]*|.[0-9]+)([eE][+-]?[0-9]+)?`,
|
|
7341
|
+
* ASCII digits only — parses with `Number`; both runtimes' parsers agree
|
|
7342
|
+
* on this set. `-0` decodes to `-0`, which the sort treats as `0`.
|
|
7343
|
+
* 4. `inf` / `infinity`, any ASCII case, optional sign, is ±Infinity.
|
|
7344
|
+
* Rust's `parse_flow_to_links` writes `-inf`, `Literal.toUrl` writes
|
|
7345
|
+
* `-Infinity`; both runtimes read both.
|
|
7346
|
+
* 5. Everything else is NaN, which the sort puts last: `NaN`, an empty
|
|
7347
|
+
* payload, `1abc`, ` 1`, `0x10`, non-ASCII digits.
|
|
7348
|
+
*
|
|
7349
|
+
* A *missing* `stateValue` link is not this function's case: `fromLinks`
|
|
7350
|
+
* reads it as `0`, as Rust does.
|
|
7351
|
+
*
|
|
7352
|
+
* `STATE_VALUE_DECIMAL` is rule 3's grammar with the dot and the digits after
|
|
7353
|
+
* it grouped, `[0-9]+(\.[0-9]*)?`. Same strings, but a digit run can no longer
|
|
7354
|
+
* split between two digit classes, so V8 does not backtrack quadratically on a
|
|
7355
|
+
* long run that fails at the end. Rust's `regex` crate matches in linear time
|
|
7356
|
+
* either way.
|
|
7357
|
+
*/
|
|
7358
|
+
const STATE_VALUE_DECIMAL = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
7359
|
+
const STATE_VALUE_INFINITE = /^[+-]?[iI][nN][fF](?:[iI][nN][iI][tT][yY])?$/;
|
|
7360
|
+
function decodeStateValue(target) {
|
|
7361
|
+
const payload = target.startsWith("literal:number:")
|
|
7362
|
+
? target.slice("literal:number:".length)
|
|
7363
|
+
: undefined;
|
|
7364
|
+
if (payload === undefined)
|
|
7365
|
+
return NaN;
|
|
7366
|
+
let decoded;
|
|
7367
|
+
try {
|
|
7368
|
+
decoded = decodeURIComponent(payload);
|
|
7369
|
+
}
|
|
7370
|
+
catch {
|
|
7371
|
+
return NaN;
|
|
7372
|
+
}
|
|
7373
|
+
if (STATE_VALUE_DECIMAL.test(decoded))
|
|
7374
|
+
return Number(decoded);
|
|
7375
|
+
if (STATE_VALUE_INFINITE.test(decoded)) {
|
|
7376
|
+
return decoded.startsWith("-") ? -Infinity : Infinity;
|
|
7377
|
+
}
|
|
7378
|
+
return NaN;
|
|
7379
|
+
}
|
|
6855
7380
|
/**
|
|
6856
7381
|
* Runtime shape check for a decoded `ModelQuery`. Deserialization paths use
|
|
6857
7382
|
* this to guard against malformed guard arrays leaking into flow metadata
|
|
@@ -6969,11 +7494,13 @@ class SHACLFlow {
|
|
|
6969
7494
|
* States in this flow.
|
|
6970
7495
|
*
|
|
6971
7496
|
* **Ordering convention (James PR #929 R9):** the array is stored sorted
|
|
6972
|
-
* ascending by `value
|
|
7497
|
+
* ascending by `value`, ties broken by state name ascending (code-point
|
|
7498
|
+
* order), NaN values last. `states[0]` is the initial state — the one
|
|
6973
7499
|
* {@link FlowInstance.start} mints a fresh instance into. A flow author
|
|
6974
7500
|
* who wants a specific state as the entry point must give it the lowest
|
|
6975
|
-
* `value` in the set
|
|
6976
|
-
*
|
|
7501
|
+
* `value` in the set; two states sharing the lowest value start in the
|
|
7502
|
+
* one whose name sorts first (#1202). `fromLinks` enforces this sort, so
|
|
7503
|
+
* link-order on the graph never dictates the initial state.
|
|
6977
7504
|
*/
|
|
6978
7505
|
this._states = [];
|
|
6979
7506
|
/** Transitions between states */
|
|
@@ -7339,7 +7866,9 @@ class SHACLFlow {
|
|
|
7339
7866
|
stateUriToName.set(stateUri, stateName);
|
|
7340
7867
|
// Get state value
|
|
7341
7868
|
const valueLink = links.find(l => l.source === stateUri && l.predicate === "ad4m://stateValue");
|
|
7342
|
-
|
|
7869
|
+
// Missing link: 0, as in Rust. Present link: the shared strict grammar
|
|
7870
|
+
// (`decodeStateValue`), NaN when it does not fit.
|
|
7871
|
+
const stateValue = valueLink ? decodeStateValue(valueLink.target) : 0;
|
|
7343
7872
|
// Get per-state interpretation hint (optional). Same non-empty-string
|
|
7344
7873
|
// guard as the flow-level hint.
|
|
7345
7874
|
const hintLink = links.find(l => l.source === stateUri && l.predicate === "ad4m://interpretationHint");
|
|
@@ -7417,8 +7946,45 @@ class SHACLFlow {
|
|
|
7417
7946
|
// was randomly one of the round-tripped states. Sort by `value` ascending
|
|
7418
7947
|
// so the "initial state = states[0]" convention (used by
|
|
7419
7948
|
// `FlowInstance.start`) survives a fromGraph round trip.
|
|
7949
|
+
//
|
|
7950
|
+
// This comparator must stay identical to the one in rust-executor's
|
|
7951
|
+
// `parse_flow_from_links` (`rust-executor/src/perspectives/shacl_parser.rs`):
|
|
7952
|
+
// both runtimes read `states[0]` as the genesis state, and a Rust-side
|
|
7953
|
+
// spawn, `derive_state` and `verify_receipt` all start from it. So must
|
|
7954
|
+
// its input: `decodeStateValue` above and Rust `decode_state_value` read
|
|
7955
|
+
// the `stateValue` literal with one grammar, so the same links decode to
|
|
7956
|
+
// the same numbers before this sort ever runs.
|
|
7957
|
+
//
|
|
7958
|
+
// - NaN sorts last. `decodeStateValue` returns NaN for every payload
|
|
7959
|
+
// outside its grammar (a literal `NaN`, an empty payload, `1abc`, …),
|
|
7960
|
+
// so NaN is the common case for a malformed definition; `a.value -
|
|
7961
|
+
// b.value` would then be NaN, which `Array.prototype.sort` treats as
|
|
7962
|
+
// "equal" in an engine-defined way that also scrambles the finite
|
|
7963
|
+
// states around it. A state whose ordering value is undecodable has
|
|
7964
|
+
// no claim to being first.
|
|
7965
|
+
// - Equal values break on state name, ascending by Unicode code point
|
|
7966
|
+
// (`compareCodePoints`), which is the order Rust's `String::cmp` gives
|
|
7967
|
+
// over UTF-8 bytes (#1202). Without this, `sort` is stable and a tie
|
|
7968
|
+
// kept link-discovery order, which differs between replicas: two
|
|
7969
|
+
// nodes loading the same definition could mint instances in
|
|
7970
|
+
// different initial states.
|
|
7420
7971
|
// The `states` getter returns a defensive copy, so mutate `_states` directly.
|
|
7421
|
-
flow._states.sort((a, b) =>
|
|
7972
|
+
flow._states.sort((a, b) => {
|
|
7973
|
+
const aNaN = Number.isNaN(a.value);
|
|
7974
|
+
const bNaN = Number.isNaN(b.value);
|
|
7975
|
+
if (aNaN !== bNaN)
|
|
7976
|
+
return aNaN ? 1 : -1;
|
|
7977
|
+
if (!aNaN && a.value !== b.value)
|
|
7978
|
+
return a.value < b.value ? -1 : 1;
|
|
7979
|
+
return compareCodePoints(a.name, b.name);
|
|
7980
|
+
});
|
|
7981
|
+
if (flow._states.length > 1 &&
|
|
7982
|
+
!Number.isNaN(flow._states[0].value) &&
|
|
7983
|
+
flow._states[0].value === flow._states[1].value) {
|
|
7984
|
+
console.warn(`flow \`${flowUri}\`: states \`${flow._states[0].name}\` and \`${flow._states[1].name}\` ` +
|
|
7985
|
+
`tie on the lowest value ${flow._states[0].value}; ` +
|
|
7986
|
+
`\`${flow._states[0].name}\` is the initial state by name order (#1202)`);
|
|
7987
|
+
}
|
|
7422
7988
|
// Find transitions
|
|
7423
7989
|
const transitionLinks = links.filter(l => l.source === flowUri && l.predicate === "ad4m://hasTransition");
|
|
7424
7990
|
for (const transitionLink of transitionLinks) {
|
|
@@ -7578,12 +8144,12 @@ SHACLFlow.STATE_AND_TRANSITION_PREDICATES = [
|
|
|
7578
8144
|
"ad4m://transitionActions",
|
|
7579
8145
|
];
|
|
7580
8146
|
|
|
7581
|
-
var __classPrivateFieldGet$
|
|
8147
|
+
var __classPrivateFieldGet$7 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
7582
8148
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7583
8149
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
7584
8150
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7585
8151
|
};
|
|
7586
|
-
var __classPrivateFieldSet$
|
|
8152
|
+
var __classPrivateFieldSet$7 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7587
8153
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
7588
8154
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
7589
8155
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
@@ -7628,55 +8194,69 @@ class QuerySubscriptionProxy {
|
|
|
7628
8194
|
_QuerySubscriptionProxy_initResolve.set(this, void 0);
|
|
7629
8195
|
_QuerySubscriptionProxy_initReject.set(this, void 0);
|
|
7630
8196
|
const open = className === undefined
|
|
7631
|
-
? () => client.subscribeQuery(uuid, query)
|
|
7632
|
-
: () => client.modelSubscribe(uuid, className, query);
|
|
7633
|
-
__classPrivateFieldSet$
|
|
7634
|
-
__classPrivateFieldSet$
|
|
7635
|
-
__classPrivateFieldSet$
|
|
7636
|
-
__classPrivateFieldSet$
|
|
8197
|
+
? (signal) => client.subscribeQuery(uuid, query, { signal })
|
|
8198
|
+
: (signal) => client.modelSubscribe(uuid, className, query, { signal });
|
|
8199
|
+
__classPrivateFieldSet$7(this, _QuerySubscriptionProxy_live, new LiveQuery(client, uuid, open, result => __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, result)), "f");
|
|
8200
|
+
__classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
|
|
8201
|
+
__classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
|
|
8202
|
+
__classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, reject, "f");
|
|
7637
8203
|
}), "f");
|
|
7638
8204
|
// `subscribe()` throws the same error, so a caller who never reads
|
|
7639
8205
|
// `initialized` must not get an unhandled rejection from it.
|
|
7640
|
-
__classPrivateFieldGet$
|
|
8206
|
+
__classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initialized, "f").catch(() => { });
|
|
7641
8207
|
}
|
|
7642
8208
|
/** Open the query; resolves with the first result delivered. */
|
|
7643
8209
|
async subscribe() {
|
|
7644
8210
|
try {
|
|
7645
|
-
__classPrivateFieldGet$
|
|
8211
|
+
__classPrivateFieldGet$7(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, await __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").start());
|
|
7646
8212
|
}
|
|
7647
8213
|
catch (error) {
|
|
7648
|
-
__classPrivateFieldGet$
|
|
7649
|
-
__classPrivateFieldSet$
|
|
8214
|
+
__classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initReject, "f")?.call(this, error);
|
|
8215
|
+
__classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, undefined, "f"), "f");
|
|
7650
8216
|
throw error;
|
|
7651
8217
|
}
|
|
7652
8218
|
}
|
|
7653
8219
|
/** The executor's id for this subscription. */
|
|
7654
8220
|
get id() {
|
|
7655
|
-
return __classPrivateFieldGet$
|
|
8221
|
+
return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").id;
|
|
7656
8222
|
}
|
|
7657
8223
|
/** Resolves once the first result has arrived. */
|
|
7658
8224
|
get initialized() {
|
|
7659
|
-
return __classPrivateFieldGet$
|
|
8225
|
+
return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initialized, "f");
|
|
7660
8226
|
}
|
|
7661
8227
|
/** The latest result. */
|
|
7662
8228
|
get result() {
|
|
7663
|
-
return __classPrivateFieldGet$
|
|
8229
|
+
return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").result;
|
|
7664
8230
|
}
|
|
7665
8231
|
/** Call `callback` with every later result. Returns a remover. */
|
|
7666
8232
|
onResult(callback) {
|
|
7667
|
-
__classPrivateFieldGet$
|
|
7668
|
-
return () => __classPrivateFieldGet$
|
|
7669
|
-
}
|
|
7670
|
-
/**
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
8233
|
+
__classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
|
|
8234
|
+
return () => __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
|
|
8235
|
+
}
|
|
8236
|
+
/** Whether the query lost its subscription (a reconnect, a failed
|
|
8237
|
+
* resync), could not open it again yet and is retrying: `result` is then
|
|
8238
|
+
* not live. */
|
|
8239
|
+
get reopening() {
|
|
8240
|
+
return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").reopening;
|
|
8241
|
+
}
|
|
8242
|
+
/** Call `listener` on each failed re-open of the subscription and when a
|
|
8243
|
+
* re-open succeeds after one failed (see {@link LiveQueryStatus}).
|
|
8244
|
+
* Returns a remover. */
|
|
8245
|
+
onStatus(listener) {
|
|
8246
|
+
return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").onStatus(listener);
|
|
8247
|
+
}
|
|
8248
|
+
/** End the subscription on the executor and drop all callbacks. With
|
|
8249
|
+
* `cancelOpening`, a `subscribe()` still waiting on the executor is
|
|
8250
|
+
* cancelled too, and rejects. */
|
|
8251
|
+
dispose(options = {}) {
|
|
8252
|
+
__classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").dispose(options);
|
|
8253
|
+
__classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").clear();
|
|
7674
8254
|
}
|
|
7675
8255
|
}
|
|
7676
8256
|
_QuerySubscriptionProxy_live = new WeakMap(), _QuerySubscriptionProxy_callbacks = new WeakMap(), _QuerySubscriptionProxy_initialized = new WeakMap(), _QuerySubscriptionProxy_initResolve = new WeakMap(), _QuerySubscriptionProxy_initReject = new WeakMap(), _QuerySubscriptionProxy_instances = new WeakSet(), _QuerySubscriptionProxy_deliver = function _QuerySubscriptionProxy_deliver(result) {
|
|
7677
|
-
__classPrivateFieldGet$
|
|
7678
|
-
__classPrivateFieldSet$
|
|
7679
|
-
for (const callback of __classPrivateFieldGet$
|
|
8257
|
+
__classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initResolve, "f")?.call(this, true);
|
|
8258
|
+
__classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, undefined, "f"), "f");
|
|
8259
|
+
for (const callback of __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f")) {
|
|
7680
8260
|
try {
|
|
7681
8261
|
callback(result);
|
|
7682
8262
|
}
|
|
@@ -7726,7 +8306,7 @@ _QuerySubscriptionProxy_live = new WeakMap(), _QuerySubscriptionProxy_callbacks
|
|
|
7726
8306
|
*/
|
|
7727
8307
|
class PerspectiveProxy {
|
|
7728
8308
|
/** @internal Exposed for ModelQueryBuilder subscription management */
|
|
7729
|
-
get client() { return __classPrivateFieldGet$
|
|
8309
|
+
get client() { return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f"); }
|
|
7730
8310
|
/**
|
|
7731
8311
|
* Creates a new PerspectiveProxy instance.
|
|
7732
8312
|
* Note: Don't create this directly, use ad4m.perspective.add() instead.
|
|
@@ -7746,23 +8326,23 @@ class PerspectiveProxy {
|
|
|
7746
8326
|
* Note: Don't create this directly, use ad4m.perspective.add() instead.
|
|
7747
8327
|
*/
|
|
7748
8328
|
);
|
|
7749
|
-
__classPrivateFieldSet$
|
|
7750
|
-
__classPrivateFieldSet$
|
|
7751
|
-
this.uuid = __classPrivateFieldGet$
|
|
7752
|
-
this.name = __classPrivateFieldGet$
|
|
7753
|
-
this.owners = __classPrivateFieldGet$
|
|
7754
|
-
this.sharedUrl = __classPrivateFieldGet$
|
|
7755
|
-
this.neighbourhood = __classPrivateFieldGet$
|
|
7756
|
-
this.state = __classPrivateFieldGet$
|
|
8329
|
+
__classPrivateFieldSet$7(this, _PerspectiveProxy_handle, handle, "f");
|
|
8330
|
+
__classPrivateFieldSet$7(this, _PerspectiveProxy_client, ad4m, "f");
|
|
8331
|
+
this.uuid = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid;
|
|
8332
|
+
this.name = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").name;
|
|
8333
|
+
this.owners = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").owners;
|
|
8334
|
+
this.sharedUrl = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").sharedUrl;
|
|
8335
|
+
this.neighbourhood = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").neighbourhood;
|
|
8336
|
+
this.state = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").state;
|
|
7757
8337
|
}
|
|
7758
8338
|
/** Update the proxy's internal handle and public fields in-place.
|
|
7759
8339
|
* Keeps the same object reference so all holders see the update. */
|
|
7760
8340
|
updateHandle(handle) {
|
|
7761
|
-
if (handle.uuid !== __classPrivateFieldGet$
|
|
7762
|
-
throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$
|
|
8341
|
+
if (handle.uuid !== __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid) {
|
|
8342
|
+
throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". ` +
|
|
7763
8343
|
`This would silently diverge from listeners registered under the original UUID.`);
|
|
7764
8344
|
}
|
|
7765
|
-
__classPrivateFieldSet$
|
|
8345
|
+
__classPrivateFieldSet$7(this, _PerspectiveProxy_handle, handle, "f");
|
|
7766
8346
|
this.uuid = handle.uuid;
|
|
7767
8347
|
this.name = handle.name;
|
|
7768
8348
|
this.owners = handle.owners;
|
|
@@ -7843,8 +8423,8 @@ class PerspectiveProxy {
|
|
|
7843
8423
|
* @param batchId - Optional batch ID to group this operation with others
|
|
7844
8424
|
*/
|
|
7845
8425
|
async executeAction(actions, expression, parameters, batchId) {
|
|
7846
|
-
const result = await __classPrivateFieldGet$
|
|
7847
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8426
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
|
|
8427
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
7848
8428
|
return result;
|
|
7849
8429
|
}
|
|
7850
8430
|
/**
|
|
@@ -7869,7 +8449,7 @@ class PerspectiveProxy {
|
|
|
7869
8449
|
* ```
|
|
7870
8450
|
*/
|
|
7871
8451
|
async get(query, options) {
|
|
7872
|
-
return await __classPrivateFieldGet$
|
|
8452
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
|
|
7873
8453
|
}
|
|
7874
8454
|
/**
|
|
7875
8455
|
* Runs generic LLM interpretation over a conversation transcript, turning it
|
|
@@ -7892,7 +8472,7 @@ class PerspectiveProxy {
|
|
|
7892
8472
|
// sixth positional parameter would have made `undefined, undefined, { … }` the normal way
|
|
7893
8473
|
// to ask for the only one of them most callers want.
|
|
7894
8474
|
const { existingScope, mintScope, observe, ...callOptions } = options ?? {};
|
|
7895
|
-
return await __classPrivateFieldGet$
|
|
8475
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, callOptions);
|
|
7896
8476
|
}
|
|
7897
8477
|
/**
|
|
7898
8478
|
* Harness-dispatched interpretation pass over this perspective (design v3
|
|
@@ -7919,7 +8499,7 @@ class PerspectiveProxy {
|
|
|
7919
8499
|
// `on('auto-processor-event')` to render the harness loop
|
|
7920
8500
|
// live in a UI. Absent = fast headless path (no telemetry cost).
|
|
7921
8501
|
observationId, emitDebugEvents, options) {
|
|
7922
|
-
return await __classPrivateFieldGet$
|
|
8502
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runInterpretationWithHarness(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, undefined, observationId, emitDebugEvents, options);
|
|
7923
8503
|
}
|
|
7924
8504
|
/**
|
|
7925
8505
|
* Ask a model something about this perspective, or ask it to change something, with the
|
|
@@ -7932,7 +8512,7 @@ class PerspectiveProxy {
|
|
|
7932
8512
|
* @param options `signal` / `timeoutMs` (default {@link LONG_TIMEOUT_MS})
|
|
7933
8513
|
*/
|
|
7934
8514
|
async runAgent(messages, settings, options) {
|
|
7935
|
-
return await __classPrivateFieldGet$
|
|
8515
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runAgent(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, messages, settings, options);
|
|
7936
8516
|
}
|
|
7937
8517
|
/**
|
|
7938
8518
|
* Register a neighbourhood auto-processor on this perspective. The executor
|
|
@@ -7941,7 +8521,7 @@ class PerspectiveProxy {
|
|
|
7941
8521
|
* processor id. Subscribe to progress via `on('auto-processor-event')`.
|
|
7942
8522
|
*/
|
|
7943
8523
|
async addAutoProcessor(config) {
|
|
7944
|
-
return await __classPrivateFieldGet$
|
|
8524
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, config);
|
|
7945
8525
|
}
|
|
7946
8526
|
/**
|
|
7947
8527
|
* Stop an auto-processor by deleting its config.
|
|
@@ -7959,7 +8539,7 @@ class PerspectiveProxy {
|
|
|
7959
8539
|
* one left off rather than re-reading every turn.
|
|
7960
8540
|
*/
|
|
7961
8541
|
async removeAutoProcessor(processorId) {
|
|
7962
|
-
return await __classPrivateFieldGet$
|
|
8542
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeAutoProcessor(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, processorId);
|
|
7963
8543
|
}
|
|
7964
8544
|
/**
|
|
7965
8545
|
* Pending interpretation overlays on this perspective — LLM suggestions the
|
|
@@ -7973,17 +8553,17 @@ class PerspectiveProxy {
|
|
|
7973
8553
|
* Each caller gets its own copy of the array.
|
|
7974
8554
|
*/
|
|
7975
8555
|
async interpretationOverlays() {
|
|
7976
|
-
if (__classPrivateFieldGet$
|
|
7977
|
-
return [...(await __classPrivateFieldGet$
|
|
8556
|
+
if (__classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f")) {
|
|
8557
|
+
return [...(await __classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f"))];
|
|
7978
8558
|
}
|
|
7979
|
-
const pending = __classPrivateFieldGet$
|
|
7980
|
-
__classPrivateFieldSet$
|
|
8559
|
+
const pending = __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8560
|
+
__classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, pending, "f");
|
|
7981
8561
|
try {
|
|
7982
8562
|
return [...(await pending)];
|
|
7983
8563
|
}
|
|
7984
8564
|
finally {
|
|
7985
|
-
if (__classPrivateFieldGet$
|
|
7986
|
-
__classPrivateFieldSet$
|
|
8565
|
+
if (__classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f") === pending) {
|
|
8566
|
+
__classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
|
|
7987
8567
|
}
|
|
7988
8568
|
}
|
|
7989
8569
|
}
|
|
@@ -7994,11 +8574,11 @@ class PerspectiveProxy {
|
|
|
7994
8574
|
*/
|
|
7995
8575
|
async acceptInterpretation(base, property) {
|
|
7996
8576
|
try {
|
|
7997
|
-
return await __classPrivateFieldGet$
|
|
8577
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, base, property);
|
|
7998
8578
|
}
|
|
7999
8579
|
finally {
|
|
8000
8580
|
// A read already in flight may predate this write; later callers must not join it.
|
|
8001
|
-
__classPrivateFieldSet$
|
|
8581
|
+
__classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
|
|
8002
8582
|
}
|
|
8003
8583
|
}
|
|
8004
8584
|
/**
|
|
@@ -8008,11 +8588,11 @@ class PerspectiveProxy {
|
|
|
8008
8588
|
*/
|
|
8009
8589
|
async rejectInterpretation(base, property) {
|
|
8010
8590
|
try {
|
|
8011
|
-
return await __classPrivateFieldGet$
|
|
8591
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, base, property);
|
|
8012
8592
|
}
|
|
8013
8593
|
finally {
|
|
8014
8594
|
// A read already in flight may predate this write; later callers must not join it.
|
|
8015
|
-
__classPrivateFieldSet$
|
|
8595
|
+
__classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
|
|
8016
8596
|
}
|
|
8017
8597
|
}
|
|
8018
8598
|
/**
|
|
@@ -8023,14 +8603,14 @@ class PerspectiveProxy {
|
|
|
8023
8603
|
* for a non-terminal state is refused.
|
|
8024
8604
|
*/
|
|
8025
8605
|
async proposeFlowTransition(instanceUri, toState, rationale, outputs) {
|
|
8026
|
-
return await __classPrivateFieldGet$
|
|
8606
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").proposeFlowTransition(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instanceUri, toState, rationale, outputs);
|
|
8027
8607
|
}
|
|
8028
8608
|
async acceptFlowProposal(proposalUri) {
|
|
8029
|
-
return await __classPrivateFieldGet$
|
|
8609
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").acceptFlowProposal(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
|
|
8030
8610
|
}
|
|
8031
8611
|
/** Withdraw our own links from a proposal; resolves to how many went. */
|
|
8032
8612
|
async rejectFlowProposal(proposalUri) {
|
|
8033
|
-
return await __classPrivateFieldGet$
|
|
8613
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").rejectFlowProposal(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
|
|
8034
8614
|
}
|
|
8035
8615
|
/**
|
|
8036
8616
|
* Re-decide a flow receipt under this perspective's own flow catalogue.
|
|
@@ -8038,7 +8618,7 @@ class PerspectiveProxy {
|
|
|
8038
8618
|
* `outcome`, never on a boolean you derive from it.
|
|
8039
8619
|
*/
|
|
8040
8620
|
async verifyFlowReceipt(receipt) {
|
|
8041
|
-
return await __classPrivateFieldGet$
|
|
8621
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").verifyFlowReceipt(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, receipt);
|
|
8042
8622
|
}
|
|
8043
8623
|
/**
|
|
8044
8624
|
* Which instances are, as they stand, valid outputs of `flow`?
|
|
@@ -8055,7 +8635,7 @@ class PerspectiveProxy {
|
|
|
8055
8635
|
* "no valid outputs". The filter rejects the same way.
|
|
8056
8636
|
*/
|
|
8057
8637
|
async flowValidOutputs(flow, state) {
|
|
8058
|
-
return await __classPrivateFieldGet$
|
|
8638
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowValidOutputs(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, flow, state);
|
|
8059
8639
|
}
|
|
8060
8640
|
/**
|
|
8061
8641
|
* The state each flow instance is in, as **this agent's** executor last
|
|
@@ -8070,7 +8650,7 @@ class PerspectiveProxy {
|
|
|
8070
8650
|
* `FlowInstance.findAll` / `start` call this for you.
|
|
8071
8651
|
*/
|
|
8072
8652
|
async flowStates(instances) {
|
|
8073
|
-
return await __classPrivateFieldGet$
|
|
8653
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowStates(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instances);
|
|
8074
8654
|
}
|
|
8075
8655
|
/**
|
|
8076
8656
|
* The proposals of `instance` whose votes settled an edge, as this
|
|
@@ -8078,7 +8658,7 @@ class PerspectiveProxy {
|
|
|
8078
8658
|
* Replaces the `resolvedAs` property proposals used to carry.
|
|
8079
8659
|
*/
|
|
8080
8660
|
async flowFired(instance) {
|
|
8081
|
-
return await __classPrivateFieldGet$
|
|
8661
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowFired(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instance);
|
|
8082
8662
|
}
|
|
8083
8663
|
/**
|
|
8084
8664
|
* Called whenever a flow instance on this perspective changes state on
|
|
@@ -8099,7 +8679,7 @@ class PerspectiveProxy {
|
|
|
8099
8679
|
}
|
|
8100
8680
|
/** Mint and store the receipt for a completed flow run. */
|
|
8101
8681
|
async mintFlowReceipt(instanceUri) {
|
|
8102
|
-
return await __classPrivateFieldGet$
|
|
8682
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").mintFlowReceipt(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instanceUri);
|
|
8103
8683
|
}
|
|
8104
8684
|
/**
|
|
8105
8685
|
* Executes a Prolog query against the perspective's knowledge base.
|
|
@@ -8125,7 +8705,7 @@ class PerspectiveProxy {
|
|
|
8125
8705
|
* ```
|
|
8126
8706
|
*/
|
|
8127
8707
|
async infer(query, options) {
|
|
8128
|
-
return await __classPrivateFieldGet$
|
|
8708
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
|
|
8129
8709
|
}
|
|
8130
8710
|
/**
|
|
8131
8711
|
* Executes a SPARQL query against the perspective's link cache.
|
|
@@ -8150,11 +8730,11 @@ class PerspectiveProxy {
|
|
|
8150
8730
|
* @returns Query results as parsed JSON
|
|
8151
8731
|
*/
|
|
8152
8732
|
async querySparql(query, options) {
|
|
8153
|
-
const cached = getCachedResult(__classPrivateFieldGet$
|
|
8733
|
+
const cached = getCachedResult(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
8154
8734
|
if (cached !== undefined)
|
|
8155
8735
|
return cached;
|
|
8156
|
-
const result = await __classPrivateFieldGet$
|
|
8157
|
-
setCachedResult(__classPrivateFieldGet$
|
|
8736
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
|
|
8737
|
+
setCachedResult(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, result);
|
|
8158
8738
|
return result;
|
|
8159
8739
|
}
|
|
8160
8740
|
/**
|
|
@@ -8171,7 +8751,7 @@ class PerspectiveProxy {
|
|
|
8171
8751
|
* @returns Object with `instances` array and `totalCount`
|
|
8172
8752
|
*/
|
|
8173
8753
|
async modelQuery(className, queryJson, options) {
|
|
8174
|
-
return await __classPrivateFieldGet$
|
|
8754
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, options);
|
|
8175
8755
|
}
|
|
8176
8756
|
/** Resolve each URI to the names of every subject class it is an instance of.
|
|
8177
8757
|
*
|
|
@@ -8206,7 +8786,7 @@ class PerspectiveProxy {
|
|
|
8206
8786
|
async subjectClassesOf(uris) {
|
|
8207
8787
|
if (uris.length === 0)
|
|
8208
8788
|
return {};
|
|
8209
|
-
return await __classPrivateFieldGet$
|
|
8789
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").subjectClassesOf(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, uris);
|
|
8210
8790
|
}
|
|
8211
8791
|
/**
|
|
8212
8792
|
* Evaluate property getters for a batch of instances in a single RPC call.
|
|
@@ -8221,7 +8801,7 @@ class PerspectiveProxy {
|
|
|
8221
8801
|
* @returns Map of instance ID → evaluated property values
|
|
8222
8802
|
*/
|
|
8223
8803
|
async evaluateGetters(className, instanceIds, propertyNames) {
|
|
8224
|
-
return await __classPrivateFieldGet$
|
|
8804
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, propertyNames);
|
|
8225
8805
|
}
|
|
8226
8806
|
/**
|
|
8227
8807
|
* Open a live model query on the executor. Later changes arrive as
|
|
@@ -8234,7 +8814,7 @@ class PerspectiveProxy {
|
|
|
8234
8814
|
* @returns `subscriptionId`, initial `result` and `revision` (0)
|
|
8235
8815
|
*/
|
|
8236
8816
|
async modelSubscribe(className, queryJson) {
|
|
8237
|
-
return await __classPrivateFieldGet$
|
|
8817
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson);
|
|
8238
8818
|
}
|
|
8239
8819
|
/**
|
|
8240
8820
|
* Adds a new link to the perspective.
|
|
@@ -8262,8 +8842,8 @@ class PerspectiveProxy {
|
|
|
8262
8842
|
* ```
|
|
8263
8843
|
*/
|
|
8264
8844
|
async add(link, status = 'shared', batchId) {
|
|
8265
|
-
const result = await __classPrivateFieldGet$
|
|
8266
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8845
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
|
|
8846
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8267
8847
|
return result;
|
|
8268
8848
|
}
|
|
8269
8849
|
/**
|
|
@@ -8276,8 +8856,8 @@ class PerspectiveProxy {
|
|
|
8276
8856
|
* @returns Array of created LinkExpressions
|
|
8277
8857
|
*/
|
|
8278
8858
|
async addLinks(links, status = 'shared', batchId) {
|
|
8279
|
-
const result = await __classPrivateFieldGet$
|
|
8280
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8859
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
|
|
8860
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8281
8861
|
return result;
|
|
8282
8862
|
}
|
|
8283
8863
|
/**
|
|
@@ -8288,8 +8868,8 @@ class PerspectiveProxy {
|
|
|
8288
8868
|
* @returns Array of removed LinkExpressions
|
|
8289
8869
|
*/
|
|
8290
8870
|
async removeLinks(links, batchId) {
|
|
8291
|
-
const result = await __classPrivateFieldGet$
|
|
8292
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8871
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
|
|
8872
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8293
8873
|
return result;
|
|
8294
8874
|
}
|
|
8295
8875
|
/**
|
|
@@ -8301,8 +8881,8 @@ class PerspectiveProxy {
|
|
|
8301
8881
|
* @returns Object containing results of the mutations
|
|
8302
8882
|
*/
|
|
8303
8883
|
async linkMutations(mutations, status = 'shared') {
|
|
8304
|
-
const result = await __classPrivateFieldGet$
|
|
8305
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8884
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
|
|
8885
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8306
8886
|
return result;
|
|
8307
8887
|
}
|
|
8308
8888
|
/**
|
|
@@ -8320,7 +8900,7 @@ class PerspectiveProxy {
|
|
|
8320
8900
|
* @returns The added LinkExpression
|
|
8321
8901
|
*/
|
|
8322
8902
|
async addLinkExpression(link, status = 'shared', batchId) {
|
|
8323
|
-
return await __classPrivateFieldGet$
|
|
8903
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
|
|
8324
8904
|
}
|
|
8325
8905
|
/**
|
|
8326
8906
|
* Updates an existing link with new data.
|
|
@@ -8330,8 +8910,8 @@ class PerspectiveProxy {
|
|
|
8330
8910
|
* @param batchId - Optional batch ID to group this operation with others
|
|
8331
8911
|
*/
|
|
8332
8912
|
async update(oldLink, newLink, batchId) {
|
|
8333
|
-
const result = await __classPrivateFieldGet$
|
|
8334
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8913
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
|
|
8914
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8335
8915
|
return result;
|
|
8336
8916
|
}
|
|
8337
8917
|
/**
|
|
@@ -8378,18 +8958,18 @@ class PerspectiveProxy {
|
|
|
8378
8958
|
else {
|
|
8379
8959
|
resolvedLink = link;
|
|
8380
8960
|
}
|
|
8381
|
-
const result = await __classPrivateFieldGet$
|
|
8382
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8961
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, resolvedLink, batchId);
|
|
8962
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8383
8963
|
return result;
|
|
8384
8964
|
}
|
|
8385
8965
|
/** Creates a new batch for grouping operations */
|
|
8386
8966
|
async createBatch() {
|
|
8387
|
-
return await __classPrivateFieldGet$
|
|
8967
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8388
8968
|
}
|
|
8389
8969
|
/** Commits a batch of operations */
|
|
8390
8970
|
async commitBatch(batchId) {
|
|
8391
|
-
const result = await __classPrivateFieldGet$
|
|
8392
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
8971
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, batchId);
|
|
8972
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8393
8973
|
return result;
|
|
8394
8974
|
}
|
|
8395
8975
|
/**
|
|
@@ -8399,7 +8979,7 @@ class PerspectiveProxy {
|
|
|
8399
8979
|
* @returns The rendered Expression
|
|
8400
8980
|
*/
|
|
8401
8981
|
async getExpression(expressionURI) {
|
|
8402
|
-
return await __classPrivateFieldGet$
|
|
8982
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
|
|
8403
8983
|
}
|
|
8404
8984
|
/**
|
|
8405
8985
|
* Creates a new Expression in the specified Language.
|
|
@@ -8409,7 +8989,7 @@ class PerspectiveProxy {
|
|
|
8409
8989
|
* @returns URI of the created Expression
|
|
8410
8990
|
*/
|
|
8411
8991
|
async createExpression(content, languageAddress) {
|
|
8412
|
-
return await __classPrivateFieldGet$
|
|
8992
|
+
return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
|
|
8413
8993
|
}
|
|
8414
8994
|
/**
|
|
8415
8995
|
* Call `handler` with every `type` event about this perspective, until the
|
|
@@ -8425,18 +9005,18 @@ class PerspectiveProxy {
|
|
|
8425
9005
|
on(type, handler) {
|
|
8426
9006
|
// A registration of this proxy's own, so dispose() cannot release another proxy's
|
|
8427
9007
|
// registration of the same function (on() treats equal handlers as one).
|
|
8428
|
-
const release = __classPrivateFieldGet$
|
|
9008
|
+
const release = __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").on(type, (event) => handler(event), { perspective: __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid });
|
|
8429
9009
|
const releaseOnce = () => {
|
|
8430
|
-
if (__classPrivateFieldGet$
|
|
9010
|
+
if (__classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f").delete(releaseOnce))
|
|
8431
9011
|
release();
|
|
8432
9012
|
};
|
|
8433
|
-
__classPrivateFieldGet$
|
|
9013
|
+
__classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f").add(releaseOnce);
|
|
8434
9014
|
return releaseOnce;
|
|
8435
9015
|
}
|
|
8436
9016
|
/** Removes every handler this proxy registered. Other proxies for the same
|
|
8437
9017
|
* perspective keep theirs. */
|
|
8438
9018
|
dispose() {
|
|
8439
|
-
for (const release of [...__classPrivateFieldGet$
|
|
9019
|
+
for (const release of [...__classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f")])
|
|
8440
9020
|
release();
|
|
8441
9021
|
}
|
|
8442
9022
|
/**
|
|
@@ -8446,7 +9026,7 @@ class PerspectiveProxy {
|
|
|
8446
9026
|
* @returns Perspective object containing all links
|
|
8447
9027
|
*/
|
|
8448
9028
|
async snapshot() {
|
|
8449
|
-
return __classPrivateFieldGet$
|
|
9029
|
+
return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8450
9030
|
}
|
|
8451
9031
|
/**
|
|
8452
9032
|
* Loads a perspective snapshot, replacing current content.
|
|
@@ -8650,14 +9230,14 @@ class PerspectiveProxy {
|
|
|
8650
9230
|
* await perspective.addSdna('Recipe', prologCode, 'subject_class');
|
|
8651
9231
|
*/
|
|
8652
9232
|
async addSdna(name, sdnaCode, sdnaType, shaclJson) {
|
|
8653
|
-
return __classPrivateFieldGet$
|
|
9233
|
+
return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
|
|
8654
9234
|
}
|
|
8655
9235
|
/**
|
|
8656
9236
|
* Batch variant of addSdna — registers multiple SDNA entries in a single RPC call.
|
|
8657
9237
|
* Acquires the Rust-side mutex once for the entire batch.
|
|
8658
9238
|
*/
|
|
8659
9239
|
async addSdnaAll(entries) {
|
|
8660
|
-
return __classPrivateFieldGet$
|
|
9240
|
+
return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addSdnaBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, entries);
|
|
8661
9241
|
}
|
|
8662
9242
|
/**
|
|
8663
9243
|
* Batch-registers multiple model classes as SHACL subject classes in a single RPC call.
|
|
@@ -8670,7 +9250,7 @@ class PerspectiveProxy {
|
|
|
8670
9250
|
if (Object.prototype.hasOwnProperty.call(jsClass, 'builtinUri'))
|
|
8671
9251
|
continue;
|
|
8672
9252
|
const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
|
|
8673
|
-
if (__classPrivateFieldGet$
|
|
9253
|
+
if (__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
|
|
8674
9254
|
continue;
|
|
8675
9255
|
if (!jsClass.generateSHACL) {
|
|
8676
9256
|
throw new Error(`Class ${jsClass.name} must have generateSHACL(). Use @Model decorator.`);
|
|
@@ -8686,7 +9266,7 @@ class PerspectiveProxy {
|
|
|
8686
9266
|
return;
|
|
8687
9267
|
await this.addSdnaAll(entries);
|
|
8688
9268
|
for (const entry of entries) {
|
|
8689
|
-
__classPrivateFieldGet$
|
|
9269
|
+
__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(entry.name);
|
|
8690
9270
|
}
|
|
8691
9271
|
}
|
|
8692
9272
|
/**
|
|
@@ -8726,7 +9306,7 @@ class PerspectiveProxy {
|
|
|
8726
9306
|
* in-process and returns link triples for client-side reconstruction.
|
|
8727
9307
|
*/
|
|
8728
9308
|
async getShacl(name) {
|
|
8729
|
-
const result = await __classPrivateFieldGet$
|
|
9309
|
+
const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShacl(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name);
|
|
8730
9310
|
if (!result)
|
|
8731
9311
|
return null;
|
|
8732
9312
|
return SHACLShape.fromLinks(result.links, result.shapeUri);
|
|
@@ -8735,7 +9315,7 @@ class PerspectiveProxy {
|
|
|
8735
9315
|
* List the names of every SHACL shape stored in this Perspective (one RPC call).
|
|
8736
9316
|
*/
|
|
8737
9317
|
async getShaclNames() {
|
|
8738
|
-
return __classPrivateFieldGet$
|
|
9318
|
+
return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShaclNames(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8739
9319
|
}
|
|
8740
9320
|
/**
|
|
8741
9321
|
* Resolve a shape's `sh:targetClass` by name (one RPC call).
|
|
@@ -8746,7 +9326,7 @@ class PerspectiveProxy {
|
|
|
8746
9326
|
* so this method is a pure passthrough.
|
|
8747
9327
|
*/
|
|
8748
9328
|
async getShaclTargetClass(name) {
|
|
8749
|
-
return __classPrivateFieldGet$
|
|
9329
|
+
return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShaclTargetClass(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name);
|
|
8750
9330
|
}
|
|
8751
9331
|
/**
|
|
8752
9332
|
* Get all SHACL shapes stored in this Perspective (one RPC call).
|
|
@@ -8755,7 +9335,7 @@ class PerspectiveProxy {
|
|
|
8755
9335
|
* does not hide the others.
|
|
8756
9336
|
*/
|
|
8757
9337
|
async getAllShacl() {
|
|
8758
|
-
const entries = await __classPrivateFieldGet$
|
|
9338
|
+
const entries = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getAllShacl(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
8759
9339
|
const shapes = [];
|
|
8760
9340
|
for (const { name, shapeUri, links } of entries) {
|
|
8761
9341
|
try {
|
|
@@ -8942,16 +9522,11 @@ class PerspectiveProxy {
|
|
|
8942
9522
|
async stringOrTemplateObjectToSubjectClassName(subjectClass) {
|
|
8943
9523
|
if (typeof subjectClass === "string")
|
|
8944
9524
|
return subjectClass;
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
else {
|
|
8951
|
-
//@ts-ignore
|
|
8952
|
-
return subjectClass.className;
|
|
8953
|
-
}
|
|
8954
|
-
}
|
|
9525
|
+
// The @Model decorator names the class, as in createSubject: no lookup.
|
|
9526
|
+
// Only an undecorated object is matched by its properties.
|
|
9527
|
+
const obj = subjectClass;
|
|
9528
|
+
return obj.className || obj.constructor?.className || obj.constructor?.prototype?.className
|
|
9529
|
+
|| (await this.subjectClassesByTemplate(obj))[0];
|
|
8955
9530
|
}
|
|
8956
9531
|
/**
|
|
8957
9532
|
* Creates a new subject instance of the given subject class
|
|
@@ -8971,7 +9546,7 @@ class PerspectiveProxy {
|
|
|
8971
9546
|
let className;
|
|
8972
9547
|
if (typeof subjectClass === "string") {
|
|
8973
9548
|
className = subjectClass;
|
|
8974
|
-
await __classPrivateFieldGet$
|
|
9549
|
+
await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
|
|
8975
9550
|
className,
|
|
8976
9551
|
initialValues
|
|
8977
9552
|
}), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
|
|
@@ -8983,7 +9558,7 @@ class PerspectiveProxy {
|
|
|
8983
9558
|
if (!resolvedClassName) {
|
|
8984
9559
|
throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
|
|
8985
9560
|
}
|
|
8986
|
-
await __classPrivateFieldGet$
|
|
9561
|
+
await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
|
|
8987
9562
|
className: resolvedClassName,
|
|
8988
9563
|
initialValues
|
|
8989
9564
|
}), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
|
|
@@ -9000,12 +9575,12 @@ class PerspectiveProxy {
|
|
|
9000
9575
|
* abstract class (#1435), each value is written by every class of the
|
|
9001
9576
|
* record that the abstract class reads, under its own name. */
|
|
9002
9577
|
async updateSubject(className, exprAddr, values, batchId) {
|
|
9003
|
-
await __classPrivateFieldGet$
|
|
9004
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
9578
|
+
await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").updateSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, JSON.stringify(values), batchId);
|
|
9579
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
9005
9580
|
}
|
|
9006
9581
|
async getSubjectData(subjectClass, exprAddr) {
|
|
9007
9582
|
if (typeof subjectClass === "string") {
|
|
9008
|
-
return JSON.parse(await __classPrivateFieldGet$
|
|
9583
|
+
return JSON.parse(await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
|
|
9009
9584
|
}
|
|
9010
9585
|
const obj = subjectClass;
|
|
9011
9586
|
const resolvedClassName = obj.className || obj.constructor?.className || obj.constructor?.prototype?.className
|
|
@@ -9013,7 +9588,7 @@ class PerspectiveProxy {
|
|
|
9013
9588
|
if (!resolvedClassName) {
|
|
9014
9589
|
throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
|
|
9015
9590
|
}
|
|
9016
|
-
return JSON.parse(await __classPrivateFieldGet$
|
|
9591
|
+
return JSON.parse(await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
|
|
9017
9592
|
}
|
|
9018
9593
|
/**
|
|
9019
9594
|
* Gets actions from SHACL links for a given predicate (e.g., ad4m://constructor, ad4m://destructor).
|
|
@@ -9064,8 +9639,8 @@ class PerspectiveProxy {
|
|
|
9064
9639
|
// so it has no marker: the executor dispatches it by its URI.
|
|
9065
9640
|
const ctor = subjectClass?.constructor;
|
|
9066
9641
|
if (typeof subjectClass === "object" && ctor && Object.prototype.hasOwnProperty.call(ctor, 'builtinUri')) {
|
|
9067
|
-
await __classPrivateFieldGet$
|
|
9068
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
9642
|
+
await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, ctor.builtinUri, exprAddr, batchId);
|
|
9643
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
9069
9644
|
return;
|
|
9070
9645
|
}
|
|
9071
9646
|
let className = await this.stringOrTemplateObjectToSubjectClassName(subjectClass);
|
|
@@ -9074,8 +9649,8 @@ class PerspectiveProxy {
|
|
|
9074
9649
|
const shapePattern = new RegExp(`[/:#]${this.escapeRegExp(className)}Shape$`);
|
|
9075
9650
|
const markers = await this.get(new LinkQuery({ predicate: "ad4m://abstract" }));
|
|
9076
9651
|
if (markers.some((link) => shapePattern.test(link.data.source))) {
|
|
9077
|
-
await __classPrivateFieldGet$
|
|
9078
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
9652
|
+
await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, batchId);
|
|
9653
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
9079
9654
|
return;
|
|
9080
9655
|
}
|
|
9081
9656
|
// Get destructor actions from SHACL links (Prolog-free)
|
|
@@ -9397,7 +9972,7 @@ class PerspectiveProxy {
|
|
|
9397
9972
|
// Get the class name from the JS class
|
|
9398
9973
|
const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
|
|
9399
9974
|
// Skip if already registered for this perspective instance
|
|
9400
|
-
if (__classPrivateFieldGet$
|
|
9975
|
+
if (__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
|
|
9401
9976
|
return;
|
|
9402
9977
|
// Note: Duplicate checking is handled on the Rust side in add_sdna
|
|
9403
9978
|
// Generate SHACL SDNA (Prolog-free)
|
|
@@ -9412,13 +9987,13 @@ class PerspectiveProxy {
|
|
|
9412
9987
|
// Backend stores SHACL links directly
|
|
9413
9988
|
await this.addSdna(className, '', 'subject_class', shaclJson);
|
|
9414
9989
|
// Mark as registered for this perspective instance
|
|
9415
|
-
__classPrivateFieldGet$
|
|
9990
|
+
__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
|
|
9416
9991
|
}
|
|
9417
9992
|
/** Clear the per-instance ensured subject class cache.
|
|
9418
9993
|
* Call this after wiping a perspective's links so that
|
|
9419
9994
|
* subsequent register() calls re-add SHACL definitions. */
|
|
9420
9995
|
clearEnsuredSubjectClasses() {
|
|
9421
|
-
__classPrivateFieldGet$
|
|
9996
|
+
__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
|
|
9422
9997
|
}
|
|
9423
9998
|
/**
|
|
9424
9999
|
* Returns a list of all class names that have been registered as SHACL
|
|
@@ -9593,7 +10168,7 @@ class PerspectiveProxy {
|
|
|
9593
10168
|
}));
|
|
9594
10169
|
}
|
|
9595
10170
|
getNeighbourhoodProxy() {
|
|
9596
|
-
return __classPrivateFieldGet$
|
|
10171
|
+
return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
|
|
9597
10172
|
}
|
|
9598
10173
|
/**
|
|
9599
10174
|
* Returns a proxy object for working with AI capabilities.
|
|
@@ -9610,26 +10185,34 @@ class PerspectiveProxy {
|
|
|
9610
10185
|
* ```
|
|
9611
10186
|
*/
|
|
9612
10187
|
get ai() {
|
|
9613
|
-
return __classPrivateFieldGet$
|
|
10188
|
+
return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").aiClient;
|
|
9614
10189
|
}
|
|
9615
10190
|
/** Live SPARQL query: resolves once the first result is in.
|
|
9616
10191
|
* Call `dispose()` on the returned proxy when done. The executor
|
|
9617
10192
|
* refuses a Prolog query (400): Prolog live queries are not supported. */
|
|
9618
10193
|
async subscribeQuery(query) {
|
|
9619
|
-
const subscription = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$
|
|
9620
|
-
|
|
10194
|
+
const subscription = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f"));
|
|
10195
|
+
try {
|
|
10196
|
+
await subscription.subscribe();
|
|
10197
|
+
}
|
|
10198
|
+
catch (e) {
|
|
10199
|
+
// Nobody gets the proxy, so nobody can dispose it: left as is, it
|
|
10200
|
+
// would re-open on every reconnect and retry for good (#1595).
|
|
10201
|
+
subscription.dispose({ cancelOpening: true });
|
|
10202
|
+
throw e;
|
|
10203
|
+
}
|
|
9621
10204
|
return subscription;
|
|
9622
10205
|
}
|
|
9623
10206
|
}
|
|
9624
10207
|
_PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_releases = new WeakMap(), _PerspectiveProxy_ensuredSubjectClasses = new WeakMap(), _PerspectiveProxy_overlaysInFlight = new WeakMap();
|
|
9625
10208
|
|
|
9626
|
-
var __classPrivateFieldSet$
|
|
10209
|
+
var __classPrivateFieldSet$6 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9627
10210
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9628
10211
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9629
10212
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
9630
10213
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
9631
10214
|
};
|
|
9632
|
-
var __classPrivateFieldGet$
|
|
10215
|
+
var __classPrivateFieldGet$6 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9633
10216
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9634
10217
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
9635
10218
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -9645,27 +10228,27 @@ class PerspectiveClient {
|
|
|
9645
10228
|
_PerspectiveClient_expressionClient.set(this, void 0);
|
|
9646
10229
|
_PerspectiveClient_neighbourhoodClient.set(this, void 0);
|
|
9647
10230
|
_PerspectiveClient_aiClient.set(this, void 0);
|
|
9648
|
-
__classPrivateFieldSet$
|
|
10231
|
+
__classPrivateFieldSet$6(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
9649
10232
|
}
|
|
9650
10233
|
setExpressionClient(client) {
|
|
9651
|
-
__classPrivateFieldSet$
|
|
10234
|
+
__classPrivateFieldSet$6(this, _PerspectiveClient_expressionClient, client, "f");
|
|
9652
10235
|
}
|
|
9653
10236
|
setNeighbourhoodClient(client) {
|
|
9654
|
-
__classPrivateFieldSet$
|
|
10237
|
+
__classPrivateFieldSet$6(this, _PerspectiveClient_neighbourhoodClient, client, "f");
|
|
9655
10238
|
}
|
|
9656
10239
|
setAIClient(client) {
|
|
9657
|
-
__classPrivateFieldSet$
|
|
10240
|
+
__classPrivateFieldSet$6(this, _PerspectiveClient_aiClient, client, "f");
|
|
9658
10241
|
}
|
|
9659
10242
|
get aiClient() {
|
|
9660
|
-
return __classPrivateFieldGet$
|
|
10243
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_aiClient, "f");
|
|
9661
10244
|
}
|
|
9662
10245
|
async all() {
|
|
9663
|
-
const perspectives = await __classPrivateFieldGet$
|
|
10246
|
+
const perspectives = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.all', {});
|
|
9664
10247
|
return perspectives.map(handle => new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this));
|
|
9665
10248
|
}
|
|
9666
10249
|
async byUUID(uuid) {
|
|
9667
10250
|
try {
|
|
9668
|
-
const perspective = await __classPrivateFieldGet$
|
|
10251
|
+
const perspective = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.get', { uuid });
|
|
9669
10252
|
if (!perspective)
|
|
9670
10253
|
return null;
|
|
9671
10254
|
return new PerspectiveProxy(PerspectiveHandle.fromWire(perspective), this);
|
|
@@ -9677,11 +10260,11 @@ class PerspectiveClient {
|
|
|
9677
10260
|
}
|
|
9678
10261
|
}
|
|
9679
10262
|
async snapshotByUUID(uuid) {
|
|
9680
|
-
const snapshot = await __classPrivateFieldGet$
|
|
10263
|
+
const snapshot = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.snapshot', { uuid });
|
|
9681
10264
|
return snapshot ? new Perspective(snapshot.links.map(LinkExpression.fromWire)) : null;
|
|
9682
10265
|
}
|
|
9683
10266
|
async publishSnapshotByUUID(uuid) {
|
|
9684
|
-
return __classPrivateFieldGet$
|
|
10267
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.publishSnapshot', { uuid });
|
|
9685
10268
|
}
|
|
9686
10269
|
async queryLinks(uuid, query, options) {
|
|
9687
10270
|
const params = { uuid };
|
|
@@ -9697,44 +10280,45 @@ class PerspectiveClient {
|
|
|
9697
10280
|
params.untilDate = query.untilDate instanceof Date ? query.untilDate.toISOString() : String(query.untilDate);
|
|
9698
10281
|
if (query.limit !== undefined)
|
|
9699
10282
|
params.limit = query.limit;
|
|
9700
|
-
const links = await __classPrivateFieldGet$
|
|
10283
|
+
const links = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.queryLinks', params, options);
|
|
9701
10284
|
return links.map(LinkExpression.fromWire);
|
|
9702
10285
|
}
|
|
9703
10286
|
async queryProlog(uuid, query, options) {
|
|
9704
|
-
const result = await __classPrivateFieldGet$
|
|
10287
|
+
const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.queryProlog', { uuid, query }, options);
|
|
9705
10288
|
return JSON.parse(result);
|
|
9706
10289
|
}
|
|
9707
10290
|
async querySparql(uuid, query, options) {
|
|
9708
|
-
const result = await __classPrivateFieldGet$
|
|
10291
|
+
const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.querySparql', { uuid, engine: 'sparql', query }, options);
|
|
9709
10292
|
return JSON.parse(result);
|
|
9710
10293
|
}
|
|
9711
10294
|
/** Open a live SPARQL query. Updates arrive through {@link onQueryUpdate}. */
|
|
9712
|
-
|
|
9713
|
-
|
|
10295
|
+
/** `options.signal` cancels the call, and the executor stops computing the first result. */
|
|
10296
|
+
async subscribeQuery(uuid, query, options) {
|
|
10297
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.subscribeQuery', { uuid, query }, options);
|
|
9714
10298
|
}
|
|
9715
10299
|
/** Every `query-subscription-update` event on this client's socket. */
|
|
9716
10300
|
onQueryUpdate(cb) {
|
|
9717
|
-
return __classPrivateFieldGet$
|
|
10301
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").on('query-subscription-update', cb);
|
|
9718
10302
|
}
|
|
9719
10303
|
/** The current result and revision of a live query, after a revision gap. */
|
|
9720
10304
|
async resyncSubscription(uuid, subscriptionId) {
|
|
9721
|
-
return __classPrivateFieldGet$
|
|
10305
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.resyncSubscription', { uuid, subscriptionId });
|
|
9722
10306
|
}
|
|
9723
10307
|
/** Ends the subscription on the executor. The caller releases its local listener
|
|
9724
10308
|
* with the function {@link onQueryUpdate} returned. */
|
|
9725
10309
|
async disposeQuerySubscription(uuid, subscriptionId) {
|
|
9726
|
-
return __classPrivateFieldGet$
|
|
10310
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
|
|
9727
10311
|
}
|
|
9728
10312
|
/** `className` may name several classes: one query over their union (#1238). */
|
|
9729
10313
|
async modelQuery(uuid, className, queryJson, options) {
|
|
9730
|
-
const resultJson = await __classPrivateFieldGet$
|
|
10314
|
+
const resultJson = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.modelQuery', { uuid, ...classParams(className), query_json: queryJson }, options);
|
|
9731
10315
|
return JSON.parse(resultJson);
|
|
9732
10316
|
}
|
|
9733
10317
|
async subjectClassesOf(uuid, uris) {
|
|
9734
|
-
return await __classPrivateFieldGet$
|
|
10318
|
+
return await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.subjectClassesOf', { uuid, uris });
|
|
9735
10319
|
}
|
|
9736
10320
|
async evaluateGetters(uuid, className, instanceIds, propertyNames) {
|
|
9737
|
-
const resultJson = await __classPrivateFieldGet$
|
|
10321
|
+
const resultJson = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.evaluateGetters', {
|
|
9738
10322
|
uuid,
|
|
9739
10323
|
class_name: className,
|
|
9740
10324
|
instance_ids: instanceIds,
|
|
@@ -9743,35 +10327,36 @@ class PerspectiveClient {
|
|
|
9743
10327
|
return JSON.parse(resultJson);
|
|
9744
10328
|
}
|
|
9745
10329
|
/** Open a live model query over one class or several. Updates arrive through {@link onQueryUpdate}. */
|
|
9746
|
-
|
|
9747
|
-
|
|
10330
|
+
/** `options.signal` cancels the call, and the executor stops computing the first result. */
|
|
10331
|
+
async modelSubscribe(uuid, className, queryJson, options) {
|
|
10332
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.modelSubscribe', { uuid, ...classParams(className), query_json: queryJson }, options);
|
|
9748
10333
|
}
|
|
9749
10334
|
async add(name) {
|
|
9750
|
-
const handle = await __classPrivateFieldGet$
|
|
10335
|
+
const handle = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.create', { name });
|
|
9751
10336
|
return new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this);
|
|
9752
10337
|
}
|
|
9753
10338
|
async update(uuid, name) {
|
|
9754
|
-
const handle = await __classPrivateFieldGet$
|
|
10339
|
+
const handle = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.update', { uuid, name });
|
|
9755
10340
|
return new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this);
|
|
9756
10341
|
}
|
|
9757
10342
|
async remove(uuid) {
|
|
9758
|
-
const result = await __classPrivateFieldGet$
|
|
10343
|
+
const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.remove', { uuid });
|
|
9759
10344
|
return { perspectiveRemove: result };
|
|
9760
10345
|
}
|
|
9761
10346
|
async addLink(uuid, link, status = 'shared', batchId) {
|
|
9762
|
-
const added = await __classPrivateFieldGet$
|
|
10347
|
+
const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addLink', { uuid, link, status, batchId });
|
|
9763
10348
|
return LinkExpression.fromWire(added);
|
|
9764
10349
|
}
|
|
9765
10350
|
async addLinks(uuid, links, status = 'shared', batchId) {
|
|
9766
|
-
const added = await __classPrivateFieldGet$
|
|
10351
|
+
const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status, batchId });
|
|
9767
10352
|
return added.map(LinkExpression.fromWire);
|
|
9768
10353
|
}
|
|
9769
10354
|
async removeLinks(uuid, links, batchId) {
|
|
9770
|
-
const removed = await __classPrivateFieldGet$
|
|
10355
|
+
const removed = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLinks', { uuid, links: links.map(linkExpressionInputToWire), batchId });
|
|
9771
10356
|
return removed.map(LinkExpression.fromWire);
|
|
9772
10357
|
}
|
|
9773
10358
|
async linkMutations(uuid, mutations, status) {
|
|
9774
|
-
const diff = await __classPrivateFieldGet$
|
|
10359
|
+
const diff = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations: linkMutationsToWire(mutations), status });
|
|
9775
10360
|
return LinkExpressionMutations.fromWire(diff);
|
|
9776
10361
|
}
|
|
9777
10362
|
/**
|
|
@@ -9791,7 +10376,7 @@ class PerspectiveClient {
|
|
|
9791
10376
|
* are NOT re-parented — same rule as the watcher).
|
|
9792
10377
|
*/
|
|
9793
10378
|
async runInterpretation(uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, options) {
|
|
9794
|
-
return __classPrivateFieldGet$
|
|
10379
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretation', {
|
|
9795
10380
|
uuid, transcript, basePrefix, classes, existingScope, mintScope,
|
|
9796
10381
|
observationId: observe?.observationId,
|
|
9797
10382
|
emitDebugEvents: observe?.emitDebugEvents,
|
|
@@ -9818,7 +10403,7 @@ class PerspectiveClient {
|
|
|
9818
10403
|
// `emitDebugEvents` is a dead-letter without an observationId
|
|
9819
10404
|
// (nothing to key against); the server gates on both.
|
|
9820
10405
|
observationId, emitDebugEvents, options) {
|
|
9821
|
-
return __classPrivateFieldGet$
|
|
10406
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretationWithHarness', {
|
|
9822
10407
|
uuid,
|
|
9823
10408
|
transcript,
|
|
9824
10409
|
basePrefix,
|
|
@@ -9841,7 +10426,7 @@ class PerspectiveClient {
|
|
|
9841
10426
|
* calls before it answers.
|
|
9842
10427
|
*/
|
|
9843
10428
|
async runAgent(uuid, messages, settings, options) {
|
|
9844
|
-
return __classPrivateFieldGet$
|
|
10429
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.runAgent', { uuid, messages, ...settings }, options);
|
|
9845
10430
|
}
|
|
9846
10431
|
/**
|
|
9847
10432
|
* Register a neighbourhood auto-processor on this perspective. The executor's
|
|
@@ -9852,15 +10437,15 @@ class PerspectiveClient {
|
|
|
9852
10437
|
* Returns the processor id.
|
|
9853
10438
|
*/
|
|
9854
10439
|
async addAutoProcessor(uuid, config) {
|
|
9855
|
-
return __classPrivateFieldGet$
|
|
10440
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addAutoProcessor', { ...config, uuid });
|
|
9856
10441
|
}
|
|
9857
10442
|
/** Delete an auto-processor's config. `false` when there was none to delete. */
|
|
9858
10443
|
async removeAutoProcessor(uuid, processorId) {
|
|
9859
|
-
return __classPrivateFieldGet$
|
|
10444
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeAutoProcessor', { uuid, processorId });
|
|
9860
10445
|
}
|
|
9861
10446
|
/** Pending interpretation overlays (LLM suggestions awaiting human accept/reject). */
|
|
9862
10447
|
async interpretationOverlays(uuid) {
|
|
9863
|
-
const overlays = await __classPrivateFieldGet$
|
|
10448
|
+
const overlays = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.interpretationOverlays', { uuid });
|
|
9864
10449
|
return overlays.map(({ base, kind, run, inferred }) => ({
|
|
9865
10450
|
base, run, inferred, kind: kind === 'create' ? 'create' : 'update',
|
|
9866
10451
|
}));
|
|
@@ -9868,18 +10453,18 @@ class PerspectiveClient {
|
|
|
9868
10453
|
/** Accept an overlay's suggestion(s): the LLM value becomes the real value and
|
|
9869
10454
|
* the overlay is deleted. Omit `property` to accept the whole base. */
|
|
9870
10455
|
async acceptInterpretation(uuid, base, property) {
|
|
9871
|
-
return __classPrivateFieldGet$
|
|
10456
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptInterpretation', { uuid, base, property });
|
|
9872
10457
|
}
|
|
9873
10458
|
/** Reject an overlay's suggestion(s). Omit `property` to reject the whole base
|
|
9874
10459
|
* (a rejected `create` deletes the suggested instance). */
|
|
9875
10460
|
async rejectInterpretation(uuid, base, property) {
|
|
9876
|
-
return __classPrivateFieldGet$
|
|
10461
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectInterpretation', { uuid, base, property });
|
|
9877
10462
|
}
|
|
9878
10463
|
async proposeFlowTransition(uuid, instanceUri, toState, rationale, outputs) {
|
|
9879
|
-
return __classPrivateFieldGet$
|
|
10464
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.proposeFlowTransition', { uuid, instanceUri, toState, rationale, outputs });
|
|
9880
10465
|
}
|
|
9881
10466
|
async acceptFlowProposal(uuid, proposalUri) {
|
|
9882
|
-
return __classPrivateFieldGet$
|
|
10467
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptFlowProposal', { uuid, proposalUri });
|
|
9883
10468
|
}
|
|
9884
10469
|
/**
|
|
9885
10470
|
* Withdraw this agent's own links from a proposal. Resolves to how many
|
|
@@ -9887,69 +10472,69 @@ class PerspectiveClient {
|
|
|
9887
10472
|
* proposal this agent opened.
|
|
9888
10473
|
*/
|
|
9889
10474
|
async rejectFlowProposal(uuid, proposalUri) {
|
|
9890
|
-
const result = await __classPrivateFieldGet$
|
|
10475
|
+
const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectFlowProposal', { uuid, proposalUri });
|
|
9891
10476
|
return result.retractedLinks;
|
|
9892
10477
|
}
|
|
9893
10478
|
/** Re-decide a flow receipt under this perspective's own flow catalogue. */
|
|
9894
10479
|
async verifyFlowReceipt(uuid, receipt) {
|
|
9895
|
-
return __classPrivateFieldGet$
|
|
10480
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.verifyFlowReceipt', { uuid, receipt });
|
|
9896
10481
|
}
|
|
9897
10482
|
/** The instances that are, as they stand, valid outputs of `flow`
|
|
9898
10483
|
* (optionally: of runs settled into terminal state `state`). */
|
|
9899
10484
|
async flowValidOutputs(uuid, flow, state) {
|
|
9900
|
-
return __classPrivateFieldGet$
|
|
10485
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.flowValidOutputs', { uuid, flow, state });
|
|
9901
10486
|
}
|
|
9902
10487
|
/** The calling agent's recorded state of each flow instance it has
|
|
9903
10488
|
* derived, optionally narrowed to `instances`. */
|
|
9904
10489
|
async flowStates(uuid, instances) {
|
|
9905
|
-
return __classPrivateFieldGet$
|
|
10490
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.flowStates', { uuid, instances });
|
|
9906
10491
|
}
|
|
9907
10492
|
/** The proposals of `instance` the calling agent's replica recorded as
|
|
9908
10493
|
* fired, sorted. */
|
|
9909
10494
|
async flowFired(uuid, instance) {
|
|
9910
|
-
return __classPrivateFieldGet$
|
|
10495
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.flowFired', { uuid, instance });
|
|
9911
10496
|
}
|
|
9912
10497
|
/** Mint and store the receipt for a completed flow run. Fails while the
|
|
9913
10498
|
* run has not settled into a terminal state, and when an output's
|
|
9914
10499
|
* content no longer matches what the quorum committed to. */
|
|
9915
10500
|
async mintFlowReceipt(uuid, instanceUri) {
|
|
9916
|
-
return __classPrivateFieldGet$
|
|
10501
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.mintFlowReceipt', { uuid, instanceUri });
|
|
9917
10502
|
}
|
|
9918
10503
|
async addLinkExpression(uuid, link, status = 'shared', batchId) {
|
|
9919
|
-
const added = await __classPrivateFieldGet$
|
|
10504
|
+
const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link: linkExpressionToWire(link), status, batchId });
|
|
9920
10505
|
return LinkExpression.fromWire(added);
|
|
9921
10506
|
}
|
|
9922
10507
|
async updateLink(uuid, oldLink, newLink, batchId) {
|
|
9923
|
-
const updated = await __classPrivateFieldGet$
|
|
10508
|
+
const updated = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.updateLink', { uuid, oldLink: linkExpressionInputToWire(oldLink), newLink, batchId });
|
|
9924
10509
|
return LinkExpression.fromWire(updated);
|
|
9925
10510
|
}
|
|
9926
10511
|
async removeLink(uuid, link, batchId) {
|
|
9927
10512
|
const { status, ...wire } = linkExpressionInputToWire(link);
|
|
9928
|
-
return __classPrivateFieldGet$
|
|
10513
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLink', { uuid, link: wire, batchId });
|
|
9929
10514
|
}
|
|
9930
10515
|
async addSdna(uuid, name, sdnaCode, sdnaType, shaclJson) {
|
|
9931
|
-
const result = await __classPrivateFieldGet$
|
|
10516
|
+
const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
|
|
9932
10517
|
return typeof result === 'boolean' ? result : result.every(Boolean);
|
|
9933
10518
|
}
|
|
9934
10519
|
async addSdnaBatch(uuid, entries) {
|
|
9935
|
-
const result = await __classPrivateFieldGet$
|
|
10520
|
+
const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, entries: entries.map(e => ({ ...e, sdnaCode: e.sdnaCode || "" })) });
|
|
9936
10521
|
return typeof result === 'boolean' ? [result] : result;
|
|
9937
10522
|
}
|
|
9938
10523
|
async executeCommands(uuid, commands, expression, parameters, batchId) {
|
|
9939
|
-
return __classPrivateFieldGet$
|
|
10524
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.executeCommands', { uuid, commands, expression, parameters, batchId });
|
|
9940
10525
|
}
|
|
9941
10526
|
async createSubject(uuid, subjectClass, expressionAddress, initialValues, batchId) {
|
|
9942
|
-
return __classPrivateFieldGet$
|
|
10527
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId });
|
|
9943
10528
|
}
|
|
9944
10529
|
/** Through an abstract class (#1435), the executor writes to the record's own classes. */
|
|
9945
10530
|
async updateSubject(uuid, subjectClass, expressionAddress, values, batchId) {
|
|
9946
|
-
return __classPrivateFieldGet$
|
|
10531
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.updateSubject', { uuid, subjectClass, expressionAddress, values, batchId });
|
|
9947
10532
|
}
|
|
9948
10533
|
async removeSubject(uuid, subjectClass, expressionAddress, batchId) {
|
|
9949
|
-
return __classPrivateFieldGet$
|
|
10534
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeSubject', { uuid, subjectClass, expressionAddress, batchId });
|
|
9950
10535
|
}
|
|
9951
10536
|
async getSubjectData(uuid, subjectClass, expressionAddress) {
|
|
9952
|
-
return __classPrivateFieldGet$
|
|
10537
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getSubjectData', { uuid, subjectClass, expressionAddress });
|
|
9953
10538
|
}
|
|
9954
10539
|
// ── SHACL resolution (server-side) ─────────────────────────────────────────
|
|
9955
10540
|
// These methods delegate shape resolution to the executor, which reads links
|
|
@@ -9957,7 +10542,7 @@ class PerspectiveClient {
|
|
|
9957
10542
|
// `queryLinks` sequences the old PerspectiveProxy methods performed.
|
|
9958
10543
|
/** List the names of every SHACL shape stored in a perspective (one RPC call). */
|
|
9959
10544
|
async getShaclNames(uuid) {
|
|
9960
|
-
return __classPrivateFieldGet$
|
|
10545
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getShaclNames', { uuid });
|
|
9961
10546
|
}
|
|
9962
10547
|
/**
|
|
9963
10548
|
* Resolve a shape's `sh:targetClass` by name (one RPC call).
|
|
@@ -9970,7 +10555,7 @@ class PerspectiveClient {
|
|
|
9970
10555
|
* than pushing the null one layer further up. PR #935 review r3897752023.
|
|
9971
10556
|
*/
|
|
9972
10557
|
async getShaclTargetClass(uuid, name) {
|
|
9973
|
-
const result = await __classPrivateFieldGet$
|
|
10558
|
+
const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getShaclTargetClass', { uuid, name });
|
|
9974
10559
|
return result ?? undefined;
|
|
9975
10560
|
}
|
|
9976
10561
|
/**
|
|
@@ -9979,51 +10564,51 @@ class PerspectiveClient {
|
|
|
9979
10564
|
* or `null` if no shape with that name exists.
|
|
9980
10565
|
*/
|
|
9981
10566
|
async getShacl(uuid, name) {
|
|
9982
|
-
return __classPrivateFieldGet$
|
|
10567
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getShacl', { uuid, name });
|
|
9983
10568
|
}
|
|
9984
10569
|
/**
|
|
9985
10570
|
* Retrieve all SHACL shapes in one call. Returns an array of
|
|
9986
10571
|
* `{name, shapeUri, links}` — one entry per shape (one RPC call).
|
|
9987
10572
|
*/
|
|
9988
10573
|
async getAllShacl(uuid) {
|
|
9989
|
-
return __classPrivateFieldGet$
|
|
10574
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getAllShacl', { uuid });
|
|
9990
10575
|
}
|
|
9991
10576
|
// ExpressionClient functions, needed for Subjects:
|
|
9992
10577
|
async getExpression(expressionURI) {
|
|
9993
|
-
return await __classPrivateFieldGet$
|
|
10578
|
+
return await __classPrivateFieldGet$6(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
|
|
9994
10579
|
}
|
|
9995
10580
|
async createExpression(content, languageAddress) {
|
|
9996
|
-
return await __classPrivateFieldGet$
|
|
10581
|
+
return await __classPrivateFieldGet$6(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
|
|
9997
10582
|
}
|
|
9998
10583
|
/** The client's event bus; see {@link ApiClient.on}. */
|
|
9999
10584
|
on(type, handler, filter) {
|
|
10000
|
-
return __classPrivateFieldGet$
|
|
10585
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").on(type, handler, filter);
|
|
10001
10586
|
}
|
|
10002
10587
|
getNeighbourhoodProxy(uuid) {
|
|
10003
|
-
return new NeighbourhoodProxy(__classPrivateFieldGet$
|
|
10588
|
+
return new NeighbourhoodProxy(__classPrivateFieldGet$6(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
|
|
10004
10589
|
}
|
|
10005
10590
|
async createBatch(uuid) {
|
|
10006
|
-
return __classPrivateFieldGet$
|
|
10591
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.createBatch', { uuid });
|
|
10007
10592
|
}
|
|
10008
10593
|
async commitBatch(uuid, batchId) {
|
|
10009
|
-
const diff = await __classPrivateFieldGet$
|
|
10594
|
+
const diff = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.commitBatch', { uuid, batchId });
|
|
10010
10595
|
return LinkExpressionMutations.fromWire(diff);
|
|
10011
10596
|
}
|
|
10012
10597
|
/** Register a callback that fires after a successful WebSocket reconnect.
|
|
10013
10598
|
* Passes through to ApiClient.onReconnect(). Returns an unsubscribe function. */
|
|
10014
10599
|
onReconnect(callback) {
|
|
10015
|
-
return __classPrivateFieldGet$
|
|
10600
|
+
return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").onReconnect(callback);
|
|
10016
10601
|
}
|
|
10017
10602
|
}
|
|
10018
10603
|
_PerspectiveClient_apiClient = new WeakMap(), _PerspectiveClient_expressionClient = new WeakMap(), _PerspectiveClient_neighbourhoodClient = new WeakMap(), _PerspectiveClient_aiClient = new WeakMap();
|
|
10019
10604
|
|
|
10020
|
-
var __classPrivateFieldSet$
|
|
10605
|
+
var __classPrivateFieldSet$5 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
10021
10606
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10022
10607
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10023
10608
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10024
10609
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
10025
10610
|
};
|
|
10026
|
-
var __classPrivateFieldGet$
|
|
10611
|
+
var __classPrivateFieldGet$5 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
10027
10612
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10028
10613
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10029
10614
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -10032,197 +10617,197 @@ var _RuntimeClient_apiClient;
|
|
|
10032
10617
|
class RuntimeClient {
|
|
10033
10618
|
constructor(baseUrl, token, sharedApiClient) {
|
|
10034
10619
|
_RuntimeClient_apiClient.set(this, void 0);
|
|
10035
|
-
__classPrivateFieldSet$
|
|
10620
|
+
__classPrivateFieldSet$5(this, _RuntimeClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
10036
10621
|
}
|
|
10037
10622
|
async info() {
|
|
10038
|
-
return __classPrivateFieldGet$
|
|
10623
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.info', {});
|
|
10039
10624
|
}
|
|
10040
10625
|
async tlsDomain() {
|
|
10041
|
-
return __classPrivateFieldGet$
|
|
10626
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.tlsDomain', {});
|
|
10042
10627
|
}
|
|
10043
10628
|
async quit() {
|
|
10044
|
-
return __classPrivateFieldGet$
|
|
10629
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.quit', {});
|
|
10045
10630
|
}
|
|
10046
10631
|
async openLink(url) {
|
|
10047
|
-
return __classPrivateFieldGet$
|
|
10632
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.openLink', { url });
|
|
10048
10633
|
}
|
|
10049
10634
|
async addTrustedAgents(agents) {
|
|
10050
|
-
return __classPrivateFieldGet$
|
|
10635
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('agent.addTrustedAgents', { agents });
|
|
10051
10636
|
}
|
|
10052
10637
|
async deleteTrustedAgents(agents) {
|
|
10053
|
-
return __classPrivateFieldGet$
|
|
10638
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('agent.deleteTrustedAgents', { agents });
|
|
10054
10639
|
}
|
|
10055
10640
|
async getTrustedAgents() {
|
|
10056
|
-
return __classPrivateFieldGet$
|
|
10641
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('agent.getTrustedAgents', {});
|
|
10057
10642
|
}
|
|
10058
10643
|
async addKnownLinkLanguageTemplates(addresses) {
|
|
10059
|
-
return __classPrivateFieldGet$
|
|
10644
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.addLinkLanguageTemplates', { addresses });
|
|
10060
10645
|
}
|
|
10061
10646
|
async removeKnownLinkLanguageTemplates(addresses) {
|
|
10062
|
-
return __classPrivateFieldGet$
|
|
10647
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.removeLinkLanguageTemplates', { addresses });
|
|
10063
10648
|
}
|
|
10064
10649
|
/** Every link-language template the executor knows, with its meta (name, description,
|
|
10065
10650
|
* `possibleTemplateParams`). A template whose meta cannot be read is left out. */
|
|
10066
10651
|
async knownLinkLanguageTemplates() {
|
|
10067
|
-
return __classPrivateFieldGet$
|
|
10652
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.linkLanguageTemplates', {});
|
|
10068
10653
|
}
|
|
10069
10654
|
async addFriends(dids) {
|
|
10070
|
-
return __classPrivateFieldGet$
|
|
10655
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.addFriends', { dids });
|
|
10071
10656
|
}
|
|
10072
10657
|
async removeFriends(dids) {
|
|
10073
|
-
return __classPrivateFieldGet$
|
|
10658
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.removeFriends', { dids });
|
|
10074
10659
|
}
|
|
10075
10660
|
async friends() {
|
|
10076
|
-
return __classPrivateFieldGet$
|
|
10661
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.friends', {});
|
|
10077
10662
|
}
|
|
10078
10663
|
async hcAgentInfos() {
|
|
10079
|
-
return __classPrivateFieldGet$
|
|
10664
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.hcAgentInfos', {});
|
|
10080
10665
|
}
|
|
10081
10666
|
async getNetworkMetrics() {
|
|
10082
|
-
return __classPrivateFieldGet$
|
|
10667
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.networkMetrics', {});
|
|
10083
10668
|
}
|
|
10084
10669
|
async restartHolochain(options) {
|
|
10085
|
-
return __classPrivateFieldGet$
|
|
10670
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.restartHolochain', {}, options);
|
|
10086
10671
|
}
|
|
10087
10672
|
async hcAddAgentInfos(agentInfos) {
|
|
10088
|
-
return __classPrivateFieldGet$
|
|
10673
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.addHcAgentInfos', { agentInfos });
|
|
10089
10674
|
}
|
|
10090
10675
|
async verifyStringSignedByDid(did, didSigningKeyId, data, signedData) {
|
|
10091
10676
|
// The executor resolves the key from the DID document; `didSigningKeyId` goes unused.
|
|
10092
|
-
return __classPrivateFieldGet$
|
|
10677
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.verifySignature', { did, data, signedData });
|
|
10093
10678
|
}
|
|
10094
10679
|
async setStatus(perspective) {
|
|
10095
|
-
return __classPrivateFieldGet$
|
|
10680
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setStatus', { status: Perspective.toWire(perspective) });
|
|
10096
10681
|
}
|
|
10097
10682
|
async friendStatus(did) {
|
|
10098
|
-
const status = await __classPrivateFieldGet$
|
|
10683
|
+
const status = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.friendStatus', { did });
|
|
10099
10684
|
return status ? PerspectiveExpression.fromWire(status) : null;
|
|
10100
10685
|
}
|
|
10101
10686
|
async friendSendMessage(did, message) {
|
|
10102
|
-
return __classPrivateFieldGet$
|
|
10687
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.sendFriendMessage', { did, message: Perspective.toWire(message) });
|
|
10103
10688
|
}
|
|
10104
10689
|
async messageInbox() {
|
|
10105
|
-
return (await __classPrivateFieldGet$
|
|
10690
|
+
return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.inbox', {})).map(PerspectiveExpression.fromWire);
|
|
10106
10691
|
}
|
|
10107
10692
|
async messageOutbox() {
|
|
10108
|
-
const sent = await __classPrivateFieldGet$
|
|
10693
|
+
const sent = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.outbox', {});
|
|
10109
10694
|
return sent.map(({ recipient, message }) => ({ recipient, message: PerspectiveExpression.fromWire(message) }));
|
|
10110
10695
|
}
|
|
10111
10696
|
async requestInstallNotification(notification) {
|
|
10112
|
-
return __classPrivateFieldGet$
|
|
10697
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.createNotification', { ...notification });
|
|
10113
10698
|
}
|
|
10114
10699
|
async grantNotification(id) {
|
|
10115
|
-
return __classPrivateFieldGet$
|
|
10700
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.grantNotification', { id, granted: true });
|
|
10116
10701
|
}
|
|
10117
10702
|
async exportDb(filePath) {
|
|
10118
|
-
return __classPrivateFieldGet$
|
|
10703
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.exportData', { type: "db", filePath });
|
|
10119
10704
|
}
|
|
10120
10705
|
async importDb(filePath) {
|
|
10121
|
-
const result = await __classPrivateFieldGet$
|
|
10706
|
+
const result = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.importData', { type: "db", filePath });
|
|
10122
10707
|
if ('success' in result)
|
|
10123
10708
|
throw new Error('runtime.importData answered a perspective import for type "db"');
|
|
10124
10709
|
return result;
|
|
10125
10710
|
}
|
|
10126
10711
|
async notifications() {
|
|
10127
|
-
return __classPrivateFieldGet$
|
|
10712
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.notifications', {});
|
|
10128
10713
|
}
|
|
10129
10714
|
async updateNotification(id, notification) {
|
|
10130
|
-
return __classPrivateFieldGet$
|
|
10715
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.updateNotification', { ...notification, id });
|
|
10131
10716
|
}
|
|
10132
10717
|
async removeNotification(id) {
|
|
10133
|
-
return __classPrivateFieldGet$
|
|
10718
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.deleteNotification', { id });
|
|
10134
10719
|
}
|
|
10135
10720
|
async exportPerspective(uuid, filePath) {
|
|
10136
|
-
return __classPrivateFieldGet$
|
|
10721
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.exportData', { type: "perspective", perspectiveUuid: uuid, filePath });
|
|
10137
10722
|
}
|
|
10138
10723
|
async importPerspective(filePath) {
|
|
10139
|
-
const result = await __classPrivateFieldGet$
|
|
10724
|
+
const result = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.importData', { type: "perspective", filePath });
|
|
10140
10725
|
return 'success' in result && result.success;
|
|
10141
10726
|
}
|
|
10142
10727
|
async multiUserEnabled() {
|
|
10143
|
-
return __classPrivateFieldGet$
|
|
10728
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.multiUserEnabled', {});
|
|
10144
10729
|
}
|
|
10145
10730
|
async setMultiUserEnabled(enabled) {
|
|
10146
|
-
return __classPrivateFieldGet$
|
|
10731
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.setMultiUserEnabled', { enabled });
|
|
10147
10732
|
}
|
|
10148
10733
|
async freeHostingEnabled() {
|
|
10149
|
-
return __classPrivateFieldGet$
|
|
10734
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.freeHostingEnabled', {});
|
|
10150
10735
|
}
|
|
10151
10736
|
async setFreeHostingEnabled(enabled) {
|
|
10152
|
-
return __classPrivateFieldGet$
|
|
10737
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setFreeHostingEnabled', { enabled });
|
|
10153
10738
|
}
|
|
10154
10739
|
async listUsers() {
|
|
10155
|
-
return __classPrivateFieldGet$
|
|
10740
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.list', {});
|
|
10156
10741
|
}
|
|
10157
10742
|
async userWalletAddress(email) {
|
|
10158
|
-
return __classPrivateFieldGet$
|
|
10743
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.wallet', { email });
|
|
10159
10744
|
}
|
|
10160
10745
|
async emailTestModeEnable() {
|
|
10161
|
-
return (await __classPrivateFieldGet$
|
|
10746
|
+
return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'enable' })) === true;
|
|
10162
10747
|
}
|
|
10163
10748
|
async emailTestModeDisable() {
|
|
10164
|
-
return (await __classPrivateFieldGet$
|
|
10749
|
+
return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'disable' })) === true;
|
|
10165
10750
|
}
|
|
10166
10751
|
async emailTestGetCode(email) {
|
|
10167
|
-
const code = await __classPrivateFieldGet$
|
|
10752
|
+
const code = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'get-code', email });
|
|
10168
10753
|
return typeof code === 'string' ? code : null;
|
|
10169
10754
|
}
|
|
10170
10755
|
async emailTestClearCodes() {
|
|
10171
|
-
return (await __classPrivateFieldGet$
|
|
10756
|
+
return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'clear-codes' })) === true;
|
|
10172
10757
|
}
|
|
10173
10758
|
async emailTestSetExpiry(email, verificationType, expiresAt) {
|
|
10174
|
-
return (await __classPrivateFieldGet$
|
|
10759
|
+
return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'set-expiry', email, verificationType, expiresAt })) === true;
|
|
10175
10760
|
}
|
|
10176
10761
|
// ---- Unyt / mHOT methods ----
|
|
10177
10762
|
async unytAgentKey() {
|
|
10178
|
-
return __classPrivateFieldGet$
|
|
10763
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytAgentKey', {});
|
|
10179
10764
|
}
|
|
10180
10765
|
async unytHotAgentPubkey() {
|
|
10181
|
-
return __classPrivateFieldGet$
|
|
10766
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytHotAgentPubkey', {});
|
|
10182
10767
|
}
|
|
10183
10768
|
async unytWalletBalance() {
|
|
10184
|
-
return __classPrivateFieldGet$
|
|
10769
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytWalletBalance', {});
|
|
10185
10770
|
}
|
|
10186
10771
|
async unytWalletHistory(page, perPage) {
|
|
10187
|
-
return __classPrivateFieldGet$
|
|
10772
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytWalletHistory', { page, perPage });
|
|
10188
10773
|
}
|
|
10189
10774
|
/** Installed and bundled DNA versions, and why the last install failed (`installError`). */
|
|
10190
10775
|
async unytVersionInfo() {
|
|
10191
|
-
return __classPrivateFieldGet$
|
|
10776
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytVersionInfo', {});
|
|
10192
10777
|
}
|
|
10193
10778
|
/** Stores the membrane proof (base64); the executor then installs the Unyt DNA in the
|
|
10194
10779
|
* background. Poll {@link unytVersionInfo} for the outcome. */
|
|
10195
10780
|
async setUnytMembraneProof(proof) {
|
|
10196
|
-
return __classPrivateFieldGet$
|
|
10781
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setUnytMembraneProof', { proof });
|
|
10197
10782
|
}
|
|
10198
10783
|
async unytReinstallDna() {
|
|
10199
|
-
return __classPrivateFieldGet$
|
|
10784
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytReinstallDna', {});
|
|
10200
10785
|
}
|
|
10201
10786
|
async unytSendHot(recipient, amount) {
|
|
10202
|
-
return __classPrivateFieldGet$
|
|
10787
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytSendHot', { recipient, amount });
|
|
10203
10788
|
}
|
|
10204
10789
|
async setUserCredits(email, amount) {
|
|
10205
|
-
return __classPrivateFieldGet$
|
|
10790
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.credits', { email, amount });
|
|
10206
10791
|
}
|
|
10207
10792
|
async setUserFreeAccess(email, enabled) {
|
|
10208
|
-
return __classPrivateFieldGet$
|
|
10793
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.freeAccess', { email, enabled });
|
|
10209
10794
|
}
|
|
10210
10795
|
async setHostRates(rates) {
|
|
10211
|
-
return __classPrivateFieldGet$
|
|
10796
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setHostRates', { rates });
|
|
10212
10797
|
}
|
|
10213
10798
|
async hostRates() {
|
|
10214
|
-
return __classPrivateFieldGet$
|
|
10799
|
+
return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.hostRates', {});
|
|
10215
10800
|
}
|
|
10216
10801
|
}
|
|
10217
10802
|
_RuntimeClient_apiClient = new WeakMap();
|
|
10218
10803
|
|
|
10219
|
-
var __classPrivateFieldSet$
|
|
10804
|
+
var __classPrivateFieldSet$4 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
10220
10805
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10221
10806
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10222
10807
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10223
10808
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
10224
10809
|
};
|
|
10225
|
-
var __classPrivateFieldGet$
|
|
10810
|
+
var __classPrivateFieldGet$4 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
10226
10811
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10227
10812
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10228
10813
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -10238,8 +10823,8 @@ class ExpressionClient {
|
|
|
10238
10823
|
_ExpressionClient_totalMemBytes.set(this, 0);
|
|
10239
10824
|
// L2: persistent cache (IndexedDB in browser, NullCache in Node)
|
|
10240
10825
|
_ExpressionClient_persistent.set(this, void 0);
|
|
10241
|
-
__classPrivateFieldSet$
|
|
10242
|
-
__classPrivateFieldSet$
|
|
10826
|
+
__classPrivateFieldSet$4(this, _ExpressionClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
10827
|
+
__classPrivateFieldSet$4(this, _ExpressionClient_persistent, createPersistentCache('ad4m-expression-cache', 'expressions'), "f");
|
|
10243
10828
|
}
|
|
10244
10829
|
async get(url, alwaysGet = false) {
|
|
10245
10830
|
// Existing literal fast-path
|
|
@@ -10256,55 +10841,55 @@ class ExpressionClient {
|
|
|
10256
10841
|
}
|
|
10257
10842
|
// L1: memory hit
|
|
10258
10843
|
if (!alwaysGet) {
|
|
10259
|
-
const memHit = __classPrivateFieldGet$
|
|
10844
|
+
const memHit = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(url);
|
|
10260
10845
|
if (memHit)
|
|
10261
10846
|
return memHit.data;
|
|
10262
10847
|
}
|
|
10263
10848
|
// Deduplicate in-flight requests
|
|
10264
10849
|
if (!alwaysGet) {
|
|
10265
|
-
const existing = __classPrivateFieldGet$
|
|
10850
|
+
const existing = __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").get(url);
|
|
10266
10851
|
if (existing)
|
|
10267
10852
|
return existing;
|
|
10268
10853
|
}
|
|
10269
10854
|
// L2 check + L3 network
|
|
10270
10855
|
const promise = (async () => {
|
|
10271
10856
|
if (!alwaysGet) {
|
|
10272
|
-
const persisted = await __classPrivateFieldGet$
|
|
10857
|
+
const persisted = await __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").get(url);
|
|
10273
10858
|
if (persisted) {
|
|
10274
|
-
__classPrivateFieldGet$
|
|
10859
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, persisted); // promote to L1
|
|
10275
10860
|
return persisted;
|
|
10276
10861
|
}
|
|
10277
10862
|
}
|
|
10278
10863
|
// L3: network fetch
|
|
10279
|
-
const result = await __classPrivateFieldGet$
|
|
10280
|
-
__classPrivateFieldGet$
|
|
10281
|
-
__classPrivateFieldGet$
|
|
10864
|
+
const result = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.get', { url });
|
|
10865
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, result);
|
|
10866
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").put(url, result); // fire-and-forget write to L2
|
|
10282
10867
|
return result;
|
|
10283
10868
|
})();
|
|
10284
|
-
__classPrivateFieldGet$
|
|
10869
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").set(url, promise);
|
|
10285
10870
|
try {
|
|
10286
10871
|
return await promise;
|
|
10287
10872
|
}
|
|
10288
10873
|
finally {
|
|
10289
|
-
__classPrivateFieldGet$
|
|
10874
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").delete(url);
|
|
10290
10875
|
}
|
|
10291
10876
|
}
|
|
10292
10877
|
async getMany(urls) {
|
|
10293
10878
|
// Check L1 first
|
|
10294
|
-
const results = urls.map(u => __classPrivateFieldGet$
|
|
10879
|
+
const results = urls.map(u => __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(u)?.data ?? null);
|
|
10295
10880
|
let uncachedIndices = results
|
|
10296
10881
|
.map((r, i) => r === null ? i : -1)
|
|
10297
10882
|
.filter(i => i >= 0);
|
|
10298
10883
|
if (uncachedIndices.length === 0)
|
|
10299
10884
|
return results;
|
|
10300
10885
|
// Check L2 for remaining misses
|
|
10301
|
-
const l2Results = await Promise.all(uncachedIndices.map(i => __classPrivateFieldGet$
|
|
10886
|
+
const l2Results = await Promise.all(uncachedIndices.map(i => __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").get(urls[i])));
|
|
10302
10887
|
const stillMissing = [];
|
|
10303
10888
|
for (let j = 0; j < uncachedIndices.length; j++) {
|
|
10304
10889
|
const idx = uncachedIndices[j];
|
|
10305
10890
|
if (l2Results[j]) {
|
|
10306
10891
|
results[idx] = l2Results[j];
|
|
10307
|
-
__classPrivateFieldGet$
|
|
10892
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, urls[idx], l2Results[j]); // promote to L1
|
|
10308
10893
|
}
|
|
10309
10894
|
else {
|
|
10310
10895
|
stillMissing.push(idx);
|
|
@@ -10314,13 +10899,13 @@ class ExpressionClient {
|
|
|
10314
10899
|
return results;
|
|
10315
10900
|
// L3: fetch only truly uncached URLs
|
|
10316
10901
|
const uncachedUrls = stillMissing.map(i => urls[i]);
|
|
10317
|
-
const fetched = await __classPrivateFieldGet$
|
|
10902
|
+
const fetched = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.getMany', { urls: uncachedUrls });
|
|
10318
10903
|
for (let i = 0; i < stillMissing.length; i++) {
|
|
10319
10904
|
const idx = stillMissing[i];
|
|
10320
10905
|
results[idx] = fetched[i];
|
|
10321
10906
|
if (fetched[i]) {
|
|
10322
|
-
__classPrivateFieldGet$
|
|
10323
|
-
__classPrivateFieldGet$
|
|
10907
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, uncachedUrls[i], fetched[i]);
|
|
10908
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").put(uncachedUrls[i], fetched[i]); // fire-and-forget
|
|
10324
10909
|
}
|
|
10325
10910
|
}
|
|
10326
10911
|
return results;
|
|
@@ -10329,44 +10914,44 @@ class ExpressionClient {
|
|
|
10329
10914
|
* Clear both L1 (memory) and L2 (persistent) expression caches.
|
|
10330
10915
|
*/
|
|
10331
10916
|
clearCache() {
|
|
10332
|
-
__classPrivateFieldGet$
|
|
10333
|
-
__classPrivateFieldGet$
|
|
10334
|
-
__classPrivateFieldSet$
|
|
10335
|
-
__classPrivateFieldGet$
|
|
10917
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").clear();
|
|
10918
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").clear();
|
|
10919
|
+
__classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, 0, "f");
|
|
10920
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").clear(); // fire-and-forget
|
|
10336
10921
|
}
|
|
10337
10922
|
async getRaw(url) {
|
|
10338
|
-
return __classPrivateFieldGet$
|
|
10923
|
+
return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.getRaw', { url });
|
|
10339
10924
|
}
|
|
10340
10925
|
async create(content, languageAddress) {
|
|
10341
10926
|
const serialized = JSON.stringify(content);
|
|
10342
|
-
return __classPrivateFieldGet$
|
|
10927
|
+
return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.create', { content: serialized, languageAddress });
|
|
10343
10928
|
}
|
|
10344
10929
|
async interactions(url) {
|
|
10345
|
-
return __classPrivateFieldGet$
|
|
10930
|
+
return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.interactions', { url });
|
|
10346
10931
|
}
|
|
10347
10932
|
async interact(url, interactionCall) {
|
|
10348
|
-
const result = await __classPrivateFieldGet$
|
|
10933
|
+
const result = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.interact', { url, interactionCall });
|
|
10349
10934
|
// Interactions can mutate the expression — invalidate cache so next get() fetches fresh
|
|
10350
|
-
__classPrivateFieldGet$
|
|
10351
|
-
__classPrivateFieldGet$
|
|
10352
|
-
__classPrivateFieldGet$
|
|
10935
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").delete(url);
|
|
10936
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").delete(url);
|
|
10937
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").delete(url); // fire-and-forget
|
|
10353
10938
|
return result;
|
|
10354
10939
|
}
|
|
10355
10940
|
}
|
|
10356
10941
|
_ExpressionClient_apiClient = new WeakMap(), _ExpressionClient_memCache = new WeakMap(), _ExpressionClient_inflight = new WeakMap(), _ExpressionClient_totalMemBytes = new WeakMap(), _ExpressionClient_persistent = new WeakMap(), _ExpressionClient_instances = new WeakSet(), _ExpressionClient_memCacheResult = function _ExpressionClient_memCacheResult(url, data) {
|
|
10357
10942
|
const size = JSON.stringify(data).length;
|
|
10358
10943
|
// Evict oldest entries if we'd exceed limits
|
|
10359
|
-
while (__classPrivateFieldGet$
|
|
10360
|
-
__classPrivateFieldGet$
|
|
10361
|
-
const oldest = __classPrivateFieldGet$
|
|
10944
|
+
while (__classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").size >= ExpressionClient.MAX_MEM_ENTRIES ||
|
|
10945
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") + size > ExpressionClient.MAX_MEM_BYTES) {
|
|
10946
|
+
const oldest = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").keys().next().value;
|
|
10362
10947
|
if (!oldest)
|
|
10363
10948
|
break;
|
|
10364
|
-
const entry = __classPrivateFieldGet$
|
|
10365
|
-
__classPrivateFieldSet$
|
|
10366
|
-
__classPrivateFieldGet$
|
|
10949
|
+
const entry = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(oldest);
|
|
10950
|
+
__classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") - entry.size, "f");
|
|
10951
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").delete(oldest);
|
|
10367
10952
|
}
|
|
10368
|
-
__classPrivateFieldGet$
|
|
10369
|
-
__classPrivateFieldSet$
|
|
10953
|
+
__classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").set(url, { data, size });
|
|
10954
|
+
__classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") + size, "f");
|
|
10370
10955
|
};
|
|
10371
10956
|
/** Maximum number of entries in the L1 memory cache. */
|
|
10372
10957
|
ExpressionClient.MAX_MEM_ENTRIES = 200;
|
|
@@ -17442,13 +18027,13 @@ class AIModelLoadingStatus {
|
|
|
17442
18027
|
}
|
|
17443
18028
|
}
|
|
17444
18029
|
|
|
17445
|
-
var __classPrivateFieldSet$
|
|
18030
|
+
var __classPrivateFieldSet$3 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
17446
18031
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
17447
18032
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
17448
18033
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
17449
18034
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17450
18035
|
};
|
|
17451
|
-
var __classPrivateFieldGet$
|
|
18036
|
+
var __classPrivateFieldGet$3 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
17452
18037
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
17453
18038
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
17454
18039
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -17459,14 +18044,14 @@ class AIClient {
|
|
|
17459
18044
|
_AIClient_apiClient.set(this, void 0);
|
|
17460
18045
|
_AIClient_transcriptionUnsubscribers.set(this, new Map());
|
|
17461
18046
|
_AIClient_pendingStreamIds.set(this, new Set());
|
|
17462
|
-
__classPrivateFieldSet$
|
|
18047
|
+
__classPrivateFieldSet$3(this, _AIClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
17463
18048
|
}
|
|
17464
18049
|
/** The executor names the model type `type`. */
|
|
17465
18050
|
serializeModelInput({ modelType, ...model }) {
|
|
17466
18051
|
return { ...model, type: modelType };
|
|
17467
18052
|
}
|
|
17468
18053
|
async getModels() {
|
|
17469
|
-
return __classPrivateFieldGet$
|
|
18054
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.models', {});
|
|
17470
18055
|
}
|
|
17471
18056
|
/**
|
|
17472
18057
|
* Ask a remote endpoint which models it serves, before adding one.
|
|
@@ -17481,35 +18066,35 @@ class AIClient {
|
|
|
17481
18066
|
* that is not Anthropic speaks.
|
|
17482
18067
|
*/
|
|
17483
18068
|
async discoverModels(baseUrl, apiKey, apiType) {
|
|
17484
|
-
return __classPrivateFieldGet$
|
|
18069
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.discoverModels', { baseUrl, apiKey, apiType });
|
|
17485
18070
|
}
|
|
17486
18071
|
async addModel(model, options) {
|
|
17487
|
-
return __classPrivateFieldGet$
|
|
18072
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.addModel', { model: this.serializeModelInput(model) }, options);
|
|
17488
18073
|
}
|
|
17489
18074
|
async updateModel(modelId, model) {
|
|
17490
|
-
return __classPrivateFieldGet$
|
|
18075
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.updateModel', { id: modelId, model: this.serializeModelInput(model) });
|
|
17491
18076
|
}
|
|
17492
18077
|
async removeModel(modelId) {
|
|
17493
|
-
return __classPrivateFieldGet$
|
|
18078
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.removeModel', { id: modelId });
|
|
17494
18079
|
}
|
|
17495
18080
|
async setDefaultModel(modelType, modelId) {
|
|
17496
|
-
return __classPrivateFieldGet$
|
|
18081
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.setDefaultModel', { id: modelId, modelType });
|
|
17497
18082
|
}
|
|
17498
18083
|
async getDefaultModel(modelType) {
|
|
17499
|
-
return __classPrivateFieldGet$
|
|
18084
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.getDefaultModel', { modelType });
|
|
17500
18085
|
}
|
|
17501
18086
|
async tasks() {
|
|
17502
|
-
return __classPrivateFieldGet$
|
|
18087
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.tasks', {});
|
|
17503
18088
|
}
|
|
17504
18089
|
async addTask(name, modelId, systemPrompt, promptExamples, metaData) {
|
|
17505
18090
|
const task = new AITaskInput(name, modelId, systemPrompt, promptExamples, metaData);
|
|
17506
|
-
return __classPrivateFieldGet$
|
|
18091
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.addTask', { task });
|
|
17507
18092
|
}
|
|
17508
18093
|
async removeTask(taskId) {
|
|
17509
|
-
return __classPrivateFieldGet$
|
|
18094
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.removeTask', { id: taskId });
|
|
17510
18095
|
}
|
|
17511
18096
|
async updateTask(taskId, task) {
|
|
17512
|
-
return __classPrivateFieldGet$
|
|
18097
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.updateTask', {
|
|
17513
18098
|
task: {
|
|
17514
18099
|
taskId,
|
|
17515
18100
|
name: task.name,
|
|
@@ -17523,13 +18108,13 @@ class AIClient {
|
|
|
17523
18108
|
});
|
|
17524
18109
|
}
|
|
17525
18110
|
async modelLoadingStatus(model) {
|
|
17526
|
-
return __classPrivateFieldGet$
|
|
18111
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.modelLoadingStatus', { model });
|
|
17527
18112
|
}
|
|
17528
18113
|
async prompt(taskId, prompt, options) {
|
|
17529
|
-
return __classPrivateFieldGet$
|
|
18114
|
+
return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.prompt', { taskId, prompt }, options);
|
|
17530
18115
|
}
|
|
17531
18116
|
async embed(modelId, text, options) {
|
|
17532
|
-
const aiEmbed = await __classPrivateFieldGet$
|
|
18117
|
+
const aiEmbed = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.embed', { modelId, text }, options);
|
|
17533
18118
|
const compressed = base64Js.toByteArray(aiEmbed);
|
|
17534
18119
|
// NB: pako v1 accepts `{ to: 'string' }`, pako v2 wants `{ toText: true }`,
|
|
17535
18120
|
// pako v3 also drops that overload from its bundled types. Call the
|
|
@@ -17540,22 +18125,22 @@ class AIClient {
|
|
|
17540
18125
|
return decompressed;
|
|
17541
18126
|
}
|
|
17542
18127
|
async openTranscriptionStream(modelId, streamCallback, params) {
|
|
17543
|
-
const streamId = await __classPrivateFieldGet$
|
|
17544
|
-
const unsub = __classPrivateFieldGet$
|
|
18128
|
+
const streamId = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.transcriptionOpen', { modelId, params });
|
|
18129
|
+
const unsub = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").on('transcription-text', (event) => {
|
|
17545
18130
|
if (event.streamId === streamId && event.text)
|
|
17546
18131
|
streamCallback(event.text);
|
|
17547
18132
|
});
|
|
17548
|
-
__classPrivateFieldGet$
|
|
18133
|
+
__classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").set(streamId, unsub);
|
|
17549
18134
|
return streamId;
|
|
17550
18135
|
}
|
|
17551
18136
|
async closeTranscriptionStream(streamId) {
|
|
17552
|
-
__classPrivateFieldGet$
|
|
18137
|
+
__classPrivateFieldGet$3(this, _AIClient_pendingStreamIds, "f").delete(streamId);
|
|
17553
18138
|
try {
|
|
17554
|
-
await __classPrivateFieldGet$
|
|
18139
|
+
await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.transcriptionClose', { streamId });
|
|
17555
18140
|
}
|
|
17556
18141
|
finally {
|
|
17557
|
-
__classPrivateFieldGet$
|
|
17558
|
-
__classPrivateFieldGet$
|
|
18142
|
+
__classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").get(streamId)?.();
|
|
18143
|
+
__classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").delete(streamId);
|
|
17559
18144
|
}
|
|
17560
18145
|
}
|
|
17561
18146
|
/**
|
|
@@ -17577,12 +18162,12 @@ class AIClient {
|
|
|
17577
18162
|
if (ids.length === 0 || typedAudio.length === 0) {
|
|
17578
18163
|
return;
|
|
17579
18164
|
}
|
|
17580
|
-
const baseUrl = __classPrivateFieldGet$
|
|
17581
|
-
const token = __classPrivateFieldGet$
|
|
18165
|
+
const baseUrl = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").getBaseUrl();
|
|
18166
|
+
const token = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").getToken();
|
|
17582
18167
|
// Use slice to get only the relevant portion of the underlying ArrayBuffer
|
|
17583
18168
|
// (Float32Array may be a view over a larger buffer)
|
|
17584
18169
|
const bodyBuffer = typedAudio.buffer.slice(typedAudio.byteOffset, typedAudio.byteOffset + typedAudio.byteLength);
|
|
17585
|
-
const response = await __classPrivateFieldGet$
|
|
18170
|
+
const response = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").doFetch(`${baseUrl}/api/v1/ai/transcription/feed`, {
|
|
17586
18171
|
method: 'POST',
|
|
17587
18172
|
headers: {
|
|
17588
18173
|
'Content-Type': 'application/octet-stream',
|
|
@@ -17599,6 +18184,103 @@ class AIClient {
|
|
|
17599
18184
|
}
|
|
17600
18185
|
_AIClient_apiClient = new WeakMap(), _AIClient_transcriptionUnsubscribers = new WeakMap(), _AIClient_pendingStreamIds = new WeakMap();
|
|
17601
18186
|
|
|
18187
|
+
var __classPrivateFieldSet$2 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
18188
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
18189
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
18190
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
18191
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
18192
|
+
};
|
|
18193
|
+
var __classPrivateFieldGet$2 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18194
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
18195
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
18196
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
18197
|
+
};
|
|
18198
|
+
var _IdentityClient_apiClient;
|
|
18199
|
+
/**
|
|
18200
|
+
* The executor's `did:scid:coasys:1` calls.
|
|
18201
|
+
*
|
|
18202
|
+
* The executor holds device keys only. Master keys and the 12 words stay with the app
|
|
18203
|
+
* (`ad4m-identity-client`), which signs the events and offers these calls pass on.
|
|
18204
|
+
* `agent.status()` and `agent.me()` carry `identity`, the `did:scid` the agent speaks for.
|
|
18205
|
+
*/
|
|
18206
|
+
class IdentityClient {
|
|
18207
|
+
constructor(baseUrl, token, sharedApiClient) {
|
|
18208
|
+
_IdentityClient_apiClient.set(this, void 0);
|
|
18209
|
+
__classPrivateFieldSet$2(this, _IdentityClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
18210
|
+
}
|
|
18211
|
+
/**
|
|
18212
|
+
* This agent's identity, device key, `enc` key and the cached head. `storeBehind` is set
|
|
18213
|
+
* (`{ since, seq }`) while the configured store answers the log behind the executor's cache,
|
|
18214
|
+
* and `null` once it catches up. `store` is the identity store this executor uses
|
|
18215
|
+
* (`{ url, trusted }`: its config's, else its network's) and whether it trusts a key for it;
|
|
18216
|
+
* `null` when its network has no store, so identities cannot be created or linked there.
|
|
18217
|
+
*/
|
|
18218
|
+
async status() {
|
|
18219
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.status", {});
|
|
18220
|
+
}
|
|
18221
|
+
/** A log through the executor's cache; `fresh` refreshes it from the store first. */
|
|
18222
|
+
async log(did, from, fresh) {
|
|
18223
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.log", { did, from, fresh });
|
|
18224
|
+
}
|
|
18225
|
+
/**
|
|
18226
|
+
* Resolves a `did:scid:coasys:1` DID URL (`?src=`, `?versionId=`, `#d1`) or a bare device
|
|
18227
|
+
* `did:key` to a W3C DID Core resolution result. The executor answers from its key-log
|
|
18228
|
+
* cache unless `fresh`, or the cache lacks the log or the asked version. A refusal comes
|
|
18229
|
+
* back as `didResolutionMetadata.error` (`invalidDid`, `invalidDidUrl`, `notFound`, …), not
|
|
18230
|
+
* as a thrown error. With a fragment, `didDocument` is null and `verificationMethod` holds
|
|
18231
|
+
* that method. For a `did:key`, `didResolutionMetadata["coasys:keyId"]` and
|
|
18232
|
+
* `["coasys:keyValid"]` say which key of the person's log it is and whether it is valid.
|
|
18233
|
+
*/
|
|
18234
|
+
async resolve(didUrl, options = {}) {
|
|
18235
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.resolve", {
|
|
18236
|
+
didUrl,
|
|
18237
|
+
fresh: options.fresh,
|
|
18238
|
+
accept: options.accept,
|
|
18239
|
+
});
|
|
18240
|
+
}
|
|
18241
|
+
/**
|
|
18242
|
+
* Drops this executor's cached copy of `did`'s log (its events, accepted head and recorded
|
|
18243
|
+
* forks); the next read refreshes from the configured store and takes the store's branch.
|
|
18244
|
+
* The way out of an `identity-fork`. The operator (admin credential) only.
|
|
18245
|
+
*/
|
|
18246
|
+
async resetLog(did) {
|
|
18247
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.resetLog", { did });
|
|
18248
|
+
}
|
|
18249
|
+
/**
|
|
18250
|
+
* Adds this agent's device-key proof to an `incept` that lists its key. For the main
|
|
18251
|
+
* agent the admin credential only; a user's session for its own agent.
|
|
18252
|
+
*/
|
|
18253
|
+
async cosignIncept(event) {
|
|
18254
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.cosignIncept", { event: event });
|
|
18255
|
+
}
|
|
18256
|
+
/**
|
|
18257
|
+
* Appends signed events through the agent language. For the main agent the admin
|
|
18258
|
+
* credential only; a user's session for its own agent.
|
|
18259
|
+
*/
|
|
18260
|
+
async publish(events) {
|
|
18261
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.publish", { events: events });
|
|
18262
|
+
}
|
|
18263
|
+
async openOffer(signedOffer) {
|
|
18264
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.openOffer", { signedOffer });
|
|
18265
|
+
}
|
|
18266
|
+
/** The identity's open and claimed offers, for a request signed by its current master key. */
|
|
18267
|
+
async offers(request, wait) {
|
|
18268
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.offers", { request, wait });
|
|
18269
|
+
}
|
|
18270
|
+
/** Claims an offer link for this executor (the operator only). */
|
|
18271
|
+
async claimOffer(offer, hint) {
|
|
18272
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.claimOffer", { offer, hint });
|
|
18273
|
+
}
|
|
18274
|
+
async joinStatus(offerId) {
|
|
18275
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.joinStatus", { offerId });
|
|
18276
|
+
}
|
|
18277
|
+
/** The identity's device keys, from its log. */
|
|
18278
|
+
async devices() {
|
|
18279
|
+
return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.devices", {});
|
|
18280
|
+
}
|
|
18281
|
+
}
|
|
18282
|
+
_IdentityClient_apiClient = new WeakMap();
|
|
18283
|
+
|
|
17602
18284
|
/**
|
|
17603
18285
|
* Shared type definitions for the Ad4mModel system.
|
|
17604
18286
|
*
|
|
@@ -18633,6 +19315,9 @@ function buildSPARQLWhereFilters(metadata, _allRelationsMetadata, where) {
|
|
|
18633
19315
|
* Allows building queries with a chainable interface and either
|
|
18634
19316
|
* running them once or subscribing to real-time updates.
|
|
18635
19317
|
*/
|
|
19318
|
+
/** What a subscription compares to skip a callback whose results equal the
|
|
19319
|
+
* last ones emitted (a resync or a reconnect re-open of an unchanged result). */
|
|
19320
|
+
const fingerprint = (value) => JSON.stringify(value, (_, v) => (typeof v === 'function' ? undefined : v));
|
|
18636
19321
|
/** Query builder for Ad4mModel queries.
|
|
18637
19322
|
* Allows building queries with a fluent interface and either running them once
|
|
18638
19323
|
* or subscribing to updates.
|
|
@@ -18687,6 +19372,10 @@ class ModelQueryBuilder {
|
|
|
18687
19372
|
}
|
|
18688
19373
|
return this.ctor.parseModelResult(this.perspective, raw, include, properties);
|
|
18689
19374
|
}
|
|
19375
|
+
/** Snapshot instances for dirty tracking, as `execute` does for its rows. */
|
|
19376
|
+
takeSnapshots(instances) {
|
|
19377
|
+
this.ctor.takeSnapshots(instances, this.queryParams.include);
|
|
19378
|
+
}
|
|
18690
19379
|
/** Ends the current subscription, if any, on the client and the executor. */
|
|
18691
19380
|
dispose() {
|
|
18692
19381
|
if (this.currentSubscription) {
|
|
@@ -19056,7 +19745,6 @@ class ModelQueryBuilder {
|
|
|
19056
19745
|
this.dispose();
|
|
19057
19746
|
const parseResults = (raw) => this.parse(raw);
|
|
19058
19747
|
// Suppress callbacks whose parsed results equal the last ones emitted.
|
|
19059
|
-
const fingerprint = (results) => JSON.stringify(results, (_, v) => (typeof v === 'function' ? undefined : v));
|
|
19060
19748
|
let lastFingerprint = null;
|
|
19061
19749
|
const { initial } = await this.live(this.queryParams, (raw) => {
|
|
19062
19750
|
try {
|
|
@@ -19207,73 +19895,46 @@ class ModelQueryBuilder {
|
|
|
19207
19895
|
*
|
|
19208
19896
|
*/
|
|
19209
19897
|
async paginateSubscribe(pageSize, pageNumber, callback) {
|
|
19210
|
-
// Clean up any existing subscription
|
|
19211
19898
|
this.dispose();
|
|
19212
|
-
// Subscribe to the
|
|
19213
|
-
//
|
|
19214
|
-
|
|
19215
|
-
|
|
19216
|
-
|
|
19217
|
-
//
|
|
19899
|
+
// Subscribe to the page itself. Since #1237 the executor re-runs a paged
|
|
19900
|
+
// subscription when a record outside the page starts or stops matching
|
|
19901
|
+
// (the `joins` and `scan` trigger rules), and a model result carries
|
|
19902
|
+
// `totalCount`, so a write outside the page still changes the result and
|
|
19903
|
+
// is pushed. Each page is built from the pushed rows: no second query, and
|
|
19904
|
+
// the executor hydrates one page per change rather than every match.
|
|
19905
|
+
// Pushes arrive in revision order, so the last callback is the latest
|
|
19906
|
+
// state (#1051). After dispose() the live query delivers nothing.
|
|
19218
19907
|
const paginatedQuery = {
|
|
19219
19908
|
...(this.queryParams || {}),
|
|
19220
19909
|
limit: pageSize,
|
|
19221
19910
|
offset: pageSize * (pageNumber - 1),
|
|
19222
19911
|
count: true,
|
|
19223
19912
|
};
|
|
19224
|
-
//
|
|
19225
|
-
//
|
|
19226
|
-
//
|
|
19227
|
-
|
|
19228
|
-
|
|
19229
|
-
|
|
19230
|
-
|
|
19231
|
-
|
|
19232
|
-
|
|
19233
|
-
|
|
19234
|
-
|
|
19235
|
-
let pending = false;
|
|
19236
|
-
const processResults = async () => {
|
|
19237
|
-
if (disposed)
|
|
19238
|
-
return;
|
|
19239
|
-
if (fetching) {
|
|
19240
|
-
pending = true;
|
|
19241
|
-
return;
|
|
19242
|
-
}
|
|
19243
|
-
fetching = true;
|
|
19913
|
+
// As subscribe(): a callback fires only when the rows or totalCount
|
|
19914
|
+
// differ from the last page emitted, not on a resync or a reconnect
|
|
19915
|
+
// re-open of an unchanged page.
|
|
19916
|
+
let lastFingerprint = null;
|
|
19917
|
+
const toPage = (raw) => {
|
|
19918
|
+
const results = this.parse(raw);
|
|
19919
|
+
const fp = fingerprint([results, raw?.totalCount]);
|
|
19920
|
+
this.takeSnapshots(results);
|
|
19921
|
+
return { page: { results, totalCount: raw?.totalCount, pageSize, pageNumber }, fp };
|
|
19922
|
+
};
|
|
19923
|
+
const { initial } = await this.live(paginatedQuery, (raw) => {
|
|
19244
19924
|
try {
|
|
19245
|
-
const {
|
|
19246
|
-
if (
|
|
19247
|
-
|
|
19925
|
+
const { page, fp } = toPage(raw);
|
|
19926
|
+
if (fp === lastFingerprint)
|
|
19927
|
+
return;
|
|
19928
|
+
lastFingerprint = fp;
|
|
19929
|
+
callback(page);
|
|
19248
19930
|
}
|
|
19249
|
-
|
|
19250
|
-
|
|
19251
|
-
if (pending) {
|
|
19252
|
-
pending = false;
|
|
19253
|
-
// Detached from the caller's promise: needs its own handler, or a
|
|
19254
|
-
// rejection here is unhandled.
|
|
19255
|
-
processResults().catch(e => console.error('Paginate subscription error:', e));
|
|
19256
|
-
}
|
|
19931
|
+
catch (e) {
|
|
19932
|
+
console.error('Paginate subscription error:', e);
|
|
19257
19933
|
}
|
|
19258
|
-
};
|
|
19259
|
-
const { live } = await this.live(subscriptionParams, () => {
|
|
19260
|
-
processResults().catch(e => console.error('Paginate subscription error:', e));
|
|
19261
19934
|
});
|
|
19262
|
-
|
|
19263
|
-
|
|
19264
|
-
|
|
19265
|
-
disposed = true;
|
|
19266
|
-
live.dispose();
|
|
19267
|
-
},
|
|
19268
|
-
};
|
|
19269
|
-
}
|
|
19270
|
-
else {
|
|
19271
|
-
// Disposed, or overtaken by a later subscribe, while opening: deliver nothing.
|
|
19272
|
-
disposed = true;
|
|
19273
|
-
}
|
|
19274
|
-
// Initial fetch (single call with count: true)
|
|
19275
|
-
const { results, totalCount } = await this.execute(paginatedQuery);
|
|
19276
|
-
return { results, totalCount, pageSize, pageNumber };
|
|
19935
|
+
const { page, fp } = toPage(initial);
|
|
19936
|
+
lastFingerprint = fp;
|
|
19937
|
+
return page;
|
|
19277
19938
|
}
|
|
19278
19939
|
/**
|
|
19279
19940
|
* Subscribes to paginated results updates using SPARQL.
|
|
@@ -19972,6 +20633,10 @@ class Ad4mModel {
|
|
|
19972
20633
|
*/
|
|
19973
20634
|
constructor(perspective, baseExpression) {
|
|
19974
20635
|
this._snapshot = null;
|
|
20636
|
+
/** True when the constructor minted the id: no record can hold links yet. */
|
|
20637
|
+
this._idMinted = false;
|
|
20638
|
+
/** Predicates this instance has already written relation links under (`add*`/`set*`), so they may hold links. */
|
|
20639
|
+
this._relationsWritten = new Set();
|
|
19975
20640
|
// Use a dedicated `ad4m://obj/<id>` scheme for auto-generated
|
|
19976
20641
|
// baseExpressions instead of `Literal.from(...).toUrl()`'s
|
|
19977
20642
|
// `literal:string:<id>`. After typed-literal storage lands, the storage
|
|
@@ -19982,6 +20647,7 @@ class Ad4mModel {
|
|
|
19982
20647
|
// IRIs, so relation links like `<post> --has_comment--> <comment-id>`
|
|
19983
20648
|
// round-trip correctly through the SPARQL store.
|
|
19984
20649
|
this._baseExpression = baseExpression ? baseExpression : `ad4m://obj/${makeRandomId(24)}`;
|
|
20650
|
+
this._idMinted = !baseExpression;
|
|
19985
20651
|
this._perspective = perspective;
|
|
19986
20652
|
}
|
|
19987
20653
|
/**
|
|
@@ -20435,6 +21101,20 @@ class Ad4mModel {
|
|
|
20435
21101
|
return [];
|
|
20436
21102
|
return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
|
|
20437
21103
|
}
|
|
21104
|
+
/**
|
|
21105
|
+
* Snapshot freshly built instances for dirty tracking, with the relations
|
|
21106
|
+
* `include` loaded (its `$`-prefixed projection keys are not relations).
|
|
21107
|
+
* Used by every query path, and by ModelQueryBuilder for pushed results.
|
|
21108
|
+
* @internal
|
|
21109
|
+
*/
|
|
21110
|
+
static takeSnapshots(instances, include) {
|
|
21111
|
+
const relations = include
|
|
21112
|
+
? Object.fromEntries(Object.entries(include).filter(([k]) => !k.startsWith('$')))
|
|
21113
|
+
: undefined;
|
|
21114
|
+
const snapshot = relations && Object.keys(relations).length > 0 ? relations : undefined;
|
|
21115
|
+
for (const inst of instances)
|
|
21116
|
+
inst.takeSnapshot?.(snapshot);
|
|
21117
|
+
}
|
|
20438
21118
|
// ── One query over several classes (#1238) ────────────────────────────────
|
|
20439
21119
|
/**
|
|
20440
21120
|
* Build the wire parameters for one query over several classes.
|
|
@@ -20536,12 +21216,7 @@ class Ad4mModel {
|
|
|
20536
21216
|
const { classNames, queryJson } = Ad4mModel.prepareUnionQueryParams(classes, query);
|
|
20537
21217
|
const result = await perspective.modelQuery(classNames, queryJson, options);
|
|
20538
21218
|
const results = Ad4mModel.parseUnionResult(classes, perspective, result, query.include, query.properties);
|
|
20539
|
-
|
|
20540
|
-
? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith('$')))
|
|
20541
|
-
: undefined;
|
|
20542
|
-
for (const inst of results) {
|
|
20543
|
-
inst.takeSnapshot?.(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : undefined);
|
|
20544
|
-
}
|
|
21219
|
+
Ad4mModel.takeSnapshots(results, query.include);
|
|
20545
21220
|
return { results, totalCount: result.totalCount };
|
|
20546
21221
|
}
|
|
20547
21222
|
/**
|
|
@@ -20607,13 +21282,7 @@ class Ad4mModel {
|
|
|
20607
21282
|
const instances = result.instances.map((json) => {
|
|
20608
21283
|
return jsonToModelInstance(this, perspective, json, query.include, query.properties);
|
|
20609
21284
|
});
|
|
20610
|
-
|
|
20611
|
-
const snapshotRelations = query.include
|
|
20612
|
-
? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith('$')))
|
|
20613
|
-
: undefined;
|
|
20614
|
-
for (const inst of instances) {
|
|
20615
|
-
inst.takeSnapshot(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : undefined);
|
|
20616
|
-
}
|
|
21285
|
+
Ad4mModel.takeSnapshots(instances, query.include);
|
|
20617
21286
|
return {
|
|
20618
21287
|
results: instances,
|
|
20619
21288
|
totalCount: result.totalCount,
|
|
@@ -20797,6 +21466,7 @@ class Ad4mModel {
|
|
|
20797
21466
|
console.warn(`Relation "${key}" has no metadata, skipping`);
|
|
20798
21467
|
return;
|
|
20799
21468
|
}
|
|
21469
|
+
this._relationsWritten.add(metadata.predicate);
|
|
20800
21470
|
const abstractName = this.abstractName();
|
|
20801
21471
|
if (abstractName) {
|
|
20802
21472
|
if (value != null)
|
|
@@ -20820,6 +21490,7 @@ class Ad4mModel {
|
|
|
20820
21490
|
console.warn(`Relation "${key}" has no metadata, skipping`);
|
|
20821
21491
|
return;
|
|
20822
21492
|
}
|
|
21493
|
+
this._relationsWritten.add(metadata.predicate);
|
|
20823
21494
|
const abstractName = this.abstractName();
|
|
20824
21495
|
if (abstractName) {
|
|
20825
21496
|
if (value != null)
|
|
@@ -21068,7 +21739,11 @@ class Ad4mModel {
|
|
|
21068
21739
|
}
|
|
21069
21740
|
}
|
|
21070
21741
|
else if (Array.isArray(value)) {
|
|
21071
|
-
// Handle all arrays as relations, including empty ones (which clears the relation)
|
|
21742
|
+
// Handle all arrays as relations, including empty ones (which clears the relation).
|
|
21743
|
+
// A record being created under an id minted here has no links to
|
|
21744
|
+
// clear, so an empty relation there costs a round trip and writes nothing.
|
|
21745
|
+
if (value.length === 0 && !this._snapshot && this._idMinted && !this._relationsWritten.has(this.getRelationOptions(key)?.predicate ?? key))
|
|
21746
|
+
continue;
|
|
21072
21747
|
await this.setRelationValues(key, value, batchId);
|
|
21073
21748
|
}
|
|
21074
21749
|
else if (value !== undefined && value !== null && value !== "") {
|
|
@@ -21672,7 +22347,7 @@ var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) |
|
|
|
21672
22347
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
21673
22348
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21674
22349
|
};
|
|
21675
|
-
var _Ad4mClient_baseUrl, _Ad4mClient_token, _Ad4mClient_apiClient, _Ad4mClient_agentClient, _Ad4mClient_expressionClient, _Ad4mClient_languageClient, _Ad4mClient_neighbourhoodClient, _Ad4mClient_perspectiveClient, _Ad4mClient_runtimeClient, _Ad4mClient_aiClient;
|
|
22350
|
+
var _Ad4mClient_baseUrl, _Ad4mClient_token, _Ad4mClient_apiClient, _Ad4mClient_agentClient, _Ad4mClient_expressionClient, _Ad4mClient_languageClient, _Ad4mClient_neighbourhoodClient, _Ad4mClient_perspectiveClient, _Ad4mClient_runtimeClient, _Ad4mClient_aiClient, _Ad4mClient_identityClient;
|
|
21676
22351
|
/**
|
|
21677
22352
|
* Client for the Ad4m interface wrapping WebSocket RPC calls
|
|
21678
22353
|
* for convenient use in user facing code.
|
|
@@ -21696,6 +22371,7 @@ class Ad4mClient {
|
|
|
21696
22371
|
_Ad4mClient_perspectiveClient.set(this, void 0);
|
|
21697
22372
|
_Ad4mClient_runtimeClient.set(this, void 0);
|
|
21698
22373
|
_Ad4mClient_aiClient.set(this, void 0);
|
|
22374
|
+
_Ad4mClient_identityClient.set(this, void 0);
|
|
21699
22375
|
__classPrivateFieldSet$1(this, _Ad4mClient_baseUrl, baseUrl, "f");
|
|
21700
22376
|
__classPrivateFieldSet$1(this, _Ad4mClient_token, token, "f");
|
|
21701
22377
|
__classPrivateFieldSet$1(this, _Ad4mClient_apiClient, new ApiClient(baseUrl, token, options?.webSocketImpl, options?.fetchImpl), "f");
|
|
@@ -21709,6 +22385,7 @@ class Ad4mClient {
|
|
|
21709
22385
|
__classPrivateFieldGet$1(this, _Ad4mClient_perspectiveClient, "f").setNeighbourhoodClient(__classPrivateFieldGet$1(this, _Ad4mClient_neighbourhoodClient, "f"));
|
|
21710
22386
|
__classPrivateFieldGet$1(this, _Ad4mClient_perspectiveClient, "f").setAIClient(__classPrivateFieldGet$1(this, _Ad4mClient_aiClient, "f"));
|
|
21711
22387
|
__classPrivateFieldSet$1(this, _Ad4mClient_runtimeClient, new RuntimeClient(baseUrl, token, __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f")), "f");
|
|
22388
|
+
__classPrivateFieldSet$1(this, _Ad4mClient_identityClient, new IdentityClient(baseUrl, token, __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f")), "f");
|
|
21712
22389
|
// Register with AD4M DevTools if the bridge is installed (e.g. browser extension)
|
|
21713
22390
|
try {
|
|
21714
22391
|
const dt = globalThis.__AD4M_DEVTOOLS__;
|
|
@@ -21740,6 +22417,10 @@ class Ad4mClient {
|
|
|
21740
22417
|
get ai() {
|
|
21741
22418
|
return __classPrivateFieldGet$1(this, _Ad4mClient_aiClient, "f");
|
|
21742
22419
|
}
|
|
22420
|
+
/** The executor's identity calls (`did:scid:coasys:1`). */
|
|
22421
|
+
get identity() {
|
|
22422
|
+
return __classPrivateFieldGet$1(this, _Ad4mClient_identityClient, "f");
|
|
22423
|
+
}
|
|
21743
22424
|
/**
|
|
21744
22425
|
* Call `handler` with every `type` event, or only those about
|
|
21745
22426
|
* `filter.perspective`. The payload is typed by the executor's event
|
|
@@ -21758,13 +22439,21 @@ class Ad4mClient {
|
|
|
21758
22439
|
onAuthFailed(callback) {
|
|
21759
22440
|
return __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").onAuthFailed(callback);
|
|
21760
22441
|
}
|
|
22442
|
+
/**
|
|
22443
|
+
* Reconnect now if the connection to the executor dropped and the client is
|
|
22444
|
+
* waiting out its backoff: for a host that knows the executor is back (it
|
|
22445
|
+
* restarted it, or the device woke). A no-op while connected or connecting.
|
|
22446
|
+
*/
|
|
22447
|
+
reconnectNow() {
|
|
22448
|
+
__classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").reconnectNow();
|
|
22449
|
+
}
|
|
21761
22450
|
/** Close all event connections and clear in-memory caches */
|
|
21762
22451
|
close() {
|
|
21763
22452
|
__classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").clearByDidCache();
|
|
21764
22453
|
__classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").closeAll();
|
|
21765
22454
|
}
|
|
21766
22455
|
}
|
|
21767
|
-
_Ad4mClient_baseUrl = new WeakMap(), _Ad4mClient_token = new WeakMap(), _Ad4mClient_apiClient = new WeakMap(), _Ad4mClient_agentClient = new WeakMap(), _Ad4mClient_expressionClient = new WeakMap(), _Ad4mClient_languageClient = new WeakMap(), _Ad4mClient_neighbourhoodClient = new WeakMap(), _Ad4mClient_perspectiveClient = new WeakMap(), _Ad4mClient_runtimeClient = new WeakMap(), _Ad4mClient_aiClient = new WeakMap();
|
|
22456
|
+
_Ad4mClient_baseUrl = new WeakMap(), _Ad4mClient_token = new WeakMap(), _Ad4mClient_apiClient = new WeakMap(), _Ad4mClient_agentClient = new WeakMap(), _Ad4mClient_expressionClient = new WeakMap(), _Ad4mClient_languageClient = new WeakMap(), _Ad4mClient_neighbourhoodClient = new WeakMap(), _Ad4mClient_perspectiveClient = new WeakMap(), _Ad4mClient_runtimeClient = new WeakMap(), _Ad4mClient_aiClient = new WeakMap(), _Ad4mClient_identityClient = new WeakMap();
|
|
21768
22457
|
|
|
21769
22458
|
exports.ExceptionType = void 0;
|
|
21770
22459
|
(function (ExceptionType) {
|
|
@@ -22720,10 +23409,12 @@ class FlowInstance {
|
|
|
22720
23409
|
// synthetic hydration field and would be silently shadowed on read).
|
|
22721
23410
|
// No explicit start-time field: Ad4mModel synthesises `createdAt` on
|
|
22722
23411
|
// hydration from the earliest link timestamp on the instance's URI.
|
|
22723
|
-
// Convention: `SHACLFlow.states` is stored sorted ascending by `value
|
|
22724
|
-
// (enforced by `fromLinks
|
|
22725
|
-
//
|
|
22726
|
-
//
|
|
23412
|
+
// Convention: `SHACLFlow.states` is stored sorted ascending by `value`,
|
|
23413
|
+
// ties broken by state name (enforced by `fromLinks`, same key as
|
|
23414
|
+
// rust-executor — #1202), so `states[0]` is the initial state. A flow
|
|
23415
|
+
// author who wants a specific state as the entry point must give it
|
|
23416
|
+
// the lowest `value` in the set, and not share that value with another
|
|
23417
|
+
// state unless the name order is the intended one.
|
|
22727
23418
|
//
|
|
22728
23419
|
// A run already on this subject for this flow is the one to return:
|
|
22729
23420
|
// minting another would leave two runs, each with its own state, and
|
|
@@ -23372,6 +24063,17 @@ class WakerSubscriptionManager {
|
|
|
23372
24063
|
/** Subscriptions the executor rejected, waiting to be re-attempted. */
|
|
23373
24064
|
this.pendingSubscriptions = new Map();
|
|
23374
24065
|
this.retryTimer = null;
|
|
24066
|
+
/** Re-attempt rounds in a row that left something pending, for the backoff. */
|
|
24067
|
+
this.retryRounds = 0;
|
|
24068
|
+
/**
|
|
24069
|
+
* Subscriptions that were active until one of their live queries lost its
|
|
24070
|
+
* executor subscription (a reconnect, a failed resync) and failed to open it
|
|
24071
|
+
* again, with the proxies still re-opening. The query retries on its own,
|
|
24072
|
+
* with backoff, so the manager does not subscribe them again; it reports
|
|
24073
|
+
* them as pending instead of active until every proxy is open again, and
|
|
24074
|
+
* keeps persisting them so a restart restores them (#1595).
|
|
24075
|
+
*/
|
|
24076
|
+
this.reopening = new Map();
|
|
23375
24077
|
/**
|
|
23376
24078
|
* Cancellation tokens for in-flight `subscribe()` calls.
|
|
23377
24079
|
*
|
|
@@ -23411,6 +24113,7 @@ class WakerSubscriptionManager {
|
|
|
23411
24113
|
this.QuerySubscriptionProxyCtor = options.QuerySubscriptionProxy ?? null;
|
|
23412
24114
|
this.previousSeenMessages = options.previousSeenMessages ?? {};
|
|
23413
24115
|
this.retryPendingMs = options.retryPendingMs ?? 30000;
|
|
24116
|
+
this.maxRetryPendingMs = Math.max(this.retryPendingMs, options.maxRetryPendingMs ?? 300000);
|
|
23414
24117
|
this.subscribeTimeoutMs = options.subscribeTimeoutMs ?? 15000;
|
|
23415
24118
|
this.retryWakeMs = options.retryWakeMs ?? 5000;
|
|
23416
24119
|
}
|
|
@@ -23429,8 +24132,9 @@ class WakerSubscriptionManager {
|
|
|
23429
24132
|
* If a subscription with the same id already exists, it is disposed first.
|
|
23430
24133
|
*/
|
|
23431
24134
|
async subscribe(sub) {
|
|
23432
|
-
// Dispose existing subscription with same id if any
|
|
23433
|
-
|
|
24135
|
+
// Dispose existing subscription with same id if any. Not `dispose()`: a
|
|
24136
|
+
// re-attempt must not start the backoff over.
|
|
24137
|
+
this.release(sub.id, false);
|
|
23434
24138
|
const token = this.beginAttempt(sub.id);
|
|
23435
24139
|
if (!this.QuerySubscriptionProxyCtor) {
|
|
23436
24140
|
throw new Error("WakerSubscriptionManager: QuerySubscriptionProxy must be provided via constructor options");
|
|
@@ -23456,10 +24160,13 @@ class WakerSubscriptionManager {
|
|
|
23456
24160
|
? new QuerySubscriptionProxy(sub.perspective, sub.mentionQuery, this.perspectiveClient, sub.mentionClass)
|
|
23457
24161
|
: undefined;
|
|
23458
24162
|
const proxies = mentionProxy ? [proxy, mentionProxy] : [proxy];
|
|
24163
|
+
// `cancelOpening`: a handshake given up on must not keep the executor
|
|
24164
|
+
// computing a first result nobody reads; abandoned ones piled up into
|
|
24165
|
+
// hundreds of busy executor threads on staging (#1595).
|
|
23459
24166
|
const disposeProxies = () => {
|
|
23460
24167
|
for (const p of proxies) {
|
|
23461
24168
|
try {
|
|
23462
|
-
p.dispose();
|
|
24169
|
+
p.dispose({ cancelOpening: true });
|
|
23463
24170
|
}
|
|
23464
24171
|
catch { }
|
|
23465
24172
|
}
|
|
@@ -23511,7 +24218,7 @@ class WakerSubscriptionManager {
|
|
|
23511
24218
|
// turn this into an error result instead of a false "Subscribed" reply.
|
|
23512
24219
|
throw new Error(`Waker subscription ${sub.id} failed: ${msg}${hintFor(msg)}` +
|
|
23513
24220
|
(this.retryPendingMs > 0
|
|
23514
|
-
? `. Not listening yet — re-attempting every ${Math.round(this.
|
|
24221
|
+
? `. Not listening yet — re-attempting within ${Math.round(this.retryCeiling() / 1000)}s, then less often (at most every ${Math.round(this.maxRetryPendingMs / 1000)}s); check ad4m_list_waker_subscriptions.`
|
|
23515
24222
|
: ""));
|
|
23516
24223
|
}
|
|
23517
24224
|
if (this.isStale(sub.id, token)) {
|
|
@@ -23519,6 +24226,8 @@ class WakerSubscriptionManager {
|
|
|
23519
24226
|
return;
|
|
23520
24227
|
}
|
|
23521
24228
|
this.pendingSubscriptions.delete(sub.id);
|
|
24229
|
+
if (this.pendingSubscriptions.size === 0)
|
|
24230
|
+
this.retryRounds = 0;
|
|
23522
24231
|
this.logger.info(`[waker] ${sub.id}: subscription initialized successfully`);
|
|
23523
24232
|
// Seed from persisted seen messages so we don't re-wake after restart
|
|
23524
24233
|
const restored = Object.prototype.hasOwnProperty.call(this.previousSeenMessages, sub.id);
|
|
@@ -23612,6 +24321,9 @@ class WakerSubscriptionManager {
|
|
|
23612
24321
|
};
|
|
23613
24322
|
proxy.onResult((result) => handleResult(result));
|
|
23614
24323
|
mentionProxy?.onResult((result) => handleResult(result, false, " (mention query)"));
|
|
24324
|
+
for (const p of proxies) {
|
|
24325
|
+
p.onStatus?.((status) => this.onReopenStatus(sub, proxies, p, status));
|
|
24326
|
+
}
|
|
23615
24327
|
if (this.isStale(sub.id, token)) {
|
|
23616
24328
|
disposeProxies();
|
|
23617
24329
|
return;
|
|
@@ -23634,6 +24346,51 @@ class WakerSubscriptionManager {
|
|
|
23634
24346
|
this.persist();
|
|
23635
24347
|
this.logger.info(`[waker] Subscription ${sub.id} active (type=${sub.type}, perspective=${sub.perspective})`);
|
|
23636
24348
|
}
|
|
24349
|
+
/**
|
|
24350
|
+
* A proxy of `sub` failed to re-open its live query, or re-opened it after
|
|
24351
|
+
* failing. `sub` counts as active again once none of its proxies is still
|
|
24352
|
+
* re-opening. `proxies` tells a status of a replaced subscription apart.
|
|
24353
|
+
*/
|
|
24354
|
+
onReopenStatus(sub, proxies, proxy, status) {
|
|
24355
|
+
if (this.proxies.get(sub.id) !== proxies)
|
|
24356
|
+
return;
|
|
24357
|
+
if (status?.state === "reopening") {
|
|
24358
|
+
const entry = this.reopening.get(sub.id) ?? { sub, proxies: new Set() };
|
|
24359
|
+
entry.proxies.add(proxy);
|
|
24360
|
+
if (!this.reopening.has(sub.id)) {
|
|
24361
|
+
this.reopening.set(sub.id, entry);
|
|
24362
|
+
this.activeSubscriptions.delete(sub.id);
|
|
24363
|
+
this.logger.warn(`[waker] ${sub.id}: live query lost after a reconnect and could not be re-opened (${status.error?.message ?? status.error}); not listening, retrying in ${Math.round((status.retryInMs ?? 0) / 1000)}s`);
|
|
24364
|
+
}
|
|
24365
|
+
return;
|
|
24366
|
+
}
|
|
24367
|
+
if (status?.state !== "open")
|
|
24368
|
+
return;
|
|
24369
|
+
const entry = this.reopening.get(sub.id);
|
|
24370
|
+
if (!entry)
|
|
24371
|
+
return;
|
|
24372
|
+
entry.proxies.delete(proxy);
|
|
24373
|
+
if (entry.proxies.size > 0)
|
|
24374
|
+
return;
|
|
24375
|
+
this.reopening.delete(sub.id);
|
|
24376
|
+
this.activeSubscriptions.set(sub.id, sub);
|
|
24377
|
+
this.logger.info(`[waker] ${sub.id}: live query re-opened, listening again`);
|
|
24378
|
+
// Wakes held back while it was not active go out now, not with the next mention.
|
|
24379
|
+
if (this.undelivered.get(sub.id)?.size)
|
|
24380
|
+
this.scheduleMentionWake(sub, proxy.result, this.debounceMs);
|
|
24381
|
+
}
|
|
24382
|
+
/** The wait before the next re-attempt round: `retryPendingMs` doubled per
|
|
24383
|
+
* round in a row that left something pending, capped at
|
|
24384
|
+
* `maxRetryPendingMs`, and between half and all of that, so wakers of a
|
|
24385
|
+
* restarted executor do not all retry at once. */
|
|
24386
|
+
nextRetryDelay() {
|
|
24387
|
+
const ceiling = this.retryCeiling();
|
|
24388
|
+
return ceiling / 2 + Math.random() * (ceiling / 2);
|
|
24389
|
+
}
|
|
24390
|
+
/** The longest the next re-attempt round waits. */
|
|
24391
|
+
retryCeiling() {
|
|
24392
|
+
return Math.min(this.retryPendingMs * 2 ** this.retryRounds, this.maxRetryPendingMs);
|
|
24393
|
+
}
|
|
23637
24394
|
/** Arm the re-attempt timer if pending subscriptions are waiting. */
|
|
23638
24395
|
scheduleRetry() {
|
|
23639
24396
|
if (this.retryPendingMs <= 0)
|
|
@@ -23642,8 +24399,9 @@ class WakerSubscriptionManager {
|
|
|
23642
24399
|
return;
|
|
23643
24400
|
this.retryTimer = setTimeout(() => {
|
|
23644
24401
|
this.retryTimer = null;
|
|
24402
|
+
this.retryRounds++;
|
|
23645
24403
|
void this.retryPending();
|
|
23646
|
-
}, this.
|
|
24404
|
+
}, this.nextRetryDelay());
|
|
23647
24405
|
if (typeof this.retryTimer.unref === "function")
|
|
23648
24406
|
this.retryTimer.unref();
|
|
23649
24407
|
}
|
|
@@ -23677,26 +24435,39 @@ class WakerSubscriptionManager {
|
|
|
23677
24435
|
}
|
|
23678
24436
|
}
|
|
23679
24437
|
}
|
|
23680
|
-
/** Subscriptions that
|
|
24438
|
+
/** Subscriptions that are not listening and are being re-attempted: the
|
|
24439
|
+
* ones the executor rejected, and active ones whose live query is
|
|
24440
|
+
* re-opening after a reconnect. */
|
|
23681
24441
|
getPending() {
|
|
23682
|
-
return
|
|
24442
|
+
return [
|
|
24443
|
+
...this.pendingSubscriptions.values(),
|
|
24444
|
+
...Array.from(this.reopening.values(), (entry) => entry.sub),
|
|
24445
|
+
];
|
|
23683
24446
|
}
|
|
23684
24447
|
/**
|
|
23685
24448
|
* Dispose a single subscription.
|
|
23686
24449
|
* @param persist — if false, skip calling onPersist (used during batch cleanup).
|
|
23687
24450
|
*/
|
|
23688
24451
|
dispose(id, persist = true) {
|
|
24452
|
+
this.release(id, persist);
|
|
24453
|
+
if (this.pendingSubscriptions.size === 0)
|
|
24454
|
+
this.retryRounds = 0;
|
|
24455
|
+
}
|
|
24456
|
+
/** Drop everything held for `id`, as `dispose()` does, but leave the
|
|
24457
|
+
* re-attempt backoff as it is. */
|
|
24458
|
+
release(id, persist) {
|
|
23689
24459
|
// Invalidate any subscribe() for this id that is still awaiting.
|
|
23690
24460
|
this.generations.set(id, (this.generations.get(id) ?? 0) + 1);
|
|
23691
24461
|
for (const proxy of this.proxies.get(id) ?? []) {
|
|
23692
24462
|
try {
|
|
23693
|
-
proxy.dispose();
|
|
24463
|
+
proxy.dispose({ cancelOpening: true });
|
|
23694
24464
|
}
|
|
23695
24465
|
catch {
|
|
23696
24466
|
/* ignore */
|
|
23697
24467
|
}
|
|
23698
24468
|
}
|
|
23699
24469
|
this.proxies.delete(id);
|
|
24470
|
+
this.reopening.delete(id);
|
|
23700
24471
|
const timer = this.debounceTimers.get(id);
|
|
23701
24472
|
if (timer) {
|
|
23702
24473
|
clearTimeout(timer);
|
|
@@ -23769,6 +24540,8 @@ class WakerSubscriptionManager {
|
|
|
23769
24540
|
this.dispose(id, false);
|
|
23770
24541
|
}
|
|
23771
24542
|
this.pendingSubscriptions.clear();
|
|
24543
|
+
this.reopening.clear();
|
|
24544
|
+
this.retryRounds = 0;
|
|
23772
24545
|
if (this.retryTimer) {
|
|
23773
24546
|
clearTimeout(this.retryTimer);
|
|
23774
24547
|
this.retryTimer = null;
|
|
@@ -23828,7 +24601,9 @@ class WakerSubscriptionManager {
|
|
|
23828
24601
|
for (const [id, set] of this.delivered) {
|
|
23829
24602
|
seen[id] = Array.from(set);
|
|
23830
24603
|
}
|
|
23831
|
-
|
|
24604
|
+
// A subscription that is re-opening was enrolled and is coming back: a
|
|
24605
|
+
// restart in the meantime must restore it.
|
|
24606
|
+
this.onPersist([...this.getActive(), ...Array.from(this.reopening.values(), (entry) => entry.sub)], seen);
|
|
23832
24607
|
}
|
|
23833
24608
|
}
|
|
23834
24609
|
}
|
|
@@ -24315,6 +25090,7 @@ exports.HasOne = HasOne;
|
|
|
24315
25090
|
exports.HostingUserInfo = HostingUserInfo;
|
|
24316
25091
|
exports.IDBCache = IDBCache;
|
|
24317
25092
|
exports.Icon = Icon;
|
|
25093
|
+
exports.IdentityClient = IdentityClient;
|
|
24318
25094
|
exports.ImportResult = ImportResult;
|
|
24319
25095
|
exports.ImportStats = ImportStats;
|
|
24320
25096
|
exports.InteractionCall = InteractionCall;
|
|
@@ -24370,6 +25146,8 @@ exports.PerspectiveUnsignedInput = PerspectiveUnsignedInput;
|
|
|
24370
25146
|
exports.Property = Property;
|
|
24371
25147
|
exports.QuerySubscriptionProxy = QuerySubscriptionProxy;
|
|
24372
25148
|
exports.READ_METHODS = READ_METHODS;
|
|
25149
|
+
exports.REOPEN_BASE_DELAY_MS = REOPEN_BASE_DELAY_MS;
|
|
25150
|
+
exports.REOPEN_MAX_DELAY_MS = REOPEN_MAX_DELAY_MS;
|
|
24373
25151
|
exports.ReadOnly = ReadOnly;
|
|
24374
25152
|
exports.Resource = Resource;
|
|
24375
25153
|
exports.ResourceInput = ResourceInput;
|
|
@@ -24458,6 +25236,7 @@ exports.parseLitNumber = parseLitNumber;
|
|
|
24458
25236
|
exports.parseSparqlCount = parseSparqlCount;
|
|
24459
25237
|
exports.path = path;
|
|
24460
25238
|
exports.queryCacheSize = queryCacheSize;
|
|
25239
|
+
exports.reopenDelay = reopenDelay;
|
|
24461
25240
|
exports.requireSingleParent = requireSingleParent;
|
|
24462
25241
|
exports.resolveParentPredicate = resolveParentPredicate;
|
|
24463
25242
|
exports.setCachedResult = setCachedResult;
|