@agentshouse/mdruntime 0.1.0-c806ecaf4afed → 0.1.0-c80bb5b77602a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -19
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +15 -24
- package/dist/act-lanes.d.ts +11 -14
- package/dist/act-lanes.d.ts.map +1 -1
- package/dist/act-lanes.js +53 -5
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +138 -68
- package/dist/adapter.d.ts +109 -24
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +20 -14
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +28 -56
- package/dist/collection.d.ts +5 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +16 -8
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +21 -11
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +21 -16
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +23 -10
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +18 -8
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +22 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +258 -188
- package/dist/declaration.js +1 -1
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +36 -9
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +5 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +14 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +45 -16
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +76 -30
- package/dist/house-query.d.ts +18 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +54 -0
- package/dist/index.d.ts +17 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/install.d.ts +10 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +45 -46
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +50 -32
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +4 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +167 -33
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +63 -19
- package/dist/messages.d.ts +17 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +29 -10
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -10
- package/dist/outcome.d.ts +24 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +33 -3
- package/dist/overlay.d.ts +7 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -9
- package/dist/parts.d.ts +4 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +198 -87
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +81 -64
- package/dist/query.d.ts +2 -2
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +73 -48
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +162 -37
- package/dist/react.d.ts +10 -11
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +22 -4
- package/dist/readiness.d.ts +20 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -10
- package/dist/reads.d.ts +4 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +7 -3
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +4 -4
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +30 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +258 -32
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +11 -6
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +8 -7
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -124
- package/dist/saves.d.ts +4 -2
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +65 -21
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +5 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +79 -43
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +4 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -9
- package/dist/source.d.ts +7 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +15 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +20 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +60 -22
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +17 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +18 -6
- package/dist/stored.d.ts +32 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +185 -49
- package/dist/surface.d.ts +14 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +59 -27
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +76 -40
- package/dist/tables.d.ts +17 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +87 -324
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +3 -9
- package/dist/wire.d.ts +38 -15
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +20 -13
- package/package.json +3 -3
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/saves.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isImageType, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { binaryRecord } from './binary.js';
|
|
3
|
+
import { changeSet } from './change-set.js';
|
|
3
4
|
import { queuedFile } from './change.js';
|
|
4
|
-
import { available } from './collection.js';
|
|
5
|
+
import { available, textType } from './collection.js';
|
|
5
6
|
import { runtimeError } from './failure.js';
|
|
6
7
|
import { attachedFile } from './file.js';
|
|
8
|
+
import { roomDraftRevision } from './identity.js';
|
|
7
9
|
import { compositionFor } from './listing.js';
|
|
8
10
|
import { scoped } from './models.js';
|
|
9
|
-
import { absentBinary, attachAnswer, binaryAnswer, binaryLinkAnswer, failure, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
11
|
+
import { absentBinary, attachAnswer, binaryAnswer, binaryLinkAnswer, failure, linkedAnswer, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
10
12
|
import { sameBinary } from './overlay.js';
|
|
11
13
|
import { ancestors } from './paths.js';
|
|
12
14
|
import { connectionNow } from './preparation.js';
|
|
13
15
|
import { append, sliceAt, withdrawable } from './queue.js';
|
|
14
16
|
import { entryAt, replaying, slicing, } from './replica.js';
|
|
15
|
-
import { binaryBase, changesOf, held, heldFile, moveTarget, readSavedParts, } from './room-draft.js';
|
|
17
|
+
import { binaryBase, changesOf, held, heldFile, joinedOver, moveTarget, readSavedParts, } from './room-draft.js';
|
|
16
18
|
import { refuse } from './refusal.js';
|
|
17
19
|
import { visibleOf } from './room-drafts.js';
|
|
18
20
|
import { destination, planSave, } from './save.js';
|
|
@@ -43,9 +45,24 @@ export function saveRoomDrafts(runtime, locator, named, writtenBy) {
|
|
|
43
45
|
if (!saved.some((draft) => draft.path === path))
|
|
44
46
|
saved.push({ path, parts: record.parts });
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
const result = await loaded(runtime, locator, replica, saved, new Set(saved.map(({ path }) => path)), [], writtenBy);
|
|
49
|
+
if (result.outcome !== 'refused' || result.code !== 'changed-underneath')
|
|
50
|
+
return result;
|
|
51
|
+
return joinedUnderneath(runtime, locator, saved.map(({ path }) => drafts.get(path)), result);
|
|
47
52
|
});
|
|
48
53
|
}
|
|
54
|
+
async function joinedUnderneath({ store }, locator, records, refused) {
|
|
55
|
+
const visible = (await visibleOf(store, locator, records.map(({ path }) => path)));
|
|
56
|
+
const joined = records.flatMap((record) => {
|
|
57
|
+
const join = joinedOver(record.parts, record.marks, record.path, visible);
|
|
58
|
+
return join === null ? [] : [{ ...record, ...join, revision: roomDraftRevision() }];
|
|
59
|
+
});
|
|
60
|
+
if (joined.length === 0)
|
|
61
|
+
return refused;
|
|
62
|
+
await (await store.open()).commit({ rooms: [], writes: [{ locator, roomDrafts: joined }] });
|
|
63
|
+
await store.changed(changeSet(locator, { drafts: joined.map(({ path }) => path) }));
|
|
64
|
+
return refused;
|
|
65
|
+
}
|
|
49
66
|
export function saveParts(runtime, locator, named, writtenBy) {
|
|
50
67
|
const { store } = runtime;
|
|
51
68
|
return store.exclusive(async () => {
|
|
@@ -162,8 +179,7 @@ function lookupOf(local, key, view) {
|
|
|
162
179
|
function declaredOf(entry) {
|
|
163
180
|
if (entry.binary !== null)
|
|
164
181
|
return { type: undefined, binary: true };
|
|
165
|
-
|
|
166
|
-
return { type: read.ok ? (read.frontmatter.type ?? 'any') : undefined, binary: false };
|
|
182
|
+
return { type: textType(parse(entry.content ?? '')), binary: false };
|
|
167
183
|
}
|
|
168
184
|
function overriddenLookup(lookup, overrides) {
|
|
169
185
|
return async (paths) => {
|
|
@@ -230,7 +246,7 @@ export function batchFile(store, batch) {
|
|
|
230
246
|
};
|
|
231
247
|
}
|
|
232
248
|
async function transferBinary(runtime, request, transfer, answer) {
|
|
233
|
-
const { store, socket, presence
|
|
249
|
+
const { store, socket, presence } = runtime;
|
|
234
250
|
const { session } = socket;
|
|
235
251
|
if (socket.closed() || session.now().refusal !== null)
|
|
236
252
|
return UNCERTAIN;
|
|
@@ -247,12 +263,10 @@ async function transferBinary(runtime, request, transfer, answer) {
|
|
|
247
263
|
if (closed || authorization === undefined || refusal !== null)
|
|
248
264
|
return UNCERTAIN;
|
|
249
265
|
const since = presence.losses();
|
|
250
|
-
journal.record(`transfer binary ${request.locator} ${request.path}`);
|
|
251
266
|
try {
|
|
252
267
|
const result = await transfer(authorization);
|
|
253
268
|
const settled = result;
|
|
254
|
-
|
|
255
|
-
if (presence.lostSince(request.locator, since))
|
|
269
|
+
if (request.locator !== null && presence.lostSince(request.locator, since))
|
|
256
270
|
return failure({ kind: 'room-not-readable', locator: request.locator });
|
|
257
271
|
if (settled.kind === 'scoped-refusal') {
|
|
258
272
|
const room = await store.record(settled.locator);
|
|
@@ -264,7 +278,6 @@ async function transferBinary(runtime, request, transfer, answer) {
|
|
|
264
278
|
return answer(result);
|
|
265
279
|
}
|
|
266
280
|
catch {
|
|
267
|
-
journal.record('outcome binary transport-uncertainty');
|
|
268
281
|
return UNCERTAIN;
|
|
269
282
|
}
|
|
270
283
|
}
|
|
@@ -363,6 +376,25 @@ async function linkBinaryPath(runtime, locator, path, revision) {
|
|
|
363
376
|
return absentBinary(path);
|
|
364
377
|
return linkOf(runtime, asked, revision === undefined ? await heldMediaType(store, locator, path) : undefined);
|
|
365
378
|
}
|
|
379
|
+
function shownImage(runtime, asked, name) {
|
|
380
|
+
const { store, socket } = runtime;
|
|
381
|
+
return new Promise((answer) => {
|
|
382
|
+
void transferBinary(runtime, asked, (authorization) => store.opened.fetch(name, async () => {
|
|
383
|
+
const read = await socket.binary(authorization, asked);
|
|
384
|
+
const copies = read.kind === 'binary' ? (read.copies ?? []) : [];
|
|
385
|
+
if (read.kind === 'binary' && read.url !== undefined && copies.length > 0) {
|
|
386
|
+
answer({
|
|
387
|
+
kind: 'link',
|
|
388
|
+
url: read.url,
|
|
389
|
+
name: asked.path.slice(asked.path.lastIndexOf('/') + 1),
|
|
390
|
+
mediaType: read.mediaType,
|
|
391
|
+
copies,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return read;
|
|
395
|
+
}), binaryAnswer).then(answer);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
366
398
|
async function showBinaryPath(runtime, locator, path, revision) {
|
|
367
399
|
const { store } = runtime;
|
|
368
400
|
const asked = await askedBinary(runtime, locator, path, revision);
|
|
@@ -377,11 +409,12 @@ async function showBinaryPath(runtime, locator, path, revision) {
|
|
|
377
409
|
if (kept !== null)
|
|
378
410
|
return kept;
|
|
379
411
|
const mediaType = await heldMediaType(store, locator, path);
|
|
380
|
-
if (mediaType
|
|
381
|
-
return
|
|
382
|
-
|
|
412
|
+
if (mediaType !== undefined && isImageType(mediaType))
|
|
413
|
+
return shownImage(runtime, asked, name);
|
|
414
|
+
const linked = await linkOf(runtime, asked, revision === undefined ? mediaType : undefined);
|
|
415
|
+
return linked.kind === 'link' ? { ...linked, copies: [] } : linked;
|
|
383
416
|
}
|
|
384
|
-
async function
|
|
417
|
+
async function attachFile(runtime, locator, file, answer) {
|
|
385
418
|
const { store, socket } = runtime;
|
|
386
419
|
await socket.ready;
|
|
387
420
|
await socket.firstDiscovery;
|
|
@@ -391,23 +424,34 @@ async function attachBinary(runtime, locator, file) {
|
|
|
391
424
|
socket.session.now().refusal !== null)
|
|
392
425
|
return OFFLINE;
|
|
393
426
|
const request = await attachedFile(locator, file);
|
|
394
|
-
return transferBinary(runtime, { locator
|
|
427
|
+
return transferBinary(runtime, { locator }, async (held) => {
|
|
395
428
|
const result = await socket.attach(held, request);
|
|
396
|
-
if (result.kind === 'attached') {
|
|
429
|
+
if (result.kind === 'attached' && locator !== null) {
|
|
397
430
|
store.attached.hold(locator, result.path, {
|
|
398
431
|
revision: result.revision,
|
|
399
432
|
mediaType: request.mediaType,
|
|
400
433
|
});
|
|
401
434
|
}
|
|
402
435
|
return result;
|
|
403
|
-
},
|
|
436
|
+
}, answer);
|
|
437
|
+
}
|
|
438
|
+
async function keyedAttachment(runtime, link) {
|
|
439
|
+
await runtime.socket.ready;
|
|
440
|
+
const asked = { kind: 'key', link };
|
|
441
|
+
return transferBinary(runtime, { locator: null }, (authorization) => runtime.socket.link(authorization, asked), (result) => binaryLinkAnswer(result));
|
|
442
|
+
}
|
|
443
|
+
export function conversationFiles(runtime) {
|
|
444
|
+
return {
|
|
445
|
+
attach: (file) => attachFile(runtime, null, file, linkedAnswer),
|
|
446
|
+
attachment: (link) => keyedAttachment(runtime, link),
|
|
447
|
+
};
|
|
404
448
|
}
|
|
405
|
-
export function
|
|
449
|
+
export function attachmentSurface(runtime) {
|
|
406
450
|
return {
|
|
407
451
|
part: runtime.store.part,
|
|
408
452
|
read: (room, path, revision) => readBinaryPath(runtime, room, path, revision),
|
|
409
453
|
link: (room, path, revision) => linkBinaryPath(runtime, room, path, revision),
|
|
410
454
|
show: (room, path, revision) => showBinaryPath(runtime, room, path, revision),
|
|
411
|
-
attach: (room, file) =>
|
|
455
|
+
attach: (room, file) => attachFile(runtime, room, file, attachAnswer),
|
|
412
456
|
};
|
|
413
457
|
}
|
package/dist/seed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAwB,KAAK,WAAW,EAAqB,MAAM,kBAAkB,CAAC;AAC7F,OAAO,KAAK,EAAE,IAAI,EAA4C,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,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
|
2
|
+
import { pendingChange, whole } from './observation.js';
|
|
3
3
|
import { documentKey } from './rows.js';
|
|
4
4
|
const seedTopic = (key) => `seed\u0000${key}`;
|
|
5
5
|
function plain(value) {
|
|
@@ -130,7 +130,7 @@ export function watchSeeded(runtime, plan, deliver, watch) {
|
|
|
130
130
|
const watcher = store.watch(seedTopic(plan.key), shown);
|
|
131
131
|
const stop = watch((cover, held) => seedBehind(runtime, plan, cover, held), (message) => {
|
|
132
132
|
const answered = message;
|
|
133
|
-
pending = whole(answered)
|
|
133
|
+
pending = whole(answered) ? 'pending' in answered.result : pendingChange(answered);
|
|
134
134
|
if (pending && store.seeds.of(plan.key) !== undefined) {
|
|
135
135
|
shown();
|
|
136
136
|
return;
|
package/dist/shown.d.ts
CHANGED
|
@@ -10,15 +10,18 @@ export declare const REFUSAL_TOPIC = "connection-refusal";
|
|
|
10
10
|
export declare const STORAGE_LOSS_TOPIC = "storage-loss";
|
|
11
11
|
export declare const SERVICE_MODE_TOPIC = "service-mode";
|
|
12
12
|
export declare const MEMBER_TOPIC = "member";
|
|
13
|
+
export declare const TIME_ZONE_TOPIC = "time-zone";
|
|
13
14
|
export declare const AUTHORITY_TOPIC = "authority-changes";
|
|
14
15
|
export declare const LOCKS_TOPIC = "locks";
|
|
15
16
|
export declare const queueTopic: (locator: string) => string;
|
|
16
|
-
export declare function recoverReads({ liveQueries, figures }: Runtime): void;
|
|
17
|
+
export declare function recoverReads({ liveQueries, figures }: Runtime, locators?: readonly string[]): void;
|
|
17
18
|
export declare function emitRooms(runtime: Runtime, changed?: readonly string[]): Promise<void>;
|
|
18
19
|
export declare function emitKnownRooms(runtime: Runtime): void;
|
|
19
20
|
export declare function emitRefusal(runtime: Runtime): void;
|
|
20
|
-
export declare function
|
|
21
|
+
export declare function storageLossNow({ store }: Runtime): string | null;
|
|
22
|
+
export declare function emitStorageLoss(runtime: Runtime): void;
|
|
21
23
|
export declare function emitMember({ store }: Runtime, member: Member | null): void;
|
|
24
|
+
export declare function emitTimeZone({ store }: Runtime, zone: string | null): void;
|
|
22
25
|
export declare function show(runtime: Runtime): Promise<void>;
|
|
23
26
|
export declare function moveTo(runtime: Runtime, next: Moving): Promise<void>;
|
|
24
27
|
export declare function statusShown(runtime: Runtime): Promise<void>;
|
package/dist/shown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shown.d.ts","sourceRoot":"","sources":["../src/shown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"shown.d.ts","sourceRoot":"","sources":["../src/shown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA6B,KAAK,aAAa,EAAmB,MAAM,aAAa,CAAC;AAiB7F,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,YAAY,gBAAgB,CAAC;AAE1C,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,UAAU,YAAa,MAAM,WAA4B,CAAC;AA6Cv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AAgB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhF;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAQjG;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAG/D;AAED,wBAAsB,IAAI,CACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,GAAG,IAAI,EAC9B,IAAI,GAAE,IAAqC,iBAkC5C"}
|
package/dist/shown.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
2
|
import { conversationsChanged, conversationsLearned } from './conversation.js';
|
|
3
|
-
import {
|
|
3
|
+
import { lossStated } from './durability.js';
|
|
4
|
+
import { listedEntries, listingNow, shownChange, shownRooms } from './listing.js';
|
|
4
5
|
import { emitPresentation, publishRoomDrafts } from './room-drafts.js';
|
|
5
6
|
import { same } from './status.js';
|
|
6
7
|
export const ROOMS_TOPIC = 'rooms';
|
|
@@ -9,11 +10,20 @@ export const REFUSAL_TOPIC = 'connection-refusal';
|
|
|
9
10
|
export const STORAGE_LOSS_TOPIC = 'storage-loss';
|
|
10
11
|
export const SERVICE_MODE_TOPIC = 'service-mode';
|
|
11
12
|
export const MEMBER_TOPIC = 'member';
|
|
13
|
+
export const TIME_ZONE_TOPIC = 'time-zone';
|
|
12
14
|
export const AUTHORITY_TOPIC = 'authority-changes';
|
|
13
15
|
export const LOCKS_TOPIC = 'locks';
|
|
14
16
|
export const queueTopic = (locator) => `queue\u0000${locator}`;
|
|
15
|
-
async function attended({ store, localSaves }) {
|
|
16
|
-
const held =
|
|
17
|
+
async function attended({ store, socket, localSaves }) {
|
|
18
|
+
const held = store.needed()
|
|
19
|
+
? await store.status()
|
|
20
|
+
: {
|
|
21
|
+
queued: [],
|
|
22
|
+
lastCompleted: socket.session.now().lastCompleted,
|
|
23
|
+
unsent: [],
|
|
24
|
+
resets: [],
|
|
25
|
+
returned: [],
|
|
26
|
+
};
|
|
17
27
|
const attentionRequired = held.returned.flatMap((record) => record.returned === null
|
|
18
28
|
? []
|
|
19
29
|
: [{ room: record.locator, path: record.path, returned: structuredClone(record.returned) }]);
|
|
@@ -41,15 +51,15 @@ async function attended({ store, localSaves }) {
|
|
|
41
51
|
};
|
|
42
52
|
}
|
|
43
53
|
async function queuedWork({ store, localSaves }) {
|
|
44
|
-
return !localSaves && (await store.queued()).length > 0;
|
|
54
|
+
return !localSaves && store.needed() && (await store.queued()).length > 0;
|
|
45
55
|
}
|
|
46
|
-
export function recoverReads({ liveQueries, figures }) {
|
|
47
|
-
liveQueries.recover();
|
|
56
|
+
export function recoverReads({ liveQueries, figures }, locators) {
|
|
57
|
+
liveQueries.recover(locators);
|
|
48
58
|
figures.recover();
|
|
49
59
|
}
|
|
50
60
|
export function emitRooms(runtime, changed) {
|
|
51
|
-
recoverReads(runtime);
|
|
52
|
-
runtime.store.readiness.queue();
|
|
61
|
+
recoverReads(runtime, changed);
|
|
62
|
+
runtime.store.readiness.queue(changed);
|
|
53
63
|
return changed === undefined
|
|
54
64
|
? publishRooms(runtime, 'all')
|
|
55
65
|
: publishRooms(runtime, 'changed', changed);
|
|
@@ -74,51 +84,58 @@ function roomsOwedWith(held, mode, touched) {
|
|
|
74
84
|
}
|
|
75
85
|
return held;
|
|
76
86
|
}
|
|
87
|
+
async function patchedRooms(runtime, owed) {
|
|
88
|
+
const { store } = runtime;
|
|
89
|
+
const touched = [...new Set([...owed.changed, ...owed.counted])];
|
|
90
|
+
const entries = await listedEntries(runtime, touched);
|
|
91
|
+
const shown = store.roomsShown.now();
|
|
92
|
+
if (entries === null || shown === null)
|
|
93
|
+
return false;
|
|
94
|
+
if (runtime.socket.closed())
|
|
95
|
+
return true;
|
|
96
|
+
const moved = entries.filter(({ locator, documents }) => owed.changed.has(locator) || shown.get(locator)?.documents !== documents);
|
|
97
|
+
const counted = moved.flatMap(({ locator }) => (owed.changed.has(locator) ? [] : [locator]));
|
|
98
|
+
if (counted.length > 0) {
|
|
99
|
+
recoverReads(runtime, counted);
|
|
100
|
+
store.readiness.queue(counted);
|
|
101
|
+
}
|
|
102
|
+
store.roomsShown.patch(moved);
|
|
103
|
+
if (moved.length === 0)
|
|
104
|
+
return true;
|
|
105
|
+
const change = shownChange(runtime, moved);
|
|
106
|
+
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
107
|
+
watcher.answer(change);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
77
110
|
async function deliverRooms(runtime, owed) {
|
|
78
111
|
const { store, socket } = runtime;
|
|
79
112
|
const waiting = () => store.watching(ROOMS_TOPIC, 'waiting');
|
|
80
113
|
if (socket.closed() || store.watching(ROOMS_TOPIC).length === 0)
|
|
81
114
|
return;
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
115
|
+
const touched = owed.changed.size > 0 || owed.counted.size > 0;
|
|
116
|
+
if (!owed.all && touched && waiting().length === 0 && (await patchedRooms(runtime, owed)))
|
|
117
|
+
return;
|
|
118
|
+
if (touched)
|
|
86
119
|
owed.all = true;
|
|
87
|
-
|
|
88
|
-
const held = await store.covering();
|
|
89
|
-
const { roomsShown } = store.device.now();
|
|
90
|
-
owed.all = [...owed.counted].some((locator) => held.rooms.has(locator) &&
|
|
91
|
-
roomsShown?.get(locator)?.documents !== held.rooms.get(locator).documents);
|
|
92
|
-
if (owed.all) {
|
|
93
|
-
recoverReads(runtime);
|
|
94
|
-
store.readiness.queue();
|
|
95
|
-
}
|
|
96
|
-
else if (waiting().length === 0)
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const listing = patched ?? (await listingNow(runtime));
|
|
120
|
+
const listing = await listingNow(runtime);
|
|
100
121
|
if (socket.closed())
|
|
101
122
|
return;
|
|
102
123
|
const { roomsListed, refusal, moving } = socket.session.now();
|
|
103
124
|
const joining = waiting().length > 0 &&
|
|
104
125
|
(roomsListed || listing.size > 0 || refusal !== null || moving.providerUnreachable);
|
|
105
|
-
if (!owed.all &&
|
|
126
|
+
if (!owed.all && !joining)
|
|
106
127
|
return;
|
|
107
128
|
const value = shownRooms(runtime, listing);
|
|
108
|
-
const
|
|
129
|
+
const shown = store.roomsShown.now();
|
|
109
130
|
const moved = owed.all ||
|
|
110
|
-
|
|
111
|
-
(roomsShown !== null &&
|
|
112
|
-
JSON.stringify(shownRooms(runtime, roomsShown)) !== JSON.stringify(value));
|
|
131
|
+
(shown !== null && JSON.stringify(shownRooms(runtime, shown)) !== JSON.stringify(value));
|
|
113
132
|
if (moved)
|
|
114
133
|
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
115
134
|
watcher.answer(value);
|
|
116
135
|
if (joining)
|
|
117
136
|
for (const watcher of waiting())
|
|
118
137
|
watcher.answer(value);
|
|
119
|
-
store.
|
|
120
|
-
roomsShown: store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing,
|
|
121
|
-
});
|
|
138
|
+
store.roomsShown.show(store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing);
|
|
122
139
|
}
|
|
123
140
|
function publishRooms(runtime, mode, touched = []) {
|
|
124
141
|
if (runtime.socket.closed())
|
|
@@ -127,17 +144,24 @@ function publishRooms(runtime, mode, touched = []) {
|
|
|
127
144
|
}
|
|
128
145
|
export function emitRefusal(runtime) {
|
|
129
146
|
const { store, socket } = runtime;
|
|
130
|
-
store.readiness.queue();
|
|
147
|
+
store.readiness.queue([]);
|
|
131
148
|
store.tell(REFUSAL_TOPIC, socket.session.now().refusal);
|
|
132
149
|
emitKnownRooms(runtime);
|
|
133
150
|
}
|
|
134
|
-
export function
|
|
135
|
-
store.
|
|
136
|
-
|
|
151
|
+
export function storageLossNow({ store }) {
|
|
152
|
+
const { persistence, storageLoss } = store.device.now();
|
|
153
|
+
return lossStated(persistence, storageLoss);
|
|
154
|
+
}
|
|
155
|
+
export function emitStorageLoss(runtime) {
|
|
156
|
+
runtime.store.readiness.queue([]);
|
|
157
|
+
runtime.store.tell(STORAGE_LOSS_TOPIC, storageLossNow(runtime));
|
|
137
158
|
}
|
|
138
159
|
export function emitMember({ store }, member) {
|
|
139
160
|
store.tell(MEMBER_TOPIC, member);
|
|
140
161
|
}
|
|
162
|
+
export function emitTimeZone({ store }, zone) {
|
|
163
|
+
store.tell(TIME_ZONE_TOPIC, zone);
|
|
164
|
+
}
|
|
141
165
|
async function deliverStatus(runtime, owed) {
|
|
142
166
|
const { store, socket } = runtime;
|
|
143
167
|
const held = await attended(runtime);
|
|
@@ -159,13 +183,16 @@ async function deliverStatus(runtime, owed) {
|
|
|
159
183
|
store.tell(STATUS_TOPIC, next);
|
|
160
184
|
}
|
|
161
185
|
}
|
|
186
|
+
function conversationsCurrent({ conversations }) {
|
|
187
|
+
return conversations.listed() && conversations.current();
|
|
188
|
+
}
|
|
162
189
|
export function show(runtime) {
|
|
163
|
-
const { store, socket
|
|
190
|
+
const { store, socket } = runtime;
|
|
164
191
|
if (socket.closed())
|
|
165
192
|
return Promise.resolve();
|
|
166
|
-
store.readiness.queue();
|
|
193
|
+
store.readiness.queue([]);
|
|
167
194
|
emitKnownRooms(runtime);
|
|
168
|
-
const moved = { moving: socket.session.now().moving, current:
|
|
195
|
+
const moved = { moving: socket.session.now().moving, current: conversationsCurrent(runtime) };
|
|
169
196
|
return store.owing(STATUS_TOPIC, (held) => {
|
|
170
197
|
if (held === undefined)
|
|
171
198
|
return [moved];
|
|
@@ -247,6 +274,8 @@ export function publishChangeSet(runtime, set) {
|
|
|
247
274
|
}
|
|
248
275
|
export async function submissionDue(runtime, locators) {
|
|
249
276
|
const { store } = runtime;
|
|
277
|
+
if (!store.needed())
|
|
278
|
+
return;
|
|
250
279
|
const due = (await store.queued()).filter((locator) => locators === undefined || locators.includes(locator));
|
|
251
280
|
if (due.length === 0)
|
|
252
281
|
return;
|
|
@@ -254,14 +283,18 @@ export async function submissionDue(runtime, locators) {
|
|
|
254
283
|
}
|
|
255
284
|
export function roomUnreadable(runtime, locator) {
|
|
256
285
|
runtime.presence.refused(locator, null);
|
|
257
|
-
emitRooms(runtime);
|
|
286
|
+
emitRooms(runtime, [locator]);
|
|
258
287
|
}
|
|
259
288
|
export async function rest(runtime, progress, live = () => !runtime.socket.closed()) {
|
|
260
289
|
const { store, socket, presence } = runtime;
|
|
261
290
|
const { session, lanes } = socket;
|
|
262
291
|
if (!live())
|
|
263
292
|
return;
|
|
264
|
-
const settled = () => session.now().complete &&
|
|
293
|
+
const settled = () => session.now().complete &&
|
|
294
|
+
lanes.roomWork() === 0 &&
|
|
295
|
+
!socket.naming() &&
|
|
296
|
+
presence.settled() &&
|
|
297
|
+
conversationsCurrent(runtime);
|
|
265
298
|
let synced = settled();
|
|
266
299
|
if (synced && !session.now().recorded) {
|
|
267
300
|
const queued = await queuedWork(runtime).catch(() => true);
|
|
@@ -272,7 +305,10 @@ export async function rest(runtime, progress, live = () => !runtime.socket.close
|
|
|
272
305
|
if (synced && !session.now().recorded) {
|
|
273
306
|
const completedAt = new Date().toISOString();
|
|
274
307
|
try {
|
|
275
|
-
|
|
308
|
+
if (store.needed())
|
|
309
|
+
await (await store.open()).fact('lastCompleted', completedAt);
|
|
310
|
+
else
|
|
311
|
+
session.set({ lastCompleted: completedAt });
|
|
276
312
|
if (!live())
|
|
277
313
|
return;
|
|
278
314
|
session.set({ recorded: true });
|
package/dist/socket/lanes.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { CallResult } from '../outcome.js';
|
|
1
2
|
export type Live = () => boolean;
|
|
3
|
+
export type KeptSender = {
|
|
4
|
+
next(): Promise<CallResult>;
|
|
5
|
+
};
|
|
2
6
|
type LaneRules = {
|
|
3
7
|
generation(): number;
|
|
4
8
|
continuing(): boolean;
|
|
5
9
|
stopping(): boolean;
|
|
10
|
+
failed(locator: string, error: unknown): void;
|
|
6
11
|
};
|
|
7
12
|
export type Lanes = {
|
|
8
13
|
task(lane: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
@@ -11,10 +16,13 @@ export type Lanes = {
|
|
|
11
16
|
roomWork(): number;
|
|
12
17
|
current(): Promise<unknown>;
|
|
13
18
|
finished(): Promise<unknown>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
sender(operation: string): KeptSender | undefined;
|
|
20
|
+
sending(operation: string, sender: KeptSender): void;
|
|
21
|
+
sent(operation: string, sender: KeptSender): void;
|
|
22
|
+
settled(operation: string): Promise<void>;
|
|
23
|
+
settle(operation: string, lost: boolean): void;
|
|
24
|
+
unclaimed(operation: string): boolean;
|
|
17
25
|
};
|
|
18
|
-
export declare function createLanes({ generation, continuing, stopping }: LaneRules): Lanes;
|
|
26
|
+
export declare function createLanes({ generation, continuing, stopping, failed }: LaneRules): Lanes;
|
|
19
27
|
export {};
|
|
20
28
|
//# sourceMappingURL=lanes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/socket/lanes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/socket/lanes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAAA;CAAE,CAAC;AAIzD,KAAK,SAAS,GAAG;IACf,UAAU,IAAI,MAAM,CAAC;IACrB,UAAU,IAAI,OAAO,CAAC;IACtB,QAAQ,IAAI,OAAO,CAAC;IACpB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,K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js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const ROOM_READS = 256;
|
|
2
|
-
export function createLanes({ generation, continuing, stopping }) {
|
|
2
|
+
export function createLanes({ generation, continuing, stopping, failed }) {
|
|
3
3
|
const lanes = new Map();
|
|
4
4
|
const roomLanes = new Map();
|
|
5
5
|
const roomReads = { free: ROOM_READS, waiting: [] };
|
|
6
6
|
const working = new Set();
|
|
7
|
-
const
|
|
7
|
+
const senders = new Map();
|
|
8
|
+
const settlements = new Map();
|
|
9
|
+
const unclaimed = new Set();
|
|
8
10
|
let roomWork = 0;
|
|
9
11
|
async function admittedRead(work) {
|
|
10
12
|
while (roomReads.free === 0) {
|
|
@@ -59,19 +61,43 @@ export function createLanes({ generation, continuing, stopping }) {
|
|
|
59
61
|
roomTask(locator, work) {
|
|
60
62
|
if (stopping())
|
|
61
63
|
return Promise.resolve();
|
|
62
|
-
return inRoom(locator, (live) => admittedRead(() => work(live))).catch(() =>
|
|
64
|
+
return inRoom(locator, (live) => admittedRead(() => work(live))).catch((error) => {
|
|
65
|
+
if (!stopping())
|
|
66
|
+
failed(locator, error);
|
|
67
|
+
});
|
|
63
68
|
},
|
|
64
69
|
roomWork: () => roomWork,
|
|
65
70
|
current: () => Promise.all([...lanes.values()]
|
|
66
71
|
.filter((held) => held.generation === generation())
|
|
67
72
|
.map((held) => held.chain)),
|
|
68
73
|
finished: () => Promise.all(working),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
sender: (operation) => senders.get(operation),
|
|
75
|
+
sending(operation, sender) {
|
|
76
|
+
senders.set(operation, sender);
|
|
72
77
|
},
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
sent(operation, sender) {
|
|
79
|
+
if (senders.get(operation) === sender)
|
|
80
|
+
senders.delete(operation);
|
|
75
81
|
},
|
|
82
|
+
settled(operation) {
|
|
83
|
+
if (unclaimed.delete(operation))
|
|
84
|
+
return Promise.resolve();
|
|
85
|
+
return new Promise((settle) => {
|
|
86
|
+
const earlier = settlements.get(operation);
|
|
87
|
+
settlements.set(operation, () => {
|
|
88
|
+
earlier?.();
|
|
89
|
+
settle();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
settle(operation, lost) {
|
|
94
|
+
const settle = settlements.get(operation);
|
|
95
|
+
settlements.delete(operation);
|
|
96
|
+
if (settle !== undefined)
|
|
97
|
+
settle();
|
|
98
|
+
else if (lost)
|
|
99
|
+
unclaimed.add(operation);
|
|
100
|
+
},
|
|
101
|
+
unclaimed: (operation) => unclaimed.has(operation),
|
|
76
102
|
};
|
|
77
103
|
}
|
package/dist/socket/session.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Authorization, ProviderRefusal, ServiceMode } from '../adapter.js';
|
|
1
|
+
import type { Authorization, Discovery, ProviderRefusal, QueriedRoom, ServiceMode } from '../adapter.js';
|
|
2
2
|
import { type Cell } from '../cell.js';
|
|
3
3
|
import type { Open } from '../open.js';
|
|
4
4
|
import type { CycleProgress, SyncStatus } from '../status.js';
|
|
@@ -23,6 +23,9 @@ export type Session = {
|
|
|
23
23
|
readonly discoveries: number;
|
|
24
24
|
readonly roomsNamed: boolean;
|
|
25
25
|
readonly roomsListed: boolean;
|
|
26
|
+
readonly queriesOnly: readonly QueriedRoom[];
|
|
27
|
+
readonly unstored: Discovery | null;
|
|
28
|
+
readonly lastCompleted: string | null;
|
|
26
29
|
readonly serviceMode: ServiceMode;
|
|
27
30
|
readonly haltedRefusal: boolean;
|
|
28
31
|
readonly openSignals: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX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MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;CACzC,CAAC;AAEF,wBAAgB,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,CAwBrF"}
|
package/dist/socket/session.js
CHANGED
package/dist/socket.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Adapter, Authorization, ConversationEvent, Discovery, HeldRoom, RoomStreamEvent, ServiceMode } from './adapter.js';
|
|
2
2
|
import type { Reads } from './bootstrap.js';
|
|
3
3
|
import type { Cell } from './cell.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Retries } from './retried.js';
|
|
5
5
|
import { type Admission } from './socket/admission.js';
|
|
6
6
|
import { type Answers } from './socket/answers.js';
|
|
7
7
|
import { type Lanes } from './socket/lanes.js';
|
|
8
8
|
import { type Session } from './socket/session.js';
|
|
9
|
-
export type { Live } from './socket/lanes.js';
|
|
9
|
+
export type { KeptSender, Live } from './socket/lanes.js';
|
|
10
10
|
export type { ConnectionRefusal, ConnectionRefusalCode, Moving, RefusalReason, } from './socket/session.js';
|
|
11
11
|
type SocketEvent = {
|
|
12
12
|
readonly kind: 'opened';
|
|
@@ -31,6 +31,7 @@ export type RuntimeSocket = Admission & Answers & {
|
|
|
31
31
|
readonly firstDiscovery: Promise<void>;
|
|
32
32
|
conversations(): Adapter['conversations'];
|
|
33
33
|
search(): Adapter['search'];
|
|
34
|
+
queryHouse(): Adapter['queryHouse'];
|
|
34
35
|
discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
|
|
35
36
|
follows: Adapter['follows'];
|
|
36
37
|
mutate: Adapter['mutate'];
|
|
@@ -63,5 +64,5 @@ export type RuntimeSocket = Admission & Answers & {
|
|
|
63
64
|
abortReads(): void;
|
|
64
65
|
stopReads(): void;
|
|
65
66
|
};
|
|
66
|
-
export declare function createSocket(adapter: Adapter,
|
|
67
|
+
export declare function createSocket(adapter: Adapter, retries: Retries, authorization: Authorization | undefined): RuntimeSocket;
|
|
67
68
|
//# sourceMappingURL=socket.d.ts.map
|