@arcships/pptx-core 0.5.0 → 0.5.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/README.md CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  ## 当前状态
4
4
 
5
- 本包提供 PPTX 静态预览、播放模型、文档会话、播放控制器、页面切换和受控媒体,从 `0.3.0` 起公开发布。实现范围和验收结果见 [实现设计](../../docs/pptx-playback-implementation-design.md) 与 [正式播放验收记录](../../docs/pptx-playback-acceptance-results.md)。
5
+ 本包提供 PPTX 纵向列表/单页静态预览、播放模型、文档会话、播放控制器、页面切换和受控媒体,从 `0.3.0` 起公开发布。实现范围和验收结果见 [实现设计](../../docs/pptx-playback-implementation-design.md) 与 [正式播放验收记录](../../docs/pptx-playback-acceptance-results.md)。
6
6
 
7
7
  ```bash
8
- pnpm add @arcships/pptx-core@0.4.0
8
+ pnpm add @arcships/pptx-core@0.5.2
9
9
  ```
10
10
 
11
11
  浏览器能力从 `@arcships/pptx-core/browser` 导入。补丁后的渲染器代码已经包含在浏览器入口中,使用方不需要安装或配置 `@aiden0z/pptx-renderer`;其普通运行依赖由 npm 自动安装。
12
12
 
13
+ `createPptxPreviewSession()` 默认使用 `renderMode: "list"`,纵向连续渲染全部幻灯片并按可视区域挂载。`createPptxDocumentSession()` 默认使用 `renderMode: "slide"`,供动画播放控制器使用。两者都可以通过会话选项显式指定 `renderMode`;`listOptions` 控制窗口化、初始挂载页数和预渲染范围。
14
+
13
15
  ## 入口边界
14
16
 
15
17
  - `src/index.ts`、`src/types.ts`:平台无关的公开类型、错误和默认限制;
package/dist/browser.d.ts CHANGED
@@ -24,6 +24,16 @@ interface PptxPreviewSessionOptions {
24
24
  zoomPercent?: number;
25
25
  lazyMedia?: boolean;
26
26
  lazySlides?: boolean;
27
+ /** Static previews use a vertical page list; presentation playback uses one slide. */
28
+ renderMode?: "list" | "slide";
29
+ listOptions?: {
30
+ windowed?: boolean;
31
+ batchSize?: number;
32
+ initialSlides?: number;
33
+ overscanViewport?: number;
34
+ showSlideLabels?: boolean;
35
+ };
36
+ onSlideChange?: (index: number) => void;
27
37
  }
28
38
  type PptxApproximationPolicy = "off" | "safe";
29
39
  interface PptxDocumentSessionOptions extends PptxPreviewSessionOptions {
package/dist/browser.js CHANGED
@@ -15454,6 +15454,9 @@ function createPptxDocumentSession(container, options = {}) {
15454
15454
  lazyMedia: options.lazyMedia ?? true,
15455
15455
  lazySlides: options.lazySlides ?? true,
15456
15456
  pdfjs: false,
15457
+ onSlideChange(index) {
15458
+ options.onSlideChange?.(index);
15459
+ },
15457
15460
  onSlideRendered(index, element) {
15458
15461
  const slide = viewer.presentationData?.slides[index];
15459
15462
  if (slide) applyPptxObjectMarkers(element, slide.slidePath);
@@ -15553,7 +15556,20 @@ function createPptxDocumentSession(container, options = {}) {
15553
15556
  Math.max(presentation.slides.length - 1, 0)
15554
15557
  );
15555
15558
  viewer.load(presentation);
15556
- await viewer.renderSlide(initialSlide);
15559
+ if ((options.renderMode ?? "slide") === "list") {
15560
+ await viewer.renderList({
15561
+ windowed: options.listOptions?.windowed ?? true,
15562
+ batchSize: options.listOptions?.batchSize,
15563
+ initialSlides: options.listOptions?.initialSlides,
15564
+ overscanViewport: options.listOptions?.overscanViewport,
15565
+ showSlideLabels: options.listOptions?.showSlideLabels
15566
+ });
15567
+ if (initialSlide > 0) {
15568
+ await viewer.goToSlide(initialSlide, { behavior: "instant", block: "start" });
15569
+ }
15570
+ } else {
15571
+ await viewer.renderSlide(initialSlide);
15572
+ }
15557
15573
  task.assertCurrent();
15558
15574
  currentArchive = files;
15559
15575
  currentPlaybackDocument = playbackDocument;
@@ -15660,7 +15676,10 @@ function createPptxDocumentSession(container, options = {}) {
15660
15676
  return session;
15661
15677
  }
15662
15678
  function createPptxPreviewSession(container, options = {}) {
15663
- return createPptxDocumentSession(container, options);
15679
+ return createPptxDocumentSession(container, {
15680
+ ...options,
15681
+ renderMode: options.renderMode ?? "list"
15682
+ });
15664
15683
  }
15665
15684
  export {
15666
15685
  createPptxDocumentSession,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcships/pptx-core",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "PPTX preview and playback model with browser document sessions and animation controls",
6
6
  "keywords": ["pptx", "powerpoint", "presentation", "viewer", "playback", "animation"],