@vue/devtools-kit 7.0.8 → 7.0.10

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/dist/index.cjs CHANGED
@@ -1746,18 +1746,39 @@ function normalizeRouterInfo(appRecord) {
1746
1746
  const routesMap = /* @__PURE__ */ new Map();
1747
1747
  return ((router == null ? void 0 : router.getRoutes()) || []).filter((i) => !routesMap.has(i.path) && routesMap.set(i.path, 1));
1748
1748
  };
1749
- function init() {
1750
- var _a8;
1751
- const router = (_a8 = appRecord.app) == null ? void 0 : _a8.config.globalProperties.$router;
1752
- const currentRoute = router == null ? void 0 : router.currentRoute.value;
1753
- const routes = getRoutes(router).map((item) => {
1754
- const { path, name, children } = item;
1749
+ function filterRoutes(routes) {
1750
+ return routes.map((item) => {
1751
+ let { path, name, children } = item;
1752
+ if (children == null ? void 0 : children.length)
1753
+ children = filterRoutes(children);
1755
1754
  return {
1756
1755
  path,
1757
1756
  name,
1758
1757
  children
1759
1758
  };
1760
1759
  });
1760
+ }
1761
+ function filterCurrentRoute(route) {
1762
+ if (route) {
1763
+ const { fullPath, hash, href, path, name, matched, params, query } = route;
1764
+ return {
1765
+ fullPath,
1766
+ hash,
1767
+ href,
1768
+ path,
1769
+ name,
1770
+ params,
1771
+ query,
1772
+ matched: filterRoutes(matched)
1773
+ };
1774
+ }
1775
+ return route;
1776
+ }
1777
+ function init() {
1778
+ var _a8;
1779
+ const router = (_a8 = appRecord.app) == null ? void 0 : _a8.config.globalProperties.$router;
1780
+ const currentRoute = filterCurrentRoute(router == null ? void 0 : router.currentRoute.value);
1781
+ const routes = filterRoutes(getRoutes(router));
1761
1782
  const c = console.warn;
1762
1783
  console.warn = () => {
1763
1784
  };
@@ -2070,7 +2091,8 @@ function formatInspectorStateValue(value, quotes = false) {
2070
2091
  if (result = internalStateTokenToString(value)) {
2071
2092
  return result;
2072
2093
  } else if (type === "custom") {
2073
- return (_a8 = value._custom.displayText) != null ? _a8 : value._custom.display;
2094
+ const nestedName = ((_a8 = value._custom.value) == null ? void 0 : _a8._custom) && formatInspectorStateValue(value._custom.value);
2095
+ return nestedName || value._custom.displayText || value._custom.display;
2074
2096
  } else if (type === "array") {
2075
2097
  return `Array[${value.length}]`;
2076
2098
  } else if (type === "plain-object") {
@@ -2090,13 +2112,14 @@ function formatInspectorStateValue(value, quotes = false) {
2090
2112
  return value;
2091
2113
  }
2092
2114
  function getRawValue(value) {
2093
- var _a8, _b8;
2115
+ var _a8, _b8, _c, _d;
2094
2116
  const isCustom = getInspectorStateValueType(value) === "custom";
2095
2117
  let inherit = {};
2096
2118
  if (isCustom) {
2097
2119
  const data = value;
2098
- inherit = ((_a8 = data._custom) == null ? void 0 : _a8.fields) || {};
2099
- value = (_b8 = data._custom) == null ? void 0 : _b8.value;
2120
+ const nestedCustom = typeof ((_a8 = data._custom) == null ? void 0 : _a8.value) === "object" && "_custom" in data._custom.value ? getRawValue((_b8 = data._custom) == null ? void 0 : _b8.value) : { inherit: void 0, value: void 0 };
2121
+ inherit = nestedCustom.inherit || ((_c = data._custom) == null ? void 0 : _c.fields) || {};
2122
+ value = nestedCustom.value || ((_d = data._custom) == null ? void 0 : _d.value);
2100
2123
  }
2101
2124
  if (value && value._isArray)
2102
2125
  value = value.items;
@@ -3102,7 +3125,8 @@ async function registerPlugin(options) {
3102
3125
  ...record,
3103
3126
  moduleDetectives: {
3104
3127
  vueRouter: !!globalProperties.$router,
3105
- pinia: !!globalProperties.$pinia
3128
+ pinia: !!globalProperties.$pinia,
3129
+ vueI18n: !!globalProperties.$i18n
3106
3130
  }
3107
3131
  };
3108
3132
  });
@@ -3856,6 +3880,17 @@ function toggleComponentInspector(options) {
3856
3880
  el.style.display = "none";
3857
3881
  }
3858
3882
  }
3883
+ function highlight(instance) {
3884
+ const bounds = getComponentBoundingRect(instance);
3885
+ const name = getInstanceName(instance);
3886
+ const container = getCotainerElement();
3887
+ container ? update({ bounds, name }) : create({ bounds, name });
3888
+ }
3889
+ function unhighlight() {
3890
+ const el = getCotainerElement();
3891
+ if (el)
3892
+ el.style.display = "none";
3893
+ }
3859
3894
  var inspectInstance = null;
3860
3895
  function inspectFn(e) {
3861
3896
  const target8 = e.target;
@@ -4080,6 +4115,18 @@ var DevToolsPluginApi = class {
4080
4115
  openInEditor(payload) {
4081
4116
  openInEditor(payload);
4082
4117
  }
4118
+ highlightElement(instance) {
4119
+ highlight(instance);
4120
+ }
4121
+ unhighlightElement() {
4122
+ unhighlight();
4123
+ }
4124
+ async getComponentInstances(app) {
4125
+ const appRecord = app.__VUE_DEVTOOLS_APP_RECORD__;
4126
+ const appId = appRecord.id.toString();
4127
+ const instances = [...appRecord.instanceMap].filter(([key]) => key.split(":")[0] === appId).map(([, instance]) => instance);
4128
+ return instances;
4129
+ }
4083
4130
  // Vite only
4084
4131
  getVueInspector() {
4085
4132
  return getVueInspector();
package/dist/index.d.cts CHANGED
@@ -42,7 +42,7 @@ interface InspectorCustomState {
42
42
  type?: string;
43
43
  displayText?: string;
44
44
  tooltipText?: string;
45
- value?: string;
45
+ value?: string | InspectorCustomState;
46
46
  stateTypeName?: string;
47
47
  fields?: {
48
48
  abstract?: boolean;
@@ -51,7 +51,7 @@ interface InspectorCustomState {
51
51
  }
52
52
  interface InspectorState {
53
53
  key: string;
54
- value: string | number | Record<string, unknown> | InspectorCustomState | Array<unknown>;
54
+ value: string | number | boolean | null | Record<string, unknown> | InspectorCustomState | Array<unknown>;
55
55
  type: string;
56
56
  stateType?: string;
57
57
  stateTypeName?: string;
@@ -355,6 +355,9 @@ declare class DevToolsPluginApi {
355
355
  removeCustomCommand(actionId: CustomCommand['id']): void;
356
356
  addInspector(payload: AddInspectorApiPayload): void;
357
357
  openInEditor(payload: OpenInEditorOptions): void;
358
+ highlightElement(instance: any): void;
359
+ unhighlightElement(): void;
360
+ getComponentInstances(app: any): Promise<any[]>;
358
361
  getVueInspector(): Promise<VueInspector>;
359
362
  visitComponentTree(payload: Parameters<DevToolsEvent[DevToolsEvents.VISIT_COMPONENT_TREE]>[0]): void;
360
363
  addTimelineLayer(payload: {
@@ -377,10 +380,7 @@ declare function addCustomTab(tab: CustomTab): void;
377
380
 
378
381
  declare function getInspectorStateValueType(value: any, raw?: boolean): string;
379
382
  declare function formatInspectorStateValue(value: any, quotes?: boolean): any;
380
- declare function getRawValue(value: InspectorState['value']): {
381
- value: string | number | Record<string, unknown> | unknown[] | InspectorCustomState;
382
- inherit: {};
383
- };
383
+ declare function getRawValue(value: InspectorState['value']): any;
384
384
 
385
385
  declare function stringify<T extends object = Record<string, unknown>>(data: T): string | string[];
386
386
  declare function parse(data: string, revive?: boolean): any;
package/dist/index.d.ts CHANGED
@@ -42,7 +42,7 @@ interface InspectorCustomState {
42
42
  type?: string;
43
43
  displayText?: string;
44
44
  tooltipText?: string;
45
- value?: string;
45
+ value?: string | InspectorCustomState;
46
46
  stateTypeName?: string;
47
47
  fields?: {
48
48
  abstract?: boolean;
@@ -51,7 +51,7 @@ interface InspectorCustomState {
51
51
  }
52
52
  interface InspectorState {
53
53
  key: string;
54
- value: string | number | Record<string, unknown> | InspectorCustomState | Array<unknown>;
54
+ value: string | number | boolean | null | Record<string, unknown> | InspectorCustomState | Array<unknown>;
55
55
  type: string;
56
56
  stateType?: string;
57
57
  stateTypeName?: string;
@@ -355,6 +355,9 @@ declare class DevToolsPluginApi {
355
355
  removeCustomCommand(actionId: CustomCommand['id']): void;
356
356
  addInspector(payload: AddInspectorApiPayload): void;
357
357
  openInEditor(payload: OpenInEditorOptions): void;
358
+ highlightElement(instance: any): void;
359
+ unhighlightElement(): void;
360
+ getComponentInstances(app: any): Promise<any[]>;
358
361
  getVueInspector(): Promise<VueInspector>;
359
362
  visitComponentTree(payload: Parameters<DevToolsEvent[DevToolsEvents.VISIT_COMPONENT_TREE]>[0]): void;
360
363
  addTimelineLayer(payload: {
@@ -377,10 +380,7 @@ declare function addCustomTab(tab: CustomTab): void;
377
380
 
378
381
  declare function getInspectorStateValueType(value: any, raw?: boolean): string;
379
382
  declare function formatInspectorStateValue(value: any, quotes?: boolean): any;
380
- declare function getRawValue(value: InspectorState['value']): {
381
- value: string | number | Record<string, unknown> | unknown[] | InspectorCustomState;
382
- inherit: {};
383
- };
383
+ declare function getRawValue(value: InspectorState['value']): any;
384
384
 
385
385
  declare function stringify<T extends object = Record<string, unknown>>(data: T): string | string[];
386
386
  declare function parse(data: string, revive?: boolean): any;
package/dist/index.mjs CHANGED
@@ -1711,18 +1711,39 @@ function normalizeRouterInfo(appRecord) {
1711
1711
  const routesMap = /* @__PURE__ */ new Map();
1712
1712
  return ((router == null ? void 0 : router.getRoutes()) || []).filter((i) => !routesMap.has(i.path) && routesMap.set(i.path, 1));
1713
1713
  };
1714
- function init() {
1715
- var _a8;
1716
- const router = (_a8 = appRecord.app) == null ? void 0 : _a8.config.globalProperties.$router;
1717
- const currentRoute = router == null ? void 0 : router.currentRoute.value;
1718
- const routes = getRoutes(router).map((item) => {
1719
- const { path, name, children } = item;
1714
+ function filterRoutes(routes) {
1715
+ return routes.map((item) => {
1716
+ let { path, name, children } = item;
1717
+ if (children == null ? void 0 : children.length)
1718
+ children = filterRoutes(children);
1720
1719
  return {
1721
1720
  path,
1722
1721
  name,
1723
1722
  children
1724
1723
  };
1725
1724
  });
1725
+ }
1726
+ function filterCurrentRoute(route) {
1727
+ if (route) {
1728
+ const { fullPath, hash, href, path, name, matched, params, query } = route;
1729
+ return {
1730
+ fullPath,
1731
+ hash,
1732
+ href,
1733
+ path,
1734
+ name,
1735
+ params,
1736
+ query,
1737
+ matched: filterRoutes(matched)
1738
+ };
1739
+ }
1740
+ return route;
1741
+ }
1742
+ function init() {
1743
+ var _a8;
1744
+ const router = (_a8 = appRecord.app) == null ? void 0 : _a8.config.globalProperties.$router;
1745
+ const currentRoute = filterCurrentRoute(router == null ? void 0 : router.currentRoute.value);
1746
+ const routes = filterRoutes(getRoutes(router));
1726
1747
  const c = console.warn;
1727
1748
  console.warn = () => {
1728
1749
  };
@@ -2035,7 +2056,8 @@ function formatInspectorStateValue(value, quotes = false) {
2035
2056
  if (result = internalStateTokenToString(value)) {
2036
2057
  return result;
2037
2058
  } else if (type === "custom") {
2038
- return (_a8 = value._custom.displayText) != null ? _a8 : value._custom.display;
2059
+ const nestedName = ((_a8 = value._custom.value) == null ? void 0 : _a8._custom) && formatInspectorStateValue(value._custom.value);
2060
+ return nestedName || value._custom.displayText || value._custom.display;
2039
2061
  } else if (type === "array") {
2040
2062
  return `Array[${value.length}]`;
2041
2063
  } else if (type === "plain-object") {
@@ -2055,13 +2077,14 @@ function formatInspectorStateValue(value, quotes = false) {
2055
2077
  return value;
2056
2078
  }
2057
2079
  function getRawValue(value) {
2058
- var _a8, _b8;
2080
+ var _a8, _b8, _c, _d;
2059
2081
  const isCustom = getInspectorStateValueType(value) === "custom";
2060
2082
  let inherit = {};
2061
2083
  if (isCustom) {
2062
2084
  const data = value;
2063
- inherit = ((_a8 = data._custom) == null ? void 0 : _a8.fields) || {};
2064
- value = (_b8 = data._custom) == null ? void 0 : _b8.value;
2085
+ const nestedCustom = typeof ((_a8 = data._custom) == null ? void 0 : _a8.value) === "object" && "_custom" in data._custom.value ? getRawValue((_b8 = data._custom) == null ? void 0 : _b8.value) : { inherit: void 0, value: void 0 };
2086
+ inherit = nestedCustom.inherit || ((_c = data._custom) == null ? void 0 : _c.fields) || {};
2087
+ value = nestedCustom.value || ((_d = data._custom) == null ? void 0 : _d.value);
2065
2088
  }
2066
2089
  if (value && value._isArray)
2067
2090
  value = value.items;
@@ -3067,7 +3090,8 @@ async function registerPlugin(options) {
3067
3090
  ...record,
3068
3091
  moduleDetectives: {
3069
3092
  vueRouter: !!globalProperties.$router,
3070
- pinia: !!globalProperties.$pinia
3093
+ pinia: !!globalProperties.$pinia,
3094
+ vueI18n: !!globalProperties.$i18n
3071
3095
  }
3072
3096
  };
3073
3097
  });
@@ -3821,6 +3845,17 @@ function toggleComponentInspector(options) {
3821
3845
  el.style.display = "none";
3822
3846
  }
3823
3847
  }
3848
+ function highlight(instance) {
3849
+ const bounds = getComponentBoundingRect(instance);
3850
+ const name = getInstanceName(instance);
3851
+ const container = getCotainerElement();
3852
+ container ? update({ bounds, name }) : create({ bounds, name });
3853
+ }
3854
+ function unhighlight() {
3855
+ const el = getCotainerElement();
3856
+ if (el)
3857
+ el.style.display = "none";
3858
+ }
3824
3859
  var inspectInstance = null;
3825
3860
  function inspectFn(e) {
3826
3861
  const target8 = e.target;
@@ -4045,6 +4080,18 @@ var DevToolsPluginApi = class {
4045
4080
  openInEditor(payload) {
4046
4081
  openInEditor(payload);
4047
4082
  }
4083
+ highlightElement(instance) {
4084
+ highlight(instance);
4085
+ }
4086
+ unhighlightElement() {
4087
+ unhighlight();
4088
+ }
4089
+ async getComponentInstances(app) {
4090
+ const appRecord = app.__VUE_DEVTOOLS_APP_RECORD__;
4091
+ const appId = appRecord.id.toString();
4092
+ const instances = [...appRecord.instanceMap].filter(([key]) => key.split(":")[0] === appId).map(([, instance]) => instance);
4093
+ return instances;
4094
+ }
4048
4095
  // Vite only
4049
4096
  getVueInspector() {
4050
4097
  return getVueInspector();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vue/devtools-kit",
3
3
  "type": "module",
4
- "version": "7.0.8",
4
+ "version": "7.0.10",
5
5
  "author": "webfansplz",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -21,8 +21,8 @@
21
21
  "mitt": "^3.0.1",
22
22
  "perfect-debounce": "^1.0.0",
23
23
  "speakingurl": "^14.0.1",
24
- "@vue/devtools-schema": "^7.0.8",
25
- "@vue/devtools-shared": "^7.0.8"
24
+ "@vue/devtools-schema": "^7.0.10",
25
+ "@vue/devtools-shared": "^7.0.10"
26
26
  },
27
27
  "devDependencies": {
28
28
  "vue": "^3.4.4",