Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed circular dependency between papi and webview service causing im… #192

Merged
merged 2 commits into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/shared/services/web-view.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ const webViewRequire = (module: string) => {
};

// TODO: Hacking in React, createRoot, and papi onto window for now so webViews can access it. Make this TypeScript-y
// getPapi must be a function because this service cannot immediately access papi since it is a
// circular dependency
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).papi = papi;
(globalThis as any).getPapi = () => papi;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).React = React;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -142,7 +144,7 @@ export const addWebView = async (

/** String that sets up 'import' statements in the webview to pull in libraries and clear out internet access and such */
const imports = `
var papi = window.parent.papi;
var papi = window.parent.getPapi();
var React = window.parent.React;
var createRoot = window.parent.createRoot;
var require = window.parent.webViewRequire;
Expand Down