-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: download zip * fix: disable data descriptor Some applications like Dolphin fail to open it otherwise
- Loading branch information
Showing
7 changed files
with
46 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { BlobWriter, TextReader, ZipWriter } from '@zip.js/zip.js'; | ||
import type * as monaco from 'monaco-editor'; | ||
import { downloadBlob } from './files.js'; | ||
|
||
export async function downloadModelsZIP(models: monaco.editor.ITextModel[]) { | ||
const zipWriter = new ZipWriter(new BlobWriter('application/zip'), { | ||
dataDescriptor: false, | ||
}); | ||
|
||
await Promise.all( | ||
models.map((model) => { | ||
const path = model.uri.fsPath.replace(/^\//, ''); | ||
const reader = new TextReader(model.getValue()); | ||
return zipWriter.add(path, reader); | ||
}), | ||
); | ||
|
||
const zipBlob = await zipWriter.close(); | ||
downloadBlob(zipBlob, 'webcrack-export.zip'); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.