@agentshouse/mdruntime 0.1.0-c6bf34fa9e444 → 0.1.0-c6d3d5d8beeb0

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