@agentshouse/mdruntime 0.1.0-cef76ea952695 → 0.1.0-cefb45338245d

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.
Files changed (295) hide show
  1. package/README.md +21 -19
  2. package/dist/acceptance.d.ts +0 -3
  3. package/dist/acceptance.d.ts.map +1 -1
  4. package/dist/acceptance.js +72 -158
  5. package/dist/act-lanes.d.ts +30 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +225 -0
  8. package/dist/actions.d.ts +8 -2
  9. package/dist/actions.d.ts.map +1 -1
  10. package/dist/actions.js +174 -75
  11. package/dist/adapter.d.ts +149 -34
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/attached-model.d.ts +0 -1
  14. package/dist/attached-model.d.ts.map +1 -1
  15. package/dist/attached-model.js +2 -7
  16. package/dist/authored.d.ts +88 -0
  17. package/dist/authored.d.ts.map +1 -0
  18. package/dist/authored.js +347 -0
  19. package/dist/binary.d.ts +6 -2
  20. package/dist/binary.d.ts.map +1 -1
  21. package/dist/binary.js +10 -3
  22. package/dist/bootstrap.d.ts +1 -1
  23. package/dist/bootstrap.d.ts.map +1 -1
  24. package/dist/bootstrap.js +6 -19
  25. package/dist/chain.d.ts +1 -1
  26. package/dist/chain.d.ts.map +1 -1
  27. package/dist/chain.js +5 -2
  28. package/dist/change-set.d.ts +4 -0
  29. package/dist/change-set.d.ts.map +1 -1
  30. package/dist/change-set.js +6 -0
  31. package/dist/change.d.ts +6 -2
  32. package/dist/change.d.ts.map +1 -1
  33. package/dist/change.js +3 -0
  34. package/dist/chat-types.d.ts +0 -2
  35. package/dist/chat-types.d.ts.map +1 -1
  36. package/dist/chat-types.js +2 -4
  37. package/dist/client.d.ts +22 -23
  38. package/dist/client.d.ts.map +1 -1
  39. package/dist/client.js +51 -66
  40. package/dist/collection.d.ts +27 -4
  41. package/dist/collection.d.ts.map +1 -1
  42. package/dist/collection.js +34 -10
  43. package/dist/column.d.ts +5 -0
  44. package/dist/column.d.ts.map +1 -0
  45. package/dist/column.js +9 -0
  46. package/dist/compile.d.ts +4 -1
  47. package/dist/compile.d.ts.map +1 -1
  48. package/dist/compile.js +87 -43
  49. package/dist/connection.d.ts +1 -1
  50. package/dist/connection.d.ts.map +1 -1
  51. package/dist/connection.js +36 -27
  52. package/dist/context.d.ts.map +1 -1
  53. package/dist/context.js +1 -1
  54. package/dist/conversation-live.d.ts +25 -11
  55. package/dist/conversation-live.d.ts.map +1 -1
  56. package/dist/conversation-live.js +23 -11
  57. package/dist/conversation-row.d.ts +8 -1
  58. package/dist/conversation-row.d.ts.map +1 -1
  59. package/dist/conversation-row.js +20 -7
  60. package/dist/conversation.d.ts +43 -11
  61. package/dist/conversation.d.ts.map +1 -1
  62. package/dist/conversation.js +312 -184
  63. package/dist/declaration.d.ts +10 -0
  64. package/dist/declaration.d.ts.map +1 -0
  65. package/dist/declaration.js +24 -0
  66. package/dist/discovery.d.ts +3 -1
  67. package/dist/discovery.d.ts.map +1 -1
  68. package/dist/discovery.js +47 -47
  69. package/dist/download.d.ts +6 -0
  70. package/dist/download.d.ts.map +1 -0
  71. package/dist/download.js +42 -0
  72. package/dist/durability.d.ts +5 -0
  73. package/dist/durability.d.ts.map +1 -1
  74. package/dist/durability.js +7 -0
  75. package/dist/entry.d.ts +22 -1
  76. package/dist/entry.d.ts.map +1 -1
  77. package/dist/entry.js +91 -34
  78. package/dist/expectation.d.ts +25 -14
  79. package/dist/expectation.d.ts.map +1 -1
  80. package/dist/expectation.js +51 -20
  81. package/dist/failure.d.ts +2 -0
  82. package/dist/failure.d.ts.map +1 -1
  83. package/dist/failure.js +6 -1
  84. package/dist/figures.d.ts.map +1 -1
  85. package/dist/figures.js +4 -2
  86. package/dist/file.d.ts +1 -1
  87. package/dist/file.d.ts.map +1 -1
  88. package/dist/file.js +3 -2
  89. package/dist/host.d.ts +24 -4
  90. package/dist/host.d.ts.map +1 -1
  91. package/dist/host.js +108 -32
  92. package/dist/house-query.d.ts +24 -0
  93. package/dist/house-query.d.ts.map +1 -0
  94. package/dist/house-query.js +102 -0
  95. package/dist/index.d.ts +23 -14
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +16 -8
  98. package/dist/install.d.ts +10 -6
  99. package/dist/install.d.ts.map +1 -1
  100. package/dist/install.js +89 -108
  101. package/dist/lifecycle.d.ts +2 -2
  102. package/dist/lifecycle.d.ts.map +1 -1
  103. package/dist/lifecycle.js +74 -54
  104. package/dist/listing.d.ts +29 -22
  105. package/dist/listing.d.ts.map +1 -1
  106. package/dist/listing.js +71 -79
  107. package/dist/live.d.ts +19 -3
  108. package/dist/live.d.ts.map +1 -1
  109. package/dist/live.js +94 -36
  110. package/dist/loaded.d.ts +7 -0
  111. package/dist/loaded.d.ts.map +1 -0
  112. package/dist/loaded.js +46 -0
  113. package/dist/locks.d.ts +2 -4
  114. package/dist/locks.d.ts.map +1 -1
  115. package/dist/locks.js +10 -38
  116. package/dist/lost.d.ts.map +1 -1
  117. package/dist/lost.js +11 -23
  118. package/dist/media.d.ts +19 -3
  119. package/dist/media.d.ts.map +1 -1
  120. package/dist/media.js +167 -33
  121. package/dist/memory.d.ts +10 -4
  122. package/dist/memory.d.ts.map +1 -1
  123. package/dist/memory.js +98 -37
  124. package/dist/messages.d.ts +17 -3
  125. package/dist/messages.d.ts.map +1 -1
  126. package/dist/messages.js +34 -13
  127. package/dist/modal.d.ts +2 -0
  128. package/dist/modal.d.ts.map +1 -0
  129. package/dist/modal.js +11 -0
  130. package/dist/model.d.ts +4 -3
  131. package/dist/model.d.ts.map +1 -1
  132. package/dist/model.js +6 -5
  133. package/dist/models.d.ts +4 -8
  134. package/dist/models.d.ts.map +1 -1
  135. package/dist/models.js +94 -138
  136. package/dist/name.d.ts +0 -1
  137. package/dist/name.d.ts.map +1 -1
  138. package/dist/name.js +3 -7
  139. package/dist/observation.d.ts +29 -12
  140. package/dist/observation.d.ts.map +1 -1
  141. package/dist/observation.js +206 -69
  142. package/dist/online.d.ts +7 -0
  143. package/dist/online.d.ts.map +1 -0
  144. package/dist/online.js +29 -0
  145. package/dist/opened.d.ts +1 -1
  146. package/dist/opened.d.ts.map +1 -1
  147. package/dist/opened.js +2 -2
  148. package/dist/opening.d.ts.map +1 -1
  149. package/dist/opening.js +21 -12
  150. package/dist/outcome.d.ts +24 -4
  151. package/dist/outcome.d.ts.map +1 -1
  152. package/dist/outcome.js +33 -3
  153. package/dist/overlay.d.ts +9 -5
  154. package/dist/overlay.d.ts.map +1 -1
  155. package/dist/overlay.js +37 -24
  156. package/dist/page-metadata.d.ts +8 -0
  157. package/dist/page-metadata.d.ts.map +1 -0
  158. package/dist/page-metadata.js +19 -0
  159. package/dist/parts.d.ts +4 -9
  160. package/dist/parts.d.ts.map +1 -1
  161. package/dist/parts.js +30 -15
  162. package/dist/preparation.d.ts +33 -7
  163. package/dist/preparation.d.ts.map +1 -1
  164. package/dist/preparation.js +207 -96
  165. package/dist/presence.d.ts +58 -0
  166. package/dist/presence.d.ts.map +1 -0
  167. package/dist/presence.js +231 -0
  168. package/dist/queries.d.ts +2 -2
  169. package/dist/queries.d.ts.map +1 -1
  170. package/dist/queries.js +136 -78
  171. package/dist/query.d.ts +2 -2
  172. package/dist/questions.d.ts +1 -5
  173. package/dist/questions.d.ts.map +1 -1
  174. package/dist/questions.js +3 -8
  175. package/dist/queue.d.ts +40 -0
  176. package/dist/queue.d.ts.map +1 -0
  177. package/dist/queue.js +480 -0
  178. package/dist/reach.d.ts +15 -6
  179. package/dist/reach.d.ts.map +1 -1
  180. package/dist/reach.js +182 -38
  181. package/dist/react.d.ts +11 -5
  182. package/dist/react.d.ts.map +1 -1
  183. package/dist/react.js +28 -5
  184. package/dist/readiness.d.ts +20 -4
  185. package/dist/readiness.d.ts.map +1 -1
  186. package/dist/readiness.js +17 -10
  187. package/dist/reads.d.ts +4 -2
  188. package/dist/reads.d.ts.map +1 -1
  189. package/dist/reads.js +9 -4
  190. package/dist/recovery.d.ts +4 -1
  191. package/dist/recovery.d.ts.map +1 -1
  192. package/dist/recovery.js +31 -8
  193. package/dist/reference-forms.d.ts +4 -0
  194. package/dist/reference-forms.d.ts.map +1 -0
  195. package/dist/reference-forms.js +74 -0
  196. package/dist/refresh.d.ts +1 -1
  197. package/dist/refresh.js +6 -6
  198. package/dist/refusal.d.ts.map +1 -1
  199. package/dist/refusal.js +2 -4
  200. package/dist/replica.d.ts +5 -11
  201. package/dist/replica.d.ts.map +1 -1
  202. package/dist/replica.js +16 -18
  203. package/dist/retried.d.ts +30 -0
  204. package/dist/retried.d.ts.map +1 -0
  205. package/dist/retried.js +72 -0
  206. package/dist/room-draft.d.ts +30 -5
  207. package/dist/room-draft.d.ts.map +1 -1
  208. package/dist/room-draft.js +275 -65
  209. package/dist/room-drafts.d.ts.map +1 -1
  210. package/dist/room-drafts.js +11 -6
  211. package/dist/room-list.d.ts +10 -0
  212. package/dist/room-list.d.ts.map +1 -0
  213. package/dist/room-list.js +45 -0
  214. package/dist/rows.d.ts +11 -2
  215. package/dist/rows.d.ts.map +1 -1
  216. package/dist/rows.js +27 -14
  217. package/dist/running.d.ts +5 -0
  218. package/dist/running.d.ts.map +1 -0
  219. package/dist/running.js +10 -0
  220. package/dist/runtime.d.ts +13 -19
  221. package/dist/runtime.d.ts.map +1 -1
  222. package/dist/save.d.ts +43 -90
  223. package/dist/save.d.ts.map +1 -1
  224. package/dist/save.js +314 -223
  225. package/dist/saves.d.ts +6 -42
  226. package/dist/saves.d.ts.map +1 -1
  227. package/dist/saves.js +176 -718
  228. package/dist/seed.d.ts.map +1 -1
  229. package/dist/seed.js +4 -4
  230. package/dist/shown.d.ts +9 -5
  231. package/dist/shown.d.ts.map +1 -1
  232. package/dist/shown.js +93 -57
  233. package/dist/socket/lanes.d.ts +12 -4
  234. package/dist/socket/lanes.d.ts.map +1 -1
  235. package/dist/socket/lanes.js +34 -8
  236. package/dist/socket/session.d.ts +4 -1
  237. package/dist/socket/session.d.ts.map +1 -1
  238. package/dist/socket/session.js +3 -0
  239. package/dist/socket.d.ts +4 -6
  240. package/dist/socket.d.ts.map +1 -1
  241. package/dist/socket.js +4 -14
  242. package/dist/source.d.ts +7 -7
  243. package/dist/source.d.ts.map +1 -1
  244. package/dist/source.js +15 -2
  245. package/dist/store/installs.d.ts +2 -2
  246. package/dist/store/installs.d.ts.map +1 -1
  247. package/dist/store/installs.js +10 -4
  248. package/dist/store/readiness.d.ts +5 -4
  249. package/dist/store/readiness.d.ts.map +1 -1
  250. package/dist/store/readiness.js +28 -12
  251. package/dist/store/records.d.ts +24 -5
  252. package/dist/store/records.d.ts.map +1 -1
  253. package/dist/store/records.js +68 -22
  254. package/dist/store/rooms-shown.d.ts +8 -0
  255. package/dist/store/rooms-shown.d.ts.map +1 -0
  256. package/dist/store/rooms-shown.js +13 -0
  257. package/dist/store.d.ts +25 -15
  258. package/dist/store.d.ts.map +1 -1
  259. package/dist/store.js +50 -18
  260. package/dist/stored.d.ts +39 -14
  261. package/dist/stored.d.ts.map +1 -1
  262. package/dist/stored.js +217 -59
  263. package/dist/surface.d.ts +14 -8
  264. package/dist/surface.d.ts.map +1 -1
  265. package/dist/surface.js +65 -34
  266. package/dist/sync.d.ts +4 -2
  267. package/dist/sync.d.ts.map +1 -1
  268. package/dist/sync.js +127 -102
  269. package/dist/tables.d.ts +28 -52
  270. package/dist/tables.d.ts.map +1 -1
  271. package/dist/tables.js +95 -326
  272. package/dist/tallies.d.ts.map +1 -1
  273. package/dist/tallies.js +1 -2
  274. package/dist/validation.d.ts +2 -0
  275. package/dist/validation.d.ts.map +1 -1
  276. package/dist/validation.js +51 -11
  277. package/dist/wire.d.ts +71 -12
  278. package/dist/wire.d.ts.map +1 -1
  279. package/dist/wire.js +30 -14
  280. package/package.json +4 -4
  281. package/dist/attempt.d.ts +0 -16
  282. package/dist/attempt.d.ts.map +0 -1
  283. package/dist/attempt.js +0 -70
  284. package/dist/job.d.ts +0 -5
  285. package/dist/job.d.ts.map +0 -1
  286. package/dist/job.js +0 -7
  287. package/dist/log.d.ts +0 -6
  288. package/dist/log.d.ts.map +0 -1
  289. package/dist/log.js +0 -14
  290. package/dist/socket/rooms.d.ts +0 -44
  291. package/dist/socket/rooms.d.ts.map +0 -1
  292. package/dist/socket/rooms.js +0 -90
  293. package/dist/store/fences.d.ts +0 -16
  294. package/dist/store/fences.d.ts.map +0 -1
  295. package/dist/store/fences.js +0 -26
package/dist/install.js CHANGED
@@ -2,11 +2,11 @@ import { attachedModel } from './attached-model.js';
2
2
  import { bootstrapRoom } from './bootstrap.js';
3
3
  import { refusedForSpace } from './durability.js';
4
4
  import { uncaught } from './failure.js';
5
- import { name, usable } from './listing.js';
5
+ import { name } from './listing.js';
6
6
  import { NO_MODEL } from './model.js';
7
+ import { settle } from './queue.js';
7
8
  import { advancement } from './refresh.js';
8
- import { recoverReads, statusShown } from './shown.js';
9
- import { NO_INSTALL, } from './store.js';
9
+ import { recoverReads } from './shown.js';
10
10
  import { unconfirmed } from './transfer.js';
11
11
  import { ROW_WEIGHT, yielded } from './turn.js';
12
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.
@@ -79,28 +79,32 @@ function batchEnd(entries, from, bytes) {
79
79
  }
80
80
  return end;
81
81
  }
82
- export function installationOf(store, coverage, held) {
83
- const bytes = { done: 0, total: 0 };
84
- let installing = 0;
85
- let downloading = false;
86
- for (const { room, state } of coverage) {
87
- if (state === 'unadmitted')
88
- continue;
89
- const install = store.installs.of(room);
90
- const underway = state === 'acquiring' || (install.installing && state !== 'complete');
91
- if (underway)
92
- installing += 1;
93
- if (underway && (install.streaming || install.arrived === null))
94
- downloading = true;
95
- const kept = underway ? NOTHING_HELD.bytes : (held.get(room)?.bytes ?? NOTHING_HELD.bytes);
96
- const now = amountOf(install, kept);
97
- const earlier = underway ? install.startedOver : null;
98
- bytes.done += Math.max(now.done, earlier?.done ?? 0);
99
- bytes.total += Math.max(now.total, earlier?.total ?? 0);
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'
@@ -113,15 +117,15 @@ export function roomInFlight(store, locator) {
113
117
  }
114
118
  function installing(runtime, locator) {
115
119
  runtime.store.installs.change(locator, (held) => ({ ...held, installing: true }));
116
- runtime.store.readiness.queue();
120
+ runtime.store.readiness.queue([locator]);
117
121
  }
118
122
  function installed(runtime, locator) {
119
123
  if (!runtime.store.installs.of(locator).installing)
120
124
  return;
121
125
  runtime.store.installs.change(locator, (held) => ({ ...held, installing: false }));
122
- runtime.store.readiness.queue();
126
+ runtime.store.readiness.queue([locator]);
123
127
  }
124
- export function sweep({ store, socket, journal }) {
128
+ export function sweep({ store, socket }) {
125
129
  if (store.device.now().sweeping || socket.closed())
126
130
  return;
127
131
  store.device.set({ sweeping: true });
@@ -132,7 +136,6 @@ export function sweep({ store, socket, journal }) {
132
136
  }
133
137
  }
134
138
  catch (error) {
135
- journal.record('erasure failed');
136
139
  uncaught(error);
137
140
  }
138
141
  finally {
@@ -140,24 +143,15 @@ export function sweep({ store, socket, journal }) {
140
143
  }
141
144
  })();
142
145
  }
143
- export function forgetInstall(store, locator) {
144
- store.installs.change(locator, ({ installing }) => ({ ...NO_INSTALL, installing }));
145
- }
146
146
  export function caughtUpTo(runtime, locator) {
147
147
  if (!runtime.store.installs.of(locator).catching)
148
148
  return;
149
149
  runtime.store.installs.change(locator, (held) => ({ ...held, catching: false }));
150
- recoverReads(runtime);
150
+ recoverReads(runtime, [locator]);
151
151
  }
152
152
  export function catching(store, locator) {
153
153
  store.installs.change(locator, (held) => ({ ...held, catching: true }));
154
154
  }
155
- export function confirmedAgain(store, locator) {
156
- store.installs.change(locator, (held) => ({
157
- ...held,
158
- confirmations: held.confirmations + 1,
159
- }));
160
- }
161
155
  export function standingAt(store, locator, held) {
162
156
  return { key: held?.key ?? null, confirmed: store.installs.of(locator).confirmations };
163
157
  }
@@ -272,7 +266,7 @@ function refreshingOf(runtime, local, locator, key, composition, liveness, repla
272
266
  export async function pullRefresh(runtime, authorized, record, liveness, hold, refresh) {
273
267
  if (!liveness())
274
268
  return unconfirmed;
275
- const { store, journal } = runtime;
269
+ const { store } = runtime;
276
270
  const from = standingAt(store, record.locator, record);
277
271
  const local = await store.open();
278
272
  try {
@@ -286,11 +280,8 @@ export async function pullRefresh(runtime, authorized, record, liveness, hold, r
286
280
  hold.take();
287
281
  }
288
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));
289
- if (result.kind !== 'advanced') {
290
- journal.record(`transfer refresh ${record.locator} ${result.kind}`);
283
+ if (result.kind !== 'advanced')
291
284
  return result;
292
- }
293
- journal.record(`transfer refresh ${record.locator} ${result.record.roomVersion}`);
294
285
  return {
295
286
  kind: 'advanced',
296
287
  record: result.record,
@@ -301,14 +292,14 @@ export async function pullRefresh(runtime, authorized, record, liveness, hold, r
301
292
  catch (error) {
302
293
  if (refusedForSpace(error))
303
294
  return unconfirmed;
304
- journal.record(`transfer refresh ${record.locator} transport-uncertainty`);
305
295
  throw error;
306
296
  }
307
297
  }
308
298
  async function abandoned(runtime, local, locator) {
309
299
  await local.abandon(locator);
310
300
  runtime.store.installs.change(locator, (held) => transferGone(setBack(held)));
311
- recoverReads(runtime);
301
+ recoverReads(runtime, [locator]);
302
+ runtime.store.readiness.queue([locator]);
312
303
  sweep(runtime);
313
304
  }
314
305
  function staging(runtime, local, liveness, unheld) {
@@ -322,7 +313,7 @@ function staging(runtime, local, liveness, unheld) {
322
313
  if (done === null)
323
314
  return false;
324
315
  store.installs.change(locator, (held) => built(held, done.done, done.text));
325
- runtime.store.readiness.queue();
316
+ runtime.store.readiness.queue([locator]);
326
317
  if (done.done)
327
318
  return true;
328
319
  }
@@ -346,9 +337,9 @@ function staging(runtime, local, liveness, unheld) {
346
337
  arrived: bytes,
347
338
  streaming: true,
348
339
  }));
349
- if (!store.installs.arrivalDue(performance.now(), ARRIVAL_REPORT_MS))
350
- return;
351
- runtime.store.readiness.queue();
340
+ const due = store.installs.arrivalsDue(locator, performance.now(), ARRIVAL_REPORT_MS);
341
+ if (due.length > 0)
342
+ runtime.store.readiness.queue(due);
352
343
  },
353
344
  end() {
354
345
  if (ended)
@@ -357,7 +348,7 @@ function staging(runtime, local, liveness, unheld) {
357
348
  if (!store.installs.of(locator).streaming)
358
349
  return;
359
350
  store.installs.change(locator, (held) => ({ ...held, streaming: false }));
360
- runtime.store.readiness.queue();
351
+ runtime.store.readiness.queue([locator]);
361
352
  },
362
353
  };
363
354
  },
@@ -385,7 +376,7 @@ function staging(runtime, local, liveness, unheld) {
385
376
  underived: owed,
386
377
  }));
387
378
  installing(runtime, locator);
388
- recoverReads(runtime);
379
+ recoverReads(runtime, [locator]);
389
380
  if (owed < store.deriveBytes())
390
381
  return held;
391
382
  return (await derived(locator, key, composition)) ? held : null;
@@ -396,7 +387,9 @@ function staging(runtime, local, liveness, unheld) {
396
387
  if (!liveness())
397
388
  return null;
398
389
  const prior = unheld === undefined ? await store.record(locator) : undefined;
399
- const published = prior !== undefined && prior.replica.selection === record.selection ? prior.key : null;
390
+ const published = prior !== undefined && prior.declaration.replica.selection === record.selection
391
+ ? prior.key
392
+ : null;
400
393
  const kept = unheld?.staged ?? (await local.held()).staged.has(locator);
401
394
  if (published === null && !kept)
402
395
  return { record: null, staged: new Set() };
@@ -418,7 +411,8 @@ function staging(runtime, local, liveness, unheld) {
418
411
  done: { bytes },
419
412
  };
420
413
  store.installs.change(locator, (room) => ({ ...room, transfer: held }));
421
- recoverReads(runtime);
414
+ recoverReads(runtime, [locator]);
415
+ store.readiness.queue([locator]);
422
416
  return { record: held, staged: parted };
423
417
  },
424
418
  derive: derived,
@@ -434,7 +428,8 @@ function staging(runtime, local, liveness, unheld) {
434
428
  if (!liveness())
435
429
  return;
436
430
  store.installs.change(locator, (held) => transferGone(setBack(held)));
437
- recoverReads(runtime);
431
+ recoverReads(runtime, [locator]);
432
+ store.readiness.queue([locator]);
438
433
  },
439
434
  release: (key) => store.exclusive(async () => {
440
435
  await local.release(key);
@@ -445,23 +440,20 @@ function staging(runtime, local, liveness, unheld) {
445
440
  export async function pullBootstrap(runtime, authorized, room, local, liveness, prior, from = runtime.socket.reads, unheld) {
446
441
  if (!liveness())
447
442
  return unconfirmed;
448
- const { store, journal } = runtime;
443
+ const { store } = runtime;
449
444
  if (prior !== undefined) {
450
445
  catching(store, room.locator);
451
- recoverReads(runtime);
446
+ recoverReads(runtime, [room.locator]);
452
447
  }
453
448
  try {
454
449
  const result = await bootstrapRoom(from, authorized, room, {
455
- collection: prior?.model ?? runtime.socket.rooms.standing(room.locator).unheldModel ?? NO_MODEL,
450
+ collection: prior?.model ?? runtime.presence.unheldModel(room.locator) ?? NO_MODEL,
456
451
  }, runtime.builtIn, runtime.typedPaths, (models, held) => (liveness() ? remodel(runtime, models, held) : held), liveness, staging(runtime, local, liveness, unheld));
457
- const detail = result.kind === 'staged' ? result.record.roomVersion : result.kind;
458
- journal.record(`transfer bootstrap ${room.locator} ${detail}`);
459
452
  if (result.kind === 'staged' &&
460
453
  (await older(runtime, room.locator, result.record.roomVersion))) {
461
454
  caughtUpTo(runtime, room.locator);
462
455
  installed(runtime, room.locator);
463
456
  await abandoned(runtime, local, room.locator);
464
- journal.record(`transfer bootstrap ${room.locator} older than shown`);
465
457
  return { kind: 'transport-uncertainty' };
466
458
  }
467
459
  if (result.kind !== 'staged') {
@@ -475,27 +467,27 @@ export async function pullBootstrap(runtime, authorized, room, local, liveness,
475
467
  installed(runtime, room.locator);
476
468
  if (refusedForSpace(error))
477
469
  return unconfirmed;
478
- journal.record(`transfer bootstrap ${room.locator} transport-uncertainty`);
479
470
  throw error;
480
471
  }
481
472
  }
482
473
  export function publish(runtime, local, room, reached, landing, live) {
483
474
  const { store } = runtime;
484
- const landed = store.exclusive(async () => {
475
+ let published = true;
476
+ const landed = settle(runtime, [room.locator], async (held) => {
485
477
  if (!live()) {
486
478
  caughtUpTo(runtime, room.locator);
487
- return true;
479
+ return [];
488
480
  }
489
- const work = await store.work(room.locator);
490
- const prior = work.replica;
481
+ const prior = held.get(room.locator)?.replica;
491
482
  if (!standsAt(store, room.locator, prior?.record, landing.from)) {
483
+ published = false;
492
484
  if (landing.kind === 'refreshed') {
493
485
  await local.unrefresh(reached.key);
494
- return false;
486
+ return [];
495
487
  }
496
488
  caughtUpTo(runtime, room.locator);
497
489
  await abandoned(runtime, local, room.locator);
498
- return false;
490
+ return [];
499
491
  }
500
492
  const record = landing.kind === 'refreshed' && prior !== undefined
501
493
  ? {
@@ -504,51 +496,40 @@ export function publish(runtime, local, room, reached, landing, live) {
504
496
  ...(landing.remodelled ? { model: reached.model } : {}),
505
497
  }
506
498
  : reached;
507
- let set;
508
- try {
509
- set = await runtime.settle(local, room.locator, work, record, work.queue, landing.kind === 'refreshed'
510
- ? {
511
- room: true,
512
- view: 'refreshed',
513
- commit: { refreshed: true },
514
- }
515
- : {
516
- room: true,
517
- view: landing.refreshed ? 'refreshed' : 'confirmed',
518
- commit: {
499
+ return [
500
+ {
501
+ locator: room.locator,
502
+ record,
503
+ installed: landing.kind === 'refreshed'
504
+ ? { refreshed: true }
505
+ : {
519
506
  published: { from: prior?.record.key ?? null },
520
507
  ...(landing.refreshed ? { refreshed: true } : {}),
521
508
  },
522
- });
523
- }
524
- catch (error) {
525
- if (!refusedForSpace(error))
526
- throw error;
527
- caughtUpTo(runtime, room.locator);
528
- return true;
529
- }
530
- if (landing.kind === 'bootstrapped') {
531
- runtime.socket.rooms.readied(room.locator);
532
- store.installs.change(room.locator, (held) => ({
533
- ...transferGone(held),
534
- highest: null,
535
- beyondHorizon: false,
536
- startedOver: null,
537
- catching: false,
538
- }));
539
- runtime.socket.rooms.stand(room.locator, { unheldModel: null });
540
- if (prior !== undefined && prior.record.key !== record.key)
541
- sweep(runtime);
542
- void name(runtime, room.locator);
543
- }
544
- usable(runtime, room);
545
- void runtime.store.changed(set);
546
- await runtime.unpair(local);
547
- void statusShown(runtime);
548
- if (landing.kind === 'bootstrapped' && work.queue.length > 0) {
549
- runtime.submitLater(room.locator);
550
- }
551
- 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;
552
533
  });
553
534
  return landing.kind === 'refreshed'
554
535
  ? landed
@@ -1,7 +1,7 @@
1
1
  import type { Runtime } from './runtime.js';
2
2
  export declare function scheduleCurrency(runtime: Runtime): void;
3
3
  export declare function spaceFreed(runtime: Runtime): void;
4
- export declare function close({ store, socket, conversations, recovery, liveQueries, figures }: Runtime): void;
4
+ export declare function close({ store, socket, presence, conversations, recovery, liveQueries, figures, }: Runtime): void;
5
5
  export declare function stop(runtime: Runtime): Promise<void>;
6
- export declare function start(runtime: Runtime, signal: AbortSignal | undefined): void;
6
+ export declare function start(runtime: Runtime, signal: AbortSignal | undefined, onNeed: boolean): void;
7
7
  //# sourceMappingURL=lifecycle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA8M5C,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAOhD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,QAS1C;AAED,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,OAAO,QAQ9F;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,iBAS1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,QAyCtE"}
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"}