@vscode/web-editors 0.0.2-104 → 0.0.2-106
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 +86 -3
- package/dist/index.js +152 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2143,12 +2143,14 @@ declare const ZodReadonly: $constructor<ZodReadonly>;
|
|
|
2143
2143
|
declare const zEditorCapabilities: ZodObject<{
|
|
2144
2144
|
supportsContentEdits: ZodOptional<ZodBoolean>;
|
|
2145
2145
|
supportsOptions: ZodOptional<ZodBoolean>;
|
|
2146
|
+
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2146
2147
|
}, $strip>;
|
|
2147
2148
|
declare const zHostCapabilities: ZodObject<{
|
|
2148
2149
|
supportsContentEdits: ZodOptional<ZodBoolean>;
|
|
2149
2150
|
supportsOptions: ZodOptional<ZodBoolean>;
|
|
2150
2151
|
supportsForceUpdate: ZodOptional<ZodBoolean>;
|
|
2151
2152
|
supportsHostTransport: ZodOptional<ZodBoolean>;
|
|
2153
|
+
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2152
2154
|
}, $strip>;
|
|
2153
2155
|
declare const zTextEdit: ZodObject<{
|
|
2154
2156
|
offset: ZodNumber;
|
|
@@ -2176,16 +2178,39 @@ declare const zWebEditorUpdate: ZodObject<{
|
|
|
2176
2178
|
acknowledgedClientRevision: ZodOptional<ZodNumber>;
|
|
2177
2179
|
force: ZodOptional<ZodBoolean>;
|
|
2178
2180
|
}, $strip>;
|
|
2181
|
+
/** How an embedding host currently presents the editor. */
|
|
2182
|
+
declare const zPresentationMode: ZodEnum<{
|
|
2183
|
+
inline: "inline";
|
|
2184
|
+
"full-width": "full-width";
|
|
2185
|
+
"full-view": "full-view";
|
|
2186
|
+
}>;
|
|
2187
|
+
/**
|
|
2188
|
+
* Presentation controls the editor asks its embedding host for. The host's own
|
|
2189
|
+
* configuration takes precedence over these preferences.
|
|
2190
|
+
*/
|
|
2191
|
+
declare const zPresentationPreferences: ZodObject<{
|
|
2192
|
+
resizable: ZodOptional<ZodBoolean>;
|
|
2193
|
+
fullWidth: ZodOptional<ZodBoolean>;
|
|
2194
|
+
fullView: ZodOptional<ZodBoolean>;
|
|
2195
|
+
minHeight: ZodOptional<ZodNumber>;
|
|
2196
|
+
maxAutomaticHeight: ZodOptional<ZodNumber>;
|
|
2197
|
+
}, $strip>;
|
|
2179
2198
|
type ContentEdit = output<typeof zContentEdit>;
|
|
2180
2199
|
type TextEdit = output<typeof zTextEdit>;
|
|
2181
2200
|
type EditorCapabilities = output<typeof zEditorCapabilities>;
|
|
2182
2201
|
type HostCapabilities = output<typeof zHostCapabilities>;
|
|
2183
2202
|
type WebEditorUpdate = output<typeof zWebEditorUpdate>;
|
|
2203
|
+
type PresentationMode = output<typeof zPresentationMode>;
|
|
2204
|
+
type PresentationPreferences = output<typeof zPresentationPreferences>;
|
|
2184
2205
|
type ContentType = "text" | "json";
|
|
2185
2206
|
declare const webEditorHostInterface: any;
|
|
2186
2207
|
declare const webEditorInterface: any;
|
|
2187
2208
|
declare const webEditorHostTransportInterface: any;
|
|
2188
2209
|
declare const webEditorClientTransportInterface: any;
|
|
2210
|
+
/** Methods the editor exposes to a presenting host. */
|
|
2211
|
+
declare const webEditorPresentationInterface: any;
|
|
2212
|
+
/** Methods a presenting host exposes to the editor. */
|
|
2213
|
+
declare const webEditorPresentationHostInterface: any;
|
|
2189
2214
|
declare const zEmbeddedAppDescriptor: ZodObject<{
|
|
2190
2215
|
handleId: ZodString;
|
|
2191
2216
|
appId: ZodString;
|
|
@@ -2210,6 +2235,8 @@ type WebEditorHostProxy = InterfaceClient<typeof webEditorHostInterface>;
|
|
|
2210
2235
|
type WebEditorProxy = InterfaceClient<typeof webEditorInterface>;
|
|
2211
2236
|
type WebEditorHostTransportProxy = InterfaceClient<typeof webEditorHostTransportInterface>;
|
|
2212
2237
|
type WebEditorClientTransportProxy = InterfaceClient<typeof webEditorClientTransportInterface>;
|
|
2238
|
+
type WebEditorPresentationProxy = InterfaceClient<typeof webEditorPresentationInterface>;
|
|
2239
|
+
type WebEditorPresentationHostProxy = InterfaceClient<typeof webEditorPresentationHostInterface>;
|
|
2213
2240
|
/** Typed proxy used by an app to invoke `vscode-app-host` methods. */
|
|
2214
2241
|
type VsCodeAppHostProxy = InterfaceClient<typeof vscodeAppHostInterface>;
|
|
2215
2242
|
type VsCodeAppEmbeddingEventsProxy = InterfaceClient<typeof vscodeAppEmbeddingEventsInterface>;
|
|
@@ -2319,6 +2346,12 @@ interface WebEditorHostOptions {
|
|
|
2319
2346
|
capabilities?: HostCapabilities;
|
|
2320
2347
|
/** Optional message transport to expose to the editor. */
|
|
2321
2348
|
hostTransport?: HostTransport;
|
|
2349
|
+
/**
|
|
2350
|
+
* The host presents the editor inline (for example as a block in a document)
|
|
2351
|
+
* and exchanges presentation state with editors that support it: see
|
|
2352
|
+
* {@link WebEditorHost.setPresentationMode} and the presentation events.
|
|
2353
|
+
*/
|
|
2354
|
+
supportsPresentation?: boolean;
|
|
2322
2355
|
/** Called when the editor sends malformed input. Defaults to `console.error`. */
|
|
2323
2356
|
onError?: (message: string, detail?: unknown) => void;
|
|
2324
2357
|
}
|
|
@@ -2333,6 +2366,7 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2333
2366
|
private readonly _connection;
|
|
2334
2367
|
private readonly _editor;
|
|
2335
2368
|
private readonly _clientTransport;
|
|
2369
|
+
private readonly _presentation;
|
|
2336
2370
|
private readonly _contentType;
|
|
2337
2371
|
private readonly _jsonFormat;
|
|
2338
2372
|
private readonly _onError;
|
|
@@ -2340,6 +2374,7 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2340
2374
|
private readonly _hostTransportSubscription;
|
|
2341
2375
|
private _text;
|
|
2342
2376
|
private _readOnly;
|
|
2377
|
+
private _presentationMode;
|
|
2343
2378
|
private _serverRevision;
|
|
2344
2379
|
private _acknowledgedClientRevision;
|
|
2345
2380
|
private _editorInitialized;
|
|
@@ -2357,6 +2392,12 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2357
2392
|
readonly onDidReportSize: Event<{
|
|
2358
2393
|
height: number;
|
|
2359
2394
|
}>;
|
|
2395
|
+
private readonly _onDidSetPresentationPreferences;
|
|
2396
|
+
/** The editor replaced its presentation preferences. Only fires with `supportsPresentation`. */
|
|
2397
|
+
readonly onDidSetPresentationPreferences: Event<PresentationPreferences>;
|
|
2398
|
+
private readonly _onDidRequestExitFullView;
|
|
2399
|
+
/** The editor asked to leave full view. Only fires with `supportsPresentation`. */
|
|
2400
|
+
readonly onDidRequestExitFullView: Event<void>;
|
|
2360
2401
|
constructor(options: WebEditorHostOptions);
|
|
2361
2402
|
/** The text the host believes the document currently holds. */
|
|
2362
2403
|
getText(): string;
|
|
@@ -2374,6 +2415,11 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2374
2415
|
*/
|
|
2375
2416
|
reuse(text: string, readOnly: boolean): void;
|
|
2376
2417
|
getReadOnly(): boolean;
|
|
2418
|
+
/**
|
|
2419
|
+
* Tell the editor how the host presents it. Sent to editors that support
|
|
2420
|
+
* presentation once they initialized, and again after they reconnect.
|
|
2421
|
+
*/
|
|
2422
|
+
setPresentationMode(mode: PresentationMode): void;
|
|
2377
2423
|
setReadOnly(readOnly: boolean): void;
|
|
2378
2424
|
/**
|
|
2379
2425
|
* Push fine-grained edits to the editor.
|
|
@@ -2383,6 +2429,7 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2383
2429
|
dispose(): void;
|
|
2384
2430
|
private _pushFullUpdate;
|
|
2385
2431
|
private _pushAcknowledgement;
|
|
2432
|
+
private _pushPresentationMode;
|
|
2386
2433
|
private _acknowledgeAndRestore;
|
|
2387
2434
|
}
|
|
2388
2435
|
//#endregion
|
|
@@ -2484,12 +2531,16 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2484
2531
|
private readonly _connection;
|
|
2485
2532
|
private readonly _host;
|
|
2486
2533
|
private readonly _hostTransportProxy;
|
|
2534
|
+
private readonly _presentationHost;
|
|
2487
2535
|
private readonly _onError;
|
|
2488
2536
|
private _hostTransport;
|
|
2489
2537
|
private _content;
|
|
2490
2538
|
private _readOnly;
|
|
2491
2539
|
private _options;
|
|
2492
2540
|
private _hostCapabilities;
|
|
2541
|
+
private _connected;
|
|
2542
|
+
private _presentationMode;
|
|
2543
|
+
private _presentationPreferences;
|
|
2493
2544
|
private readonly _pendingHostTransportMessages;
|
|
2494
2545
|
private _hostTransportActivated;
|
|
2495
2546
|
private _clientRevision;
|
|
@@ -2514,6 +2565,11 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2514
2565
|
readonly onDidChangeOptions: Event<{
|
|
2515
2566
|
options: JsonValue;
|
|
2516
2567
|
}>;
|
|
2568
|
+
private readonly _onDidChangePresentationMode;
|
|
2569
|
+
/** The embedding host changed how it presents this editor. See {@link getPresentationMode}. */
|
|
2570
|
+
readonly onDidChangePresentationMode: Event<{
|
|
2571
|
+
mode: PresentationMode;
|
|
2572
|
+
}>;
|
|
2517
2573
|
private readonly _onDidReceiveHostMessage;
|
|
2518
2574
|
/** Resolves once the host has acknowledged `initialized`. */
|
|
2519
2575
|
readonly onDidConnect: Promise<{
|
|
@@ -2539,10 +2595,24 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2539
2595
|
*/
|
|
2540
2596
|
applyEdits(edits: readonly ContentEdit[]): void;
|
|
2541
2597
|
/**
|
|
2542
|
-
* Report the editor's
|
|
2543
|
-
*
|
|
2598
|
+
* Report the editor's preferred content height (px): the height it needs to
|
|
2599
|
+
* show its content without scrolling, independent of the frame's current
|
|
2600
|
+
* height. A host embedding this editor in an iframe sizes the frame to it.
|
|
2544
2601
|
*/
|
|
2545
2602
|
reportSize(height: number): void;
|
|
2603
|
+
/**
|
|
2604
|
+
* How an embedding host currently presents this editor, or `undefined` when
|
|
2605
|
+
* the host does not present it inline (for example a standalone editor).
|
|
2606
|
+
*/
|
|
2607
|
+
getPresentationMode(): PresentationMode | undefined;
|
|
2608
|
+
/**
|
|
2609
|
+
* Ask a presenting host for presentation controls (resize grips, full view).
|
|
2610
|
+
* Replaces earlier preferences; sent once connected, and ignored by hosts
|
|
2611
|
+
* that do not present the editor inline.
|
|
2612
|
+
*/
|
|
2613
|
+
setPresentationPreferences(preferences: PresentationPreferences): void;
|
|
2614
|
+
/** Ask a presenting host to leave full view. */
|
|
2615
|
+
exitFullView(): void;
|
|
2546
2616
|
dispose(): void;
|
|
2547
2617
|
private _handleUpdate;
|
|
2548
2618
|
private _handleApplyContentEdits;
|
|
@@ -2681,7 +2751,20 @@ declare class VsCodeAppHostClient {
|
|
|
2681
2751
|
configureEditorAssociation(extension: string, options?: {
|
|
2682
2752
|
dismissable?: boolean;
|
|
2683
2753
|
}): Promise<EditorAssociationResult>;
|
|
2754
|
+
/**
|
|
2755
|
+
* This editor tab's view state, or `undefined` when none is set. VS Code
|
|
2756
|
+
* restores it with the tab (for example after a window reload); a newly
|
|
2757
|
+
* opened tab starts without one. Validate it like any other persisted
|
|
2758
|
+
* input, since it may come from an older version of the app.
|
|
2759
|
+
*/
|
|
2760
|
+
getViewState(): Promise<unknown>;
|
|
2761
|
+
/**
|
|
2762
|
+
* Replace this editor tab's view state with a JSON value, for example
|
|
2763
|
+
* scroll positions or selections. Use per-app storage for state shared by
|
|
2764
|
+
* every tab. Rejects for values too large to persist and in embedded apps.
|
|
2765
|
+
*/
|
|
2766
|
+
setViewState(value: unknown): Promise<void>;
|
|
2684
2767
|
}
|
|
2685
2768
|
//#endregion
|
|
2686
|
-
export { AppContext, type ConnectionInput, ContentEdit, ContentType, EditorAssociationResult, EditorCapabilities, EditorRegistrationStatus, EditorScope, EmbeddedAppAccessOptions, EmbeddedAppDescriptor, EmbeddedAppHandle, EmbeddingContext, type Event, HostCapabilities, HostTransport, type IDisposable, JsonFormatOptions, JsonValue, type MessageEndpoint, type MessageLikeEvent, ScopeRegistration, TextEdit, VsCodeAppEmbeddingEventsProxy, VsCodeAppHostClient, VsCodeAppHostClientOptions, VsCodeAppHostProxy, WebEditorClient, WebEditorClientOptions, WebEditorClientState, WebEditorClientTransportProxy, WebEditorHost, WebEditorHostOptions, WebEditorHostProxy, WebEditorHostTransportProxy, WebEditorProxy, WebEditorUpdate, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface };
|
|
2769
|
+
export { AppContext, type ConnectionInput, ContentEdit, ContentType, EditorAssociationResult, EditorCapabilities, EditorRegistrationStatus, EditorScope, EmbeddedAppAccessOptions, EmbeddedAppDescriptor, EmbeddedAppHandle, EmbeddingContext, type Event, HostCapabilities, HostTransport, type IDisposable, JsonFormatOptions, JsonValue, type MessageEndpoint, type MessageLikeEvent, PresentationMode, PresentationPreferences, ScopeRegistration, TextEdit, VsCodeAppEmbeddingEventsProxy, VsCodeAppHostClient, VsCodeAppHostClientOptions, VsCodeAppHostProxy, WebEditorClient, WebEditorClientOptions, WebEditorClientState, WebEditorClientTransportProxy, WebEditorHost, WebEditorHostOptions, WebEditorHostProxy, WebEditorHostTransportProxy, WebEditorPresentationHostProxy, WebEditorPresentationProxy, WebEditorProxy, WebEditorUpdate, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface, webEditorPresentationHostInterface, webEditorPresentationInterface };
|
|
2687
2770
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4120,13 +4120,17 @@ function superRefine(fn, params) {
|
|
|
4120
4120
|
const zJsonValue = unknown();
|
|
4121
4121
|
const zEditorCapabilities = object({
|
|
4122
4122
|
supportsContentEdits: boolean().optional(),
|
|
4123
|
-
supportsOptions: boolean().optional()
|
|
4123
|
+
supportsOptions: boolean().optional(),
|
|
4124
|
+
/** The editor implements `web-editor-presentation` (see {@link webEditorPresentationInterface}). */
|
|
4125
|
+
supportsPresentation: boolean().optional()
|
|
4124
4126
|
});
|
|
4125
4127
|
const zHostCapabilities = object({
|
|
4126
4128
|
supportsContentEdits: boolean().optional(),
|
|
4127
4129
|
supportsOptions: boolean().optional(),
|
|
4128
4130
|
supportsForceUpdate: boolean().optional(),
|
|
4129
|
-
supportsHostTransport: boolean().optional()
|
|
4131
|
+
supportsHostTransport: boolean().optional(),
|
|
4132
|
+
/** The host presents the editor inline and implements `web-editor-presentation-host`. */
|
|
4133
|
+
supportsPresentation: boolean().optional()
|
|
4130
4134
|
});
|
|
4131
4135
|
const zTextEdit = object({
|
|
4132
4136
|
offset: number().int().nonnegative(),
|
|
@@ -4150,6 +4154,28 @@ const zWebEditorUpdate = object({
|
|
|
4150
4154
|
acknowledgedClientRevision: number().int().nonnegative().optional(),
|
|
4151
4155
|
force: boolean().optional()
|
|
4152
4156
|
});
|
|
4157
|
+
/** How an embedding host currently presents the editor. */
|
|
4158
|
+
const zPresentationMode = _enum([
|
|
4159
|
+
"inline",
|
|
4160
|
+
"full-width",
|
|
4161
|
+
"full-view"
|
|
4162
|
+
]);
|
|
4163
|
+
const zEditorHeight = number().positive().max(1e4);
|
|
4164
|
+
/**
|
|
4165
|
+
* Presentation controls the editor asks its embedding host for. The host's own
|
|
4166
|
+
* configuration takes precedence over these preferences.
|
|
4167
|
+
*/
|
|
4168
|
+
const zPresentationPreferences = object({
|
|
4169
|
+
/** A height grip; dragging near the automatic (content) height snaps back to it. */
|
|
4170
|
+
resizable: boolean().optional(),
|
|
4171
|
+
/** A width grip that widens the editor up to the host's viewport. */
|
|
4172
|
+
fullWidth: boolean().optional(),
|
|
4173
|
+
/** A toolbar action that fills the host's viewport. */
|
|
4174
|
+
fullView: boolean().optional(),
|
|
4175
|
+
minHeight: zEditorHeight.optional(),
|
|
4176
|
+
/** Upper bound for the automatic height; users can still resize beyond it. */
|
|
4177
|
+
maxAutomaticHeight: zEditorHeight.optional()
|
|
4178
|
+
});
|
|
4153
4179
|
const webEditorHostInterface = defineInterface({
|
|
4154
4180
|
id: "web-editor-host",
|
|
4155
4181
|
description: "Methods the host exposes to the editor (web-editor/0.12)."
|
|
@@ -4197,6 +4223,23 @@ const webEditorClientTransportInterface = defineInterface({
|
|
|
4197
4223
|
id: "web-editor-client-transport",
|
|
4198
4224
|
description: "Optional messages the web editor host sends to the editor."
|
|
4199
4225
|
}, { message: notificationType(object({ message: zJsonValue })) });
|
|
4226
|
+
/** Methods the editor exposes to a presenting host. */
|
|
4227
|
+
const webEditorPresentationInterface = defineInterface({
|
|
4228
|
+
id: "web-editor-presentation",
|
|
4229
|
+
description: "How the embedding host currently presents the editor."
|
|
4230
|
+
}, {
|
|
4231
|
+
/** Sent once the editor initialized, and whenever the mode changes. */
|
|
4232
|
+
changed: notificationType(object({ mode: zPresentationMode })) });
|
|
4233
|
+
/** Methods a presenting host exposes to the editor. */
|
|
4234
|
+
const webEditorPresentationHostInterface = defineInterface({
|
|
4235
|
+
id: "web-editor-presentation-host",
|
|
4236
|
+
description: "Presentation preferences and actions of an embedded editor."
|
|
4237
|
+
}, {
|
|
4238
|
+
/** Replaces the editor's previous preferences. */
|
|
4239
|
+
setPreferences: notificationType(zPresentationPreferences),
|
|
4240
|
+
/** Asks the host to leave full view, for example when the user presses Escape. */
|
|
4241
|
+
exitFullView: notificationType(object({}))
|
|
4242
|
+
});
|
|
4200
4243
|
/** Per-scope registration: `registered` (toolbar button) and `isDefault` (auto-open). */
|
|
4201
4244
|
const zScopeRegistration = object({
|
|
4202
4245
|
registered: boolean(),
|
|
@@ -4272,7 +4315,21 @@ const vscodeAppHostInterface = defineInterface({
|
|
|
4272
4315
|
workspace: zScopeRegistration,
|
|
4273
4316
|
hasWorkspace: boolean(),
|
|
4274
4317
|
changed: boolean()
|
|
4275
|
-
}))
|
|
4318
|
+
})),
|
|
4319
|
+
/**
|
|
4320
|
+
* The view state of this editor tab, such as scroll positions or
|
|
4321
|
+
* selections, as last set by {@link setViewState}. `value` is omitted
|
|
4322
|
+
* when none is set. VS Code restores it when it restores the tab (for
|
|
4323
|
+
* example after a window reload), but a newly opened tab starts
|
|
4324
|
+
* without one. Only the top-level app of a tab has view state.
|
|
4325
|
+
*/
|
|
4326
|
+
getViewState: requestType(object({}), object({ value: zJsonValue.optional() })),
|
|
4327
|
+
/**
|
|
4328
|
+
* Replace this editor tab's view state with a JSON value. The host
|
|
4329
|
+
* rejects values too large to persist with the tab, and calls from
|
|
4330
|
+
* embedded apps.
|
|
4331
|
+
*/
|
|
4332
|
+
setViewState: requestType(object({ value: zJsonValue }), object({}))
|
|
4276
4333
|
});
|
|
4277
4334
|
/** Host-to-parent notifications for loaded child runtime changes. */
|
|
4278
4335
|
const vscodeAppEmbeddingEventsInterface = defineInterface({
|
|
@@ -4395,6 +4452,7 @@ var WebEditorHost = class {
|
|
|
4395
4452
|
_connection;
|
|
4396
4453
|
_editor;
|
|
4397
4454
|
_clientTransport;
|
|
4455
|
+
_presentation;
|
|
4398
4456
|
_contentType;
|
|
4399
4457
|
_jsonFormat;
|
|
4400
4458
|
_onError;
|
|
@@ -4402,6 +4460,7 @@ var WebEditorHost = class {
|
|
|
4402
4460
|
_hostTransportSubscription;
|
|
4403
4461
|
_text;
|
|
4404
4462
|
_readOnly;
|
|
4463
|
+
_presentationMode;
|
|
4405
4464
|
_serverRevision = 0;
|
|
4406
4465
|
_acknowledgedClientRevision = 0;
|
|
4407
4466
|
_editorInitialized = false;
|
|
@@ -4413,6 +4472,12 @@ var WebEditorHost = class {
|
|
|
4413
4472
|
onDidInitialize = this._onDidInitialize.event;
|
|
4414
4473
|
_onDidReportSize = new Emitter();
|
|
4415
4474
|
onDidReportSize = this._onDidReportSize.event;
|
|
4475
|
+
_onDidSetPresentationPreferences = new Emitter();
|
|
4476
|
+
/** The editor replaced its presentation preferences. Only fires with `supportsPresentation`. */
|
|
4477
|
+
onDidSetPresentationPreferences = this._onDidSetPresentationPreferences.event;
|
|
4478
|
+
_onDidRequestExitFullView = new Emitter();
|
|
4479
|
+
/** The editor asked to leave full view. Only fires with `supportsPresentation`. */
|
|
4480
|
+
onDidRequestExitFullView = this._onDidRequestExitFullView.event;
|
|
4416
4481
|
constructor(options) {
|
|
4417
4482
|
this._connection = options.connection;
|
|
4418
4483
|
this._contentType = options.contentType ?? "text";
|
|
@@ -4422,10 +4487,12 @@ var WebEditorHost = class {
|
|
|
4422
4487
|
this._onError = options.onError ?? ((m, d) => console.error("WebEditorHost:", m, d));
|
|
4423
4488
|
this._capabilities = {
|
|
4424
4489
|
...options.capabilities ?? { supportsForceUpdate: true },
|
|
4425
|
-
supportsHostTransport: options.hostTransport ? true : void 0
|
|
4490
|
+
supportsHostTransport: options.hostTransport ? true : void 0,
|
|
4491
|
+
supportsPresentation: options.supportsPresentation ? true : void 0
|
|
4426
4492
|
};
|
|
4427
4493
|
this._editor = this._connection.get(webEditorInterface);
|
|
4428
4494
|
this._clientTransport = this._connection.get(webEditorClientTransportInterface);
|
|
4495
|
+
this._presentation = this._connection.get(webEditorPresentationInterface);
|
|
4429
4496
|
this._connection.register(webEditorHostInterface, {
|
|
4430
4497
|
initialized: (params) => {
|
|
4431
4498
|
if (params.contentType !== this._contentType) this._onError(`Editor contentType "${params.contentType}" does not match host "${this._contentType}"`);
|
|
@@ -4435,6 +4502,7 @@ var WebEditorHost = class {
|
|
|
4435
4502
|
this._acknowledgedClientRevision = 0;
|
|
4436
4503
|
this._pushFullUpdate();
|
|
4437
4504
|
for (const message of this._pendingHostTransportMessages.splice(0)) this._clientTransport.message({ message });
|
|
4505
|
+
this._pushPresentationMode();
|
|
4438
4506
|
this._onDidInitialize.fire({ capabilities: params.capabilities });
|
|
4439
4507
|
return {
|
|
4440
4508
|
protocolVersion: "web-editor-host/0.12",
|
|
@@ -4479,6 +4547,10 @@ var WebEditorHost = class {
|
|
|
4479
4547
|
this._onDidReportSize.fire({ height: params.height });
|
|
4480
4548
|
}
|
|
4481
4549
|
});
|
|
4550
|
+
if (options.supportsPresentation) this._connection.register(webEditorPresentationHostInterface, {
|
|
4551
|
+
setPreferences: (preferences) => this._onDidSetPresentationPreferences.fire(preferences),
|
|
4552
|
+
exitFullView: () => this._onDidRequestExitFullView.fire()
|
|
4553
|
+
});
|
|
4482
4554
|
if (options.hostTransport) {
|
|
4483
4555
|
this._connection.register(webEditorHostTransportInterface, { message: ({ message }) => options.hostTransport.sendMessage(message) });
|
|
4484
4556
|
this._hostTransportSubscription = options.hostTransport.onMessage((message) => {
|
|
@@ -4513,6 +4585,15 @@ var WebEditorHost = class {
|
|
|
4513
4585
|
getReadOnly() {
|
|
4514
4586
|
return this._readOnly;
|
|
4515
4587
|
}
|
|
4588
|
+
/**
|
|
4589
|
+
* Tell the editor how the host presents it. Sent to editors that support
|
|
4590
|
+
* presentation once they initialized, and again after they reconnect.
|
|
4591
|
+
*/
|
|
4592
|
+
setPresentationMode(mode) {
|
|
4593
|
+
if (this._presentationMode === mode) return;
|
|
4594
|
+
this._presentationMode = mode;
|
|
4595
|
+
this._pushPresentationMode();
|
|
4596
|
+
}
|
|
4516
4597
|
setReadOnly(readOnly) {
|
|
4517
4598
|
if (this._readOnly === readOnly) return;
|
|
4518
4599
|
this._readOnly = readOnly;
|
|
@@ -4547,6 +4628,8 @@ var WebEditorHost = class {
|
|
|
4547
4628
|
this._onDidChangeText.dispose();
|
|
4548
4629
|
this._onDidInitialize.dispose();
|
|
4549
4630
|
this._onDidReportSize.dispose();
|
|
4631
|
+
this._onDidSetPresentationPreferences.dispose();
|
|
4632
|
+
this._onDidRequestExitFullView.dispose();
|
|
4550
4633
|
this._pendingHostTransportMessages.length = 0;
|
|
4551
4634
|
this._connection.close();
|
|
4552
4635
|
}
|
|
@@ -4575,6 +4658,10 @@ var WebEditorHost = class {
|
|
|
4575
4658
|
acknowledgedClientRevision: this._acknowledgedClientRevision
|
|
4576
4659
|
});
|
|
4577
4660
|
}
|
|
4661
|
+
_pushPresentationMode() {
|
|
4662
|
+
if (!this._editorInitialized || !this._capabilities.supportsPresentation || !this._editorCapabilities?.supportsPresentation || this._presentationMode === void 0) return;
|
|
4663
|
+
this._presentation.changed({ mode: this._presentationMode });
|
|
4664
|
+
}
|
|
4578
4665
|
_acknowledgeAndRestore(clientRevision) {
|
|
4579
4666
|
this._acknowledgedClientRevision = Math.max(this._acknowledgedClientRevision, clientRevision);
|
|
4580
4667
|
this._pushFullUpdate(true);
|
|
@@ -4727,12 +4814,16 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4727
4814
|
_connection;
|
|
4728
4815
|
_host;
|
|
4729
4816
|
_hostTransportProxy;
|
|
4817
|
+
_presentationHost;
|
|
4730
4818
|
_onError;
|
|
4731
4819
|
_hostTransport;
|
|
4732
4820
|
_content = void 0;
|
|
4733
4821
|
_readOnly = false;
|
|
4734
4822
|
_options = void 0;
|
|
4735
4823
|
_hostCapabilities;
|
|
4824
|
+
_connected = false;
|
|
4825
|
+
_presentationMode;
|
|
4826
|
+
_presentationPreferences;
|
|
4736
4827
|
_pendingHostTransportMessages = [];
|
|
4737
4828
|
_hostTransportActivated = false;
|
|
4738
4829
|
_clientRevision = 0;
|
|
@@ -4747,6 +4838,9 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4747
4838
|
onDidChangeReadOnly = this._onDidChangeReadOnly.event;
|
|
4748
4839
|
_onDidChangeOptions = new Emitter();
|
|
4749
4840
|
onDidChangeOptions = this._onDidChangeOptions.event;
|
|
4841
|
+
_onDidChangePresentationMode = new Emitter();
|
|
4842
|
+
/** The embedding host changed how it presents this editor. See {@link getPresentationMode}. */
|
|
4843
|
+
onDidChangePresentationMode = this._onDidChangePresentationMode.event;
|
|
4750
4844
|
_onDidReceiveHostMessage = new Emitter();
|
|
4751
4845
|
/** Resolves once the host has acknowledged `initialized`. */
|
|
4752
4846
|
onDidConnect;
|
|
@@ -4760,6 +4854,7 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4760
4854
|
this._onError = options.onError ?? ((m, d) => console.error("WebEditorClient:", m, d));
|
|
4761
4855
|
this._host = this._connection.get(webEditorHostInterface);
|
|
4762
4856
|
this._hostTransportProxy = this._connection.get(webEditorHostTransportInterface);
|
|
4857
|
+
this._presentationHost = this._connection.get(webEditorPresentationHostInterface);
|
|
4763
4858
|
this._connection.register(webEditorInterface, {
|
|
4764
4859
|
update: (params) => this._handleUpdate(params),
|
|
4765
4860
|
applyContentEdits: (params) => this._handleApplyContentEdits(params),
|
|
@@ -4767,6 +4862,11 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4767
4862
|
return { schema: options.getContentSchema ? await options.getContentSchema() : null };
|
|
4768
4863
|
}
|
|
4769
4864
|
});
|
|
4865
|
+
this._connection.register(webEditorPresentationInterface, { changed: ({ mode }) => {
|
|
4866
|
+
if (mode === this._presentationMode) return;
|
|
4867
|
+
this._presentationMode = mode;
|
|
4868
|
+
this._onDidChangePresentationMode.fire({ mode });
|
|
4869
|
+
} });
|
|
4770
4870
|
this._connection.register(webEditorClientTransportInterface, { message: ({ message }) => {
|
|
4771
4871
|
if (this._hostTransportActivated) this._onDidReceiveHostMessage.fire(message);
|
|
4772
4872
|
else this._pendingHostTransportMessages.push(message);
|
|
@@ -4774,9 +4874,14 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4774
4874
|
this.onDidConnect = this._host.initialized({
|
|
4775
4875
|
protocolVersion: "web-editor/0.12",
|
|
4776
4876
|
contentType: options.contentType ?? "text",
|
|
4777
|
-
capabilities:
|
|
4877
|
+
capabilities: {
|
|
4878
|
+
...options.capabilities,
|
|
4879
|
+
supportsPresentation: true
|
|
4880
|
+
}
|
|
4778
4881
|
}).then((r) => {
|
|
4779
4882
|
this._hostCapabilities = r.capabilities;
|
|
4883
|
+
this._connected = true;
|
|
4884
|
+
if (this._presentationPreferences) this.setPresentationPreferences(this._presentationPreferences);
|
|
4780
4885
|
if (r.capabilities?.supportsHostTransport) this._hostTransport = {
|
|
4781
4886
|
onMessage: (listener) => {
|
|
4782
4887
|
const disposable = this._onDidReceiveHostMessage.event(listener);
|
|
@@ -4841,17 +4946,39 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4841
4946
|
});
|
|
4842
4947
|
}
|
|
4843
4948
|
/**
|
|
4844
|
-
* Report the editor's
|
|
4845
|
-
*
|
|
4949
|
+
* Report the editor's preferred content height (px): the height it needs to
|
|
4950
|
+
* show its content without scrolling, independent of the frame's current
|
|
4951
|
+
* height. A host embedding this editor in an iframe sizes the frame to it.
|
|
4846
4952
|
*/
|
|
4847
4953
|
reportSize(height) {
|
|
4848
4954
|
this._host.reportSize({ height });
|
|
4849
4955
|
}
|
|
4956
|
+
/**
|
|
4957
|
+
* How an embedding host currently presents this editor, or `undefined` when
|
|
4958
|
+
* the host does not present it inline (for example a standalone editor).
|
|
4959
|
+
*/
|
|
4960
|
+
getPresentationMode() {
|
|
4961
|
+
return this._presentationMode;
|
|
4962
|
+
}
|
|
4963
|
+
/**
|
|
4964
|
+
* Ask a presenting host for presentation controls (resize grips, full view).
|
|
4965
|
+
* Replaces earlier preferences; sent once connected, and ignored by hosts
|
|
4966
|
+
* that do not present the editor inline.
|
|
4967
|
+
*/
|
|
4968
|
+
setPresentationPreferences(preferences) {
|
|
4969
|
+
this._presentationPreferences = preferences;
|
|
4970
|
+
if (this._connected && this._hostCapabilities?.supportsPresentation) this._presentationHost.setPreferences(preferences);
|
|
4971
|
+
}
|
|
4972
|
+
/** Ask a presenting host to leave full view. */
|
|
4973
|
+
exitFullView() {
|
|
4974
|
+
if (this._connected && this._hostCapabilities?.supportsPresentation) this._presentationHost.exitFullView({});
|
|
4975
|
+
}
|
|
4850
4976
|
dispose() {
|
|
4851
4977
|
this._onDidChangeContent.dispose();
|
|
4852
4978
|
this._onDidApplyHostEdits.dispose();
|
|
4853
4979
|
this._onDidChangeReadOnly.dispose();
|
|
4854
4980
|
this._onDidChangeOptions.dispose();
|
|
4981
|
+
this._onDidChangePresentationMode.dispose();
|
|
4855
4982
|
this._onDidReceiveHostMessage.dispose();
|
|
4856
4983
|
this._pendingHostTransportMessages.length = 0;
|
|
4857
4984
|
this._connection.close();
|
|
@@ -5102,8 +5229,25 @@ var VsCodeAppHostClient = class {
|
|
|
5102
5229
|
dismissable: options?.dismissable
|
|
5103
5230
|
});
|
|
5104
5231
|
}
|
|
5232
|
+
/**
|
|
5233
|
+
* This editor tab's view state, or `undefined` when none is set. VS Code
|
|
5234
|
+
* restores it with the tab (for example after a window reload); a newly
|
|
5235
|
+
* opened tab starts without one. Validate it like any other persisted
|
|
5236
|
+
* input, since it may come from an older version of the app.
|
|
5237
|
+
*/
|
|
5238
|
+
async getViewState() {
|
|
5239
|
+
return (await this._host.getViewState({})).value;
|
|
5240
|
+
}
|
|
5241
|
+
/**
|
|
5242
|
+
* Replace this editor tab's view state with a JSON value, for example
|
|
5243
|
+
* scroll positions or selections. Use per-app storage for state shared by
|
|
5244
|
+
* every tab. Rejects for values too large to persist and in embedded apps.
|
|
5245
|
+
*/
|
|
5246
|
+
async setViewState(value) {
|
|
5247
|
+
await this._host.setViewState({ value });
|
|
5248
|
+
}
|
|
5105
5249
|
};
|
|
5106
5250
|
//#endregion
|
|
5107
|
-
export { EmbeddedAppHandle, VsCodeAppHostClient, WebEditorClient, WebEditorHost, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface };
|
|
5251
|
+
export { EmbeddedAppHandle, VsCodeAppHostClient, WebEditorClient, WebEditorHost, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface, webEditorPresentationHostInterface, webEditorPresentationInterface };
|
|
5108
5252
|
|
|
5109
5253
|
//# sourceMappingURL=index.js.map
|