Skip to content

Commit

Permalink
fix: Fix issues with puppeteer rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
andymac4182 committed May 9, 2023
1 parent a7d44d3 commit 01824b6
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 122 deletions.
45 changes: 0 additions & 45 deletions packages/lib/esbuild.config.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions packages/lib/package.json
Expand Up @@ -8,8 +8,8 @@
"type": "module",
"sideEffects": false,
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc && node esbuild.config.mjs production",
"dev": "tsc --watch",
"build": "tsc",
"fmt": "npx prettier --write src/",
"lint": "eslint --ignore-path ../../.eslintignore --ext .js,.ts src/",
"prettier-check": "npx prettier --check src/",
Expand Down
@@ -1,4 +1,3 @@
import path from "path";
import { ConfluenceSettings } from "../Settings";
import { SettingsLoader } from "./SettingsLoader";
import yargs from "yargs";
Expand All @@ -15,16 +14,6 @@ export class CommandLineArgumentSettingsLoader extends SettingsLoader {
loadPartial(): Partial<ConfluenceSettings> {
const options = yargs(process.argv)
.usage("Usage: $0 [options]")
.option("config", {
alias: "c",
describe: "Path to the config file",
type: "string",
default: path.join(
process.env["HOME"] ?? "",
".mermaid-confluence.json"
),
demandOption: false,
})
.option("baseUrl", {
alias: "b",
describe: "Confluence base URL",
Expand Down
19 changes: 11 additions & 8 deletions packages/lib/tsconfig.json
@@ -1,13 +1,16 @@
{
"extends": "../../tsconfig.json",
"compilerOptions":{
"baseUrl":".",
"rootDir": "src",
"outDir": "dist",
"declarationDir": "dist",
"emitDeclarationOnly": true,
"skipLibCheck": true
"baseUrl":".",
"rootDir": "src",
"outDir": "dist",
"declarationDir": "dist",
"emitDeclarationOnly": false,
"skipLibCheck": true,
"listEmittedFiles": true,
"module":"ESNext",
"target":"ESNext",
},
"include":[ "**/*.ts", "**/*.tsx" ],
"exclude": ["node_modules", "packages/**/dist/*", "dist/*", "**/*.test.ts", "**/jest.config.ts"]
"include":[ "**/*.ts", "**/*.tsx", "**/**.js", "**/**.jsx", ],
"exclude": ["node_modules", "packages/**/dist/*", "dist/*", "**/*.test.ts", "**/jest.config.ts"]
}
42 changes: 0 additions & 42 deletions packages/mermaid-electron-renderer/esbuild.config.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions packages/mermaid-electron-renderer/package.json
Expand Up @@ -8,8 +8,8 @@
"type": "module",
"sideEffects": false,
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc && node esbuild.config.mjs production",
"dev": "tsc --watch",
"build": "tsc",
"fmt": "npx prettier --write src/",
"lint": "eslint --ignore-path ../../.eslintignore --ext .js,.ts src/",
"prettier-check": "npx prettier --check src/"
Expand Down
7 changes: 5 additions & 2 deletions packages/mermaid-electron-renderer/tsconfig.json
Expand Up @@ -5,8 +5,11 @@
"rootDir": "src",
"outDir": "dist",
"declarationDir": "dist",
"emitDeclarationOnly": true,
"skipLibCheck": true,
"emitDeclarationOnly": false,
"skipLibCheck": true,
"listEmittedFiles": true,
"module":"ESNext",
"target":"ESNext",
},
"include":[ "**/*.ts", "**/*.tsx" ],
"exclude": ["node_modules", "packages/**/dist/*", "dist/*", "**/*.test.ts", "**/jest.config.ts"]
Expand Down
6 changes: 0 additions & 6 deletions packages/mermaid-puppeteer-renderer/src/global.d.ts

This file was deleted.

15 changes: 11 additions & 4 deletions packages/mermaid-puppeteer-renderer/src/index.ts
Expand Up @@ -3,6 +3,13 @@ import path from "path";
import puppeteer from "puppeteer";
import url from "url";

interface RemoteWindowedCustomFunctions {
renderMermaidChart: (
mermaidData: string,
mermaidConfig: unknown
) => Promise<{ width: number; height: number }>;
}

export class PuppeteerMermaidRenderer implements MermaidRenderer {
async captureMermaidCharts(
charts: ChartData[]
Expand Down Expand Up @@ -46,10 +53,10 @@ export class PuppeteerMermaidRenderer implements MermaidRenderer {

const result = await page.evaluate(
(mermaidData, mermaidConfig) => {
return window.renderMermaidChart(
mermaidData,
mermaidConfig
);
const { renderMermaidChart } =
globalThis as unknown as RemoteWindowedCustomFunctions;

return renderMermaidChart(mermaidData, mermaidConfig);
},
chart.data,
mermaidConfig
Expand Down

0 comments on commit 01824b6

Please sign in to comment.