Skip to content

Commit

Permalink
fix: it builds, oh my god
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah committed Mar 6, 2023
1 parent 6d8087e commit 62ff1e3
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 37 deletions.
4 changes: 1 addition & 3 deletions libs/reoff/docx-to-vfile/.swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"jsc": {
"target": "es2022",
"parser": {
"dts": true,
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
Expand All @@ -27,6 +26,5 @@
"./src/jest-setup.ts$",
"./**/jest-setup.ts$",
".*.js$"
],
"isModule": true
]
}
42 changes: 32 additions & 10 deletions libs/reoff/docx-to-vfile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
> This repository is automatically generated from the [main parser monorepo](https://github.com/TrialAndErrorOrg/parsers). Please submit any issues or pull requests there.
# docx-to-vfile

[![npm version](https://badge.fury.io/js/docx-to-vfile.svg)](https://badge.fury.io/js/docx-to-vfile) [![npm downloads](https://img.shields.io/npm/dm/docx-to-vfile.svg)](https://www.npmjs.com/package/docx-to-vfile)

Reads a `.docx` file and stores its components in vfile format to be processed by other tools, like [`reoff-parse`](https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-parse).
Expand Down Expand Up @@ -57,7 +58,7 @@ Takes a docx file as an ArrayBuffer and returns a VFile with the contents of the
#### Signature

```ts
docxToVFile(file: ArrayBuffer, userOptions: Options = {}): Promise<DocxVFile>;
docxToVFile(file: ArrayBuffer, userOptions: Options = {}): Promise<VFile>;
```

#### Parameters
Expand All @@ -69,23 +70,26 @@ docxToVFile(file: ArrayBuffer, userOptions: Options = {}): Promise<DocxVFile>;

#### Returns

`Promise`<[`DocxVFile`](modules.md#docxvfile)>
`Promise`<`VFile`>

A VFile with the contents of the document.xml file as the root, and the contents of the other xml files as data.

Defined in: [src/lib/docx-to-vfile-unzipit.ts:59](https://github.com/TrialAndErrorOrg/parsers/blob/5ec48a5/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L59)
Defined in: [src/lib/docx-to-vfile-unzipit.ts:90](https://github.com/TrialAndErrorOrg/parsers/blob/934a9b2/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L90)

***

### `DocxData`

The data attribute of a VFile
Is set to the DataMap interface in the vfile module

#### Hierarchy

* `Data`.**DocxData**

#### Indexable

[`key`: `${string}.xml` | `${string}.rels`]: `string` | `undefined`
[`key`: [`XMLOrRelsString`](modules.md#xmlorrelsstring)]: `string` | `undefined`

#### Properties

Expand All @@ -101,7 +105,9 @@ The media files in the .docx file

###### Type declaration

Defined in: [src/lib/docx-to-vfile-unzipit.ts:38](https://github.com/TrialAndErrorOrg/parsers/blob/5ec48a5/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L38)
Overrides: Data.media

Defined in: [src/lib/docx-to-vfile-unzipit.ts:45](https://github.com/TrialAndErrorOrg/parsers/blob/934a9b2/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L45)

##### `relations`

Expand All @@ -115,14 +121,19 @@ The relations between the .xml files in the .docx file

###### Type declaration

Defined in: [src/lib/docx-to-vfile-unzipit.ts:42](https://github.com/TrialAndErrorOrg/parsers/blob/5ec48a5/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L42)
Overrides: Data.relations

Defined in: [src/lib/docx-to-vfile-unzipit.ts:49](https://github.com/TrialAndErrorOrg/parsers/blob/934a9b2/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L49)

***

### `DocxVFile`

Extends VFile with a custom data attribute

This information should be on the VFile interface, this is just used in contexts where you only want to know the type of the data attribute,
e.g. when writing a library that does something with the output of `docxToVFile`.

#### Hierarchy

* `VFile`.**DocxVFile**
Expand All @@ -145,7 +156,7 @@ Defined in: node\_modules/.pnpm/vfile\@5.3.7/node\_modules/vfile/lib/index.d.ts
Overrides: VFile.data

Defined in: [src/lib/docx-to-vfile-unzipit.ts:49](https://github.com/TrialAndErrorOrg/parsers/blob/5ec48a5/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L49)
Defined in: [src/lib/docx-to-vfile-unzipit.ts:80](https://github.com/TrialAndErrorOrg/parsers/blob/934a9b2/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L80)

##### `history`

Expand Down Expand Up @@ -595,17 +606,20 @@ Defined in: node\_modules/.pnpm/vfile\@5.3.7/node\_modules/vfile/lib/index.d.ts
> `string`[] | `RegExp`[] | (`key`: `string`) => `boolean` | `"all"` | `"allWithDocumentXML"`
Include only the specified files on the `data` attribute of the VFile.
This may be useful if you want to only do something with a subset of the files in the docx file, and don't intend to use 'reoff-stringify' to turn the VFile back into a docx file.

* If an array of strings or regexps is passed, only files that match one of the values will be included.
* If a function is passed, it will be called for each file and should return true to include the file.
* If the value is 'all', almost all files will be included, except for 'word/document.xml', as that already is the root of the VFile.
* If the value is 'allWithDocumentXML', all files will be included, including `word/document.xml`, even though that is already the root of the VFile. Useful if you really want to mimic the original docx file.

You should keep it at the default value if you intend to use 'reoff-stringify' to turn the VFile back into a docx file.

###### Default

["word/footnotes.xml", "word/endnotes.xml", "word/styles.xml", "customXml/item1.xml", "word/glossary/document.xml"]
'all'

Defined in: [src/lib/docx-to-vfile-unzipit.ts:27](https://github.com/TrialAndErrorOrg/parsers/blob/5ec48a5/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L27)
Defined in: [src/lib/docx-to-vfile-unzipit.ts:30](https://github.com/TrialAndErrorOrg/parsers/blob/934a9b2/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L30)

##### `withoutMedia?`

Expand All @@ -619,7 +633,15 @@ By default, images are included on the `data.media` attribute of the VFile as an

false

Defined in: [src/lib/docx-to-vfile-unzipit.ts:16](https://github.com/TrialAndErrorOrg/parsers/blob/5ec48a5/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L16)
Defined in: [src/lib/docx-to-vfile-unzipit.ts:16](https://github.com/TrialAndErrorOrg/parsers/blob/934a9b2/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L16)

***

### `XMLOrRelsString`

> `${string}.xml` | `${string}.rels`
Defined in: [src/lib/docx-to-vfile-unzipit.ts:71](https://github.com/TrialAndErrorOrg/parsers/blob/934a9b2/libs/reoff/docx-to-vfile/src/lib/docx-to-vfile-unzipit.ts#L71)

## Syntax tree

Expand Down
16 changes: 10 additions & 6 deletions libs/reoff/docx-to-vfile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
},
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs",
"types": "./index.d.ts"
},
"./package.json": "./package.json"
}
"types": "./index.d.ts",
"import": "./index.js"
}
},
"main": "./index.js",
"module": "./index.js",
"types": "./index.d.ts",
"files": [
"./"
]
}
21 changes: 5 additions & 16 deletions libs/reoff/docx-to-vfile/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,19 @@
"passWithNoTests": true
}
},
"tsc": {
"executor": "@nrwl/js:tsc",
"options": {
"tsConfig": "libs/reoff/docx-to-vfile/tsconfig.publish.json",
"clean": false,
"outputPath": "dist/libs/reoff/docx-to-vfile",
"main": "libs/reoff/docx-to-vfile/src/index.ts",
"parallel": false
}
},

"build": {
"executor": "@nrwl/js:swc",
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],

"options": {
"outputPath": "dist/libs/reoff/docx-to-vfile",
"rootDir": "libs/reoff/docx-to-vfile/src",
"outputPath": "dist/libs/reoff/docx-to-vfile/",
"tsConfig": "libs/reoff/docx-to-vfile/tsconfig.lib.json",
"main": "libs/reoff/docx-to-vfile/src/index.ts",
"assets": ["libs/reoff/docx-to-vfile/*.md"],
"platform": "node",
"updateBuildableProjectDepsInPackageJson": true,
"buildableProjectDepsInPackageJsonType": "dependencies",
"thirdParty": false,
"format": ["esm"]
"buildableProjectDepsInPackageJsonType": "dependencies"
},
"configurations": {
"cjs": {
Expand Down
2 changes: 1 addition & 1 deletion libs/reoff/docx-to-vfile/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
//export * from './lib/get-xml-data'
//export * from './lib/get-xml-data.js'
export * from './lib/docx-to-vfile-unzipit.js'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { docxToVFile } from './docx-to-vfile-unzipit'
import { docxToVFile } from './docx-to-vfile-unzipit.js'
import fs from 'fs'
import path from 'path'

Expand Down

0 comments on commit 62ff1e3

Please sign in to comment.