@lvce-editor/editor-worker 19.75.0 → 19.75.2
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/README.md +26 -0
- package/dist/diff-sdk.d.ts +236 -0
- package/dist/diff-sdk.js +20336 -0
- package/dist/editorWorkerMain.js +382 -274
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -146,3 +146,29 @@ npm run e2e:headless
|
|
|
146
146
|
## License
|
|
147
147
|
|
|
148
148
|
MIT
|
|
149
|
+
|
|
150
|
+
## Embedded editors
|
|
151
|
+
|
|
152
|
+
`@lvce-editor/editor-worker/dist/diff-sdk.js` exports `createEmbeddedEditor(options)`
|
|
153
|
+
with TypeScript declarations. It does not start a worker or install message
|
|
154
|
+
listeners. Bundle this entry into the embedding worker; the normal editor worker
|
|
155
|
+
entry does not import it.
|
|
156
|
+
|
|
157
|
+
The host supplies a unique editor ID, document URI, optional application ID,
|
|
158
|
+
content, font metrics, tokenizer path, and viewport geometry through
|
|
159
|
+
`StandaloneEditorOptions`. Initialize the shared `@lvce-editor/rpc-registry`
|
|
160
|
+
connections before invoking commands that use workbench services (including
|
|
161
|
+
syntax highlighting, preferences, clipboard, and language providers). The SDK
|
|
162
|
+
keeps that dependency external so the host and SDK use the same connections.
|
|
163
|
+
|
|
164
|
+
The returned editor exposes `execute(command, ...args)`, `getState()`, and
|
|
165
|
+
`dispose()`. State commands accept the usual `Editor.` or `EditorText.` command
|
|
166
|
+
IDs, or their short names, with the same arguments as the normal editor.
|
|
167
|
+
Commands operate on document coordinates. The embedding view is responsible for
|
|
168
|
+
mapping pointer positions and rendering anchors to its display rows.
|
|
169
|
+
Worker lifecycle commands and getters are not accepted by `execute`.
|
|
170
|
+
|
|
171
|
+
Accepted commands run in order and retain normal-editor undo, selection, and
|
|
172
|
+
same-document synchronization behavior. Read state after awaiting a command.
|
|
173
|
+
Treat returned state as read-only. Await `dispose()` before reusing an ID;
|
|
174
|
+
disposal rejects new commands and drains commands already accepted.
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { VirtualDomNode } from '@lvce-editor/virtual-dom-worker';
|
|
2
|
+
|
|
3
|
+
export interface StandaloneEditorOptions {
|
|
4
|
+
readonly applicationId?: string;
|
|
5
|
+
readonly assetDir: string;
|
|
6
|
+
readonly charWidth: number;
|
|
7
|
+
readonly content: string;
|
|
8
|
+
readonly fontFamily: string;
|
|
9
|
+
readonly fontSize: number;
|
|
10
|
+
readonly fontWeight: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
readonly id: number;
|
|
13
|
+
readonly languageId: string;
|
|
14
|
+
readonly letterSpacing: number;
|
|
15
|
+
readonly lineNumbers: boolean;
|
|
16
|
+
readonly platform: number;
|
|
17
|
+
readonly rowHeight: number;
|
|
18
|
+
readonly tabSize: number;
|
|
19
|
+
readonly tokenizePath: string;
|
|
20
|
+
readonly uri: string;
|
|
21
|
+
readonly width: number;
|
|
22
|
+
readonly x: number;
|
|
23
|
+
readonly y: number;
|
|
24
|
+
}
|
|
25
|
+
export interface BracketMatchInfo {
|
|
26
|
+
readonly height: number;
|
|
27
|
+
readonly width: number;
|
|
28
|
+
readonly x: number;
|
|
29
|
+
readonly y: number;
|
|
30
|
+
}
|
|
31
|
+
export interface DocumentSymbol {
|
|
32
|
+
readonly children?: readonly DocumentSymbol[];
|
|
33
|
+
readonly detail?: string;
|
|
34
|
+
readonly endOffset: number;
|
|
35
|
+
readonly kind: number | string;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly selectionEndOffset: number;
|
|
38
|
+
readonly selectionStartOffset: number;
|
|
39
|
+
readonly startOffset: number;
|
|
40
|
+
}
|
|
41
|
+
export type EditorGutterDecorationType = "added" | "deleted" | "modified";
|
|
42
|
+
export interface EditorGutterDecoration {
|
|
43
|
+
readonly rowIndex: number;
|
|
44
|
+
readonly type: EditorGutterDecorationType;
|
|
45
|
+
}
|
|
46
|
+
export interface EditorLifecycle {
|
|
47
|
+
disposed: boolean;
|
|
48
|
+
sentLines?: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
export interface EditorLineDecoration {
|
|
51
|
+
readonly rowIndex: number;
|
|
52
|
+
readonly text: string;
|
|
53
|
+
}
|
|
54
|
+
export interface EditorTextDecoration {
|
|
55
|
+
readonly color: string;
|
|
56
|
+
readonly endColumnIndex: number;
|
|
57
|
+
readonly endRowIndex: number;
|
|
58
|
+
readonly startColumnIndex: number;
|
|
59
|
+
readonly startRowIndex: number;
|
|
60
|
+
readonly thickness?: number;
|
|
61
|
+
}
|
|
62
|
+
declare const Lf = "lf";
|
|
63
|
+
declare const Crlf = "crlf";
|
|
64
|
+
export type EndOfLine = typeof Lf | typeof Crlf;
|
|
65
|
+
export interface MergeConflict {
|
|
66
|
+
readonly baseEndRowIndex: number;
|
|
67
|
+
readonly baseStartRowIndex: number;
|
|
68
|
+
readonly currentEndRowIndex: number;
|
|
69
|
+
readonly currentStartRowIndex: number;
|
|
70
|
+
readonly endRowIndex: number;
|
|
71
|
+
readonly incomingEndRowIndex: number;
|
|
72
|
+
readonly incomingStartRowIndex: number;
|
|
73
|
+
readonly separatorRowIndex: number;
|
|
74
|
+
readonly startRowIndex: number;
|
|
75
|
+
}
|
|
76
|
+
export interface EditorState {
|
|
77
|
+
readonly additionalFocus: number;
|
|
78
|
+
readonly applicationId?: string;
|
|
79
|
+
readonly assetDir: string;
|
|
80
|
+
readonly bracketMatchInfos: readonly BracketMatchInfo[];
|
|
81
|
+
readonly breadcrumbFileIcon?: string;
|
|
82
|
+
readonly breadcrumbsEnabled?: boolean;
|
|
83
|
+
readonly breakPoints: readonly number[];
|
|
84
|
+
readonly canCoalesceTyping?: boolean;
|
|
85
|
+
readonly charWidth: number;
|
|
86
|
+
readonly columnWidth: number;
|
|
87
|
+
readonly combineWhitespaceTokens?: boolean;
|
|
88
|
+
readonly completionsOnType?: boolean;
|
|
89
|
+
readonly completionState: string;
|
|
90
|
+
readonly completionTriggerCharacters: readonly string[];
|
|
91
|
+
readonly completionUid: number;
|
|
92
|
+
readonly completionWidgetDismissedOnBlur?: boolean;
|
|
93
|
+
readonly cursorInfos: readonly any[];
|
|
94
|
+
readonly cursorUndoStack?: readonly Uint32Array[];
|
|
95
|
+
readonly cursorWidth: number;
|
|
96
|
+
readonly debugEnabled: boolean;
|
|
97
|
+
readonly decorations: any;
|
|
98
|
+
readonly deltaX: number;
|
|
99
|
+
readonly deltaY: number;
|
|
100
|
+
readonly diagnostics: readonly any[];
|
|
101
|
+
readonly diagnosticsEnabled: boolean;
|
|
102
|
+
differences: any[];
|
|
103
|
+
readonly documentSymbols?: readonly DocumentSymbol[];
|
|
104
|
+
readonly dragAndDropEnabled: boolean;
|
|
105
|
+
readonly editorFileCacheEnabled?: boolean;
|
|
106
|
+
readonly embeds: any;
|
|
107
|
+
readonly endOfLine: EndOfLine;
|
|
108
|
+
readonly endOfLineDecorations: readonly EditorLineDecoration[];
|
|
109
|
+
readonly explicitLanguageId?: string;
|
|
110
|
+
readonly finalDeltaY: number;
|
|
111
|
+
readonly finalY: number;
|
|
112
|
+
readonly focus: number;
|
|
113
|
+
readonly focused: boolean;
|
|
114
|
+
readonly focusKey: number;
|
|
115
|
+
readonly foldingRanges: readonly {
|
|
116
|
+
readonly end: number;
|
|
117
|
+
readonly start: number;
|
|
118
|
+
}[];
|
|
119
|
+
readonly fontFamily: string;
|
|
120
|
+
readonly fontSize: number;
|
|
121
|
+
readonly fontWeight: number;
|
|
122
|
+
readonly formatOnSave?: boolean;
|
|
123
|
+
readonly gutterDecorations: readonly EditorGutterDecoration[];
|
|
124
|
+
readonly gutterWidth: number;
|
|
125
|
+
readonly handleOffset: number;
|
|
126
|
+
readonly handleOffsetX: number;
|
|
127
|
+
readonly hasListener: boolean;
|
|
128
|
+
readonly height: number;
|
|
129
|
+
readonly highlightActiveLineNumber: boolean;
|
|
130
|
+
readonly highlightedLine: number;
|
|
131
|
+
readonly horizontalVirtualizationThreshold?: number;
|
|
132
|
+
readonly horizontalVisibleRanges?: readonly {
|
|
133
|
+
readonly end: number;
|
|
134
|
+
readonly rowIndex: number;
|
|
135
|
+
readonly segments?: readonly number[];
|
|
136
|
+
readonly start: number;
|
|
137
|
+
}[];
|
|
138
|
+
readonly hoverDelay?: number;
|
|
139
|
+
readonly hoverEnabled: boolean;
|
|
140
|
+
readonly id: number;
|
|
141
|
+
readonly incrementalEdits: readonly any[];
|
|
142
|
+
readonly initial: boolean;
|
|
143
|
+
readonly insertSpaces: boolean;
|
|
144
|
+
readonly invalidStartIndex: number;
|
|
145
|
+
readonly isAutoClosingBracketsEnabled: boolean;
|
|
146
|
+
readonly isAutoClosingQuotesEnabled: boolean;
|
|
147
|
+
readonly isAutoClosingTagsEnabled: boolean;
|
|
148
|
+
readonly isMonospaceFont: boolean;
|
|
149
|
+
readonly isQuickSuggestionsEnabled: boolean;
|
|
150
|
+
readonly isSelecting: boolean;
|
|
151
|
+
readonly itemHeight: number;
|
|
152
|
+
readonly languageId: string;
|
|
153
|
+
readonly largeFile?: boolean;
|
|
154
|
+
readonly letterSpacing: number;
|
|
155
|
+
readonly lifecycle?: EditorLifecycle;
|
|
156
|
+
readonly lightBulbRowIndex: number;
|
|
157
|
+
readonly lineCache: readonly any[];
|
|
158
|
+
readonly lineNumbers: boolean;
|
|
159
|
+
readonly lines: readonly string[];
|
|
160
|
+
readonly loadError?: string;
|
|
161
|
+
readonly longestLineWidth: number;
|
|
162
|
+
readonly maxLineY: number;
|
|
163
|
+
readonly mergeConflictActionsEnabled: boolean;
|
|
164
|
+
readonly mergeConflicts: readonly MergeConflict[];
|
|
165
|
+
readonly messageDelay?: number;
|
|
166
|
+
readonly minimapEnabled: boolean;
|
|
167
|
+
readonly minimapLines: readonly (readonly (number | string)[])[];
|
|
168
|
+
readonly minimapRevision: number;
|
|
169
|
+
readonly minimumSliderSize: number;
|
|
170
|
+
readonly minLineY: number;
|
|
171
|
+
readonly modified: boolean;
|
|
172
|
+
readonly numberOfLines: number;
|
|
173
|
+
readonly numberOfVisibleLines: number;
|
|
174
|
+
readonly outerHeight?: number;
|
|
175
|
+
readonly outerWidth: number;
|
|
176
|
+
readonly platform: number;
|
|
177
|
+
readonly primarySelectionIndex: number;
|
|
178
|
+
readonly problemNavigationDiagnostic?: any;
|
|
179
|
+
readonly problemsHighlightedRow: number;
|
|
180
|
+
readonly redoStack: readonly any[];
|
|
181
|
+
readonly roundedSelection: boolean;
|
|
182
|
+
readonly rowHeight: number;
|
|
183
|
+
readonly savedSelections: readonly any[];
|
|
184
|
+
readonly scrollBarHeight: number;
|
|
185
|
+
readonly scrollBarWidth: number;
|
|
186
|
+
readonly scrollBarY?: number;
|
|
187
|
+
readonly selectedTextOccurrenceMatching?: string;
|
|
188
|
+
readonly selectionAnchorPosition: {
|
|
189
|
+
readonly rowIndex: number;
|
|
190
|
+
readonly columnIndex: number;
|
|
191
|
+
};
|
|
192
|
+
readonly selectionAutoMovePosition: {
|
|
193
|
+
readonly x: number;
|
|
194
|
+
readonly y: number;
|
|
195
|
+
};
|
|
196
|
+
readonly selectionInfos: readonly any[];
|
|
197
|
+
readonly selections: Uint32Array;
|
|
198
|
+
readonly tabSize: number;
|
|
199
|
+
readonly textDecorationDom?: readonly VirtualDomNode[];
|
|
200
|
+
readonly textDecorations?: readonly EditorTextDecoration[];
|
|
201
|
+
readonly textDragDropPosition: {
|
|
202
|
+
readonly rowIndex: number;
|
|
203
|
+
readonly columnIndex: number;
|
|
204
|
+
};
|
|
205
|
+
readonly textDragId: number;
|
|
206
|
+
readonly textInfos: readonly any[];
|
|
207
|
+
readonly tokenizerId: any;
|
|
208
|
+
readonly uid: number;
|
|
209
|
+
readonly undoStack: readonly any[];
|
|
210
|
+
readonly uri: string;
|
|
211
|
+
readonly useFunctionalRendering?: boolean;
|
|
212
|
+
readonly validLines: readonly number[];
|
|
213
|
+
readonly viewLineIndices: readonly number[];
|
|
214
|
+
readonly visibleLineIndices: readonly number[];
|
|
215
|
+
readonly visibleViewLineIndices: readonly number[];
|
|
216
|
+
readonly visualDecorations?: any;
|
|
217
|
+
readonly widgetRevision: number;
|
|
218
|
+
readonly widgets: readonly any[];
|
|
219
|
+
readonly width: number;
|
|
220
|
+
readonly workspaceUri?: string;
|
|
221
|
+
readonly x: number;
|
|
222
|
+
readonly y: number;
|
|
223
|
+
}
|
|
224
|
+
export interface EmbeddedEditor {
|
|
225
|
+
readonly dispose: () => Promise<void>;
|
|
226
|
+
readonly execute: (command: string, ...args: readonly any[]) => Promise<EditorState>;
|
|
227
|
+
readonly getState: () => EditorState;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Creates an editor owned by the caller, without starting a worker or installing
|
|
231
|
+
* message listeners. The host initializes the shared rpc-registry connections.
|
|
232
|
+
* Commands use document coordinates; the host owns display coordinate mapping.
|
|
233
|
+
*/
|
|
234
|
+
export declare const createEmbeddedEditor: (options: StandaloneEditorOptions) => Promise<EmbeddedEditor>;
|
|
235
|
+
|
|
236
|
+
export {};
|