-import { createApp } from 'vue'
+import { computed, createApp, markRaw } from 'vue'
import App from './App.vue'
import { createPinia } from '../../src'
import { router } from './router'
const pinia = createPinia()
+pinia.use(() => ({
+ route: computed(() => markRaw(router.currentRoute.value)),
+}))
+
if (import.meta.hot) {
// const isUseStore = (fn: any): fn is StoreDefinition => {
// return typeof fn === 'function' && typeof fn.$id === 'string'
import { setupDevtoolsPlugin, TimelineEvent } from '@vue/devtools-api'
-import { App, ComponentPublicInstance, markRaw, toRaw } from 'vue'
+import {
+ App,
+ ComponentPublicInstance,
+ isReactive,
+ isRef,
+ markRaw,
+ toRaw,
+ unref,
+ watch,
+} from 'vue'
import { Pinia, PiniaPluginContext } from '../rootStore'
import {
GettersTree,
})
}, true)
- store.$subscribe(({ events, type }, state) => {
- if (!isTimelineActive) return
- // rootStore.state[store.id] = state
+ store._customProperties.forEach((name) => {
+ watch(
+ () => unref(store[name]),
+ (newValue, oldValue) => {
+ api.notifyComponentUpdate()
+ api.sendInspectorState(INSPECTOR_ID)
+ if (isTimelineActive) {
+ api.addTimelineEvent({
+ layerId: MUTATIONS_LAYER_ID,
+ event: {
+ time: Date.now(),
+ title: 'Change',
+ subtitle: name,
+ data: {
+ newValue,
+ oldValue,
+ },
+ groupId: activeAction,
+ },
+ })
+ }
+ },
+ { deep: true }
+ )
+ })
+ store.$subscribe(({ events, type }, state) => {
api.notifyComponentUpdate()
api.sendInspectorState(INSPECTOR_ID)
+ if (!isTimelineActive) return
+ // rootStore.state[store.id] = state
+
const eventData: TimelineEvent = {
time: Date.now(),
title: formatMutationType(type),