-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from silx-kit/up-h5web
Upgrade H5Web to v9 + support JSON export
- Loading branch information
Showing
11 changed files
with
127 additions
and
66 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 was deleted.
Oops, something went wrong.
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,10 +1,24 @@ | ||
import { FileInfo, Message } from './models'; | ||
import type { GetExportURL } from '@h5web/app'; | ||
import { MessageType } from '../src/models.js'; | ||
import { vscode } from './vscode-api.js'; | ||
|
||
// 2 GB = 2 * 1024 * 1024 * 1024 B | ||
export const MAX_SIZE_IN_BYTES = 2147483648; | ||
|
||
export function isFileInfoMessage( | ||
message: Message | ||
): message is Message<FileInfo> { | ||
return message.type === 'FileInfo'; | ||
} | ||
export const getExportURL: GetExportURL = (format, dataset, __, value) => { | ||
if (format === 'json') { | ||
return async () => { | ||
vscode.postMessage({ | ||
type: MessageType.Export, | ||
data: { | ||
format, | ||
name: dataset.name, | ||
payload: JSON.stringify(value, null, 2), | ||
}, | ||
}); | ||
return new Blob(); // doesn't matter as long as it's not falsy | ||
}; | ||
} | ||
|
||
return undefined; | ||
}; |
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,7 +1 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
interface VsCodeApi { | ||
postMessage(message: any): void; | ||
} | ||
|
||
declare function acquireVsCodeApi(): VsCodeApi; |
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 @@ | ||
export const vscode = acquireVsCodeApi(); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
import { ExportFormat } from '@h5web/app'; | ||
|
||
export type Message = | ||
| { type: MessageType.Ready } | ||
| { type: MessageType.FileInfo; data: FileInfo } | ||
| { type: MessageType.Export; data: Export }; | ||
|
||
export enum MessageType { | ||
Ready = 'Ready', | ||
FileInfo = 'FileInfo', | ||
Export = 'Export', | ||
} | ||
|
||
export interface FileInfo { | ||
uri: string; | ||
name: string; | ||
size: number; | ||
} | ||
|
||
export interface Export { | ||
format: ExportFormat; | ||
name: string; | ||
payload: string; | ||
} |