Skip to content

Commit e6e763e

Browse files
committed
fix #8327 -- jupyter gif Image output
1 parent 088e521 commit e6e763e

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/packages/jupyter/kernel/kernel.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,6 @@ nodeCleanup(() => {
218218
}
219219
});
220220

221-
// TODO: are these the only base64 encoded types that jupyter kernels return?
222-
export const BASE64_TYPES = [
223-
"image/png",
224-
"image/jpeg",
225-
"application/pdf",
226-
"base64",
227-
] as const;
228-
229221
// NOTE: keep JupyterKernel implementation private -- use the kernel function
230222
// above, and the interface defined in types.
231223
class JupyterKernel extends EventEmitter implements JupyterKernelInterface {
@@ -760,15 +752,14 @@ class JupyterKernel extends EventEmitter implements JupyterKernelInterface {
760752
return await new CodeExecutionEmitter(this, opts).go();
761753
};
762754

763-
private saveBlob = (data: string, type?: string) => {
755+
private saveBlob = (data: string, type: string) => {
764756
const blobs = this._actions?.blobs;
765757
if (blobs == null) {
766758
throw Error("blob store not available");
767759
}
768-
const buf: Buffer =
769-
type && BASE64_TYPES.includes(type as any)
770-
? Buffer.from(data, "base64")
771-
: Buffer.from(data);
760+
const buf: Buffer = !type.startsWith("text/")
761+
? Buffer.from(data, "base64")
762+
: Buffer.from(data);
772763

773764
const sha1: string = misc_node_sha1(buf);
774765
blobs.set(sha1, buf);

0 commit comments

Comments
 (0)