unplugin-dingtalk 1006.0.0 → 1007.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/dist/{chunk-2YQKM4BX.js → __chrome_devtools-CIQ5zFZx.js} +11 -12
- package/dist/__chrome_devtools-CJ3sXpVj.cjs +95 -0
- package/dist/__chrome_devtools.cjs +2 -114
- package/dist/__chrome_devtools.d.cts +3 -2
- package/dist/__chrome_devtools.d.ts +3 -2
- package/dist/__chrome_devtools.js +3 -7
- package/dist/astro.cjs +12 -676
- package/dist/astro.d.cts +7 -10
- package/dist/astro.d.ts +8 -10
- package/dist/astro.js +12 -17
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/esbuild.cjs +9 -667
- package/dist/esbuild.d.cts +5 -8
- package/dist/esbuild.d.ts +6 -8
- package/dist/esbuild.js +8 -10
- package/dist/index.cjs +10 -676
- package/dist/index.d.cts +11 -13
- package/dist/index.d.ts +11 -13
- package/dist/index.js +5 -16
- package/dist/inject-script.cjs +15 -0
- package/dist/inject-script.d.cts +3 -0
- package/dist/inject-script.d.ts +4 -0
- package/dist/inject-script.js +14 -0
- package/dist/main-BvTybYko.js +99 -0
- package/dist/main-DQgEHuwp.cjs +101 -0
- package/dist/nuxt.cjs +459 -825
- package/dist/nuxt.d.cts +7 -10
- package/dist/nuxt.d.ts +7 -10
- package/dist/nuxt.js +474 -24
- package/dist/rollup.cjs +9 -667
- package/dist/rollup.d.cts +5 -8
- package/dist/rollup.d.ts +6 -8
- package/dist/rollup.js +8 -10
- package/dist/rspack.cjs +54 -728
- package/dist/rspack.d.cts +5 -8
- package/dist/rspack.d.ts +6 -8
- package/dist/rspack.js +50 -74
- package/dist/src-BVX_Roo9.js +364 -0
- package/dist/src-hLDO4Q22.cjs +394 -0
- package/dist/types-D6mfGNG_.d.ts +38 -0
- package/dist/types-DodDHiEA.d.cts +38 -0
- package/dist/types.cjs +0 -19
- package/dist/types.d.cts +2 -38
- package/dist/types.d.ts +2 -38
- package/dist/types.js +1 -0
- package/dist/utils-Chlbb6jf.js +23 -0
- package/dist/utils-CmfBxo4J.cjs +41 -0
- package/dist/utils.cjs +4 -33
- package/dist/utils.d.cts +6 -3
- package/dist/utils.d.ts +6 -3
- package/dist/utils.js +3 -7
- package/dist/vite-CKIDsKJ-.cjs +24 -0
- package/dist/vite-DoBUfGyY.js +18 -0
- package/dist/vite.cjs +5 -824
- package/dist/vite.d.cts +4 -7
- package/dist/vite.d.ts +5 -7
- package/dist/vite.js +6 -10
- package/dist/webpack.cjs +52 -722
- package/dist/webpack.d.cts +5 -8
- package/dist/webpack.d.ts +6 -8
- package/dist/webpack.js +48 -68
- package/package.json +12 -10
- package/dist/chunk-5JBD5THX.js +0 -20
- package/dist/chunk-EG2ZYJ3S.js +0 -542
- package/dist/chunk-KQOHODTC.js +0 -9
- package/dist/chunk-LMNMIIAV.js +0 -26
- package/dist/main-Q4R5NCQC.js +0 -129
package/dist/esbuild.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "./chunk-2YQKM4BX.js";
|
|
5
|
-
import "./chunk-5JBD5THX.js";
|
|
6
|
-
|
|
7
|
-
// src/esbuild.ts
|
|
1
|
+
import "./__chrome_devtools-CIQ5zFZx.js";
|
|
2
|
+
import { unpluginFactory } from "./src-BVX_Roo9.js";
|
|
3
|
+
import "./utils-Chlbb6jf.js";
|
|
8
4
|
import { createEsbuildPlugin } from "unplugin";
|
|
5
|
+
|
|
6
|
+
//#region src/esbuild.ts
|
|
9
7
|
var esbuild_default = createEsbuildPlugin(unpluginFactory);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { esbuild_default as default };
|
package/dist/index.cjs
CHANGED
|
@@ -1,676 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let key of __getOwnPropNames(from))
|
|
29
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
-
}
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
-
mod
|
|
41
|
-
));
|
|
42
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
-
|
|
44
|
-
// src/index.ts
|
|
45
|
-
var index_exports = {};
|
|
46
|
-
__export(index_exports, {
|
|
47
|
-
createProxyMiddleware: () => createProxyMiddleware,
|
|
48
|
-
default: () => index_default,
|
|
49
|
-
resovedInfo: () => resovedInfo,
|
|
50
|
-
unplugin: () => unplugin,
|
|
51
|
-
unpluginFactory: () => unpluginFactory
|
|
52
|
-
});
|
|
53
|
-
module.exports = __toCommonJS(index_exports);
|
|
54
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
55
|
-
var import_node_http = require("http");
|
|
56
|
-
var import_node_net2 = require("net");
|
|
57
|
-
var import_unplugin = require("unplugin");
|
|
58
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
59
|
-
var import_cookie = __toESM(require("cookie"), 1);
|
|
60
|
-
var import_z_chii = require("z-chii");
|
|
61
|
-
|
|
62
|
-
// node_modules/.pnpm/get-port-please@3.1.2/node_modules/get-port-please/dist/index.mjs
|
|
63
|
-
var import_node_net = require("net");
|
|
64
|
-
var import_node_os = require("os");
|
|
65
|
-
var unsafePorts = /* @__PURE__ */ new Set([
|
|
66
|
-
1,
|
|
67
|
-
// tcpmux
|
|
68
|
-
7,
|
|
69
|
-
// echo
|
|
70
|
-
9,
|
|
71
|
-
// discard
|
|
72
|
-
11,
|
|
73
|
-
// systat
|
|
74
|
-
13,
|
|
75
|
-
// daytime
|
|
76
|
-
15,
|
|
77
|
-
// netstat
|
|
78
|
-
17,
|
|
79
|
-
// qotd
|
|
80
|
-
19,
|
|
81
|
-
// chargen
|
|
82
|
-
20,
|
|
83
|
-
// ftp data
|
|
84
|
-
21,
|
|
85
|
-
// ftp access
|
|
86
|
-
22,
|
|
87
|
-
// ssh
|
|
88
|
-
23,
|
|
89
|
-
// telnet
|
|
90
|
-
25,
|
|
91
|
-
// smtp
|
|
92
|
-
37,
|
|
93
|
-
// time
|
|
94
|
-
42,
|
|
95
|
-
// name
|
|
96
|
-
43,
|
|
97
|
-
// nicname
|
|
98
|
-
53,
|
|
99
|
-
// domain
|
|
100
|
-
69,
|
|
101
|
-
// tftp
|
|
102
|
-
77,
|
|
103
|
-
// priv-rjs
|
|
104
|
-
79,
|
|
105
|
-
// finger
|
|
106
|
-
87,
|
|
107
|
-
// ttylink
|
|
108
|
-
95,
|
|
109
|
-
// supdup
|
|
110
|
-
101,
|
|
111
|
-
// hostriame
|
|
112
|
-
102,
|
|
113
|
-
// iso-tsap
|
|
114
|
-
103,
|
|
115
|
-
// gppitnp
|
|
116
|
-
104,
|
|
117
|
-
// acr-nema
|
|
118
|
-
109,
|
|
119
|
-
// pop2
|
|
120
|
-
110,
|
|
121
|
-
// pop3
|
|
122
|
-
111,
|
|
123
|
-
// sunrpc
|
|
124
|
-
113,
|
|
125
|
-
// auth
|
|
126
|
-
115,
|
|
127
|
-
// sftp
|
|
128
|
-
117,
|
|
129
|
-
// uucp-path
|
|
130
|
-
119,
|
|
131
|
-
// nntp
|
|
132
|
-
123,
|
|
133
|
-
// NTP
|
|
134
|
-
135,
|
|
135
|
-
// loc-srv /epmap
|
|
136
|
-
137,
|
|
137
|
-
// netbios
|
|
138
|
-
139,
|
|
139
|
-
// netbios
|
|
140
|
-
143,
|
|
141
|
-
// imap2
|
|
142
|
-
161,
|
|
143
|
-
// snmp
|
|
144
|
-
179,
|
|
145
|
-
// BGP
|
|
146
|
-
389,
|
|
147
|
-
// ldap
|
|
148
|
-
427,
|
|
149
|
-
// SLP (Also used by Apple Filing Protocol)
|
|
150
|
-
465,
|
|
151
|
-
// smtp+ssl
|
|
152
|
-
512,
|
|
153
|
-
// print / exec
|
|
154
|
-
513,
|
|
155
|
-
// login
|
|
156
|
-
514,
|
|
157
|
-
// shell
|
|
158
|
-
515,
|
|
159
|
-
// printer
|
|
160
|
-
526,
|
|
161
|
-
// tempo
|
|
162
|
-
530,
|
|
163
|
-
// courier
|
|
164
|
-
531,
|
|
165
|
-
// chat
|
|
166
|
-
532,
|
|
167
|
-
// netnews
|
|
168
|
-
540,
|
|
169
|
-
// uucp
|
|
170
|
-
548,
|
|
171
|
-
// AFP (Apple Filing Protocol)
|
|
172
|
-
554,
|
|
173
|
-
// rtsp
|
|
174
|
-
556,
|
|
175
|
-
// remotefs
|
|
176
|
-
563,
|
|
177
|
-
// nntp+ssl
|
|
178
|
-
587,
|
|
179
|
-
// smtp (rfc6409)
|
|
180
|
-
601,
|
|
181
|
-
// syslog-conn (rfc3195)
|
|
182
|
-
636,
|
|
183
|
-
// ldap+ssl
|
|
184
|
-
989,
|
|
185
|
-
// ftps-data
|
|
186
|
-
990,
|
|
187
|
-
// ftps
|
|
188
|
-
993,
|
|
189
|
-
// ldap+ssl
|
|
190
|
-
995,
|
|
191
|
-
// pop3+ssl
|
|
192
|
-
1719,
|
|
193
|
-
// h323gatestat
|
|
194
|
-
1720,
|
|
195
|
-
// h323hostcall
|
|
196
|
-
1723,
|
|
197
|
-
// pptp
|
|
198
|
-
2049,
|
|
199
|
-
// nfs
|
|
200
|
-
3659,
|
|
201
|
-
// apple-sasl / PasswordServer
|
|
202
|
-
4045,
|
|
203
|
-
// lockd
|
|
204
|
-
5060,
|
|
205
|
-
// sip
|
|
206
|
-
5061,
|
|
207
|
-
// sips
|
|
208
|
-
6e3,
|
|
209
|
-
// X11
|
|
210
|
-
6566,
|
|
211
|
-
// sane-port
|
|
212
|
-
6665,
|
|
213
|
-
// Alternate IRC [Apple addition]
|
|
214
|
-
6666,
|
|
215
|
-
// Alternate IRC [Apple addition]
|
|
216
|
-
6667,
|
|
217
|
-
// Standard IRC [Apple addition]
|
|
218
|
-
6668,
|
|
219
|
-
// Alternate IRC [Apple addition]
|
|
220
|
-
6669,
|
|
221
|
-
// Alternate IRC [Apple addition]
|
|
222
|
-
6697,
|
|
223
|
-
// IRC + TLS
|
|
224
|
-
10080
|
|
225
|
-
// Amanda
|
|
226
|
-
]);
|
|
227
|
-
function isUnsafePort(port) {
|
|
228
|
-
return unsafePorts.has(port);
|
|
229
|
-
}
|
|
230
|
-
function isSafePort(port) {
|
|
231
|
-
return !isUnsafePort(port);
|
|
232
|
-
}
|
|
233
|
-
var __defProp2 = Object.defineProperty;
|
|
234
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
235
|
-
var __publicField = (obj, key, value) => {
|
|
236
|
-
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
237
|
-
return value;
|
|
238
|
-
};
|
|
239
|
-
var GetPortError = class extends Error {
|
|
240
|
-
constructor(message, opts) {
|
|
241
|
-
super(message, opts);
|
|
242
|
-
this.message = message;
|
|
243
|
-
__publicField(this, "name", "GetPortError");
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
function _log(verbose, message) {
|
|
247
|
-
if (verbose) {
|
|
248
|
-
console.log(`[get-port] ${message}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function _tryPort(port, host) {
|
|
252
|
-
return new Promise((resolve) => {
|
|
253
|
-
const server = (0, import_node_net.createServer)();
|
|
254
|
-
server.unref();
|
|
255
|
-
server.on("error", () => {
|
|
256
|
-
resolve(false);
|
|
257
|
-
});
|
|
258
|
-
server.listen({ port, host }, () => {
|
|
259
|
-
const { port: port2 } = server.address();
|
|
260
|
-
server.close(() => {
|
|
261
|
-
resolve(isSafePort(port2) && port2);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
function _getLocalHosts(additional) {
|
|
267
|
-
const hosts = new Set(additional);
|
|
268
|
-
for (const _interface of Object.values((0, import_node_os.networkInterfaces)())) {
|
|
269
|
-
for (const config2 of _interface || []) {
|
|
270
|
-
if (config2.address && !config2.internal && !config2.address.startsWith("fe80::")) {
|
|
271
|
-
hosts.add(config2.address);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return [...hosts];
|
|
276
|
-
}
|
|
277
|
-
function _fmtOnHost(hostname) {
|
|
278
|
-
return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
|
|
279
|
-
}
|
|
280
|
-
var HOSTNAME_RE = new RegExp("^(?!-)[\\d.:A-Za-z-]{1,63}(?<!-)$");
|
|
281
|
-
async function getRandomPort(host) {
|
|
282
|
-
const port = await checkPort(0, host);
|
|
283
|
-
if (port === false) {
|
|
284
|
-
throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
|
|
285
|
-
}
|
|
286
|
-
return port;
|
|
287
|
-
}
|
|
288
|
-
async function checkPort(port, host = process.env.HOST, verbose) {
|
|
289
|
-
if (!host) {
|
|
290
|
-
host = _getLocalHosts([void 0, "0.0.0.0"]);
|
|
291
|
-
}
|
|
292
|
-
if (!Array.isArray(host)) {
|
|
293
|
-
return _tryPort(port, host);
|
|
294
|
-
}
|
|
295
|
-
for (const _host of host) {
|
|
296
|
-
const _port = await _tryPort(port, _host);
|
|
297
|
-
if (_port === false) {
|
|
298
|
-
if (port < 1024 && verbose) {
|
|
299
|
-
_log(
|
|
300
|
-
verbose,
|
|
301
|
-
`Unable to listen to the privileged port ${port} ${_fmtOnHost(
|
|
302
|
-
_host
|
|
303
|
-
)}`
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
return false;
|
|
307
|
-
}
|
|
308
|
-
if (port === 0 && _port !== 0) {
|
|
309
|
-
port = _port;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return port;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// src/index.ts
|
|
316
|
-
var import_http_proxy = __toESM(require("http-proxy"), 1);
|
|
317
|
-
|
|
318
|
-
// src/__chrome_devtools.ts
|
|
319
|
-
function getChromeDevtoolsHtml(targetPort) {
|
|
320
|
-
return `<!DOCTYPE html>
|
|
321
|
-
<html>
|
|
322
|
-
|
|
323
|
-
<head>
|
|
324
|
-
<meta charset="utf-8">
|
|
325
|
-
<title>DevTools Targets</title>
|
|
326
|
-
<style>
|
|
327
|
-
body {
|
|
328
|
-
font-family: sans-serif;
|
|
329
|
-
padding: 2em;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
ul {
|
|
333
|
-
padding: 0;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
li {
|
|
337
|
-
margin-bottom: 1.2em;
|
|
338
|
-
list-style: none;
|
|
339
|
-
line-height: 1.5;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
a.button {
|
|
343
|
-
display: inline-block;
|
|
344
|
-
background: #409eff;
|
|
345
|
-
color: #fff;
|
|
346
|
-
padding: 0.2em 0.5em;
|
|
347
|
-
text-decoration: none;
|
|
348
|
-
border-radius: 4px;
|
|
349
|
-
margin-top: 0.5em;
|
|
350
|
-
font-size: 14px;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
a.button:hover {
|
|
354
|
-
background: #66b1ff;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
#refresh {
|
|
358
|
-
margin-bottom: 1.5em;
|
|
359
|
-
}
|
|
360
|
-
</style>
|
|
361
|
-
</head>
|
|
362
|
-
|
|
363
|
-
<body>
|
|
364
|
-
<h2>\u53EF\u7528 DevTools Targets</h2><button id="refresh">\u5237\u65B0</button>
|
|
365
|
-
<ul id="target-list">
|
|
366
|
-
<li>\u52A0\u8F7D\u4E2D...</li>
|
|
367
|
-
</ul>
|
|
368
|
-
<script>
|
|
369
|
-
async function fetchTargets() {
|
|
370
|
-
const list = document.getElementById("target-list");
|
|
371
|
-
list.innerHTML = "<li>\u52A0\u8F7D\u4E2D...</li>";
|
|
372
|
-
try {
|
|
373
|
-
const resp = await fetch("/__chii_proxy/targets");
|
|
374
|
-
const data = await resp.json();
|
|
375
|
-
const targets = data.targets || [];
|
|
376
|
-
if (targets.length === 0) {
|
|
377
|
-
list.innerHTML = "<li>\u6682\u65E0\u53EF\u7528\u7684\u8C03\u8BD5\u76EE\u6807\u3002</li>";
|
|
378
|
-
} else {
|
|
379
|
-
list.innerHTML = "";
|
|
380
|
-
for (const target of targets) {
|
|
381
|
-
console.log(target)
|
|
382
|
-
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";
|
|
383
|
-
const item = document.createElement("li");
|
|
384
|
-
item.innerHTML =
|
|
385
|
-
"<div><strong>" + (target.title) + "</strong></div>" +
|
|
386
|
-
"<div>URL: " + (target.url || "") + "</div>" +
|
|
387
|
-
"<div>UA: <code>" + (target.userAgent || "unknown") + "</code></div>" +
|
|
388
|
-
"<a href='" + devToolsUrl + "' target='_blank' class='button'>\u6253\u5F00\u8C03\u8BD5</a>";
|
|
389
|
-
list.appendChild(item);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
} catch (e) {
|
|
393
|
-
list.innerHTML = "<li>\u83B7\u53D6\u8C03\u8BD5\u76EE\u6807\u5931\u8D25</li>";
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
document.getElementById("refresh").onclick = () => window.location.reload();
|
|
397
|
-
window.onload = fetchTargets;
|
|
398
|
-
document.addEventListener('visibilitychange', window.location.reload);
|
|
399
|
-
</script>
|
|
400
|
-
</body>
|
|
401
|
-
|
|
402
|
-
</html>`;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// src/index.ts
|
|
406
|
-
var cwd = import_node_process.default.cwd();
|
|
407
|
-
var config;
|
|
408
|
-
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
409
|
-
var resovedInfo = {
|
|
410
|
-
availablePort: void 0,
|
|
411
|
-
targetURL: void 0
|
|
412
|
-
};
|
|
413
|
-
function createProxyMiddleware(debug) {
|
|
414
|
-
let proxy = null;
|
|
415
|
-
const handleUpgrade = (req, socket, head) => {
|
|
416
|
-
var _a;
|
|
417
|
-
if (proxy && ((_a = req.url) == null ? void 0 : _a.startsWith("/__chii_proxy"))) {
|
|
418
|
-
debug("WS upgrade:", req.url);
|
|
419
|
-
req.url = req.url.replace("/__chii_proxy", "");
|
|
420
|
-
proxy.ws(req, socket, head);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
return (resolvedInfo) => {
|
|
424
|
-
return (req, res, next) => {
|
|
425
|
-
var _a;
|
|
426
|
-
if (!proxy && resolvedInfo.availablePort) {
|
|
427
|
-
proxy = import_http_proxy.default.createProxyServer({
|
|
428
|
-
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
429
|
-
ws: true
|
|
430
|
-
});
|
|
431
|
-
proxy.on("error", (err, req2, res2) => {
|
|
432
|
-
console.error("Proxy error:", err);
|
|
433
|
-
if (res2 instanceof import_node_http.ServerResponse) {
|
|
434
|
-
if (!res2.headersSent) {
|
|
435
|
-
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
436
|
-
}
|
|
437
|
-
res2.end(`Proxy error: ${err.message}`);
|
|
438
|
-
} else if (res2 instanceof import_node_net2.Socket) {
|
|
439
|
-
res2.destroy();
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
if (req.socket.server) {
|
|
443
|
-
req.socket.server.on("upgrade", handleUpgrade);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (proxy && ((_a = req.url) == null ? void 0 : _a.startsWith("/__chii_proxy"))) {
|
|
447
|
-
debug(req.url);
|
|
448
|
-
req.url = req.url.replace("/__chii_proxy", "");
|
|
449
|
-
proxy.web(req, res);
|
|
450
|
-
} else {
|
|
451
|
-
next();
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
var unpluginFactory = (options) => {
|
|
457
|
-
const {
|
|
458
|
-
chii
|
|
459
|
-
} = options || {};
|
|
460
|
-
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
461
|
-
function debug(...args) {
|
|
462
|
-
if (options == null ? void 0 : options.debug) {
|
|
463
|
-
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
const unpluginDing = {
|
|
467
|
-
name: "unplugin-dingtalk",
|
|
468
|
-
enforce: "pre",
|
|
469
|
-
resolveId(source) {
|
|
470
|
-
if (source === "chii-client") {
|
|
471
|
-
return source;
|
|
472
|
-
}
|
|
473
|
-
},
|
|
474
|
-
loadInclude(id) {
|
|
475
|
-
return id === "chii-client";
|
|
476
|
-
},
|
|
477
|
-
load(id) {
|
|
478
|
-
var _a, _b;
|
|
479
|
-
if (id === "chii-client") {
|
|
480
|
-
return `
|
|
481
|
-
;(function(){
|
|
482
|
-
if (document.getElementById('__chii_client')) return;
|
|
483
|
-
const script = document.createElement('script');
|
|
484
|
-
script.id = '__chii_client';
|
|
485
|
-
script.src="/__chii_proxy/target.js";
|
|
486
|
-
${((_a = options == null ? void 0 : options.chii) == null ? void 0 : _a.embedded) ? "script.setAttribute('embedded','true');" : ""}
|
|
487
|
-
document.body.appendChild(script);
|
|
488
|
-
})();
|
|
489
|
-
if (import.meta.hot) {
|
|
490
|
-
import.meta.hot.accept(() => {
|
|
491
|
-
const old = document.getElementById('__chii_client');
|
|
492
|
-
if (old) old.remove();
|
|
493
|
-
const script = document.createElement('script');
|
|
494
|
-
script.id = '__chii_client';
|
|
495
|
-
script.src="/__chii_proxy/target.js";
|
|
496
|
-
${((_b = options == null ? void 0 : options.chii) == null ? void 0 : _b.embedded) ? "script.setAttribute('embedded','true');" : ""}
|
|
497
|
-
document.body.appendChild(script);
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
`;
|
|
501
|
-
}
|
|
502
|
-
},
|
|
503
|
-
transformInclude(id) {
|
|
504
|
-
return !!id.split("?")[0].match(/\.[t|j]s$/);
|
|
505
|
-
},
|
|
506
|
-
async transform(source, id) {
|
|
507
|
-
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
508
|
-
resovedInfo.availablePort = await getRandomPort();
|
|
509
|
-
(0, import_z_chii.start)({ port: resovedInfo.availablePort });
|
|
510
|
-
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
511
|
-
}
|
|
512
|
-
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
513
|
-
const file = id.split("?")[0];
|
|
514
|
-
if (file.startsWith((config == null ? void 0 : config.root) || cwd) && !file.includes("node_modules") && file.match(/\.[t|j]s$/)) {
|
|
515
|
-
return {
|
|
516
|
-
code: `import 'chii-client';
|
|
517
|
-
${source}`,
|
|
518
|
-
map: null
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return { code: source, map: null };
|
|
523
|
-
},
|
|
524
|
-
vite: {
|
|
525
|
-
configResolved(_config) {
|
|
526
|
-
config = _config;
|
|
527
|
-
},
|
|
528
|
-
transformIndexHtml(html) {
|
|
529
|
-
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
530
|
-
const tag = `<script type="module">import 'chii-client';</script>`;
|
|
531
|
-
if (!html.includes(tag)) {
|
|
532
|
-
return html.replace(
|
|
533
|
-
"</body>",
|
|
534
|
-
`</body>${tag}
|
|
535
|
-
`
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
return html;
|
|
540
|
-
},
|
|
541
|
-
async configureServer(server) {
|
|
542
|
-
var _a, _b;
|
|
543
|
-
if (!(options == null ? void 0 : options.enable)) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
const _printUrls = server.printUrls.bind(server);
|
|
547
|
-
let source = `localhost:${config.server.port || 5173}`;
|
|
548
|
-
const url = (_a = server.resolvedUrls) == null ? void 0 : _a.local[0];
|
|
549
|
-
if (url) {
|
|
550
|
-
const u = new URL(url);
|
|
551
|
-
source = u.host;
|
|
552
|
-
}
|
|
553
|
-
const base = server.config.base || "/";
|
|
554
|
-
const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
|
|
555
|
-
server.printUrls = () => {
|
|
556
|
-
_printUrls();
|
|
557
|
-
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
558
|
-
"Open in dingtalk"
|
|
559
|
-
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
560
|
-
if (enableChii) {
|
|
561
|
-
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
562
|
-
"Click to open chrome devtools"
|
|
563
|
-
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
const targetURL = new URL(_targetUrl);
|
|
567
|
-
targetURL.searchParams.append("ddtab", "true");
|
|
568
|
-
if (options == null ? void 0 : options.corpId) {
|
|
569
|
-
targetURL.searchParams.append("corpId", options.corpId);
|
|
570
|
-
}
|
|
571
|
-
if (options.debugCookies && options.debugCookies.length > 0) {
|
|
572
|
-
server.middlewares.use((req, res, next) => {
|
|
573
|
-
const cookies = import_cookie.default.parse(req.headers.cookie || "");
|
|
574
|
-
for (const [name, value] of Object.entries(cookies)) {
|
|
575
|
-
if (value && options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
576
|
-
const serializedCookie = import_cookie.default.serialize(name, value, {
|
|
577
|
-
httpOnly: false
|
|
578
|
-
});
|
|
579
|
-
res.setHeader("Set-Cookie", serializedCookie);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
next();
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
if (enableChii) {
|
|
586
|
-
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
587
|
-
if (!resovedInfo.availablePort) {
|
|
588
|
-
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
589
|
-
res.end("Server not started");
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
593
|
-
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
|
|
594
|
-
res.end();
|
|
595
|
-
});
|
|
596
|
-
const proxyMiddleware = createProxyMiddleware(debug);
|
|
597
|
-
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
598
|
-
}
|
|
599
|
-
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
600
|
-
debug(targetURL.toString());
|
|
601
|
-
res.writeHead(302, {
|
|
602
|
-
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
603
|
-
});
|
|
604
|
-
res.end();
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
},
|
|
608
|
-
webpack(compiler) {
|
|
609
|
-
var _a, _b;
|
|
610
|
-
if (!(options == null ? void 0 : options.enable)) {
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
const devServerOptions = __spreadValues(__spreadValues({
|
|
614
|
-
host: "localhost",
|
|
615
|
-
port: 8080
|
|
616
|
-
}, compiler.options.devServer), (_a = import_node_process.default.VUE_CLI_SERVICE) == null ? void 0 : _a.projectOptions.devServer);
|
|
617
|
-
const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
|
|
618
|
-
const base = compiler.options.output.publicPath || "/";
|
|
619
|
-
const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
|
|
620
|
-
compiler.hooks.done.tap("unplugin-dingtalk", () => {
|
|
621
|
-
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
622
|
-
"Open in dingtalk"
|
|
623
|
-
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
624
|
-
if (enableChii) {
|
|
625
|
-
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
626
|
-
"Click to open chrome devtools"
|
|
627
|
-
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
resovedInfo.targetURL = new URL(_targetUrl);
|
|
631
|
-
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
632
|
-
if (options == null ? void 0 : options.corpId) {
|
|
633
|
-
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
634
|
-
}
|
|
635
|
-
},
|
|
636
|
-
async rspack(compiler) {
|
|
637
|
-
var _a, _b, _c, _d;
|
|
638
|
-
if (!(options == null ? void 0 : options.enable)) {
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
const devServerOptions = __spreadValues(__spreadValues({
|
|
642
|
-
host: "localhost",
|
|
643
|
-
port: 8080
|
|
644
|
-
}, compiler.options.devServer), (_c = (_b = await ((_a = await import("@rsbuild/core")) == null ? void 0 : _a.loadConfig({
|
|
645
|
-
cwd
|
|
646
|
-
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
647
|
-
const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
|
|
648
|
-
const base = compiler.options.output.publicPath || "/";
|
|
649
|
-
const _targetUrl = (_d = options == null ? void 0 : options.targetUrl) != null ? _d : `http://${source}${base}`;
|
|
650
|
-
resovedInfo.targetURL = new URL(_targetUrl);
|
|
651
|
-
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
652
|
-
if (options == null ? void 0 : options.corpId) {
|
|
653
|
-
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
654
|
-
}
|
|
655
|
-
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
656
|
-
"Open in dingtalk"
|
|
657
|
-
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
658
|
-
if (enableChii) {
|
|
659
|
-
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
660
|
-
"Click to open chrome devtools"
|
|
661
|
-
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
return unpluginDing;
|
|
666
|
-
};
|
|
667
|
-
var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
|
|
668
|
-
var index_default = unplugin;
|
|
669
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
670
|
-
0 && (module.exports = {
|
|
671
|
-
createProxyMiddleware,
|
|
672
|
-
resovedInfo,
|
|
673
|
-
unplugin,
|
|
674
|
-
unpluginFactory
|
|
675
|
-
});
|
|
676
|
-
exports.default = module.exports;
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
require('./__chrome_devtools-CJ3sXpVj.cjs');
|
|
3
|
+
const require_src = require('./src-hLDO4Q22.cjs');
|
|
4
|
+
require('./utils-CmfBxo4J.cjs');
|
|
5
|
+
|
|
6
|
+
exports.createProxyMiddleware = require_src.createProxyMiddleware;
|
|
7
|
+
exports.default = require_src.src_default;
|
|
8
|
+
exports.resovedInfo = require_src.resovedInfo;
|
|
9
|
+
exports.unplugin = require_src.unplugin;
|
|
10
|
+
exports.unpluginFactory = require_src.unpluginFactory;
|