@vscode/web-editors 0.0.2-14 → 0.0.2-141

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.
@@ -0,0 +1,26 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ //#region src/utils/event.ts
6
+ var Emitter = class {
7
+ _listeners = /* @__PURE__ */ new Set();
8
+ event = (listener) => {
9
+ this._listeners.add(listener);
10
+ return { dispose: () => this._listeners.delete(listener) };
11
+ };
12
+ fire(value) {
13
+ for (const listener of this._listeners) try {
14
+ listener(value);
15
+ } catch (e) {
16
+ console.error("Emitter listener threw:", e);
17
+ }
18
+ }
19
+ dispose() {
20
+ this._listeners.clear();
21
+ }
22
+ };
23
+ //#endregion
24
+ export { Emitter as t };
25
+
26
+ //# sourceMappingURL=event-BrSLCUGr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-BrSLCUGr.js","names":[],"sources":["../../src/utils/event.ts"],"sourcesContent":["export interface IDisposable {\n dispose(): void;\n}\n\nexport type EventListener<T> = (event: T) => void;\nexport type Event<T> = (listener: EventListener<T>) => IDisposable;\n\nexport class Emitter<T> {\n private readonly _listeners = new Set<EventListener<T>>();\n\n public readonly event: Event<T> = (listener) => {\n this._listeners.add(listener);\n return { dispose: () => this._listeners.delete(listener) };\n };\n\n public fire(value: T): void {\n for (const listener of this._listeners) {\n try {\n listener(value);\n } catch (e) {\n console.error(\"Emitter listener threw:\", e);\n }\n }\n }\n\n public dispose(): void {\n this._listeners.clear();\n }\n}\n"],"mappings":";;;;;AAOA,IAAa,UAAb,MAAwB;CACpB,6BAA8B,IAAI,IAAsB;CAExD,SAAmC,aAAa;EAC5C,KAAK,WAAW,IAAI,QAAQ;EAC5B,OAAO,EAAE,eAAe,KAAK,WAAW,OAAO,QAAQ,EAAE;CAC7D;CAEA,KAAY,OAAgB;EACxB,KAAK,MAAM,YAAY,KAAK,YACxB,IAAI;GACA,SAAS,KAAK;EAClB,SAAS,GAAG;GACR,QAAQ,MAAM,2BAA2B,CAAC;EAC9C;CAER;CAEA,UAAuB;EACnB,KAAK,WAAW,MAAM;CAC1B;AACJ"}
@@ -0,0 +1,54 @@
1
+ //#region src/utils/event.d.ts
2
+ interface IDisposable {
3
+ dispose(): void;
4
+ }
5
+ type EventListener<T> = (event: T) => void;
6
+ type Event<T> = (listener: EventListener<T>) => IDisposable;
7
+ //#endregion
8
+ //#region src/documentSync/syncedTextDocument.d.ts
9
+ /**
10
+ * A text document that changes independently of the editor, for example a
11
+ * VS Code `TextDocument` (see `vsCodeTextDocument` in `@vscode/web-editors/vscode`).
12
+ */
13
+ interface SyncedTextDocument {
14
+ /** Changes with every change of the text. */
15
+ readonly version: number;
16
+ getText(): string;
17
+ /**
18
+ * Applies `edits` unless the document changed since `version`. Resolves
19
+ * whether it applied them. The document may apply them differently, for
20
+ * example with its own line breaks; its change event shows the result.
21
+ *
22
+ * The change event for the edits must fire before the returned promise
23
+ * resolves.
24
+ */
25
+ applyEdits(version: number, edits: readonly DocumentTextEdit[]): Promise<boolean>;
26
+ /**
27
+ * Fires after the text changed (not for other changes such as the dirty
28
+ * state). {@link getText} and {@link version} are those after the change.
29
+ */
30
+ readonly onDidChangeText: Event<DocumentTextChange>;
31
+ }
32
+ /** A change of a {@link SyncedTextDocument}'s text. */
33
+ interface DocumentTextChange {
34
+ /**
35
+ * Where the text changed, if known, with offsets into the text before the
36
+ * change; the edits don't overlap. Without them, the old and new text are
37
+ * compared, which turns separate changes into one replacement of
38
+ * everything between them, so the editor loses its cursor there.
39
+ */
40
+ readonly edits?: readonly DocumentTextEdit[];
41
+ }
42
+ /**
43
+ * Replaces `length` characters at `offset` with `newText`. Unlike the
44
+ * protocol's `TextEdit`, the offsets of a batch all refer to the text before
45
+ * the batch; the edits are ascending and don't overlap.
46
+ */
47
+ interface DocumentTextEdit {
48
+ readonly offset: number;
49
+ readonly length: number;
50
+ readonly newText: string;
51
+ }
52
+ //#endregion
53
+ export { IDisposable as a, Event as i, DocumentTextEdit as n, SyncedTextDocument as r, DocumentTextChange as t };
54
+ //# sourceMappingURL=syncedTextDocument-BIWK0LCP.d.ts.map