vite-plugin-devtools-vue2 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/lib/config.js +5 -0
- package/lib/panel.js +62 -11
- package/package.json +9 -1
package/README.md
CHANGED
package/lib/config.js
CHANGED
|
@@ -20,3 +20,8 @@ export const DragThreshold = 4;
|
|
|
20
20
|
// Show a per-section (props/data/computed/attrs…) filter input once a section
|
|
21
21
|
// has more than this many keys.
|
|
22
22
|
export const SectionFilterThreshold = 10;
|
|
23
|
+
|
|
24
|
+
// When collapsed, tuck the entry toward the edge after this idle time (ms)…
|
|
25
|
+
export const IdleTuckDelay = 3000;
|
|
26
|
+
// …by shrinking its edge margin to this (negative = peek partly off-screen).
|
|
27
|
+
export const IdleTuckMargin = -12;
|
package/lib/panel.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// on every Vue scheduler flush.
|
|
4
4
|
|
|
5
5
|
import { LitElement, css, html } from 'lit';
|
|
6
|
-
import { DragThreshold, EdgeMargin, PanelEdge, PanelH, PanelW, SectionFilterThreshold, StoreKey } from './config.js';
|
|
6
|
+
import { DragThreshold, EdgeMargin, IdleTuckDelay, IdleTuckMargin, PanelEdge, PanelH, PanelW, SectionFilterThreshold, StoreKey } from './config.js';
|
|
7
|
+
import { clearEvents, subscribe as eventsSubscribe, getEvents } from './events.js';
|
|
7
8
|
import hook from './hook.js';
|
|
8
9
|
import { hide, highlight } from './inspector.js';
|
|
9
10
|
import { isPicking, startPicking, stopPicking } from './picker.js';
|
|
10
11
|
import { commitAll, getSnapshots, getStore, hasStore, travelTo, subscribe as vuexSubscribe } from './vuex.js';
|
|
11
|
-
import { clearEvents, getEvents, subscribe as eventsSubscribe } from './events.js';
|
|
12
12
|
import { buildTree, formatValue, getInstance } from './walker.js';
|
|
13
13
|
|
|
14
14
|
export class VueDevToolsPanel extends LitElement {
|
|
@@ -51,6 +51,9 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
51
51
|
// the right; { edge: 'left'|'right'|'top'|'bottom', along: number }.
|
|
52
52
|
this._pos = ui.pos || { edge: 'bottom', along: Number.POSITIVE_INFINITY };
|
|
53
53
|
this._drag = null;
|
|
54
|
+
// When collapsed + idle, the entry tucks toward the edge (see IdleTuck*).
|
|
55
|
+
this._idleTucked = false;
|
|
56
|
+
this._idleTimer = 0;
|
|
54
57
|
this._editingPath = null;
|
|
55
58
|
this._focusEdit = false;
|
|
56
59
|
this._flushTimer = null;
|
|
@@ -122,12 +125,15 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
122
125
|
const alongY = clamp(pos.along, vh - eh - margin);
|
|
123
126
|
|
|
124
127
|
const es = entry.style;
|
|
128
|
+
// When collapsed and idle, tuck the entry toward the edge (smaller /
|
|
129
|
+
// negative margin) so it peeks; hovering/interacting restores it.
|
|
130
|
+
const dockMargin = this.collapsed && this._idleTucked ? IdleTuckMargin : EdgeMargin;
|
|
125
131
|
es.insetInlineStart = es.insetBlockStart = es.insetInlineEnd = es.insetBlockEnd = 'auto';
|
|
126
132
|
if (pos.edge === 'right' || pos.edge === 'left') {
|
|
127
|
-
es['inset' + (pos.edge === 'right' ? 'InlineEnd' : 'InlineStart')] =
|
|
133
|
+
es['inset' + (pos.edge === 'right' ? 'InlineEnd' : 'InlineStart')] = dockMargin + 'px';
|
|
128
134
|
es.insetBlockStart = alongY + 'px';
|
|
129
135
|
} else {
|
|
130
|
-
es['inset' + (pos.edge === 'bottom' ? 'BlockEnd' : 'BlockStart')] =
|
|
136
|
+
es['inset' + (pos.edge === 'bottom' ? 'BlockEnd' : 'BlockStart')] = dockMargin + 'px';
|
|
131
137
|
es.insetInlineStart = alongX + 'px';
|
|
132
138
|
}
|
|
133
139
|
this.setAttribute('dock', pos.edge);
|
|
@@ -164,6 +170,7 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
164
170
|
}
|
|
165
171
|
event.preventDefault();
|
|
166
172
|
hide(); // clear any hover highlight before dragging
|
|
173
|
+
this._wakeEntry();
|
|
167
174
|
const entry = this.renderRoot.querySelector('.entry');
|
|
168
175
|
const rect = entry.getBoundingClientRect();
|
|
169
176
|
this._drag = {
|
|
@@ -222,6 +229,28 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
222
229
|
}
|
|
223
230
|
// Position was already decided live in _dragMove; just remember it.
|
|
224
231
|
this._persistUiState();
|
|
232
|
+
this._scheduleIdleTuck();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Idle-tuck: when collapsed with no interaction, the entry slides toward the
|
|
236
|
+
// edge; hovering/dragging/opening wakes it back to the normal margin.
|
|
237
|
+
_scheduleIdleTuck() {
|
|
238
|
+
clearTimeout(this._idleTimer);
|
|
239
|
+
if (!this.collapsed) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
this._idleTimer = setTimeout(() => {
|
|
243
|
+
this._idleTucked = true;
|
|
244
|
+
this._applyPos();
|
|
245
|
+
}, IdleTuckDelay);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_wakeEntry() {
|
|
249
|
+
clearTimeout(this._idleTimer);
|
|
250
|
+
if (this._idleTucked) {
|
|
251
|
+
this._idleTucked = false;
|
|
252
|
+
this._applyPos();
|
|
253
|
+
}
|
|
225
254
|
}
|
|
226
255
|
|
|
227
256
|
connectedCallback() {
|
|
@@ -246,6 +275,7 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
246
275
|
hook.off('flush', this._onFlush);
|
|
247
276
|
window.removeEventListener('keydown', this._onKeydown, true);
|
|
248
277
|
window.removeEventListener('resize', this._onResize);
|
|
278
|
+
clearTimeout(this._idleTimer);
|
|
249
279
|
if (this._resizeRaf) {
|
|
250
280
|
cancelAnimationFrame(this._resizeRaf);
|
|
251
281
|
this._resizeRaf = 0;
|
|
@@ -266,6 +296,7 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
266
296
|
firstUpdated() {
|
|
267
297
|
this._applyPos();
|
|
268
298
|
this.setAttribute('theme', this.theme);
|
|
299
|
+
this._scheduleIdleTuck();
|
|
269
300
|
}
|
|
270
301
|
|
|
271
302
|
_toggleTheme() {
|
|
@@ -535,6 +566,12 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
535
566
|
// Re-clamp the docked position when switching fab <-> panel (sizes differ).
|
|
536
567
|
if (changed && changed.has('collapsed')) {
|
|
537
568
|
this._applyPos();
|
|
569
|
+
// Opening wakes the entry; collapsing restarts the idle-tuck timer.
|
|
570
|
+
if (this.collapsed) {
|
|
571
|
+
this._scheduleIdleTuck();
|
|
572
|
+
} else {
|
|
573
|
+
this._wakeEntry();
|
|
574
|
+
}
|
|
538
575
|
}
|
|
539
576
|
// Focus a freshly opened inline editor.
|
|
540
577
|
if (this._focusEdit) {
|
|
@@ -1002,7 +1039,12 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
1002
1039
|
|
|
1003
1040
|
render() {
|
|
1004
1041
|
return html`
|
|
1005
|
-
<div
|
|
1042
|
+
<div
|
|
1043
|
+
class="entry"
|
|
1044
|
+
@pointerdown=${event => this._onFabPointerDown(event)}
|
|
1045
|
+
@pointerenter=${() => this._wakeEntry()}
|
|
1046
|
+
@pointerleave=${() => this._scheduleIdleTuck()}
|
|
1047
|
+
>
|
|
1006
1048
|
<span class="fab-icon">${this._vueLogo()}</span>
|
|
1007
1049
|
</div>
|
|
1008
1050
|
${this.collapsed ? null : this._renderPanel()}
|
|
@@ -1013,7 +1055,6 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
1013
1055
|
return html`
|
|
1014
1056
|
<div class="panel">
|
|
1015
1057
|
<nav class="sidebar">
|
|
1016
|
-
<div class="logo">${this._vueLogo()}</div>
|
|
1017
1058
|
<button class="side-tab ${this.tab === 'components' ? 'active' : ''}" @click=${() => (this.tab = 'components')}>
|
|
1018
1059
|
${this._icon('components')}
|
|
1019
1060
|
<span class="tip">Components</span>
|
|
@@ -1234,8 +1275,7 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
1234
1275
|
return html`
|
|
1235
1276
|
<button class="btn on time-travel" @click=${() => travelTo(entry.index)}>⏱ Time Travel</button>
|
|
1236
1277
|
${this._renderKvSection('mutation', { type: snap.type, time: new Date(snap.time).toLocaleTimeString() }, false)}
|
|
1237
|
-
${payloadObj ? this._renderKvSection('payload', payloadObj, false) : null}
|
|
1238
|
-
${this._renderKvSection('state', snap.state || {}, false)}
|
|
1278
|
+
${payloadObj ? this._renderKvSection('payload', payloadObj, false) : null} ${this._renderKvSection('state', snap.state || {}, false)}
|
|
1239
1279
|
${store ? this._renderKvSection('getters (live)', store.getters || {}, false) : null}
|
|
1240
1280
|
`;
|
|
1241
1281
|
}
|
|
@@ -1246,12 +1286,13 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
1246
1286
|
return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}`;
|
|
1247
1287
|
}
|
|
1248
1288
|
|
|
1249
|
-
// Plugin logo
|
|
1289
|
+
// Plugin logo (Vite mark).
|
|
1250
1290
|
_vueLogo() {
|
|
1251
1291
|
return html`
|
|
1252
|
-
<svg
|
|
1292
|
+
<svg class="vlogo" viewBox="0 0 48 46" fill="none" aria-hidden="true">
|
|
1253
1293
|
<path
|
|
1254
|
-
d="
|
|
1294
|
+
d="M25.9456 44.9383C25.2821 45.7827 23.925 45.3131 23.925 44.2403V33.9369C23.925 32.6875 22.9126 31.6751 21.6631 31.6751H10.287C9.36714 31.6751 8.83075 30.6346 9.36713 29.8871L16.8464 19.4157C17.917 17.9185 16.8464 15.8376 15.0046 15.8376H1.23731C0.317479 15.8376 -0.218913 14.7972 0.317475 14.0497L10.0134 0.4741C10.2266 0.176825 10.5692 0.000183105 10.9332 0.000183105H39.8271C40.7469 0.000183105 41.2833 1.04065 40.7469 1.78814L33.2676 12.2595C32.197 13.7567 33.2676 15.8376 35.1094 15.8376H46.4856C47.4291 15.8376 47.959 16.9255 47.3753 17.6687L25.9478 44.9404L25.9456 44.9383Z"
|
|
1295
|
+
fill="#863BFF"
|
|
1255
1296
|
/>
|
|
1256
1297
|
</svg>
|
|
1257
1298
|
`;
|
|
@@ -1422,6 +1463,11 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
1422
1463
|
background: var(--bg);
|
|
1423
1464
|
border: 1px solid var(--border-strong);
|
|
1424
1465
|
box-shadow: 0 6px 20px rgb(16 24 40 / 0.18);
|
|
1466
|
+
transition:
|
|
1467
|
+
inset-block-start 0.2s ease,
|
|
1468
|
+
inset-block-end 0.2s ease,
|
|
1469
|
+
inset-inline-start 0.2s ease,
|
|
1470
|
+
inset-inline-end 0.2s ease;
|
|
1425
1471
|
}
|
|
1426
1472
|
.entry:active {
|
|
1427
1473
|
cursor: grabbing;
|
|
@@ -1436,6 +1482,11 @@ export class VueDevToolsPanel extends LitElement {
|
|
|
1436
1482
|
inline-size: 16px;
|
|
1437
1483
|
block-size: 16px;
|
|
1438
1484
|
}
|
|
1485
|
+
.fab-icon .vlogo {
|
|
1486
|
+
inline-size: 18px;
|
|
1487
|
+
block-size: 18px;
|
|
1488
|
+
display: block;
|
|
1489
|
+
}
|
|
1439
1490
|
/* On the left/right edges, stack the entry's icons vertically. */
|
|
1440
1491
|
:host([dock='left']) .entry,
|
|
1441
1492
|
:host([dock='right']) .entry {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-devtools-vue2",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "vite-plugin-vue-devtools for vue@2.x",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
"inspector"
|
|
19
19
|
],
|
|
20
20
|
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/shuoshubao/vite-plugin-vue2-devtools.git"
|
|
24
|
+
},
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "shuoshuobao",
|
|
27
|
+
"email": "shuoshuobao@gmail.com"
|
|
28
|
+
},
|
|
21
29
|
"dependencies": {
|
|
22
30
|
"lit": "^3.1.4"
|
|
23
31
|
}
|