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/index.cjs
CHANGED
|
@@ -5210,6 +5210,8 @@ var src_exports = {};
|
|
|
5210
5210
|
__export(src_exports, {
|
|
5211
5211
|
default: () => src_default,
|
|
5212
5212
|
resovedInfo: () => resovedInfo,
|
|
5213
|
+
startDnsServer: () => startDnsServer,
|
|
5214
|
+
startVueDevtools: () => startVueDevtools,
|
|
5213
5215
|
unplugin: () => unplugin,
|
|
5214
5216
|
unpluginFactory: () => unpluginFactory
|
|
5215
5217
|
});
|
|
@@ -6514,19 +6516,92 @@ var import_unplugin = require("unplugin");
|
|
|
6514
6516
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6515
6517
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6516
6518
|
var import_chii = require("chii");
|
|
6519
|
+
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6517
6520
|
var import_get_port_please = require("get-port-please");
|
|
6518
6521
|
var cwd = import_node_process.default.cwd();
|
|
6519
6522
|
var config;
|
|
6520
6523
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
6521
6524
|
var resovedInfo = {
|
|
6522
6525
|
devtoolsInstance: void 0,
|
|
6526
|
+
dnsServerInstence: void 0,
|
|
6523
6527
|
availablePort: void 0,
|
|
6524
6528
|
targetURL: void 0
|
|
6525
6529
|
};
|
|
6530
|
+
function startVueDevtools(enable) {
|
|
6531
|
+
if (enable && !resovedInfo.devtoolsInstance) {
|
|
6532
|
+
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6533
|
+
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6534
|
+
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6535
|
+
resovedInfo.devtoolsInstance = void 0;
|
|
6536
|
+
});
|
|
6537
|
+
import_node_process.default.on("exit", () => {
|
|
6538
|
+
if (resovedInfo.devtoolsInstance) {
|
|
6539
|
+
resovedInfo.devtoolsInstance.kill();
|
|
6540
|
+
}
|
|
6541
|
+
});
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
function startDnsServer(options) {
|
|
6545
|
+
function debug(...args) {
|
|
6546
|
+
if (options == null ? void 0 : options.debug) {
|
|
6547
|
+
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
6548
|
+
}
|
|
6549
|
+
}
|
|
6550
|
+
if ((options == null ? void 0 : options.enable) && (options == null ? void 0 : options.dns) && !resovedInfo.dnsServerInstence) {
|
|
6551
|
+
const { Packet } = import_dns2.default;
|
|
6552
|
+
resovedInfo.dnsServerInstence = import_dns2.default.createServer({
|
|
6553
|
+
tcp: true,
|
|
6554
|
+
udp: true,
|
|
6555
|
+
handle: (request, send, rinfo) => {
|
|
6556
|
+
var _a4;
|
|
6557
|
+
const response = Packet.createResponseFromRequest(request);
|
|
6558
|
+
const [question] = request.questions;
|
|
6559
|
+
const { name } = question;
|
|
6560
|
+
if (name === options.dns.host) {
|
|
6561
|
+
response.answers.push({
|
|
6562
|
+
name,
|
|
6563
|
+
type: Packet.TYPE.A,
|
|
6564
|
+
class: Packet.CLASS.IN,
|
|
6565
|
+
ttl: 300,
|
|
6566
|
+
address: (_a4 = options.dns) == null ? void 0 : _a4.ip
|
|
6567
|
+
});
|
|
6568
|
+
debug(`dns request from ${rinfo.address}:${rinfo.port} for ${name} => ${options.dns.ip}`);
|
|
6569
|
+
}
|
|
6570
|
+
send(response);
|
|
6571
|
+
}
|
|
6572
|
+
});
|
|
6573
|
+
resovedInfo.dnsServerInstence.listen({
|
|
6574
|
+
udp: { address: "0.0.0.0", port: 53 },
|
|
6575
|
+
tcp: { address: "0.0.0.0", port: 53 }
|
|
6576
|
+
}).then(() => {
|
|
6577
|
+
debug("DNS server is running.");
|
|
6578
|
+
const dns = new import_dns2.default({
|
|
6579
|
+
port: 53,
|
|
6580
|
+
nameServers: ["127.0.0.1", "8.8.8.8"]
|
|
6581
|
+
});
|
|
6582
|
+
dns.resolveA(options.dns.host).then((addresses) => {
|
|
6583
|
+
var _a4;
|
|
6584
|
+
if (((_a4 = addresses.answers[0]) == null ? void 0 : _a4.address) === options.dns.ip) {
|
|
6585
|
+
startDnsServer(options);
|
|
6586
|
+
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}`)}`);
|
|
6587
|
+
} else {
|
|
6588
|
+
debug(addresses.answers[0].address);
|
|
6589
|
+
throw new Error("DNS server started failed");
|
|
6590
|
+
}
|
|
6591
|
+
}).catch((e2) => {
|
|
6592
|
+
throw e2;
|
|
6593
|
+
});
|
|
6594
|
+
}).catch((e2) => {
|
|
6595
|
+
debug(e2);
|
|
6596
|
+
console.log(` ${import_picocolors.default.red("\u279C")} ${import_picocolors.default.bold((e2 == null ? void 0 : e2.message) || e2)}`);
|
|
6597
|
+
});
|
|
6598
|
+
}
|
|
6599
|
+
}
|
|
6526
6600
|
var unpluginFactory = (options) => {
|
|
6527
6601
|
const {
|
|
6528
|
-
chii
|
|
6602
|
+
chii
|
|
6529
6603
|
} = options || {};
|
|
6604
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
6530
6605
|
function debug(...args) {
|
|
6531
6606
|
if (options == null ? void 0 : options.debug) {
|
|
6532
6607
|
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
@@ -6542,20 +6617,19 @@ var unpluginFactory = (options) => {
|
|
|
6542
6617
|
var _a4, _b, _c;
|
|
6543
6618
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6544
6619
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6545
|
-
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
6546
6620
|
(0, import_chii.start)({
|
|
6547
|
-
host: "0.0.0.0",
|
|
6548
6621
|
port: resovedInfo.availablePort
|
|
6549
6622
|
});
|
|
6623
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
6550
6624
|
}
|
|
6551
6625
|
if (options == null ? void 0 : options.enable) {
|
|
6552
6626
|
const codes = [
|
|
6553
6627
|
"/* eslint-disable */;",
|
|
6554
6628
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6555
|
-
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});` : "",
|
|
6629
|
+
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});` : "",
|
|
6556
6630
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6557
6631
|
const script = document.createElement('script');
|
|
6558
|
-
script.src="http
|
|
6632
|
+
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6559
6633
|
document.body.appendChild(script);
|
|
6560
6634
|
})()` : "",
|
|
6561
6635
|
"/* eslint-enable */",
|
|
@@ -6631,6 +6705,9 @@ var unpluginFactory = (options) => {
|
|
|
6631
6705
|
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`;
|
|
6632
6706
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6633
6707
|
res.end();
|
|
6708
|
+
} else {
|
|
6709
|
+
res.writeHead(404);
|
|
6710
|
+
res.end();
|
|
6634
6711
|
}
|
|
6635
6712
|
} catch (error) {
|
|
6636
6713
|
debug(`${error}`);
|
|
@@ -6645,20 +6722,10 @@ var unpluginFactory = (options) => {
|
|
|
6645
6722
|
res.writeHead(302, {
|
|
6646
6723
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6647
6724
|
});
|
|
6648
|
-
|
|
6649
|
-
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6650
|
-
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6651
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6652
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
6653
|
-
});
|
|
6654
|
-
import_node_process.default.on("exit", () => {
|
|
6655
|
-
if (resovedInfo.devtoolsInstance) {
|
|
6656
|
-
resovedInfo.devtoolsInstance.kill();
|
|
6657
|
-
}
|
|
6658
|
-
});
|
|
6659
|
-
}
|
|
6725
|
+
startVueDevtools((_a5 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a5.enable);
|
|
6660
6726
|
res.end();
|
|
6661
6727
|
});
|
|
6728
|
+
startDnsServer(options);
|
|
6662
6729
|
}
|
|
6663
6730
|
},
|
|
6664
6731
|
webpack(compiler) {
|
|
@@ -6689,6 +6756,7 @@ var unpluginFactory = (options) => {
|
|
|
6689
6756
|
if (options == null ? void 0 : options.corpId) {
|
|
6690
6757
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6691
6758
|
}
|
|
6759
|
+
startDnsServer(options);
|
|
6692
6760
|
},
|
|
6693
6761
|
async rspack(compiler) {
|
|
6694
6762
|
var _a4, _b, _c, _d2, _e;
|
|
@@ -6717,6 +6785,7 @@ var unpluginFactory = (options) => {
|
|
|
6717
6785
|
"Click to open chrome devtools"
|
|
6718
6786
|
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
6719
6787
|
}
|
|
6788
|
+
startDnsServer(options);
|
|
6720
6789
|
}
|
|
6721
6790
|
};
|
|
6722
6791
|
return unpluginDing;
|
|
@@ -6726,6 +6795,8 @@ var src_default = unplugin;
|
|
|
6726
6795
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6727
6796
|
0 && (module.exports = {
|
|
6728
6797
|
resovedInfo,
|
|
6798
|
+
startDnsServer,
|
|
6799
|
+
startVueDevtools,
|
|
6729
6800
|
unplugin,
|
|
6730
6801
|
unpluginFactory
|
|
6731
6802
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _unplugin from 'unplugin';
|
|
2
2
|
import { UnpluginFactory } from 'unplugin';
|
|
3
3
|
import { ChildProcess } from 'node:child_process';
|
|
4
|
+
import dns2 from 'dns2';
|
|
4
5
|
import { Options } from './types.cjs';
|
|
5
6
|
import 'webpack-dev-server';
|
|
6
7
|
import 'node:http';
|
|
@@ -8,10 +9,13 @@ import 'vite-plugin-vconsole';
|
|
|
8
9
|
|
|
9
10
|
declare const resovedInfo: {
|
|
10
11
|
devtoolsInstance: ChildProcess | undefined;
|
|
12
|
+
dnsServerInstence: ReturnType<typeof dns2.createServer> | undefined;
|
|
11
13
|
availablePort: number | undefined;
|
|
12
14
|
targetURL: undefined | URL;
|
|
13
15
|
};
|
|
16
|
+
declare function startVueDevtools(enable?: boolean): void;
|
|
17
|
+
declare function startDnsServer(options?: Options): void;
|
|
14
18
|
declare const unpluginFactory: UnpluginFactory<Options | undefined, boolean>;
|
|
15
19
|
declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
|
|
16
20
|
|
|
17
|
-
export { unplugin as default, resovedInfo, unplugin, unpluginFactory };
|
|
21
|
+
export { unplugin as default, resovedInfo, startDnsServer, startVueDevtools, unplugin, unpluginFactory };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _unplugin from 'unplugin';
|
|
2
2
|
import { UnpluginFactory } from 'unplugin';
|
|
3
3
|
import { ChildProcess } from 'node:child_process';
|
|
4
|
+
import dns2 from 'dns2';
|
|
4
5
|
import { Options } from './types.js';
|
|
5
6
|
import 'webpack-dev-server';
|
|
6
7
|
import 'node:http';
|
|
@@ -8,10 +9,13 @@ import 'vite-plugin-vconsole';
|
|
|
8
9
|
|
|
9
10
|
declare const resovedInfo: {
|
|
10
11
|
devtoolsInstance: ChildProcess | undefined;
|
|
12
|
+
dnsServerInstence: ReturnType<typeof dns2.createServer> | undefined;
|
|
11
13
|
availablePort: number | undefined;
|
|
12
14
|
targetURL: undefined | URL;
|
|
13
15
|
};
|
|
16
|
+
declare function startVueDevtools(enable?: boolean): void;
|
|
17
|
+
declare function startDnsServer(options?: Options): void;
|
|
14
18
|
declare const unpluginFactory: UnpluginFactory<Options | undefined, boolean>;
|
|
15
19
|
declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
|
|
16
20
|
|
|
17
|
-
export { unplugin as default, resovedInfo, unplugin, unpluginFactory };
|
|
21
|
+
export { unplugin as default, resovedInfo, startDnsServer, startVueDevtools, unplugin, unpluginFactory };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resovedInfo,
|
|
3
3
|
src_default,
|
|
4
|
+
startDnsServer,
|
|
5
|
+
startVueDevtools,
|
|
4
6
|
unplugin,
|
|
5
7
|
unpluginFactory
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OSHJOAQB.js";
|
|
7
9
|
import "./chunk-PMOTCIQR.js";
|
|
8
10
|
export {
|
|
9
11
|
src_default as default,
|
|
10
12
|
resovedInfo,
|
|
13
|
+
startDnsServer,
|
|
14
|
+
startVueDevtools,
|
|
11
15
|
unplugin,
|
|
12
16
|
unpluginFactory
|
|
13
17
|
};
|
package/dist/nuxt.cjs
CHANGED
|
@@ -6518,19 +6518,92 @@ var import_unplugin = require("unplugin");
|
|
|
6518
6518
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6519
6519
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6520
6520
|
var import_chii = require("chii");
|
|
6521
|
+
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6521
6522
|
var import_get_port_please = require("get-port-please");
|
|
6522
6523
|
var cwd = import_node_process.default.cwd();
|
|
6523
6524
|
var config;
|
|
6524
6525
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
6525
6526
|
var resovedInfo = {
|
|
6526
6527
|
devtoolsInstance: void 0,
|
|
6528
|
+
dnsServerInstence: void 0,
|
|
6527
6529
|
availablePort: void 0,
|
|
6528
6530
|
targetURL: void 0
|
|
6529
6531
|
};
|
|
6532
|
+
function startVueDevtools(enable) {
|
|
6533
|
+
if (enable && !resovedInfo.devtoolsInstance) {
|
|
6534
|
+
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6535
|
+
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6536
|
+
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6537
|
+
resovedInfo.devtoolsInstance = void 0;
|
|
6538
|
+
});
|
|
6539
|
+
import_node_process.default.on("exit", () => {
|
|
6540
|
+
if (resovedInfo.devtoolsInstance) {
|
|
6541
|
+
resovedInfo.devtoolsInstance.kill();
|
|
6542
|
+
}
|
|
6543
|
+
});
|
|
6544
|
+
}
|
|
6545
|
+
}
|
|
6546
|
+
function startDnsServer(options) {
|
|
6547
|
+
function debug(...args) {
|
|
6548
|
+
if (options == null ? void 0 : options.debug) {
|
|
6549
|
+
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
6550
|
+
}
|
|
6551
|
+
}
|
|
6552
|
+
if ((options == null ? void 0 : options.enable) && (options == null ? void 0 : options.dns) && !resovedInfo.dnsServerInstence) {
|
|
6553
|
+
const { Packet } = import_dns2.default;
|
|
6554
|
+
resovedInfo.dnsServerInstence = import_dns2.default.createServer({
|
|
6555
|
+
tcp: true,
|
|
6556
|
+
udp: true,
|
|
6557
|
+
handle: (request, send, rinfo) => {
|
|
6558
|
+
var _a4;
|
|
6559
|
+
const response = Packet.createResponseFromRequest(request);
|
|
6560
|
+
const [question] = request.questions;
|
|
6561
|
+
const { name } = question;
|
|
6562
|
+
if (name === options.dns.host) {
|
|
6563
|
+
response.answers.push({
|
|
6564
|
+
name,
|
|
6565
|
+
type: Packet.TYPE.A,
|
|
6566
|
+
class: Packet.CLASS.IN,
|
|
6567
|
+
ttl: 300,
|
|
6568
|
+
address: (_a4 = options.dns) == null ? void 0 : _a4.ip
|
|
6569
|
+
});
|
|
6570
|
+
debug(`dns request from ${rinfo.address}:${rinfo.port} for ${name} => ${options.dns.ip}`);
|
|
6571
|
+
}
|
|
6572
|
+
send(response);
|
|
6573
|
+
}
|
|
6574
|
+
});
|
|
6575
|
+
resovedInfo.dnsServerInstence.listen({
|
|
6576
|
+
udp: { address: "0.0.0.0", port: 53 },
|
|
6577
|
+
tcp: { address: "0.0.0.0", port: 53 }
|
|
6578
|
+
}).then(() => {
|
|
6579
|
+
debug("DNS server is running.");
|
|
6580
|
+
const dns = new import_dns2.default({
|
|
6581
|
+
port: 53,
|
|
6582
|
+
nameServers: ["127.0.0.1", "8.8.8.8"]
|
|
6583
|
+
});
|
|
6584
|
+
dns.resolveA(options.dns.host).then((addresses) => {
|
|
6585
|
+
var _a4;
|
|
6586
|
+
if (((_a4 = addresses.answers[0]) == null ? void 0 : _a4.address) === options.dns.ip) {
|
|
6587
|
+
startDnsServer(options);
|
|
6588
|
+
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}`)}`);
|
|
6589
|
+
} else {
|
|
6590
|
+
debug(addresses.answers[0].address);
|
|
6591
|
+
throw new Error("DNS server started failed");
|
|
6592
|
+
}
|
|
6593
|
+
}).catch((e2) => {
|
|
6594
|
+
throw e2;
|
|
6595
|
+
});
|
|
6596
|
+
}).catch((e2) => {
|
|
6597
|
+
debug(e2);
|
|
6598
|
+
console.log(` ${import_picocolors.default.red("\u279C")} ${import_picocolors.default.bold((e2 == null ? void 0 : e2.message) || e2)}`);
|
|
6599
|
+
});
|
|
6600
|
+
}
|
|
6601
|
+
}
|
|
6530
6602
|
var unpluginFactory = (options) => {
|
|
6531
6603
|
const {
|
|
6532
|
-
chii
|
|
6604
|
+
chii
|
|
6533
6605
|
} = options || {};
|
|
6606
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
6534
6607
|
function debug(...args) {
|
|
6535
6608
|
if (options == null ? void 0 : options.debug) {
|
|
6536
6609
|
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
@@ -6546,20 +6619,19 @@ var unpluginFactory = (options) => {
|
|
|
6546
6619
|
var _a4, _b, _c;
|
|
6547
6620
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6548
6621
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6549
|
-
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
6550
6622
|
(0, import_chii.start)({
|
|
6551
|
-
host: "0.0.0.0",
|
|
6552
6623
|
port: resovedInfo.availablePort
|
|
6553
6624
|
});
|
|
6625
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
6554
6626
|
}
|
|
6555
6627
|
if (options == null ? void 0 : options.enable) {
|
|
6556
6628
|
const codes = [
|
|
6557
6629
|
"/* eslint-disable */;",
|
|
6558
6630
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6559
|
-
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});` : "",
|
|
6631
|
+
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});` : "",
|
|
6560
6632
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6561
6633
|
const script = document.createElement('script');
|
|
6562
|
-
script.src="http
|
|
6634
|
+
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6563
6635
|
document.body.appendChild(script);
|
|
6564
6636
|
})()` : "",
|
|
6565
6637
|
"/* eslint-enable */",
|
|
@@ -6635,6 +6707,9 @@ var unpluginFactory = (options) => {
|
|
|
6635
6707
|
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`;
|
|
6636
6708
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6637
6709
|
res.end();
|
|
6710
|
+
} else {
|
|
6711
|
+
res.writeHead(404);
|
|
6712
|
+
res.end();
|
|
6638
6713
|
}
|
|
6639
6714
|
} catch (error) {
|
|
6640
6715
|
debug(`${error}`);
|
|
@@ -6649,20 +6724,10 @@ var unpluginFactory = (options) => {
|
|
|
6649
6724
|
res.writeHead(302, {
|
|
6650
6725
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6651
6726
|
});
|
|
6652
|
-
|
|
6653
|
-
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6654
|
-
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6655
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6656
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
6657
|
-
});
|
|
6658
|
-
import_node_process.default.on("exit", () => {
|
|
6659
|
-
if (resovedInfo.devtoolsInstance) {
|
|
6660
|
-
resovedInfo.devtoolsInstance.kill();
|
|
6661
|
-
}
|
|
6662
|
-
});
|
|
6663
|
-
}
|
|
6727
|
+
startVueDevtools((_a5 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a5.enable);
|
|
6664
6728
|
res.end();
|
|
6665
6729
|
});
|
|
6730
|
+
startDnsServer(options);
|
|
6666
6731
|
}
|
|
6667
6732
|
},
|
|
6668
6733
|
webpack(compiler) {
|
|
@@ -6693,6 +6758,7 @@ var unpluginFactory = (options) => {
|
|
|
6693
6758
|
if (options == null ? void 0 : options.corpId) {
|
|
6694
6759
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6695
6760
|
}
|
|
6761
|
+
startDnsServer(options);
|
|
6696
6762
|
},
|
|
6697
6763
|
async rspack(compiler) {
|
|
6698
6764
|
var _a4, _b, _c, _d2, _e;
|
|
@@ -6721,6 +6787,7 @@ var unpluginFactory = (options) => {
|
|
|
6721
6787
|
"Click to open chrome devtools"
|
|
6722
6788
|
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
6723
6789
|
}
|
|
6790
|
+
startDnsServer(options);
|
|
6724
6791
|
}
|
|
6725
6792
|
};
|
|
6726
6793
|
return unpluginDing;
|
package/dist/nuxt.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -6514,19 +6514,92 @@ var import_unplugin = require("unplugin");
|
|
|
6514
6514
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6515
6515
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6516
6516
|
var import_chii = require("chii");
|
|
6517
|
+
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6517
6518
|
var import_get_port_please = require("get-port-please");
|
|
6518
6519
|
var cwd = import_node_process.default.cwd();
|
|
6519
6520
|
var config;
|
|
6520
6521
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
6521
6522
|
var resovedInfo = {
|
|
6522
6523
|
devtoolsInstance: void 0,
|
|
6524
|
+
dnsServerInstence: void 0,
|
|
6523
6525
|
availablePort: void 0,
|
|
6524
6526
|
targetURL: void 0
|
|
6525
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
|
+
}
|
|
6526
6598
|
var unpluginFactory = (options) => {
|
|
6527
6599
|
const {
|
|
6528
|
-
chii
|
|
6600
|
+
chii
|
|
6529
6601
|
} = options || {};
|
|
6602
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
6530
6603
|
function debug(...args) {
|
|
6531
6604
|
if (options == null ? void 0 : options.debug) {
|
|
6532
6605
|
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
@@ -6542,20 +6615,19 @@ var unpluginFactory = (options) => {
|
|
|
6542
6615
|
var _a4, _b, _c;
|
|
6543
6616
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6544
6617
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6545
|
-
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
6546
6618
|
(0, import_chii.start)({
|
|
6547
|
-
host: "0.0.0.0",
|
|
6548
6619
|
port: resovedInfo.availablePort
|
|
6549
6620
|
});
|
|
6621
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
6550
6622
|
}
|
|
6551
6623
|
if (options == null ? void 0 : options.enable) {
|
|
6552
6624
|
const codes = [
|
|
6553
6625
|
"/* eslint-disable */;",
|
|
6554
6626
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6555
|
-
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});` : "",
|
|
6556
6628
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6557
6629
|
const script = document.createElement('script');
|
|
6558
|
-
script.src="http
|
|
6630
|
+
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6559
6631
|
document.body.appendChild(script);
|
|
6560
6632
|
})()` : "",
|
|
6561
6633
|
"/* eslint-enable */",
|
|
@@ -6631,6 +6703,9 @@ var unpluginFactory = (options) => {
|
|
|
6631
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`;
|
|
6632
6704
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6633
6705
|
res.end();
|
|
6706
|
+
} else {
|
|
6707
|
+
res.writeHead(404);
|
|
6708
|
+
res.end();
|
|
6634
6709
|
}
|
|
6635
6710
|
} catch (error) {
|
|
6636
6711
|
debug(`${error}`);
|
|
@@ -6645,20 +6720,10 @@ var unpluginFactory = (options) => {
|
|
|
6645
6720
|
res.writeHead(302, {
|
|
6646
6721
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6647
6722
|
});
|
|
6648
|
-
|
|
6649
|
-
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6650
|
-
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6651
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6652
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
6653
|
-
});
|
|
6654
|
-
import_node_process.default.on("exit", () => {
|
|
6655
|
-
if (resovedInfo.devtoolsInstance) {
|
|
6656
|
-
resovedInfo.devtoolsInstance.kill();
|
|
6657
|
-
}
|
|
6658
|
-
});
|
|
6659
|
-
}
|
|
6723
|
+
startVueDevtools((_a5 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a5.enable);
|
|
6660
6724
|
res.end();
|
|
6661
6725
|
});
|
|
6726
|
+
startDnsServer(options);
|
|
6662
6727
|
}
|
|
6663
6728
|
},
|
|
6664
6729
|
webpack(compiler) {
|
|
@@ -6689,6 +6754,7 @@ var unpluginFactory = (options) => {
|
|
|
6689
6754
|
if (options == null ? void 0 : options.corpId) {
|
|
6690
6755
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6691
6756
|
}
|
|
6757
|
+
startDnsServer(options);
|
|
6692
6758
|
},
|
|
6693
6759
|
async rspack(compiler) {
|
|
6694
6760
|
var _a4, _b, _c, _d2, _e;
|
|
@@ -6717,6 +6783,7 @@ var unpluginFactory = (options) => {
|
|
|
6717
6783
|
"Click to open chrome devtools"
|
|
6718
6784
|
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
6719
6785
|
}
|
|
6786
|
+
startDnsServer(options);
|
|
6720
6787
|
}
|
|
6721
6788
|
};
|
|
6722
6789
|
return unpluginDing;
|