@file-viewer/pptx 2.2.2 → 2.2.4
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/dist/styles.d.ts +7 -1
- package/dist/styles.js +14 -1
- package/dist/viewer.d.ts +4 -0
- package/dist/viewer.js +77 -2
- package/dist/worker/pptx.worker.js +9 -10
- package/dist/worker.js +24 -6
- package/package.json +4 -4
package/dist/worker.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
const
|
|
1
|
+
const viteOptimizedWorkerPathPattern = /\/\.?vite\/deps\/worker\/pptx\.worker\.js$/;
|
|
2
|
+
const angularCachePath = '/.angular/cache/';
|
|
2
3
|
const viteOptimizedPptxSourcePattern = /\/\/\s+(node_modules\/(?:\.pnpm\/[^\n]+?\/node_modules\/)?@file-viewer\/pptx\/dist\/worker\.js)\b/;
|
|
3
4
|
const resolveBundledPptxWorkerUrl = () => new URL('./worker/pptx.worker.js', import.meta.url);
|
|
4
5
|
const canResolveAbsolutePathFrom = (url) => url.protocol !== 'data:' && url.protocol !== 'blob:';
|
|
5
6
|
const resolveViteDevPptxWorkerUrl = (baseUrl) => new URL('/node_modules/@file-viewer/pptx/dist/worker/pptx.worker.js', canResolveAbsolutePathFrom(baseUrl)
|
|
6
7
|
? baseUrl
|
|
7
8
|
: new URL(typeof location !== 'undefined' ? location.href : 'file:///'));
|
|
8
|
-
const
|
|
9
|
+
const resolveAngularVitePptxWorkerUrl = (baseUrl, workerPath) => {
|
|
10
|
+
const cacheIndex = baseUrl.pathname.indexOf(angularCachePath);
|
|
11
|
+
if (cacheIndex < 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const workerUrl = new URL(baseUrl.href);
|
|
15
|
+
workerUrl.pathname = `${workerUrl.pathname.slice(0, cacheIndex)}/${workerPath}`;
|
|
16
|
+
workerUrl.search = '';
|
|
17
|
+
workerUrl.hash = '';
|
|
18
|
+
return workerUrl;
|
|
19
|
+
};
|
|
20
|
+
const resolveViteOptimizedPptxWorkerUrl = (defaultPptxWorkerUrl) => {
|
|
9
21
|
if (typeof XMLHttpRequest === 'undefined') {
|
|
10
22
|
return null;
|
|
11
23
|
}
|
|
@@ -23,7 +35,10 @@ const resolveViteOptimizedPptxWorkerUrl = () => {
|
|
|
23
35
|
return null;
|
|
24
36
|
}
|
|
25
37
|
const workerPath = match[1].replace(/dist\/worker\.js$/, 'dist/worker/pptx.worker.js');
|
|
26
|
-
const
|
|
38
|
+
const angularWorkerUrl = resolveAngularVitePptxWorkerUrl(defaultPptxWorkerUrl, workerPath);
|
|
39
|
+
if (angularWorkerUrl) {
|
|
40
|
+
return angularWorkerUrl;
|
|
41
|
+
}
|
|
27
42
|
const origin = typeof location !== 'undefined' && location.origin
|
|
28
43
|
? location.origin
|
|
29
44
|
: defaultPptxWorkerUrl.origin;
|
|
@@ -38,9 +53,12 @@ const resolveDefaultPptxWorkerUrl = () => {
|
|
|
38
53
|
if (!canResolveAbsolutePathFrom(defaultPptxWorkerUrl)) {
|
|
39
54
|
return defaultPptxWorkerUrl;
|
|
40
55
|
}
|
|
41
|
-
// Vite dep optimization rewrites import.meta.url into
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
// Vite dep optimization rewrites import.meta.url into vite/deps, away from
|
|
57
|
+
// this package's worker file. Angular's application builder uses the same
|
|
58
|
+
// optimizer under .angular/cache and prefixes its @fs URL with baseHref.
|
|
59
|
+
if (viteOptimizedWorkerPathPattern.test(defaultPptxWorkerUrl.pathname)) {
|
|
60
|
+
return resolveViteOptimizedPptxWorkerUrl(defaultPptxWorkerUrl)
|
|
61
|
+
|| resolveViteDevPptxWorkerUrl(defaultPptxWorkerUrl);
|
|
44
62
|
}
|
|
45
63
|
return defaultPptxWorkerUrl;
|
|
46
64
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/pptx",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Native PPTX renderer extracted from
|
|
6
|
+
"description": "Native PPTX renderer extracted from File Viewer",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"pptx",
|
|
9
9
|
"powerpoint",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|
|
20
20
|
},
|
|
21
21
|
"author": {
|
|
22
|
-
"name": "
|
|
23
|
-
"email": "
|
|
22
|
+
"name": "Yu Wang",
|
|
23
|
+
"email": "admin@flyfish.dev"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|