@embedpdf-editor/vue3-chapter-viewer 1.0.2 → 1.0.3
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 +27 -50
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +49 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5901 -5023
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -131,6 +131,11 @@ export declare interface ChapterDescriptor {
|
|
|
131
131
|
* PDF 来源。可省略:须在 ChapterManager 配置 `chapterPdfLoader` 中统一加载。
|
|
132
132
|
*/
|
|
133
133
|
source?: ChapterSource;
|
|
134
|
+
/**
|
|
135
|
+
* 章内多 PDF 分段时,每段最多页数(如 5 表示 13 页 → 3 段)。
|
|
136
|
+
* URL 由 `chapterPdfLoader.loadChapterUrls` 按章拉取,**不要**写在 `source` 里。
|
|
137
|
+
*/
|
|
138
|
+
segmentPageThreshold?: number;
|
|
134
139
|
encrypted?: boolean;
|
|
135
140
|
/**
|
|
136
141
|
* 仅当 OverlapOwnerStrategy = 'explicit' 时使用:
|
|
@@ -197,6 +202,9 @@ export declare class ChapterManagerPlugin extends BasePlugin<ChapterManagerPlugi
|
|
|
197
202
|
private readonly passwordAttempts;
|
|
198
203
|
private readonly pendingChapterLoadPromises;
|
|
199
204
|
private readonly pendingSegmentLoadPromises;
|
|
205
|
+
/** 步骤 2:`loadChapterUrls` 按章缓存 */
|
|
206
|
+
private readonly chapterUrlsCache;
|
|
207
|
+
private readonly pendingChapterUrlsPromises;
|
|
200
208
|
private unloadTimer;
|
|
201
209
|
private documentManagerUnsubs;
|
|
202
210
|
constructor(id: string, registry: PluginRegistry);
|
|
@@ -215,6 +223,8 @@ export declare class ChapterManagerPlugin extends BasePlugin<ChapterManagerPlugi
|
|
|
215
223
|
ensureAllSegmentsLoaded(chapterId: string): Promise<ChapterLoadStatus>;
|
|
216
224
|
ensureSegmentLoaded(chapterId: string, segmentIndex: number): Promise<ChapterLoadStatus>;
|
|
217
225
|
private ensureSingleDocumentChapter;
|
|
226
|
+
private resolveChapterUrls;
|
|
227
|
+
private openPayloadFromUrl;
|
|
218
228
|
private resolvePdfPayload;
|
|
219
229
|
private startLoadSegment;
|
|
220
230
|
private waitForTerminalStatus;
|
|
@@ -251,6 +261,21 @@ declare interface ChapterPageDocumentRef {
|
|
|
251
261
|
pageIndex: number;
|
|
252
262
|
}
|
|
253
263
|
|
|
264
|
+
/**
|
|
265
|
+
* 打开某一段 PDF 时的上下文(步骤 2 已拿到 urls,步骤 3 可选处理)。
|
|
266
|
+
*/
|
|
267
|
+
export declare interface ChapterPdfLoadContext {
|
|
268
|
+
chapter: ChapterDescriptor;
|
|
269
|
+
/** 当前要打开的段,0-based */
|
|
270
|
+
segmentIndex: number;
|
|
271
|
+
/** 该章总段数 */
|
|
272
|
+
segmentCount: number;
|
|
273
|
+
/** 步骤 2:`loadChapterUrls` 返回的完整列表 */
|
|
274
|
+
urls: string[];
|
|
275
|
+
/** 当前段对应 URL:`urls[segmentIndex]` */
|
|
276
|
+
url: string;
|
|
277
|
+
}
|
|
278
|
+
|
|
254
279
|
/**
|
|
255
280
|
* Backend-supplied chapter contract.
|
|
256
281
|
*
|
|
@@ -289,6 +314,7 @@ export declare interface ChapterPdfViewerProps {
|
|
|
289
314
|
|
|
290
315
|
declare interface ChapterSegmentInfo {
|
|
291
316
|
index: number;
|
|
317
|
+
/** 静态 manifest 有值;动态 loader 时为空,打开段时再解析 URL */
|
|
292
318
|
url: string;
|
|
293
319
|
localPageStart: number;
|
|
294
320
|
localPageEnd: number;
|
|
@@ -318,8 +344,8 @@ export declare type ChapterSource = {
|
|
|
318
344
|
load: () => Promise<ChapterPdfPayload>;
|
|
319
345
|
}
|
|
320
346
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
347
|
+
* @deprecated 请用章节级 `segmentPageThreshold` + `chapterPdfLoader.loadChapterUrls`。
|
|
348
|
+
* 静态多 URL 时:`urls.length` 须为 ceil(章页数 / segmentPageThreshold)。
|
|
323
349
|
*/
|
|
324
350
|
| {
|
|
325
351
|
urls: string[];
|
|
@@ -346,6 +372,8 @@ export declare type ChapterTreeInput = {
|
|
|
346
372
|
startPage: number;
|
|
347
373
|
endPage: number;
|
|
348
374
|
source?: ChapterSource;
|
|
375
|
+
/** 章内分段阈值;URL 由 `chapterPdfLoader.loadChapterUrls` 拉取 */
|
|
376
|
+
segmentPageThreshold?: number;
|
|
349
377
|
encrypted?: boolean;
|
|
350
378
|
children?: ChapterTreeInput[];
|
|
351
379
|
};
|
|
@@ -581,20 +609,32 @@ declare interface HoverBookmarkUiConfig_2 {
|
|
|
581
609
|
}
|
|
582
610
|
|
|
583
611
|
/**
|
|
584
|
-
*
|
|
612
|
+
* 章节 PDF 加载(推荐三步;`loadPdf` 仍兼容旧版单步写法)。
|
|
585
613
|
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
614
|
+
* | 步骤 | 方法 | 说明 |
|
|
615
|
+
* | --- | --- | --- |
|
|
616
|
+
* | 1 | manifest 章节树 | 仅 `chapterId`、页码、`segmentPageThreshold` 等,**无 URL** |
|
|
617
|
+
* | 2 | `loadChapterUrls(chapter)` | 按章请求详情,返回 URL 列表(分段时多项) |
|
|
618
|
+
* | 3 | `openPdf(ctx)`(可选) | 对 `ctx.url` 解密/下载;省略则直接用 `ctx.url` 打开 |
|
|
590
619
|
*
|
|
591
|
-
*
|
|
620
|
+
* 仍可使用 `loadPdf(chapter, segmentIndex)` 单步实现(等价于 2+3 合并)。
|
|
592
621
|
*/
|
|
593
622
|
export declare interface IChapterPdfLoader {
|
|
594
623
|
/**
|
|
624
|
+
* 步骤 2:按章拉取 PDF 地址列表。
|
|
625
|
+
* 单 PDF 章节返回长度为 1 的数组;分段章节返回与 `ceil(页数/threshold)` 一致的多项。
|
|
626
|
+
*/
|
|
627
|
+
loadChapterUrls?(chapter: ChapterDescriptor): Promise<string[]>;
|
|
628
|
+
/**
|
|
629
|
+
* 步骤 3(可选):将步骤 2 的 URL 转为可打开的 payload。
|
|
630
|
+
* 未实现时引擎使用 `{ url: ctx.url }`。
|
|
631
|
+
*/
|
|
632
|
+
openPdf?(ctx: ChapterPdfLoadContext): Promise<ChapterPdfPayload>;
|
|
633
|
+
/**
|
|
634
|
+
* @deprecated 单步加载;新代码请用 `loadChapterUrls` + 可选 `openPdf`。
|
|
595
635
|
* @param segmentIndex 章内分段索引;单 URL 章节为 0 或省略
|
|
596
636
|
*/
|
|
597
|
-
loadPdf(chapter: ChapterDescriptor, segmentIndex?: number): Promise<ChapterPdfPayload>;
|
|
637
|
+
loadPdf?(chapter: ChapterDescriptor, segmentIndex?: number): Promise<ChapterPdfPayload>;
|
|
598
638
|
}
|
|
599
639
|
|
|
600
640
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,gCAAgC,EAChC,+BAA+B,EAC/B,6BAA6B,EAC7B,oBAAoB,EACpB,4BAA4B,EAC5B,wBAAwB,EACxB,QAAQ,EACR,aAAa,GACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,+BAA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