@file-viewer/pptx
Advanced tools
+7
-1
@@ -1,2 +0,8 @@ | ||
| export declare const pptxViewerCss = "\n.flyfish-pptx-scale-box{position:relative;box-sizing:border-box;max-width:100%;margin:0 auto;min-width:0}\n.flyfish-pptx-content{position:absolute;top:0;left:0;box-sizing:border-box;max-width:none;min-width:0;transform-origin:top left;will-change:transform}\n.flyfish-pptx-content[data-render-state=\"loading\"]{opacity:.82}\n.flyfish-pptx-slide-slot{display:flow-root;box-sizing:border-box;width:100%;min-width:0}\n.flyfish-pptx-slide-error{display:flex;align-items:center;justify-content:center;background:#fff7ed!important;color:#9a3412}\n.flyfish-pptx-slide-error-card{display:grid;gap:10px;max-width:70%;padding:24px;border:1px solid #fdba74;border-radius:12px;background:#fff;text-align:center;font:14px/1.5 system-ui,sans-serif}\n.flyfish-pptx-slide-error-card strong{font-size:18px}\n.flyfish-pptx-content .slide{background:#fff;box-shadow:0 18px 36px rgba(18,35,52,.12)}\n.flyfish-pptx-thumbnail{display:block;box-sizing:border-box;width:min(960px,100%);height:auto;margin:0 auto 28px;border-radius:12px;background:#fff;box-shadow:0 18px 36px rgba(18,35,52,.14)}\n\n.slide{position:relative;border:0;border-radius:0;overflow:hidden;margin-bottom:50px;margin-left:auto;margin-right:auto;z-index:100}\n.slide div.block{position:absolute;top:0;left:0;width:100%;line-height:1}\n.slide div.content{display:flex;flex-direction:column}\n.slide div.diagram-content{display:flex;flex-direction:column}\n.slide div.content-rtl{display:flex;flex-direction:column;direction:rtl}\n.slide .pregraph-rtl{direction:rtl}\n.slide .pregraph-ltr{direction:ltr}\n.slide .pregraph-inherit{direction:inherit}\n.slide .slide-prgrph{width:100%}\n.slide .line-break-br::before{content:\"\\A\";white-space:pre}\n.slide div.v-up{justify-content:flex-start}\n.slide div.v-mid{justify-content:center}\n.slide div.v-down{justify-content:flex-end}\n.slide div.h-left{justify-content:flex-start;align-items:flex-start;text-align:left}\n.slide div.h-left-rtl{justify-content:flex-end;align-items:flex-end;text-align:left}\n.slide div.h-mid{justify-content:center;align-items:center;text-align:center}\n.slide div.h-right{justify-content:flex-end;align-items:flex-end;text-align:right}\n.slide div.h-right-rtl{justify-content:flex-start;align-items:flex-start;text-align:right}\n.slide div.h-just,.slide div.h-dist{text-align:justify}\n.slide div.up-left{justify-content:flex-start;align-items:flex-start;text-align:left}\n.slide div.up-center{justify-content:flex-start;align-items:center}\n.slide div.up-right{justify-content:flex-start;align-items:flex-end}\n.slide div.center-left{justify-content:center;align-items:flex-start;text-align:left}\n.slide div.center-center{justify-content:center;align-items:center}\n.slide div.center-right{justify-content:center;align-items:flex-end}\n.slide div.down-left{justify-content:flex-end;align-items:flex-start;text-align:left}\n.slide div.down-center{justify-content:flex-end;align-items:center}\n.slide div.down-right{justify-content:flex-end;align-items:flex-end}\n.slide li.slide{margin:10px 0;font-size:18px}\n.slide table{position:absolute}\n.slide svg.drawing{position:absolute;overflow:visible}\n\n.flyfish-pptx-content > .slide:last-of-type{margin-bottom:0}\n.flyfish-pptx-slide-slot:last-of-type > .slide{margin-bottom:0}\n"; | ||
| /** | ||
| * The legacy engine emits class-only selector lists. Prefix each top-level | ||
| * class rule so light-DOM consumers do not inherit generic `.slide` or | ||
| * generated `._css_*` rules from a renderer-local style element. | ||
| */ | ||
| export declare const scopePptxContentStyleText: (cssText: string) => string; | ||
| export declare const pptxViewerCss: string; | ||
| export declare const ensurePptxViewerStyles: (documentRef: Document, root?: Document | ShadowRoot) => void; |
+14
-1
@@ -34,2 +34,15 @@ const legacyPptxCss = ` | ||
| `; | ||
| const PPTX_CONTENT_STYLE_SCOPE = '.flyfish-pptx-content'; | ||
| /** | ||
| * The legacy engine emits class-only selector lists. Prefix each top-level | ||
| * class rule so light-DOM consumers do not inherit generic `.slide` or | ||
| * generated `._css_*` rules from a renderer-local style element. | ||
| */ | ||
| export const scopePptxContentStyleText = (cssText) => cssText.replace(/(^|})\s*(\.[^{}]+)\{/g, (_match, boundary, selectorList) => { | ||
| const scopedSelectors = selectorList | ||
| .split(',') | ||
| .map(selector => `${PPTX_CONTENT_STYLE_SCOPE} ${selector.trim()}`) | ||
| .join(','); | ||
| return `${boundary}${scopedSelectors}{`; | ||
| }); | ||
| export const pptxViewerCss = ` | ||
@@ -45,3 +58,3 @@ .flyfish-pptx-scale-box{position:relative;box-sizing:border-box;max-width:100%;margin:0 auto;min-width:0} | ||
| .flyfish-pptx-thumbnail{display:block;box-sizing:border-box;width:min(960px,100%);height:auto;margin:0 auto 28px;border-radius:12px;background:#fff;box-shadow:0 18px 36px rgba(18,35,52,.14)} | ||
| ${legacyPptxCss} | ||
| ${scopePptxContentStyleText(legacyPptxCss)} | ||
| .flyfish-pptx-content > .slide:last-of-type{margin-bottom:0} | ||
@@ -48,0 +61,0 @@ .flyfish-pptx-slide-slot:last-of-type > .slide{margin-bottom:0} |
+2
-2
| import { renderPptxPostProcessing } from './chart.js'; | ||
| import { resolvePptxEngineOptions, RECOMMENDED_ZIP_LIMITS } from './options.js'; | ||
| import { ensurePptxViewerStyles } from './styles.js'; | ||
| import { ensurePptxViewerStyles, scopePptxContentStyleText } from './styles.js'; | ||
| import { createPptxWorker } from './worker.js'; | ||
@@ -254,3 +254,3 @@ const clamp = (value, min, max) => { | ||
| const style = this.target.ownerDocument.createElement('style'); | ||
| style.textContent = css; | ||
| style.textContent = scopePptxContentStyleText(css); | ||
| this.content.append(style); | ||
@@ -257,0 +257,0 @@ } |
+24
-6
@@ -1,2 +0,3 @@ | ||
| const viteOptimizedWorkerPath = '/node_modules/.vite/deps/worker/pptx.worker.js'; | ||
| const viteOptimizedWorkerPathPattern = /\/\.?vite\/deps\/worker\/pptx\.worker\.js$/; | ||
| const angularCachePath = '/.angular/cache/'; | ||
| const viteOptimizedPptxSourcePattern = /\/\/\s+(node_modules\/(?:\.pnpm\/[^\n]+?\/node_modules\/)?@file-viewer\/pptx\/dist\/worker\.js)\b/; | ||
@@ -8,3 +9,14 @@ const resolveBundledPptxWorkerUrl = () => new URL('./worker/pptx.worker.js', import.meta.url); | ||
| : new URL(typeof location !== 'undefined' ? location.href : 'file:///')); | ||
| const resolveViteOptimizedPptxWorkerUrl = () => { | ||
| const resolveAngularVitePptxWorkerUrl = (baseUrl, workerPath) => { | ||
| const cacheIndex = baseUrl.pathname.indexOf(angularCachePath); | ||
| if (cacheIndex < 0) { | ||
| return null; | ||
| } | ||
| const workerUrl = new URL(baseUrl.href); | ||
| workerUrl.pathname = `${workerUrl.pathname.slice(0, cacheIndex)}/${workerPath}`; | ||
| workerUrl.search = ''; | ||
| workerUrl.hash = ''; | ||
| return workerUrl; | ||
| }; | ||
| const resolveViteOptimizedPptxWorkerUrl = (defaultPptxWorkerUrl) => { | ||
| if (typeof XMLHttpRequest === 'undefined') { | ||
@@ -27,3 +39,6 @@ return null; | ||
| const workerPath = match[1].replace(/dist\/worker\.js$/, 'dist/worker/pptx.worker.js'); | ||
| const defaultPptxWorkerUrl = resolveBundledPptxWorkerUrl(); | ||
| const angularWorkerUrl = resolveAngularVitePptxWorkerUrl(defaultPptxWorkerUrl, workerPath); | ||
| if (angularWorkerUrl) { | ||
| return angularWorkerUrl; | ||
| } | ||
| const origin = typeof location !== 'undefined' && location.origin | ||
@@ -43,5 +58,8 @@ ? location.origin | ||
| } | ||
| // Vite dep optimization rewrites import.meta.url into .vite/deps, away from this package's worker file. | ||
| if (defaultPptxWorkerUrl.pathname.includes(viteOptimizedWorkerPath)) { | ||
| return resolveViteOptimizedPptxWorkerUrl() || resolveViteDevPptxWorkerUrl(defaultPptxWorkerUrl); | ||
| // Vite dep optimization rewrites import.meta.url into vite/deps, away from | ||
| // this package's worker file. Angular's application builder uses the same | ||
| // optimizer under .angular/cache and prefixes its @fs URL with baseHref. | ||
| if (viteOptimizedWorkerPathPattern.test(defaultPptxWorkerUrl.pathname)) { | ||
| return resolveViteOptimizedPptxWorkerUrl(defaultPptxWorkerUrl) | ||
| || resolveViteDevPptxWorkerUrl(defaultPptxWorkerUrl); | ||
| } | ||
@@ -48,0 +66,0 @@ return defaultPptxWorkerUrl; |
+4
-4
| { | ||
| "name": "@file-viewer/pptx", | ||
| "version": "2.2.2", | ||
| "version": "2.2.3", | ||
| "private": false, | ||
| "type": "module", | ||
| "description": "Native PPTX renderer extracted from Flyfish File Viewer", | ||
| "description": "Native PPTX renderer extracted from File Viewer", | ||
| "keywords": [ | ||
@@ -22,4 +22,4 @@ "pptx", | ||
| "author": { | ||
| "name": "Wangyu", | ||
| "email": "wybaby168@gmail.com" | ||
| "name": "Yu Wang", | ||
| "email": "admin@flyfish.dev" | ||
| }, | ||
@@ -26,0 +26,0 @@ "repository": { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
3655
0.69%3
-25%643541
-0.24%