Skip to content

Commit

Permalink
chore(js-ts): Convert app/util/browserScripts.js to TypeScript (#11405)
Browse files Browse the repository at this point in the history
Link to Devin run:
https://preview.devin.ai/devin/1b5085c4c16446edbf1768153a885382

If you have any feedback, you can leave comments in the PR and I'll
address them in the app!

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
  • Loading branch information
devin-ai-integration[bot] authored Sep 24, 2024
1 parent eaa9805 commit c4b9767
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/util/browserScripts.js → app/util/browserScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,21 @@ export const JS_WINDOW_INFORMATION = `
export const JS_DESELECT_TEXT = `if (window.getSelection) {window.getSelection().removeAllRanges();}
else if (document.selection) {document.selection.empty();}`;

export const JS_POST_MESSAGE_TO_PROVIDER = (message, origin) => `(function () {
export const JS_POST_MESSAGE_TO_PROVIDER = (
message: object,
origin: string
) => `(function () {
try {
window.postMessage(${JSON.stringify(message)}, '${origin}');
} catch (e) {
//Nothing to do
}
})()`;

export const JS_IFRAME_POST_MESSAGE_TO_PROVIDER = (message, origin) =>
export const JS_IFRAME_POST_MESSAGE_TO_PROVIDER = (
_message: object,
_origin: string
) =>
`(function () {})()`;
/** Disable sending messages to iframes for now
*
Expand All @@ -93,7 +99,7 @@ export const JS_IFRAME_POST_MESSAGE_TO_PROVIDER = (message, origin) =>
for (let frame of iframes){
try {
frame.contentWindow.postMessage(${JSON.stringify(message)}, '${origin}');
frame.contentWindow.postMessage(${JSON.stringify(_message)}, '${_origin}');
} catch (e) {
//Nothing to do
}
Expand Down

0 comments on commit c4b9767

Please sign in to comment.