unplugin-dingtalk 1003.0.0 → 1004.0.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/README.md +9 -2
- package/dist/__chrome_devtools.d.ts +3 -0
- package/dist/__chrome_devtools.js +7 -0
- package/dist/astro.js +3 -3
- package/dist/chunk-5JBD5THX.js +20 -0
- package/dist/chunk-5U7LETMH.js +505 -0
- package/dist/{chunk-552KT7KH.js → chunk-7VYUT3GL.js} +3 -3
- package/dist/chunk-DZEMXGMI.js +90 -0
- package/dist/esbuild.js +3 -3
- package/dist/index.js +3 -3
- package/dist/nuxt.js +4 -4
- package/dist/rollup.js +3 -3
- package/dist/rspack.js +8 -15
- package/dist/types.d.ts +5 -2
- package/dist/utils.js +1 -1
- package/dist/vite.js +4 -4
- package/dist/webpack.js +8 -15
- package/package.json +1 -2
- package/dist/chunk-A2RZ6ACY.js +0 -4743
- package/dist/chunk-MCTMMV5B.js +0 -115
- package/dist/chunk-W3PXXTYA.js +0 -1811
- package/dist/multipart-parser-WSPU7YI5.js +0 -373
package/README.md
CHANGED
|
@@ -33,8 +33,15 @@ interface Options {
|
|
|
33
33
|
vconsole?: viteVConsoleOptions
|
|
34
34
|
/** 需要调试的 cookies, 避免无法调试 HttpOnly 的 cookie */
|
|
35
35
|
debugCookies?: string[]
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
chii?: {
|
|
37
|
+
/** 默认值 `true` */
|
|
38
|
+
enable?: boolean
|
|
39
|
+
/**
|
|
40
|
+
* 默认值 `false`
|
|
41
|
+
* @link https://chii.liriliri.io/docs/#usage
|
|
42
|
+
*/
|
|
43
|
+
embedded?: boolean
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
```
|
|
40
47
|
|
package/dist/astro.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
index_default
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-5U7LETMH.js";
|
|
4
|
+
import "./chunk-DZEMXGMI.js";
|
|
5
|
+
import "./chunk-5JBD5THX.js";
|
|
6
6
|
|
|
7
7
|
// src/astro.ts
|
|
8
8
|
var astro_default = (options) => ({
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
__spreadValues
|
|
20
|
+
};
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getChromeDevtoolsHtml
|
|
3
|
+
} from "./chunk-DZEMXGMI.js";
|
|
4
|
+
import {
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "./chunk-5JBD5THX.js";
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
import process2 from "node:process";
|
|
10
|
+
import { ServerResponse } from "node:http";
|
|
11
|
+
import { Socket } from "node:net";
|
|
12
|
+
import { createUnplugin } from "unplugin";
|
|
13
|
+
import c from "picocolors";
|
|
14
|
+
import cookie from "cookie";
|
|
15
|
+
import { start } from "z-chii";
|
|
16
|
+
|
|
17
|
+
// node_modules/.pnpm/get-port-please@3.1.2/node_modules/get-port-please/dist/index.mjs
|
|
18
|
+
import { createServer } from "node:net";
|
|
19
|
+
import { networkInterfaces } from "node:os";
|
|
20
|
+
var unsafePorts = /* @__PURE__ */ new Set([
|
|
21
|
+
1,
|
|
22
|
+
// tcpmux
|
|
23
|
+
7,
|
|
24
|
+
// echo
|
|
25
|
+
9,
|
|
26
|
+
// discard
|
|
27
|
+
11,
|
|
28
|
+
// systat
|
|
29
|
+
13,
|
|
30
|
+
// daytime
|
|
31
|
+
15,
|
|
32
|
+
// netstat
|
|
33
|
+
17,
|
|
34
|
+
// qotd
|
|
35
|
+
19,
|
|
36
|
+
// chargen
|
|
37
|
+
20,
|
|
38
|
+
// ftp data
|
|
39
|
+
21,
|
|
40
|
+
// ftp access
|
|
41
|
+
22,
|
|
42
|
+
// ssh
|
|
43
|
+
23,
|
|
44
|
+
// telnet
|
|
45
|
+
25,
|
|
46
|
+
// smtp
|
|
47
|
+
37,
|
|
48
|
+
// time
|
|
49
|
+
42,
|
|
50
|
+
// name
|
|
51
|
+
43,
|
|
52
|
+
// nicname
|
|
53
|
+
53,
|
|
54
|
+
// domain
|
|
55
|
+
69,
|
|
56
|
+
// tftp
|
|
57
|
+
77,
|
|
58
|
+
// priv-rjs
|
|
59
|
+
79,
|
|
60
|
+
// finger
|
|
61
|
+
87,
|
|
62
|
+
// ttylink
|
|
63
|
+
95,
|
|
64
|
+
// supdup
|
|
65
|
+
101,
|
|
66
|
+
// hostriame
|
|
67
|
+
102,
|
|
68
|
+
// iso-tsap
|
|
69
|
+
103,
|
|
70
|
+
// gppitnp
|
|
71
|
+
104,
|
|
72
|
+
// acr-nema
|
|
73
|
+
109,
|
|
74
|
+
// pop2
|
|
75
|
+
110,
|
|
76
|
+
// pop3
|
|
77
|
+
111,
|
|
78
|
+
// sunrpc
|
|
79
|
+
113,
|
|
80
|
+
// auth
|
|
81
|
+
115,
|
|
82
|
+
// sftp
|
|
83
|
+
117,
|
|
84
|
+
// uucp-path
|
|
85
|
+
119,
|
|
86
|
+
// nntp
|
|
87
|
+
123,
|
|
88
|
+
// NTP
|
|
89
|
+
135,
|
|
90
|
+
// loc-srv /epmap
|
|
91
|
+
137,
|
|
92
|
+
// netbios
|
|
93
|
+
139,
|
|
94
|
+
// netbios
|
|
95
|
+
143,
|
|
96
|
+
// imap2
|
|
97
|
+
161,
|
|
98
|
+
// snmp
|
|
99
|
+
179,
|
|
100
|
+
// BGP
|
|
101
|
+
389,
|
|
102
|
+
// ldap
|
|
103
|
+
427,
|
|
104
|
+
// SLP (Also used by Apple Filing Protocol)
|
|
105
|
+
465,
|
|
106
|
+
// smtp+ssl
|
|
107
|
+
512,
|
|
108
|
+
// print / exec
|
|
109
|
+
513,
|
|
110
|
+
// login
|
|
111
|
+
514,
|
|
112
|
+
// shell
|
|
113
|
+
515,
|
|
114
|
+
// printer
|
|
115
|
+
526,
|
|
116
|
+
// tempo
|
|
117
|
+
530,
|
|
118
|
+
// courier
|
|
119
|
+
531,
|
|
120
|
+
// chat
|
|
121
|
+
532,
|
|
122
|
+
// netnews
|
|
123
|
+
540,
|
|
124
|
+
// uucp
|
|
125
|
+
548,
|
|
126
|
+
// AFP (Apple Filing Protocol)
|
|
127
|
+
554,
|
|
128
|
+
// rtsp
|
|
129
|
+
556,
|
|
130
|
+
// remotefs
|
|
131
|
+
563,
|
|
132
|
+
// nntp+ssl
|
|
133
|
+
587,
|
|
134
|
+
// smtp (rfc6409)
|
|
135
|
+
601,
|
|
136
|
+
// syslog-conn (rfc3195)
|
|
137
|
+
636,
|
|
138
|
+
// ldap+ssl
|
|
139
|
+
989,
|
|
140
|
+
// ftps-data
|
|
141
|
+
990,
|
|
142
|
+
// ftps
|
|
143
|
+
993,
|
|
144
|
+
// ldap+ssl
|
|
145
|
+
995,
|
|
146
|
+
// pop3+ssl
|
|
147
|
+
1719,
|
|
148
|
+
// h323gatestat
|
|
149
|
+
1720,
|
|
150
|
+
// h323hostcall
|
|
151
|
+
1723,
|
|
152
|
+
// pptp
|
|
153
|
+
2049,
|
|
154
|
+
// nfs
|
|
155
|
+
3659,
|
|
156
|
+
// apple-sasl / PasswordServer
|
|
157
|
+
4045,
|
|
158
|
+
// lockd
|
|
159
|
+
5060,
|
|
160
|
+
// sip
|
|
161
|
+
5061,
|
|
162
|
+
// sips
|
|
163
|
+
6e3,
|
|
164
|
+
// X11
|
|
165
|
+
6566,
|
|
166
|
+
// sane-port
|
|
167
|
+
6665,
|
|
168
|
+
// Alternate IRC [Apple addition]
|
|
169
|
+
6666,
|
|
170
|
+
// Alternate IRC [Apple addition]
|
|
171
|
+
6667,
|
|
172
|
+
// Standard IRC [Apple addition]
|
|
173
|
+
6668,
|
|
174
|
+
// Alternate IRC [Apple addition]
|
|
175
|
+
6669,
|
|
176
|
+
// Alternate IRC [Apple addition]
|
|
177
|
+
6697,
|
|
178
|
+
// IRC + TLS
|
|
179
|
+
10080
|
|
180
|
+
// Amanda
|
|
181
|
+
]);
|
|
182
|
+
function isUnsafePort(port) {
|
|
183
|
+
return unsafePorts.has(port);
|
|
184
|
+
}
|
|
185
|
+
function isSafePort(port) {
|
|
186
|
+
return !isUnsafePort(port);
|
|
187
|
+
}
|
|
188
|
+
var __defProp = Object.defineProperty;
|
|
189
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
190
|
+
var __publicField = (obj, key, value) => {
|
|
191
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
192
|
+
return value;
|
|
193
|
+
};
|
|
194
|
+
var GetPortError = class extends Error {
|
|
195
|
+
constructor(message, opts) {
|
|
196
|
+
super(message, opts);
|
|
197
|
+
this.message = message;
|
|
198
|
+
__publicField(this, "name", "GetPortError");
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
function _log(verbose, message) {
|
|
202
|
+
if (verbose) {
|
|
203
|
+
console.log(`[get-port] ${message}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function _tryPort(port, host) {
|
|
207
|
+
return new Promise((resolve) => {
|
|
208
|
+
const server = createServer();
|
|
209
|
+
server.unref();
|
|
210
|
+
server.on("error", () => {
|
|
211
|
+
resolve(false);
|
|
212
|
+
});
|
|
213
|
+
server.listen({ port, host }, () => {
|
|
214
|
+
const { port: port2 } = server.address();
|
|
215
|
+
server.close(() => {
|
|
216
|
+
resolve(isSafePort(port2) && port2);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function _getLocalHosts(additional) {
|
|
222
|
+
const hosts = new Set(additional);
|
|
223
|
+
for (const _interface of Object.values(networkInterfaces())) {
|
|
224
|
+
for (const config2 of _interface || []) {
|
|
225
|
+
if (config2.address && !config2.internal && !config2.address.startsWith("fe80::")) {
|
|
226
|
+
hosts.add(config2.address);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return [...hosts];
|
|
231
|
+
}
|
|
232
|
+
function _fmtOnHost(hostname) {
|
|
233
|
+
return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
|
|
234
|
+
}
|
|
235
|
+
var HOSTNAME_RE = new RegExp("^(?!-)[\\d.:A-Za-z-]{1,63}(?<!-)$");
|
|
236
|
+
async function getRandomPort(host) {
|
|
237
|
+
const port = await checkPort(0, host);
|
|
238
|
+
if (port === false) {
|
|
239
|
+
throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
|
|
240
|
+
}
|
|
241
|
+
return port;
|
|
242
|
+
}
|
|
243
|
+
async function checkPort(port, host = process.env.HOST, verbose) {
|
|
244
|
+
if (!host) {
|
|
245
|
+
host = _getLocalHosts([void 0, "0.0.0.0"]);
|
|
246
|
+
}
|
|
247
|
+
if (!Array.isArray(host)) {
|
|
248
|
+
return _tryPort(port, host);
|
|
249
|
+
}
|
|
250
|
+
for (const _host of host) {
|
|
251
|
+
const _port = await _tryPort(port, _host);
|
|
252
|
+
if (_port === false) {
|
|
253
|
+
if (port < 1024 && verbose) {
|
|
254
|
+
_log(
|
|
255
|
+
verbose,
|
|
256
|
+
`Unable to listen to the privileged port ${port} ${_fmtOnHost(
|
|
257
|
+
_host
|
|
258
|
+
)}`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
if (port === 0 && _port !== 0) {
|
|
264
|
+
port = _port;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return port;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/index.ts
|
|
271
|
+
import httpProxy from "http-proxy";
|
|
272
|
+
var cwd = process2.cwd();
|
|
273
|
+
var config;
|
|
274
|
+
var colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
275
|
+
var resovedInfo = {
|
|
276
|
+
availablePort: void 0,
|
|
277
|
+
targetURL: void 0
|
|
278
|
+
};
|
|
279
|
+
var unpluginFactory = (options) => {
|
|
280
|
+
const {
|
|
281
|
+
chii
|
|
282
|
+
} = options || {};
|
|
283
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
284
|
+
function debug(...args) {
|
|
285
|
+
if (options == null ? void 0 : options.debug) {
|
|
286
|
+
console.log(` ${c.yellow("DEBUG")} `, ...args);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const unpluginDing = {
|
|
290
|
+
name: "unplugin-dingtalk",
|
|
291
|
+
enforce: "pre",
|
|
292
|
+
transformInclude(id) {
|
|
293
|
+
return (id.endsWith("main.ts") || id.endsWith("main.js")) && !id.includes("node_modules");
|
|
294
|
+
},
|
|
295
|
+
async transform(_source) {
|
|
296
|
+
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
297
|
+
resovedInfo.availablePort = await getRandomPort();
|
|
298
|
+
start({
|
|
299
|
+
port: resovedInfo.availablePort
|
|
300
|
+
});
|
|
301
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
code: _source,
|
|
305
|
+
map: null
|
|
306
|
+
// support source map
|
|
307
|
+
};
|
|
308
|
+
},
|
|
309
|
+
vite: {
|
|
310
|
+
configResolved(_config) {
|
|
311
|
+
config = _config;
|
|
312
|
+
},
|
|
313
|
+
transformIndexHtml(html) {
|
|
314
|
+
var _a;
|
|
315
|
+
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
316
|
+
return html.replace(
|
|
317
|
+
"</body>",
|
|
318
|
+
`</body>
|
|
319
|
+
<script>
|
|
320
|
+
(() => {
|
|
321
|
+
const script = document.createElement('script');
|
|
322
|
+
script.src="/__chii_proxy/target.js";
|
|
323
|
+
${((_a = options == null ? void 0 : options.chii) == null ? void 0 : _a.embedded) ? 'script.setAttribute("embedded", "true");' : ""}
|
|
324
|
+
document.body.appendChild(script);
|
|
325
|
+
})()
|
|
326
|
+
</script>
|
|
327
|
+
`
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
async configureServer(server) {
|
|
332
|
+
var _a, _b;
|
|
333
|
+
if (!(options == null ? void 0 : options.enable)) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const _printUrls = server.printUrls.bind(server);
|
|
337
|
+
let source = `localhost:${config.server.port || 5173}`;
|
|
338
|
+
const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
|
|
339
|
+
if (url) {
|
|
340
|
+
const u = new URL(url);
|
|
341
|
+
source = u.host;
|
|
342
|
+
}
|
|
343
|
+
const base = server.config.base || "/";
|
|
344
|
+
const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
|
|
345
|
+
server.printUrls = () => {
|
|
346
|
+
_printUrls();
|
|
347
|
+
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
348
|
+
"Open in dingtalk"
|
|
349
|
+
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
350
|
+
if (enableChii) {
|
|
351
|
+
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
352
|
+
"Click to open chrome devtools"
|
|
353
|
+
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const targetURL = new URL(_targetUrl);
|
|
357
|
+
targetURL.searchParams.append("ddtab", "true");
|
|
358
|
+
if (options == null ? void 0 : options.corpId) {
|
|
359
|
+
targetURL.searchParams.append("corpId", options.corpId);
|
|
360
|
+
}
|
|
361
|
+
if (options.debugCookies && options.debugCookies.length > 0) {
|
|
362
|
+
server.middlewares.use((req, res, next) => {
|
|
363
|
+
const cookies = cookie.parse(req.headers.cookie || "");
|
|
364
|
+
for (const [name, value] of Object.entries(cookies)) {
|
|
365
|
+
if (value && options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
366
|
+
const serializedCookie = cookie.serialize(name, value, {
|
|
367
|
+
httpOnly: false
|
|
368
|
+
});
|
|
369
|
+
res.setHeader("Set-Cookie", serializedCookie);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
next();
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (enableChii) {
|
|
376
|
+
let createProxyMiddleware2 = function() {
|
|
377
|
+
let proxy = null;
|
|
378
|
+
const handleUpgrade = (req, socket, head) => {
|
|
379
|
+
var _a2;
|
|
380
|
+
if (proxy && ((_a2 = req.url) == null ? void 0 : _a2.startsWith("/__chii_proxy"))) {
|
|
381
|
+
debug("WS upgrade:", req.url);
|
|
382
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
383
|
+
proxy.ws(req, socket, head);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
return (resolvedInfo) => {
|
|
387
|
+
return (req, res, next) => {
|
|
388
|
+
var _a2;
|
|
389
|
+
if (!proxy && resolvedInfo.availablePort) {
|
|
390
|
+
proxy = httpProxy.createProxyServer({
|
|
391
|
+
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
392
|
+
ws: true
|
|
393
|
+
// changeOrigin: true, // Consider if you need this
|
|
394
|
+
});
|
|
395
|
+
proxy.on("error", (err, req2, res2) => {
|
|
396
|
+
console.error("Proxy error:", err);
|
|
397
|
+
if (res2 instanceof ServerResponse) {
|
|
398
|
+
if (!res2.headersSent) {
|
|
399
|
+
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
400
|
+
}
|
|
401
|
+
res2.end(`Proxy error: ${err.message}`);
|
|
402
|
+
} else if (res2 instanceof Socket) {
|
|
403
|
+
res2.destroy();
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
if (req.socket.server) {
|
|
407
|
+
req.socket.server.on("upgrade", handleUpgrade);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (proxy && ((_a2 = req.url) == null ? void 0 : _a2.startsWith("/__chii_proxy"))) {
|
|
411
|
+
debug(req.url);
|
|
412
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
413
|
+
proxy.web(req, res);
|
|
414
|
+
} else {
|
|
415
|
+
next();
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
var createProxyMiddleware = createProxyMiddleware2;
|
|
421
|
+
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
422
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
423
|
+
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
|
|
424
|
+
res.end();
|
|
425
|
+
});
|
|
426
|
+
const proxyMiddleware = createProxyMiddleware2();
|
|
427
|
+
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
428
|
+
}
|
|
429
|
+
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
430
|
+
debug(targetURL.toString());
|
|
431
|
+
res.writeHead(302, {
|
|
432
|
+
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
433
|
+
});
|
|
434
|
+
res.end();
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
webpack(compiler) {
|
|
439
|
+
var _a, _b;
|
|
440
|
+
if (!(options == null ? void 0 : options.enable)) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const devServerOptions = __spreadValues(__spreadValues({
|
|
444
|
+
host: "localhost",
|
|
445
|
+
port: 8080
|
|
446
|
+
}, compiler.options.devServer), (_a = process2.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
447
|
+
const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
|
|
448
|
+
const base = compiler.options.output.publicPath || "/";
|
|
449
|
+
const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
|
|
450
|
+
compiler.hooks.done.tap("unplugin-dingtalk", () => {
|
|
451
|
+
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
452
|
+
"Open in dingtalk"
|
|
453
|
+
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
454
|
+
if (enableChii) {
|
|
455
|
+
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
456
|
+
"Click to open chrome devtools"
|
|
457
|
+
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
resovedInfo.targetURL = new URL(_targetUrl);
|
|
461
|
+
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
462
|
+
if (options == null ? void 0 : options.corpId) {
|
|
463
|
+
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
async rspack(compiler) {
|
|
467
|
+
var _a, _b, _c, _d;
|
|
468
|
+
if (!(options == null ? void 0 : options.enable)) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const devServerOptions = __spreadValues(__spreadValues({
|
|
472
|
+
host: "localhost",
|
|
473
|
+
port: 8080
|
|
474
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
475
|
+
cwd
|
|
476
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
477
|
+
const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
|
|
478
|
+
const base = compiler.options.output.publicPath || "/";
|
|
479
|
+
const _targetUrl = (_d = options == null ? void 0 : options.targetUrl) != null ? _d : `http://${source}${base}`;
|
|
480
|
+
resovedInfo.targetURL = new URL(_targetUrl);
|
|
481
|
+
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
482
|
+
if (options == null ? void 0 : options.corpId) {
|
|
483
|
+
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
484
|
+
}
|
|
485
|
+
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
486
|
+
"Open in dingtalk"
|
|
487
|
+
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
488
|
+
if (enableChii) {
|
|
489
|
+
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
490
|
+
"Click to open chrome devtools"
|
|
491
|
+
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
return unpluginDing;
|
|
496
|
+
};
|
|
497
|
+
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
498
|
+
var index_default = unplugin;
|
|
499
|
+
|
|
500
|
+
export {
|
|
501
|
+
resovedInfo,
|
|
502
|
+
unpluginFactory,
|
|
503
|
+
unplugin,
|
|
504
|
+
index_default
|
|
505
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/__chrome_devtools.ts
|
|
2
|
+
function getChromeDevtoolsHtml(targetPort) {
|
|
3
|
+
return `<!DOCTYPE html>
|
|
4
|
+
<html>
|
|
5
|
+
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="utf-8">
|
|
8
|
+
<title>DevTools Targets</title>
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
font-family: sans-serif;
|
|
12
|
+
padding: 2em;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
ul {
|
|
16
|
+
padding: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
li {
|
|
20
|
+
margin-bottom: 1.2em;
|
|
21
|
+
list-style: none;
|
|
22
|
+
line-height: 1.5;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
a.button {
|
|
26
|
+
display: inline-block;
|
|
27
|
+
background: #409eff;
|
|
28
|
+
color: #fff;
|
|
29
|
+
padding: 0.2em 0.5em;
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
border-radius: 4px;
|
|
32
|
+
margin-top: 0.5em;
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
a.button:hover {
|
|
37
|
+
background: #66b1ff;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#refresh {
|
|
41
|
+
margin-bottom: 1.5em;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
44
|
+
</head>
|
|
45
|
+
|
|
46
|
+
<body>
|
|
47
|
+
<h2>\u53EF\u7528 DevTools Targets</h2><button id="refresh">\u5237\u65B0</button>
|
|
48
|
+
<ul id="target-list">
|
|
49
|
+
<li>\u52A0\u8F7D\u4E2D...</li>
|
|
50
|
+
</ul>
|
|
51
|
+
<script>
|
|
52
|
+
async function fetchTargets() {
|
|
53
|
+
const list = document.getElementById("target-list");
|
|
54
|
+
list.innerHTML = "<li>\u52A0\u8F7D\u4E2D...</li>";
|
|
55
|
+
try {
|
|
56
|
+
const resp = await fetch("/__chii_proxy/targets");
|
|
57
|
+
const data = await resp.json();
|
|
58
|
+
const targets = data.targets || [];
|
|
59
|
+
if (targets.length === 0) {
|
|
60
|
+
list.innerHTML = "<li>\u6682\u65E0\u53EF\u7528\u7684\u8C03\u8BD5\u76EE\u6807\u3002</li>";
|
|
61
|
+
} else {
|
|
62
|
+
list.innerHTML = "";
|
|
63
|
+
for (const target of targets) {
|
|
64
|
+
console.log(target)
|
|
65
|
+
const devToolsUrl = "http://localhost:${targetPort}/front_end/chii_app.html?ws=localhost:${targetPort}/client/" + Math.random().toString(20).substring(2, 8) + "?target=" + encodeURIComponent(target.id) + "&rtc=false";
|
|
66
|
+
const item = document.createElement("li");
|
|
67
|
+
item.innerHTML =
|
|
68
|
+
"<div><strong>" + (target.title) + "</strong></div>" +
|
|
69
|
+
"<div>URL: " + (target.url || "") + "</div>" +
|
|
70
|
+
"<div>UA: <code>" + (target.userAgent || "unknown") + "</code></div>" +
|
|
71
|
+
"<a href='" + devToolsUrl + "' target='_blank' class='button'>\u6253\u5F00\u8C03\u8BD5</a>";
|
|
72
|
+
list.appendChild(item);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
list.innerHTML = "<li>\u83B7\u53D6\u8C03\u8BD5\u76EE\u6807\u5931\u8D25</li>";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
document.getElementById("refresh").onclick = fetchTargets;
|
|
80
|
+
window.onload = fetchTargets;
|
|
81
|
+
document.addEventListener('visibilitychange', fetchTargets);
|
|
82
|
+
</script>
|
|
83
|
+
</body>
|
|
84
|
+
|
|
85
|
+
</html>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
getChromeDevtoolsHtml
|
|
90
|
+
};
|
package/dist/esbuild.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unpluginFactory
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-5U7LETMH.js";
|
|
4
|
+
import "./chunk-DZEMXGMI.js";
|
|
5
|
+
import "./chunk-5JBD5THX.js";
|
|
6
6
|
|
|
7
7
|
// src/esbuild.ts
|
|
8
8
|
import { createEsbuildPlugin } from "unplugin";
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
resovedInfo,
|
|
4
4
|
unplugin,
|
|
5
5
|
unpluginFactory
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-5U7LETMH.js";
|
|
7
|
+
import "./chunk-DZEMXGMI.js";
|
|
8
|
+
import "./chunk-5JBD5THX.js";
|
|
9
9
|
export {
|
|
10
10
|
index_default as default,
|
|
11
11
|
resovedInfo,
|