@vitejs/devtools 0.0.0-alpha.20 → 0.0.0-alpha.22

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.
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+ export { __toESM as n, __commonJSMin as t };
@@ -1,13 +1,13 @@
1
- import { a as ansis_default, c as fromNodeMiddleware, d as createDevToolsContext, i as getPort, l as sendRedirect, n as createDevToolsMiddleware, o as createApp, r as MARK_NODE, s as eventHandler, t as DevTools, u as toNodeListener } from "./plugins-DfJlAQ2j.js";
2
- import { t as dirClientStandalone } from "./dirs-C0s1Ghvy.js";
1
+ import { a as createApp, c as sendRedirect, d as ansis_default, i as getPort, l as toNodeListener, n as createDevToolsMiddleware, o as eventHandler, r as MARK_NODE, s as fromNodeMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-C1AF2q2c.js";
2
+ import { t as dirClientStandalone } from "./dirs-BJIz1OY5.js";
3
+ import { resolveConfig } from "vite";
3
4
  import process from "node:process";
4
5
  import { existsSync } from "node:fs";
5
6
  import sirv from "sirv";
6
- import { resolveConfig } from "vite";
7
- import fs from "node:fs/promises";
7
+ import { join, relative, resolve } from "pathe";
8
+ import fs$1 from "node:fs/promises";
8
9
  import { createServer } from "node:http";
9
10
  import open from "open";
10
- import { join, relative, resolve } from "pathe";
11
11
 
12
12
  //#region src/node/standalone.ts
13
13
  async function startStandaloneDevTools(options = {}) {
@@ -43,12 +43,12 @@ async function start(options) {
43
43
  const { host } = options;
44
44
  const port = await getPort({
45
45
  host,
46
- port: options.port == null ? void 0 : +options.port,
47
- portRange: [9999, 15e3]
46
+ port: options.port == null ? void 0 : +options.port
48
47
  });
49
48
  const devtools = await startStandaloneDevTools({ cwd: options.root });
50
49
  const { h3 } = await createDevToolsMiddleware({
51
50
  cwd: devtools.config.root,
51
+ hostWebSocket: host,
52
52
  context: devtools.context
53
53
  });
54
54
  const app = createApp();
@@ -72,21 +72,21 @@ async function build(options) {
72
72
  config: options.config
73
73
  });
74
74
  const outDir = resolve(devtools.config.root, options.outDir);
75
- if (existsSync(outDir)) await fs.rm(outDir, { recursive: true });
75
+ if (existsSync(outDir)) await fs$1.rm(outDir, { recursive: true });
76
76
  const devToolsRoot = join(outDir, ".devtools");
77
- await fs.mkdir(devToolsRoot, { recursive: true });
78
- await fs.cp(dirClientStandalone, devToolsRoot, { recursive: true });
77
+ await fs$1.mkdir(devToolsRoot, { recursive: true });
78
+ await fs$1.cp(dirClientStandalone, devToolsRoot, { recursive: true });
79
79
  for (const { baseUrl, distDir } of devtools.context.views.buildStaticDirs) {
80
80
  console.log(ansis_default.cyan`${MARK_NODE} Copying static files from ${distDir} to ${join(outDir, baseUrl)}`);
81
- await fs.mkdir(join(outDir, baseUrl), { recursive: true });
82
- await fs.cp(distDir, join(outDir, baseUrl), { recursive: true });
81
+ await fs$1.mkdir(join(outDir, baseUrl), { recursive: true });
82
+ await fs$1.cp(distDir, join(outDir, baseUrl), { recursive: true });
83
83
  }
84
- await fs.mkdir(resolve(devToolsRoot, "api"), { recursive: true });
85
- await fs.writeFile(resolve(devToolsRoot, ".vdt-connection.json"), JSON.stringify({ backend: "static" }, null, 2), "utf-8");
84
+ await fs$1.mkdir(resolve(devToolsRoot, "api"), { recursive: true });
85
+ await fs$1.writeFile(resolve(devToolsRoot, ".vdt-connection.json"), JSON.stringify({ backend: "static" }, null, 2), "utf-8");
86
86
  console.log(ansis_default.cyan`${MARK_NODE} Writing RPC dump to ${resolve(devToolsRoot, ".vdt-rpc-dump.json")}`);
87
87
  const dump = {};
88
88
  for (const [key, value] of Object.entries(devtools.context.rpc.functions)) if (value.type === "static") dump[key] = await value.handler?.();
89
- await fs.writeFile(resolve(devToolsRoot, ".vdt-rpc-dump.json"), JSON.stringify(dump, null, 2), "utf-8");
89
+ await fs$1.writeFile(resolve(devToolsRoot, ".vdt-rpc-dump.json"), JSON.stringify(dump, null, 2), "utf-8");
90
90
  console.log(ansis_default.green`${MARK_NODE} Built to ${relative(devtools.config.root, outDir)}`);
91
91
  throw new Error("[Vite DevTools] Build mode of Vite DevTools is not yet complete");
92
92
  }
@@ -1,4 +1,4 @@
1
- import "./plugins-DfJlAQ2j.js";
2
- import { n as start, t as build } from "./cli-commands-BBPbCd8A.js";
1
+ import "./plugins-C1AF2q2c.js";
2
+ import { n as start, t as build } from "./cli-commands-91HuPBSu.js";
3
3
 
4
4
  export { build, start };
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
- import "./plugins-DfJlAQ2j.js";
2
- import { n as start, t as build } from "./cli-commands-BBPbCd8A.js";
1
+ import "./plugins-C1AF2q2c.js";
2
+ import { n as start, t as build } from "./cli-commands-91HuPBSu.js";
3
3
  import process from "node:process";
4
4
  import cac from "cac";
5
5
 
@@ -1,4 +1,4 @@
1
- import { A as watchEffect, F as ref, L as toRefs, N as markRaw, P as reactive, m as computed, n as createDockEntryState, o as useLocalStorage, r as useDocksEntries, t as DEFAULT_DOCK_PANEL_STORE } from "../docks-B3cDUs1u.js";
1
+ import { F as markRaw, I as reactive, L as ref, M as watchEffect, c as useLocalStorage, g as computed, i as BUILTIN_ENTRIES, n as createDockEntryState, r as useDocksEntries, t as DEFAULT_DOCK_PANEL_STORE, z as toRefs } from "../docks-C4khS_Su.js";
2
2
  import { getDevToolsRpcClient } from "@vitejs/devtools-kit/client";
3
3
 
4
4
  //#region src/client/webcomponents/state/setup-script.ts
@@ -29,9 +29,9 @@ function executeSetupScript(entry, context) {
29
29
  let _docksContext;
30
30
  async function createDocksContext(clientType, rpc, panelStore) {
31
31
  if (_docksContext) return _docksContext;
32
- const selectedId = ref(null);
33
32
  const dockEntries = await useDocksEntries(rpc);
34
- const selected = computed(() => dockEntries.value.find((entry) => entry.id === selectedId.value) ?? null);
33
+ const selectedId = ref(null);
34
+ const selected = computed(() => dockEntries.value.find((entry) => entry.id === selectedId.value) ?? BUILTIN_ENTRIES.find((entry) => entry.id === selectedId.value) ?? null);
35
35
  const dockEntryStateMap = reactive(/* @__PURE__ */ new Map());
36
36
  watchEffect(() => {
37
37
  for (const entry of dockEntries.value) {
@@ -43,6 +43,33 @@ async function createDocksContext(clientType, rpc, panelStore) {
43
43
  }
44
44
  });
45
45
  panelStore ||= ref(DEFAULT_DOCK_PANEL_STORE());
46
+ const switchEntry = async (id = null) => {
47
+ if (id == null) {
48
+ selectedId.value = null;
49
+ return true;
50
+ }
51
+ if (id === "~client-auth-notice") {
52
+ selectedId.value = id;
53
+ panelStore.value.open = true;
54
+ return true;
55
+ }
56
+ const entry = dockEntries.value.find((e) => e.id === id);
57
+ if (!entry) return false;
58
+ if (entry.type === "action" || entry.type === "custom-render" || entry.type === "iframe" && entry.clientScript) {
59
+ const current = dockEntryStateMap.get(id);
60
+ await executeSetupScript(entry, reactive({
61
+ ...toRefs(_docksContext),
62
+ current
63
+ }));
64
+ }
65
+ selectedId.value = entry.id;
66
+ panelStore.value.open = true;
67
+ return true;
68
+ };
69
+ const toggleEntry = async (id) => {
70
+ if (selectedId.value === id) return switchEntry(null);
71
+ return switchEntry(id);
72
+ };
46
73
  _docksContext = reactive({
47
74
  panel: {
48
75
  store: panelStore,
@@ -56,24 +83,8 @@ async function createDocksContext(clientType, rpc, panelStore) {
56
83
  entries: dockEntries,
57
84
  entryToStateMap: markRaw(dockEntryStateMap),
58
85
  getStateById: (id) => dockEntryStateMap.get(id),
59
- switchEntry: async (id = null) => {
60
- if (id == null) {
61
- selectedId.value = null;
62
- return true;
63
- }
64
- const entry = dockEntries.value.find((e) => e.id === id);
65
- if (!entry) return false;
66
- if (entry.type === "action" || entry.type === "custom-render" || entry.type === "iframe" && entry.clientScript) {
67
- const current = dockEntryStateMap.get(id);
68
- await executeSetupScript(entry, reactive({
69
- ...toRefs(_docksContext),
70
- current
71
- }));
72
- }
73
- selectedId.value = entry.id;
74
- panelStore.value.open = true;
75
- return true;
76
- }
86
+ switchEntry,
87
+ toggleEntry
77
88
  },
78
89
  rpc,
79
90
  clientType