@file-viewer/vite-plugin 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.
Files changed (2) hide show
  1. package/dist/index.js +34 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -465,6 +465,15 @@ const rendererModules = [
465
465
  rendererIds: ['data-asset'],
466
466
  chunkName: 'file-viewer-data'
467
467
  },
468
+ {
469
+ id: 'binary',
470
+ packageName: '@file-viewer/renderer-binary',
471
+ exportName: 'binaryRenderer',
472
+ formats: ['binary', 'binary-inspector', 'bin', 'hex', 'elf', 'exe', 'dll', 'class', 'macho'],
473
+ rendererIds: ['binary-inspector'],
474
+ chunkName: 'file-viewer-binary',
475
+ includeInPresetAll: false
476
+ },
468
477
  {
469
478
  id: 'eda',
470
479
  packageName: '@file-viewer/renderer-eda',
@@ -1483,6 +1492,21 @@ async function copyPdfCjkFontAssets(from, to) {
1483
1492
  await copyFile(license, join(to, 'OFL-1.1.txt'));
1484
1493
  return true;
1485
1494
  }
1495
+ function hasPdfCjkFontAssets(root, stylesheet, license) {
1496
+ if (!root) {
1497
+ return false;
1498
+ }
1499
+ const files = join(root, 'files');
1500
+ try {
1501
+ return (existsSync(join(root, stylesheet)) &&
1502
+ existsSync(join(root, license)) &&
1503
+ statSync(files).isDirectory() &&
1504
+ readdirSync(files, { withFileTypes: true }).some((entry) => entry.isFile() && entry.name.endsWith('.woff2')));
1505
+ }
1506
+ catch {
1507
+ return false;
1508
+ }
1509
+ }
1486
1510
  async function copyKnownRendererAssets(targetRoot, rendererIds) {
1487
1511
  const selected = new Set(rendererIds);
1488
1512
  const results = [];
@@ -1551,25 +1575,24 @@ async function copyKnownRendererAssets(targetRoot, rendererIds) {
1551
1575
  '@file-viewer/renderer-pdf'
1552
1576
  ]);
1553
1577
  const pdfCjkFontTarget = join(targetRoot, 'vendor/pdf/fonts');
1554
- // The standard profile pack owns the CJK fallback font; presets that activate the pdf
1555
- // renderer without that pack declare the font package directly. renderer-pdf must not
1556
- // vendor a second copy, so when no source is installed the build warns instead of
1557
- // failing and PDF rendering keeps using embedded fonts.
1558
- const pdfCjkFontSourceAvailable = Boolean(standardPdfCjkFontRoot && existsSync(join(standardPdfCjkFontRoot, 'noto-sans-sc.css'))) ||
1559
- Boolean(stagedPdfCjkFontRoot && existsSync(join(stagedPdfCjkFontRoot, 'wght.css'))) ||
1560
- Boolean(dependencyPdfCjkFontRoot);
1578
+ // The PDF renderer owns the runtime font dependency so direct renderer installs retain
1579
+ // CJK fallback support. The standard profile pack is only a pre-staged copy source.
1580
+ // A missing source means an incomplete install and must not silently drop the fallback.
1581
+ const hasStandardPdfCjkFont = hasPdfCjkFontAssets(standardPdfCjkFontRoot, 'noto-sans-sc.css', 'OFL-1.1.txt');
1582
+ const hasStagedPdfCjkFont = hasPdfCjkFontAssets(stagedPdfCjkFontRoot, 'wght.css', 'LICENSE');
1583
+ const hasDependencyPdfCjkFont = hasPdfCjkFontAssets(dependencyPdfCjkFontRoot, 'wght.css', 'LICENSE');
1584
+ const pdfCjkFontSourceAvailable = hasStandardPdfCjkFont || hasStagedPdfCjkFont || hasDependencyPdfCjkFont;
1561
1585
  await push('pdf', 'pdf-cjk-font-fallback', pdfCjkFontTarget, async () => {
1562
- if (standardPdfCjkFontRoot &&
1563
- existsSync(join(standardPdfCjkFontRoot, 'noto-sans-sc.css'))) {
1586
+ if (hasStandardPdfCjkFont && standardPdfCjkFontRoot) {
1564
1587
  return copyDirectoryIfPresent(standardPdfCjkFontRoot, pdfCjkFontTarget);
1565
1588
  }
1566
- if (stagedPdfCjkFontRoot && existsSync(join(stagedPdfCjkFontRoot, 'wght.css'))) {
1589
+ if (hasStagedPdfCjkFont && stagedPdfCjkFontRoot) {
1567
1590
  return copyPdfCjkFontAssets(stagedPdfCjkFontRoot, pdfCjkFontTarget);
1568
1591
  }
1569
1592
  return copyPdfCjkFontAssets(dependencyPdfCjkFontRoot, pdfCjkFontTarget);
1570
1593
  }, pdfCjkFontSourceAvailable
1571
1594
  ? undefined
1572
- : `install ${independentlyOwnedAssetRendererIds.get('pdf')} or @fontsource-variable/noto-sans-sc`, undefined, pdfCjkFontSourceAvailable ? undefined : false);
1595
+ : `repair @file-viewer/renderer-pdf and its @fontsource-variable/noto-sans-sc dependency`, undefined, true);
1573
1596
  const pptxRoot = resolvePackageRoot('@file-viewer/pptx', [
1574
1597
  '@file-viewer/renderer-pptx',
1575
1598
  '@file-viewer/renderer-presentation'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/vite-plugin",
3
- "version": "3.0.3",
3
+ "version": "3.1.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Vite plugin for File Viewer on-demand renderer assembly, chunk planning, and offline asset deployment.",
@@ -63,7 +63,7 @@
63
63
  }
64
64
  },
65
65
  "devDependencies": {
66
- "@types/node": "^26.4.0",
66
+ "@types/node": "^26.5.1",
67
67
  "typescript": "^6.0.3",
68
68
  "vite": "^8.2.2"
69
69
  },