@agentshouse/mdruntime 0.1.0-cde2b99d2fcbc → 0.1.0-cdf06805b9658
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 +286 -292
- package/README.md +16 -14
- package/dist/adapter.d.ts +99 -36
- 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 +21 -4
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +27 -9
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +155 -64
- 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 -63
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/client.d.ts +24 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +49 -9
- package/dist/collection.d.ts +7 -6
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +30 -77
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +721 -0
- package/dist/connection.d.ts +42 -15
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3397 -804
- package/dist/conversation.d.ts +30 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +549 -181
- 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 +5 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +19 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -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 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +126 -16
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/memory.d.ts +10 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +54 -26
- 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 +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -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 +19 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- 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 +38 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +26 -0
- package/dist/overlay.d.ts +3 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +100 -182
- package/dist/query.d.ts +60 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +48 -7
- package/dist/reach.d.ts +11 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +182 -62
- package/dist/react.d.ts +8 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/readiness.d.ts +64 -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 +100 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +198 -0
- package/dist/refresh.d.ts +16 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +113 -49
- package/dist/replica.d.ts +56 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +297 -162
- package/dist/room-draft.d.ts +17 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -25
- package/dist/rows.d.ts +28 -37
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +113 -72
- package/dist/save.d.ts +50 -9
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +528 -166
- package/dist/search.d.ts +39 -28
- 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 +16 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +431 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +118 -76
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +355 -444
- package/dist/stored.d.ts +145 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +567 -0
- package/dist/tables.d.ts +354 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +624 -0
- 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 +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -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 +164 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +55 -31
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +27 -23
- package/dist/chat/acts.d.ts +0 -34
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -60
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -20
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -59
- package/dist/chat/markdown.d.ts +0 -19
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -187
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -645
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -80
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -33
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.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 -440
package/dist/model.js
CHANGED
|
@@ -6,7 +6,7 @@ export function definitionOf(state, type) {
|
|
|
6
6
|
}
|
|
7
7
|
export function modelTypes(state) {
|
|
8
8
|
return state.status === 'unavailable'
|
|
9
|
-
? { ...state }
|
|
9
|
+
? { ...state, types: null }
|
|
10
10
|
: {
|
|
11
11
|
status: state.status,
|
|
12
12
|
identity: state.snapshot.identity,
|
|
@@ -14,7 +14,7 @@ export function modelTypes(state) {
|
|
|
14
14
|
verifiedWith: { ...state.verifiedWith },
|
|
15
15
|
schema: state.snapshot.schema,
|
|
16
16
|
revision: state.snapshot.revision,
|
|
17
|
-
types:
|
|
17
|
+
types: Object.values(state.types).sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export function cached(state) {
|
|
@@ -23,6 +23,15 @@ export function cached(state) {
|
|
|
23
23
|
export function sameModel(left, right) {
|
|
24
24
|
return left.identity === right.identity && left.version === right.version;
|
|
25
25
|
}
|
|
26
|
+
export function sameTyping(left, right) {
|
|
27
|
+
if (left === right)
|
|
28
|
+
return true;
|
|
29
|
+
if (left.status === 'unavailable' || right.status === 'unavailable') {
|
|
30
|
+
return left.status === right.status;
|
|
31
|
+
}
|
|
32
|
+
return (left.snapshot.schema === right.snapshot.schema &&
|
|
33
|
+
sameModel(left.verifiedWith, right.verifiedWith));
|
|
34
|
+
}
|
|
26
35
|
export function referenceField(facts) {
|
|
27
36
|
return facts?.reference !== undefined || facts?.items?.reference !== undefined;
|
|
28
37
|
}
|
package/dist/name.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../src/name.ts"],"names":[],"mappings":"AAgHA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
package/dist/name.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const LETTERS = {
|
|
2
|
+
а: 'a',
|
|
3
|
+
б: 'b',
|
|
4
|
+
в: 'v',
|
|
5
|
+
г: 'g',
|
|
6
|
+
ґ: 'g',
|
|
7
|
+
д: 'd',
|
|
8
|
+
ђ: 'dj',
|
|
9
|
+
ѓ: 'gj',
|
|
10
|
+
е: 'e',
|
|
11
|
+
ё: 'yo',
|
|
12
|
+
є: 'ye',
|
|
13
|
+
ж: 'zh',
|
|
14
|
+
з: 'z',
|
|
15
|
+
ѕ: 'dz',
|
|
16
|
+
и: 'i',
|
|
17
|
+
і: 'i',
|
|
18
|
+
ї: 'yi',
|
|
19
|
+
й: 'y',
|
|
20
|
+
ј: 'j',
|
|
21
|
+
к: 'k',
|
|
22
|
+
ќ: 'kj',
|
|
23
|
+
л: 'l',
|
|
24
|
+
љ: 'lj',
|
|
25
|
+
м: 'm',
|
|
26
|
+
н: 'n',
|
|
27
|
+
њ: 'nj',
|
|
28
|
+
о: 'o',
|
|
29
|
+
п: 'p',
|
|
30
|
+
р: 'r',
|
|
31
|
+
с: 's',
|
|
32
|
+
т: 't',
|
|
33
|
+
ћ: 'c',
|
|
34
|
+
у: 'u',
|
|
35
|
+
ў: 'u',
|
|
36
|
+
ф: 'f',
|
|
37
|
+
х: 'kh',
|
|
38
|
+
ц: 'ts',
|
|
39
|
+
ч: 'ch',
|
|
40
|
+
џ: 'dz',
|
|
41
|
+
ш: 'sh',
|
|
42
|
+
щ: 'shch',
|
|
43
|
+
ъ: '',
|
|
44
|
+
ы: 'y',
|
|
45
|
+
ь: '',
|
|
46
|
+
э: 'e',
|
|
47
|
+
ю: 'yu',
|
|
48
|
+
я: 'ya',
|
|
49
|
+
α: 'a',
|
|
50
|
+
β: 'v',
|
|
51
|
+
γ: 'g',
|
|
52
|
+
δ: 'd',
|
|
53
|
+
ε: 'e',
|
|
54
|
+
ζ: 'z',
|
|
55
|
+
η: 'i',
|
|
56
|
+
θ: 'th',
|
|
57
|
+
ι: 'i',
|
|
58
|
+
κ: 'k',
|
|
59
|
+
λ: 'l',
|
|
60
|
+
μ: 'm',
|
|
61
|
+
ν: 'n',
|
|
62
|
+
ξ: 'x',
|
|
63
|
+
ο: 'o',
|
|
64
|
+
π: 'p',
|
|
65
|
+
ρ: 'r',
|
|
66
|
+
σ: 's',
|
|
67
|
+
ς: 's',
|
|
68
|
+
τ: 't',
|
|
69
|
+
υ: 'y',
|
|
70
|
+
φ: 'f',
|
|
71
|
+
χ: 'ch',
|
|
72
|
+
ψ: 'ps',
|
|
73
|
+
ω: 'o',
|
|
74
|
+
ß: 'ss',
|
|
75
|
+
æ: 'ae',
|
|
76
|
+
œ: 'oe',
|
|
77
|
+
ø: 'o',
|
|
78
|
+
đ: 'd',
|
|
79
|
+
ð: 'd',
|
|
80
|
+
þ: 'th',
|
|
81
|
+
ł: 'l',
|
|
82
|
+
ı: 'i',
|
|
83
|
+
};
|
|
84
|
+
const MARKS = /\p{M}/gu;
|
|
85
|
+
const ADMITTED = /^[a-z0-9]$/;
|
|
86
|
+
const WORDLIKE = /^[\p{L}\p{N}]$/u;
|
|
87
|
+
function lowerLetterOf(character) {
|
|
88
|
+
const known = LETTERS[character];
|
|
89
|
+
if (known !== undefined)
|
|
90
|
+
return known;
|
|
91
|
+
const bare = character.normalize('NFKD').replace(MARKS, '');
|
|
92
|
+
const mapped = LETTERS[bare];
|
|
93
|
+
if (mapped !== undefined)
|
|
94
|
+
return mapped;
|
|
95
|
+
return [...bare].every((one) => ADMITTED.test(one)) ? bare : null;
|
|
96
|
+
}
|
|
97
|
+
function codePoint(character) {
|
|
98
|
+
return WORDLIKE.test(character) ? `-u${character.codePointAt(0)?.toString(16) ?? ''}-` : '-';
|
|
99
|
+
}
|
|
100
|
+
function latin(text, unknown) {
|
|
101
|
+
return [...text]
|
|
102
|
+
.map((character) => {
|
|
103
|
+
if ((character.codePointAt(0) ?? 0) < 0x80)
|
|
104
|
+
return character;
|
|
105
|
+
const lower = character.toLowerCase();
|
|
106
|
+
const letter = lowerLetterOf(lower) ?? unknown(lower);
|
|
107
|
+
return lower === character ? letter : `${letter.charAt(0).toUpperCase()}${letter.slice(1)}`;
|
|
108
|
+
})
|
|
109
|
+
.join('');
|
|
110
|
+
}
|
|
111
|
+
export function transliterated(text) {
|
|
112
|
+
return latin(text, () => '-');
|
|
113
|
+
}
|
|
114
|
+
export function nameFrom(title) {
|
|
115
|
+
return latin(title, codePoint)
|
|
116
|
+
.toLowerCase()
|
|
117
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
118
|
+
.replace(/^-+|-+$/g, '');
|
|
119
|
+
}
|
|
120
|
+
export function cutName(name, most) {
|
|
121
|
+
return name.slice(0, most).replace(/-+$/, '');
|
|
122
|
+
}
|
package/dist/observation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
1
|
+
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
2
|
export type Observation<T> = {
|
|
3
3
|
current(): T;
|
|
4
4
|
subscribe(listener: (value: T) => void): () => void;
|
|
@@ -13,15 +13,32 @@ export type QueryChange = {
|
|
|
13
13
|
changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
|
|
14
14
|
removed: readonly RowKey[];
|
|
15
15
|
order: readonly RowKey[] | null;
|
|
16
|
+
coverage?: QueryCoverage;
|
|
17
|
+
next?: string | null;
|
|
18
|
+
total?: number;
|
|
16
19
|
};
|
|
20
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
17
21
|
export type Observed = {
|
|
18
22
|
observation: Observation<unknown>;
|
|
19
23
|
receive(message: unknown): void;
|
|
20
24
|
end(): void;
|
|
21
25
|
};
|
|
22
26
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
23
|
-
export declare function
|
|
27
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
24
29
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
25
30
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
26
31
|
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
|
+
export type Digest = {
|
|
33
|
+
readonly pending: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly keys: readonly RowKey[];
|
|
36
|
+
readonly rows: ReadonlyMap<RowKey, number>;
|
|
37
|
+
readonly coverage: string;
|
|
38
|
+
readonly next: string | undefined;
|
|
39
|
+
readonly total: number | undefined;
|
|
40
|
+
};
|
|
41
|
+
export declare function digestOf({ result, keys }: KeyedResult): Digest;
|
|
42
|
+
export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
|
|
43
|
+
export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
|
|
27
44
|
//# sourceMappingURL=observation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,IAAI,CAAC,CAAC;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG;IACr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,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAqBN,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,WAAW,GAAG,MAAM,CAU9D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAY3E;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CA+BjF"}
|
package/dist/observation.js
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
export function rowsOf(result) {
|
|
2
|
-
|
|
2
|
+
if ('groups' in result)
|
|
3
|
+
return result.groups;
|
|
4
|
+
return 'documents' in result ? result.documents : [];
|
|
3
5
|
}
|
|
4
|
-
export function
|
|
5
|
-
|
|
6
|
+
export function whole(message) {
|
|
7
|
+
return 'result' in message;
|
|
8
|
+
}
|
|
9
|
+
export function applied(keyed, message) {
|
|
10
|
+
if (whole(message))
|
|
11
|
+
return message;
|
|
12
|
+
const result = keyed.result;
|
|
13
|
+
if ('pending' in result)
|
|
14
|
+
return keyed;
|
|
15
|
+
const rows = rowsOf(result);
|
|
6
16
|
const byKey = new Map(keyed.keys.map((key, index) => [key, rows[index]]));
|
|
7
|
-
for (const key of
|
|
17
|
+
for (const key of message.removed)
|
|
8
18
|
byKey.delete(key);
|
|
9
|
-
for (const [key, row] of
|
|
19
|
+
for (const [key, row] of message.changed)
|
|
10
20
|
byKey.set(key, row);
|
|
11
|
-
const keys =
|
|
12
|
-
const
|
|
21
|
+
const keys = message.order ?? keyed.keys.filter((key) => byKey.has(key));
|
|
22
|
+
const kept = keys.map((key) => byKey.get(key));
|
|
23
|
+
const coverage = message.coverage ?? result.coverage;
|
|
24
|
+
const next = message.next === undefined ? result.next : (message.next ?? undefined);
|
|
25
|
+
const total = message.total ?? result.total;
|
|
26
|
+
const window = {
|
|
27
|
+
...(next === undefined ? {} : { next }),
|
|
28
|
+
...(total === undefined ? {} : { total }),
|
|
29
|
+
};
|
|
13
30
|
return {
|
|
14
|
-
result: 'groups' in
|
|
15
|
-
? { groups:
|
|
16
|
-
: { documents:
|
|
31
|
+
result: 'groups' in result
|
|
32
|
+
? { groups: kept, coverage, ...window }
|
|
33
|
+
: { documents: kept, coverage, ...window },
|
|
17
34
|
keys,
|
|
18
35
|
};
|
|
19
36
|
}
|
|
@@ -27,11 +44,11 @@ function keyedResult(first) {
|
|
|
27
44
|
},
|
|
28
45
|
};
|
|
29
46
|
}
|
|
30
|
-
function
|
|
47
|
+
function replaced(first) {
|
|
31
48
|
return { value: first, next: (message) => message };
|
|
32
49
|
}
|
|
33
50
|
export function observed(first, stop, keyed) {
|
|
34
|
-
const reducer = keyed ? keyedResult(first) :
|
|
51
|
+
const reducer = keyed ? keyedResult(first) : replaced(first);
|
|
35
52
|
let value = reducer.value;
|
|
36
53
|
let open = true;
|
|
37
54
|
const listeners = new Set();
|
|
@@ -93,3 +110,87 @@ export function observing(watch) {
|
|
|
93
110
|
deliver(structuredClone(message));
|
|
94
111
|
}), topic === 'query');
|
|
95
112
|
}
|
|
113
|
+
function hashed(text) {
|
|
114
|
+
let first = 0xdeadbeef;
|
|
115
|
+
let second = 0x41c6ce57;
|
|
116
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
117
|
+
const code = text.charCodeAt(index);
|
|
118
|
+
first = Math.imul(first ^ code, 2654435761);
|
|
119
|
+
second = Math.imul(second ^ code, 1597334677);
|
|
120
|
+
}
|
|
121
|
+
first =
|
|
122
|
+
Math.imul(first ^ (first >>> 16), 2246822507) ^ Math.imul(second ^ (second >>> 13), 3266489909);
|
|
123
|
+
second =
|
|
124
|
+
Math.imul(second ^ (second >>> 16), 2246822507) ^ Math.imul(first ^ (first >>> 13), 3266489909);
|
|
125
|
+
return 4294967296 * (2097151 & second) + (first >>> 0);
|
|
126
|
+
}
|
|
127
|
+
function rowDigest(row) {
|
|
128
|
+
return hashed(JSON.stringify(row));
|
|
129
|
+
}
|
|
130
|
+
export function digestOf({ result, keys }) {
|
|
131
|
+
if ('pending' in result)
|
|
132
|
+
return { pending: JSON.stringify(result) };
|
|
133
|
+
const rows = rowsOf(result);
|
|
134
|
+
return {
|
|
135
|
+
keys,
|
|
136
|
+
rows: new Map(keys.map((key, index) => [key, rowDigest(rows[index])])),
|
|
137
|
+
coverage: JSON.stringify(result.coverage),
|
|
138
|
+
next: result.next,
|
|
139
|
+
total: result.total,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function digestApplied(digest, message) {
|
|
143
|
+
if (whole(message) || 'pending' in digest)
|
|
144
|
+
return whole(message) ? digestOf(message) : digest;
|
|
145
|
+
const rows = new Map(digest.rows);
|
|
146
|
+
for (const key of message.removed)
|
|
147
|
+
rows.delete(key);
|
|
148
|
+
for (const [key, row] of message.changed)
|
|
149
|
+
rows.set(key, rowDigest(row));
|
|
150
|
+
return {
|
|
151
|
+
keys: message.order ?? digest.keys.filter((key) => rows.has(key)),
|
|
152
|
+
rows,
|
|
153
|
+
coverage: message.coverage === undefined ? digest.coverage : JSON.stringify(message.coverage),
|
|
154
|
+
next: message.next === undefined ? digest.next : (message.next ?? undefined),
|
|
155
|
+
total: message.total ?? digest.total,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export function changeOf(previous, next) {
|
|
159
|
+
const after = next.result;
|
|
160
|
+
if ('pending' in previous || 'pending' in after) {
|
|
161
|
+
return 'pending' in previous && 'pending' in after && previous.pending === JSON.stringify(after)
|
|
162
|
+
? null
|
|
163
|
+
: next;
|
|
164
|
+
}
|
|
165
|
+
const later = rowsOf(after);
|
|
166
|
+
const present = new Set(next.keys);
|
|
167
|
+
const changed = [];
|
|
168
|
+
next.keys.forEach((key, index) => {
|
|
169
|
+
const row = later[index];
|
|
170
|
+
if (previous.rows.get(key) !== rowDigest(row))
|
|
171
|
+
changed.push([key, row]);
|
|
172
|
+
});
|
|
173
|
+
const removed = previous.keys.filter((key) => !present.has(key));
|
|
174
|
+
const kept = previous.keys.filter((key) => present.has(key));
|
|
175
|
+
const moved = kept.length !== next.keys.length || kept.some((key, index) => next.keys[index] !== key);
|
|
176
|
+
const coverage = JSON.stringify(after.coverage);
|
|
177
|
+
const covered = previous.coverage !== coverage;
|
|
178
|
+
const framing = reframed(previous, after);
|
|
179
|
+
if (changed.length === 0 && removed.length === 0 && !moved && !covered && framing === null) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
changed,
|
|
184
|
+
removed,
|
|
185
|
+
order: moved ? next.keys : null,
|
|
186
|
+
...(covered ? { coverage: after.coverage } : {}),
|
|
187
|
+
...framing,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function reframed(before, after) {
|
|
191
|
+
const next = before.next === after.next ? {} : { next: after.next ?? null };
|
|
192
|
+
const total = before.total === after.total || after.total === undefined ? {} : { total: after.total };
|
|
193
|
+
return Object.keys(next).length === 0 && Object.keys(total).length === 0
|
|
194
|
+
? null
|
|
195
|
+
: { ...next, ...total };
|
|
196
|
+
}
|
package/dist/opened.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BinaryResult } from './adapter.js';
|
|
2
|
+
import { type RuntimeDatabase } from './tables.js';
|
|
3
|
+
export type OpenedName = {
|
|
4
|
+
readonly locator: string;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly revision: string;
|
|
7
|
+
};
|
|
8
|
+
export type KeptBinary = {
|
|
9
|
+
readonly kind: 'binary';
|
|
10
|
+
readonly file: string;
|
|
11
|
+
readonly byteLength: number;
|
|
12
|
+
readonly mediaType: string;
|
|
13
|
+
};
|
|
14
|
+
export type KeptResult = KeptBinary | Exclude<BinaryResult, {
|
|
15
|
+
kind: 'binary';
|
|
16
|
+
}>;
|
|
17
|
+
export type OpenedFiles = {
|
|
18
|
+
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
|
+
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
|
+
};
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;
|
|
22
|
+
//# sourceMappingURL=opened.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAEhF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACnC,WAAW,CAsFb"}
|
package/dist/opened.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { digest } from './digest.js';
|
|
2
|
+
import { binaryLocalId } from './identity.js';
|
|
3
|
+
import { FILE_PART_BYTES } from './tables.js';
|
|
4
|
+
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
5
|
+
function kept({ key, byteLength, mediaType }) {
|
|
6
|
+
return { kind: 'binary', file: key, byteLength, mediaType };
|
|
7
|
+
}
|
|
8
|
+
function taken(chunks, size) {
|
|
9
|
+
const part = new Uint8Array(size);
|
|
10
|
+
let at = 0;
|
|
11
|
+
while (at < size) {
|
|
12
|
+
const chunk = chunks[0];
|
|
13
|
+
const wanted = Math.min(chunk.length, size - at);
|
|
14
|
+
part.set(chunk.subarray(0, wanted), at);
|
|
15
|
+
at += wanted;
|
|
16
|
+
if (wanted === chunk.length)
|
|
17
|
+
chunks.shift();
|
|
18
|
+
else
|
|
19
|
+
chunks[0] = chunk.subarray(wanted);
|
|
20
|
+
}
|
|
21
|
+
return part;
|
|
22
|
+
}
|
|
23
|
+
export function openedFiles(database, fenced) {
|
|
24
|
+
const fetching = new Map();
|
|
25
|
+
async function find(name) {
|
|
26
|
+
const held = await database.ask({ kind: 'opened.find', ...name });
|
|
27
|
+
return held === null ? null : kept(held);
|
|
28
|
+
}
|
|
29
|
+
async function written(name, { body, mediaType, sha256 }) {
|
|
30
|
+
const key = binaryLocalId();
|
|
31
|
+
const reader = body.getReader();
|
|
32
|
+
const hashed = digest();
|
|
33
|
+
const chunks = [];
|
|
34
|
+
let held = 0;
|
|
35
|
+
let size = 0;
|
|
36
|
+
let part = 0;
|
|
37
|
+
const write = async (bytes) => {
|
|
38
|
+
if (!(await database.ask({ kind: 'opened.part', key, part, bytes }))) {
|
|
39
|
+
throw new Error('the device no longer keeps this download');
|
|
40
|
+
}
|
|
41
|
+
part += 1;
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
if (fenced(name.locator) ||
|
|
45
|
+
!(await database.ask({ kind: 'opened.begin', key, ...name, mediaType }))) {
|
|
46
|
+
throw new Error('the device no longer reads this Room');
|
|
47
|
+
}
|
|
48
|
+
for (;;) {
|
|
49
|
+
const read = await reader.read();
|
|
50
|
+
if (read.done)
|
|
51
|
+
break;
|
|
52
|
+
hashed.update(read.value);
|
|
53
|
+
size += read.value.length;
|
|
54
|
+
chunks.push(read.value);
|
|
55
|
+
held += read.value.length;
|
|
56
|
+
for (; held >= FILE_PART_BYTES; held -= FILE_PART_BYTES) {
|
|
57
|
+
await write(taken(chunks, FILE_PART_BYTES));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (held > 0)
|
|
61
|
+
await write(taken(chunks, held));
|
|
62
|
+
const received = hashed.hex();
|
|
63
|
+
if (sha256 !== undefined && sha256 !== received) {
|
|
64
|
+
throw new Error('the bytes are not the file the device asked for');
|
|
65
|
+
}
|
|
66
|
+
const whole = await database.ask({
|
|
67
|
+
kind: 'opened.keep',
|
|
68
|
+
key,
|
|
69
|
+
sha256: received,
|
|
70
|
+
byteLength: size,
|
|
71
|
+
parts: part,
|
|
72
|
+
});
|
|
73
|
+
return whole ? { kind: 'binary', file: key, byteLength: size, mediaType } : null;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
await reader.cancel().catch(() => { });
|
|
77
|
+
await database.ask({ kind: 'opened.drop', key }).catch(() => null);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function fetched(name, read) {
|
|
82
|
+
const held = await find(name);
|
|
83
|
+
if (held !== null)
|
|
84
|
+
return held;
|
|
85
|
+
const result = await read();
|
|
86
|
+
if (result.kind !== 'binary')
|
|
87
|
+
return result;
|
|
88
|
+
return (await written(name, result)) ?? UNCERTAIN;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
find,
|
|
92
|
+
fetch(name, read) {
|
|
93
|
+
const identity = `${name.locator}\u0000${name.path}\u0000${name.revision}`;
|
|
94
|
+
const held = fetching.get(identity);
|
|
95
|
+
if (held !== undefined)
|
|
96
|
+
return held;
|
|
97
|
+
const work = fetched(name, read);
|
|
98
|
+
fetching.set(identity, work);
|
|
99
|
+
const done = () => {
|
|
100
|
+
if (fetching.get(identity) === work)
|
|
101
|
+
fetching.delete(identity);
|
|
102
|
+
};
|
|
103
|
+
work.then(done, done);
|
|
104
|
+
return work;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure,
|
|
1
|
+
import type { ActionResult, AdapterFailure, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { KeptBinary, KeptResult } from './opened.js';
|
|
3
4
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
5
|
kind: Kind;
|
|
5
6
|
};
|
|
6
7
|
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
7
8
|
locator: string;
|
|
9
|
+
}) | (Refused<'room-locked'> & {
|
|
10
|
+
locator: string;
|
|
8
11
|
}) | ScopedRefusal;
|
|
9
12
|
export type CallResult = {
|
|
10
13
|
kind: 'action';
|
|
@@ -14,12 +17,43 @@ export type CallResult = {
|
|
|
14
17
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
18
|
kind: Failure['kind'];
|
|
16
19
|
}> | Failure;
|
|
20
|
+
type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
17
21
|
export type BinaryAnswer = {
|
|
18
22
|
kind: 'binary';
|
|
19
|
-
|
|
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;
|
|
20
32
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
-
export
|
|
22
|
-
|
|
33
|
+
export type Resolution = {
|
|
34
|
+
readonly kind: 'document';
|
|
35
|
+
readonly room: string;
|
|
36
|
+
readonly path: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'deleted';
|
|
39
|
+
readonly room: string;
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly revision: HistoryRevision;
|
|
42
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
43
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
44
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
45
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
46
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
47
|
+
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
48
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
|
|
49
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
50
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
51
|
+
locator: string;
|
|
52
|
+
};
|
|
53
|
+
export type Offline = {
|
|
54
|
+
readonly kind: 'offline';
|
|
55
|
+
};
|
|
56
|
+
export declare const OFFLINE: Offline;
|
|
23
57
|
export declare const UNCERTAIN: Failure;
|
|
24
58
|
export declare function undeclared(name: string): CallResult;
|
|
25
59
|
export declare function failure(result: AdapterFailure): Failure;
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../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able',
|
|
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
|
+
};
|
|
1
19
|
export function absentBinary(path) {
|
|
2
20
|
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
3
21
|
}
|
|
4
22
|
export function binaryAnswer(result) {
|
|
5
23
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
6
24
|
}
|
|
25
|
+
export function binaryLinkAnswer(result) {
|
|
26
|
+
return result.kind === 'link' || result.kind === 'rejected' ? result : failure(result);
|
|
27
|
+
}
|
|
28
|
+
export const ROOM_LOCKED = 'room-locked';
|
|
29
|
+
export function lockedRoom(locator) {
|
|
30
|
+
return { kind: ROOM_LOCKED, locator, code: ROOM_LOCKED, fields: {}, retryable: true };
|
|
31
|
+
}
|
|
32
|
+
export const OFFLINE = { kind: 'offline' };
|
|
7
33
|
export const UNCERTAIN = {
|
|
8
34
|
kind: 'transport-uncertainty',
|
|
9
35
|
code: 'transport-uncertainty',
|
package/dist/overlay.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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
|
};
|
|
7
8
|
export type HeldBinary = ({
|
|
@@ -17,10 +18,8 @@ export type Layer = Heads & {
|
|
|
17
18
|
documents: Readonly<Record<string, string>>;
|
|
18
19
|
binaries: Readonly<Record<string, HeldBinary>>;
|
|
19
20
|
};
|
|
20
|
-
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>):
|
|
21
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
21
22
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
22
23
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
25
|
-
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>;
|
|
26
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,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAU,WAAW,EAAgB,MAAM,aAAa,CAAC;AAIrE,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,UA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