@file-viewer/renderer-pptx 3.0.3 → 3.1.1

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.en.md CHANGED
@@ -8,4 +8,4 @@ import { pptxRenderer } from '@file-viewer/renderer-pptx'
8
8
 
9
9
  Install `@file-viewer/renderer-ppt` explicitly for legacy `.ppt`, or keep using the compatibility aggregate `@file-viewer/renderer-presentation` when both are required.
10
10
 
11
- Worker resolution first honors `presentation.workerUrl` or a configured shared asset base, then uses an emitted or directly served package asset, then checks the standard asset-copy manifest before retaining the package default. Normal Vite/Webpack builds do not probe absent optional manifests. Angular builds that omit dependency Workers can still use the standard asset-copy command without application aliases.
11
+ Worker resolution first honors `presentation.workerUrl` or a configured shared asset base, then uses an emitted or directly served package asset, then checks the standard asset-copy manifest. Unknown locations never fall back to a guessed application-relative URL; Angular, offline, and separate static directories use the standard asset-copy command without application aliases.
package/README.md CHANGED
@@ -8,4 +8,4 @@ import { pptxRenderer } from '@file-viewer/renderer-pptx'
8
8
 
9
9
  需要同时支持旧 `.ppt` 时,可显式安装 `@file-viewer/renderer-ppt`,或继续使用兼容聚合包 `@file-viewer/renderer-presentation`。
10
10
 
11
- Worker 选择顺序为显式 `presentation.workerUrl` 或共享资源根目录、打包器已输出或包目录内可解析的 Worker、标准复制工具的资源清单,最后保留包默认路径。正常 Vite/Webpack 构建不会为了探测可选清单而额外请求不存在的文件;Angular 未输出依赖中的 Worker 时仍可使用标准资产复制,无需业务 alias。
11
+ Worker 选择顺序为显式 `presentation.workerUrl` 或共享资源根目录、打包器已输出或包目录内可解析的 Worker、标准复制工具的资源清单。未知路径不会回退为猜测的应用相对地址;Angular、离线或独立静态目录使用标准资产复制,无需业务 alias。
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PptxViewer, RECOMMENDED_ZIP_LIMITS, resolvePptxPackageWorkerUrl } from '@file-viewer/pptx';
2
- import { DEFAULT_RENDERER_DEFINITIONS, createFileViewerTranslator, createFileViewerZoomChangeEmitter, getFileViewerShadowRootForNode, getDefaultFileViewerAssetBaseUrl, normalizeFileViewerErrorMessage, registerFileViewerZoomProvider, resolveFileViewerLocale, resolveFileViewerPresentationWorkerUrl, resolveFileViewerCopiedAssetUrl, resolveFileViewerRuntimeAssetBaseUrl, waitForFileViewerNextPaint, unregisterFileViewerZoomProvider, } from '@file-viewer/core';
2
+ import { DEFAULT_RENDERER_DEFINITIONS, attachFileViewerErrorMessage, createFileViewerTranslator, createFileViewerZoomChangeEmitter, getFileViewerShadowRootForNode, getDefaultFileViewerAssetBaseUrl, normalizeFileViewerErrorMessage, registerFileViewerZoomProvider, resolveFileViewerLocale, resolveFileViewerPresentationWorkerUrl, resolveFileViewerCopiedAssetUrl, resolveFileViewerRuntimeAssetBaseUrl, waitForFileViewerNextPaint, unregisterFileViewerZoomProvider, } from '@file-viewer/core';
3
3
  const pptxStyle = `
4
4
  .pptx-viewer-shell{position:relative;box-sizing:border-box;min-height:100%;padding:24px 20px;background:var(--file-viewer-render-surface-background,#eef3f8);color:#1f2d3b;font-family:Aptos,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif}
5
5
  .pptx-render-surface{min-height:240px}
@@ -235,8 +235,10 @@ const formatPptxDiagnosticError = (error, fallback, context) => {
235
235
  ? rawReason || localizedReason
236
236
  : localizedReason || rawReason) || fallback;
237
237
  const detail = sanitizePptxDiagnosticText(error.detail);
238
- const hint = sanitizePptxDiagnosticText(error.hint) ||
239
- localizePptxDiagnosticCopy(pptxDiagnosticFallbackHints[code], locale);
238
+ // Engine diagnostics may carry source-language hints. A known code has a
239
+ // wrapper-owned translation, so prefer it over the engine's raw copy.
240
+ const hint = localizePptxDiagnosticCopy(pptxDiagnosticFallbackHints[code], locale) ||
241
+ sanitizePptxDiagnosticText(error.hint);
240
242
  const stage = sanitizePptxDiagnosticText(error.stage);
241
243
  const usesWesternPunctuation = locale === 'en-US' || locale === 'de-DE';
242
244
  const separator = usesWesternPunctuation ? ': ' : ':';
@@ -471,6 +473,14 @@ export default async function renderPptx(buffer, target, _type, context) {
471
473
  var _a;
472
474
  (_a = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _a === void 0 ? void 0 : _a.call(context, buildExportAdapter(surface, targetWindow, () => viewer));
473
475
  };
476
+ const reportPptxFailure = (failure) => {
477
+ var _a;
478
+ state = 'error';
479
+ errorMessage = formatErrorMessage(failure, t('presentation.error.parseFailed'), context);
480
+ (_a = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _a === void 0 ? void 0 : _a.call(context, null);
481
+ syncUi();
482
+ return attachFileViewerErrorMessage(failure, errorMessage);
483
+ };
474
484
  registerFileViewerZoomProvider(shell, {
475
485
  zoomIn: () => setZoom(getCurrentZoomPercent() + 15),
476
486
  zoomOut: () => setZoom(getCurrentZoomPercent() - 15),
@@ -480,7 +490,7 @@ export default async function renderPptx(buffer, target, _type, context) {
480
490
  subscribe: zoomEmitter.subscribe,
481
491
  });
482
492
  const openPresentation = async () => {
483
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
493
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
484
494
  state = 'loading';
485
495
  errorMessage = '';
486
496
  progressiveReady = false;
@@ -518,6 +528,9 @@ export default async function renderPptx(buffer, target, _type, context) {
518
528
  if ((_d = context === null || context === void 0 ? void 0 : context.signal) === null || _d === void 0 ? void 0 : _d.aborted) {
519
529
  throw context.signal.reason || new DOMException('PPTX rendering aborted.', 'AbortError');
520
530
  }
531
+ if (!workerUrl) {
532
+ throw new Error('PPTX Worker URL is unavailable. Run file-viewer-copy-assets or provide presentation.workerUrl.');
533
+ }
521
534
  const nextViewer = await PptxViewer.open(buffer, surface, {
522
535
  styleRoot: resolvePptxStyleRoot(surface, context),
523
536
  fitMode: 'contain',
@@ -562,15 +575,11 @@ export default async function renderPptx(buffer, target, _type, context) {
562
575
  console.warn('PPTX slide render warning:', error);
563
576
  },
564
577
  onError: error => {
565
- var _a, _b;
578
+ var _a;
566
579
  if (disposed || ((_a = context === null || context === void 0 ? void 0 : context.signal) === null || _a === void 0 ? void 0 : _a.aborted)) {
567
580
  return;
568
581
  }
569
- state = 'error';
570
- errorMessage = formatErrorMessage(error, t('presentation.error.parseFailed'), context);
571
- (_b = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _b === void 0 ? void 0 : _b.call(context, null);
572
- syncUi();
573
- rejectCompletion(error);
582
+ rejectCompletion(reportPptxFailure(error));
574
583
  },
575
584
  });
576
585
  if (disposed || ((_e = context === null || context === void 0 ? void 0 : context.signal) === null || _e === void 0 ? void 0 : _e.aborted)) {
@@ -593,14 +602,10 @@ export default async function renderPptx(buffer, target, _type, context) {
593
602
  }
594
603
  viewer === null || viewer === void 0 ? void 0 : viewer.destroy();
595
604
  viewer = null;
596
- state = 'error';
597
- errorMessage = formatErrorMessage(error, t('presentation.error.parseFailed'), context);
598
- (_k = context === null || context === void 0 ? void 0 : context.registerExportAdapter) === null || _k === void 0 ? void 0 : _k.call(context, null);
599
- syncUi();
600
- throw error;
605
+ throw reportPptxFailure(error);
601
606
  }
602
607
  finally {
603
- (_l = context === null || context === void 0 ? void 0 : context.signal) === null || _l === void 0 ? void 0 : _l.removeEventListener('abort', abort);
608
+ (_k = context === null || context === void 0 ? void 0 : context.signal) === null || _k === void 0 ? void 0 : _k.removeEventListener('abort', abort);
604
609
  }
605
610
  };
606
611
  const cleanup = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/renderer-pptx",
3
- "version": "3.0.3",
3
+ "version": "3.1.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Standalone OpenXML PowerPoint renderer for PPTX, PPTM, POTX, POTM, PPSX, and PPSM files.",
@@ -53,8 +53,8 @@
53
53
  "LICENSE"
54
54
  ],
55
55
  "dependencies": {
56
- "@file-viewer/core": "3.0.3",
57
- "@file-viewer/pptx": "3.0.3"
56
+ "@file-viewer/core": "3.1.1",
57
+ "@file-viewer/pptx": "3.1.1"
58
58
  },
59
59
  "devDependencies": {
60
60
  "typescript": "^6.0.3"