vuex-webextensions icon indicating copy to clipboard operation
vuex-webextensions copied to clipboard

Vuex 4 support

Open NetCZ opened this issue 4 years ago • 7 comments

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.

NetCZ avatar May 29 '20 08:05 NetCZ

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

bbird1980 avatar Jul 16 '20 08:07 bbird1980

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

MitsuhaKitsune avatar Aug 04 '21 21:08 MitsuhaKitsune

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.

kinghat avatar Aug 04 '21 21:08 kinghat

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

bbird1980 avatar Aug 04 '21 21:08 bbird1980

@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.

MitsuhaKitsune avatar Aug 04 '21 21:08 MitsuhaKitsune

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

kinghat avatar Aug 04 '21 21:08 kinghat

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.

MitsuhaKitsune avatar Aug 05 '21 23:08 MitsuhaKitsune