vite-plugin-debugger 0.2.0 → 0.3.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.
- package/dist/chunk-AY5SPOLM.js +75 -0
- package/dist/chunk-M5FN5N6N.js +75 -0
- package/dist/chunk-WG6FWYWY.js +7010 -0
- package/dist/eruda.d.ts +22 -0
- package/dist/eruda.js +9 -0
- package/dist/index.d-D0Oa6UqJ.d.ts +48 -0
- package/dist/index.d.ts +6 -89
- package/dist/index.js +10 -247
- package/dist/precompiled/eruda/dynamic-import.js +1 -0
- package/dist/precompiled/eruda/prepend-script.js +1 -0
- package/dist/precompiled/show-or-not.js +1 -0
- package/dist/precompiled/vconsole/dynamic-import.js +1 -0
- package/dist/precompiled/vconsole/prepend-script.js +1 -0
- package/dist/vconsole.d.ts +22 -0
- package/dist/vconsole.js +9 -0
- package/package.json +28 -5
@@ -0,0 +1,75 @@
|
|
1
|
+
import {
|
2
|
+
isPackageExists,
|
3
|
+
readFileContent,
|
4
|
+
transformCDN
|
5
|
+
} from "./chunk-WG6FWYWY.js";
|
6
|
+
|
7
|
+
// src/plugins/vconsole.ts
|
8
|
+
import { normalizePath } from "vite";
|
9
|
+
var transformVConsoleOptions = async (html, opts) => {
|
10
|
+
const { debug, active } = opts;
|
11
|
+
const { options, cdn = "jsdelivr", src } = opts.config;
|
12
|
+
const tags = [];
|
13
|
+
let injectCodes = ``;
|
14
|
+
injectCodes += "\n(function(debug,active,options,cdn){\n";
|
15
|
+
injectCodes += readFileContent("./precompiled/show-or-not.js");
|
16
|
+
injectCodes += readFileContent("./precompiled/vconsole/prepend-script.js");
|
17
|
+
injectCodes += `
|
18
|
+
})(${debug},${JSON.stringify(active)},${JSON.stringify(options)},${JSON.stringify(src || await transformCDN("vConsole", cdn))});
|
19
|
+
`;
|
20
|
+
tags.push({
|
21
|
+
tag: "script",
|
22
|
+
injectTo: "head",
|
23
|
+
children: injectCodes
|
24
|
+
});
|
25
|
+
if (debug !== void 0) {
|
26
|
+
return {
|
27
|
+
html,
|
28
|
+
tags
|
29
|
+
};
|
30
|
+
}
|
31
|
+
};
|
32
|
+
var transformVConsoleImport = (code, opts) => {
|
33
|
+
const { debug, active } = opts;
|
34
|
+
const { options = {} } = opts.config;
|
35
|
+
let injectCodes = ``;
|
36
|
+
injectCodes += "\n/* eslint-disable */\n";
|
37
|
+
injectCodes += "\n(function(debug,active,options){\n";
|
38
|
+
injectCodes += readFileContent("./precompiled/show-or-not.js");
|
39
|
+
injectCodes += readFileContent("./precompiled/vconsole/dynamic-import.js");
|
40
|
+
injectCodes += `
|
41
|
+
})(${debug},${JSON.stringify(active)},${JSON.stringify(options)});
|
42
|
+
`;
|
43
|
+
injectCodes += "\n/* eslint-enable */\n";
|
44
|
+
return {
|
45
|
+
code: `${injectCodes}${code}`,
|
46
|
+
map: null
|
47
|
+
};
|
48
|
+
};
|
49
|
+
function vDebugger(options) {
|
50
|
+
const { local = isPackageExists("vconsole"), entry } = options;
|
51
|
+
const entryPath = entry ? (Array.isArray(entry) ? entry : [entry]).map((path) => normalizePath(path)) : [];
|
52
|
+
if (local) {
|
53
|
+
return {
|
54
|
+
name: "vite:mobile-devtools:vconsole",
|
55
|
+
transform(code, id) {
|
56
|
+
if (entryPath.includes(id)) {
|
57
|
+
return transformVConsoleImport(code, options);
|
58
|
+
}
|
59
|
+
return { code, map: null };
|
60
|
+
}
|
61
|
+
};
|
62
|
+
}
|
63
|
+
return {
|
64
|
+
name: "vite:mobile-devtools:vconsole",
|
65
|
+
transformIndexHtml: async (html) => {
|
66
|
+
return await transformVConsoleOptions(html, options);
|
67
|
+
}
|
68
|
+
};
|
69
|
+
}
|
70
|
+
var vconsole_default = vDebugger;
|
71
|
+
|
72
|
+
export {
|
73
|
+
vDebugger,
|
74
|
+
vconsole_default
|
75
|
+
};
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import {
|
2
|
+
isPackageExists,
|
3
|
+
readFileContent,
|
4
|
+
transformCDN
|
5
|
+
} from "./chunk-WG6FWYWY.js";
|
6
|
+
|
7
|
+
// src/plugins/eruda.ts
|
8
|
+
import { normalizePath } from "vite";
|
9
|
+
var transformErudaOptions = async (html, opts) => {
|
10
|
+
const { debug, active } = opts;
|
11
|
+
const { options, cdn = "jsdelivr", src } = opts.config;
|
12
|
+
const tags = [];
|
13
|
+
let injectCodes = ``;
|
14
|
+
injectCodes += "\n(function(debug,active,options,cdn){\n";
|
15
|
+
injectCodes += readFileContent("./precompiled/show-or-not.js");
|
16
|
+
injectCodes += readFileContent("./precompiled/eruda/prepend-script.js");
|
17
|
+
injectCodes += `
|
18
|
+
})(${debug},${JSON.stringify(active)},${JSON.stringify(options)},${JSON.stringify(src || await transformCDN("eruda", cdn))});
|
19
|
+
`;
|
20
|
+
tags.push({
|
21
|
+
tag: "script",
|
22
|
+
injectTo: "head",
|
23
|
+
children: injectCodes
|
24
|
+
});
|
25
|
+
if (debug !== void 0) {
|
26
|
+
return {
|
27
|
+
html,
|
28
|
+
tags
|
29
|
+
};
|
30
|
+
}
|
31
|
+
};
|
32
|
+
var transformErudaImport = (code, opts) => {
|
33
|
+
const { debug, active } = opts;
|
34
|
+
const { options = {} } = opts.config;
|
35
|
+
let injectCodes = ``;
|
36
|
+
injectCodes += "\n/* eslint-disable */\n";
|
37
|
+
injectCodes += "\n(function(debug,active,options){\n";
|
38
|
+
injectCodes += readFileContent("./precompiled/show-or-not.js");
|
39
|
+
injectCodes += readFileContent("./precompiled/eruda/dynamic-import.js");
|
40
|
+
injectCodes += `
|
41
|
+
})(${debug},${JSON.stringify(active)},${JSON.stringify(options)});
|
42
|
+
`;
|
43
|
+
injectCodes += "\n/* eslint-enable */\n";
|
44
|
+
return {
|
45
|
+
code: `${injectCodes}${code}`,
|
46
|
+
map: null
|
47
|
+
};
|
48
|
+
};
|
49
|
+
function vDebugger(options) {
|
50
|
+
const { local = isPackageExists("eruda"), entry } = options;
|
51
|
+
const entryPath = entry ? (Array.isArray(entry) ? entry : [entry]).map((path) => normalizePath(path)) : [];
|
52
|
+
if (local) {
|
53
|
+
return {
|
54
|
+
name: "vite:mobile-devtools:eruda",
|
55
|
+
transform(code, id) {
|
56
|
+
if (entryPath.includes(id)) {
|
57
|
+
return transformErudaImport(code, options);
|
58
|
+
}
|
59
|
+
return { code, map: null };
|
60
|
+
}
|
61
|
+
};
|
62
|
+
}
|
63
|
+
return {
|
64
|
+
name: "vite:mobile-devtools:eruda",
|
65
|
+
transformIndexHtml: async (html) => {
|
66
|
+
return await transformErudaOptions(html, options);
|
67
|
+
}
|
68
|
+
};
|
69
|
+
}
|
70
|
+
var eruda_default = vDebugger;
|
71
|
+
|
72
|
+
export {
|
73
|
+
vDebugger,
|
74
|
+
eruda_default
|
75
|
+
};
|