vite-plugin-debugger 0.0.7 → 0.0.8
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/index.d.ts +5 -1
- package/dist/index.js +20 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -44,6 +44,10 @@ interface CommonConfig {
|
|
44
44
|
}
|
45
45
|
|
46
46
|
interface ActiveConfig {
|
47
|
+
/**
|
48
|
+
* define is active override debug
|
49
|
+
*/
|
50
|
+
override?: boolean
|
47
51
|
/**
|
48
52
|
* use url or storage
|
49
53
|
*/
|
@@ -51,7 +55,7 @@ interface ActiveConfig {
|
|
51
55
|
/**
|
52
56
|
* parameter name
|
53
57
|
*/
|
54
|
-
param
|
58
|
+
param: string
|
55
59
|
}
|
56
60
|
interface DebuggerOptions {
|
57
61
|
/**
|
package/dist/index.js
CHANGED
@@ -50,17 +50,28 @@ var transformCDN = (pkg, cdn) => {
|
|
50
50
|
};
|
51
51
|
var debugInit = (debug, active) => {
|
52
52
|
return `
|
53
|
-
|
53
|
+
const activeConfig = ${!!active}
|
54
|
+
const activePriority = ${active == null ? void 0 : active.override}
|
55
|
+
let showDebug = false;
|
54
56
|
let storageStr = ''
|
55
57
|
if(${(active == null ? void 0 : active.mode) === "url"}){
|
56
58
|
let queryStr='';
|
57
|
-
const result = (window.location.href || '').match(new RegExp('[?&]${
|
58
|
-
if (Array.isArray(result) && result.length > 1) queryStr= result[1];
|
59
|
-
if (queryStr
|
59
|
+
const result = (window.location.href || '').match(new RegExp('[?&]${active == null ? void 0 : active.param}=([^&]+)', 'i'));
|
60
|
+
if (Array.isArray(result) && result.length > 1) queryStr = result[1];
|
61
|
+
if (queryStr) localStorage.setItem('${active == null ? void 0 : active.param}', queryStr);
|
62
|
+
}
|
63
|
+
if(${(active == null ? void 0 : active.mode) === "url" || (active == null ? void 0 : active.mode) === "storage"}){
|
64
|
+
storageStr = localStorage.getItem('${active == null ? void 0 : active.param}')
|
65
|
+
}
|
66
|
+
if(activeConfig){
|
67
|
+
if(activePriority){
|
68
|
+
if (storageStr){ showDebug = true };
|
69
|
+
} else {
|
70
|
+
if (${debug} && storageStr){ showDebug = true };
|
71
|
+
}
|
72
|
+
} else {
|
73
|
+
showDebug = ${debug}
|
60
74
|
}
|
61
|
-
if(${(active == null ? void 0 : active.mode) === "url" || (active == null ? void 0 : active.mode) === "storage"})
|
62
|
-
storageStr = localStorage.getItem('${(active == null ? void 0 : active.param) || "debugwhatever"}')
|
63
|
-
if (storageStr === 'true'){ showDebug=true };
|
64
75
|
`;
|
65
76
|
};
|
66
77
|
|
@@ -109,7 +120,7 @@ var transformErudaOptions = (html, opts) => {
|
|
109
120
|
if(showDebug===true){ ${erudaScript}}`,
|
110
121
|
injectTo: "head"
|
111
122
|
});
|
112
|
-
if (debug
|
123
|
+
if (debug !== void 0) {
|
113
124
|
return {
|
114
125
|
html,
|
115
126
|
tags
|
@@ -162,7 +173,7 @@ var transformVConsoleOptions = (html, opts) => {
|
|
162
173
|
if(showDebug===true){var vConsole = new VConsole(${JSON.stringify(options || {})})};`,
|
163
174
|
injectTo: "head"
|
164
175
|
});
|
165
|
-
if (debug
|
176
|
+
if (debug !== void 0) {
|
166
177
|
return {
|
167
178
|
html,
|
168
179
|
tags
|