Skip to content

Commit

Permalink
Remove deprecated notebook output item fields
Browse files Browse the repository at this point in the history
These old properties are not document and have been deperecated for a few iterations now
  • Loading branch information
mjbvz committed Aug 20, 2021
1 parent f46990a commit e410db3
Showing 1 changed file with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,21 +455,41 @@ async function webviewPreloads(ctx: PreloadContext) {
interface IOutputItem {
readonly id: string;

/** @deprecated */
readonly outputId?: string;

/** @deprecated */
readonly element: HTMLElement;

readonly mime: string;
metadata: unknown;

text(): string;
json(): any;
data(): Uint8Array;
blob(): Blob;
/** @deprecated */
bytes(): Uint8Array;
}

class OutputItem implements IOutputItem {
constructor(
public readonly id: string,
public readonly element: HTMLElement,
public readonly mime: string,
public readonly metadata: unknown,
public readonly valueBytes: Uint8Array
) { }

data() {
return this.valueBytes;
}

bytes() { return this.data(); }

text() {
return new TextDecoder().decode(this.valueBytes);
}

json() {
return JSON.parse(this.text());
}

blob() {
return new Blob([this.valueBytes], { type: this.mime });
}
}

const onDidReceiveKernelMessage = createEmitter<unknown>();
Expand Down Expand Up @@ -555,25 +575,7 @@ async function webviewPreloads(ctx: PreloadContext) {
} else {
const rendererApi = preloadsAndErrors[0] as RendererApi;
try {
rendererApi.renderOutputItem({
id: outputId,
element: outputNode,
mime: content.mimeType,
metadata: content.metadata,
data() {
return content.valueBytes;
},
bytes() { return this.data(); },
text() {
return new TextDecoder().decode(content.valueBytes);
},
json() {
return JSON.parse(this.text());
},
blob() {
return new Blob([content.valueBytes], { type: content.mimeType });
}
}, outputNode);
rendererApi.renderOutputItem(new OutputItem(outputId, outputNode, content.mimeType, content.mimeType, content.valueBytes), outputNode);
} catch (e) {
showPreloadErrors(outputNode, e);
}
Expand Down Expand Up @@ -956,7 +958,7 @@ async function webviewPreloads(ctx: PreloadContext) {
public deleteMarkupCell(id: string) {
const cell = this.getExpectedMarkupCell(id);
if (cell) {
cell.element.remove();
cell.remove();
this._markupCells.delete(id);
}
}
Expand Down Expand Up @@ -1066,6 +1068,8 @@ async function webviewPreloads(ctx: PreloadContext) {

public readonly ready: Promise<void>;

public readonly element: HTMLElement;

/// Internal field that holds text content
private _content: string;

Expand Down Expand Up @@ -1097,12 +1101,8 @@ async function webviewPreloads(ctx: PreloadContext) {

//#region IOutputItem
public readonly id: string;
public readonly mime;
public readonly element: HTMLElement;

// deprecated fields
public readonly mime: string;
public readonly metadata = undefined;
public readonly outputId?: string | undefined;

text() { return this._content; }
json() { return undefined; }
Expand Down Expand Up @@ -1230,6 +1230,10 @@ async function webviewPreloads(ctx: PreloadContext) {
this.updateContentAndRender(this._content);
}

public remove() {
this.element.remove();
}

private async updateMarkupDimensions() {
dimensionUpdater.updateHeight(this.id, this.element.offsetHeight, {
isOutput: false
Expand Down

0 comments on commit e410db3

Please sign in to comment.