@cj-tech-master/excelts 8.1.0 → 8.1.1-canary.20260407231219.4faedf6
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 +11 -26
- package/README_zh.md +18 -26
- package/dist/browser/modules/pdf/reader/metadata-reader.js +4 -3
- package/dist/cjs/modules/pdf/reader/metadata-reader.js +4 -2
- package/dist/esm/modules/pdf/reader/metadata-reader.js +4 -3
- package/dist/iife/excelts.iife.js +1 -1
- package/dist/iife/excelts.iife.min.js +1 -1
- package/package.json +19 -2
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/cjnoname/excelts/actions/workflows/ci.yml) [中文](README_zh.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The TypeScript ecosystem is heavily fragmented when it comes to document and data processing. To handle Excel, PDF, CSV, XML, ZIP, and streaming, developers often need to pull in a different package for each task — and then yet another set of packages to make them work in the browser, plus separate streaming wrappers on top. These libraries vary in API style, quality, and maintenance status, creating a tax on every project that needs more than one of them.
|
|
6
|
+
|
|
7
|
+
ExcelTS was built to fix this. One package, one consistent API, one codebase — working identically across Node.js, Bun, and browsers. Streaming is a first-class citizen in every module, not an afterthought bolted on through a third-party adapter. The goal is simple: install once, import what you need, and get the same reliable behavior everywhere — with maximum streaming performance out of the box.
|
|
6
8
|
|
|
7
9
|
## About This Project
|
|
8
10
|
|
|
@@ -14,12 +16,6 @@ ExcelTS is a zero-dependency TypeScript toolkit for spreadsheets and documents:
|
|
|
14
16
|
- **Cross-Platform** — Node.js 22+, Bun, Chrome 89+, Firefox 102+, Safari 14.1+
|
|
15
17
|
- **ESM First** — Native ES Modules with CommonJS compatibility and full tree-shaking
|
|
16
18
|
|
|
17
|
-
## Motivation
|
|
18
|
-
|
|
19
|
-
The TypeScript ecosystem is heavily fragmented when it comes to document and data processing. To handle Excel, PDF, CSV, XML, ZIP, and streaming, developers often need to pull in a different package for each task — and then yet another set of packages to make them work in the browser, plus separate streaming wrappers on top. These libraries vary in API style, quality, and maintenance status, creating a tax on every project that needs more than one of them.
|
|
20
|
-
|
|
21
|
-
ExcelTS was built to fix this. One package, one consistent API, one codebase — working identically across Node.js, Bun, and browsers. Streaming is a first-class citizen in every module, not an afterthought bolted on through a third-party adapter. The goal is simple: install once, import what you need, and get the same reliable behavior everywhere — with maximum streaming performance out of the box.
|
|
22
|
-
|
|
23
19
|
## Modules
|
|
24
20
|
|
|
25
21
|
ExcelTS is organized into seven standalone modules. Each module has its own documentation and runnable examples.
|
|
@@ -59,7 +55,7 @@ Streaming and buffered XML processing with query engine, namespace support, and
|
|
|
59
55
|
- [Documentation](src/modules/xml/README.md) | [中文](src/modules/xml/README_zh.md)
|
|
60
56
|
- [Examples](src/modules/xml/examples/)
|
|
61
57
|
|
|
62
|
-
### Archive —
|
|
58
|
+
### Archive — Create/Read/Edit Archives
|
|
63
59
|
|
|
64
60
|
ZIP and TAR archive creation, reading, editing, streaming, encryption, and compression utilities.
|
|
65
61
|
|
|
@@ -77,8 +73,14 @@ Node.js-compatible Readable/Writable/Transform/Duplex that works identically in
|
|
|
77
73
|
|
|
78
74
|
```bash
|
|
79
75
|
npm install @cj-tech-master/excelts
|
|
76
|
+
# or
|
|
77
|
+
pnpm add @cj-tech-master/excelts
|
|
78
|
+
# or
|
|
79
|
+
bun add @cj-tech-master/excelts
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
Each module is available as a standalone subpath export. All subpaths support `browser`, `import` (ESM), and `require` (CJS) conditions.
|
|
83
|
+
|
|
82
84
|
## Quick Start
|
|
83
85
|
|
|
84
86
|
```typescript
|
|
@@ -95,9 +97,7 @@ await workbook.xlsx.writeFile("output.xlsx");
|
|
|
95
97
|
const wb = new Workbook();
|
|
96
98
|
await wb.xlsx.readFile("output.xlsx");
|
|
97
99
|
wb.getWorksheet(1).eachRow((row, n) => console.log(n, row.values));
|
|
98
|
-
```
|
|
99
100
|
|
|
100
|
-
```typescript
|
|
101
101
|
// PDF — generate from data, no Workbook needed
|
|
102
102
|
import { pdf } from "@cj-tech-master/excelts/pdf";
|
|
103
103
|
const pdfBytes = pdf([
|
|
@@ -129,22 +129,6 @@ import { parseMarkdown, formatMarkdown } from "@cj-tech-master/excelts/markdown"
|
|
|
129
129
|
const table = parseMarkdown("| A | B |\n|---|---|\n| 1 | 2 |");
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
## Subpath Exports
|
|
133
|
-
|
|
134
|
-
Each module is available as a standalone subpath export:
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
import { Workbook, WorkbookWriter } from "@cj-tech-master/excelts";
|
|
138
|
-
import { pdf, readPdf, excelToPdf } from "@cj-tech-master/excelts/pdf";
|
|
139
|
-
import { SaxParser, parseXml, XmlWriter, query } from "@cj-tech-master/excelts/xml";
|
|
140
|
-
import { zip, unzip, ZipArchive, compress } from "@cj-tech-master/excelts/zip";
|
|
141
|
-
import { parseCsv, formatCsv, CsvParserStream } from "@cj-tech-master/excelts/csv";
|
|
142
|
-
import { parseMarkdown, formatMarkdown, parseMarkdownAll } from "@cj-tech-master/excelts/markdown";
|
|
143
|
-
import { Readable, pipeline, createTransform } from "@cj-tech-master/excelts/stream";
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Each subpath supports `browser`, `import` (ESM), and `require` (CJS) conditions.
|
|
147
|
-
|
|
148
132
|
## Browser Support
|
|
149
133
|
|
|
150
134
|
ExcelTS has native browser support with **zero configuration** for modern bundlers.
|
|
@@ -165,6 +149,7 @@ For older browsers without native `CompressionStream` API, ExcelTS automatically
|
|
|
165
149
|
## Requirements
|
|
166
150
|
|
|
167
151
|
- **Node.js >= 22.0.0**
|
|
152
|
+
- **Bun >= 1.0**
|
|
168
153
|
|
|
169
154
|
| Browser | Minimum Version |
|
|
170
155
|
| ------- | ------------------ |
|
package/README_zh.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/cjnoname/excelts/actions/workflows/ci.yml) [English](README.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
TypeScript 生态在文档和数据处理领域长期存在碎片化问题。处理 Excel、PDF、CSV、XML、ZIP 和流式操作,往往需要分别引入不同的包;到了浏览器端又要换一套方案;流式处理还得再额外接入一个适配库。这些库的 API 风格、质量和维护状态参差不齐,给每个需要组合使用它们的项目都带来了额外的负担。
|
|
6
|
+
|
|
7
|
+
ExcelTS 正是为了解决这个问题而生。一个包、一套 API、一份代码 — 在 Node.js、Bun 和浏览器中行为完全一致。流式处理是每个模块的一等公民,而非通过第三方适配器后期拼装的附属品。目标很简单:安装一次,按需导入,在任何环境下都获得相同的可靠体验 — 同时将流式处理的性能发挥到极致。
|
|
6
8
|
|
|
7
9
|
## 关于本项目
|
|
8
10
|
|
|
@@ -14,12 +16,6 @@ ExcelTS 是一个零依赖的 TypeScript 电子表格和文档工具包:
|
|
|
14
16
|
- **跨平台** — Node.js 22+、Bun、Chrome 89+、Firefox 102+、Safari 14.1+
|
|
15
17
|
- **ESM 优先** — 原生 ES Modules,兼容 CommonJS,完整的 tree-shaking 支持
|
|
16
18
|
|
|
17
|
-
## 项目初衷
|
|
18
|
-
|
|
19
|
-
TypeScript 生态在文档和数据处理领域长期存在碎片化问题。处理 Excel、PDF、CSV、XML、ZIP 和流式操作,往往需要分别引入不同的包;到了浏览器端又要换一套方案;流式处理还得再额外接入一个适配库。这些库的 API 风格、质量和维护状态参差不齐,给每个需要组合使用它们的项目都带来了额外的负担。
|
|
20
|
-
|
|
21
|
-
ExcelTS 正是为了解决这个问题而生。一个包、一套 API、一份代码 — 在 Node.js、Bun 和浏览器中行为完全一致。流式处理是每个模块的一等公民,而非通过第三方适配器后期拼装的附属品。目标很简单:安装一次,按需导入,在任何环境下都获得相同的可靠体验 — 同时将流式处理的性能发挥到极致。
|
|
22
|
-
|
|
23
19
|
## 模块
|
|
24
20
|
|
|
25
21
|
ExcelTS 由七个独立模块组成,每个模块都有自己的文档和可运行示例。
|
|
@@ -33,7 +29,7 @@ ExcelTS 由七个独立模块组成,每个模块都有自己的文档和可运
|
|
|
33
29
|
|
|
34
30
|
### PDF — 零依赖 PDF 引擎
|
|
35
31
|
|
|
36
|
-
功能完整的 PDF
|
|
32
|
+
功能完整的 PDF 生成和读取。写入支持字体嵌入、AES-256 加密、图片和 Excel 转 PDF。读取支持从任意 PDF 提取文本、图片、注解、表单字段和元数据。
|
|
37
33
|
|
|
38
34
|
- [文档](src/modules/pdf/README.md) | [中文](src/modules/pdf/README_zh.md)
|
|
39
35
|
- [示例](src/modules/pdf/examples/)
|
|
@@ -59,7 +55,7 @@ ExcelTS 由七个独立模块组成,每个模块都有自己的文档和可运
|
|
|
59
55
|
- [文档](src/modules/xml/README.md) | [中文](src/modules/xml/README_zh.md)
|
|
60
56
|
- [示例](src/modules/xml/examples/)
|
|
61
57
|
|
|
62
|
-
### Archive —
|
|
58
|
+
### Archive — 归档创建/读取/编辑
|
|
63
59
|
|
|
64
60
|
ZIP 和 TAR 归档创建、读取、编辑、流式处理、加密和压缩工具。
|
|
65
61
|
|
|
@@ -77,8 +73,14 @@ ZIP 和 TAR 归档创建、读取、编辑、流式处理、加密和压缩工
|
|
|
77
73
|
|
|
78
74
|
```bash
|
|
79
75
|
npm install @cj-tech-master/excelts
|
|
76
|
+
# or
|
|
77
|
+
pnpm add @cj-tech-master/excelts
|
|
78
|
+
# or
|
|
79
|
+
bun add @cj-tech-master/excelts
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
每个模块都可以作为独立的子路径导出使用。所有子路径均支持 `browser`、`import`(ESM)和 `require`(CJS)条件导出。
|
|
83
|
+
|
|
82
84
|
## 快速开始
|
|
83
85
|
|
|
84
86
|
```typescript
|
|
@@ -95,9 +97,7 @@ await workbook.xlsx.writeFile("output.xlsx");
|
|
|
95
97
|
const wb = new Workbook();
|
|
96
98
|
await wb.xlsx.readFile("output.xlsx");
|
|
97
99
|
wb.getWorksheet(1).eachRow((row, n) => console.log(n, row.values));
|
|
98
|
-
```
|
|
99
100
|
|
|
100
|
-
```typescript
|
|
101
101
|
// PDF — 直接从数据生成,无需 Workbook
|
|
102
102
|
import { pdf } from "@cj-tech-master/excelts/pdf";
|
|
103
103
|
const pdfBytes = pdf([
|
|
@@ -105,6 +105,12 @@ const pdfBytes = pdf([
|
|
|
105
105
|
["小工具", 1000]
|
|
106
106
|
]);
|
|
107
107
|
|
|
108
|
+
// PDF — 读取任意 PDF 的文本、图片和元数据
|
|
109
|
+
import { readPdf } from "@cj-tech-master/excelts/pdf";
|
|
110
|
+
const result = readPdf(pdfBytes);
|
|
111
|
+
console.log(result.text); // 提取的文本
|
|
112
|
+
console.log(result.metadata); // 标题、作者等
|
|
113
|
+
|
|
108
114
|
// CSV — 解析和格式化
|
|
109
115
|
import { parseCsv, formatCsv } from "@cj-tech-master/excelts/csv";
|
|
110
116
|
const rows = parseCsv("name,age\nAlice,30", { headers: true });
|
|
@@ -123,21 +129,6 @@ import { parseMarkdown, formatMarkdown } from "@cj-tech-master/excelts/markdown"
|
|
|
123
129
|
const table = parseMarkdown("| A | B |\n|---|---|\n| 1 | 2 |");
|
|
124
130
|
```
|
|
125
131
|
|
|
126
|
-
## 子路径导出
|
|
127
|
-
|
|
128
|
-
每个模块都可以作为独立的子路径导出使用:
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
import { Workbook, WorkbookWriter } from "@cj-tech-master/excelts";
|
|
132
|
-
import { SaxParser, parseXml, XmlWriter, query } from "@cj-tech-master/excelts/xml";
|
|
133
|
-
import { zip, unzip, ZipArchive, compress } from "@cj-tech-master/excelts/zip";
|
|
134
|
-
import { parseCsv, formatCsv, CsvParserStream } from "@cj-tech-master/excelts/csv";
|
|
135
|
-
import { parseMarkdown, formatMarkdown, parseMarkdownAll } from "@cj-tech-master/excelts/markdown";
|
|
136
|
-
import { Readable, pipeline, createTransform } from "@cj-tech-master/excelts/stream";
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
每个子路径均支持 `browser`、`import`(ESM)和 `require`(CJS)条件导出。
|
|
140
|
-
|
|
141
132
|
## 浏览器支持
|
|
142
133
|
|
|
143
134
|
ExcelTS 原生支持浏览器,现代打包工具**零配置**即可使用。
|
|
@@ -158,6 +149,7 @@ const buffer = await new Workbook().addWorksheet("S1").workbook.xlsx.writeBuffer
|
|
|
158
149
|
## 系统要求
|
|
159
150
|
|
|
160
151
|
- **Node.js >= 22.0.0**
|
|
152
|
+
- **Bun >= 1.0**
|
|
161
153
|
|
|
162
154
|
| 浏览器 | 最低版本 |
|
|
163
155
|
| ------- | ------------------ |
|
|
@@ -217,13 +217,14 @@ function extractXmpField(xml, field) {
|
|
|
217
217
|
}
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
220
|
-
|
|
220
|
+
/** @internal Exported for testing only. */
|
|
221
|
+
export function decodeXmlEntities(text) {
|
|
221
222
|
return text
|
|
222
|
-
.replace(/&/g, "&")
|
|
223
223
|
.replace(/</g, "<")
|
|
224
224
|
.replace(/>/g, ">")
|
|
225
225
|
.replace(/"/g, '"')
|
|
226
|
-
.replace(/'/g, "'")
|
|
226
|
+
.replace(/'/g, "'")
|
|
227
|
+
.replace(/&/g, "&");
|
|
227
228
|
}
|
|
228
229
|
// =============================================================================
|
|
229
230
|
// Page Size
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.extractMetadata = extractMetadata;
|
|
19
|
+
exports.decodeXmlEntities = decodeXmlEntities;
|
|
19
20
|
const pdf_parser_1 = require("./pdf-parser");
|
|
20
21
|
// =============================================================================
|
|
21
22
|
// Public API
|
|
@@ -220,13 +221,14 @@ function extractXmpField(xml, field) {
|
|
|
220
221
|
}
|
|
221
222
|
return null;
|
|
222
223
|
}
|
|
224
|
+
/** @internal Exported for testing only. */
|
|
223
225
|
function decodeXmlEntities(text) {
|
|
224
226
|
return text
|
|
225
|
-
.replace(/&/g, "&")
|
|
226
227
|
.replace(/</g, "<")
|
|
227
228
|
.replace(/>/g, ">")
|
|
228
229
|
.replace(/"/g, '"')
|
|
229
|
-
.replace(/'/g, "'")
|
|
230
|
+
.replace(/'/g, "'")
|
|
231
|
+
.replace(/&/g, "&");
|
|
230
232
|
}
|
|
231
233
|
// =============================================================================
|
|
232
234
|
// Page Size
|
|
@@ -217,13 +217,14 @@ function extractXmpField(xml, field) {
|
|
|
217
217
|
}
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
220
|
-
|
|
220
|
+
/** @internal Exported for testing only. */
|
|
221
|
+
export function decodeXmlEntities(text) {
|
|
221
222
|
return text
|
|
222
|
-
.replace(/&/g, "&")
|
|
223
223
|
.replace(/</g, "<")
|
|
224
224
|
.replace(/>/g, ">")
|
|
225
225
|
.replace(/"/g, '"')
|
|
226
|
-
.replace(/'/g, "'")
|
|
226
|
+
.replace(/'/g, "'")
|
|
227
|
+
.replace(/&/g, "&");
|
|
227
228
|
}
|
|
228
229
|
// =============================================================================
|
|
229
230
|
// Page Size
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cj-tech-master/excelts",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.1-canary.20260407231219.4faedf6",
|
|
4
4
|
"description": "Zero-dependency TypeScript toolkit — Excel (XLSX), PDF, CSV, Markdown, XML, ZIP/TAR, and streaming.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -107,6 +107,20 @@
|
|
|
107
107
|
"default": "./dist/cjs/modules/stream/index.js"
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
+
"./pdf": {
|
|
111
|
+
"browser": {
|
|
112
|
+
"types": "./dist/browser/modules/pdf/index.d.ts",
|
|
113
|
+
"default": "./dist/browser/modules/pdf/index.js"
|
|
114
|
+
},
|
|
115
|
+
"import": {
|
|
116
|
+
"types": "./dist/types/modules/pdf/index.d.ts",
|
|
117
|
+
"default": "./dist/esm/modules/pdf/index.js"
|
|
118
|
+
},
|
|
119
|
+
"require": {
|
|
120
|
+
"types": "./dist/types/modules/pdf/index.d.ts",
|
|
121
|
+
"default": "./dist/cjs/modules/pdf/index.js"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
110
124
|
"./xml": {
|
|
111
125
|
"browser": {
|
|
112
126
|
"types": "./dist/browser/modules/xml/index.d.ts",
|
|
@@ -145,6 +159,9 @@
|
|
|
145
159
|
"stream": [
|
|
146
160
|
"dist/types/modules/stream/index.d.ts"
|
|
147
161
|
],
|
|
162
|
+
"pdf": [
|
|
163
|
+
"dist/types/modules/pdf/index.d.ts"
|
|
164
|
+
],
|
|
148
165
|
"xml": [
|
|
149
166
|
"dist/types/modules/xml/index.d.ts"
|
|
150
167
|
],
|
|
@@ -229,7 +246,7 @@
|
|
|
229
246
|
"test:browser": "npm run generate:csv-worker && rimraf dist && npm run build:browser:bundle && vitest run --config vitest.browser.config.ts",
|
|
230
247
|
"test:watch": "vitest",
|
|
231
248
|
"build": "npm run generate:csv-worker && rimraf dist && concurrently \"npm run build:esm\" \"npm run build:cjs\" \"npm run build:browser\" \"npm run build:browser:bundle\" && npm run build:verify",
|
|
232
|
-
"build:verify": "tsc --noEmit --ignoreConfig --module NodeNext --moduleResolution NodeNext --lib ESNext,DOM --types node dist/types/index.d.ts dist/types/modules/archive/index.d.ts dist/types/modules/csv/index.d.ts dist/types/modules/markdown/index.d.ts dist/types/modules/stream/index.d.ts dist/types/modules/xml/index.d.ts",
|
|
249
|
+
"build:verify": "tsc --noEmit --ignoreConfig --module NodeNext --moduleResolution NodeNext --lib ESNext,DOM --types node dist/types/index.d.ts dist/types/modules/archive/index.d.ts dist/types/modules/csv/index.d.ts dist/types/modules/markdown/index.d.ts dist/types/modules/pdf/index.d.ts dist/types/modules/stream/index.d.ts dist/types/modules/xml/index.d.ts",
|
|
233
250
|
"verify:treeshake": "node scripts/treeshake-verify.ts",
|
|
234
251
|
"analyze:browser": "rimraf dist && node --input-type=module -e \"import { execSync } from 'node:child_process'; process.env.ANALYZE='true'; execSync('rolldown -c rolldown.config.ts', { stdio: 'inherit' });\"",
|
|
235
252
|
"clean": "pnpm dlx --reporter=silent rimraf \"**/node_modules\" pnpm-lock.yaml \"**/dist\" -g && pnpm i",
|