@mdgate/wps 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -11
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1,30 +1,155 @@
|
|
|
1
1
|
# @mdgate/wps
|
|
2
2
|
|
|
3
|
-
Convert
|
|
4
|
-
Outputs GitHub-Flavored Markdown. Works in Node, Edge, and browsers. No native
|
|
5
|
-
addons.
|
|
3
|
+
**Convert WPS Office files to Markdown in TypeScript.**
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
[`@mdgate/wps`](https://github.com/mdgate/converters/tree/main/packages/wps) reads Kingsoft WPS Writer, Spreadsheets, and Presentation files (`.wps`, `.wpt`, `.et`, `.ett`, `.dps`, `.dpt`) directly in JavaScript and converts them into GitHub-Flavored Markdown, without Python, native addons, WASM, or WPS Office.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
converter. Proprietary Kingsoft packages are best-effort text extraction.
|
|
7
|
+
Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mdgate/wps
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { toMarkdown } from '@mdgate/wps';
|
|
15
|
+
|
|
16
|
+
const markdown = await toMarkdown(bytes);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`bytes` is a `Uint8Array`, so the file can come from a file upload, object storage, an HTTP request, a browser file picker, or anywhere else your application gets bytes.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Why [`@mdgate/wps`](https://github.com/mdgate/converters/tree/main/packages/wps)
|
|
24
|
+
|
|
25
|
+
WPS Office is widely used in China. Some WPS files are Office-compatible OOXML or OLE packages. Others are proprietary Kingsoft packages.
|
|
26
|
+
|
|
27
|
+
[`@mdgate/wps`](https://github.com/mdgate/converters/tree/main/packages/wps) is a WPS reader written for the same runtime as your application:
|
|
28
|
+
|
|
29
|
+
* **Pure TypeScript**
|
|
30
|
+
* **WPS → Markdown locally**
|
|
31
|
+
* **No Python runtime**
|
|
32
|
+
* **No native addons**
|
|
33
|
+
* **No WASM runtime**
|
|
34
|
+
* **Zero third-party runtime dependencies**
|
|
35
|
+
* **Works with raw `Uint8Array` input**
|
|
36
|
+
* **Detects WPS files from contents and extension, not only the filename**
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## What it extracts
|
|
41
|
+
|
|
42
|
+
When the file is an Office-compatible OOXML or OLE package, [`@mdgate/wps`](https://github.com/mdgate/converters/tree/main/packages/wps) delegates to the matching official converter (Word, Excel, or PowerPoint).
|
|
43
|
+
|
|
44
|
+
When the file is a proprietary Kingsoft package, extraction is best-effort text:
|
|
45
|
+
|
|
46
|
+
* readable strings from ZIP parts or OLE streams
|
|
47
|
+
* duplicate runs removed
|
|
48
|
+
* no claim of full WPS layout reconstruction
|
|
49
|
+
|
|
50
|
+
Encrypted Office-compatible packages are reported as encrypted.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Node.js
|
|
13
55
|
|
|
14
56
|
```ts
|
|
57
|
+
import { readFile } from 'node:fs/promises';
|
|
15
58
|
import { toMarkdown } from '@mdgate/wps';
|
|
16
59
|
|
|
60
|
+
const bytes = new Uint8Array(await readFile('report.wps'));
|
|
17
61
|
const markdown = await toMarkdown(bytes);
|
|
62
|
+
|
|
63
|
+
console.log(markdown);
|
|
18
64
|
```
|
|
19
65
|
|
|
20
|
-
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Browser
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { toMarkdown } from '@mdgate/wps';
|
|
72
|
+
|
|
73
|
+
const file = input.files![0];
|
|
74
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
75
|
+
|
|
76
|
+
const markdown = await toMarkdown(bytes);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Cloudflare Workers and Edge runtimes
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { toMarkdown } from '@mdgate/wps';
|
|
85
|
+
|
|
86
|
+
export default {
|
|
87
|
+
async fetch(request: Request) {
|
|
88
|
+
const bytes = new Uint8Array(await request.arrayBuffer());
|
|
89
|
+
const markdown = await toMarkdown(bytes);
|
|
90
|
+
|
|
91
|
+
return new Response(markdown, {
|
|
92
|
+
headers: {
|
|
93
|
+
'content-type': 'text/markdown; charset=utf-8',
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Format detection
|
|
103
|
+
|
|
104
|
+
A path hint helps route `.wps` / `.et` / `.dps` files. Office-compatible contents are still identified from the package itself.
|
|
105
|
+
|
|
106
|
+
A path is never used to read a file from disk.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Compose it with other file readers
|
|
111
|
+
|
|
112
|
+
[`@mdgate/wps`](https://github.com/mdgate/converters/tree/main/packages/wps) implements the converter interface from [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core).
|
|
21
113
|
|
|
22
114
|
```ts
|
|
23
115
|
import { create } from '@mdgate/core';
|
|
24
116
|
import { wps } from '@mdgate/wps';
|
|
117
|
+
import { docx } from '@mdgate/docx';
|
|
118
|
+
import { xlsx } from '@mdgate/xlsx';
|
|
25
119
|
|
|
26
|
-
const
|
|
120
|
+
const read = create([
|
|
121
|
+
wps(),
|
|
122
|
+
docx(),
|
|
123
|
+
xlsx(),
|
|
124
|
+
]);
|
|
27
125
|
```
|
|
28
126
|
|
|
29
|
-
|
|
30
|
-
|
|
127
|
+
The application still uses one reading interface while each format remains independently installable.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Need more than WPS?
|
|
132
|
+
|
|
133
|
+
If your application needs to read many different file types, use the complete converter set:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm install @mdgate/converters
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
import { toMarkdown } from '@mdgate/converters';
|
|
141
|
+
|
|
142
|
+
const markdown = await toMarkdown(bytes, {
|
|
143
|
+
path: filename,
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
[`@mdgate/wps`](https://github.com/mdgate/converters/tree/main/packages/wps) is one of the single-format packages in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
|
|
148
|
+
|
|
149
|
+
For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdgate/wps",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"description": "mdgate Kingsoft WPS converter (wps/et/dps)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://convert.mdgate.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/mdgate/converters.git",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"prepublishOnly": "bun run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@mdgate/containers": "0.6.
|
|
32
|
-
"@mdgate/core": "0.6.
|
|
33
|
-
"@mdgate/doc": "0.6.
|
|
34
|
-
"@mdgate/document": "0.6.
|
|
35
|
-
"@mdgate/docx": "0.6.
|
|
36
|
-
"@mdgate/ppt": "0.6.
|
|
37
|
-
"@mdgate/pptx": "0.6.
|
|
38
|
-
"@mdgate/utils": "0.6.
|
|
39
|
-
"@mdgate/xlsx": "0.6.
|
|
31
|
+
"@mdgate/containers": "0.6.9",
|
|
32
|
+
"@mdgate/core": "0.6.9",
|
|
33
|
+
"@mdgate/doc": "0.6.9",
|
|
34
|
+
"@mdgate/document": "0.6.9",
|
|
35
|
+
"@mdgate/docx": "0.6.9",
|
|
36
|
+
"@mdgate/ppt": "0.6.9",
|
|
37
|
+
"@mdgate/pptx": "0.6.9",
|
|
38
|
+
"@mdgate/utils": "0.6.9",
|
|
39
|
+
"@mdgate/xlsx": "0.6.9"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|