@agentshouse/mdruntime 0.1.0-cd507e16e5fc0 → 0.1.0-cd574a610e9c8
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 +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +75 -165
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +118 -67
- package/dist/adapter.d.ts +90 -58
- 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 +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -19
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +0 -2
- package/dist/client.d.ts +13 -20
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -20
- package/dist/collection.d.ts +25 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +19 -2
- 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 +31 -25
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +31 -24
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +26 -12
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +23 -12
- 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 +37 -12
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +320 -234
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +19 -44
- package/dist/durability.d.ts +4 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- 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 +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +59 -15
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -7
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +92 -111
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +54 -40
- package/dist/listing.d.ts +11 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +48 -72
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +74 -33
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- package/dist/media.d.ts +6 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +68 -17
- package/dist/memory.d.ts +8 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +92 -33
- package/dist/messages.d.ts +12 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +30 -38
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -139
- package/dist/observation.d.ts +27 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +184 -85
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +5 -9
- package/dist/outcome.d.ts +13 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +32 -2
- package/dist/overlay.d.ts +6 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -24
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +10 -115
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +156 -68
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +67 -31
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +1 -7
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +2 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +88 -26
- package/dist/react.d.ts +8 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +9 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +4 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +11 -4
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/replica.d.ts +5 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -17
- 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 +31 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +273 -66
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +22 -18
- 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 +9 -10
- package/dist/runtime.d.ts +9 -18
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +42 -90
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +327 -229
- package/dist/saves.d.ts +4 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +143 -714
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -5
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -90
- package/dist/shown.d.ts +7 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +77 -63
- 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 +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +3 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +5 -16
- package/dist/source.d.ts +5 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +18 -6
- 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 +18 -7
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +58 -24
- 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/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +23 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +46 -17
- package/dist/stored.d.ts +25 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +83 -32
- package/dist/surface.d.ts +5 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +25 -23
- package/dist/sync.d.ts +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +96 -92
- package/dist/tables.d.ts +16 -57
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +91 -332
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +4 -10
- package/dist/wire.d.ts +53 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +17 -4
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -44
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
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,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;KAAE,EAAE,CAAC;CACpF,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC;AAEjG,KAAK,WAAW,GAAG,CACjB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,KAAK,KAAK,EACjD,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAChC,MAAM,IAAI,CAAC;AA0ChB,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAe5D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAmBtD;AA+BD,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAOxF;AAYD,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAMlE;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,WAAW,GACjB,MAAM,IAAI,CA4BZ"}
|
package/dist/seed.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { queryKey } from '@agentshouse/mdmodel';
|
|
2
|
-
import { whole } from './observation.js';
|
|
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) {
|
|
@@ -62,7 +62,6 @@ export function seededResult(seed) {
|
|
|
62
62
|
generation,
|
|
63
63
|
current: false,
|
|
64
64
|
})),
|
|
65
|
-
indexes: [],
|
|
66
65
|
overlay: [],
|
|
67
66
|
};
|
|
68
67
|
if ('groups' in seed.rows) {
|
|
@@ -83,9 +82,9 @@ function seedRoomHeld({ socket }, room, version, held) {
|
|
|
83
82
|
socket.reads.reached(room, stored.roomVersion, version));
|
|
84
83
|
}
|
|
85
84
|
function seedHeld(runtime, at, held) {
|
|
86
|
-
const { socket } = runtime;
|
|
85
|
+
const { socket, presence } = runtime;
|
|
87
86
|
return Object.entries(at).every(([room, version]) => (socket.session.now().roomsListed &&
|
|
88
|
-
|
|
87
|
+
presence.room(room) === undefined &&
|
|
89
88
|
!held.rooms.has(room)) ||
|
|
90
89
|
seedRoomHeld(runtime, room, version, held));
|
|
91
90
|
}
|
|
@@ -131,7 +130,7 @@ export function watchSeeded(runtime, plan, deliver, watch) {
|
|
|
131
130
|
const watcher = store.watch(seedTopic(plan.key), shown);
|
|
132
131
|
const stop = watch((cover, held) => seedBehind(runtime, plan, cover, held), (message) => {
|
|
133
132
|
const answered = message;
|
|
134
|
-
pending = whole(answered)
|
|
133
|
+
pending = whole(answered) ? 'pending' in answered.result : pendingChange(answered);
|
|
135
134
|
if (pending && store.seeds.of(plan.key) !== undefined) {
|
|
136
135
|
shown();
|
|
137
136
|
return;
|
package/dist/shared.d.ts
CHANGED
|
@@ -3,12 +3,7 @@ export declare function guarding<V>(values: Paths<V>, handler: ProxyHandler<Path
|
|
|
3
3
|
export declare function entriesIn<V>(map: Paths<V>): Generator<readonly [string, V]>;
|
|
4
4
|
export declare function sortedKeys(map: Paths<unknown>): Generator<number, readonly string[], void>;
|
|
5
5
|
export declare function sorting(keys: Iterable<string>): Generator<number, readonly string[], void>;
|
|
6
|
-
export declare function sharing<V>(map: Paths<V>): Generator<number, Paths<V>, void>;
|
|
7
|
-
export declare function shared<V>(map: Paths<V>): Paths<V>;
|
|
8
|
-
export declare function patched<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Paths<V>;
|
|
9
6
|
export declare function patching<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Generator<number, Paths<V>, void>;
|
|
10
|
-
export declare function differences<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): Generator<number, ReadonlySet<string>, void>;
|
|
11
|
-
export declare function differing<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): ReadonlySet<string>;
|
|
12
7
|
export declare function drafted<V>(base: Paths<V>): Record<string, V>;
|
|
13
8
|
export declare function settled<V>(draft: Record<string, V>): Paths<V>;
|
|
14
9
|
export declare function settling<V>(draft: Record<string, V>): Generator<number, Paths<V>, void>;
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AA8LnD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAIvF;AAED,wBAAiB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAQ5E;AAqCD,wBAAiB,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,CAAC,CAE3F;AAED,wBAAiB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,CAAC,CAoB3F;AAED,wBAAiB,QAAQ,CAAC,CAAC,EACzB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,GAAG,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EACnC,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAM,GAC7B,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAgBnC;AAMD,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAiD5D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE7D;AAED,wBAAiB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAUxF"}
|
package/dist/shared.js
CHANGED
|
@@ -100,21 +100,15 @@ function lone(node) {
|
|
|
100
100
|
}
|
|
101
101
|
function taken(node, hash, key, shift) {
|
|
102
102
|
if (isLeaf(node))
|
|
103
|
-
return
|
|
103
|
+
return undefined;
|
|
104
104
|
if (isCollision(node)) {
|
|
105
105
|
const leaves = node.leaves.filter((leaf) => leaf.key !== key);
|
|
106
|
-
if (leaves.length === node.leaves.length)
|
|
107
|
-
return node;
|
|
108
106
|
return leaves.length === 1 ? leaves[0] : { hash: node.hash, leaves };
|
|
109
107
|
}
|
|
110
108
|
const bit = 1 << fragment(hash, shift);
|
|
111
|
-
if ((node.bitmap & bit) === 0)
|
|
112
|
-
return node;
|
|
113
109
|
const at = slot(node.bitmap, bit);
|
|
114
110
|
const child = node.children[at];
|
|
115
111
|
const next = taken(child, hash, key, shift + BITS);
|
|
116
|
-
if (next === child)
|
|
117
|
-
return node;
|
|
118
112
|
if (next === undefined) {
|
|
119
113
|
if (node.children.length === 1)
|
|
120
114
|
return undefined;
|
|
@@ -201,13 +195,11 @@ function* rooted(map) {
|
|
|
201
195
|
if (held !== undefined)
|
|
202
196
|
return held;
|
|
203
197
|
let node;
|
|
204
|
-
let size = 0;
|
|
205
198
|
for (const [key, value] of entriesIn(map)) {
|
|
206
199
|
node = put(node, { key, hash: hashOf(key), value }, 0);
|
|
207
|
-
size += 1;
|
|
208
200
|
yield ROW_WEIGHT;
|
|
209
201
|
}
|
|
210
|
-
return { node
|
|
202
|
+
return { node };
|
|
211
203
|
}
|
|
212
204
|
const RUN = 1 << 10;
|
|
213
205
|
function* merged(left, right) {
|
|
@@ -251,103 +243,25 @@ export function* sorting(keys) {
|
|
|
251
243
|
}
|
|
252
244
|
return runs[0] ?? [];
|
|
253
245
|
}
|
|
254
|
-
export function* sharing(map) {
|
|
255
|
-
return roots.has(map) ? map : facade(yield* rooted(map));
|
|
256
|
-
}
|
|
257
|
-
export function shared(map) {
|
|
258
|
-
return finished(sharing(map));
|
|
259
|
-
}
|
|
260
|
-
export function patched(base, set, removed = []) {
|
|
261
|
-
return finished(patching(base, set, removed));
|
|
262
|
-
}
|
|
263
246
|
export function* patching(base, set, removed = []) {
|
|
264
247
|
const root = yield* rooted(base);
|
|
265
248
|
let node = root.node;
|
|
266
|
-
let size = root.size;
|
|
267
249
|
for (const key of removed) {
|
|
268
250
|
if (node === undefined)
|
|
269
251
|
break;
|
|
270
|
-
const before = lookup({ node
|
|
252
|
+
const before = lookup({ node }, key);
|
|
271
253
|
if (before === undefined)
|
|
272
254
|
continue;
|
|
273
255
|
node = taken(node, before.hash, key, 0);
|
|
274
|
-
size -= 1;
|
|
275
256
|
yield ROW_WEIGHT;
|
|
276
257
|
}
|
|
277
258
|
for (const [key, value] of set) {
|
|
278
|
-
const before = lookup({ node, size }, key);
|
|
279
259
|
node = put(node, { key, hash: hashOf(key), value }, 0);
|
|
280
|
-
if (before === undefined)
|
|
281
|
-
size += 1;
|
|
282
260
|
yield ROW_WEIGHT;
|
|
283
261
|
}
|
|
284
262
|
if (node === root.node && roots.has(base))
|
|
285
263
|
return base;
|
|
286
|
-
return facade({ node
|
|
287
|
-
}
|
|
288
|
-
function* compared(left, right, same, into) {
|
|
289
|
-
const pending = [[left, right]];
|
|
290
|
-
for (let pair = pending.pop(); pair !== undefined; pair = pending.pop()) {
|
|
291
|
-
const [one, other] = pair;
|
|
292
|
-
if (one === other)
|
|
293
|
-
continue;
|
|
294
|
-
if (one !== undefined &&
|
|
295
|
-
other !== undefined &&
|
|
296
|
-
!isLeaf(one) &&
|
|
297
|
-
!isCollision(one) &&
|
|
298
|
-
!isLeaf(other) &&
|
|
299
|
-
!isCollision(other)) {
|
|
300
|
-
const children = [];
|
|
301
|
-
for (let remaining = one.bitmap | other.bitmap; remaining !== 0; remaining &= remaining - 1) {
|
|
302
|
-
const bit = remaining & -remaining;
|
|
303
|
-
children.push([
|
|
304
|
-
(one.bitmap & bit) === 0 ? undefined : one.children[slot(one.bitmap, bit)],
|
|
305
|
-
(other.bitmap & bit) === 0 ? undefined : other.children[slot(other.bitmap, bit)],
|
|
306
|
-
]);
|
|
307
|
-
}
|
|
308
|
-
pending.push(...children.reverse());
|
|
309
|
-
continue;
|
|
310
|
-
}
|
|
311
|
-
const before = new Map();
|
|
312
|
-
for (const leaf of leavesOf(one)) {
|
|
313
|
-
before.set(leaf.key, leaf.value);
|
|
314
|
-
yield ROW_WEIGHT;
|
|
315
|
-
}
|
|
316
|
-
for (const leaf of leavesOf(other)) {
|
|
317
|
-
const held = before.get(leaf.key);
|
|
318
|
-
before.delete(leaf.key);
|
|
319
|
-
if (held === undefined || !same(held, leaf.value))
|
|
320
|
-
into.add(leaf.key);
|
|
321
|
-
yield ROW_WEIGHT;
|
|
322
|
-
}
|
|
323
|
-
for (const key of before.keys())
|
|
324
|
-
into.add(key);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
export function* differences(left, right, same = Object.is) {
|
|
328
|
-
const into = new Set();
|
|
329
|
-
if (left === right)
|
|
330
|
-
return into;
|
|
331
|
-
const leftRoot = roots.get(left);
|
|
332
|
-
const rightRoot = roots.get(right);
|
|
333
|
-
if (leftRoot !== undefined && rightRoot !== undefined) {
|
|
334
|
-
yield* compared(leftRoot.node, rightRoot.node, same, into);
|
|
335
|
-
return into;
|
|
336
|
-
}
|
|
337
|
-
for (const [key, value] of entriesIn(left)) {
|
|
338
|
-
if (!Object.hasOwn(right, key) || !same(value, right[key]))
|
|
339
|
-
into.add(key);
|
|
340
|
-
yield ROW_WEIGHT;
|
|
341
|
-
}
|
|
342
|
-
for (const [key] of entriesIn(right)) {
|
|
343
|
-
if (!Object.hasOwn(left, key))
|
|
344
|
-
into.add(key);
|
|
345
|
-
yield ROW_WEIGHT;
|
|
346
|
-
}
|
|
347
|
-
return into;
|
|
348
|
-
}
|
|
349
|
-
export function differing(left, right, same = Object.is) {
|
|
350
|
-
return finished(differences(left, right, same));
|
|
264
|
+
return facade({ node });
|
|
351
265
|
}
|
|
352
266
|
const drafts = new WeakMap();
|
|
353
267
|
const GONE = Symbol('gone');
|
package/dist/shown.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { Member } from './adapter.js';
|
|
2
|
+
import { type ChangeSet } from './change-set.js';
|
|
3
3
|
import type { QueueEntry } from './outcome.js';
|
|
4
4
|
import type { Runtime } from './runtime.js';
|
|
5
5
|
import type { Live, Moving } from './socket.js';
|
|
@@ -13,11 +13,12 @@ export declare const MEMBER_TOPIC = "member";
|
|
|
13
13
|
export declare const AUTHORITY_TOPIC = "authority-changes";
|
|
14
14
|
export declare const LOCKS_TOPIC = "locks";
|
|
15
15
|
export declare const queueTopic: (locator: string) => string;
|
|
16
|
-
export declare function recoverReads({ liveQueries, figures }: Runtime): void;
|
|
16
|
+
export declare function recoverReads({ liveQueries, figures }: Runtime, locators?: readonly string[]): void;
|
|
17
17
|
export declare function emitRooms(runtime: Runtime, changed?: readonly string[]): Promise<void>;
|
|
18
18
|
export declare function emitKnownRooms(runtime: Runtime): void;
|
|
19
19
|
export declare function emitRefusal(runtime: Runtime): void;
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function storageLossNow({ store }: Runtime): string | null;
|
|
21
|
+
export declare function emitStorageLoss(runtime: Runtime): void;
|
|
21
22
|
export declare function emitMember({ store }: Runtime, member: Member | null): void;
|
|
22
23
|
export declare function show(runtime: Runtime): Promise<void>;
|
|
23
24
|
export declare function moveTo(runtime: Runtime, next: Moving): Promise<void>;
|
|
@@ -26,6 +27,7 @@ export declare function transferring({ socket }: Runtime): Moving;
|
|
|
26
27
|
export declare function pendingShown(runtime: Runtime): Promise<void>;
|
|
27
28
|
export declare function entriesOf(runtime: Runtime, locator: string): Promise<readonly QueueEntry[]>;
|
|
28
29
|
export declare function publishChangeSet(runtime: Runtime, set: ChangeSet): Promise<void>;
|
|
29
|
-
export declare function
|
|
30
|
+
export declare function submissionDue(runtime: Runtime, locators?: readonly string[]): Promise<void>;
|
|
31
|
+
export declare function roomUnreadable(runtime: Runtime, locator: string): void;
|
|
30
32
|
export declare function rest(runtime: Runtime, progress: CycleProgress | null, live?: Live): Promise<void>;
|
|
31
33
|
//# sourceMappingURL=shown.d.ts.map
|
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,
|
|
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,sBAAsB,CAAC;AAEnD,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,UAAU,YAAa,MAAM,WAA4B,CAAC;AAqCvE,wBAAgB,YAAY,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,QAG3F;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAMtF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAI9C;AAiFD,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAK3C;AAED,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,QAG/C;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,QAEnE;AA0BD,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAepD;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,CAExD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5D;AAYD,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAGjG;AAcD,wBAAgB,gBAAgB,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,CAOjG;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,iBAiC5C"}
|
package/dist/shown.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
1
2
|
import { conversationsChanged, conversationsLearned } from './conversation.js';
|
|
2
|
-
import {
|
|
3
|
+
import { lossStated } from './durability.js';
|
|
4
|
+
import { listedEntries, listingNow, shownChange, shownRooms } from './listing.js';
|
|
3
5
|
import { emitPresentation, publishRoomDrafts } from './room-drafts.js';
|
|
4
6
|
import { same } from './status.js';
|
|
5
7
|
export const ROOMS_TOPIC = 'rooms';
|
|
@@ -12,9 +14,8 @@ export const AUTHORITY_TOPIC = 'authority-changes';
|
|
|
12
14
|
export const LOCKS_TOPIC = 'locks';
|
|
13
15
|
export const queueTopic = (locator) => `queue\u0000${locator}`;
|
|
14
16
|
async function attended({ store, localSaves }) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const attentionRequired = held.returned.flatMap((record) => record.returned === null || isFenced(record.locator)
|
|
17
|
+
const held = await store.status();
|
|
18
|
+
const attentionRequired = held.returned.flatMap((record) => record.returned === null
|
|
18
19
|
? []
|
|
19
20
|
: [{ room: record.locator, path: record.path, returned: structuredClone(record.returned) }]);
|
|
20
21
|
attentionRequired.sort((left, right) => {
|
|
@@ -26,33 +27,30 @@ async function attended({ store, localSaves }) {
|
|
|
26
27
|
});
|
|
27
28
|
const changed = new Map();
|
|
28
29
|
if (!localSaves) {
|
|
29
|
-
for (const change of held.unsent)
|
|
30
|
-
|
|
31
|
-
changed.set(`${change.room}\u0000${change.path}`, change);
|
|
32
|
-
}
|
|
30
|
+
for (const change of held.unsent)
|
|
31
|
+
changed.set(`${change.room}\u0000${change.path}`, change);
|
|
33
32
|
}
|
|
34
33
|
const unsent = [...changed]
|
|
35
34
|
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
|
|
36
35
|
.map(([, change]) => change);
|
|
37
36
|
return {
|
|
38
|
-
queued: !localSaves && held.queued.
|
|
37
|
+
queued: !localSaves && held.queued.length > 0,
|
|
39
38
|
lastCompleted: held.lastCompleted,
|
|
40
39
|
attentionRequired,
|
|
41
40
|
unsent,
|
|
42
|
-
reset: held.resets.reduce((earliest, {
|
|
41
|
+
reset: held.resets.reduce((earliest, { reset }) => (earliest !== null && earliest <= reset ? earliest : reset), null),
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
44
|
async function queuedWork({ store, localSaves }) {
|
|
46
|
-
|
|
47
|
-
return !localSaves && held.some((locator) => !store.fences.has(locator));
|
|
45
|
+
return !localSaves && (await store.queued()).length > 0;
|
|
48
46
|
}
|
|
49
|
-
export function recoverReads({ liveQueries, figures }) {
|
|
50
|
-
liveQueries.recover();
|
|
47
|
+
export function recoverReads({ liveQueries, figures }, locators) {
|
|
48
|
+
liveQueries.recover(locators);
|
|
51
49
|
figures.recover();
|
|
52
50
|
}
|
|
53
51
|
export function emitRooms(runtime, changed) {
|
|
54
|
-
recoverReads(runtime);
|
|
55
|
-
runtime.store.readiness.queue();
|
|
52
|
+
recoverReads(runtime, changed);
|
|
53
|
+
runtime.store.readiness.queue(changed);
|
|
56
54
|
return changed === undefined
|
|
57
55
|
? publishRooms(runtime, 'all')
|
|
58
56
|
: publishRooms(runtime, 'changed', changed);
|
|
@@ -77,53 +75,58 @@ function roomsOwedWith(held, mode, touched) {
|
|
|
77
75
|
}
|
|
78
76
|
return held;
|
|
79
77
|
}
|
|
78
|
+
async function patchedRooms(runtime, owed) {
|
|
79
|
+
const { store } = runtime;
|
|
80
|
+
const touched = [...new Set([...owed.changed, ...owed.counted])];
|
|
81
|
+
const entries = await listedEntries(runtime, touched);
|
|
82
|
+
const shown = store.roomsShown.now();
|
|
83
|
+
if (entries === null || shown === null)
|
|
84
|
+
return false;
|
|
85
|
+
if (runtime.socket.closed())
|
|
86
|
+
return true;
|
|
87
|
+
const moved = entries.filter(({ locator, documents }) => owed.changed.has(locator) || shown.get(locator)?.documents !== documents);
|
|
88
|
+
const counted = moved.flatMap(({ locator }) => (owed.changed.has(locator) ? [] : [locator]));
|
|
89
|
+
if (counted.length > 0) {
|
|
90
|
+
recoverReads(runtime, counted);
|
|
91
|
+
store.readiness.queue(counted);
|
|
92
|
+
}
|
|
93
|
+
store.roomsShown.patch(moved);
|
|
94
|
+
if (moved.length === 0)
|
|
95
|
+
return true;
|
|
96
|
+
const change = shownChange(runtime, moved);
|
|
97
|
+
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
98
|
+
watcher.answer(change);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
80
101
|
async function deliverRooms(runtime, owed) {
|
|
81
102
|
const { store, socket } = runtime;
|
|
82
103
|
const waiting = () => store.watching(ROOMS_TOPIC, 'waiting');
|
|
83
104
|
if (socket.closed() || store.watching(ROOMS_TOPIC).length === 0)
|
|
84
105
|
return;
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (
|
|
106
|
+
const touched = owed.changed.size > 0 || owed.counted.size > 0;
|
|
107
|
+
if (!owed.all && touched && waiting().length === 0 && (await patchedRooms(runtime, owed)))
|
|
108
|
+
return;
|
|
109
|
+
if (touched)
|
|
89
110
|
owed.all = true;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (held === null)
|
|
93
|
-
return;
|
|
94
|
-
const { roomsShown } = store.device.now();
|
|
95
|
-
owed.all = [...owed.counted].some((locator) => held.rooms.has(locator) &&
|
|
96
|
-
roomsShown?.get(locator)?.documents !== held.rooms.get(locator).documents);
|
|
97
|
-
if (owed.all) {
|
|
98
|
-
recoverReads(runtime);
|
|
99
|
-
store.readiness.queue();
|
|
100
|
-
}
|
|
101
|
-
else if (waiting().length === 0)
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const listing = patched ?? (await listingNow(runtime).catch(() => null));
|
|
105
|
-
if (listing === null || socket.closed())
|
|
111
|
+
const listing = await listingNow(runtime);
|
|
112
|
+
if (socket.closed())
|
|
106
113
|
return;
|
|
107
|
-
const value = shownRooms(runtime, listing);
|
|
108
114
|
const { roomsListed, refusal, moving } = socket.session.now();
|
|
109
115
|
const joining = waiting().length > 0 &&
|
|
110
116
|
(roomsListed || listing.size > 0 || refusal !== null || moving.providerUnreachable);
|
|
111
|
-
if (!owed.all &&
|
|
117
|
+
if (!owed.all && !joining)
|
|
112
118
|
return;
|
|
113
|
-
const
|
|
119
|
+
const value = shownRooms(runtime, listing);
|
|
120
|
+
const shown = store.roomsShown.now();
|
|
114
121
|
const moved = owed.all ||
|
|
115
|
-
|
|
116
|
-
(roomsShown !== null &&
|
|
117
|
-
JSON.stringify(shownRooms(runtime, roomsShown)) !== JSON.stringify(value));
|
|
122
|
+
(shown !== null && JSON.stringify(shownRooms(runtime, shown)) !== JSON.stringify(value));
|
|
118
123
|
if (moved)
|
|
119
124
|
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
120
125
|
watcher.answer(value);
|
|
121
126
|
if (joining)
|
|
122
127
|
for (const watcher of waiting())
|
|
123
128
|
watcher.answer(value);
|
|
124
|
-
store.
|
|
125
|
-
roomsShown: store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing,
|
|
126
|
-
});
|
|
129
|
+
store.roomsShown.show(store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing);
|
|
127
130
|
}
|
|
128
131
|
function publishRooms(runtime, mode, touched = []) {
|
|
129
132
|
if (runtime.socket.closed())
|
|
@@ -132,13 +135,17 @@ function publishRooms(runtime, mode, touched = []) {
|
|
|
132
135
|
}
|
|
133
136
|
export function emitRefusal(runtime) {
|
|
134
137
|
const { store, socket } = runtime;
|
|
135
|
-
store.readiness.queue();
|
|
138
|
+
store.readiness.queue([]);
|
|
136
139
|
store.tell(REFUSAL_TOPIC, socket.session.now().refusal);
|
|
137
140
|
emitKnownRooms(runtime);
|
|
138
141
|
}
|
|
139
|
-
export function
|
|
140
|
-
store.
|
|
141
|
-
|
|
142
|
+
export function storageLossNow({ store }) {
|
|
143
|
+
const { persistence, storageLoss } = store.device.now();
|
|
144
|
+
return lossStated(persistence, storageLoss);
|
|
145
|
+
}
|
|
146
|
+
export function emitStorageLoss(runtime) {
|
|
147
|
+
runtime.store.readiness.queue([]);
|
|
148
|
+
runtime.store.tell(STORAGE_LOSS_TOPIC, storageLossNow(runtime));
|
|
142
149
|
}
|
|
143
150
|
export function emitMember({ store }, member) {
|
|
144
151
|
store.tell(MEMBER_TOPIC, member);
|
|
@@ -164,13 +171,16 @@ async function deliverStatus(runtime, owed) {
|
|
|
164
171
|
store.tell(STATUS_TOPIC, next);
|
|
165
172
|
}
|
|
166
173
|
}
|
|
174
|
+
function conversationsCurrent({ conversations }) {
|
|
175
|
+
return conversations.listed() && conversations.current();
|
|
176
|
+
}
|
|
167
177
|
export function show(runtime) {
|
|
168
|
-
const { store, socket
|
|
178
|
+
const { store, socket } = runtime;
|
|
169
179
|
if (socket.closed())
|
|
170
180
|
return Promise.resolve();
|
|
171
|
-
store.readiness.queue();
|
|
181
|
+
store.readiness.queue([]);
|
|
172
182
|
emitKnownRooms(runtime);
|
|
173
|
-
const moved = { moving: socket.session.now().moving, current:
|
|
183
|
+
const moved = { moving: socket.session.now().moving, current: conversationsCurrent(runtime) };
|
|
174
184
|
return store.owing(STATUS_TOPIC, (held) => {
|
|
175
185
|
if (held === undefined)
|
|
176
186
|
return [moved];
|
|
@@ -204,10 +214,7 @@ function entryOf({ localSaves }, states, batch) {
|
|
|
204
214
|
return Object.freeze({ batch, ...(state?.submission ?? { state: 'waiting' }) });
|
|
205
215
|
}
|
|
206
216
|
export async function entriesOf(runtime, locator) {
|
|
207
|
-
const {
|
|
208
|
-
if (store.fences.has(locator))
|
|
209
|
-
return [];
|
|
210
|
-
const { queue, states } = await store.work(locator);
|
|
217
|
+
const { queue, states } = await runtime.store.work(locator);
|
|
211
218
|
return queue.map((batch) => entryOf(runtime, states, batch));
|
|
212
219
|
}
|
|
213
220
|
function emitQueue(runtime, locator) {
|
|
@@ -253,20 +260,27 @@ export function publishChangeSet(runtime, set) {
|
|
|
253
260
|
conversationsChanged(conversations, set);
|
|
254
261
|
return Promise.all(shownNow).then(() => undefined);
|
|
255
262
|
}
|
|
256
|
-
export function
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
263
|
+
export async function submissionDue(runtime, locators) {
|
|
264
|
+
const { store } = runtime;
|
|
265
|
+
const due = (await store.queued()).filter((locator) => locators === undefined || locators.includes(locator));
|
|
266
|
+
if (due.length === 0)
|
|
267
|
+
return;
|
|
268
|
+
await store.changed(mergeChangeSets(due.map((locator) => changeSet(locator, { due: true }))));
|
|
269
|
+
}
|
|
270
|
+
export function roomUnreadable(runtime, locator) {
|
|
271
|
+
runtime.presence.refused(locator, null);
|
|
272
|
+
emitRooms(runtime, [locator]);
|
|
260
273
|
}
|
|
261
274
|
export async function rest(runtime, progress, live = () => !runtime.socket.closed()) {
|
|
262
|
-
const { store, socket } = runtime;
|
|
263
|
-
const { session, lanes
|
|
275
|
+
const { store, socket, presence } = runtime;
|
|
276
|
+
const { session, lanes } = socket;
|
|
264
277
|
if (!live())
|
|
265
278
|
return;
|
|
266
279
|
const settled = () => session.now().complete &&
|
|
267
280
|
lanes.roomWork() === 0 &&
|
|
268
281
|
!socket.naming() &&
|
|
269
|
-
|
|
282
|
+
presence.settled() &&
|
|
283
|
+
conversationsCurrent(runtime);
|
|
270
284
|
let synced = settled();
|
|
271
285
|
if (synced && !session.now().recorded) {
|
|
272
286
|
const queued = await queuedWork(runtime).catch(() => 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,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,QAAQ,IAAI,MAAM,CAAC;IACnB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAClD,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAClD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CACvC,CAAC;AAIF,wBAAgB,WAAW,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,GAAG,KAAK,CAqG1F"}
|
package/dist/socket/lanes.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
|
@@ -6,7 +6,6 @@ export type RefusalReason = 'missing-required-guarantee' | 'revoked-authorizatio
|
|
|
6
6
|
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
7
7
|
export type ConnectionRefusal = {
|
|
8
8
|
code: ConnectionRefusalCode;
|
|
9
|
-
retryable: boolean;
|
|
10
9
|
reauthorizationOffered: boolean;
|
|
11
10
|
refusal: ProviderRefusal | null;
|
|
12
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,4BAA4B,GAAG,uBAAuB,CAAC;AAEnF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,4BAA4B,GAAG,uBAAuB,CAAC;AAEnF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,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,CAqBrF"}
|