-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Inject DevTools Script in Browser Extension #2778
Inject DevTools Script in Browser Extension #2778
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
interface DocumentEventMap { | ||
editorStateUpdate: CustomEvent; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the highlight
CustomEvent
. I'm unsure if a declare global
is what I'm supposed to be doing here. @thegreatercurve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do, it will just get referenced in this module scope either way.
const data = {lexicalKey: message.lexicalKey}; | ||
const detail = IS_FIREFOX | ||
? // eslint-disable-next-line no-undef | ||
cloneInto(data, document.defaultView) // see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts#cloneinto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only TS error I couldn't find a way to handle. This is a Firefox-only browser extension API.
There's a definition written in this package, should I just copy it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the current type definition from types.ts
:
export type cloneInto = (
arg: {data: {lexicalKey: string}},
arg2: WindowProxy,
) => {data: {lexicalKey: string}};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface DocumentEventMap { | ||
editorStateUpdate: CustomEvent; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do, it will just get referenced in this module scope either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the small type issues
5ce53b2
to
81e0e1a
Compare
@thegreatercurve My current fix for cloneInto being undefined is a little weird, you might want to take a look. I ended up dropping a Otherwise this is merge ready! |
@noi5e This seems fine to me. You're not polluting any global name space with this, and tbh, I'd probably just case it to |
* move devtools code to injected script * correct typescript errors * write cloneInto type * add injected script to web_accessible_resources * fix highlighting bug * wrapper function for cloneInto
This moves all of the code that was previously running as an inline string in
devtools.inspectedWindow.eval()
like so:And moves it to a new
inject.ts
file:Developer Tools Web Extension Planning Issue: #2127