MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / waitForExportWindowState

Function waitForExportWindowState

apps/desktop/src/main/index.ts:1467–1491  ·  view source on GitHub ↗
(
  win: BrowserWindow,
  timeoutMs = 15000
)

Source from the content-addressed store, hash-verified

1465}
1466
1467async function waitForExportWindowState(
1468 win: BrowserWindow,
1469 timeoutMs = 15000
1470): Promise<void> {
1471 const startedAt = Date.now()
1472 while (!win.isDestroyed()) {
1473 const state = await win.webContents.executeJavaScript(
1474 'document.body?.dataset.exportState ?? ""',
1475 true
1476 )
1477 if (state === 'ready') return
1478 if (state === 'error') {
1479 const message = await win.webContents.executeJavaScript(
1480 'document.body?.dataset.exportError ?? "The export renderer reported an error."',
1481 true
1482 )
1483 throw new Error(typeof message === 'string' ? message : 'The export renderer reported an error.')
1484 }
1485 if (Date.now() - startedAt >= timeoutMs) {
1486 throw new Error('Timed out while preparing the note preview for PDF export.')
1487 }
1488 await new Promise((resolve) => setTimeout(resolve, 100))
1489 }
1490 throw new Error('The export window closed before PDF export completed.')
1491}
1492
1493async function exportNotePdf(
1494 relPath: string,

Callers 1

exportNotePdfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected