(
output: nbformat.IOutput,
cellIndex?: number,
cellId?: string,
cellMetadata?: Record<string, unknown>
)
| 137 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 138 | cellOutputMappers.set('update_display_data', translateDisplayDataOutput as any); |
| 139 | export function cellOutputToVSCCellOutput( |
| 140 | output: nbformat.IOutput, |
| 141 | cellIndex?: number, |
| 142 | cellId?: string, |
| 143 | cellMetadata?: Record<string, unknown> |
| 144 | ): NotebookCellOutput { |
| 145 | /** |
| 146 | * Stream, `application/x.notebook.stream` |
| 147 | * Error, `application/x.notebook.error-traceback` |
| 148 | * Rich, { mime: value } |
| 149 | * |
| 150 | * outputs: [ |
| 151 | new vscode.NotebookCellOutput([ |
| 152 | new vscode.NotebookCellOutputItem('application/x.notebook.stream', 2), |
| 153 | new vscode.NotebookCellOutputItem('application/x.notebook.stream', 3), |
| 154 | ]), |
| 155 | new vscode.NotebookCellOutput([ |
| 156 | new vscode.NotebookCellOutputItem('text/markdown', '## header 2'), |
| 157 | new vscode.NotebookCellOutputItem('image/svg+xml', [ |
| 158 | "<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"300\" xmlns=\"http://www.w3.org/2000/svg\">\n", |
| 159 | " <rect fill=\"blue\" height=\"100%\" width=\"100%\"/>\n", |
| 160 | " <circle cx=\"150\" cy=\"100\" fill=\"green\" r=\"80\"/>\n", |
| 161 | " <text fill=\"white\" font-size=\"60\" text-anchor=\"middle\" x=\"150\" y=\"125\">SVG</text>\n", |
| 162 | "</svg>" |
| 163 | ]), |
| 164 | ]), |
| 165 | ] |
| 166 | * |
| 167 | */ |
| 168 | const fn = cellOutputMappers.get(output.output_type as nbformat.OutputType); |
| 169 | let result: NotebookCellOutput; |
| 170 | if (fn) { |
| 171 | result = fn(output, cellIndex, cellId, cellMetadata); |
| 172 | } else { |
| 173 | logger.warn(`Unable to translate cell from ${output.output_type} to NotebookCellData for VS Code.`); |
| 174 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 175 | result = translateDisplayDataOutput(output as any, cellIndex, cellId, cellMetadata); |
| 176 | } |
| 177 | return result; |
| 178 | } |
| 179 | |
| 180 | function getOutputMetadata( |
| 181 | output: nbformat.IOutput, |
no test coverage detected