@agentshouse/mdruntime 0.1.0-ca9afacd5aebd → 0.1.0-cab6762661a85

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 (237) hide show
  1. package/README.md +18 -15
  2. package/dist/adapter.d.ts +114 -34
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +5 -1
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +38 -4
  7. package/dist/attempt.d.ts.map +1 -1
  8. package/dist/attempt.js +14 -1
  9. package/dist/binary.d.ts +0 -5
  10. package/dist/binary.d.ts.map +1 -1
  11. package/dist/binary.js +1 -1
  12. package/dist/bootstrap.d.ts +27 -11
  13. package/dist/bootstrap.d.ts.map +1 -1
  14. package/dist/bootstrap.js +181 -81
  15. package/dist/chain.d.ts +11 -0
  16. package/dist/chain.d.ts.map +1 -0
  17. package/dist/chain.js +64 -0
  18. package/dist/change-set.d.ts +9 -14
  19. package/dist/change-set.d.ts.map +1 -1
  20. package/dist/change-set.js +11 -63
  21. package/dist/change.d.ts +31 -1
  22. package/dist/change.d.ts.map +1 -1
  23. package/dist/change.js +10 -1
  24. package/dist/client.d.ts +24 -12
  25. package/dist/client.d.ts.map +1 -1
  26. package/dist/client.js +98 -11
  27. package/dist/collection.d.ts +10 -7
  28. package/dist/collection.d.ts.map +1 -1
  29. package/dist/collection.js +38 -79
  30. package/dist/compile.d.ts +16 -0
  31. package/dist/compile.d.ts.map +1 -0
  32. package/dist/compile.js +773 -0
  33. package/dist/connection.d.ts +45 -16
  34. package/dist/connection.d.ts.map +1 -1
  35. package/dist/connection.js +3435 -890
  36. package/dist/conversation.d.ts +33 -12
  37. package/dist/conversation.d.ts.map +1 -1
  38. package/dist/conversation.js +662 -202
  39. package/dist/digest.d.ts +7 -0
  40. package/dist/digest.d.ts.map +1 -0
  41. package/dist/digest.js +113 -0
  42. package/dist/durability.d.ts +4 -1
  43. package/dist/durability.d.ts.map +1 -1
  44. package/dist/durability.js +5 -0
  45. package/dist/entry.d.ts +20 -0
  46. package/dist/entry.d.ts.map +1 -0
  47. package/dist/entry.js +151 -0
  48. package/dist/fence.d.ts +6 -0
  49. package/dist/fence.d.ts.map +1 -0
  50. package/dist/fence.js +10 -0
  51. package/dist/file.d.ts +2 -19
  52. package/dist/file.d.ts.map +1 -1
  53. package/dist/file.js +7 -122
  54. package/dist/fulltext.d.ts +27 -0
  55. package/dist/fulltext.d.ts.map +1 -0
  56. package/dist/fulltext.js +370 -0
  57. package/dist/host.d.ts +14 -3
  58. package/dist/host.d.ts.map +1 -1
  59. package/dist/host.js +131 -17
  60. package/dist/identity.d.ts +1 -0
  61. package/dist/identity.d.ts.map +1 -1
  62. package/dist/identity.js +3 -0
  63. package/dist/index.d.ts +15 -9
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +6 -0
  66. package/dist/live.d.ts +22 -0
  67. package/dist/live.d.ts.map +1 -0
  68. package/dist/live.js +124 -0
  69. package/dist/media.d.ts +8 -0
  70. package/dist/media.d.ts.map +1 -0
  71. package/dist/media.js +218 -0
  72. package/dist/memory.d.ts +11 -4
  73. package/dist/memory.d.ts.map +1 -1
  74. package/dist/memory.js +98 -28
  75. package/dist/messages.d.ts +28 -0
  76. package/dist/messages.d.ts.map +1 -0
  77. package/dist/messages.js +90 -0
  78. package/dist/model.d.ts +9 -2
  79. package/dist/model.d.ts.map +1 -1
  80. package/dist/model.js +8 -2
  81. package/dist/name.d.ts +4 -0
  82. package/dist/name.d.ts.map +1 -0
  83. package/dist/name.js +122 -0
  84. package/dist/observation.d.ts +20 -2
  85. package/dist/observation.d.ts.map +1 -1
  86. package/dist/observation.js +113 -12
  87. package/dist/opened.d.ts +22 -0
  88. package/dist/opened.d.ts.map +1 -0
  89. package/dist/opened.js +107 -0
  90. package/dist/outcome.d.ts +49 -7
  91. package/dist/outcome.d.ts.map +1 -1
  92. package/dist/outcome.js +40 -0
  93. package/dist/overlay.d.ts +3 -4
  94. package/dist/overlay.d.ts.map +1 -1
  95. package/dist/overlay.js +100 -182
  96. package/dist/paths.d.ts +1 -0
  97. package/dist/paths.d.ts.map +1 -1
  98. package/dist/paths.js +4 -0
  99. package/dist/query.d.ts +66 -4
  100. package/dist/query.d.ts.map +1 -1
  101. package/dist/query.js +48 -7
  102. package/dist/reach.d.ts +18 -6
  103. package/dist/reach.d.ts.map +1 -1
  104. package/dist/reach.js +224 -70
  105. package/dist/react.d.ts +8 -6
  106. package/dist/react.d.ts.map +1 -1
  107. package/dist/react.js +7 -17
  108. package/dist/readiness.d.ts +52 -0
  109. package/dist/readiness.d.ts.map +1 -0
  110. package/dist/readiness.js +27 -0
  111. package/dist/reads.d.ts +11 -0
  112. package/dist/reads.d.ts.map +1 -0
  113. package/dist/reads.js +91 -0
  114. package/dist/recovery.d.ts +26 -0
  115. package/dist/recovery.d.ts.map +1 -0
  116. package/dist/recovery.js +224 -0
  117. package/dist/refresh.d.ts +16 -15
  118. package/dist/refresh.d.ts.map +1 -1
  119. package/dist/refresh.js +113 -49
  120. package/dist/replica.d.ts +55 -33
  121. package/dist/replica.d.ts.map +1 -1
  122. package/dist/replica.js +297 -165
  123. package/dist/room-draft.d.ts +34 -4
  124. package/dist/room-draft.d.ts.map +1 -1
  125. package/dist/room-draft.js +105 -31
  126. package/dist/rows.d.ts +37 -37
  127. package/dist/rows.d.ts.map +1 -1
  128. package/dist/rows.js +173 -104
  129. package/dist/save.d.ts +52 -9
  130. package/dist/save.d.ts.map +1 -1
  131. package/dist/save.js +539 -171
  132. package/dist/search.d.ts +39 -28
  133. package/dist/search.d.ts.map +1 -1
  134. package/dist/search.js +37 -105
  135. package/dist/seed.d.ts +16 -0
  136. package/dist/seed.d.ts.map +1 -0
  137. package/dist/seed.js +75 -0
  138. package/dist/shared.d.ts +15 -0
  139. package/dist/shared.d.ts.map +1 -0
  140. package/dist/shared.js +421 -0
  141. package/dist/status.d.ts +5 -0
  142. package/dist/status.d.ts.map +1 -1
  143. package/dist/status.js +3 -1
  144. package/dist/store.d.ts +109 -76
  145. package/dist/store.d.ts.map +1 -1
  146. package/dist/store.js +331 -442
  147. package/dist/stored.d.ts +130 -0
  148. package/dist/stored.d.ts.map +1 -0
  149. package/dist/stored.js +562 -0
  150. package/dist/tables.d.ts +342 -0
  151. package/dist/tables.d.ts.map +1 -0
  152. package/dist/tables.js +615 -0
  153. package/dist/transfer.d.ts +0 -5
  154. package/dist/transfer.d.ts.map +1 -1
  155. package/dist/turn.d.ts +9 -0
  156. package/dist/turn.d.ts.map +1 -0
  157. package/dist/turn.js +75 -0
  158. package/dist/validation.d.ts +29 -0
  159. package/dist/validation.d.ts.map +1 -0
  160. package/dist/validation.js +101 -0
  161. package/dist/windows.d.ts +22 -0
  162. package/dist/windows.d.ts.map +1 -0
  163. package/dist/windows.js +89 -0
  164. package/dist/wire.d.ts +168 -32
  165. package/dist/wire.d.ts.map +1 -1
  166. package/dist/wire.js +56 -31
  167. package/dist/words.d.ts +19 -0
  168. package/dist/words.d.ts.map +1 -0
  169. package/dist/words.js +156 -0
  170. package/package.json +27 -24
  171. package/AGENTS.md +0 -318
  172. package/dist/chat/acts.d.ts +0 -34
  173. package/dist/chat/acts.d.ts.map +0 -1
  174. package/dist/chat/acts.js +0 -36
  175. package/dist/chat/context.d.ts +0 -3
  176. package/dist/chat/context.d.ts.map +0 -1
  177. package/dist/chat/context.js +0 -10
  178. package/dist/chat/input.d.ts +0 -9
  179. package/dist/chat/input.d.ts.map +0 -1
  180. package/dist/chat/input.js +0 -99
  181. package/dist/chat/kit.d.ts +0 -60
  182. package/dist/chat/kit.d.ts.map +0 -1
  183. package/dist/chat/kit.js +0 -123
  184. package/dist/chat/lasting.d.ts +0 -6
  185. package/dist/chat/lasting.d.ts.map +0 -1
  186. package/dist/chat/lasting.js +0 -19
  187. package/dist/chat/list.d.ts +0 -20
  188. package/dist/chat/list.d.ts.map +0 -1
  189. package/dist/chat/list.js +0 -59
  190. package/dist/chat/markdown.d.ts +0 -19
  191. package/dist/chat/markdown.d.ts.map +0 -1
  192. package/dist/chat/markdown.js +0 -187
  193. package/dist/chat/message.d.ts +0 -6
  194. package/dist/chat/message.d.ts.map +0 -1
  195. package/dist/chat/message.js +0 -192
  196. package/dist/chat/messages.d.ts +0 -21
  197. package/dist/chat/messages.d.ts.map +0 -1
  198. package/dist/chat/messages.js +0 -151
  199. package/dist/chat/name.d.ts +0 -6
  200. package/dist/chat/name.d.ts.map +0 -1
  201. package/dist/chat/name.js +0 -37
  202. package/dist/chat/opened.d.ts +0 -11
  203. package/dist/chat/opened.d.ts.map +0 -1
  204. package/dist/chat/opened.js +0 -17
  205. package/dist/chat/overlay.d.ts +0 -31
  206. package/dist/chat/overlay.d.ts.map +0 -1
  207. package/dist/chat/overlay.js +0 -97
  208. package/dist/chat/parts.d.ts +0 -57
  209. package/dist/chat/parts.d.ts.map +0 -1
  210. package/dist/chat/parts.js +0 -119
  211. package/dist/chat/process.d.ts +0 -20
  212. package/dist/chat/process.d.ts.map +0 -1
  213. package/dist/chat/process.js +0 -32
  214. package/dist/chat/provider.d.ts +0 -63
  215. package/dist/chat/provider.d.ts.map +0 -1
  216. package/dist/chat/provider.js +0 -645
  217. package/dist/chat/question.d.ts +0 -9
  218. package/dist/chat/question.d.ts.map +0 -1
  219. package/dist/chat/question.js +0 -80
  220. package/dist/chat/questions.d.ts +0 -31
  221. package/dist/chat/questions.d.ts.map +0 -1
  222. package/dist/chat/questions.js +0 -111
  223. package/dist/chat/read.d.ts +0 -5
  224. package/dist/chat/read.d.ts.map +0 -1
  225. package/dist/chat/read.js +0 -13
  226. package/dist/chat/ready.d.ts +0 -33
  227. package/dist/chat/ready.d.ts.map +0 -1
  228. package/dist/chat/ready.js +0 -91
  229. package/dist/chat/style.d.ts +0 -4
  230. package/dist/chat/style.d.ts.map +0 -1
  231. package/dist/chat/style.js +0 -302
  232. package/dist/chat.d.ts +0 -14
  233. package/dist/chat.d.ts.map +0 -1
  234. package/dist/chat.js +0 -8
  235. package/dist/read-side.d.ts +0 -18
  236. package/dist/read-side.d.ts.map +0 -1
  237. package/dist/read-side.js +0 -440
package/dist/bootstrap.js CHANGED
@@ -1,107 +1,207 @@
1
1
  import { transferIdentity } from './identity.js';
2
- import { advancement } from './refresh.js';
3
- import { acceptedBinaries } from './overlay.js';
4
- import { readStaged } from './replica.js';
2
+ import { advancement, pageEntries } from './refresh.js';
3
+ import { entriesIn } from './shared.js';
5
4
  import { unconfirmed } from './transfer.js';
6
- const RESUMABLE = new Set([
7
- 'transport-uncertainty',
8
- 'retryable-refusal',
9
- 'unconfirmed',
10
- ]);
11
- function pageLayer(page) {
5
+ const NOTHING_PRIOR = () => Promise.resolve(new Map());
6
+ function textOf(page) {
7
+ let text = 0;
8
+ for (const [, content] of entriesIn(page.documents))
9
+ text += content.length;
10
+ return text;
11
+ }
12
+ async function pageOf(page) {
13
+ return {
14
+ entries: await pageEntries(page, [], page.roomVersion, NOTHING_PRIOR),
15
+ folders: page.folders ?? [],
16
+ };
17
+ }
18
+ function heldTogether(first, second) {
19
+ if (first === null)
20
+ return second;
21
+ return {
22
+ async files(after, limit) {
23
+ const [left, right] = await Promise.all([
24
+ first.files(after, limit),
25
+ second.files(after, limit),
26
+ ]);
27
+ const merged = new Map([...left, ...right].map((file) => [file.path, file]));
28
+ return [...merged.values()]
29
+ .sort((one, other) => (one.path < other.path ? -1 : one.path > other.path ? 1 : 0))
30
+ .slice(0, limit);
31
+ },
32
+ async contents(paths) {
33
+ const [left, right] = await Promise.all([first.contents(paths), second.contents(paths)]);
34
+ return new Map([...left, ...right]);
35
+ },
36
+ };
37
+ }
38
+ const NO_CONTENT = {
39
+ files: () => Promise.resolve([]),
40
+ contents: () => Promise.resolve(new Map()),
41
+ };
42
+ export async function bootstrapRoom(adapter, authorization, room, held, builtIn, remodel, continuing, staging, reuse) {
43
+ if (staging.held(room.locator) !== null)
44
+ await staging.abandon(room.locator);
45
+ const begun = (pool) => started(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool);
46
+ const first = await begun(reuse);
47
+ if (first.kind !== 'expired')
48
+ return first;
49
+ await staging.setAside(room.locator);
50
+ try {
51
+ const replacement = await begun(heldTogether(reuse, first.held));
52
+ if (replacement.kind !== 'expired')
53
+ return replacement;
54
+ await staging.abandon(room.locator);
55
+ return unconfirmed;
56
+ }
57
+ finally {
58
+ if (first.key !== null)
59
+ await staging.release(first.key);
60
+ }
61
+ }
62
+ function dropped(ahead) {
63
+ void ahead?.fetched.then(({ next, written }) => {
64
+ written();
65
+ dropped(next);
66
+ }, () => { });
67
+ }
68
+ function compositionFor(room, models, builtIn) {
12
69
  return {
13
- documents: page.documents,
14
- revisions: page.revisions,
15
- changes: page.changes,
16
- written: Object.fromEntries(Object.keys(page.documents).map((path) => [path, page.roomVersion])),
17
- binaries: acceptedBinaries(page.binaryFiles),
70
+ model: models.collection,
71
+ selection: room.typedSelection === undefined
72
+ ? null
73
+ : { roots: room.typedSelection.roots, model: builtIn },
18
74
  };
19
75
  }
20
- async function heldTransfer(staging, room) {
21
- const record = staging.held(room.locator);
22
- if (record === null)
23
- return null;
24
- if (record.selection === room.replica.selection) {
25
- return { record, layer: await staging.staged(record) };
76
+ async function started(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool) {
77
+ let outcome;
78
+ try {
79
+ outcome = await bundle(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool);
80
+ }
81
+ catch (error) {
82
+ await staging.abandon(room.locator).catch(() => { });
83
+ throw error;
84
+ }
85
+ if (outcome.kind !== 'staged' && outcome.kind !== 'expired') {
86
+ await staging.abandon(room.locator);
26
87
  }
27
- await staging.abandon(room.locator);
28
- return null;
88
+ return outcome;
29
89
  }
30
- export async function bootstrapRoom(adapter, authorization, room, held, remodel, continuing, staging) {
90
+ async function bundle(adapter, authorization, room, held, builtIn, remodel, continuing, staging, pool) {
31
91
  const locator = room.locator;
32
92
  const selection = room.replica.selection;
33
- const kept = await heldTransfer(staging, room);
34
- const documents = { ...kept?.layer.documents };
35
- const revisions = { ...kept?.layer.revisions };
36
- const changes = { ...kept?.layer.changes };
37
- const written = { ...kept?.layer.written };
38
- const binaries = { ...kept?.layer.binaries };
39
- let transfer = kept?.record ?? null;
40
- while (transfer === null || transfer.pageToken !== null) {
41
- if (!continuing())
42
- return unconfirmed;
43
- const page = await adapter.bootstrap(authorization, {
44
- locator,
45
- selection,
46
- ...(transfer?.pageToken == null ? {} : { pageToken: transfer.pageToken }),
47
- });
48
- if (page.kind !== 'bootstrap') {
49
- if (!RESUMABLE.has(page.kind))
50
- await staging.abandon(locator);
51
- return page;
93
+ const ending = new AbortController();
94
+ const arriving = staging.arriving(locator);
95
+ const downloaded = await staging.turn(locator, 'downloading');
96
+ const asking = (token) => adapter.bootstrap(authorization, {
97
+ locator,
98
+ selection,
99
+ signal: ending.signal,
100
+ ...(token === null
101
+ ? { arriving: (bytes) => arriving.at(bytes) }
102
+ : { pageToken: token }),
103
+ ...(pool === null ? {} : { held: pool }),
104
+ });
105
+ const fetching = (token) => {
106
+ const fetched = (async () => {
107
+ await staging.unqueued();
108
+ const page = continuing() ? await asking(token) : unconfirmed;
109
+ if (page.kind !== 'bootstrap')
110
+ return { page, next: null, written: () => { } };
111
+ const written = staging.queued(textOf(page));
112
+ const later = page.pageToken;
113
+ if (later === undefined) {
114
+ downloaded();
115
+ arriving.end();
116
+ }
117
+ return { page, written, next: later === undefined || !continuing() ? null : fetching(later) };
118
+ })();
119
+ fetched.catch(() => { });
120
+ return { fetched };
121
+ };
122
+ let transfer = null;
123
+ let ahead = fetching(null);
124
+ try {
125
+ while (ahead !== null) {
126
+ if (!continuing())
127
+ return unconfirmed;
128
+ const fetched = await ahead.fetched;
129
+ ahead = fetched.next;
130
+ try {
131
+ if (!continuing())
132
+ return unconfirmed;
133
+ const page = fetched.page;
134
+ if (page.kind === 'beyond-horizon') {
135
+ const key = transfer?.key ?? null;
136
+ return { kind: 'expired', held: key === null ? NO_CONTENT : staging.content(key), key };
137
+ }
138
+ if (page.kind !== 'bootstrap')
139
+ return page;
140
+ const models = remodel(page.models, transfer?.models ?? held);
141
+ const staged = await staging.stage({
142
+ locator,
143
+ transfer: transfer?.transfer ?? transferIdentity(),
144
+ selection,
145
+ from: transfer !== null && adapter.reached(locator, page.roomVersion, transfer.from)
146
+ ? transfer.from
147
+ : page.roomVersion,
148
+ last: transfer !== null && !adapter.reached(locator, page.roomVersion, transfer.last)
149
+ ? transfer.last
150
+ : page.roomVersion,
151
+ done: { bytes: (transfer?.done.bytes ?? 0) + (page.bytes ?? 0) },
152
+ models,
153
+ key: transfer?.key ?? null,
154
+ }, await pageOf(page), compositionFor(room, models, builtIn));
155
+ if (staged === null)
156
+ return unconfirmed;
157
+ transfer = staged;
158
+ }
159
+ finally {
160
+ fetched.written();
161
+ }
52
162
  }
53
- transfer = {
54
- locator,
55
- transfer: transfer?.transfer ?? transferIdentity(),
56
- selection,
57
- from: transfer?.from ?? page.roomVersion,
58
- last: page.roomVersion,
59
- pageToken: page.pageToken ?? null,
60
- models: remodel(page.models, transfer?.models ?? held),
61
- };
62
- const staged = pageLayer(page);
63
- if (!(await staging.stage(transfer, staged)))
64
- return unconfirmed;
65
- Object.assign(documents, staged.documents);
66
- Object.assign(revisions, staged.revisions);
67
- Object.assign(changes, staged.changes);
68
- Object.assign(written, staged.written);
69
- Object.assign(binaries, staged.binaries);
70
163
  }
164
+ finally {
165
+ ending.abort();
166
+ downloaded();
167
+ arriving.end();
168
+ dropped(ahead);
169
+ }
170
+ if (transfer === null)
171
+ return unconfirmed;
172
+ const installed = transfer;
173
+ const composition = compositionFor(room, installed.models, builtIn);
174
+ if (!(await staging.derive(locator, installed.key, composition)))
175
+ return unconfirmed;
176
+ await staging.turn(locator, 'replaying');
177
+ if (!continuing())
178
+ return unconfirmed;
71
179
  const record = {
72
180
  locator,
73
181
  name: room.name,
74
182
  handle: room.handle,
75
183
  operations: room.operations,
76
184
  replica: room.replica,
77
- model: transfer.models.collection,
185
+ model: installed.models.collection,
78
186
  typedSelection: room.typedSelection ?? null,
79
- selectionModel: transfer.models.selection,
80
187
  providerOwnedPaths: room.providerOwnedPaths,
81
- roomVersion: transfer.from,
82
- transfer: transfer.transfer,
83
- documents,
84
- binaries,
85
- revisions,
86
- changes,
87
- written,
188
+ roomVersion: installed.from,
189
+ transfer: installed.transfer,
190
+ inventory: installed.done,
191
+ key: installed.key,
88
192
  };
89
- const reconciled = transfer.last === transfer.from
193
+ const due = [room.roomVersion, ...staging.announced(locator)];
194
+ const last = installed.last;
195
+ const reconciled = last === installed.from && due.every((version) => adapter.reached(locator, last, version))
90
196
  ? { kind: 'still-current' }
91
- : await advancement(adapter, authorization, record, remodel, continuing);
92
- if (reconciled.kind === 'advanced' || reconciled.kind === 'still-current') {
93
- const read = readStaged(reconciled.kind === 'advanced' ? reconciled.record : record);
94
- if (read.kind === 'refused') {
95
- await staging.abandon(locator);
96
- return read;
97
- }
98
- return { kind: 'staged', confirmed: read.confirmed, stored: record };
197
+ : await advancement(adapter, authorization, record, remodel, continuing, await staging.refreshing(locator, record.key, composition));
198
+ if (reconciled.kind === 'advanced') {
199
+ return { kind: 'staged', record: reconciled.record, refreshed: true };
99
200
  }
201
+ if (reconciled.kind === 'still-current')
202
+ return { kind: 'staged', record, refreshed: false };
100
203
  if (reconciled.kind === 'beyond-horizon') {
101
- await staging.abandon(locator);
102
- return unconfirmed;
204
+ return { kind: 'expired', held: staging.content(record.key), key: record.key };
103
205
  }
104
- if (!RESUMABLE.has(reconciled.kind))
105
- await staging.abandon(locator);
106
206
  return reconciled;
107
207
  }
@@ -0,0 +1,11 @@
1
+ import type { MdRuntimeClient } from './client.js';
2
+ import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
3
+ type Rows = DocumentResult | GroupResult;
4
+ export type WindowAnswer = Rows | PendingResult;
5
+ export type WindowChain = {
6
+ want(count: number): void;
7
+ close(): void;
8
+ };
9
+ export declare function chainedWindows(runtime: MdRuntimeClient, query: DocumentQuery | GroupQuery, count: number, publish: (answers: readonly (WindowAnswer | null)[], settled: boolean) => void): WindowChain;
10
+ export {};
11
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,KAAK,IAAI,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,aAAa,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAaF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,GAAG,UAAU,EACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GAC7E,WAAW,CAkEb"}
package/dist/chain.js ADDED
@@ -0,0 +1,64 @@
1
+ function answered(answer) {
2
+ return answer !== null && !('pending' in answer);
3
+ }
4
+ export function chainedWindows(runtime, query, count, publish) {
5
+ let links = [];
6
+ let wanted = count;
7
+ let closed = false;
8
+ const observe = runtime.observe;
9
+ const open = (after, shown) => {
10
+ const link = { after, observation: null, value: shown, fresh: false };
11
+ void observe('query', after === undefined ? query : { ...query, after }).then((observation) => {
12
+ if (closed || !links.includes(link)) {
13
+ observation.close();
14
+ return;
15
+ }
16
+ link.observation = observation;
17
+ const take = (value) => {
18
+ link.value = value;
19
+ link.fresh = true;
20
+ settle();
21
+ };
22
+ observation.subscribe(take);
23
+ take(observation.current());
24
+ }, () => { });
25
+ return link;
26
+ };
27
+ const settle = () => {
28
+ if (closed)
29
+ return;
30
+ const next = [];
31
+ for (let at = 0; at < wanted; at += 1) {
32
+ const before = next[at - 1];
33
+ if (before !== undefined && !before.fresh) {
34
+ next.push(...links.slice(at, wanted));
35
+ break;
36
+ }
37
+ if (before !== undefined && (!answered(before.value) || before.value.next === undefined)) {
38
+ break;
39
+ }
40
+ const after = before === undefined ? undefined : before.value.next;
41
+ const held = links[at];
42
+ next.push(held !== undefined && held.after === after ? held : open(after, held?.value ?? null));
43
+ }
44
+ for (const link of links)
45
+ if (!next.includes(link))
46
+ link.observation?.close();
47
+ links = next;
48
+ publish(links.map((link) => link.value), links.every((link) => link.fresh));
49
+ };
50
+ settle();
51
+ return {
52
+ want(count) {
53
+ if (count === wanted)
54
+ return;
55
+ wanted = count;
56
+ settle();
57
+ },
58
+ close() {
59
+ closed = true;
60
+ for (const link of links)
61
+ link.observation?.close();
62
+ },
63
+ };
64
+ }
@@ -1,14 +1,6 @@
1
- import { type Replica } from './replica.js';
2
- import { type Row } from './rows.js';
3
1
  export type DocumentChange = {
4
- locator: string;
5
- path: string;
6
- before: readonly Row[];
7
- after: readonly Row[];
8
- };
9
- export type MessageChange = {
10
- conversation: string;
11
- identity: string;
2
+ readonly locator: string;
3
+ readonly path: string | null;
12
4
  };
13
5
  export type ChangeSet = {
14
6
  documents: readonly DocumentChange[];
@@ -19,15 +11,18 @@ export type ChangeSet = {
19
11
  rooms: readonly string[];
20
12
  queues: readonly string[];
21
13
  presentations: readonly string[];
22
- messages: readonly MessageChange[];
23
14
  conversations: readonly string[];
24
15
  };
25
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
16
+ type Changed = {
17
+ documents?: readonly string[] | null;
26
18
  drafts?: readonly string[];
27
19
  room?: boolean;
28
20
  queue?: boolean;
29
21
  presentation?: string;
30
- }): ChangeSet;
31
- export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
22
+ };
23
+ export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
24
+ export declare function conversationChangeSet(conversations: readonly string[]): ChangeSet;
32
25
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
26
+ export declare function touches(set: ChangeSet, locator: string, path: string): boolean;
27
+ export {};
33
28
  //# sourceMappingURL=change-set.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAwB,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,EAAE,CAAC;IACvB,KAAK,EAAE,SAAS,GAAG,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,SAAS;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAuBF,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,GAAG,IAAI,EACtB,KAAK,EAAE,OAAO,GAAG,IAAI,EACrB,OAA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AE,MAAM,EAAE,OAAO,GAAE,OAAY,GAAG,SAAS,CAe3E;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CASjF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CASrE;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI9E"}
@@ -1,79 +1,25 @@
1
- import { passingDocument } from './collection.js';
2
- import { binaryRecord } from './binary.js';
3
- import { sameBinary, sameChange } from './overlay.js';
4
- import { beneath } from './paths.js';
5
- import { compositionOf, sameMembership } from './replica.js';
6
- import { markdownPath, rowsOf } from './rows.js';
7
- function rowsAt(locator, replica, path) {
8
- if (replica === null)
9
- return [];
10
- const visible = replica.visible;
11
- const document = markdownPath(path) ? passingDocument(visible.collection, path) : null;
12
- const held = visible.documents[path] !== undefined && document !== undefined;
13
- const binary = visible.binaries[path];
14
- if (!held && binary === undefined)
15
- return [];
16
- return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record), visible.changes[path] ?? null, binary === undefined ? null : binaryRecord(path, binary, visible.revisions[path]));
17
- }
18
- function modelShape(model) {
19
- return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
20
- }
21
- export function changeSet(locator, before, after, changed = {}) {
22
- const paths = new Set([
23
- ...Object.keys(before?.visible.documents ?? {}),
24
- ...Object.keys(after?.visible.documents ?? {}),
25
- ...Object.keys(before?.visible.binaries ?? {}),
26
- ...Object.keys(after?.visible.binaries ?? {}),
27
- ]);
28
- const documents = [];
29
- const oldRoom = before?.confirmed.record;
30
- const newRoom = after?.confirmed.record;
31
- const collectionChanged = oldRoom !== undefined &&
32
- newRoom !== undefined &&
33
- modelShape(oldRoom.model) !== modelShape(newRoom.model);
34
- const selectionChanged = oldRoom !== undefined &&
35
- newRoom !== undefined &&
36
- modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);
37
- const reclassified = oldRoom !== undefined && newRoom !== undefined && !sameMembership(oldRoom, newRoom);
38
- for (const path of paths) {
39
- const selected = newRoom?.typedSelection?.roots.some((root) => beneath(root, path)) ?? false;
40
- const retyped = selected ? selectionChanged : collectionChanged;
41
- if (before?.visible.documents[path] === after?.visible.documents[path] &&
42
- sameBinary(before?.visible.binaries[path], after?.visible.binaries[path]) &&
43
- before?.visible.revisions[path] === after?.visible.revisions[path] &&
44
- sameChange(before?.visible.changes[path], after?.visible.changes[path]) &&
45
- !retyped &&
46
- !reclassified)
47
- continue;
48
- documents.push({
49
- locator,
50
- path,
51
- get before() {
52
- return rowsAt(locator, before, path);
53
- },
54
- get after() {
55
- return rowsAt(locator, after, path);
56
- },
57
- });
58
- }
1
+ export function changeSet(locator, changed = {}) {
2
+ const documents = changed.documents;
59
3
  return {
60
- documents,
4
+ documents: documents === undefined
5
+ ? []
6
+ : documents === null
7
+ ? [{ locator, path: null }]
8
+ : documents.map((path) => ({ locator, path })),
61
9
  drafts: (changed.drafts ?? []).map((path) => ({ locator, path })),
62
10
  rooms: changed.room ? [locator] : [],
63
11
  queues: changed.queue ? [locator] : [],
64
12
  presentations: changed.presentation === undefined ? [] : [changed.presentation],
65
- messages: [],
66
13
  conversations: [],
67
14
  };
68
15
  }
69
- export function conversationChangeSet(messages, conversations) {
16
+ export function conversationChangeSet(conversations) {
70
17
  return {
71
18
  documents: [],
72
19
  drafts: [],
73
20
  rooms: [],
74
21
  queues: [],
75
22
  presentations: [],
76
- messages,
77
23
  conversations: [...new Set(conversations)],
78
24
  };
79
25
  }
@@ -84,7 +30,9 @@ export function mergeChangeSets(sets) {
84
30
  rooms: [...new Set(sets.flatMap((set) => set.rooms))],
85
31
  queues: [...new Set(sets.flatMap((set) => set.queues))],
86
32
  presentations: [...new Set(sets.flatMap((set) => set.presentations))],
87
- messages: sets.flatMap((set) => set.messages),
88
33
  conversations: [...new Set(sets.flatMap((set) => set.conversations))],
89
34
  };
90
35
  }
36
+ export function touches(set, locator, path) {
37
+ return set.documents.some((change) => change.locator === locator && (change.path === null || change.path === path));
38
+ }
package/dist/change.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { BinaryFile, HeadChange } from './adapter.js';
1
2
  export type Change = {
2
3
  readonly kind: 'field';
3
4
  readonly path: string;
@@ -29,7 +30,6 @@ export type Change = {
29
30
  readonly kind: 'binary';
30
31
  readonly path: string;
31
32
  readonly localId: string;
32
- readonly blob: Blob;
33
33
  readonly byteLength: number;
34
34
  readonly mediaType: string;
35
35
  readonly sha256: string;
@@ -40,6 +40,32 @@ export type Change = {
40
40
  } | {
41
41
  readonly kind: 'remove';
42
42
  readonly path: string;
43
+ } | (Arriving & {
44
+ readonly content: string;
45
+ }) | (Arriving & {
46
+ readonly binary: BinaryFile;
47
+ });
48
+ type Arriving = {
49
+ readonly kind: 'arrival';
50
+ readonly path: string;
51
+ readonly revision?: string;
52
+ readonly fileId?: string;
53
+ readonly change?: HeadChange;
54
+ };
55
+ export type RoomMove = {
56
+ readonly source: {
57
+ readonly room: string;
58
+ readonly baseRoomVersion: string;
59
+ };
60
+ readonly destination: {
61
+ readonly room: string;
62
+ readonly baseRoomVersion: string;
63
+ readonly handle: string;
64
+ };
65
+ readonly moves: readonly {
66
+ readonly path: string;
67
+ readonly to: string;
68
+ }[];
43
69
  };
44
70
  export type Precondition = {
45
71
  readonly kind: 'field';
@@ -81,9 +107,13 @@ export type ChangeBatch = {
81
107
  readonly changes: readonly Change[];
82
108
  readonly preconditions: readonly Precondition[];
83
109
  readonly writtenBy?: WrittenBy;
110
+ readonly between?: RoomMove;
84
111
  };
85
112
  export declare function immutable(batch: ChangeBatch): ChangeBatch;
113
+ export declare function partnerOf(batch: ChangeBatch, locator: string): string | null;
114
+ export declare function leaving(batch: ChangeBatch, locator: string): boolean;
86
115
  export declare function landing(changes: readonly Change[], index: number, path: string): string | null;
87
116
  export declare function departure(changes: readonly Change[], index: number): string;
88
117
  export declare function queuedFile(batch: ChangeBatch, path: string, localId: string): number;
118
+ export {};
89
119
  //# sourceMappingURL=change.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../src/change.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5E;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,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function frozen(value) {
2
2
  if (Array.isArray(value))
3
3
  return Object.freeze(value.map((item) => frozen(item)));
4
- if (value === null || typeof value !== 'object' || value instanceof Blob)
4
+ if (value === null || typeof value !== 'object')
5
5
  return value;
6
6
  const copy = {};
7
7
  for (const [name, item] of Object.entries(value))
@@ -11,6 +11,15 @@ function frozen(value) {
11
11
  export function immutable(batch) {
12
12
  return frozen(batch);
13
13
  }
14
+ export function partnerOf(batch, locator) {
15
+ const between = batch.between;
16
+ if (between === undefined)
17
+ return null;
18
+ return between.source.room === locator ? between.destination.room : between.source.room;
19
+ }
20
+ export function leaving(batch, locator) {
21
+ return batch.between?.source.room === locator;
22
+ }
14
23
  export function landing(changes, index, path) {
15
24
  let at = path;
16
25
  for (const change of changes.slice(index + 1)) {