@vitejs/devtools-kit 0.0.0-alpha.25 → 0.0.0-alpha.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.mts CHANGED
@@ -1,3 +1,2 @@
1
- import { a as DockEntryState, c as DocksContext, d as RpcClientEvents, f as DevToolsRpcClient, i as DockClientType, l as DocksEntriesContext, m as getDevToolsRpcClient, n as DevToolsClientContext, o as DockEntryStateEvents, p as DevToolsRpcClientOptions, r as DevToolsClientRpcHost, s as DockPanelStorage, t as DockClientScriptContext, u as DocksPanelContext } from "./index-DKkzr1AR.mjs";
2
- import "./shared-state-7JDpUVVs.mjs";
1
+ import { a as DockEntryState, c as DocksContext, d as RpcClientEvents, f as DevToolsRpcClient, i as DockClientType, l as DocksEntriesContext, m as getDevToolsRpcClient, n as DevToolsClientContext, o as DockEntryStateEvents, p as DevToolsRpcClientOptions, r as DevToolsClientRpcHost, s as DockPanelStorage, t as DockClientScriptContext, u as DocksPanelContext } from "./client-script-BOHKZVPh.mjs";
3
2
  export { DevToolsClientContext, DevToolsClientRpcHost, DevToolsRpcClient, DevToolsRpcClientOptions, DockClientScriptContext, DockClientType, DockEntryState, DockEntryStateEvents, DockPanelStorage, DocksContext, DocksEntriesContext, DocksPanelContext, RpcClientEvents, getDevToolsRpcClient };
package/dist/client.mjs CHANGED
@@ -1,24 +1,24 @@
1
- import { t as createEventEmitter } from "./events-CWYZG96x.mjs";
2
- import { t as nanoid } from "./nanoid-B0pJU5uW.mjs";
3
- import { t as createSharedState } from "./shared-state-BAC6HwFS.mjs";
4
- import { RpcFunctionsCollectorBase } from "birpc-x";
5
- import { createRpcClient } from "@vitejs/devtools-rpc";
1
+ import { createEventEmitter } from "./utils/events.mjs";
2
+ import { nanoid } from "./utils/nanoid.mjs";
3
+ import { createSharedState } from "./utils/shared-state.mjs";
4
+ import { RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
5
+ import { createRpcClient } from "@vitejs/devtools-rpc/client";
6
6
  import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/client";
7
7
 
8
- //#region rolldown:runtime
8
+ //#region \0rolldown/runtime.js
9
9
  var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
10
 
11
11
  //#endregion
12
12
  //#region ../../node_modules/.pnpm/my-ua-parser@2.0.4/node_modules/my-ua-parser/ua-parser.js
13
13
  var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14
- (function(window$1, undefined$1) {
14
+ (function(window, undefined) {
15
15
  "use strict";
16
16
  var EMPTY = "", UNKNOWN = "?", FUNC_TYPE = "function", UNDEF_TYPE = "undefined", OBJ_TYPE = "object", STR_TYPE = "string", MAJOR = "major", MODEL = "model", NAME = "name", TYPE = "type", VENDOR = "vendor", VERSION = "version", ARCHITECTURE = "architecture", CONSOLE = "console", MOBILE = "mobile", TABLET = "tablet", SMARTTV = "smarttv", WEARABLE = "wearable", EMBEDDED = "embedded", UA_MAX_LENGTH = 500;
17
17
  var AMAZON = "Amazon", APPLE = "Apple", ASUS = "ASUS", BLACKBERRY = "BlackBerry", BROWSER = "Browser", CHROME = "Chrome", EDGE = "Edge", FIREFOX = "Firefox", GOOGLE = "Google", HUAWEI = "Huawei", LG = "LG", MICROSOFT = "Microsoft", MOTOROLA = "Motorola", OPERA = "Opera", SAMSUNG = "Samsung", SHARP = "Sharp", SONY = "Sony", XIAOMI = "Xiaomi", ZEBRA = "Zebra", FACEBOOK = "Facebook", CHROMIUM_OS = "Chromium OS", MAC_OS = "Mac OS";
18
- var extend = function(regexes$1, extensions) {
18
+ var extend = function(regexes, extensions) {
19
19
  var mergedRegexes = {};
20
- for (var i in regexes$1) if (extensions[i] && extensions[i].length % 2 === 0) mergedRegexes[i] = extensions[i].concat(regexes$1[i]);
21
- else mergedRegexes[i] = regexes$1[i];
20
+ for (var i in regexes) if (extensions[i] && extensions[i].length % 2 === 0) mergedRegexes[i] = extensions[i].concat(regexes[i]);
21
+ else mergedRegexes[i] = regexes[i];
22
22
  return mergedRegexes;
23
23
  }, enumerize = function(arr) {
24
24
  var enums = {};
@@ -29,7 +29,7 @@ var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29
29
  }, lowerize = function(str) {
30
30
  return str.toLowerCase();
31
31
  }, majorize = function(version) {
32
- return typeof version === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split(".")[0] : undefined$1;
32
+ return typeof version === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split(".")[0] : undefined;
33
33
  }, trim = function(str, len) {
34
34
  if (typeof str === STR_TYPE) {
35
35
  str = str.replace(/^\s\s*/, EMPTY);
@@ -50,18 +50,18 @@ var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
50
50
  if (typeof q === OBJ_TYPE && q.length > 0) {
51
51
  if (q.length === 2) if (typeof q[1] == FUNC_TYPE) this[q[0]] = q[1].call(this, match);
52
52
  else this[q[0]] = q[1];
53
- else if (q.length === 3) if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined$1;
54
- else this[q[0]] = match ? match.replace(q[1], q[2]) : undefined$1;
55
- else if (q.length === 4) this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined$1;
56
- } else this[q] = match ? match : undefined$1;
53
+ else if (q.length === 3) if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
54
+ else this[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
55
+ else if (q.length === 4) this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
56
+ } else this[q] = match ? match : undefined;
57
57
  }
58
58
  }
59
59
  i += 2;
60
60
  }
61
61
  }, strMapper = function(str, map) {
62
62
  for (var i in map) if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
63
- for (var j = 0; j < map[i].length; j++) if (has(map[i][j], str)) return i === UNKNOWN ? undefined$1 : i;
64
- } else if (has(map[i], str)) return i === UNKNOWN ? undefined$1 : i;
63
+ for (var j = 0; j < map[i].length; j++) if (has(map[i][j], str)) return i === UNKNOWN ? undefined : i;
64
+ } else if (has(map[i], str)) return i === UNKNOWN ? undefined : i;
65
65
  return str;
66
66
  };
67
67
  var oldSafariMap = {
@@ -973,21 +973,21 @@ var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
973
973
  [NAME, VERSION]
974
974
  ]
975
975
  };
976
- var UAParser$1 = function(ua, extensions) {
976
+ var UAParser = function(ua, extensions) {
977
977
  if (typeof ua === OBJ_TYPE) {
978
978
  extensions = ua;
979
- ua = undefined$1;
979
+ ua = undefined;
980
980
  }
981
- if (!(this instanceof UAParser$1)) return new UAParser$1(ua, extensions).getResult();
982
- var _navigator = typeof window$1 !== UNDEF_TYPE && window$1.navigator ? window$1.navigator : undefined$1;
981
+ if (!(this instanceof UAParser)) return new UAParser(ua, extensions).getResult();
982
+ var _navigator = typeof window !== UNDEF_TYPE && window.navigator ? window.navigator : undefined;
983
983
  var _ua = ua || (_navigator && _navigator.userAgent ? _navigator.userAgent : EMPTY);
984
- var _uach = _navigator && _navigator.userAgentData ? _navigator.userAgentData : undefined$1;
984
+ var _uach = _navigator && _navigator.userAgentData ? _navigator.userAgentData : undefined;
985
985
  var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
986
986
  var _isSelfNav = _navigator && _navigator.userAgent == _ua;
987
987
  this.getBrowser = function() {
988
988
  var _browser = {};
989
- _browser[NAME] = undefined$1;
990
- _browser[VERSION] = undefined$1;
989
+ _browser[NAME] = undefined;
990
+ _browser[VERSION] = undefined;
991
991
  rgxMapper.call(_browser, _ua, _rgxmap.browser);
992
992
  _browser[MAJOR] = majorize(_browser[VERSION]);
993
993
  if (_isSelfNav && _navigator && _navigator.brave && typeof _navigator.brave.isBrave == FUNC_TYPE) _browser[NAME] = "Brave";
@@ -995,15 +995,15 @@ var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
995
995
  };
996
996
  this.getCPU = function() {
997
997
  var _cpu = {};
998
- _cpu[ARCHITECTURE] = undefined$1;
998
+ _cpu[ARCHITECTURE] = undefined;
999
999
  rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
1000
1000
  return _cpu;
1001
1001
  };
1002
1002
  this.getDevice = function() {
1003
1003
  var _device = {};
1004
- _device[VENDOR] = undefined$1;
1005
- _device[MODEL] = undefined$1;
1006
- _device[TYPE] = undefined$1;
1004
+ _device[VENDOR] = undefined;
1005
+ _device[MODEL] = undefined;
1006
+ _device[TYPE] = undefined;
1007
1007
  rgxMapper.call(_device, _ua, _rgxmap.device);
1008
1008
  if (_isSelfNav && !_device[TYPE] && _uach && _uach.mobile) _device[TYPE] = MOBILE;
1009
1009
  if (_isSelfNav && _device[MODEL] == "Macintosh" && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
@@ -1014,15 +1014,15 @@ var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1014
1014
  };
1015
1015
  this.getEngine = function() {
1016
1016
  var _engine = {};
1017
- _engine[NAME] = undefined$1;
1018
- _engine[VERSION] = undefined$1;
1017
+ _engine[NAME] = undefined;
1018
+ _engine[VERSION] = undefined;
1019
1019
  rgxMapper.call(_engine, _ua, _rgxmap.engine);
1020
1020
  return _engine;
1021
1021
  };
1022
1022
  this.getOS = function() {
1023
1023
  var _os = {};
1024
- _os[NAME] = undefined$1;
1025
- _os[VERSION] = undefined$1;
1024
+ _os[NAME] = undefined;
1025
+ _os[VERSION] = undefined;
1026
1026
  rgxMapper.call(_os, _ua, _rgxmap.os);
1027
1027
  if (_isSelfNav && !_os[NAME] && _uach && _uach.platform && _uach.platform != "Unknown") _os[NAME] = _uach.platform.replace(/chrome os/i, CHROMIUM_OS).replace(/macos/i, MAC_OS);
1028
1028
  return _os;
@@ -1040,20 +1040,20 @@ var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1040
1040
  this.getUA = function() {
1041
1041
  return _ua;
1042
1042
  };
1043
- this.setUA = function(ua$1) {
1044
- _ua = typeof ua$1 === STR_TYPE && ua$1.length > UA_MAX_LENGTH ? trim(ua$1, UA_MAX_LENGTH) : ua$1;
1043
+ this.setUA = function(ua) {
1044
+ _ua = typeof ua === STR_TYPE && ua.length > UA_MAX_LENGTH ? trim(ua, UA_MAX_LENGTH) : ua;
1045
1045
  return this;
1046
1046
  };
1047
1047
  this.setUA(_ua);
1048
1048
  return this;
1049
1049
  };
1050
- UAParser$1.BROWSER = enumerize([
1050
+ UAParser.BROWSER = enumerize([
1051
1051
  NAME,
1052
1052
  VERSION,
1053
1053
  MAJOR
1054
1054
  ]);
1055
- UAParser$1.CPU = enumerize([ARCHITECTURE]);
1056
- UAParser$1.DEVICE = enumerize([
1055
+ UAParser.CPU = enumerize([ARCHITECTURE]);
1056
+ UAParser.DEVICE = enumerize([
1057
1057
  MODEL,
1058
1058
  VENDOR,
1059
1059
  TYPE,
@@ -1064,17 +1064,17 @@ var require_ua_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1064
1064
  WEARABLE,
1065
1065
  EMBEDDED
1066
1066
  ]);
1067
- UAParser$1.ENGINE = UAParser$1.OS = enumerize([NAME, VERSION]);
1067
+ UAParser.ENGINE = UAParser.OS = enumerize([NAME, VERSION]);
1068
1068
  if (typeof exports !== UNDEF_TYPE) {
1069
- if (typeof module !== UNDEF_TYPE && module.exports) exports = module.exports = UAParser$1;
1070
- exports.UAParser = UAParser$1;
1069
+ if (typeof module !== UNDEF_TYPE && module.exports) exports = module.exports = UAParser;
1070
+ exports.UAParser = UAParser;
1071
1071
  } else if (typeof define === FUNC_TYPE && define.amd) define(function() {
1072
- return UAParser$1;
1072
+ return UAParser;
1073
1073
  });
1074
- else if (typeof window$1 !== UNDEF_TYPE) window$1.UAParser = UAParser$1;
1075
- var $ = typeof window$1 !== UNDEF_TYPE && (window$1.jQuery || window$1.Zepto);
1074
+ else if (typeof window !== UNDEF_TYPE) window.UAParser = UAParser;
1075
+ var $ = typeof window !== UNDEF_TYPE && (window.jQuery || window.Zepto);
1076
1076
  if ($ && !$.ua) {
1077
- var parser = new UAParser$1();
1077
+ var parser = new UAParser();
1078
1078
  $.ua = parser.getResult();
1079
1079
  $.ua.get = function() {
1080
1080
  return parser.getUA();
@@ -1109,7 +1109,7 @@ function promiseWithResolver() {
1109
1109
  function createRpcSharedStateClientHost(rpc) {
1110
1110
  const sharedState = /* @__PURE__ */ new Map();
1111
1111
  rpc.client.register({
1112
- name: "vite:internal:rpc:client-state:updated",
1112
+ name: "devtoolskit:internal:rpc:client-state:updated",
1113
1113
  type: "event",
1114
1114
  handler: (key, fullState, syncId) => {
1115
1115
  const state = sharedState.get(key);
@@ -1118,7 +1118,7 @@ function createRpcSharedStateClientHost(rpc) {
1118
1118
  }
1119
1119
  });
1120
1120
  rpc.client.register({
1121
- name: "vite:internal:rpc:client-state:patch",
1121
+ name: "devtoolskit:internal:rpc:client-state:patch",
1122
1122
  type: "event",
1123
1123
  handler: (key, patches, syncId) => {
1124
1124
  const state = sharedState.get(key);
@@ -1129,8 +1129,8 @@ function createRpcSharedStateClientHost(rpc) {
1129
1129
  function registerSharedState(key, state) {
1130
1130
  const offs = [];
1131
1131
  offs.push(state.on("updated", (fullState, patches, syncId) => {
1132
- if (patches) rpc.callEvent("vite:internal:rpc:server-state:patch", key, patches, syncId);
1133
- else rpc.callEvent("vite:internal:rpc:server-state:set", key, fullState, syncId);
1132
+ if (patches) rpc.callEvent("devtoolskit:internal:rpc:server-state:patch", key, patches, syncId);
1133
+ else rpc.callEvent("devtoolskit:internal:rpc:server-state:set", key, fullState, syncId);
1134
1134
  }));
1135
1135
  return () => {
1136
1136
  for (const off of offs) off();
@@ -1143,10 +1143,10 @@ function createRpcSharedStateClientHost(rpc) {
1143
1143
  enablePatches: false
1144
1144
  });
1145
1145
  async function initSharedState() {
1146
- rpc.callEvent("vite:internal:rpc:server-state:subscribe", key);
1146
+ rpc.callEvent("devtoolskit:internal:rpc:server-state:subscribe", key);
1147
1147
  if (options?.initialValue !== void 0) {
1148
1148
  sharedState.set(key, state);
1149
- rpc.call("vite:internal:rpc:server-state:get", key).then((serverState) => {
1149
+ rpc.call("devtoolskit:internal:rpc:server-state:get", key).then((serverState) => {
1150
1150
  state.mutate(() => serverState);
1151
1151
  }).catch((error) => {
1152
1152
  console.error("Error getting server state", error);
@@ -1154,7 +1154,7 @@ function createRpcSharedStateClientHost(rpc) {
1154
1154
  registerSharedState(key, state);
1155
1155
  return state;
1156
1156
  } else {
1157
- const initialValue = await rpc.call("vite:internal:rpc:server-state:get", key);
1157
+ const initialValue = await rpc.call("devtoolskit:internal:rpc:server-state:get", key);
1158
1158
  state.mutate(() => initialValue);
1159
1159
  sharedState.set(key, state);
1160
1160
  registerSharedState(key, state);
@@ -0,0 +1,7 @@
1
+ import { C as DevToolsDocksUserSettings } from "./client-script-BOHKZVPh.mjs";
2
+
3
+ //#region src/constants.d.ts
4
+ declare const DEFAULT_CATEGORIES_ORDER: Record<string, number>;
5
+ declare const DEFAULT_STATE_USER_SETTINGS: () => DevToolsDocksUserSettings;
6
+ //#endregion
7
+ export { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS };
@@ -0,0 +1,20 @@
1
+ //#region src/constants.ts
2
+ const DEFAULT_CATEGORIES_ORDER = {
3
+ "~viteplus": -1e3,
4
+ "default": 0,
5
+ "app": 100,
6
+ "framework": 200,
7
+ "web": 300,
8
+ "advanced": 400,
9
+ "~builtin": 1e3
10
+ };
11
+ const DEFAULT_STATE_USER_SETTINGS = () => ({
12
+ docksHidden: [],
13
+ docksCategoriesHidden: [],
14
+ docksPinned: [],
15
+ docksCustomOrder: {},
16
+ showIframeAddressBar: false
17
+ });
18
+
19
+ //#endregion
20
+ export { DEFAULT_CATEGORIES_ORDER, DEFAULT_STATE_USER_SETTINGS };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,3 @@
1
- import { n as EventUnsubscribe, r as EventsMap, t as EventEmitter } from "./events-ChUECkY3.mjs";
2
- import { $ as DevToolsViewCustomRender, A as DevToolsNodeUtils, B as DevToolsRpcClientFunctions, C as RpcBroadcastOptions, D as ConnectionMeta, E as RpcSharedStateHost, F as DevToolsTerminalHost, G as DevToolsDockEntry, H as DevToolsRpcSharedStates, I as DevToolsTerminalSession, J as DevToolsDockEntryIcon, K as DevToolsDockEntryBase, L as DevToolsTerminalSessionBase, M as DevToolsViewHost, N as DevToolsChildProcessExecuteOptions, O as DevToolsCapabilities, P as DevToolsChildProcessTerminalSession, Q as DevToolsViewBuiltin, R as DevToolsTerminalSessionStreamChunkEvent, S as DevToolsNodeRpcSession, T as RpcSharedStateGetOptions, U as DevToolsNodeRpcSessionMeta, V as DevToolsRpcServerFunctions, W as ClientScriptEntry, X as DevToolsDockUserEntry, Y as DevToolsDockHost, Z as DevToolsViewAction, _ as PluginWithDevTools, b as PartialWithoutId, et as DevToolsViewIframe, g as RpcDefinitionsToFunctions, h as RpcDefinitionsFilter, j as DevToolsPluginOptions, k as DevToolsNodeContext, nt as DevToolsViewLauncherStatus, q as DevToolsDockEntryCategory, tt as DevToolsViewLauncher, v as ViteConfigDevtoolsOptions, w as RpcFunctionsHost, x as Thenable, y as EntriesToObject, z as DevToolsTerminalStatus } from "./index-DKkzr1AR.mjs";
3
- import "./shared-state-7JDpUVVs.mjs";
4
- import * as birpc_x0 from "birpc-x";
5
-
6
- //#region src/utils/define.d.ts
7
- declare const defineRpcFunction: <NAME extends string, TYPE extends birpc_x0.RpcFunctionType, ARGS$1 extends any[], RETURN$1 = void>(definition: birpc_x0.RpcFunctionDefinition<NAME, TYPE, ARGS$1, RETURN$1, DevToolsNodeContext>) => birpc_x0.RpcFunctionDefinition<NAME, TYPE, ARGS$1, RETURN$1, DevToolsNodeContext>;
8
- //#endregion
9
- export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsNodeRpcSessionMeta, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsRpcSharedStates, DevToolsTerminalHost, DevToolsTerminalSession, DevToolsTerminalSessionBase, DevToolsTerminalSessionStreamChunkEvent, DevToolsTerminalStatus, DevToolsViewAction, DevToolsViewBuiltin, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewLauncher, DevToolsViewLauncherStatus, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, PartialWithoutId, PluginWithDevTools, RpcBroadcastOptions, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, Thenable, ViteConfigDevtoolsOptions, defineRpcFunction };
1
+ import { $ as DevToolsViewAction, A as ConnectionMeta, B as DevToolsTerminalSessionBase, C as DevToolsDocksUserSettings, D as RpcFunctionsHost, E as RpcBroadcastOptions, F as DevToolsViewHost, G as DevToolsRpcSharedStates, H as DevToolsTerminalStatus, I as DevToolsChildProcessExecuteOptions, J as DevToolsDockEntryBase, K as ClientScriptEntry, L as DevToolsChildProcessTerminalSession, M as DevToolsNodeContext, N as DevToolsNodeUtils, O as RpcSharedStateGetOptions, P as DevToolsPluginOptions, Q as DevToolsDockUserEntry, R as DevToolsTerminalHost, S as Thenable, T as DevToolsNodeRpcSessionMeta, U as DevToolsRpcClientFunctions, V as DevToolsTerminalSessionStreamChunkEvent, W as DevToolsRpcServerFunctions, X as DevToolsDockEntryIcon, Y as DevToolsDockEntryCategory, Z as DevToolsDockHost, _ as RpcDefinitionsToFunctions, b as EntriesToObject, et as DevToolsViewBuiltin, g as RpcDefinitionsFilter, h as defineRpcFunction, it as DevToolsViewLauncherStatus, j as DevToolsCapabilities, k as RpcSharedStateHost, nt as DevToolsViewIframe, q as DevToolsDockEntry, rt as DevToolsViewLauncher, tt as DevToolsViewCustomRender, v as PluginWithDevTools, w as DevToolsNodeRpcSession, x as PartialWithoutId, y as ViteConfigDevtoolsOptions, z as DevToolsTerminalSession } from "./client-script-BOHKZVPh.mjs";
2
+ import { n as EventUnsubscribe, r as EventsMap, t as EventEmitter } from "./events-57bKw4ct.mjs";
3
+ export { ClientScriptEntry, ConnectionMeta, DevToolsCapabilities, DevToolsChildProcessExecuteOptions, DevToolsChildProcessTerminalSession, DevToolsDockEntry, DevToolsDockEntryBase, DevToolsDockEntryCategory, DevToolsDockEntryIcon, DevToolsDockHost, DevToolsDockUserEntry, DevToolsDocksUserSettings, DevToolsNodeContext, DevToolsNodeRpcSession, DevToolsNodeRpcSessionMeta, DevToolsNodeUtils, DevToolsPluginOptions, DevToolsRpcClientFunctions, DevToolsRpcServerFunctions, DevToolsRpcSharedStates, DevToolsTerminalHost, DevToolsTerminalSession, DevToolsTerminalSessionBase, DevToolsTerminalSessionStreamChunkEvent, DevToolsTerminalStatus, DevToolsViewAction, DevToolsViewBuiltin, DevToolsViewCustomRender, DevToolsViewHost, DevToolsViewIframe, DevToolsViewLauncher, DevToolsViewLauncherStatus, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, PartialWithoutId, PluginWithDevTools, RpcBroadcastOptions, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, Thenable, ViteConfigDevtoolsOptions, defineRpcFunction };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createDefineWrapperWithContext } from "birpc-x";
1
+ import { createDefineWrapperWithContext } from "@vitejs/devtools-rpc";
2
2
 
3
3
  //#region src/utils/define.ts
4
4
  const defineRpcFunction = createDefineWrapperWithContext();
@@ -1,7 +1,6 @@
1
- import { r as EventsMap, t as EventEmitter } from "../events-ChUECkY3.mjs";
1
+ import { r as EventsMap, t as EventEmitter } from "../events-57bKw4ct.mjs";
2
2
 
3
3
  //#region src/utils/events.d.ts
4
-
5
4
  /**
6
5
  * Create event emitter.
7
6
  */
@@ -1,3 +1,41 @@
1
- import { t as createEventEmitter } from "../events-CWYZG96x.mjs";
1
+ //#region src/utils/events.ts
2
+ /**
3
+ * Create event emitter.
4
+ */
5
+ function createEventEmitter() {
6
+ const _listeners = {};
7
+ function emit(event, ...args) {
8
+ const callbacks = _listeners[event] || [];
9
+ for (let i = 0, length = callbacks.length; i < length; i++) {
10
+ const callback = callbacks[i];
11
+ if (callback) callback(...args);
12
+ }
13
+ }
14
+ function emitOnce(event, ...args) {
15
+ emit(event, ...args);
16
+ delete _listeners[event];
17
+ }
18
+ function on(event, cb) {
19
+ (_listeners[event] ||= []).push(cb);
20
+ return () => {
21
+ _listeners[event] = _listeners[event]?.filter((i) => cb !== i);
22
+ };
23
+ }
24
+ function once(event, cb) {
25
+ const unsubscribe = on(event, ((...args) => {
26
+ unsubscribe();
27
+ return cb(...args);
28
+ }));
29
+ return unsubscribe;
30
+ }
31
+ return {
32
+ _listeners,
33
+ emit,
34
+ emitOnce,
35
+ on,
36
+ once
37
+ };
38
+ }
2
39
 
40
+ //#endregion
3
41
  export { createEventEmitter };
@@ -1,3 +1,11 @@
1
- import { t as nanoid } from "../nanoid-B0pJU5uW.mjs";
1
+ //#region src/utils/nanoid.ts
2
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
3
+ function nanoid(size = 21) {
4
+ let id = "";
5
+ let i = size;
6
+ while (i--) id += urlAlphabet[Math.random() * 64 | 0];
7
+ return id;
8
+ }
2
9
 
10
+ //#endregion
3
11
  export { nanoid };
@@ -1,2 +1,53 @@
1
- import { a as ImmutableSet, c as SharedStateOptions, i as ImmutableObject, l as SharedStatePatch, n as ImmutableArray, o as SharedState, r as ImmutableMap, s as SharedStateEvents, t as Immutable, u as createSharedState } from "../shared-state-7JDpUVVs.mjs";
2
- export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
1
+ import { t as EventEmitter } from "../events-57bKw4ct.mjs";
2
+ import { Objectish, Patch, Patch as SharedStatePatch } from "immer";
3
+
4
+ //#region src/utils/shared-state.d.ts
5
+ type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
6
+ type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
7
+ type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
8
+ type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
9
+ type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
10
+ type ImmutableObject<T> = { readonly [K in keyof T]: Immutable<T[K]> };
11
+ /**
12
+ * State host that is immutable by default with explicit mutate.
13
+ */
14
+ interface SharedState<T> {
15
+ /**
16
+ * Get the current state. Immutable.
17
+ */
18
+ value: () => Immutable<T>;
19
+ /**
20
+ * Subscribe to state changes.
21
+ */
22
+ on: EventEmitter<SharedStateEvents<T>>['on'];
23
+ /**
24
+ * Mutate the state.
25
+ */
26
+ mutate: (fn: (state: T) => void, syncId?: string) => void;
27
+ /**
28
+ * Apply patches to the state.
29
+ */
30
+ patch: (patches: Patch[], syncId?: string) => void;
31
+ /**
32
+ * Sync IDs that have been applied to the state.
33
+ */
34
+ syncIds: Set<string>;
35
+ }
36
+ interface SharedStateEvents<T> {
37
+ updated: (fullState: T, patches: Patch[] | undefined, syncId: string) => void;
38
+ }
39
+ interface SharedStateOptions<T> {
40
+ /**
41
+ * Initial state.
42
+ */
43
+ initialValue: T;
44
+ /**
45
+ * Enable patches.
46
+ *
47
+ * @default false
48
+ */
49
+ enablePatches?: boolean;
50
+ }
51
+ declare function createSharedState<T extends Objectish>(options: SharedStateOptions<T>): SharedState<T>;
52
+ //#endregion
53
+ export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, type SharedStatePatch, createSharedState };
@@ -1,3 +1,38 @@
1
- import { t as createSharedState } from "../shared-state-BAC6HwFS.mjs";
1
+ import { createEventEmitter } from "./events.mjs";
2
+ import { nanoid } from "./nanoid.mjs";
3
+ import { applyPatches, enablePatches, produce, produceWithPatches } from "immer";
2
4
 
5
+ //#region src/utils/shared-state.ts
6
+ function createSharedState(options) {
7
+ const { enablePatches: enablePatches$1 = false } = options;
8
+ const events = createEventEmitter();
9
+ let state = options.initialValue;
10
+ const syncIds = /* @__PURE__ */ new Set();
11
+ return {
12
+ on: events.on,
13
+ value: () => state,
14
+ patch: (patches, syncId = nanoid()) => {
15
+ if (syncIds.has(syncId)) return;
16
+ enablePatches();
17
+ state = applyPatches(state, patches);
18
+ syncIds.add(syncId);
19
+ events.emit("updated", state, void 0, syncId);
20
+ },
21
+ mutate: (fn, syncId = nanoid()) => {
22
+ if (syncIds.has(syncId)) return;
23
+ syncIds.add(syncId);
24
+ if (enablePatches$1) {
25
+ const [newState, patches] = produceWithPatches(state, fn);
26
+ state = newState;
27
+ events.emit("updated", state, patches, syncId);
28
+ } else {
29
+ state = produce(state, fn);
30
+ events.emit("updated", state, void 0, syncId);
31
+ }
32
+ },
33
+ syncIds
34
+ };
35
+ }
36
+
37
+ //#endregion
3
38
  export { createSharedState };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitejs/devtools-kit",
3
3
  "type": "module",
4
- "version": "0.0.0-alpha.25",
4
+ "version": "0.0.0-alpha.27",
5
5
  "description": "Vite DevTools Kit",
6
6
  "author": "VoidZero Inc.",
7
7
  "license": "MIT",
@@ -21,6 +21,7 @@
21
21
  "exports": {
22
22
  ".": "./dist/index.mjs",
23
23
  "./client": "./dist/client.mjs",
24
+ "./constants": "./dist/constants.mjs",
24
25
  "./utils/events": "./dist/utils/events.mjs",
25
26
  "./utils/nanoid": "./dist/utils/nanoid.mjs",
26
27
  "./utils/shared-state": "./dist/utils/shared-state.mjs",
@@ -35,14 +36,13 @@
35
36
  },
36
37
  "dependencies": {
37
38
  "birpc": "^4.0.0",
38
- "birpc-x": "0.0.6",
39
39
  "immer": "^11.1.3",
40
- "@vitejs/devtools-rpc": "0.0.0-alpha.25"
40
+ "@vitejs/devtools-rpc": "0.0.0-alpha.27"
41
41
  },
42
42
  "devDependencies": {
43
43
  "my-ua-parser": "^2.0.4",
44
- "tsdown": "^0.19.0",
45
- "vite": "^8.0.0-beta.7"
44
+ "tsdown": "^0.20.2",
45
+ "vite": "^8.0.0-beta.13"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsdown",
@@ -1,41 +0,0 @@
1
- //#region src/utils/events.ts
2
- /**
3
- * Create event emitter.
4
- */
5
- function createEventEmitter() {
6
- const _listeners = {};
7
- function emit(event, ...args) {
8
- const callbacks = _listeners[event] || [];
9
- for (let i = 0, length = callbacks.length; i < length; i++) {
10
- const callback = callbacks[i];
11
- if (callback) callback(...args);
12
- }
13
- }
14
- function emitOnce(event, ...args) {
15
- emit(event, ...args);
16
- delete _listeners[event];
17
- }
18
- function on(event, cb) {
19
- (_listeners[event] ||= []).push(cb);
20
- return () => {
21
- _listeners[event] = _listeners[event]?.filter((i) => cb !== i);
22
- };
23
- }
24
- function once(event, cb) {
25
- const unsubscribe = on(event, ((...args) => {
26
- unsubscribe();
27
- return cb(...args);
28
- }));
29
- return unsubscribe;
30
- }
31
- return {
32
- _listeners,
33
- emit,
34
- emitOnce,
35
- on,
36
- once
37
- };
38
- }
39
-
40
- //#endregion
41
- export { createEventEmitter as t };