@xiaou66/vite-plugin-vue-mcp-next 1.1.1 → 1.2.0

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.
@@ -1,105 +1,6 @@
1
1
  // src/runtime/client.ts
2
2
  import { createHotContext } from "vite-hot-client";
3
3
 
4
- // src/shared/limits.ts
5
- var DEFAULT_DOM_MAX_DEPTH = 8;
6
- var DEFAULT_DOM_MAX_NODES = 2e3;
7
- var DEFAULT_DOM_MAX_TEXT_LENGTH = 300;
8
- var DEFAULT_CONSOLE_MAX_RECORDS = 1e3;
9
- var DEFAULT_NETWORK_MAX_RECORDS = 500;
10
- var DEFAULT_NETWORK_MAX_BODY_SIZE = 1e5;
11
- var DEFAULT_MASK_HEADERS = [
12
- "authorization",
13
- "cookie",
14
- "set-cookie"
15
- ];
16
-
17
- // src/constants.ts
18
- var DEFAULT_MCP_PATH = "/__mcp";
19
- var DEFAULT_SCREENSHOT_MAX_BYTES = 5 * 1024 * 1024;
20
- var DEFAULT_SCREENSHOT_SAVE_DIR = ".vite-mcp/screenshot";
21
- var DEFAULT_PERFORMANCE_SAVE_DIR = ".vite-mcp/performance";
22
- var DEFAULT_PERFORMANCE_MAX_DURATION_MS = 3e4;
23
- var DEFAULT_PERFORMANCE_SAMPLE_INTERVAL_MS = 250;
24
- var DEFAULT_PERFORMANCE_LONG_TASK_THRESHOLD_MS = 50;
25
- var VIRTUAL_RUNTIME_ID = "virtual:vite-plugin-vue-mcp-next/runtime";
26
- var RESOLVED_VIRTUAL_RUNTIME_ID = `\0${VIRTUAL_RUNTIME_ID}`;
27
- var VIRTUAL_SCREENSHOT_CONFIG_ID = "virtual:vite-plugin-vue-mcp-next/screenshot-config";
28
- var RESOLVED_VIRTUAL_SCREENSHOT_CONFIG_ID = `\0${VIRTUAL_SCREENSHOT_CONFIG_ID}`;
29
- var VIRTUAL_SNAPDOM_LOADER_ID = "virtual:vite-plugin-vue-mcp-next/snapdom-loader";
30
- var RESOLVED_VIRTUAL_SNAPDOM_LOADER_ID = `\0${VIRTUAL_SNAPDOM_LOADER_ID}`;
31
- var DEFAULT_MCP_CLIENT_SERVER_NAME = "vite-mcp-next";
32
- var RUNTIME_PAGE_CONNECTED_EVENT = "vite-plugin-vue-mcp-next:page-connected";
33
- var RUNTIME_PAGE_DISCONNECTED_EVENT = "vite-plugin-vue-mcp-next:page-disconnected";
34
- var RUNTIME_PAGE_HEARTBEAT_EVENT = "vite-plugin-vue-mcp-next:heartbeat";
35
- var DEFAULT_RUNTIME_PAGE_HEARTBEAT_INTERVAL_MS = 15e3;
36
- var DEFAULT_OPTIONS = {
37
- mcpPath: DEFAULT_MCP_PATH,
38
- host: "localhost",
39
- printUrl: true,
40
- updateCursorMcpJson: {
41
- enabled: true,
42
- serverName: DEFAULT_MCP_CLIENT_SERVER_NAME
43
- },
44
- mcpClients: {
45
- cursor: true,
46
- codex: true,
47
- claudeCode: true,
48
- trae: true,
49
- serverName: DEFAULT_MCP_CLIENT_SERVER_NAME
50
- },
51
- skill: {
52
- autoConfig: true
53
- },
54
- runtime: {
55
- mode: "auto",
56
- evaluate: {
57
- enabled: false,
58
- timeoutMs: 3e3
59
- }
60
- },
61
- cdp: {},
62
- network: {
63
- mode: "auto",
64
- maxRecords: DEFAULT_NETWORK_MAX_RECORDS,
65
- captureRequestBody: true,
66
- captureResponseBody: true,
67
- maxBodySize: DEFAULT_NETWORK_MAX_BODY_SIZE,
68
- maskHeaders: [...DEFAULT_MASK_HEADERS]
69
- },
70
- dom: {
71
- maxDepth: DEFAULT_DOM_MAX_DEPTH,
72
- maxNodes: DEFAULT_DOM_MAX_NODES,
73
- maxTextLength: DEFAULT_DOM_MAX_TEXT_LENGTH
74
- },
75
- console: {
76
- maxRecords: DEFAULT_CONSOLE_MAX_RECORDS
77
- },
78
- screenshot: {
79
- type: "path",
80
- saveDir: DEFAULT_SCREENSHOT_SAVE_DIR,
81
- prefer: "auto",
82
- maxBytes: DEFAULT_SCREENSHOT_MAX_BYTES,
83
- snapdom: {
84
- options: {},
85
- plugins: []
86
- }
87
- },
88
- performance: {
89
- mode: "auto",
90
- maxDurationMs: DEFAULT_PERFORMANCE_MAX_DURATION_MS,
91
- sampleIntervalMs: DEFAULT_PERFORMANCE_SAMPLE_INTERVAL_MS,
92
- longTaskThresholdMs: DEFAULT_PERFORMANCE_LONG_TASK_THRESHOLD_MS,
93
- saveDir: DEFAULT_PERFORMANCE_SAVE_DIR,
94
- memory: {
95
- enabled: true
96
- },
97
- stacks: {
98
- enabled: true
99
- }
100
- }
101
- };
102
-
103
4
  // src/runtime/consoleHook.ts
104
5
  import { nanoid } from "nanoid";
105
6
 
@@ -455,6 +356,101 @@ function getRuntimePageIdentity(input) {
455
356
  // src/runtime/performanceHook.ts
456
357
  import { nanoid as nanoid4 } from "nanoid";
457
358
 
359
+ // src/shared/limits.ts
360
+ var DEFAULT_DOM_MAX_DEPTH = 8;
361
+ var DEFAULT_DOM_MAX_NODES = 2e3;
362
+ var DEFAULT_DOM_MAX_TEXT_LENGTH = 300;
363
+ var DEFAULT_CONSOLE_MAX_RECORDS = 1e3;
364
+ var DEFAULT_NETWORK_MAX_RECORDS = 500;
365
+ var DEFAULT_NETWORK_MAX_BODY_SIZE = 1e5;
366
+ var DEFAULT_MASK_HEADERS = [
367
+ "authorization",
368
+ "cookie",
369
+ "set-cookie"
370
+ ];
371
+
372
+ // src/constants.ts
373
+ var DEFAULT_MCP_PATH = "/__mcp";
374
+ var DEFAULT_SCREENSHOT_MAX_BYTES = 5 * 1024 * 1024;
375
+ var DEFAULT_SCREENSHOT_SAVE_DIR = ".vite-mcp/screenshot";
376
+ var DEFAULT_PERFORMANCE_SAVE_DIR = ".vite-mcp/performance";
377
+ var DEFAULT_PERFORMANCE_MAX_DURATION_MS = 3e4;
378
+ var DEFAULT_PERFORMANCE_SAMPLE_INTERVAL_MS = 250;
379
+ var DEFAULT_PERFORMANCE_LONG_TASK_THRESHOLD_MS = 50;
380
+ var VIRTUAL_RUNTIME_ID = "virtual:vite-plugin-vue-mcp-next/runtime";
381
+ var RESOLVED_VIRTUAL_RUNTIME_ID = `\0${VIRTUAL_RUNTIME_ID}`;
382
+ var VIRTUAL_SCREENSHOT_CONFIG_ID = "virtual:vite-plugin-vue-mcp-next/screenshot-config";
383
+ var RESOLVED_VIRTUAL_SCREENSHOT_CONFIG_ID = `\0${VIRTUAL_SCREENSHOT_CONFIG_ID}`;
384
+ var VIRTUAL_SNAPDOM_LOADER_ID = "virtual:vite-plugin-vue-mcp-next/snapdom-loader";
385
+ var RESOLVED_VIRTUAL_SNAPDOM_LOADER_ID = `\0${VIRTUAL_SNAPDOM_LOADER_ID}`;
386
+ var DEFAULT_MCP_CLIENT_SERVER_NAME = "vite-mcp-next";
387
+ var DEFAULT_OPTIONS = {
388
+ mcpPath: DEFAULT_MCP_PATH,
389
+ host: "localhost",
390
+ printUrl: true,
391
+ updateCursorMcpJson: {
392
+ enabled: true,
393
+ serverName: DEFAULT_MCP_CLIENT_SERVER_NAME
394
+ },
395
+ mcpClients: {
396
+ cursor: true,
397
+ codex: true,
398
+ claudeCode: true,
399
+ trae: true,
400
+ serverName: DEFAULT_MCP_CLIENT_SERVER_NAME
401
+ },
402
+ skill: {
403
+ autoConfig: true
404
+ },
405
+ runtime: {
406
+ mode: "auto",
407
+ evaluate: {
408
+ enabled: false,
409
+ timeoutMs: 3e3
410
+ }
411
+ },
412
+ cdp: {},
413
+ network: {
414
+ mode: "auto",
415
+ maxRecords: DEFAULT_NETWORK_MAX_RECORDS,
416
+ captureRequestBody: true,
417
+ captureResponseBody: true,
418
+ maxBodySize: DEFAULT_NETWORK_MAX_BODY_SIZE,
419
+ maskHeaders: [...DEFAULT_MASK_HEADERS]
420
+ },
421
+ dom: {
422
+ maxDepth: DEFAULT_DOM_MAX_DEPTH,
423
+ maxNodes: DEFAULT_DOM_MAX_NODES,
424
+ maxTextLength: DEFAULT_DOM_MAX_TEXT_LENGTH
425
+ },
426
+ console: {
427
+ maxRecords: DEFAULT_CONSOLE_MAX_RECORDS
428
+ },
429
+ screenshot: {
430
+ type: "path",
431
+ saveDir: DEFAULT_SCREENSHOT_SAVE_DIR,
432
+ prefer: "auto",
433
+ maxBytes: DEFAULT_SCREENSHOT_MAX_BYTES,
434
+ snapdom: {
435
+ options: {},
436
+ plugins: []
437
+ }
438
+ },
439
+ performance: {
440
+ mode: "auto",
441
+ maxDurationMs: DEFAULT_PERFORMANCE_MAX_DURATION_MS,
442
+ sampleIntervalMs: DEFAULT_PERFORMANCE_SAMPLE_INTERVAL_MS,
443
+ longTaskThresholdMs: DEFAULT_PERFORMANCE_LONG_TASK_THRESHOLD_MS,
444
+ saveDir: DEFAULT_PERFORMANCE_SAVE_DIR,
445
+ memory: {
446
+ enabled: true
447
+ },
448
+ stacks: {
449
+ enabled: true
450
+ }
451
+ }
452
+ };
453
+
458
454
  // src/performance/summary.ts
459
455
  function buildPerformanceSummary(input) {
460
456
  const memory = buildMemorySummary(input.memorySamples);
@@ -1096,6 +1092,390 @@ function createTimeout(timeoutMs) {
1096
1092
  });
1097
1093
  }
1098
1094
 
1095
+ // src/runtime/storageBridge.ts
1096
+ function createRuntimeStorageBridge(env) {
1097
+ return {
1098
+ async manageStorage(request) {
1099
+ try {
1100
+ return await manageRuntimeStorage(env, request);
1101
+ } catch (error) {
1102
+ return createRuntimeStorageError(
1103
+ request,
1104
+ error instanceof Error ? error.message : String(error)
1105
+ );
1106
+ }
1107
+ }
1108
+ };
1109
+ }
1110
+ async function manageRuntimeStorage(env, request) {
1111
+ if (request.origin !== env.origin) {
1112
+ return createRuntimeStorageError(
1113
+ request,
1114
+ "Runtime storage access is limited to the current page origin"
1115
+ );
1116
+ }
1117
+ if (request.scope === "cookie") {
1118
+ return manageRuntimeCookie(env, request);
1119
+ }
1120
+ if (request.scope === "indexedDB") {
1121
+ return manageRuntimeIndexedDb(env, request);
1122
+ }
1123
+ return manageRuntimeWebStorage(getWebStorage(env, request.scope), request);
1124
+ }
1125
+ function manageRuntimeCookie(env, request) {
1126
+ if (!env.cookie) {
1127
+ return createRuntimeStorageError(
1128
+ request,
1129
+ "Runtime cookie access is unavailable",
1130
+ ["document.cookie is not available in this runtime environment"]
1131
+ );
1132
+ }
1133
+ if (request.action === "list") {
1134
+ return createRuntimeStorageSuccess(request, {
1135
+ origin: request.origin,
1136
+ cookies: readRuntimeCookies(env.cookie)
1137
+ });
1138
+ }
1139
+ if (request.action === "get") {
1140
+ assertCookieName(request);
1141
+ return createRuntimeStorageSuccess(request, {
1142
+ origin: request.origin,
1143
+ cookies: readRuntimeCookies(env.cookie).filter(
1144
+ (cookie) => cookie.name === request.cookie.name
1145
+ )
1146
+ });
1147
+ }
1148
+ if (request.action === "set") {
1149
+ assertCookieName(request);
1150
+ env.cookie.set(createRuntimeCookieWrite(request));
1151
+ return createRuntimeStorageSuccess(request, { ok: true });
1152
+ }
1153
+ if (request.action === "delete") {
1154
+ assertCookieName(request);
1155
+ env.cookie.set(createRuntimeCookieDelete(request));
1156
+ return createRuntimeStorageSuccess(request, {
1157
+ deletedCount: 1,
1158
+ skippedHttpOnlyCount: 0,
1159
+ limitations: ["HttpOnly cookies are invisible to runtime cookie access"]
1160
+ });
1161
+ }
1162
+ const cookies = readRuntimeCookies(env.cookie);
1163
+ for (const cookie of cookies) {
1164
+ env.cookie.set(
1165
+ createRuntimeCookieDelete({
1166
+ ...request,
1167
+ cookie: {
1168
+ name: cookie.name,
1169
+ path: request.cookie?.path
1170
+ }
1171
+ })
1172
+ );
1173
+ }
1174
+ return createRuntimeStorageSuccess(request, {
1175
+ deletedCount: cookies.length,
1176
+ skippedHttpOnlyCount: 0,
1177
+ limitations: ["HttpOnly cookies are invisible to runtime cookie access"]
1178
+ });
1179
+ }
1180
+ function getWebStorage(env, scope) {
1181
+ return scope === "sessionStorage" ? env.sessionStorage : env.localStorage;
1182
+ }
1183
+ function manageRuntimeWebStorage(storage, request) {
1184
+ if (request.action === "list") {
1185
+ return createRuntimeStorageSuccess(request, {
1186
+ origin: request.origin,
1187
+ scope: request.scope,
1188
+ entries: readStorageEntries(storage)
1189
+ });
1190
+ }
1191
+ if (request.action === "get") {
1192
+ assertStorageKey(request);
1193
+ return createRuntimeStorageSuccess(request, {
1194
+ origin: request.origin,
1195
+ scope: request.scope,
1196
+ key: request.key,
1197
+ value: storage.getItem(request.key)
1198
+ });
1199
+ }
1200
+ if (request.action === "set") {
1201
+ assertStorageKey(request);
1202
+ storage.setItem(request.key, request.value ?? "");
1203
+ return createRuntimeStorageSuccess(request, { ok: true });
1204
+ }
1205
+ if (request.action === "delete") {
1206
+ assertStorageKey(request);
1207
+ storage.removeItem(request.key);
1208
+ return createRuntimeStorageSuccess(request, { ok: true });
1209
+ }
1210
+ storage.clear();
1211
+ return createRuntimeStorageSuccess(request, { ok: true });
1212
+ }
1213
+ async function manageRuntimeIndexedDb(env, request) {
1214
+ if (!env.indexedDB?.databases) {
1215
+ return createRuntimeStorageError(request, "IndexedDB metadata API is unavailable");
1216
+ }
1217
+ if (request.action === "list") {
1218
+ const databases = await env.indexedDB.databases();
1219
+ return createRuntimeStorageSuccess(request, {
1220
+ origin: request.origin,
1221
+ scope: request.scope,
1222
+ databases: databases.map((database) => ({
1223
+ name: database.name,
1224
+ version: database.version
1225
+ }))
1226
+ });
1227
+ }
1228
+ assertIndexedDbTarget(request);
1229
+ if ("stores" in env.indexedDB) {
1230
+ return manageMemoryIndexedDb(env.indexedDB, request);
1231
+ }
1232
+ return manageBrowserIndexedDb(env.indexedDB, request);
1233
+ }
1234
+ function manageMemoryIndexedDb(indexedDB, request) {
1235
+ const storeId = `${request.databaseName}:${request.objectStoreName}`;
1236
+ const store = indexedDB.stores.get(storeId) ?? /* @__PURE__ */ new Map();
1237
+ indexedDB.stores.set(storeId, store);
1238
+ if (request.action === "get") {
1239
+ assertStorageKey(request);
1240
+ return createRuntimeStorageSuccess(request, {
1241
+ key: request.key,
1242
+ value: store.get(request.key) ?? null
1243
+ });
1244
+ }
1245
+ if (request.action === "set") {
1246
+ assertStorageKey(request);
1247
+ store.set(request.key, parseIndexedDbValue(request.value));
1248
+ return createRuntimeStorageSuccess(request, { ok: true });
1249
+ }
1250
+ if (request.action === "delete") {
1251
+ assertStorageKey(request);
1252
+ store.delete(request.key);
1253
+ return createRuntimeStorageSuccess(request, { ok: true });
1254
+ }
1255
+ store.clear();
1256
+ return createRuntimeStorageSuccess(request, { ok: true });
1257
+ }
1258
+ async function manageBrowserIndexedDb(indexedDB, request) {
1259
+ const database = await openIndexedDbForRequest(indexedDB, request);
1260
+ try {
1261
+ return await executeIndexedDbTransaction(database, request);
1262
+ } finally {
1263
+ database.close();
1264
+ }
1265
+ }
1266
+ function openIndexedDb(indexedDB, databaseName) {
1267
+ return new Promise((resolve, reject) => {
1268
+ const request = indexedDB.open(databaseName);
1269
+ request.onerror = () => {
1270
+ reject(request.error ?? new Error("IndexedDB open failed"));
1271
+ };
1272
+ request.onsuccess = () => {
1273
+ resolve(request.result);
1274
+ };
1275
+ });
1276
+ }
1277
+ async function openIndexedDbForRequest(indexedDB, request) {
1278
+ const database = await openIndexedDb(indexedDB, request.databaseName);
1279
+ if (request.action !== "set" || database.objectStoreNames.contains(request.objectStoreName)) {
1280
+ return database;
1281
+ }
1282
+ const version = database.version + 1;
1283
+ database.close();
1284
+ return openIndexedDbWithStore(indexedDB, {
1285
+ databaseName: request.databaseName,
1286
+ objectStoreName: request.objectStoreName,
1287
+ version
1288
+ });
1289
+ }
1290
+ function openIndexedDbWithStore(indexedDB, options) {
1291
+ return new Promise((resolve, reject) => {
1292
+ const request = indexedDB.open(options.databaseName, options.version);
1293
+ request.onupgradeneeded = () => {
1294
+ const database = request.result;
1295
+ if (!database.objectStoreNames.contains(options.objectStoreName)) {
1296
+ database.createObjectStore(options.objectStoreName);
1297
+ }
1298
+ };
1299
+ request.onerror = () => {
1300
+ reject(request.error ?? new Error("IndexedDB upgrade failed"));
1301
+ };
1302
+ request.onsuccess = () => {
1303
+ resolve(request.result);
1304
+ };
1305
+ });
1306
+ }
1307
+ function executeIndexedDbTransaction(database, request) {
1308
+ return new Promise((resolve, reject) => {
1309
+ const mode = request.action === "get" ? "readonly" : "readwrite";
1310
+ const transaction = database.transaction(request.objectStoreName, mode);
1311
+ const store = transaction.objectStore(request.objectStoreName);
1312
+ transaction.onerror = () => {
1313
+ reject(transaction.error ?? new Error("IndexedDB transaction failed"));
1314
+ };
1315
+ if (request.action === "get") {
1316
+ assertStorageKey(request);
1317
+ const getRequest = store.get(request.key);
1318
+ getRequest.onerror = () => {
1319
+ reject(getRequest.error ?? new Error("IndexedDB get failed"));
1320
+ };
1321
+ getRequest.onsuccess = () => {
1322
+ const value = getRequest.result ?? null;
1323
+ resolve(
1324
+ createRuntimeStorageSuccess(request, {
1325
+ key: request.key,
1326
+ value
1327
+ })
1328
+ );
1329
+ };
1330
+ return;
1331
+ }
1332
+ if (request.action === "set") {
1333
+ assertStorageKey(request);
1334
+ store.put(parseIndexedDbValue(request.value), request.key);
1335
+ transaction.oncomplete = () => {
1336
+ resolve(createRuntimeStorageSuccess(request, { ok: true }));
1337
+ };
1338
+ return;
1339
+ }
1340
+ if (request.action === "delete") {
1341
+ assertStorageKey(request);
1342
+ store.delete(request.key);
1343
+ transaction.oncomplete = () => {
1344
+ resolve(createRuntimeStorageSuccess(request, { ok: true }));
1345
+ };
1346
+ return;
1347
+ }
1348
+ store.clear();
1349
+ transaction.oncomplete = () => {
1350
+ resolve(createRuntimeStorageSuccess(request, { ok: true }));
1351
+ };
1352
+ });
1353
+ }
1354
+ function readStorageEntries(storage) {
1355
+ const entries = [];
1356
+ for (let index = 0; index < storage.length; index += 1) {
1357
+ const key = storage.key(index);
1358
+ if (!key) {
1359
+ continue;
1360
+ }
1361
+ const value = storage.getItem(key);
1362
+ if (value === null) {
1363
+ continue;
1364
+ }
1365
+ entries.push({ key, value });
1366
+ }
1367
+ return entries;
1368
+ }
1369
+ function readRuntimeCookies(cookieAccess) {
1370
+ return cookieAccess.get().split(";").map((item) => item.trim()).filter(Boolean).map((item) => {
1371
+ const separatorIndex = item.indexOf("=");
1372
+ if (separatorIndex === -1) {
1373
+ return { name: decodeCookiePart(item), value: "" };
1374
+ }
1375
+ return {
1376
+ name: decodeCookiePart(item.slice(0, separatorIndex)),
1377
+ value: decodeCookiePart(item.slice(separatorIndex + 1))
1378
+ };
1379
+ });
1380
+ }
1381
+ function createRuntimeCookieWrite(request) {
1382
+ const value = request.cookie.value ?? request.value ?? "";
1383
+ const parts = [
1384
+ `${encodeURIComponent(request.cookie.name)}=${encodeURIComponent(value)}`
1385
+ ];
1386
+ appendRuntimeCookieAttributes(parts, request.cookie);
1387
+ return parts.join("; ");
1388
+ }
1389
+ function createRuntimeCookieDelete(request) {
1390
+ const parts = [
1391
+ `${encodeURIComponent(request.cookie.name)}=`,
1392
+ "Expires=Thu, 01 Jan 1970 00:00:00 GMT",
1393
+ "Max-Age=0"
1394
+ ];
1395
+ appendRuntimeCookieAttributes(parts, {
1396
+ path: request.cookie.path,
1397
+ domain: request.cookie.domain
1398
+ });
1399
+ return parts.join("; ");
1400
+ }
1401
+ function appendRuntimeCookieAttributes(parts, cookie) {
1402
+ if (cookie.path) {
1403
+ parts.push(`Path=${cookie.path}`);
1404
+ }
1405
+ if (cookie.domain) {
1406
+ parts.push(`Domain=${cookie.domain}`);
1407
+ }
1408
+ if (cookie.expires !== void 0) {
1409
+ parts.push(`Expires=${new Date(cookie.expires * 1e3).toUTCString()}`);
1410
+ }
1411
+ if (cookie.sameSite) {
1412
+ parts.push(`SameSite=${normalizeRuntimeSameSite(cookie.sameSite)}`);
1413
+ }
1414
+ if (cookie.secure) {
1415
+ parts.push("Secure");
1416
+ }
1417
+ }
1418
+ function normalizeRuntimeSameSite(sameSite) {
1419
+ if (sameSite === "strict") {
1420
+ return "Strict";
1421
+ }
1422
+ if (sameSite === "lax") {
1423
+ return "Lax";
1424
+ }
1425
+ return "None";
1426
+ }
1427
+ function decodeCookiePart(value) {
1428
+ try {
1429
+ return decodeURIComponent(value);
1430
+ } catch {
1431
+ return value;
1432
+ }
1433
+ }
1434
+ function assertStorageKey(request) {
1435
+ if (!request.key) {
1436
+ throw new Error("Storage key is required for this operation");
1437
+ }
1438
+ }
1439
+ function assertCookieName(request) {
1440
+ if (!request.cookie?.name) {
1441
+ throw new Error("Cookie name is required for this operation");
1442
+ }
1443
+ }
1444
+ function assertIndexedDbTarget(request) {
1445
+ if (!request.databaseName || !request.objectStoreName) {
1446
+ throw new Error("IndexedDB databaseName and objectStoreName are required");
1447
+ }
1448
+ }
1449
+ function parseIndexedDbValue(value) {
1450
+ if (value === void 0) {
1451
+ return null;
1452
+ }
1453
+ try {
1454
+ return JSON.parse(value);
1455
+ } catch {
1456
+ return value;
1457
+ }
1458
+ }
1459
+ function createRuntimeStorageSuccess(request, data) {
1460
+ return {
1461
+ ok: true,
1462
+ source: "hook",
1463
+ action: request.action,
1464
+ scope: request.scope,
1465
+ data
1466
+ };
1467
+ }
1468
+ function createRuntimeStorageError(request, error, limitations) {
1469
+ return {
1470
+ ok: false,
1471
+ source: "hook",
1472
+ action: request.action,
1473
+ scope: request.scope,
1474
+ error,
1475
+ limitations
1476
+ };
1477
+ }
1478
+
1099
1479
  // src/runtime/devtoolsBridge.ts
1100
1480
  function createRuntimeDevtoolsRpc(getRpc) {
1101
1481
  return {
@@ -1151,7 +1531,26 @@ function createRuntimeDevtoolsRpc(getRpc) {
1151
1531
  });
1152
1532
  }
1153
1533
  },
1154
- onScreenshotTaken: () => void 0
1534
+ onScreenshotTaken: () => void 0,
1535
+ async manageStorage(options) {
1536
+ const bridge = createRuntimeStorageBridge({
1537
+ origin: window.location.origin,
1538
+ localStorage: window.localStorage,
1539
+ sessionStorage: window.sessionStorage,
1540
+ indexedDB: window.indexedDB,
1541
+ cookie: {
1542
+ get: () => window.document.cookie,
1543
+ set: (value) => {
1544
+ window.document.cookie = value;
1545
+ }
1546
+ }
1547
+ });
1548
+ getRpc().onStorageUpdated(
1549
+ options.event,
1550
+ await bridge.manageStorage(options)
1551
+ );
1552
+ },
1553
+ onStorageUpdated: () => void 0
1155
1554
  };
1156
1555
  }
1157
1556
 
@@ -1449,11 +1848,7 @@ async function startRuntimeClient() {
1449
1848
  innerHeight: window.innerHeight,
1450
1849
  readyState: document.readyState
1451
1850
  });
1452
- hot.send(RUNTIME_PAGE_CONNECTED_EVENT, identity);
1453
- installRuntimePageLifecycle({
1454
- pageId: identity.pageId,
1455
- send: hot.send.bind(hot)
1456
- });
1851
+ hot.send("vite-plugin-vue-mcp-next:page-connected", identity);
1457
1852
  installPerformanceHook({
1458
1853
  pageId: identity.pageId,
1459
1854
  send(report) {
@@ -1475,27 +1870,6 @@ async function startRuntimeClient() {
1475
1870
  }
1476
1871
  });
1477
1872
  }
1478
- function installRuntimePageLifecycle(options) {
1479
- let disconnected = false;
1480
- const heartbeatTimer = setInterval(() => {
1481
- options.send(RUNTIME_PAGE_HEARTBEAT_EVENT, {
1482
- pageId: options.pageId,
1483
- timestamp: Date.now()
1484
- });
1485
- }, DEFAULT_RUNTIME_PAGE_HEARTBEAT_INTERVAL_MS);
1486
- const disconnect = () => {
1487
- if (disconnected) {
1488
- return;
1489
- }
1490
- disconnected = true;
1491
- clearInterval(heartbeatTimer);
1492
- options.send(RUNTIME_PAGE_DISCONNECTED_EVENT, {
1493
- pageId: options.pageId
1494
- });
1495
- };
1496
- window.addEventListener("pagehide", disconnect, { once: true });
1497
- window.addEventListener("beforeunload", disconnect, { once: true });
1498
- }
1499
1873
  export {
1500
1874
  evaluateExpression,
1501
1875
  setScreenshotModuleRegistry,