@embedpdf-editor/chapter-snippet 0.3.6 → 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,9 @@ 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
+ This package redistributes pdfium.wasm. PDFium is licensed under the
12
+ Apache License 2.0. See NOTICE.pdfium, LICENSE.pdfium (also under dist/),
13
+ 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
@@ -43,7 +43,18 @@ import ChapterEmbedPDF from '@embedpdf-editor/chapter-snippet';
43
43
 
44
44
  发包构建会对 `dist/embedpdf-chapter.js` 做语法降级(去掉 `??` 等 ES2020 语法),Webpack / Vue CLI 默认可 parse。默认 `wasmUrl` 指向 jsDelivr 上的 `pdfium.wasm`,无需复制到 `public/`。
45
45
 
46
- 离线或内网部署时,可传 `wasmUrl: '/pdfium.wasm'`(自行把 `node_modules/@embedpdf-editor/chapter-snippet/dist/pdfium.wasm` 放到静态目录)。
46
+ 离线或内网部署时,可传 `wasmUrl`(**init 顶层**,与 `options` 同级):
47
+
48
+ ```js
49
+ // 相对路径:自行把 dist/pdfium.wasm 放到静态目录
50
+ wasmUrl: '/pdfium.wasm',
51
+
52
+ // 自有 OSS / CDN(完整 HTTPS 地址,示例)
53
+ wasmUrl:
54
+ 'https://hep-editor.oss-cn-beijing.aliyuncs.com/public/editor-public/js/pdfium.wasm',
55
+ ```
56
+
57
+ 详见 [docs/get-started/01-installation.md](../../docs/get-started/01-installation.md)。
47
58
 
48
59
  `@embedpdf-editor/chapter-snippet/webpack` 为**可选**辅助(仅 monorepo Vue 2.6 解析、或自定义 devServer COOP/COEP),普通用户不必使用。
49
60
 
@@ -132,6 +143,25 @@ viewer?.addEventListener(CHAPTER_SNIPPET_EVENTS.ready, (event) => {
132
143
 
133
144
  旧版本的 `editorInput` 仍可使用,但新代码应改为 `options`,并把 `features` 写在 `options.features` 或顶层 `features`。
134
145
 
146
+ ### 章内多 PDF 分段(`source.urls[]`)
147
+
148
+ ```js
149
+ source: {
150
+ urls: [part0Url, part1Url, part2Url],
151
+ segmentPageThreshold: 5, // 例:13 页 → 3 段
152
+ },
153
+ ```
154
+
155
+ - 先加载第一段,滚动懒加载后续段;`localPageIndex` 仍为章内连续页。
156
+ - 引擎内部 `documentId` 为 `chapterId#s0`、`#s1`…;**业务 API / 数据库只存 `chapterId` + `localPageIndex`**。
157
+ - `chapterPdfLoader.loadPdf(chapter, segmentIndex)` 第二参数为段索引(0-based)。
158
+
159
+ [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)
160
+
161
+ ### 按章持久化
162
+
163
+ `options.notes` / `options.bookmarks` 回调里的 `chapterId`、`localPageIndex` 与单 URL 章相同。划线备份用 `exportChapterAnnotations`,JSON 键为 `chapters[chapterId]`(导出 markup 时会拉全部分段)。
164
+
135
165
  ### `ChapterViewerOptions`(与 React / Vue3 一致)
136
166
 
137
167
  | 字段 | 说明 |
@@ -155,7 +185,7 @@ viewer?.addEventListener(CHAPTER_SNIPPET_EVENTS.ready, (event) => {
155
185
  | `notes` | `marker.renderIcon`、`renderMenuActions`、`highlightColor` |
156
186
  | `zoom` | `pageWidth`、`min` / `max` / `enabled`;实际上限不超过 `[data-chapter-scroll-viewport]` 宽度,resize 时自动 clamp |
157
187
  | `scrollViewport` | `background`(默认 `#f1f5f9`),`[data-chapter-scroll-viewport]` 背景 |
158
- | `selectionToolbar` | `hiddenBuiltinActions`、`extraActions`;扩展动作监听 `selectionExtraAction` 事件 |
188
+ | `selectionToolbar` | `hiddenBuiltinActions`(含 `copy`)、`renderCopyIcon`、`extraActions`;扩展动作监听 `selectionExtraAction` 事件 |
159
189
 
160
190
  ```js
161
191
  features: {
@@ -182,12 +212,27 @@ features: {
182
212
  },
183
213
  },
184
214
  selectionToolbar: {
215
+ // 复制默认开启,浮窗最左侧;隐藏:hiddenBuiltinActions: ['copy']
216
+ renderCopyIcon: () => {
217
+ const span = document.createElement('span');
218
+ span.textContent = '📋';
219
+ span.setAttribute('aria-hidden', 'true');
220
+ return span;
221
+ },
185
222
  extraActions: [{ id: 'cite', label: '引用', order: 10 }],
186
223
  },
187
224
  },
188
225
  ```
189
226
 
190
- `renderMenu` / `renderIcon` 在 snippet(Preact)内执行,请返回 **DOM 或 Preact 节点**;Vue 2 宿主不要用 `h()` 直接塞进 Shadow DOM。
227
+ 划词后点**复制**会将选中文本写入剪贴板。程序化:
228
+
229
+ ```js
230
+ import { copyTextToClipboard } from '@embedpdf-editor/chapter-snippet';
231
+
232
+ await copyTextToClipboard('文本');
233
+ ```
234
+
235
+ `renderMenu` / `renderIcon` / `renderCopyIcon` 在 snippet(Preact)内执行,请返回 **DOM 或 Preact 节点**;Vue 2 宿主不要用 `h()` 直接塞进 Shadow DOM。
191
236
 
192
237
  ## 事件
193
238
 
@@ -247,11 +292,21 @@ import {
247
292
  | 选项 | 说明 |
248
293
  | --- | --- |
249
294
  | `mode` | `replace` 清空后导入;`merge` 合并 |
250
- | `ensureChapterLoaded` | 默认 true,导入 markup 前打开 PDF |
295
+ | `ensureChapterLoaded` | 默认 true;含 markup 的分段章会加载 **全部段** 再合并页码 |
251
296
  | `bookmarks` / `notes` / `markup` | 默认 true,可关闭某一类 |
252
297
  | `persistNotes` / `persistBookmarks` | 导入后写回业务存储 |
253
298
 
254
- 示例见 `examples/chapter-viewer-demo-vue2/src/components/AnnotationsDemoBar.vue`。
299
+ 示例见 `examples/chapter-viewer-demo-vue2/src/components/AnnotationsDemoBar.vue`。详见 [10-annotations-io.md](../../docs/get-started/10-annotations-io.md)。
300
+
301
+ ## 教程索引
302
+
303
+ | 主题 | 文档 |
304
+ | --- | --- |
305
+ | 目录 | [docs/get-started/README.md](../../docs/get-started/README.md) |
306
+ | `wasmUrl`(含 OSS 示例) | [01-installation.md](../../docs/get-started/01-installation.md) |
307
+ | 划词复制 | [07-selection-toolbar.md](../../docs/get-started/07-selection-toolbar.md) |
308
+ | 事件常量 | [11-events-callbacks-and-component-api.md](../../docs/get-started/11-events-callbacks-and-component-api.md) |
309
+ | 分段 + 按章存储 | [12-segmented-pdf-and-per-chapter-storage.md](../../docs/get-started/12-segmented-pdf-and-per-chapter-storage.md) |
255
310
 
256
311
  ## 与 React / Vue3 渲染器的区别
257
312
 
@@ -262,6 +317,12 @@ import {
262
317
  | Registry | hook / ref | `chapter-viewer-ready` → `detail.registry` |
263
318
  | Vite | `chapterViewerViteResolve()` | `chapterSnippetViteResolve()` |
264
319
 
320
+ ## 许可
321
+
322
+ - 本包 JavaScript / 类型定义:**MIT**(见 `LICENSE`、`NOTICE`)
323
+ - **`dist/pdfium.wasm`**:来自 **PDFium**,适用 **Apache License 2.0**(见 `LICENSE.pdfium`、`NOTICE.pdfium`、`THIRD-PARTY-NOTICES.md`)
324
+ - 再分发本包或随产品打包 wasm 时,须保留上述许可文件
325
+
265
326
  ## 常见问题
266
327
 
267
328
  | 现象 | 处理 |
@@ -271,3 +332,4 @@ import {
271
332
  | 只显示空白 | 确认宿主元素有高度,且没有被父容器 `overflow`/flex 布局压到 0 |
272
333
  | 划词后没有笔记弹窗 | 监听 `chapter-note-request-create`,保存后调用 `detail.complete(noteId)` |
273
334
  | Vue/Vite 开发环境异常预构建 | 使用 `chapterSnippetViteResolve()`,确保 snippet 和 PDFium 引擎没有被 optimizeDeps 预构建 |
335
+ | 分段章存了 `#sN` | 业务层只用 `chapterId`;引擎段 ID 勿写入库 |
@@ -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` 在构建后存在(由同步脚本写入)。
@@ -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.
@@ -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.