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

Feature/window-link #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

janek26
Copy link

@janek26 janek26 commented Mar 29, 2023

Hey! Nice project, it's quite helpful especially combined with plasmo

Plasmo has the concept of "injecting into the main world" or how I like to call it "inpage scripts", which allow the extension to access the global objects used by a webpage, and escapes from the isolation content scripts usually run in.
https://docs.plasmo.com/framework/content-scripts#injecting-into-the-main-world

I added a link called windowLink and a relayer called relay to the package. Heavily inspired by how @plasmohq/messaging works.

In the process I found a bug with your chromeLink implementation for subscriptions, where the stop message would not be send (unsub before sending). Fixed that in the process, and covered that case with tests.

@jqphu
Copy link

jqphu commented Apr 7, 2023

This is awesome! I'd love to try using this :)

@janek26
Copy link
Author

janek26 commented Apr 7, 2023

@jqphu I’m using it myself, it works great!

@jlalmes promised me to have a look at the PR as soon as he can find some time 🙂
Happy eastern 🥚🐰

@blueagler
Copy link

wtf thats fantastic

import { relay } from 'trpc-chrome/relay';

const port = chrome.runtime.connect();
relay(port, window);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janek26 how do you use this relay?
Could you add like 2-3 line example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants