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