notebooks: remove old renderer api
This commit is contained in:
parent
d0c212ce1e
commit
8a0f4763b1
1 changed files with 1 additions and 55 deletions
|
@ -158,48 +158,6 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const runRenderScript = async (url: string, rendererId: string): Promise<ScriptModule> => {
|
|
||||||
const text = await loadScriptSource(url);
|
|
||||||
// TODO: Support both the new module based renderers and the old style global renderers
|
|
||||||
const isModule = !text.includes('acquireNotebookRendererApi');
|
|
||||||
if (isModule) {
|
|
||||||
return __import(url);
|
|
||||||
} else {
|
|
||||||
return createBackCompatModule(rendererId, url, text);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const createBackCompatModule = (rendererId: string, scriptUrl: string, scriptText: string): ScriptModule => ({
|
|
||||||
activate: (): RendererApi => {
|
|
||||||
const onDidCreateOutput = createEmitter<IOutputItem>();
|
|
||||||
const onWillDestroyOutput = createEmitter<undefined | IDestroyCellInfo>();
|
|
||||||
|
|
||||||
const globals = {
|
|
||||||
scriptUrl,
|
|
||||||
acquireNotebookRendererApi: <T>(): GlobalNotebookRendererApi<T> => ({
|
|
||||||
onDidCreateOutput: onDidCreateOutput.event,
|
|
||||||
onWillDestroyOutput: onWillDestroyOutput.event,
|
|
||||||
setState: newState => vscode.setState({ ...vscode.getState(), [rendererId]: newState }),
|
|
||||||
getState: () => {
|
|
||||||
const state = vscode.getState();
|
|
||||||
return typeof state === 'object' && state ? state[rendererId] as T : undefined;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
invokeSourceWithGlobals(scriptText, globals);
|
|
||||||
|
|
||||||
return {
|
|
||||||
renderOutputItem(outputItem) {
|
|
||||||
onDidCreateOutput.fire({ ...outputItem, outputId: outputItem.id });
|
|
||||||
},
|
|
||||||
disposeOutputItem(id) {
|
|
||||||
onWillDestroyOutput.fire(id ? { outputId: id } : undefined);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const dimensionUpdater = new class {
|
const dimensionUpdater = new class {
|
||||||
private readonly pending = new Map<string, webviewMessages.DimensionUpdate>();
|
private readonly pending = new Map<string, webviewMessages.DimensionUpdate>();
|
||||||
|
|
||||||
|
@ -477,20 +435,8 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
|
||||||
bytes(): Uint8Array;
|
bytes(): Uint8Array;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IDestroyCellInfo {
|
|
||||||
outputId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const onDidReceiveKernelMessage = createEmitter<unknown>();
|
const onDidReceiveKernelMessage = createEmitter<unknown>();
|
||||||
|
|
||||||
/** @deprecated */
|
|
||||||
interface GlobalNotebookRendererApi<T> {
|
|
||||||
setState: (newState: T) => void;
|
|
||||||
getState(): T | undefined;
|
|
||||||
readonly onWillDestroyOutput: Event<undefined | IDestroyCellInfo>;
|
|
||||||
readonly onDidCreateOutput: Event<IOutputItem>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const kernelPreloadGlobals = {
|
const kernelPreloadGlobals = {
|
||||||
acquireVsCodeApi,
|
acquireVsCodeApi,
|
||||||
onDidReceiveKernelMessage: onDidReceiveKernelMessage.event,
|
onDidReceiveKernelMessage: onDidReceiveKernelMessage.event,
|
||||||
|
@ -766,7 +712,7 @@ async function webviewPreloads(style: PreloadStyles, options: PreloadOptions, re
|
||||||
|
|
||||||
/** Inner function cached in the _loadPromise(). */
|
/** Inner function cached in the _loadPromise(). */
|
||||||
private async _load(): Promise<RendererApi | undefined> {
|
private async _load(): Promise<RendererApi | undefined> {
|
||||||
const module = await runRenderScript(this.data.entrypoint, this.data.id);
|
const module = await __import(this.data.entrypoint);
|
||||||
if (!module) {
|
if (!module) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue