From: Eduardo San Martin Morote Date: Tue, 23 Mar 2021 10:45:28 +0000 (+0100) Subject: fix(devtools): time travel and state display X-Git-Tag: v0.2.1~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=043ae2ac229b55087d962432b7501483403742e2;p=thirdparty%2Fvuejs%2Fpinia.git fix(devtools): time travel and state display Fix #394 Fix #19 --- diff --git a/src/devtools.ts b/src/devtools.ts index 6e41b9ba..e1dacb38 100644 --- a/src/devtools.ts +++ b/src/devtools.ts @@ -1,6 +1,4 @@ -import { Pinia } from './rootStore' import { DevtoolHook, StateTree, StoreWithState } from './types' -import { assign } from './utils' const target = typeof window !== 'undefined' @@ -65,7 +63,10 @@ export function useStoreDevtools( // tell the devtools we added a module rootStore.registerModule(store.$id, store) - Object.defineProperty(rootStore.state, store.$id, stateDescriptor) + Object.defineProperty(rootStore.state, store.$id, { + enumerable: true, + ...stateDescriptor, + }) // Vue.set(rootStore.state, store.name, store.state) // the trailing slash is removed by the devtools @@ -77,9 +78,14 @@ export function useStoreDevtools( store.$subscribe((mutation, state) => { rootStore.state[store.$id] = state - devtoolHook.emit('vuex:mutation', { - type: `[${mutation.storeName}] ${mutation.type}`, - payload: mutation.payload, - }) + devtoolHook.emit( + 'vuex:mutation', + { + type: `[${mutation.storeName}] ${mutation.type}`, + payload: mutation.payload, + }, + // this doesn't seem to be used by the devtools but it's in vuex codebase + rootStore.state + ) }) }