rearrage_stuff
This commit is contained in:
95
node_modules/vite-plugin-devtools-json/dist/index.cjs
generated
vendored
Normal file
95
node_modules/vite-plugin-devtools-json/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var uuid = require('uuid');
|
||||
|
||||
const ENDPOINT = "/.well-known/appspecific/com.chrome.devtools.json";
|
||||
const plugin = (options = {}) => ({
|
||||
name: "devtools-json",
|
||||
enforce: "post",
|
||||
configureServer(server) {
|
||||
const { config } = server;
|
||||
const { logger } = config;
|
||||
if (!config.env.DEV) {
|
||||
return;
|
||||
}
|
||||
const getOrCreateUUID = () => {
|
||||
if (options.uuid) {
|
||||
return options.uuid;
|
||||
}
|
||||
let { cacheDir } = config;
|
||||
if (!path.isAbsolute(cacheDir)) {
|
||||
let { root } = config;
|
||||
if (!path.isAbsolute(root)) {
|
||||
root = path.resolve(process.cwd(), root);
|
||||
}
|
||||
cacheDir = path.resolve(root, cacheDir);
|
||||
}
|
||||
const uuidPath = path.resolve(cacheDir, "uuid.json");
|
||||
if (fs.existsSync(uuidPath)) {
|
||||
const uuid2 = fs.readFileSync(uuidPath, { encoding: "utf-8" });
|
||||
if (uuid.validate(uuid2)) {
|
||||
return uuid2;
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(cacheDir)) {
|
||||
fs.mkdirSync(cacheDir, { recursive: true });
|
||||
}
|
||||
const uuid$1 = uuid.v4();
|
||||
fs.writeFileSync(uuidPath, uuid$1, { encoding: "utf-8" });
|
||||
return uuid$1;
|
||||
};
|
||||
const normalizePaths = options.normalizeForWindowsContainer ?? (options.normalizeForChrome ?? true);
|
||||
if (Object.prototype.hasOwnProperty.call(options, "normalizeForChrome") && options.normalizeForWindowsContainer === void 0) {
|
||||
logger.warn(
|
||||
'[vite-plugin-devtools-json] "normalizeForChrome" is deprecated \u2013 please rename to "normalizeForWindowsContainer".'
|
||||
);
|
||||
}
|
||||
server.middlewares.use(ENDPOINT, async (_req, res) => {
|
||||
const resolveProjectRoot = () => {
|
||||
if (options.projectRoot) {
|
||||
return path.resolve(options.projectRoot);
|
||||
}
|
||||
let { root: root2 } = config;
|
||||
if (!path.isAbsolute(root2)) {
|
||||
root2 = path.resolve(process.cwd(), root2);
|
||||
}
|
||||
return root2;
|
||||
};
|
||||
const maybeNormalizePath = (absRoot) => {
|
||||
if (!normalizePaths) return absRoot;
|
||||
if (process.env.WSL_DISTRO_NAME) {
|
||||
const distro = process.env.WSL_DISTRO_NAME;
|
||||
const withoutLeadingSlash = absRoot.replace(/^\//, "");
|
||||
return path.join("\\\\wsl.localhost", distro, withoutLeadingSlash).replace(/\//g, "\\");
|
||||
}
|
||||
if (process.env.DOCKER_DESKTOP && !absRoot.startsWith("\\\\")) {
|
||||
const withoutLeadingSlash = absRoot.replace(/^\//, "");
|
||||
return path.join("\\\\wsl.localhost", "docker-desktop-data", withoutLeadingSlash).replace(/\//g, "\\");
|
||||
}
|
||||
return absRoot;
|
||||
};
|
||||
let root = maybeNormalizePath(resolveProjectRoot());
|
||||
const uuid = getOrCreateUUID();
|
||||
const devtoolsJson = {
|
||||
workspace: {
|
||||
root,
|
||||
uuid
|
||||
}
|
||||
};
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.end(JSON.stringify(devtoolsJson, null, 2));
|
||||
});
|
||||
},
|
||||
configurePreviewServer(server) {
|
||||
server.middlewares.use(ENDPOINT, async (req, res) => {
|
||||
res.writeHead(404);
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
exports.default = plugin;
|
||||
26
node_modules/vite-plugin-devtools-json/dist/index.d.ts
generated
vendored
Normal file
26
node_modules/vite-plugin-devtools-json/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Plugin } from 'vite';
|
||||
|
||||
interface DevToolsJsonOptions {
|
||||
/**
|
||||
* Optional fixed UUID. If omitted the plugin will generate
|
||||
* (and cache) one automatically, which is the previous default behaviour.
|
||||
*/
|
||||
uuid?: string;
|
||||
/**
|
||||
* Absolute (or relative) path that should be reported as the project root
|
||||
* in DevTools. When omitted, we fall back to Vite’s `config.root` logic.
|
||||
*/
|
||||
projectRoot?: string;
|
||||
/**
|
||||
* @deprecated Use `normalizeForWindowsContainer` instead. Will be removed in a future major version.
|
||||
*/
|
||||
normalizeForChrome?: boolean;
|
||||
/**
|
||||
* Whether to rewrite Linux paths to UNC form so Chrome running on Windows
|
||||
* (WSL or Docker Desktop) can mount them as a workspace. Enabled by default.
|
||||
*/
|
||||
normalizeForWindowsContainer?: boolean;
|
||||
}
|
||||
declare const plugin: (options?: DevToolsJsonOptions) => Plugin;
|
||||
|
||||
export { plugin as default };
|
||||
91
node_modules/vite-plugin-devtools-json/dist/index.mjs
generated
vendored
Normal file
91
node_modules/vite-plugin-devtools-json/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { validate, v4 } from 'uuid';
|
||||
|
||||
const ENDPOINT = "/.well-known/appspecific/com.chrome.devtools.json";
|
||||
const plugin = (options = {}) => ({
|
||||
name: "devtools-json",
|
||||
enforce: "post",
|
||||
configureServer(server) {
|
||||
const { config } = server;
|
||||
const { logger } = config;
|
||||
if (!config.env.DEV) {
|
||||
return;
|
||||
}
|
||||
const getOrCreateUUID = () => {
|
||||
if (options.uuid) {
|
||||
return options.uuid;
|
||||
}
|
||||
let { cacheDir } = config;
|
||||
if (!path.isAbsolute(cacheDir)) {
|
||||
let { root } = config;
|
||||
if (!path.isAbsolute(root)) {
|
||||
root = path.resolve(process.cwd(), root);
|
||||
}
|
||||
cacheDir = path.resolve(root, cacheDir);
|
||||
}
|
||||
const uuidPath = path.resolve(cacheDir, "uuid.json");
|
||||
if (fs.existsSync(uuidPath)) {
|
||||
const uuid2 = fs.readFileSync(uuidPath, { encoding: "utf-8" });
|
||||
if (validate(uuid2)) {
|
||||
return uuid2;
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(cacheDir)) {
|
||||
fs.mkdirSync(cacheDir, { recursive: true });
|
||||
}
|
||||
const uuid = v4();
|
||||
fs.writeFileSync(uuidPath, uuid, { encoding: "utf-8" });
|
||||
return uuid;
|
||||
};
|
||||
const normalizePaths = options.normalizeForWindowsContainer ?? (options.normalizeForChrome ?? true);
|
||||
if (Object.prototype.hasOwnProperty.call(options, "normalizeForChrome") && options.normalizeForWindowsContainer === void 0) {
|
||||
logger.warn(
|
||||
'[vite-plugin-devtools-json] "normalizeForChrome" is deprecated \u2013 please rename to "normalizeForWindowsContainer".'
|
||||
);
|
||||
}
|
||||
server.middlewares.use(ENDPOINT, async (_req, res) => {
|
||||
const resolveProjectRoot = () => {
|
||||
if (options.projectRoot) {
|
||||
return path.resolve(options.projectRoot);
|
||||
}
|
||||
let { root: root2 } = config;
|
||||
if (!path.isAbsolute(root2)) {
|
||||
root2 = path.resolve(process.cwd(), root2);
|
||||
}
|
||||
return root2;
|
||||
};
|
||||
const maybeNormalizePath = (absRoot) => {
|
||||
if (!normalizePaths) return absRoot;
|
||||
if (process.env.WSL_DISTRO_NAME) {
|
||||
const distro = process.env.WSL_DISTRO_NAME;
|
||||
const withoutLeadingSlash = absRoot.replace(/^\//, "");
|
||||
return path.join("\\\\wsl.localhost", distro, withoutLeadingSlash).replace(/\//g, "\\");
|
||||
}
|
||||
if (process.env.DOCKER_DESKTOP && !absRoot.startsWith("\\\\")) {
|
||||
const withoutLeadingSlash = absRoot.replace(/^\//, "");
|
||||
return path.join("\\\\wsl.localhost", "docker-desktop-data", withoutLeadingSlash).replace(/\//g, "\\");
|
||||
}
|
||||
return absRoot;
|
||||
};
|
||||
let root = maybeNormalizePath(resolveProjectRoot());
|
||||
const uuid = getOrCreateUUID();
|
||||
const devtoolsJson = {
|
||||
workspace: {
|
||||
root,
|
||||
uuid
|
||||
}
|
||||
};
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.end(JSON.stringify(devtoolsJson, null, 2));
|
||||
});
|
||||
},
|
||||
configurePreviewServer(server) {
|
||||
server.middlewares.use(ENDPOINT, async (req, res) => {
|
||||
res.writeHead(404);
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export { plugin as default };
|
||||
Reference in New Issue
Block a user