unplugin-dingtalk 0.1.6 → 0.1.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/astro.cjs +3 -188
- package/dist/astro.js +1 -1
- package/dist/{chunk-KEG2NDRE.js → chunk-GCW3A6BF.js} +1 -1
- package/dist/{chunk-BNQALGGL.js → chunk-JVGHIAFT.js} +1 -1
- package/dist/chunk-YU6RRDIU.js +109 -0
- package/dist/esbuild.cjs +3 -188
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +3 -188
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +3 -188
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +3 -188
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +3 -188
- package/dist/rspack.js +1 -1
- package/dist/vite.cjs +3 -188
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +3 -188
- package/dist/webpack.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-QTZOG6NL.js +0 -324
package/dist/astro.cjs
CHANGED
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,64 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
// node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
|
|
34
|
-
var require_picocolors = __commonJS({
|
|
35
|
-
"node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var argv = process.argv || [];
|
|
38
|
-
var env = process.env;
|
|
39
|
-
var isColorSupported = !("NO_COLOR" in env || argv.includes("--no-color")) && ("FORCE_COLOR" in env || argv.includes("--color") || process.platform === "win32" || require != null && require("tty").isatty(1) && env.TERM !== "dumb" || "CI" in env);
|
|
40
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
41
|
-
let string = "" + input;
|
|
42
|
-
let index = string.indexOf(close, open.length);
|
|
43
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
44
|
-
};
|
|
45
|
-
var replaceClose = (string, close, replace, index) => {
|
|
46
|
-
let result = "";
|
|
47
|
-
let cursor = 0;
|
|
48
|
-
do {
|
|
49
|
-
result += string.substring(cursor, index) + replace;
|
|
50
|
-
cursor = index + close.length;
|
|
51
|
-
index = string.indexOf(close, cursor);
|
|
52
|
-
} while (~index);
|
|
53
|
-
return result + string.substring(cursor);
|
|
54
|
-
};
|
|
55
|
-
var createColors = (enabled = isColorSupported) => {
|
|
56
|
-
let init = enabled ? formatter : () => String;
|
|
57
|
-
return {
|
|
58
|
-
isColorSupported: enabled,
|
|
59
|
-
reset: init("\x1B[0m", "\x1B[0m"),
|
|
60
|
-
bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
61
|
-
dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
62
|
-
italic: init("\x1B[3m", "\x1B[23m"),
|
|
63
|
-
underline: init("\x1B[4m", "\x1B[24m"),
|
|
64
|
-
inverse: init("\x1B[7m", "\x1B[27m"),
|
|
65
|
-
hidden: init("\x1B[8m", "\x1B[28m"),
|
|
66
|
-
strikethrough: init("\x1B[9m", "\x1B[29m"),
|
|
67
|
-
black: init("\x1B[30m", "\x1B[39m"),
|
|
68
|
-
red: init("\x1B[31m", "\x1B[39m"),
|
|
69
|
-
green: init("\x1B[32m", "\x1B[39m"),
|
|
70
|
-
yellow: init("\x1B[33m", "\x1B[39m"),
|
|
71
|
-
blue: init("\x1B[34m", "\x1B[39m"),
|
|
72
|
-
magenta: init("\x1B[35m", "\x1B[39m"),
|
|
73
|
-
cyan: init("\x1B[36m", "\x1B[39m"),
|
|
74
|
-
white: init("\x1B[37m", "\x1B[39m"),
|
|
75
|
-
gray: init("\x1B[90m", "\x1B[39m"),
|
|
76
|
-
bgBlack: init("\x1B[40m", "\x1B[49m"),
|
|
77
|
-
bgRed: init("\x1B[41m", "\x1B[49m"),
|
|
78
|
-
bgGreen: init("\x1B[42m", "\x1B[49m"),
|
|
79
|
-
bgYellow: init("\x1B[43m", "\x1B[49m"),
|
|
80
|
-
bgBlue: init("\x1B[44m", "\x1B[49m"),
|
|
81
|
-
bgMagenta: init("\x1B[45m", "\x1B[49m"),
|
|
82
|
-
bgCyan: init("\x1B[46m", "\x1B[49m"),
|
|
83
|
-
bgWhite: init("\x1B[47m", "\x1B[49m")
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
module2.exports = createColors();
|
|
87
|
-
module2.exports.createColors = createColors;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
30
|
// src/astro.ts
|
|
92
31
|
var astro_exports = {};
|
|
93
32
|
__export(astro_exports, {
|
|
@@ -99,132 +38,8 @@ module.exports = __toCommonJS(astro_exports);
|
|
|
99
38
|
var import_node_child_process = require("child_process");
|
|
100
39
|
var import_node_process = __toESM(require("process"), 1);
|
|
101
40
|
var import_unplugin = require("unplugin");
|
|
102
|
-
var import_picocolors = __toESM(
|
|
103
|
-
|
|
104
|
-
// node_modules/.pnpm/vite-plugin-vconsole@2.1.1/node_modules/vite-plugin-vconsole/dist/main.mjs
|
|
105
|
-
var parseVConsoleOptions = (config2) => Object.keys(config2).reduce((code, key) => {
|
|
106
|
-
const value = config2[key];
|
|
107
|
-
if (typeof value === "function") {
|
|
108
|
-
if (/^[(f]/.test(value.toString())) {
|
|
109
|
-
code += `${key}: ${value},`;
|
|
110
|
-
return code;
|
|
111
|
-
} else {
|
|
112
|
-
code += `${value},`;
|
|
113
|
-
return code;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
code += `${key}: ${JSON.stringify(config2[key])},`;
|
|
117
|
-
return code;
|
|
118
|
-
}, "");
|
|
119
|
-
var getEventItems = (event, id) => {
|
|
120
|
-
return event.map(
|
|
121
|
-
(ele) => `
|
|
122
|
-
${id}.on('${ele.eventName}', ${ele.callback})
|
|
123
|
-
`
|
|
124
|
-
).join(";");
|
|
125
|
-
};
|
|
126
|
-
var getDynamicConfig = (dynamicConfig) => {
|
|
127
|
-
let configString = "";
|
|
128
|
-
if (!dynamicConfig) {
|
|
129
|
-
return configString;
|
|
130
|
-
}
|
|
131
|
-
for (const key in dynamicConfig) {
|
|
132
|
-
if (typeof dynamicConfig[key] === "string") {
|
|
133
|
-
configString += `${key}: ${dynamicConfig[key]},`;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return configString;
|
|
137
|
-
};
|
|
138
|
-
var getPlugins = (plugin) => {
|
|
139
|
-
let plugins = "";
|
|
140
|
-
if (plugin && plugin.length) {
|
|
141
|
-
plugins = plugin.map(
|
|
142
|
-
(e) => `
|
|
143
|
-
const ${e.id} = new VConsole.VConsolePlugin('${e.id}', '${e.name}');
|
|
144
|
-
${getEventItems(e.event, e.id)}
|
|
145
|
-
vConsole.addPlugin(${e.id})
|
|
146
|
-
`
|
|
147
|
-
).join(";");
|
|
148
|
-
}
|
|
149
|
-
return plugins;
|
|
150
|
-
};
|
|
151
|
-
function viteVConsole(opt) {
|
|
152
|
-
const {
|
|
153
|
-
entry,
|
|
154
|
-
enabled = true,
|
|
155
|
-
config: config2 = {},
|
|
156
|
-
plugin,
|
|
157
|
-
customHide = false,
|
|
158
|
-
dynamicConfig = {},
|
|
159
|
-
eventListener = ""
|
|
160
|
-
} = opt;
|
|
161
|
-
let entryPath = Array.isArray(entry) ? entry : [entry];
|
|
162
|
-
if (process.platform === "win32")
|
|
163
|
-
entryPath = entryPath.map((item) => item.replace(/\\/g, "/"));
|
|
164
|
-
const enabledTruly = enabled;
|
|
165
|
-
return {
|
|
166
|
-
name: "vite:vconsole",
|
|
167
|
-
enforce: "pre",
|
|
168
|
-
transform(_source, id) {
|
|
169
|
-
if (entryPath.includes(id) && enabledTruly) {
|
|
170
|
-
const code = `/* eslint-disable */;
|
|
171
|
-
import VConsole from 'vconsole';
|
|
172
|
-
// config
|
|
173
|
-
const vConsole = new VConsole({${parseVConsoleOptions(
|
|
174
|
-
config2
|
|
175
|
-
)}});
|
|
176
|
-
window.vConsole = vConsole;
|
|
177
|
-
|
|
178
|
-
// plugins
|
|
179
|
-
${getPlugins(plugin)}
|
|
180
|
-
|
|
181
|
-
// dynamic config
|
|
182
|
-
window.vConsole.dynamicFunction = function() {
|
|
183
|
-
if (${getDynamicConfig(dynamicConfig).length > 0}) {
|
|
184
|
-
vConsole.setOption({${getDynamicConfig(dynamicConfig)}});
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
window.vConsole.dynamicChange = {
|
|
189
|
-
value: new Date().getTime()
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
window.vConsole.dynamicFunction();
|
|
193
|
-
|
|
194
|
-
if (${customHide}) {
|
|
195
|
-
vConsole.hideSwitch();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// In order to be compatible with old equipment, I used defineProperty. In the future, when proxy covers enough devices, proxy will be used.
|
|
199
|
-
Object.defineProperty(window.vConsole.dynamicChange, 'value', {
|
|
200
|
-
get: function() {
|
|
201
|
-
return this._value;
|
|
202
|
-
},
|
|
203
|
-
set: function(newValue) {
|
|
204
|
-
window.vConsole.dynamicFunction();
|
|
205
|
-
this._value = newValue;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// eventListener
|
|
210
|
-
${eventListener}
|
|
211
|
-
/* eslint-enable */${_source}`;
|
|
212
|
-
return {
|
|
213
|
-
code,
|
|
214
|
-
map: null
|
|
215
|
-
// support source map
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
return {
|
|
219
|
-
code: _source,
|
|
220
|
-
map: null
|
|
221
|
-
// support source map
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// src/index.ts
|
|
41
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
42
|
+
var import_vite_plugin_vconsole = require("vite-plugin-vconsole");
|
|
228
43
|
var config;
|
|
229
44
|
var devtoolsInstance;
|
|
230
45
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
@@ -315,7 +130,7 @@ var unpluginFactory = (options) => {
|
|
|
315
130
|
}
|
|
316
131
|
};
|
|
317
132
|
if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
|
|
318
|
-
return [viteVConsole(options == null ? void 0 : options.vconsole), unpluginDing];
|
|
133
|
+
return [(0, import_vite_plugin_vconsole.viteVConsole)(options == null ? void 0 : options.vconsole), unpluginDing];
|
|
319
134
|
} else {
|
|
320
135
|
return unpluginDing;
|
|
321
136
|
}
|
package/dist/astro.js
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { exec } from "child_process";
|
|
3
|
+
import process from "process";
|
|
4
|
+
import { createUnplugin } from "unplugin";
|
|
5
|
+
import c from "picocolors";
|
|
6
|
+
import { viteVConsole } from "vite-plugin-vconsole";
|
|
7
|
+
var config;
|
|
8
|
+
var devtoolsInstance;
|
|
9
|
+
var colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
10
|
+
var unpluginFactory = (options) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const unpluginDing = {
|
|
13
|
+
name: "unplugin-dingtalk",
|
|
14
|
+
enforce: "pre",
|
|
15
|
+
transformInclude(id) {
|
|
16
|
+
return id.endsWith("main.ts") || id.endsWith("main.js");
|
|
17
|
+
},
|
|
18
|
+
transform(_source) {
|
|
19
|
+
var _a2, _b, _c;
|
|
20
|
+
if ((options == null ? void 0 : options.enable) && ((_a2 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a2.enable)) {
|
|
21
|
+
const code = `/* eslint-disable */;
|
|
22
|
+
import { devtools } from '@vue/devtools'
|
|
23
|
+
devtools.connect(${(_b = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _b.host}, ${(_c = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _c.port})
|
|
24
|
+
/* eslint-enable */${_source};
|
|
25
|
+
`;
|
|
26
|
+
return {
|
|
27
|
+
code,
|
|
28
|
+
map: null
|
|
29
|
+
// support source map
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
code: _source,
|
|
34
|
+
map: null
|
|
35
|
+
// support source map
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
vite: {
|
|
39
|
+
configResolved(_config) {
|
|
40
|
+
config = _config;
|
|
41
|
+
},
|
|
42
|
+
configureServer(server) {
|
|
43
|
+
var _a2, _b;
|
|
44
|
+
if (!(options == null ? void 0 : options.enable)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
function debug(...args) {
|
|
48
|
+
if (options == null ? void 0 : options.debug) {
|
|
49
|
+
console.log(` ${c.yellow("DEBUG")} `, ...args);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const _printUrls = server.printUrls.bind(server);
|
|
53
|
+
let source = `localhost:${config.server.port || 5173}`;
|
|
54
|
+
const url = (_a2 = server.resolvedUrls) == null ? void 0 : _a2.local[0];
|
|
55
|
+
if (url) {
|
|
56
|
+
const u = new URL(url);
|
|
57
|
+
source = u.host;
|
|
58
|
+
}
|
|
59
|
+
const base = server.config.base || "/";
|
|
60
|
+
const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
|
|
61
|
+
server.printUrls = () => {
|
|
62
|
+
var _a3;
|
|
63
|
+
_printUrls();
|
|
64
|
+
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
65
|
+
`Open in dingtalk${((_a3 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a3.enable) ? " (with vue-devtools)" : ""}`
|
|
66
|
+
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
67
|
+
};
|
|
68
|
+
const targetURL = new URL(_targetUrl);
|
|
69
|
+
targetURL.searchParams.append("ddtab", "true");
|
|
70
|
+
if (options == null ? void 0 : options.corpId) {
|
|
71
|
+
targetURL.searchParams.append("corpId", options.corpId);
|
|
72
|
+
}
|
|
73
|
+
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
74
|
+
var _a3;
|
|
75
|
+
debug(targetURL.toString());
|
|
76
|
+
res.writeHead(302, {
|
|
77
|
+
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
78
|
+
});
|
|
79
|
+
if (((_a3 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a3.enable) && !devtoolsInstance) {
|
|
80
|
+
devtoolsInstance = exec("npx vue-devtools");
|
|
81
|
+
console.log(` ${c.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
82
|
+
devtoolsInstance.on("exit", () => {
|
|
83
|
+
devtoolsInstance = void 0;
|
|
84
|
+
});
|
|
85
|
+
process.on("exit", () => {
|
|
86
|
+
if (devtoolsInstance) {
|
|
87
|
+
devtoolsInstance.kill();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
res.end();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
|
|
97
|
+
return [viteVConsole(options == null ? void 0 : options.vconsole), unpluginDing];
|
|
98
|
+
} else {
|
|
99
|
+
return unpluginDing;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
103
|
+
var src_default = unplugin;
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
unpluginFactory,
|
|
107
|
+
unplugin,
|
|
108
|
+
src_default
|
|
109
|
+
};
|
package/dist/esbuild.cjs
CHANGED
|
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
8
|
var __export = (target, all) => {
|
|
12
9
|
for (var name in all)
|
|
13
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,64 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
27
|
));
|
|
31
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
29
|
|
|
33
|
-
// node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
|
|
34
|
-
var require_picocolors = __commonJS({
|
|
35
|
-
"node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var argv = process.argv || [];
|
|
38
|
-
var env = process.env;
|
|
39
|
-
var isColorSupported = !("NO_COLOR" in env || argv.includes("--no-color")) && ("FORCE_COLOR" in env || argv.includes("--color") || process.platform === "win32" || require != null && require("tty").isatty(1) && env.TERM !== "dumb" || "CI" in env);
|
|
40
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
41
|
-
let string = "" + input;
|
|
42
|
-
let index = string.indexOf(close, open.length);
|
|
43
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
44
|
-
};
|
|
45
|
-
var replaceClose = (string, close, replace, index) => {
|
|
46
|
-
let result = "";
|
|
47
|
-
let cursor = 0;
|
|
48
|
-
do {
|
|
49
|
-
result += string.substring(cursor, index) + replace;
|
|
50
|
-
cursor = index + close.length;
|
|
51
|
-
index = string.indexOf(close, cursor);
|
|
52
|
-
} while (~index);
|
|
53
|
-
return result + string.substring(cursor);
|
|
54
|
-
};
|
|
55
|
-
var createColors = (enabled = isColorSupported) => {
|
|
56
|
-
let init = enabled ? formatter : () => String;
|
|
57
|
-
return {
|
|
58
|
-
isColorSupported: enabled,
|
|
59
|
-
reset: init("\x1B[0m", "\x1B[0m"),
|
|
60
|
-
bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
61
|
-
dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
62
|
-
italic: init("\x1B[3m", "\x1B[23m"),
|
|
63
|
-
underline: init("\x1B[4m", "\x1B[24m"),
|
|
64
|
-
inverse: init("\x1B[7m", "\x1B[27m"),
|
|
65
|
-
hidden: init("\x1B[8m", "\x1B[28m"),
|
|
66
|
-
strikethrough: init("\x1B[9m", "\x1B[29m"),
|
|
67
|
-
black: init("\x1B[30m", "\x1B[39m"),
|
|
68
|
-
red: init("\x1B[31m", "\x1B[39m"),
|
|
69
|
-
green: init("\x1B[32m", "\x1B[39m"),
|
|
70
|
-
yellow: init("\x1B[33m", "\x1B[39m"),
|
|
71
|
-
blue: init("\x1B[34m", "\x1B[39m"),
|
|
72
|
-
magenta: init("\x1B[35m", "\x1B[39m"),
|
|
73
|
-
cyan: init("\x1B[36m", "\x1B[39m"),
|
|
74
|
-
white: init("\x1B[37m", "\x1B[39m"),
|
|
75
|
-
gray: init("\x1B[90m", "\x1B[39m"),
|
|
76
|
-
bgBlack: init("\x1B[40m", "\x1B[49m"),
|
|
77
|
-
bgRed: init("\x1B[41m", "\x1B[49m"),
|
|
78
|
-
bgGreen: init("\x1B[42m", "\x1B[49m"),
|
|
79
|
-
bgYellow: init("\x1B[43m", "\x1B[49m"),
|
|
80
|
-
bgBlue: init("\x1B[44m", "\x1B[49m"),
|
|
81
|
-
bgMagenta: init("\x1B[45m", "\x1B[49m"),
|
|
82
|
-
bgCyan: init("\x1B[46m", "\x1B[49m"),
|
|
83
|
-
bgWhite: init("\x1B[47m", "\x1B[49m")
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
module2.exports = createColors();
|
|
87
|
-
module2.exports.createColors = createColors;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
30
|
// src/esbuild.ts
|
|
92
31
|
var esbuild_exports = {};
|
|
93
32
|
__export(esbuild_exports, {
|
|
@@ -100,132 +39,8 @@ var import_unplugin2 = require("unplugin");
|
|
|
100
39
|
var import_node_child_process = require("child_process");
|
|
101
40
|
var import_node_process = __toESM(require("process"), 1);
|
|
102
41
|
var import_unplugin = require("unplugin");
|
|
103
|
-
var import_picocolors = __toESM(
|
|
104
|
-
|
|
105
|
-
// node_modules/.pnpm/vite-plugin-vconsole@2.1.1/node_modules/vite-plugin-vconsole/dist/main.mjs
|
|
106
|
-
var parseVConsoleOptions = (config2) => Object.keys(config2).reduce((code, key) => {
|
|
107
|
-
const value = config2[key];
|
|
108
|
-
if (typeof value === "function") {
|
|
109
|
-
if (/^[(f]/.test(value.toString())) {
|
|
110
|
-
code += `${key}: ${value},`;
|
|
111
|
-
return code;
|
|
112
|
-
} else {
|
|
113
|
-
code += `${value},`;
|
|
114
|
-
return code;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
code += `${key}: ${JSON.stringify(config2[key])},`;
|
|
118
|
-
return code;
|
|
119
|
-
}, "");
|
|
120
|
-
var getEventItems = (event, id) => {
|
|
121
|
-
return event.map(
|
|
122
|
-
(ele) => `
|
|
123
|
-
${id}.on('${ele.eventName}', ${ele.callback})
|
|
124
|
-
`
|
|
125
|
-
).join(";");
|
|
126
|
-
};
|
|
127
|
-
var getDynamicConfig = (dynamicConfig) => {
|
|
128
|
-
let configString = "";
|
|
129
|
-
if (!dynamicConfig) {
|
|
130
|
-
return configString;
|
|
131
|
-
}
|
|
132
|
-
for (const key in dynamicConfig) {
|
|
133
|
-
if (typeof dynamicConfig[key] === "string") {
|
|
134
|
-
configString += `${key}: ${dynamicConfig[key]},`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return configString;
|
|
138
|
-
};
|
|
139
|
-
var getPlugins = (plugin) => {
|
|
140
|
-
let plugins = "";
|
|
141
|
-
if (plugin && plugin.length) {
|
|
142
|
-
plugins = plugin.map(
|
|
143
|
-
(e) => `
|
|
144
|
-
const ${e.id} = new VConsole.VConsolePlugin('${e.id}', '${e.name}');
|
|
145
|
-
${getEventItems(e.event, e.id)}
|
|
146
|
-
vConsole.addPlugin(${e.id})
|
|
147
|
-
`
|
|
148
|
-
).join(";");
|
|
149
|
-
}
|
|
150
|
-
return plugins;
|
|
151
|
-
};
|
|
152
|
-
function viteVConsole(opt) {
|
|
153
|
-
const {
|
|
154
|
-
entry,
|
|
155
|
-
enabled = true,
|
|
156
|
-
config: config2 = {},
|
|
157
|
-
plugin,
|
|
158
|
-
customHide = false,
|
|
159
|
-
dynamicConfig = {},
|
|
160
|
-
eventListener = ""
|
|
161
|
-
} = opt;
|
|
162
|
-
let entryPath = Array.isArray(entry) ? entry : [entry];
|
|
163
|
-
if (process.platform === "win32")
|
|
164
|
-
entryPath = entryPath.map((item) => item.replace(/\\/g, "/"));
|
|
165
|
-
const enabledTruly = enabled;
|
|
166
|
-
return {
|
|
167
|
-
name: "vite:vconsole",
|
|
168
|
-
enforce: "pre",
|
|
169
|
-
transform(_source, id) {
|
|
170
|
-
if (entryPath.includes(id) && enabledTruly) {
|
|
171
|
-
const code = `/* eslint-disable */;
|
|
172
|
-
import VConsole from 'vconsole';
|
|
173
|
-
// config
|
|
174
|
-
const vConsole = new VConsole({${parseVConsoleOptions(
|
|
175
|
-
config2
|
|
176
|
-
)}});
|
|
177
|
-
window.vConsole = vConsole;
|
|
178
|
-
|
|
179
|
-
// plugins
|
|
180
|
-
${getPlugins(plugin)}
|
|
181
|
-
|
|
182
|
-
// dynamic config
|
|
183
|
-
window.vConsole.dynamicFunction = function() {
|
|
184
|
-
if (${getDynamicConfig(dynamicConfig).length > 0}) {
|
|
185
|
-
vConsole.setOption({${getDynamicConfig(dynamicConfig)}});
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
window.vConsole.dynamicChange = {
|
|
190
|
-
value: new Date().getTime()
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
window.vConsole.dynamicFunction();
|
|
194
|
-
|
|
195
|
-
if (${customHide}) {
|
|
196
|
-
vConsole.hideSwitch();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// In order to be compatible with old equipment, I used defineProperty. In the future, when proxy covers enough devices, proxy will be used.
|
|
200
|
-
Object.defineProperty(window.vConsole.dynamicChange, 'value', {
|
|
201
|
-
get: function() {
|
|
202
|
-
return this._value;
|
|
203
|
-
},
|
|
204
|
-
set: function(newValue) {
|
|
205
|
-
window.vConsole.dynamicFunction();
|
|
206
|
-
this._value = newValue;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// eventListener
|
|
211
|
-
${eventListener}
|
|
212
|
-
/* eslint-enable */${_source}`;
|
|
213
|
-
return {
|
|
214
|
-
code,
|
|
215
|
-
map: null
|
|
216
|
-
// support source map
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
code: _source,
|
|
221
|
-
map: null
|
|
222
|
-
// support source map
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/index.ts
|
|
42
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
43
|
+
var import_vite_plugin_vconsole = require("vite-plugin-vconsole");
|
|
229
44
|
var config;
|
|
230
45
|
var devtoolsInstance;
|
|
231
46
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
@@ -316,7 +131,7 @@ var unpluginFactory = (options) => {
|
|
|
316
131
|
}
|
|
317
132
|
};
|
|
318
133
|
if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
|
|
319
|
-
return [viteVConsole(options == null ? void 0 : options.vconsole), unpluginDing];
|
|
134
|
+
return [(0, import_vite_plugin_vconsole.viteVConsole)(options == null ? void 0 : options.vconsole), unpluginDing];
|
|
320
135
|
} else {
|
|
321
136
|
return unpluginDing;
|
|
322
137
|
}
|