@difizen/libro-code-editor 0.1.1 → 0.1.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.
Files changed (42) hide show
  1. package/es/code-editor-info-manager.d.ts +7 -0
  2. package/es/code-editor-info-manager.d.ts.map +1 -0
  3. package/es/code-editor-info-manager.js +32 -0
  4. package/es/code-editor-manager.d.ts +67 -0
  5. package/es/code-editor-manager.d.ts.map +1 -0
  6. package/es/code-editor-manager.js +130 -0
  7. package/es/{model.d.ts → code-editor-model.d.ts} +2 -2
  8. package/es/code-editor-model.d.ts.map +1 -0
  9. package/es/{model.js → code-editor-model.js} +1 -3
  10. package/es/{code-editor.d.ts → code-editor-protocol.d.ts} +70 -145
  11. package/es/code-editor-protocol.d.ts.map +1 -0
  12. package/es/{code-editor.js → code-editor-protocol.js} +17 -15
  13. package/es/code-editor-settings.d.ts +34 -0
  14. package/es/code-editor-settings.d.ts.map +1 -0
  15. package/es/code-editor-settings.js +225 -0
  16. package/es/code-editor-view.d.ts +26 -14
  17. package/es/code-editor-view.d.ts.map +1 -1
  18. package/es/code-editor-view.js +108 -72
  19. package/es/index.d.ts +5 -3
  20. package/es/index.d.ts.map +1 -1
  21. package/es/index.js +6 -4
  22. package/es/mimetype.d.ts.map +1 -1
  23. package/es/mimetype.js +3 -0
  24. package/es/module.d.ts.map +1 -1
  25. package/es/module.js +5 -2
  26. package/package.json +4 -5
  27. package/src/code-editor-info-manager.ts +25 -0
  28. package/src/code-editor-manager.ts +86 -0
  29. package/src/{model.ts → code-editor-model.ts} +4 -4
  30. package/src/{code-editor.ts → code-editor-protocol.ts} +136 -189
  31. package/src/code-editor-settings.ts +214 -0
  32. package/src/code-editor-view.tsx +93 -49
  33. package/src/index.spec.ts +1 -3
  34. package/src/index.ts +5 -3
  35. package/src/mimetype.ts +3 -0
  36. package/src/module.ts +13 -2
  37. package/es/code-editor.d.ts.map +0 -1
  38. package/es/completer/completer-protocol.d.ts +0 -210
  39. package/es/completer/completer-protocol.d.ts.map +0 -1
  40. package/es/completer/completer-protocol.js +0 -34
  41. package/es/model.d.ts.map +0 -1
  42. package/src/completer/completer-protocol.ts +0 -259
@@ -1,23 +1,34 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
1
4
  import { getOrigin, prop } from '@difizen/mana-app';
2
- import { BaseView, view, ViewOption } from '@difizen/mana-app';
3
- import { inject, transient } from '@difizen/mana-app';
4
- import { Deferred, Emitter } from '@difizen/mana-app';
5
+ import {
6
+ inject,
7
+ transient,
8
+ Deferred,
9
+ Emitter,
10
+ BaseView,
11
+ ThemeService,
12
+ view,
13
+ ViewOption,
14
+ } from '@difizen/mana-app';
5
15
  import { forwardRef, memo } from 'react';
6
16
 
7
- import type { IEditor } from './code-editor.js';
17
+ import { CodeEditorInfoManager } from './code-editor-info-manager.js';
18
+ import type { CodeEditorFactory } from './code-editor-manager.js';
19
+ import type { IModel } from './code-editor-model.js';
8
20
  import type {
9
- CodeEditorFactory,
21
+ CompletionProvider,
10
22
  ICoordinate,
11
23
  IEditorConfig,
12
24
  IEditorSelectionStyle,
13
- CompletionProvider,
14
25
  TooltipProvider,
15
- LSPProvider,
16
- } from './code-editor.js';
17
- import type { IModel } from './model.js';
26
+ } from './code-editor-protocol.js';
27
+ import type { IEditor } from './code-editor-protocol.js';
28
+ import { CodeEditorSettings } from './code-editor-settings.js';
18
29
 
19
30
  export const CodeEditorRender = memo(
20
- forwardRef<HTMLDivElement>((_props, ref) => {
31
+ forwardRef<HTMLDivElement>((props, ref) => {
21
32
  return <div ref={ref} />;
22
33
  }),
23
34
  );
@@ -49,6 +60,11 @@ const leadingWhitespaceRe = /^\s+$/;
49
60
  @transient()
50
61
  @view('code-editor-view')
51
62
  export class CodeEditorView extends BaseView {
63
+ @inject(ThemeService) protected readonly themeService: ThemeService;
64
+ @inject(CodeEditorSettings) protected readonly codeEditorSettings: CodeEditorSettings;
65
+
66
+ codeEditorInfoManager: CodeEditorInfoManager;
67
+
52
68
  override view = CodeEditorRender;
53
69
 
54
70
  protected classlist: string[] = [];
@@ -57,6 +73,8 @@ export class CodeEditorView extends BaseView {
57
73
 
58
74
  protected modalChangeEmitter = new Emitter();
59
75
 
76
+ protected editorHostRef: any;
77
+
60
78
  get onModalChange() {
61
79
  return this.modalChangeEmitter.event;
62
80
  }
@@ -65,7 +83,7 @@ export class CodeEditorView extends BaseView {
65
83
  * Get the editor wrapped by the widget.
66
84
  */
67
85
  @prop()
68
- editor: IEditor | undefined;
86
+ editor: IEditor;
69
87
  protected editorReadyDeferred: Deferred<void> = new Deferred<void>();
70
88
  get editorReady() {
71
89
  return this.editorReadyDeferred.promise;
@@ -73,23 +91,36 @@ export class CodeEditorView extends BaseView {
73
91
  /**
74
92
  * Construct a new code editor widget.
75
93
  */
76
- constructor(@inject(ViewOption) options: CodeEditorViewOptions) {
94
+ constructor(
95
+ @inject(ViewOption) options: CodeEditorViewOptions,
96
+ @inject(CodeEditorInfoManager) codeEditorInfoManager: CodeEditorInfoManager,
97
+ ) {
77
98
  super();
78
99
  this.options = options;
100
+ this.codeEditorInfoManager = codeEditorInfoManager;
79
101
  }
80
102
 
81
- override onViewMount() {
82
- const node = this.container?.current;
83
- if (node) {
103
+ override async onViewMount() {
104
+ const settings = this.codeEditorSettings.getUserEditorSettings();
105
+
106
+ const editorHostId = this.options.editorHostId;
107
+ const editorHostRef = editorHostId
108
+ ? this.codeEditorInfoManager.getEditorHostRef(editorHostId)
109
+ : undefined;
110
+
111
+ this.editorHostRef =
112
+ editorHostRef && editorHostRef.current ? editorHostRef : this.container;
113
+
114
+ if (this.editorHostRef.current && this.options.factory) {
84
115
  this.editor = this.options.factory({
85
- host: node,
116
+ ...this.options,
117
+ host: this.editorHostRef.current,
86
118
  model: this.options.model,
87
119
  uuid: this.options.uuid,
88
- config: this.options.config,
120
+ config: { ...settings, ...this.options.config },
89
121
  selectionStyle: this.options.selectionStyle,
90
122
  tooltipProvider: this.options.tooltipProvider,
91
123
  completionProvider: this.options.completionProvider,
92
- lspProvider: this.options.lspProvider,
93
124
  });
94
125
  this.editorReadyDeferred.resolve();
95
126
  this.editor.onModalChange((val) => this.modalChangeEmitter.fire(val));
@@ -99,30 +130,52 @@ export class CodeEditorView extends BaseView {
99
130
  getOrigin(this.editor).focus();
100
131
  }
101
132
 
102
- node.addEventListener('focus', this.onViewActive);
103
- node.addEventListener('dragenter', this._evtDragEnter);
104
- node.addEventListener('dragleave', this._evtDragLeave);
105
- node.addEventListener('dragover', this._evtDragOver);
106
- node.addEventListener('drop', this._evtDrop);
133
+ this.editorHostRef.current.addEventListener('focus', this.onViewActive);
134
+ this.editorHostRef.current.addEventListener('dragenter', this._evtDragEnter);
135
+ this.editorHostRef.current.addEventListener('dragleave', this._evtDragLeave);
136
+ this.editorHostRef.current.addEventListener('dragover', this._evtDragOver);
137
+ this.editorHostRef.current.addEventListener('drop', this._evtDrop);
138
+
139
+ this.toDispose.push(
140
+ this.codeEditorSettings.onCodeEditorSettingsChange((e) => {
141
+ this.editor.setOption(e.key, e.value);
142
+ }),
143
+ );
107
144
  }
108
145
  }
109
146
 
110
- override onViewUnmount() {
111
- const node = this.container?.current;
147
+ removeChildNodes = (parent: any) => {
148
+ while (parent.firstChild) {
149
+ parent.removeChild(parent.firstChild);
150
+ }
151
+ };
152
+
153
+ override onViewUnmount = () => {
154
+ if (this.editor.dispose) {
155
+ this.editor.dispose();
156
+ }
157
+
158
+ const node = this.editorHostRef?.current;
112
159
  if (node) {
113
160
  node.removeEventListener('focus', this.onViewActive);
114
161
  node.removeEventListener('dragenter', this._evtDragEnter);
115
162
  node.removeEventListener('dragleave', this._evtDragLeave);
116
163
  node.removeEventListener('dragover', this._evtDragOver);
117
164
  node.removeEventListener('drop', this._evtDrop);
165
+
166
+ this.removeChildNodes(node);
118
167
  }
168
+ };
169
+
170
+ override onViewResize() {
171
+ this.editor?.resizeToFit();
119
172
  }
120
173
 
121
174
  /**
122
175
  * Get the model used by the widget.
123
176
  */
124
- get model(): IModel | undefined {
125
- return this.editor?.model;
177
+ get model(): IModel {
178
+ return this.editor.model;
126
179
  }
127
180
 
128
181
  /**
@@ -133,11 +186,11 @@ export class CodeEditorView extends BaseView {
133
186
  return;
134
187
  }
135
188
  super.dispose();
136
- this.editor?.dispose();
189
+ this.editor.dispose();
137
190
  }
138
191
 
139
192
  protected onViewActive = (): void => {
140
- this.editor?.focus();
193
+ this.editor.focus();
141
194
  };
142
195
 
143
196
  /**
@@ -145,7 +198,7 @@ export class CodeEditorView extends BaseView {
145
198
  */
146
199
  protected onResize(): void {
147
200
  if (this.isVisible) {
148
- this.editor?.resizeToFit();
201
+ this.editor.resizeToFit();
149
202
  }
150
203
  }
151
204
 
@@ -164,9 +217,6 @@ export class CodeEditorView extends BaseView {
164
217
  * Handle a change in model selections.
165
218
  */
166
219
  protected _onSelectionsChanged(): void {
167
- if (!this.editor) {
168
- return;
169
- }
170
220
  const { start, end } = this.editor.getSelection();
171
221
 
172
222
  if (start.column !== end.column || start.line !== end.line) {
@@ -191,9 +241,6 @@ export class CodeEditorView extends BaseView {
191
241
  * Handle the `'lm-dragenter'` event for the widget.
192
242
  */
193
243
  protected _evtDragEnter = (event: DragEvent): void => {
194
- if (!this.editor) {
195
- return;
196
- }
197
244
  if (this.editor.getOption('readOnly') === true) {
198
245
  return;
199
246
  }
@@ -210,9 +257,6 @@ export class CodeEditorView extends BaseView {
210
257
  * Handle the `'lm-dragleave'` event for the widget.
211
258
  */
212
259
  protected _evtDragLeave = (event: DragEvent): void => {
213
- if (!this.editor) {
214
- return;
215
- }
216
260
  this.removeClass(DROP_TARGET_CLASS);
217
261
  if (this.editor.getOption('readOnly') === true) {
218
262
  return;
@@ -229,9 +273,6 @@ export class CodeEditorView extends BaseView {
229
273
  * Handle the `'lm-dragover'` event for the widget.
230
274
  */
231
275
  protected _evtDragOver = (event: DragEvent): void => {
232
- if (!this.editor) {
233
- return;
234
- }
235
276
  this.removeClass(DROP_TARGET_CLASS);
236
277
  if (this.editor.getOption('readOnly') === true) {
237
278
  return;
@@ -250,9 +291,6 @@ export class CodeEditorView extends BaseView {
250
291
  * Handle the `'lm-drop'` event for the widget.
251
292
  */
252
293
  protected _evtDrop = (event: DragEvent): void => {
253
- if (!this.editor) {
254
- return;
255
- }
256
294
  if (this.editor.getOption('readOnly') === true) {
257
295
  return;
258
296
  }
@@ -292,7 +330,7 @@ export class CodeEditorView extends BaseView {
292
330
  /**
293
331
  * The options used to initialize a code editor widget.
294
332
  */
295
- export interface CodeEditorViewOptions {
333
+ export interface CodeEditorViewOptions<Config extends IEditorConfig = IEditorConfig> {
296
334
  /**
297
335
  * A code editor factory.
298
336
  *
@@ -300,7 +338,12 @@ export interface CodeEditorViewOptions {
300
338
  * The widget needs a factory and a model instead of a `CodeEditor.IEditor`
301
339
  * object because it needs to provide its own node as the host.
302
340
  */
303
- factory: CodeEditorFactory;
341
+ factory?: CodeEditorFactory;
342
+
343
+ /**
344
+ * where to mount the editor
345
+ */
346
+ editorHostId?: string;
304
347
 
305
348
  /**
306
349
  * The model used to initialize the code editor.
@@ -315,7 +358,7 @@ export interface CodeEditorViewOptions {
315
358
  /**
316
359
  * The configuration options for the editor.
317
360
  */
318
- config?: Partial<IEditorConfig>;
361
+ config?: Partial<Config>;
319
362
 
320
363
  /**
321
364
  * The default selection style for the editor.
@@ -324,9 +367,10 @@ export interface CodeEditorViewOptions {
324
367
 
325
368
  tooltipProvider?: TooltipProvider;
326
369
  completionProvider?: CompletionProvider;
327
- lspProvider?: LSPProvider;
328
370
 
329
371
  autoFocus?: boolean;
372
+
373
+ [key: string]: any;
330
374
  }
331
375
 
332
376
  /**
package/src/index.spec.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import 'reflect-metadata';
2
2
  import assert from 'assert';
3
3
 
4
- import { CodeEditorView, CodeEditorModule, defaultMimeType } from './index.js';
4
+ import { CodeEditorView } from './index.js';
5
5
 
6
6
  describe('libro-code-editor', () => {
7
7
  it('#import', () => {
8
8
  assert(CodeEditorView);
9
- assert(CodeEditorModule);
10
- assert(defaultMimeType);
11
9
  });
12
10
  });
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
- export * from './code-editor.js';
2
- export * from './mimetype.js';
1
+ export * from './code-editor-manager.js';
2
+ export * from './code-editor-model.js';
3
+ export * from './code-editor-protocol.js';
4
+ export * from './code-editor-settings.js';
3
5
  export * from './code-editor-view.js';
6
+ export * from './mimetype.js';
4
7
  export * from './module.js';
5
- export * from './model.js';
package/src/mimetype.ts CHANGED
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+
1
4
  import type { ILanguageInfoMetadata } from '@difizen/libro-common';
2
5
 
3
6
  /**
package/src/module.ts CHANGED
@@ -1,6 +1,17 @@
1
1
  import { ManaModule } from '@difizen/mana-app';
2
2
 
3
+ import { CodeEditorInfoManager } from './code-editor-info-manager.js';
4
+ import { CodeEditorContribution, CodeEditorManager } from './code-editor-manager.js';
5
+ import { Model } from './code-editor-model.js';
6
+ import { CodeEditorSettings } from './code-editor-settings.js';
3
7
  import { CodeEditorView } from './code-editor-view.js';
4
- import { Model } from './model.js';
5
8
 
6
- export const CodeEditorModule = ManaModule.create().register(CodeEditorView, Model);
9
+ export const CodeEditorModule = ManaModule.create()
10
+ .register(
11
+ CodeEditorInfoManager,
12
+ CodeEditorView,
13
+ CodeEditorManager,
14
+ Model,
15
+ CodeEditorSettings,
16
+ )
17
+ .contribution(CodeEditorContribution);
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-editor.d.ts","sourceRoot":"","sources":["../src/code-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EACV,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AAEx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IAAI,CAAC;IAGd;;OAEG;IACH,cAAc,IAAI,IAAI,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IAE5C;;OAEG;IACH,UAAU,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IAE9C;;OAEG;IACH,SAAS,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IAE7C;;OAEG;IACH,uBAAuB,CAAC,QAAQ,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAEtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,kBAAkB,GAAG,OAAO,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,SAAS,CAAC;IAE5D;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC;IAQ5C,eAAe,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IAC9C,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACpD,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACvC"}
@@ -1,210 +0,0 @@
1
- import type { SourceChange } from '@difizen/libro-shared-model';
2
- import { Syringe } from '@difizen/mana-app';
3
- import type { View } from '@difizen/mana-app';
4
- import type { Event } from '@difizen/mana-app';
5
- import type React from 'react';
6
- import type { IEditor } from '../code-editor.js';
7
- /**
8
- * The context which will be passed to the `fetch` function
9
- * of a provider.
10
- */
11
- export interface CompletionContext {
12
- /**
13
- * The widget (notebook, console, code editor) which invoked
14
- * the completer
15
- */
16
- widget: View;
17
- /**
18
- * The current editor.
19
- */
20
- editor?: IEditor | null;
21
- }
22
- /**
23
- * An object describing a completion option injection into text.
24
- */
25
- export interface IPatch {
26
- /**
27
- * The start of the range to be patched.
28
- */
29
- start: number;
30
- /**
31
- * The end of the range to be patched.
32
- */
33
- end: number;
34
- /**
35
- * The value to be patched in.
36
- */
37
- value: string;
38
- }
39
- /**
40
- * Completion item object based off of LSP CompletionItem.
41
- * Compared to the old kernel completions interface, this enhances the completions UI to support:
42
- * - differentiation between inserted text and user facing text
43
- * - documentation for each completion item to be displayed adjacently
44
- * - deprecation styling
45
- * - custom icons
46
- * and other potential new features.
47
- */
48
- export interface ICompletionItem {
49
- /**
50
- * User facing completion.
51
- * If insertText is not set, this will be inserted.
52
- */
53
- label: string;
54
- /**
55
- * Completion to be inserted.
56
- */
57
- insertText?: string;
58
- /**
59
- * Type of this completion item.
60
- */
61
- type?: string;
62
- /**
63
- * LabIcon object for icon to be rendered with completion type.
64
- */
65
- icon?: React.ReactNode;
66
- /**
67
- * A human-readable string with additional information
68
- * about this item, like type or symbol information.
69
- */
70
- documentation?: string;
71
- /**
72
- * Indicates if the item is deprecated.
73
- */
74
- deprecated?: boolean;
75
- resolve?: (patch?: IPatch) => Promise<ICompletionItem>;
76
- }
77
- /**
78
- * A reply to a completion items fetch request.
79
- */
80
- export interface ICompletionItemsReply<T extends ICompletionItem = ICompletionItem> {
81
- /**
82
- * The starting index for the substring being replaced by completion.
83
- */
84
- start: number;
85
- /**
86
- * The end index for the substring being replaced by completion.
87
- */
88
- end: number;
89
- /**
90
- * A list of completion items. default to CompletionHandler.ICompletionItems
91
- */
92
- items: T[];
93
- }
94
- /**
95
- * The details of a completion request.
96
- */
97
- export interface IRequest {
98
- /**
99
- * The cursor offset position within the text being completed.
100
- */
101
- offset: number;
102
- /**
103
- * The text being completed.
104
- */
105
- text: string;
106
- }
107
- export declare const CompletionProvider: Syringe.DefinedToken;
108
- /**
109
- * The interface to implement a completer provider.
110
- */
111
- export interface CompletionProvider<T extends ICompletionItem = ICompletionItem> {
112
- /**
113
- * Unique identifier of the provider
114
- */
115
- readonly identifier: string;
116
- /**
117
- * Renderer for provider's completions (optional).
118
- */
119
- /**
120
- * Is completion provider applicable to specified context?
121
- * @param request - the completion request text and details
122
- * @param context - additional information about context of completion request
123
- */
124
- isApplicable: (context: CompletionContext) => Promise<boolean>;
125
- /**
126
- * Fetch completion requests.
127
- *
128
- * @param request - the completion request text and details
129
- * @param context - additional information about context of completion request
130
- */
131
- fetch: (request: IRequest, context: CompletionContext) => Promise<ICompletionItemsReply<T>>;
132
- /**
133
- * This method is called to customize the model of a completer widget.
134
- * If it is not provided, the default model will be used.
135
- *
136
- * @param context - additional information about context of completion request
137
- * @returns The completer model
138
- */
139
- modelFactory?: (context: CompletionContext) => Promise<Record<string, any>>;
140
- /**
141
- * Given an incomplete (unresolved) completion item, resolve it by adding
142
- * all missing details, such as lazy-fetched documentation.
143
- *
144
- * @param completion - the completion item to resolve
145
- * @param context - The context of the completer
146
- * @param patch - The text which will be injected if the completion item is
147
- * selected.
148
- */
149
- resolve?: (completionItem: T, context: CompletionContext, patch?: IPatch | null) => Promise<T>;
150
- /**
151
- * If users enable `autoCompletion` in setting, this method is
152
- * called on text changed event of `CodeMirror` to check if the
153
- * completion items should be shown.
154
- *
155
- * @param completerIsVisible - Current visibility status of the
156
- * completer widget0
157
- * @param changed - changed text.
158
- */
159
- shouldShowContinuousHint?: (completerIsVisible: boolean, changed: SourceChange) => boolean;
160
- }
161
- export interface ICompletionProviderManager {
162
- /**
163
- * Register a completer provider with the manager.
164
- *
165
- * @param {CompletionProvider} provider - the provider to be registered.
166
- */
167
- registerProvider: (provider: CompletionProvider) => void;
168
- /**
169
- * Invoke the completer in the widget with provided id.
170
- *
171
- * @param {string} id - the id of notebook panel, console panel or code editor.
172
- */
173
- invoke: (id: string) => void;
174
- /**
175
- * Activate `select` command in the widget with provided id.
176
- *
177
- * @param {string} id - the id of notebook panel, console panel or code editor.
178
- */
179
- select: (id: string) => void;
180
- /**
181
- * Update completer handler of a widget with new context.
182
- *
183
- * @param newCompleterContext - The completion context.
184
- */
185
- updateCompleter: (newCompleterContext: CompletionContext) => Promise<void>;
186
- /**
187
- * Signal emitted when active providers list is changed.
188
- */
189
- activeProvidersChanged: Event<void>;
190
- }
191
- export interface IConnectorProxy {
192
- /**
193
- * Fetch response from multiple providers, If a provider can not return
194
- * the response for a completer request before timeout,
195
- * the result of this provider will be ignore.
196
- *
197
- * @param {CompletionHandler.IRequest} request - The completion request.
198
- */
199
- fetch: (request: IRequest) => Promise<(ICompletionItemsReply | null)[]>;
200
- /**
201
- * Check if completer should make request to fetch completion responses
202
- * on user typing. If the provider with highest rank does not have
203
- * `shouldShowContinuousHint` method, a default one will be used.
204
- *
205
- * @param completerIsVisible - The visible status of completer widget.
206
- * @param changed - CodeMirror changed argument.
207
- */
208
- shouldShowContinuousHint: (completerIsVisible: boolean, changed: SourceChange) => boolean;
209
- }
210
- //# sourceMappingURL=completer-protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"completer-protocol.d.ts","sourceRoot":"","sources":["../../src/completer/completer-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAC;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAMzB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,KAAK,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'@difizen/mana-app';
2
-
3
- /**
4
- * The context which will be passed to the `fetch` function
5
- * of a provider.
6
- */
7
-
8
- /**
9
- * An object describing a completion option injection into text.
10
- */
11
-
12
- /**
13
- * Completion item object based off of LSP CompletionItem.
14
- * Compared to the old kernel completions interface, this enhances the completions UI to support:
15
- * - differentiation between inserted text and user facing text
16
- * - documentation for each completion item to be displayed adjacently
17
- * - deprecation styling
18
- * - custom icons
19
- * and other potential new features.
20
- */
21
-
22
- /**
23
- * A reply to a completion items fetch request.
24
- */
25
-
26
- /**
27
- * The details of a completion request.
28
- */
29
-
30
- export var CompletionProvider = new Syringe.DefinedToken('CompletionProvider');
31
-
32
- /**
33
- * The interface to implement a completer provider.
34
- */
package/es/model.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,qBACa,KAAM,YAAW,MAAM;IAClC,EAAE,EAAE,MAAM,CAAC;IACX;;OA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