@fuentis/phoenix-ui 0.0.9-alpha.614 → 0.0.9-alpha.615

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.
@@ -2465,15 +2465,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
2465
2465
  // DejaVu Sans font in base64 format for jsPDF
2466
2466
  // This font has excellent support for Serbian characters (ć, č, đ, š, ž)
2467
2467
  // Font source: https://github.com/dejavu-fonts/dejavu-fonts
2468
+ // Note: Full base64 string is very large, so we'll load it dynamically from CDN
2468
2469
  const DEJAVU_SANS = '';
2469
- const CDN_URL = 'https://cdn.jsdelivr.net/npm/dejavu-fonts-ttf@2.37.3/ttf/DejaVuSans.ttf';
2470
- const LOCAL_PATH = '/assets/fonts/DejaVuSans.ttf';
2471
- async function tryFetchFont(url) {
2470
+ // Function to load DejaVu Sans font dynamically
2471
+ async function loadDejaVuSansFont() {
2472
2472
  try {
2473
- const response = await fetch(url);
2474
- if (!response.ok)
2473
+ const response = await fetch('https://cdn.jsdelivr.net/npm/dejavu-fonts-ttf@2.37.3/ttf/DejaVuSans.ttf');
2474
+ if (!response.ok) {
2475
2475
  return null;
2476
+ }
2476
2477
  const arrayBuffer = await response.arrayBuffer();
2478
+ // Convert to base64 using chunking to avoid stack overflow
2477
2479
  const bytes = new Uint8Array(arrayBuffer);
2478
2480
  let binary = '';
2479
2481
  const chunkSize = 8192;
@@ -2481,23 +2483,14 @@ async function tryFetchFont(url) {
2481
2483
  const chunk = bytes.subarray(i, i + chunkSize);
2482
2484
  binary += String.fromCharCode.apply(null, Array.from(chunk));
2483
2485
  }
2484
- return btoa(binary);
2486
+ const base64 = btoa(binary);
2487
+ return base64;
2485
2488
  }
2486
- catch {
2489
+ catch (error) {
2490
+ console.warn('Failed to load DejaVu Sans font from CDN:', error);
2487
2491
  return null;
2488
2492
  }
2489
2493
  }
2490
- // Loads DejaVu Sans font. If url is provided, uses only that URL.
2491
- // Otherwise tries LOCAL_PATH first, then CDN as fallback.
2492
- async function loadDejaVuSansFont(url) {
2493
- if (url)
2494
- return tryFetchFont(url);
2495
- const local = await tryFetchFont(LOCAL_PATH);
2496
- if (local)
2497
- return local;
2498
- console.warn('DejaVu Sans not found at local path, falling back to CDN');
2499
- return tryFetchFont(CDN_URL);
2500
- }
2501
2494
 
2502
2495
  /* ----------------------------- Helpers ----------------------------- */
2503
2496
  /**
@@ -2668,10 +2661,8 @@ async function exportRowsToPdf(columns, rows, columnTypeMap, columnTypeEnum, t,
2668
2661
  else {
2669
2662
  pdfMake.vfs = pdfFonts || {};
2670
2663
  }
2671
- // vfs was just reset to Roboto-only; remove any stale font reference so vfs and fonts stay in sync
2672
- delete pdfMake.fonts?.DejaVuSans;
2673
2664
  try {
2674
- const dejaVuFont = await loadDejaVuSansFont(options.fontUrl);
2665
+ const dejaVuFont = await loadDejaVuSansFont();
2675
2666
  if (dejaVuFont) {
2676
2667
  pdfMake.fonts ??= {};
2677
2668
  pdfMake.fonts.DejaVuSans = {
@@ -3550,7 +3541,7 @@ class TableComponent {
3550
3541
  const file = this.tableConfiguration?.key
3551
3542
  ? buildFileName(this.tableConfiguration.key, 'pdf')
3552
3543
  : buildFileName('table', 'pdf');
3553
- exportRowsToPdf(this.selectedColumns, this.tableData, this.columnTypeMap, this.columnTypeEnum, (k) => this.translateService.instant(k), file, { fontUrl: this.tableConfiguration?.pdfFontUrl }).catch((error) => {
3544
+ exportRowsToPdf(this.selectedColumns, this.tableData, this.columnTypeMap, this.columnTypeEnum, (k) => this.translateService.instant(k), file).catch((error) => {
3554
3545
  console.error('Failed to export PDF:', error);
3555
3546
  });
3556
3547
  return;