@agentshouse/mdruntime 0.1.0-c6e4c19c13638 → 0.1.0-c6f02ec9468d4
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/README.md +23 -10
- package/dist/adapter.d.ts +156 -43
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +53 -6
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +33 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +201 -48
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -56
- package/dist/change.d.ts +45 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- package/dist/client.d.ts +37 -16
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +156 -20
- package/dist/collection.d.ts +12 -14
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +52 -56
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +786 -0
- package/dist/connection.d.ts +61 -20
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3877 -885
- package/dist/conversation.d.ts +48 -19
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +723 -240
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +4 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +370 -0
- package/dist/host.d.ts +13 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +134 -24
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +16 -1
- package/dist/index.d.ts +20 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +18 -7
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +252 -92
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +19 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -2
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +20 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +72 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +81 -1
- package/dist/overlay.d.ts +15 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +136 -180
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +70 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +53 -38
- package/dist/reach.d.ts +18 -4
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +235 -64
- package/dist/react.d.ts +32 -19
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +13 -21
- package/dist/readiness.d.ts +52 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +27 -0
- package/dist/recovery.d.ts +26 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +224 -0
- package/dist/refresh.d.ts +20 -7
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +148 -59
- package/dist/replica.d.ts +58 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +320 -157
- package/dist/room-draft.d.ts +57 -10
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +222 -39
- package/dist/rows.d.ts +39 -35
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +176 -99
- package/dist/save.d.ts +73 -4
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +825 -150
- package/dist/search.d.ts +41 -29
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -105
- 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 +15 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +421 -0
- package/dist/status.d.ts +7 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -9
- package/dist/store.d.ts +110 -59
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +324 -344
- package/dist/stored.d.ts +130 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +560 -0
- package/dist/tables.d.ts +325 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +578 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +101 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +170 -33
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +69 -31
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +156 -0
- package/package.json +26 -15
- package/AGENTS.md +0 -241
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -433
package/dist/outcome.d.ts
CHANGED
|
@@ -1,8 +1,75 @@
|
|
|
1
|
-
import type { ActionResult } from './adapter.js';
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import type { KeptBinary, KeptResult } from './opened.js';
|
|
4
|
+
type Refused<Kind extends string> = ProviderRefusal & {
|
|
5
|
+
kind: Kind;
|
|
5
6
|
};
|
|
7
|
+
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
8
|
+
locator: string;
|
|
9
|
+
}) | (Refused<'room-locked'> & {
|
|
10
|
+
locator: string;
|
|
11
|
+
}) | ScopedRefusal;
|
|
12
|
+
export type CallResult = {
|
|
13
|
+
kind: 'action';
|
|
14
|
+
result: unknown;
|
|
15
|
+
at?: RoomVersionAt;
|
|
16
|
+
} | Refused<'rejected'> | Refused<'undeclared'> | Failure;
|
|
17
|
+
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
18
|
+
kind: Failure['kind'];
|
|
19
|
+
}> | Failure;
|
|
20
|
+
type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
+
export type BinaryAnswer = {
|
|
22
|
+
kind: 'binary';
|
|
23
|
+
stream: ReadableStream<Uint8Array>;
|
|
24
|
+
byteLength: number;
|
|
25
|
+
mediaType: string;
|
|
26
|
+
} | BinaryRefusal;
|
|
27
|
+
export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
|
|
28
|
+
export type BinaryLinkAnswer = {
|
|
29
|
+
kind: 'link';
|
|
30
|
+
url: string;
|
|
31
|
+
name: string;
|
|
32
|
+
mediaType: string;
|
|
33
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
34
|
+
export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
|
|
35
|
+
export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
|
|
36
|
+
export type AttachAnswer = {
|
|
37
|
+
kind: 'attached';
|
|
38
|
+
path: string;
|
|
39
|
+
} | Offline | Refused<'rejected'> | Failure;
|
|
40
|
+
export type DownloadAnswer = {
|
|
41
|
+
kind: 'started';
|
|
42
|
+
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
43
|
+
export type Resolution = {
|
|
44
|
+
readonly kind: 'document';
|
|
45
|
+
readonly room: string;
|
|
46
|
+
readonly path: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'deleted';
|
|
49
|
+
readonly room: string;
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly revision: HistoryRevision;
|
|
52
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
53
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
54
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
55
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
56
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
57
|
+
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
58
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
59
|
+
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
60
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
61
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
62
|
+
locator: string;
|
|
63
|
+
};
|
|
64
|
+
export type Offline = {
|
|
65
|
+
readonly kind: 'offline';
|
|
66
|
+
};
|
|
67
|
+
export declare const OFFLINE: Offline;
|
|
68
|
+
export declare const UNCERTAIN: Failure;
|
|
69
|
+
export declare function undeclared(name: string): CallResult;
|
|
70
|
+
export declare function failure(result: AdapterFailure): Failure;
|
|
71
|
+
export declare function calledResult(result: ActionResult): CallResult;
|
|
72
|
+
export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
|
|
6
73
|
export type Submission = {
|
|
7
74
|
readonly state: 'waiting' | 'submitted';
|
|
8
75
|
} | {
|
|
@@ -12,7 +79,7 @@ export type Submission = {
|
|
|
12
79
|
export type QueueEntry = {
|
|
13
80
|
readonly batch: ChangeBatch;
|
|
14
81
|
} & (Submission | {
|
|
15
|
-
readonly state: '
|
|
16
|
-
readonly roomVersion: string;
|
|
82
|
+
readonly state: 'local';
|
|
17
83
|
});
|
|
84
|
+
export {};
|
|
18
85
|
//# sourceMappingURL=outcome.d.ts.map
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAA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D,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG,CACvD,UAAU,GACV;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC9B,CAAC"}
|
package/dist/outcome.js
CHANGED
|
@@ -1 +1,81 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export const UNREADABLE = {
|
|
2
|
+
kind: 'unreadable',
|
|
3
|
+
code: 'room-not-readable',
|
|
4
|
+
fields: {},
|
|
5
|
+
retryable: false,
|
|
6
|
+
};
|
|
7
|
+
export const LOCKED_UNREADABLE = {
|
|
8
|
+
kind: 'unreadable',
|
|
9
|
+
code: 'room-locked',
|
|
10
|
+
fields: {},
|
|
11
|
+
retryable: true,
|
|
12
|
+
};
|
|
13
|
+
export const ABSENT_TARGET = {
|
|
14
|
+
kind: 'absent',
|
|
15
|
+
code: 'reference-absent',
|
|
16
|
+
fields: {},
|
|
17
|
+
retryable: false,
|
|
18
|
+
};
|
|
19
|
+
export function absentBinary(path) {
|
|
20
|
+
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
21
|
+
}
|
|
22
|
+
export function binaryAnswer(result) {
|
|
23
|
+
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
24
|
+
}
|
|
25
|
+
const OCTET_STREAM = 'application/octet-stream';
|
|
26
|
+
export function binaryLinkAnswer(result, held) {
|
|
27
|
+
if (result.kind === 'link') {
|
|
28
|
+
return {
|
|
29
|
+
kind: 'link',
|
|
30
|
+
url: result.url,
|
|
31
|
+
name: result.name,
|
|
32
|
+
mediaType: result.mediaType ?? held ?? OCTET_STREAM,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
36
|
+
}
|
|
37
|
+
export function attachAnswer(result) {
|
|
38
|
+
if (result.kind === 'attached')
|
|
39
|
+
return { kind: 'attached', path: result.path };
|
|
40
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
41
|
+
}
|
|
42
|
+
export const ROOM_LOCKED = 'room-locked';
|
|
43
|
+
export function lockedRoom(locator) {
|
|
44
|
+
return { kind: ROOM_LOCKED, locator, code: ROOM_LOCKED, fields: {}, retryable: true };
|
|
45
|
+
}
|
|
46
|
+
export const OFFLINE = { kind: 'offline' };
|
|
47
|
+
export const UNCERTAIN = {
|
|
48
|
+
kind: 'transport-uncertainty',
|
|
49
|
+
code: 'transport-uncertainty',
|
|
50
|
+
fields: {},
|
|
51
|
+
retryable: true,
|
|
52
|
+
};
|
|
53
|
+
export function undeclared(name) {
|
|
54
|
+
return { kind: 'undeclared', code: 'action-undeclared', fields: { name }, retryable: false };
|
|
55
|
+
}
|
|
56
|
+
export function failure(result) {
|
|
57
|
+
switch (result.kind) {
|
|
58
|
+
case 'transport-uncertainty':
|
|
59
|
+
return UNCERTAIN;
|
|
60
|
+
case 'revoked-authorization':
|
|
61
|
+
return { kind: result.kind, code: result.kind, fields: {}, retryable: false };
|
|
62
|
+
case 'room-not-readable':
|
|
63
|
+
return {
|
|
64
|
+
kind: result.kind,
|
|
65
|
+
locator: result.locator,
|
|
66
|
+
code: result.kind,
|
|
67
|
+
fields: {},
|
|
68
|
+
retryable: false,
|
|
69
|
+
};
|
|
70
|
+
case 'scoped-refusal':
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function calledResult(result) {
|
|
75
|
+
return result.kind === 'action' || result.kind === 'rejected' ? result : failure(result);
|
|
76
|
+
}
|
|
77
|
+
export function historyAnswer(result) {
|
|
78
|
+
return result.kind === 'history' || result.kind === 'revision' || result.kind === 'no-history'
|
|
79
|
+
? result
|
|
80
|
+
: failure(result);
|
|
81
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import type { HeadChange } from './adapter.js';
|
|
1
|
+
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
|
+
fileIds: Readonly<Record<string, string>>;
|
|
5
6
|
changes: Readonly<Record<string, HeadChange>>;
|
|
6
7
|
};
|
|
8
|
+
export type HeldBinary = ({
|
|
9
|
+
readonly state: 'accepted';
|
|
10
|
+
} & BinaryFile) | {
|
|
11
|
+
readonly state: 'pending';
|
|
12
|
+
readonly localId: string;
|
|
13
|
+
readonly byteLength: number;
|
|
14
|
+
readonly mediaType: string;
|
|
15
|
+
readonly sha256: string;
|
|
16
|
+
};
|
|
7
17
|
export type Layer = Heads & {
|
|
8
18
|
documents: Readonly<Record<string, string>>;
|
|
9
|
-
|
|
19
|
+
binaries: Readonly<Record<string, HeldBinary>>;
|
|
10
20
|
};
|
|
21
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
22
|
+
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
11
23
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
14
|
-
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|
|
24
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
|
|
15
25
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MA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AU,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAQ/F;AAqMD,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAoChC"}
|
package/dist/overlay.js
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import { apply, parse, serialize } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { drafted, entriesIn, settling } from './shared.js';
|
|
3
|
+
import { ROW_WEIGHT } from './turn.js';
|
|
4
|
+
export function* acceptedBinaries(files) {
|
|
5
|
+
for (const [path, file] of entriesIn(files))
|
|
6
|
+
yield [path, { state: 'accepted', ...file }];
|
|
7
|
+
}
|
|
8
|
+
export function sameBinary(left, right) {
|
|
9
|
+
if (left === undefined || right === undefined)
|
|
10
|
+
return left === right;
|
|
11
|
+
return (left.state === right.state &&
|
|
12
|
+
left.byteLength === right.byteLength &&
|
|
13
|
+
left.mediaType === right.mediaType &&
|
|
14
|
+
left.sha256 === right.sha256 &&
|
|
15
|
+
(left.state === 'accepted'
|
|
16
|
+
? right.state === 'accepted'
|
|
17
|
+
: right.state === 'pending' && left.localId === right.localId));
|
|
18
|
+
}
|
|
2
19
|
export function sameChange(left, right) {
|
|
3
20
|
if (left === undefined || right === undefined)
|
|
4
21
|
return left === right;
|
|
@@ -8,10 +25,13 @@ export function sameChange(left, right) {
|
|
|
8
25
|
left.author?.name === right.author?.name);
|
|
9
26
|
}
|
|
10
27
|
const EMPTY_FRONTMATTER = '---\n---\n';
|
|
28
|
+
function isPart(change) {
|
|
29
|
+
return change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble';
|
|
30
|
+
}
|
|
11
31
|
function at(path, name) {
|
|
12
32
|
return `${path} ${name}`;
|
|
13
33
|
}
|
|
14
|
-
function priorsOf(preconditions) {
|
|
34
|
+
function* priorsOf(preconditions) {
|
|
15
35
|
const fields = new Map();
|
|
16
36
|
const sections = new Map();
|
|
17
37
|
const preambles = new Map();
|
|
@@ -25,6 +45,7 @@ function priorsOf(preconditions) {
|
|
|
25
45
|
if (precondition.kind === 'preamble') {
|
|
26
46
|
preambles.set(precondition.path, precondition.value);
|
|
27
47
|
}
|
|
48
|
+
yield ROW_WEIGHT;
|
|
28
49
|
}
|
|
29
50
|
return {
|
|
30
51
|
field: (path, name) => fields.get(at(path, name)),
|
|
@@ -40,49 +61,50 @@ function compose(fields, sections) {
|
|
|
40
61
|
const opened = parse(skeleton);
|
|
41
62
|
if (!opened.ok)
|
|
42
63
|
return skeleton;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const next = apply(document, { kind: 'field', name, value, prior: undefined });
|
|
46
|
-
if (next.outcome === 'applied')
|
|
47
|
-
document = next.document;
|
|
48
|
-
}
|
|
49
|
-
return serialize(document);
|
|
64
|
+
const next = apply(opened.document, Object.entries(fields).flatMap(([name, value]) => frontmatterValue(value) ? [{ kind: 'field', name, value, prior: undefined }] : []));
|
|
65
|
+
return serialize(next.outcome === 'applied' ? next.document : opened.document);
|
|
50
66
|
}
|
|
51
|
-
function edited(
|
|
52
|
-
if (change.kind === 'field')
|
|
53
|
-
return
|
|
67
|
+
function edited(change, priors) {
|
|
68
|
+
if (change.kind === 'field')
|
|
69
|
+
return {
|
|
54
70
|
kind: 'field',
|
|
55
71
|
name: change.name,
|
|
56
72
|
value: change.value,
|
|
57
73
|
prior: priors.field(change.path, change.name),
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
kind: 'preamble',
|
|
63
|
-
value: change.value,
|
|
64
|
-
prior: priors.preamble(change.path),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (change.kind !== 'section')
|
|
68
|
-
return null;
|
|
69
|
-
return apply(document, {
|
|
74
|
+
};
|
|
75
|
+
if (change.kind === 'preamble')
|
|
76
|
+
return { kind: 'preamble', value: change.value, prior: priors.preamble(change.path) };
|
|
77
|
+
return {
|
|
70
78
|
kind: 'section',
|
|
71
79
|
name: change.name,
|
|
72
80
|
value: change.value,
|
|
73
81
|
prior: priors.section(change.path, change.name),
|
|
74
|
-
}
|
|
82
|
+
};
|
|
75
83
|
}
|
|
76
|
-
function edit(staged,
|
|
77
|
-
const
|
|
84
|
+
function edit(staged, changes, priors) {
|
|
85
|
+
const path = changes[0].path;
|
|
86
|
+
delete staged.revisions[path];
|
|
87
|
+
const text = staged.documents[path];
|
|
78
88
|
if (text === undefined)
|
|
79
|
-
return;
|
|
80
|
-
const parsed = parse(text,
|
|
89
|
+
return changes.length;
|
|
90
|
+
const parsed = parse(text, path);
|
|
81
91
|
if (!parsed.ok)
|
|
82
|
-
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
return changes.length;
|
|
93
|
+
const wanted = changes.map((change) => edited(change, priors));
|
|
94
|
+
const first = apply(parsed.document, wanted);
|
|
95
|
+
if (first.outcome === 'refuse')
|
|
96
|
+
return changes.length;
|
|
97
|
+
if (first.outcome === 'applied') {
|
|
98
|
+
staged.documents[path] = serialize(first.document);
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
const stale = new Set(first.stale);
|
|
102
|
+
const kept = wanted.filter((_, at) => !stale.has(at));
|
|
103
|
+
const rest = apply(parsed.document, kept);
|
|
104
|
+
if (rest.outcome !== 'applied')
|
|
105
|
+
return changes.length;
|
|
106
|
+
staged.documents[path] = serialize(rest.document);
|
|
107
|
+
return first.stale.length;
|
|
86
108
|
}
|
|
87
109
|
function relocate(staged, from, to) {
|
|
88
110
|
const text = staged.documents[from];
|
|
@@ -90,194 +112,128 @@ function relocate(staged, from, to) {
|
|
|
90
112
|
delete staged.documents[from];
|
|
91
113
|
staged.documents[to] = text;
|
|
92
114
|
}
|
|
93
|
-
else if (staged.
|
|
94
|
-
staged.
|
|
115
|
+
else if (staged.binaries[from] !== undefined) {
|
|
116
|
+
staged.binaries[to] = staged.binaries[from];
|
|
117
|
+
delete staged.binaries[from];
|
|
95
118
|
}
|
|
96
119
|
else {
|
|
97
|
-
return;
|
|
120
|
+
return false;
|
|
98
121
|
}
|
|
99
122
|
moveHead(staged, from, to);
|
|
123
|
+
return true;
|
|
100
124
|
}
|
|
101
125
|
function moveHead(heads, from, to) {
|
|
102
126
|
const revision = heads.revisions[from];
|
|
127
|
+
const fileId = heads.fileIds[from];
|
|
103
128
|
const change = heads.changes[from];
|
|
104
129
|
delete heads.revisions[from];
|
|
130
|
+
delete heads.fileIds[from];
|
|
105
131
|
delete heads.changes[from];
|
|
132
|
+
delete heads.fileIds[to];
|
|
106
133
|
delete heads.changes[to];
|
|
107
134
|
if (revision !== undefined)
|
|
108
135
|
heads.revisions[to] = revision;
|
|
136
|
+
if (fileId !== undefined)
|
|
137
|
+
heads.fileIds[to] = fileId;
|
|
109
138
|
if (change !== undefined)
|
|
110
139
|
heads.changes[to] = change;
|
|
111
140
|
}
|
|
112
141
|
function erase(staged, path) {
|
|
113
142
|
delete staged.documents[path];
|
|
114
143
|
delete staged.revisions[path];
|
|
144
|
+
delete staged.fileIds[path];
|
|
115
145
|
delete staged.changes[path];
|
|
116
|
-
staged.
|
|
146
|
+
delete staged.binaries[path];
|
|
117
147
|
}
|
|
118
|
-
function stage(staged, change
|
|
119
|
-
if (change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble') {
|
|
120
|
-
edit(staged, change, priors);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
148
|
+
function stage(staged, change) {
|
|
123
149
|
if (change.kind === 'create') {
|
|
124
150
|
staged.documents[change.path] =
|
|
125
151
|
'content' in change ? change.content : compose(change.fields, change.sections);
|
|
152
|
+
delete staged.fileIds[change.path];
|
|
126
153
|
delete staged.changes[change.path];
|
|
127
|
-
return;
|
|
154
|
+
return true;
|
|
128
155
|
}
|
|
129
156
|
if (change.kind === 'replace') {
|
|
157
|
+
delete staged.revisions[change.path];
|
|
130
158
|
if (staged.documents[change.path] === undefined)
|
|
131
|
-
return;
|
|
159
|
+
return false;
|
|
132
160
|
staged.documents[change.path] = change.content;
|
|
133
|
-
return;
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
if (change.kind === 'binary') {
|
|
164
|
+
if (staged.documents[change.path] !== undefined)
|
|
165
|
+
return false;
|
|
166
|
+
staged.binaries[change.path] = {
|
|
167
|
+
state: 'pending',
|
|
168
|
+
localId: change.localId,
|
|
169
|
+
byteLength: change.byteLength,
|
|
170
|
+
mediaType: change.mediaType,
|
|
171
|
+
sha256: change.sha256,
|
|
172
|
+
};
|
|
173
|
+
delete staged.revisions[change.path];
|
|
174
|
+
delete staged.changes[change.path];
|
|
175
|
+
return true;
|
|
134
176
|
}
|
|
135
177
|
if (change.kind === 'move') {
|
|
136
|
-
relocate(staged, change.path, change.to);
|
|
137
|
-
|
|
178
|
+
return relocate(staged, change.path, change.to);
|
|
179
|
+
}
|
|
180
|
+
if (change.kind === 'arrival') {
|
|
181
|
+
erase(staged, change.path);
|
|
182
|
+
if ('content' in change)
|
|
183
|
+
staged.documents[change.path] = change.content;
|
|
184
|
+
else
|
|
185
|
+
staged.binaries[change.path] = { state: 'accepted', ...change.binary };
|
|
186
|
+
arrive(staged, change);
|
|
187
|
+
return true;
|
|
138
188
|
}
|
|
139
189
|
erase(staged, change.path);
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
function arrive(heads, change) {
|
|
193
|
+
if (change.revision !== undefined)
|
|
194
|
+
heads.revisions[change.path] = change.revision;
|
|
195
|
+
if (change.fileId !== undefined)
|
|
196
|
+
heads.fileIds[change.path] = change.fileId;
|
|
197
|
+
if (change.change !== undefined)
|
|
198
|
+
heads.changes[change.path] = change.change;
|
|
140
199
|
}
|
|
141
|
-
export function
|
|
200
|
+
export function* overlaying(base, queue, unapplied) {
|
|
142
201
|
const staged = {
|
|
143
|
-
documents:
|
|
144
|
-
|
|
145
|
-
revisions:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
for (const batch of queue) {
|
|
149
|
-
const priors = priorsOf(batch.preconditions);
|
|
150
|
-
for (const change of batch.changes)
|
|
151
|
-
stage(staged, change, priors);
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
documents: staged.documents,
|
|
155
|
-
binaryTargets: [...staged.binaryTargets].sort(),
|
|
156
|
-
revisions: staged.revisions,
|
|
157
|
-
changes: staged.changes,
|
|
202
|
+
documents: drafted(base.documents),
|
|
203
|
+
binaries: drafted(base.binaries),
|
|
204
|
+
revisions: drafted(base.revisions),
|
|
205
|
+
fileIds: drafted(base.fileIds),
|
|
206
|
+
changes: drafted(base.changes),
|
|
158
207
|
};
|
|
159
|
-
}
|
|
160
|
-
function pathsOf(batch) {
|
|
161
|
-
return batch.changes.flatMap((change) => change.kind === 'move' ? [change.path, change.to] : [change.path]);
|
|
162
|
-
}
|
|
163
|
-
export function sameLayerText(left, right) {
|
|
164
|
-
const paths = Object.keys(left.documents);
|
|
165
|
-
return (paths.length === Object.keys(right.documents).length &&
|
|
166
|
-
paths.every((path) => left.documents[path] === right.documents[path]) &&
|
|
167
|
-
left.binaryTargets.length === right.binaryTargets.length &&
|
|
168
|
-
left.binaryTargets.every((path) => right.binaryTargets.includes(path)));
|
|
169
|
-
}
|
|
170
|
-
function replayHeads(base, queue) {
|
|
171
|
-
const heads = { revisions: { ...base.revisions }, changes: { ...base.changes } };
|
|
172
208
|
for (const batch of queue) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
else if (change.kind === 'move') {
|
|
182
|
-
moveHead(heads, change.path, change.to);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return heads;
|
|
187
|
-
}
|
|
188
|
-
export function overlayChanged(base, queue, previousBase, previousQueue, previousVisible) {
|
|
189
|
-
const before = previousQueue.map((batch) => JSON.stringify(batch));
|
|
190
|
-
const after = queue.map((batch) => JSON.stringify(batch));
|
|
191
|
-
if (before.length === after.length &&
|
|
192
|
-
before.every((id, index) => id === after[index]) &&
|
|
193
|
-
sameLayerText(base, previousBase)) {
|
|
194
|
-
return {
|
|
195
|
-
documents: previousVisible.documents,
|
|
196
|
-
binaryTargets: previousVisible.binaryTargets,
|
|
197
|
-
...replayHeads(base, queue),
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
const affected = new Set();
|
|
201
|
-
const paths = new Set([
|
|
202
|
-
...Object.keys(base.documents),
|
|
203
|
-
...Object.keys(previousBase.documents),
|
|
204
|
-
...Object.keys(base.revisions),
|
|
205
|
-
...Object.keys(previousBase.revisions),
|
|
206
|
-
...Object.keys(base.changes),
|
|
207
|
-
...Object.keys(previousBase.changes),
|
|
208
|
-
...base.binaryTargets,
|
|
209
|
-
...previousBase.binaryTargets,
|
|
210
|
-
]);
|
|
211
|
-
for (const path of paths) {
|
|
212
|
-
if (base.documents[path] !== previousBase.documents[path] ||
|
|
213
|
-
base.revisions[path] !== previousBase.revisions[path] ||
|
|
214
|
-
!sameChange(base.changes[path], previousBase.changes[path]) ||
|
|
215
|
-
base.binaryTargets.includes(path) !== previousBase.binaryTargets.includes(path))
|
|
216
|
-
affected.add(path);
|
|
217
|
-
}
|
|
218
|
-
const oldIds = new Set(before);
|
|
219
|
-
const newIds = new Set(after);
|
|
220
|
-
for (const batch of previousQueue) {
|
|
221
|
-
if (!newIds.has(JSON.stringify(batch)))
|
|
222
|
-
for (const path of pathsOf(batch))
|
|
223
|
-
affected.add(path);
|
|
224
|
-
}
|
|
225
|
-
for (const batch of queue) {
|
|
226
|
-
if (!oldIds.has(JSON.stringify(batch)))
|
|
227
|
-
for (const path of pathsOf(batch))
|
|
228
|
-
affected.add(path);
|
|
229
|
-
}
|
|
230
|
-
let expanded = true;
|
|
231
|
-
while (expanded) {
|
|
232
|
-
expanded = false;
|
|
233
|
-
for (const batch of queue) {
|
|
234
|
-
const touched = pathsOf(batch);
|
|
235
|
-
if (!touched.some((path) => affected.has(path)))
|
|
209
|
+
const priors = yield* priorsOf(batch.preconditions);
|
|
210
|
+
for (let index = 0; index < batch.changes.length; index += 1) {
|
|
211
|
+
const change = batch.changes[index];
|
|
212
|
+
if (!isPart(change)) {
|
|
213
|
+
if (!stage(staged, change))
|
|
214
|
+
unapplied?.();
|
|
215
|
+
yield ROW_WEIGHT;
|
|
236
216
|
continue;
|
|
237
|
-
for (const path of touched) {
|
|
238
|
-
if (affected.has(path))
|
|
239
|
-
continue;
|
|
240
|
-
affected.add(path);
|
|
241
|
-
expanded = true;
|
|
242
217
|
}
|
|
218
|
+
const run = [change];
|
|
219
|
+
while (index + 1 < batch.changes.length) {
|
|
220
|
+
const next = batch.changes[index + 1];
|
|
221
|
+
if (!isPart(next) || next.path !== change.path)
|
|
222
|
+
break;
|
|
223
|
+
run.push(next);
|
|
224
|
+
index += 1;
|
|
225
|
+
}
|
|
226
|
+
const text = staged.documents[change.path] ?? '';
|
|
227
|
+
for (let left = edit(staged, run, priors); left > 0; left -= 1)
|
|
228
|
+
unapplied?.();
|
|
229
|
+
yield ROW_WEIGHT + text.length;
|
|
243
230
|
}
|
|
244
231
|
}
|
|
245
|
-
const documents = {};
|
|
246
|
-
const revisions = {};
|
|
247
|
-
const changes = {};
|
|
248
|
-
for (const path of affected) {
|
|
249
|
-
if (base.documents[path] !== undefined)
|
|
250
|
-
documents[path] = base.documents[path];
|
|
251
|
-
if (base.revisions[path] !== undefined)
|
|
252
|
-
revisions[path] = base.revisions[path];
|
|
253
|
-
if (base.changes[path] !== undefined)
|
|
254
|
-
changes[path] = base.changes[path];
|
|
255
|
-
}
|
|
256
|
-
const staged = overlay({
|
|
257
|
-
documents,
|
|
258
|
-
revisions,
|
|
259
|
-
changes,
|
|
260
|
-
binaryTargets: base.binaryTargets.filter((path) => affected.has(path)),
|
|
261
|
-
}, queue.filter((batch) => pathsOf(batch).some((path) => affected.has(path))));
|
|
262
|
-
const mergedDocuments = { ...previousVisible.documents };
|
|
263
|
-
const mergedRevisions = { ...previousVisible.revisions };
|
|
264
|
-
const mergedChanges = { ...previousVisible.changes };
|
|
265
|
-
const mergedTargets = new Set(previousVisible.binaryTargets);
|
|
266
|
-
for (const path of affected) {
|
|
267
|
-
delete mergedDocuments[path];
|
|
268
|
-
delete mergedRevisions[path];
|
|
269
|
-
delete mergedChanges[path];
|
|
270
|
-
mergedTargets.delete(path);
|
|
271
|
-
}
|
|
272
|
-
Object.assign(mergedDocuments, staged.documents);
|
|
273
|
-
Object.assign(mergedRevisions, staged.revisions);
|
|
274
|
-
Object.assign(mergedChanges, staged.changes);
|
|
275
|
-
for (const path of staged.binaryTargets)
|
|
276
|
-
mergedTargets.add(path);
|
|
277
232
|
return {
|
|
278
|
-
documents:
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
233
|
+
documents: yield* settling(staged.documents),
|
|
234
|
+
binaries: yield* settling(staged.binaries),
|
|
235
|
+
revisions: yield* settling(staged.revisions),
|
|
236
|
+
fileIds: yield* settling(staged.fileIds),
|
|
237
|
+
changes: yield* settling(staged.changes),
|
|
282
238
|
};
|
|
283
239
|
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function normalize(path: string): string | null;
|
|
2
2
|
export declare function beneath(prefix: string, path: string): boolean;
|
|
3
3
|
export declare function covered(prefixes: readonly string[], path: string): boolean;
|
|
4
|
+
export declare function ancestors(path: string): readonly string[];
|
|
4
5
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK1E"}
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK1E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAGzD"}
|
package/dist/paths.js
CHANGED
|
@@ -22,3 +22,7 @@ export function covered(prefixes, path) {
|
|
|
22
22
|
return normalized !== null && (normalized === '' || beneath(normalized, path));
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
export function ancestors(path) {
|
|
26
|
+
const parts = path.split('/');
|
|
27
|
+
return parts.slice(1).map((_, at) => parts.slice(0, at + 1).join('/'));
|
|
28
|
+
}
|