@vitejs/devtools 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/{DockIcon-zZkKuxFy.js → DockIcon-7v-JouW5.js} +25 -25
  2. package/dist/DockStandalone-CX4RwLuJ.js +3243 -0
  3. package/dist/{LogItem-D-AbVX5q.js → LogItem-Ca0SsU39.js} +20 -17
  4. package/dist/{ViewBuiltinLogs-D9GVXA00.js → ViewBuiltinLogs-B_CLlali.js} +2 -2
  5. package/dist/{ViewBuiltinTerminals-afgLtRQP.js → ViewBuiltinTerminals-ZrMObMte.js} +2 -3
  6. package/dist/auth-state-DXCxEqSd.js +54 -0
  7. package/dist/build-static-Cb3vKjJS.js +49 -0
  8. package/dist/cli-commands.js +10 -45
  9. package/dist/client/inject.js +186 -3
  10. package/dist/client/standalone/assets/DockStandalone-BvXvOkmY.js +1 -0
  11. package/dist/client/standalone/assets/LogItem-BnVhub2j.js +1 -0
  12. package/dist/client/standalone/assets/ViewBuiltinLogs-rU-E-8qT.js +1 -0
  13. package/dist/client/standalone/assets/{ViewBuiltinTerminals-CpNVjAgX.js → ViewBuiltinTerminals-DqaYBA6Q.js} +2 -2
  14. package/dist/client/standalone/assets/{ViewJsonRender-CbWAIBeO.js → ViewJsonRender-De5eeIha.js} +3 -3
  15. package/dist/client/standalone/assets/dist-CAaP5Isp.js +1 -0
  16. package/dist/client/standalone/assets/iconify-C-CPDXMf.js +2 -0
  17. package/dist/client/standalone/assets/index-2_yFTdkG.js +3 -0
  18. package/dist/client/standalone/assets/index-DtZFMvER.css +1 -0
  19. package/dist/client/standalone/assets/runtime-core.esm-bundler-Bvz2jy0O.js +1 -0
  20. package/dist/client/standalone/index.html +6 -5
  21. package/dist/client/webcomponents.js +28 -25
  22. package/dist/{server-DhChc9gv.js → context-BWju7fup.js} +115 -54
  23. package/dist/{dist-CBtGbo90.js → dist-CCdqIez-.js} +124 -1
  24. package/dist/index.d.ts +41 -2
  25. package/dist/index.js +3 -4
  26. package/dist/internal.d.ts +1 -1
  27. package/dist/plugins-Dhpm6Ql_.js +59 -0
  28. package/dist/{popup-CAT8YohS.js → popup-DgYOsFy3.js} +113 -54
  29. package/dist/server-BQ4s1VXj.js +2 -0
  30. package/dist/{server-BuWZ1h8p.js → server-DSh-GQIq.js} +3 -56
  31. package/dist/server-ZWEvQMOm.js +50 -0
  32. package/dist/{standalone-CAJbdnf4.js → standalone-D_6Gsoqw.js} +2 -3
  33. package/package.json +8 -6
  34. package/dist/DockStandalone-BuMVHLt_.js +0 -1256
  35. package/dist/client/standalone/assets/DockStandalone-DvxQ5kAU.js +0 -1
  36. package/dist/client/standalone/assets/LogItem-Mx4UyReX.js +0 -1
  37. package/dist/client/standalone/assets/ViewBuiltinLogs-C4j4vgSn.js +0 -1
  38. package/dist/client/standalone/assets/dist-DIlAYcjk.js +0 -1
  39. package/dist/client/standalone/assets/index-BEyoIK7m.css +0 -1
  40. package/dist/client/standalone/assets/index-BGGAiDua.js +0 -4
  41. package/dist/client/standalone/assets/runtime-core.esm-bundler-CJlaYmKv.js +0 -1
  42. package/dist/plugins-DfC1vp4w.js +0 -31
  43. package/dist/server-Ca6LOTxO.js +0 -3
  44. /package/dist/{ViewJsonRender-DtluXw3F.js → ViewJsonRender-Cc5BPfnv.js} +0 -0
  45. /package/dist/{context-internal-BA4ba-FN.d.ts → context-internal-Ys7Zu3q3.d.ts} +0 -0
  46. /package/dist/{static-dump-Q0iG9hz3.js → static-dump-BqRb_x-O.js} +0 -0
@@ -1,12 +1,12 @@
1
- import { n as ansis_default, r as __commonJSMin, t as MARK_INFO } from "./constants-DfEeYo9W.js";
1
+ import { i as __exportAll, n as ansis_default, r as __commonJSMin, t as MARK_INFO } from "./constants-DfEeYo9W.js";
2
2
  import { n as createStorage, t as getInternalContext } from "./context-internal-DZpoJjMz.js";
3
- import { a as refreshTempAuthToken, i as getTempAuthToken, o as setPendingAuth, r as abortPendingAuth, t as createDevToolsMiddleware } from "./server-BuWZ1h8p.js";
3
+ import { a as setPendingAuth, i as refreshTempAuthToken, r as getTempAuthToken, t as abortPendingAuth } from "./auth-state-DXCxEqSd.js";
4
4
  import { t as isObject } from "./utils-HWI9S6d-.js";
5
5
  import { createDebug } from "obug";
6
6
  import { debounce } from "perfect-debounce";
7
7
  import { toDataURL } from "mlly";
8
- import { DEFAULT_STATE_USER_SETTINGS, DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID, DEVTOOLS_MOUNT_PATH } from "@vitejs/devtools-kit/constants";
9
8
  import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
9
+ import { DEFAULT_STATE_USER_SETTINGS } from "@vitejs/devtools-kit/constants";
10
10
  import { join } from "pathe";
11
11
  import { existsSync } from "node:fs";
12
12
  import { createSharedState } from "@vitejs/devtools-kit/utils/shared-state";
@@ -28,6 +28,61 @@ const ContextUtils = { createSimpleClientScript(fn) {
28
28
  };
29
29
  } };
30
30
  //#endregion
31
+ //#region src/node/host-commands.ts
32
+ var DevToolsCommandsHost = class {
33
+ commands = /* @__PURE__ */ new Map();
34
+ events = createEventEmitter();
35
+ constructor(context) {
36
+ this.context = context;
37
+ }
38
+ register(command) {
39
+ if (this.commands.has(command.id)) throw new Error(`Command "${command.id}" is already registered`);
40
+ this.commands.set(command.id, command);
41
+ this.events.emit("command:registered", this.toSerializable(command));
42
+ return {
43
+ id: command.id,
44
+ update: (patch) => {
45
+ if ("id" in patch) throw new Error(`Cannot change the id of a command. Use register() to add new commands.`);
46
+ const existing = this.commands.get(command.id);
47
+ if (!existing) throw new Error(`Command "${command.id}" is not registered`);
48
+ Object.assign(existing, patch);
49
+ this.events.emit("command:registered", this.toSerializable(existing));
50
+ },
51
+ unregister: () => this.unregister(command.id)
52
+ };
53
+ }
54
+ unregister(id) {
55
+ const deleted = this.commands.delete(id);
56
+ if (deleted) this.events.emit("command:unregistered", id);
57
+ return deleted;
58
+ }
59
+ async execute(id, ...args) {
60
+ const found = this.findCommand(id);
61
+ if (!found) throw new Error(`Command "${id}" is not registered`);
62
+ if (!found.handler) throw new Error(`Command "${id}" has no handler (group-only command)`);
63
+ return found.handler(...args);
64
+ }
65
+ list() {
66
+ return Array.from(this.commands.values()).map((cmd) => this.toSerializable(cmd));
67
+ }
68
+ findCommand(id) {
69
+ const topLevel = this.commands.get(id);
70
+ if (topLevel) return topLevel;
71
+ for (const cmd of this.commands.values()) if (cmd.children) {
72
+ const child = cmd.children.find((c) => c.id === id);
73
+ if (child) return child;
74
+ }
75
+ }
76
+ toSerializable(cmd) {
77
+ const { handler: _, children, ...rest } = cmd;
78
+ return {
79
+ ...rest,
80
+ source: "server",
81
+ ...children ? { children: children.map((c) => this.toSerializable(c)) } : {}
82
+ };
83
+ }
84
+ };
85
+ //#endregion
31
86
  //#region src/node/host-docks.ts
32
87
  var DevToolsDockHost = class {
33
88
  views = /* @__PURE__ */ new Map();
@@ -51,8 +106,8 @@ var DevToolsDockHost = class {
51
106
  title: "Terminals",
52
107
  icon: "ph:terminal-duotone",
53
108
  category: "~builtin",
54
- get isHidden() {
55
- return context.terminals.sessions.size === 0;
109
+ get when() {
110
+ return context.terminals.sessions.size === 0 ? "false" : void 0;
56
111
  }
57
112
  },
58
113
  {
@@ -1251,6 +1306,28 @@ const anonymousAuth = defineRpcFunction({
1251
1306
  }
1252
1307
  });
1253
1308
  //#endregion
1309
+ //#region src/node/rpc/internal/commands-execute.ts
1310
+ const commandsExecute = defineRpcFunction({
1311
+ name: "devtoolskit:internal:commands:execute",
1312
+ type: "action",
1313
+ setup: (context) => {
1314
+ return { async handler(id, ...args) {
1315
+ return context.commands.execute(id, ...args);
1316
+ } };
1317
+ }
1318
+ });
1319
+ //#endregion
1320
+ //#region src/node/rpc/internal/commands-list.ts
1321
+ const commandsList = defineRpcFunction({
1322
+ name: "devtoolskit:internal:commands:list",
1323
+ type: "static",
1324
+ setup: (context) => {
1325
+ return { async handler() {
1326
+ return context.commands.list();
1327
+ } };
1328
+ }
1329
+ });
1330
+ //#endregion
1254
1331
  //#region src/node/rpc/internal/docks-on-launch.ts
1255
1332
  const docksOnLaunch = defineRpcFunction({
1256
1333
  name: "devtoolskit:internal:docks:on-launch",
@@ -1395,6 +1472,7 @@ const sharedStateGet = defineRpcFunction({
1395
1472
  },
1396
1473
  setup: (context) => {
1397
1474
  return { handler: async (key) => {
1475
+ if (!context.rpc.sharedState.keys().includes(key)) return void 0;
1398
1476
  return (await context.rpc.sharedState.get(key)).value();
1399
1477
  } };
1400
1478
  }
@@ -1406,6 +1484,7 @@ const sharedStatePatch = defineRpcFunction({
1406
1484
  type: "query",
1407
1485
  setup: (context) => {
1408
1486
  return { handler: async (key, patches, syncId) => {
1487
+ if (!context.rpc.sharedState.keys().includes(key)) return;
1409
1488
  (await context.rpc.sharedState.get(key)).patch(patches, syncId);
1410
1489
  } };
1411
1490
  }
@@ -1417,7 +1496,7 @@ const sharedStateSet = defineRpcFunction({
1417
1496
  type: "query",
1418
1497
  setup: (context) => {
1419
1498
  return { handler: async (key, value, syncId) => {
1420
- (await context.rpc.sharedState.get(key)).mutate(() => value, syncId);
1499
+ (await context.rpc.sharedState.get(key, { initialValue: value })).mutate(() => value, syncId);
1421
1500
  } };
1422
1501
  }
1423
1502
  });
@@ -1494,6 +1573,8 @@ const builtinPublicRpcDeclarations = [defineRpcFunction({
1494
1573
  })];
1495
1574
  const builtinAnonymousRpcDeclarations = [anonymousAuth];
1496
1575
  const builtinInternalRpcDeclarations = [
1576
+ commandsExecute,
1577
+ commandsList,
1497
1578
  docksOnLaunch,
1498
1579
  logsAdd,
1499
1580
  logsClear,
@@ -1515,6 +1596,7 @@ const builtinRpcDeclarations = [
1515
1596
  ];
1516
1597
  //#endregion
1517
1598
  //#region src/node/context.ts
1599
+ var context_exports = /* @__PURE__ */ __exportAll({ createDevToolsContext: () => createDevToolsContext });
1518
1600
  const debugSetup = createDebug("vite:devtools:context:setup");
1519
1601
  function shouldSkipSetupByCapabilities(plugin, mode) {
1520
1602
  const modeCapabilities = plugin.devtools?.capabilities?.[mode];
@@ -1537,6 +1619,7 @@ async function createDevToolsContext(viteConfig, viteServer) {
1537
1619
  utils: ContextUtils,
1538
1620
  terminals: void 0,
1539
1621
  logs: void 0,
1622
+ commands: void 0,
1540
1623
  createJsonRenderer: void 0
1541
1624
  };
1542
1625
  const rpcHost = new RpcFunctionsHost(context);
@@ -1544,14 +1627,16 @@ async function createDevToolsContext(viteConfig, viteServer) {
1544
1627
  const viewsHost = new DevToolsViewHost(context);
1545
1628
  const terminalsHost = new DevToolsTerminalHost(context);
1546
1629
  const logsHost = new DevToolsLogsHost(context);
1630
+ const commandsHost = new DevToolsCommandsHost(context);
1547
1631
  context.rpc = rpcHost;
1548
1632
  context.docks = docksHost;
1549
1633
  context.views = viewsHost;
1550
1634
  context.terminals = terminalsHost;
1551
1635
  context.logs = logsHost;
1636
+ context.commands = commandsHost;
1552
1637
  let jrCounter = 0;
1553
1638
  context.createJsonRenderer = (initialSpec) => {
1554
- const stateKey = `__jr:${jrCounter++}`;
1639
+ const stateKey = `devtoolskit:internal:json-render:${jrCounter++}`;
1555
1640
  const statePromise = rpcHost.sharedState.get(stateKey, { initialValue: initialSpec });
1556
1641
  return {
1557
1642
  _stateKey: stateKey,
@@ -1598,6 +1683,28 @@ async function createDevToolsContext(viteConfig, viteServer) {
1598
1683
  logsHost.events.on("log:updated", () => debouncedLogsUpdate());
1599
1684
  logsHost.events.on("log:removed", () => debouncedLogsUpdate());
1600
1685
  logsHost.events.on("log:cleared", () => debouncedLogsUpdate());
1686
+ const commandsSharedState = await rpcHost.sharedState.get("devtoolskit:internal:commands", { initialValue: [] });
1687
+ const debouncedCommandsSync = debounce(() => {
1688
+ commandsSharedState.mutate(() => commandsHost.list());
1689
+ }, context.mode === "build" ? 0 : 10);
1690
+ commandsHost.events.on("command:registered", () => debouncedCommandsSync());
1691
+ commandsHost.events.on("command:unregistered", () => debouncedCommandsSync());
1692
+ commandsHost.register({
1693
+ id: "vite:open-in-editor",
1694
+ title: "Open in Editor",
1695
+ icon: "ph:pencil-duotone",
1696
+ category: "editor",
1697
+ showInPalette: false,
1698
+ handler: (path) => rpcHost.invokeLocal("vite:core:open-in-editor", path)
1699
+ });
1700
+ commandsHost.register({
1701
+ id: "vite:open-in-finder",
1702
+ title: "Open in Finder",
1703
+ icon: "ph:folder-open-duotone",
1704
+ category: "editor",
1705
+ showInPalette: false,
1706
+ handler: (path) => rpcHost.invokeLocal("vite:core:open-in-finder", path)
1707
+ });
1601
1708
  const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
1602
1709
  for (const plugin of plugins) {
1603
1710
  if (!plugin.devtools?.setup) continue;
@@ -1616,50 +1723,4 @@ async function createDevToolsContext(viteConfig, viteServer) {
1616
1723
  return context;
1617
1724
  }
1618
1725
  //#endregion
1619
- //#region src/node/plugins/server.ts
1620
- /**
1621
- * Core plugin for enabling Vite DevTools
1622
- */
1623
- function renderDockImportsMap(docks) {
1624
- const map = /* @__PURE__ */ new Map();
1625
- for (const dock of docks) {
1626
- const id = `${dock.type}:${dock.id}`;
1627
- if (dock.type === "action") map.set(id, dock.action);
1628
- else if (dock.type === "custom-render") map.set(id, dock.renderer);
1629
- else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
1630
- }
1631
- return [
1632
- `export const importsMap = {`,
1633
- ...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName ?? "default")}]),`),
1634
- "}"
1635
- ].join("\n");
1636
- }
1637
- function DevToolsServer() {
1638
- let context;
1639
- return {
1640
- name: "vite:devtools:server",
1641
- enforce: "post",
1642
- apply: "serve",
1643
- async configureServer(viteDevServer) {
1644
- context = await createDevToolsContext(viteDevServer.config, viteDevServer);
1645
- const host = viteDevServer.config.server.host === true ? "0.0.0.0" : viteDevServer.config.server.host || "localhost";
1646
- const { middleware } = await createDevToolsMiddleware({
1647
- cwd: viteDevServer.config.root,
1648
- hostWebSocket: host,
1649
- context
1650
- });
1651
- viteDevServer.middlewares.use(DEVTOOLS_MOUNT_PATH, middleware);
1652
- },
1653
- resolveId(id) {
1654
- if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) return id;
1655
- },
1656
- load(id) {
1657
- if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) {
1658
- if (!context) throw new Error("DevTools context is not initialized");
1659
- return renderDockImportsMap(context.docks.values());
1660
- }
1661
- }
1662
- };
1663
- }
1664
- //#endregion
1665
- export { renderDockImportsMap as n, createDevToolsContext as r, DevToolsServer as t };
1726
+ export { createDevToolsContext as n, context_exports as t };
@@ -576,6 +576,17 @@ function getHandlers() {
576
576
  function getSSRHandler(key, fallback) {
577
577
  return handlers[key] || fallback;
578
578
  }
579
+ /**
580
+ * Reactive dark theme preference.
581
+ *
582
+ * @see https://vueuse.org/usePreferredDark
583
+ * @param [options]
584
+ *
585
+ * @__NO_SIDE_EFFECTS__
586
+ */
587
+ function usePreferredDark(options) {
588
+ return useMediaQuery("(prefers-color-scheme: dark)", options);
589
+ }
579
590
  function guessSerializerType(rawInit) {
580
591
  return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
581
592
  }
@@ -730,6 +741,86 @@ function useStorage(key, defaults$1, storage, options = {}) {
730
741
  }
731
742
  return data;
732
743
  }
744
+ const CSS_DISABLE_TRANS = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
745
+ /**
746
+ * Reactive color mode with auto data persistence.
747
+ *
748
+ * @see https://vueuse.org/useColorMode
749
+ * @param options
750
+ */
751
+ function useColorMode(options = {}) {
752
+ const { selector = "html", attribute = "class", initialValue = "auto", window: window$1 = defaultWindow, storage, storageKey = "vueuse-color-scheme", listenToStorageChanges = true, storageRef, emitAuto, disableTransition = true } = options;
753
+ const modes = {
754
+ auto: "",
755
+ light: "light",
756
+ dark: "dark",
757
+ ...options.modes || {}
758
+ };
759
+ const preferredDark = usePreferredDark({ window: window$1 });
760
+ const system = computed(() => preferredDark.value ? "dark" : "light");
761
+ const store = storageRef || (storageKey == null ? toRef$1(initialValue) : useStorage(storageKey, initialValue, storage, {
762
+ window: window$1,
763
+ listenToStorageChanges
764
+ }));
765
+ const state = computed(() => store.value === "auto" ? system.value : store.value);
766
+ const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector$1, attribute$1, value) => {
767
+ const el = typeof selector$1 === "string" ? window$1 === null || window$1 === void 0 ? void 0 : window$1.document.querySelector(selector$1) : unrefElement(selector$1);
768
+ if (!el) return;
769
+ const classesToAdd = /* @__PURE__ */ new Set();
770
+ const classesToRemove = /* @__PURE__ */ new Set();
771
+ let attributeToChange = null;
772
+ if (attribute$1 === "class") {
773
+ const current = value.split(/\s/g);
774
+ Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
775
+ if (current.includes(v)) classesToAdd.add(v);
776
+ else classesToRemove.add(v);
777
+ });
778
+ } else attributeToChange = {
779
+ key: attribute$1,
780
+ value
781
+ };
782
+ if (classesToAdd.size === 0 && classesToRemove.size === 0 && attributeToChange === null) return;
783
+ let style;
784
+ if (disableTransition) {
785
+ style = window$1.document.createElement("style");
786
+ style.appendChild(document.createTextNode(CSS_DISABLE_TRANS));
787
+ window$1.document.head.appendChild(style);
788
+ }
789
+ for (const c of classesToAdd) el.classList.add(c);
790
+ for (const c of classesToRemove) el.classList.remove(c);
791
+ if (attributeToChange) el.setAttribute(attributeToChange.key, attributeToChange.value);
792
+ if (disableTransition) {
793
+ window$1.getComputedStyle(style).opacity;
794
+ document.head.removeChild(style);
795
+ }
796
+ });
797
+ function defaultOnChanged(mode) {
798
+ var _modes$mode;
799
+ updateHTMLAttrs(selector, attribute, (_modes$mode = modes[mode]) !== null && _modes$mode !== void 0 ? _modes$mode : mode);
800
+ }
801
+ function onChanged(mode) {
802
+ if (options.onChanged) options.onChanged(mode, defaultOnChanged);
803
+ else defaultOnChanged(mode);
804
+ }
805
+ watch(state, onChanged, {
806
+ flush: "post",
807
+ immediate: true
808
+ });
809
+ tryOnMounted(() => onChanged(state.value));
810
+ const auto = computed({
811
+ get() {
812
+ return emitAuto ? store.value : state.value;
813
+ },
814
+ set(v) {
815
+ store.value = v;
816
+ }
817
+ });
818
+ return Object.assign(auto, {
819
+ store,
820
+ system,
821
+ state
822
+ });
823
+ }
733
824
  /**
734
825
  * Manipulate CSS variables.
735
826
  *
@@ -769,6 +860,38 @@ function useCssVar(prop, target, options = {}) {
769
860
  return variable;
770
861
  }
771
862
  /**
863
+ * Reactive dark mode with auto data persistence.
864
+ *
865
+ * @see https://vueuse.org/useDark
866
+ * @param options
867
+ */
868
+ function useDark(options = {}) {
869
+ const { valueDark = "dark", valueLight = "" } = options;
870
+ const mode = useColorMode({
871
+ ...options,
872
+ onChanged: (mode$1, defaultHandler) => {
873
+ var _options$onChanged;
874
+ if (options.onChanged) (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, mode$1 === "dark", defaultHandler, mode$1);
875
+ else defaultHandler(mode$1);
876
+ },
877
+ modes: {
878
+ dark: valueDark,
879
+ light: valueLight
880
+ }
881
+ });
882
+ const system = computed(() => mode.system.value);
883
+ return computed({
884
+ get() {
885
+ return mode.value === "dark";
886
+ },
887
+ set(v) {
888
+ const modeVal = v ? "dark" : "light";
889
+ if (system.value === modeVal) mode.value = "auto";
890
+ else mode.value = modeVal;
891
+ }
892
+ });
893
+ }
894
+ /**
772
895
  * Reports changes to the dimensions of an Element's content or the border-box
773
896
  *
774
897
  * @see https://vueuse.org/useResizeObserver
@@ -1110,4 +1233,4 @@ function useWindowSize(options = {}) {
1110
1233
  };
1111
1234
  }
1112
1235
  //#endregion
1113
- export { useScreenSafeArea as a, useDebounceFn as c, useLocalStorage as i, watchDebounced as l, useElementBounding as n, useTimeAgo as o, useEventListener as r, useWindowSize as s, onClickOutside as t, watchImmediate as u };
1236
+ export { useLocalStorage as a, useWindowSize as c, watchImmediate as d, useEventListener as i, useDebounceFn as l, useDark as n, useScreenSafeArea as o, useElementBounding as r, useTimeAgo as s, onClickOutside as t, watchDebounced as u };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { n as InternalAnonymousAuthStorage, t as DevToolsInternalContext } from "./context-internal-BA4ba-FN.js";
1
+ import { n as InternalAnonymousAuthStorage, t as DevToolsInternalContext } from "./context-internal-Ys7Zu3q3.js";
2
2
  import { SharedStatePatch } from "@vitejs/devtools-kit/utils/shared-state";
3
3
  import * as _vitejs_devtools_rpc0 from "@vitejs/devtools-rpc";
4
4
  import { RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
5
5
  import * as _vitejs_devtools_kit0 from "@vitejs/devtools-kit";
6
- import { DevToolsDockEntry, DevToolsDocksUserSettings, DevToolsLogEntry, DevToolsNodeContext, DevToolsTerminalSessionStreamChunkEvent, RpcDefinitionsToFunctions } from "@vitejs/devtools-kit";
6
+ import { DevToolsDockEntry, DevToolsDocksUserSettings, DevToolsLogEntry, DevToolsNodeContext, DevToolsServerCommandEntry, DevToolsTerminalSessionStreamChunkEvent, RpcDefinitionsToFunctions } from "@vitejs/devtools-kit";
7
7
  import * as h3 from "h3";
8
8
  import { AsyncLocalStorage } from "node:async_hooks";
9
9
  import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
@@ -64,6 +64,28 @@ declare const builtinRpcDeclarations: readonly [{
64
64
  dump?: _vitejs_devtools_rpc0.RpcDump<[query: DevToolsAuthInput], Promise<DevToolsAuthReturn>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
65
65
  __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[query: DevToolsAuthInput], Promise<DevToolsAuthReturn>> | undefined;
66
66
  __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[query: DevToolsAuthInput], Promise<DevToolsAuthReturn>>> | undefined;
67
+ }, {
68
+ name: "devtoolskit:internal:commands:execute";
69
+ type?: "action" | undefined;
70
+ cacheable?: boolean;
71
+ args?: undefined;
72
+ returns?: undefined;
73
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[id: string, ...args: any[]], Promise<unknown>>>) | undefined;
74
+ handler?: ((id: string, ...args: any[]) => Promise<unknown>) | undefined;
75
+ dump?: _vitejs_devtools_rpc0.RpcDump<[id: string, ...args: any[]], Promise<unknown>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
76
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[id: string, ...args: any[]], Promise<unknown>> | undefined;
77
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[id: string, ...args: any[]], Promise<unknown>>> | undefined;
78
+ }, {
79
+ name: "devtoolskit:internal:commands:list";
80
+ type?: "static" | undefined;
81
+ cacheable?: boolean;
82
+ args?: undefined;
83
+ returns?: undefined;
84
+ setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<DevToolsServerCommandEntry[]>>>) | undefined;
85
+ handler?: (() => Promise<DevToolsServerCommandEntry[]>) | undefined;
86
+ dump?: _vitejs_devtools_rpc0.RpcDump<[], Promise<DevToolsServerCommandEntry[]>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
87
+ __resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<DevToolsServerCommandEntry[]>> | undefined;
88
+ __promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[], Promise<DevToolsServerCommandEntry[]>>> | undefined;
67
89
  }, {
68
90
  name: "devtoolskit:internal:docks:on-launch";
69
91
  type?: "action" | undefined;
@@ -255,6 +277,7 @@ declare module '@vitejs/devtools-kit' {
255
277
  'devtoolskit:internal:terminals:updated': () => Promise<void>;
256
278
  }
257
279
  interface DevToolsRpcSharedStates {
280
+ 'devtoolskit:internal:commands': DevToolsServerCommandEntry[];
258
281
  'devtoolskit:internal:docks': DevToolsDockEntry[];
259
282
  'devtoolskit:internal:user-settings': DevToolsDocksUserSettings;
260
283
  }
@@ -268,6 +291,22 @@ interface DevToolsOptions {
268
291
  * @default true
269
292
  */
270
293
  builtinDevTools?: boolean;
294
+ /**
295
+ * Options for building static DevTools output alongside `vite build`.
296
+ */
297
+ build?: {
298
+ /**
299
+ * Automatically build DevTools when running `vite build`.
300
+ *
301
+ * @default false
302
+ */
303
+ withApp?: boolean;
304
+ /**
305
+ * Output directory for the DevTools build (relative to root).
306
+ * Defaults to Vite's `build.outDir`.
307
+ */
308
+ outDir?: string;
309
+ };
271
310
  }
272
311
  declare function DevTools(options?: DevToolsOptions): Promise<Plugin[]>;
273
312
  //#endregion
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { r as createDevToolsContext } from "./server-DhChc9gv.js";
2
- import { t as createDevToolsMiddleware } from "./server-BuWZ1h8p.js";
3
- import { t as DevTools } from "./plugins-DfC1vp4w.js";
4
- import "./dist-DpLy3ojW.js";
1
+ import { n as createDevToolsContext } from "./context-BWju7fup.js";
2
+ import { t as DevTools } from "./plugins-Dhpm6Ql_.js";
3
+ import { t as createDevToolsMiddleware } from "./server-DSh-GQIq.js";
5
4
  export { DevTools, createDevToolsContext, createDevToolsMiddleware };
@@ -1,2 +1,2 @@
1
- import { n as InternalAnonymousAuthStorage, r as getInternalContext, t as DevToolsInternalContext } from "./context-internal-BA4ba-FN.js";
1
+ import { n as InternalAnonymousAuthStorage, r as getInternalContext, t as DevToolsInternalContext } from "./context-internal-Ys7Zu3q3.js";
2
2
  export { type DevToolsInternalContext, type InternalAnonymousAuthStorage, getInternalContext };
@@ -0,0 +1,59 @@
1
+ import { n as ansis_default } from "./constants-DfEeYo9W.js";
2
+ import { dirDist } from "./dirs.js";
3
+ import { t as DevToolsServer } from "./server-ZWEvQMOm.js";
4
+ import { join, normalize, resolve } from "pathe";
5
+ import process from "node:process";
6
+ //#region src/node/plugins/build.ts
7
+ function DevToolsBuild(options = {}) {
8
+ let context;
9
+ let resolvedConfig;
10
+ return {
11
+ name: "vite:devtools:build",
12
+ apply: "build",
13
+ configResolved(config) {
14
+ resolvedConfig = config;
15
+ },
16
+ async buildStart() {
17
+ const { createDevToolsContext } = await import("./context-BWju7fup.js").then((n) => n.t);
18
+ context = await createDevToolsContext(resolvedConfig);
19
+ },
20
+ async closeBundle() {
21
+ console.log(ansis_default.cyan`${"⬢"} Building static Vite DevTools...`);
22
+ const outDir = options.outDir ? resolve(resolvedConfig.root, options.outDir) : resolve(resolvedConfig.root, resolvedConfig.build.outDir);
23
+ const { buildStaticDevTools } = await import("./build-static-Cb3vKjJS.js");
24
+ await buildStaticDevTools({
25
+ context,
26
+ outDir
27
+ });
28
+ }
29
+ };
30
+ }
31
+ //#endregion
32
+ //#region src/node/plugins/injection.ts
33
+ function DevToolsInjection() {
34
+ return {
35
+ name: "vite:devtools:injection",
36
+ enforce: "post",
37
+ transformIndexHtml() {
38
+ return [{
39
+ tag: "script",
40
+ attrs: {
41
+ src: `/@fs/${process.env.VITE_DEVTOOLS_LOCAL_DEV ? normalize(join(dirDist, "..", "src/client/inject/index.ts")) : normalize(join(dirDist, "client/inject.js"))}`,
42
+ type: "module"
43
+ },
44
+ injectTo: "body"
45
+ }];
46
+ }
47
+ };
48
+ }
49
+ //#endregion
50
+ //#region src/node/plugins/index.ts
51
+ async function DevTools(options = {}) {
52
+ const { builtinDevTools = true, build } = options;
53
+ const plugins = [DevToolsInjection(), DevToolsServer()];
54
+ if (build?.withApp) plugins.push(DevToolsBuild({ outDir: build.outDir }));
55
+ if (builtinDevTools) plugins.push(await import("@vitejs/devtools-rolldown").then((m) => m.DevToolsRolldownUI()));
56
+ return plugins;
57
+ }
58
+ //#endregion
59
+ export { DevTools as t };