unplugin-dingtalk 0.4.2 → 0.5.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/astro.cjs +84 -17
- package/dist/astro.js +1 -1
- package/dist/{chunk-RDTWBIQD.js → chunk-OSHJOAQB.js} +86 -17
- package/dist/{chunk-2OB7UBRW.js → chunk-TZDLEHKX.js} +1 -1
- package/dist/esbuild.cjs +84 -17
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +88 -17
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/nuxt.cjs +84 -17
- package/dist/nuxt.js +2 -2
- package/dist/rollup.cjs +84 -17
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +95 -37
- package/dist/rspack.js +8 -16
- package/dist/types.d.cts +13 -2
- package/dist/types.d.ts +13 -2
- package/dist/vite.cjs +84 -17
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +95 -37
- package/dist/webpack.js +8 -16
- package/package.json +4 -2
package/dist/rspack.cjs
CHANGED
|
@@ -4389,15 +4389,15 @@ var require_streams = __commonJS({
|
|
|
4389
4389
|
var POOL_SIZE2 = 65536;
|
|
4390
4390
|
if (!globalThis.ReadableStream) {
|
|
4391
4391
|
try {
|
|
4392
|
-
const
|
|
4393
|
-
const { emitWarning } =
|
|
4392
|
+
const process3 = require("process");
|
|
4393
|
+
const { emitWarning } = process3;
|
|
4394
4394
|
try {
|
|
4395
|
-
|
|
4395
|
+
process3.emitWarning = () => {
|
|
4396
4396
|
};
|
|
4397
4397
|
Object.assign(globalThis, require("stream/web"));
|
|
4398
|
-
|
|
4398
|
+
process3.emitWarning = emitWarning;
|
|
4399
4399
|
} catch (error) {
|
|
4400
|
-
|
|
4400
|
+
process3.emitWarning = emitWarning;
|
|
4401
4401
|
throw error;
|
|
4402
4402
|
}
|
|
4403
4403
|
} catch (error) {
|
|
@@ -5211,8 +5211,6 @@ __export(rspack_exports, {
|
|
|
5211
5211
|
default: () => rspack_default
|
|
5212
5212
|
});
|
|
5213
5213
|
module.exports = __toCommonJS(rspack_exports);
|
|
5214
|
-
var import_node_child_process2 = require("child_process");
|
|
5215
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
5216
5214
|
var import_unplugin2 = require("unplugin");
|
|
5217
5215
|
var import_cookie2 = __toESM(require("cookie"), 1);
|
|
5218
5216
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
@@ -6516,19 +6514,92 @@ var import_unplugin = require("unplugin");
|
|
|
6516
6514
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6517
6515
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6518
6516
|
var import_chii = require("chii");
|
|
6517
|
+
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6519
6518
|
var import_get_port_please = require("get-port-please");
|
|
6520
6519
|
var cwd = import_node_process.default.cwd();
|
|
6521
6520
|
var config;
|
|
6522
6521
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
6523
6522
|
var resovedInfo = {
|
|
6524
6523
|
devtoolsInstance: void 0,
|
|
6524
|
+
dnsServerInstence: void 0,
|
|
6525
6525
|
availablePort: void 0,
|
|
6526
6526
|
targetURL: void 0
|
|
6527
6527
|
};
|
|
6528
|
+
function startVueDevtools(enable) {
|
|
6529
|
+
if (enable && !resovedInfo.devtoolsInstance) {
|
|
6530
|
+
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6531
|
+
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6532
|
+
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6533
|
+
resovedInfo.devtoolsInstance = void 0;
|
|
6534
|
+
});
|
|
6535
|
+
import_node_process.default.on("exit", () => {
|
|
6536
|
+
if (resovedInfo.devtoolsInstance) {
|
|
6537
|
+
resovedInfo.devtoolsInstance.kill();
|
|
6538
|
+
}
|
|
6539
|
+
});
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
function startDnsServer(options) {
|
|
6543
|
+
function debug(...args) {
|
|
6544
|
+
if (options == null ? void 0 : options.debug) {
|
|
6545
|
+
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
6546
|
+
}
|
|
6547
|
+
}
|
|
6548
|
+
if ((options == null ? void 0 : options.enable) && (options == null ? void 0 : options.dns) && !resovedInfo.dnsServerInstence) {
|
|
6549
|
+
const { Packet } = import_dns2.default;
|
|
6550
|
+
resovedInfo.dnsServerInstence = import_dns2.default.createServer({
|
|
6551
|
+
tcp: true,
|
|
6552
|
+
udp: true,
|
|
6553
|
+
handle: (request, send, rinfo) => {
|
|
6554
|
+
var _a4;
|
|
6555
|
+
const response = Packet.createResponseFromRequest(request);
|
|
6556
|
+
const [question] = request.questions;
|
|
6557
|
+
const { name } = question;
|
|
6558
|
+
if (name === options.dns.host) {
|
|
6559
|
+
response.answers.push({
|
|
6560
|
+
name,
|
|
6561
|
+
type: Packet.TYPE.A,
|
|
6562
|
+
class: Packet.CLASS.IN,
|
|
6563
|
+
ttl: 300,
|
|
6564
|
+
address: (_a4 = options.dns) == null ? void 0 : _a4.ip
|
|
6565
|
+
});
|
|
6566
|
+
debug(`dns request from ${rinfo.address}:${rinfo.port} for ${name} => ${options.dns.ip}`);
|
|
6567
|
+
}
|
|
6568
|
+
send(response);
|
|
6569
|
+
}
|
|
6570
|
+
});
|
|
6571
|
+
resovedInfo.dnsServerInstence.listen({
|
|
6572
|
+
udp: { address: "0.0.0.0", port: 53 },
|
|
6573
|
+
tcp: { address: "0.0.0.0", port: 53 }
|
|
6574
|
+
}).then(() => {
|
|
6575
|
+
debug("DNS server is running.");
|
|
6576
|
+
const dns = new import_dns2.default({
|
|
6577
|
+
port: 53,
|
|
6578
|
+
nameServers: ["127.0.0.1", "8.8.8.8"]
|
|
6579
|
+
});
|
|
6580
|
+
dns.resolveA(options.dns.host).then((addresses) => {
|
|
6581
|
+
var _a4;
|
|
6582
|
+
if (((_a4 = addresses.answers[0]) == null ? void 0 : _a4.address) === options.dns.ip) {
|
|
6583
|
+
startDnsServer(options);
|
|
6584
|
+
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(`DNS server is started, please modify the DNS of the remote device to ${options.dns.ip}`)}`);
|
|
6585
|
+
} else {
|
|
6586
|
+
debug(addresses.answers[0].address);
|
|
6587
|
+
throw new Error("DNS server started failed");
|
|
6588
|
+
}
|
|
6589
|
+
}).catch((e2) => {
|
|
6590
|
+
throw e2;
|
|
6591
|
+
});
|
|
6592
|
+
}).catch((e2) => {
|
|
6593
|
+
debug(e2);
|
|
6594
|
+
console.log(` ${import_picocolors.default.red("\u279C")} ${import_picocolors.default.bold((e2 == null ? void 0 : e2.message) || e2)}`);
|
|
6595
|
+
});
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6528
6598
|
var unpluginFactory = (options) => {
|
|
6529
6599
|
const {
|
|
6530
|
-
chii
|
|
6600
|
+
chii
|
|
6531
6601
|
} = options || {};
|
|
6602
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
6532
6603
|
function debug(...args) {
|
|
6533
6604
|
if (options == null ? void 0 : options.debug) {
|
|
6534
6605
|
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
@@ -6544,20 +6615,19 @@ var unpluginFactory = (options) => {
|
|
|
6544
6615
|
var _a4, _b, _c;
|
|
6545
6616
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6546
6617
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6547
|
-
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
6548
6618
|
(0, import_chii.start)({
|
|
6549
|
-
host: "0.0.0.0",
|
|
6550
6619
|
port: resovedInfo.availablePort
|
|
6551
6620
|
});
|
|
6621
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
6552
6622
|
}
|
|
6553
6623
|
if (options == null ? void 0 : options.enable) {
|
|
6554
6624
|
const codes = [
|
|
6555
6625
|
"/* eslint-disable */;",
|
|
6556
6626
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6557
|
-
devtools.connect(${(_b = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _b.host}, ${(_c = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _c.port});` : "",
|
|
6627
|
+
devtools.connect(${((_b = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _b.host) ? `"${options.vueDevtools.host}"` : void 0}, ${((_c = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _c.port) ? `${options.vueDevtools.port}` : void 0});` : "",
|
|
6558
6628
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6559
6629
|
const script = document.createElement('script');
|
|
6560
|
-
script.src="http
|
|
6630
|
+
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6561
6631
|
document.body.appendChild(script);
|
|
6562
6632
|
})()` : "",
|
|
6563
6633
|
"/* eslint-enable */",
|
|
@@ -6633,6 +6703,9 @@ var unpluginFactory = (options) => {
|
|
|
6633
6703
|
const devToolsUrl = `http://localhost:${resovedInfo.availablePort}/front_end/chii_app.html?ws=localhost:${resovedInfo.availablePort}/client/${Math.random().toString(20).substring(2, 8)}?target=${data.targets[0].id}&rtc=false`;
|
|
6634
6704
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6635
6705
|
res.end();
|
|
6706
|
+
} else {
|
|
6707
|
+
res.writeHead(404);
|
|
6708
|
+
res.end();
|
|
6636
6709
|
}
|
|
6637
6710
|
} catch (error) {
|
|
6638
6711
|
debug(`${error}`);
|
|
@@ -6647,20 +6720,10 @@ var unpluginFactory = (options) => {
|
|
|
6647
6720
|
res.writeHead(302, {
|
|
6648
6721
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6649
6722
|
});
|
|
6650
|
-
|
|
6651
|
-
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6652
|
-
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6653
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6654
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
6655
|
-
});
|
|
6656
|
-
import_node_process.default.on("exit", () => {
|
|
6657
|
-
if (resovedInfo.devtoolsInstance) {
|
|
6658
|
-
resovedInfo.devtoolsInstance.kill();
|
|
6659
|
-
}
|
|
6660
|
-
});
|
|
6661
|
-
}
|
|
6723
|
+
startVueDevtools((_a5 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a5.enable);
|
|
6662
6724
|
res.end();
|
|
6663
6725
|
});
|
|
6726
|
+
startDnsServer(options);
|
|
6664
6727
|
}
|
|
6665
6728
|
},
|
|
6666
6729
|
webpack(compiler) {
|
|
@@ -6691,6 +6754,7 @@ var unpluginFactory = (options) => {
|
|
|
6691
6754
|
if (options == null ? void 0 : options.corpId) {
|
|
6692
6755
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6693
6756
|
}
|
|
6757
|
+
startDnsServer(options);
|
|
6694
6758
|
},
|
|
6695
6759
|
async rspack(compiler) {
|
|
6696
6760
|
var _a4, _b, _c, _d2, _e;
|
|
@@ -6719,6 +6783,7 @@ var unpluginFactory = (options) => {
|
|
|
6719
6783
|
"Click to open chrome devtools"
|
|
6720
6784
|
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
6721
6785
|
}
|
|
6786
|
+
startDnsServer(options);
|
|
6722
6787
|
}
|
|
6723
6788
|
};
|
|
6724
6789
|
return unpluginDing;
|
|
@@ -6732,8 +6797,9 @@ var rspack_default = (options) => {
|
|
|
6732
6797
|
}
|
|
6733
6798
|
}
|
|
6734
6799
|
const {
|
|
6735
|
-
chii
|
|
6800
|
+
chii
|
|
6736
6801
|
} = options || {};
|
|
6802
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
6737
6803
|
const injectSetupMiddlewares = (middlewares, _devServer) => {
|
|
6738
6804
|
if (options.debugCookies && options.debugCookies.length > 0) {
|
|
6739
6805
|
middlewares.unshift((req, res, next) => {
|
|
@@ -6762,6 +6828,9 @@ var rspack_default = (options) => {
|
|
|
6762
6828
|
const devToolsUrl = `http://localhost:${availablePort}/front_end/chii_app.html?ws=localhost:${availablePort}/client/${Math.random().toString(20).substring(2, 8)}?target=${data.targets[0].id}&rtc=false`;
|
|
6763
6829
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6764
6830
|
res.end();
|
|
6831
|
+
} else {
|
|
6832
|
+
res.writeHead(404);
|
|
6833
|
+
res.end();
|
|
6765
6834
|
}
|
|
6766
6835
|
} catch (error) {
|
|
6767
6836
|
debug(`${error}`);
|
|
@@ -6780,18 +6849,7 @@ var rspack_default = (options) => {
|
|
|
6780
6849
|
res.writeHead(302, {
|
|
6781
6850
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6782
6851
|
});
|
|
6783
|
-
|
|
6784
|
-
resovedInfo.devtoolsInstance = (0, import_node_child_process2.exec)("npx vue-devtools");
|
|
6785
|
-
console.log(` ${import_picocolors2.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6786
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6787
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
6788
|
-
});
|
|
6789
|
-
import_node_process2.default.on("exit", () => {
|
|
6790
|
-
if (resovedInfo.devtoolsInstance) {
|
|
6791
|
-
resovedInfo.devtoolsInstance.kill();
|
|
6792
|
-
}
|
|
6793
|
-
});
|
|
6794
|
-
}
|
|
6852
|
+
startVueDevtools((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable);
|
|
6795
6853
|
res.end();
|
|
6796
6854
|
});
|
|
6797
6855
|
return middlewares;
|
package/dist/rspack.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetch,
|
|
3
3
|
resovedInfo,
|
|
4
|
+
startVueDevtools,
|
|
4
5
|
unpluginFactory
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OSHJOAQB.js";
|
|
6
7
|
import "./chunk-PMOTCIQR.js";
|
|
7
8
|
|
|
8
9
|
// src/rspack.ts
|
|
9
|
-
import { exec } from "child_process";
|
|
10
|
-
import process from "process";
|
|
11
10
|
import { createRspackPlugin } from "unplugin";
|
|
12
11
|
import cookie from "cookie";
|
|
13
12
|
import c from "picocolors";
|
|
@@ -18,8 +17,9 @@ var rspack_default = (options) => {
|
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
const {
|
|
21
|
-
chii
|
|
20
|
+
chii
|
|
22
21
|
} = options || {};
|
|
22
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
23
23
|
const injectSetupMiddlewares = (middlewares, _devServer) => {
|
|
24
24
|
if (options.debugCookies && options.debugCookies.length > 0) {
|
|
25
25
|
middlewares.unshift((req, res, next) => {
|
|
@@ -48,6 +48,9 @@ var rspack_default = (options) => {
|
|
|
48
48
|
const devToolsUrl = `http://localhost:${availablePort}/front_end/chii_app.html?ws=localhost:${availablePort}/client/${Math.random().toString(20).substring(2, 8)}?target=${data.targets[0].id}&rtc=false`;
|
|
49
49
|
res.writeHead(302, { Location: devToolsUrl });
|
|
50
50
|
res.end();
|
|
51
|
+
} else {
|
|
52
|
+
res.writeHead(404);
|
|
53
|
+
res.end();
|
|
51
54
|
}
|
|
52
55
|
} catch (error) {
|
|
53
56
|
debug(`${error}`);
|
|
@@ -66,18 +69,7 @@ var rspack_default = (options) => {
|
|
|
66
69
|
res.writeHead(302, {
|
|
67
70
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
68
71
|
});
|
|
69
|
-
|
|
70
|
-
resovedInfo.devtoolsInstance = exec("npx vue-devtools");
|
|
71
|
-
console.log(` ${c.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
72
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
73
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
74
|
-
});
|
|
75
|
-
process.on("exit", () => {
|
|
76
|
-
if (resovedInfo.devtoolsInstance) {
|
|
77
|
-
resovedInfo.devtoolsInstance.kill();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
72
|
+
startVueDevtools((_a = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a.enable);
|
|
81
73
|
res.end();
|
|
82
74
|
});
|
|
83
75
|
return middlewares;
|
package/dist/types.d.cts
CHANGED
|
@@ -5,16 +5,27 @@ import { viteVConsoleOptions } from 'vite-plugin-vconsole';
|
|
|
5
5
|
interface Options {
|
|
6
6
|
enable?: boolean;
|
|
7
7
|
targetUrl?: string;
|
|
8
|
+
/** 是否启动dns服务器 */
|
|
9
|
+
dns?: {
|
|
10
|
+
host: string;
|
|
11
|
+
ip: string;
|
|
12
|
+
};
|
|
8
13
|
corpId?: string;
|
|
9
14
|
debug?: boolean;
|
|
10
15
|
/** only support vite */
|
|
11
16
|
vconsole?: viteVConsoleOptions;
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
chii?: {
|
|
18
|
+
/** default true */
|
|
19
|
+
enable?: boolean;
|
|
20
|
+
/** default 127.0.0.1 */
|
|
21
|
+
host: string;
|
|
22
|
+
};
|
|
14
23
|
debugCookies?: string[];
|
|
15
24
|
vueDevtools?: {
|
|
16
25
|
enable?: boolean;
|
|
26
|
+
/** default 127.0.0.1 */
|
|
17
27
|
host?: string;
|
|
28
|
+
/** default 8098 */
|
|
18
29
|
port?: number;
|
|
19
30
|
};
|
|
20
31
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,16 +5,27 @@ import { viteVConsoleOptions } from 'vite-plugin-vconsole';
|
|
|
5
5
|
interface Options {
|
|
6
6
|
enable?: boolean;
|
|
7
7
|
targetUrl?: string;
|
|
8
|
+
/** 是否启动dns服务器 */
|
|
9
|
+
dns?: {
|
|
10
|
+
host: string;
|
|
11
|
+
ip: string;
|
|
12
|
+
};
|
|
8
13
|
corpId?: string;
|
|
9
14
|
debug?: boolean;
|
|
10
15
|
/** only support vite */
|
|
11
16
|
vconsole?: viteVConsoleOptions;
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
chii?: {
|
|
18
|
+
/** default true */
|
|
19
|
+
enable?: boolean;
|
|
20
|
+
/** default 127.0.0.1 */
|
|
21
|
+
host: string;
|
|
22
|
+
};
|
|
14
23
|
debugCookies?: string[];
|
|
15
24
|
vueDevtools?: {
|
|
16
25
|
enable?: boolean;
|
|
26
|
+
/** default 127.0.0.1 */
|
|
17
27
|
host?: string;
|
|
28
|
+
/** default 8098 */
|
|
18
29
|
port?: number;
|
|
19
30
|
};
|
|
20
31
|
}
|
package/dist/vite.cjs
CHANGED
|
@@ -6515,19 +6515,92 @@ var import_unplugin = require("unplugin");
|
|
|
6515
6515
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6516
6516
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6517
6517
|
var import_chii = require("chii");
|
|
6518
|
+
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6518
6519
|
var import_get_port_please = require("get-port-please");
|
|
6519
6520
|
var cwd = import_node_process.default.cwd();
|
|
6520
6521
|
var config;
|
|
6521
6522
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
6522
6523
|
var resovedInfo = {
|
|
6523
6524
|
devtoolsInstance: void 0,
|
|
6525
|
+
dnsServerInstence: void 0,
|
|
6524
6526
|
availablePort: void 0,
|
|
6525
6527
|
targetURL: void 0
|
|
6526
6528
|
};
|
|
6529
|
+
function startVueDevtools(enable) {
|
|
6530
|
+
if (enable && !resovedInfo.devtoolsInstance) {
|
|
6531
|
+
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6532
|
+
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6533
|
+
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6534
|
+
resovedInfo.devtoolsInstance = void 0;
|
|
6535
|
+
});
|
|
6536
|
+
import_node_process.default.on("exit", () => {
|
|
6537
|
+
if (resovedInfo.devtoolsInstance) {
|
|
6538
|
+
resovedInfo.devtoolsInstance.kill();
|
|
6539
|
+
}
|
|
6540
|
+
});
|
|
6541
|
+
}
|
|
6542
|
+
}
|
|
6543
|
+
function startDnsServer(options) {
|
|
6544
|
+
function debug(...args) {
|
|
6545
|
+
if (options == null ? void 0 : options.debug) {
|
|
6546
|
+
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
6547
|
+
}
|
|
6548
|
+
}
|
|
6549
|
+
if ((options == null ? void 0 : options.enable) && (options == null ? void 0 : options.dns) && !resovedInfo.dnsServerInstence) {
|
|
6550
|
+
const { Packet } = import_dns2.default;
|
|
6551
|
+
resovedInfo.dnsServerInstence = import_dns2.default.createServer({
|
|
6552
|
+
tcp: true,
|
|
6553
|
+
udp: true,
|
|
6554
|
+
handle: (request, send, rinfo) => {
|
|
6555
|
+
var _a4;
|
|
6556
|
+
const response = Packet.createResponseFromRequest(request);
|
|
6557
|
+
const [question] = request.questions;
|
|
6558
|
+
const { name } = question;
|
|
6559
|
+
if (name === options.dns.host) {
|
|
6560
|
+
response.answers.push({
|
|
6561
|
+
name,
|
|
6562
|
+
type: Packet.TYPE.A,
|
|
6563
|
+
class: Packet.CLASS.IN,
|
|
6564
|
+
ttl: 300,
|
|
6565
|
+
address: (_a4 = options.dns) == null ? void 0 : _a4.ip
|
|
6566
|
+
});
|
|
6567
|
+
debug(`dns request from ${rinfo.address}:${rinfo.port} for ${name} => ${options.dns.ip}`);
|
|
6568
|
+
}
|
|
6569
|
+
send(response);
|
|
6570
|
+
}
|
|
6571
|
+
});
|
|
6572
|
+
resovedInfo.dnsServerInstence.listen({
|
|
6573
|
+
udp: { address: "0.0.0.0", port: 53 },
|
|
6574
|
+
tcp: { address: "0.0.0.0", port: 53 }
|
|
6575
|
+
}).then(() => {
|
|
6576
|
+
debug("DNS server is running.");
|
|
6577
|
+
const dns = new import_dns2.default({
|
|
6578
|
+
port: 53,
|
|
6579
|
+
nameServers: ["127.0.0.1", "8.8.8.8"]
|
|
6580
|
+
});
|
|
6581
|
+
dns.resolveA(options.dns.host).then((addresses) => {
|
|
6582
|
+
var _a4;
|
|
6583
|
+
if (((_a4 = addresses.answers[0]) == null ? void 0 : _a4.address) === options.dns.ip) {
|
|
6584
|
+
startDnsServer(options);
|
|
6585
|
+
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(`DNS server is started, please modify the DNS of the remote device to ${options.dns.ip}`)}`);
|
|
6586
|
+
} else {
|
|
6587
|
+
debug(addresses.answers[0].address);
|
|
6588
|
+
throw new Error("DNS server started failed");
|
|
6589
|
+
}
|
|
6590
|
+
}).catch((e2) => {
|
|
6591
|
+
throw e2;
|
|
6592
|
+
});
|
|
6593
|
+
}).catch((e2) => {
|
|
6594
|
+
debug(e2);
|
|
6595
|
+
console.log(` ${import_picocolors.default.red("\u279C")} ${import_picocolors.default.bold((e2 == null ? void 0 : e2.message) || e2)}`);
|
|
6596
|
+
});
|
|
6597
|
+
}
|
|
6598
|
+
}
|
|
6527
6599
|
var unpluginFactory = (options) => {
|
|
6528
6600
|
const {
|
|
6529
|
-
chii
|
|
6601
|
+
chii
|
|
6530
6602
|
} = options || {};
|
|
6603
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
6531
6604
|
function debug(...args) {
|
|
6532
6605
|
if (options == null ? void 0 : options.debug) {
|
|
6533
6606
|
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
@@ -6543,20 +6616,19 @@ var unpluginFactory = (options) => {
|
|
|
6543
6616
|
var _a4, _b, _c;
|
|
6544
6617
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6545
6618
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6546
|
-
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
6547
6619
|
(0, import_chii.start)({
|
|
6548
|
-
host: "0.0.0.0",
|
|
6549
6620
|
port: resovedInfo.availablePort
|
|
6550
6621
|
});
|
|
6622
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
6551
6623
|
}
|
|
6552
6624
|
if (options == null ? void 0 : options.enable) {
|
|
6553
6625
|
const codes = [
|
|
6554
6626
|
"/* eslint-disable */;",
|
|
6555
6627
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6556
|
-
devtools.connect(${(_b = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _b.host}, ${(_c = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _c.port});` : "",
|
|
6628
|
+
devtools.connect(${((_b = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _b.host) ? `"${options.vueDevtools.host}"` : void 0}, ${((_c = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _c.port) ? `${options.vueDevtools.port}` : void 0});` : "",
|
|
6557
6629
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6558
6630
|
const script = document.createElement('script');
|
|
6559
|
-
script.src="http
|
|
6631
|
+
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6560
6632
|
document.body.appendChild(script);
|
|
6561
6633
|
})()` : "",
|
|
6562
6634
|
"/* eslint-enable */",
|
|
@@ -6632,6 +6704,9 @@ var unpluginFactory = (options) => {
|
|
|
6632
6704
|
const devToolsUrl = `http://localhost:${resovedInfo.availablePort}/front_end/chii_app.html?ws=localhost:${resovedInfo.availablePort}/client/${Math.random().toString(20).substring(2, 8)}?target=${data.targets[0].id}&rtc=false`;
|
|
6633
6705
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6634
6706
|
res.end();
|
|
6707
|
+
} else {
|
|
6708
|
+
res.writeHead(404);
|
|
6709
|
+
res.end();
|
|
6635
6710
|
}
|
|
6636
6711
|
} catch (error) {
|
|
6637
6712
|
debug(`${error}`);
|
|
@@ -6646,20 +6721,10 @@ var unpluginFactory = (options) => {
|
|
|
6646
6721
|
res.writeHead(302, {
|
|
6647
6722
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6648
6723
|
});
|
|
6649
|
-
|
|
6650
|
-
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6651
|
-
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6652
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6653
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
6654
|
-
});
|
|
6655
|
-
import_node_process.default.on("exit", () => {
|
|
6656
|
-
if (resovedInfo.devtoolsInstance) {
|
|
6657
|
-
resovedInfo.devtoolsInstance.kill();
|
|
6658
|
-
}
|
|
6659
|
-
});
|
|
6660
|
-
}
|
|
6724
|
+
startVueDevtools((_a5 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a5.enable);
|
|
6661
6725
|
res.end();
|
|
6662
6726
|
});
|
|
6727
|
+
startDnsServer(options);
|
|
6663
6728
|
}
|
|
6664
6729
|
},
|
|
6665
6730
|
webpack(compiler) {
|
|
@@ -6690,6 +6755,7 @@ var unpluginFactory = (options) => {
|
|
|
6690
6755
|
if (options == null ? void 0 : options.corpId) {
|
|
6691
6756
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6692
6757
|
}
|
|
6758
|
+
startDnsServer(options);
|
|
6693
6759
|
},
|
|
6694
6760
|
async rspack(compiler) {
|
|
6695
6761
|
var _a4, _b, _c, _d2, _e;
|
|
@@ -6718,6 +6784,7 @@ var unpluginFactory = (options) => {
|
|
|
6718
6784
|
"Click to open chrome devtools"
|
|
6719
6785
|
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
6720
6786
|
}
|
|
6787
|
+
startDnsServer(options);
|
|
6721
6788
|
}
|
|
6722
6789
|
};
|
|
6723
6790
|
return unpluginDing;
|