vite-plugin-devtools-vue2 0.1.2 → 0.1.3

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/lib/config.js CHANGED
@@ -1,22 +1,22 @@
1
1
  // config.js — shared tunables for the devtools panel.
2
2
 
3
3
  // localStorage key for persisted UI state (open/closed, tab, docked position).
4
- export const STORE_KEY = 'vue-devtools:ui';
4
+ export const StoreKey = 'vue-devtools:ui';
5
5
 
6
6
  // Panel size (keep in sync with .panel CSS) — used to keep it on-screen.
7
- export const PANEL_W = 620;
8
- export const PANEL_H = 420;
7
+ export const PanelW = 620;
8
+ export const PanelH = 420;
9
9
 
10
10
  // Margin between the floating entry and the viewport edge.
11
- export const EDGE_MARGIN = 12;
11
+ export const EdgeMargin = 12;
12
12
 
13
13
  // Distance from the viewport edge to the panel when open (leaves room for the
14
14
  // floating entry to sit in the gutter, matching the official devtools).
15
- export const PANEL_EDGE = EDGE_MARGIN + 30 / 2;
15
+ export const PanelEdge = EdgeMargin + 30 / 2;
16
16
 
17
17
  // Pointer travel (px) before a press on the entry counts as a drag vs a click.
18
- export const DRAG_THRESHOLD = 4;
18
+ export const DragThreshold = 4;
19
19
 
20
20
  // Show a per-section (props/data/computed/attrs…) filter input once a section
21
21
  // has more than this many keys.
22
- export const SECTION_FILTER_THRESHOLD = 10;
22
+ export const SectionFilterThreshold = 10;
package/lib/events.js CHANGED
@@ -12,26 +12,31 @@ const listeners = new Set();
12
12
  let patched = false;
13
13
  let seq = 0;
14
14
 
15
- const MAX_EVENTS = 200;
15
+ const MaxEvents = 200;
16
16
 
17
17
  const emit = () => {
18
- listeners.forEach(l => l());
18
+ listeners.forEach(item => item());
19
19
  };
20
20
 
21
21
  const componentName = vm => {
22
- const o = (vm && vm.$options) || {};
23
- let n = o.name || o._componentTag;
24
- if (!n && o.__file)
25
- n = String(o.__file)
22
+ const options = (vm && vm.$options) || {};
23
+ let name = options.name || options._componentTag;
24
+ if (!name && options.__file) {
25
+ name = String(options.__file)
26
26
  .split(/[\\/]/)
27
27
  .pop()
28
28
  .replace(/\.vue$/, '');
29
- if (!n && vm && vm.$root === vm) n = 'Root';
30
- return n || 'Anonymous';
29
+ }
30
+ if (!name && vm && vm.$root === vm) {
31
+ name = 'Root';
32
+ }
33
+ return name || 'Anonymous';
31
34
  };
32
35
 
33
36
  const record = (vm, name, args) => {
34
- if (typeof name === 'string' && name.indexOf('hook:') === 0) return; // lifecycle noise
37
+ if (typeof name === 'string' && name.indexOf('hook:') === 0) {
38
+ return; // lifecycle noise
39
+ }
35
40
  events.push({
36
41
  id: ++seq,
37
42
  name: String(name),
@@ -39,19 +44,23 @@ const record = (vm, name, args) => {
39
44
  component: componentName(vm),
40
45
  time: Date.now()
41
46
  });
42
- if (events.length > MAX_EVENTS) events.shift();
47
+ if (events.length > MaxEvents) {
48
+ events.shift();
49
+ }
43
50
  emit();
44
51
  };
45
52
 
46
53
  hook.on('init', Vue => {
47
- if (patched || !Vue || !Vue.prototype) return;
54
+ if (patched || !Vue || !Vue.prototype) {
55
+ return;
56
+ }
48
57
  patched = true;
49
58
  const original = Vue.prototype.$emit;
50
59
  // Must stay a real function: `this` is the emitting component instance.
51
60
  Vue.prototype.$emit = function (name, ...args) {
52
61
  try {
53
62
  record(this, name, args);
54
- } catch (e) {
63
+ } catch (err) {
55
64
  /* never break the app because of devtools */
56
65
  }
57
66
  return original.apply(this, arguments);
package/lib/hook.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // so we can capture the Vue constructor and subscribe to flushes for live
8
8
  // refresh. This module MUST be imported before the app imports Vue.
9
9
 
10
- const HOOK_KEY = '__VUE_DEVTOOLS_GLOBAL_HOOK__';
10
+ const HookKey = '__VUE_DEVTOOLS_GLOBAL_HOOK__';
11
11
 
12
12
  const createHook = () => {
13
13
  const listeners = Object.create(null);
@@ -19,19 +19,25 @@ const createHook = () => {
19
19
  },
20
20
  off(event, fn) {
21
21
  const arr = listeners[event];
22
- if (!arr) return;
23
- const i = arr.indexOf(fn);
24
- if (i > -1) arr.splice(i, 1);
22
+ if (!arr) {
23
+ return;
24
+ }
25
+ const index = arr.indexOf(fn);
26
+ if (index > -1) {
27
+ arr.splice(index, 1);
28
+ }
25
29
  },
26
30
  emit(event, ...args) {
27
31
  const arr = listeners[event];
28
- if (arr) arr.slice().forEach(fn => fn(...args));
32
+ if (arr) {
33
+ arr.slice().forEach(item => item(...args));
34
+ }
29
35
  }
30
36
  };
31
37
  };
32
38
 
33
39
  // Reuse an existing hook if one somehow already exists, otherwise install ours.
34
- const hook = window[HOOK_KEY] || (window[HOOK_KEY] = createHook());
40
+ const hook = window[HookKey] || (window[HookKey] = createHook());
35
41
 
36
42
  // Capture the Vue constructor as soon as Vue registers itself.
37
43
  hook.on('init', Vue => {
package/lib/inspector.js CHANGED
@@ -3,7 +3,9 @@
3
3
  let box = null;
4
4
 
5
5
  const ensureBox = () => {
6
- if (box) return box;
6
+ if (box) {
7
+ return box;
8
+ }
7
9
  box = document.createElement('div');
8
10
  Object.assign(box.style, {
9
11
  position: 'fixed',
@@ -21,10 +23,12 @@ const ensureBox = () => {
21
23
 
22
24
  export const highlight = vm => {
23
25
  const el = vm && vm.$el;
24
- if (!el || !el.getBoundingClientRect) return hide();
26
+ if (!el || !el.getBoundingClientRect) {
27
+ return hide();
28
+ }
25
29
  const rect = el.getBoundingClientRect();
26
- const b = ensureBox();
27
- Object.assign(b.style, {
30
+ const boxEl = ensureBox();
31
+ Object.assign(boxEl.style, {
28
32
  display: 'block',
29
33
  top: `${rect.top}px`,
30
34
  left: `${rect.left}px`,
@@ -34,5 +38,7 @@ export const highlight = vm => {
34
38
  };
35
39
 
36
40
  export const hide = () => {
37
- if (box) box.style.display = 'none';
41
+ if (box) {
42
+ box.style.display = 'none';
43
+ }
38
44
  };
package/lib/main.js CHANGED
@@ -8,7 +8,9 @@ import './vuex.js';
8
8
  import './events.js';
9
9
 
10
10
  const mount = () => {
11
- if (document.querySelector('#__vue_devtools__')) return;
11
+ if (document.querySelector('#__vue_devtools__')) {
12
+ return;
13
+ }
12
14
  const host = document.createElement('div');
13
15
  host.id = '__vue_devtools__';
14
16
  document.body.appendChild(host);