@theia/plugin-ext 1.46.1 → 1.47.0-next.0
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/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts +0 -1
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts.map +1 -1
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js +5 -7
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js.map +1 -1
- package/lib/main/browser/view/plugin-view-registry.d.ts +2 -0
- package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
- package/lib/main/browser/view/plugin-view-registry.js +16 -3
- package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
- package/lib/plugin/custom-editors.js +1 -1
- package/lib/plugin/custom-editors.js.map +1 -1
- package/lib/plugin/notebook/notebook-kernels.d.ts +1 -1
- package/lib/plugin/notebook/notebook-kernels.d.ts.map +1 -1
- package/lib/plugin/notebook/notebook-kernels.js +4 -4
- package/lib/plugin/notebook/notebook-kernels.js.map +1 -1
- package/lib/plugin/notebook/notebooks.d.ts +1 -0
- package/lib/plugin/notebook/notebooks.d.ts.map +1 -1
- package/lib/plugin/notebook/notebooks.js +19 -0
- package/lib/plugin/notebook/notebooks.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +2 -1
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/webviews.d.ts +13 -1
- package/lib/plugin/webviews.d.ts.map +1 -1
- package/lib/plugin/webviews.js +15 -2
- package/lib/plugin/webviews.js.map +1 -1
- package/package.json +29 -29
- package/src/main/browser/notebooks/notebook-documents-and-editors-main.ts +5 -8
- package/src/main/browser/view/plugin-view-registry.ts +18 -3
- package/src/plugin/custom-editors.ts +1 -1
- package/src/plugin/notebook/notebook-kernels.ts +4 -4
- package/src/plugin/notebook/notebooks.ts +20 -0
- package/src/plugin/plugin-context.ts +2 -1
- package/src/plugin/webviews.ts +16 -2
|
@@ -294,11 +294,11 @@ export class NotebookKernelsExtImpl implements NotebookKernelsExt {
|
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
$acceptNotebookAssociation(handle: number, uri: UriComponents, value: boolean): void {
|
|
297
|
+
async $acceptNotebookAssociation(handle: number, uri: UriComponents, value: boolean): Promise<void> {
|
|
298
298
|
const obj = this.kernelData.get(handle);
|
|
299
299
|
if (obj) {
|
|
300
300
|
// update data structure
|
|
301
|
-
const notebook = this.notebooks.
|
|
301
|
+
const notebook = await this.notebooks.waitForNotebookDocument(URI.from(uri));
|
|
302
302
|
if (value) {
|
|
303
303
|
obj.associatedNotebooks.set(notebook.uri.toString(), true);
|
|
304
304
|
} else {
|
|
@@ -320,7 +320,7 @@ export class NotebookKernelsExtImpl implements NotebookKernelsExt {
|
|
|
320
320
|
// extension can dispose kernels in the meantime
|
|
321
321
|
return Promise.resolve();
|
|
322
322
|
}
|
|
323
|
-
const document = this.notebooks.
|
|
323
|
+
const document = await this.notebooks.waitForNotebookDocument(URI.from(uri));
|
|
324
324
|
const cells: theia.NotebookCell[] = [];
|
|
325
325
|
for (const cellHandle of handles) {
|
|
326
326
|
const cell = document.getCell(cellHandle);
|
|
@@ -347,7 +347,7 @@ export class NotebookKernelsExtImpl implements NotebookKernelsExt {
|
|
|
347
347
|
|
|
348
348
|
// cancel or interrupt depends on the controller. When an interrupt handler is used we
|
|
349
349
|
// don't trigger the cancelation token of executions.N
|
|
350
|
-
const document = this.notebooks.
|
|
350
|
+
const document = await this.notebooks.waitForNotebookDocument(URI.from(uri));
|
|
351
351
|
if (obj.controller.interruptHandler) {
|
|
352
352
|
await obj.controller.interruptHandler.call(obj.controller, document.apiNotebook);
|
|
353
353
|
|
|
@@ -312,6 +312,26 @@ export class NotebooksExtImpl implements NotebooksExt {
|
|
|
312
312
|
return result;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
waitForNotebookDocument(uri: TheiaURI, duration = 2000): Promise<NotebookDocument> {
|
|
316
|
+
const existing = this.getNotebookDocument(uri, true);
|
|
317
|
+
if (existing) {
|
|
318
|
+
return Promise.resolve(existing);
|
|
319
|
+
}
|
|
320
|
+
return new Promise<NotebookDocument>((resolve, reject) => {
|
|
321
|
+
const listener = this.onDidOpenNotebookDocument(event => {
|
|
322
|
+
if (event.uri.toString() === uri.toString()) {
|
|
323
|
+
clearTimeout(timeout);
|
|
324
|
+
listener.dispose();
|
|
325
|
+
resolve(this.getNotebookDocument(uri));
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
const timeout = setTimeout(() => {
|
|
329
|
+
listener.dispose();
|
|
330
|
+
reject(new Error(`Notebook document did NOT open in ${duration}ms: ${uri}`));
|
|
331
|
+
}, duration);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
315
335
|
private createExtHostEditor(document: NotebookDocument, editorId: string, data: NotebookEditorAddData): void {
|
|
316
336
|
|
|
317
337
|
if (this.editors.has(editorId)) {
|
|
@@ -709,7 +709,8 @@ export function createAPIFactory(
|
|
|
709
709
|
} else {
|
|
710
710
|
throw new Error('Invalid arguments');
|
|
711
711
|
}
|
|
712
|
-
|
|
712
|
+
const result = await notebooksExt.waitForNotebookDocument(uri);
|
|
713
|
+
return result.apiNotebook;
|
|
713
714
|
|
|
714
715
|
},
|
|
715
716
|
createFileSystemWatcher: (pattern, ignoreCreate, ignoreChange, ignoreDelete): theia.FileSystemWatcher =>
|
package/src/plugin/webviews.ts
CHANGED
|
@@ -126,19 +126,33 @@ export class WebviewsExtImpl implements WebviewsExt {
|
|
|
126
126
|
return panel;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new webview panel.
|
|
131
|
+
*
|
|
132
|
+
* @param viewType Identifies the type of the webview panel.
|
|
133
|
+
* @param title Title of the panel.
|
|
134
|
+
* @param showOptions Where webview panel will be reside.
|
|
135
|
+
* @param options Settings for the new panel.
|
|
136
|
+
* @param plugin The plugin contributing the webview.
|
|
137
|
+
* @param viewId The identifier of the webview instance.
|
|
138
|
+
* @param originBasedOnType true if a stable origin based on the viewType shall be used, false if the viewId should be used.
|
|
139
|
+
* @returns The new webview panel.
|
|
140
|
+
*/
|
|
129
141
|
createWebviewPanel(
|
|
130
142
|
viewType: string,
|
|
131
143
|
title: string,
|
|
132
144
|
showOptions: theia.ViewColumn | theia.WebviewPanelShowOptions,
|
|
133
145
|
options: theia.WebviewPanelOptions & theia.WebviewOptions,
|
|
134
146
|
plugin: Plugin,
|
|
135
|
-
viewId: string
|
|
147
|
+
viewId: string,
|
|
148
|
+
originBasedOnType = true
|
|
136
149
|
): WebviewPanelImpl {
|
|
137
150
|
if (!this.initData) {
|
|
138
151
|
throw new Error('Webviews are not initialized');
|
|
139
152
|
}
|
|
140
153
|
const webviewShowOptions = toWebviewPanelShowOptions(showOptions);
|
|
141
|
-
const
|
|
154
|
+
const origin = originBasedOnType ? hashValue(viewType) : undefined;
|
|
155
|
+
const webview = new WebviewImpl(viewId, this.proxy, options, this.initData, this.workspace, plugin, origin);
|
|
142
156
|
const panel = new WebviewPanelImpl(viewId, this.proxy, viewType, title, webviewShowOptions, options, webview);
|
|
143
157
|
this.webviewPanels.set(viewId, panel);
|
|
144
158
|
return panel;
|