@mdgate/zip 0.6.7 → 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.
Files changed (2) hide show
  1. package/README.md +141 -10
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,29 +1,160 @@
1
1
  # @mdgate/zip
2
2
 
3
- Convert generic ZIP archives by converting each member. Outputs GitHub-Flavored Markdown. Works in
4
- Node, Edge, and browsers. No native addons.
3
+ **Convert ZIP archives to Markdown in TypeScript.**
5
4
 
6
- Handles: `.zip`, `.zipx`, `.jar` (not Office/ODF/EPUB/iWork packages those win at sniff 2)
5
+ [`@mdgate/zip`](https://github.com/mdgate/converters/tree/main/packages/zip) reads `.zip`, `.zipx`, and `.jar` files directly in JavaScript and converts each member into Markdown, without Python, native addons, WASM, or an unzip CLI.
7
6
 
8
- ## Usage
7
+ Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
8
+
9
+ ```bash
10
+ npm install @mdgate/zip
11
+ ```
12
+
13
+ ```ts
14
+ import { toMarkdown } from '@mdgate/zip';
15
+
16
+ const markdown = await toMarkdown(bytes);
17
+ ```
18
+
19
+ `bytes` is a `Uint8Array`, so the archive 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/zip`](https://github.com/mdgate/converters/tree/main/packages/zip)
24
+
25
+ A ZIP is a container. The useful content is inside: emails, Word files, PDFs, more ZIPs.
26
+
27
+ [`@mdgate/zip`](https://github.com/mdgate/converters/tree/main/packages/zip) is a ZIP reader written for the same runtime as your application:
28
+
29
+ * **Pure TypeScript**
30
+ * **ZIP members converted 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 generic ZIP from the PK signature, and leaves Office / ODF / EPUB / iWork packages to those converters**
37
+
38
+ ---
39
+
40
+ ## What it extracts
41
+
42
+ Used alone, [`@mdgate/zip`](https://github.com/mdgate/converters/tree/main/packages/zip) lists member names as Markdown.
43
+
44
+ Used inside `create()`, it hands each member back to the same converter registry:
45
+
46
+ ```text
47
+ archive.zip
48
+ └── email.eml
49
+ └── attachment.docx
50
+ └── Markdown
51
+ ```
52
+
53
+ The ZIP converter does not need to know how DOCX works. It passes nested bytes to `convert`.
54
+
55
+ Office, ODF, EPUB, and iWork packages are also ZIP files. Those converters win on sniff score, so [`@mdgate/zip`](https://github.com/mdgate/converters/tree/main/packages/zip) does not steal them.
56
+
57
+ Encrypted members are reported as encrypted.
58
+
59
+ ---
60
+
61
+ ## Node.js
62
+
63
+ ```ts
64
+ import { readFile } from 'node:fs/promises';
65
+ import { toMarkdown } from '@mdgate/zip';
66
+
67
+ const bytes = new Uint8Array(await readFile('bundle.zip'));
68
+ const markdown = await toMarkdown(bytes);
69
+
70
+ console.log(markdown);
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Browser
9
76
 
10
77
  ```ts
11
78
  import { toMarkdown } from '@mdgate/zip';
12
79
 
80
+ const file = input.files![0];
81
+ const bytes = new Uint8Array(await file.arrayBuffer());
82
+
13
83
  const markdown = await toMarkdown(bytes);
14
84
  ```
15
85
 
16
- Compose with other converters so members are converted by format:
86
+ ---
87
+
88
+ ## Cloudflare Workers and Edge runtimes
89
+
90
+ ```ts
91
+ import { toMarkdown } from '@mdgate/zip';
92
+
93
+ export default {
94
+ async fetch(request: Request) {
95
+ const bytes = new Uint8Array(await request.arrayBuffer());
96
+ const markdown = await toMarkdown(bytes);
97
+
98
+ return new Response(markdown, {
99
+ headers: {
100
+ 'content-type': 'text/markdown; charset=utf-8',
101
+ },
102
+ });
103
+ },
104
+ };
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Compose it with other file readers
110
+
111
+ [`@mdgate/zip`](https://github.com/mdgate/converters/tree/main/packages/zip) implements the converter interface from [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core).
17
112
 
18
113
  ```ts
19
114
  import { create } from '@mdgate/core';
20
- import { csv } from '@mdgate/csv';
21
115
  import { zip } from '@mdgate/zip';
116
+ import { email } from '@mdgate/email';
117
+ import { docx } from '@mdgate/docx';
118
+ import { pdf } from '@mdgate/pdf';
22
119
 
23
- const convert = create([zip(), csv()]);
120
+ const read = create([
121
+ zip(),
122
+ email(),
123
+ docx(),
124
+ pdf(),
125
+ ]);
126
+
127
+ const markdown = await read(bytes);
128
+ ```
129
+
130
+ Without nested `convert`, member names are listed as a bullet list.
131
+
132
+ The application still uses one reading interface while each format remains independently installable.
133
+
134
+ ---
135
+
136
+ ## Need more than ZIP?
137
+
138
+ If your application needs to read many different file types, use the complete converter set:
139
+
140
+ ```bash
141
+ npm install @mdgate/converters
24
142
  ```
25
143
 
26
- Without a nested `convert`, member names are listed as a bullet list.
144
+ ```ts
145
+ import { toMarkdown } from '@mdgate/converters';
146
+
147
+ const markdown = await toMarkdown(bytes, {
148
+ path: filename,
149
+ });
150
+ ```
151
+
152
+ [`@mdgate/zip`](https://github.com/mdgate/converters/tree/main/packages/zip) is one of the single-format packages in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
153
+
154
+ For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
155
+
156
+ ---
157
+
158
+ ## License
27
159
 
28
- Part of [mdgate converters](https://github.com/mdgate/converters); install
29
- `@mdgate/converters` for every format at once.
160
+ MIT
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mdgate/zip",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "description": "mdgate generic ZIP converter",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "homepage": "https://demo.mdgate.dev",
7
+ "homepage": "https://convert.mdgate.dev",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/mdgate/converters.git",
@@ -28,10 +28,10 @@
28
28
  "prepublishOnly": "bun run build"
29
29
  },
30
30
  "dependencies": {
31
- "@mdgate/containers": "0.6.7",
32
- "@mdgate/core": "0.6.7",
33
- "@mdgate/document": "0.6.7",
34
- "@mdgate/utils": "0.6.7"
31
+ "@mdgate/containers": "0.6.9",
32
+ "@mdgate/core": "0.6.9",
33
+ "@mdgate/document": "0.6.9",
34
+ "@mdgate/utils": "0.6.9"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"