Repository navigation
feat: autoMount content script UIs - #1210
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Also, seems like windows tests are broken? |
|
Hmm, the stop function returned from |
|
Actually, maybe there is value in keeping the stop function. Maybe we should just tell people to call remove in the docs, and optionally mention that they can stop watching but keep the UI mounted if they want by calling stop. |
|
Hmm but now I feel it is better to stipulate the operation strictly. In the original Issue we had a conversation about covering only one scenario, and the |
|
If we are confused, the users will be more confused. |
It was an error that the document object was not found in the background, but there may be a flaky test. Edit: |
aklinker1
left a comment
There was a problem hiding this comment.
OK, then let's remove the return value since remove and stop are doing the same thing.
|
@aklinker1 Alright, I've integrated |
aklinker1
left a comment
There was a problem hiding this comment.
Nice, thanks for adding all those tests too!
|
Hmmm background test is still failing. Why would the auto mount library be imported for that test? |
|
Hmm, I thought the cleanup was inadequate, but I guess not.
stderr | src/client/content-scripts/ui/__tests__/index.test.ts > Content Script UIs > mounted value > iframe > should set the mounted value based on the onMounted return value
DOMException [NotSupportedError]: Failed to fetch from "chrome-extension://test-extension-id/": URL scheme "chrome-extension" is not supported.
at Function.validateSchema (file:///Users/1natsu/ghq/github.com/wxt-dev/wxt/node_modules/.pnpm/[email protected]/node_modules/happy-dom/src/fetch/utilities/FetchRequestValidationUtility.ts:120:10)stdout | src/client/content-scripts/ui/__tests__/index.test.ts
[wxt] Content script "test" context invalidated
[wxt] Content script "test" context invalidated
[wxt] Content script "test" context invalidated
.
. |
|
Huh, if I look closely, it's a |
|
@aklinker1 I figured out that if I commented out the useAppConfig here, it would pass. but……Why is my library code flowing in here? 🤷 |
|
Ok, thanks for investigating. I'll check it out after work today |
|
I see, simple problem. @1natsu172 this is caused because in That said, this is WXT's fault, so I'll come up with a fix for it on my side. Just a compatibility recommendation. |
I see...thank you for the investigation.
I didn't expect it to be referenced outside of the browser environment, but you're right about cases like this one. I'll fix soon my library and publish it too. |
|
Okay, I added a commit updating upstream(my library). The test passes on my local. |
|
Awesome, I've got the WXT change working, but there's a bit more cleanup to do. But we can merge this PR! |
|
@aklinker1 @1natsu172 is it possible to add the element multiple times? If the anchor is present more the once then also the elements should be mounted to every element on the page. Is this possible? |
refer: #537
implementation
Basically the style of the existing implementation, the
ui.removemethod is internally split. Because what autoMount callback and what the user calls are different in behavior.testing
Tested for all built-in UIs.
The API spec makes it a floating-promise, so I'm hacking to get over the asynchronous processing. We must call
runMicrotasksafter every dom change and floating-promise process. Otherwise, only the vitest process would proceed and result in a false positive test.wxt-demo
Added new
automount.content. The gif I posted on Discord, with a delay in between for directional purposes.docs
It's pretty temporary, so feel free to fix it so that it's consistent with the other pages. The same is true for JSDoc, please correct any areas of concern.