vite-plugin-vue-devtools 7.3.6 → 7.3.7

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/vite.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { fileURLToPath } from 'node:url';
2
2
  import path$a, { dirname, resolve as resolve$1 } from 'node:path';
3
+ import fs$8 from 'node:fs';
3
4
  import { normalizePath } from 'vite';
4
5
  import sirv from 'sirv';
5
6
  import Inspect from 'vite-plugin-inspect';
@@ -6879,6 +6880,7 @@ function normalizeWindowsPath(input = "") {
6879
6880
  const _UNC_REGEX = /^[/\\]{2}/;
6880
6881
  const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
6881
6882
  const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
6883
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
6882
6884
  const normalize = function(path) {
6883
6885
  if (path.length === 0) {
6884
6886
  return ".";
@@ -7013,6 +7015,22 @@ function normalizeString(path, allowAboveRoot) {
7013
7015
  const isAbsolute = function(p) {
7014
7016
  return _IS_ABSOLUTE_RE.test(p);
7015
7017
  };
7018
+ const relative = function(from, to) {
7019
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
7020
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
7021
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7022
+ return _to.join("/");
7023
+ }
7024
+ const _fromCopy = [..._from];
7025
+ for (const segment of _fromCopy) {
7026
+ if (_to[0] !== segment) {
7027
+ break;
7028
+ }
7029
+ _from.shift();
7030
+ _to.shift();
7031
+ }
7032
+ return [..._from.map(() => ".."), ..._to].join("/");
7033
+ };
7016
7034
 
7017
7035
  const decoder = new TextDecoder();
7018
7036
  const toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
@@ -7820,6 +7838,8 @@ function getAssetsFunctions(ctx) {
7820
7838
  async function scan() {
7821
7839
  const dir = resolve(config.root);
7822
7840
  const baseURL = config.base;
7841
+ const publicDir = config.publicDir;
7842
+ const relativePublicDir = publicDir === "" ? "" : `${relative(dir, publicDir)}/`;
7823
7843
  const files = await fg([
7824
7844
  // image
7825
7845
  "**/*.(png|jpg|jpeg|gif|svg|webp|avif|ico|bmp|tiff)",
@@ -7845,15 +7865,16 @@ function getAssetsFunctions(ctx) {
7845
7865
  "**/pnpm-workspace.*"
7846
7866
  ]
7847
7867
  });
7848
- cache = await Promise.all(files.map(async (path) => {
7849
- const filePath = resolve(dir, path);
7868
+ cache = await Promise.all(files.map(async (relativePath) => {
7869
+ const filePath = resolve(dir, relativePath);
7850
7870
  const stat = await fsp.lstat(filePath);
7851
- path = path.startsWith("public/") ? path.slice(7) : path;
7871
+ const path = relativePath.replace(relativePublicDir, "");
7852
7872
  return {
7853
7873
  path,
7874
+ relativePath,
7854
7875
  publicPath: join(baseURL, path),
7855
7876
  filePath,
7856
- type: guessType(path),
7877
+ type: guessType(relativePath),
7857
7878
  size: stat.size,
7858
7879
  mtime: stat.mtimeMs
7859
7880
  };
@@ -7950,6 +7971,10 @@ function getRpcFunctions(ctx) {
7950
7971
  };
7951
7972
  }
7952
7973
 
7974
+ function removeUrlQuery(url) {
7975
+ return url.replace(/\?.*$/, "");
7976
+ }
7977
+
7953
7978
  function getVueDevtoolsPath() {
7954
7979
  const pluginPath = normalizePath(path$a.dirname(fileURLToPath(import.meta.url)));
7955
7980
  return pluginPath.replace(/\/dist$/, "//src");
@@ -7962,6 +7987,7 @@ const toggleComboKeysMap = {
7962
7987
  function normalizeComboKeyPrint(toggleComboKey) {
7963
7988
  return toggleComboKey.split("-").map((key) => toggleComboKeysMap[key] || key[0].toUpperCase() + key.slice(1)).join(dim("+"));
7964
7989
  }
7990
+ const devtoolsNextResourceSymbol = "?__vue-devtools-next-resource";
7965
7991
  const defaultOptions = {
7966
7992
  appendTo: "",
7967
7993
  componentInspector: true,
@@ -8004,6 +8030,8 @@ function VitePluginVueDevTools(options) {
8004
8030
  `);
8005
8031
  };
8006
8032
  }
8033
+ const devtoolsOptionsImportee = "virtual:vue-devtools-options";
8034
+ const resolvedDevtoolsOptions = `\0${devtoolsOptionsImportee}`;
8007
8035
  const plugin = {
8008
8036
  name: "vite-plugin-vue-devtools",
8009
8037
  enforce: "pre",
@@ -8015,16 +8043,20 @@ function VitePluginVueDevTools(options) {
8015
8043
  configureServer(server);
8016
8044
  },
8017
8045
  async resolveId(importee) {
8018
- if (importee.startsWith("virtual:vue-devtools-options")) {
8019
- return importee;
8046
+ if (importee === devtoolsOptionsImportee) {
8047
+ return resolvedDevtoolsOptions;
8020
8048
  } else if (importee.startsWith("virtual:vue-devtools-path:")) {
8021
8049
  const resolved = importee.replace("virtual:vue-devtools-path:", `${vueDevtoolsPath}/`);
8022
- return resolved;
8050
+ return `${resolved}${devtoolsNextResourceSymbol}`;
8023
8051
  }
8024
8052
  },
8025
8053
  async load(id) {
8026
- if (id === "virtual:vue-devtools-options")
8054
+ if (id === resolvedDevtoolsOptions) {
8027
8055
  return `export default ${JSON.stringify({ base: config.base, componentInspector: pluginOptions.componentInspector })}`;
8056
+ } else if (id.endsWith(devtoolsNextResourceSymbol)) {
8057
+ const filename = removeUrlQuery(id);
8058
+ return await fs$8.promises.readFile(filename, "utf-8");
8059
+ }
8028
8060
  },
8029
8061
  transform(code, id, options2) {
8030
8062
  if (options2?.ssr)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-vue-devtools",
3
3
  "type": "module",
4
- "version": "7.3.6",
4
+ "version": "7.3.7",
5
5
  "description": "A vite plugin for Vue DevTools",
6
6
  "author": "webfansplz",
7
7
  "license": "MIT",
@@ -49,10 +49,10 @@
49
49
  "execa": "^8.0.1",
50
50
  "sirv": "^2.0.4",
51
51
  "vite-plugin-inspect": "^0.8.4",
52
- "vite-plugin-vue-inspector": "^5.1.2",
53
- "@vue/devtools-core": "^7.3.6",
54
- "@vue/devtools-kit": "^7.3.6",
55
- "@vue/devtools-shared": "^7.3.6"
52
+ "vite-plugin-vue-inspector": "^5.1.3",
53
+ "@vue/devtools-shared": "^7.3.7",
54
+ "@vue/devtools-core": "^7.3.7",
55
+ "@vue/devtools-kit": "^7.3.7"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/node": "^20.14.10",