@file-viewer/vite-plugin 2.3.0 → 2.3.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/dist/index.js +69 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53,20 +53,26 @@ const rendererModules = [
|
|
|
53
53
|
id: 'presentation',
|
|
54
54
|
packageName: '@file-viewer/renderer-presentation',
|
|
55
55
|
exportName: 'presentationRenderer',
|
|
56
|
-
formats: [
|
|
57
|
-
'presentation',
|
|
58
|
-
'ppt',
|
|
59
|
-
'pptx',
|
|
60
|
-
'pptm',
|
|
61
|
-
'pot',
|
|
62
|
-
'potx',
|
|
63
|
-
'potm',
|
|
64
|
-
'ppsx',
|
|
65
|
-
'ppsm'
|
|
66
|
-
],
|
|
56
|
+
formats: ['presentation'],
|
|
67
57
|
rendererIds: ['office-presentation-binary', 'office-presentation'],
|
|
68
58
|
chunkName: 'file-viewer-presentation'
|
|
69
59
|
},
|
|
60
|
+
{
|
|
61
|
+
id: 'presentation-binary',
|
|
62
|
+
packageName: '@file-viewer/renderer-presentation/ppt',
|
|
63
|
+
exportName: 'pptRenderer',
|
|
64
|
+
formats: ['ppt', 'pot'],
|
|
65
|
+
rendererIds: ['office-presentation-binary'],
|
|
66
|
+
chunkName: 'file-viewer-presentation-ppt'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'presentation-openxml',
|
|
70
|
+
packageName: '@file-viewer/renderer-presentation/pptx',
|
|
71
|
+
exportName: 'pptxRenderer',
|
|
72
|
+
formats: ['pptx', 'pptm', 'potx', 'potm', 'ppsx', 'ppsm'],
|
|
73
|
+
rendererIds: ['office-presentation'],
|
|
74
|
+
chunkName: 'file-viewer-presentation-pptx'
|
|
75
|
+
},
|
|
70
76
|
{
|
|
71
77
|
id: 'word',
|
|
72
78
|
packageName: '@file-viewer/renderer-word',
|
|
@@ -1070,8 +1076,37 @@ function resolvePackageEntry(packageName, anchorPackages = []) {
|
|
|
1070
1076
|
return null;
|
|
1071
1077
|
}
|
|
1072
1078
|
const packageRoot = dirname(packageJsonPath);
|
|
1079
|
+
const anchorPackageJson = anchorPackages
|
|
1080
|
+
.map((anchorPackage) => resolvePackageJson(anchorPackage))
|
|
1081
|
+
.find(Boolean);
|
|
1082
|
+
const requireFns = [
|
|
1083
|
+
projectRequire(),
|
|
1084
|
+
pluginRequire,
|
|
1085
|
+
...(anchorPackageJson ? [createRequire(anchorPackageJson)] : [])
|
|
1086
|
+
];
|
|
1073
1087
|
try {
|
|
1074
1088
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
1089
|
+
const exportSubpath = packageJson.name && packageName.startsWith(`${packageJson.name}/`)
|
|
1090
|
+
? `.${packageName.slice(packageJson.name.length)}`
|
|
1091
|
+
: null;
|
|
1092
|
+
if (exportSubpath) {
|
|
1093
|
+
const exportedEntry = readPackageExportEntry(packageJson.exports?.[exportSubpath]);
|
|
1094
|
+
if (exportedEntry) {
|
|
1095
|
+
const entry = resolve(packageRoot, exportedEntry);
|
|
1096
|
+
if (existsSync(entry) && statSync(entry).isFile()) {
|
|
1097
|
+
return entry;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
for (const requireFn of requireFns) {
|
|
1101
|
+
try {
|
|
1102
|
+
return requireFn.resolve(packageName);
|
|
1103
|
+
}
|
|
1104
|
+
catch {
|
|
1105
|
+
// Continue probing alternate anchors.
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return null;
|
|
1109
|
+
}
|
|
1075
1110
|
const candidates = unique([
|
|
1076
1111
|
packageJson.module,
|
|
1077
1112
|
packageJson.main,
|
|
@@ -1087,14 +1122,6 @@ function resolvePackageEntry(packageName, anchorPackages = []) {
|
|
|
1087
1122
|
catch {
|
|
1088
1123
|
// Fall back to Node resolution below.
|
|
1089
1124
|
}
|
|
1090
|
-
const anchorPackageJson = anchorPackages
|
|
1091
|
-
.map((anchorPackage) => resolvePackageJson(anchorPackage))
|
|
1092
|
-
.find(Boolean);
|
|
1093
|
-
const requireFns = [
|
|
1094
|
-
projectRequire(),
|
|
1095
|
-
pluginRequire,
|
|
1096
|
-
...(anchorPackageJson ? [createRequire(anchorPackageJson)] : [])
|
|
1097
|
-
];
|
|
1098
1125
|
for (const requireFn of requireFns) {
|
|
1099
1126
|
try {
|
|
1100
1127
|
return requireFn.resolve(packageName);
|
|
@@ -1209,6 +1236,20 @@ async function copyDirectoryIfPresent(from, to) {
|
|
|
1209
1236
|
await cp(from, to, { recursive: true, force: true });
|
|
1210
1237
|
return true;
|
|
1211
1238
|
}
|
|
1239
|
+
async function copyVersionedCadRuntimeDirectoryIfPresent(from, to, runtimeVersion) {
|
|
1240
|
+
if (!from || !existsSync(from)) {
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
if (!runtimeVersion || !/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(runtimeVersion)) {
|
|
1244
|
+
throw new Error(`[file-viewer:vite-plugin] Cannot publish CAD runtime assets with invalid version ${JSON.stringify(runtimeVersion)}.`);
|
|
1245
|
+
}
|
|
1246
|
+
const copied = await copyDirectoryIfPresent(from, to);
|
|
1247
|
+
if (!copied) {
|
|
1248
|
+
return false;
|
|
1249
|
+
}
|
|
1250
|
+
const versionedTarget = join(to, runtimeVersion);
|
|
1251
|
+
return copyDirectoryIfPresent(from, versionedTarget);
|
|
1252
|
+
}
|
|
1212
1253
|
async function copyPdfCjkFontAssets(from, to) {
|
|
1213
1254
|
if (!from) {
|
|
1214
1255
|
return false;
|
|
@@ -1291,8 +1332,15 @@ async function copyKnownRendererAssets(targetRoot, rendererIds) {
|
|
|
1291
1332
|
sourceVersion: spreadsheetVersion || undefined
|
|
1292
1333
|
}
|
|
1293
1334
|
: undefined);
|
|
1294
|
-
const
|
|
1295
|
-
|
|
1335
|
+
const cadDependencyAnchors = ['@file-viewer/renderer-cad'];
|
|
1336
|
+
const cadRoot = resolvePackageRoot('@flyfish-dev/cad-viewer', cadDependencyAnchors);
|
|
1337
|
+
const cadRuntimeVersion = assertOwnedPackageVersion('@flyfish-dev/cad-viewer', cadRoot, '@file-viewer/renderer-cad', cadDependencyAnchors);
|
|
1338
|
+
await push('cad', 'cad-wasm-directory', join(targetRoot, 'wasm/cad'), () => copyVersionedCadRuntimeDirectoryIfPresent(cadRoot ? join(cadRoot, 'dist/wasm') : null, join(targetRoot, 'wasm/cad'), cadRuntimeVersion), undefined, cadRoot
|
|
1339
|
+
? {
|
|
1340
|
+
sourcePackage: '@flyfish-dev/cad-viewer',
|
|
1341
|
+
sourceVersion: cadRuntimeVersion || undefined
|
|
1342
|
+
}
|
|
1343
|
+
: undefined);
|
|
1296
1344
|
const modelDependencyAnchors = [
|
|
1297
1345
|
'@file-viewer/renderer-3d',
|
|
1298
1346
|
'@file-viewer/geometry-engine'
|
package/package.json
CHANGED