-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docx-to-vfile): make more isomorphic
- Loading branch information
Showing
11 changed files
with
981 additions
and
186 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 +1,42 @@ | ||
// import type { ReadStream } from 'fs' | ||
// import { VFile } from 'vfile' | ||
// import { docxToVFile as docxToVFileBrowser, Options } from './lib/docx-to-vfile-unzipit.js' | ||
|
||
// /** | ||
// * Takes a docx file as a Blob, Buffer, ArrayBuffer, ReadStream or string | ||
// * and returns a VFile with the contents of the document.xml file as the root, and the contents of the other xml files as data. | ||
// * | ||
// * Should work in both Node and the browser, but to be sure it works in the browser, import it like | ||
// * ```ts | ||
// * import { docxToVFile } from 'docx-to-vfile/browser' | ||
// * ``` | ||
// * | ||
// * @param file The docx file as a File, Blob, Buffer, ArrayBuffer, ReadStream or string | ||
// * @param options Options | ||
// * @returns A VFile with the contents of the document.xml file as the root, and the contents of the other xml files as data. | ||
// */ | ||
// export async function docxToVFile( | ||
// file: ArrayBuffer | File | Blob | Buffer | ReadStream | string, | ||
// options?: Options, | ||
// ): Promise<VFile> { | ||
// if (typeof window !== 'undefined') { | ||
// return await docxToVFileBrowser(file as Blob, options) | ||
// } | ||
|
||
// const { createReadStream, ReadStream } = await import('fs') | ||
// const { blob } = await import('stream/consumers') | ||
// const { Blob: NodeBlob } = await import('buffer') | ||
|
||
// const inp = typeof file === 'string' ? createReadStream(file) : file | ||
|
||
// const input = | ||
// inp instanceof ReadStream | ||
// ? await blob(inp) | ||
// : inp instanceof ArrayBuffer | ||
// ? new NodeBlob([Buffer.from(inp)]) | ||
// : inp | ||
|
||
// return await docxToVFileBrowser(input as Blob | File, options) | ||
// } | ||
|
||
export * from './lib/docx-to-vfile-unzipit.js' |
32 changes: 27 additions & 5 deletions
32
libs/reoff/docx-to-vfile/src/lib/__snapshots__/docx-to-vfile-unzipit.spec.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
libs/reoff/docx-to-vfile/src/lib/__snapshots__/docx-to-vfile-yauzl.spec.ts.snap
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
libs/reoff/docx-to-vfile/src/lib/__snapshots__/docx-to-vfile.spec.ts.snap
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
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
Oops, something went wrong.