@agentshouse/mdruntime 0.1.0-ce6bc9239a3ee → 0.1.0-ce80727f9590f
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 +2 -25
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +119 -204
- 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 +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +321 -0
- package/dist/adapter.d.ts +114 -57
- 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 -18
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- 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 +2 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -2
- package/dist/client.d.ts +25 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +45 -58
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +28 -10
- 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 +4 -116
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +103 -2994
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +150 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +22 -3
- package/dist/conversation.d.ts +57 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +974 -1031
- 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 +12 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- 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 +14 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +5 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +23 -12
- 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 +8 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +20 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +83 -19
- package/dist/house-query.d.ts +21 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +41 -0
- package/dist/index.d.ts +28 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -6
- package/dist/install.d.ts +22 -48
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +161 -161
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +290 -0
- package/dist/listing.d.ts +60 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +168 -0
- 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 +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +34 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +19 -2
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +105 -27
- package/dist/memory.d.ts +9 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +94 -32
- package/dist/messages.d.ts +12 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +35 -39
- 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 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -5
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +217 -85
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- 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 +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +70 -0
- package/dist/outcome.d.ts +16 -2
- 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 +5 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +28 -110
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +41 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +326 -0
- 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 +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +287 -0
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +3 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +4 -6
- 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 +15 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +164 -33
- package/dist/react.d.ts +17 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +9 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +5 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +49 -7
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +17 -18
- 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 +7 -12
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +44 -40
- 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/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +36 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +326 -225
- package/dist/saves.d.ts +8 -70
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +199 -761
- package/dist/seed.d.ts +3 -8
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +21 -17
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +35 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +326 -0
- package/dist/socket/lanes.d.ts +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/session.d.ts +41 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +26 -0
- package/dist/socket.d.ts +30 -5
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +75 -6
- 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 +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +22 -8
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +84 -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 +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +2 -0
- package/dist/store/watchers.d.ts.map +1 -1
- package/dist/store/watchers.js +23 -3
- package/dist/store.d.ts +50 -9
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +78 -17
- package/dist/stored.d.ts +25 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +99 -36
- package/dist/surface.d.ts +94 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +255 -0
- package/dist/sync.d.ts +21 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +557 -0
- package/dist/tables.d.ts +28 -59
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +106 -331
- 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 +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +26 -9
- 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/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/install.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { attachedModel } from './attached-model.js';
|
|
2
2
|
import { bootstrapRoom } from './bootstrap.js';
|
|
3
3
|
import { refusedForSpace } from './durability.js';
|
|
4
|
+
import { uncaught } from './failure.js';
|
|
5
|
+
import { name } from './listing.js';
|
|
4
6
|
import { NO_MODEL } from './model.js';
|
|
7
|
+
import { settle } from './queue.js';
|
|
5
8
|
import { advancement } from './refresh.js';
|
|
6
|
-
import {
|
|
9
|
+
import { recoverReads } from './shown.js';
|
|
7
10
|
import { unconfirmed } from './transfer.js';
|
|
8
|
-
import { ROW_WEIGHT } from './turn.js';
|
|
11
|
+
import { ROW_WEIGHT, yielded } from './turn.js';
|
|
9
12
|
// Bytes still arriving are reported at most this often, so readiness is not rebuilt for every chunk the network hands over while a slow link still moves the figure.
|
|
10
13
|
const ARRIVAL_REPORT_MS = 250;
|
|
11
14
|
const NOTHING_HELD = { bytes: 0 };
|
|
15
|
+
export const ERASE_BATCH = 512;
|
|
12
16
|
function transferGone(held) {
|
|
13
17
|
return {
|
|
14
18
|
...held,
|
|
@@ -75,70 +79,79 @@ function batchEnd(entries, from, bytes) {
|
|
|
75
79
|
}
|
|
76
80
|
return end;
|
|
77
81
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
82
|
+
const UNSHARED = {
|
|
83
|
+
installing: false,
|
|
84
|
+
downloading: false,
|
|
85
|
+
bytes: { done: 0, total: 0 },
|
|
86
|
+
};
|
|
87
|
+
export function installShare(store, { room, state }, held) {
|
|
88
|
+
if (state === 'unadmitted')
|
|
89
|
+
return UNSHARED;
|
|
90
|
+
const install = store.installs.of(room);
|
|
91
|
+
const underway = state === 'acquiring' || (install.installing && state !== 'complete');
|
|
92
|
+
const kept = underway ? NOTHING_HELD.bytes : (held.get(room)?.bytes ?? NOTHING_HELD.bytes);
|
|
93
|
+
const now = amountOf(install, kept);
|
|
94
|
+
const earlier = underway ? install.startedOver : null;
|
|
95
|
+
return {
|
|
96
|
+
installing: underway,
|
|
97
|
+
downloading: underway && (install.streaming || install.arrived === null),
|
|
98
|
+
bytes: {
|
|
99
|
+
done: Math.max(now.done, earlier?.done ?? 0),
|
|
100
|
+
total: Math.max(now.total, earlier?.total ?? 0),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function installationOf(installing, downloading, bytes) {
|
|
101
105
|
const step = installing === 0
|
|
102
106
|
? null
|
|
103
|
-
: downloading
|
|
107
|
+
: downloading > 0
|
|
104
108
|
? 'downloading'
|
|
105
109
|
: bytes.done < bytes.total
|
|
106
110
|
? 'writing'
|
|
107
111
|
: 'replaying';
|
|
108
|
-
return { step,
|
|
112
|
+
return { step, bytes };
|
|
109
113
|
}
|
|
110
114
|
export function roomInFlight(store, locator) {
|
|
111
115
|
const { catching, transfer } = store.installs.of(locator);
|
|
112
116
|
return catching || transfer !== null;
|
|
113
117
|
}
|
|
114
|
-
function installing(
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
function installing(runtime, locator) {
|
|
119
|
+
runtime.store.installs.change(locator, (held) => ({ ...held, installing: true }));
|
|
120
|
+
runtime.store.readiness.queue([locator]);
|
|
117
121
|
}
|
|
118
|
-
function installed(
|
|
119
|
-
if (!
|
|
122
|
+
function installed(runtime, locator) {
|
|
123
|
+
if (!runtime.store.installs.of(locator).installing)
|
|
120
124
|
return;
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
runtime.store.installs.change(locator, (held) => ({ ...held, installing: false }));
|
|
126
|
+
runtime.store.readiness.queue([locator]);
|
|
123
127
|
}
|
|
124
|
-
export function
|
|
125
|
-
store.
|
|
128
|
+
export function sweep({ store, socket }) {
|
|
129
|
+
if (store.device.now().sweeping || socket.closed())
|
|
130
|
+
return;
|
|
131
|
+
store.device.set({ sweeping: true });
|
|
132
|
+
void (async () => {
|
|
133
|
+
try {
|
|
134
|
+
while (!socket.closed() && (await store.durably((local) => local.erase(null, ERASE_BATCH)))) {
|
|
135
|
+
await yielded();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
uncaught(error);
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
store.device.set({ sweeping: false });
|
|
143
|
+
}
|
|
144
|
+
})();
|
|
126
145
|
}
|
|
127
|
-
export function caughtUpTo(
|
|
128
|
-
if (!
|
|
146
|
+
export function caughtUpTo(runtime, locator) {
|
|
147
|
+
if (!runtime.store.installs.of(locator).catching)
|
|
129
148
|
return;
|
|
130
|
-
|
|
131
|
-
|
|
149
|
+
runtime.store.installs.change(locator, (held) => ({ ...held, catching: false }));
|
|
150
|
+
recoverReads(runtime, [locator]);
|
|
132
151
|
}
|
|
133
152
|
export function catching(store, locator) {
|
|
134
153
|
store.installs.change(locator, (held) => ({ ...held, catching: true }));
|
|
135
154
|
}
|
|
136
|
-
export function confirmedAgain(store, locator) {
|
|
137
|
-
store.installs.change(locator, (held) => ({
|
|
138
|
-
...held,
|
|
139
|
-
confirmations: held.confirmations + 1,
|
|
140
|
-
}));
|
|
141
|
-
}
|
|
142
155
|
export function standingAt(store, locator, held) {
|
|
143
156
|
return { key: held?.key ?? null, confirmed: store.installs.of(locator).confirmations };
|
|
144
157
|
}
|
|
@@ -167,11 +180,11 @@ export function olderThan(system, locator, roomVersion, held) {
|
|
|
167
180
|
socket.reads.reached(locator, at, roomVersion) &&
|
|
168
181
|
!socket.reads.reached(locator, roomVersion, at));
|
|
169
182
|
}
|
|
170
|
-
async function older(
|
|
171
|
-
const { store } =
|
|
183
|
+
async function older(runtime, locator, roomVersion) {
|
|
184
|
+
const { store } = runtime;
|
|
172
185
|
if (store.installs.of(locator).beyondHorizon)
|
|
173
186
|
return false;
|
|
174
|
-
return olderThan(
|
|
187
|
+
return olderThan(runtime, locator, roomVersion, (await store.record(locator))?.roomVersion);
|
|
175
188
|
}
|
|
176
189
|
export function replaced(store, locators) {
|
|
177
190
|
for (const locator of locators) {
|
|
@@ -196,13 +209,13 @@ export async function writtenAfter({ store, socket }, locator, roomVersion, path
|
|
|
196
209
|
socket.reads.reached(locator, written, roomVersion) &&
|
|
197
210
|
!socket.reads.reached(locator, roomVersion, written));
|
|
198
211
|
}
|
|
199
|
-
async function writtenLater(
|
|
212
|
+
async function writtenLater(runtime, local, locator, key, paths, roomVersion, heldAt) {
|
|
200
213
|
if (paths.length === 0)
|
|
201
214
|
return new Set();
|
|
202
|
-
const { reached } =
|
|
215
|
+
const { reached } = runtime.socket.reads;
|
|
203
216
|
const behindShown = heldAt === undefined
|
|
204
|
-
? await older(
|
|
205
|
-
: olderThan(
|
|
217
|
+
? await older(runtime, locator, roomVersion)
|
|
218
|
+
: olderThan(runtime, locator, roomVersion, heldAt);
|
|
206
219
|
if (!behindShown)
|
|
207
220
|
return new Set();
|
|
208
221
|
const entries = await local.entries(key, 'confirmed', paths);
|
|
@@ -212,22 +225,22 @@ async function writtenLater(installer, local, locator, key, paths, roomVersion,
|
|
|
212
225
|
? [path]
|
|
213
226
|
: []));
|
|
214
227
|
}
|
|
215
|
-
function remodel(
|
|
228
|
+
function remodel(runtime, answers, held) {
|
|
216
229
|
const answer = answers?.collection;
|
|
217
230
|
if (answer === undefined)
|
|
218
231
|
return held;
|
|
219
|
-
return { collection: attachedModel(answer,
|
|
232
|
+
return { collection: attachedModel(answer, runtime.roomTypes) };
|
|
220
233
|
}
|
|
221
|
-
function refreshingOf(
|
|
222
|
-
const { store } =
|
|
234
|
+
function refreshingOf(runtime, local, locator, key, composition, liveness, replaying = false, heldAt) {
|
|
235
|
+
const { store } = runtime;
|
|
223
236
|
const write = replaying ? store.finishingWrite : store.exclusive;
|
|
224
237
|
return {
|
|
225
238
|
turn() {
|
|
226
239
|
if (replaying)
|
|
227
|
-
installing(
|
|
240
|
+
installing(runtime, locator);
|
|
228
241
|
},
|
|
229
242
|
prior: async (paths) => new Map((await local.entries(key, 'refreshed', paths)).map((entry) => [entry.path, entry])),
|
|
230
|
-
later: (paths, roomVersion) => writtenLater(
|
|
243
|
+
later: (paths, roomVersion) => writtenLater(runtime, local, locator, key, paths, roomVersion, heldAt),
|
|
231
244
|
async stage(page) {
|
|
232
245
|
for (let written = 0;;) {
|
|
233
246
|
const end = batchEnd(page.entries, written, store.stageBytes());
|
|
@@ -250,10 +263,10 @@ function refreshingOf(installer, local, locator, key, composition, liveness, rep
|
|
|
250
263
|
},
|
|
251
264
|
};
|
|
252
265
|
}
|
|
253
|
-
export async function pullRefresh(
|
|
266
|
+
export async function pullRefresh(runtime, authorized, record, liveness, hold, refresh) {
|
|
254
267
|
if (!liveness())
|
|
255
268
|
return unconfirmed;
|
|
256
|
-
const { store
|
|
269
|
+
const { store } = runtime;
|
|
257
270
|
const from = standingAt(store, record.locator, record);
|
|
258
271
|
const local = await store.open();
|
|
259
272
|
try {
|
|
@@ -266,12 +279,9 @@ export async function pullRefresh(installer, authorized, record, liveness, hold,
|
|
|
266
279
|
finally {
|
|
267
280
|
hold.take();
|
|
268
281
|
}
|
|
269
|
-
}, authorized, record, (models, kept) => (liveness() ? remodel(
|
|
270
|
-
if (result.kind !== 'advanced')
|
|
271
|
-
journal.record(`transfer refresh ${record.locator} ${result.kind}`);
|
|
282
|
+
}, authorized, record, (models, kept) => (liveness() ? remodel(runtime, models, kept) : kept), liveness, refreshingOf(runtime, local, record.locator, record.key, store.composed(record), liveness, false, record.roomVersion));
|
|
283
|
+
if (result.kind !== 'advanced')
|
|
272
284
|
return result;
|
|
273
|
-
}
|
|
274
|
-
journal.record(`transfer refresh ${record.locator} ${result.record.roomVersion}`);
|
|
275
285
|
return {
|
|
276
286
|
kind: 'advanced',
|
|
277
287
|
record: result.record,
|
|
@@ -282,18 +292,18 @@ export async function pullRefresh(installer, authorized, record, liveness, hold,
|
|
|
282
292
|
catch (error) {
|
|
283
293
|
if (refusedForSpace(error))
|
|
284
294
|
return unconfirmed;
|
|
285
|
-
journal.record(`transfer refresh ${record.locator} transport-uncertainty`);
|
|
286
295
|
throw error;
|
|
287
296
|
}
|
|
288
297
|
}
|
|
289
|
-
async function abandoned(
|
|
298
|
+
async function abandoned(runtime, local, locator) {
|
|
290
299
|
await local.abandon(locator);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
300
|
+
runtime.store.installs.change(locator, (held) => transferGone(setBack(held)));
|
|
301
|
+
recoverReads(runtime, [locator]);
|
|
302
|
+
runtime.store.readiness.queue([locator]);
|
|
303
|
+
sweep(runtime);
|
|
294
304
|
}
|
|
295
|
-
function staging(
|
|
296
|
-
const { store, socket } =
|
|
305
|
+
function staging(runtime, local, liveness, unheld) {
|
|
306
|
+
const { store, socket } = runtime;
|
|
297
307
|
const derived = async (locator, key, composition) => {
|
|
298
308
|
store.installs.change(locator, (held) => ({ ...held, underived: 0 }));
|
|
299
309
|
for (;;) {
|
|
@@ -303,7 +313,7 @@ function staging(installer, local, liveness, unheld) {
|
|
|
303
313
|
if (done === null)
|
|
304
314
|
return false;
|
|
305
315
|
store.installs.change(locator, (held) => built(held, done.done, done.text));
|
|
306
|
-
|
|
316
|
+
runtime.store.readiness.queue([locator]);
|
|
307
317
|
if (done.done)
|
|
308
318
|
return true;
|
|
309
319
|
}
|
|
@@ -311,7 +321,7 @@ function staging(installer, local, liveness, unheld) {
|
|
|
311
321
|
return {
|
|
312
322
|
held: (locator) => store.installs.of(locator).transfer,
|
|
313
323
|
async turn(locator, step) {
|
|
314
|
-
installing(
|
|
324
|
+
installing(runtime, locator);
|
|
315
325
|
return step === 'downloading' ? socket.heldStream() : () => { };
|
|
316
326
|
},
|
|
317
327
|
unqueued: socket.unqueued,
|
|
@@ -327,9 +337,9 @@ function staging(installer, local, liveness, unheld) {
|
|
|
327
337
|
arrived: bytes,
|
|
328
338
|
streaming: true,
|
|
329
339
|
}));
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
340
|
+
const due = store.installs.arrivalsDue(locator, performance.now(), ARRIVAL_REPORT_MS);
|
|
341
|
+
if (due.length > 0)
|
|
342
|
+
runtime.store.readiness.queue(due);
|
|
333
343
|
},
|
|
334
344
|
end() {
|
|
335
345
|
if (ended)
|
|
@@ -338,14 +348,14 @@ function staging(installer, local, liveness, unheld) {
|
|
|
338
348
|
if (!store.installs.of(locator).streaming)
|
|
339
349
|
return;
|
|
340
350
|
store.installs.change(locator, (held) => ({ ...held, streaming: false }));
|
|
341
|
-
|
|
351
|
+
runtime.store.readiness.queue([locator]);
|
|
342
352
|
},
|
|
343
353
|
};
|
|
344
354
|
},
|
|
345
355
|
streamed: socket.streamed,
|
|
346
356
|
async stage(record, page, composition) {
|
|
347
357
|
const { locator } = record;
|
|
348
|
-
installing(
|
|
358
|
+
installing(runtime, locator);
|
|
349
359
|
if (!liveness())
|
|
350
360
|
return null;
|
|
351
361
|
const key = await store.startingWrite(async () => {
|
|
@@ -365,21 +375,21 @@ function staging(installer, local, liveness, unheld) {
|
|
|
365
375
|
transfer: held,
|
|
366
376
|
underived: owed,
|
|
367
377
|
}));
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
installing(installer, locator);
|
|
371
|
-
installer.recover();
|
|
378
|
+
installing(runtime, locator);
|
|
379
|
+
recoverReads(runtime, [locator]);
|
|
372
380
|
if (owed < store.deriveBytes())
|
|
373
381
|
return held;
|
|
374
382
|
return (await derived(locator, key, composition)) ? held : null;
|
|
375
383
|
},
|
|
376
384
|
async resume(record, parts, composition) {
|
|
377
385
|
const { locator } = record;
|
|
378
|
-
installing(
|
|
386
|
+
installing(runtime, locator);
|
|
379
387
|
if (!liveness())
|
|
380
388
|
return null;
|
|
381
389
|
const prior = unheld === undefined ? await store.record(locator) : undefined;
|
|
382
|
-
const published = prior !== undefined && prior.replica.selection === record.selection
|
|
390
|
+
const published = prior !== undefined && prior.declaration.replica.selection === record.selection
|
|
391
|
+
? prior.key
|
|
392
|
+
: null;
|
|
383
393
|
const kept = unheld?.staged ?? (await local.held()).staged.has(locator);
|
|
384
394
|
if (published === null && !kept)
|
|
385
395
|
return { record: null, staged: new Set() };
|
|
@@ -401,82 +411,83 @@ function staging(installer, local, liveness, unheld) {
|
|
|
401
411
|
done: { bytes },
|
|
402
412
|
};
|
|
403
413
|
store.installs.change(locator, (room) => ({ ...room, transfer: held }));
|
|
404
|
-
|
|
414
|
+
recoverReads(runtime, [locator]);
|
|
415
|
+
store.readiness.queue([locator]);
|
|
405
416
|
return { record: held, staged: parted };
|
|
406
417
|
},
|
|
407
418
|
derive: derived,
|
|
408
419
|
async refreshing(locator, key, composition) {
|
|
409
420
|
await store.exclusive(() => local.unrefresh(key));
|
|
410
|
-
return refreshingOf(
|
|
421
|
+
return refreshingOf(runtime, local, locator, key, composition, liveness, true);
|
|
411
422
|
},
|
|
412
423
|
abandon: (locator) => store.exclusive(async () => {
|
|
413
424
|
if (liveness())
|
|
414
|
-
await abandoned(
|
|
425
|
+
await abandoned(runtime, local, locator);
|
|
415
426
|
}),
|
|
416
427
|
setAside: async (locator) => {
|
|
417
428
|
if (!liveness())
|
|
418
429
|
return;
|
|
419
430
|
store.installs.change(locator, (held) => transferGone(setBack(held)));
|
|
420
|
-
|
|
431
|
+
recoverReads(runtime, [locator]);
|
|
432
|
+
store.readiness.queue([locator]);
|
|
421
433
|
},
|
|
422
434
|
release: (key) => store.exclusive(async () => {
|
|
423
435
|
await local.release(key);
|
|
424
|
-
|
|
436
|
+
sweep(runtime);
|
|
425
437
|
}),
|
|
426
438
|
};
|
|
427
439
|
}
|
|
428
|
-
export async function pullBootstrap(
|
|
440
|
+
export async function pullBootstrap(runtime, authorized, room, local, liveness, prior, from = runtime.socket.reads, unheld) {
|
|
429
441
|
if (!liveness())
|
|
430
442
|
return unconfirmed;
|
|
431
|
-
const { store
|
|
443
|
+
const { store } = runtime;
|
|
432
444
|
if (prior !== undefined) {
|
|
433
445
|
catching(store, room.locator);
|
|
434
|
-
|
|
446
|
+
recoverReads(runtime, [room.locator]);
|
|
435
447
|
}
|
|
436
448
|
try {
|
|
437
|
-
const result = await bootstrapRoom(from, authorized, room, {
|
|
438
|
-
|
|
439
|
-
|
|
449
|
+
const result = await bootstrapRoom(from, authorized, room, {
|
|
450
|
+
collection: prior?.model ?? runtime.presence.unheldModel(room.locator) ?? NO_MODEL,
|
|
451
|
+
}, runtime.builtIn, runtime.typedPaths, (models, held) => (liveness() ? remodel(runtime, models, held) : held), liveness, staging(runtime, local, liveness, unheld));
|
|
440
452
|
if (result.kind === 'staged' &&
|
|
441
|
-
(await older(
|
|
442
|
-
caughtUpTo(
|
|
443
|
-
installed(
|
|
444
|
-
await abandoned(
|
|
445
|
-
journal.record(`transfer bootstrap ${room.locator} older than shown`);
|
|
453
|
+
(await older(runtime, room.locator, result.record.roomVersion))) {
|
|
454
|
+
caughtUpTo(runtime, room.locator);
|
|
455
|
+
installed(runtime, room.locator);
|
|
456
|
+
await abandoned(runtime, local, room.locator);
|
|
446
457
|
return { kind: 'transport-uncertainty' };
|
|
447
458
|
}
|
|
448
459
|
if (result.kind !== 'staged') {
|
|
449
|
-
caughtUpTo(
|
|
450
|
-
installed(
|
|
460
|
+
caughtUpTo(runtime, room.locator);
|
|
461
|
+
installed(runtime, room.locator);
|
|
451
462
|
}
|
|
452
463
|
return result;
|
|
453
464
|
}
|
|
454
465
|
catch (error) {
|
|
455
|
-
caughtUpTo(
|
|
456
|
-
installed(
|
|
466
|
+
caughtUpTo(runtime, room.locator);
|
|
467
|
+
installed(runtime, room.locator);
|
|
457
468
|
if (refusedForSpace(error))
|
|
458
469
|
return unconfirmed;
|
|
459
|
-
journal.record(`transfer bootstrap ${room.locator} transport-uncertainty`);
|
|
460
470
|
throw error;
|
|
461
471
|
}
|
|
462
472
|
}
|
|
463
|
-
export function publish(
|
|
464
|
-
const { store } =
|
|
465
|
-
|
|
473
|
+
export function publish(runtime, local, room, reached, landing, live) {
|
|
474
|
+
const { store } = runtime;
|
|
475
|
+
let published = true;
|
|
476
|
+
const landed = settle(runtime, [room.locator], async (held) => {
|
|
466
477
|
if (!live()) {
|
|
467
|
-
caughtUpTo(
|
|
468
|
-
return
|
|
478
|
+
caughtUpTo(runtime, room.locator);
|
|
479
|
+
return [];
|
|
469
480
|
}
|
|
470
|
-
const
|
|
471
|
-
const prior = work.replica;
|
|
481
|
+
const prior = held.get(room.locator)?.replica;
|
|
472
482
|
if (!standsAt(store, room.locator, prior?.record, landing.from)) {
|
|
483
|
+
published = false;
|
|
473
484
|
if (landing.kind === 'refreshed') {
|
|
474
485
|
await local.unrefresh(reached.key);
|
|
475
|
-
return
|
|
486
|
+
return [];
|
|
476
487
|
}
|
|
477
|
-
caughtUpTo(
|
|
478
|
-
await abandoned(
|
|
479
|
-
return
|
|
488
|
+
caughtUpTo(runtime, room.locator);
|
|
489
|
+
await abandoned(runtime, local, room.locator);
|
|
490
|
+
return [];
|
|
480
491
|
}
|
|
481
492
|
const record = landing.kind === 'refreshed' && prior !== undefined
|
|
482
493
|
? {
|
|
@@ -485,53 +496,42 @@ export function publish(installer, local, room, reached, landing, live) {
|
|
|
485
496
|
...(landing.remodelled ? { model: reached.model } : {}),
|
|
486
497
|
}
|
|
487
498
|
: reached;
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
: {
|
|
497
|
-
room: true,
|
|
498
|
-
view: landing.refreshed ? 'refreshed' : 'confirmed',
|
|
499
|
-
commit: {
|
|
499
|
+
return [
|
|
500
|
+
{
|
|
501
|
+
locator: room.locator,
|
|
502
|
+
record,
|
|
503
|
+
installed: landing.kind === 'refreshed'
|
|
504
|
+
? { refreshed: true }
|
|
505
|
+
: {
|
|
500
506
|
published: { from: prior?.record.key ?? null },
|
|
501
507
|
...(landing.refreshed ? { refreshed: true } : {}),
|
|
502
508
|
},
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
await installer.unpair(local);
|
|
528
|
-
void installer.statusShown();
|
|
529
|
-
if (landing.kind === 'bootstrapped' && work.queue.length > 0) {
|
|
530
|
-
installer.submitLater(room.locator);
|
|
531
|
-
}
|
|
532
|
-
return true;
|
|
509
|
+
after() {
|
|
510
|
+
runtime.presence.installed(room.locator, landing.kind === 'bootstrapped');
|
|
511
|
+
runtime.retries.succeeded('download', room.locator);
|
|
512
|
+
store.prepareAgain(room.locator);
|
|
513
|
+
if (landing.kind === 'bootstrapped') {
|
|
514
|
+
store.installs.change(room.locator, (held) => ({
|
|
515
|
+
...transferGone(held),
|
|
516
|
+
highest: null,
|
|
517
|
+
beyondHorizon: false,
|
|
518
|
+
startedOver: null,
|
|
519
|
+
catching: false,
|
|
520
|
+
}));
|
|
521
|
+
if (prior !== undefined && prior.record.key !== record.key)
|
|
522
|
+
sweep(runtime);
|
|
523
|
+
void name(runtime, room.locator);
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
];
|
|
528
|
+
}).then(() => published, (error) => {
|
|
529
|
+
if (!refusedForSpace(error))
|
|
530
|
+
throw error;
|
|
531
|
+
caughtUpTo(runtime, room.locator);
|
|
532
|
+
return published;
|
|
533
533
|
});
|
|
534
534
|
return landing.kind === 'refreshed'
|
|
535
535
|
? landed
|
|
536
|
-
: landed.finally(() => installed(
|
|
536
|
+
: landed.finally(() => installed(runtime, room.locator));
|
|
537
537
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Runtime } from './runtime.js';
|
|
2
|
+
export declare function scheduleCurrency(runtime: Runtime): void;
|
|
3
|
+
export declare function spaceFreed(runtime: Runtime): void;
|
|
4
|
+
export declare function close({ store, socket, presence, conversations, recovery, liveQueries, figures, }: Runtime): void;
|
|
5
|
+
export declare function stop(runtime: Runtime): Promise<void>;
|
|
6
|
+
export declare function start(runtime: Runtime, signal: AbortSignal | undefined, onNeed: boolean): void;
|
|
7
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA6O5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAOhD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,QAQ1C;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,WAAW,EACX,OAAO,GACR,EAAE,OAAO,QAST;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,iBAS1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,QAwCvF"}
|