MCPcopy Create free account
hub / github.com/UNLINEARITY/Obsidian-CodeSpace / beginNativeExportSession

Function beginNativeExportSession

src/native_pdf_export_patch.ts:384–483  ·  view source on GitHub ↗
(
	plugin: CodeSpacePlugin,
	sourceFile: TFile,
	fallbackMarkdown: string,
	ownerDoc: Document,
	knownModals: Set<HTMLElement>
)

Source from the content-addressed store, hash-verified

382}
383
384function beginNativeExportSession(
385 plugin: CodeSpacePlugin,
386 sourceFile: TFile,
387 fallbackMarkdown: string,
388 ownerDoc: Document,
389 knownModals: Set<HTMLElement>
390): () => void {
391 cleanupActiveNativeExportSession();
392
393 const docWindow = ownerDoc.defaultView ?? window;
394 const body = ownerDoc.body;
395 if (!body) {
396 return () => undefined;
397 }
398
399 const session: NativeExportSession = {
400 id: ++nativeExportSessionCounter,
401 sourceFile,
402 ownerDoc,
403 ownerWindow: docWindow,
404 fallbackMarkdown,
405 knownModals,
406 trackedModals: new Set<HTMLElement>(),
407 sawTrackedModal: false,
408 observer: null,
409 timeoutId: null,
410 restoreWindowOpen: null,
411 popupCleanups: new Set<() => void>(),
412 lastPopupScanSignature: null,
413 cachedReadHits: 0,
414 replacementAttempts: 0,
415 replacementSuccesses: 0,
416 popupOpened: false,
417 cleanup: () => undefined,
418 };
419
420 const cleanup = () => {
421 if (activeNativeExportSession !== session) {
422 return;
423 }
424
425 session.observer?.disconnect();
426 if (session.timeoutId !== null) {
427 docWindow.clearTimeout(session.timeoutId);
428 }
429 for (const popupCleanup of Array.from(session.popupCleanups)) {
430 popupCleanup();
431 }
432 session.restoreWindowOpen?.();
433 debugNativePdf(session, "cleaning up native export session", {
434 cachedReadHits: session.cachedReadHits,
435 replacementAttempts: session.replacementAttempts,
436 replacementSuccesses: session.replacementSuccesses,
437 trackedModalCount: session.trackedModals.size,
438 });
439 activeNativeExportSession = null;
440 };
441

Callers 1

Calls 4

refreshTrackedModalsFunction · 0.85
debugNativePdfFunction · 0.85
installPopupWindowHookFunction · 0.85

Tested by

no test coverage detected