@vscode/web-editors 0.0.2-12 → 0.0.2-121
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 +398 -12
- package/dist/index.js +1074 -68
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/dist/index.d.ts
CHANGED
|
@@ -2140,14 +2140,25 @@ 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>;
|
|
2152
|
+
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2153
|
+
editTransforms: ZodOptional<ZodArray<ZodString>>;
|
|
2146
2154
|
}, $strip>;
|
|
2147
2155
|
declare const zHostCapabilities: ZodObject<{
|
|
2148
2156
|
supportsContentEdits: ZodOptional<ZodBoolean>;
|
|
2149
2157
|
supportsOptions: ZodOptional<ZodBoolean>;
|
|
2150
2158
|
supportsForceUpdate: ZodOptional<ZodBoolean>;
|
|
2159
|
+
supportsHostTransport: ZodOptional<ZodBoolean>;
|
|
2160
|
+
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2161
|
+
editTransform: ZodOptional<ZodString>;
|
|
2151
2162
|
}, $strip>;
|
|
2152
2163
|
declare const zTextEdit: ZodObject<{
|
|
2153
2164
|
offset: ZodNumber;
|
|
@@ -2174,15 +2185,51 @@ declare const zWebEditorUpdate: ZodObject<{
|
|
|
2174
2185
|
serverRevision: ZodOptional<ZodNumber>;
|
|
2175
2186
|
acknowledgedClientRevision: ZodOptional<ZodNumber>;
|
|
2176
2187
|
force: ZodOptional<ZodBoolean>;
|
|
2188
|
+
editTransform: ZodOptional<ZodString>;
|
|
2189
|
+
}, $strip>;
|
|
2190
|
+
/** How an embedding host currently presents the editor. */
|
|
2191
|
+
declare const zPresentationMode: ZodEnum<{
|
|
2192
|
+
inline: "inline";
|
|
2193
|
+
"full-width": "full-width";
|
|
2194
|
+
"full-view": "full-view";
|
|
2195
|
+
}>;
|
|
2196
|
+
/**
|
|
2197
|
+
* Presentation controls the editor asks its embedding host for. The host's own
|
|
2198
|
+
* configuration takes precedence over these preferences.
|
|
2199
|
+
*/
|
|
2200
|
+
declare const zPresentationPreferences: ZodObject<{
|
|
2201
|
+
resizable: ZodOptional<ZodBoolean>;
|
|
2202
|
+
fullWidth: ZodOptional<ZodBoolean>;
|
|
2203
|
+
fullView: ZodOptional<ZodBoolean>;
|
|
2204
|
+
minHeight: ZodOptional<ZodNumber>;
|
|
2205
|
+
maxAutomaticHeight: ZodOptional<ZodNumber>;
|
|
2177
2206
|
}, $strip>;
|
|
2178
2207
|
type ContentEdit = output<typeof zContentEdit>;
|
|
2179
2208
|
type TextEdit = output<typeof zTextEdit>;
|
|
2180
2209
|
type EditorCapabilities = output<typeof zEditorCapabilities>;
|
|
2181
2210
|
type HostCapabilities = output<typeof zHostCapabilities>;
|
|
2182
2211
|
type WebEditorUpdate = output<typeof zWebEditorUpdate>;
|
|
2212
|
+
type PresentationMode = output<typeof zPresentationMode>;
|
|
2213
|
+
type PresentationPreferences = output<typeof zPresentationPreferences>;
|
|
2183
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
|
+
}
|
|
2184
2225
|
declare const webEditorHostInterface: any;
|
|
2185
2226
|
declare const webEditorInterface: any;
|
|
2227
|
+
declare const webEditorHostTransportInterface: any;
|
|
2228
|
+
declare const webEditorClientTransportInterface: any;
|
|
2229
|
+
/** Methods the editor exposes to a presenting host. */
|
|
2230
|
+
declare const webEditorPresentationInterface: any;
|
|
2231
|
+
/** Methods a presenting host exposes to the editor. */
|
|
2232
|
+
declare const webEditorPresentationHostInterface: any;
|
|
2186
2233
|
declare const zEmbeddedAppDescriptor: ZodObject<{
|
|
2187
2234
|
handleId: ZodString;
|
|
2188
2235
|
appId: ZodString;
|
|
@@ -2205,6 +2252,10 @@ declare const vscodeAppEmbeddingEventsInterface: any;
|
|
|
2205
2252
|
type WebEditorHostProxy = InterfaceClient<typeof webEditorHostInterface>;
|
|
2206
2253
|
/** Typed proxy used by the host to invoke editor methods. */
|
|
2207
2254
|
type WebEditorProxy = InterfaceClient<typeof webEditorInterface>;
|
|
2255
|
+
type WebEditorHostTransportProxy = InterfaceClient<typeof webEditorHostTransportInterface>;
|
|
2256
|
+
type WebEditorClientTransportProxy = InterfaceClient<typeof webEditorClientTransportInterface>;
|
|
2257
|
+
type WebEditorPresentationProxy = InterfaceClient<typeof webEditorPresentationInterface>;
|
|
2258
|
+
type WebEditorPresentationHostProxy = InterfaceClient<typeof webEditorPresentationHostInterface>;
|
|
2208
2259
|
/** Typed proxy used by an app to invoke `vscode-app-host` methods. */
|
|
2209
2260
|
type VsCodeAppHostProxy = InterfaceClient<typeof vscodeAppHostInterface>;
|
|
2210
2261
|
type VsCodeAppEmbeddingEventsProxy = InterfaceClient<typeof vscodeAppEmbeddingEventsInterface>;
|
|
@@ -2280,6 +2331,16 @@ interface IDisposable {
|
|
|
2280
2331
|
type EventListener<T> = (event: T) => void;
|
|
2281
2332
|
type Event<T> = (listener: EventListener<T>) => IDisposable;
|
|
2282
2333
|
//#endregion
|
|
2334
|
+
//#region src/hostTransport.d.ts
|
|
2335
|
+
/**
|
|
2336
|
+
* Optional message transport between a web editor and its host.
|
|
2337
|
+
*/
|
|
2338
|
+
interface HostTransport {
|
|
2339
|
+
readonly onMessage: Event<JsonValue>;
|
|
2340
|
+
/** Sends a notification to the host. */
|
|
2341
|
+
sendMessage(message: JsonValue): void;
|
|
2342
|
+
}
|
|
2343
|
+
//#endregion
|
|
2283
2344
|
//#region src/host/WebEditorHost.d.ts
|
|
2284
2345
|
interface WebEditorHostOptions {
|
|
2285
2346
|
/**
|
|
@@ -2302,6 +2363,14 @@ interface WebEditorHostOptions {
|
|
|
2302
2363
|
jsonFormat?: JsonFormatOptions;
|
|
2303
2364
|
/** Host capabilities advertised on `initialized`. */
|
|
2304
2365
|
capabilities?: HostCapabilities;
|
|
2366
|
+
/** Optional message transport to expose to the editor. */
|
|
2367
|
+
hostTransport?: HostTransport;
|
|
2368
|
+
/**
|
|
2369
|
+
* The host presents the editor inline (for example as a block in a document)
|
|
2370
|
+
* and exchanges presentation state with editors that support it: see
|
|
2371
|
+
* {@link WebEditorHost.setPresentationMode} and the presentation events.
|
|
2372
|
+
*/
|
|
2373
|
+
supportsPresentation?: boolean;
|
|
2305
2374
|
/** Called when the editor sends malformed input. Defaults to `console.error`. */
|
|
2306
2375
|
onError?: (message: string, detail?: unknown) => void;
|
|
2307
2376
|
}
|
|
@@ -2309,25 +2378,40 @@ interface WebEditorHostOptions {
|
|
|
2309
2378
|
* Host-side façade for the web-editor v0.12 protocol.
|
|
2310
2379
|
*
|
|
2311
2380
|
* Owns the canonical text content. Translates between text/JSON form and the
|
|
2312
|
-
* structural edits exchanged with the editor.
|
|
2313
|
-
*
|
|
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.
|
|
2314
2387
|
*/
|
|
2315
2388
|
declare class WebEditorHost implements IDisposable {
|
|
2316
2389
|
private readonly _connection;
|
|
2317
2390
|
private readonly _editor;
|
|
2391
|
+
private readonly _clientTransport;
|
|
2392
|
+
private readonly _presentation;
|
|
2318
2393
|
private readonly _contentType;
|
|
2319
2394
|
private readonly _jsonFormat;
|
|
2320
2395
|
private readonly _onError;
|
|
2321
2396
|
private readonly _capabilities;
|
|
2397
|
+
private readonly _hostTransportSubscription;
|
|
2322
2398
|
private _text;
|
|
2323
2399
|
private _readOnly;
|
|
2400
|
+
private _presentationMode;
|
|
2401
|
+
/** Set while connected to an editor that merges concurrent edits. */
|
|
2402
|
+
private _transform;
|
|
2403
|
+
/** Client-authority policy only. */
|
|
2324
2404
|
private _serverRevision;
|
|
2405
|
+
/** Client-authority policy only. */
|
|
2325
2406
|
private _acknowledgedClientRevision;
|
|
2326
2407
|
private _editorInitialized;
|
|
2327
2408
|
private _editorCapabilities;
|
|
2409
|
+
private readonly _pendingHostTransportMessages;
|
|
2328
2410
|
private readonly _onDidChangeText;
|
|
2411
|
+
/** The editor changed the content. `edits` apply to the previous content, in the editor's form. */
|
|
2329
2412
|
readonly onDidChangeText: Event<{
|
|
2330
2413
|
text: string;
|
|
2414
|
+
edits: readonly ContentEdit[];
|
|
2331
2415
|
}>;
|
|
2332
2416
|
private readonly _onDidInitialize;
|
|
2333
2417
|
readonly onDidInitialize: Event<{
|
|
@@ -2337,12 +2421,33 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2337
2421
|
readonly onDidReportSize: Event<{
|
|
2338
2422
|
height: number;
|
|
2339
2423
|
}>;
|
|
2424
|
+
private readonly _onDidSetPresentationPreferences;
|
|
2425
|
+
/** The editor replaced its presentation preferences. Only fires with `supportsPresentation`. */
|
|
2426
|
+
readonly onDidSetPresentationPreferences: Event<PresentationPreferences>;
|
|
2427
|
+
private readonly _onDidRequestExitFullView;
|
|
2428
|
+
/** The editor asked to leave full view. Only fires with `supportsPresentation`. */
|
|
2429
|
+
readonly onDidRequestExitFullView: Event<void>;
|
|
2340
2430
|
constructor(options: WebEditorHostOptions);
|
|
2341
2431
|
/** The text the host believes the document currently holds. */
|
|
2342
2432
|
getText(): string;
|
|
2433
|
+
/** The current content's version, to send along with offsets into it. */
|
|
2434
|
+
get version(): ContentVersion;
|
|
2343
2435
|
/**
|
|
2344
|
-
*
|
|
2345
|
-
*
|
|
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.
|
|
2346
2451
|
*/
|
|
2347
2452
|
setText(text: string, opts?: {
|
|
2348
2453
|
force?: boolean;
|
|
@@ -2354,15 +2459,32 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2354
2459
|
*/
|
|
2355
2460
|
reuse(text: string, readOnly: boolean): void;
|
|
2356
2461
|
getReadOnly(): boolean;
|
|
2462
|
+
/**
|
|
2463
|
+
* Tell the editor how the host presents it. Sent to editors that support
|
|
2464
|
+
* presentation once they initialized, and again after they reconnect.
|
|
2465
|
+
*/
|
|
2466
|
+
setPresentationMode(mode: PresentationMode): void;
|
|
2357
2467
|
setReadOnly(readOnly: boolean): void;
|
|
2358
2468
|
/**
|
|
2359
|
-
*
|
|
2360
|
-
*
|
|
2469
|
+
* Change the text by fine-grained edits, which are pushed to the editor.
|
|
2470
|
+
* An editor that initializes later receives the changed text.
|
|
2361
2471
|
*/
|
|
2362
2472
|
applyEdits(edits: readonly ContentEdit[]): void;
|
|
2363
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;
|
|
2364
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;
|
|
2365
2486
|
private _pushAcknowledgement;
|
|
2487
|
+
private _pushPresentationMode;
|
|
2366
2488
|
private _acknowledgeAndRestore;
|
|
2367
2489
|
}
|
|
2368
2490
|
//#endregion
|
|
@@ -2459,25 +2581,46 @@ interface WebEditorClientState {
|
|
|
2459
2581
|
* Calls `host.initialized` immediately, then exposes the current content and
|
|
2460
2582
|
* read-only flag as observable events. Local edits made through {@link applyEdits}
|
|
2461
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).
|
|
2462
2589
|
*/
|
|
2463
2590
|
declare class WebEditorClient implements IDisposable {
|
|
2464
2591
|
private readonly _connection;
|
|
2465
2592
|
private readonly _host;
|
|
2593
|
+
private readonly _hostTransportProxy;
|
|
2594
|
+
private readonly _presentationHost;
|
|
2466
2595
|
private readonly _onError;
|
|
2596
|
+
private _hostTransport;
|
|
2467
2597
|
private _content;
|
|
2468
2598
|
private _readOnly;
|
|
2469
2599
|
private _options;
|
|
2470
2600
|
private _hostCapabilities;
|
|
2471
|
-
private
|
|
2601
|
+
private _connected;
|
|
2602
|
+
private _presentationMode;
|
|
2603
|
+
private _presentationPreferences;
|
|
2604
|
+
private readonly _pendingHostTransportMessages;
|
|
2605
|
+
private _hostTransportActivated;
|
|
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. */
|
|
2472
2611
|
private _basedOnServerRevision;
|
|
2473
|
-
/** Number of un-acked local revisions. While > 0 the editor has pending edits. */
|
|
2474
|
-
private _pendingLocalEdits;
|
|
2475
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
|
+
*/
|
|
2476
2618
|
readonly onDidChangeContent: Event<{
|
|
2477
2619
|
content: JsonValue;
|
|
2478
2620
|
force: boolean;
|
|
2479
2621
|
}>;
|
|
2480
2622
|
private readonly _onDidApplyHostEdits;
|
|
2623
|
+
/** Host edits were applied; `edits` are relative to the previous content, after transformation against local edits. */
|
|
2481
2624
|
readonly onDidApplyHostEdits: Event<{
|
|
2482
2625
|
edits: ContentEdit[];
|
|
2483
2626
|
content: JsonValue;
|
|
@@ -2490,6 +2633,12 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2490
2633
|
readonly onDidChangeOptions: Event<{
|
|
2491
2634
|
options: JsonValue;
|
|
2492
2635
|
}>;
|
|
2636
|
+
private readonly _onDidChangePresentationMode;
|
|
2637
|
+
/** The embedding host changed how it presents this editor. See {@link getPresentationMode}. */
|
|
2638
|
+
readonly onDidChangePresentationMode: Event<{
|
|
2639
|
+
mode: PresentationMode;
|
|
2640
|
+
}>;
|
|
2641
|
+
private readonly _onDidReceiveHostMessage;
|
|
2493
2642
|
/** Resolves once the host has acknowledged `initialized`. */
|
|
2494
2643
|
readonly onDidConnect: Promise<{
|
|
2495
2644
|
capabilities: HostCapabilities | undefined;
|
|
@@ -2502,7 +2651,22 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2502
2651
|
* second one.
|
|
2503
2652
|
*/
|
|
2504
2653
|
get connection(): HubRpcConnection;
|
|
2654
|
+
/** Optional notification transport supplied by the web editor host. */
|
|
2655
|
+
get hostTransport(): HostTransport | undefined;
|
|
2505
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();
|
|
2506
2670
|
getReadOnly(): boolean;
|
|
2507
2671
|
getOptions(): JsonValue;
|
|
2508
2672
|
getHostCapabilities(): HostCapabilities | undefined;
|
|
@@ -2512,13 +2676,28 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2512
2676
|
*/
|
|
2513
2677
|
applyEdits(edits: readonly ContentEdit[]): void;
|
|
2514
2678
|
/**
|
|
2515
|
-
* Report the editor's
|
|
2516
|
-
*
|
|
2679
|
+
* Report the editor's preferred content height (px): the height it needs to
|
|
2680
|
+
* show its content without scrolling, independent of the frame's current
|
|
2681
|
+
* height. A host embedding this editor in an iframe sizes the frame to it.
|
|
2517
2682
|
*/
|
|
2518
2683
|
reportSize(height: number): void;
|
|
2684
|
+
/**
|
|
2685
|
+
* How an embedding host currently presents this editor, or `undefined` when
|
|
2686
|
+
* the host does not present it inline (for example a standalone editor).
|
|
2687
|
+
*/
|
|
2688
|
+
getPresentationMode(): PresentationMode | undefined;
|
|
2689
|
+
/**
|
|
2690
|
+
* Ask a presenting host for presentation controls (resize grips, full view).
|
|
2691
|
+
* Replaces earlier preferences; sent once connected, and ignored by hosts
|
|
2692
|
+
* that do not present the editor inline.
|
|
2693
|
+
*/
|
|
2694
|
+
setPresentationPreferences(preferences: PresentationPreferences): void;
|
|
2695
|
+
/** Ask a presenting host to leave full view. */
|
|
2696
|
+
exitFullView(): void;
|
|
2519
2697
|
dispose(): void;
|
|
2520
2698
|
private _handleUpdate;
|
|
2521
2699
|
private _handleApplyContentEdits;
|
|
2700
|
+
private _applyTransformedHostEdits;
|
|
2522
2701
|
private _acknowledge;
|
|
2523
2702
|
}
|
|
2524
2703
|
//#endregion
|
|
@@ -2654,7 +2833,214 @@ declare class VsCodeAppHostClient {
|
|
|
2654
2833
|
configureEditorAssociation(extension: string, options?: {
|
|
2655
2834
|
dismissable?: boolean;
|
|
2656
2835
|
}): Promise<EditorAssociationResult>;
|
|
2836
|
+
/**
|
|
2837
|
+
* This editor tab's view state, or `undefined` when none is set. VS Code
|
|
2838
|
+
* restores it with the tab (for example after a window reload); a newly
|
|
2839
|
+
* opened tab starts without one. Validate it like any other persisted
|
|
2840
|
+
* input, since it may come from an older version of the app.
|
|
2841
|
+
*/
|
|
2842
|
+
getViewState(): Promise<unknown>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Replace this editor tab's view state with a JSON value, for example
|
|
2845
|
+
* scroll positions or selections. Use per-app storage for state shared by
|
|
2846
|
+
* every tab. Rejects for values too large to persist and in embedded apps.
|
|
2847
|
+
*/
|
|
2848
|
+
setViewState(value: unknown): Promise<void>;
|
|
2849
|
+
}
|
|
2850
|
+
//#endregion
|
|
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];
|
|
2657
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
|
+
* An operation that turns `oldText` into `newText` by replacing everything
|
|
3009
|
+
* between their common prefix and suffix. Linear time, so it stays fast for
|
|
3010
|
+
* large texts; separate changes become one replacement of the text between them.
|
|
3011
|
+
*/
|
|
3012
|
+
declare function diffText(oldText: string, newText: string): TextOperation;
|
|
3013
|
+
//#endregion
|
|
3014
|
+
//#region src/sync/contentOperation.d.ts
|
|
3015
|
+
/** {@link OtType} for lists of {@link ContentEdit}s, as exchanged by web editors. */
|
|
3016
|
+
declare const contentEditsOt: OtType<readonly ContentEdit[]>;
|
|
3017
|
+
/**
|
|
3018
|
+
* Transforms two concurrent lists of {@link ContentEdit}s made on the same
|
|
3019
|
+
* content, so that each list applies after the other and both orders give the
|
|
3020
|
+
* same content.
|
|
3021
|
+
*
|
|
3022
|
+
* Edits at unrelated paths do not interact. String edits at the same path are
|
|
3023
|
+
* merged with {@link TextOperation.transform}. A `replace` overrides every
|
|
3024
|
+
* concurrent edit at or below its path; of two replacements at the same path,
|
|
3025
|
+
* `winner`'s is kept.
|
|
3026
|
+
*
|
|
3027
|
+
* @returns `[winner', loser']`: `winner'` applies after `loser`, `loser'` after `winner`.
|
|
3028
|
+
*/
|
|
3029
|
+
declare function transformContentEdits(winner: readonly ContentEdit[], loser: readonly ContentEdit[]): [ContentEdit[], ContentEdit[]];
|
|
3030
|
+
/**
|
|
3031
|
+
* Where `offset` in the string at `path` ends up after `edits`, or `undefined`
|
|
3032
|
+
* if the string was replaced. See {@link TextOperation.mapOffset} for `assoc`.
|
|
3033
|
+
*/
|
|
3034
|
+
declare function mapContentOffset(edits: readonly ContentEdit[], path: readonly string[], offset: number, assoc?: "before" | "after"): number | undefined;
|
|
3035
|
+
/** Maps `offset` through each list of edits in turn; `undefined` if `operations` is `undefined` or the offset does not survive an edit. */
|
|
3036
|
+
declare function mapThrough(operations: readonly (readonly ContentEdit[])[] | undefined, path: readonly string[], offset: number, assoc?: "before" | "after"): number | undefined;
|
|
3037
|
+
/**
|
|
3038
|
+
* Edits that turn `oldValue` into `newValue`, as fine-grained as possible so
|
|
3039
|
+
* that they merge with concurrent edits: changed strings become string edits,
|
|
3040
|
+
* objects with the same keys and arrays with the same length are compared
|
|
3041
|
+
* member by member, and anything else is replaced.
|
|
3042
|
+
*/
|
|
3043
|
+
declare function diffContent(oldValue: JsonValue, newValue: JsonValue, path?: string[]): ContentEdit[];
|
|
2658
3044
|
//#endregion
|
|
2659
|
-
export { AppContext, type ConnectionInput, ContentEdit, ContentType, EditorAssociationResult, EditorCapabilities, EditorRegistrationStatus, EditorScope, EmbeddedAppAccessOptions, EmbeddedAppDescriptor, EmbeddedAppHandle, EmbeddingContext, type Event, HostCapabilities, type IDisposable, JsonFormatOptions, JsonValue, type MessageEndpoint, type MessageLikeEvent, ScopeRegistration, TextEdit, VsCodeAppEmbeddingEventsProxy, VsCodeAppHostClient, VsCodeAppHostClientOptions, VsCodeAppHostProxy, WebEditorClient, WebEditorClientOptions, WebEditorClientState, WebEditorHost, WebEditorHostOptions, WebEditorHostProxy, WebEditorProxy, WebEditorUpdate, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorHostInterface, webEditorInterface };
|
|
3045
|
+
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 };
|
|
2660
3046
|
//# sourceMappingURL=index.d.ts.map
|