@graview/ship 0.1.49 → 0.1.51
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 +5 -5
- package/dist/browser-adapter.d.ts +1 -1
- package/dist/browser-adapter.d.ts.map +1 -1
- package/dist/browser-adapter.js +23 -6
- package/dist/browser-adapter.js.map +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -0
- package/dist/browser.js.map +1 -1
- package/dist/cursor.d.ts +22 -0
- package/dist/cursor.d.ts.map +1 -0
- package/dist/cursor.js +13 -0
- package/dist/cursor.js.map +1 -0
- package/dist/file-adapter.d.ts.map +1 -1
- package/dist/file-adapter.js +44 -3
- package/dist/file-adapter.js.map +1 -1
- package/dist/handler.d.ts +20 -6
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js +33 -11
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/live-protocol.d.ts +32 -4
- package/dist/live-protocol.d.ts.map +1 -1
- package/dist/live-protocol.js +262 -40
- package/dist/live-protocol.js.map +1 -1
- package/dist/live.d.ts +28 -11
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +6 -3
- package/dist/live.js.map +1 -1
- package/dist/open-store.d.ts +3 -1
- package/dist/open-store.d.ts.map +1 -1
- package/dist/open-store.js +28 -7
- package/dist/open-store.js.map +1 -1
- package/dist/remote-typing.d.ts +127 -0
- package/dist/remote-typing.d.ts.map +1 -0
- package/dist/remote-typing.js +205 -0
- package/dist/remote-typing.js.map +1 -0
- package/dist/remote.d.ts +12 -0
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +114 -19
- package/dist/remote.js.map +1 -1
- package/dist/runtime.d.ts +4 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +3 -0
- package/dist/runtime.js.map +1 -1
- package/dist/serve.d.ts +4 -2
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +2 -0
- package/dist/serve.js.map +1 -1
- package/dist/snapshot.d.ts +3 -0
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +20 -5
- package/dist/snapshot.js.map +1 -1
- package/dist/steps.d.ts.map +1 -1
- package/dist/steps.js +5 -2
- package/dist/steps.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type AnySchema, type MutationCall, type Operation, type Principal, type Store, type TextSplice } from "@graview/core";
|
|
2
|
+
/**
|
|
3
|
+
* TYPING INTO A FIELD TYPED TOGETHER, OVER THE WIRE (Roadmap f-collab-text,
|
|
4
|
+
* phase 3). Loaded by `remote.typing(node, field)` — with
|
|
5
|
+
* `@graview/core/typing` — once somebody types into such a field, so a
|
|
6
|
+
* page that only opens an app carries none of it.
|
|
7
|
+
*
|
|
8
|
+
* The discipline is the one a server-ordered transform needs (ot.js): at
|
|
9
|
+
* most ONE run of keystrokes per field is on its way to the server. What is
|
|
10
|
+
* typed meanwhile is shown at once and held, as runs of its own, and sent
|
|
11
|
+
* only once the server has answered the one before — so the revision it
|
|
12
|
+
* claims is past that run, and the server carries it over nobody's typing
|
|
13
|
+
* but other people's. While runs wait, the server's ops land under them
|
|
14
|
+
* and each keystroke is carried over what they typed (`Store.rebase`, with
|
|
15
|
+
* `@graview/core/typing` loaded), so what is sent is where the text now
|
|
16
|
+
* says it is.
|
|
17
|
+
*
|
|
18
|
+
* A run is one batch, sent as one `type-text` splice: the text as it was
|
|
19
|
+
* before the run against the text after it. It ends after 400 ms with no
|
|
20
|
+
* keystroke, when the caret jumps (a keystroke that does not touch the run),
|
|
21
|
+
* after a word (a space or a stop typed), or when the editor says so
|
|
22
|
+
* (`flush`, on a blur).
|
|
23
|
+
*/
|
|
24
|
+
/** What the typing of one field is handed of the remote store it types through. */
|
|
25
|
+
export interface TypingWire {
|
|
26
|
+
readonly store: Store<AnySchema>;
|
|
27
|
+
/** Applies calls here only — shown, not sent — in `batch` when given, else a new one. */
|
|
28
|
+
apply(calls: readonly MutationCall[], batch?: string): {
|
|
29
|
+
readonly batch: string;
|
|
30
|
+
readonly ops: readonly Operation[];
|
|
31
|
+
};
|
|
32
|
+
/** Holds a batch this client applied as its own and pending, until it is sent or let go. */
|
|
33
|
+
hold(batch: string): void;
|
|
34
|
+
/** What a held batch would be sent as, should it be carried to a new store (a reload, a new declaration). */
|
|
35
|
+
ask(batch: string, calls: readonly MutationCall[]): void;
|
|
36
|
+
/** Sends a held batch; resolves once the server answered it, either way. */
|
|
37
|
+
send(batch: string, calls: readonly MutationCall[]): Promise<unknown>;
|
|
38
|
+
/** Lets go of a held batch that came to change nothing: taken out here, and never sent. */
|
|
39
|
+
drop(batch: string): void;
|
|
40
|
+
/** The last of the server's ops this client has: the revision a run claims. */
|
|
41
|
+
seen(): number;
|
|
42
|
+
/** Whether the remote store has been closed or let go of. */
|
|
43
|
+
gone(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The answers to wait for before a run is sent: the batches of this
|
|
46
|
+
* client's pending ahead of it that changed the same field — an undo of
|
|
47
|
+
* an earlier run, a whole write. A run claims the revision the server's
|
|
48
|
+
* ops reach here, so it is sent only once what it was typed over is
|
|
49
|
+
* among them.
|
|
50
|
+
*/
|
|
51
|
+
ahead(batch: string, node: string, field: string): readonly {
|
|
52
|
+
readonly batch: string;
|
|
53
|
+
readonly answer: Promise<unknown>;
|
|
54
|
+
}[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* WHAT `openRemote` HANDS THE DOOR OF ITS INSIDES: its store and its own
|
|
58
|
+
* apply, the batches it holds pending and what each asked, and how it
|
|
59
|
+
* sends, settles and lands one. The wire is made of them here, so a page
|
|
60
|
+
* that never types carries none of it.
|
|
61
|
+
*/
|
|
62
|
+
export interface TypingInsides {
|
|
63
|
+
readonly store: Store<AnySchema>;
|
|
64
|
+
readonly author: Principal | undefined;
|
|
65
|
+
readonly appliedAll: (calls: readonly MutationCall[], options: {
|
|
66
|
+
author?: Principal;
|
|
67
|
+
batch?: string;
|
|
68
|
+
}) => {
|
|
69
|
+
readonly batch: string;
|
|
70
|
+
readonly ops: readonly Operation[];
|
|
71
|
+
};
|
|
72
|
+
readonly pending: string[];
|
|
73
|
+
readonly provisional: Set<string>;
|
|
74
|
+
readonly asked: Map<string, {
|
|
75
|
+
calls: readonly MutationCall[];
|
|
76
|
+
}>;
|
|
77
|
+
readonly answers: Map<string, Promise<unknown>>;
|
|
78
|
+
/** Batches let go of without ever being sent, so an undo of one is let go of too. */
|
|
79
|
+
readonly letGo: Set<string>;
|
|
80
|
+
/** Sends a batch, taken back if refused; resolves once answered either way. */
|
|
81
|
+
sent(batch: string, calls: readonly MutationCall[]): Promise<unknown>;
|
|
82
|
+
settle(batch: string): void;
|
|
83
|
+
land(ops: readonly Operation[], drop: readonly string[]): unknown;
|
|
84
|
+
seen(): number;
|
|
85
|
+
gone(): boolean;
|
|
86
|
+
}
|
|
87
|
+
/** The wire a field's typing runs on, made of a remote store's insides. */
|
|
88
|
+
export declare function wireOf(inside: TypingInsides): TypingWire;
|
|
89
|
+
/** Typing into one field of one record, as `remote.typing(node, field)` hands it to an editor. */
|
|
90
|
+
export interface RemoteTyping {
|
|
91
|
+
/**
|
|
92
|
+
* A keystroke, or several: at `at` (UTF-16 code units) in the field's
|
|
93
|
+
* text as the page shows it now, `remove` characters out and `insert` in.
|
|
94
|
+
* Shown at once; sent with the run it belongs to. Throws what the store
|
|
95
|
+
* refuses here, as `store.apply` would.
|
|
96
|
+
*/
|
|
97
|
+
splice(at: number, remove: number, insert: string): void;
|
|
98
|
+
/** Ends the run typed so far and sends it, or holds it behind the one on its way: a blur, Enter, a caret moved. */
|
|
99
|
+
flush(): void;
|
|
100
|
+
/** Runs typed and not yet answered by the server: the one on its way and the ones held behind it. */
|
|
101
|
+
waiting(): number;
|
|
102
|
+
}
|
|
103
|
+
/** How long a run waits for another keystroke before it is sent. */
|
|
104
|
+
export declare const TYPING_IDLE_MS = 400;
|
|
105
|
+
/**
|
|
106
|
+
* WHAT A RUN TYPED, AS ONE SPLICE: the field's text before its first
|
|
107
|
+
* keystroke against the text after its last, read by walking the log back
|
|
108
|
+
* from the field's text now. Whatever this client typed after the run (a
|
|
109
|
+
* later run, held) is walked back first, so the splice says the run alone.
|
|
110
|
+
* None when the run changed nothing, or is no longer in the log.
|
|
111
|
+
*/
|
|
112
|
+
export declare function runSplice(store: Store<AnySchema>, batch: string, node: string, field: string): TextSplice | undefined;
|
|
113
|
+
export declare function typingOf(node: string, field: string, wire: TypingWire): RemoteTyping;
|
|
114
|
+
/**
|
|
115
|
+
* A RUN OF TYPING THAT CONFLICTS — typed against text whose history the
|
|
116
|
+
* server no longer holds — as the person is offered it, read before it is
|
|
117
|
+
* taken back: the text this page showed, typing and all ("yours"), and the
|
|
118
|
+
* one keystroke that puts it over theirs whole, against the text the page
|
|
119
|
+
* holds once theirs stands. None for calls that are not typing.
|
|
120
|
+
*/
|
|
121
|
+
export declare function yoursOf(store: Store<AnySchema>, calls: readonly MutationCall[]): {
|
|
122
|
+
readonly node: string;
|
|
123
|
+
readonly field: string;
|
|
124
|
+
readonly yours: unknown;
|
|
125
|
+
over(seen: number): MutationCall;
|
|
126
|
+
} | undefined;
|
|
127
|
+
//# sourceMappingURL=remote-typing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-typing.d.ts","sourceRoot":"","sources":["../src/remote-typing.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhK;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,mFAAmF;AACnF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,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M,cAAc,MAAM,CAAC;AAMlC;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAiBrH;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,CA8EpF;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,GAAG,SAAS,CAezM"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// A door: tied to what the page drew first (TIED DOORS, packages/primitives/src/frame.ts) — `@graview/core`, which it reads text with.
|
|
2
|
+
import { applySplice, isUnset, TYPE_TEXT } from "@graview/core";
|
|
3
|
+
import { composeSplices, diffSplice } from "@graview/core/typing";
|
|
4
|
+
/** The wire a field's typing runs on, made of a remote store's insides. */
|
|
5
|
+
export function wireOf(inside) {
|
|
6
|
+
const { store, author, pending, provisional, asked } = inside;
|
|
7
|
+
/*
|
|
8
|
+
* A run is answered from the moment it is held, not only once it is sent:
|
|
9
|
+
* an undo of a run still held behind the one on its way waits for its
|
|
10
|
+
* answer (`answers`), so it never reaches the server before the run does.
|
|
11
|
+
*/
|
|
12
|
+
const answered = new Map();
|
|
13
|
+
const answer = (batch, value) => {
|
|
14
|
+
answered.get(batch)?.(value);
|
|
15
|
+
answered.delete(batch);
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
store,
|
|
19
|
+
apply: (calls, batch) => inside.appliedAll(calls, { ...(author ? { author } : {}), ...(batch !== undefined ? { batch } : {}) }),
|
|
20
|
+
hold(batch) {
|
|
21
|
+
pending.push(batch);
|
|
22
|
+
provisional.add(batch);
|
|
23
|
+
inside.answers.set(batch, new Promise((resolve) => answered.set(batch, resolve)));
|
|
24
|
+
},
|
|
25
|
+
ask: (batch, calls) => void asked.set(batch, { calls }),
|
|
26
|
+
send(batch, calls) {
|
|
27
|
+
asked.set(batch, { calls });
|
|
28
|
+
const sent = inside.sent(batch, calls);
|
|
29
|
+
const done = () => answer(batch, sent);
|
|
30
|
+
sent.then((said) => {
|
|
31
|
+
// Carried over what others deleted meanwhile, the run made nothing on the server: an undo of it has nothing to take back there either.
|
|
32
|
+
if (Array.isArray(said?.ops) && said.ops.length === 0)
|
|
33
|
+
inside.letGo.add(batch);
|
|
34
|
+
done();
|
|
35
|
+
}, done);
|
|
36
|
+
return sent;
|
|
37
|
+
},
|
|
38
|
+
drop(batch) {
|
|
39
|
+
inside.letGo.add(batch);
|
|
40
|
+
inside.settle(batch);
|
|
41
|
+
asked.delete(batch);
|
|
42
|
+
inside.land([], [batch]);
|
|
43
|
+
answer(batch);
|
|
44
|
+
},
|
|
45
|
+
seen: inside.seen,
|
|
46
|
+
gone: inside.gone,
|
|
47
|
+
ahead(batch, node, field) {
|
|
48
|
+
const at = pending.indexOf(batch);
|
|
49
|
+
const ops = store.log.all();
|
|
50
|
+
const touches = (one) => ops.some((op) => op.batch === one && op.primitives.some((p) => (p.op === "splice-text" && p.id === node && p.field === field) || (p.op === "patch-node" && p.id === node && field in p.after)));
|
|
51
|
+
return pending.slice(0, Math.max(0, at)).flatMap((one) => {
|
|
52
|
+
const answer = inside.answers.get(one);
|
|
53
|
+
return answer && touches(one) ? [{ batch: one, answer }] : [];
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** How long a run waits for another keystroke before it is sent. */
|
|
59
|
+
export const TYPING_IDLE_MS = 400;
|
|
60
|
+
/** A keystroke ending in one of these ends a word, and its run. */
|
|
61
|
+
const WORD_ENDS = /[\s.,;:!?)\]}]$/u;
|
|
62
|
+
const textOf = (value) => (typeof value === "string" ? value : "");
|
|
63
|
+
/**
|
|
64
|
+
* WHAT A RUN TYPED, AS ONE SPLICE: the field's text before its first
|
|
65
|
+
* keystroke against the text after its last, read by walking the log back
|
|
66
|
+
* from the field's text now. Whatever this client typed after the run (a
|
|
67
|
+
* later run, held) is walked back first, so the splice says the run alone.
|
|
68
|
+
* None when the run changed nothing, or is no longer in the log.
|
|
69
|
+
*/
|
|
70
|
+
export function runSplice(store, batch, node, field) {
|
|
71
|
+
const log = store.log.all();
|
|
72
|
+
const first = log.findIndex((op) => op.batch === batch);
|
|
73
|
+
if (first < 0)
|
|
74
|
+
return undefined;
|
|
75
|
+
let text = textOf(store.graph.getNode(node)?.[field]);
|
|
76
|
+
let after;
|
|
77
|
+
for (let at = log.length - 1; at >= first; at--) {
|
|
78
|
+
const op = log[at];
|
|
79
|
+
if (op.batch === batch && after === undefined)
|
|
80
|
+
after = text;
|
|
81
|
+
for (let index = op.primitives.length - 1; index >= 0; index--) {
|
|
82
|
+
const one = op.primitives[index];
|
|
83
|
+
if (one.op === "splice-text" && one.id === node && one.field === field)
|
|
84
|
+
text = applySplice(text, { at: one.at, removed: one.inserted, inserted: one.removed });
|
|
85
|
+
else if (one.op === "patch-node" && one.id === node && field in one.after)
|
|
86
|
+
text = isUnset(one.before[field]) ? "" : textOf(one.before[field]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (after === undefined || after === text)
|
|
90
|
+
return undefined;
|
|
91
|
+
return diffSplice(text, after);
|
|
92
|
+
}
|
|
93
|
+
export function typingOf(node, field, wire) {
|
|
94
|
+
/** The run being typed: its batch, shown and held, not yet ended. */
|
|
95
|
+
let open;
|
|
96
|
+
/** Runs ended and waiting for the one on its way. */
|
|
97
|
+
const queue = [];
|
|
98
|
+
/** The run on its way to the server. */
|
|
99
|
+
let flying;
|
|
100
|
+
let idle;
|
|
101
|
+
/** Waiting for the answer to a change of this client's to the field, made ahead of the next run (an undo, a whole write). */
|
|
102
|
+
let holding = false;
|
|
103
|
+
/** Those changes, once answered. */
|
|
104
|
+
const heard = new Set();
|
|
105
|
+
const callOf = (splice) => ({
|
|
106
|
+
name: TYPE_TEXT,
|
|
107
|
+
args: { node, field, at: splice.at, remove: splice.removed.length, insert: splice.inserted, rev: wire.seen() },
|
|
108
|
+
});
|
|
109
|
+
const end = () => {
|
|
110
|
+
if (idle)
|
|
111
|
+
clearTimeout(idle);
|
|
112
|
+
idle = undefined;
|
|
113
|
+
if (open !== undefined)
|
|
114
|
+
queue.push(open);
|
|
115
|
+
open = undefined;
|
|
116
|
+
pump();
|
|
117
|
+
};
|
|
118
|
+
/** The next run, once nothing of this field's is on its way: one at a time, so the server only carries it over other people's typing. */
|
|
119
|
+
const pump = () => {
|
|
120
|
+
if (flying !== undefined || holding || wire.gone())
|
|
121
|
+
return;
|
|
122
|
+
const batch = queue.shift();
|
|
123
|
+
if (batch === undefined)
|
|
124
|
+
return;
|
|
125
|
+
const waits = wire.ahead(batch, node, field).filter((one) => !heard.has(one.batch));
|
|
126
|
+
if (waits.length > 0) {
|
|
127
|
+
queue.unshift(batch);
|
|
128
|
+
holding = true;
|
|
129
|
+
void Promise.allSettled(waits.map((one) => one.answer)).then(() => {
|
|
130
|
+
for (const one of waits)
|
|
131
|
+
heard.add(one.batch);
|
|
132
|
+
holding = false;
|
|
133
|
+
pump();
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const splice = runSplice(wire.store, batch, node, field);
|
|
138
|
+
if (!splice) {
|
|
139
|
+
wire.drop(batch);
|
|
140
|
+
return pump();
|
|
141
|
+
}
|
|
142
|
+
flying = batch;
|
|
143
|
+
void wire.send(batch, [callOf(splice)]).finally(() => {
|
|
144
|
+
flying = undefined;
|
|
145
|
+
pump();
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
splice(at, remove, insert) {
|
|
150
|
+
if (wire.gone())
|
|
151
|
+
return;
|
|
152
|
+
const text = textOf(wire.store.graph.getNode(node)?.[field]);
|
|
153
|
+
const keystroke = { at, removed: text.slice(at, at + remove), inserted: insert };
|
|
154
|
+
// A keystroke that does not touch the run is the caret moved: the run ends there.
|
|
155
|
+
if (open !== undefined) {
|
|
156
|
+
const run = runSplice(wire.store, open, node, field);
|
|
157
|
+
if (!run || !composeSplices(run, keystroke))
|
|
158
|
+
end();
|
|
159
|
+
}
|
|
160
|
+
const made = wire.apply([{ name: TYPE_TEXT, args: { node, field, at, remove, insert } }], open);
|
|
161
|
+
if (made.ops.length === 0)
|
|
162
|
+
return;
|
|
163
|
+
if (open === undefined) {
|
|
164
|
+
open = made.batch;
|
|
165
|
+
wire.hold(open);
|
|
166
|
+
}
|
|
167
|
+
const run = runSplice(wire.store, open, node, field);
|
|
168
|
+
if (run)
|
|
169
|
+
wire.ask(open, [callOf(run)]);
|
|
170
|
+
if (WORD_ENDS.test(insert))
|
|
171
|
+
return end();
|
|
172
|
+
if (idle)
|
|
173
|
+
clearTimeout(idle);
|
|
174
|
+
idle = setTimeout(end, TYPING_IDLE_MS);
|
|
175
|
+
idle.unref?.();
|
|
176
|
+
},
|
|
177
|
+
flush: end,
|
|
178
|
+
waiting: () => queue.length + (open !== undefined ? 1 : 0) + (flying !== undefined ? 1 : 0),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A RUN OF TYPING THAT CONFLICTS — typed against text whose history the
|
|
183
|
+
* server no longer holds — as the person is offered it, read before it is
|
|
184
|
+
* taken back: the text this page showed, typing and all ("yours"), and the
|
|
185
|
+
* one keystroke that puts it over theirs whole, against the text the page
|
|
186
|
+
* holds once theirs stands. None for calls that are not typing.
|
|
187
|
+
*/
|
|
188
|
+
export function yoursOf(store, calls) {
|
|
189
|
+
const typed = calls.find((one) => one.name === TYPE_TEXT)?.args;
|
|
190
|
+
if (typeof typed?.node !== "string" || typeof typed.field !== "string")
|
|
191
|
+
return undefined;
|
|
192
|
+
const { node, field } = typed;
|
|
193
|
+
const textOf = () => store.graph.getNode(node)?.[field];
|
|
194
|
+
const yours = textOf();
|
|
195
|
+
return {
|
|
196
|
+
node,
|
|
197
|
+
field,
|
|
198
|
+
yours,
|
|
199
|
+
over: (seen) => {
|
|
200
|
+
const theirs = textOf();
|
|
201
|
+
return { name: TYPE_TEXT, args: { node, field, at: 0, remove: typeof theirs === "string" ? theirs.length : 0, insert: typeof yours === "string" ? yours : "", rev: seen } };
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=remote-typing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-typing.js","sourceRoot":"","sources":["../src/remote-typing.ts"],"names":[],"mappings":"AAAA,uIAAuI;AACvI,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAkG,MAAM,eAAe,CAAC;AAChK,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AA4ElE,2EAA2E;AAC3E,MAAM,UAAU,MAAM,CAAC,MAAqB;IAC1C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAC9D;;;;OAIG;IACH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoC,CAAC;IAC7D,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,KAAe,EAAE,EAAE;QAChD,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAC7B,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO;QACL,KAAK;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,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AC"}
|
package/dist/remote.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Store, type AnySchema, type FieldConflict, type GraviewApp, type MutationCall, type Operation, type Presence, type PresenceChannel, type Principal, type Via, type WireRefusal } from "@graview/core";
|
|
2
2
|
import type { StorageLike } from "./browser-adapter.js";
|
|
3
|
+
import type { RemoteTyping } from "./remote-typing.js";
|
|
3
4
|
import type { GraphSnapshot } from "./snapshot.js";
|
|
4
5
|
/**
|
|
5
6
|
* THE OTHER END OF THE WIRE: a store whose graph lives on a server.
|
|
@@ -351,6 +352,17 @@ export interface RemoteStore<S extends AnySchema> {
|
|
|
351
352
|
* was noticed is told at once. The client keeps working.
|
|
352
353
|
*/
|
|
353
354
|
onBuild(listener: (build: string) => void): () => void;
|
|
355
|
+
/**
|
|
356
|
+
* TYPING INTO A FIELD TYPED TOGETHER (Roadmap f-collab-text, phase 3):
|
|
357
|
+
* what an editor calls a keystroke at a time. Each is shown at once; a
|
|
358
|
+
* run of them goes to the server as one `type-text`, at most one run per
|
|
359
|
+
* field on its way, the rest held and carried over what others type
|
|
360
|
+
* until it is their turn — so two people typing into one text converge
|
|
361
|
+
* character for character. Loads `@graview/core/typing` the first time,
|
|
362
|
+
* so a page carries none of it until somebody types. One per field: asked
|
|
363
|
+
* again, the same one.
|
|
364
|
+
*/
|
|
365
|
+
typing(node: string, field: string): Promise<RemoteTyping>;
|
|
354
366
|
close(): void;
|
|
355
367
|
}
|
|
356
368
|
/** A refusal as the client is told it: the reason, the sentence and who could (FR-46). */
|
package/dist/remote.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,EAML,KAAK,SAAS,EACd,KAAK,aAA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