(plugin: CodeSpacePlugin)
| 514 | } |
| 515 | |
| 516 | function installCachedReadOverride(plugin: CodeSpacePlugin) { |
| 517 | const vault = plugin.app.vault as MutableVault; |
| 518 | const originalCachedRead = vault.cachedRead.bind(vault); |
| 519 | |
| 520 | vault.cachedRead = async (file: TFile) => { |
| 521 | const session = activeNativeExportSession; |
| 522 | if (!session || file.path !== session.sourceFile.path) { |
| 523 | return await originalCachedRead(file); |
| 524 | } |
| 525 | |
| 526 | session.cachedReadHits += 1; |
| 527 | debugNativePdf(session, "cachedRead intercepted for source file", { |
| 528 | file: file.path, |
| 529 | hit: session.cachedReadHits, |
| 530 | }); |
| 531 | const activeView = plugin.app.workspace.getActiveViewOfType(MarkdownView) as MutableMarkdownView | null; |
| 532 | return await buildExpandedMarkdown( |
| 533 | plugin, |
| 534 | activeView, |
| 535 | session.sourceFile, |
| 536 | session.fallbackMarkdown |
| 537 | ); |
| 538 | }; |
| 539 | |
| 540 | plugin.register(() => { |
| 541 | vault.cachedRead = originalCachedRead; |
| 542 | cleanupActiveNativeExportSession(); |
| 543 | }); |
| 544 | } |
| 545 | |
| 546 | function installMarkdownViewPrintPatch(plugin: CodeSpacePlugin) { |
| 547 | const markdownViewProto = MarkdownView.prototype as MutableMarkdownView; |
no test coverage detected