-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helper functions for MIME-tagged outputs
fixes #35
- Loading branch information
Jake Donham
committed
Jun 4, 2024
1 parent
fd94d11
commit b466833
Showing
8 changed files
with
113 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
export * from "./types"; | ||
export * from "./rpc-types"; | ||
|
||
export function text(data: string) { | ||
return { data, mime: "text/plain" }; | ||
} | ||
|
||
export function markdown(data: string) { | ||
return { data, mime: "text/markdown" }; | ||
} | ||
|
||
export function html(html: string | { outerHTML: string }) { | ||
const data = typeof html === "object" ? html.outerHTML : html; | ||
return { data, mime: "text/html" }; | ||
} | ||
|
||
export function svg(html: string | { outerHTML: string }) { | ||
const data = typeof html === "object" ? html.outerHTML : html; | ||
return { data, mime: "image/svg+xml" }; | ||
} | ||
|
||
export function json(obj: object) { | ||
return { data: JSON.stringify(obj), mime: "application/json" }; | ||
} | ||
|
||
export function jsonView(obj: object) { | ||
return { data: JSON.stringify(obj), mime: "application/x-json-view" }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export interface CellOutputItem { | ||
data: number[]; // Uint8Array | ||
mime: string; | ||
} | ||
|
||
export interface CellOutput { | ||
items: CellOutputItem[]; | ||
} | ||
|
||
export type ServerFunctions = { | ||
ping: () => Promise<"pong">; | ||
|
||
removeCells: ( | ||
cells: { | ||
path: string; | ||
cellId: string; | ||
language: string; | ||
}[] | ||
) => void; | ||
|
||
executeCells: ( | ||
cells: { | ||
path: string; | ||
cellId: string; | ||
language: string; | ||
code?: string; | ||
}[], | ||
force: boolean, | ||
executeDirtyCells: boolean | ||
) => void; | ||
}; | ||
|
||
export type ClientFunctions = { | ||
markCellsDirty: (cells: { path: string; cellId: string }[]) => void; | ||
startCellExecution: ( | ||
path: string, | ||
cellId: string, | ||
force: boolean | ||
) => Promise<boolean>; | ||
endCellExecution: ( | ||
path: string, | ||
cellId: string, | ||
cellOutput: CellOutput | ||
) => void; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters