MitsuhaKitsune / vuex-webextensions

A Vuex plugin to share store through webextensions components
MIT License
83 stars 30 forks source link

Vuex 4 support #32

Open NetCZ opened 4 years ago

NetCZ commented 4 years ago

Hi @MitsuhaKitsune, thanks for the great plugin.

I'm trying to make it work with new version of Vuex and I'm getting following error: Initial state not sent: DataCloneError: The object could not be cloned.

I believe problem lies in state object being wrapped with Proxy in new version, which cannot be handled by structured clone algorithm.

Problem is in initial @@STORE_SYNC_STATE message: https://github.com/MitsuhaKitsune/vuex-webextensions/blob/eccfedb94cfa28017b77745cb01db09d42653427/src/backgroundScript.js#L178

Quick workaround could be this.store._modules.root.state or JSON.parse(JSON.stringify(...)) as I haven't found any way how to get original object from Proxy.

bbird1980 commented 4 years ago

I haven't found any way how to get original object from Proxy.

https://stackoverflow.com/questions/51096547/how-to-get-the-target-of-a-javascript-proxy

MitsuhaKitsune commented 2 years ago

Didn't check vuex 4 for now, I'm still using vuex 3 on my projects, so I need time to test with v4.

kinghat commented 2 years ago

Didn't check vuex 4 for now, I'm still using vuex 3 on my projects, so I need time to test with v4.

vuex 5 and pinia are also right around the corner.

bbird1980 commented 2 years ago

Also manifest v3 is here and there is no background-pages, event-based worker only :(

MitsuhaKitsune commented 2 years ago

@kinhat Yes, I admit that I have been absent for a long time. My extension project has been closed for a year and I no longer use this plugin in any of my projects, but I really want to keep it for all of you because of the support it has received to date.

I will check both versions, both v4 and v5 and offer support for them as soon as possible as soon as I find the problem and manage to develop a solution.

@bbird1980 As I understand it, the background pages are replaced by workers, and they still have access to the browser APIs, so in principle, there should be no problem adapting the plugin to manifest v3.

kinghat commented 2 years ago

thanks for the update. i recently came across this and maybe it could be used to simplify part of the library or make it easier to bring up to date? https://github.com/antfu/webext-bridge

MitsuhaKitsune commented 2 years ago

Vuex 4 support (WIP) it's on new branch: https://github.com/MitsuhaKitsune/vuex-webextensions/tree/vuex-v4

When it's ready for production use I notice it here, probably I publish the compatible version with @next tag similar to vuex at this moment.