unplugin-dingtalk 1006.0.0 → 1007.0.1

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