@vscode/web-editors 0.0.2-113 → 0.0.2-115
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/dist/index.d.ts +288 -10
- package/dist/index.js +935 -60
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/dist/index.d.ts
CHANGED
|
@@ -2140,10 +2140,17 @@ interface ZodReadonly<T extends SomeType = $ZodType> extends _ZodType<$ZodReadon
|
|
|
2140
2140
|
declare const ZodReadonly: $constructor<ZodReadonly>;
|
|
2141
2141
|
//#endregion
|
|
2142
2142
|
//#region src/protocol.d.ts
|
|
2143
|
+
/**
|
|
2144
|
+
* The concurrency control both sides use when they announce it: concurrent
|
|
2145
|
+
* edits are transformed against each other instead of one side's being
|
|
2146
|
+
* dropped. See `OtPeer`.
|
|
2147
|
+
*/
|
|
2148
|
+
declare const OT_EDIT_TRANSFORM = "ot/1";
|
|
2143
2149
|
declare const zEditorCapabilities: ZodObject<{
|
|
2144
2150
|
supportsContentEdits: ZodOptional<ZodBoolean>;
|
|
2145
2151
|
supportsOptions: ZodOptional<ZodBoolean>;
|
|
2146
2152
|
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2153
|
+
editTransforms: ZodOptional<ZodArray<ZodString>>;
|
|
2147
2154
|
}, $strip>;
|
|
2148
2155
|
declare const zHostCapabilities: ZodObject<{
|
|
2149
2156
|
supportsContentEdits: ZodOptional<ZodBoolean>;
|
|
@@ -2151,6 +2158,7 @@ declare const zHostCapabilities: ZodObject<{
|
|
|
2151
2158
|
supportsForceUpdate: ZodOptional<ZodBoolean>;
|
|
2152
2159
|
supportsHostTransport: ZodOptional<ZodBoolean>;
|
|
2153
2160
|
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2161
|
+
editTransform: ZodOptional<ZodString>;
|
|
2154
2162
|
}, $strip>;
|
|
2155
2163
|
declare const zTextEdit: ZodObject<{
|
|
2156
2164
|
offset: ZodNumber;
|
|
@@ -2177,6 +2185,7 @@ declare const zWebEditorUpdate: ZodObject<{
|
|
|
2177
2185
|
serverRevision: ZodOptional<ZodNumber>;
|
|
2178
2186
|
acknowledgedClientRevision: ZodOptional<ZodNumber>;
|
|
2179
2187
|
force: ZodOptional<ZodBoolean>;
|
|
2188
|
+
editTransform: ZodOptional<ZodString>;
|
|
2180
2189
|
}, $strip>;
|
|
2181
2190
|
/** How an embedding host currently presents the editor. */
|
|
2182
2191
|
declare const zPresentationMode: ZodEnum<{
|
|
@@ -2203,6 +2212,16 @@ type WebEditorUpdate = output<typeof zWebEditorUpdate>;
|
|
|
2203
2212
|
type PresentationMode = output<typeof zPresentationMode>;
|
|
2204
2213
|
type PresentationPreferences = output<typeof zPresentationPreferences>;
|
|
2205
2214
|
type ContentType = "text" | "json";
|
|
2215
|
+
/**
|
|
2216
|
+
* Identifies a state of the content that the host and the editor share: the
|
|
2217
|
+
* host's and the editor's edits integrated into it. Send it along with
|
|
2218
|
+
* offsets into the content, so that the other side can map them into its
|
|
2219
|
+
* current content (`mapOffset` on `WebEditorHost` and `WebEditorClient`).
|
|
2220
|
+
*/
|
|
2221
|
+
interface ContentVersion {
|
|
2222
|
+
readonly serverRevision: number;
|
|
2223
|
+
readonly clientRevision: number;
|
|
2224
|
+
}
|
|
2206
2225
|
declare const webEditorHostInterface: any;
|
|
2207
2226
|
declare const webEditorInterface: any;
|
|
2208
2227
|
declare const webEditorHostTransportInterface: any;
|
|
@@ -2359,8 +2378,12 @@ interface WebEditorHostOptions {
|
|
|
2359
2378
|
* Host-side façade for the web-editor v0.12 protocol.
|
|
2360
2379
|
*
|
|
2361
2380
|
* Owns the canonical text content. Translates between text/JSON form and the
|
|
2362
|
-
* structural edits exchanged with the editor.
|
|
2363
|
-
*
|
|
2381
|
+
* structural edits exchanged with the editor.
|
|
2382
|
+
*
|
|
2383
|
+
* Concurrent edits from both sides are merged with operational transformation
|
|
2384
|
+
* when the editor supports it ({@link OT_EDIT_TRANSFORM}). Otherwise the host
|
|
2385
|
+
* maintains the revision pair required by the client-authority conflict
|
|
2386
|
+
* policy, under which conflicting edits are dropped.
|
|
2364
2387
|
*/
|
|
2365
2388
|
declare class WebEditorHost implements IDisposable {
|
|
2366
2389
|
private readonly _connection;
|
|
@@ -2375,14 +2398,20 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2375
2398
|
private _text;
|
|
2376
2399
|
private _readOnly;
|
|
2377
2400
|
private _presentationMode;
|
|
2401
|
+
/** Set while connected to an editor that merges concurrent edits. */
|
|
2402
|
+
private _transform;
|
|
2403
|
+
/** Client-authority policy only. */
|
|
2378
2404
|
private _serverRevision;
|
|
2405
|
+
/** Client-authority policy only. */
|
|
2379
2406
|
private _acknowledgedClientRevision;
|
|
2380
2407
|
private _editorInitialized;
|
|
2381
2408
|
private _editorCapabilities;
|
|
2382
2409
|
private readonly _pendingHostTransportMessages;
|
|
2383
2410
|
private readonly _onDidChangeText;
|
|
2411
|
+
/** The editor changed the content. `edits` apply to the previous content, in the editor's form. */
|
|
2384
2412
|
readonly onDidChangeText: Event<{
|
|
2385
2413
|
text: string;
|
|
2414
|
+
edits: readonly ContentEdit[];
|
|
2386
2415
|
}>;
|
|
2387
2416
|
private readonly _onDidInitialize;
|
|
2388
2417
|
readonly onDidInitialize: Event<{
|
|
@@ -2401,9 +2430,24 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2401
2430
|
constructor(options: WebEditorHostOptions);
|
|
2402
2431
|
/** The text the host believes the document currently holds. */
|
|
2403
2432
|
getText(): string;
|
|
2433
|
+
/** The current content's version, to send along with offsets into it. */
|
|
2434
|
+
get version(): ContentVersion;
|
|
2404
2435
|
/**
|
|
2405
|
-
*
|
|
2406
|
-
*
|
|
2436
|
+
* Maps an offset into the string at `path`, which the editor computed on
|
|
2437
|
+
* its content at `version`, into the current content. Call it when the
|
|
2438
|
+
* editor's message arrives: its earlier edits are integrated by then.
|
|
2439
|
+
*
|
|
2440
|
+
* @returns `undefined` if the offset cannot be mapped, for example because
|
|
2441
|
+
* the string was replaced or the content was reset since.
|
|
2442
|
+
*/
|
|
2443
|
+
mapOffset(version: ContentVersion, path: readonly string[], offset: number, assoc?: "before" | "after"): number | undefined;
|
|
2444
|
+
/**
|
|
2445
|
+
* Change the text the editor shows.
|
|
2446
|
+
*
|
|
2447
|
+
* When the editor merges concurrent edits, the change is sent as edits
|
|
2448
|
+
* that merge with the editor's unsent edits. Otherwise, and with `force`,
|
|
2449
|
+
* the full text is sent. If `force`, the editor must adopt it even with
|
|
2450
|
+
* pending local edits, which are then discarded.
|
|
2407
2451
|
*/
|
|
2408
2452
|
setText(text: string, opts?: {
|
|
2409
2453
|
force?: boolean;
|
|
@@ -2422,12 +2466,23 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2422
2466
|
setPresentationMode(mode: PresentationMode): void;
|
|
2423
2467
|
setReadOnly(readOnly: boolean): void;
|
|
2424
2468
|
/**
|
|
2425
|
-
*
|
|
2426
|
-
*
|
|
2469
|
+
* Change the text by fine-grained edits, which are pushed to the editor.
|
|
2470
|
+
* An editor that initializes later receives the changed text.
|
|
2427
2471
|
*/
|
|
2428
2472
|
applyEdits(edits: readonly ContentEdit[]): void;
|
|
2429
2473
|
dispose(): void;
|
|
2474
|
+
private _applyTransformedEditorEdit;
|
|
2475
|
+
/** The text after the editor's `edits`, or `undefined` after reporting why they do not apply. */
|
|
2476
|
+
private _applyEditorEdits;
|
|
2477
|
+
/** Edits from `oldText` to `newText` in the editor's form, or `undefined` if either cannot be encoded. */
|
|
2478
|
+
private _diff;
|
|
2479
|
+
private _sendHostEdits;
|
|
2430
2480
|
private _pushFullUpdate;
|
|
2481
|
+
/**
|
|
2482
|
+
* Sends the full content, which replaces the editor's. Editor edits made
|
|
2483
|
+
* before the editor receives it are discarded on both sides.
|
|
2484
|
+
*/
|
|
2485
|
+
private _resetEditor;
|
|
2431
2486
|
private _pushAcknowledgement;
|
|
2432
2487
|
private _pushPresentationMode;
|
|
2433
2488
|
private _acknowledgeAndRestore;
|
|
@@ -2526,6 +2581,11 @@ interface WebEditorClientState {
|
|
|
2526
2581
|
* Calls `host.initialized` immediately, then exposes the current content and
|
|
2527
2582
|
* read-only flag as observable events. Local edits made through {@link applyEdits}
|
|
2528
2583
|
* are sent to the host with monotonically increasing client revisions.
|
|
2584
|
+
*
|
|
2585
|
+
* When the host supports it ({@link OT_EDIT_TRANSFORM}), host edits that
|
|
2586
|
+
* arrive while local edits are unacknowledged are transformed against them,
|
|
2587
|
+
* so neither side's edits are lost. Otherwise such host changes are dropped
|
|
2588
|
+
* (client-authority policy).
|
|
2529
2589
|
*/
|
|
2530
2590
|
declare class WebEditorClient implements IDisposable {
|
|
2531
2591
|
private readonly _connection;
|
|
@@ -2543,16 +2603,24 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2543
2603
|
private _presentationPreferences;
|
|
2544
2604
|
private readonly _pendingHostTransportMessages;
|
|
2545
2605
|
private _hostTransportActivated;
|
|
2546
|
-
|
|
2606
|
+
/** Local edits and their revisions; its pending edits are those the host has not acknowledged. */
|
|
2607
|
+
private readonly _edits;
|
|
2608
|
+
/** Whether the host transforms concurrent edits, as announced with its first content. */
|
|
2609
|
+
private _transform;
|
|
2610
|
+
/** Client-authority policy only. */
|
|
2547
2611
|
private _basedOnServerRevision;
|
|
2548
|
-
/** Number of un-acked local revisions. While > 0 the editor has pending edits. */
|
|
2549
|
-
private _pendingLocalEdits;
|
|
2550
2612
|
private readonly _onDidChangeContent;
|
|
2613
|
+
/**
|
|
2614
|
+
* The content changed: by a local edit, by host edits (after
|
|
2615
|
+
* {@link onDidApplyHostEdits}) or replaced by the host. Listeners must
|
|
2616
|
+
* tolerate content they already show.
|
|
2617
|
+
*/
|
|
2551
2618
|
readonly onDidChangeContent: Event<{
|
|
2552
2619
|
content: JsonValue;
|
|
2553
2620
|
force: boolean;
|
|
2554
2621
|
}>;
|
|
2555
2622
|
private readonly _onDidApplyHostEdits;
|
|
2623
|
+
/** Host edits were applied; `edits` are relative to the previous content, after transformation against local edits. */
|
|
2556
2624
|
readonly onDidApplyHostEdits: Event<{
|
|
2557
2625
|
edits: ContentEdit[];
|
|
2558
2626
|
content: JsonValue;
|
|
@@ -2586,6 +2654,19 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2586
2654
|
/** Optional notification transport supplied by the web editor host. */
|
|
2587
2655
|
get hostTransport(): HostTransport | undefined;
|
|
2588
2656
|
getContent(): JsonValue;
|
|
2657
|
+
/** The current content's version, to send along with offsets into it. */
|
|
2658
|
+
get version(): ContentVersion;
|
|
2659
|
+
/**
|
|
2660
|
+
* Maps an offset into the string at `path`, which the host computed on its
|
|
2661
|
+
* content at `version`, into the current content. Call it when the host's
|
|
2662
|
+
* message arrives.
|
|
2663
|
+
*
|
|
2664
|
+
* @returns `undefined` if the offset cannot be mapped, for example because
|
|
2665
|
+
* host edits arrived since or the string was replaced.
|
|
2666
|
+
*/
|
|
2667
|
+
mapOffset(version: ContentVersion, path: readonly string[], offset: number, assoc?: "before" | "after"): number | undefined;
|
|
2668
|
+
/** The host revision the content is based on. */
|
|
2669
|
+
private get _serverRevision();
|
|
2589
2670
|
getReadOnly(): boolean;
|
|
2590
2671
|
getOptions(): JsonValue;
|
|
2591
2672
|
getHostCapabilities(): HostCapabilities | undefined;
|
|
@@ -2616,6 +2697,7 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2616
2697
|
dispose(): void;
|
|
2617
2698
|
private _handleUpdate;
|
|
2618
2699
|
private _handleApplyContentEdits;
|
|
2700
|
+
private _applyTransformedHostEdits;
|
|
2619
2701
|
private _acknowledge;
|
|
2620
2702
|
}
|
|
2621
2703
|
//#endregion
|
|
@@ -2766,5 +2848,201 @@ declare class VsCodeAppHostClient {
|
|
|
2766
2848
|
setViewState(value: unknown): Promise<void>;
|
|
2767
2849
|
}
|
|
2768
2850
|
//#endregion
|
|
2769
|
-
|
|
2851
|
+
//#region src/sync/otPeer.d.ts
|
|
2852
|
+
/**
|
|
2853
|
+
* How to transform two concurrent operations of type `TOp`.
|
|
2854
|
+
*
|
|
2855
|
+
* `transform(winner, loser)` returns `[winner', loser']` such that applying
|
|
2856
|
+
* `loser` then `winner'` gives the same state as applying `winner` then
|
|
2857
|
+
* `loser'`. Where both conflict, `winner` takes precedence.
|
|
2858
|
+
*/
|
|
2859
|
+
interface OtType<TOp> {
|
|
2860
|
+
transform(winner: TOp, loser: TOp): readonly [TOp, TOp];
|
|
2861
|
+
}
|
|
2862
|
+
/**
|
|
2863
|
+
* One of the two sides of a session that keeps a document in sync between
|
|
2864
|
+
* two parties who both edit it (the Jupiter algorithm behind most operational
|
|
2865
|
+
* transformation systems).
|
|
2866
|
+
*
|
|
2867
|
+
* Each side applies its own operations immediately and sends them along with
|
|
2868
|
+
* how many of the other side's operations it had applied. When an operation
|
|
2869
|
+
* from the other side arrives, it was made without the local operations the
|
|
2870
|
+
* other side had not seen yet. Those pending operations and the incoming one
|
|
2871
|
+
* are transformed against each other: the incoming one is then applied, and
|
|
2872
|
+
* the pending ones now describe how the local state differs from the other
|
|
2873
|
+
* side's. Once both sides have received everything, they hold the same
|
|
2874
|
+
* document, and no operation was dropped.
|
|
2875
|
+
*
|
|
2876
|
+
* The leader's operations take precedence in conflicts. Exactly one side must
|
|
2877
|
+
* be the leader. Messages must arrive in the order they were sent.
|
|
2878
|
+
*
|
|
2879
|
+
* The leader can also start over from a state it sends in full ({@link reset});
|
|
2880
|
+
* the follower's operations that were made before it received that state are
|
|
2881
|
+
* then discarded on both sides.
|
|
2882
|
+
*/
|
|
2883
|
+
declare class OtPeer<TOp> {
|
|
2884
|
+
private readonly _type;
|
|
2885
|
+
readonly role: "leader" | "follower";
|
|
2886
|
+
private _localRevision;
|
|
2887
|
+
private _remoteRevision;
|
|
2888
|
+
private _pending;
|
|
2889
|
+
/** Remote operations made before the remote side saw this local revision are discarded. */
|
|
2890
|
+
private _barrier;
|
|
2891
|
+
constructor(_type: OtType<TOp>, role: "leader" | "follower");
|
|
2892
|
+
/** Number of local operations, including resets. */
|
|
2893
|
+
get localRevision(): number;
|
|
2894
|
+
/** Number of remote operations integrated, including discarded ones. */
|
|
2895
|
+
get remoteRevision(): number;
|
|
2896
|
+
/** Local operations the remote side has not acknowledged yet, oldest first. */
|
|
2897
|
+
get pending(): readonly TOp[];
|
|
2898
|
+
/**
|
|
2899
|
+
* The local operations after `revision`, oldest first: how the local state
|
|
2900
|
+
* differs from the state the remote side had when it had integrated
|
|
2901
|
+
* `revision` and everything local before. `undefined` if they are no
|
|
2902
|
+
* longer known, because they were acknowledged since or a reset happened.
|
|
2903
|
+
*/
|
|
2904
|
+
operationsAfter(revision: number): readonly TOp[] | undefined;
|
|
2905
|
+
/**
|
|
2906
|
+
* Records an operation already applied to the local state. Send it with
|
|
2907
|
+
* the returned revision and {@link remoteRevision} as the acknowledgement.
|
|
2908
|
+
*/
|
|
2909
|
+
local(op: TOp): number;
|
|
2910
|
+
/**
|
|
2911
|
+
* Integrates an operation from the remote side.
|
|
2912
|
+
*
|
|
2913
|
+
* @param revision The remote side's revision after `op`.
|
|
2914
|
+
* @param acknowledgedRevision How many local operations the remote side had integrated when it made `op`.
|
|
2915
|
+
* @returns The operation to apply to the local state, or `undefined` if
|
|
2916
|
+
* `op` was made before the remote side received the latest reset.
|
|
2917
|
+
*/
|
|
2918
|
+
remote(op: TOp, revision: number, acknowledgedRevision: number): TOp | undefined;
|
|
2919
|
+
/** The remote side has integrated all local operations up to `revision`. */
|
|
2920
|
+
acknowledge(revision: number): void;
|
|
2921
|
+
/**
|
|
2922
|
+
* Leader only: the local state is about to be sent in full and replaces
|
|
2923
|
+
* whatever the follower has. Returns the revision of the reset.
|
|
2924
|
+
*
|
|
2925
|
+
* @param remoteRevision Treat remote operations up to this revision as
|
|
2926
|
+
* integrated, to recover when the remote side's revisions got out of step.
|
|
2927
|
+
*/
|
|
2928
|
+
reset(remoteRevision?: number): number;
|
|
2929
|
+
/**
|
|
2930
|
+
* Follower only: replaces the local state with the leader's full state at
|
|
2931
|
+
* `revision`. Pending local operations are discarded, as the leader
|
|
2932
|
+
* discards them too.
|
|
2933
|
+
*/
|
|
2934
|
+
acceptReset(revision: number): void;
|
|
2935
|
+
}
|
|
2936
|
+
//#endregion
|
|
2937
|
+
//#region src/sync/textOperation.d.ts
|
|
2938
|
+
/** {@link OtType} for {@link TextOperation}s. */
|
|
2939
|
+
declare const textOperationOt: OtType<TextOperation>;
|
|
2940
|
+
/**
|
|
2941
|
+
* A change to a string, as a sequence of components that walk the original
|
|
2942
|
+
* string from start to end: keep (`retain`), add (`insert`) or remove
|
|
2943
|
+
* (`delete`) text. Everything after the last component is kept.
|
|
2944
|
+
*
|
|
2945
|
+
* Operations are normalized (see {@link TextOperationBuilder}), so equal
|
|
2946
|
+
* changes have equal components. Their size depends on the number of edited
|
|
2947
|
+
* regions, not on the length of the string.
|
|
2948
|
+
*/
|
|
2949
|
+
declare class TextOperation {
|
|
2950
|
+
readonly components: readonly TextComponent[];
|
|
2951
|
+
static get identity(): TextOperation;
|
|
2952
|
+
/** Converts edits that apply one after another, as on the wire, into one operation. */
|
|
2953
|
+
static fromTextEdits(edits: readonly TextEdit[]): TextOperation;
|
|
2954
|
+
/** Use {@link TextOperationBuilder}, which normalizes the components. */
|
|
2955
|
+
constructor(token: typeof normalizedToken, components: readonly TextComponent[]);
|
|
2956
|
+
get isIdentity(): boolean;
|
|
2957
|
+
/** Length of the shortest string this operation applies to. */
|
|
2958
|
+
get baseSpan(): number;
|
|
2959
|
+
apply(text: string): string;
|
|
2960
|
+
/** Edits in ascending order that, applied one after another, have the effect of this operation. */
|
|
2961
|
+
toTextEdits(): TextEdit[];
|
|
2962
|
+
/** The operation that has the effect of this operation followed by `next`. */
|
|
2963
|
+
compose(next: TextOperation): TextOperation;
|
|
2964
|
+
/**
|
|
2965
|
+
* Transforms two operations on the same string so that each applies after
|
|
2966
|
+
* the other and both orders give the same result (`b'(a(s)) === a'(b(s))`).
|
|
2967
|
+
* Where both insert at the same position, `winner`'s text comes first.
|
|
2968
|
+
*
|
|
2969
|
+
* @returns `[winner', loser']`: `winner'` applies after `loser`, `loser'` after `winner`.
|
|
2970
|
+
*/
|
|
2971
|
+
static transform(winner: TextOperation, loser: TextOperation): [TextOperation, TextOperation];
|
|
2972
|
+
/**
|
|
2973
|
+
* Where `offset` in the original string ends up after this operation.
|
|
2974
|
+
* An offset inside deleted text maps to where the deletion happened. Text
|
|
2975
|
+
* inserted exactly at `offset` ends up before the result for
|
|
2976
|
+
* `assoc === "after"` and after it for `assoc === "before"`.
|
|
2977
|
+
*/
|
|
2978
|
+
mapOffset(offset: number, assoc?: "before" | "after"): number;
|
|
2979
|
+
equals(other: TextOperation): boolean;
|
|
2980
|
+
toString(): string;
|
|
2981
|
+
}
|
|
2982
|
+
type TextComponent = {
|
|
2983
|
+
readonly kind: "retain";
|
|
2984
|
+
readonly length: number;
|
|
2985
|
+
} | {
|
|
2986
|
+
readonly kind: "insert";
|
|
2987
|
+
readonly text: string;
|
|
2988
|
+
} | {
|
|
2989
|
+
readonly kind: "delete";
|
|
2990
|
+
readonly length: number;
|
|
2991
|
+
};
|
|
2992
|
+
declare const normalizedToken: unique symbol;
|
|
2993
|
+
/**
|
|
2994
|
+
* Builds normalized {@link TextOperation}s: no empty components, adjacent
|
|
2995
|
+
* components of the same kind merged, an insert before a delete at the same
|
|
2996
|
+
* position, and no trailing retain.
|
|
2997
|
+
*/
|
|
2998
|
+
declare class TextOperationBuilder {
|
|
2999
|
+
private readonly _components;
|
|
3000
|
+
retain(length: number): this;
|
|
3001
|
+
insert(text: string): this;
|
|
3002
|
+
delete(length: number): this;
|
|
3003
|
+
build(): TextOperation;
|
|
3004
|
+
}
|
|
3005
|
+
//#endregion
|
|
3006
|
+
//#region src/sync/textDiff.d.ts
|
|
3007
|
+
/**
|
|
3008
|
+
* A minimal operation that turns `oldText` into `newText`, so that unchanged
|
|
3009
|
+
* text in between separate changes is kept (and concurrent edits there keep
|
|
3010
|
+
* their place). Uses Myers' O(ND) algorithm on the part between the common
|
|
3011
|
+
* prefix and suffix; when the texts differ in more than `maxDistance`
|
|
3012
|
+
* characters, everything in between is replaced instead.
|
|
3013
|
+
*/
|
|
3014
|
+
declare function diffText(oldText: string, newText: string, maxDistance?: number): TextOperation;
|
|
3015
|
+
//#endregion
|
|
3016
|
+
//#region src/sync/contentOperation.d.ts
|
|
3017
|
+
/** {@link OtType} for lists of {@link ContentEdit}s, as exchanged by web editors. */
|
|
3018
|
+
declare const contentEditsOt: OtType<readonly ContentEdit[]>;
|
|
3019
|
+
/**
|
|
3020
|
+
* Transforms two concurrent lists of {@link ContentEdit}s made on the same
|
|
3021
|
+
* content, so that each list applies after the other and both orders give the
|
|
3022
|
+
* same content.
|
|
3023
|
+
*
|
|
3024
|
+
* Edits at unrelated paths do not interact. String edits at the same path are
|
|
3025
|
+
* merged with {@link TextOperation.transform}. A `replace` overrides every
|
|
3026
|
+
* concurrent edit at or below its path; of two replacements at the same path,
|
|
3027
|
+
* `winner`'s is kept.
|
|
3028
|
+
*
|
|
3029
|
+
* @returns `[winner', loser']`: `winner'` applies after `loser`, `loser'` after `winner`.
|
|
3030
|
+
*/
|
|
3031
|
+
declare function transformContentEdits(winner: readonly ContentEdit[], loser: readonly ContentEdit[]): [ContentEdit[], ContentEdit[]];
|
|
3032
|
+
/**
|
|
3033
|
+
* Where `offset` in the string at `path` ends up after `edits`, or `undefined`
|
|
3034
|
+
* if the string was replaced. See {@link TextOperation.mapOffset} for `assoc`.
|
|
3035
|
+
*/
|
|
3036
|
+
declare function mapContentOffset(edits: readonly ContentEdit[], path: readonly string[], offset: number, assoc?: "before" | "after"): number | undefined;
|
|
3037
|
+
/** Maps `offset` through each list of edits in turn; `undefined` if `operations` is `undefined` or the offset does not survive an edit. */
|
|
3038
|
+
declare function mapThrough(operations: readonly (readonly ContentEdit[])[] | undefined, path: readonly string[], offset: number, assoc?: "before" | "after"): number | undefined;
|
|
3039
|
+
/**
|
|
3040
|
+
* Edits that turn `oldValue` into `newValue`, as fine-grained as possible so
|
|
3041
|
+
* that they merge with concurrent edits: changed strings become string edits,
|
|
3042
|
+
* objects with the same keys and arrays with the same length are compared
|
|
3043
|
+
* member by member, and anything else is replaced.
|
|
3044
|
+
*/
|
|
3045
|
+
declare function diffContent(oldValue: JsonValue, newValue: JsonValue, path?: string[]): ContentEdit[];
|
|
3046
|
+
//#endregion
|
|
3047
|
+
export { AppContext, type ConnectionInput, ContentEdit, ContentType, ContentVersion, EditorAssociationResult, EditorCapabilities, EditorRegistrationStatus, EditorScope, EmbeddedAppAccessOptions, EmbeddedAppDescriptor, EmbeddedAppHandle, EmbeddingContext, type Event, HostCapabilities, HostTransport, type IDisposable, JsonFormatOptions, JsonValue, type MessageEndpoint, type MessageLikeEvent, OT_EDIT_TRANSFORM, OtPeer, OtType, PresentationMode, PresentationPreferences, ScopeRegistration, TextComponent, TextEdit, TextOperation, TextOperationBuilder, VsCodeAppEmbeddingEventsProxy, VsCodeAppHostClient, VsCodeAppHostClientOptions, VsCodeAppHostProxy, WebEditorClient, WebEditorClientOptions, WebEditorClientState, WebEditorClientTransportProxy, WebEditorHost, WebEditorHostOptions, WebEditorHostProxy, WebEditorHostTransportProxy, WebEditorPresentationHostProxy, WebEditorPresentationProxy, WebEditorProxy, WebEditorUpdate, WindowMessageTransport, applyContentEdits, applyTextEdits, contentEditsOt, createWindowParentConnection, decodeFromEditor, diffContent, diffText, encodeForEditor, mapContentOffset, mapThrough, textOperationOt, transformContentEdits, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface, webEditorPresentationHostInterface, webEditorPresentationInterface };
|
|
2770
3048
|
//# sourceMappingURL=index.d.ts.map
|