Skip to content

Commit e8e5f28

Browse files
committed
feat: up vue-devtools
1 parent 0e9ffec commit e8e5f28

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

packages/pinia/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"vue2": "npm:vue@2"
7777
},
7878
"dependencies": {
79-
"@vue/devtools-api": "^6.0.13",
79+
"@vue/devtools-api": "^6.1.0",
8080
"vue-demi": "*"
8181
},
8282
"peerDependencies": {

packages/pinia/src/devtools/plugin.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export function registerPiniaDevtools(app: DevtoolsApp, pinia: Pinia) {
6363
app,
6464
},
6565
(api) => {
66+
if (typeof api.now !== 'function') {
67+
toastMessage(
68+
'You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.'
69+
)
70+
}
71+
6672
api.addTimelineLayer({
6773
id: MUTATIONS_LAYER_ID,
6874
label: `Pinia 🍍`,
@@ -289,13 +295,16 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) {
289295
},
290296
},
291297
(api) => {
298+
// gracefully handle errors
299+
const now = typeof api.now === 'function' ? api.now.bind(api) : Date.now
300+
292301
store.$onAction(({ after, onError, name, args }) => {
293302
const groupId = runningActionId++
294303

295304
api.addTimelineEvent({
296305
layerId: MUTATIONS_LAYER_ID,
297306
event: {
298-
time: api.now(),
307+
time: now(),
299308
title: '🛫 ' + name,
300309
subtitle: 'start',
301310
data: {
@@ -312,7 +321,7 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) {
312321
api.addTimelineEvent({
313322
layerId: MUTATIONS_LAYER_ID,
314323
event: {
315-
time: api.now(),
324+
time: now(),
316325
title: '🛬 ' + name,
317326
subtitle: 'end',
318327
data: {
@@ -331,7 +340,7 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) {
331340
api.addTimelineEvent({
332341
layerId: MUTATIONS_LAYER_ID,
333342
event: {
334-
time: api.now(),
343+
time: now(),
335344
logType: 'error',
336345
title: '💥 ' + name,
337346
subtitle: 'end',
@@ -357,7 +366,7 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) {
357366
api.addTimelineEvent({
358367
layerId: MUTATIONS_LAYER_ID,
359368
event: {
360-
time: api.now(),
369+
time: now(),
361370
title: 'Change',
362371
subtitle: name,
363372
data: {
@@ -382,7 +391,7 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) {
382391
// rootStore.state[store.id] = state
383392

384393
const eventData: TimelineEvent = {
385-
time: api.now(),
394+
time: now(),
386395
title: formatMutationType(type),
387396
data: {
388397
store: formatDisplay(store.$id),
@@ -427,7 +436,7 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) {
427436
api.addTimelineEvent({
428437
layerId: MUTATIONS_LAYER_ID,
429438
event: {
430-
time: api.now(),
439+
time: now(),
431440
title: '🔥 ' + store.$id,
432441
subtitle: 'HMR update',
433442
data: {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -2236,10 +2236,10 @@
22362236
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.21.1.tgz#f1410f53c42aa67fa3b01ca7bdba891f69d7bc97"
22372237
integrity sha512-FqC4s3pm35qGVeXRGOjTsRzlkJjrBLriDS9YXbflHLsfA9FrcKzIyWnLXoNm+/7930E8rRakXuAc2QkC50swAw==
22382238

2239-
"@vue/devtools-api@^6.0.13":
2240-
version "6.0.13"
2241-
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.13.tgz#33f8debe2d0239903b6fc8af10ace45ed3a4fab1"
2242-
integrity sha512-T34EjcArVqzANedEZe2kXQ+AZsld2z1ptJlkOGm87+blk+s6udnP4ze/NYqV8lz1o9AIivimN0xxteLlWiWQdg==
2239+
"@vue/devtools-api@^6.1.0":
2240+
version "6.1.1"
2241+
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.1.1.tgz#10fd2ca8d5b3cbcde4d6aec5c3fcc7113fa913d6"
2242+
integrity sha512-VeqwqAOtI42AWeiAIHaoigw+0Km8MVwzDwICgsX95hy6R4UaHnLtTdF0a5JFy4T5vacTeRnuWxZtQ0B/Cytq4g==
22432243

22442244
22452245
version "3.2.31"

0 commit comments

Comments
 (0)