Skip to content

Commit

Permalink
fix: Improve plugin initial load time. Don't create the createObjectU…
Browse files Browse the repository at this point in the history
…RL till first publishing time.
  • Loading branch information
andymac4182 committed May 2, 2023
1 parent 1a622e3 commit 2c11c8e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/mermaid-electron-renderer/src/index.ts
Expand Up @@ -2,14 +2,18 @@ import { BrowserWindow } from "@electron/remote";
import { ChartData, MermaidRenderer } from "@markdown-confluence/lib";
import MermaidRendererClient from "mermaid_renderer.esbuild";

const mermaidRenderHtml = URL.createObjectURL(
new Blob([MermaidRendererClient], { type: "text/html" })
);
let mermaidRenderHtml: string;

export class ElectronMermaidRenderer implements MermaidRenderer {
async captureMermaidCharts(
charts: ChartData[]
): Promise<Map<string, Buffer>> {
if (!mermaidRenderHtml) {
mermaidRenderHtml = URL.createObjectURL(
new Blob([MermaidRendererClient], { type: "text/html" })
);
}

const capturedCharts = new Map<string, Buffer>();

const promises = charts.map(async (chart) => {
Expand Down

0 comments on commit 2c11c8e

Please sign in to comment.