@vscode/web-editors 0.0.2-2 → 0.0.2-21
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 +18 -1
- package/dist/index.js +41 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -2167,10 +2167,19 @@ declare const zContentEdit: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2167
2167
|
newText: ZodString;
|
|
2168
2168
|
}, $strip>>;
|
|
2169
2169
|
}, $strip>], "kind">;
|
|
2170
|
+
declare const zWebEditorUpdate: ZodObject<{
|
|
2171
|
+
content: ZodOptional<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>;
|
|
2172
|
+
options: ZodOptional<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>>;
|
|
2173
|
+
readOnly: ZodOptional<ZodBoolean>;
|
|
2174
|
+
serverRevision: ZodOptional<ZodNumber>;
|
|
2175
|
+
acknowledgedClientRevision: ZodOptional<ZodNumber>;
|
|
2176
|
+
force: ZodOptional<ZodBoolean>;
|
|
2177
|
+
}, $strip>;
|
|
2170
2178
|
type ContentEdit = output<typeof zContentEdit>;
|
|
2171
2179
|
type TextEdit = output<typeof zTextEdit>;
|
|
2172
2180
|
type EditorCapabilities = output<typeof zEditorCapabilities>;
|
|
2173
2181
|
type HostCapabilities = output<typeof zHostCapabilities>;
|
|
2182
|
+
type WebEditorUpdate = output<typeof zWebEditorUpdate>;
|
|
2174
2183
|
type ContentType = "text" | "json";
|
|
2175
2184
|
declare const webEditorHostInterface: any;
|
|
2176
2185
|
declare const webEditorInterface: any;
|
|
@@ -2338,6 +2347,12 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2338
2347
|
setText(text: string, opts?: {
|
|
2339
2348
|
force?: boolean;
|
|
2340
2349
|
}): void;
|
|
2350
|
+
/**
|
|
2351
|
+
* Reassign this host/editor connection to another logical document.
|
|
2352
|
+
* The forced update advances the server revision, making edits queued by
|
|
2353
|
+
* the previous logical document stale before the caller switches routing.
|
|
2354
|
+
*/
|
|
2355
|
+
reuse(text: string, readOnly: boolean): void;
|
|
2341
2356
|
getReadOnly(): boolean;
|
|
2342
2357
|
setReadOnly(readOnly: boolean): void;
|
|
2343
2358
|
/**
|
|
@@ -2347,6 +2362,8 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2347
2362
|
applyEdits(edits: readonly ContentEdit[]): void;
|
|
2348
2363
|
dispose(): void;
|
|
2349
2364
|
private _pushFullUpdate;
|
|
2365
|
+
private _pushAcknowledgement;
|
|
2366
|
+
private _acknowledgeAndRestore;
|
|
2350
2367
|
}
|
|
2351
2368
|
//#endregion
|
|
2352
2369
|
//#region src/client/connection.d.ts
|
|
@@ -2639,5 +2656,5 @@ declare class VsCodeAppHostClient {
|
|
|
2639
2656
|
}): Promise<EditorAssociationResult>;
|
|
2640
2657
|
}
|
|
2641
2658
|
//#endregion
|
|
2642
|
-
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, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorHostInterface, webEditorInterface };
|
|
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 };
|
|
2643
2660
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4141,6 +4141,14 @@ const zContentEdit = discriminatedUnion("kind", [object({
|
|
|
4141
4141
|
path: array(string()),
|
|
4142
4142
|
stringEdits: array(zTextEdit)
|
|
4143
4143
|
})]);
|
|
4144
|
+
const zWebEditorUpdate = object({
|
|
4145
|
+
content: zJsonValue.optional(),
|
|
4146
|
+
options: zJsonValue.optional(),
|
|
4147
|
+
readOnly: boolean().optional(),
|
|
4148
|
+
serverRevision: number().int().nonnegative().optional(),
|
|
4149
|
+
acknowledgedClientRevision: number().int().nonnegative().optional(),
|
|
4150
|
+
force: boolean().optional()
|
|
4151
|
+
});
|
|
4144
4152
|
const webEditorHostInterface = defineInterface({
|
|
4145
4153
|
id: "web-editor-host",
|
|
4146
4154
|
description: "Methods the host exposes to the editor (web-editor/0.12)."
|
|
@@ -4169,14 +4177,7 @@ const webEditorInterface = defineInterface({
|
|
|
4169
4177
|
id: "web-editor",
|
|
4170
4178
|
description: "Methods the editor exposes to the host (web-editor/0.12)."
|
|
4171
4179
|
}, {
|
|
4172
|
-
update: notificationType(
|
|
4173
|
-
content: zJsonValue.optional(),
|
|
4174
|
-
options: zJsonValue.optional(),
|
|
4175
|
-
readOnly: boolean().optional(),
|
|
4176
|
-
serverRevision: number().int().nonnegative().optional(),
|
|
4177
|
-
acknowledgedClientRevision: number().int().nonnegative().optional(),
|
|
4178
|
-
force: boolean().optional()
|
|
4179
|
-
})),
|
|
4180
|
+
update: notificationType(zWebEditorUpdate),
|
|
4180
4181
|
applyContentEdits: notificationType(object({
|
|
4181
4182
|
edits: array(zContentEdit),
|
|
4182
4183
|
serverRevision: number().int().nonnegative(),
|
|
@@ -4423,6 +4424,12 @@ var WebEditorHost = class {
|
|
|
4423
4424
|
applyContentEdit: (params) => {
|
|
4424
4425
|
if (this._readOnly) {
|
|
4425
4426
|
this._onError("Editor sent applyContentEdit while readOnly");
|
|
4427
|
+
this._acknowledgeAndRestore(params.clientRevision);
|
|
4428
|
+
return;
|
|
4429
|
+
}
|
|
4430
|
+
if (params.basedOnServerRevision !== this._serverRevision) {
|
|
4431
|
+
this._onError(`Editor edit is based on stale server revision ${params.basedOnServerRevision}; current revision is ${this._serverRevision}`);
|
|
4432
|
+
this._acknowledgeAndRestore(params.clientRevision);
|
|
4426
4433
|
return;
|
|
4427
4434
|
}
|
|
4428
4435
|
let newValue;
|
|
@@ -4430,6 +4437,7 @@ var WebEditorHost = class {
|
|
|
4430
4437
|
newValue = applyContentEdits(encodeForEditor(this._text, this._contentType), params.edits);
|
|
4431
4438
|
} catch (e) {
|
|
4432
4439
|
this._onError("Failed to apply content edits from editor", e);
|
|
4440
|
+
this._acknowledgeAndRestore(params.clientRevision);
|
|
4433
4441
|
return;
|
|
4434
4442
|
}
|
|
4435
4443
|
let newText;
|
|
@@ -4437,13 +4445,15 @@ var WebEditorHost = class {
|
|
|
4437
4445
|
newText = decodeFromEditor(newValue, this._contentType, this._jsonFormat);
|
|
4438
4446
|
} catch (e) {
|
|
4439
4447
|
this._onError("Failed to decode editor content", e);
|
|
4448
|
+
this._acknowledgeAndRestore(params.clientRevision);
|
|
4440
4449
|
return;
|
|
4441
4450
|
}
|
|
4442
|
-
this._acknowledgedClientRevision = params.clientRevision;
|
|
4451
|
+
this._acknowledgedClientRevision = Math.max(this._acknowledgedClientRevision, params.clientRevision);
|
|
4443
4452
|
if (newText !== this._text) {
|
|
4444
4453
|
this._text = newText;
|
|
4445
4454
|
this._onDidChangeText.fire({ text: newText });
|
|
4446
4455
|
}
|
|
4456
|
+
this._pushAcknowledgement();
|
|
4447
4457
|
},
|
|
4448
4458
|
reportSize: (params) => {
|
|
4449
4459
|
this._onDidReportSize.fire({ height: params.height });
|
|
@@ -4459,10 +4469,20 @@ var WebEditorHost = class {
|
|
|
4459
4469
|
* root. If `force`, the editor must adopt it even with pending local edits.
|
|
4460
4470
|
*/
|
|
4461
4471
|
setText(text, opts = {}) {
|
|
4462
|
-
if (text === this._text) return;
|
|
4472
|
+
if (text === this._text && !opts.force) return;
|
|
4463
4473
|
this._text = text;
|
|
4464
4474
|
this._pushFullUpdate(opts.force);
|
|
4465
4475
|
}
|
|
4476
|
+
/**
|
|
4477
|
+
* Reassign this host/editor connection to another logical document.
|
|
4478
|
+
* The forced update advances the server revision, making edits queued by
|
|
4479
|
+
* the previous logical document stale before the caller switches routing.
|
|
4480
|
+
*/
|
|
4481
|
+
reuse(text, readOnly) {
|
|
4482
|
+
this._readOnly = readOnly;
|
|
4483
|
+
this._text = text;
|
|
4484
|
+
this._pushFullUpdate(true);
|
|
4485
|
+
}
|
|
4466
4486
|
getReadOnly() {
|
|
4467
4487
|
return this._readOnly;
|
|
4468
4488
|
}
|
|
@@ -4519,6 +4539,17 @@ var WebEditorHost = class {
|
|
|
4519
4539
|
force
|
|
4520
4540
|
});
|
|
4521
4541
|
}
|
|
4542
|
+
_pushAcknowledgement() {
|
|
4543
|
+
if (!this._editorInitialized) return;
|
|
4544
|
+
this._editor.update({
|
|
4545
|
+
serverRevision: this._serverRevision,
|
|
4546
|
+
acknowledgedClientRevision: this._acknowledgedClientRevision
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
_acknowledgeAndRestore(clientRevision) {
|
|
4550
|
+
this._acknowledgedClientRevision = Math.max(this._acknowledgedClientRevision, clientRevision);
|
|
4551
|
+
this._pushFullUpdate(true);
|
|
4552
|
+
}
|
|
4522
4553
|
};
|
|
4523
4554
|
//#endregion
|
|
4524
4555
|
//#region src/client/connection.ts
|