@agentshouse/mdruntime 0.1.0-cfb2ae0107054 → 0.1.0-cfcbb238a5fa0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +262 -262
- package/dist/acquisition.d.ts +14 -0
- package/dist/acquisition.d.ts.map +1 -0
- package/dist/acquisition.js +24 -0
- package/dist/adapter.d.ts +14 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +4 -0
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +36 -10
- package/dist/chat/kit.d.ts +2 -1
- package/dist/chat/kit.d.ts.map +1 -1
- package/dist/chat/kit.js +3 -3
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +4 -3
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +2 -2
- package/dist/chat/messages.d.ts +1 -0
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +4 -0
- package/dist/chat/provider.d.ts +1 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +26 -17
- package/dist/chat/ready.d.ts +1 -0
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +2 -2
- package/dist/client.d.ts +10 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +11 -2
- package/dist/collection.d.ts +17 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +230 -19
- package/dist/connection.d.ts +23 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1065 -192
- package/dist/conversation.d.ts +11 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +241 -100
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +3 -3
- package/dist/host.d.ts +16 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +82 -8
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +6 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/memory.d.ts +7 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +20 -7
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -1
- package/dist/observation.d.ts +5 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -11
- package/dist/overlay.d.ts +2 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +58 -55
- package/dist/query.d.ts +35 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +8 -2
- package/dist/reach.d.ts +6 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +16 -4
- package/dist/react.d.ts +7 -4
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +6 -4
- package/dist/read-side.d.ts +13 -6
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +285 -83
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +17 -10
- package/dist/replica.d.ts +1 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +57 -20
- package/dist/room-draft.d.ts +13 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +2 -2
- package/dist/rows.d.ts +5 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +5 -13
- package/dist/save.d.ts +5 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +36 -13
- package/dist/search.d.ts +36 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +132 -46
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +61 -0
- package/dist/shared.d.ts +11 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +368 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +21 -5
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +157 -53
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +45 -0
- package/dist/wire.d.ts +136 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +48 -31
- package/package.json +2 -2
package/dist/store.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { sameBinary, sameChange } from './overlay.js';
|
|
2
|
+
import { differing } from './shared.js';
|
|
2
3
|
const DATABASE = 'mdruntime';
|
|
3
4
|
const AUTHORED = 'mdruntime-authored';
|
|
4
5
|
const FENCES = 'fences';
|
|
@@ -19,10 +20,11 @@ const QUEUES = 'queues';
|
|
|
19
20
|
const FACTS = 'facts';
|
|
20
21
|
const CURRENT = 'current';
|
|
21
22
|
const MEMBER = 'member';
|
|
23
|
+
const TARGETS = 'targets';
|
|
22
24
|
const GENERATION = 'generation';
|
|
23
25
|
const HOLDER = 'holder';
|
|
24
26
|
const BINDING = 'binding';
|
|
25
|
-
export const STORE_SCHEMA =
|
|
27
|
+
export const STORE_SCHEMA = 25;
|
|
26
28
|
const REPLICA_SHAPE = 23;
|
|
27
29
|
export const AUTHORED_SCHEMA = 2;
|
|
28
30
|
const AUTHORED_STORES = [
|
|
@@ -46,6 +48,11 @@ const REPLICA_STORES = [
|
|
|
46
48
|
[MESSAGES, { keyPath: ['conversation', 'identity'] }],
|
|
47
49
|
];
|
|
48
50
|
const READ_BATCH = 256;
|
|
51
|
+
const MESSAGE_INDEXES = [
|
|
52
|
+
['conversation', 'conversation'],
|
|
53
|
+
['position', ['conversation', 'position']],
|
|
54
|
+
['turn', ['conversation', 'turn']],
|
|
55
|
+
];
|
|
49
56
|
function settled(request) {
|
|
50
57
|
return new Promise((resolve, reject) => {
|
|
51
58
|
request.onsuccess = () => resolve(request.result);
|
|
@@ -88,8 +95,11 @@ function amendPending(database, locator, id, amendment) {
|
|
|
88
95
|
};
|
|
89
96
|
return completed(transaction);
|
|
90
97
|
}
|
|
98
|
+
function accepted({ conversation: _held, ...message }) {
|
|
99
|
+
return message;
|
|
100
|
+
}
|
|
91
101
|
function roomRecord(record) {
|
|
92
|
-
const { documents, binaries, revisions, changes, written, ...room } = record;
|
|
102
|
+
const { documents, binaries, revisions, fileIds, changes, written, ...room } = record;
|
|
93
103
|
return room;
|
|
94
104
|
}
|
|
95
105
|
function chatDraftRecord(record) {
|
|
@@ -115,13 +125,15 @@ async function readTransfer(store, locator, transfer, receive) {
|
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
127
|
function emptyLayer() {
|
|
118
|
-
return { documents: {}, binaries: {}, revisions: {}, changes: {}, written: {} };
|
|
128
|
+
return { documents: {}, binaries: {}, revisions: {}, fileIds: {}, changes: {}, written: {} };
|
|
119
129
|
}
|
|
120
130
|
async function readLayer(transaction, locator, transfer) {
|
|
121
131
|
const layer = emptyLayer();
|
|
122
132
|
const head = (held) => {
|
|
123
133
|
if (held.revision !== null)
|
|
124
134
|
layer.revisions[held.path] = held.revision;
|
|
135
|
+
if (held.fileId !== null)
|
|
136
|
+
layer.fileIds[held.path] = held.fileId;
|
|
125
137
|
if (held.change !== null)
|
|
126
138
|
layer.changes[held.path] = held.change;
|
|
127
139
|
};
|
|
@@ -144,6 +156,7 @@ function documentRecord(locator, transfer, layer, path) {
|
|
|
144
156
|
path,
|
|
145
157
|
content: layer.documents[path],
|
|
146
158
|
revision: layer.revisions[path] ?? null,
|
|
159
|
+
fileId: layer.fileIds[path] ?? null,
|
|
147
160
|
change: layer.changes[path] ?? null,
|
|
148
161
|
written: layer.written[path] ?? null,
|
|
149
162
|
};
|
|
@@ -154,35 +167,37 @@ function binaryFileRecord(locator, transfer, layer, path) {
|
|
|
154
167
|
transfer,
|
|
155
168
|
path,
|
|
156
169
|
revision: layer.revisions[path] ?? null,
|
|
170
|
+
fileId: layer.fileIds[path] ?? null,
|
|
157
171
|
change: layer.changes[path] ?? null,
|
|
158
172
|
binary: layer.binaries[path],
|
|
159
173
|
};
|
|
160
174
|
}
|
|
161
175
|
function writeLayer(transaction, locator, transfer, next, base) {
|
|
162
176
|
const documents = transaction.objectStore(DOCUMENTS);
|
|
163
|
-
for (const path of Object.keys(base?.documents ?? {})) {
|
|
164
|
-
if (next.documents[path] === undefined)
|
|
165
|
-
documents.delete([locator, transfer, path]);
|
|
166
|
-
}
|
|
167
|
-
for (const [path, content] of Object.entries(next.documents)) {
|
|
168
|
-
if (base?.documents[path] === content &&
|
|
169
|
-
base.revisions[path] === next.revisions[path] &&
|
|
170
|
-
base.written[path] === next.written[path] &&
|
|
171
|
-
sameChange(base.changes[path], next.changes[path]))
|
|
172
|
-
continue;
|
|
173
|
-
documents.put(documentRecord(locator, transfer, next, path));
|
|
174
|
-
}
|
|
175
177
|
const files = transaction.objectStore(BINARY_FILES);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
base
|
|
183
|
-
|
|
178
|
+
const paths = base === null
|
|
179
|
+
? new Set([...Object.keys(next.documents), ...Object.keys(next.binaries)])
|
|
180
|
+
: new Set([
|
|
181
|
+
...differing(base.documents, next.documents),
|
|
182
|
+
...differing(base.revisions, next.revisions),
|
|
183
|
+
...differing(base.fileIds, next.fileIds),
|
|
184
|
+
...differing(base.written, next.written),
|
|
185
|
+
...differing(base.changes, next.changes, sameChange),
|
|
186
|
+
...differing(base.binaries, next.binaries, sameBinary),
|
|
187
|
+
]);
|
|
188
|
+
for (const path of paths) {
|
|
189
|
+
if (next.documents[path] !== undefined) {
|
|
190
|
+
documents.put(documentRecord(locator, transfer, next, path));
|
|
191
|
+
}
|
|
192
|
+
else if (base?.documents[path] !== undefined) {
|
|
193
|
+
documents.delete([locator, transfer, path]);
|
|
194
|
+
}
|
|
195
|
+
if (next.binaries[path] !== undefined) {
|
|
184
196
|
files.put(binaryFileRecord(locator, transfer, next, path));
|
|
185
197
|
}
|
|
198
|
+
else if (base?.binaries[path] !== undefined) {
|
|
199
|
+
files.delete([locator, transfer, path]);
|
|
200
|
+
}
|
|
186
201
|
}
|
|
187
202
|
}
|
|
188
203
|
function removeRoomEntries(store, locator) {
|
|
@@ -263,34 +278,49 @@ export async function removeRuntimeStore(holder) {
|
|
|
263
278
|
await removeDatabase(AUTHORED);
|
|
264
279
|
return false;
|
|
265
280
|
}
|
|
281
|
+
export function openDatabase(name, version, upgrade) {
|
|
282
|
+
return new Promise((resolve, reject) => {
|
|
283
|
+
const opening = indexedDB.open(name, version);
|
|
284
|
+
opening.onupgradeneeded = (event) => upgrade(opening, event.oldVersion);
|
|
285
|
+
opening.onsuccess = () => resolve(opening.result);
|
|
286
|
+
opening.onerror = () => {
|
|
287
|
+
if (opening.error?.name !== 'VersionError') {
|
|
288
|
+
reject(opening.error);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
removeDatabase(name)
|
|
292
|
+
.then(() => openDatabase(name, version, upgrade))
|
|
293
|
+
.then(resolve, reject);
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
266
297
|
function openReplica() {
|
|
267
|
-
|
|
268
|
-
opening.onupgradeneeded = (event) => {
|
|
298
|
+
return openDatabase(DATABASE, STORE_SCHEMA, (opening, oldVersion) => {
|
|
269
299
|
const database = opening.result;
|
|
270
|
-
if (
|
|
300
|
+
if (oldVersion < REPLICA_SHAPE) {
|
|
271
301
|
for (const name of [...database.objectStoreNames])
|
|
272
302
|
database.deleteObjectStore(name);
|
|
273
303
|
}
|
|
274
304
|
for (const [name, parameters] of REPLICA_STORES) {
|
|
275
305
|
if (database.objectStoreNames.contains(name))
|
|
276
306
|
continue;
|
|
277
|
-
|
|
278
|
-
if (name === MESSAGES)
|
|
279
|
-
store.createIndex('conversation', 'conversation');
|
|
307
|
+
database.createObjectStore(name, parameters);
|
|
280
308
|
}
|
|
281
|
-
|
|
282
|
-
|
|
309
|
+
const messages = opening.transaction.objectStore(MESSAGES);
|
|
310
|
+
for (const [name, keyPath] of MESSAGE_INDEXES) {
|
|
311
|
+
if (!messages.indexNames.contains(name))
|
|
312
|
+
messages.createIndex(name, keyPath);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
283
315
|
}
|
|
284
316
|
function openAuthored() {
|
|
285
|
-
|
|
286
|
-
opening.onupgradeneeded = () => {
|
|
317
|
+
return openDatabase(AUTHORED, AUTHORED_SCHEMA, (opening) => {
|
|
287
318
|
const database = opening.result;
|
|
288
319
|
for (const [name, parameters] of AUTHORED_STORES) {
|
|
289
320
|
if (!database.objectStoreNames.contains(name))
|
|
290
321
|
database.createObjectStore(name, parameters);
|
|
291
322
|
}
|
|
292
|
-
};
|
|
293
|
-
return settled(opening);
|
|
323
|
+
});
|
|
294
324
|
}
|
|
295
325
|
export async function openRuntimeStore(fenced) {
|
|
296
326
|
const authored = await openAuthored();
|
|
@@ -402,6 +432,16 @@ export async function openRuntimeStore(fenced) {
|
|
|
402
432
|
transaction.objectStore(DECLARATIONS).put(member, MEMBER);
|
|
403
433
|
await completed(transaction);
|
|
404
434
|
},
|
|
435
|
+
async targets() {
|
|
436
|
+
const transaction = database.transaction(DECLARATIONS, 'readonly');
|
|
437
|
+
const held = await settled(transaction.objectStore(DECLARATIONS).get(TARGETS));
|
|
438
|
+
return held ?? {};
|
|
439
|
+
},
|
|
440
|
+
async keepTargets(targets) {
|
|
441
|
+
const transaction = database.transaction(DECLARATIONS, 'readwrite');
|
|
442
|
+
transaction.objectStore(DECLARATIONS).put(targets, TARGETS);
|
|
443
|
+
await completed(transaction);
|
|
444
|
+
},
|
|
405
445
|
async queues() {
|
|
406
446
|
const transaction = authored.transaction([QUEUES, PENDING_CHANGES], 'readonly');
|
|
407
447
|
const [queues, pending] = await Promise.all([
|
|
@@ -450,19 +490,28 @@ export async function openRuntimeStore(fenced) {
|
|
|
450
490
|
},
|
|
451
491
|
async conversations() {
|
|
452
492
|
const transaction = database.transaction([CONVERSATIONS, MESSAGES], 'readonly');
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
493
|
+
const records = await settled(transaction.objectStore(CONVERSATIONS).getAll());
|
|
494
|
+
const held = new Map(records.map(({ conversation, read, partial }) => [
|
|
495
|
+
conversation,
|
|
496
|
+
{ conversation, read, partial: partial === true },
|
|
497
|
+
]));
|
|
498
|
+
const keys = transaction.objectStore(MESSAGES).index('conversation');
|
|
499
|
+
await new Promise((resolve, reject) => {
|
|
500
|
+
const cursor = keys.openKeyCursor(null, 'nextunique');
|
|
501
|
+
cursor.onerror = () => reject(cursor.error);
|
|
502
|
+
cursor.onsuccess = () => {
|
|
503
|
+
const at = cursor.result;
|
|
504
|
+
if (at === null) {
|
|
505
|
+
resolve();
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const conversation = at.key;
|
|
509
|
+
if (!held.has(conversation)) {
|
|
510
|
+
held.set(conversation, { conversation, read: undefined, partial: true });
|
|
511
|
+
}
|
|
512
|
+
at.continue();
|
|
513
|
+
};
|
|
514
|
+
});
|
|
466
515
|
return [...held.values()];
|
|
467
516
|
},
|
|
468
517
|
async keepMessages({ conversation, messages, read }) {
|
|
@@ -472,12 +521,60 @@ export async function openRuntimeStore(fenced) {
|
|
|
472
521
|
stored.put({ ...message, conversation });
|
|
473
522
|
}
|
|
474
523
|
if (read !== undefined) {
|
|
475
|
-
transaction
|
|
476
|
-
|
|
477
|
-
.
|
|
524
|
+
transaction.objectStore(CONVERSATIONS).put({
|
|
525
|
+
conversation,
|
|
526
|
+
read: read.at,
|
|
527
|
+
...(read.partial ? { partial: true } : {}),
|
|
528
|
+
});
|
|
478
529
|
}
|
|
479
530
|
await completed(transaction);
|
|
480
531
|
},
|
|
532
|
+
async messageWindow(conversation, limit) {
|
|
533
|
+
const transaction = database.transaction(MESSAGES, 'readonly');
|
|
534
|
+
const index = transaction.objectStore(MESSAGES).index('position');
|
|
535
|
+
const range = IDBKeyRange.bound([conversation], [conversation, []]);
|
|
536
|
+
if (limit === undefined) {
|
|
537
|
+
return (await settled(index.getAll(range))).map(accepted);
|
|
538
|
+
}
|
|
539
|
+
const latest = [];
|
|
540
|
+
if (limit === 0)
|
|
541
|
+
return latest;
|
|
542
|
+
await new Promise((resolve, reject) => {
|
|
543
|
+
const cursor = index.openCursor(range, 'prev');
|
|
544
|
+
cursor.onerror = () => reject(cursor.error);
|
|
545
|
+
cursor.onsuccess = () => {
|
|
546
|
+
const at = cursor.result;
|
|
547
|
+
if (at === null) {
|
|
548
|
+
resolve();
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
latest.push(accepted(at.value));
|
|
552
|
+
if (latest.length === limit)
|
|
553
|
+
resolve();
|
|
554
|
+
else
|
|
555
|
+
at.continue();
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
return latest.reverse();
|
|
559
|
+
},
|
|
560
|
+
async messagesAfter(conversation, identity) {
|
|
561
|
+
const transaction = database.transaction(MESSAGES, 'readonly');
|
|
562
|
+
const range = identity === null
|
|
563
|
+
? IDBKeyRange.bound([conversation], [conversation, []])
|
|
564
|
+
: IDBKeyRange.bound([conversation, identity], [conversation, []], true);
|
|
565
|
+
const held = await settled(transaction.objectStore(MESSAGES).getAll(range, READ_BATCH));
|
|
566
|
+
return held.map(accepted);
|
|
567
|
+
},
|
|
568
|
+
async messageIdentities(conversation) {
|
|
569
|
+
const transaction = database.transaction(MESSAGES, 'readonly');
|
|
570
|
+
const keys = await settled(transaction.objectStore(MESSAGES).index('conversation').getAllKeys(conversation));
|
|
571
|
+
return keys.map((key) => key[1]);
|
|
572
|
+
},
|
|
573
|
+
async turnArrived(conversation, turn) {
|
|
574
|
+
const transaction = database.transaction(MESSAGES, 'readonly');
|
|
575
|
+
const held = await settled(transaction.objectStore(MESSAGES).index('turn').count([conversation, turn]));
|
|
576
|
+
return held > 0;
|
|
577
|
+
},
|
|
481
578
|
async dropConversations(conversations) {
|
|
482
579
|
const drafts = authored.transaction(CHAT_DRAFTS, 'readwrite');
|
|
483
580
|
for (const conversation of conversations)
|
|
@@ -500,9 +597,10 @@ export async function openRuntimeStore(fenced) {
|
|
|
500
597
|
const held = await settled(transaction.objectStore(CHAT_DRAFTS).getAll());
|
|
501
598
|
return held.map(chatDraftRecord);
|
|
502
599
|
},
|
|
503
|
-
async
|
|
600
|
+
async keepChatDrafts(records) {
|
|
504
601
|
const transaction = authored.transaction(CHAT_DRAFTS, 'readwrite');
|
|
505
|
-
|
|
602
|
+
for (const record of records)
|
|
603
|
+
transaction.objectStore(CHAT_DRAFTS).put(record);
|
|
506
604
|
await completed(transaction);
|
|
507
605
|
},
|
|
508
606
|
async dropChatDraft(conversation) {
|
|
@@ -552,6 +650,12 @@ export async function openRuntimeStore(fenced) {
|
|
|
552
650
|
fences.objectStore(FENCES).delete(locator);
|
|
553
651
|
await completed(fences);
|
|
554
652
|
},
|
|
653
|
+
async discard(locator) {
|
|
654
|
+
const transaction = authored.transaction([QUEUES, PENDING_CHANGES], 'readwrite');
|
|
655
|
+
transaction.objectStore(QUEUES).delete(locator);
|
|
656
|
+
removeRoomEntries(transaction.objectStore(PENDING_CHANGES), locator);
|
|
657
|
+
await completed(transaction);
|
|
658
|
+
},
|
|
555
659
|
async transfers() {
|
|
556
660
|
const transaction = database.transaction(TRANSFERS, 'readonly');
|
|
557
661
|
const held = await settled(transaction.objectStore(TRANSFERS).getAll());
|
package/dist/turn.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function yielded(): Promise<void>;
|
|
2
|
+
export declare const ROW_WEIGHT = 256;
|
|
3
|
+
export type Later<T> = T | Promise<T>;
|
|
4
|
+
export declare function after<T, R>(value: Later<T>, next: (value: T) => R): Later<R>;
|
|
5
|
+
export declare function inUnits<T>(items: Iterable<T>, each: (item: T) => number): Later<void>;
|
|
6
|
+
export declare function inChunks<T>(items: readonly T[], weigh: (item: T) => number, each: (chunk: readonly T[]) => void): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=turn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../src/turn.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CASvC;AAID,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE5E;AAaD,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAOrF;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC1B,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,IAAI,GAClC,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
package/dist/turn.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function yielded() {
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
const channel = new MessageChannel();
|
|
4
|
+
channel.port1.onmessage = () => {
|
|
5
|
+
channel.port1.close();
|
|
6
|
+
resolve();
|
|
7
|
+
};
|
|
8
|
+
channel.port2.postMessage(null);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const UNIT = 1 << 20;
|
|
12
|
+
export const ROW_WEIGHT = 256;
|
|
13
|
+
export function after(value, next) {
|
|
14
|
+
return value instanceof Promise ? value.then(next) : next(value);
|
|
15
|
+
}
|
|
16
|
+
async function resumed(iterator, each) {
|
|
17
|
+
let spent = UNIT;
|
|
18
|
+
for (let next = iterator.next(); next.done !== true; next = iterator.next()) {
|
|
19
|
+
if (spent >= UNIT) {
|
|
20
|
+
await yielded();
|
|
21
|
+
spent = 0;
|
|
22
|
+
}
|
|
23
|
+
spent += each(next.value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function inUnits(items, each) {
|
|
27
|
+
const iterator = items[Symbol.iterator]();
|
|
28
|
+
let spent = 0;
|
|
29
|
+
for (let next = iterator.next(); next.done !== true; next = iterator.next()) {
|
|
30
|
+
spent += each(next.value);
|
|
31
|
+
if (spent >= UNIT)
|
|
32
|
+
return resumed(iterator, each);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function inChunks(items, weigh, each) {
|
|
36
|
+
for (let at = 0; at < items.length;) {
|
|
37
|
+
await yielded();
|
|
38
|
+
const chunk = [];
|
|
39
|
+
for (let spent = 0; at < items.length && spent < UNIT; at += 1) {
|
|
40
|
+
chunk.push(items[at]);
|
|
41
|
+
spent += weigh(items[at]);
|
|
42
|
+
}
|
|
43
|
+
each(chunk);
|
|
44
|
+
}
|
|
45
|
+
}
|
package/dist/wire.d.ts
CHANGED
|
@@ -8,40 +8,140 @@ export type RuntimePort = {
|
|
|
8
8
|
start(): void;
|
|
9
9
|
};
|
|
10
10
|
export type WireReach = 'within' | 'app' | 'runtime' | 'actions' | 'whole';
|
|
11
|
+
export type WireEffect = 'read' | 'write' | 'action';
|
|
12
|
+
export type WireCall = {
|
|
13
|
+
readonly reach: WireReach;
|
|
14
|
+
readonly effect: WireEffect;
|
|
15
|
+
};
|
|
11
16
|
declare const MEMBERS: {
|
|
12
|
-
readonly rooms:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
readonly
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
readonly
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
readonly
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
readonly '
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
readonly '
|
|
41
|
-
|
|
17
|
+
readonly rooms: {
|
|
18
|
+
readonly reach: 'within';
|
|
19
|
+
readonly effect: 'read';
|
|
20
|
+
};
|
|
21
|
+
readonly query: {
|
|
22
|
+
readonly reach: 'within';
|
|
23
|
+
readonly effect: 'read';
|
|
24
|
+
};
|
|
25
|
+
readonly search: {
|
|
26
|
+
readonly reach: 'within';
|
|
27
|
+
readonly effect: 'read';
|
|
28
|
+
};
|
|
29
|
+
readonly types: {
|
|
30
|
+
readonly reach: 'within';
|
|
31
|
+
readonly effect: 'read';
|
|
32
|
+
};
|
|
33
|
+
readonly save: {
|
|
34
|
+
readonly reach: 'within';
|
|
35
|
+
readonly effect: 'write';
|
|
36
|
+
};
|
|
37
|
+
readonly history: {
|
|
38
|
+
readonly reach: 'within';
|
|
39
|
+
readonly effect: 'read';
|
|
40
|
+
};
|
|
41
|
+
readonly 'binaryFile.read': {
|
|
42
|
+
readonly reach: 'within';
|
|
43
|
+
readonly effect: 'read';
|
|
44
|
+
};
|
|
45
|
+
readonly 'binaryFile.readReference': {
|
|
46
|
+
readonly reach: 'within';
|
|
47
|
+
readonly effect: 'read';
|
|
48
|
+
};
|
|
49
|
+
readonly call: {
|
|
50
|
+
readonly reach: 'actions';
|
|
51
|
+
readonly effect: 'action';
|
|
52
|
+
};
|
|
53
|
+
readonly reached: {
|
|
54
|
+
readonly reach: 'within';
|
|
55
|
+
readonly effect: 'read';
|
|
56
|
+
};
|
|
57
|
+
readonly log: {
|
|
58
|
+
readonly reach: 'whole';
|
|
59
|
+
readonly effect: 'read';
|
|
60
|
+
};
|
|
61
|
+
readonly persistence: {
|
|
62
|
+
readonly reach: 'runtime';
|
|
63
|
+
readonly effect: 'read';
|
|
64
|
+
};
|
|
65
|
+
readonly retry: {
|
|
66
|
+
readonly reach: 'runtime';
|
|
67
|
+
readonly effect: 'write';
|
|
68
|
+
};
|
|
69
|
+
readonly reauthorize: {
|
|
70
|
+
readonly reach: 'runtime';
|
|
71
|
+
readonly effect: 'write';
|
|
72
|
+
};
|
|
73
|
+
readonly 'roomDraft.list': {
|
|
74
|
+
readonly reach: 'within';
|
|
75
|
+
readonly effect: 'read';
|
|
76
|
+
};
|
|
77
|
+
readonly 'roomDraft.read': {
|
|
78
|
+
readonly reach: 'within';
|
|
79
|
+
readonly effect: 'read';
|
|
80
|
+
};
|
|
81
|
+
readonly 'roomDraft.write': {
|
|
82
|
+
readonly reach: 'within';
|
|
83
|
+
readonly effect: 'write';
|
|
84
|
+
};
|
|
85
|
+
readonly 'roomDraft.discard': {
|
|
86
|
+
readonly reach: 'within';
|
|
87
|
+
readonly effect: 'write';
|
|
88
|
+
};
|
|
89
|
+
readonly 'presentation.read': {
|
|
90
|
+
readonly reach: 'app';
|
|
91
|
+
readonly effect: 'read';
|
|
92
|
+
};
|
|
93
|
+
readonly 'presentation.write': {
|
|
94
|
+
readonly reach: 'app';
|
|
95
|
+
readonly effect: 'write';
|
|
96
|
+
};
|
|
97
|
+
readonly 'conversation.list': {
|
|
98
|
+
readonly reach: 'within';
|
|
99
|
+
readonly effect: 'read';
|
|
100
|
+
};
|
|
101
|
+
readonly 'conversation.read': {
|
|
102
|
+
readonly reach: 'within';
|
|
103
|
+
readonly effect: 'read';
|
|
104
|
+
};
|
|
105
|
+
readonly 'conversation.create': {
|
|
106
|
+
readonly reach: 'within';
|
|
107
|
+
readonly effect: 'action';
|
|
108
|
+
};
|
|
109
|
+
readonly 'conversation.send': {
|
|
110
|
+
readonly reach: 'within';
|
|
111
|
+
readonly effect: 'action';
|
|
112
|
+
};
|
|
113
|
+
readonly 'conversation.answer': {
|
|
114
|
+
readonly reach: 'within';
|
|
115
|
+
readonly effect: 'action';
|
|
116
|
+
};
|
|
117
|
+
readonly 'conversation.interrupt': {
|
|
118
|
+
readonly reach: 'within';
|
|
119
|
+
readonly effect: 'action';
|
|
120
|
+
};
|
|
121
|
+
readonly 'conversation.kill': {
|
|
122
|
+
readonly reach: 'within';
|
|
123
|
+
readonly effect: 'action';
|
|
124
|
+
};
|
|
125
|
+
readonly 'conversation.cancel': {
|
|
126
|
+
readonly reach: 'within';
|
|
127
|
+
readonly effect: 'action';
|
|
128
|
+
};
|
|
129
|
+
readonly 'conversation.delete': {
|
|
130
|
+
readonly reach: 'within';
|
|
131
|
+
readonly effect: 'action';
|
|
132
|
+
};
|
|
133
|
+
readonly 'chatDraft.write': {
|
|
134
|
+
readonly reach: 'within';
|
|
135
|
+
readonly effect: 'write';
|
|
136
|
+
};
|
|
137
|
+
readonly 'chatDraft.discard': {
|
|
138
|
+
readonly reach: 'within';
|
|
139
|
+
readonly effect: 'write';
|
|
140
|
+
};
|
|
42
141
|
};
|
|
43
142
|
declare const TOPICS: {
|
|
44
143
|
readonly rooms: 'within';
|
|
144
|
+
readonly readiness: 'within';
|
|
45
145
|
readonly 'connection-refusal': 'runtime';
|
|
46
146
|
readonly 'storage-loss': 'runtime';
|
|
47
147
|
readonly 'deployment-facts': 'runtime';
|
|
@@ -56,8 +156,8 @@ declare const TOPICS: {
|
|
|
56
156
|
readonly conversations: 'within';
|
|
57
157
|
readonly agents: 'within';
|
|
58
158
|
};
|
|
59
|
-
export declare const
|
|
60
|
-
readonly members: Readonly<Record<string,
|
|
159
|
+
export declare const WIRE: {
|
|
160
|
+
readonly members: Readonly<Record<string, WireCall>>;
|
|
61
161
|
readonly topics: Readonly<Record<string, WireReach>>;
|
|
62
162
|
};
|
|
63
163
|
export type WireMember = keyof typeof MEMBERS;
|
|
@@ -95,6 +195,10 @@ export type WireAnswer = {
|
|
|
95
195
|
} | {
|
|
96
196
|
kind: 'ended';
|
|
97
197
|
};
|
|
198
|
+
export declare function unanswered(call: {
|
|
199
|
+
readonly id: number;
|
|
200
|
+
readonly member: WireMember;
|
|
201
|
+
}): WireAnswer | null;
|
|
98
202
|
export declare const AUTHORIZATION_ENDED = "the host authorization ended";
|
|
99
203
|
export declare const PORT_CLOSED = "the port closed";
|
|
100
204
|
export declare function request(message: unknown): WireRequest | null;
|
package/dist/wire.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE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