@agentshouse/mdruntime 0.1.0-c5d3fa6fb67bc → 0.1.0-c6636685d0c4b
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 +205 -205
- package/README.md +8 -8
- package/dist/adapter.d.ts +36 -9
- 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 +1 -1
- package/dist/change-set.d.ts +5 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -1
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/kit.js +1 -1
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +45 -5
- package/dist/chat/markdown.d.ts +1 -0
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +78 -20
- package/dist/chat/message.d.ts +1 -0
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +12 -2
- package/dist/chat/messages.d.ts +2 -0
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +52 -20
- package/dist/chat/overlay.d.ts +1 -0
- package/dist/chat/overlay.d.ts.map +1 -1
- package/dist/chat/overlay.js +10 -0
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/provider.d.ts +1 -0
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +23 -14
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/ready.d.ts +1 -1
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +1 -1
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.js +1 -1
- package/dist/chat.d.ts +2 -2
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/client.d.ts +6 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -5
- package/dist/collection.d.ts +4 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +128 -63
- package/dist/connection.d.ts +12 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +577 -217
- package/dist/conversation.d.ts +12 -0
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +196 -41
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +2 -1
- package/dist/host.d.ts +5 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +45 -5
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/memory.d.ts +6 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +17 -11
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +9 -3
- package/dist/outcome.d.ts +14 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +7 -0
- package/dist/overlay.d.ts +4 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +181 -140
- package/dist/query.d.ts +26 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +34 -6
- package/dist/reach.d.ts +4 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +90 -21
- package/dist/react.d.ts +3 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/read-side.d.ts +3 -1
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +271 -82
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +35 -16
- package/dist/replica.d.ts +11 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +69 -40
- package/dist/room-draft.d.ts +12 -0
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +11 -12
- package/dist/rows.d.ts +1 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +5 -0
- package/dist/save.d.ts +4 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +195 -111
- package/dist/search.d.ts +17 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +81 -7
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +4 -0
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +63 -33
- package/dist/store.d.ts +18 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +398 -316
- package/dist/turn.d.ts +5 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +26 -7
- package/dist/windows.d.ts +26 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +93 -0
- package/dist/wire.d.ts +16 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +4 -0
- package/package.json +2 -2
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
package/dist/reads.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function declaredAs(declaration) {
|
|
2
|
+
if (declaration === null || typeof declaration !== 'object')
|
|
3
|
+
return declaration;
|
|
4
|
+
const { roomVersion: _version, ...declared } = declaration;
|
|
5
|
+
return declared;
|
|
6
|
+
}
|
|
7
|
+
function sameHeld(one, other) {
|
|
8
|
+
return one?.documents === other?.documents && one?.revisions === other?.revisions;
|
|
9
|
+
}
|
|
10
|
+
function failed(answer) {
|
|
11
|
+
return answer?.kind === 'transport-uncertainty';
|
|
12
|
+
}
|
|
13
|
+
function continues(answer) {
|
|
14
|
+
const page = answer;
|
|
15
|
+
return page?.kind === 'net-advancement' && page.pageToken !== undefined;
|
|
16
|
+
}
|
|
17
|
+
export function doorReads(adapter, declaration, generation) {
|
|
18
|
+
const reading = new Map();
|
|
19
|
+
const taken = new Map();
|
|
20
|
+
let carrying = false;
|
|
21
|
+
function joined(read, authorization, request, ask) {
|
|
22
|
+
const key = `${read} ${request.locator} ${request.pageToken ?? ''}`;
|
|
23
|
+
const { held, ...named } = request;
|
|
24
|
+
const asked = JSON.stringify([declaredAs(declaration(request.locator)), named]);
|
|
25
|
+
const asking = generation();
|
|
26
|
+
const current = reading.get(key);
|
|
27
|
+
if (current !== undefined &&
|
|
28
|
+
current.authorization === authorization &&
|
|
29
|
+
current.asked === asked &&
|
|
30
|
+
sameHeld(current.held, held) &&
|
|
31
|
+
(!current.settled || current.holder < asking)) {
|
|
32
|
+
if (current.settled && !current.continued)
|
|
33
|
+
reading.delete(key);
|
|
34
|
+
else
|
|
35
|
+
current.holder = Math.max(current.holder, asking);
|
|
36
|
+
if (current.from === asking)
|
|
37
|
+
return current.answer;
|
|
38
|
+
const again = () => joined(read, authorization, request, ask);
|
|
39
|
+
return current.answer.then((answer) => {
|
|
40
|
+
if (failed(answer))
|
|
41
|
+
return again();
|
|
42
|
+
taken.set(request.locator, (taken.get(request.locator) ?? 0) + 1);
|
|
43
|
+
return answer;
|
|
44
|
+
}, again);
|
|
45
|
+
}
|
|
46
|
+
const answer = ask();
|
|
47
|
+
const sent = {
|
|
48
|
+
locator: request.locator,
|
|
49
|
+
authorization,
|
|
50
|
+
asked,
|
|
51
|
+
held,
|
|
52
|
+
answer,
|
|
53
|
+
from: asking,
|
|
54
|
+
holder: asking,
|
|
55
|
+
settled: false,
|
|
56
|
+
continued: false,
|
|
57
|
+
};
|
|
58
|
+
reading.set(key, sent);
|
|
59
|
+
const settled = (result, kept) => {
|
|
60
|
+
sent.settled = true;
|
|
61
|
+
sent.continued = kept && read === 'refresh' && continues(result);
|
|
62
|
+
if (reading.get(key) !== sent)
|
|
63
|
+
return;
|
|
64
|
+
const live = sent.holder === generation();
|
|
65
|
+
if (!kept || (live ? !sent.continued : !carrying))
|
|
66
|
+
reading.delete(key);
|
|
67
|
+
};
|
|
68
|
+
answer.then((result) => settled(result, !failed(result)), () => settled(null, false));
|
|
69
|
+
return answer;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
bootstrap: (authorization, request) => joined('bootstrap', authorization, request, () => adapter.bootstrap(authorization, request)),
|
|
73
|
+
refresh: (authorization, request) => joined('refresh', authorization, request, () => adapter.refresh(authorization, request)),
|
|
74
|
+
reached: (locator, roomVersion, target) => adapter.reached(locator, roomVersion, target),
|
|
75
|
+
carried: (locator) => taken.get(locator) ?? 0,
|
|
76
|
+
finished(locator, turn) {
|
|
77
|
+
for (const [key, held] of reading) {
|
|
78
|
+
if (held.locator !== locator || !held.settled || held.holder !== turn)
|
|
79
|
+
continue;
|
|
80
|
+
if (turn === generation() || !carrying)
|
|
81
|
+
reading.delete(key);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
opened() {
|
|
85
|
+
carrying = true;
|
|
86
|
+
},
|
|
87
|
+
applied() {
|
|
88
|
+
carrying = false;
|
|
89
|
+
for (const [key, held] of reading) {
|
|
90
|
+
if (held.settled && held.holder !== generation())
|
|
91
|
+
reading.delete(key);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
lost() {
|
|
95
|
+
reading.clear();
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
package/dist/refresh.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Remodel } from './bootstrap.js';
|
|
1
|
+
import type { AdapterFailure, Authorization, RetryableRefusal } from './adapter.js';
|
|
2
|
+
import type { Reads, Remodel } from './bootstrap.js';
|
|
3
3
|
import { type ConfirmedLayer } from './replica.js';
|
|
4
4
|
import type { ReplicaRecord } from './store.js';
|
|
5
5
|
import { type Refused, type Unconfirmed } from './transfer.js';
|
|
@@ -19,6 +19,6 @@ export type RefreshOutcome = {
|
|
|
19
19
|
} | {
|
|
20
20
|
kind: 'beyond-horizon';
|
|
21
21
|
} | RetryableRefusal | Unconfirmed | Refused | AdapterFailure;
|
|
22
|
-
export declare function advancement(adapter:
|
|
23
|
-
export declare function refreshRoom(adapter:
|
|
22
|
+
export declare function advancement(adapter: Reads, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean): Promise<Advancement>;
|
|
23
|
+
export declare function refreshRoom(adapter: Reads, authorization: Authorization, confirmed: ConfirmedLayer, remodel: Remodel, continuing: () => boolean): Promise<RefreshOutcome>;
|
|
24
24
|
//# sourceMappingURL=refresh.d.ts.map
|
package/dist/refresh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAe,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,cAAc,CAAC;AAEnB,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,cAAc,CAAC;AAEnB,wBAAsB,WAAW,CAC/B,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,WAAW,CAAC,CAgGtB;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,cAAc,CAAC,CAKzB"}
|
package/dist/refresh.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { acceptedBinaries } from './overlay.js';
|
|
2
2
|
import { readStaged } from './replica.js';
|
|
3
|
-
import { drafted,
|
|
3
|
+
import { drafted, settling } from './shared.js';
|
|
4
|
+
import { ROW_WEIGHT, stepped } from './turn.js';
|
|
4
5
|
import { unconfirmed } from './transfer.js';
|
|
5
6
|
export async function advancement(adapter, authorization, held, remodel, continuing) {
|
|
6
7
|
const locator = held.locator;
|
|
@@ -23,24 +24,41 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
23
24
|
const changes = drafted(held.changes);
|
|
24
25
|
const written = drafted(held.written);
|
|
25
26
|
const binaries = drafted(held.binaries);
|
|
26
|
-
const stage = (page)
|
|
27
|
+
const stage = function* (page) {
|
|
27
28
|
for (const path of Object.keys(page.documents)) {
|
|
28
29
|
delete binaries[path];
|
|
29
30
|
delete fileIds[path];
|
|
30
31
|
delete changes[path];
|
|
31
32
|
written[path] = roomVersion;
|
|
33
|
+
yield ROW_WEIGHT;
|
|
32
34
|
}
|
|
33
35
|
for (const path of Object.keys(page.binaryFiles)) {
|
|
34
36
|
delete documents[path];
|
|
35
37
|
delete fileIds[path];
|
|
36
38
|
delete changes[path];
|
|
37
39
|
delete written[path];
|
|
40
|
+
yield ROW_WEIGHT;
|
|
41
|
+
}
|
|
42
|
+
for (const [path, content] of Object.entries(page.documents)) {
|
|
43
|
+
documents[path] = content;
|
|
44
|
+
yield ROW_WEIGHT + content.length;
|
|
45
|
+
}
|
|
46
|
+
for (const [path, binary] of Object.entries(acceptedBinaries(page.binaryFiles))) {
|
|
47
|
+
binaries[path] = binary;
|
|
48
|
+
yield ROW_WEIGHT;
|
|
49
|
+
}
|
|
50
|
+
for (const [path, revision] of Object.entries(page.revisions)) {
|
|
51
|
+
revisions[path] = revision;
|
|
52
|
+
yield ROW_WEIGHT;
|
|
53
|
+
}
|
|
54
|
+
for (const [path, fileId] of Object.entries(page.fileIds ?? {})) {
|
|
55
|
+
fileIds[path] = fileId;
|
|
56
|
+
yield ROW_WEIGHT;
|
|
57
|
+
}
|
|
58
|
+
for (const [path, change] of Object.entries(page.changes)) {
|
|
59
|
+
changes[path] = change;
|
|
60
|
+
yield ROW_WEIGHT;
|
|
38
61
|
}
|
|
39
|
-
Object.assign(documents, page.documents);
|
|
40
|
-
Object.assign(binaries, acceptedBinaries(page.binaryFiles));
|
|
41
|
-
Object.assign(revisions, page.revisions);
|
|
42
|
-
Object.assign(fileIds, page.fileIds);
|
|
43
|
-
Object.assign(changes, page.changes);
|
|
44
62
|
for (const path of page.removals) {
|
|
45
63
|
delete documents[path];
|
|
46
64
|
delete revisions[path];
|
|
@@ -48,9 +66,10 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
48
66
|
delete changes[path];
|
|
49
67
|
delete written[path];
|
|
50
68
|
delete binaries[path];
|
|
69
|
+
yield ROW_WEIGHT;
|
|
51
70
|
}
|
|
52
71
|
};
|
|
53
|
-
stage(first);
|
|
72
|
+
await stepped(stage(first));
|
|
54
73
|
let pageToken = first.pageToken;
|
|
55
74
|
while (pageToken !== undefined) {
|
|
56
75
|
if (!continuing())
|
|
@@ -67,7 +86,7 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
67
86
|
return page;
|
|
68
87
|
if (page.roomVersion !== roomVersion)
|
|
69
88
|
return unconfirmed;
|
|
70
|
-
stage(page);
|
|
89
|
+
await stepped(stage(page));
|
|
71
90
|
pageToken = page.pageToken;
|
|
72
91
|
}
|
|
73
92
|
return {
|
|
@@ -77,12 +96,12 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
77
96
|
model: models.collection,
|
|
78
97
|
selectionModel: models.selection,
|
|
79
98
|
roomVersion,
|
|
80
|
-
documents:
|
|
81
|
-
binaries:
|
|
82
|
-
revisions:
|
|
83
|
-
fileIds:
|
|
84
|
-
changes:
|
|
85
|
-
written:
|
|
99
|
+
documents: await stepped(settling(documents)),
|
|
100
|
+
binaries: await stepped(settling(binaries)),
|
|
101
|
+
revisions: await stepped(settling(revisions)),
|
|
102
|
+
fileIds: await stepped(settling(fileIds)),
|
|
103
|
+
changes: await stepped(settling(changes)),
|
|
104
|
+
written: await stepped(settling(written)),
|
|
86
105
|
},
|
|
87
106
|
};
|
|
88
107
|
}
|
|
@@ -90,6 +109,6 @@ export async function refreshRoom(adapter, authorization, confirmed, remodel, co
|
|
|
90
109
|
const advanced = await advancement(adapter, authorization, confirmed.record, remodel, continuing);
|
|
91
110
|
if (advanced.kind !== 'advanced')
|
|
92
111
|
return advanced;
|
|
93
|
-
const staged = readStaged(advanced.record, confirmed);
|
|
112
|
+
const staged = await readStaged(advanced.record, confirmed);
|
|
94
113
|
return staged.kind === 'staged' ? { kind: 'advanced', confirmed: staged.confirmed } : staged;
|
|
95
114
|
}
|
package/dist/replica.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type Layer } from './overlay.js';
|
|
|
4
4
|
import type { MutationResult } from './adapter.js';
|
|
5
5
|
import type { ReplicaRecord } from './store.js';
|
|
6
6
|
import type { Refused } from './transfer.js';
|
|
7
|
+
import { type Later } from './turn.js';
|
|
7
8
|
export type ConfirmedLayer = {
|
|
8
9
|
record: ReplicaRecord;
|
|
9
10
|
collection: Collection;
|
|
@@ -31,16 +32,21 @@ type ReplayStep = {
|
|
|
31
32
|
export declare function compositionOf(record: ReplicaRecord): Composition;
|
|
32
33
|
export declare function confirmedOf(record: ReplicaRecord, previous?: ConfirmedLayer): ConfirmedLayer;
|
|
33
34
|
export declare function sameMembership(record: ReplicaRecord, other: ReplicaRecord): boolean;
|
|
34
|
-
export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Staged
|
|
35
|
-
export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
|
|
35
|
+
export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Later<Staged>;
|
|
36
|
+
export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Later<Staged | {
|
|
36
37
|
kind: 'deferred';
|
|
37
|
-
}
|
|
38
|
+
}>;
|
|
38
39
|
type Accepted = Extract<MutationResult, {
|
|
39
40
|
kind: 'accepted';
|
|
40
41
|
}>;
|
|
41
|
-
export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Staged
|
|
42
|
+
export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Later<Staged>;
|
|
43
|
+
export declare function replicating(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Generator<number, Replica, void>;
|
|
42
44
|
export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Replica;
|
|
43
45
|
export declare function landed(batch: ChangeBatch, confirmed: ConfirmedLayer, current?: Readonly<Record<string, string>>): boolean;
|
|
44
|
-
export
|
|
46
|
+
export type Standing = {
|
|
47
|
+
readonly withdrawn: readonly ChangeBatch[];
|
|
48
|
+
readonly kept: readonly ChangeBatch[];
|
|
49
|
+
};
|
|
50
|
+
export declare function standing(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): Generator<number, Standing, void>;
|
|
45
51
|
export {};
|
|
46
52
|
//# sourceMappingURL=replica.d.ts.map
|
package/dist/replica.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnG,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnG,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,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AAE,CAAC,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,SAAS,EAAE,cAAc,EACzB,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,KAAK,CAAC,MAAM,CAAC,CAoCf;AAgDD,wBAAiB,WAAW,CAC1B,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,QAAQ,CAAC,EAAE,OAAO,GACjB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CA+BlC;AAED,wBAAgB,SAAS,CACvB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAET;AA0ED,wBAAgB,MAAM,CACpB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC7C,OAAO,CAoBT;AAgBD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;CACvC,CAAC;AAEF,wBAAiB,QAAQ,CACvB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,EAC7C,KAAK,EAAE,OAAO,GACb,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA6BnC"}
|
package/dist/replica.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { equalValue, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { immutable, landing } from './change.js';
|
|
3
|
-
import { changedCleanly,
|
|
4
|
-
import { acceptedBinaries,
|
|
3
|
+
import { changedCleanly, collecting, unreadable, validateCollection, } from './collection.js';
|
|
4
|
+
import { acceptedBinaries, overlayChanged, overlaying, sameText, } from './overlay.js';
|
|
5
5
|
import { providerRewritten } from './save.js';
|
|
6
|
-
import { drafted, patched, settled,
|
|
6
|
+
import { drafted, patched, settled, sharing } from './shared.js';
|
|
7
|
+
import { finished, stepped } from './turn.js';
|
|
7
8
|
export function compositionOf(record) {
|
|
8
9
|
return {
|
|
9
10
|
model: record.model,
|
|
@@ -12,13 +13,13 @@ export function compositionOf(record) {
|
|
|
12
13
|
: { roots: record.typedSelection.roots, model: record.selectionModel },
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
const documents =
|
|
17
|
-
const binaries =
|
|
18
|
-
const revisions =
|
|
19
|
-
const fileIds =
|
|
20
|
-
const changes =
|
|
21
|
-
const written =
|
|
16
|
+
function* holding(record) {
|
|
17
|
+
const documents = yield* sharing(record.documents);
|
|
18
|
+
const binaries = yield* sharing(record.binaries);
|
|
19
|
+
const revisions = yield* sharing(record.revisions);
|
|
20
|
+
const fileIds = yield* sharing(record.fileIds);
|
|
21
|
+
const changes = yield* sharing(record.changes);
|
|
22
|
+
const written = yield* sharing(record.written);
|
|
22
23
|
return documents === record.documents &&
|
|
23
24
|
binaries === record.binaries &&
|
|
24
25
|
revisions === record.revisions &&
|
|
@@ -29,56 +30,65 @@ function held(record) {
|
|
|
29
30
|
: { ...record, documents, binaries, revisions, fileIds, changes, written };
|
|
30
31
|
}
|
|
31
32
|
export function confirmedOf(record, previous) {
|
|
32
|
-
|
|
33
|
+
return finished(confirming(record, previous));
|
|
34
|
+
}
|
|
35
|
+
function* confirming(record, previous) {
|
|
36
|
+
const kept = yield* holding(record);
|
|
33
37
|
return {
|
|
34
38
|
record: kept,
|
|
35
|
-
collection:
|
|
39
|
+
collection: yield* collecting(kept.documents, compositionOf(kept), previous?.collection),
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
export function sameMembership(record, other) {
|
|
39
43
|
return (JSON.stringify(record.typedSelection?.roots ?? null) ===
|
|
40
44
|
JSON.stringify(other.typedSelection?.roots ?? null));
|
|
41
45
|
}
|
|
42
|
-
function cleanly(record, previous) {
|
|
46
|
+
function* cleanly(record, previous) {
|
|
43
47
|
if (previous === undefined)
|
|
44
48
|
return false;
|
|
45
49
|
const before = previous.record;
|
|
46
|
-
return changedCleanly({ text: record.documents, binaries: record.binaries }, { text: before.documents, binaries: before.binaries, composition: compositionOf(before) }, compositionOf(record));
|
|
50
|
+
return yield* changedCleanly({ text: record.documents, binaries: record.binaries }, { text: before.documents, binaries: before.binaries, composition: compositionOf(before) }, compositionOf(record));
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
const record =
|
|
50
|
-
const textChanged = previous === undefined || !
|
|
52
|
+
function* staging(staged, previous) {
|
|
53
|
+
const record = yield* holding(staged);
|
|
54
|
+
const textChanged = previous === undefined || !(yield* sameText(record, previous.record));
|
|
51
55
|
const modeled = record.model.status !== 'unavailable' || record.selectionModel.status !== 'unavailable';
|
|
52
56
|
if (modeled &&
|
|
53
57
|
(textChanged ||
|
|
54
58
|
record.model !== previous?.record.model ||
|
|
55
59
|
record.selectionModel !== previous?.record.selectionModel) &&
|
|
56
|
-
!cleanly(record, previous)) {
|
|
57
|
-
const verdict = validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
60
|
+
!(yield* cleanly(record, previous))) {
|
|
61
|
+
const verdict = yield* validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
58
62
|
if (verdict.verdict === 'refuse' && verdict.rule !== 'model-unavailable') {
|
|
59
63
|
return { kind: 'refused', refusal: verdict };
|
|
60
64
|
}
|
|
61
65
|
if (verdict.verdict === 'refuse') {
|
|
62
|
-
const refused = unreadable(record.documents, previous?.record.documents);
|
|
66
|
+
const refused = yield* unreadable(record.documents, previous?.record.documents);
|
|
63
67
|
if (refused !== null)
|
|
64
68
|
return refused;
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
else if (textChanged) {
|
|
68
|
-
const refused = unreadable(record.documents, previous?.record.documents);
|
|
72
|
+
const refused = yield* unreadable(record.documents, previous?.record.documents);
|
|
69
73
|
if (refused !== null)
|
|
70
74
|
return refused;
|
|
71
75
|
}
|
|
72
|
-
return { kind: 'staged', confirmed:
|
|
76
|
+
return { kind: 'staged', confirmed: yield* confirming(record, previous) };
|
|
73
77
|
}
|
|
74
|
-
export function
|
|
75
|
-
|
|
78
|
+
export function readStaged(staged, previous) {
|
|
79
|
+
return stepped(staging(staged, previous));
|
|
80
|
+
}
|
|
81
|
+
function* reclassifying(record, previous) {
|
|
82
|
+
const verdict = yield* validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
76
83
|
if (verdict.verdict !== 'refuse')
|
|
77
|
-
return { kind: 'staged', confirmed:
|
|
84
|
+
return { kind: 'staged', confirmed: yield* confirming(record, previous) };
|
|
78
85
|
return verdict.rule === 'model-unavailable'
|
|
79
86
|
? { kind: 'deferred' }
|
|
80
87
|
: { kind: 'refused', refusal: verdict };
|
|
81
88
|
}
|
|
89
|
+
export function readReclassified(record, previous) {
|
|
90
|
+
return stepped(reclassifying(record, previous));
|
|
91
|
+
}
|
|
82
92
|
function returnedBinaries(held, submitted, accepted) {
|
|
83
93
|
const binaries = drafted(held);
|
|
84
94
|
for (const change of submitted.changes) {
|
|
@@ -132,7 +142,7 @@ export function applyReturned(confirmed, submitted, accepted, roomVersion, writt
|
|
|
132
142
|
binaries: returnedBinaries(confirmed.record.binaries, submitted, accepted),
|
|
133
143
|
}, confirmed);
|
|
134
144
|
}
|
|
135
|
-
function
|
|
145
|
+
function* predicting(confirmed, batches, previous) {
|
|
136
146
|
const composition = compositionOf(confirmed.record);
|
|
137
147
|
let layer = confirmed.record;
|
|
138
148
|
const replay = [];
|
|
@@ -142,7 +152,7 @@ function predicted(confirmed, batches, previous) {
|
|
|
142
152
|
const old = prior.get(batch.id);
|
|
143
153
|
const hasMove = batch.changes.some((change) => change.kind === 'move');
|
|
144
154
|
const reuseRewrite = old?.collection !== undefined &&
|
|
145
|
-
|
|
155
|
+
(yield* sameText(before, old.before)) &&
|
|
146
156
|
old.collection.composition.model === composition.model &&
|
|
147
157
|
old.collection.composition.selection?.model === composition.selection?.model &&
|
|
148
158
|
JSON.stringify(old.collection.composition.selection?.roots) ===
|
|
@@ -150,17 +160,17 @@ function predicted(confirmed, batches, previous) {
|
|
|
150
160
|
const collection = hasMove
|
|
151
161
|
? reuseRewrite
|
|
152
162
|
? old.collection
|
|
153
|
-
:
|
|
163
|
+
: yield* collecting(before.documents, composition, old?.collection ?? confirmed.collection)
|
|
154
164
|
: undefined;
|
|
155
165
|
const effective = collection === undefined
|
|
156
166
|
? batch
|
|
157
167
|
: reuseRewrite
|
|
158
168
|
? old.effective
|
|
159
|
-
: providerRewritten(batch, { ...before, collection });
|
|
169
|
+
: yield* providerRewritten(batch, { ...before, collection });
|
|
160
170
|
layer =
|
|
161
171
|
old === undefined
|
|
162
|
-
?
|
|
163
|
-
: overlayChanged(before,
|
|
172
|
+
? yield* overlaying(before, [effective])
|
|
173
|
+
: yield* overlayChanged(before, effective, old.before, old.effective, old.after);
|
|
164
174
|
replay.push({
|
|
165
175
|
id: batch.id,
|
|
166
176
|
before,
|
|
@@ -171,7 +181,7 @@ function predicted(confirmed, batches, previous) {
|
|
|
171
181
|
}
|
|
172
182
|
return { layer, replay };
|
|
173
183
|
}
|
|
174
|
-
export function
|
|
184
|
+
export function* replicating(confirmed, queue, previous) {
|
|
175
185
|
const batches = Object.freeze(queue.map(immutable));
|
|
176
186
|
if (batches.length === 0) {
|
|
177
187
|
return {
|
|
@@ -188,17 +198,20 @@ export function replicaOf(confirmed, queue, previous) {
|
|
|
188
198
|
replay: [],
|
|
189
199
|
};
|
|
190
200
|
}
|
|
191
|
-
const { layer, replay } =
|
|
201
|
+
const { layer, replay } = yield* predicting(confirmed, batches, previous);
|
|
192
202
|
return {
|
|
193
203
|
confirmed,
|
|
194
204
|
queue: batches,
|
|
195
205
|
replay,
|
|
196
206
|
visible: {
|
|
197
207
|
...layer,
|
|
198
|
-
collection:
|
|
208
|
+
collection: yield* collecting(layer.documents, compositionOf(confirmed.record), previous?.visible.collection ?? confirmed.collection),
|
|
199
209
|
},
|
|
200
210
|
};
|
|
201
211
|
}
|
|
212
|
+
export function replicaOf(confirmed, queue, previous) {
|
|
213
|
+
return finished(replicating(confirmed, queue, previous));
|
|
214
|
+
}
|
|
202
215
|
function present(layer, path) {
|
|
203
216
|
return layer.documents[path] !== undefined || layer.binaries[path] !== undefined;
|
|
204
217
|
}
|
|
@@ -293,32 +306,48 @@ export function landed(batch, confirmed, current = {}) {
|
|
|
293
306
|
});
|
|
294
307
|
});
|
|
295
308
|
}
|
|
296
|
-
|
|
309
|
+
function founded(batch, layer) {
|
|
310
|
+
let changed = false;
|
|
311
|
+
const preconditions = batch.preconditions.map((precondition) => {
|
|
312
|
+
if (precondition.kind !== 'content')
|
|
313
|
+
return precondition;
|
|
314
|
+
const revision = layer.revisions[precondition.path];
|
|
315
|
+
if (revision === undefined || layer.documents[precondition.path] !== precondition.content) {
|
|
316
|
+
return precondition;
|
|
317
|
+
}
|
|
318
|
+
changed = true;
|
|
319
|
+
return { kind: 'revision', path: precondition.path, revision };
|
|
320
|
+
});
|
|
321
|
+
return changed ? immutable({ ...batch, preconditions }) : batch;
|
|
322
|
+
}
|
|
323
|
+
export function* standing(confirmed, queue, withdrawable, local) {
|
|
297
324
|
if (!queue.some(withdrawable))
|
|
298
|
-
return [];
|
|
325
|
+
return { withdrawn: [], kept: queue };
|
|
299
326
|
const composition = compositionOf(confirmed.record);
|
|
300
327
|
let layer = confirmed.record;
|
|
301
328
|
const withdrawn = [];
|
|
329
|
+
const kept = [];
|
|
302
330
|
for (const batch of queue) {
|
|
303
331
|
if (withdrawable(batch) && !holds(layer, batch.preconditions)) {
|
|
304
332
|
withdrawn.push(batch);
|
|
305
333
|
continue;
|
|
306
334
|
}
|
|
307
335
|
const effective = batch.changes.some((change) => change.kind === 'move')
|
|
308
|
-
? providerRewritten(batch, {
|
|
336
|
+
? yield* providerRewritten(batch, {
|
|
309
337
|
...layer,
|
|
310
|
-
collection:
|
|
338
|
+
collection: yield* collecting(layer.documents, composition),
|
|
311
339
|
})
|
|
312
340
|
: batch;
|
|
313
341
|
let unapplied = false;
|
|
314
|
-
const next =
|
|
342
|
+
const next = yield* overlaying(layer, [effective], () => {
|
|
315
343
|
unapplied = true;
|
|
316
344
|
});
|
|
317
345
|
if (local && unapplied) {
|
|
318
346
|
withdrawn.push(batch);
|
|
319
347
|
continue;
|
|
320
348
|
}
|
|
349
|
+
kept.push(local || !withdrawable(batch) ? batch : founded(batch, layer));
|
|
321
350
|
layer = next;
|
|
322
351
|
}
|
|
323
|
-
return withdrawn;
|
|
352
|
+
return { withdrawn, kept };
|
|
324
353
|
}
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -130,6 +130,18 @@ export declare function underneath(parts: HeldParts, path: string, visible: Visi
|
|
|
130
130
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
131
131
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
132
132
|
export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
|
|
133
|
+
export type TextParts = {
|
|
134
|
+
readonly fields?: Readonly<Record<string, {
|
|
135
|
+
readonly value: unknown;
|
|
136
|
+
}>>;
|
|
137
|
+
readonly sections?: Readonly<Record<string, {
|
|
138
|
+
readonly value: string;
|
|
139
|
+
}>>;
|
|
140
|
+
readonly preamble?: {
|
|
141
|
+
readonly value: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
export declare function partsAfter(markdown: string, parts: TextParts): string;
|
|
133
145
|
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
134
146
|
export declare function moveTarget(move: {
|
|
135
147
|
readonly to: string;
|
package/dist/room-draft.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB;IACE,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,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CACxB,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE,CAAC,CACxE,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAA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@
|
|
|
1
|
-
import { apply, equalValue, frontmatterValue, parse, serialize } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
3
|
import { hexDigest } from './file.js';
|
|
4
4
|
import { binaryLocalId } from './identity.js';
|
|
@@ -279,16 +279,15 @@ function frontmatterOf(fields) {
|
|
|
279
279
|
const opened = parse('---\n---\n');
|
|
280
280
|
if (!opened.ok)
|
|
281
281
|
return malformed();
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
function concatenated(markdown, parts) {
|
|
282
|
+
const next = apply(opened.document, fields.map(([name, part]) => ({
|
|
283
|
+
kind: 'field',
|
|
284
|
+
name,
|
|
285
|
+
value: part.value,
|
|
286
|
+
prior: undefined,
|
|
287
|
+
})));
|
|
288
|
+
return next.outcome === 'applied' ? serialize(next.document) : malformed();
|
|
289
|
+
}
|
|
290
|
+
export function partsAfter(markdown, parts) {
|
|
292
291
|
const fields = named(parts.fields);
|
|
293
292
|
const pieces = [
|
|
294
293
|
...(fields.length === 0 ? [] : [frontmatterOf(fields)]),
|
|
@@ -319,7 +318,7 @@ export function returnedInto(existing, returned) {
|
|
|
319
318
|
delete next.fields;
|
|
320
319
|
delete next.sections;
|
|
321
320
|
delete next.preamble;
|
|
322
|
-
const value =
|
|
321
|
+
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
|
|
323
322
|
next.markdown = { value, base: whole.base };
|
|
324
323
|
}
|
|
325
324
|
const creation = existing.creation ?? returned.creation;
|
package/dist/rows.d.ts
CHANGED
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,K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