unplugin-dingtalk 0.4.1 → 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/README.md +1 -1
- 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/README.md
CHANGED
package/dist/astro.cjs
CHANGED
|
@@ -6513,19 +6513,92 @@ var import_unplugin = require("unplugin");
|
|
|
6513
6513
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6514
6514
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6515
6515
|
var import_chii = require("chii");
|
|
6516
|
+
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6516
6517
|
var import_get_port_please = require("get-port-please");
|
|
6517
6518
|
var cwd = import_node_process.default.cwd();
|
|
6518
6519
|
var config;
|
|
6519
6520
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
6520
6521
|
var resovedInfo = {
|
|
6521
6522
|
devtoolsInstance: void 0,
|
|
6523
|
+
dnsServerInstence: void 0,
|
|
6522
6524
|
availablePort: void 0,
|
|
6523
6525
|
targetURL: void 0
|
|
6524
6526
|
};
|
|
6527
|
+
function startVueDevtools(enable) {
|
|
6528
|
+
if (enable && !resovedInfo.devtoolsInstance) {
|
|
6529
|
+
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6530
|
+
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6531
|
+
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6532
|
+
resovedInfo.devtoolsInstance = void 0;
|
|
6533
|
+
});
|
|
6534
|
+
import_node_process.default.on("exit", () => {
|
|
6535
|
+
if (resovedInfo.devtoolsInstance) {
|
|
6536
|
+
resovedInfo.devtoolsInstance.kill();
|
|
6537
|
+
}
|
|
6538
|
+
});
|
|
6539
|
+
}
|
|
6540
|
+
}
|
|
6541
|
+
function startDnsServer(options) {
|
|
6542
|
+
function debug(...args) {
|
|
6543
|
+
if (options == null ? void 0 : options.debug) {
|
|
6544
|
+
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
6545
|
+
}
|
|
6546
|
+
}
|
|
6547
|
+
if ((options == null ? void 0 : options.enable) && (options == null ? void 0 : options.dns) && !resovedInfo.dnsServerInstence) {
|
|
6548
|
+
const { Packet } = import_dns2.default;
|
|
6549
|
+
resovedInfo.dnsServerInstence = import_dns2.default.createServer({
|
|
6550
|
+
tcp: true,
|
|
6551
|
+
udp: true,
|
|
6552
|
+
handle: (request, send, rinfo) => {
|
|
6553
|
+
var _a4;
|
|
6554
|
+
const response = Packet.createResponseFromRequest(request);
|
|
6555
|
+
const [question] = request.questions;
|
|
6556
|
+
const { name } = question;
|
|
6557
|
+
if (name === options.dns.host) {
|
|
6558
|
+
response.answers.push({
|
|
6559
|
+
name,
|
|
6560
|
+
type: Packet.TYPE.A,
|
|
6561
|
+
class: Packet.CLASS.IN,
|
|
6562
|
+
ttl: 300,
|
|
6563
|
+
address: (_a4 = options.dns) == null ? void 0 : _a4.ip
|
|
6564
|
+
});
|
|
6565
|
+
debug(`dns request from ${rinfo.address}:${rinfo.port} for ${name} => ${options.dns.ip}`);
|
|
6566
|
+
}
|
|
6567
|
+
send(response);
|
|
6568
|
+
}
|
|
6569
|
+
});
|
|
6570
|
+
resovedInfo.dnsServerInstence.listen({
|
|
6571
|
+
udp: { address: "0.0.0.0", port: 53 },
|
|
6572
|
+
tcp: { address: "0.0.0.0", port: 53 }
|
|
6573
|
+
}).then(() => {
|
|
6574
|
+
debug("DNS server is running.");
|
|
6575
|
+
const dns = new import_dns2.default({
|
|
6576
|
+
port: 53,
|
|
6577
|
+
nameServers: ["127.0.0.1", "8.8.8.8"]
|
|
6578
|
+
});
|
|
6579
|
+
dns.resolveA(options.dns.host).then((addresses) => {
|
|
6580
|
+
var _a4;
|
|
6581
|
+
if (((_a4 = addresses.answers[0]) == null ? void 0 : _a4.address) === options.dns.ip) {
|
|
6582
|
+
startDnsServer(options);
|
|
6583
|
+
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}`)}`);
|
|
6584
|
+
} else {
|
|
6585
|
+
debug(addresses.answers[0].address);
|
|
6586
|
+
throw new Error("DNS server started failed");
|
|
6587
|
+
}
|
|
6588
|
+
}).catch((e2) => {
|
|
6589
|
+
throw e2;
|
|
6590
|
+
});
|
|
6591
|
+
}).catch((e2) => {
|
|
6592
|
+
debug(e2);
|
|
6593
|
+
console.log(` ${import_picocolors.default.red("\u279C")} ${import_picocolors.default.bold((e2 == null ? void 0 : e2.message) || e2)}`);
|
|
6594
|
+
});
|
|
6595
|
+
}
|
|
6596
|
+
}
|
|
6525
6597
|
var unpluginFactory = (options) => {
|
|
6526
6598
|
const {
|
|
6527
|
-
chii
|
|
6599
|
+
chii
|
|
6528
6600
|
} = options || {};
|
|
6601
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
6529
6602
|
function debug(...args) {
|
|
6530
6603
|
if (options == null ? void 0 : options.debug) {
|
|
6531
6604
|
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
@@ -6541,20 +6614,19 @@ var unpluginFactory = (options) => {
|
|
|
6541
6614
|
var _a4, _b, _c;
|
|
6542
6615
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6543
6616
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6544
|
-
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
6545
6617
|
(0, import_chii.start)({
|
|
6546
|
-
host: "0.0.0.0",
|
|
6547
6618
|
port: resovedInfo.availablePort
|
|
6548
6619
|
});
|
|
6620
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
6549
6621
|
}
|
|
6550
6622
|
if (options == null ? void 0 : options.enable) {
|
|
6551
6623
|
const codes = [
|
|
6552
6624
|
"/* eslint-disable */;",
|
|
6553
6625
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6554
|
-
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});` : "",
|
|
6626
|
+
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});` : "",
|
|
6555
6627
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6556
6628
|
const script = document.createElement('script');
|
|
6557
|
-
script.src="http
|
|
6629
|
+
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6558
6630
|
document.body.appendChild(script);
|
|
6559
6631
|
})()` : "",
|
|
6560
6632
|
"/* eslint-enable */",
|
|
@@ -6630,6 +6702,9 @@ var unpluginFactory = (options) => {
|
|
|
6630
6702
|
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`;
|
|
6631
6703
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6632
6704
|
res.end();
|
|
6705
|
+
} else {
|
|
6706
|
+
res.writeHead(404);
|
|
6707
|
+
res.end();
|
|
6633
6708
|
}
|
|
6634
6709
|
} catch (error) {
|
|
6635
6710
|
debug(`${error}`);
|
|
@@ -6644,20 +6719,10 @@ var unpluginFactory = (options) => {
|
|
|
6644
6719
|
res.writeHead(302, {
|
|
6645
6720
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6646
6721
|
});
|
|
6647
|
-
|
|
6648
|
-
resovedInfo.devtoolsInstance = (0, import_node_child_process.exec)("npx vue-devtools");
|
|
6649
|
-
console.log(` ${import_picocolors.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
6650
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
6651
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
6652
|
-
});
|
|
6653
|
-
import_node_process.default.on("exit", () => {
|
|
6654
|
-
if (resovedInfo.devtoolsInstance) {
|
|
6655
|
-
resovedInfo.devtoolsInstance.kill();
|
|
6656
|
-
}
|
|
6657
|
-
});
|
|
6658
|
-
}
|
|
6722
|
+
startVueDevtools((_a5 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a5.enable);
|
|
6659
6723
|
res.end();
|
|
6660
6724
|
});
|
|
6725
|
+
startDnsServer(options);
|
|
6661
6726
|
}
|
|
6662
6727
|
},
|
|
6663
6728
|
webpack(compiler) {
|
|
@@ -6688,6 +6753,7 @@ var unpluginFactory = (options) => {
|
|
|
6688
6753
|
if (options == null ? void 0 : options.corpId) {
|
|
6689
6754
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6690
6755
|
}
|
|
6756
|
+
startDnsServer(options);
|
|
6691
6757
|
},
|
|
6692
6758
|
async rspack(compiler) {
|
|
6693
6759
|
var _a4, _b, _c, _d2, _e;
|
|
@@ -6716,6 +6782,7 @@ var unpluginFactory = (options) => {
|
|
|
6716
6782
|
"Click to open chrome devtools"
|
|
6717
6783
|
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
6718
6784
|
}
|
|
6785
|
+
startDnsServer(options);
|
|
6719
6786
|
}
|
|
6720
6787
|
};
|
|
6721
6788
|
return unpluginDing;
|
package/dist/astro.js
CHANGED
|
@@ -1304,19 +1304,92 @@ import { createUnplugin } from "unplugin";
|
|
|
1304
1304
|
import c from "picocolors";
|
|
1305
1305
|
import cookie from "cookie";
|
|
1306
1306
|
import { start } from "chii";
|
|
1307
|
+
import dns2 from "dns2";
|
|
1307
1308
|
import { getRandomPort } from "get-port-please";
|
|
1308
1309
|
var cwd = process2.cwd();
|
|
1309
1310
|
var config;
|
|
1310
1311
|
var colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
1311
1312
|
var resovedInfo = {
|
|
1312
1313
|
devtoolsInstance: void 0,
|
|
1314
|
+
dnsServerInstence: void 0,
|
|
1313
1315
|
availablePort: void 0,
|
|
1314
1316
|
targetURL: void 0
|
|
1315
1317
|
};
|
|
1318
|
+
function startVueDevtools(enable) {
|
|
1319
|
+
if (enable && !resovedInfo.devtoolsInstance) {
|
|
1320
|
+
resovedInfo.devtoolsInstance = exec("npx vue-devtools");
|
|
1321
|
+
console.log(` ${c.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
1322
|
+
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
1323
|
+
resovedInfo.devtoolsInstance = void 0;
|
|
1324
|
+
});
|
|
1325
|
+
process2.on("exit", () => {
|
|
1326
|
+
if (resovedInfo.devtoolsInstance) {
|
|
1327
|
+
resovedInfo.devtoolsInstance.kill();
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
function startDnsServer(options) {
|
|
1333
|
+
function debug(...args) {
|
|
1334
|
+
if (options == null ? void 0 : options.debug) {
|
|
1335
|
+
console.log(` ${c.yellow("DEBUG")} `, ...args);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
if ((options == null ? void 0 : options.enable) && (options == null ? void 0 : options.dns) && !resovedInfo.dnsServerInstence) {
|
|
1339
|
+
const { Packet } = dns2;
|
|
1340
|
+
resovedInfo.dnsServerInstence = dns2.createServer({
|
|
1341
|
+
tcp: true,
|
|
1342
|
+
udp: true,
|
|
1343
|
+
handle: (request, send, rinfo) => {
|
|
1344
|
+
var _a;
|
|
1345
|
+
const response = Packet.createResponseFromRequest(request);
|
|
1346
|
+
const [question] = request.questions;
|
|
1347
|
+
const { name } = question;
|
|
1348
|
+
if (name === options.dns.host) {
|
|
1349
|
+
response.answers.push({
|
|
1350
|
+
name,
|
|
1351
|
+
type: Packet.TYPE.A,
|
|
1352
|
+
class: Packet.CLASS.IN,
|
|
1353
|
+
ttl: 300,
|
|
1354
|
+
address: (_a = options.dns) == null ? void 0 : _a.ip
|
|
1355
|
+
});
|
|
1356
|
+
debug(`dns request from ${rinfo.address}:${rinfo.port} for ${name} => ${options.dns.ip}`);
|
|
1357
|
+
}
|
|
1358
|
+
send(response);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
resovedInfo.dnsServerInstence.listen({
|
|
1362
|
+
udp: { address: "0.0.0.0", port: 53 },
|
|
1363
|
+
tcp: { address: "0.0.0.0", port: 53 }
|
|
1364
|
+
}).then(() => {
|
|
1365
|
+
debug("DNS server is running.");
|
|
1366
|
+
const dns = new dns2({
|
|
1367
|
+
port: 53,
|
|
1368
|
+
nameServers: ["127.0.0.1", "8.8.8.8"]
|
|
1369
|
+
});
|
|
1370
|
+
dns.resolveA(options.dns.host).then((addresses) => {
|
|
1371
|
+
var _a;
|
|
1372
|
+
if (((_a = addresses.answers[0]) == null ? void 0 : _a.address) === options.dns.ip) {
|
|
1373
|
+
startDnsServer(options);
|
|
1374
|
+
console.log(` ${c.green("\u279C")} ${c.bold(`DNS server is started, please modify the DNS of the remote device to ${options.dns.ip}`)}`);
|
|
1375
|
+
} else {
|
|
1376
|
+
debug(addresses.answers[0].address);
|
|
1377
|
+
throw new Error("DNS server started failed");
|
|
1378
|
+
}
|
|
1379
|
+
}).catch((e) => {
|
|
1380
|
+
throw e;
|
|
1381
|
+
});
|
|
1382
|
+
}).catch((e) => {
|
|
1383
|
+
debug(e);
|
|
1384
|
+
console.log(` ${c.red("\u279C")} ${c.bold((e == null ? void 0 : e.message) || e)}`);
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1316
1388
|
var unpluginFactory = (options) => {
|
|
1317
1389
|
const {
|
|
1318
|
-
chii
|
|
1390
|
+
chii
|
|
1319
1391
|
} = options || {};
|
|
1392
|
+
const enableChii = (chii == null ? void 0 : chii.enable) !== false;
|
|
1320
1393
|
function debug(...args) {
|
|
1321
1394
|
if (options == null ? void 0 : options.debug) {
|
|
1322
1395
|
console.log(` ${c.yellow("DEBUG")} `, ...args);
|
|
@@ -1332,20 +1405,19 @@ var unpluginFactory = (options) => {
|
|
|
1332
1405
|
var _a, _b, _c;
|
|
1333
1406
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
1334
1407
|
resovedInfo.availablePort = await getRandomPort();
|
|
1335
|
-
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
1336
1408
|
start({
|
|
1337
|
-
host: "0.0.0.0",
|
|
1338
1409
|
port: resovedInfo.availablePort
|
|
1339
1410
|
});
|
|
1411
|
+
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
1340
1412
|
}
|
|
1341
1413
|
if (options == null ? void 0 : options.enable) {
|
|
1342
1414
|
const codes = [
|
|
1343
1415
|
"/* eslint-disable */;",
|
|
1344
1416
|
((_a = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a.enable) ? `import { devtools } from '@vue/devtools'
|
|
1345
|
-
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});` : "",
|
|
1417
|
+
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});` : "",
|
|
1346
1418
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
1347
1419
|
const script = document.createElement('script');
|
|
1348
|
-
script.src="http
|
|
1420
|
+
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
1349
1421
|
document.body.appendChild(script);
|
|
1350
1422
|
})()` : "",
|
|
1351
1423
|
"/* eslint-enable */",
|
|
@@ -1421,6 +1493,9 @@ var unpluginFactory = (options) => {
|
|
|
1421
1493
|
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`;
|
|
1422
1494
|
res.writeHead(302, { Location: devToolsUrl });
|
|
1423
1495
|
res.end();
|
|
1496
|
+
} else {
|
|
1497
|
+
res.writeHead(404);
|
|
1498
|
+
res.end();
|
|
1424
1499
|
}
|
|
1425
1500
|
} catch (error) {
|
|
1426
1501
|
debug(`${error}`);
|
|
@@ -1435,20 +1510,10 @@ var unpluginFactory = (options) => {
|
|
|
1435
1510
|
res.writeHead(302, {
|
|
1436
1511
|
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
1437
1512
|
});
|
|
1438
|
-
|
|
1439
|
-
resovedInfo.devtoolsInstance = exec("npx vue-devtools");
|
|
1440
|
-
console.log(` ${c.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
1441
|
-
resovedInfo.devtoolsInstance.on("exit", () => {
|
|
1442
|
-
resovedInfo.devtoolsInstance = void 0;
|
|
1443
|
-
});
|
|
1444
|
-
process2.on("exit", () => {
|
|
1445
|
-
if (resovedInfo.devtoolsInstance) {
|
|
1446
|
-
resovedInfo.devtoolsInstance.kill();
|
|
1447
|
-
}
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1513
|
+
startVueDevtools((_a2 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a2.enable);
|
|
1450
1514
|
res.end();
|
|
1451
1515
|
});
|
|
1516
|
+
startDnsServer(options);
|
|
1452
1517
|
}
|
|
1453
1518
|
},
|
|
1454
1519
|
webpack(compiler) {
|
|
@@ -1479,6 +1544,7 @@ var unpluginFactory = (options) => {
|
|
|
1479
1544
|
if (options == null ? void 0 : options.corpId) {
|
|
1480
1545
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
1481
1546
|
}
|
|
1547
|
+
startDnsServer(options);
|
|
1482
1548
|
},
|
|
1483
1549
|
async rspack(compiler) {
|
|
1484
1550
|
var _a, _b, _c, _d, _e;
|
|
@@ -1507,6 +1573,7 @@ var unpluginFactory = (options) => {
|
|
|
1507
1573
|
"Click to open chrome devtools"
|
|
1508
1574
|
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
1509
1575
|
}
|
|
1576
|
+
startDnsServer(options);
|
|
1510
1577
|
}
|
|
1511
1578
|
};
|
|
1512
1579
|
return unpluginDing;
|
|
@@ -1517,6 +1584,8 @@ var src_default = unplugin;
|
|
|
1517
1584
|
export {
|
|
1518
1585
|
fetch,
|
|
1519
1586
|
resovedInfo,
|
|
1587
|
+
startVueDevtools,
|
|
1588
|
+
startDnsServer,
|
|
1520
1589
|
unpluginFactory,
|
|
1521
1590
|
unplugin,
|
|
1522
1591
|
src_default
|
package/dist/esbuild.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;
|