unplugin-dingtalk 1004.0.0 → 1006.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/__chrome_devtools.cjs +115 -0
- package/dist/__chrome_devtools.d.cts +3 -0
- package/dist/__chrome_devtools.js +1 -1
- package/dist/astro.cjs +679 -0
- package/dist/astro.d.cts +13 -0
- package/dist/astro.js +2 -2
- package/dist/{chunk-DZEMXGMI.js → chunk-2YQKM4BX.js} +2 -2
- package/dist/{chunk-5U7LETMH.js → chunk-EG2ZYJ3S.js} +112 -75
- package/dist/{chunk-7VYUT3GL.js → chunk-LMNMIIAV.js} +2 -2
- package/dist/esbuild.cjs +669 -0
- package/dist/esbuild.d.cts +9 -0
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +676 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -2
- package/dist/main-Q4R5NCQC.js +129 -0
- package/dist/nuxt.cjs +844 -0
- package/dist/nuxt.d.cts +11 -0
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +669 -0
- package/dist/rollup.d.cts +9 -0
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +729 -0
- package/dist/rspack.d.cts +9 -0
- package/dist/rspack.d.ts +2 -1
- package/dist/rspack.js +8 -2
- package/dist/types.cjs +19 -0
- package/dist/types.d.cts +38 -0
- package/dist/utils.cjs +34 -0
- package/dist/utils.d.cts +6 -0
- package/dist/vite.cjs +825 -0
- package/dist/vite.d.cts +9 -0
- package/dist/vite.js +3 -3
- package/dist/webpack.cjs +723 -0
- package/dist/webpack.d.cts +9 -0
- package/dist/webpack.js +8 -2
- package/package.json +55 -14
|
@@ -76,9 +76,9 @@ function getChromeDevtoolsHtml(targetPort) {
|
|
|
76
76
|
list.innerHTML = "<li>\u83B7\u53D6\u8C03\u8BD5\u76EE\u6807\u5931\u8D25</li>";
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
document.getElementById("refresh").onclick =
|
|
79
|
+
document.getElementById("refresh").onclick = () => window.location.reload();
|
|
80
80
|
window.onload = fetchTargets;
|
|
81
|
-
document.addEventListener('visibilitychange',
|
|
81
|
+
document.addEventListener('visibilitychange', window.location.reload);
|
|
82
82
|
</script>
|
|
83
83
|
</body>
|
|
84
84
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getChromeDevtoolsHtml
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2YQKM4BX.js";
|
|
4
4
|
import {
|
|
5
5
|
__spreadValues
|
|
6
6
|
} from "./chunk-5JBD5THX.js";
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
|
-
import process2 from "
|
|
10
|
-
import { ServerResponse } from "
|
|
11
|
-
import { Socket } from "
|
|
9
|
+
import process2 from "process";
|
|
10
|
+
import { ServerResponse } from "http";
|
|
11
|
+
import { Socket } from "net";
|
|
12
12
|
import { createUnplugin } from "unplugin";
|
|
13
13
|
import c from "picocolors";
|
|
14
14
|
import cookie from "cookie";
|
|
15
15
|
import { start } from "z-chii";
|
|
16
16
|
|
|
17
17
|
// node_modules/.pnpm/get-port-please@3.1.2/node_modules/get-port-please/dist/index.mjs
|
|
18
|
-
import { createServer } from "
|
|
19
|
-
import { networkInterfaces } from "
|
|
18
|
+
import { createServer } from "net";
|
|
19
|
+
import { networkInterfaces } from "os";
|
|
20
20
|
var unsafePorts = /* @__PURE__ */ new Set([
|
|
21
21
|
1,
|
|
22
22
|
// tcpmux
|
|
@@ -276,6 +276,49 @@ var resovedInfo = {
|
|
|
276
276
|
availablePort: void 0,
|
|
277
277
|
targetURL: void 0
|
|
278
278
|
};
|
|
279
|
+
function createProxyMiddleware(debug) {
|
|
280
|
+
let proxy = null;
|
|
281
|
+
const handleUpgrade = (req, socket, head) => {
|
|
282
|
+
var _a;
|
|
283
|
+
if (proxy && ((_a = req.url) == null ? void 0 : _a.startsWith("/__chii_proxy"))) {
|
|
284
|
+
debug("WS upgrade:", req.url);
|
|
285
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
286
|
+
proxy.ws(req, socket, head);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
return (resolvedInfo) => {
|
|
290
|
+
return (req, res, next) => {
|
|
291
|
+
var _a;
|
|
292
|
+
if (!proxy && resolvedInfo.availablePort) {
|
|
293
|
+
proxy = httpProxy.createProxyServer({
|
|
294
|
+
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
295
|
+
ws: true
|
|
296
|
+
});
|
|
297
|
+
proxy.on("error", (err, req2, res2) => {
|
|
298
|
+
console.error("Proxy error:", err);
|
|
299
|
+
if (res2 instanceof ServerResponse) {
|
|
300
|
+
if (!res2.headersSent) {
|
|
301
|
+
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
302
|
+
}
|
|
303
|
+
res2.end(`Proxy error: ${err.message}`);
|
|
304
|
+
} else if (res2 instanceof Socket) {
|
|
305
|
+
res2.destroy();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
if (req.socket.server) {
|
|
309
|
+
req.socket.server.on("upgrade", handleUpgrade);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (proxy && ((_a = req.url) == null ? void 0 : _a.startsWith("/__chii_proxy"))) {
|
|
313
|
+
debug(req.url);
|
|
314
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
315
|
+
proxy.web(req, res);
|
|
316
|
+
} else {
|
|
317
|
+
next();
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
}
|
|
279
322
|
var unpluginFactory = (options) => {
|
|
280
323
|
const {
|
|
281
324
|
chii
|
|
@@ -289,44 +332,77 @@ var unpluginFactory = (options) => {
|
|
|
289
332
|
const unpluginDing = {
|
|
290
333
|
name: "unplugin-dingtalk",
|
|
291
334
|
enforce: "pre",
|
|
335
|
+
resolveId(source) {
|
|
336
|
+
if (source === "chii-client") {
|
|
337
|
+
return source;
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
loadInclude(id) {
|
|
341
|
+
return id === "chii-client";
|
|
342
|
+
},
|
|
343
|
+
load(id) {
|
|
344
|
+
var _a, _b;
|
|
345
|
+
if (id === "chii-client") {
|
|
346
|
+
return `
|
|
347
|
+
;(function(){
|
|
348
|
+
if (document.getElementById('__chii_client')) return;
|
|
349
|
+
const script = document.createElement('script');
|
|
350
|
+
script.id = '__chii_client';
|
|
351
|
+
script.src="/__chii_proxy/target.js";
|
|
352
|
+
${((_a = options == null ? void 0 : options.chii) == null ? void 0 : _a.embedded) ? "script.setAttribute('embedded','true');" : ""}
|
|
353
|
+
document.body.appendChild(script);
|
|
354
|
+
})();
|
|
355
|
+
if (import.meta.hot) {
|
|
356
|
+
import.meta.hot.accept(() => {
|
|
357
|
+
const old = document.getElementById('__chii_client');
|
|
358
|
+
if (old) old.remove();
|
|
359
|
+
const script = document.createElement('script');
|
|
360
|
+
script.id = '__chii_client';
|
|
361
|
+
script.src="/__chii_proxy/target.js";
|
|
362
|
+
${((_b = options == null ? void 0 : options.chii) == null ? void 0 : _b.embedded) ? "script.setAttribute('embedded','true');" : ""}
|
|
363
|
+
document.body.appendChild(script);
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
`;
|
|
367
|
+
}
|
|
368
|
+
},
|
|
292
369
|
transformInclude(id) {
|
|
293
|
-
return
|
|
370
|
+
return !!id.split("?")[0].match(/\.[t|j]s$/);
|
|
294
371
|
},
|
|
295
|
-
async transform(
|
|
372
|
+
async transform(source, id) {
|
|
296
373
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
297
374
|
resovedInfo.availablePort = await getRandomPort();
|
|
298
|
-
start({
|
|
299
|
-
port: resovedInfo.availablePort
|
|
300
|
-
});
|
|
375
|
+
start({ port: resovedInfo.availablePort });
|
|
301
376
|
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
302
377
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
378
|
+
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
379
|
+
const file = id.split("?")[0];
|
|
380
|
+
if (file.startsWith((config == null ? void 0 : config.root) || cwd) && !file.includes("node_modules") && file.match(/\.[t|j]s$/)) {
|
|
381
|
+
return {
|
|
382
|
+
code: `import 'chii-client';
|
|
383
|
+
${source}`,
|
|
384
|
+
map: null
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return { code: source, map: null };
|
|
308
389
|
},
|
|
309
390
|
vite: {
|
|
310
391
|
configResolved(_config) {
|
|
311
392
|
config = _config;
|
|
312
393
|
},
|
|
313
394
|
transformIndexHtml(html) {
|
|
314
|
-
var _a;
|
|
315
395
|
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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>
|
|
396
|
+
const tag = `<script type="module">import 'chii-client';</script>`;
|
|
397
|
+
if (!html.includes(tag)) {
|
|
398
|
+
return html.replace(
|
|
399
|
+
"</body>",
|
|
400
|
+
`</body>${tag}
|
|
327
401
|
`
|
|
328
|
-
|
|
402
|
+
);
|
|
403
|
+
}
|
|
329
404
|
}
|
|
405
|
+
return html;
|
|
330
406
|
},
|
|
331
407
|
async configureServer(server) {
|
|
332
408
|
var _a, _b;
|
|
@@ -373,57 +449,17 @@ var unpluginFactory = (options) => {
|
|
|
373
449
|
});
|
|
374
450
|
}
|
|
375
451
|
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
452
|
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
453
|
+
if (!resovedInfo.availablePort) {
|
|
454
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
455
|
+
res.end("Server not started");
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
422
458
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
423
459
|
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
|
|
424
460
|
res.end();
|
|
425
461
|
});
|
|
426
|
-
const proxyMiddleware =
|
|
462
|
+
const proxyMiddleware = createProxyMiddleware(debug);
|
|
427
463
|
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
428
464
|
}
|
|
429
465
|
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
@@ -499,6 +535,7 @@ var index_default = unplugin;
|
|
|
499
535
|
|
|
500
536
|
export {
|
|
501
537
|
resovedInfo,
|
|
538
|
+
createProxyMiddleware,
|
|
502
539
|
unpluginFactory,
|
|
503
540
|
unplugin,
|
|
504
541
|
index_default
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KQOHODTC.js";
|
|
4
4
|
import {
|
|
5
5
|
unpluginFactory
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EG2ZYJ3S.js";
|
|
7
7
|
|
|
8
8
|
// src/vite.ts
|
|
9
9
|
import { createVitePlugin } from "unplugin";
|
|
@@ -12,7 +12,7 @@ var vite_default = async (options) => {
|
|
|
12
12
|
const plugins = [createVitePlugin(unpluginFactory)(options)];
|
|
13
13
|
if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
|
|
14
14
|
try {
|
|
15
|
-
const viteVConsilePlugin = await interopDefault(import("
|
|
15
|
+
const viteVConsilePlugin = await interopDefault(import("./main-Q4R5NCQC.js"));
|
|
16
16
|
plugins.push(viteVConsilePlugin(options == null ? void 0 : options.vconsole));
|
|
17
17
|
} catch (e) {
|
|
18
18
|
console.error("vite-plugin-vconsole not found");
|