@embedpdf-editor/vue3-chapter-viewer 0.3.5 → 1.0.2

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/LICENSE.pdfium ADDED
@@ -0,0 +1,196 @@
1
+ // Copyright 2014 PDFium Authors. All rights reserved.
2
+ //
3
+ // Redistribution and use in source and binary forms, with or without
4
+ // modification, are permitted provided that the following conditions are
5
+ // met:
6
+ //
7
+ // * Redistributions of source code must retain the above copyright
8
+ // notice, this list of conditions and the following disclaimer.
9
+ // * Redistributions in binary form must reproduce the above
10
+ // copyright notice, this list of conditions and the following disclaimer
11
+ // in the documentation and/or other materials provided with the
12
+ // distribution.
13
+ // * Neither the name of Google Inc. nor the names of its
14
+ // contributors may be used to endorse or promote products derived from
15
+ // this software without specific prior written permission.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ Apache License
29
+ Version 2.0, January 2004
30
+ https://www.apache.org/licenses/
31
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
32
+ 1. Definitions.
33
+ "License" shall mean the terms and conditions for use, reproduction,
34
+ and distribution as defined by Sections 1 through 9 of this document.
35
+ "Licensor" shall mean the copyright owner or entity authorized by
36
+ the copyright owner that is granting the License.
37
+ "Legal Entity" shall mean the union of the acting entity and all
38
+ other entities that control, are controlled by, or are under common
39
+ control with that entity. For the purposes of this definition,
40
+ "control" means (i) the power, direct or indirect, to cause the
41
+ direction or management of such entity, whether by contract or
42
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
43
+ outstanding shares, or (iii) beneficial ownership of such entity.
44
+ "You" (or "Your") shall mean an individual or Legal Entity
45
+ exercising permissions granted by this License.
46
+ "Source" form shall mean the preferred form for making modifications,
47
+ including but not limited to software source code, documentation
48
+ source, and configuration files.
49
+ "Object" form shall mean any form resulting from mechanical
50
+ transformation or translation of a Source form, including but
51
+ not limited to compiled object code, generated documentation,
52
+ and conversions to other media types.
53
+ "Work" shall mean the work of authorship, whether in Source or
54
+ Object form, made available under the License, as indicated by a
55
+ copyright notice that is included in or attached to the work
56
+ (an example is provided in the Appendix below).
57
+ "Derivative Works" shall mean any work, whether in Source or Object
58
+ form, that is based on (or derived from) the Work and for which the
59
+ editorial revisions, annotations, elaborations, or other modifications
60
+ represent, as a whole, an original work of authorship. For the purposes
61
+ of this License, Derivative Works shall not include works that remain
62
+ separable from, or merely link (or bind by name) to the interfaces of,
63
+ the Work and Derivative Works thereof.
64
+ "Contribution" shall mean any work of authorship, including
65
+ the original version of the Work and any modifications or additions
66
+ to that Work or Derivative Works thereof, that is intentionally
67
+ submitted to Licensor for inclusion in the Work by the copyright owner
68
+ or by an individual or Legal Entity authorized to submit on behalf of
69
+ the copyright owner. For the purposes of this definition, "submitted"
70
+ means any form of electronic, verbal, or written communication sent
71
+ to the Licensor or its representatives, including but not limited to
72
+ communication on electronic mailing lists, source code control systems,
73
+ and issue tracking systems that are managed by, or on behalf of, the
74
+ Licensor for the purpose of discussing and improving the Work, but
75
+ excluding communication that is conspicuously marked or otherwise
76
+ designated in writing by the copyright owner as "Not a Contribution."
77
+ "Contributor" shall mean Licensor and any individual or Legal Entity
78
+ on behalf of whom a Contribution has been received by Licensor and
79
+ subsequently incorporated within the Work.
80
+ 2. Grant of Copyright License. Subject to the terms and conditions of
81
+ this License, each Contributor hereby grants to You a perpetual,
82
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
+ copyright license to reproduce, prepare Derivative Works of,
84
+ publicly display, publicly perform, sublicense, and distribute the
85
+ Work and such Derivative Works in Source or Object form.
86
+ 3. Grant of Patent License. Subject to the terms and conditions of
87
+ this License, each Contributor hereby grants to You a perpetual,
88
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
89
+ (except as stated in this section) patent license to make, have made,
90
+ use, offer to sell, sell, import, and otherwise transfer the Work,
91
+ where such license applies only to those patent claims licensable
92
+ by such Contributor that are necessarily infringed by their
93
+ Contribution(s) alone or by combination of their Contribution(s)
94
+ with the Work to which such Contribution(s) was submitted. If You
95
+ institute patent litigation against any entity (including a
96
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
97
+ or a Contribution incorporated within the Work constitutes direct
98
+ or contributory patent infringement, then any patent licenses
99
+ granted to You under this License for that Work shall terminate
100
+ as of the date such litigation is filed.
101
+ 4. Redistribution. You may reproduce and distribute copies of the
102
+ Work or Derivative Works thereof in any medium, with or without
103
+ modifications, and in Source or Object form, provided that You
104
+ meet the following conditions:
105
+ (a) You must give any other recipients of the Work or
106
+ Derivative Works a copy of this License; and
107
+ (b) You must cause any modified files to carry prominent notices
108
+ stating that You changed the files; and
109
+ (c) You must retain, in the Source form of any Derivative Works
110
+ that You distribute, all copyright, patent, trademark, and
111
+ attribution notices from the Source form of the Work,
112
+ excluding those notices that do not pertain to any part of
113
+ the Derivative Works; and
114
+ (d) If the Work includes a "NOTICE" text file as part of its
115
+ distribution, then any Derivative Works that You distribute must
116
+ include a readable copy of the attribution notices contained
117
+ within such NOTICE file, excluding those notices that do not
118
+ pertain to any part of the Derivative Works, in at least one
119
+ of the following places: within a NOTICE text file distributed
120
+ as part of the Derivative Works; within the Source form or
121
+ documentation, if provided along with the Derivative Works; or,
122
+ within a display generated by the Derivative Works, if and
123
+ wherever such third-party notices normally appear. The contents
124
+ of the NOTICE file are for informational purposes only and
125
+ do not modify the License. You may add Your own attribution
126
+ notices within Derivative Works that You distribute, alongside
127
+ or as an addendum to the NOTICE text from the Work, provided
128
+ that such additional attribution notices cannot be construed
129
+ as modifying the License.
130
+ You may add Your own copyright statement to Your modifications and
131
+ may provide additional or different license terms and conditions
132
+ for use, reproduction, or distribution of Your modifications, or
133
+ for any such Derivative Works as a whole, provided Your use,
134
+ reproduction, and distribution of the Work otherwise complies with
135
+ the conditions stated in this License.
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+ 7. Disclaimer of Warranty. Unless required by applicable law or
148
+ agreed to in writing, Licensor provides the Work (and each
149
+ Contributor provides its Contributions) on an "AS IS" BASIS,
150
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
151
+ implied, including, without limitation, any warranties or conditions
152
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
153
+ PARTICULAR PURPOSE. You are solely responsible for determining the
154
+ appropriateness of using or redistributing the Work and assume any
155
+ risks associated with Your exercise of permissions under this License.
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor be
160
+ liable to You for damages, including any direct, indirect, special,
161
+ incidental, or consequential damages of any character arising as a
162
+ result of this License or out of the use or inability to use the
163
+ Work (including but not limited to damages for loss of goodwill,
164
+ work stoppage, computer failure or malfunction, or any and all
165
+ other commercial damages or losses), even if such Contributor
166
+ has been advised of the possibility of such damages.
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+ END OF TERMS AND CONDITIONS
178
+ APPENDIX: How to apply the Apache License to your work.
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment syntax for the file format. We also recommend that a
184
+ file or class name and description of purpose be included on the
185
+ same "printed page" as the copyright notice for easier
186
+ identification within third-party archives.
187
+ Copyright [yyyy] [name of copyright owner]
188
+ Licensed under the Apache License, Version 2.0 (the "License");
189
+ you may not use this file except in compliance with the License.
190
+ You may obtain a copy of the License at
191
+ https://www.apache.org/licenses/LICENSE-2.0
192
+ Unless required by applicable law or agreed to in writing, software
193
+ distributed under the License is distributed on an "AS IS" BASIS,
194
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
195
+ See the License for the specific language governing permissions and
196
+ limitations under the License.
package/NOTICE CHANGED
@@ -5,3 +5,8 @@ Copyright (c) 2025 CloudPDF
5
5
  Copyright (c) 2026 xiaoliuing
6
6
 
7
7
  See LICENSE for the full MIT License text.
8
+
9
+ ---
10
+
11
+ PDF rendering uses PDFium (Apache License 2.0). See NOTICE.pdfium and
12
+ LICENSE.pdfium in this package, and THIRD-PARTY-NOTICES.md.
package/NOTICE.pdfium ADDED
@@ -0,0 +1,13 @@
1
+ PDFium (WebAssembly binary: pdfium.wasm)
2
+ =====================================
3
+
4
+ This product includes PDFium, an open-source PDF rendering library:
5
+ https://pdfium.googlesource.com/pdfium/
6
+
7
+ Copyright (c) PDFium Authors. Portions copyright Google LLC.
8
+
9
+ Licensed under the Apache License, Version 2.0 and additional BSD-style
10
+ terms as stated in LICENSE.pdfium in this directory (or package root).
11
+
12
+ You must retain LICENSE.pdfium when redistributing pdfium.wasm or
13
+ products that bundle it. See THIRD-PARTY-NOTICES.md for an overview.
package/README.md CHANGED
@@ -136,7 +136,11 @@ type ChapterManifest = {
136
136
  title: string;
137
137
  globalPageRange: [number, number];
138
138
  localPageRange: [number, number];
139
- source?: { url: string } | { buffer: ArrayBuffer } | { load: () => Promise<{ url: string } | { buffer: ArrayBuffer }> };
139
+ source?:
140
+ | { url: string }
141
+ | { buffer: ArrayBuffer }
142
+ | { load: () => Promise<{ url: string } | { buffer: ArrayBuffer }> }
143
+ | { urls: string[]; segmentPageThreshold: number };
140
144
  encrypted?: boolean;
141
145
  ownedGlobalPages?: number[];
142
146
  }>;
@@ -144,7 +148,7 @@ type ChapterManifest = {
144
148
  };
145
149
  ```
146
150
 
147
- `globalPageRange` 和 `localPageRange` 都是闭区间,且页数必须一致。`chapterId` 同时作为内部 `documentId`,需要在整本书内唯一。
151
+ `globalPageRange` 和 `localPageRange` 都是闭区间,且页数必须一致。`chapterId` 在整本书内唯一;单 URL 章时 `documentId === chapterId`,分段章内部为 `chapterId#s0`、`#s1`…(业务存储仍只用 `chapterId`)。
148
152
 
149
153
  | 字段 | 说明 |
150
154
  | --- | --- |
@@ -236,8 +240,8 @@ const options: ChapterViewerOptions = {
236
240
  import type { ChapterViewerOptions, IChapterPdfLoader } from '@embedpdf-editor/vue3-chapter-viewer';
237
241
 
238
242
  const loader: IChapterPdfLoader = {
239
- async loadPdf(chapter) {
240
- const res = await api.getChapterPdf(chapter.chapterId);
243
+ async loadPdf(chapter, segmentIndex) {
244
+ const res = await api.getChapterPdf(chapter.chapterId, segmentIndex ?? 0);
241
245
  return { url: res.signedUrl };
242
246
  // 或 return { buffer: await res.arrayBuffer() };
243
247
  },
@@ -251,6 +255,26 @@ const options: ChapterViewerOptions = {
251
255
  };
252
256
  ```
253
257
 
258
+ ### 章内多 PDF 分段(`source.urls[]`)
259
+
260
+ ```ts
261
+ source: {
262
+ urls: [part0Url, part1Url, part2Url],
263
+ segmentPageThreshold: 5, // 13 页 → 3 段
264
+ },
265
+ ```
266
+
267
+ - 先加载 `urls[0]`,滚动时懒加载后续段。
268
+ - `localPageIndex` 为章内 0-based 连续页;Vue 侧无需为分段改 `features`。
269
+ - 业务持久化:**`chapterId` + `localPageIndex`**,勿存 `chapterId#sN`。
270
+ - 导出划线会加载全部分段并合并页码。
271
+
272
+ [03-manifest.md](../../docs/get-started/03-manifest.md) · [12-segmented-pdf-and-per-chapter-storage.md](../../docs/get-started/12-segmented-pdf-and-per-chapter-storage.md)
273
+
274
+ ### 按章持久化(笔记 / 书签)
275
+
276
+ `NoteAnchor` / `ParagraphBookmark.anchor` 的 `chapterId`、`localPageIndex` 与单 URL 章相同。`loadNotes` / `bookmarks.load` 按章查询即可。划线备份用 `exportChapterAnnotations`(归档键为 `chapterId`)。
277
+
254
278
  ### 加密 PDF 与 `passwordProvider`
255
279
 
256
280
  ```ts
@@ -275,9 +299,9 @@ const passwordProvider = new CallbackPasswordProvider(async (chapter, attempt) =
275
299
  | `notes` | `enabled`、`marker`(`renderIcon`、`renderMenuActions`、`iconSize`、`highlightColor`) |
276
300
  | `zoom` | `enabled`(默认 true)、`min` 0.5、`max` 3、`initial` 1、`pageWidth`;实际上限由 `[data-chapter-scroll-viewport]` 宽度决定,resize 时自动更新 |
277
301
  | `scrollViewport` | `background`(默认 `#f1f5f9`),滚动视口背景 |
278
- | `selectionToolbar` | `enabled`、`hiddenBuiltinActions`、`extraActions` |
302
+ | `selectionToolbar` | `enabled`、`hiddenBuiltinActions`(含 `copy`)、`renderCopyIcon`、`extraActions` |
279
303
 
280
- 默认划线 `offsetY`:`squiggly` 为 **4**。内置工具条按钮:`highlight` | `underline` | `squiggly` | `strikeout` | `note`。
304
+ 默认划线 `offsetY`:`squiggly` 为 **4**。内置工具条顺序:**`copy`** 划线类 扩展 **`note`**。
281
305
 
282
306
  ---
283
307
 
@@ -303,12 +327,21 @@ const passwordProvider = new CallbackPasswordProvider(async (chapter, attempt) =
303
327
  usePdfiumEngine();
304
328
  ```
305
329
 
306
- 如果业务要求内网部署、固定版本或自定义 CDN,再传入自托管地址:
330
+ 如果业务要求内网部署、固定版本或自定义 CDN,再传入自托管地址(**完整 URL** 或站点相对路径):
307
331
 
308
332
  ```ts
309
333
  usePdfiumEngine({ wasmUrl: '/assets/pdfium.wasm', worker: true });
334
+
335
+ // 自有 OSS / CDN(示例)
336
+ usePdfiumEngine({
337
+ wasmUrl:
338
+ 'https://hep-editor.oss-cn-beijing.aliyuncs.com/public/editor-public/js/pdfium.wasm',
339
+ worker: true,
340
+ });
310
341
  ```
311
342
 
343
+ 详见 [docs/get-started/01-installation.md](../../docs/get-started/01-installation.md)。
344
+
312
345
  使用 `worker: true` 时,部署环境需要允许 worker 加载 wasm。若只在 worker 模式失败,可先用 `worker: false` 定位资源或响应头问题。
313
346
 
314
347
  ## `features` 配置示例
@@ -377,6 +410,28 @@ features: {
377
410
 
378
411
  ### 选区工具栏
379
412
 
413
+ #### 复制(默认开启,浮窗最左侧)
414
+
415
+ ```ts
416
+ import { h } from 'vue';
417
+
418
+ features: {
419
+ selectionToolbar: {
420
+ // hiddenBuiltinActions: ['copy'],
421
+ renderCopyIcon: () =>
422
+ h('span', { 'aria-hidden': true, style: { fontSize: '18px' } }, '📋'),
423
+ },
424
+ },
425
+ ```
426
+
427
+ ```ts
428
+ import { copyTextToClipboard } from '@embedpdf-editor/vue3-chapter-viewer';
429
+
430
+ await copyTextToClipboard('文本');
431
+ ```
432
+
433
+ #### 划线 + 扩展按钮
434
+
380
435
  ```ts
381
436
  features: {
382
437
  selectionToolbar: {
@@ -386,7 +441,8 @@ features: {
386
441
  },
387
442
  ```
388
443
 
389
- 配合 `ChapterPdfViewer` 的 `@extra-selection-action` 或 `build-selection-menu`。
444
+ 配合 `ChapterPdfViewer` 的 `@extra-selection-action` 或 `build-selection-menu`。
445
+ 更多字段说明见 [React 包 `features.selectionToolbar`](../react-chapter-viewer/README.md#featuresselectiontoolbar)。
390
446
 
391
447
  ## 进阶组合
392
448
 
@@ -430,10 +486,14 @@ import {
430
486
  | --- | --- |
431
487
  | `mode` | `replace` \| `merge` |
432
488
  | `bookmarks` / `notes` / `markup` | 导入导出子集,默认 true |
433
- | `ensureChapterLoaded` | 默认 true |
489
+ | `ensureChapterLoaded` | 默认 true;导出含 markup 的分段章会加载 **全部段** |
434
490
  | `persistNotes` / `persistBookmarks` | 导入后写回存储 |
435
491
 
436
- 详见 [React README 标注章节](../react-chapter-viewer/README.md#标注导入导出)。
492
+ 归档按 `chapterId` 分桶。详见 [10-annotations-io.md](../../docs/get-started/10-annotations-io.md)、[12-segmented-pdf-and-per-chapter-storage.md](../../docs/get-started/12-segmented-pdf-and-per-chapter-storage.md)、[React README 标注章节](../react-chapter-viewer/README.md#标注导入导出)。
493
+
494
+ ## 教程索引
495
+
496
+ [docs/get-started/README.md](../../docs/get-started/README.md)(含 `wasmUrl`、划词复制、事件全集 [11](./../../docs/get-started/11-events-callbacks-and-component-api.md)、分段 [12](./../../docs/get-started/12-segmented-pdf-and-per-chapter-storage.md))
437
497
 
438
498
  ## 常见问题
439
499
 
@@ -444,3 +504,4 @@ import {
444
504
  | 页码或滚动错位 | 检查 `globalPageRange` 与 `localPageRange` 页数是否一致 |
445
505
  | 划词笔记没有保存 | 实现 `notes.onCreateNote` 或自定义 `onRequestCreateNote` 流程 |
446
506
  | 书签删除无效 | `bookmarks.onRequestRemove` 需要返回 `true` 才会删除 |
507
+ | 分段章业务 ID 混乱 | 对外只用 `chapterId` + `localPageIndex`,勿用 `chapterId#sN` |
@@ -0,0 +1,102 @@
1
+ # Third-Party Notices
2
+
3
+ 本文件说明本仓库及对外发布的 `@embedpdf-editor/*` 包所涉及的主要第三方软件及其许可义务。
4
+ **本文不构成法律意见**;若用于商业产品,请由法务根据实际分发形态审阅。
5
+
6
+ ---
7
+
8
+ ## 1. 本仓库自有与二开代码(MIT)
9
+
10
+ 章节阅读器扩展(`engine-packages/` 下 `@embedpdf-editor/*` 中你们编写的部分,以及对外发布的 3 个 npm 包中的 **JavaScript/TypeScript 封装与 bundle**)在以下版权下发布:
11
+
12
+ - Copyright (c) 2025 CloudPDF(上游 EmbedPDF,须保留)
13
+ - Copyright (c) 2026 xiaoliuing(本仓库修改与扩展,追加)
14
+
15
+ 完整条文见根目录 [LICENSE](LICENSE) 与 [NOTICE](NOTICE)。
16
+
17
+ 再分发这些部分时,须保留上述版权行及 MIT 许可全文。
18
+
19
+ ---
20
+
21
+ ## 2. 上游 EmbedPDF(MIT)
22
+
23
+ 本仓库基于 [embedpdf/embed-pdf-viewer](https://github.com/embedpdf/embed-pdf-viewer) 二次开发。
24
+ `packages/`、`viewers/` 下的 `@embedpdf/*` 包多为 **MIT**(以各包内 `package.json` 与 `LICENSE` 为准)。
25
+
26
+ 运行时依赖示例:`@embedpdf/core`、`@embedpdf/engines`、`@embedpdf/plugin-*` 等。
27
+
28
+ ---
29
+
30
+ ## 3. PDFium(Apache License 2.0 — 重要)
31
+
32
+ ### 3.1 是什么
33
+
34
+ **PDFium** 是 Google 维护的开源 PDF 渲染引擎(C++),浏览器端通过 **WebAssembly**(`pdfium.wasm`)加载。
35
+ 本仓库通过 `@embedpdf/pdfium` 使用 PDFium;章节 snippet 等包会 **直接分发** `pdfium.wasm`。
36
+
37
+ ### 3.2 许可(非 MIT)
38
+
39
+ PDFium 许可全文见:
40
+
41
+ - 仓库路径:[packages/pdfium/LICENSE.pdfium](packages/pdfium/LICENSE.pdfium)
42
+ - 对外 npm 包内:`LICENSE.pdfium`(由 `pnpm sync:pdfium-licenses` 同步)
43
+
44
+ 该文件包含 **PDFium Authors 的 BSD 风格条款** 与 **Apache License Version 2.0** 全文。
45
+ **不得以「整个项目仅 MIT」为由忽略 PDFium 义务。**
46
+
47
+ `@embedpdf/pdfium` 包根目录的 `LICENSE`(MIT)一般仅指 **JavaScript 胶水层**;**WASM 二进制仍适用 PDFium / Apache 2.0**。
48
+
49
+ ### 3.3 再分发时建议做到(最安全实践)
50
+
51
+ | 做法 | 说明 |
52
+ | ---- | ---- |
53
+ | 附带 `LICENSE.pdfium` | 随应用安装包、静态资源目录或 npm tarball **一并提供** 完整许可文本 |
54
+ | 附带 `NOTICE.pdfium` | 简短说明使用了 PDFium 及版权归属 |
55
+ | 保留版权声明 | 不得删除 `LICENSE.pdfium` 中的版权与 Apache 2.0 正文 |
56
+ | 产品「开源许可」页 | App / SaaS 建议在「关于 → 开源许可」中列出 PDFium 与 Apache 2.0 |
57
+ | 勿暗示官方背书 | 不得声称产品获 Google / PDFium / Chrome 官方认证 |
58
+
59
+ 若 **未修改** PDFium 源码、仅使用预编译 `pdfium.wasm`,通常 **无需** 在源码中标注「修改说明」;若自行编译并改动了 PDFium,须按 Apache 2.0 标注变更文件。
60
+
61
+ ### 3.4 各发布形态
62
+
63
+ | 包 | PDFium 如何到达终端用户 | 建议 |
64
+ | --- | ------------------------ | ---- |
65
+ | `@embedpdf-editor/chapter-snippet` | **tarball 内含 `dist/pdfium.wasm`** | 必须随包提供 `LICENSE.pdfium`(已纳入 `files`);`dist/` 构建后也会同步一份 |
66
+ | `@embedpdf-editor/react-chapter-viewer` | 依赖 `@embedpdf/pdfium`,由用户安装依赖获得 wasm | 包内仍附带 `LICENSE.pdfium` / 本文件,并在文档中说明依赖链 |
67
+ | `@embedpdf-editor/vue3-chapter-viewer` | 同上 | 同上 |
68
+
69
+ ### 3.5 Apache 2.0 与 MIT 的关系
70
+
71
+ - 二者 **可并存**:你们的章节编辑器可用 MIT,PDFium 部分适用 Apache 2.0。
72
+ - Apache 2.0 提供明确的 **专利授权** 条款(使用 PDFium 时的常见关注项之一)。
73
+ - **闭源商业产品** 一般可使用 PDFium,但仍须履行上述声明与许可附带义务。
74
+
75
+ ---
76
+
77
+ ## 4. 其他常见依赖
78
+
79
+ 通过 `@embedpdf/*` 与构建工具链可能间接引入的其他开源组件(如 Preact、Babel 等),其许可以 **各依赖包在 npm 上的声明** 为准。
80
+ 发版前可对生产 bundle 运行许可扫描(如 `license-checker`、`pnpm licenses list`)作为补充。
81
+
82
+ ---
83
+
84
+ ## 5. 维护说明
85
+
86
+ - PDFium 许可 **唯一源文件**:`packages/pdfium/LICENSE.pdfium`(随上游更新)
87
+ - 同步命令:`pnpm sync:pdfium-licenses`(在 `build:chapter-viewers` 前会自动执行)
88
+ - 模板:`engine-packages/shared/NOTICE.pdfium`、`engine-packages/shared/NOTICE`
89
+
90
+ ---
91
+
92
+ ## 6. 对外 npm 包内应包含的文件(检查清单)
93
+
94
+ 发布 `@embedpdf-editor/react-chapter-viewer` / `vue3-chapter-viewer` / `chapter-snippet` 时,tarball 中建议包含:
95
+
96
+ - [ ] `LICENSE`(MIT,含双版权行)
97
+ - [ ] `NOTICE`(衍生说明 + 指向 PDFium)
98
+ - [ ] `LICENSE.pdfium`(PDFium / Apache 2.0 全文)
99
+ - [ ] `NOTICE.pdfium`(PDFium 摘要)
100
+ - [ ] `THIRD-PARTY-NOTICES.md`(本文件副本)
101
+
102
+ `chapter-snippet` 另含 `dist/pdfium.wasm` 时,**尤其** 须保证 `dist/LICENSE.pdfium` 在构建后存在(由同步脚本写入)。