@vue/devtools-kit 7.0.14 → 7.0.16

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
@@ -11,9 +11,9 @@ var __esm = (fn, res) => function __init() {
11
11
  var __commonJS = (cb, mod) => function __require() {
12
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
13
  };
14
- var __export = (target8, all) => {
14
+ var __export = (target9, all) => {
15
15
  for (var name in all)
16
- __defProp(target8, name, { get: all[name], enumerable: true });
16
+ __defProp(target9, name, { get: all[name], enumerable: true });
17
17
  };
18
18
  var __copyProps = (to, from, except, desc) => {
19
19
  if (from && typeof from === "object" || typeof from === "function") {
@@ -23,19 +23,19 @@ var __copyProps = (to, from, except, desc) => {
23
23
  }
24
24
  return to;
25
25
  };
26
- var __toESM = (mod, isNodeMode, target8) => (target8 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ var __toESM = (mod, isNodeMode, target9) => (target9 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
27
  // If the importer is in node compatibility mode or this is not an ESM
28
28
  // file that has been converted to a CommonJS file using a Babel-
29
29
  // compatible transform (i.e. "__esModule" has not been set), then set
30
30
  // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target8, "default", { value: mod, enumerable: true }) : target8,
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target9, "default", { value: mod, enumerable: true }) : target9,
32
32
  mod
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.0.1_postcss@8.4.33_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.0.2_postcss@8.4.35_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "../../node_modules/.pnpm/tsup@8.0.1_postcss@8.4.33_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js"() {
38
+ "../../node_modules/.pnpm/tsup@8.0.2_postcss@8.4.35_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js"() {
39
39
  "use strict";
40
40
  }
41
41
  });
@@ -1581,81 +1581,78 @@ var require_speakingurl2 = __commonJS({
1581
1581
  // src/index.ts
1582
1582
  var src_exports = {};
1583
1583
  __export(src_exports, {
1584
- ESC: () => ESC,
1585
- INFINITY: () => INFINITY,
1586
- MAX_ARRAY_SIZE: () => MAX_ARRAY_SIZE,
1587
- MAX_STRING_SIZE: () => MAX_STRING_SIZE,
1588
- NAN: () => NAN,
1589
- NEGATIVE_INFINITY: () => NEGATIVE_INFINITY,
1590
1584
  UNDEFINED: () => UNDEFINED,
1591
1585
  addCustomCommand: () => addCustomCommand,
1592
1586
  addCustomTab: () => addCustomTab,
1593
1587
  devtools: () => devtools,
1594
- fnTypeRE: () => fnTypeRE,
1595
1588
  formatInspectorStateValue: () => formatInspectorStateValue,
1596
1589
  getInspectorStateValueType: () => getInspectorStateValueType,
1597
- getRawValue: () => getRawValue,
1598
- now: () => now,
1590
+ getRaw: () => getRaw,
1599
1591
  onDevToolsClientConnected: () => onDevToolsClientConnected,
1600
1592
  onDevToolsConnected: () => onDevToolsConnected,
1601
1593
  parse: () => parse,
1602
- rawTypeRE: () => rawTypeRE,
1603
1594
  removeCustomCommand: () => removeCustomCommand,
1595
+ setDevToolsEnv: () => setDevToolsEnv,
1604
1596
  setupDevToolsPlugin: () => setupDevToolsPlugin,
1605
- specialTypeRE: () => specialTypeRE,
1606
1597
  stringify: () => stringify,
1607
- symbolRE: () => symbolRE,
1608
1598
  toEdit: () => toEdit,
1609
1599
  toSubmit: () => toSubmit,
1610
- toggleComponentInspectorEnabled: () => toggleComponentInspectorEnabled,
1611
- vueBuiltins: () => vueBuiltins
1600
+ toggleComponentInspectorEnabled: () => toggleComponentInspectorEnabled
1612
1601
  });
1613
1602
  module.exports = __toCommonJS(src_exports);
1614
1603
  init_cjs_shims();
1615
1604
 
1616
- // src/core/general/index.ts
1605
+ // src/core/index.ts
1617
1606
  init_cjs_shims();
1618
- var import_devtools_shared12 = require("@vue/devtools-shared");
1619
- var import_devtools_schema3 = require("@vue/devtools-schema");
1607
+ var import_devtools_shared15 = require("@vue/devtools-shared");
1620
1608
 
1621
- // src/api/index.ts
1609
+ // src/hook/index.ts
1622
1610
  init_cjs_shims();
1611
+ var import_devtools_shared = require("@vue/devtools-shared");
1612
+ var import_hookable = require("hookable");
1623
1613
 
1624
- // src/core/general/state.ts
1614
+ // src/types/index.ts
1625
1615
  init_cjs_shims();
1626
- var import_devtools_shared3 = require("@vue/devtools-shared");
1627
- var import_perfect_debounce2 = require("perfect-debounce");
1628
1616
 
1629
- // src/core/router/index.ts
1617
+ // src/types/app.ts
1630
1618
  init_cjs_shims();
1631
- var import_devtools_shared2 = require("@vue/devtools-shared");
1632
- var import_perfect_debounce = require("perfect-debounce");
1633
1619
 
1634
- // src/core/general/hook.ts
1620
+ // src/types/hook.ts
1635
1621
  init_cjs_shims();
1636
- var import_devtools_schema = require("@vue/devtools-schema");
1637
- var import_devtools_shared = require("@vue/devtools-shared");
1638
- var import_hookable = require("hookable");
1622
+
1623
+ // src/types/state.ts
1624
+ init_cjs_shims();
1625
+
1626
+ // src/types/context.ts
1627
+ init_cjs_shims();
1628
+
1629
+ // src/types/router.ts
1630
+ init_cjs_shims();
1631
+
1632
+ // src/types/env.ts
1633
+ init_cjs_shims();
1634
+
1635
+ // src/hook/index.ts
1639
1636
  var _a, _b;
1640
1637
  var devtoolsHooks = (_b = (_a = import_devtools_shared.target).__VUE_DEVTOOLS_HOOK) != null ? _b : _a.__VUE_DEVTOOLS_HOOK = (0, import_hookable.createHooks)();
1641
1638
  var on = {
1642
1639
  vueAppInit(fn) {
1643
- devtoolsHooks.hook(import_devtools_schema.DevToolsHooks.APP_INIT, fn);
1640
+ devtoolsHooks.hook("app:init" /* APP_INIT */, fn);
1644
1641
  },
1645
1642
  vueAppConnected(fn) {
1646
- devtoolsHooks.hook(import_devtools_schema.DevToolsHooks.APP_CONNECTED, fn);
1643
+ devtoolsHooks.hook("app:connected" /* APP_CONNECTED */, fn);
1647
1644
  },
1648
1645
  componentAdded(fn) {
1649
- return devtoolsHooks.hook(import_devtools_schema.DevToolsHooks.COMPONENT_ADDED, fn);
1646
+ return devtoolsHooks.hook("component:added" /* COMPONENT_ADDED */, fn);
1650
1647
  },
1651
1648
  componentUpdated(fn) {
1652
- return devtoolsHooks.hook(import_devtools_schema.DevToolsHooks.COMPONENT_UPDATED, fn);
1649
+ return devtoolsHooks.hook("component:updated" /* COMPONENT_UPDATED */, fn);
1653
1650
  },
1654
1651
  componentRemoved(fn) {
1655
- return devtoolsHooks.hook(import_devtools_schema.DevToolsHooks.COMPONENT_REMOVED, fn);
1652
+ return devtoolsHooks.hook("component:removed" /* COMPONENT_REMOVED */, fn);
1656
1653
  },
1657
1654
  setupDevtoolsPlugin(fn) {
1658
- devtoolsHooks.hook(import_devtools_schema.DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, fn);
1655
+ devtoolsHooks.hook("devtools-plugin:setup" /* SETUP_DEVTOOLS_PLUGIN */, fn);
1659
1656
  }
1660
1657
  };
1661
1658
  function createDevToolsHook() {
@@ -1666,10 +1663,10 @@ function createDevToolsHook() {
1666
1663
  apps: {},
1667
1664
  events: /* @__PURE__ */ new Map(),
1668
1665
  on(event, fn) {
1669
- var _a9;
1666
+ var _a10;
1670
1667
  if (!this.events.has(event))
1671
1668
  this.events.set(event, []);
1672
- (_a9 = this.events.get(event)) == null ? void 0 : _a9.push(fn);
1669
+ (_a10 = this.events.get(event)) == null ? void 0 : _a10.push(fn);
1673
1670
  return () => this.off(event, fn);
1674
1671
  },
1675
1672
  once(event, fn) {
@@ -1696,295 +1693,203 @@ function createDevToolsHook() {
1696
1693
  }
1697
1694
  function subscribeDevToolsHook() {
1698
1695
  const hook2 = import_devtools_shared.target.__VUE_DEVTOOLS_GLOBAL_HOOK__;
1699
- hook2.on(import_devtools_schema.DevToolsHooks.APP_INIT, (app, version) => {
1700
- var _a9, _b9, _c;
1701
- if ((_c = (_b9 = (_a9 = app == null ? void 0 : app._instance) == null ? void 0 : _a9.type) == null ? void 0 : _b9.devtools) == null ? void 0 : _c.hide)
1696
+ hook2.on("app:init" /* APP_INIT */, (app, version) => {
1697
+ var _a10, _b10, _c;
1698
+ if ((_c = (_b10 = (_a10 = app == null ? void 0 : app._instance) == null ? void 0 : _a10.type) == null ? void 0 : _b10.devtools) == null ? void 0 : _c.hide)
1702
1699
  return;
1703
- devtoolsHooks.callHook(import_devtools_schema.DevToolsHooks.APP_INIT, app, version);
1700
+ devtoolsHooks.callHook("app:init" /* APP_INIT */, app, version);
1704
1701
  });
1705
- hook2.on(import_devtools_schema.DevToolsHooks.COMPONENT_ADDED, async (app, uid, parentUid, component) => {
1706
- var _a9, _b9, _c;
1707
- if ((_c = (_b9 = (_a9 = app == null ? void 0 : app._instance) == null ? void 0 : _a9.type) == null ? void 0 : _b9.devtools) == null ? void 0 : _c.hide)
1702
+ hook2.on("component:added" /* COMPONENT_ADDED */, async (app, uid, parentUid, component) => {
1703
+ var _a10, _b10, _c;
1704
+ if ((_c = (_b10 = (_a10 = app == null ? void 0 : app._instance) == null ? void 0 : _a10.type) == null ? void 0 : _b10.devtools) == null ? void 0 : _c.hide)
1708
1705
  return;
1709
1706
  if (!app || typeof uid !== "number" && !uid || !component)
1710
1707
  return;
1711
- devtoolsHooks.callHook(import_devtools_schema.DevToolsHooks.COMPONENT_ADDED, app, uid, parentUid, component);
1708
+ devtoolsHooks.callHook("component:added" /* COMPONENT_ADDED */, app, uid, parentUid, component);
1712
1709
  });
1713
- hook2.on(import_devtools_schema.DevToolsHooks.COMPONENT_UPDATED, (app, uid, parentUid, component) => {
1710
+ hook2.on("component:updated" /* COMPONENT_UPDATED */, (app, uid, parentUid, component) => {
1714
1711
  if (!app || typeof uid !== "number" && !uid || !component)
1715
1712
  return;
1716
- devtoolsHooks.callHook(import_devtools_schema.DevToolsHooks.COMPONENT_UPDATED, app, uid, parentUid, component);
1713
+ devtoolsHooks.callHook("component:updated" /* COMPONENT_UPDATED */, app, uid, parentUid, component);
1717
1714
  });
1718
- hook2.on(import_devtools_schema.DevToolsHooks.COMPONENT_REMOVED, async (app, uid, parentUid, component) => {
1715
+ hook2.on("component:removed" /* COMPONENT_REMOVED */, async (app, uid, parentUid, component) => {
1719
1716
  if (!app || typeof uid !== "number" && !uid || !component)
1720
1717
  return;
1721
- devtoolsHooks.callHook(import_devtools_schema.DevToolsHooks.COMPONENT_REMOVED, app, uid, parentUid, component);
1718
+ devtoolsHooks.callHook("component:removed" /* COMPONENT_REMOVED */, app, uid, parentUid, component);
1722
1719
  });
1723
- hook2.on(import_devtools_schema.DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, (pluginDescriptor, setupFn) => {
1724
- devtoolsHooks.callHook(import_devtools_schema.DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, pluginDescriptor, setupFn);
1720
+ hook2.on("devtools-plugin:setup" /* SETUP_DEVTOOLS_PLUGIN */, (pluginDescriptor, setupFn) => {
1721
+ devtoolsHooks.callHook("devtools-plugin:setup" /* SETUP_DEVTOOLS_PLUGIN */, pluginDescriptor, setupFn);
1725
1722
  });
1726
1723
  }
1727
1724
  var hook = {
1728
- on
1725
+ on,
1726
+ setupDevToolsPlugin(pluginDescriptor, setupFn) {
1727
+ return devtoolsHooks.callHook("devtools-plugin:setup" /* SETUP_DEVTOOLS_PLUGIN */, pluginDescriptor, setupFn);
1728
+ }
1729
1729
  };
1730
1730
 
1731
+ // src/state/index.ts
1732
+ init_cjs_shims();
1733
+
1734
+ // src/state/state.ts
1735
+ init_cjs_shims();
1736
+ var import_devtools_shared10 = require("@vue/devtools-shared");
1737
+ var import_perfect_debounce3 = require("perfect-debounce");
1738
+
1739
+ // src/api/index.ts
1740
+ init_cjs_shims();
1741
+
1742
+ // src/api/api.ts
1743
+ init_cjs_shims();
1744
+
1745
+ // src/core/timeline/index.ts
1746
+ init_cjs_shims();
1747
+ function addTimelineLayer(payload) {
1748
+ devtoolsContext.timelineLayer.push(payload);
1749
+ }
1750
+
1751
+ // src/core/inspector/index.ts
1752
+ init_cjs_shims();
1753
+ function addInspector(payload) {
1754
+ devtoolsContext.inspector.push(payload);
1755
+ }
1756
+ function getInspector(inspectorId) {
1757
+ return devtoolsContext.inspector.find((inspector) => inspector.id === inspectorId);
1758
+ }
1759
+ function updateInspector(inspectorId, payload) {
1760
+ const inspector = getInspector(inspectorId);
1761
+ inspector && Object.assign(inspector, payload);
1762
+ }
1763
+
1764
+ // src/core/app-record/index.ts
1765
+ init_cjs_shims();
1766
+ var import_speakingurl = __toESM(require_speakingurl2(), 1);
1767
+
1768
+ // src/api/plugin.ts
1769
+ init_cjs_shims();
1770
+
1731
1771
  // src/core/router/index.ts
1732
- var RouterInfoKey = "__VUE_DEVTOOLS_ROUTER_INFO__";
1733
- var RouterKey = "__VUE_DEVTOOLS_ROUTER__";
1772
+ init_cjs_shims();
1773
+ var import_devtools_shared3 = require("@vue/devtools-shared");
1774
+ var import_perfect_debounce = require("perfect-debounce");
1775
+
1776
+ // src/api/hook.ts
1777
+ init_cjs_shims();
1778
+ var import_devtools_shared2 = require("@vue/devtools-shared");
1779
+ var import_hookable2 = require("hookable");
1734
1780
  var _a2, _b2;
1735
- (_b2 = (_a2 = import_devtools_shared2.target)[RouterInfoKey]) != null ? _b2 : _a2[RouterInfoKey] = {
1736
- currentRoute: null,
1737
- routes: [],
1738
- router: null
1739
- };
1740
- var _a3, _b3;
1741
- (_b3 = (_a3 = import_devtools_shared2.target)[RouterKey]) != null ? _b3 : _a3[RouterKey] = null;
1742
- var devtoolsRouterInfo = new Proxy(import_devtools_shared2.target[RouterInfoKey], {
1743
- get(target8, property) {
1744
- return import_devtools_shared2.target[RouterInfoKey][property];
1781
+ var apiHooks = (_b2 = (_a2 = import_devtools_shared2.target).__VUE_DEVTOOLS_API_HOOK) != null ? _b2 : _a2.__VUE_DEVTOOLS_API_HOOK = (0, import_hookable2.createHooks)();
1782
+
1783
+ // src/core/router/index.ts
1784
+ function getRoutes(router) {
1785
+ const routesMap = /* @__PURE__ */ new Map();
1786
+ return ((router == null ? void 0 : router.getRoutes()) || []).filter((i) => !routesMap.has(i.path) && routesMap.set(i.path, 1));
1787
+ }
1788
+ function filterRoutes(routes) {
1789
+ return routes.map((item) => {
1790
+ let { path, name, children } = item;
1791
+ if (children == null ? void 0 : children.length)
1792
+ children = filterRoutes(children);
1793
+ return {
1794
+ path,
1795
+ name,
1796
+ children
1797
+ };
1798
+ });
1799
+ }
1800
+ function filterCurrentRoute(route) {
1801
+ if (route) {
1802
+ const { fullPath, hash, href, path, name, matched, params, query } = route;
1803
+ return {
1804
+ fullPath,
1805
+ hash,
1806
+ href,
1807
+ path,
1808
+ name,
1809
+ params,
1810
+ query,
1811
+ matched: filterRoutes(matched)
1812
+ };
1745
1813
  }
1746
- });
1814
+ return route;
1815
+ }
1747
1816
  function normalizeRouterInfo(appRecord) {
1748
- const getRoutes = (router) => {
1749
- const routesMap = /* @__PURE__ */ new Map();
1750
- return ((router == null ? void 0 : router.getRoutes()) || []).filter((i) => !routesMap.has(i.path) && routesMap.set(i.path, 1));
1751
- };
1752
- function filterRoutes(routes) {
1753
- return routes.map((item) => {
1754
- let { path, name, children } = item;
1755
- if (children == null ? void 0 : children.length)
1756
- children = filterRoutes(children);
1757
- return {
1758
- path,
1759
- name,
1760
- children
1761
- };
1762
- });
1763
- }
1764
- function filterCurrentRoute(route) {
1765
- if (route) {
1766
- const { fullPath, hash, href, path, name, matched, params, query } = route;
1767
- return {
1768
- fullPath,
1769
- hash,
1770
- href,
1771
- path,
1772
- name,
1773
- params,
1774
- query,
1775
- matched: filterRoutes(matched)
1776
- };
1777
- }
1778
- return route;
1779
- }
1780
1817
  function init() {
1781
- var _a9;
1782
- const router = (_a9 = appRecord.app) == null ? void 0 : _a9.config.globalProperties.$router;
1818
+ var _a10;
1819
+ const router = (_a10 = appRecord.app) == null ? void 0 : _a10.config.globalProperties.$router;
1783
1820
  const currentRoute = filterCurrentRoute(router == null ? void 0 : router.currentRoute.value);
1784
1821
  const routes = filterRoutes(getRoutes(router));
1785
1822
  const c = console.warn;
1786
1823
  console.warn = () => {
1787
1824
  };
1788
- import_devtools_shared2.target[RouterInfoKey] = {
1789
- currentRoute: currentRoute ? (0, import_devtools_shared2.deepClone)(currentRoute) : {},
1790
- routes: (0, import_devtools_shared2.deepClone)(routes)
1825
+ import_devtools_shared3.target[ROUTER_INFO_KEY] = {
1826
+ currentRoute: currentRoute ? (0, import_devtools_shared3.deepClone)(currentRoute) : {},
1827
+ routes: (0, import_devtools_shared3.deepClone)(routes)
1791
1828
  };
1792
- import_devtools_shared2.target[RouterKey] = router;
1829
+ import_devtools_shared3.target[ROUTER_KEY] = router;
1793
1830
  console.warn = c;
1794
1831
  }
1795
1832
  init();
1796
1833
  hook.on.componentUpdated((0, import_perfect_debounce.debounce)(() => {
1797
1834
  init();
1798
- apiHooks.callHook("router-info:updated" /* ROUTER_INFO_UPDATED */, import_devtools_shared2.target[RouterInfoKey]);
1835
+ apiHooks.callHook("router-info:updated" /* ROUTER_INFO_UPDATED */, import_devtools_shared3.target[ROUTER_INFO_KEY]);
1799
1836
  }, 200));
1800
1837
  }
1801
1838
  function getRouterDevToolsId(id) {
1802
1839
  return id.replace(/\D/g, "") || "0";
1803
1840
  }
1804
1841
 
1805
- // src/core/general/state.ts
1806
- var StateKey = "__VUE_DEVTOOLS_GLOBAL_STATE__";
1807
- var ContextKey = "__VUE_DEVTOOLS_CONTEXT__";
1808
- var DefaultContext = {
1809
- appRecord: null,
1810
- api: null,
1811
- inspector: [],
1812
- timelineLayer: [],
1813
- routerInfo: {},
1814
- router: null,
1815
- activeInspectorTreeId: "",
1816
- componentPluginHookBuffer: []
1817
- };
1818
- var _a4, _b4;
1819
- (_b4 = (_a4 = import_devtools_shared3.target)[StateKey]) != null ? _b4 : _a4[StateKey] = {
1820
- connected: false,
1821
- clientConnected: false,
1822
- appRecords: [],
1823
- activeAppRecord: null,
1824
- selectedComponentId: null,
1825
- pluginBuffer: [],
1826
- tabs: [],
1827
- commands: [],
1828
- vitePluginDetected: false,
1829
- activeAppRecordId: null
1830
- };
1831
- var _a5, _b5;
1832
- (_b5 = (_a5 = import_devtools_shared3.target)[ContextKey]) != null ? _b5 : _a5[ContextKey] = (0, import_devtools_shared3.deepClone)(DefaultContext);
1833
- var callStateUpdatedHook = (0, import_perfect_debounce2.debounce)((state, oldState) => {
1834
- apiHooks.callHook("devtools:state-updated" /* DEVTOOLS_STATE_UPDATED */, state, oldState);
1835
- }, 80);
1836
- var callConnectedUpdatedHook = (0, import_perfect_debounce2.debounce)((state, oldState) => {
1837
- apiHooks.callHook("devtools:connected-updated" /* DEVTOOLS_CONNECTED_UPDATED */, state, oldState);
1838
- }, 80);
1839
- var devtoolsState = new Proxy(import_devtools_shared3.target[StateKey], {
1840
- get(target8, property) {
1841
- return import_devtools_shared3.target[StateKey][property];
1842
- },
1843
- set(target8, property, value) {
1844
- var _a9;
1845
- const oldState = { ...import_devtools_shared3.target[StateKey] };
1846
- target8[property] = value;
1847
- import_devtools_shared3.target[StateKey][property] = value;
1848
- if (property === "activeAppRecord") {
1849
- import_devtools_shared3.target[ContextKey].appRecord = value;
1850
- import_devtools_shared3.target[ContextKey].api = value.api;
1851
- import_devtools_shared3.target[ContextKey].inspector = (_a9 = value.inspector) != null ? _a9 : [];
1852
- normalizeRouterInfo(value);
1853
- import_devtools_shared3.target[ContextKey].routerInfo = devtoolsRouterInfo;
1854
- }
1855
- callStateUpdatedHook(import_devtools_shared3.target[StateKey], oldState);
1856
- if (["connected", "clientConnected"].includes(property.toString()) && oldState[property] !== value)
1857
- callConnectedUpdatedHook(import_devtools_shared3.target[StateKey], oldState);
1858
- return true;
1859
- },
1860
- deleteProperty(target8, property) {
1861
- delete target8[property];
1862
- return true;
1863
- }
1864
- });
1865
- Object.defineProperty(devtoolsState.tabs, "push", {
1866
- configurable: true,
1867
- value(...items) {
1868
- const result = Array.prototype.push.apply(this, items);
1869
- devtoolsState.tabs = this;
1870
- apiHooks.callHook("custom-tabs:updated" /* CUSTOM_TABS_UPDATED */, this);
1871
- return result;
1842
+ // src/api/plugin.ts
1843
+ function collectDevToolsPlugin(pluginDescriptor, setupFn) {
1844
+ devtoolsState.pluginBuffer.push([pluginDescriptor, setupFn]);
1845
+ }
1846
+ function setupDevToolsPlugin(pluginDescriptor, setupFn) {
1847
+ return hook.setupDevToolsPlugin(pluginDescriptor, setupFn);
1848
+ }
1849
+ function setupExternalPlugin(plugin, app, api) {
1850
+ const [pluginDescriptor, setupFn] = plugin;
1851
+ if (pluginDescriptor.app !== app)
1852
+ return;
1853
+ if (pluginDescriptor.packageName === "vue-query") {
1854
+ return;
1872
1855
  }
1873
- });
1874
- ["push", "splice"].forEach((method) => {
1875
- Object.defineProperty(devtoolsState.commands, method, {
1876
- configurable: true,
1877
- value(...args) {
1878
- const result = Array.prototype[method].apply(this, args);
1879
- devtoolsState.commands = this;
1880
- apiHooks.callHook("custom-commands:updated" /* CUSTOM_COMMANDS_UPDATED */, this);
1881
- return result;
1856
+ if (pluginDescriptor.packageName === "vue-router") {
1857
+ const id = getRouterDevToolsId(`${pluginDescriptor.id}`);
1858
+ if (pluginDescriptor.app === app) {
1859
+ devtoolsAppRecords.value = devtoolsAppRecords.value.map((item) => ({
1860
+ ...item,
1861
+ routerId: id
1862
+ }));
1882
1863
  }
1883
- });
1884
- });
1885
- var devtoolsContext = new Proxy(import_devtools_shared3.target[ContextKey], {
1886
- get(target8, property) {
1887
- if (property === "router")
1888
- return import_devtools_shared3.target[RouterKey];
1889
- else if (property === "clear")
1890
- return clearDevToolsContext;
1891
- return import_devtools_shared3.target[ContextKey][property];
1892
- },
1893
- set(target8, property, value) {
1894
- if (property === "componentPluginHookBuffer")
1895
- import_devtools_shared3.target[ContextKey][property] = value;
1896
- return true;
1897
1864
  }
1898
- });
1899
- function clearDevToolsContext() {
1900
- import_devtools_shared3.target[ContextKey] = (0, import_devtools_shared3.deepClone)(DefaultContext);
1865
+ setupFn(api);
1866
+ }
1867
+ function registerPlugin(app, api) {
1868
+ devtoolsState.pluginBuffer.forEach((plugin) => setupExternalPlugin(plugin, app, api));
1869
+ devtoolsAppRecords.value = devtoolsAppRecords.value.map((record) => {
1870
+ var _a10, _b10;
1871
+ const globalProperties = (_b10 = (_a10 = record.app) == null ? void 0 : _a10.config) == null ? void 0 : _b10.globalProperties;
1872
+ if (!globalProperties)
1873
+ return record;
1874
+ return {
1875
+ ...record,
1876
+ moduleDetectives: {
1877
+ vueRouter: !!globalProperties.$router,
1878
+ pinia: !!globalProperties.$pinia,
1879
+ vueI18n: !!globalProperties.$i18n
1880
+ }
1881
+ };
1882
+ });
1901
1883
  }
1902
1884
 
1903
- // src/shared/index.ts
1904
- init_cjs_shims();
1905
-
1906
- // src/shared/util.ts
1907
- init_cjs_shims();
1908
-
1909
- // src/core/component/state/replacer.ts
1910
- init_cjs_shims();
1911
-
1912
- // src/core/component/state/constants.ts
1885
+ // src/plugins/index.ts
1913
1886
  init_cjs_shims();
1914
- var vueBuiltins = /* @__PURE__ */ new Set([
1915
- "nextTick",
1916
- "defineComponent",
1917
- "defineAsyncComponent",
1918
- "defineCustomElement",
1919
- "ref",
1920
- "computed",
1921
- "reactive",
1922
- "readonly",
1923
- "watchEffect",
1924
- "watchPostEffect",
1925
- "watchSyncEffect",
1926
- "watch",
1927
- "isRef",
1928
- "unref",
1929
- "toRef",
1930
- "toRefs",
1931
- "isProxy",
1932
- "isReactive",
1933
- "isReadonly",
1934
- "shallowRef",
1935
- "triggerRef",
1936
- "customRef",
1937
- "shallowReactive",
1938
- "shallowReadonly",
1939
- "toRaw",
1940
- "markRaw",
1941
- "effectScope",
1942
- "getCurrentScope",
1943
- "onScopeDispose",
1944
- "onMounted",
1945
- "onUpdated",
1946
- "onUnmounted",
1947
- "onBeforeMount",
1948
- "onBeforeUpdate",
1949
- "onBeforeUnmount",
1950
- "onErrorCaptured",
1951
- "onRenderTracked",
1952
- "onRenderTriggered",
1953
- "onActivated",
1954
- "onDeactivated",
1955
- "onServerPrefetch",
1956
- "provide",
1957
- "inject",
1958
- "h",
1959
- "mergeProps",
1960
- "cloneVNode",
1961
- "isVNode",
1962
- "resolveComponent",
1963
- "resolveDirective",
1964
- "withDirectives",
1965
- "withModifiers"
1966
- ]);
1967
- var symbolRE = /^\[native Symbol Symbol\((.*)\)\]$/;
1968
- var rawTypeRE = /^\[object (\w+)]$/;
1969
- var specialTypeRE = /^\[native (\w+) (.*?)(<>((.|\s)*))?\]$/;
1970
- var fnTypeRE = /^(?:function|class) (\w+)/;
1971
- var MAX_STRING_SIZE = 1e4;
1972
- var MAX_ARRAY_SIZE = 5e3;
1973
- var UNDEFINED = "__vue_devtool_undefined__";
1974
- var INFINITY = "__vue_devtool_infinity__";
1975
- var NEGATIVE_INFINITY = "__vue_devtool_negative_infinity__";
1976
- var NAN = "__vue_devtool_nan__";
1977
- var ESC = {
1978
- "<": "&lt;",
1979
- ">": "&gt;",
1980
- '"': "&quot;",
1981
- "&": "&amp;"
1982
- };
1983
1887
 
1984
- // src/core/component/state/custom.ts
1888
+ // src/plugins/component.ts
1985
1889
  init_cjs_shims();
1890
+ var import_perfect_debounce2 = require("perfect-debounce");
1986
1891
 
1987
- // src/core/component/general/util.ts
1892
+ // src/core/component/utils/index.ts
1988
1893
  init_cjs_shims();
1989
1894
  var import_devtools_shared4 = require("@vue/devtools-shared");
1990
1895
  var import_vue = require("vue");
@@ -2026,21 +1931,21 @@ async function getComponentId(options) {
2026
1931
  }
2027
1932
  }
2028
1933
  function isFragment(instance) {
2029
- var _a9;
2030
- const subTreeType = (_a9 = instance.subTree) == null ? void 0 : _a9.type;
1934
+ var _a10;
1935
+ const subTreeType = (_a10 = instance.subTree) == null ? void 0 : _a10.type;
2031
1936
  return subTreeType === import_vue.Fragment;
2032
1937
  }
2033
1938
  function isBeingDestroyed(instance) {
2034
1939
  return instance._isBeingDestroyed || instance.isUnmounted;
2035
1940
  }
2036
1941
  function getInstanceName(instance) {
2037
- var _a9, _b9, _c;
1942
+ var _a10, _b10, _c;
2038
1943
  const name = getComponentTypeName(instance.type || {});
2039
1944
  if (name)
2040
1945
  return name;
2041
1946
  if (instance.root === instance)
2042
1947
  return "Root";
2043
- for (const key in (_b9 = (_a9 = instance.parent) == null ? void 0 : _a9.type) == null ? void 0 : _b9.components) {
1948
+ for (const key in (_b10 = (_a10 = instance.parent) == null ? void 0 : _a10.type) == null ? void 0 : _b10.components) {
2044
1949
  if (instance.parent.type.components[key] === instance.type)
2045
1950
  return saveComponentGussedName(instance, key);
2046
1951
  }
@@ -2054,8 +1959,8 @@ function getInstanceName(instance) {
2054
1959
  return "Anonymous Component";
2055
1960
  }
2056
1961
  function getUniqueComponentId(instance) {
2057
- var _a9, _b9, _c;
2058
- const appId = (_c = (_b9 = (_a9 = instance == null ? void 0 : instance.appContext) == null ? void 0 : _a9.app) == null ? void 0 : _b9.__VUE_DEVTOOLS_APP_RECORD_ID__) != null ? _c : 0;
1962
+ var _a10, _b10, _c;
1963
+ const appId = (_c = (_b10 = (_a10 = instance == null ? void 0 : instance.appContext) == null ? void 0 : _a10.app) == null ? void 0 : _b10.__VUE_DEVTOOLS_APP_RECORD_ID__) != null ? _c : 0;
2059
1964
  const instanceId = instance === instance.root ? "root" : instance.uid;
2060
1965
  return `${appId}:${instanceId}`;
2061
1966
  }
@@ -2084,1648 +1989,1864 @@ function getComponentInstance(appRecord, instanceId) {
2084
1989
  return instance || appRecord.instanceMap.get(":root");
2085
1990
  }
2086
1991
 
2087
- // src/core/component/state/process.ts
2088
- init_cjs_shims();
2089
- var import_devtools_shared5 = require("@vue/devtools-shared");
2090
-
2091
- // src/core/component/state/util.ts
2092
- init_cjs_shims();
2093
-
2094
- // src/core/component/state/is.ts
1992
+ // src/core/component/state/bounding-rect.ts
2095
1993
  init_cjs_shims();
2096
- function isVueInstance(value) {
2097
- return value._ && Object.keys(value._).includes("vnode");
1994
+ function createRect() {
1995
+ const rect = {
1996
+ top: 0,
1997
+ bottom: 0,
1998
+ left: 0,
1999
+ right: 0,
2000
+ get width() {
2001
+ return rect.right - rect.left;
2002
+ },
2003
+ get height() {
2004
+ return rect.bottom - rect.top;
2005
+ }
2006
+ };
2007
+ return rect;
2098
2008
  }
2099
- function isPlainObject(obj) {
2100
- return Object.prototype.toString.call(obj) === "[object Object]";
2101
- }
2102
- function isPrimitive(data) {
2103
- if (data == null)
2104
- return true;
2105
- const type = typeof data;
2106
- return type === "string" || type === "number" || type === "boolean";
2107
- }
2108
- function isRef(raw) {
2109
- return !!raw.__v_isRef;
2110
- }
2111
- function isComputed(raw) {
2112
- return isRef(raw) && !!raw.effect;
2009
+ var range;
2010
+ function getTextRect(node) {
2011
+ if (!range)
2012
+ range = document.createRange();
2013
+ range.selectNode(node);
2014
+ return range.getBoundingClientRect();
2113
2015
  }
2114
- function isReactive(raw) {
2115
- return !!raw.__v_isReactive;
2016
+ function getFragmentRect(vnode) {
2017
+ const rect = createRect();
2018
+ if (!vnode.children)
2019
+ return rect;
2020
+ for (let i = 0, l = vnode.children.length; i < l; i++) {
2021
+ const childVnode = vnode.children[i];
2022
+ let childRect;
2023
+ if (childVnode.component) {
2024
+ childRect = getComponentBoundingRect(childVnode.component);
2025
+ } else if (childVnode.el) {
2026
+ const el = childVnode.el;
2027
+ if (el.nodeType === 1 || el.getBoundingClientRect)
2028
+ childRect = el.getBoundingClientRect();
2029
+ else if (el.nodeType === 3 && el.data.trim())
2030
+ childRect = getTextRect(el);
2031
+ }
2032
+ if (childRect)
2033
+ mergeRects(rect, childRect);
2034
+ }
2035
+ return rect;
2116
2036
  }
2117
- function isReadOnly(raw) {
2118
- return !!raw.__v_isReadonly;
2037
+ function mergeRects(a, b) {
2038
+ if (!a.top || b.top < a.top)
2039
+ a.top = b.top;
2040
+ if (!a.bottom || b.bottom > a.bottom)
2041
+ a.bottom = b.bottom;
2042
+ if (!a.left || b.left < a.left)
2043
+ a.left = b.left;
2044
+ if (!a.right || b.right > a.right)
2045
+ a.right = b.right;
2046
+ return a;
2119
2047
  }
2120
-
2121
- // src/core/component/state/util.ts
2122
- var tokenMap = {
2123
- [UNDEFINED]: "undefined",
2124
- [NAN]: "NaN",
2125
- [INFINITY]: "Infinity",
2126
- [NEGATIVE_INFINITY]: "-Infinity"
2048
+ var DEFAULT_RECT = {
2049
+ top: 0,
2050
+ left: 0,
2051
+ right: 0,
2052
+ bottom: 0,
2053
+ width: 0,
2054
+ height: 0
2127
2055
  };
2128
- var reversedTokenMap = Object.entries(tokenMap).reduce((acc, [key, value]) => {
2129
- acc[value] = key;
2130
- return acc;
2131
- }, {});
2132
- function internalStateTokenToString(value) {
2133
- if (value === null)
2134
- return "null";
2135
- return typeof value === "string" && tokenMap[value] || false;
2136
- }
2137
- function replaceTokenToString(value) {
2138
- const replaceRegex = new RegExp(`"(${Object.keys(tokenMap).join("|")})"`, "g");
2139
- return value.replace(replaceRegex, (_, g1) => tokenMap[g1]);
2140
- }
2141
- function replaceStringToToken(value) {
2142
- const literalValue = reversedTokenMap[value.trim()];
2143
- if (literalValue)
2144
- return `"${literalValue}"`;
2145
- const replaceRegex = new RegExp(`:\\s*(${Object.keys(reversedTokenMap).join("|")})`, "g");
2146
- return value.replace(replaceRegex, (_, g1) => `:"${reversedTokenMap[g1]}"`);
2147
- }
2148
- function getPropType(type) {
2149
- if (Array.isArray(type))
2150
- return type.map((t) => getPropType(t)).join(" or ");
2151
- if (type == null)
2152
- return "null";
2153
- const match = type.toString().match(fnTypeRE);
2154
- return typeof type === "function" ? match && match[1] || "any" : "any";
2155
- }
2156
- function sanitize(data) {
2157
- if (!isPrimitive(data) && !Array.isArray(data) && !isPlainObject(data)) {
2158
- return Object.prototype.toString.call(data);
2159
- } else {
2160
- return data;
2056
+ function getComponentBoundingRect(instance) {
2057
+ const el = instance.subTree.el;
2058
+ if (typeof window === "undefined") {
2059
+ return DEFAULT_RECT;
2161
2060
  }
2061
+ if (isFragment(instance))
2062
+ return getFragmentRect(instance.subTree);
2063
+ else if ((el == null ? void 0 : el.nodeType) === 1)
2064
+ return el == null ? void 0 : el.getBoundingClientRect();
2065
+ else if (instance.subTree.component)
2066
+ return getComponentBoundingRect(instance.subTree.component);
2067
+ else
2068
+ return DEFAULT_RECT;
2162
2069
  }
2163
- function getSetupStateType(raw) {
2164
- return {
2165
- ref: isRef(raw),
2166
- computed: isComputed(raw),
2167
- reactive: isReactive(raw),
2168
- readonly: isReadOnly(raw)
2169
- };
2170
- }
2171
- function toRaw(value) {
2172
- if (value == null ? void 0 : value.__v_raw)
2173
- return value.__v_raw;
2174
- return value;
2070
+
2071
+ // src/core/component/tree/walker.ts
2072
+ init_cjs_shims();
2073
+
2074
+ // src/core/component/tree/el.ts
2075
+ init_cjs_shims();
2076
+ function getRootElementsFromComponentInstance(instance) {
2077
+ if (isFragment(instance))
2078
+ return getFragmentRootElements(instance.subTree);
2079
+ if (!instance.subTree)
2080
+ return [];
2081
+ return [instance.subTree.el];
2175
2082
  }
2176
- function escape(s) {
2177
- return s.replace(/[<>"&]/g, (s2) => {
2178
- return ESC[s2] || s2;
2083
+ function getFragmentRootElements(vnode) {
2084
+ if (!vnode.children)
2085
+ return [];
2086
+ const list = [];
2087
+ vnode.children.forEach((childVnode) => {
2088
+ if (childVnode.component)
2089
+ list.push(...getRootElementsFromComponentInstance(childVnode.component));
2090
+ else if (childVnode == null ? void 0 : childVnode.el)
2091
+ list.push(childVnode.el);
2179
2092
  });
2093
+ return list;
2180
2094
  }
2181
2095
 
2182
- // src/core/component/state/process.ts
2183
- function mergeOptions(to, from, instance) {
2184
- if (typeof from === "function")
2185
- from = from.options;
2186
- if (!from)
2187
- return to;
2188
- const { mixins, extends: extendsOptions } = from;
2189
- extendsOptions && mergeOptions(to, extendsOptions, instance);
2190
- mixins && mixins.forEach(
2191
- (m) => mergeOptions(to, m, instance)
2192
- );
2193
- for (const key of ["computed", "inject"]) {
2194
- if (Object.prototype.hasOwnProperty.call(from, key)) {
2195
- if (!to[key])
2196
- to[key] = from[key];
2197
- else
2198
- Object.assign(to[key], from[key]);
2199
- }
2096
+ // src/core/component/tree/filter.ts
2097
+ init_cjs_shims();
2098
+ var import_devtools_shared5 = require("@vue/devtools-shared");
2099
+ var ComponentFilter = class {
2100
+ constructor(filter) {
2101
+ this.filter = filter || "";
2200
2102
  }
2201
- return to;
2202
- }
2203
- function resolveMergedOptions(instance) {
2204
- const raw = instance.type;
2205
- const { mixins, extends: extendsOptions } = raw;
2206
- const globalMixins = instance.appContext.mixins;
2207
- if (!globalMixins.length && !mixins && !extendsOptions)
2208
- return raw;
2209
- const options = {};
2210
- globalMixins.forEach((m) => mergeOptions(options, m, instance));
2211
- mergeOptions(options, raw, instance);
2212
- return options;
2213
- }
2214
- function processProps(instance) {
2215
- const props = [];
2216
- const propDefinitions = instance.type.props;
2217
- for (const key in instance.props) {
2218
- const propDefinition = propDefinitions ? propDefinitions[key] : null;
2219
- const camelizeKey = (0, import_devtools_shared5.camelize)(key);
2220
- props.push({
2221
- type: "props",
2222
- key: camelizeKey,
2223
- value: returnError(() => instance.props[key]),
2224
- meta: propDefinition ? {
2225
- type: propDefinition.type ? getPropType(propDefinition.type) : "any",
2226
- required: !!propDefinition.required,
2227
- ...propDefinition.default ? {
2228
- default: propDefinition.default.toString()
2229
- } : {}
2230
- } : { type: "invalid" }
2231
- });
2103
+ /**
2104
+ * Check if an instance is qualified.
2105
+ *
2106
+ * @param {Vue|Vnode} instance
2107
+ * @return {boolean}
2108
+ */
2109
+ isQualified(instance) {
2110
+ const name = getInstanceName(instance);
2111
+ return (0, import_devtools_shared5.classify)(name).toLowerCase().includes(this.filter) || (0, import_devtools_shared5.kebabize)(name).toLowerCase().includes(this.filter);
2232
2112
  }
2233
- return props;
2234
- }
2235
- function processState(instance) {
2236
- const type = instance.type;
2237
- const props = type.props;
2238
- const getters = type.vuex && type.vuex.getters;
2239
- const computedDefs = type.computed;
2240
- const data = {
2241
- ...instance.data,
2242
- ...instance.renderContext
2243
- };
2244
- return Object.keys(data).filter((key) => !(props && key in props) && !(getters && key in getters) && !(computedDefs && key in computedDefs)).map((key) => ({
2245
- key,
2246
- type: "data",
2247
- value: returnError(() => data[key]),
2248
- editable: true
2249
- }));
2250
- }
2251
- function getStateTypeAndName(info) {
2252
- const stateType = info.computed ? "computed" : info.ref ? "ref" : info.reactive ? "reactive" : null;
2253
- const stateTypeName = stateType ? `${stateType.charAt(0).toUpperCase()}${stateType.slice(1)}` : null;
2254
- return {
2255
- stateType,
2256
- stateTypeName
2257
- };
2113
+ };
2114
+ function createComponentFilter(filterText) {
2115
+ return new ComponentFilter(filterText);
2258
2116
  }
2259
- function processSetupState(instance) {
2260
- const raw = instance.devtoolsRawSetupState || {};
2261
- return Object.keys(instance.setupState).filter((key) => !vueBuiltins.has(key) && key.split(/(?=[A-Z])/)[0] !== "use").map((key) => {
2262
- var _a9, _b9, _c, _d;
2263
- const value = returnError(() => toRaw(instance.setupState[key]));
2264
- const rawData = raw[key];
2265
- let result;
2266
- let isOtherType = typeof value === "function" || typeof (value == null ? void 0 : value.render) === "function" || typeof (value == null ? void 0 : value.__asyncLoader) === "function";
2267
- if (rawData) {
2268
- const info = getSetupStateType(rawData);
2269
- const { stateType, stateTypeName } = getStateTypeAndName(info);
2270
- const isState = info.ref || info.computed || info.reactive;
2271
- const raw2 = ((_b9 = (_a9 = rawData.effect) == null ? void 0 : _a9.raw) == null ? void 0 : _b9.toString()) || ((_d = (_c = rawData.effect) == null ? void 0 : _c.fn) == null ? void 0 : _d.toString());
2272
- if (stateType)
2273
- isOtherType = false;
2274
- result = {
2275
- ...stateType ? { stateType, stateTypeName } : {},
2276
- ...raw2 ? { raw: raw2 } : {},
2277
- editable: isState && !info.readonly
2278
- };
2279
- }
2280
- const type = isOtherType ? "setup (other)" : "setup";
2281
- return {
2282
- key,
2283
- value,
2284
- type,
2285
- // @ts-expect-error ignore
2286
- ...result
2287
- };
2288
- });
2289
- }
2290
- function processComputed(instance, mergedType) {
2291
- const type = mergedType;
2292
- const computed = [];
2293
- const defs = type.computed || {};
2294
- for (const key in defs) {
2295
- const def = defs[key];
2296
- const type2 = typeof def === "function" && def.vuex ? "vuex bindings" : "computed";
2297
- computed.push({
2298
- type: type2,
2299
- key,
2300
- value: returnError(() => {
2301
- var _a9;
2302
- return (_a9 = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a9[key];
2303
- }),
2304
- editable: typeof def.set === "function"
2305
- });
2117
+
2118
+ // src/core/component/tree/walker.ts
2119
+ var ComponentWalker = class {
2120
+ constructor(options) {
2121
+ // Dedupe instances (Some instances may be both on a component and on a child abstract/functional component)
2122
+ this.captureIds = /* @__PURE__ */ new Map();
2123
+ const { filterText = "", maxDepth, recursively } = options;
2124
+ this.componentFilter = createComponentFilter(filterText);
2125
+ this.maxDepth = maxDepth;
2126
+ this.recursively = recursively;
2306
2127
  }
2307
- return computed;
2308
- }
2309
- function processAttrs(instance) {
2310
- return Object.keys(instance.attrs).map((key) => ({
2311
- type: "attrs",
2312
- key,
2313
- value: returnError(() => instance.attrs[key])
2314
- }));
2315
- }
2316
- function processProvide(instance) {
2317
- return Reflect.ownKeys(instance.provides).map((key) => ({
2318
- type: "provided",
2319
- key: key.toString(),
2320
- value: returnError(() => instance.provides[key])
2321
- }));
2322
- }
2323
- function processInject(instance, mergedType) {
2324
- if (!(mergedType == null ? void 0 : mergedType.inject))
2325
- return [];
2326
- let keys = [];
2327
- let defaultValue;
2328
- if (Array.isArray(mergedType.inject)) {
2329
- keys = mergedType.inject.map((key) => ({
2330
- key,
2331
- originalKey: key
2332
- }));
2333
- } else {
2334
- keys = Reflect.ownKeys(mergedType.inject).map((key) => {
2335
- const value = mergedType.inject[key];
2336
- let originalKey;
2337
- if (typeof value === "string" || typeof value === "symbol") {
2338
- originalKey = value;
2339
- } else {
2340
- originalKey = value.from;
2341
- defaultValue = value.default;
2342
- }
2343
- return {
2344
- key,
2345
- originalKey
2346
- };
2347
- });
2128
+ getComponentTree(instance) {
2129
+ this.captureIds = /* @__PURE__ */ new Map();
2130
+ return this.findQualifiedChildren(instance, 0);
2348
2131
  }
2349
- return keys.map(({ key, originalKey }) => ({
2350
- type: "injected",
2351
- key: originalKey && key !== originalKey ? `${originalKey.toString()} \u279E ${key.toString()}` : key.toString(),
2352
- // eslint-disable-next-line no-prototype-builtins
2353
- value: returnError(() => instance.ctx.hasOwnProperty(key) ? instance.ctx[key] : instance.provides.hasOwnProperty(originalKey) ? instance.provides[originalKey] : defaultValue)
2354
- }));
2355
- }
2356
- function processRefs(instance) {
2357
- return Object.keys(instance.refs).map((key) => ({
2358
- type: "refs",
2359
- key,
2360
- value: returnError(() => instance.refs[key])
2361
- }));
2362
- }
2363
- function processEventListeners(instance) {
2364
- var _a9;
2365
- const emitsDefinition = instance.type.emits;
2366
- const declaredEmits = Array.isArray(emitsDefinition) ? emitsDefinition : Object.keys(emitsDefinition != null ? emitsDefinition : {});
2367
- const keys = Object.keys((_a9 = instance.vnode.props) != null ? _a9 : {});
2368
- const result = [];
2369
- for (const key of keys) {
2370
- const [prefix, ...eventNameParts] = key.split(/(?=[A-Z])/);
2371
- if (prefix === "on") {
2372
- const eventName = eventNameParts.join("-").toLowerCase();
2373
- const isDeclared = declaredEmits.includes(eventName);
2374
- result.push({
2375
- type: "event listeners",
2376
- key: eventName,
2377
- value: {
2378
- _custom: {
2379
- displayText: isDeclared ? "\u2705 Declared" : "\u26A0\uFE0F Not declared",
2380
- key: isDeclared ? "\u2705 Declared" : "\u26A0\uFE0F Not declared",
2381
- value: isDeclared ? "\u2705 Declared" : "\u26A0\uFE0F Not declared",
2382
- tooltipText: !isDeclared ? `The event <code>${eventName}</code> is not declared in the <code>emits</code> option. It will leak into the component's attributes (<code>$attrs</code>).` : null
2383
- }
2384
- }
2385
- });
2132
+ getComponentParents(instance) {
2133
+ this.captureIds = /* @__PURE__ */ new Map();
2134
+ const parents = [];
2135
+ this.captureId(instance);
2136
+ let parent = instance;
2137
+ while (parent = parent.parent) {
2138
+ this.captureId(parent);
2139
+ parents.push(parent);
2386
2140
  }
2141
+ return parents;
2387
2142
  }
2388
- return result;
2389
- }
2390
- function processInstanceState(instance) {
2391
- const mergedType = resolveMergedOptions(instance);
2392
- return processProps(instance).concat(
2393
- processState(instance),
2394
- processSetupState(instance),
2395
- processComputed(instance, mergedType),
2396
- processAttrs(instance),
2397
- processProvide(instance),
2398
- processInject(instance, mergedType),
2399
- processRefs(instance),
2400
- processEventListeners(instance)
2401
- );
2402
- }
2403
-
2404
- // src/core/component/state/custom.ts
2405
- function getFunctionDetails(func) {
2406
- let string = "";
2407
- let matches = null;
2408
- try {
2409
- string = Function.prototype.toString.call(func);
2410
- matches = String.prototype.match.call(string, /\([\s\S]*?\)/);
2411
- } catch (e) {
2143
+ captureId(instance) {
2144
+ if (!instance)
2145
+ return null;
2146
+ const id = instance.__VUE_DEVTOOLS_UID__ != null ? instance.__VUE_DEVTOOLS_UID__ : getUniqueComponentId(instance);
2147
+ instance.__VUE_DEVTOOLS_UID__ = id;
2148
+ if (this.captureIds.has(id))
2149
+ return null;
2150
+ else
2151
+ this.captureIds.set(id, void 0);
2152
+ this.mark(instance);
2153
+ return id;
2412
2154
  }
2413
- const match = matches && matches[0];
2414
- const args = typeof match === "string" ? match : "(?)";
2415
- const name = typeof func.name === "string" ? func.name : "";
2416
- return {
2417
- _custom: {
2418
- type: "function",
2419
- displayText: `<span style="opacity:.5;">function</span> ${escape(name)}${args}`,
2420
- tooltipText: string.trim() ? `<pre>${string}</pre>` : null
2421
- }
2422
- };
2423
- }
2424
- function getBigIntDetails(val) {
2425
- const stringifiedBigInt = BigInt.prototype.toString.call(val);
2426
- return {
2427
- _custom: {
2428
- type: "bigint",
2429
- displayText: `BigInt(${stringifiedBigInt})`,
2430
- value: stringifiedBigInt
2155
+ /**
2156
+ * Capture the meta information of an instance. (recursive)
2157
+ *
2158
+ * @param {Vue} instance
2159
+ * @return {object}
2160
+ */
2161
+ async capture(instance, depth) {
2162
+ var _a10;
2163
+ if (!instance)
2164
+ return null;
2165
+ const id = this.captureId(instance);
2166
+ const name = getInstanceName(instance);
2167
+ const children = this.getInternalInstanceChildren(instance.subTree).filter((child) => !isBeingDestroyed(child));
2168
+ const parents = this.getComponentParents(instance) || [];
2169
+ const inactive = !!instance.isDeactivated || parents.some((parent) => parent.isDeactivated);
2170
+ const treeNode = {
2171
+ uid: instance.uid,
2172
+ id,
2173
+ name,
2174
+ renderKey: getRenderKey(instance.vnode ? instance.vnode.key : null),
2175
+ inactive,
2176
+ children: [],
2177
+ isFragment: isFragment(instance),
2178
+ tags: typeof instance.type !== "function" ? [] : [
2179
+ {
2180
+ label: "functional",
2181
+ textColor: 5592405,
2182
+ backgroundColor: 15658734
2183
+ }
2184
+ ],
2185
+ autoOpen: this.recursively,
2186
+ file: instance.type.__file || ""
2187
+ };
2188
+ if (depth < this.maxDepth || instance.type.__isKeepAlive || parents.some((parent) => parent.type.__isKeepAlive)) {
2189
+ treeNode.children = await Promise.all(children.map((child) => this.capture(child, depth + 1)).filter(Boolean));
2431
2190
  }
2432
- };
2433
- }
2434
- function getMapDetails(val) {
2435
- const list = [];
2436
- val.forEach(
2437
- (value, key) => list.push({
2438
- key,
2439
- value
2440
- })
2441
- );
2442
- return {
2443
- _custom: {
2444
- type: "map",
2445
- displayText: "Map",
2446
- value: list,
2447
- readOnly: true,
2448
- fields: {
2449
- abstract: true
2191
+ if (this.isKeepAlive(instance)) {
2192
+ const cachedComponents = this.getKeepAliveCachedInstances(instance);
2193
+ const childrenIds = children.map((child) => child.__VUE_DEVTOOLS_UID__);
2194
+ for (const cachedChild of cachedComponents) {
2195
+ if (!childrenIds.includes(cachedChild.__VUE_DEVTOOLS_UID__)) {
2196
+ const node = await this.capture({ ...cachedChild, isDeactivated: true }, depth + 1);
2197
+ if (node)
2198
+ treeNode.children.push(node);
2199
+ }
2450
2200
  }
2451
2201
  }
2452
- };
2453
- }
2454
- function getSetDetails(val) {
2455
- const list = Array.from(val);
2456
- return {
2457
- _custom: {
2458
- type: "set",
2459
- displayText: `Set[${list.length}]`,
2460
- value: list,
2461
- readOnly: true
2202
+ const rootElements = getRootElementsFromComponentInstance(instance);
2203
+ const firstElement = rootElements[0];
2204
+ if (firstElement == null ? void 0 : firstElement.parentElement) {
2205
+ const parentInstance = instance.parent;
2206
+ const parentRootElements = parentInstance ? getRootElementsFromComponentInstance(parentInstance) : [];
2207
+ let el = firstElement;
2208
+ const indexList = [];
2209
+ do {
2210
+ indexList.push(Array.from(el.parentElement.childNodes).indexOf(el));
2211
+ el = el.parentElement;
2212
+ } while (el.parentElement && parentRootElements.length && !parentRootElements.includes(el));
2213
+ treeNode.domOrder = indexList.reverse();
2214
+ } else {
2215
+ treeNode.domOrder = [-1];
2462
2216
  }
2463
- };
2464
- }
2465
- function getCatchedGetters(store) {
2466
- const getters = {};
2467
- const origGetters = store.getters || {};
2468
- const keys = Object.keys(origGetters);
2469
- for (let i = 0; i < keys.length; i++) {
2470
- const key = keys[i];
2471
- Object.defineProperty(getters, key, {
2472
- enumerable: true,
2473
- get: () => {
2474
- try {
2475
- return origGetters[key];
2476
- } catch (e) {
2477
- return e;
2478
- }
2479
- }
2217
+ if ((_a10 = instance.suspense) == null ? void 0 : _a10.suspenseKey) {
2218
+ treeNode.tags.push({
2219
+ label: instance.suspense.suspenseKey,
2220
+ backgroundColor: 14979812,
2221
+ textColor: 16777215
2222
+ });
2223
+ this.mark(instance, true);
2224
+ }
2225
+ devtoolsContext.api.visitComponentTree({
2226
+ treeNode,
2227
+ componentInstance: instance,
2228
+ app: instance.appContext.app,
2229
+ filter: this.componentFilter.filter
2480
2230
  });
2231
+ return treeNode;
2481
2232
  }
2482
- return getters;
2483
- }
2484
- function reduceStateList(list) {
2485
- if (!list.length)
2486
- return void 0;
2487
- return list.reduce((map, item) => {
2488
- const key = item.type || "data";
2489
- const obj = map[key] = map[key] || {};
2490
- obj[item.key] = item.value;
2491
- return map;
2492
- }, {});
2493
- }
2494
- function namedNodeMapToObject(map) {
2495
- const result = {};
2496
- const l = map.length;
2497
- for (let i = 0; i < l; i++) {
2498
- const node = map.item(i);
2499
- result[node.name] = node.value;
2233
+ /**
2234
+ * Find qualified children from a single instance.
2235
+ * If the instance itself is qualified, just return itself.
2236
+ * This is ok because [].concat works in both cases.
2237
+ *
2238
+ * @param {Vue|Vnode} instance
2239
+ * @return {Vue|Array}
2240
+ */
2241
+ async findQualifiedChildren(instance, depth) {
2242
+ var _a10;
2243
+ if (this.componentFilter.isQualified(instance) && !((_a10 = instance.type.devtools) == null ? void 0 : _a10.hide)) {
2244
+ return [await this.capture(instance, depth)];
2245
+ } else if (instance.subTree) {
2246
+ const list = this.isKeepAlive(instance) ? this.getKeepAliveCachedInstances(instance) : this.getInternalInstanceChildren(instance.subTree);
2247
+ return this.findQualifiedChildrenFromList(list, depth);
2248
+ } else {
2249
+ return [];
2250
+ }
2500
2251
  }
2501
- return result;
2502
- }
2503
- function getStoreDetails(store) {
2504
- return {
2505
- _custom: {
2506
- type: "store",
2507
- displayText: "Store",
2508
- value: {
2509
- state: store.state,
2510
- getters: getCatchedGetters(store)
2511
- },
2512
- fields: {
2513
- abstract: true
2252
+ /**
2253
+ * Iterate through an array of instances and flatten it into
2254
+ * an array of qualified instances. This is a depth-first
2255
+ * traversal - e.g. if an instance is not matched, we will
2256
+ * recursively go deeper until a qualified child is found.
2257
+ *
2258
+ * @param {Array} instances
2259
+ * @return {Array}
2260
+ */
2261
+ async findQualifiedChildrenFromList(instances, depth) {
2262
+ instances = instances.filter((child) => {
2263
+ var _a10;
2264
+ return !isBeingDestroyed(child) && !((_a10 = child.type.devtools) == null ? void 0 : _a10.hide);
2265
+ });
2266
+ if (!this.componentFilter.filter)
2267
+ return Promise.all(instances.map((child) => this.capture(child, depth)));
2268
+ else
2269
+ return Array.prototype.concat.apply([], await Promise.all(instances.map((i) => this.findQualifiedChildren(i, depth))));
2270
+ }
2271
+ /**
2272
+ * Get children from a component instance.
2273
+ */
2274
+ getInternalInstanceChildren(subTree, suspense = null) {
2275
+ const list = [];
2276
+ if (subTree) {
2277
+ if (subTree.component) {
2278
+ !suspense ? list.push(subTree.component) : list.push({ ...subTree.component, suspense });
2279
+ } else if (subTree.suspense) {
2280
+ const suspenseKey = !subTree.suspense.isInFallback ? "suspense default" : "suspense fallback";
2281
+ list.push(...this.getInternalInstanceChildren(subTree.suspense.activeBranch, { ...subTree.suspense, suspenseKey }));
2282
+ } else if (Array.isArray(subTree.children)) {
2283
+ subTree.children.forEach((childSubTree) => {
2284
+ if (childSubTree.component)
2285
+ !suspense ? list.push(childSubTree.component) : list.push({ ...childSubTree.component, suspense });
2286
+ else
2287
+ list.push(...this.getInternalInstanceChildren(childSubTree, suspense));
2288
+ });
2514
2289
  }
2515
2290
  }
2516
- };
2517
- }
2518
- function getRouterDetails(router) {
2519
- return {
2520
- _custom: {
2521
- type: "router",
2522
- displayText: "VueRouter",
2523
- value: {
2524
- options: router.options,
2525
- currentRoute: router.currentRoute
2526
- },
2527
- fields: {
2528
- abstract: true
2529
- }
2291
+ return list.filter((child) => {
2292
+ var _a10;
2293
+ return !isBeingDestroyed(child) && !((_a10 = child.type.devtools) == null ? void 0 : _a10.hide);
2294
+ });
2295
+ }
2296
+ /**
2297
+ * Mark an instance as captured and store it in the instance map.
2298
+ *
2299
+ * @param {Vue} instance
2300
+ */
2301
+ mark(instance, force = false) {
2302
+ const instanceMap = getAppRecord(instance).instanceMap;
2303
+ if (force || !instanceMap.has(instance.__VUE_DEVTOOLS_UID__))
2304
+ instanceMap.set(instance.__VUE_DEVTOOLS_UID__, instance);
2305
+ }
2306
+ isKeepAlive(instance) {
2307
+ return instance.type.__isKeepAlive && instance.__v_cache;
2308
+ }
2309
+ getKeepAliveCachedInstances(instance) {
2310
+ return Array.from(instance.__v_cache.values()).map((vnode) => vnode.component).filter(Boolean);
2311
+ }
2312
+ };
2313
+
2314
+ // src/core/component/state/editor.ts
2315
+ init_cjs_shims();
2316
+ var import_vue2 = require("vue");
2317
+ var StateEditor = class {
2318
+ constructor() {
2319
+ this.refEditor = new RefStateEditor();
2320
+ }
2321
+ set(object, path, value, cb) {
2322
+ const sections = Array.isArray(path) ? path : path.split(".");
2323
+ const markRef = false;
2324
+ while (sections.length > 1) {
2325
+ const section = sections.shift();
2326
+ if (object instanceof Map)
2327
+ object = object.get(section);
2328
+ else
2329
+ object = object[section];
2330
+ if (this.refEditor.isRef(object))
2331
+ object = this.refEditor.get(object);
2530
2332
  }
2531
- };
2532
- }
2533
- function getInstanceDetails(instance) {
2534
- if (instance._)
2535
- instance = instance._;
2536
- const state = processInstanceState(instance);
2537
- return {
2538
- _custom: {
2539
- type: "component",
2540
- id: instance.__VUE_DEVTOOLS_UID__,
2541
- displayText: getInstanceName(instance),
2542
- tooltipText: "Component instance",
2543
- value: reduceStateList(state),
2544
- fields: {
2545
- abstract: true
2546
- }
2333
+ const field = sections[0];
2334
+ const item = this.refEditor.get(object)[field];
2335
+ if (cb) {
2336
+ cb(object, field, value);
2337
+ } else {
2338
+ if (this.refEditor.isRef(item))
2339
+ this.refEditor.set(item, value);
2340
+ else if (markRef)
2341
+ object[field] = value;
2342
+ else
2343
+ object[field] = value;
2547
2344
  }
2548
- };
2549
- }
2550
- function getComponentDefinitionDetails(definition) {
2551
- let display = getComponentName(definition);
2552
- if (display) {
2553
- if (definition.name && definition.__file)
2554
- display += ` <span>(${definition.__file})</span>`;
2555
- } else {
2556
- display = "<i>Unknown Component</i>";
2557
2345
  }
2558
- return {
2559
- _custom: {
2560
- type: "component-definition",
2561
- displayText: display,
2562
- tooltipText: "Component definition",
2563
- ...definition.__file ? {
2564
- file: definition.__file
2565
- } : {}
2346
+ get(object, path) {
2347
+ const sections = Array.isArray(path) ? path : path.split(".");
2348
+ for (let i = 0; i < sections.length; i++) {
2349
+ if (object instanceof Map)
2350
+ object = object.get(sections[i]);
2351
+ else
2352
+ object = object[sections[i]];
2353
+ if (this.refEditor.isRef(object))
2354
+ object = this.refEditor.get(object);
2355
+ if (!object)
2356
+ return void 0;
2566
2357
  }
2567
- };
2568
- }
2569
- function getHTMLElementDetails(value) {
2570
- try {
2571
- return {
2572
- _custom: {
2573
- type: "HTMLElement",
2574
- displayText: `<span class="opacity-30">&lt;</span><span class="text-blue-500">${value.tagName.toLowerCase()}</span><span class="opacity-30">&gt;</span>`,
2575
- value: namedNodeMapToObject(value.attributes)
2358
+ return object;
2359
+ }
2360
+ has(object, path, parent = false) {
2361
+ if (typeof object === "undefined")
2362
+ return false;
2363
+ const sections = Array.isArray(path) ? path.slice() : path.split(".");
2364
+ const size = !parent ? 1 : 2;
2365
+ while (object && sections.length > size) {
2366
+ const section = sections.shift();
2367
+ object = object[section];
2368
+ if (this.refEditor.isRef(object))
2369
+ object = this.refEditor.get(object);
2370
+ }
2371
+ return object != null && Object.prototype.hasOwnProperty.call(object, sections[0]);
2372
+ }
2373
+ createDefaultSetCallback(state) {
2374
+ return (object, field, value) => {
2375
+ if (state.remove || state.newKey) {
2376
+ if (Array.isArray(object))
2377
+ object.splice(field, 1);
2378
+ else if ((0, import_vue2.toRaw)(object) instanceof Map)
2379
+ object.delete(field);
2380
+ else if ((0, import_vue2.toRaw)(object) instanceof Set)
2381
+ object.delete(value);
2382
+ else
2383
+ Reflect.deleteProperty(object, field);
2576
2384
  }
2577
- };
2578
- } catch (e) {
2579
- return {
2580
- _custom: {
2581
- type: "HTMLElement",
2582
- displayText: `<span class="text-blue-500">${String(value)}</span>`
2385
+ if (!state.remove) {
2386
+ const target9 = object[state.newKey || field];
2387
+ if (this.refEditor.isRef(target9))
2388
+ this.refEditor.set(target9, value);
2389
+ else if ((0, import_vue2.toRaw)(object) instanceof Map)
2390
+ object.set(state.newKey || field, value);
2391
+ else
2392
+ object[state.newKey || field] = value;
2583
2393
  }
2584
2394
  };
2585
2395
  }
2586
- }
2587
- function getObjectDetails(object) {
2588
- var _a9, _b9, _c, _d;
2589
- const info = getSetupStateType(object);
2590
- const isState = info.ref || info.computed || info.reactive;
2591
- if (isState) {
2592
- const stateTypeName = info.computed ? "Computed" : info.ref ? "Ref" : info.reactive ? "Reactive" : null;
2593
- const value = toRaw(info.reactive ? object : object._value);
2594
- const raw = ((_b9 = (_a9 = object.effect) == null ? void 0 : _a9.raw) == null ? void 0 : _b9.toString()) || ((_d = (_c = object.effect) == null ? void 0 : _c.fn) == null ? void 0 : _d.toString());
2595
- return {
2596
- _custom: {
2597
- type: stateTypeName == null ? void 0 : stateTypeName.toLowerCase(),
2598
- stateTypeName,
2599
- value,
2600
- ...raw ? { tooltipText: `<span class="font-mono">${raw}</span>` } : {}
2396
+ };
2397
+ var RefStateEditor = class {
2398
+ set(ref, value) {
2399
+ if ((0, import_vue2.isRef)(ref)) {
2400
+ ref.value = value;
2401
+ } else {
2402
+ if (ref instanceof Set && Array.isArray(value)) {
2403
+ ref.clear();
2404
+ value.forEach((v) => ref.add(v));
2405
+ return;
2601
2406
  }
2602
- };
2603
- }
2604
- if (typeof object.__asyncLoader === "function") {
2605
- return {
2606
- _custom: {
2607
- type: "component-definition",
2608
- display: "Async component definition"
2407
+ const currentKeys = Object.keys(value);
2408
+ if (ref instanceof Map) {
2409
+ const previousKeysSet2 = new Set(ref.keys());
2410
+ currentKeys.forEach((key) => {
2411
+ ref.set(key, Reflect.get(value, key));
2412
+ previousKeysSet2.delete(key);
2413
+ });
2414
+ previousKeysSet2.forEach((key) => ref.delete(key));
2415
+ return;
2609
2416
  }
2610
- };
2417
+ const previousKeysSet = new Set(Object.keys(ref));
2418
+ currentKeys.forEach((key) => {
2419
+ Reflect.set(ref, key, Reflect.get(value, key));
2420
+ previousKeysSet.delete(key);
2421
+ });
2422
+ previousKeysSet.forEach((key) => Reflect.deleteProperty(ref, key));
2423
+ }
2611
2424
  }
2612
- }
2613
-
2614
- // src/core/component/state/replacer.ts
2615
- function stringifyReplacer(key) {
2616
- var _a9;
2617
- if (key === "compilerOptions")
2425
+ get(ref) {
2426
+ return (0, import_vue2.isRef)(ref) ? ref.value : ref;
2427
+ }
2428
+ isRef(ref) {
2429
+ return (0, import_vue2.isRef)(ref) || (0, import_vue2.isReactive)(ref);
2430
+ }
2431
+ };
2432
+ async function editComponentState(payload, stateEditor2) {
2433
+ const { path, nodeId, state, type } = payload;
2434
+ const instance = getComponentInstance(devtoolsContext.appRecord, nodeId);
2435
+ if (!instance)
2618
2436
  return;
2619
- const val = this[key];
2620
- const type = typeof val;
2621
- if (Array.isArray(val)) {
2622
- const l = val.length;
2623
- if (l > MAX_ARRAY_SIZE) {
2624
- return {
2625
- _isArray: true,
2626
- length: l,
2627
- items: val.slice(0, MAX_ARRAY_SIZE)
2628
- };
2629
- }
2630
- return val;
2631
- } else if (typeof val === "string") {
2632
- if (val.length > MAX_STRING_SIZE)
2633
- return `${val.substring(0, MAX_STRING_SIZE)}... (${val.length} total length)`;
2634
- else
2635
- return val;
2636
- } else if (type === "undefined") {
2637
- return UNDEFINED;
2638
- } else if (val === Number.POSITIVE_INFINITY) {
2639
- return INFINITY;
2640
- } else if (val === Number.NEGATIVE_INFINITY) {
2641
- return NEGATIVE_INFINITY;
2642
- } else if (typeof val === "function") {
2643
- return getFunctionDetails(val);
2644
- } else if (type === "symbol") {
2645
- return `[native Symbol ${Symbol.prototype.toString.call(val)}]`;
2646
- } else if (typeof val === "bigint") {
2647
- return getBigIntDetails(val);
2648
- } else if (val !== null && typeof val === "object") {
2649
- const proto = Object.prototype.toString.call(val);
2650
- if (proto === "[object Map]") {
2651
- return getMapDetails(val);
2652
- } else if (proto === "[object Set]") {
2653
- return getSetDetails(val);
2654
- } else if (proto === "[object RegExp]") {
2655
- return `[native RegExp ${RegExp.prototype.toString.call(val)}]`;
2656
- } else if (proto === "[object Date]") {
2657
- return `[native Date ${Date.prototype.toString.call(val)}]`;
2658
- } else if (proto === "[object Error]") {
2659
- return `[native Error ${val.message}<>${val.stack}]`;
2660
- } else if (val.state && val._vm) {
2661
- return getStoreDetails(val);
2662
- } else if (val.constructor && val.constructor.name === "VueRouter") {
2663
- return getRouterDetails(val);
2664
- } else if (isVueInstance(val)) {
2665
- return getInstanceDetails(val);
2666
- } else if (typeof val.render === "function") {
2667
- return getComponentDefinitionDetails(val);
2668
- } else if (val.constructor && val.constructor.name === "VNode") {
2669
- return `[native VNode <${val.tag}>]`;
2670
- } else if (typeof HTMLElement !== "undefined" && val instanceof HTMLElement) {
2671
- return getHTMLElementDetails(val);
2672
- } else if (((_a9 = val.constructor) == null ? void 0 : _a9.name) === "Store" && val._wrappedGetters) {
2673
- return "[object Store]";
2674
- } else if (val.currentRoute) {
2675
- return "[object Router]";
2437
+ const targetPath = path.slice();
2438
+ let target9;
2439
+ if (instance.devtoolsRawSetupState && Object.keys(instance.devtoolsRawSetupState).includes(path[0])) {
2440
+ target9 = instance.devtoolsRawSetupState;
2441
+ }
2442
+ if (target9 && targetPath) {
2443
+ if (state.type === "object" && type === "reactive") {
2676
2444
  }
2677
- const customDetails = getObjectDetails(val);
2678
- if (customDetails != null)
2679
- return customDetails;
2680
- } else if (Number.isNaN(val)) {
2681
- return NAN;
2445
+ stateEditor2.set(target9, targetPath, state.value, stateEditor2.createDefaultSetCallback(state));
2682
2446
  }
2683
- return sanitize(val);
2447
+ }
2448
+ var stateEditor = new StateEditor();
2449
+ async function editState(payload) {
2450
+ editComponentState(payload, stateEditor);
2684
2451
  }
2685
2452
 
2686
- // src/core/component/state/reviver.ts
2453
+ // src/core/component/state/index.ts
2454
+ init_cjs_shims();
2455
+
2456
+ // src/core/component/state/process.ts
2687
2457
  init_cjs_shims();
2688
2458
  var import_devtools_shared6 = require("@vue/devtools-shared");
2689
- function reviveSet(val) {
2690
- const result = /* @__PURE__ */ new Set();
2691
- const list = val._custom.value;
2692
- for (let i = 0; i < list.length; i++) {
2693
- const value = list[i];
2694
- result.add(revive(value));
2695
- }
2696
- return result;
2459
+
2460
+ // src/core/component/state/constants.ts
2461
+ init_cjs_shims();
2462
+ var vueBuiltins = /* @__PURE__ */ new Set([
2463
+ "nextTick",
2464
+ "defineComponent",
2465
+ "defineAsyncComponent",
2466
+ "defineCustomElement",
2467
+ "ref",
2468
+ "computed",
2469
+ "reactive",
2470
+ "readonly",
2471
+ "watchEffect",
2472
+ "watchPostEffect",
2473
+ "watchSyncEffect",
2474
+ "watch",
2475
+ "isRef",
2476
+ "unref",
2477
+ "toRef",
2478
+ "toRefs",
2479
+ "isProxy",
2480
+ "isReactive",
2481
+ "isReadonly",
2482
+ "shallowRef",
2483
+ "triggerRef",
2484
+ "customRef",
2485
+ "shallowReactive",
2486
+ "shallowReadonly",
2487
+ "toRaw",
2488
+ "markRaw",
2489
+ "effectScope",
2490
+ "getCurrentScope",
2491
+ "onScopeDispose",
2492
+ "onMounted",
2493
+ "onUpdated",
2494
+ "onUnmounted",
2495
+ "onBeforeMount",
2496
+ "onBeforeUpdate",
2497
+ "onBeforeUnmount",
2498
+ "onErrorCaptured",
2499
+ "onRenderTracked",
2500
+ "onRenderTriggered",
2501
+ "onActivated",
2502
+ "onDeactivated",
2503
+ "onServerPrefetch",
2504
+ "provide",
2505
+ "inject",
2506
+ "h",
2507
+ "mergeProps",
2508
+ "cloneVNode",
2509
+ "isVNode",
2510
+ "resolveComponent",
2511
+ "resolveDirective",
2512
+ "withDirectives",
2513
+ "withModifiers"
2514
+ ]);
2515
+ var symbolRE = /^\[native Symbol Symbol\((.*)\)\]$/;
2516
+ var rawTypeRE = /^\[object (\w+)]$/;
2517
+ var specialTypeRE = /^\[native (\w+) (.*?)(<>((.|\s)*))?\]$/;
2518
+ var fnTypeRE = /^(?:function|class) (\w+)/;
2519
+ var MAX_STRING_SIZE = 1e4;
2520
+ var MAX_ARRAY_SIZE = 5e3;
2521
+ var UNDEFINED = "__vue_devtool_undefined__";
2522
+ var INFINITY = "__vue_devtool_infinity__";
2523
+ var NEGATIVE_INFINITY = "__vue_devtool_negative_infinity__";
2524
+ var NAN = "__vue_devtool_nan__";
2525
+ var ESC = {
2526
+ "<": "&lt;",
2527
+ ">": "&gt;",
2528
+ '"': "&quot;",
2529
+ "&": "&amp;"
2530
+ };
2531
+
2532
+ // src/core/component/state/util.ts
2533
+ init_cjs_shims();
2534
+
2535
+ // src/core/component/state/is.ts
2536
+ init_cjs_shims();
2537
+ function isVueInstance(value) {
2538
+ return value._ && Object.keys(value._).includes("vnode");
2697
2539
  }
2698
- function reviveMap(val) {
2699
- const result = /* @__PURE__ */ new Map();
2700
- const list = val._custom.value;
2701
- for (let i = 0; i < list.length; i++) {
2702
- const { key, value } = list[i];
2703
- result.set(key, revive(value));
2704
- }
2705
- return result;
2540
+ function isPlainObject(obj) {
2541
+ return Object.prototype.toString.call(obj) === "[object Object]";
2706
2542
  }
2707
- function revive(val) {
2708
- var _a9;
2709
- if (val === UNDEFINED) {
2710
- return void 0;
2711
- } else if (val === INFINITY) {
2712
- return Number.POSITIVE_INFINITY;
2713
- } else if (val === NEGATIVE_INFINITY) {
2714
- return Number.NEGATIVE_INFINITY;
2715
- } else if (val === NAN) {
2716
- return Number.NaN;
2717
- } else if (val && val._custom) {
2718
- const { _custom: custom } = val;
2719
- if (custom.type === "component")
2720
- return (_a9 = devtoolsContext.appRecord) == null ? void 0 : _a9.instanceMap.get(custom.id);
2721
- else if (custom.type === "map")
2722
- return reviveMap(val);
2723
- else if (custom.type === "set")
2724
- return reviveSet(val);
2725
- else if (custom.type === "bigint")
2726
- return BigInt(custom.value);
2727
- else
2728
- return revive(custom.value);
2729
- } else if (symbolRE.test(val)) {
2730
- const [, string] = symbolRE.exec(val);
2731
- return Symbol.for(string);
2732
- } else if (specialTypeRE.test(val)) {
2733
- const [, type, string, , details] = specialTypeRE.exec(val);
2734
- const result = new import_devtools_shared6.target[type](string);
2735
- if (type === "Error" && details)
2736
- result.stack = details;
2737
- return result;
2738
- } else {
2739
- return val;
2740
- }
2543
+ function isPrimitive(data) {
2544
+ if (data == null)
2545
+ return true;
2546
+ const type = typeof data;
2547
+ return type === "string" || type === "number" || type === "boolean";
2741
2548
  }
2742
- function reviver(key, value) {
2743
- return revive(value);
2549
+ function isRef2(raw) {
2550
+ return !!raw.__v_isRef;
2744
2551
  }
2745
-
2746
- // src/shared/transfer.ts
2747
- init_cjs_shims();
2748
- var MAX_SERIALIZED_SIZE = 512 * 1024;
2749
- function encode(data, replacer, list, seen) {
2750
- let stored, key, value, i, l;
2751
- const seenIndex = seen.get(data);
2752
- if (seenIndex != null)
2753
- return seenIndex;
2754
- const index = list.length;
2755
- const proto = Object.prototype.toString.call(data);
2756
- if (proto === "[object Object]") {
2757
- stored = {};
2758
- seen.set(data, index);
2759
- list.push(stored);
2760
- const keys = Object.keys(data);
2761
- for (i = 0, l = keys.length; i < l; i++) {
2762
- key = keys[i];
2763
- try {
2764
- if (key === "compilerOptions")
2765
- return;
2766
- value = data[key];
2767
- if (replacer)
2768
- value = replacer.call(data, key, value);
2769
- } catch (e) {
2770
- value = e;
2771
- }
2772
- stored[key] = encode(value, replacer, list, seen);
2773
- }
2774
- } else if (proto === "[object Array]") {
2775
- stored = [];
2776
- seen.set(data, index);
2777
- list.push(stored);
2778
- for (i = 0, l = data.length; i < l; i++) {
2779
- try {
2780
- value = data[i];
2781
- if (replacer)
2782
- value = replacer.call(data, i, value);
2783
- } catch (e) {
2784
- value = e;
2785
- }
2786
- stored[i] = encode(value, replacer, list, seen);
2787
- }
2788
- } else {
2789
- list.push(data);
2790
- }
2791
- return index;
2552
+ function isComputed(raw) {
2553
+ return isRef2(raw) && !!raw.effect;
2792
2554
  }
2793
- function decode(list, reviver2 = null) {
2794
- let i = list.length;
2795
- let j, k, data, key, value, proto;
2796
- while (i--) {
2797
- data = list[i];
2798
- proto = Object.prototype.toString.call(data);
2799
- if (proto === "[object Object]") {
2800
- const keys = Object.keys(data);
2801
- for (j = 0, k = keys.length; j < k; j++) {
2802
- key = keys[j];
2803
- value = list[data[key]];
2804
- if (reviver2)
2805
- value = reviver2.call(data, key, value);
2806
- data[key] = value;
2807
- }
2808
- } else if (proto === "[object Array]") {
2809
- for (j = 0, k = data.length; j < k; j++) {
2810
- value = list[data[j]];
2811
- if (reviver2)
2812
- value = reviver2.call(data, j, value);
2813
- data[j] = value;
2814
- }
2815
- }
2816
- }
2555
+ function isReactive2(raw) {
2556
+ return !!raw.__v_isReactive;
2817
2557
  }
2818
- function stringifyCircularAutoChunks(data, replacer = null, space = null) {
2819
- let result;
2820
- try {
2821
- result = arguments.length === 1 ? JSON.stringify(data) : JSON.stringify(data, replacer, space);
2822
- } catch (e) {
2823
- result = stringifyStrictCircularAutoChunks(data, replacer, space);
2824
- }
2825
- if (result.length > MAX_SERIALIZED_SIZE) {
2826
- const chunkCount = Math.ceil(result.length / MAX_SERIALIZED_SIZE);
2827
- const chunks = [];
2828
- for (let i = 0; i < chunkCount; i++)
2829
- chunks.push(result.slice(i * MAX_SERIALIZED_SIZE, (i + 1) * MAX_SERIALIZED_SIZE));
2830
- return chunks;
2831
- }
2832
- return result;
2558
+ function isReadOnly(raw) {
2559
+ return !!raw.__v_isReadonly;
2833
2560
  }
2834
- function stringifyStrictCircularAutoChunks(data, replacer = null, space = null) {
2835
- const list = [];
2836
- encode(data, replacer, list, /* @__PURE__ */ new Map());
2837
- return space ? ` ${JSON.stringify(list, null, space)}` : ` ${JSON.stringify(list)}`;
2561
+
2562
+ // src/core/component/state/util.ts
2563
+ var tokenMap = {
2564
+ [UNDEFINED]: "undefined",
2565
+ [NAN]: "NaN",
2566
+ [INFINITY]: "Infinity",
2567
+ [NEGATIVE_INFINITY]: "-Infinity"
2568
+ };
2569
+ var reversedTokenMap = Object.entries(tokenMap).reduce((acc, [key, value]) => {
2570
+ acc[value] = key;
2571
+ return acc;
2572
+ }, {});
2573
+ function internalStateTokenToString(value) {
2574
+ if (value === null)
2575
+ return "null";
2576
+ return typeof value === "string" && tokenMap[value] || false;
2838
2577
  }
2839
- function parseCircularAutoChunks(data, reviver2 = null) {
2840
- if (Array.isArray(data))
2841
- data = data.join("");
2842
- const hasCircular = /^\s/.test(data);
2843
- if (!hasCircular) {
2844
- return arguments.length === 1 ? JSON.parse(data) : JSON.parse(data, reviver2);
2845
- } else {
2846
- const list = JSON.parse(data);
2847
- decode(list, reviver2);
2848
- return list[0];
2849
- }
2578
+ function replaceTokenToString(value) {
2579
+ const replaceRegex = new RegExp(`"(${Object.keys(tokenMap).join("|")})"`, "g");
2580
+ return value.replace(replaceRegex, (_, g1) => tokenMap[g1]);
2850
2581
  }
2851
-
2852
- // src/core/component/state/format.ts
2853
- init_cjs_shims();
2854
- function getInspectorStateValueType(value, raw = true) {
2855
- const type = typeof value;
2856
- if (value == null || value === UNDEFINED) {
2582
+ function replaceStringToToken(value) {
2583
+ const literalValue = reversedTokenMap[value.trim()];
2584
+ if (literalValue)
2585
+ return `"${literalValue}"`;
2586
+ const replaceRegex = new RegExp(`:\\s*(${Object.keys(reversedTokenMap).join("|")})`, "g");
2587
+ return value.replace(replaceRegex, (_, g1) => `:"${reversedTokenMap[g1]}"`);
2588
+ }
2589
+ function getPropType(type) {
2590
+ if (Array.isArray(type))
2591
+ return type.map((t) => getPropType(t)).join(" or ");
2592
+ if (type == null)
2857
2593
  return "null";
2858
- } else if (type === "boolean" || type === "number" || value === INFINITY || value === NEGATIVE_INFINITY || value === NAN) {
2859
- return "literal";
2860
- } else if (value == null ? void 0 : value._custom) {
2861
- if (raw || value._custom.display != null || value._custom.displayText != null)
2862
- return "custom";
2863
- else
2864
- return getInspectorStateValueType(value._custom.value);
2865
- } else if (typeof value === "string") {
2866
- const typeMatch = specialTypeRE.exec(value);
2867
- if (typeMatch) {
2868
- const [, type2] = typeMatch;
2869
- return `native ${type2}`;
2870
- } else {
2871
- return "string";
2872
- }
2873
- } else if (Array.isArray(value) || (value == null ? void 0 : value._isArray)) {
2874
- return "array";
2875
- } else if (isPlainObject(value)) {
2876
- return "plain-object";
2877
- } else {
2878
- return "unknown";
2879
- }
2594
+ const match = type.toString().match(fnTypeRE);
2595
+ return typeof type === "function" ? match && match[1] || "any" : "any";
2880
2596
  }
2881
- function formatInspectorStateValue(value, quotes = false) {
2882
- var _a9, _b9;
2883
- let result;
2884
- const type = getInspectorStateValueType(value, false);
2885
- if (type !== "custom" && (value == null ? void 0 : value._custom))
2886
- value = value._custom.value;
2887
- if (result = internalStateTokenToString(value)) {
2888
- return result;
2889
- } else if (type === "custom") {
2890
- const nestedName = ((_a9 = value._custom.value) == null ? void 0 : _a9._custom) && formatInspectorStateValue(value._custom.value);
2891
- return nestedName || value._custom.displayText || value._custom.display;
2892
- } else if (type === "array") {
2893
- return `Array[${value.length}]`;
2894
- } else if (type === "plain-object") {
2895
- return `Object${Object.keys(value).length ? "" : " (empty)"}`;
2896
- } else if (type == null ? void 0 : type.includes("native")) {
2897
- return escape((_b9 = specialTypeRE.exec(value)) == null ? void 0 : _b9[2]);
2898
- } else if (typeof value === "string") {
2899
- const typeMatch = value.match(rawTypeRE);
2900
- if (typeMatch)
2901
- value = escape(typeMatch[1]);
2902
- else if (quotes)
2903
- value = `<span>"</span>${escape(value)}<span>"</span>`;
2904
- else
2905
- value = escape(value);
2906
- value = value.replace(/ /g, "&nbsp;").replace(/\n/g, "<span>\\n</span>");
2597
+ function sanitize(data) {
2598
+ if (!isPrimitive(data) && !Array.isArray(data) && !isPlainObject(data)) {
2599
+ return Object.prototype.toString.call(data);
2600
+ } else {
2601
+ return data;
2907
2602
  }
2908
- return value;
2909
2603
  }
2910
- function getRawValue(value) {
2911
- var _a9, _b9;
2912
- const isCustom = getInspectorStateValueType(value) === "custom";
2913
- let inherit = {};
2914
- if (isCustom) {
2915
- const data = value;
2916
- const customValue = (_a9 = data._custom) == null ? void 0 : _a9.value;
2917
- const nestedCustom = typeof customValue === "object" && customValue !== null && "_custom" in customValue ? getRawValue(customValue) : { inherit: void 0, value: void 0 };
2918
- inherit = nestedCustom.inherit || ((_b9 = data._custom) == null ? void 0 : _b9.fields) || {};
2919
- value = nestedCustom.value || customValue;
2920
- }
2921
- if (value && value._isArray)
2922
- value = value.items;
2923
- return { value, inherit };
2604
+ function getSetupStateType(raw) {
2605
+ return {
2606
+ ref: isRef2(raw),
2607
+ computed: isComputed(raw),
2608
+ reactive: isReactive2(raw),
2609
+ readonly: isReadOnly(raw)
2610
+ };
2924
2611
  }
2925
- function toEdit(value) {
2926
- return replaceTokenToString(JSON.stringify(value));
2612
+ function toRaw2(value) {
2613
+ if (value == null ? void 0 : value.__v_raw)
2614
+ return value.__v_raw;
2615
+ return value;
2927
2616
  }
2928
- function toSubmit(value) {
2929
- return JSON.parse(replaceStringToToken(value), reviver);
2617
+ function escape(s) {
2618
+ return s.replace(/[<>"&]/g, (s2) => {
2619
+ return ESC[s2] || s2;
2620
+ });
2930
2621
  }
2931
2622
 
2932
- // src/shared/util.ts
2933
- function stringify(data) {
2934
- return stringifyCircularAutoChunks(data, stringifyReplacer);
2623
+ // src/core/component/state/process.ts
2624
+ function mergeOptions(to, from, instance) {
2625
+ if (typeof from === "function")
2626
+ from = from.options;
2627
+ if (!from)
2628
+ return to;
2629
+ const { mixins, extends: extendsOptions } = from;
2630
+ extendsOptions && mergeOptions(to, extendsOptions, instance);
2631
+ mixins && mixins.forEach(
2632
+ (m) => mergeOptions(to, m, instance)
2633
+ );
2634
+ for (const key of ["computed", "inject"]) {
2635
+ if (Object.prototype.hasOwnProperty.call(from, key)) {
2636
+ if (!to[key])
2637
+ to[key] = from[key];
2638
+ else
2639
+ Object.assign(to[key], from[key]);
2640
+ }
2641
+ }
2642
+ return to;
2935
2643
  }
2936
- function parse(data, revive2 = false) {
2937
- if (data == void 0)
2938
- return {};
2939
- return revive2 ? parseCircularAutoChunks(data, reviver) : parseCircularAutoChunks(data);
2644
+ function resolveMergedOptions(instance) {
2645
+ const raw = instance.type;
2646
+ const { mixins, extends: extendsOptions } = raw;
2647
+ const globalMixins = instance.appContext.mixins;
2648
+ if (!globalMixins.length && !mixins && !extendsOptions)
2649
+ return raw;
2650
+ const options = {};
2651
+ globalMixins.forEach((m) => mergeOptions(options, m, instance));
2652
+ mergeOptions(options, raw, instance);
2653
+ return options;
2940
2654
  }
2941
-
2942
- // src/shared/time.ts
2943
- init_cjs_shims();
2944
- function now() {
2945
- return Date.now();
2946
- }
2947
-
2948
- // src/shared/env.ts
2949
- init_cjs_shims();
2950
-
2951
- // src/core/general/inspector.ts
2952
- init_cjs_shims();
2953
- function addInspector(payload) {
2954
- devtoolsContext.inspector.push(payload);
2955
- }
2956
- function getInspector(inspectorId) {
2957
- return devtoolsContext.inspector.find((inspector) => inspector.id === inspectorId);
2958
- }
2959
- function updateInspector(inspectorId, payload) {
2960
- const inspector = getInspector(inspectorId);
2961
- inspector && Object.assign(inspector, payload);
2962
- }
2963
-
2964
- // src/core/timeline/index.ts
2965
- init_cjs_shims();
2966
- function addTimelineLayer(payload) {
2967
- devtoolsContext.timelineLayer.push(payload);
2968
- }
2969
-
2970
- // src/core/component/state/editor.ts
2971
- init_cjs_shims();
2972
- var import_vue2 = require("vue");
2973
-
2974
- // src/core/component/general/index.ts
2975
- init_cjs_shims();
2976
-
2977
- // src/core/component/state/editor.ts
2978
- var StateEditor = class {
2979
- constructor() {
2980
- this.refEditor = new RefStateEditor();
2981
- }
2982
- set(object, path, value, cb) {
2983
- const sections = Array.isArray(path) ? path : path.split(".");
2984
- const markRef = false;
2985
- while (sections.length > 1) {
2986
- const section = sections.shift();
2987
- object = object[section];
2988
- if (this.refEditor.isRef(object))
2989
- object = this.refEditor.get(object);
2990
- }
2991
- const field = sections[0];
2992
- const item = this.refEditor.get(object)[field];
2993
- if (cb) {
2994
- cb(object, field, value);
2995
- } else {
2996
- if (this.refEditor.isRef(item))
2997
- this.refEditor.set(item, value);
2998
- else if (markRef)
2999
- object[field] = value;
3000
- else
3001
- object[field] = value;
3002
- }
3003
- }
3004
- get(object, path) {
3005
- const sections = Array.isArray(path) ? path : path.split(".");
3006
- for (let i = 0; i < sections.length; i++) {
3007
- object = object[sections[i]];
3008
- if (this.refEditor.isRef(object))
3009
- object = this.refEditor.get(object);
3010
- if (!object)
3011
- return void 0;
3012
- }
3013
- return object;
3014
- }
3015
- has(object, path, parent = false) {
3016
- if (typeof object === "undefined")
3017
- return false;
3018
- const sections = Array.isArray(path) ? path.slice() : path.split(".");
3019
- const size = !parent ? 1 : 2;
3020
- while (object && sections.length > size) {
3021
- const section = sections.shift();
3022
- object = object[section];
3023
- if (this.refEditor.isRef(object))
3024
- object = this.refEditor.get(object);
3025
- }
3026
- return object != null && Object.prototype.hasOwnProperty.call(object, sections[0]);
3027
- }
3028
- createDefaultSetCallback(state) {
3029
- return (object, field, value) => {
3030
- if (state.remove || state.newKey) {
3031
- if (Array.isArray(object))
3032
- object.splice(field, 1);
3033
- else if ((0, import_vue2.toRaw)(object) instanceof Map && typeof value === "object" && value && "key" in value)
3034
- object.delete(value.key);
3035
- else if ((0, import_vue2.toRaw)(object) instanceof Set)
3036
- object.delete(value);
3037
- else
3038
- Reflect.deleteProperty(object, field);
3039
- }
3040
- if (!state.remove) {
3041
- const target8 = object[state.newKey || field];
3042
- if (this.refEditor.isRef(target8))
3043
- this.refEditor.set(target8, value);
3044
- else
3045
- object[state.newKey || field] = value;
3046
- }
3047
- };
3048
- }
3049
- };
3050
- var RefStateEditor = class {
3051
- set(ref, value) {
3052
- if ((0, import_vue2.isRef)(ref)) {
3053
- ref.value = value;
3054
- } else {
3055
- const previousKeys = Object.keys(ref);
3056
- const currentKeys = Object.keys(value);
3057
- if (previousKeys.length > currentKeys.length) {
3058
- const diffKeys = previousKeys.filter((key) => !currentKeys.includes(key));
3059
- diffKeys.forEach((key) => Reflect.deleteProperty(ref, key));
3060
- }
3061
- currentKeys.forEach((key) => {
3062
- Reflect.set(ref, key, Reflect.get(value, key));
3063
- });
3064
- }
3065
- }
3066
- get(ref) {
3067
- return (0, import_vue2.isRef)(ref) ? ref.value : ref;
3068
- }
3069
- isRef(ref) {
3070
- return (0, import_vue2.isRef)(ref) || (0, import_vue2.isReactive)(ref);
3071
- }
3072
- };
3073
- async function editComponentState(payload, stateEditor2) {
3074
- const { path, nodeId, state, type } = payload;
3075
- const instance = getComponentInstance(devtoolsContext.appRecord, nodeId);
3076
- if (!instance)
3077
- return;
3078
- const targetPath = path.slice();
3079
- let target8;
3080
- if (instance.devtoolsRawSetupState && Object.keys(instance.devtoolsRawSetupState).includes(path[0])) {
3081
- target8 = instance.devtoolsRawSetupState;
3082
- }
3083
- if (target8 && targetPath) {
3084
- if (state.type === "object" && type === "reactive") {
3085
- }
3086
- stateEditor2.set(target8, targetPath, state.value, stateEditor2.createDefaultSetCallback(state));
2655
+ function processProps(instance) {
2656
+ const props = [];
2657
+ const propDefinitions = instance.type.props;
2658
+ for (const key in instance.props) {
2659
+ const propDefinition = propDefinitions ? propDefinitions[key] : null;
2660
+ const camelizeKey = (0, import_devtools_shared6.camelize)(key);
2661
+ props.push({
2662
+ type: "props",
2663
+ key: camelizeKey,
2664
+ value: returnError(() => instance.props[key]),
2665
+ meta: propDefinition ? {
2666
+ type: propDefinition.type ? getPropType(propDefinition.type) : "any",
2667
+ required: !!propDefinition.required,
2668
+ ...propDefinition.default ? {
2669
+ default: propDefinition.default.toString()
2670
+ } : {}
2671
+ } : { type: "invalid" }
2672
+ });
3087
2673
  }
2674
+ return props;
3088
2675
  }
3089
- var stateEditor = new StateEditor();
3090
- async function editState(payload) {
3091
- editComponentState(payload, stateEditor);
3092
- }
3093
-
3094
- // src/core/open-in-editor/index.ts
3095
- init_cjs_shims();
3096
- var import_devtools_shared7 = require("@vue/devtools-shared");
3097
- function openInEditor(options = {}) {
3098
- const { file, line = 0, column = 0 } = options;
3099
- if (file) {
3100
- const baseUrl = window.location.origin;
3101
- if (import_devtools_shared7.target.__VUE_DEVTOOLS_VITE_PLUGIN_DETECTED__) {
3102
- import_devtools_shared7.target.__VUE_INSPECTOR__.openInEditor(baseUrl, file, line, column);
3103
- } else {
3104
- }
3105
- }
2676
+ function processState(instance) {
2677
+ const type = instance.type;
2678
+ const props = type.props;
2679
+ const getters = type.vuex && type.vuex.getters;
2680
+ const computedDefs = type.computed;
2681
+ const data = {
2682
+ ...instance.data,
2683
+ ...instance.renderContext
2684
+ };
2685
+ return Object.keys(data).filter((key) => !(props && key in props) && !(getters && key in getters) && !(computedDefs && key in computedDefs)).map((key) => ({
2686
+ key,
2687
+ type: "data",
2688
+ value: returnError(() => data[key]),
2689
+ editable: true
2690
+ }));
3106
2691
  }
3107
-
3108
- // src/core/general/app-record.ts
3109
- init_cjs_shims();
3110
-
3111
- // src/core/plugins/index.ts
3112
- init_cjs_shims();
3113
-
3114
- // src/core/plugins/components.ts
3115
- init_cjs_shims();
3116
- var import_perfect_debounce3 = require("perfect-debounce");
3117
-
3118
- // src/api/plugin.ts
3119
- init_cjs_shims();
3120
- var import_devtools_schema2 = require("@vue/devtools-schema");
3121
- function collectRegisteredPlugin(pluginDescriptor, setupFn) {
3122
- devtoolsState.pluginBuffer.push([pluginDescriptor, setupFn]);
2692
+ function getStateTypeAndName(info) {
2693
+ const stateType = info.computed ? "computed" : info.ref ? "ref" : info.reactive ? "reactive" : null;
2694
+ const stateTypeName = stateType ? `${stateType.charAt(0).toUpperCase()}${stateType.slice(1)}` : null;
2695
+ return {
2696
+ stateType,
2697
+ stateTypeName
2698
+ };
3123
2699
  }
3124
- async function registerPlugin(options) {
3125
- const { app, api } = options;
3126
- const plugins = devtoolsState.pluginBuffer.filter(([plugin]) => plugin.app === app);
3127
- plugins.forEach(async ([plugin, setupFn]) => {
3128
- if (plugin.packageName === "vue-query") {
3129
- return;
3130
- }
3131
- const appRecord = await getAppRecord(plugin.app);
3132
- if (plugin.packageName === "vue-router") {
3133
- const id = getRouterDevToolsId(`${plugin.id}`);
3134
- if (plugin.app === app) {
3135
- devtoolsState.appRecords = devtoolsState.appRecords.map((item) => ({
3136
- ...item,
3137
- routerId: id
3138
- }));
3139
- }
2700
+ function processSetupState(instance) {
2701
+ const raw = instance.devtoolsRawSetupState || {};
2702
+ return Object.keys(instance.setupState).filter((key) => !vueBuiltins.has(key) && key.split(/(?=[A-Z])/)[0] !== "use").map((key) => {
2703
+ var _a10, _b10, _c, _d;
2704
+ const value = returnError(() => toRaw2(instance.setupState[key]));
2705
+ const rawData = raw[key];
2706
+ let result;
2707
+ let isOtherType = typeof value === "function" || typeof (value == null ? void 0 : value.render) === "function" || typeof (value == null ? void 0 : value.__asyncLoader) === "function";
2708
+ if (rawData) {
2709
+ const info = getSetupStateType(rawData);
2710
+ const { stateType, stateTypeName } = getStateTypeAndName(info);
2711
+ const isState = info.ref || info.computed || info.reactive;
2712
+ const raw2 = ((_b10 = (_a10 = rawData.effect) == null ? void 0 : _a10.raw) == null ? void 0 : _b10.toString()) || ((_d = (_c = rawData.effect) == null ? void 0 : _c.fn) == null ? void 0 : _d.toString());
2713
+ if (stateType)
2714
+ isOtherType = false;
2715
+ result = {
2716
+ ...stateType ? { stateType, stateTypeName } : {},
2717
+ ...raw2 ? { raw: raw2 } : {},
2718
+ editable: isState && !info.readonly
2719
+ };
3140
2720
  }
3141
- setupFn(api);
3142
- });
3143
- devtoolsState.appRecords = devtoolsState.appRecords.map((record) => {
3144
- var _a9, _b9;
3145
- const globalProperties = (_b9 = (_a9 = record.app) == null ? void 0 : _a9.config) == null ? void 0 : _b9.globalProperties;
3146
- if (!globalProperties)
3147
- return record;
2721
+ const type = isOtherType ? "setup (other)" : "setup";
3148
2722
  return {
3149
- ...record,
3150
- moduleDetectives: {
3151
- vueRouter: !!globalProperties.$router,
3152
- pinia: !!globalProperties.$pinia,
3153
- vueI18n: !!globalProperties.$i18n
3154
- }
2723
+ key,
2724
+ value,
2725
+ type,
2726
+ // @ts-expect-error ignore
2727
+ ...result
3155
2728
  };
3156
2729
  });
3157
2730
  }
3158
- function setupDevToolsPlugin(pluginDescriptor, setupFn) {
3159
- return devtoolsHooks.callHook(import_devtools_schema2.DevToolsHooks.SETUP_DEVTOOLS_PLUGIN, pluginDescriptor, setupFn);
2731
+ function processComputed(instance, mergedType) {
2732
+ const type = mergedType;
2733
+ const computed = [];
2734
+ const defs = type.computed || {};
2735
+ for (const key in defs) {
2736
+ const def = defs[key];
2737
+ const type2 = typeof def === "function" && def.vuex ? "vuex bindings" : "computed";
2738
+ computed.push({
2739
+ type: type2,
2740
+ key,
2741
+ value: returnError(() => {
2742
+ var _a10;
2743
+ return (_a10 = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a10[key];
2744
+ }),
2745
+ editable: typeof def.set === "function"
2746
+ });
2747
+ }
2748
+ return computed;
3160
2749
  }
3161
-
3162
- // src/core/component/tree/walker.ts
3163
- init_cjs_shims();
3164
-
3165
- // src/core/component/tree/el.ts
3166
- init_cjs_shims();
3167
- function getRootElementsFromComponentInstance(instance) {
3168
- if (isFragment(instance))
3169
- return getFragmentRootElements(instance.subTree);
3170
- if (!instance.subTree)
3171
- return [];
3172
- return [instance.subTree.el];
2750
+ function processAttrs(instance) {
2751
+ return Object.keys(instance.attrs).map((key) => ({
2752
+ type: "attrs",
2753
+ key,
2754
+ value: returnError(() => instance.attrs[key])
2755
+ }));
3173
2756
  }
3174
- function getFragmentRootElements(vnode) {
3175
- if (!vnode.children)
3176
- return [];
3177
- const list = [];
3178
- vnode.children.forEach((childVnode) => {
3179
- if (childVnode.component)
3180
- list.push(...getRootElementsFromComponentInstance(childVnode.component));
3181
- else if (childVnode == null ? void 0 : childVnode.el)
3182
- list.push(childVnode.el);
3183
- });
3184
- return list;
2757
+ function processProvide(instance) {
2758
+ return Reflect.ownKeys(instance.provides).map((key) => ({
2759
+ type: "provided",
2760
+ key: key.toString(),
2761
+ value: returnError(() => instance.provides[key])
2762
+ }));
3185
2763
  }
3186
-
3187
- // src/core/component/tree/filter.ts
3188
- init_cjs_shims();
3189
- var import_devtools_shared8 = require("@vue/devtools-shared");
3190
- var ComponentFilter = class {
3191
- constructor(filter) {
3192
- this.filter = filter || "";
3193
- }
3194
- /**
3195
- * Check if an instance is qualified.
3196
- *
3197
- * @param {Vue|Vnode} instance
3198
- * @return {boolean}
3199
- */
3200
- isQualified(instance) {
3201
- const name = getInstanceName(instance);
3202
- return (0, import_devtools_shared8.classify)(name).toLowerCase().includes(this.filter) || (0, import_devtools_shared8.kebabize)(name).toLowerCase().includes(this.filter);
2764
+ function processInject(instance, mergedType) {
2765
+ if (!(mergedType == null ? void 0 : mergedType.inject))
2766
+ return [];
2767
+ let keys = [];
2768
+ let defaultValue;
2769
+ if (Array.isArray(mergedType.inject)) {
2770
+ keys = mergedType.inject.map((key) => ({
2771
+ key,
2772
+ originalKey: key
2773
+ }));
2774
+ } else {
2775
+ keys = Reflect.ownKeys(mergedType.inject).map((key) => {
2776
+ const value = mergedType.inject[key];
2777
+ let originalKey;
2778
+ if (typeof value === "string" || typeof value === "symbol") {
2779
+ originalKey = value;
2780
+ } else {
2781
+ originalKey = value.from;
2782
+ defaultValue = value.default;
2783
+ }
2784
+ return {
2785
+ key,
2786
+ originalKey
2787
+ };
2788
+ });
3203
2789
  }
3204
- };
3205
- function createComponentFilter(filterText) {
3206
- return new ComponentFilter(filterText);
2790
+ return keys.map(({ key, originalKey }) => ({
2791
+ type: "injected",
2792
+ key: originalKey && key !== originalKey ? `${originalKey.toString()} \u279E ${key.toString()}` : key.toString(),
2793
+ // eslint-disable-next-line no-prototype-builtins
2794
+ value: returnError(() => instance.ctx.hasOwnProperty(key) ? instance.ctx[key] : instance.provides.hasOwnProperty(originalKey) ? instance.provides[originalKey] : defaultValue)
2795
+ }));
3207
2796
  }
3208
-
3209
- // src/core/component/tree/walker.ts
3210
- var ComponentWalker = class {
3211
- constructor(options) {
3212
- // Dedupe instances (Some instances may be both on a component and on a child abstract/functional component)
3213
- this.captureIds = /* @__PURE__ */ new Map();
3214
- const { filterText = "", maxDepth, recursively } = options;
3215
- this.componentFilter = createComponentFilter(filterText);
3216
- this.maxDepth = maxDepth;
3217
- this.recursively = recursively;
3218
- }
3219
- getComponentTree(instance) {
3220
- this.captureIds = /* @__PURE__ */ new Map();
3221
- return this.findQualifiedChildren(instance, 0);
3222
- }
3223
- getComponentParents(instance) {
3224
- this.captureIds = /* @__PURE__ */ new Map();
3225
- const parents = [];
3226
- this.captureId(instance);
3227
- let parent = instance;
3228
- while (parent = parent.parent) {
3229
- this.captureId(parent);
3230
- parents.push(parent);
2797
+ function processRefs(instance) {
2798
+ return Object.keys(instance.refs).map((key) => ({
2799
+ type: "refs",
2800
+ key,
2801
+ value: returnError(() => instance.refs[key])
2802
+ }));
2803
+ }
2804
+ function processEventListeners(instance) {
2805
+ var _a10;
2806
+ const emitsDefinition = instance.type.emits;
2807
+ const declaredEmits = Array.isArray(emitsDefinition) ? emitsDefinition : Object.keys(emitsDefinition != null ? emitsDefinition : {});
2808
+ const keys = Object.keys((_a10 = instance.vnode.props) != null ? _a10 : {});
2809
+ const result = [];
2810
+ for (const key of keys) {
2811
+ const [prefix, ...eventNameParts] = key.split(/(?=[A-Z])/);
2812
+ if (prefix === "on") {
2813
+ const eventName = eventNameParts.join("-").toLowerCase();
2814
+ const isDeclared = declaredEmits.includes(eventName);
2815
+ result.push({
2816
+ type: "event listeners",
2817
+ key: eventName,
2818
+ value: {
2819
+ _custom: {
2820
+ displayText: isDeclared ? "\u2705 Declared" : "\u26A0\uFE0F Not declared",
2821
+ key: isDeclared ? "\u2705 Declared" : "\u26A0\uFE0F Not declared",
2822
+ value: isDeclared ? "\u2705 Declared" : "\u26A0\uFE0F Not declared",
2823
+ tooltipText: !isDeclared ? `The event <code>${eventName}</code> is not declared in the <code>emits</code> option. It will leak into the component's attributes (<code>$attrs</code>).` : null
2824
+ }
2825
+ }
2826
+ });
3231
2827
  }
3232
- return parents;
3233
2828
  }
3234
- captureId(instance) {
3235
- if (!instance)
3236
- return null;
3237
- const id = instance.__VUE_DEVTOOLS_UID__ != null ? instance.__VUE_DEVTOOLS_UID__ : getUniqueComponentId(instance);
3238
- instance.__VUE_DEVTOOLS_UID__ = id;
3239
- if (this.captureIds.has(id))
3240
- return null;
3241
- else
3242
- this.captureIds.set(id, void 0);
3243
- this.mark(instance);
3244
- return id;
3245
- }
3246
- /**
3247
- * Capture the meta information of an instance. (recursive)
3248
- *
3249
- * @param {Vue} instance
3250
- * @return {object}
3251
- */
3252
- async capture(instance, depth) {
3253
- var _a9;
3254
- if (!instance)
3255
- return null;
3256
- const id = this.captureId(instance);
3257
- const name = getInstanceName(instance);
3258
- const children = this.getInternalInstanceChildren(instance.subTree).filter((child) => !isBeingDestroyed(child));
3259
- const parents = this.getComponentParents(instance) || [];
3260
- const inactive = !!instance.isDeactivated || parents.some((parent) => parent.isDeactivated);
3261
- const treeNode = {
3262
- uid: instance.uid,
3263
- id,
3264
- name,
3265
- renderKey: getRenderKey(instance.vnode ? instance.vnode.key : null),
3266
- inactive,
3267
- children: [],
3268
- isFragment: isFragment(instance),
3269
- tags: typeof instance.type !== "function" ? [] : [
3270
- {
3271
- label: "functional",
3272
- textColor: 5592405,
3273
- backgroundColor: 15658734
2829
+ return result;
2830
+ }
2831
+ function processInstanceState(instance) {
2832
+ const mergedType = resolveMergedOptions(instance);
2833
+ return processProps(instance).concat(
2834
+ processState(instance),
2835
+ processSetupState(instance),
2836
+ processComputed(instance, mergedType),
2837
+ processAttrs(instance),
2838
+ processProvide(instance),
2839
+ processInject(instance, mergedType),
2840
+ processRefs(instance),
2841
+ processEventListeners(instance)
2842
+ );
2843
+ }
2844
+
2845
+ // src/core/component/state/index.ts
2846
+ function getInstanceState(params) {
2847
+ var _a10;
2848
+ const instance = getComponentInstance(devtoolsContext.appRecord, params.instanceId);
2849
+ const id = getUniqueComponentId(instance);
2850
+ const name = getInstanceName(instance);
2851
+ const file = (_a10 = instance == null ? void 0 : instance.type) == null ? void 0 : _a10.__file;
2852
+ const state = processInstanceState(instance);
2853
+ return {
2854
+ id,
2855
+ name,
2856
+ file,
2857
+ state,
2858
+ instance
2859
+ };
2860
+ }
2861
+
2862
+ // src/plugins/component.ts
2863
+ var INSPECTOR_ID = "components";
2864
+ function registerComponentDevToolsPlugin(app) {
2865
+ setupDevToolsPlugin({
2866
+ id: INSPECTOR_ID,
2867
+ label: "Components",
2868
+ app
2869
+ }, (api) => {
2870
+ api.addInspector({
2871
+ id: INSPECTOR_ID,
2872
+ label: "Components",
2873
+ treeFilterPlaceholder: "Search components"
2874
+ });
2875
+ api.on.getComponentBoundingRect((payload) => {
2876
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
2877
+ const instance = getComponentInstance(devtoolsContext.appRecord, payload.instanceId);
2878
+ if (instance) {
2879
+ if (typeof DOMRect === "undefined")
2880
+ return;
2881
+ payload.rect = getComponentBoundingRect(instance);
2882
+ if (payload.rect instanceof DOMRect) {
2883
+ payload.rect = {
2884
+ top: payload.rect.top,
2885
+ left: payload.rect.left,
2886
+ right: payload.rect.right,
2887
+ bottom: payload.rect.bottom,
2888
+ width: payload.rect.width,
2889
+ height: payload.rect.height
2890
+ };
2891
+ }
3274
2892
  }
3275
- ],
3276
- autoOpen: this.recursively,
3277
- file: instance.type.__file || ""
3278
- };
3279
- if (depth < this.maxDepth || instance.type.__isKeepAlive || parents.some((parent) => parent.type.__isKeepAlive)) {
3280
- treeNode.children = await Promise.all(children.map((child) => this.capture(child, depth + 1)).filter(Boolean));
3281
- }
3282
- if (this.isKeepAlive(instance)) {
3283
- const cachedComponents = this.getKeepAliveCachedInstances(instance);
3284
- const childrenIds = children.map((child) => child.__VUE_DEVTOOLS_UID__);
3285
- for (const cachedChild of cachedComponents) {
3286
- if (!childrenIds.includes(cachedChild.__VUE_DEVTOOLS_UID__)) {
3287
- const node = await this.capture({ ...cachedChild, isDeactivated: true }, depth + 1);
3288
- if (node)
3289
- treeNode.children.push(node);
2893
+ }
2894
+ });
2895
+ api.on.getInspectorTree(async (payload) => {
2896
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
2897
+ const instance = getComponentInstance(devtoolsContext.appRecord, payload.instanceId);
2898
+ if (instance) {
2899
+ const walker = new ComponentWalker({
2900
+ filterText: payload.filter,
2901
+ // @TODO: should make this configurable?
2902
+ maxDepth: 100,
2903
+ recursively: false
2904
+ });
2905
+ payload.rootNodes = await walker.getComponentTree(instance);
3290
2906
  }
3291
2907
  }
3292
- }
3293
- const rootElements = getRootElementsFromComponentInstance(instance);
3294
- const firstElement = rootElements[0];
3295
- if (firstElement == null ? void 0 : firstElement.parentElement) {
3296
- const parentInstance = instance.parent;
3297
- const parentRootElements = parentInstance ? getRootElementsFromComponentInstance(parentInstance) : [];
3298
- let el = firstElement;
3299
- const indexList = [];
3300
- do {
3301
- indexList.push(Array.from(el.parentElement.childNodes).indexOf(el));
3302
- el = el.parentElement;
3303
- } while (el.parentElement && parentRootElements.length && !parentRootElements.includes(el));
3304
- treeNode.domOrder = indexList.reverse();
3305
- } else {
3306
- treeNode.domOrder = [-1];
3307
- }
3308
- if ((_a9 = instance.suspense) == null ? void 0 : _a9.suspenseKey) {
3309
- treeNode.tags.push({
3310
- label: instance.suspense.suspenseKey,
3311
- backgroundColor: 14979812,
3312
- textColor: 16777215
3313
- });
3314
- this.mark(instance, true);
3315
- }
3316
- devtoolsContext.api.visitComponentTree({
3317
- treeNode,
3318
- componentInstance: instance,
3319
- app: instance.appContext.app,
3320
- filter: this.componentFilter.filter
3321
- });
3322
- return treeNode;
3323
- }
3324
- /**
3325
- * Find qualified children from a single instance.
3326
- * If the instance itself is qualified, just return itself.
3327
- * This is ok because [].concat works in both cases.
3328
- *
3329
- * @param {Vue|Vnode} instance
3330
- * @return {Vue|Array}
3331
- */
3332
- async findQualifiedChildren(instance, depth) {
3333
- var _a9;
3334
- if (this.componentFilter.isQualified(instance) && !((_a9 = instance.type.devtools) == null ? void 0 : _a9.hide)) {
3335
- return [await this.capture(instance, depth)];
3336
- } else if (instance.subTree) {
3337
- const list = this.isKeepAlive(instance) ? this.getKeepAliveCachedInstances(instance) : this.getInternalInstanceChildren(instance.subTree);
3338
- return this.findQualifiedChildrenFromList(list, depth);
3339
- } else {
3340
- return [];
3341
- }
3342
- }
3343
- /**
3344
- * Iterate through an array of instances and flatten it into
3345
- * an array of qualified instances. This is a depth-first
3346
- * traversal - e.g. if an instance is not matched, we will
3347
- * recursively go deeper until a qualified child is found.
3348
- *
3349
- * @param {Array} instances
3350
- * @return {Array}
3351
- */
3352
- async findQualifiedChildrenFromList(instances, depth) {
3353
- instances = instances.filter((child) => {
3354
- var _a9;
3355
- return !isBeingDestroyed(child) && !((_a9 = child.type.devtools) == null ? void 0 : _a9.hide);
3356
2908
  });
3357
- if (!this.componentFilter.filter)
3358
- return Promise.all(instances.map((child) => this.capture(child, depth)));
3359
- else
3360
- return Array.prototype.concat.apply([], await Promise.all(instances.map((i) => this.findQualifiedChildren(i, depth))));
3361
- }
3362
- /**
3363
- * Get children from a component instance.
3364
- */
3365
- getInternalInstanceChildren(subTree, suspense = null) {
3366
- const list = [];
3367
- if (subTree) {
3368
- if (subTree.component) {
3369
- !suspense ? list.push(subTree.component) : list.push({ ...subTree.component, suspense });
3370
- } else if (subTree.suspense) {
3371
- const suspenseKey = !subTree.suspense.isInFallback ? "suspense default" : "suspense fallback";
3372
- list.push(...this.getInternalInstanceChildren(subTree.suspense.activeBranch, { ...subTree.suspense, suspenseKey }));
3373
- } else if (Array.isArray(subTree.children)) {
3374
- subTree.children.forEach((childSubTree) => {
3375
- if (childSubTree.component)
3376
- !suspense ? list.push(childSubTree.component) : list.push({ ...childSubTree.component, suspense });
3377
- else
3378
- list.push(...this.getInternalInstanceChildren(childSubTree, suspense));
2909
+ api.on.getInspectorState(async (payload) => {
2910
+ var _a10;
2911
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
2912
+ const result = getInstanceState({
2913
+ instanceId: payload.nodeId
3379
2914
  });
2915
+ const componentInstance = result.instance;
2916
+ const app2 = (_a10 = result.instance) == null ? void 0 : _a10.appContext.app;
2917
+ const _payload = {
2918
+ componentInstance,
2919
+ app: app2,
2920
+ instanceData: result
2921
+ };
2922
+ apiHooks.callHookWith((callbacks) => {
2923
+ callbacks.forEach((cb) => cb(_payload));
2924
+ }, "component-state:inspect" /* COMPONENT_STATE_INSPECT */);
2925
+ payload.state = result;
3380
2926
  }
3381
- }
3382
- return list.filter((child) => {
3383
- var _a9;
3384
- return !isBeingDestroyed(child) && !((_a9 = child.type.devtools) == null ? void 0 : _a9.hide);
3385
2927
  });
2928
+ api.on.editInspectorState(async (payload) => {
2929
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
2930
+ editState(payload);
2931
+ await api.sendInspectorState("components");
2932
+ }
2933
+ });
2934
+ const debounceSendInspectorTree = (0, import_perfect_debounce2.debounce)(() => {
2935
+ api.sendInspectorTree(INSPECTOR_ID);
2936
+ }, 120);
2937
+ const debounceSendInspectorState = (0, import_perfect_debounce2.debounce)(() => {
2938
+ api.sendInspectorState(INSPECTOR_ID);
2939
+ }, 120);
2940
+ const componentAddedCleanup = hook.on.componentAdded(async (app2, uid, parentUid, component) => {
2941
+ var _a10, _b10, _c;
2942
+ if ((_c = (_b10 = (_a10 = app2 == null ? void 0 : app2._instance) == null ? void 0 : _a10.type) == null ? void 0 : _b10.devtools) == null ? void 0 : _c.hide)
2943
+ return;
2944
+ if (!app2 || typeof uid !== "number" && !uid || !component)
2945
+ return;
2946
+ const id = await getComponentId({
2947
+ app: app2,
2948
+ uid,
2949
+ instance: component
2950
+ });
2951
+ const appRecord = await getAppRecord(app2);
2952
+ if (component) {
2953
+ if (component.__VUE_DEVTOOLS_UID__ == null)
2954
+ component.__VUE_DEVTOOLS_UID__ = id;
2955
+ if (!(appRecord == null ? void 0 : appRecord.instanceMap.has(id)))
2956
+ appRecord == null ? void 0 : appRecord.instanceMap.set(id, component);
2957
+ }
2958
+ if (!appRecord)
2959
+ return;
2960
+ debounceSendInspectorTree();
2961
+ });
2962
+ const componentUpdatedCleanup = hook.on.componentUpdated(async (app2, uid, parentUid, component) => {
2963
+ var _a10, _b10, _c;
2964
+ if ((_c = (_b10 = (_a10 = app2 == null ? void 0 : app2._instance) == null ? void 0 : _a10.type) == null ? void 0 : _b10.devtools) == null ? void 0 : _c.hide)
2965
+ return;
2966
+ if (!app2 || typeof uid !== "number" && !uid || !component)
2967
+ return;
2968
+ const id = await getComponentId({
2969
+ app: app2,
2970
+ uid,
2971
+ instance: component
2972
+ });
2973
+ const appRecord = await getAppRecord(app2);
2974
+ if (component) {
2975
+ if (component.__VUE_DEVTOOLS_UID__ == null)
2976
+ component.__VUE_DEVTOOLS_UID__ = id;
2977
+ if (!(appRecord == null ? void 0 : appRecord.instanceMap.has(id)))
2978
+ appRecord == null ? void 0 : appRecord.instanceMap.set(id, component);
2979
+ }
2980
+ if (!appRecord)
2981
+ return;
2982
+ debounceSendInspectorTree();
2983
+ debounceSendInspectorState();
2984
+ });
2985
+ const componentRemovedCleanup = hook.on.componentRemoved(async (app2, uid, parentUid, component) => {
2986
+ var _a10, _b10, _c;
2987
+ if ((_c = (_b10 = (_a10 = app2 == null ? void 0 : app2._instance) == null ? void 0 : _a10.type) == null ? void 0 : _b10.devtools) == null ? void 0 : _c.hide)
2988
+ return;
2989
+ if (!app2 || typeof uid !== "number" && !uid || !component)
2990
+ return;
2991
+ const appRecord = await getAppRecord(app2);
2992
+ if (!appRecord)
2993
+ return;
2994
+ const id = await getComponentId({
2995
+ app: app2,
2996
+ uid,
2997
+ instance: component
2998
+ });
2999
+ appRecord == null ? void 0 : appRecord.instanceMap.delete(id);
3000
+ debounceSendInspectorTree();
3001
+ });
3002
+ devtoolsContext.componentPluginHookBuffer = [
3003
+ componentAddedCleanup,
3004
+ componentUpdatedCleanup,
3005
+ componentRemovedCleanup
3006
+ ];
3007
+ });
3008
+ }
3009
+
3010
+ // src/core/app-record/index.ts
3011
+ function getAppRecordName(app, fallbackName) {
3012
+ var _a10;
3013
+ return ((_a10 = app == null ? void 0 : app._component) == null ? void 0 : _a10.name) || `App ${fallbackName}`;
3014
+ }
3015
+ function getAppRootInstance(app) {
3016
+ var _a10, _b10, _c, _d;
3017
+ if (app._instance)
3018
+ return app._instance;
3019
+ else if ((_b10 = (_a10 = app._container) == null ? void 0 : _a10._vnode) == null ? void 0 : _b10.component)
3020
+ return (_d = (_c = app._container) == null ? void 0 : _c._vnode) == null ? void 0 : _d.component;
3021
+ }
3022
+ function getAppRecordId(app, defaultId) {
3023
+ if (app.__VUE_DEVTOOLS_APP_RECORD_ID__ != null)
3024
+ return app.__VUE_DEVTOOLS_APP_RECORD_ID__;
3025
+ let id = defaultId != null ? defaultId : (appRecordInfo.id++).toString();
3026
+ if (defaultId && appRecordInfo.appIds.has(id)) {
3027
+ let count = 1;
3028
+ while (appRecordInfo.appIds.has(`${defaultId}_${count}`))
3029
+ count++;
3030
+ id = `${defaultId}_${count}`;
3386
3031
  }
3387
- /**
3388
- * Mark an instance as captured and store it in the instance map.
3389
- *
3390
- * @param {Vue} instance
3391
- */
3392
- mark(instance, force = false) {
3393
- const instanceMap = getAppRecord(instance).instanceMap;
3394
- if (force || !instanceMap.has(instance.__VUE_DEVTOOLS_UID__))
3395
- instanceMap.set(instance.__VUE_DEVTOOLS_UID__, instance);
3396
- }
3397
- isKeepAlive(instance) {
3398
- return instance.type.__isKeepAlive && instance.__v_cache;
3032
+ appRecordInfo.appIds.add(id);
3033
+ app.__VUE_DEVTOOLS_APP_RECORD_ID__ = id;
3034
+ return id;
3035
+ }
3036
+ function createAppRecord(app) {
3037
+ const rootInstance = getAppRootInstance(app);
3038
+ if (rootInstance) {
3039
+ appRecordInfo.id++;
3040
+ const name = getAppRecordName(app, appRecordInfo.id.toString());
3041
+ const id = getAppRecordId(app, (0, import_speakingurl.default)(name));
3042
+ const record = {
3043
+ id,
3044
+ name,
3045
+ instanceMap: /* @__PURE__ */ new Map(),
3046
+ rootInstance
3047
+ };
3048
+ app.__VUE_DEVTOOLS_APP_RECORD__ = record;
3049
+ const rootId = `${record.id}:root`;
3050
+ record.instanceMap.set(rootId, record.rootInstance);
3051
+ record.rootInstance.__VUE_DEVTOOLS_UID__ = rootId;
3052
+ return record;
3053
+ } else {
3054
+ return {};
3399
3055
  }
3400
- getKeepAliveCachedInstances(instance) {
3401
- return Array.from(instance.__v_cache.values()).map((vnode) => vnode.component).filter(Boolean);
3056
+ }
3057
+ async function setActiveAppRecord(appRecord) {
3058
+ await registerComponentDevToolsPlugin(appRecord == null ? void 0 : appRecord.app);
3059
+ devtoolsAppRecords.active = appRecord;
3060
+ devtoolsAppRecords.activeId = `${appRecord.id}`;
3061
+ registerPlugin(appRecord.app, appRecord.api);
3062
+ }
3063
+ async function toggleActiveAppRecord(id) {
3064
+ devtoolsContext.componentPluginHookBuffer.forEach((cleanup) => cleanup());
3065
+ devtoolsContext.api.clear();
3066
+ devtoolsContext.clear();
3067
+ const appRecord = devtoolsAppRecords.value.find((record) => record.id === id);
3068
+ if (appRecord) {
3069
+ devtoolsState.pluginBuffer = devtoolsState.pluginBuffer.filter(([plugin]) => plugin.id !== "components");
3070
+ const api = new DevToolsPluginApi();
3071
+ appRecord.api = api;
3072
+ setActiveAppRecord(appRecord);
3402
3073
  }
3403
- };
3404
-
3405
- // src/core/component/state/index.ts
3406
- init_cjs_shims();
3407
- function getInstanceState(params) {
3408
- var _a9;
3409
- const instance = getComponentInstance(devtoolsContext.appRecord, params.instanceId);
3410
- const id = getUniqueComponentId(instance);
3411
- const name = getInstanceName(instance);
3412
- const file = (_a9 = instance == null ? void 0 : instance.type) == null ? void 0 : _a9.__file;
3413
- const state = processInstanceState(instance);
3414
- return {
3415
- id,
3416
- name,
3417
- file,
3418
- state,
3419
- instance
3420
- };
3421
3074
  }
3422
3075
 
3423
- // src/core/component/state/bounding-rect.ts
3076
+ // src/core/component-highlighter/index.ts
3424
3077
  init_cjs_shims();
3425
- function createRect() {
3426
- const rect = {
3427
- top: 0,
3428
- bottom: 0,
3429
- left: 0,
3430
- right: 0,
3431
- get width() {
3432
- return rect.right - rect.left;
3433
- },
3434
- get height() {
3435
- return rect.bottom - rect.top;
3436
- }
3078
+ var CONTAINER_ELEMENT_ID = "__vue-devtools-component-inspector__";
3079
+ var CARD_ELEMENT_ID = "__vue-devtools-component-inspector__card__";
3080
+ var COMPONENT_NAME_ELEMENT_ID = "__vue-devtools-component-inspector__name__";
3081
+ var INDICATOR_ELEMENT_ID = "__vue-devtools-component-inspector__indicator__";
3082
+ var containerStyles = {
3083
+ display: "block",
3084
+ zIndex: 2147483640,
3085
+ position: "fixed",
3086
+ backgroundColor: "#42b88325",
3087
+ border: "1px solid #42b88350",
3088
+ borderRadius: "5px",
3089
+ transition: "all 0.1s ease-in",
3090
+ pointerEvents: "none"
3091
+ };
3092
+ var cardStyles = {
3093
+ fontFamily: "Arial, Helvetica, sans-serif",
3094
+ padding: "5px 8px",
3095
+ borderRadius: "4px",
3096
+ textAlign: "left",
3097
+ position: "absolute",
3098
+ left: 0,
3099
+ color: "#e9e9e9",
3100
+ fontSize: "14px",
3101
+ fontWeight: 600,
3102
+ lineHeight: "24px",
3103
+ backgroundColor: "#42b883",
3104
+ boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)"
3105
+ };
3106
+ var indicatorStyles = {
3107
+ display: "inline-block",
3108
+ fontWeight: 400,
3109
+ fontStyle: "normal",
3110
+ fontSize: "12px",
3111
+ opacity: 0.7
3112
+ };
3113
+ function getContainerElement() {
3114
+ return document.getElementById(CONTAINER_ELEMENT_ID);
3115
+ }
3116
+ function getCardElement() {
3117
+ return document.getElementById(CARD_ELEMENT_ID);
3118
+ }
3119
+ function getIndicatorElement() {
3120
+ return document.getElementById(INDICATOR_ELEMENT_ID);
3121
+ }
3122
+ function getNameElement() {
3123
+ return document.getElementById(COMPONENT_NAME_ELEMENT_ID);
3124
+ }
3125
+ function getStyles(bounds) {
3126
+ return {
3127
+ left: `${Math.round(bounds.left * 100) / 100}px`,
3128
+ top: `${Math.round(bounds.top * 100) / 100}px`,
3129
+ width: `${Math.round(bounds.width * 100) / 100}px`,
3130
+ height: `${Math.round(bounds.height * 100) / 100}px`
3437
3131
  };
3438
- return rect;
3439
3132
  }
3440
- var range;
3441
- function getTextRect(node) {
3442
- if (!range)
3443
- range = document.createRange();
3444
- range.selectNode(node);
3445
- return range.getBoundingClientRect();
3133
+ function create(options) {
3134
+ var _a10;
3135
+ const containerEl = document.createElement("div");
3136
+ containerEl.id = (_a10 = options.elementId) != null ? _a10 : CONTAINER_ELEMENT_ID;
3137
+ Object.assign(containerEl.style, {
3138
+ ...containerStyles,
3139
+ ...getStyles(options.bounds),
3140
+ ...options.style
3141
+ });
3142
+ const cardEl = document.createElement("span");
3143
+ cardEl.id = CARD_ELEMENT_ID;
3144
+ Object.assign(cardEl.style, {
3145
+ ...cardStyles,
3146
+ top: options.bounds.top < 35 ? 0 : "-35px"
3147
+ });
3148
+ const nameEl = document.createElement("span");
3149
+ nameEl.id = COMPONENT_NAME_ELEMENT_ID;
3150
+ nameEl.innerHTML = `&lt;${options.name}&gt;&nbsp;&nbsp;`;
3151
+ const indicatorEl = document.createElement("i");
3152
+ indicatorEl.id = INDICATOR_ELEMENT_ID;
3153
+ indicatorEl.innerHTML = `${Math.round(options.bounds.width * 100) / 100} x ${Math.round(options.bounds.height * 100) / 100}`;
3154
+ Object.assign(indicatorEl.style, indicatorStyles);
3155
+ cardEl.appendChild(nameEl);
3156
+ cardEl.appendChild(indicatorEl);
3157
+ containerEl.appendChild(cardEl);
3158
+ document.body.appendChild(containerEl);
3159
+ return containerEl;
3446
3160
  }
3447
- function getFragmentRect(vnode) {
3448
- const rect = createRect();
3449
- if (!vnode.children)
3450
- return rect;
3451
- for (let i = 0, l = vnode.children.length; i < l; i++) {
3452
- const childVnode = vnode.children[i];
3453
- let childRect;
3454
- if (childVnode.component) {
3455
- childRect = getComponentBoundingRect(childVnode.component);
3456
- } else if (childVnode.el) {
3457
- const el = childVnode.el;
3458
- if (el.nodeType === 1 || el.getBoundingClientRect)
3459
- childRect = el.getBoundingClientRect();
3460
- else if (el.nodeType === 3 && el.data.trim())
3461
- childRect = getTextRect(el);
3161
+ function update(options) {
3162
+ const containerEl = getContainerElement();
3163
+ const cardEl = getCardElement();
3164
+ const nameEl = getNameElement();
3165
+ const indicatorEl = getIndicatorElement();
3166
+ if (containerEl) {
3167
+ Object.assign(containerEl.style, {
3168
+ ...containerStyles,
3169
+ ...getStyles(options.bounds)
3170
+ });
3171
+ Object.assign(cardEl.style, {
3172
+ top: options.bounds.top < 35 ? 0 : "-35px"
3173
+ });
3174
+ nameEl.innerHTML = `&lt;${options.name}&gt;&nbsp;&nbsp;`;
3175
+ indicatorEl.innerHTML = `${Math.round(options.bounds.width * 100) / 100} x ${Math.round(options.bounds.height * 100) / 100}`;
3176
+ }
3177
+ }
3178
+ function toggleComponentHighLighter(options) {
3179
+ if (options.visible) {
3180
+ const instance = getComponentInstance(devtoolsContext.appRecord, options.id);
3181
+ if (instance && (options.bounds.width || options.bounds.height)) {
3182
+ const name = getInstanceName(instance);
3183
+ const el = getContainerElement();
3184
+ el ? update({ ...options, name }) : create({ ...options, name });
3462
3185
  }
3463
- if (childRect)
3464
- mergeRects(rect, childRect);
3186
+ } else {
3187
+ const el = getContainerElement();
3188
+ if (el)
3189
+ el.style.display = "none";
3465
3190
  }
3466
- return rect;
3467
3191
  }
3468
- function mergeRects(a, b) {
3469
- if (!a.top || b.top < a.top)
3470
- a.top = b.top;
3471
- if (!a.bottom || b.bottom > a.bottom)
3472
- a.bottom = b.bottom;
3473
- if (!a.left || b.left < a.left)
3474
- a.left = b.left;
3475
- if (!a.right || b.right > a.right)
3476
- a.right = b.right;
3477
- return a;
3192
+ function highlight(instance) {
3193
+ const bounds = getComponentBoundingRect(instance);
3194
+ const name = getInstanceName(instance);
3195
+ const container = getContainerElement();
3196
+ container ? update({ bounds, name }) : create({ bounds, name });
3478
3197
  }
3479
- var DEFAULT_RECT = {
3480
- top: 0,
3481
- left: 0,
3482
- right: 0,
3483
- bottom: 0,
3484
- width: 0,
3485
- height: 0
3486
- };
3487
- function getComponentBoundingRect(instance) {
3488
- const el = instance.subTree.el;
3489
- if (typeof window === "undefined") {
3490
- return DEFAULT_RECT;
3198
+ function unhighlight() {
3199
+ const el = getContainerElement();
3200
+ if (el)
3201
+ el.style.display = "none";
3202
+ }
3203
+ var inspectInstance = null;
3204
+ function inspectFn(e) {
3205
+ const target9 = e.target;
3206
+ if (target9) {
3207
+ const instance = target9.__vueParentComponent;
3208
+ if (instance) {
3209
+ inspectInstance = instance;
3210
+ const el = instance.vnode.el;
3211
+ if (el) {
3212
+ const bounds = getComponentBoundingRect(instance);
3213
+ const name = getInstanceName(instance);
3214
+ const container = getContainerElement();
3215
+ container ? update({ bounds, name }) : create({ bounds, name });
3216
+ }
3217
+ }
3491
3218
  }
3492
- if (isFragment(instance))
3493
- return getFragmentRect(instance.subTree);
3494
- else if ((el == null ? void 0 : el.nodeType) === 1)
3495
- return el == null ? void 0 : el.getBoundingClientRect();
3496
- else if (instance.subTree.component)
3497
- return getComponentBoundingRect(instance.subTree.component);
3498
- else
3499
- return DEFAULT_RECT;
3500
3219
  }
3501
-
3502
- // src/api/on.ts
3503
- init_cjs_shims();
3504
- var import_devtools_shared9 = require("@vue/devtools-shared");
3505
- var import_hookable2 = require("hookable");
3506
- var _a6, _b6;
3507
- var apiHooks = (_b6 = (_a6 = import_devtools_shared9.target).__VUE_DEVTOOLS_API_HOOK) != null ? _b6 : _a6.__VUE_DEVTOOLS_API_HOOK = (0, import_hookable2.createHooks)();
3508
- var on2 = {
3509
- devtoolsStateUpdated(fn) {
3510
- apiHooks.hook("devtools:state-updated" /* DEVTOOLS_STATE_UPDATED */, fn);
3511
- },
3512
- routerInfoUpdated(fn) {
3513
- apiHooks.hook("router-info:updated" /* ROUTER_INFO_UPDATED */, fn);
3514
- },
3515
- getComponentBoundingRect(fn) {
3516
- apiHooks.hook("component-bounding-rect:get" /* GET_COMPONENT_BOUNDING_RECT */, fn);
3517
- },
3518
- // compatible
3519
- inspectComponent(fn) {
3520
- apiHooks.hook("component-state:inspect" /* COMPONENT_STATE_INSPECT */, fn);
3521
- },
3522
- visitComponentTree(fn) {
3523
- apiHooks.hook("component-tree:visit" /* VISIT_COMPONENT_TREE */, fn);
3524
- },
3525
- getInspectorTree(fn) {
3526
- apiHooks.hook("inspector-tree:get" /* GET_INSPECTOR_TREE */, fn);
3527
- },
3528
- getInspectorState(fn) {
3529
- apiHooks.hook("inspector-state:get" /* GET_INSPECTOR_STATE */, fn);
3530
- },
3531
- // private
3532
- sendInspectorTree(fn) {
3533
- apiHooks.hook("inspector-tree:send" /* SEND_INSPECTOR_TREE */, fn);
3534
- },
3535
- sendInspectorState(fn) {
3536
- apiHooks.hook("inspector-state:send" /* SEND_INSPECTOR_STATE */, fn);
3537
- },
3538
- addTimelineEvent(fn) {
3539
- apiHooks.hook("timeline:add-event" /* ADD_TIMELINE_EVENT */, fn);
3540
- },
3541
- editInspectorState(fn) {
3542
- apiHooks.hook("inspector-state:edit" /* EDIT_INSPECTOR_STATE */, fn);
3543
- },
3544
- editComponentState() {
3545
- },
3546
- customTabsUpdated(fn) {
3547
- apiHooks.hook("custom-tabs:updated" /* CUSTOM_TABS_UPDATED */, fn);
3548
- },
3549
- customCommandsUpdated(fn) {
3550
- apiHooks.hook("custom-commands:updated" /* CUSTOM_COMMANDS_UPDATED */, fn);
3220
+ function selectComponentFn(e, cb) {
3221
+ var _a10;
3222
+ e.preventDefault();
3223
+ e.stopPropagation();
3224
+ if (inspectInstance) {
3225
+ const app = (_a10 = devtoolsContext.appRecord) == null ? void 0 : _a10.app;
3226
+ getComponentId({
3227
+ app,
3228
+ uid: app.uid,
3229
+ instance: inspectInstance
3230
+ }).then((id) => {
3231
+ cb(id);
3232
+ });
3551
3233
  }
3552
- };
3553
-
3554
- // src/core/plugins/components.ts
3555
- var INSPECTOR_ID = "components";
3556
- function registerComponentsDevTools(app) {
3557
- setupDevToolsPlugin({
3558
- id: INSPECTOR_ID,
3559
- label: "Components",
3560
- app
3561
- }, (api) => {
3562
- api.addInspector({
3563
- id: INSPECTOR_ID,
3564
- label: "Components",
3565
- treeFilterPlaceholder: "Search components"
3566
- });
3567
- api.on.getComponentBoundingRect((payload) => {
3568
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
3569
- const instance = getComponentInstance(devtoolsContext.appRecord, payload.instanceId);
3570
- if (instance) {
3571
- if (typeof DOMRect === "undefined")
3572
- return;
3573
- payload.rect = getComponentBoundingRect(instance);
3574
- if (payload.rect instanceof DOMRect) {
3575
- payload.rect = {
3576
- top: payload.rect.top,
3577
- left: payload.rect.left,
3578
- right: payload.rect.right,
3579
- bottom: payload.rect.bottom,
3580
- width: payload.rect.width,
3581
- height: payload.rect.height
3582
- };
3583
- }
3584
- }
3234
+ }
3235
+ function inspectComponentHighLighter() {
3236
+ window.addEventListener("mouseover", inspectFn);
3237
+ return new Promise((resolve) => {
3238
+ function onSelect(e) {
3239
+ e.preventDefault();
3240
+ e.stopPropagation();
3241
+ selectComponentFn(e, (id) => {
3242
+ window.removeEventListener("click", onSelect);
3243
+ window.removeEventListener("mouseover", inspectFn);
3244
+ const el = getContainerElement();
3245
+ if (el)
3246
+ el.style.display = "none";
3247
+ resolve(JSON.stringify({ id }));
3248
+ });
3249
+ }
3250
+ window.addEventListener("click", onSelect);
3251
+ });
3252
+ }
3253
+ function scrollToComponent(options) {
3254
+ const instance = getComponentInstance(devtoolsContext.appRecord, options.id);
3255
+ if (instance) {
3256
+ const [el] = getRootElementsFromComponentInstance(instance);
3257
+ if (typeof el.scrollIntoView === "function") {
3258
+ el.scrollIntoView({
3259
+ behavior: "smooth"
3260
+ });
3261
+ } else {
3262
+ const bounds = getComponentBoundingRect(instance);
3263
+ const scrollTarget = document.createElement("div");
3264
+ const styles = {
3265
+ ...getStyles(bounds),
3266
+ position: "absolute"
3267
+ };
3268
+ Object.assign(scrollTarget.style, styles);
3269
+ document.body.appendChild(scrollTarget);
3270
+ scrollTarget.scrollIntoView({
3271
+ behavior: "smooth"
3272
+ });
3273
+ setTimeout(() => {
3274
+ document.body.removeChild(scrollTarget);
3275
+ }, 2e3);
3276
+ }
3277
+ setTimeout(() => {
3278
+ const bounds = getComponentBoundingRect(instance);
3279
+ if (bounds.width || bounds.height) {
3280
+ const name = getInstanceName(instance);
3281
+ const el2 = getContainerElement();
3282
+ el2 ? update({ ...options, name, bounds }) : create({ ...options, name, bounds });
3283
+ setTimeout(() => {
3284
+ if (el2)
3285
+ el2.style.display = "none";
3286
+ }, 1500);
3585
3287
  }
3586
- });
3587
- api.on.getInspectorTree(async (payload) => {
3588
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
3589
- const instance = getComponentInstance(devtoolsContext.appRecord, payload.instanceId);
3590
- if (instance) {
3591
- const walker = new ComponentWalker({
3592
- filterText: payload.filter,
3593
- // @TODO: should make this configurable?
3594
- maxDepth: 100,
3595
- recursively: false
3596
- });
3597
- payload.rootNodes = await walker.getComponentTree(instance);
3598
- }
3288
+ }, 1200);
3289
+ }
3290
+ }
3291
+
3292
+ // src/shared/index.ts
3293
+ init_cjs_shims();
3294
+
3295
+ // src/shared/util.ts
3296
+ init_cjs_shims();
3297
+
3298
+ // src/core/component/state/replacer.ts
3299
+ init_cjs_shims();
3300
+
3301
+ // src/core/component/state/custom.ts
3302
+ init_cjs_shims();
3303
+ function getFunctionDetails(func) {
3304
+ let string = "";
3305
+ let matches = null;
3306
+ try {
3307
+ string = Function.prototype.toString.call(func);
3308
+ matches = String.prototype.match.call(string, /\([\s\S]*?\)/);
3309
+ } catch (e) {
3310
+ }
3311
+ const match = matches && matches[0];
3312
+ const args = typeof match === "string" ? match : "(?)";
3313
+ const name = typeof func.name === "string" ? func.name : "";
3314
+ return {
3315
+ _custom: {
3316
+ type: "function",
3317
+ displayText: `<span style="opacity:.5;">function</span> ${escape(name)}${args}`,
3318
+ tooltipText: string.trim() ? `<pre>${string}</pre>` : null
3319
+ }
3320
+ };
3321
+ }
3322
+ function getBigIntDetails(val) {
3323
+ const stringifiedBigInt = BigInt.prototype.toString.call(val);
3324
+ return {
3325
+ _custom: {
3326
+ type: "bigint",
3327
+ displayText: `BigInt(${stringifiedBigInt})`,
3328
+ value: stringifiedBigInt
3329
+ }
3330
+ };
3331
+ }
3332
+ function getMapDetails(val) {
3333
+ const list = Object.fromEntries(val);
3334
+ return {
3335
+ _custom: {
3336
+ type: "map",
3337
+ displayText: "Map",
3338
+ value: list,
3339
+ readOnly: true,
3340
+ fields: {
3341
+ abstract: true
3599
3342
  }
3600
- });
3601
- api.on.getInspectorState(async (payload) => {
3602
- var _a9;
3603
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
3604
- const result = getInstanceState({
3605
- instanceId: payload.nodeId
3606
- });
3607
- const componentInstance = result.instance;
3608
- const app2 = (_a9 = result.instance) == null ? void 0 : _a9.appContext.app;
3609
- const _payload = {
3610
- componentInstance,
3611
- app: app2,
3612
- instanceData: result
3613
- };
3614
- apiHooks.callHookWith((callbacks) => {
3615
- callbacks.forEach((cb) => cb(_payload));
3616
- }, "component-state:inspect" /* COMPONENT_STATE_INSPECT */);
3617
- payload.state = result;
3343
+ }
3344
+ };
3345
+ }
3346
+ function getSetDetails(val) {
3347
+ const list = Array.from(val);
3348
+ return {
3349
+ _custom: {
3350
+ type: "set",
3351
+ displayText: `Set[${list.length}]`,
3352
+ value: list,
3353
+ readOnly: true
3354
+ }
3355
+ };
3356
+ }
3357
+ function getCatchedGetters(store) {
3358
+ const getters = {};
3359
+ const origGetters = store.getters || {};
3360
+ const keys = Object.keys(origGetters);
3361
+ for (let i = 0; i < keys.length; i++) {
3362
+ const key = keys[i];
3363
+ Object.defineProperty(getters, key, {
3364
+ enumerable: true,
3365
+ get: () => {
3366
+ try {
3367
+ return origGetters[key];
3368
+ } catch (e) {
3369
+ return e;
3370
+ }
3618
3371
  }
3619
3372
  });
3620
- api.on.editInspectorState(async (payload) => {
3621
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
3622
- editState(payload);
3623
- await api.sendInspectorState("components");
3373
+ }
3374
+ return getters;
3375
+ }
3376
+ function reduceStateList(list) {
3377
+ if (!list.length)
3378
+ return void 0;
3379
+ return list.reduce((map, item) => {
3380
+ const key = item.type || "data";
3381
+ const obj = map[key] = map[key] || {};
3382
+ obj[item.key] = item.value;
3383
+ return map;
3384
+ }, {});
3385
+ }
3386
+ function namedNodeMapToObject(map) {
3387
+ const result = {};
3388
+ const l = map.length;
3389
+ for (let i = 0; i < l; i++) {
3390
+ const node = map.item(i);
3391
+ result[node.name] = node.value;
3392
+ }
3393
+ return result;
3394
+ }
3395
+ function getStoreDetails(store) {
3396
+ return {
3397
+ _custom: {
3398
+ type: "store",
3399
+ displayText: "Store",
3400
+ value: {
3401
+ state: store.state,
3402
+ getters: getCatchedGetters(store)
3403
+ },
3404
+ fields: {
3405
+ abstract: true
3624
3406
  }
3625
- });
3626
- const debounceSendInspectorTree = (0, import_perfect_debounce3.debounce)(() => {
3627
- api.sendInspectorTree(INSPECTOR_ID);
3628
- }, 120);
3629
- const debounceSendInspectorState = (0, import_perfect_debounce3.debounce)(() => {
3630
- api.sendInspectorState(INSPECTOR_ID);
3631
- }, 120);
3632
- const componentAddedCleanup = hook.on.componentAdded(async (app2, uid, parentUid, component) => {
3633
- var _a9, _b9, _c;
3634
- if ((_c = (_b9 = (_a9 = app2 == null ? void 0 : app2._instance) == null ? void 0 : _a9.type) == null ? void 0 : _b9.devtools) == null ? void 0 : _c.hide)
3635
- return;
3636
- if (!app2 || typeof uid !== "number" && !uid || !component)
3637
- return;
3638
- const id = await getComponentId({
3639
- app: app2,
3640
- uid,
3641
- instance: component
3642
- });
3643
- const appRecord = await getAppRecord(app2);
3644
- if (component) {
3645
- if (component.__VUE_DEVTOOLS_UID__ == null)
3646
- component.__VUE_DEVTOOLS_UID__ = id;
3647
- if (!(appRecord == null ? void 0 : appRecord.instanceMap.has(id)))
3648
- appRecord == null ? void 0 : appRecord.instanceMap.set(id, component);
3407
+ }
3408
+ };
3409
+ }
3410
+ function getRouterDetails(router) {
3411
+ return {
3412
+ _custom: {
3413
+ type: "router",
3414
+ displayText: "VueRouter",
3415
+ value: {
3416
+ options: router.options,
3417
+ currentRoute: router.currentRoute
3418
+ },
3419
+ fields: {
3420
+ abstract: true
3649
3421
  }
3650
- if (!appRecord)
3651
- return;
3652
- debounceSendInspectorTree();
3653
- });
3654
- const componentUpdatedCleanup = hook.on.componentUpdated(async (app2, uid, parentUid, component) => {
3655
- var _a9, _b9, _c;
3656
- if ((_c = (_b9 = (_a9 = app2 == null ? void 0 : app2._instance) == null ? void 0 : _a9.type) == null ? void 0 : _b9.devtools) == null ? void 0 : _c.hide)
3657
- return;
3658
- if (!app2 || typeof uid !== "number" && !uid || !component)
3659
- return;
3660
- const id = await getComponentId({
3661
- app: app2,
3662
- uid,
3663
- instance: component
3664
- });
3665
- const appRecord = await getAppRecord(app2);
3666
- if (component) {
3667
- if (component.__VUE_DEVTOOLS_UID__ == null)
3668
- component.__VUE_DEVTOOLS_UID__ = id;
3669
- if (!(appRecord == null ? void 0 : appRecord.instanceMap.has(id)))
3670
- appRecord == null ? void 0 : appRecord.instanceMap.set(id, component);
3422
+ }
3423
+ };
3424
+ }
3425
+ function getInstanceDetails(instance) {
3426
+ if (instance._)
3427
+ instance = instance._;
3428
+ const state = processInstanceState(instance);
3429
+ return {
3430
+ _custom: {
3431
+ type: "component",
3432
+ id: instance.__VUE_DEVTOOLS_UID__,
3433
+ displayText: getInstanceName(instance),
3434
+ tooltipText: "Component instance",
3435
+ value: reduceStateList(state),
3436
+ fields: {
3437
+ abstract: true
3671
3438
  }
3672
- if (!appRecord)
3673
- return;
3674
- debounceSendInspectorTree();
3675
- debounceSendInspectorState();
3676
- });
3677
- const componentRemovedCleanup = hook.on.componentRemoved(async (app2, uid, parentUid, component) => {
3678
- var _a9, _b9, _c;
3679
- if ((_c = (_b9 = (_a9 = app2 == null ? void 0 : app2._instance) == null ? void 0 : _a9.type) == null ? void 0 : _b9.devtools) == null ? void 0 : _c.hide)
3680
- return;
3681
- if (!app2 || typeof uid !== "number" && !uid || !component)
3682
- return;
3683
- const appRecord = await getAppRecord(app2);
3684
- if (!appRecord)
3685
- return;
3686
- const id = await getComponentId({
3687
- app: app2,
3688
- uid,
3689
- instance: component
3690
- });
3691
- appRecord == null ? void 0 : appRecord.instanceMap.delete(id);
3692
- debounceSendInspectorTree();
3693
- });
3694
- devtoolsContext.componentPluginHookBuffer = [
3695
- componentAddedCleanup,
3696
- componentUpdatedCleanup,
3697
- componentRemovedCleanup
3698
- ];
3699
- });
3439
+ }
3440
+ };
3441
+ }
3442
+ function getComponentDefinitionDetails(definition) {
3443
+ let display = getComponentName(definition);
3444
+ if (display) {
3445
+ if (definition.name && definition.__file)
3446
+ display += ` <span>(${definition.__file})</span>`;
3447
+ } else {
3448
+ display = "<i>Unknown Component</i>";
3449
+ }
3450
+ return {
3451
+ _custom: {
3452
+ type: "component-definition",
3453
+ displayText: display,
3454
+ tooltipText: "Component definition",
3455
+ ...definition.__file ? {
3456
+ file: definition.__file
3457
+ } : {}
3458
+ }
3459
+ };
3460
+ }
3461
+ function getHTMLElementDetails(value) {
3462
+ try {
3463
+ return {
3464
+ _custom: {
3465
+ type: "HTMLElement",
3466
+ displayText: `<span class="opacity-30">&lt;</span><span class="text-blue-500">${value.tagName.toLowerCase()}</span><span class="opacity-30">&gt;</span>`,
3467
+ value: namedNodeMapToObject(value.attributes)
3468
+ }
3469
+ };
3470
+ } catch (e) {
3471
+ return {
3472
+ _custom: {
3473
+ type: "HTMLElement",
3474
+ displayText: `<span class="text-blue-500">${String(value)}</span>`
3475
+ }
3476
+ };
3477
+ }
3478
+ }
3479
+ function getObjectDetails(object) {
3480
+ var _a10, _b10, _c, _d;
3481
+ const info = getSetupStateType(object);
3482
+ const isState = info.ref || info.computed || info.reactive;
3483
+ if (isState) {
3484
+ const stateTypeName = info.computed ? "Computed" : info.ref ? "Ref" : info.reactive ? "Reactive" : null;
3485
+ const value = toRaw2(info.reactive ? object : object._value);
3486
+ const raw = ((_b10 = (_a10 = object.effect) == null ? void 0 : _a10.raw) == null ? void 0 : _b10.toString()) || ((_d = (_c = object.effect) == null ? void 0 : _c.fn) == null ? void 0 : _d.toString());
3487
+ return {
3488
+ _custom: {
3489
+ type: stateTypeName == null ? void 0 : stateTypeName.toLowerCase(),
3490
+ stateTypeName,
3491
+ value,
3492
+ ...raw ? { tooltipText: `<span class="font-mono">${raw}</span>` } : {}
3493
+ }
3494
+ };
3495
+ }
3496
+ if (typeof object.__asyncLoader === "function") {
3497
+ return {
3498
+ _custom: {
3499
+ type: "component-definition",
3500
+ display: "Async component definition"
3501
+ }
3502
+ };
3503
+ }
3504
+ }
3505
+
3506
+ // src/core/component/state/replacer.ts
3507
+ function stringifyReplacer(key) {
3508
+ var _a10;
3509
+ if (key === "compilerOptions")
3510
+ return;
3511
+ const val = this[key];
3512
+ const type = typeof val;
3513
+ if (Array.isArray(val)) {
3514
+ const l = val.length;
3515
+ if (l > MAX_ARRAY_SIZE) {
3516
+ return {
3517
+ _isArray: true,
3518
+ length: l,
3519
+ items: val.slice(0, MAX_ARRAY_SIZE)
3520
+ };
3521
+ }
3522
+ return val;
3523
+ } else if (typeof val === "string") {
3524
+ if (val.length > MAX_STRING_SIZE)
3525
+ return `${val.substring(0, MAX_STRING_SIZE)}... (${val.length} total length)`;
3526
+ else
3527
+ return val;
3528
+ } else if (type === "undefined") {
3529
+ return UNDEFINED;
3530
+ } else if (val === Number.POSITIVE_INFINITY) {
3531
+ return INFINITY;
3532
+ } else if (val === Number.NEGATIVE_INFINITY) {
3533
+ return NEGATIVE_INFINITY;
3534
+ } else if (typeof val === "function") {
3535
+ return getFunctionDetails(val);
3536
+ } else if (type === "symbol") {
3537
+ return `[native Symbol ${Symbol.prototype.toString.call(val)}]`;
3538
+ } else if (typeof val === "bigint") {
3539
+ return getBigIntDetails(val);
3540
+ } else if (val !== null && typeof val === "object") {
3541
+ const proto = Object.prototype.toString.call(val);
3542
+ if (proto === "[object Map]") {
3543
+ return getMapDetails(val);
3544
+ } else if (proto === "[object Set]") {
3545
+ return getSetDetails(val);
3546
+ } else if (proto === "[object RegExp]") {
3547
+ return `[native RegExp ${RegExp.prototype.toString.call(val)}]`;
3548
+ } else if (proto === "[object Date]") {
3549
+ return `[native Date ${Date.prototype.toString.call(val)}]`;
3550
+ } else if (proto === "[object Error]") {
3551
+ return `[native Error ${val.message}<>${val.stack}]`;
3552
+ } else if (val.state && val._vm) {
3553
+ return getStoreDetails(val);
3554
+ } else if (val.constructor && val.constructor.name === "VueRouter") {
3555
+ return getRouterDetails(val);
3556
+ } else if (isVueInstance(val)) {
3557
+ return getInstanceDetails(val);
3558
+ } else if (typeof val.render === "function") {
3559
+ return getComponentDefinitionDetails(val);
3560
+ } else if (val.constructor && val.constructor.name === "VNode") {
3561
+ return `[native VNode <${val.tag}>]`;
3562
+ } else if (typeof HTMLElement !== "undefined" && val instanceof HTMLElement) {
3563
+ return getHTMLElementDetails(val);
3564
+ } else if (((_a10 = val.constructor) == null ? void 0 : _a10.name) === "Store" && val._wrappedGetters) {
3565
+ return "[object Store]";
3566
+ } else if (val.currentRoute) {
3567
+ return "[object Router]";
3568
+ }
3569
+ const customDetails = getObjectDetails(val);
3570
+ if (customDetails != null)
3571
+ return customDetails;
3572
+ } else if (Number.isNaN(val)) {
3573
+ return NAN;
3574
+ }
3575
+ return sanitize(val);
3576
+ }
3577
+
3578
+ // src/core/component/state/reviver.ts
3579
+ init_cjs_shims();
3580
+ var import_devtools_shared7 = require("@vue/devtools-shared");
3581
+ function reviveSet(val) {
3582
+ const result = /* @__PURE__ */ new Set();
3583
+ const list = val._custom.value;
3584
+ for (let i = 0; i < list.length; i++) {
3585
+ const value = list[i];
3586
+ result.add(revive(value));
3587
+ }
3588
+ return result;
3589
+ }
3590
+ function reviveMap(val) {
3591
+ const result = /* @__PURE__ */ new Map();
3592
+ const list = val._custom.value;
3593
+ for (let i = 0; i < list.length; i++) {
3594
+ const { key, value } = list[i];
3595
+ result.set(key, revive(value));
3596
+ }
3597
+ return result;
3598
+ }
3599
+ function revive(val) {
3600
+ var _a10;
3601
+ if (val === UNDEFINED) {
3602
+ return void 0;
3603
+ } else if (val === INFINITY) {
3604
+ return Number.POSITIVE_INFINITY;
3605
+ } else if (val === NEGATIVE_INFINITY) {
3606
+ return Number.NEGATIVE_INFINITY;
3607
+ } else if (val === NAN) {
3608
+ return Number.NaN;
3609
+ } else if (val && val._custom) {
3610
+ const { _custom: custom } = val;
3611
+ if (custom.type === "component")
3612
+ return (_a10 = devtoolsContext.appRecord) == null ? void 0 : _a10.instanceMap.get(custom.id);
3613
+ else if (custom.type === "map")
3614
+ return reviveMap(val);
3615
+ else if (custom.type === "set")
3616
+ return reviveSet(val);
3617
+ else if (custom.type === "bigint")
3618
+ return BigInt(custom.value);
3619
+ else
3620
+ return revive(custom.value);
3621
+ } else if (symbolRE.test(val)) {
3622
+ const [, string] = symbolRE.exec(val);
3623
+ return Symbol.for(string);
3624
+ } else if (specialTypeRE.test(val)) {
3625
+ const [, type, string, , details] = specialTypeRE.exec(val);
3626
+ const result = new import_devtools_shared7.target[type](string);
3627
+ if (type === "Error" && details)
3628
+ result.stack = details;
3629
+ return result;
3630
+ } else {
3631
+ return val;
3632
+ }
3633
+ }
3634
+ function reviver(key, value) {
3635
+ return revive(value);
3636
+ }
3637
+
3638
+ // src/shared/transfer.ts
3639
+ init_cjs_shims();
3640
+ var MAX_SERIALIZED_SIZE = 512 * 1024;
3641
+ function encode(data, replacer, list, seen) {
3642
+ let stored, key, value, i, l;
3643
+ const seenIndex = seen.get(data);
3644
+ if (seenIndex != null)
3645
+ return seenIndex;
3646
+ const index = list.length;
3647
+ const proto = Object.prototype.toString.call(data);
3648
+ if (proto === "[object Object]") {
3649
+ stored = {};
3650
+ seen.set(data, index);
3651
+ list.push(stored);
3652
+ const keys = Object.keys(data);
3653
+ for (i = 0, l = keys.length; i < l; i++) {
3654
+ key = keys[i];
3655
+ try {
3656
+ if (key === "compilerOptions")
3657
+ return;
3658
+ value = data[key];
3659
+ if (replacer)
3660
+ value = replacer.call(data, key, value);
3661
+ } catch (e) {
3662
+ value = e;
3663
+ }
3664
+ stored[key] = encode(value, replacer, list, seen);
3665
+ }
3666
+ } else if (proto === "[object Array]") {
3667
+ stored = [];
3668
+ seen.set(data, index);
3669
+ list.push(stored);
3670
+ for (i = 0, l = data.length; i < l; i++) {
3671
+ try {
3672
+ value = data[i];
3673
+ if (replacer)
3674
+ value = replacer.call(data, i, value);
3675
+ } catch (e) {
3676
+ value = e;
3677
+ }
3678
+ stored[i] = encode(value, replacer, list, seen);
3679
+ }
3680
+ } else {
3681
+ list.push(data);
3682
+ }
3683
+ return index;
3684
+ }
3685
+ function decode(list, reviver2 = null) {
3686
+ let i = list.length;
3687
+ let j, k, data, key, value, proto;
3688
+ while (i--) {
3689
+ data = list[i];
3690
+ proto = Object.prototype.toString.call(data);
3691
+ if (proto === "[object Object]") {
3692
+ const keys = Object.keys(data);
3693
+ for (j = 0, k = keys.length; j < k; j++) {
3694
+ key = keys[j];
3695
+ value = list[data[key]];
3696
+ if (reviver2)
3697
+ value = reviver2.call(data, key, value);
3698
+ data[key] = value;
3699
+ }
3700
+ } else if (proto === "[object Array]") {
3701
+ for (j = 0, k = data.length; j < k; j++) {
3702
+ value = list[data[j]];
3703
+ if (reviver2)
3704
+ value = reviver2.call(data, j, value);
3705
+ data[j] = value;
3706
+ }
3707
+ }
3708
+ }
3709
+ }
3710
+ function stringifyCircularAutoChunks(data, replacer = null, space = null) {
3711
+ let result;
3712
+ try {
3713
+ result = arguments.length === 1 ? JSON.stringify(data) : JSON.stringify(data, replacer, space);
3714
+ } catch (e) {
3715
+ result = stringifyStrictCircularAutoChunks(data, replacer, space);
3716
+ }
3717
+ if (result.length > MAX_SERIALIZED_SIZE) {
3718
+ const chunkCount = Math.ceil(result.length / MAX_SERIALIZED_SIZE);
3719
+ const chunks = [];
3720
+ for (let i = 0; i < chunkCount; i++)
3721
+ chunks.push(result.slice(i * MAX_SERIALIZED_SIZE, (i + 1) * MAX_SERIALIZED_SIZE));
3722
+ return chunks;
3723
+ }
3724
+ return result;
3725
+ }
3726
+ function stringifyStrictCircularAutoChunks(data, replacer = null, space = null) {
3727
+ const list = [];
3728
+ encode(data, replacer, list, /* @__PURE__ */ new Map());
3729
+ return space ? ` ${JSON.stringify(list, null, space)}` : ` ${JSON.stringify(list)}`;
3730
+ }
3731
+ function parseCircularAutoChunks(data, reviver2 = null) {
3732
+ if (Array.isArray(data))
3733
+ data = data.join("");
3734
+ const hasCircular = /^\s/.test(data);
3735
+ if (!hasCircular) {
3736
+ return arguments.length === 1 ? JSON.parse(data) : JSON.parse(data, reviver2);
3737
+ } else {
3738
+ const list = JSON.parse(data);
3739
+ decode(list, reviver2);
3740
+ return list[0];
3741
+ }
3742
+ }
3743
+
3744
+ // src/core/component/state/format.ts
3745
+ init_cjs_shims();
3746
+ function getInspectorStateValueType(value, raw = true) {
3747
+ const type = typeof value;
3748
+ if (value == null || value === UNDEFINED) {
3749
+ return "null";
3750
+ } else if (type === "boolean" || type === "number" || value === INFINITY || value === NEGATIVE_INFINITY || value === NAN) {
3751
+ return "literal";
3752
+ } else if (value == null ? void 0 : value._custom) {
3753
+ if (raw || value._custom.display != null || value._custom.displayText != null)
3754
+ return "custom";
3755
+ else
3756
+ return getInspectorStateValueType(value._custom.value);
3757
+ } else if (typeof value === "string") {
3758
+ const typeMatch = specialTypeRE.exec(value);
3759
+ if (typeMatch) {
3760
+ const [, type2] = typeMatch;
3761
+ return `native ${type2}`;
3762
+ } else {
3763
+ return "string";
3764
+ }
3765
+ } else if (Array.isArray(value) || (value == null ? void 0 : value._isArray)) {
3766
+ return "array";
3767
+ } else if (isPlainObject(value)) {
3768
+ return "plain-object";
3769
+ } else {
3770
+ return "unknown";
3771
+ }
3772
+ }
3773
+ function formatInspectorStateValue(value, quotes = false) {
3774
+ var _a10, _b10;
3775
+ let result;
3776
+ const type = getInspectorStateValueType(value, false);
3777
+ if (type !== "custom" && (value == null ? void 0 : value._custom))
3778
+ value = value._custom.value;
3779
+ if (result = internalStateTokenToString(value)) {
3780
+ return result;
3781
+ } else if (type === "custom") {
3782
+ const nestedName = ((_a10 = value._custom.value) == null ? void 0 : _a10._custom) && formatInspectorStateValue(value._custom.value);
3783
+ return nestedName || value._custom.displayText || value._custom.display;
3784
+ } else if (type === "array") {
3785
+ return `Array[${value.length}]`;
3786
+ } else if (type === "plain-object") {
3787
+ return `Object${Object.keys(value).length ? "" : " (empty)"}`;
3788
+ } else if (type == null ? void 0 : type.includes("native")) {
3789
+ return escape((_b10 = specialTypeRE.exec(value)) == null ? void 0 : _b10[2]);
3790
+ } else if (typeof value === "string") {
3791
+ const typeMatch = value.match(rawTypeRE);
3792
+ if (typeMatch)
3793
+ value = escape(typeMatch[1]);
3794
+ else if (quotes)
3795
+ value = `<span>"</span>${escape(value)}<span>"</span>`;
3796
+ else
3797
+ value = escape(value);
3798
+ value = value.replace(/ /g, "&nbsp;").replace(/\n/g, "<span>\\n</span>");
3799
+ }
3800
+ return value;
3801
+ }
3802
+ function getRaw(value) {
3803
+ var _a10, _b10, _c;
3804
+ let customType;
3805
+ const isCustom = getInspectorStateValueType(value) === "custom";
3806
+ let inherit = {};
3807
+ if (isCustom) {
3808
+ const data = value;
3809
+ const customValue = (_a10 = data._custom) == null ? void 0 : _a10.value;
3810
+ const currentCustomType = (_b10 = data._custom) == null ? void 0 : _b10.type;
3811
+ const nestedCustom = typeof customValue === "object" && customValue !== null && "_custom" in customValue ? getRaw(customValue) : { inherit: void 0, value: void 0, customType: void 0 };
3812
+ inherit = nestedCustom.inherit || ((_c = data._custom) == null ? void 0 : _c.fields) || {};
3813
+ value = nestedCustom.value || customValue;
3814
+ customType = nestedCustom.customType || currentCustomType;
3815
+ }
3816
+ if (value && value._isArray)
3817
+ value = value.items;
3818
+ return { value, inherit, customType };
3819
+ }
3820
+ function toEdit(value, customType) {
3821
+ if (customType === "bigint")
3822
+ return value;
3823
+ return replaceTokenToString(JSON.stringify(value));
3824
+ }
3825
+ function toSubmit(value, customType) {
3826
+ if (customType === "bigint")
3827
+ return BigInt(value);
3828
+ return JSON.parse(replaceStringToToken(value), reviver);
3700
3829
  }
3701
3830
 
3702
- // src/core/general/app-record.ts
3703
- async function setActiveAppRecord(appRecord) {
3704
- await registerComponentsDevTools(appRecord.app);
3705
- devtoolsState.activeAppRecord = appRecord;
3706
- devtoolsState.activeAppRecordId = `${appRecord.id}`;
3707
- registerPlugin({
3708
- app: appRecord.app,
3709
- api: appRecord.api
3710
- });
3831
+ // src/shared/util.ts
3832
+ function stringify(data) {
3833
+ return stringifyCircularAutoChunks(data, stringifyReplacer);
3711
3834
  }
3712
- async function toggleAppRecord(id) {
3713
- devtoolsContext.componentPluginHookBuffer.forEach((cleanup) => cleanup());
3714
- devtoolsContext.api.clear();
3715
- devtoolsContext.clear();
3716
- const appRecord = devtoolsState.appRecords.find((record) => record.id === id);
3717
- if (appRecord) {
3718
- devtoolsState.pluginBuffer = devtoolsState.pluginBuffer.filter(([plugin]) => plugin.id !== "components");
3719
- const api = new DevToolsPluginApi();
3720
- appRecord.api = api;
3721
- setActiveAppRecord(appRecord);
3722
- window.postMessage({
3723
- event: "toggle-app-record",
3724
- target: "vue-devtools"
3725
- });
3726
- }
3835
+ function parse(data, revive2 = false) {
3836
+ if (data == void 0)
3837
+ return {};
3838
+ return revive2 ? parseCircularAutoChunks(data, reviver) : parseCircularAutoChunks(data);
3839
+ }
3840
+
3841
+ // src/shared/time.ts
3842
+ init_cjs_shims();
3843
+ function now() {
3844
+ return Date.now();
3727
3845
  }
3728
3846
 
3847
+ // src/shared/env.ts
3848
+ init_cjs_shims();
3849
+
3729
3850
  // src/core/custom-tab/index.ts
3730
3851
  init_cjs_shims();
3731
3852
  function addCustomTab(tab) {
@@ -3748,18 +3869,18 @@ function removeCustomCommand(actionId) {
3748
3869
  devtoolsState.commands.splice(index, 1);
3749
3870
  }
3750
3871
 
3751
- // src/core/vue-inspector/index.ts
3872
+ // src/core/component-inspector/index.ts
3752
3873
  init_cjs_shims();
3753
- var import_devtools_shared10 = require("@vue/devtools-shared");
3754
- var _a7, _b7;
3755
- (_b7 = (_a7 = import_devtools_shared10.target).__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__) != null ? _b7 : _a7.__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__ = true;
3874
+ var import_devtools_shared8 = require("@vue/devtools-shared");
3875
+ var _a3, _b3;
3876
+ (_b3 = (_a3 = import_devtools_shared8.target).__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__) != null ? _b3 : _a3.__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__ = true;
3756
3877
  function toggleComponentInspectorEnabled(enabled) {
3757
- import_devtools_shared10.target.__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__ = enabled;
3878
+ import_devtools_shared8.target.__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__ = enabled;
3758
3879
  }
3759
3880
  function waitForInspectorInit(cb) {
3760
3881
  let total = 0;
3761
3882
  const timer = setInterval(() => {
3762
- if (import_devtools_shared10.target.__VUE_INSPECTOR__) {
3883
+ if (import_devtools_shared8.target.__VUE_INSPECTOR__) {
3763
3884
  clearInterval(timer);
3764
3885
  total += 30;
3765
3886
  cb();
@@ -3770,22 +3891,20 @@ function waitForInspectorInit(cb) {
3770
3891
  }, 30);
3771
3892
  }
3772
3893
  function setupInspector() {
3773
- const inspector = import_devtools_shared10.target.__VUE_INSPECTOR__;
3894
+ const inspector = import_devtools_shared8.target.__VUE_INSPECTOR__;
3774
3895
  const _openInEditor = inspector.openInEditor;
3775
3896
  inspector.openInEditor = async (...params) => {
3776
3897
  inspector.disable();
3777
3898
  _openInEditor(...params);
3778
3899
  };
3779
3900
  }
3780
- function getVueInspector() {
3901
+ function getComponentInspector() {
3781
3902
  return new Promise((resolve) => {
3782
- if (!import_devtools_shared10.target.__VUE_DEVTOOLS_COMPONENT_INSPECTOR_ENABLED__)
3783
- resolve(null);
3784
3903
  function setup() {
3785
3904
  setupInspector();
3786
- resolve(import_devtools_shared10.target.__VUE_INSPECTOR__);
3905
+ resolve(import_devtools_shared8.target.__VUE_INSPECTOR__);
3787
3906
  }
3788
- if (!import_devtools_shared10.target.__VUE_INSPECTOR__) {
3907
+ if (!import_devtools_shared8.target.__VUE_INSPECTOR__) {
3789
3908
  waitForInspectorInit(() => {
3790
3909
  setup();
3791
3910
  });
@@ -3795,271 +3914,117 @@ function getVueInspector() {
3795
3914
  });
3796
3915
  }
3797
3916
 
3798
- // src/core/component-inspector/index.ts
3917
+ // src/core/open-in-editor/index.ts
3799
3918
  init_cjs_shims();
3800
- var CONTAINER_ELEMENT_ID = "__vue-devtools-component-inspector__";
3801
- var CARD_ELEMENT_ID = "__vue-devtools-component-inspector__card__";
3802
- var COMPONENT_NAME_ELEMENT_ID = "__vue-devtools-component-inspector__name__";
3803
- var INDICATOR_ELEMENT_ID = "__vue-devtools-component-inspector__indicator__";
3804
- var containerStyles = {
3805
- display: "block",
3806
- zIndex: 2147483640,
3807
- position: "fixed",
3808
- backgroundColor: "#42b88325",
3809
- border: "1px solid #42b88350",
3810
- borderRadius: "5px",
3811
- transition: "all 0.1s ease-in",
3812
- pointerEvents: "none"
3813
- };
3814
- var cardStyles = {
3815
- fontFamily: "Arial, Helvetica, sans-serif",
3816
- padding: "5px 8px",
3817
- borderRadius: "4px",
3818
- textAlign: "left",
3819
- position: "absolute",
3820
- left: 0,
3821
- color: "#e9e9e9",
3822
- fontSize: "14px",
3823
- fontWeight: 600,
3824
- lineHeight: "24px",
3825
- backgroundColor: "#42b883",
3826
- boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)"
3827
- };
3828
- var indicatorStyles = {
3829
- display: "inline-block",
3830
- fontWeight: 400,
3831
- fontStyle: "normal",
3832
- fontSize: "12px",
3833
- opacity: 0.7
3834
- };
3835
- function getContainerElement() {
3836
- return document.getElementById(CONTAINER_ELEMENT_ID);
3837
- }
3838
- function getCardElement() {
3839
- return document.getElementById(CARD_ELEMENT_ID);
3840
- }
3841
- function getIndicatorElement() {
3842
- return document.getElementById(INDICATOR_ELEMENT_ID);
3843
- }
3844
- function getNameElement() {
3845
- return document.getElementById(COMPONENT_NAME_ELEMENT_ID);
3846
- }
3847
- function getStyles(bounds) {
3848
- return {
3849
- left: `${Math.round(bounds.left * 100) / 100}px`,
3850
- top: `${Math.round(bounds.top * 100) / 100}px`,
3851
- width: `${Math.round(bounds.width * 100) / 100}px`,
3852
- height: `${Math.round(bounds.height * 100) / 100}px`
3853
- };
3854
- }
3855
- function create(options) {
3856
- var _a9;
3857
- const containerEl = document.createElement("div");
3858
- containerEl.id = (_a9 = options.elementId) != null ? _a9 : CONTAINER_ELEMENT_ID;
3859
- Object.assign(containerEl.style, {
3860
- ...containerStyles,
3861
- ...getStyles(options.bounds),
3862
- ...options.style
3863
- });
3864
- const cardEl = document.createElement("span");
3865
- cardEl.id = CARD_ELEMENT_ID;
3866
- Object.assign(cardEl.style, {
3867
- ...cardStyles,
3868
- top: options.bounds.top < 35 ? 0 : "-35px"
3869
- });
3870
- const nameEl = document.createElement("span");
3871
- nameEl.id = COMPONENT_NAME_ELEMENT_ID;
3872
- nameEl.innerHTML = `&lt;${options.name}&gt;&nbsp;&nbsp;`;
3873
- const indicatorEl = document.createElement("i");
3874
- indicatorEl.id = INDICATOR_ELEMENT_ID;
3875
- indicatorEl.innerHTML = `${Math.round(options.bounds.width * 100) / 100} x ${Math.round(options.bounds.height * 100) / 100}`;
3876
- Object.assign(indicatorEl.style, indicatorStyles);
3877
- cardEl.appendChild(nameEl);
3878
- cardEl.appendChild(indicatorEl);
3879
- containerEl.appendChild(cardEl);
3880
- document.body.appendChild(containerEl);
3881
- return containerEl;
3882
- }
3883
- function update(options) {
3884
- const containerEl = getContainerElement();
3885
- const cardEl = getCardElement();
3886
- const nameEl = getNameElement();
3887
- const indicatorEl = getIndicatorElement();
3888
- if (containerEl) {
3889
- Object.assign(containerEl.style, {
3890
- ...containerStyles,
3891
- ...getStyles(options.bounds)
3892
- });
3893
- Object.assign(cardEl.style, {
3894
- top: options.bounds.top < 35 ? 0 : "-35px"
3895
- });
3896
- nameEl.innerHTML = `&lt;${options.name}&gt;&nbsp;&nbsp;`;
3897
- indicatorEl.innerHTML = `${Math.round(options.bounds.width * 100) / 100} x ${Math.round(options.bounds.height * 100) / 100}`;
3898
- }
3899
- }
3900
- function toggleComponentInspector(options) {
3901
- if (options.visible) {
3902
- const instance = getComponentInstance(devtoolsContext.appRecord, options.id);
3903
- if (instance && (options.bounds.width || options.bounds.height)) {
3904
- const name = getInstanceName(instance);
3905
- const el = getContainerElement();
3906
- el ? update({ ...options, name }) : create({ ...options, name });
3907
- }
3908
- } else {
3909
- const el = getContainerElement();
3910
- if (el)
3911
- el.style.display = "none";
3912
- }
3913
- }
3914
- function highlight(instance) {
3915
- const bounds = getComponentBoundingRect(instance);
3916
- const name = getInstanceName(instance);
3917
- const container = getContainerElement();
3918
- container ? update({ bounds, name }) : create({ bounds, name });
3919
- }
3920
- function unhighlight() {
3921
- const el = getContainerElement();
3922
- if (el)
3923
- el.style.display = "none";
3924
- }
3925
- var inspectInstance = null;
3926
- function inspectFn(e) {
3927
- const target8 = e.target;
3928
- if (target8) {
3929
- const instance = target8.__vueParentComponent;
3930
- if (instance) {
3931
- inspectInstance = instance;
3932
- const el = instance.vnode.el;
3933
- if (el) {
3934
- const bounds = getComponentBoundingRect(instance);
3935
- const name = getInstanceName(instance);
3936
- const container = getContainerElement();
3937
- container ? update({ bounds, name }) : create({ bounds, name });
3938
- }
3919
+ var import_devtools_shared9 = require("@vue/devtools-shared");
3920
+ function openInEditor(options = {}) {
3921
+ const { file, line = 0, column = 0 } = options;
3922
+ if (file) {
3923
+ const baseUrl = window.location.origin;
3924
+ if (devtoolsState.vitePluginDetected) {
3925
+ import_devtools_shared9.target.__VUE_INSPECTOR__.openInEditor(baseUrl, file, line, column);
3926
+ } else {
3939
3927
  }
3940
3928
  }
3941
3929
  }
3942
- function selectComponentFn(e, cb) {
3943
- var _a9;
3944
- e.preventDefault();
3945
- e.stopPropagation();
3946
- if (inspectInstance) {
3947
- const app = (_a9 = devtoolsContext.appRecord) == null ? void 0 : _a9.app;
3948
- getComponentId({
3949
- app,
3950
- uid: app.uid,
3951
- instance: inspectInstance
3952
- }).then((id) => {
3953
- cb(id);
3954
- });
3955
- }
3956
- }
3957
- function inspectComponentInspector() {
3958
- window.addEventListener("mouseover", inspectFn);
3959
- return new Promise((resolve) => {
3960
- function onSelect(e) {
3961
- e.preventDefault();
3962
- e.stopPropagation();
3963
- selectComponentFn(e, (id) => {
3964
- window.removeEventListener("click", onSelect);
3965
- window.removeEventListener("mouseover", inspectFn);
3966
- const el = getContainerElement();
3967
- if (el)
3968
- el.style.display = "none";
3969
- resolve(JSON.stringify({ id }));
3970
- });
3971
- }
3972
- window.addEventListener("click", onSelect);
3973
- });
3974
- }
3975
- function scrollToComponent(options) {
3976
- const instance = getComponentInstance(devtoolsContext.appRecord, options.id);
3977
- if (instance) {
3978
- const [el] = getRootElementsFromComponentInstance(instance);
3979
- if (typeof el.scrollIntoView === "function") {
3980
- el.scrollIntoView({
3981
- behavior: "smooth"
3982
- });
3983
- } else {
3984
- const bounds = getComponentBoundingRect(instance);
3985
- const scrollTarget = document.createElement("div");
3986
- const styles = {
3987
- ...getStyles(bounds),
3988
- position: "absolute"
3989
- };
3990
- Object.assign(scrollTarget.style, styles);
3991
- document.body.appendChild(scrollTarget);
3992
- scrollTarget.scrollIntoView({
3993
- behavior: "smooth"
3994
- });
3995
- setTimeout(() => {
3996
- document.body.removeChild(scrollTarget);
3997
- }, 2e3);
3998
- }
3999
- setTimeout(() => {
4000
- const bounds = getComponentBoundingRect(instance);
4001
- if (bounds.width || bounds.height) {
4002
- const name = getInstanceName(instance);
4003
- const el2 = getContainerElement();
4004
- el2 ? update({ ...options, name, bounds }) : create({ ...options, name, bounds });
4005
- setTimeout(() => {
4006
- if (el2)
4007
- el2.style.display = "none";
4008
- }, 1500);
4009
- }
4010
- }, 1200);
3930
+
3931
+ // src/api/on.ts
3932
+ init_cjs_shims();
3933
+ var on2 = {
3934
+ // #region compatible with old devtools
3935
+ addTimelineEvent(fn) {
3936
+ apiHooks.hook("timeline:add-event" /* ADD_TIMELINE_EVENT */, fn);
3937
+ },
3938
+ inspectComponent(fn) {
3939
+ apiHooks.hook("component-state:inspect" /* COMPONENT_STATE_INSPECT */, fn);
3940
+ },
3941
+ visitComponentTree(fn) {
3942
+ apiHooks.hook("component-tree:visit" /* VISIT_COMPONENT_TREE */, fn);
3943
+ },
3944
+ getInspectorTree(fn) {
3945
+ apiHooks.hook("inspector-tree:get" /* GET_INSPECTOR_TREE */, fn);
3946
+ },
3947
+ getInspectorState(fn) {
3948
+ apiHooks.hook("inspector-state:get" /* GET_INSPECTOR_STATE */, fn);
3949
+ },
3950
+ sendInspectorTree(fn) {
3951
+ apiHooks.hook("inspector-tree:send" /* SEND_INSPECTOR_TREE */, fn);
3952
+ },
3953
+ sendInspectorState(fn) {
3954
+ apiHooks.hook("inspector-state:send" /* SEND_INSPECTOR_STATE */, fn);
3955
+ },
3956
+ editInspectorState(fn) {
3957
+ apiHooks.hook("inspector-state:edit" /* EDIT_INSPECTOR_STATE */, fn);
3958
+ },
3959
+ editComponentState() {
3960
+ },
3961
+ componentUpdated(fn) {
3962
+ apiHooks.hook("component:updated" /* COMPONENT_UPDATED */, fn);
3963
+ },
3964
+ // #endregion compatible with old devtools
3965
+ // router
3966
+ routerInfoUpdated(fn) {
3967
+ apiHooks.hook("router-info:updated" /* ROUTER_INFO_UPDATED */, fn);
3968
+ },
3969
+ // component highlighter
3970
+ getComponentBoundingRect(fn) {
3971
+ apiHooks.hook("component-bounding-rect:get" /* GET_COMPONENT_BOUNDING_RECT */, fn);
3972
+ },
3973
+ // custom tabs
3974
+ customTabsUpdated(fn) {
3975
+ apiHooks.hook("custom-tabs:updated" /* CUSTOM_TABS_UPDATED */, fn);
3976
+ },
3977
+ // custom commands
3978
+ customCommandsUpdated(fn) {
3979
+ apiHooks.hook("custom-commands:updated" /* CUSTOM_COMMANDS_UPDATED */, fn);
3980
+ },
3981
+ devtoolsStateUpdated(fn) {
3982
+ apiHooks.hook("devtools:state-updated" /* DEVTOOLS_STATE_UPDATED */, fn);
4011
3983
  }
4012
- }
3984
+ };
4013
3985
 
4014
3986
  // src/api/off.ts
4015
3987
  init_cjs_shims();
4016
- function clear() {
3988
+ function remove() {
4017
3989
  apiHooks.removeAllHooks();
4018
3990
  }
4019
3991
 
4020
- // src/api/index.ts
3992
+ // src/api/api.ts
4021
3993
  var DevToolsPluginApi = class {
4022
3994
  constructor() {
3995
+ this.clear = remove;
4023
3996
  this.on = on2;
4024
- this.clear = clear;
4025
3997
  }
4026
- toggleApp(id) {
4027
- return toggleAppRecord(id);
4028
- }
4029
- addTimelineEvent(payload) {
4030
- apiHooks.callHook("timeline:add-event" /* ADD_TIMELINE_EVENT */, payload);
3998
+ // #region compatible with old devtools
3999
+ // timeline layer
4000
+ addTimelineLayer(payload) {
4001
+ addTimelineLayer(payload);
4031
4002
  }
4032
- toggleComponentInspector(payload) {
4033
- return toggleComponentInspector(payload);
4003
+ // timeline event
4004
+ addTimelineEvent(...params) {
4005
+ apiHooks.callHook("timeline:add-event" /* ADD_TIMELINE_EVENT */, ...params);
4034
4006
  }
4035
- inspectComponentInspector() {
4036
- return inspectComponentInspector();
4007
+ // add inspector
4008
+ addInspector(payload) {
4009
+ addInspector({
4010
+ id: payload.id,
4011
+ nodeId: "",
4012
+ filter: "",
4013
+ treeFilterPlaceholder: payload.treeFilterPlaceholder || ""
4014
+ });
4037
4015
  }
4038
- scrollToComponent(payload) {
4039
- return scrollToComponent(payload);
4016
+ highlightElement(instance) {
4017
+ highlight(instance);
4040
4018
  }
4041
- getComponentBoundingRect(payload) {
4042
- const { inspectorId, instanceId = "" } = payload;
4043
- const _payload = {
4044
- app: devtoolsContext.appRecord.app,
4045
- inspectorId,
4046
- instanceId,
4047
- rect: {
4048
- top: 0,
4049
- left: 0,
4050
- width: 0,
4051
- height: 0
4052
- }
4053
- };
4054
- apiHooks.callHookWith((callbacks) => {
4055
- callbacks.map((cb) => cb(_payload));
4056
- }, "component-bounding-rect:get" /* GET_COMPONENT_BOUNDING_RECT */);
4057
- return stringify(_payload.rect);
4019
+ unhighlightElement() {
4020
+ unhighlight();
4058
4021
  }
4022
+ // inspector
4059
4023
  async getInspectorTree(payload = {}) {
4024
+ var _a10;
4060
4025
  const { inspectorId, filter = "", instanceId = "" } = payload;
4061
4026
  const _payload = {
4062
- app: devtoolsContext.appRecord.app,
4027
+ app: (_a10 = devtoolsContext.appRecord) == null ? void 0 : _a10.app,
4063
4028
  inspectorId,
4064
4029
  instanceId,
4065
4030
  filter,
@@ -4077,9 +4042,10 @@ var DevToolsPluginApi = class {
4077
4042
  return stringify(_payload.rootNodes);
4078
4043
  }
4079
4044
  getInspectorState(payload = {}) {
4045
+ var _a10;
4080
4046
  const { inspectorId, nodeId } = payload;
4081
4047
  const _payload = {
4082
- app: devtoolsContext.appRecord.app,
4048
+ app: (_a10 = devtoolsContext.appRecord) == null ? void 0 : _a10.app,
4083
4049
  inspectorId,
4084
4050
  nodeId
4085
4051
  };
@@ -4094,10 +4060,11 @@ var DevToolsPluginApi = class {
4094
4060
  return stringify(state);
4095
4061
  }
4096
4062
  async editInspectorState(payload) {
4063
+ var _a10;
4097
4064
  const stateEditor2 = new StateEditor();
4098
4065
  apiHooks.callHook("inspector-state:edit" /* EDIT_INSPECTOR_STATE */, {
4099
4066
  ...payload,
4100
- app: devtoolsContext.appRecord.app,
4067
+ app: (_a10 = devtoolsContext.appRecord) == null ? void 0 : _a10.app,
4101
4068
  set: (obj, path = payload.path, value = payload.state.value, cb) => {
4102
4069
  stateEditor2.set(obj, path, value, cb || stateEditor2.createDefaultSetCallback(payload.state));
4103
4070
  }
@@ -4125,50 +4092,17 @@ var DevToolsPluginApi = class {
4125
4092
  apiHooks.callHook("inspector-state:send" /* SEND_INSPECTOR_STATE */, stringify({ ...parse(res), inspectorId }));
4126
4093
  }
4127
4094
  }
4128
- addCustomTab(tab) {
4129
- addCustomTab(tab);
4130
- }
4131
- addCustomCommand(action) {
4132
- addCustomCommand(action);
4133
- }
4134
- removeCustomCommand(actionId) {
4135
- removeCustomCommand(actionId);
4136
- }
4137
- addInspector(payload) {
4138
- var _a9;
4139
- addInspector({
4140
- id: payload.id,
4141
- nodeId: "",
4142
- filter: "",
4143
- treeFilterPlaceholder: (_a9 = payload.treeFilterPlaceholder) != null ? _a9 : ""
4144
- });
4145
- }
4146
- openInEditor(payload) {
4147
- openInEditor(payload);
4148
- }
4149
- highlightElement(instance) {
4150
- highlight(instance);
4151
- }
4152
- unhighlightElement() {
4153
- unhighlight();
4154
- }
4155
4095
  async getComponentInstances(app) {
4156
4096
  const appRecord = app.__VUE_DEVTOOLS_APP_RECORD__;
4157
4097
  const appId = appRecord.id.toString();
4158
4098
  const instances = [...appRecord.instanceMap].filter(([key]) => key.split(":")[0] === appId).map(([, instance]) => instance);
4159
4099
  return instances;
4160
4100
  }
4161
- // Vite only
4162
- getVueInspector() {
4163
- return getVueInspector();
4164
- }
4165
- visitComponentTree(payload) {
4166
- apiHooks.callHook("component-tree:visit" /* VISIT_COMPONENT_TREE */, payload);
4167
- }
4168
- addTimelineLayer(payload) {
4169
- addTimelineLayer(payload);
4101
+ visitComponentTree(...params) {
4102
+ apiHooks.callHook("component-tree:visit" /* VISIT_COMPONENT_TREE */, ...params);
4170
4103
  }
4171
4104
  notifyComponentUpdate() {
4105
+ apiHooks.callHook("component:updated" /* COMPONENT_UPDATED */);
4172
4106
  }
4173
4107
  now() {
4174
4108
  return now();
@@ -4178,83 +4112,255 @@ var DevToolsPluginApi = class {
4178
4112
  logStoreChanges: null
4179
4113
  };
4180
4114
  }
4115
+ // #endregion compatible with old devtools
4116
+ // #region highlighter
4117
+ toggleComponentInspector(...params) {
4118
+ return toggleComponentHighLighter(...params);
4119
+ }
4120
+ inspectComponentInspector() {
4121
+ return inspectComponentHighLighter();
4122
+ }
4123
+ scrollToComponent(...params) {
4124
+ return scrollToComponent(...params);
4125
+ }
4126
+ getComponentBoundingRect(...params) {
4127
+ var _a10;
4128
+ const { inspectorId, instanceId = "" } = params[0];
4129
+ const _payload = {
4130
+ app: (_a10 = devtoolsContext.appRecord) == null ? void 0 : _a10.app,
4131
+ inspectorId,
4132
+ instanceId,
4133
+ rect: {
4134
+ top: 0,
4135
+ left: 0,
4136
+ width: 0,
4137
+ height: 0
4138
+ }
4139
+ };
4140
+ apiHooks.callHookWith((callbacks) => {
4141
+ callbacks.map((cb) => cb(_payload));
4142
+ }, "component-bounding-rect:get" /* GET_COMPONENT_BOUNDING_RECT */);
4143
+ return stringify(_payload.rect);
4144
+ }
4145
+ // #endregion highlighter
4146
+ toggleApp(id) {
4147
+ return toggleActiveAppRecord(id);
4148
+ }
4149
+ addCustomTab(tab) {
4150
+ addCustomTab(tab);
4151
+ }
4152
+ addCustomCommand(action) {
4153
+ addCustomCommand(action);
4154
+ }
4155
+ removeCustomCommand(actionId) {
4156
+ removeCustomCommand(actionId);
4157
+ }
4158
+ openInEditor(payload) {
4159
+ openInEditor(payload);
4160
+ }
4161
+ getVueInspector() {
4162
+ return getComponentInspector();
4163
+ }
4181
4164
  };
4182
4165
 
4183
- // src/core/general/app.ts
4166
+ // src/state/state.ts
4167
+ var STATE_KEY = "__VUE_DEVTOOLS_GLOBAL_STATE__";
4168
+ function initStateFactory() {
4169
+ return {
4170
+ connected: false,
4171
+ clientConnected: false,
4172
+ appRecords: [],
4173
+ activeAppRecord: null,
4174
+ selectedComponentId: null,
4175
+ pluginBuffer: [],
4176
+ tabs: [],
4177
+ commands: [],
4178
+ vitePluginDetected: false,
4179
+ activeAppRecordId: null
4180
+ };
4181
+ }
4182
+ var _a4, _b4;
4183
+ (_b4 = (_a4 = import_devtools_shared10.target)[STATE_KEY]) != null ? _b4 : _a4[STATE_KEY] = initStateFactory();
4184
+ var callStateUpdatedHook = (0, import_perfect_debounce3.debounce)((state, oldState) => {
4185
+ apiHooks.callHook("devtools:state-updated" /* DEVTOOLS_STATE_UPDATED */, state, oldState);
4186
+ }, 80);
4187
+ var callConnectedUpdatedHook = (0, import_perfect_debounce3.debounce)((state, oldState) => {
4188
+ apiHooks.callHook("devtools:connected-updated" /* DEVTOOLS_CONNECTED_UPDATED */, state, oldState);
4189
+ }, 80);
4190
+ var devtoolsState = new Proxy(import_devtools_shared10.target[STATE_KEY], {
4191
+ get(target9, property) {
4192
+ return import_devtools_shared10.target[STATE_KEY][property];
4193
+ },
4194
+ deleteProperty(target9, property) {
4195
+ delete target9[property];
4196
+ return true;
4197
+ },
4198
+ set(target9, property, value) {
4199
+ const oldState = { ...import_devtools_shared10.target[STATE_KEY] };
4200
+ target9[property] = value;
4201
+ import_devtools_shared10.target[STATE_KEY][property] = value;
4202
+ callStateUpdatedHook(import_devtools_shared10.target[STATE_KEY], oldState);
4203
+ if (["connected", "clientConnected"].includes(property.toString()) && oldState[property] !== value)
4204
+ callConnectedUpdatedHook(import_devtools_shared10.target[STATE_KEY], oldState);
4205
+ return true;
4206
+ }
4207
+ });
4208
+ Object.defineProperty(devtoolsState.tabs, "push", {
4209
+ configurable: true,
4210
+ value(...items) {
4211
+ const result = Array.prototype.push.apply(this, items);
4212
+ devtoolsState.tabs = this;
4213
+ apiHooks.callHook("custom-tabs:updated" /* CUSTOM_TABS_UPDATED */, this);
4214
+ return result;
4215
+ }
4216
+ });
4217
+ ["push", "splice"].forEach((method) => {
4218
+ Object.defineProperty(devtoolsState.commands, method, {
4219
+ configurable: true,
4220
+ value(...args) {
4221
+ const result = Array.prototype[method].apply(this, args);
4222
+ devtoolsState.commands = this;
4223
+ apiHooks.callHook("custom-commands:updated" /* CUSTOM_COMMANDS_UPDATED */, this);
4224
+ return result;
4225
+ }
4226
+ });
4227
+ });
4228
+
4229
+ // src/state/app-record.ts
4230
+ init_cjs_shims();
4231
+ var import_devtools_shared13 = require("@vue/devtools-shared");
4232
+
4233
+ // src/state/router.ts
4184
4234
  init_cjs_shims();
4185
4235
  var import_devtools_shared11 = require("@vue/devtools-shared");
4186
- var import_speakingurl = __toESM(require_speakingurl2(), 1);
4187
- var _a8, _b8;
4188
- var appRecordInfo = (_b8 = (_a8 = import_devtools_shared11.target).__VUE_DEVTOOLS_APP_RECROD_INFO__) != null ? _b8 : _a8.__VUE_DEVTOOLS_APP_RECROD_INFO__ = {
4189
- id: 0,
4190
- appIds: /* @__PURE__ */ new Set()
4236
+ var ROUTER_KEY = "__VUE_DEVTOOLS_ROUTER__";
4237
+ var ROUTER_INFO_KEY = "__VUE_DEVTOOLS_ROUTER_INFO__";
4238
+ var _a5, _b5;
4239
+ (_b5 = (_a5 = import_devtools_shared11.target)[ROUTER_INFO_KEY]) != null ? _b5 : _a5[ROUTER_INFO_KEY] = {
4240
+ currentRoute: null,
4241
+ routes: []
4191
4242
  };
4192
- function getAppRecordName(app, fallbackName) {
4193
- var _a9;
4194
- return ((_a9 = app == null ? void 0 : app._component) == null ? void 0 : _a9.name) || `App ${fallbackName}`;
4243
+ var _a6, _b6;
4244
+ (_b6 = (_a6 = import_devtools_shared11.target)[ROUTER_KEY]) != null ? _b6 : _a6[ROUTER_KEY] = null;
4245
+ var devtoolsRouterInfo = new Proxy(import_devtools_shared11.target[ROUTER_INFO_KEY], {
4246
+ get(target9, property) {
4247
+ return import_devtools_shared11.target[ROUTER_INFO_KEY][property];
4248
+ }
4249
+ });
4250
+
4251
+ // src/state/context.ts
4252
+ init_cjs_shims();
4253
+ var import_devtools_shared12 = require("@vue/devtools-shared");
4254
+ var CONTEXT_KEY = "__VUE_DEVTOOLS_CONTEXT__";
4255
+ function initContextFactory() {
4256
+ return {
4257
+ appRecord: null,
4258
+ api: null,
4259
+ inspector: [],
4260
+ timelineLayer: [],
4261
+ routerInfo: {},
4262
+ router: null,
4263
+ activeInspectorTreeId: "",
4264
+ componentPluginHookBuffer: []
4265
+ };
4195
4266
  }
4196
- function getAppRootInstance(app) {
4197
- var _a9, _b9, _c, _d;
4198
- if (app._instance)
4199
- return app._instance;
4200
- else if ((_b9 = (_a9 = app._container) == null ? void 0 : _a9._vnode) == null ? void 0 : _b9.component)
4201
- return (_d = (_c = app._container) == null ? void 0 : _c._vnode) == null ? void 0 : _d.component;
4267
+ var _a7, _b7;
4268
+ (_b7 = (_a7 = import_devtools_shared12.target)[CONTEXT_KEY]) != null ? _b7 : _a7[CONTEXT_KEY] = initContextFactory();
4269
+ function resetDevToolsContext() {
4270
+ import_devtools_shared12.target[CONTEXT_KEY] = initContextFactory();
4202
4271
  }
4203
- function getAppRecordId(app, defaultId) {
4204
- if (app.__VUE_DEVTOOLS_APP_RECORD_ID__ != null)
4205
- return app.__VUE_DEVTOOLS_APP_RECORD_ID__;
4206
- let id = defaultId != null ? defaultId : (appRecordInfo.id++).toString();
4207
- if (defaultId && appRecordInfo.appIds.has(id)) {
4208
- let count = 1;
4209
- while (appRecordInfo.appIds.has(`${defaultId}_${count}`))
4210
- count++;
4211
- id = `${defaultId}_${count}`;
4272
+ var devtoolsContext = new Proxy(import_devtools_shared12.target[CONTEXT_KEY], {
4273
+ get(target9, property) {
4274
+ if (property === "router")
4275
+ return import_devtools_shared12.target[ROUTER_KEY];
4276
+ else if (property === "clear")
4277
+ return resetDevToolsContext;
4278
+ return import_devtools_shared12.target[CONTEXT_KEY][property];
4279
+ },
4280
+ set(target9, property, value) {
4281
+ import_devtools_shared12.target[CONTEXT_KEY][property] = value;
4282
+ return true;
4212
4283
  }
4213
- appRecordInfo.appIds.add(id);
4214
- app.__VUE_DEVTOOLS_APP_RECORD_ID__ = id;
4215
- return id;
4216
- }
4217
- function createAppRecord(app) {
4218
- const rootInstance = getAppRootInstance(app);
4219
- if (rootInstance) {
4220
- appRecordInfo.id++;
4221
- const name = getAppRecordName(app, appRecordInfo.id.toString());
4222
- const id = getAppRecordId(app, (0, import_speakingurl.default)(name));
4223
- const record = {
4224
- id,
4225
- name,
4226
- instanceMap: /* @__PURE__ */ new Map(),
4227
- rootInstance
4228
- };
4229
- app.__VUE_DEVTOOLS_APP_RECORD__ = record;
4230
- const rootId = `${record.id}:root`;
4231
- record.instanceMap.set(rootId, record.rootInstance);
4232
- record.rootInstance.__VUE_DEVTOOLS_UID__ = rootId;
4233
- return record;
4234
- } else {
4235
- return {};
4284
+ });
4285
+
4286
+ // src/state/app-record.ts
4287
+ var devtoolsAppRecords = new Proxy(devtoolsState.appRecords, {
4288
+ get(_, property) {
4289
+ if (property === "value")
4290
+ return devtoolsState.appRecords;
4291
+ else if (property === "active")
4292
+ return devtoolsState.activeAppRecord;
4293
+ else if (property === "activeId")
4294
+ return devtoolsState.activeAppRecordId;
4295
+ },
4296
+ set(target9, property, value) {
4297
+ var _a10;
4298
+ const oldState = { ...devtoolsState };
4299
+ if (property === "value") {
4300
+ devtoolsState.appRecords = value;
4301
+ } else if (property === "active") {
4302
+ const _value = value;
4303
+ devtoolsState.activeAppRecord = _value;
4304
+ devtoolsContext.appRecord = _value;
4305
+ devtoolsContext.api = _value.api;
4306
+ devtoolsContext.inspector = (_a10 = _value.inspector) != null ? _a10 : [];
4307
+ normalizeRouterInfo(value);
4308
+ devtoolsContext.routerInfo = devtoolsRouterInfo;
4309
+ } else if (property === "activeId") {
4310
+ devtoolsState.activeAppRecordId = value;
4311
+ }
4312
+ callStateUpdatedHook(devtoolsState, oldState);
4313
+ if (["connected", "clientConnected"].includes(property.toString()) && oldState[property] !== value)
4314
+ callConnectedUpdatedHook(devtoolsState, oldState);
4315
+ return true;
4236
4316
  }
4317
+ });
4318
+ var _a8, _b8;
4319
+ var appRecordInfo = (_b8 = (_a8 = import_devtools_shared13.target).__VUE_DEVTOOLS_APP_RECROD_INFO__) != null ? _b8 : _a8.__VUE_DEVTOOLS_APP_RECROD_INFO__ = {
4320
+ id: 0,
4321
+ appIds: /* @__PURE__ */ new Set()
4322
+ };
4323
+
4324
+ // src/state/env.ts
4325
+ init_cjs_shims();
4326
+ var import_devtools_shared14 = require("@vue/devtools-shared");
4327
+ var _a9, _b9;
4328
+ (_b9 = (_a9 = import_devtools_shared14.target).__VUE_DEVTOOLS_ENV__) != null ? _b9 : _a9.__VUE_DEVTOOLS_ENV__ = {
4329
+ vitePluginDetected: false
4330
+ };
4331
+ function getDevToolsEnv() {
4332
+ return import_devtools_shared14.target.__VUE_DEVTOOLS_ENV__;
4333
+ }
4334
+ function setDevToolsEnv(env) {
4335
+ import_devtools_shared14.target.__VUE_DEVTOOLS_ENV__ = {
4336
+ ...import_devtools_shared14.target.__VUE_DEVTOOLS_ENV__,
4337
+ ...env
4338
+ };
4237
4339
  }
4238
4340
 
4239
- // src/core/general/index.ts
4341
+ // src/core/index.ts
4240
4342
  function initDevTools() {
4241
- var _a9, _b9, _c;
4242
- devtoolsState.vitePluginDetected = !!import_devtools_shared12.target.__VUE_DEVTOOLS_VITE_PLUGIN_DETECTED__;
4243
- const isNewDevTools = ((_a9 = import_devtools_shared12.target.__VUE_DEVTOOLS_GLOBAL_HOOK__) == null ? void 0 : _a9.id) === "vue-devtools-next";
4244
- if (import_devtools_shared12.target.__VUE_DEVTOOLS_GLOBAL_HOOK__ && isNewDevTools)
4343
+ var _a10;
4344
+ devtoolsState.vitePluginDetected = getDevToolsEnv().vitePluginDetected;
4345
+ const isDevToolsNext = ((_a10 = import_devtools_shared15.target.__VUE_DEVTOOLS_GLOBAL_HOOK__) == null ? void 0 : _a10.id) === "vue-devtools-next";
4346
+ if (import_devtools_shared15.target.__VUE_DEVTOOLS_GLOBAL_HOOK__ && isDevToolsNext)
4245
4347
  return;
4246
- if (import_devtools_shared12.target.__VUE_DEVTOOLS_GLOBAL_HOOK__)
4348
+ if (import_devtools_shared15.target.__VUE_DEVTOOLS_GLOBAL_HOOK__)
4247
4349
  Object.assign(__VUE_DEVTOOLS_GLOBAL_HOOK__, createDevToolsHook());
4248
4350
  else
4249
- import_devtools_shared12.target.__VUE_DEVTOOLS_GLOBAL_HOOK__ = createDevToolsHook();
4250
- (_c = (_b9 = import_devtools_shared12.target).__VUE_DEVTOOLS_APP_RECORDS__) != null ? _c : _b9.__VUE_DEVTOOLS_APP_RECORDS__ = [];
4251
- hook.on.setupDevtoolsPlugin(collectRegisteredPlugin);
4351
+ import_devtools_shared15.target.__VUE_DEVTOOLS_GLOBAL_HOOK__ = createDevToolsHook();
4352
+ hook.on.setupDevtoolsPlugin((pluginDescriptor, setupFn) => {
4353
+ collectDevToolsPlugin(pluginDescriptor, setupFn);
4354
+ const { app, api } = devtoolsAppRecords.active || {};
4355
+ if (!app || !api)
4356
+ return;
4357
+ setupExternalPlugin([pluginDescriptor, setupFn], app, api);
4358
+ });
4252
4359
  hook.on.vueAppInit(async (app, version) => {
4253
- var _a10;
4254
4360
  const record = createAppRecord(app);
4255
4361
  const api = new DevToolsPluginApi();
4256
- devtoolsState.appRecords = [
4257
- ...(_a10 = devtoolsState.appRecords) != null ? _a10 : [],
4362
+ devtoolsAppRecords.value = [
4363
+ ...devtoolsAppRecords.value,
4258
4364
  {
4259
4365
  ...record,
4260
4366
  app,
@@ -4262,10 +4368,10 @@ function initDevTools() {
4262
4368
  api
4263
4369
  }
4264
4370
  ];
4265
- if (devtoolsState.appRecords.length === 1) {
4266
- await setActiveAppRecord(devtoolsState.appRecords[0]);
4371
+ if (devtoolsAppRecords.value.length === 1) {
4372
+ await setActiveAppRecord(devtoolsAppRecords.value[0]);
4267
4373
  devtoolsState.connected = true;
4268
- devtoolsHooks.callHook(import_devtools_schema3.DevToolsHooks.APP_CONNECTED);
4374
+ devtoolsHooks.callHook("app:connected" /* APP_CONNECTED */);
4269
4375
  }
4270
4376
  });
4271
4377
  subscribeDevToolsHook();
@@ -4305,40 +4411,29 @@ function onDevToolsClientConnected(fn) {
4305
4411
  var devtools = {
4306
4412
  state: devtoolsState,
4307
4413
  context: devtoolsContext,
4308
- init: initDevTools,
4309
4414
  hook,
4415
+ init: initDevTools,
4310
4416
  get api() {
4311
4417
  return devtoolsContext.api;
4312
4418
  }
4313
4419
  };
4314
4420
  // Annotate the CommonJS export names for ESM import in node:
4315
4421
  0 && (module.exports = {
4316
- ESC,
4317
- INFINITY,
4318
- MAX_ARRAY_SIZE,
4319
- MAX_STRING_SIZE,
4320
- NAN,
4321
- NEGATIVE_INFINITY,
4322
4422
  UNDEFINED,
4323
4423
  addCustomCommand,
4324
4424
  addCustomTab,
4325
4425
  devtools,
4326
- fnTypeRE,
4327
4426
  formatInspectorStateValue,
4328
4427
  getInspectorStateValueType,
4329
- getRawValue,
4330
- now,
4428
+ getRaw,
4331
4429
  onDevToolsClientConnected,
4332
4430
  onDevToolsConnected,
4333
4431
  parse,
4334
- rawTypeRE,
4335
4432
  removeCustomCommand,
4433
+ setDevToolsEnv,
4336
4434
  setupDevToolsPlugin,
4337
- specialTypeRE,
4338
4435
  stringify,
4339
- symbolRE,
4340
4436
  toEdit,
4341
4437
  toSubmit,
4342
- toggleComponentInspectorEnabled,
4343
- vueBuiltins
4438
+ toggleComponentInspectorEnabled
4344
4439
  });