@vitejs/devtools 0.0.0-alpha.9 → 0.1.1

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 (42) hide show
  1. package/dist/DockIcon-BtMEW4VE.js +97 -0
  2. package/dist/DockStandalone-CZAqITKs.js +81 -0
  3. package/dist/LogItem-BTrEubKY.js +205 -0
  4. package/dist/ToastOverlay-DO3Kl_rY.js +1055 -0
  5. package/dist/ViewBuiltinLogs-BL373XPJ.js +428 -0
  6. package/dist/ViewBuiltinTerminals-DdpE1Ftb.js +10409 -0
  7. package/dist/ViewJsonRender-coidkW9b.js +6835 -0
  8. package/dist/cli-commands-BRswBnHn.js +180 -0
  9. package/dist/cli-commands.js +3 -5
  10. package/dist/cli.js +3 -6
  11. package/dist/client/inject.js +171 -18
  12. package/dist/client/standalone/assets/DockStandalone-DDaYjGO1.js +1 -0
  13. package/dist/client/standalone/assets/LogItem-CKbVrExA.js +1 -0
  14. package/dist/client/standalone/assets/ViewBuiltinLogs-9oWDdl1G.js +1 -0
  15. package/dist/client/standalone/assets/ViewBuiltinTerminals-CpexS-ib.js +36 -0
  16. package/dist/client/standalone/assets/ViewJsonRender-CKPzRgqQ.js +43 -0
  17. package/dist/client/standalone/assets/dist-JpCJ4ieR.js +1 -0
  18. package/dist/client/standalone/assets/iconify-C-CPDXMf.js +2 -0
  19. package/dist/client/standalone/assets/index-3wlMt-60.js +3 -0
  20. package/dist/client/standalone/assets/index-6F2y1lxr.css +1 -0
  21. package/dist/client/standalone/assets/runtime-core.esm-bundler-oO31W4LZ.js +1 -0
  22. package/dist/client/standalone/index.html +7 -3
  23. package/dist/client/webcomponents.d.ts +21657 -31
  24. package/dist/client/webcomponents.js +307 -455
  25. package/dist/config.d.ts +25 -0
  26. package/dist/config.js +14 -0
  27. package/dist/dirs.js +7 -3
  28. package/dist/dist-Cgqg5_oP.js +1113 -0
  29. package/dist/iconify-YyqAMHKf.js +1625 -0
  30. package/dist/index.d.ts +256 -13
  31. package/dist/index.js +2 -4
  32. package/dist/plugins-Cvy_lJ0L.js +2135 -0
  33. package/dist/popup-ffZHGm5D.js +358 -0
  34. package/dist/utils-Csuu5uNf.js +10 -0
  35. package/dist/{dist-2aLfy0Lc.js → vue.runtime.esm-bundler-D2MZbyFr.js} +1948 -1734
  36. package/package.json +53 -21
  37. package/dist/cli-commands-CWESTkWI.js +0 -97
  38. package/dist/client/standalone/assets/index-CXKamp9k.js +0 -7
  39. package/dist/client/standalone/assets/index-DULlvzQC.css +0 -1
  40. package/dist/dirs-DcSK9l9L.js +0 -9
  41. package/dist/index-C-9eMTqf.d.ts +0 -142
  42. package/dist/plugins-5VE4Mfdt.js +0 -1365
@@ -0,0 +1,2135 @@
1
+ import { t as isObject } from "./utils-Csuu5uNf.js";
2
+ import { dirClientStandalone, dirDist } from "./dirs.js";
3
+ import { createDebug } from "obug";
4
+ import { debounce } from "perfect-debounce";
5
+ import { normalizePath, searchForWorkspaceRoot } from "vite";
6
+ import { toDataURL } from "mlly";
7
+ import { DEFAULT_STATE_USER_SETTINGS, DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID, DEVTOOLS_MOUNT_PATH } from "@vitejs/devtools-kit/constants";
8
+ import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
9
+ import { dirname, join } from "pathe";
10
+ import fs, { existsSync } from "node:fs";
11
+ import { createSharedState } from "@vitejs/devtools-kit/utils/shared-state";
12
+ import { RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
13
+ import { nanoid } from "@vitejs/devtools-kit/utils/nanoid";
14
+ import process$1, { stdin, stdout } from "node:process";
15
+ import sirv from "sirv";
16
+ import { stripVTControlCharacters, styleText } from "node:util";
17
+ import "node:readline";
18
+ import ot from "node:readline";
19
+ import "node:tty";
20
+ import { join as join$1 } from "node:path";
21
+ import { defineRpcFunction } from "@vitejs/devtools-kit";
22
+ import { createServer } from "node:net";
23
+ import { createApp, eventHandler, fromNodeMiddleware, toNodeListener } from "h3";
24
+ import { AsyncLocalStorage } from "node:async_hooks";
25
+ import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
26
+ import { createRpcServer } from "@vitejs/devtools-rpc/server";
27
+ import { networkInterfaces } from "node:os";
28
+ import "node:fs/promises";
29
+ //#region \0rolldown/runtime.js
30
+ var __create = Object.create;
31
+ var __defProp = Object.defineProperty;
32
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
33
+ var __getOwnPropNames = Object.getOwnPropertyNames;
34
+ var __getProtoOf = Object.getPrototypeOf;
35
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
36
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
37
+ var __copyProps = (to, from, except, desc) => {
38
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
39
+ key = keys[i];
40
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
41
+ get: ((k) => from[k]).bind(null, key),
42
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
43
+ });
44
+ }
45
+ return to;
46
+ };
47
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
48
+ value: mod,
49
+ enumerable: true
50
+ }) : target, mod));
51
+ //#endregion
52
+ //#region src/node/context-utils.ts
53
+ const ContextUtils = { createSimpleClientScript(fn) {
54
+ return {
55
+ importFrom: toDataURL(`const fn = ${fn.toString()}; export default fn`),
56
+ importName: "default"
57
+ };
58
+ } };
59
+ //#endregion
60
+ //#region src/node/storage.ts
61
+ function createStorage(options) {
62
+ const { mergeInitialValue = (initialValue, savedValue) => ({
63
+ ...initialValue,
64
+ ...savedValue
65
+ }), debounce: debounceTime = 100 } = options;
66
+ let initialValue = options.initialValue;
67
+ if (fs.existsSync(options.filepath)) try {
68
+ const savedValue = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
69
+ initialValue = mergeInitialValue ? mergeInitialValue(options.initialValue, savedValue) : savedValue;
70
+ } catch (error) {
71
+ console.warn(`[Vite DevTools] Failed to parse storage file: ${options.filepath}, falling back to defaults.`);
72
+ console.warn(error);
73
+ initialValue = options.initialValue;
74
+ }
75
+ const state = createSharedState({
76
+ initialValue,
77
+ enablePatches: false
78
+ });
79
+ state.on("updated", debounce((newState) => {
80
+ fs.mkdirSync(dirname(options.filepath), { recursive: true });
81
+ fs.writeFileSync(options.filepath, `${JSON.stringify(newState, null, 2)}\n`);
82
+ }, debounceTime));
83
+ return state;
84
+ }
85
+ //#endregion
86
+ //#region src/node/host-docks.ts
87
+ var DevToolsDockHost = class {
88
+ views = /* @__PURE__ */ new Map();
89
+ events = createEventEmitter();
90
+ userSettings = void 0;
91
+ constructor(context) {
92
+ this.context = context;
93
+ }
94
+ async init() {
95
+ this.userSettings = await this.context.rpc.sharedState.get("devtoolskit:internal:user-settings", { sharedState: createStorage({
96
+ filepath: join(this.context.workspaceRoot, "node_modules/.vite/devtools/settings.json"),
97
+ initialValue: DEFAULT_STATE_USER_SETTINGS()
98
+ }) });
99
+ }
100
+ values({ includeBuiltin = true } = {}) {
101
+ const context = this.context;
102
+ const builtinDocksEntries = [
103
+ {
104
+ type: "~builtin",
105
+ id: "~terminals",
106
+ title: "Terminals",
107
+ icon: "ph:terminal-duotone",
108
+ category: "~builtin",
109
+ get isHidden() {
110
+ return context.terminals.sessions.size === 0;
111
+ }
112
+ },
113
+ {
114
+ type: "~builtin",
115
+ id: "~logs",
116
+ title: "Logs & Notifications",
117
+ icon: "ph:notification-duotone",
118
+ category: "~builtin",
119
+ get badge() {
120
+ const size = context.logs.entries.size;
121
+ return size > 0 ? String(size) : void 0;
122
+ }
123
+ },
124
+ {
125
+ type: "~builtin",
126
+ id: "~popup",
127
+ title: "Popup",
128
+ category: "~builtin",
129
+ icon: "ph:arrow-square-out-duotone"
130
+ },
131
+ {
132
+ type: "~builtin",
133
+ id: "~settings",
134
+ title: "Settings",
135
+ category: "~builtin",
136
+ icon: "ph:gear-duotone"
137
+ }
138
+ ];
139
+ return [...Array.from(this.views.values()), ...includeBuiltin ? builtinDocksEntries : []];
140
+ }
141
+ register(view, force) {
142
+ if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
143
+ this.views.set(view.id, view);
144
+ this.events.emit("dock:entry:updated", view);
145
+ return { update: (patch) => {
146
+ if (patch.id && patch.id !== view.id) throw new Error(`Cannot change the id of a dock. Use register() to add new docks.`);
147
+ this.update(Object.assign(this.views.get(view.id), patch));
148
+ } };
149
+ }
150
+ update(view) {
151
+ if (!this.views.has(view.id)) throw new Error(`Dock with id "${view.id}" is not registered. Use register() to add new docks.`);
152
+ this.views.set(view.id, view);
153
+ this.events.emit("dock:entry:updated", view);
154
+ }
155
+ };
156
+ //#endregion
157
+ //#region src/node/rpc-shared-state.ts
158
+ const debug$1 = createDebug("vite:devtools:rpc:state:changed");
159
+ function createRpcSharedStateServerHost(rpc) {
160
+ const sharedState = /* @__PURE__ */ new Map();
161
+ function registerSharedState(key, state) {
162
+ const offs = [];
163
+ offs.push(state.on("updated", (fullState, patches, syncId) => {
164
+ if (patches) {
165
+ debug$1("patch", {
166
+ key,
167
+ syncId
168
+ });
169
+ rpc.broadcast({
170
+ method: "devtoolskit:internal:rpc:client-state:patch",
171
+ args: [
172
+ key,
173
+ patches,
174
+ syncId
175
+ ],
176
+ filter: (client) => client.$meta.subscribedStates.has(key)
177
+ });
178
+ } else {
179
+ debug$1("updated", {
180
+ key,
181
+ syncId
182
+ });
183
+ rpc.broadcast({
184
+ method: "devtoolskit:internal:rpc:client-state:updated",
185
+ args: [
186
+ key,
187
+ fullState,
188
+ syncId
189
+ ],
190
+ filter: (client) => client.$meta.subscribedStates.has(key)
191
+ });
192
+ }
193
+ }));
194
+ return () => {
195
+ for (const off of offs) off();
196
+ };
197
+ }
198
+ return {
199
+ get: async (key, options) => {
200
+ if (sharedState.has(key)) return sharedState.get(key);
201
+ if (options?.initialValue === void 0 && options?.sharedState === void 0) throw new Error(`Shared state of "${key}" is not found, please provide an initial value for the first time`);
202
+ debug$1("new-state", key);
203
+ const state = options.sharedState ?? createSharedState({
204
+ initialValue: options.initialValue,
205
+ enablePatches: false
206
+ });
207
+ registerSharedState(key, state);
208
+ sharedState.set(key, state);
209
+ return state;
210
+ },
211
+ keys() {
212
+ return Array.from(sharedState.keys());
213
+ }
214
+ };
215
+ }
216
+ //#endregion
217
+ //#region src/node/host-functions.ts
218
+ const debugBroadcast = createDebug("vite:devtools:rpc:broadcast");
219
+ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
220
+ /**
221
+ * @internal
222
+ */
223
+ _rpcGroup = void 0;
224
+ _asyncStorage = void 0;
225
+ constructor(context) {
226
+ super(context);
227
+ this.sharedState = createRpcSharedStateServerHost(this);
228
+ }
229
+ sharedState;
230
+ async invokeLocal(method, ...args) {
231
+ if (!this.definitions.has(method)) throw new Error(`RPC function "${String(method)}" is not registered`);
232
+ const handler = await this.getHandler(method);
233
+ return await Promise.resolve(handler(...args));
234
+ }
235
+ async broadcast(options) {
236
+ if (!this._rpcGroup) return;
237
+ debugBroadcast(JSON.stringify(options.method));
238
+ await Promise.all(this._rpcGroup.clients.map((client) => {
239
+ if (options.filter?.(client) === false) return void 0;
240
+ return client.$callRaw({
241
+ optional: true,
242
+ event: true,
243
+ ...options
244
+ });
245
+ }));
246
+ }
247
+ getCurrentRpcSession() {
248
+ if (!this._asyncStorage) throw new Error("RpcFunctionsHost] AsyncLocalStorage is not set, it likely to be an internal bug of Vite DevTools");
249
+ return this._asyncStorage.getStore();
250
+ }
251
+ };
252
+ //#endregion
253
+ //#region src/node/host-logs.ts
254
+ const MAX_ENTRIES = 1e3;
255
+ var DevToolsLogsHost = class {
256
+ entries = /* @__PURE__ */ new Map();
257
+ events = createEventEmitter();
258
+ /** Tracks when each entry was last added or updated (monotonic) */
259
+ lastModified = /* @__PURE__ */ new Map();
260
+ /** Tracks recently removed entry IDs with their removal time */
261
+ removals = [];
262
+ _autoDeleteTimers = /* @__PURE__ */ new Map();
263
+ _clock = 0;
264
+ _tick() {
265
+ return ++this._clock;
266
+ }
267
+ constructor(context) {
268
+ this.context = context;
269
+ }
270
+ async add(input) {
271
+ if (input.id && this.entries.has(input.id)) {
272
+ await this.update(input.id, input);
273
+ return this._createHandle(input.id);
274
+ }
275
+ const entry = {
276
+ ...input,
277
+ id: input.id ?? nanoid(),
278
+ timestamp: input.timestamp ?? Date.now(),
279
+ from: input.from ?? "server"
280
+ };
281
+ if (this.entries.size >= MAX_ENTRIES) {
282
+ const oldest = this.entries.keys().next().value;
283
+ await this.remove(oldest);
284
+ }
285
+ this.entries.set(entry.id, entry);
286
+ this.lastModified.set(entry.id, this._tick());
287
+ this.events.emit("log:added", entry);
288
+ if (entry.autoDelete) this._autoDeleteTimers.set(entry.id, setTimeout(() => {
289
+ this.remove(entry.id);
290
+ }, entry.autoDelete));
291
+ return this._createHandle(entry.id);
292
+ }
293
+ async update(id, patch) {
294
+ const existing = this.entries.get(id);
295
+ if (!existing) return void 0;
296
+ const updated = {
297
+ ...existing,
298
+ ...patch,
299
+ id: existing.id,
300
+ from: existing.from,
301
+ timestamp: existing.timestamp
302
+ };
303
+ this.entries.set(id, updated);
304
+ this.lastModified.set(id, this._tick());
305
+ this.events.emit("log:updated", updated);
306
+ if (patch.autoDelete !== void 0) {
307
+ const timer = this._autoDeleteTimers.get(id);
308
+ if (timer) {
309
+ clearTimeout(timer);
310
+ this._autoDeleteTimers.delete(id);
311
+ }
312
+ if (patch.autoDelete) this._autoDeleteTimers.set(id, setTimeout(() => {
313
+ this.remove(id);
314
+ }, patch.autoDelete));
315
+ }
316
+ return updated;
317
+ }
318
+ async remove(id) {
319
+ const timer = this._autoDeleteTimers.get(id);
320
+ if (timer) {
321
+ clearTimeout(timer);
322
+ this._autoDeleteTimers.delete(id);
323
+ }
324
+ this.entries.delete(id);
325
+ this.lastModified.delete(id);
326
+ this.removals.push({
327
+ id,
328
+ time: this._tick()
329
+ });
330
+ this.events.emit("log:removed", id);
331
+ }
332
+ async clear() {
333
+ for (const timer of this._autoDeleteTimers.values()) clearTimeout(timer);
334
+ this._autoDeleteTimers.clear();
335
+ const tick = this._tick();
336
+ for (const id of this.entries.keys()) this.removals.push({
337
+ id,
338
+ time: tick
339
+ });
340
+ this.entries.clear();
341
+ this.lastModified.clear();
342
+ this.events.emit("log:cleared");
343
+ }
344
+ _createHandle(id) {
345
+ const host = this;
346
+ return {
347
+ get entry() {
348
+ return host.entries.get(id);
349
+ },
350
+ get id() {
351
+ return id;
352
+ },
353
+ update: (patch) => host.update(id, patch),
354
+ dismiss: () => host.remove(id)
355
+ };
356
+ }
357
+ };
358
+ //#endregion
359
+ //#region src/node/host-terminals.ts
360
+ var DevToolsTerminalHost = class {
361
+ sessions = /* @__PURE__ */ new Map();
362
+ events = createEventEmitter();
363
+ _boundStreams = /* @__PURE__ */ new Map();
364
+ constructor(context) {
365
+ this.context = context;
366
+ }
367
+ register(session) {
368
+ if (this.sessions.has(session.id)) throw new Error(`Terminal session with id "${session.id}" already registered`);
369
+ this.sessions.set(session.id, session);
370
+ this.bindStream(session);
371
+ this.events.emit("terminal:session:updated", session);
372
+ return session;
373
+ }
374
+ update(patch) {
375
+ if (!this.sessions.has(patch.id)) throw new Error(`Terminal session with id "${patch.id}" not registered`);
376
+ const session = this.sessions.get(patch.id);
377
+ Object.assign(session, patch);
378
+ this.sessions.set(patch.id, session);
379
+ this.bindStream(session);
380
+ this.events.emit("terminal:session:updated", session);
381
+ }
382
+ remove(session) {
383
+ this._boundStreams.get(session.id)?.dispose();
384
+ this.sessions.delete(session.id);
385
+ this.events.emit("terminal:session:updated", session);
386
+ this._boundStreams.delete(session.id);
387
+ }
388
+ bindStream(session) {
389
+ if (this._boundStreams.has(session.id) && this._boundStreams.get(session.id)?.stream === session.stream) return;
390
+ this._boundStreams.get(session.id)?.dispose();
391
+ this._boundStreams.delete(session.id);
392
+ if (!session.stream) return;
393
+ session.buffer ||= [];
394
+ const events = this.events;
395
+ const writer = new WritableStream({ write(chunk) {
396
+ session.buffer.push(chunk);
397
+ events.emit("terminal:session:stream-chunk", {
398
+ id: session.id,
399
+ chunks: [chunk],
400
+ ts: Date.now()
401
+ });
402
+ } });
403
+ session.stream.pipeTo(writer);
404
+ this._boundStreams.set(session.id, {
405
+ dispose: () => {
406
+ writer.close();
407
+ },
408
+ stream: session.stream
409
+ });
410
+ }
411
+ async startChildProcess(executeOptions, terminal) {
412
+ if (this.sessions.has(terminal.id)) throw new Error(`Terminal session with id "${terminal.id}" already registered`);
413
+ const { exec } = await import("tinyexec");
414
+ let controller;
415
+ const stream = new ReadableStream({ start(_controller) {
416
+ controller = _controller;
417
+ } });
418
+ function createChildProcess() {
419
+ const cp = exec(executeOptions.command, executeOptions.args || [], { nodeOptions: {
420
+ env: {
421
+ COLORS: "true",
422
+ FORCE_COLOR: "true",
423
+ ...executeOptions.env || {}
424
+ },
425
+ cwd: executeOptions.cwd ?? process$1.cwd(),
426
+ stdio: "pipe"
427
+ } });
428
+ (async () => {
429
+ for await (const chunk of cp) controller?.enqueue(chunk);
430
+ })();
431
+ return cp;
432
+ }
433
+ let cp = createChildProcess();
434
+ const restart = async () => {
435
+ cp?.kill();
436
+ cp = createChildProcess();
437
+ };
438
+ const terminate = async () => {
439
+ cp?.kill();
440
+ cp = void 0;
441
+ };
442
+ const session = {
443
+ ...terminal,
444
+ status: "running",
445
+ stream,
446
+ type: "child-process",
447
+ executeOptions,
448
+ getChildProcess: () => cp?.process,
449
+ terminate,
450
+ restart
451
+ };
452
+ this.register(session);
453
+ return Promise.resolve(session);
454
+ }
455
+ };
456
+ //#endregion
457
+ //#region src/node/host-views.ts
458
+ var DevToolsViewHost = class {
459
+ /**
460
+ * @internal
461
+ */
462
+ buildStaticDirs = [];
463
+ constructor(context) {
464
+ this.context = context;
465
+ }
466
+ hostStatic(baseUrl, distDir) {
467
+ if (!existsSync(distDir)) throw new Error(`[Vite DevTools] distDir ${distDir} does not exist`);
468
+ this.buildStaticDirs.push({
469
+ baseUrl,
470
+ distDir
471
+ });
472
+ if (this.context.viteConfig.command === "serve") {
473
+ if (!this.context.viteServer) throw new Error("[Vite DevTools] viteServer is required in dev mode");
474
+ this.context.viteServer.middlewares.use(baseUrl, sirv(distDir, {
475
+ dev: true,
476
+ single: true
477
+ }));
478
+ }
479
+ }
480
+ };
481
+ //#endregion
482
+ //#region ../../node_modules/.pnpm/@clack+core@1.1.0/node_modules/@clack/core/dist/index.mjs
483
+ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
484
+ const ESC = "\x1B";
485
+ const CSI = `${ESC}[`;
486
+ const beep = "\x07";
487
+ const cursor = {
488
+ to(x, y) {
489
+ if (!y) return `${CSI}${x + 1}G`;
490
+ return `${CSI}${y + 1};${x + 1}H`;
491
+ },
492
+ move(x, y) {
493
+ let ret = "";
494
+ if (x < 0) ret += `${CSI}${-x}D`;
495
+ else if (x > 0) ret += `${CSI}${x}C`;
496
+ if (y < 0) ret += `${CSI}${-y}A`;
497
+ else if (y > 0) ret += `${CSI}${y}B`;
498
+ return ret;
499
+ },
500
+ up: (count = 1) => `${CSI}${count}A`,
501
+ down: (count = 1) => `${CSI}${count}B`,
502
+ forward: (count = 1) => `${CSI}${count}C`,
503
+ backward: (count = 1) => `${CSI}${count}D`,
504
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
505
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
506
+ left: `${CSI}G`,
507
+ hide: `${CSI}?25l`,
508
+ show: `${CSI}?25h`,
509
+ save: `${ESC}7`,
510
+ restore: `${ESC}8`
511
+ };
512
+ module.exports = {
513
+ cursor,
514
+ scroll: {
515
+ up: (count = 1) => `${CSI}S`.repeat(count),
516
+ down: (count = 1) => `${CSI}T`.repeat(count)
517
+ },
518
+ erase: {
519
+ screen: `${CSI}2J`,
520
+ up: (count = 1) => `${CSI}1J`.repeat(count),
521
+ down: (count = 1) => `${CSI}J`.repeat(count),
522
+ line: `${CSI}2K`,
523
+ lineEnd: `${CSI}K`,
524
+ lineStart: `${CSI}1K`,
525
+ lines(count) {
526
+ let clear = "";
527
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
528
+ if (count) clear += cursor.left;
529
+ return clear;
530
+ }
531
+ },
532
+ beep
533
+ };
534
+ })))();
535
+ function x$1(t, e, s) {
536
+ if (!s.some((u) => !u.disabled)) return t;
537
+ const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
538
+ return s[n].disabled ? x$1(n, e < 0 ? -1 : 1, s) : n;
539
+ }
540
+ const at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L = /\t{1,1000}/y, P = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, ft$1 = {
541
+ limit: Infinity,
542
+ ellipsis: ""
543
+ }, X$1 = (t, e = {}, s = {}) => {
544
+ const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$1, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
545
+ let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
546
+ t: for (;;) {
547
+ if (w > C || o >= p && o > h) {
548
+ const ut = t.slice(C, w) || t.slice(h, o);
549
+ v = 0;
550
+ for (const Y of ut.replaceAll(ct, "")) {
551
+ const $ = Y.codePointAt(0) || 0;
552
+ if (lt($) ? f = m : ht($) ? f = V : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
553
+ F = !0;
554
+ break t;
555
+ }
556
+ v += Y.length, c += f;
557
+ }
558
+ C = w = 0;
559
+ }
560
+ if (o >= p) break;
561
+ if (M.lastIndex = o, M.test(t)) {
562
+ if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
563
+ F = !0;
564
+ break;
565
+ }
566
+ c += f, C = h, w = o, o = h = M.lastIndex;
567
+ continue;
568
+ }
569
+ if (O.lastIndex = o, O.test(t)) {
570
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
571
+ F = !0;
572
+ break;
573
+ }
574
+ c += u, C = h, w = o, o = h = O.lastIndex;
575
+ continue;
576
+ }
577
+ if (y.lastIndex = o, y.test(t)) {
578
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
579
+ F = !0;
580
+ break;
581
+ }
582
+ c += f, C = h, w = o, o = h = y.lastIndex;
583
+ continue;
584
+ }
585
+ if (L.lastIndex = o, L.test(t)) {
586
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
587
+ F = !0;
588
+ break;
589
+ }
590
+ c += f, C = h, w = o, o = h = L.lastIndex;
591
+ continue;
592
+ }
593
+ if (P.lastIndex = o, P.test(t)) {
594
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
595
+ F = !0;
596
+ break;
597
+ }
598
+ c += g, C = h, w = o, o = h = P.lastIndex;
599
+ continue;
600
+ }
601
+ o += 1;
602
+ }
603
+ return {
604
+ width: F ? b : c,
605
+ index: F ? d : p,
606
+ truncated: F,
607
+ ellipsed: F && i >= n
608
+ };
609
+ }, pt$1 = {
610
+ limit: Infinity,
611
+ ellipsis: "",
612
+ ellipsisWidth: 0
613
+ }, S = (t, e = {}) => X$1(t, pt$1, e).width, T = "\x1B", Z = "›", Ft$1 = 39, j = "\x07", Q$1 = "[", dt = "]", tt = "m", U$1 = `${dt}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$1}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
614
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
615
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
616
+ if (t === 1 || t === 2) return 22;
617
+ if (t === 3) return 23;
618
+ if (t === 4) return 24;
619
+ if (t === 7) return 27;
620
+ if (t === 8) return 28;
621
+ if (t === 9) return 29;
622
+ if (t === 0) return 0;
623
+ }, st = (t) => `${T}${Q$1}${t}${tt}`, it = (t) => `${T}${U$1}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G = (t, e, s) => {
624
+ const i = e[Symbol.iterator]();
625
+ let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
626
+ for (; !l.done;) {
627
+ const m = l.value, A = S(m);
628
+ a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === T || m === Z) && (r = !0, n = e.startsWith(U$1, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
629
+ }
630
+ u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
631
+ }, vt$1 = (t) => {
632
+ const e = t.split(" ");
633
+ let s = e.length;
634
+ for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
635
+ return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
636
+ }, Et$1 = (t, e, s = {}) => {
637
+ if (s.trim !== !1 && t.trim() === "") return "";
638
+ let i = "", r, n;
639
+ const u = t.split(" "), a = gt$1(u);
640
+ let l = [""];
641
+ for (const [h, o] of u.entries()) {
642
+ s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
643
+ let p = S(l.at(-1) ?? "");
644
+ if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
645
+ const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
646
+ Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
647
+ continue;
648
+ }
649
+ if (p + a[h] > e && p > 0 && a[h] > 0) {
650
+ if (s.wordWrap === !1 && p < e) {
651
+ G(l, o, e);
652
+ continue;
653
+ }
654
+ l.push("");
655
+ }
656
+ if (p + a[h] > e && s.wordWrap === !1) {
657
+ G(l, o, e);
658
+ continue;
659
+ }
660
+ l[l.length - 1] += o;
661
+ }
662
+ s.trim !== !1 && (l = l.map((h) => vt$1(h)));
663
+ const E = l.join(`
664
+ `), g = E[Symbol.iterator]();
665
+ let m = g.next(), A = g.next(), V = 0;
666
+ for (; !m.done;) {
667
+ const h = m.value, o = A.value;
668
+ if (i += h, h === T || h === Z) {
669
+ et.lastIndex = V + 1;
670
+ const F = et.exec(E)?.groups;
671
+ if (F?.code !== void 0) {
672
+ const d = Number.parseFloat(F.code);
673
+ r = d === Ft$1 ? void 0 : d;
674
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
675
+ }
676
+ const p = r ? mt$1(r) : void 0;
677
+ o === `
678
+ ` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
679
+ ` && (r && p && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
680
+ }
681
+ return i;
682
+ };
683
+ function K$1(t, e, s) {
684
+ return String(t).normalize().replaceAll(`\r
685
+ `, `
686
+ `).split(`
687
+ `).map((i) => Et$1(i, e, s)).join(`
688
+ `);
689
+ }
690
+ const _ = {
691
+ actions: new Set([
692
+ "up",
693
+ "down",
694
+ "left",
695
+ "right",
696
+ "space",
697
+ "enter",
698
+ "cancel"
699
+ ]),
700
+ aliases: new Map([
701
+ ["k", "up"],
702
+ ["j", "down"],
703
+ ["h", "left"],
704
+ ["l", "right"],
705
+ ["", "cancel"],
706
+ ["escape", "cancel"]
707
+ ]),
708
+ messages: {
709
+ cancel: "Canceled",
710
+ error: "Something went wrong"
711
+ },
712
+ withGuide: !0
713
+ };
714
+ function H$1(t, e) {
715
+ if (typeof t == "string") return _.aliases.get(t) === e;
716
+ for (const s of t) if (s !== void 0 && H$1(s, e)) return !0;
717
+ return !1;
718
+ }
719
+ function _t$1(t, e) {
720
+ if (t === e) return;
721
+ const s = t.split(`
722
+ `), i = e.split(`
723
+ `), r = Math.max(s.length, i.length), n = [];
724
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
725
+ return {
726
+ lines: n,
727
+ numLinesBefore: s.length,
728
+ numLinesAfter: i.length,
729
+ numLines: r
730
+ };
731
+ }
732
+ globalThis.process.platform.startsWith("win");
733
+ const z$1 = Symbol("clack:cancel");
734
+ function W$1(t, e) {
735
+ const s = t;
736
+ s.isTTY && s.setRawMode(e);
737
+ }
738
+ const rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
739
+ var B = class {
740
+ input;
741
+ output;
742
+ _abortSignal;
743
+ rl;
744
+ opts;
745
+ _render;
746
+ _track = !1;
747
+ _prevFrame = "";
748
+ _subscribers = /* @__PURE__ */ new Map();
749
+ _cursor = 0;
750
+ state = "initial";
751
+ error = "";
752
+ value;
753
+ userInput = "";
754
+ constructor(e, s = !0) {
755
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
756
+ this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
757
+ }
758
+ unsubscribe() {
759
+ this._subscribers.clear();
760
+ }
761
+ setSubscriber(e, s) {
762
+ const i = this._subscribers.get(e) ?? [];
763
+ i.push(s), this._subscribers.set(e, i);
764
+ }
765
+ on(e, s) {
766
+ this.setSubscriber(e, { cb: s });
767
+ }
768
+ once(e, s) {
769
+ this.setSubscriber(e, {
770
+ cb: s,
771
+ once: !0
772
+ });
773
+ }
774
+ emit(e, ...s) {
775
+ const i = this._subscribers.get(e) ?? [], r = [];
776
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
777
+ for (const n of r) n();
778
+ }
779
+ prompt() {
780
+ return new Promise((e) => {
781
+ if (this._abortSignal) {
782
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$1);
783
+ this._abortSignal.addEventListener("abort", () => {
784
+ this.state = "cancel", this.close();
785
+ }, { once: !0 });
786
+ }
787
+ this.rl = ot.createInterface({
788
+ input: this.input,
789
+ tabSize: 2,
790
+ prompt: "",
791
+ escapeCodeTimeout: 50,
792
+ terminal: !0
793
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), W$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
794
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), W$1(this.input, !1), e(this.value);
795
+ }), this.once("cancel", () => {
796
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), W$1(this.input, !1), e(z$1);
797
+ });
798
+ });
799
+ }
800
+ _isActionKey(e, s) {
801
+ return e === " ";
802
+ }
803
+ _setValue(e) {
804
+ this.value = e, this.emit("value", this.value);
805
+ }
806
+ _setUserInput(e, s) {
807
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
808
+ }
809
+ _clearUserInput() {
810
+ this.rl?.write(null, {
811
+ ctrl: !0,
812
+ name: "u"
813
+ }), this._setUserInput("");
814
+ }
815
+ onKeypress(e, s) {
816
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
817
+ ctrl: !0,
818
+ name: "h"
819
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
820
+ if (this.opts.validate) {
821
+ const i = this.opts.validate(this.value);
822
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
823
+ }
824
+ this.state !== "error" && (this.state = "submit");
825
+ }
826
+ H$1([
827
+ e,
828
+ s?.name,
829
+ s?.sequence
830
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
831
+ }
832
+ close() {
833
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
834
+ `), W$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
835
+ }
836
+ restoreCursor() {
837
+ const e = K$1(this._prevFrame, process.stdout.columns, {
838
+ hard: !0,
839
+ trim: !1
840
+ }).split(`
841
+ `).length - 1;
842
+ this.output.write(import_src.cursor.move(-999, e * -1));
843
+ }
844
+ render() {
845
+ const e = K$1(this._render(this) ?? "", process.stdout.columns, {
846
+ hard: !0,
847
+ trim: !1
848
+ });
849
+ if (e !== this._prevFrame) {
850
+ if (this.state === "initial") this.output.write(import_src.cursor.hide);
851
+ else {
852
+ const s = _t$1(this._prevFrame, e), i = nt(this.output);
853
+ if (this.restoreCursor(), s) {
854
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
855
+ let u = s.lines.find((a) => a >= r);
856
+ if (u === void 0) {
857
+ this._prevFrame = e;
858
+ return;
859
+ }
860
+ if (s.lines.length === 1) {
861
+ this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
862
+ const a = e.split(`
863
+ `);
864
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
865
+ return;
866
+ } else if (s.lines.length > 1) {
867
+ if (r < n) u = r;
868
+ else {
869
+ const l = u - n;
870
+ l > 0 && this.output.write(import_src.cursor.move(0, l));
871
+ }
872
+ this.output.write(import_src.erase.down());
873
+ const a = e.split(`
874
+ `).slice(u);
875
+ this.output.write(a.join(`
876
+ `)), this._prevFrame = e;
877
+ return;
878
+ }
879
+ }
880
+ this.output.write(import_src.erase.down());
881
+ }
882
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
883
+ }
884
+ }
885
+ };
886
+ var kt$1 = class extends B {
887
+ get cursor() {
888
+ return this.value ? 0 : 1;
889
+ }
890
+ get _value() {
891
+ return this.cursor === 0;
892
+ }
893
+ constructor(e) {
894
+ super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
895
+ this.value = this._value;
896
+ }), this.on("confirm", (s) => {
897
+ this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
898
+ }), this.on("cursor", () => {
899
+ this.value = !this.value;
900
+ });
901
+ }
902
+ };
903
+ //#endregion
904
+ //#region ../../node_modules/.pnpm/@clack+prompts@1.1.0/node_modules/@clack/prompts/dist/index.mjs
905
+ function pt() {
906
+ return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
907
+ }
908
+ const ee = pt(), I = (e, r) => ee ? e : r, Re = I("◆", "*"), $e = I("■", "x"), de = I("▲", "x"), V = I("◇", "o");
909
+ I("┌", "T");
910
+ const h = I("│", "|"), x = I("└", "—");
911
+ I("┐", "T");
912
+ I("┘", "—");
913
+ const z = I("●", ">"), H = I("○", " ");
914
+ I("◻", "[•]");
915
+ I("◼", "[+]");
916
+ I("◻", "[ ]");
917
+ I("▪", "•");
918
+ const se = I("─", "-"), pe = I("╮", "+"), We = I("├", "+"), me = I("╯", "+"), ge = I("╰", "+");
919
+ I("╭", "+");
920
+ const fe = I("●", "•"), Fe = I("◆", "*"), ye = I("▲", "!"), Ee = I("■", "x"), W = (e) => {
921
+ switch (e) {
922
+ case "initial":
923
+ case "active": return styleText("cyan", Re);
924
+ case "cancel": return styleText("red", $e);
925
+ case "error": return styleText("yellow", de);
926
+ case "submit": return styleText("green", V);
927
+ }
928
+ }, mt = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, gt = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, ft = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, ie = /\t{1,1000}/y, Ae = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, Ft = /\p{M}+/gu, yt = {
929
+ limit: Infinity,
930
+ ellipsis: ""
931
+ }, Le = (e, r = {}, s = {}) => {
932
+ const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
933
+ let $ = 0, m = 0, d = e.length, F = 0, y = !1, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S = 0;
934
+ e: for (;;) {
935
+ if (b > A || m >= d && m > $) {
936
+ const T = e.slice(A, b) || e.slice($, m);
937
+ F = 0;
938
+ for (const M of T.replaceAll(Ft, "")) {
939
+ const O = M.codePointAt(0) || 0;
940
+ if (gt(O) ? S = f : ft(O) ? S = E : c !== g && mt(O) ? S = c : S = g, w + S > C && (v = Math.min(v, Math.max(A, $) + F)), w + S > i) {
941
+ y = !0;
942
+ break e;
943
+ }
944
+ F += M.length, w += S;
945
+ }
946
+ A = b = 0;
947
+ }
948
+ if (m >= d) break;
949
+ if (ne.lastIndex = m, ne.test(e)) {
950
+ if (F = ne.lastIndex - m, S = F * g, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S > i) {
951
+ y = !0;
952
+ break;
953
+ }
954
+ w += S, A = $, b = m, m = $ = ne.lastIndex;
955
+ continue;
956
+ }
957
+ if (we.lastIndex = m, we.test(e)) {
958
+ if (w + u > C && (v = Math.min(v, m)), w + u > i) {
959
+ y = !0;
960
+ break;
961
+ }
962
+ w += u, A = $, b = m, m = $ = we.lastIndex;
963
+ continue;
964
+ }
965
+ if (re.lastIndex = m, re.test(e)) {
966
+ if (F = re.lastIndex - m, S = F * l, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S > i) {
967
+ y = !0;
968
+ break;
969
+ }
970
+ w += S, A = $, b = m, m = $ = re.lastIndex;
971
+ continue;
972
+ }
973
+ if (ie.lastIndex = m, ie.test(e)) {
974
+ if (F = ie.lastIndex - m, S = F * n, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S > i) {
975
+ y = !0;
976
+ break;
977
+ }
978
+ w += S, A = $, b = m, m = $ = ie.lastIndex;
979
+ continue;
980
+ }
981
+ if (Ae.lastIndex = m, Ae.test(e)) {
982
+ if (w + p > C && (v = Math.min(v, m)), w + p > i) {
983
+ y = !0;
984
+ break;
985
+ }
986
+ w += p, A = $, b = m, m = $ = Ae.lastIndex;
987
+ continue;
988
+ }
989
+ m += 1;
990
+ }
991
+ return {
992
+ width: y ? C : w,
993
+ index: y ? v : d,
994
+ truncated: y,
995
+ ellipsed: y && i >= o
996
+ };
997
+ }, Et = {
998
+ limit: Infinity,
999
+ ellipsis: "",
1000
+ ellipsisWidth: 0
1001
+ }, D = (e, r = {}) => Le(e, Et, r).width, ae = "\x1B", je = "›", vt = 39, Ce = "\x07", ke = "[", wt = "]", Ve = "m", Se = `${wt}8;;`, He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y"), At = (e) => {
1002
+ if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
1003
+ if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
1004
+ if (e === 1 || e === 2) return 22;
1005
+ if (e === 3) return 23;
1006
+ if (e === 4) return 24;
1007
+ if (e === 7) return 27;
1008
+ if (e === 8) return 28;
1009
+ if (e === 9) return 29;
1010
+ if (e === 0) return 0;
1011
+ }, Ue = (e) => `${ae}${ke}${e}${Ve}`, Ke = (e) => `${ae}${Se}${e}${Ce}`, Ct = (e) => e.map((r) => D(r)), Ie = (e, r, s) => {
1012
+ const i = r[Symbol.iterator]();
1013
+ let a = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : D(u), n = i.next(), c = i.next(), p = 0;
1014
+ for (; !n.done;) {
1015
+ const f = n.value, g = D(f);
1016
+ l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = !0, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = !1, o = !1) : f === Ve && (a = !1) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
1017
+ }
1018
+ u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
1019
+ }, St = (e) => {
1020
+ const r = e.split(" ");
1021
+ let s = r.length;
1022
+ for (; s > 0 && !(D(r[s - 1]) > 0);) s--;
1023
+ return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
1024
+ }, It = (e, r, s = {}) => {
1025
+ if (s.trim !== !1 && e.trim() === "") return "";
1026
+ let i = "", a, o;
1027
+ const u = e.split(" "), l = Ct(u);
1028
+ let n = [""];
1029
+ for (const [$, m] of u.entries()) {
1030
+ s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
1031
+ let d = D(n.at(-1) ?? "");
1032
+ if ($ !== 0 && (d >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), d = 0), (d > 0 || s.trim === !1) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
1033
+ const F = r - d, y = 1 + Math.floor((l[$] - F - 1) / r);
1034
+ Math.floor((l[$] - 1) / r) < y && n.push(""), Ie(n, m, r);
1035
+ continue;
1036
+ }
1037
+ if (d + l[$] > r && d > 0 && l[$] > 0) {
1038
+ if (s.wordWrap === !1 && d < r) {
1039
+ Ie(n, m, r);
1040
+ continue;
1041
+ }
1042
+ n.push("");
1043
+ }
1044
+ if (d + l[$] > r && s.wordWrap === !1) {
1045
+ Ie(n, m, r);
1046
+ continue;
1047
+ }
1048
+ n[n.length - 1] += m;
1049
+ }
1050
+ s.trim !== !1 && (n = n.map(($) => St($)));
1051
+ const c = n.join(`
1052
+ `), p = c[Symbol.iterator]();
1053
+ let f = p.next(), g = p.next(), E = 0;
1054
+ for (; !f.done;) {
1055
+ const $ = f.value, m = g.value;
1056
+ if (i += $, $ === ae || $ === je) {
1057
+ He.lastIndex = E + 1;
1058
+ const y = He.exec(c)?.groups;
1059
+ if (y?.code !== void 0) {
1060
+ const v = Number.parseFloat(y.code);
1061
+ a = v === vt ? void 0 : v;
1062
+ } else y?.uri !== void 0 && (o = y.uri.length === 0 ? void 0 : y.uri);
1063
+ }
1064
+ const d = a ? At(a) : void 0;
1065
+ m === `
1066
+ ` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
1067
+ ` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
1068
+ }
1069
+ return i;
1070
+ };
1071
+ function J(e, r, s) {
1072
+ return String(e).normalize().replaceAll(`\r
1073
+ `, `
1074
+ `).split(`
1075
+ `).map((i) => It(i, r, s)).join(`
1076
+ `);
1077
+ }
1078
+ const Rt = (e) => {
1079
+ const r = e.active ?? "Yes", s = e.inactive ?? "No";
1080
+ return new kt$1({
1081
+ active: r,
1082
+ inactive: s,
1083
+ signal: e.signal,
1084
+ input: e.input,
1085
+ output: e.output,
1086
+ initialValue: e.initialValue ?? !0,
1087
+ render() {
1088
+ const i = e.withGuide ?? _.withGuide, a = `${i ? `${styleText("gray", h)}
1089
+ ` : ""}${W(this.state)} ${e.message}
1090
+ `, o = this.value ? r : s;
1091
+ switch (this.state) {
1092
+ case "submit": return `${a}${i ? `${styleText("gray", h)} ` : ""}${styleText("dim", o)}`;
1093
+ case "cancel": return `${a}${i ? `${styleText("gray", h)} ` : ""}${styleText(["strikethrough", "dim"], o)}${i ? `
1094
+ ${styleText("gray", h)}` : ""}`;
1095
+ default: {
1096
+ const u = i ? `${styleText("cyan", h)} ` : "", l = i ? styleText("cyan", x) : "";
1097
+ return `${a}${u}${this.value ? `${styleText("green", z)} ${r}` : `${styleText("dim", H)} ${styleText("dim", r)}`}${e.vertical ? i ? `
1098
+ ${styleText("cyan", h)} ` : `
1099
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", H)} ${styleText("dim", s)}` : `${styleText("green", z)} ${s}`}
1100
+ ${l}
1101
+ `;
1102
+ }
1103
+ }
1104
+ }
1105
+ }).prompt();
1106
+ }, R = {
1107
+ message: (e = [], { symbol: r = styleText("gray", h), secondarySymbol: s = styleText("gray", h), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
1108
+ const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", p = l ? `${s} ` : "";
1109
+ for (let g = 0; g < a; g++) u.push(n);
1110
+ const f = Array.isArray(e) ? e : e.split(`
1111
+ `);
1112
+ if (f.length > 0) {
1113
+ const [g, ...E] = f;
1114
+ g.length > 0 ? u.push(`${c}${g}`) : u.push(l ? r : "");
1115
+ for (const $ of E) $.length > 0 ? u.push(`${p}${$}`) : u.push(l ? s : "");
1116
+ }
1117
+ i.write(`${u.join(`
1118
+ `)}
1119
+ `);
1120
+ },
1121
+ info: (e, r) => {
1122
+ R.message(e, {
1123
+ ...r,
1124
+ symbol: styleText("blue", fe)
1125
+ });
1126
+ },
1127
+ success: (e, r) => {
1128
+ R.message(e, {
1129
+ ...r,
1130
+ symbol: styleText("green", Fe)
1131
+ });
1132
+ },
1133
+ step: (e, r) => {
1134
+ R.message(e, {
1135
+ ...r,
1136
+ symbol: styleText("green", V)
1137
+ });
1138
+ },
1139
+ warn: (e, r) => {
1140
+ R.message(e, {
1141
+ ...r,
1142
+ symbol: styleText("yellow", ye)
1143
+ });
1144
+ },
1145
+ warning: (e, r) => {
1146
+ R.warn(e, r);
1147
+ },
1148
+ error: (e, r) => {
1149
+ R.message(e, {
1150
+ ...r,
1151
+ symbol: styleText("red", Ee)
1152
+ });
1153
+ }
1154
+ }, Gt = (e = "", r) => {
1155
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${styleText("gray", h)}
1156
+ ${styleText("gray", x)} ` : "";
1157
+ s.write(`${i}${e}
1158
+
1159
+ `);
1160
+ }, jt = (e) => styleText("dim", e), kt = (e, r, s) => {
1161
+ const i = {
1162
+ hard: !0,
1163
+ trim: !1
1164
+ }, a = J(e, r, i).split(`
1165
+ `), o = a.reduce((n, c) => Math.max(D(c), n), 0);
1166
+ return J(e, r - (a.map(s).reduce((n, c) => Math.max(D(c), n), 0) - o), i);
1167
+ }, Vt = (e = "", r = "", s) => {
1168
+ const i = s?.output ?? process$1.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? jt, u = [
1169
+ "",
1170
+ ...kt(e, rt(i) - 6, o).split(`
1171
+ `).map(o),
1172
+ ""
1173
+ ], l = D(r), n = Math.max(u.reduce((g, E) => {
1174
+ const $ = D(E);
1175
+ return $ > g ? $ : g;
1176
+ }, 0), l) + 2, c = u.map((g) => `${styleText("gray", h)} ${g}${" ".repeat(n - D(g))}${styleText("gray", h)}`).join(`
1177
+ `), p = a ? `${styleText("gray", h)}
1178
+ ` : "", f = a ? We : ge;
1179
+ i.write(`${p}${styleText("green", V)} ${styleText("reset", r)} ${styleText("gray", se.repeat(Math.max(n - l - 1, 1)) + pe)}
1180
+ ${c}
1181
+ ${styleText("gray", f + se.repeat(n + 2) + me)}
1182
+ `);
1183
+ };
1184
+ I("─", "-"), I("━", "="), I("█", "#");
1185
+ const Qe = `${styleText("gray", h)} `, K = {
1186
+ message: async (e, { symbol: r = styleText("gray", h) } = {}) => {
1187
+ process.stdout.write(`${styleText("gray", h)}
1188
+ ${r} `);
1189
+ let s = 3;
1190
+ for await (let i of e) {
1191
+ i = i.replace(/\n/g, `
1192
+ ${Qe}`), i.includes(`
1193
+ `) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
1194
+ `))).length);
1195
+ const a = stripVTControlCharacters(i).length;
1196
+ s + a < process.stdout.columns ? (s += a, process.stdout.write(i)) : (process.stdout.write(`
1197
+ ${Qe}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
1198
+ }
1199
+ process.stdout.write(`
1200
+ `);
1201
+ },
1202
+ info: (e) => K.message(e, { symbol: styleText("blue", fe) }),
1203
+ success: (e) => K.message(e, { symbol: styleText("green", Fe) }),
1204
+ step: (e) => K.message(e, { symbol: styleText("green", V) }),
1205
+ warn: (e) => K.message(e, { symbol: styleText("yellow", ye) }),
1206
+ warning: (e) => K.warn(e),
1207
+ error: (e) => K.message(e, { symbol: styleText("red", Ee) })
1208
+ };
1209
+ //#endregion
1210
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
1211
+ var import_ansis = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1212
+ let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a } = Math, p = (e) => {
1213
+ let t = /([a-f\d]{3,6})/i.exec(e)?.[1], r = t?.length, l = parseInt(6 ^ r ? 3 ^ r ? "0" : t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, 16);
1214
+ return [
1215
+ l >> 16 & 255,
1216
+ l >> 8 & 255,
1217
+ 255 & l
1218
+ ];
1219
+ }, u = (e, t, r) => e ^ t || t ^ r ? 16 + 36 * c(e / 51) + 6 * c(t / 51) + c(r / 51) : 8 > e ? 16 : e > 248 ? 231 : c(24 * (e - 8) / 247) + 232, d = (e) => {
1220
+ let t, r, l, n, o;
1221
+ return 8 > e ? 30 + e : 16 > e ? e - 8 + 90 : (232 > e ? (o = (e -= 16) % 36, t = (e / 36 | 0) / 5, r = (o / 6 | 0) / 5, l = o % 6 / 5) : t = r = l = (10 * (e - 232) + 8) / 255, n = 2 * a(t, r, l), n ? 30 + (c(l) << 2 | c(r) << 1 | c(t)) + (2 ^ n ? 0 : 60) : 30);
1222
+ }, f = (() => {
1223
+ let r = (e) => o.some(((t) => e.test(t))), l = globalThis, n = l.process ?? {}, o = n.argv ?? [], i = n.env ?? {}, c = -1;
1224
+ try {
1225
+ e = "," + s(i).join(",");
1226
+ } catch (e) {
1227
+ i = {}, c = 0;
1228
+ }
1229
+ let a = "FORCE_COLOR", p = {
1230
+ false: 0,
1231
+ 0: 0,
1232
+ 1: 1,
1233
+ 2: 2,
1234
+ 3: 3
1235
+ }[i[a]] ?? -1, u = a in i && p || r(/^--color=?(true|always)?$/);
1236
+ return u && (c = p), ~c || (c = ((r, l, n) => (t = r.TERM, {
1237
+ "24bit": 3,
1238
+ truecolor: 3,
1239
+ ansi256: 2,
1240
+ ansi: 1
1241
+ }[r.COLORTERM] || (r.CI ? /,GITHUB/.test(e) ? 3 : 1 : l && "dumb" !== t ? n ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i, !!i.PM2_HOME || i.NEXT_RUNTIME?.includes("edge") || !!n.stdout?.isTTY, "win32" === n.platform)), !p || i.NO_COLOR || r(/^--(no-color|color=(false|never))$/) ? 0 : l.window?.chrome || u && !c ? 3 : c;
1242
+ })(), g = {
1243
+ open: i,
1244
+ close: i
1245
+ }, h = 39, b = 49, O = {}, m = ({ p: e }, { open: t, close: l }) => {
1246
+ let o = (e, ...r) => {
1247
+ if (!e) {
1248
+ if (t && t === l) return t;
1249
+ if ((e ?? i) === i) return i;
1250
+ }
1251
+ let n, s = e.raw ? String.raw({ raw: e }, ...r) : i + e, c = o.p, a = c.o, p = c.c;
1252
+ if (s.includes("\x1B")) for (; c; c = c.p) {
1253
+ let { open: e, close: t } = c, r = t.length, l = i, o = 0;
1254
+ if (r) for (; ~(n = s.indexOf(t, o)); o = n + r) l += s.slice(o, n) + e;
1255
+ s = l + s.slice(o);
1256
+ }
1257
+ return a + (s.includes("\n") ? s.replace(/(\r?\n)/g, p + "$1" + a) : s) + p;
1258
+ }, s = t, c = l;
1259
+ return e && (s = e.o + t, c = l + e.c), n(o, r), o.p = {
1260
+ open: t,
1261
+ close: l,
1262
+ o: s,
1263
+ c,
1264
+ p: e
1265
+ }, o.open = s, o.close = c, o;
1266
+ };
1267
+ const w = new function e(t = f) {
1268
+ let s = {
1269
+ Ansis: e,
1270
+ level: t,
1271
+ isSupported: () => a,
1272
+ strip: (e) => e.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
1273
+ extend(e) {
1274
+ for (let t in e) {
1275
+ let r = e[t], l = (typeof r)[0];
1276
+ "s" === l ? (c(t, T(...p(r))), c(_(t), v(...p(r)))) : c(t, r, "f" === l);
1277
+ }
1278
+ return r = o({}, O), n(s, r), s;
1279
+ }
1280
+ }, c = (e, t, r) => {
1281
+ O[e] = { get() {
1282
+ let n = r ? (...e) => m(this, t(...e)) : m(this, t);
1283
+ return l(this, e, { value: n }), n;
1284
+ } };
1285
+ }, a = t > 0, w = (e, t) => a ? {
1286
+ open: `[${e}m`,
1287
+ close: `[${t}m`
1288
+ } : g, y = (e) => (t) => e(...p(t)), R = (e, t) => (r, l, n) => w(`${e}8;2;${r};${l};${n}`, t), $ = (e, t) => (r, l, n) => w(((e, t, r) => d(u(e, t, r)))(r, l, n) + e, t), x = (e) => (t, r, l) => e(u(t, r, l)), T = R(3, h), v = R(4, b), C = (e) => w("38;5;" + e, h), E = (e) => w("48;5;" + e, b);
1289
+ 2 === t ? (T = x(C), v = x(E)) : 1 === t && (T = $(0, h), v = $(10, b), C = (e) => w(d(e), h), E = (e) => w(d(e) + 10, b));
1290
+ let M, I = {
1291
+ fg: C,
1292
+ bg: E,
1293
+ rgb: T,
1294
+ bgRgb: v,
1295
+ hex: y(T),
1296
+ bgHex: y(v),
1297
+ visible: g,
1298
+ reset: w(0, 0),
1299
+ bold: w(1, 22),
1300
+ dim: w(2, 22),
1301
+ italic: w(3, 23),
1302
+ underline: w(4, 24),
1303
+ inverse: w(7, 27),
1304
+ hidden: w(8, 28),
1305
+ strikethrough: w(9, 29)
1306
+ }, _ = (e) => "bg" + e[0].toUpperCase() + e.slice(1), k = "Bright";
1307
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e, t) => {
1308
+ M = _(e), 8 > t ? (I[e + k] = w(90 + t, h), I[M + k] = w(100 + t, b)) : t = 60, I[e] = w(30 + t, h), I[M] = w(40 + t, b);
1309
+ })), s.extend(I);
1310
+ }();
1311
+ module.exports = w, w.default = w;
1312
+ })))(), 1);
1313
+ var ansis_default = import_ansis.default;
1314
+ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
1315
+ //#endregion
1316
+ //#region src/node/context-internal.ts
1317
+ const internalContextMap = /* @__PURE__ */ new WeakMap();
1318
+ function getInternalContext(context) {
1319
+ if (!internalContextMap.has(context)) {
1320
+ const internalContext = { storage: { auth: createStorage({
1321
+ filepath: join(context.workspaceRoot, "node_modules/.vite/devtools/auth.json"),
1322
+ initialValue: { trusted: {} }
1323
+ }) } };
1324
+ internalContextMap.set(context, internalContext);
1325
+ }
1326
+ return internalContextMap.get(context);
1327
+ }
1328
+ //#endregion
1329
+ //#region src/node/rpc/anonymous/auth.ts
1330
+ const anonymousAuth = defineRpcFunction({
1331
+ name: "vite:anonymous:auth",
1332
+ type: "action",
1333
+ setup: (context) => {
1334
+ const storage = getInternalContext(context).storage.auth;
1335
+ return { handler: async (query) => {
1336
+ const session = context.rpc.getCurrentRpcSession();
1337
+ if (!session) throw new Error("Failed to retrieve the current RPC session");
1338
+ if (session.meta.isTrusted || storage.value().trusted[query.authId]) {
1339
+ session.meta.clientAuthId = query.authId;
1340
+ session.meta.isTrusted = true;
1341
+ return { isTrusted: true };
1342
+ }
1343
+ const message = [
1344
+ `A browser is requesting permissions to connect to the Vite DevTools.`,
1345
+ "",
1346
+ `User Agent: ${ansis_default.yellow(ansis_default.bold(query.ua || "Unknown"))}`,
1347
+ `Origin : ${ansis_default.cyan(ansis_default.bold(query.origin || "Unknown"))}`,
1348
+ `Identifier: ${ansis_default.green(ansis_default.bold(query.authId))}`,
1349
+ "",
1350
+ "This will allow the browser to interact with the server, make file changes and run commands.",
1351
+ ansis_default.red(ansis_default.bold("You should only trust your local development browsers."))
1352
+ ];
1353
+ Vt(ansis_default.reset(message.join("\n")), ansis_default.bold(ansis_default.yellow(" Vite DevTools Permission Request ")));
1354
+ if (await Rt({
1355
+ message: ansis_default.bold(`Do you trust this client (${ansis_default.green(ansis_default.bold(query.authId))})?`),
1356
+ initialValue: false
1357
+ })) {
1358
+ storage.mutate((state) => {
1359
+ state.trusted[query.authId] = {
1360
+ authId: query.authId,
1361
+ ua: query.ua,
1362
+ origin: query.origin,
1363
+ timestamp: Date.now()
1364
+ };
1365
+ });
1366
+ session.meta.clientAuthId = query.authId;
1367
+ session.meta.isTrusted = true;
1368
+ Gt(ansis_default.green(ansis_default.bold(`You have granted permissions to ${ansis_default.bold(query.authId)}`)));
1369
+ return { isTrusted: true };
1370
+ }
1371
+ Gt(ansis_default.red(ansis_default.bold(`You have denied permissions to ${ansis_default.bold(query.authId)}`)));
1372
+ return { isTrusted: false };
1373
+ } };
1374
+ }
1375
+ });
1376
+ //#endregion
1377
+ //#region src/node/rpc/internal/docks-on-launch.ts
1378
+ const docksOnLaunch = defineRpcFunction({
1379
+ name: "devtoolskit:internal:docks:on-launch",
1380
+ type: "action",
1381
+ setup: (context) => {
1382
+ const launchMap = /* @__PURE__ */ new Map();
1383
+ return { handler: async (entryId) => {
1384
+ if (launchMap.has(entryId)) return launchMap.get(entryId);
1385
+ const entry = context.docks.values().find((entry) => entry.id === entryId);
1386
+ if (!entry) throw new Error(`Dock entry with id "${entryId}" not found`);
1387
+ if (entry.type !== "launcher") throw new Error(`Dock entry with id "${entryId}" is not a launcher`);
1388
+ try {
1389
+ context.docks.update({
1390
+ ...entry,
1391
+ launcher: {
1392
+ ...entry.launcher,
1393
+ status: "loading"
1394
+ }
1395
+ });
1396
+ const promise = entry.launcher.onLaunch();
1397
+ launchMap.set(entryId, promise);
1398
+ const result = await promise;
1399
+ const newEntry = context.docks.values().find((entry) => entry.id === entryId) || entry;
1400
+ if (newEntry.type === "launcher") context.docks.update({
1401
+ ...newEntry,
1402
+ launcher: {
1403
+ ...newEntry.launcher,
1404
+ status: "success"
1405
+ }
1406
+ });
1407
+ return result;
1408
+ } catch (error) {
1409
+ console.error(`[VITE DEVTOOLS] Error launching dock entry "${entryId}"`, error);
1410
+ context.docks.update({
1411
+ ...entry,
1412
+ launcher: {
1413
+ ...entry.launcher,
1414
+ status: "error",
1415
+ error: error instanceof Error ? error.message : String(error)
1416
+ }
1417
+ });
1418
+ }
1419
+ } };
1420
+ }
1421
+ });
1422
+ //#endregion
1423
+ //#region src/node/rpc/internal/logs-add.ts
1424
+ const logsAdd = defineRpcFunction({
1425
+ name: "devtoolskit:internal:logs:add",
1426
+ type: "action",
1427
+ setup: (context) => {
1428
+ return { async handler(input) {
1429
+ return (await context.logs.add({
1430
+ ...input,
1431
+ from: "browser"
1432
+ })).entry;
1433
+ } };
1434
+ }
1435
+ });
1436
+ //#endregion
1437
+ //#region src/node/rpc/internal/logs-clear.ts
1438
+ const logsClear = defineRpcFunction({
1439
+ name: "devtoolskit:internal:logs:clear",
1440
+ type: "action",
1441
+ setup: (context) => {
1442
+ return { async handler() {
1443
+ await context.logs.clear();
1444
+ } };
1445
+ }
1446
+ });
1447
+ //#endregion
1448
+ //#region src/node/rpc/internal/logs-list.ts
1449
+ const logsList = defineRpcFunction({
1450
+ name: "devtoolskit:internal:logs:list",
1451
+ type: "static",
1452
+ setup: (context) => {
1453
+ const host = context.logs;
1454
+ return { async handler(since) {
1455
+ const currentVersion = host._clock;
1456
+ if (since == null) return {
1457
+ entries: Array.from(host.entries.values()),
1458
+ removedIds: [],
1459
+ version: currentVersion
1460
+ };
1461
+ const entries = [];
1462
+ for (const [id, entry] of host.entries) {
1463
+ const mod = host.lastModified.get(id);
1464
+ if (mod != null && mod > since) entries.push(entry);
1465
+ }
1466
+ const removedIds = [];
1467
+ for (const r of host.removals) if (r.time > since) removedIds.push(r.id);
1468
+ const pruneThreshold = since;
1469
+ while (host.removals.length > 0 && host.removals[0].time <= pruneThreshold) host.removals.shift();
1470
+ return {
1471
+ entries,
1472
+ removedIds,
1473
+ version: currentVersion
1474
+ };
1475
+ } };
1476
+ }
1477
+ });
1478
+ //#endregion
1479
+ //#region src/node/rpc/internal/logs-remove.ts
1480
+ const logsRemove = defineRpcFunction({
1481
+ name: "devtoolskit:internal:logs:remove",
1482
+ type: "action",
1483
+ setup: (context) => {
1484
+ return { async handler(id) {
1485
+ await context.logs.remove(id);
1486
+ } };
1487
+ }
1488
+ });
1489
+ //#endregion
1490
+ //#region src/node/rpc/internal/logs-update.ts
1491
+ const logsUpdate = defineRpcFunction({
1492
+ name: "devtoolskit:internal:logs:update",
1493
+ type: "action",
1494
+ setup: (context) => {
1495
+ return { async handler(id, patch) {
1496
+ return await context.logs.update(id, patch) ?? null;
1497
+ } };
1498
+ }
1499
+ });
1500
+ //#endregion
1501
+ //#region src/node/rpc/internal/rpc-server-list.ts
1502
+ const rpcServerList = defineRpcFunction({
1503
+ name: "devtoolskit:internal:rpc:server:list",
1504
+ type: "static",
1505
+ setup: (context) => {
1506
+ return { async handler() {
1507
+ return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
1508
+ } };
1509
+ }
1510
+ });
1511
+ //#endregion
1512
+ //#region src/node/rpc/internal/state/get.ts
1513
+ const sharedStateGet = defineRpcFunction({
1514
+ name: "devtoolskit:internal:rpc:server-state:get",
1515
+ type: "query",
1516
+ dump: (context) => {
1517
+ return { inputs: context.rpc.sharedState.keys().map((key) => [key]) };
1518
+ },
1519
+ setup: (context) => {
1520
+ return { handler: async (key) => {
1521
+ return (await context.rpc.sharedState.get(key)).value();
1522
+ } };
1523
+ }
1524
+ });
1525
+ //#endregion
1526
+ //#region src/node/rpc/internal/state/patch.ts
1527
+ const sharedStatePatch = defineRpcFunction({
1528
+ name: "devtoolskit:internal:rpc:server-state:patch",
1529
+ type: "query",
1530
+ setup: (context) => {
1531
+ return { handler: async (key, patches, syncId) => {
1532
+ (await context.rpc.sharedState.get(key)).patch(patches, syncId);
1533
+ } };
1534
+ }
1535
+ });
1536
+ //#endregion
1537
+ //#region src/node/rpc/internal/state/set.ts
1538
+ const sharedStateSet = defineRpcFunction({
1539
+ name: "devtoolskit:internal:rpc:server-state:set",
1540
+ type: "query",
1541
+ setup: (context) => {
1542
+ return { handler: async (key, value, syncId) => {
1543
+ (await context.rpc.sharedState.get(key)).mutate(() => value, syncId);
1544
+ } };
1545
+ }
1546
+ });
1547
+ //#endregion
1548
+ //#region src/node/rpc/internal/state/subscribe.ts
1549
+ const debug = createDebug("vite:devtools:rpc:state:subscribe");
1550
+ const sharedStateSubscribe = defineRpcFunction({
1551
+ name: "devtoolskit:internal:rpc:server-state:subscribe",
1552
+ type: "event",
1553
+ setup: (context) => {
1554
+ return { handler: async (key) => {
1555
+ const session = context.rpc.getCurrentRpcSession();
1556
+ if (!session) return;
1557
+ debug("subscribe", {
1558
+ key,
1559
+ session: session.meta.id
1560
+ });
1561
+ session.meta.subscribedStates.add(key);
1562
+ } };
1563
+ }
1564
+ });
1565
+ //#endregion
1566
+ //#region src/node/rpc/internal/terminals-list.ts
1567
+ const terminalsList = defineRpcFunction({
1568
+ name: "devtoolskit:internal:terminals:list",
1569
+ type: "static",
1570
+ setup: (context) => {
1571
+ return { async handler() {
1572
+ return Array.from(context.terminals.sessions.values()).map((i) => {
1573
+ return {
1574
+ id: i.id,
1575
+ title: i.title,
1576
+ description: i.description,
1577
+ status: i.status
1578
+ };
1579
+ });
1580
+ } };
1581
+ }
1582
+ });
1583
+ //#endregion
1584
+ //#region src/node/rpc/internal/terminals-read.ts
1585
+ const terminalsRead = defineRpcFunction({
1586
+ name: "devtoolskit:internal:terminals:read",
1587
+ type: "query",
1588
+ setup: (context) => {
1589
+ return { async handler(id) {
1590
+ const session = context.terminals.sessions.get(id);
1591
+ if (!session) throw new Error(`Terminal session with id "${id}" not found`);
1592
+ return {
1593
+ buffer: session.buffer ?? [],
1594
+ ts: Date.now()
1595
+ };
1596
+ } };
1597
+ }
1598
+ });
1599
+ //#endregion
1600
+ //#region src/node/rpc/index.ts
1601
+ const builtinPublicRpcDeclarations = [defineRpcFunction({
1602
+ name: "vite:core:open-in-editor",
1603
+ type: "action",
1604
+ setup: () => {
1605
+ return { handler: async (path) => {
1606
+ await import("launch-editor").then((r) => r.default(path));
1607
+ } };
1608
+ }
1609
+ }), defineRpcFunction({
1610
+ name: "vite:core:open-in-finder",
1611
+ type: "action",
1612
+ setup: () => {
1613
+ return { handler: async (path) => {
1614
+ await import("open").then((r) => r.default(path));
1615
+ } };
1616
+ }
1617
+ })];
1618
+ const builtinAnonymousRpcDeclarations = [anonymousAuth];
1619
+ const builtinInternalRpcDeclarations = [
1620
+ docksOnLaunch,
1621
+ logsAdd,
1622
+ logsClear,
1623
+ logsList,
1624
+ logsRemove,
1625
+ logsUpdate,
1626
+ rpcServerList,
1627
+ sharedStateGet,
1628
+ sharedStatePatch,
1629
+ sharedStateSet,
1630
+ sharedStateSubscribe,
1631
+ terminalsList,
1632
+ terminalsRead
1633
+ ];
1634
+ const builtinRpcDeclarations = [
1635
+ ...builtinPublicRpcDeclarations,
1636
+ ...builtinAnonymousRpcDeclarations,
1637
+ ...builtinInternalRpcDeclarations
1638
+ ];
1639
+ //#endregion
1640
+ //#region src/node/context.ts
1641
+ const debugSetup = createDebug("vite:devtools:context:setup");
1642
+ function shouldSkipSetupByCapabilities(plugin, mode) {
1643
+ const modeCapabilities = plugin.devtools?.capabilities?.[mode];
1644
+ if (modeCapabilities === false) return true;
1645
+ if (!isObject(modeCapabilities)) return false;
1646
+ return Object.values(modeCapabilities).includes(false);
1647
+ }
1648
+ async function createDevToolsContext(viteConfig, viteServer) {
1649
+ const cwd = viteConfig.root;
1650
+ const context = {
1651
+ cwd,
1652
+ workspaceRoot: searchForWorkspaceRoot(cwd) ?? cwd,
1653
+ viteConfig,
1654
+ viteServer,
1655
+ mode: viteConfig.command === "serve" ? "dev" : "build",
1656
+ rpc: void 0,
1657
+ docks: void 0,
1658
+ views: void 0,
1659
+ utils: ContextUtils,
1660
+ terminals: void 0,
1661
+ logs: void 0,
1662
+ createJsonRenderer: void 0
1663
+ };
1664
+ const rpcHost = new RpcFunctionsHost(context);
1665
+ const docksHost = new DevToolsDockHost(context);
1666
+ const viewsHost = new DevToolsViewHost(context);
1667
+ const terminalsHost = new DevToolsTerminalHost(context);
1668
+ const logsHost = new DevToolsLogsHost(context);
1669
+ context.rpc = rpcHost;
1670
+ context.docks = docksHost;
1671
+ context.views = viewsHost;
1672
+ context.terminals = terminalsHost;
1673
+ context.logs = logsHost;
1674
+ let jrCounter = 0;
1675
+ context.createJsonRenderer = (initialSpec) => {
1676
+ const stateKey = `__jr:${jrCounter++}`;
1677
+ const statePromise = rpcHost.sharedState.get(stateKey, { initialValue: initialSpec });
1678
+ return {
1679
+ _stateKey: stateKey,
1680
+ async updateSpec(spec) {
1681
+ (await statePromise).mutate(() => spec);
1682
+ },
1683
+ async updateState(newState) {
1684
+ (await statePromise).mutate((draft) => {
1685
+ draft.state = {
1686
+ ...draft.state,
1687
+ ...newState
1688
+ };
1689
+ });
1690
+ }
1691
+ };
1692
+ };
1693
+ for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
1694
+ await docksHost.init();
1695
+ const docksSharedState = await rpcHost.sharedState.get("devtoolskit:internal:docks", { initialValue: [] });
1696
+ docksHost.events.on("dock:entry:updated", debounce(() => {
1697
+ docksSharedState.mutate(() => context.docks.values());
1698
+ }, context.mode === "build" ? 0 : 10));
1699
+ terminalsHost.events.on("terminal:session:updated", debounce(() => {
1700
+ rpcHost.broadcast({
1701
+ method: "devtoolskit:internal:terminals:updated",
1702
+ args: []
1703
+ });
1704
+ docksSharedState.mutate(() => context.docks.values());
1705
+ }, context.mode === "build" ? 0 : 10));
1706
+ terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
1707
+ rpcHost.broadcast({
1708
+ method: "devtoolskit:internal:terminals:stream-chunk",
1709
+ args: [data]
1710
+ });
1711
+ });
1712
+ const debouncedLogsUpdate = debounce(() => {
1713
+ rpcHost.broadcast({
1714
+ method: "devtoolskit:internal:logs:updated",
1715
+ args: []
1716
+ });
1717
+ docksSharedState.mutate(() => context.docks.values());
1718
+ }, context.mode === "build" ? 0 : 10);
1719
+ logsHost.events.on("log:added", () => debouncedLogsUpdate());
1720
+ logsHost.events.on("log:updated", () => debouncedLogsUpdate());
1721
+ logsHost.events.on("log:removed", () => debouncedLogsUpdate());
1722
+ logsHost.events.on("log:cleared", () => debouncedLogsUpdate());
1723
+ const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
1724
+ for (const plugin of plugins) {
1725
+ if (!plugin.devtools?.setup) continue;
1726
+ if (shouldSkipSetupByCapabilities(plugin, context.mode)) {
1727
+ debugSetup(`skipping plugin ${JSON.stringify(plugin.name)} due to disabled capabilities in ${context.mode} mode`);
1728
+ continue;
1729
+ }
1730
+ try {
1731
+ debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`);
1732
+ await plugin.devtools?.setup?.(context);
1733
+ } catch (error) {
1734
+ console.error(`[Vite DevTools] Error setting up plugin ${plugin.name}:`, error);
1735
+ throw error;
1736
+ }
1737
+ }
1738
+ return context;
1739
+ }
1740
+ //#endregion
1741
+ //#region src/node/plugins/injection.ts
1742
+ function DevToolsInjection() {
1743
+ return {
1744
+ name: "vite:devtools:injection",
1745
+ enforce: "post",
1746
+ transformIndexHtml() {
1747
+ return [{
1748
+ tag: "script",
1749
+ attrs: {
1750
+ src: `/@fs/${process$1.env.VITE_DEVTOOLS_LOCAL_DEV ? normalizePath(join$1(dirDist, "..", "src/client/inject/index.ts")) : normalizePath(join$1(dirDist, "client/inject.js"))}`,
1751
+ type: "module"
1752
+ },
1753
+ injectTo: "body"
1754
+ }];
1755
+ }
1756
+ };
1757
+ }
1758
+ //#endregion
1759
+ //#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
1760
+ const unsafePorts = /* @__PURE__ */ new Set([
1761
+ 1,
1762
+ 7,
1763
+ 9,
1764
+ 11,
1765
+ 13,
1766
+ 15,
1767
+ 17,
1768
+ 19,
1769
+ 20,
1770
+ 21,
1771
+ 22,
1772
+ 23,
1773
+ 25,
1774
+ 37,
1775
+ 42,
1776
+ 43,
1777
+ 53,
1778
+ 69,
1779
+ 77,
1780
+ 79,
1781
+ 87,
1782
+ 95,
1783
+ 101,
1784
+ 102,
1785
+ 103,
1786
+ 104,
1787
+ 109,
1788
+ 110,
1789
+ 111,
1790
+ 113,
1791
+ 115,
1792
+ 117,
1793
+ 119,
1794
+ 123,
1795
+ 135,
1796
+ 137,
1797
+ 139,
1798
+ 143,
1799
+ 161,
1800
+ 179,
1801
+ 389,
1802
+ 427,
1803
+ 465,
1804
+ 512,
1805
+ 513,
1806
+ 514,
1807
+ 515,
1808
+ 526,
1809
+ 530,
1810
+ 531,
1811
+ 532,
1812
+ 540,
1813
+ 548,
1814
+ 554,
1815
+ 556,
1816
+ 563,
1817
+ 587,
1818
+ 601,
1819
+ 636,
1820
+ 989,
1821
+ 990,
1822
+ 993,
1823
+ 995,
1824
+ 1719,
1825
+ 1720,
1826
+ 1723,
1827
+ 2049,
1828
+ 3659,
1829
+ 4045,
1830
+ 5060,
1831
+ 5061,
1832
+ 6e3,
1833
+ 6566,
1834
+ 6665,
1835
+ 6666,
1836
+ 6667,
1837
+ 6668,
1838
+ 6669,
1839
+ 6697,
1840
+ 10080
1841
+ ]);
1842
+ function isUnsafePort(port) {
1843
+ return unsafePorts.has(port);
1844
+ }
1845
+ function isSafePort(port) {
1846
+ return !isUnsafePort(port);
1847
+ }
1848
+ var GetPortError = class extends Error {
1849
+ constructor(message, opts) {
1850
+ super(message, opts);
1851
+ this.message = message;
1852
+ }
1853
+ name = "GetPortError";
1854
+ };
1855
+ function _log(verbose, message) {
1856
+ if (verbose) console.log(`[get-port] ${message}`);
1857
+ }
1858
+ function _generateRange(from, to) {
1859
+ if (to < from) return [];
1860
+ const r = [];
1861
+ for (let index = from; index <= to; index++) r.push(index);
1862
+ return r;
1863
+ }
1864
+ function _tryPort(port, host) {
1865
+ return new Promise((resolve) => {
1866
+ const server = createServer();
1867
+ server.unref();
1868
+ server.on("error", () => {
1869
+ resolve(false);
1870
+ });
1871
+ server.listen({
1872
+ port,
1873
+ host
1874
+ }, () => {
1875
+ const { port: port2 } = server.address();
1876
+ server.close(() => {
1877
+ resolve(isSafePort(port2) && port2);
1878
+ });
1879
+ });
1880
+ });
1881
+ }
1882
+ function _getLocalHosts(additional) {
1883
+ const hosts = new Set(additional);
1884
+ for (const _interface of Object.values(networkInterfaces())) for (const config of _interface || []) if (config.address && !config.internal && !config.address.startsWith("fe80::") && !config.address.startsWith("169.254")) hosts.add(config.address);
1885
+ return [...hosts];
1886
+ }
1887
+ async function _findPort(ports, host) {
1888
+ for (const port of ports) {
1889
+ const r = await _tryPort(port, host);
1890
+ if (r) return r;
1891
+ }
1892
+ }
1893
+ function _fmtOnHost(hostname) {
1894
+ return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
1895
+ }
1896
+ const HOSTNAME_RE = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
1897
+ function _validateHostname(hostname, _public, verbose) {
1898
+ if (hostname && !HOSTNAME_RE.test(hostname)) {
1899
+ const fallbackHost = _public ? "0.0.0.0" : "127.0.0.1";
1900
+ _log(verbose, `Invalid hostname: ${JSON.stringify(hostname)}. Using ${JSON.stringify(fallbackHost)} as fallback.`);
1901
+ return fallbackHost;
1902
+ }
1903
+ return hostname;
1904
+ }
1905
+ async function getPort(_userOptions = {}) {
1906
+ if (typeof _userOptions === "number" || typeof _userOptions === "string") _userOptions = { port: Number.parseInt(_userOptions + "") || 0 };
1907
+ const _port = Number(_userOptions.port ?? process.env.PORT);
1908
+ const _userSpecifiedAnyPort = Boolean(_userOptions.port || _userOptions.ports?.length || _userOptions.portRange?.length);
1909
+ const options = {
1910
+ random: _port === 0,
1911
+ ports: [],
1912
+ portRange: [],
1913
+ alternativePortRange: _userSpecifiedAnyPort ? [] : [3e3, 3100],
1914
+ verbose: false,
1915
+ ..._userOptions,
1916
+ port: _port,
1917
+ host: _validateHostname(_userOptions.host ?? process.env.HOST, _userOptions.public, _userOptions.verbose)
1918
+ };
1919
+ if (options.random && !_userSpecifiedAnyPort) return getRandomPort(options.host);
1920
+ const portsToCheck = [
1921
+ options.port,
1922
+ ...options.ports,
1923
+ ..._generateRange(...options.portRange)
1924
+ ].filter((port) => {
1925
+ if (!port) return false;
1926
+ if (!isSafePort(port)) {
1927
+ _log(options.verbose, `Ignoring unsafe port: ${port}`);
1928
+ return false;
1929
+ }
1930
+ return true;
1931
+ });
1932
+ if (portsToCheck.length === 0) portsToCheck.push(3e3);
1933
+ let availablePort = await _findPort(portsToCheck, options.host);
1934
+ if (!availablePort && options.alternativePortRange.length > 0) {
1935
+ availablePort = await _findPort(_generateRange(...options.alternativePortRange), options.host);
1936
+ if (portsToCheck.length > 0) {
1937
+ let message = `Unable to find an available port (tried ${portsToCheck.join("-")} ${_fmtOnHost(options.host)}).`;
1938
+ if (availablePort) message += ` Using alternative port ${availablePort}.`;
1939
+ _log(options.verbose, message);
1940
+ }
1941
+ }
1942
+ if (!availablePort && _userOptions.random !== false) {
1943
+ availablePort = await getRandomPort(options.host);
1944
+ if (availablePort) _log(options.verbose, `Using random port ${availablePort}`);
1945
+ }
1946
+ if (!availablePort) {
1947
+ const triedRanges = [
1948
+ options.port,
1949
+ options.portRange.join("-"),
1950
+ options.alternativePortRange.join("-")
1951
+ ].filter(Boolean).join(", ");
1952
+ throw new GetPortError(`Unable to find an available port ${_fmtOnHost(options.host)} (tried ${triedRanges})`);
1953
+ }
1954
+ return availablePort;
1955
+ }
1956
+ async function getRandomPort(host) {
1957
+ const port = await checkPort(0, host);
1958
+ if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
1959
+ return port;
1960
+ }
1961
+ async function checkPort(port, host = process.env.HOST, verbose) {
1962
+ if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
1963
+ if (!Array.isArray(host)) return _tryPort(port, host);
1964
+ for (const _host of host) {
1965
+ const _port = await _tryPort(port, _host);
1966
+ if (_port === false) {
1967
+ if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
1968
+ return false;
1969
+ }
1970
+ if (port === 0 && _port !== 0) port = _port;
1971
+ }
1972
+ return port;
1973
+ }
1974
+ ansis_default.green("✔");
1975
+ const MARK_INFO = ansis_default.blue("ℹ");
1976
+ ansis_default.red("✖");
1977
+ //#endregion
1978
+ //#region src/node/ws.ts
1979
+ const debugInvoked = createDebug("vite:devtools:rpc:invoked");
1980
+ const ANONYMOUS_SCOPE = "vite:anonymous:";
1981
+ async function createWsServer(options) {
1982
+ const rpcHost = options.context.rpc;
1983
+ const host = options.hostWebSocket ?? "localhost";
1984
+ const https = options.context.viteConfig.server.https;
1985
+ const port = options.portWebSocket ?? await getPort({
1986
+ port: 7812,
1987
+ host,
1988
+ random: true
1989
+ });
1990
+ const wsClients = /* @__PURE__ */ new Set();
1991
+ const context = options.context;
1992
+ const contextInternal = getInternalContext(context);
1993
+ const isClientAuthDisabled = context.mode === "build" || context.viteConfig.devtools?.config?.clientAuth === false || process$1.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
1994
+ if (isClientAuthDisabled) console.warn("[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.");
1995
+ const preset = createWsRpcPreset({
1996
+ port,
1997
+ host,
1998
+ https,
1999
+ onConnected: (ws, req, meta) => {
2000
+ const authId = new URL(req.url ?? "", "http://localhost").searchParams.get("vite_devtools_auth_id") ?? void 0;
2001
+ if (isClientAuthDisabled) meta.isTrusted = true;
2002
+ else if (authId && contextInternal.storage.auth.value().trusted[authId]) {
2003
+ meta.isTrusted = true;
2004
+ meta.clientAuthId = authId;
2005
+ }
2006
+ wsClients.add(ws);
2007
+ const color = meta.isTrusted ? ansis_default.green : ansis_default.yellow;
2008
+ console.log(color`${MARK_INFO} Websocket client connected. [${meta.id}] [${meta.clientAuthId}] (${meta.isTrusted ? "trusted" : "untrusted"})`);
2009
+ },
2010
+ onDisconnected: (ws, meta) => {
2011
+ wsClients.delete(ws);
2012
+ console.log(ansis_default.red`${MARK_INFO} Websocket client disconnected. [${meta.id}]`);
2013
+ }
2014
+ });
2015
+ const asyncStorage = new AsyncLocalStorage();
2016
+ const rpcGroup = createRpcServer(rpcHost.functions, {
2017
+ preset,
2018
+ rpcOptions: {
2019
+ onFunctionError(error, name) {
2020
+ console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
2021
+ console.error(error);
2022
+ },
2023
+ onGeneralError(error) {
2024
+ console.error(ansis_default.red`⬢ RPC error on executing rpc`);
2025
+ console.error(error);
2026
+ },
2027
+ resolver(name, fn) {
2028
+ const rpc = this;
2029
+ if (!name.startsWith(ANONYMOUS_SCOPE) && !rpc.$meta.isTrusted) return () => {
2030
+ throw new Error(`Unauthorized access to method ${JSON.stringify(name)} from client [${rpc.$meta.id}]`);
2031
+ };
2032
+ if (!fn) return void 0;
2033
+ return async function(...args) {
2034
+ debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
2035
+ return await asyncStorage.run({
2036
+ rpc,
2037
+ meta: rpc.$meta
2038
+ }, async () => {
2039
+ return (await fn).apply(this, args);
2040
+ });
2041
+ };
2042
+ }
2043
+ }
2044
+ });
2045
+ rpcHost._rpcGroup = rpcGroup;
2046
+ rpcHost._asyncStorage = asyncStorage;
2047
+ const getConnectionMeta = async () => {
2048
+ return {
2049
+ backend: "websocket",
2050
+ websocket: port
2051
+ };
2052
+ };
2053
+ return {
2054
+ port,
2055
+ rpc: rpcGroup,
2056
+ rpcHost,
2057
+ getConnectionMeta
2058
+ };
2059
+ }
2060
+ //#endregion
2061
+ //#region src/node/server.ts
2062
+ async function createDevToolsMiddleware(options) {
2063
+ const h3 = createApp();
2064
+ const { rpc, getConnectionMeta } = await createWsServer(options);
2065
+ h3.use(`/${DEVTOOLS_CONNECTION_META_FILENAME}`, eventHandler(async (event) => {
2066
+ event.node.res.setHeader("Content-Type", "application/json");
2067
+ return event.node.res.end(JSON.stringify(await getConnectionMeta()));
2068
+ }));
2069
+ h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
2070
+ dev: true,
2071
+ single: true
2072
+ })));
2073
+ return {
2074
+ h3,
2075
+ rpc,
2076
+ middleware: toNodeListener(h3),
2077
+ getConnectionMeta
2078
+ };
2079
+ }
2080
+ //#endregion
2081
+ //#region src/node/plugins/server.ts
2082
+ /**
2083
+ * Core plugin for enabling Vite DevTools
2084
+ */
2085
+ function renderDockImportsMap(docks) {
2086
+ const map = /* @__PURE__ */ new Map();
2087
+ for (const dock of docks) {
2088
+ const id = `${dock.type}:${dock.id}`;
2089
+ if (dock.type === "action") map.set(id, dock.action);
2090
+ else if (dock.type === "custom-render") map.set(id, dock.renderer);
2091
+ else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
2092
+ }
2093
+ return [
2094
+ `export const importsMap = {`,
2095
+ ...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName ?? "default")}]),`),
2096
+ "}"
2097
+ ].join("\n");
2098
+ }
2099
+ function DevToolsServer() {
2100
+ let context;
2101
+ return {
2102
+ name: "vite:devtools:server",
2103
+ enforce: "post",
2104
+ apply: "serve",
2105
+ async configureServer(viteDevServer) {
2106
+ context = await createDevToolsContext(viteDevServer.config, viteDevServer);
2107
+ const host = viteDevServer.config.server.host === true ? "0.0.0.0" : viteDevServer.config.server.host || "localhost";
2108
+ const { middleware } = await createDevToolsMiddleware({
2109
+ cwd: viteDevServer.config.root,
2110
+ hostWebSocket: host,
2111
+ context
2112
+ });
2113
+ viteDevServer.middlewares.use(DEVTOOLS_MOUNT_PATH, middleware);
2114
+ },
2115
+ resolveId(id) {
2116
+ if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) return id;
2117
+ },
2118
+ load(id) {
2119
+ if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) {
2120
+ if (!context) throw new Error("DevTools context is not initialized");
2121
+ return renderDockImportsMap(context.docks.values());
2122
+ }
2123
+ }
2124
+ };
2125
+ }
2126
+ //#endregion
2127
+ //#region src/node/plugins/index.ts
2128
+ async function DevTools(options = {}) {
2129
+ const { builtinDevTools = true } = options;
2130
+ const plugins = [DevToolsInjection(), DevToolsServer()];
2131
+ if (builtinDevTools) plugins.push(await import("@vitejs/devtools-rolldown").then((m) => m.DevToolsRolldownUI()));
2132
+ return plugins;
2133
+ }
2134
+ //#endregion
2135
+ export { createDevToolsContext as a, getPort as i, renderDockImportsMap as n, ansis_default as o, createDevToolsMiddleware as r, DevTools as t };