unplugin-dingtalk 0.5.0 → 0.5.2
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 +74 -10
- package/dist/astro.js +4 -4
- package/dist/{chunk-OSHJOAQB.js → chunk-QU7HLXVD.js} +87 -26
- package/dist/{chunk-TZDLEHKX.js → chunk-VQXY6FXR.js} +1 -1
- package/dist/{chunk-PMOTCIQR.js → chunk-ZEHXGFFH.js} +3 -3
- package/dist/esbuild.cjs +72 -8
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +77 -13
- package/dist/index.js +4 -4
- package/dist/{multipart-parser-HI4LNJC5.js → multipart-parser-VO5TIRQZ.js} +4 -1
- package/dist/nuxt.cjs +72 -8
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +72 -8
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +73 -9
- package/dist/rspack.d.cts +1 -2
- package/dist/rspack.d.ts +1 -2
- package/dist/rspack.js +3 -3
- package/dist/vite.cjs +72 -8
- package/dist/vite.js +3 -3
- package/dist/webpack.cjs +73 -9
- package/dist/webpack.js +3 -3
- package/package.json +5 -4
package/dist/astro.cjs
CHANGED
|
@@ -5069,6 +5069,7 @@ var init_multipart_parser = __esm({
|
|
|
5069
5069
|
state = S.HEADER_FIELD;
|
|
5070
5070
|
mark("onHeaderField");
|
|
5071
5071
|
index = 0;
|
|
5072
|
+
// falls through
|
|
5072
5073
|
case S.HEADER_FIELD:
|
|
5073
5074
|
if (c2 === CR) {
|
|
5074
5075
|
clear("onHeaderField");
|
|
@@ -5098,6 +5099,7 @@ var init_multipart_parser = __esm({
|
|
|
5098
5099
|
}
|
|
5099
5100
|
mark("onHeaderValue");
|
|
5100
5101
|
state = S.HEADER_VALUE;
|
|
5102
|
+
// falls through
|
|
5101
5103
|
case S.HEADER_VALUE:
|
|
5102
5104
|
if (c2 === CR) {
|
|
5103
5105
|
dataCallback("onHeaderValue", true);
|
|
@@ -5121,6 +5123,7 @@ var init_multipart_parser = __esm({
|
|
|
5121
5123
|
case S.PART_DATA_START:
|
|
5122
5124
|
state = S.PART_DATA;
|
|
5123
5125
|
mark("onPartData");
|
|
5126
|
+
// falls through
|
|
5124
5127
|
case S.PART_DATA:
|
|
5125
5128
|
previousIndex = index;
|
|
5126
5129
|
if (index === 0) {
|
|
@@ -5215,6 +5218,8 @@ module.exports = __toCommonJS(astro_exports);
|
|
|
5215
5218
|
// src/index.ts
|
|
5216
5219
|
var import_node_child_process = require("child_process");
|
|
5217
5220
|
var import_node_process = __toESM(require("process"), 1);
|
|
5221
|
+
var import_node_http3 = require("http");
|
|
5222
|
+
var import_node_net2 = require("net");
|
|
5218
5223
|
|
|
5219
5224
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
|
|
5220
5225
|
var import_node_http2 = __toESM(require("http"), 1);
|
|
@@ -6512,9 +6517,10 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6512
6517
|
var import_unplugin = require("unplugin");
|
|
6513
6518
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6514
6519
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6515
|
-
var
|
|
6520
|
+
var import_z_chii = require("z-chii");
|
|
6516
6521
|
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6517
6522
|
var import_get_port_please = require("get-port-please");
|
|
6523
|
+
var import_http_proxy = __toESM(require("http-proxy"), 1);
|
|
6518
6524
|
var cwd = import_node_process.default.cwd();
|
|
6519
6525
|
var config;
|
|
6520
6526
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
@@ -6614,7 +6620,7 @@ var unpluginFactory = (options) => {
|
|
|
6614
6620
|
var _a4, _b, _c;
|
|
6615
6621
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6616
6622
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6617
|
-
(0,
|
|
6623
|
+
(0, import_z_chii.start)({
|
|
6618
6624
|
port: resovedInfo.availablePort
|
|
6619
6625
|
});
|
|
6620
6626
|
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
@@ -6624,11 +6630,6 @@ var unpluginFactory = (options) => {
|
|
|
6624
6630
|
"/* eslint-disable */;",
|
|
6625
6631
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6626
6632
|
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});` : "",
|
|
6627
|
-
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6628
|
-
const script = document.createElement('script');
|
|
6629
|
-
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6630
|
-
document.body.appendChild(script);
|
|
6631
|
-
})()` : "",
|
|
6632
6633
|
"/* eslint-enable */",
|
|
6633
6634
|
`${_source};`
|
|
6634
6635
|
];
|
|
@@ -6648,6 +6649,22 @@ var unpluginFactory = (options) => {
|
|
|
6648
6649
|
configResolved(_config) {
|
|
6649
6650
|
config = _config;
|
|
6650
6651
|
},
|
|
6652
|
+
transformIndexHtml(html) {
|
|
6653
|
+
if (enableChii) {
|
|
6654
|
+
return html.replace(
|
|
6655
|
+
"</body>",
|
|
6656
|
+
`</body>
|
|
6657
|
+
<script>
|
|
6658
|
+
(() => {
|
|
6659
|
+
const script = document.createElement('script');
|
|
6660
|
+
script.src="./__chii_proxy/target.js";
|
|
6661
|
+
document.body.appendChild(script);
|
|
6662
|
+
})()
|
|
6663
|
+
</script>
|
|
6664
|
+
`
|
|
6665
|
+
);
|
|
6666
|
+
}
|
|
6667
|
+
},
|
|
6651
6668
|
async configureServer(server) {
|
|
6652
6669
|
var _a4, _b;
|
|
6653
6670
|
if (!(options == null ? void 0 : options.enable)) {
|
|
@@ -6683,7 +6700,7 @@ var unpluginFactory = (options) => {
|
|
|
6683
6700
|
server.middlewares.use((req, res, next) => {
|
|
6684
6701
|
const cookies = import_cookie.default.parse(req.headers.cookie || "");
|
|
6685
6702
|
for (const [name, value] of Object.entries(cookies)) {
|
|
6686
|
-
if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
6703
|
+
if (value && options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
6687
6704
|
const serializedCookie = import_cookie.default.serialize(name, value, {
|
|
6688
6705
|
httpOnly: false
|
|
6689
6706
|
});
|
|
@@ -6694,6 +6711,51 @@ var unpluginFactory = (options) => {
|
|
|
6694
6711
|
});
|
|
6695
6712
|
}
|
|
6696
6713
|
if (enableChii) {
|
|
6714
|
+
let createProxyMiddleware2 = function() {
|
|
6715
|
+
let proxy = null;
|
|
6716
|
+
const handleUpgrade = (req, socket, head) => {
|
|
6717
|
+
var _a5;
|
|
6718
|
+
if (proxy && ((_a5 = req.url) == null ? void 0 : _a5.startsWith("/__chii_proxy"))) {
|
|
6719
|
+
debug("WS upgrade:", req.url);
|
|
6720
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
6721
|
+
proxy.ws(req, socket, head);
|
|
6722
|
+
}
|
|
6723
|
+
};
|
|
6724
|
+
return (resolvedInfo) => {
|
|
6725
|
+
return (req, res, next) => {
|
|
6726
|
+
var _a5;
|
|
6727
|
+
if (!proxy && resolvedInfo.availablePort) {
|
|
6728
|
+
proxy = import_http_proxy.default.createProxyServer({
|
|
6729
|
+
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
6730
|
+
ws: true
|
|
6731
|
+
// changeOrigin: true, // Consider if you need this
|
|
6732
|
+
});
|
|
6733
|
+
proxy.on("error", (err, req2, res2) => {
|
|
6734
|
+
console.error("Proxy error:", err);
|
|
6735
|
+
if (res2 instanceof import_node_http3.ServerResponse) {
|
|
6736
|
+
if (!res2.headersSent) {
|
|
6737
|
+
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
6738
|
+
}
|
|
6739
|
+
res2.end(`Proxy error: ${err.message}`);
|
|
6740
|
+
} else if (res2 instanceof import_node_net2.Socket) {
|
|
6741
|
+
res2.destroy();
|
|
6742
|
+
}
|
|
6743
|
+
});
|
|
6744
|
+
if (req.socket.server) {
|
|
6745
|
+
req.socket.server.on("upgrade", handleUpgrade);
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
if (proxy && ((_a5 = req.url) == null ? void 0 : _a5.startsWith("/__chii_proxy"))) {
|
|
6749
|
+
debug(req.url);
|
|
6750
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
6751
|
+
proxy.web(req, res);
|
|
6752
|
+
} else {
|
|
6753
|
+
next();
|
|
6754
|
+
}
|
|
6755
|
+
};
|
|
6756
|
+
};
|
|
6757
|
+
};
|
|
6758
|
+
var createProxyMiddleware = createProxyMiddleware2;
|
|
6697
6759
|
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
6698
6760
|
try {
|
|
6699
6761
|
const raw = await fetch(`http://localhost:${resovedInfo.availablePort}/targets`);
|
|
@@ -6712,6 +6774,8 @@ var unpluginFactory = (options) => {
|
|
|
6712
6774
|
res.end();
|
|
6713
6775
|
}
|
|
6714
6776
|
});
|
|
6777
|
+
const proxyMiddleware = createProxyMiddleware2();
|
|
6778
|
+
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
6715
6779
|
}
|
|
6716
6780
|
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
6717
6781
|
var _a5;
|
|
@@ -6788,7 +6852,7 @@ var unpluginFactory = (options) => {
|
|
|
6788
6852
|
return unpluginDing;
|
|
6789
6853
|
};
|
|
6790
6854
|
var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
|
|
6791
|
-
var
|
|
6855
|
+
var index_default = unplugin;
|
|
6792
6856
|
|
|
6793
6857
|
// src/astro.ts
|
|
6794
6858
|
var astro_default = (options) => ({
|
|
@@ -6797,7 +6861,7 @@ var astro_default = (options) => ({
|
|
|
6797
6861
|
"astro:config:setup": async (astro) => {
|
|
6798
6862
|
var _a4;
|
|
6799
6863
|
(_a4 = astro.config.vite).plugins || (_a4.plugins = []);
|
|
6800
|
-
astro.config.vite.plugins.push(
|
|
6864
|
+
astro.config.vite.plugins.push(index_default.vite(options));
|
|
6801
6865
|
}
|
|
6802
6866
|
}
|
|
6803
6867
|
});
|
package/dist/astro.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
2
|
+
index_default
|
|
3
|
+
} from "./chunk-QU7HLXVD.js";
|
|
4
|
+
import "./chunk-ZEHXGFFH.js";
|
|
5
5
|
|
|
6
6
|
// src/astro.ts
|
|
7
7
|
var astro_default = (options) => ({
|
|
@@ -10,7 +10,7 @@ var astro_default = (options) => ({
|
|
|
10
10
|
"astro:config:setup": async (astro) => {
|
|
11
11
|
var _a;
|
|
12
12
|
(_a = astro.config.vite).plugins || (_a.plugins = []);
|
|
13
|
-
astro.config.vite.plugins.push(
|
|
13
|
+
astro.config.vite.plugins.push(index_default.vite(options));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
});
|
|
@@ -5,18 +5,20 @@ import {
|
|
|
5
5
|
__spreadValues,
|
|
6
6
|
fetch_blob_default,
|
|
7
7
|
formDataToBlob
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZEHXGFFH.js";
|
|
9
9
|
|
|
10
10
|
// src/index.ts
|
|
11
|
-
import { exec } from "child_process";
|
|
12
|
-
import process2 from "process";
|
|
11
|
+
import { exec } from "node:child_process";
|
|
12
|
+
import process2 from "node:process";
|
|
13
|
+
import { ServerResponse } from "node:http";
|
|
14
|
+
import { Socket } from "node:net";
|
|
13
15
|
|
|
14
16
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
|
|
15
|
-
import http2 from "http";
|
|
16
|
-
import https from "https";
|
|
17
|
-
import zlib from "zlib";
|
|
18
|
-
import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "stream";
|
|
19
|
-
import { Buffer as Buffer3 } from "buffer";
|
|
17
|
+
import http2 from "node:http";
|
|
18
|
+
import https from "node:https";
|
|
19
|
+
import zlib from "node:zlib";
|
|
20
|
+
import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "node:stream";
|
|
21
|
+
import { Buffer as Buffer3 } from "node:buffer";
|
|
20
22
|
|
|
21
23
|
// node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js
|
|
22
24
|
function dataUriToBuffer(uri) {
|
|
@@ -58,9 +60,9 @@ function dataUriToBuffer(uri) {
|
|
|
58
60
|
var dist_default = dataUriToBuffer;
|
|
59
61
|
|
|
60
62
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/body.js
|
|
61
|
-
import Stream, { PassThrough } from "stream";
|
|
62
|
-
import { types, deprecate, promisify } from "util";
|
|
63
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
63
|
+
import Stream, { PassThrough } from "node:stream";
|
|
64
|
+
import { types, deprecate, promisify } from "node:util";
|
|
65
|
+
import { Buffer as Buffer2 } from "node:buffer";
|
|
64
66
|
|
|
65
67
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/base.js
|
|
66
68
|
var FetchBaseError = class extends Error {
|
|
@@ -186,7 +188,7 @@ var Body = class {
|
|
|
186
188
|
}
|
|
187
189
|
return formData;
|
|
188
190
|
}
|
|
189
|
-
const { toFormData } = await import("./multipart-parser-
|
|
191
|
+
const { toFormData } = await import("./multipart-parser-VO5TIRQZ.js");
|
|
190
192
|
return toFormData(this.body, ct);
|
|
191
193
|
}
|
|
192
194
|
/**
|
|
@@ -373,8 +375,8 @@ var writeToStream = async (dest, { body }) => {
|
|
|
373
375
|
};
|
|
374
376
|
|
|
375
377
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
|
|
376
|
-
import { types as types2 } from "util";
|
|
377
|
-
import http from "http";
|
|
378
|
+
import { types as types2 } from "node:util";
|
|
379
|
+
import http from "node:http";
|
|
378
380
|
var validateHeaderName = typeof http.validateHeaderName === "function" ? http.validateHeaderName : (name) => {
|
|
379
381
|
if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
|
|
380
382
|
const error = new TypeError(`Header name must be a valid HTTP token [${name}]`);
|
|
@@ -682,8 +684,8 @@ Object.defineProperties(Response.prototype, {
|
|
|
682
684
|
});
|
|
683
685
|
|
|
684
686
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/request.js
|
|
685
|
-
import { format as formatUrl } from "url";
|
|
686
|
-
import { deprecate as deprecate2 } from "util";
|
|
687
|
+
import { format as formatUrl } from "node:url";
|
|
688
|
+
import { deprecate as deprecate2 } from "node:util";
|
|
687
689
|
|
|
688
690
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/get-search.js
|
|
689
691
|
var getSearch = (parsedURL) => {
|
|
@@ -696,7 +698,7 @@ var getSearch = (parsedURL) => {
|
|
|
696
698
|
};
|
|
697
699
|
|
|
698
700
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/referrer.js
|
|
699
|
-
import { isIP } from "net";
|
|
701
|
+
import { isIP } from "node:net";
|
|
700
702
|
function stripURLForUseAsAReferrer(url, originOnly = false) {
|
|
701
703
|
if (url == null) {
|
|
702
704
|
return "no-referrer";
|
|
@@ -1303,9 +1305,10 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
1303
1305
|
import { createUnplugin } from "unplugin";
|
|
1304
1306
|
import c from "picocolors";
|
|
1305
1307
|
import cookie from "cookie";
|
|
1306
|
-
import { start } from "chii";
|
|
1308
|
+
import { start } from "z-chii";
|
|
1307
1309
|
import dns2 from "dns2";
|
|
1308
1310
|
import { getRandomPort } from "get-port-please";
|
|
1311
|
+
import httpProxy from "http-proxy";
|
|
1309
1312
|
var cwd = process2.cwd();
|
|
1310
1313
|
var config;
|
|
1311
1314
|
var colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
@@ -1415,11 +1418,6 @@ var unpluginFactory = (options) => {
|
|
|
1415
1418
|
"/* eslint-disable */;",
|
|
1416
1419
|
((_a = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a.enable) ? `import { devtools } from '@vue/devtools'
|
|
1417
1420
|
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});` : "",
|
|
1418
|
-
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
1419
|
-
const script = document.createElement('script');
|
|
1420
|
-
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
1421
|
-
document.body.appendChild(script);
|
|
1422
|
-
})()` : "",
|
|
1423
1421
|
"/* eslint-enable */",
|
|
1424
1422
|
`${_source};`
|
|
1425
1423
|
];
|
|
@@ -1439,6 +1437,22 @@ var unpluginFactory = (options) => {
|
|
|
1439
1437
|
configResolved(_config) {
|
|
1440
1438
|
config = _config;
|
|
1441
1439
|
},
|
|
1440
|
+
transformIndexHtml(html) {
|
|
1441
|
+
if (enableChii) {
|
|
1442
|
+
return html.replace(
|
|
1443
|
+
"</body>",
|
|
1444
|
+
`</body>
|
|
1445
|
+
<script>
|
|
1446
|
+
(() => {
|
|
1447
|
+
const script = document.createElement('script');
|
|
1448
|
+
script.src="./__chii_proxy/target.js";
|
|
1449
|
+
document.body.appendChild(script);
|
|
1450
|
+
})()
|
|
1451
|
+
</script>
|
|
1452
|
+
`
|
|
1453
|
+
);
|
|
1454
|
+
}
|
|
1455
|
+
},
|
|
1442
1456
|
async configureServer(server) {
|
|
1443
1457
|
var _a, _b;
|
|
1444
1458
|
if (!(options == null ? void 0 : options.enable)) {
|
|
@@ -1474,7 +1488,7 @@ var unpluginFactory = (options) => {
|
|
|
1474
1488
|
server.middlewares.use((req, res, next) => {
|
|
1475
1489
|
const cookies = cookie.parse(req.headers.cookie || "");
|
|
1476
1490
|
for (const [name, value] of Object.entries(cookies)) {
|
|
1477
|
-
if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
1491
|
+
if (value && options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
1478
1492
|
const serializedCookie = cookie.serialize(name, value, {
|
|
1479
1493
|
httpOnly: false
|
|
1480
1494
|
});
|
|
@@ -1485,6 +1499,51 @@ var unpluginFactory = (options) => {
|
|
|
1485
1499
|
});
|
|
1486
1500
|
}
|
|
1487
1501
|
if (enableChii) {
|
|
1502
|
+
let createProxyMiddleware2 = function() {
|
|
1503
|
+
let proxy = null;
|
|
1504
|
+
const handleUpgrade = (req, socket, head) => {
|
|
1505
|
+
var _a2;
|
|
1506
|
+
if (proxy && ((_a2 = req.url) == null ? void 0 : _a2.startsWith("/__chii_proxy"))) {
|
|
1507
|
+
debug("WS upgrade:", req.url);
|
|
1508
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
1509
|
+
proxy.ws(req, socket, head);
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
return (resolvedInfo) => {
|
|
1513
|
+
return (req, res, next) => {
|
|
1514
|
+
var _a2;
|
|
1515
|
+
if (!proxy && resolvedInfo.availablePort) {
|
|
1516
|
+
proxy = httpProxy.createProxyServer({
|
|
1517
|
+
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
1518
|
+
ws: true
|
|
1519
|
+
// changeOrigin: true, // Consider if you need this
|
|
1520
|
+
});
|
|
1521
|
+
proxy.on("error", (err, req2, res2) => {
|
|
1522
|
+
console.error("Proxy error:", err);
|
|
1523
|
+
if (res2 instanceof ServerResponse) {
|
|
1524
|
+
if (!res2.headersSent) {
|
|
1525
|
+
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
1526
|
+
}
|
|
1527
|
+
res2.end(`Proxy error: ${err.message}`);
|
|
1528
|
+
} else if (res2 instanceof Socket) {
|
|
1529
|
+
res2.destroy();
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
if (req.socket.server) {
|
|
1533
|
+
req.socket.server.on("upgrade", handleUpgrade);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
if (proxy && ((_a2 = req.url) == null ? void 0 : _a2.startsWith("/__chii_proxy"))) {
|
|
1537
|
+
debug(req.url);
|
|
1538
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
1539
|
+
proxy.web(req, res);
|
|
1540
|
+
} else {
|
|
1541
|
+
next();
|
|
1542
|
+
}
|
|
1543
|
+
};
|
|
1544
|
+
};
|
|
1545
|
+
};
|
|
1546
|
+
var createProxyMiddleware = createProxyMiddleware2;
|
|
1488
1547
|
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
1489
1548
|
try {
|
|
1490
1549
|
const raw = await fetch(`http://localhost:${resovedInfo.availablePort}/targets`);
|
|
@@ -1503,6 +1562,8 @@ var unpluginFactory = (options) => {
|
|
|
1503
1562
|
res.end();
|
|
1504
1563
|
}
|
|
1505
1564
|
});
|
|
1565
|
+
const proxyMiddleware = createProxyMiddleware2();
|
|
1566
|
+
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
1506
1567
|
}
|
|
1507
1568
|
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
1508
1569
|
var _a2;
|
|
@@ -1579,7 +1640,7 @@ var unpluginFactory = (options) => {
|
|
|
1579
1640
|
return unpluginDing;
|
|
1580
1641
|
};
|
|
1581
1642
|
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
1582
|
-
var
|
|
1643
|
+
var index_default = unplugin;
|
|
1583
1644
|
|
|
1584
1645
|
export {
|
|
1585
1646
|
fetch,
|
|
@@ -1588,5 +1649,5 @@ export {
|
|
|
1588
1649
|
startDnsServer,
|
|
1589
1650
|
unpluginFactory,
|
|
1590
1651
|
unplugin,
|
|
1591
|
-
|
|
1652
|
+
index_default
|
|
1592
1653
|
};
|
|
@@ -4386,12 +4386,12 @@ var require_streams = __commonJS({
|
|
|
4386
4386
|
var POOL_SIZE2 = 65536;
|
|
4387
4387
|
if (!globalThis.ReadableStream) {
|
|
4388
4388
|
try {
|
|
4389
|
-
const process = __require("process");
|
|
4389
|
+
const process = __require("node:process");
|
|
4390
4390
|
const { emitWarning } = process;
|
|
4391
4391
|
try {
|
|
4392
4392
|
process.emitWarning = () => {
|
|
4393
4393
|
};
|
|
4394
|
-
Object.assign(globalThis, __require("stream/web"));
|
|
4394
|
+
Object.assign(globalThis, __require("node:stream/web"));
|
|
4395
4395
|
process.emitWarning = emitWarning;
|
|
4396
4396
|
} catch (error) {
|
|
4397
4397
|
process.emitWarning = emitWarning;
|
|
@@ -4799,7 +4799,7 @@ Content-Type: ${v.type || "application/octet-stream"}\r
|
|
|
4799
4799
|
}
|
|
4800
4800
|
|
|
4801
4801
|
// node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js
|
|
4802
|
-
import { statSync, createReadStream, promises as fs } from "fs";
|
|
4802
|
+
import { statSync, createReadStream, promises as fs } from "node:fs";
|
|
4803
4803
|
var import_node_domexception = __toESM(require_node_domexception(), 1);
|
|
4804
4804
|
var { stat } = fs;
|
|
4805
4805
|
|
package/dist/esbuild.cjs
CHANGED
|
@@ -5069,6 +5069,7 @@ var init_multipart_parser = __esm({
|
|
|
5069
5069
|
state = S.HEADER_FIELD;
|
|
5070
5070
|
mark("onHeaderField");
|
|
5071
5071
|
index = 0;
|
|
5072
|
+
// falls through
|
|
5072
5073
|
case S.HEADER_FIELD:
|
|
5073
5074
|
if (c2 === CR) {
|
|
5074
5075
|
clear("onHeaderField");
|
|
@@ -5098,6 +5099,7 @@ var init_multipart_parser = __esm({
|
|
|
5098
5099
|
}
|
|
5099
5100
|
mark("onHeaderValue");
|
|
5100
5101
|
state = S.HEADER_VALUE;
|
|
5102
|
+
// falls through
|
|
5101
5103
|
case S.HEADER_VALUE:
|
|
5102
5104
|
if (c2 === CR) {
|
|
5103
5105
|
dataCallback("onHeaderValue", true);
|
|
@@ -5121,6 +5123,7 @@ var init_multipart_parser = __esm({
|
|
|
5121
5123
|
case S.PART_DATA_START:
|
|
5122
5124
|
state = S.PART_DATA;
|
|
5123
5125
|
mark("onPartData");
|
|
5126
|
+
// falls through
|
|
5124
5127
|
case S.PART_DATA:
|
|
5125
5128
|
previousIndex = index;
|
|
5126
5129
|
if (index === 0) {
|
|
@@ -5216,6 +5219,8 @@ var import_unplugin2 = require("unplugin");
|
|
|
5216
5219
|
// src/index.ts
|
|
5217
5220
|
var import_node_child_process = require("child_process");
|
|
5218
5221
|
var import_node_process = __toESM(require("process"), 1);
|
|
5222
|
+
var import_node_http3 = require("http");
|
|
5223
|
+
var import_node_net2 = require("net");
|
|
5219
5224
|
|
|
5220
5225
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
|
|
5221
5226
|
var import_node_http2 = __toESM(require("http"), 1);
|
|
@@ -6513,9 +6518,10 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6513
6518
|
var import_unplugin = require("unplugin");
|
|
6514
6519
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6515
6520
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6516
|
-
var
|
|
6521
|
+
var import_z_chii = require("z-chii");
|
|
6517
6522
|
var import_dns2 = __toESM(require("dns2"), 1);
|
|
6518
6523
|
var import_get_port_please = require("get-port-please");
|
|
6524
|
+
var import_http_proxy = __toESM(require("http-proxy"), 1);
|
|
6519
6525
|
var cwd = import_node_process.default.cwd();
|
|
6520
6526
|
var config;
|
|
6521
6527
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
@@ -6615,7 +6621,7 @@ var unpluginFactory = (options) => {
|
|
|
6615
6621
|
var _a4, _b, _c;
|
|
6616
6622
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
6617
6623
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6618
|
-
(0,
|
|
6624
|
+
(0, import_z_chii.start)({
|
|
6619
6625
|
port: resovedInfo.availablePort
|
|
6620
6626
|
});
|
|
6621
6627
|
debug(`chii server port: ${resovedInfo.availablePort}`);
|
|
@@ -6625,11 +6631,6 @@ var unpluginFactory = (options) => {
|
|
|
6625
6631
|
"/* eslint-disable */;",
|
|
6626
6632
|
((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) ? `import { devtools } from '@vue/devtools'
|
|
6627
6633
|
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});` : "",
|
|
6628
|
-
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6629
|
-
const script = document.createElement('script');
|
|
6630
|
-
script.src="http://${(chii == null ? void 0 : chii.host) || "127.0.0.1"}:${resovedInfo.availablePort}/target.js";
|
|
6631
|
-
document.body.appendChild(script);
|
|
6632
|
-
})()` : "",
|
|
6633
6634
|
"/* eslint-enable */",
|
|
6634
6635
|
`${_source};`
|
|
6635
6636
|
];
|
|
@@ -6649,6 +6650,22 @@ var unpluginFactory = (options) => {
|
|
|
6649
6650
|
configResolved(_config) {
|
|
6650
6651
|
config = _config;
|
|
6651
6652
|
},
|
|
6653
|
+
transformIndexHtml(html) {
|
|
6654
|
+
if (enableChii) {
|
|
6655
|
+
return html.replace(
|
|
6656
|
+
"</body>",
|
|
6657
|
+
`</body>
|
|
6658
|
+
<script>
|
|
6659
|
+
(() => {
|
|
6660
|
+
const script = document.createElement('script');
|
|
6661
|
+
script.src="./__chii_proxy/target.js";
|
|
6662
|
+
document.body.appendChild(script);
|
|
6663
|
+
})()
|
|
6664
|
+
</script>
|
|
6665
|
+
`
|
|
6666
|
+
);
|
|
6667
|
+
}
|
|
6668
|
+
},
|
|
6652
6669
|
async configureServer(server) {
|
|
6653
6670
|
var _a4, _b;
|
|
6654
6671
|
if (!(options == null ? void 0 : options.enable)) {
|
|
@@ -6684,7 +6701,7 @@ var unpluginFactory = (options) => {
|
|
|
6684
6701
|
server.middlewares.use((req, res, next) => {
|
|
6685
6702
|
const cookies = import_cookie.default.parse(req.headers.cookie || "");
|
|
6686
6703
|
for (const [name, value] of Object.entries(cookies)) {
|
|
6687
|
-
if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
6704
|
+
if (value && options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
6688
6705
|
const serializedCookie = import_cookie.default.serialize(name, value, {
|
|
6689
6706
|
httpOnly: false
|
|
6690
6707
|
});
|
|
@@ -6695,6 +6712,51 @@ var unpluginFactory = (options) => {
|
|
|
6695
6712
|
});
|
|
6696
6713
|
}
|
|
6697
6714
|
if (enableChii) {
|
|
6715
|
+
let createProxyMiddleware2 = function() {
|
|
6716
|
+
let proxy = null;
|
|
6717
|
+
const handleUpgrade = (req, socket, head) => {
|
|
6718
|
+
var _a5;
|
|
6719
|
+
if (proxy && ((_a5 = req.url) == null ? void 0 : _a5.startsWith("/__chii_proxy"))) {
|
|
6720
|
+
debug("WS upgrade:", req.url);
|
|
6721
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
6722
|
+
proxy.ws(req, socket, head);
|
|
6723
|
+
}
|
|
6724
|
+
};
|
|
6725
|
+
return (resolvedInfo) => {
|
|
6726
|
+
return (req, res, next) => {
|
|
6727
|
+
var _a5;
|
|
6728
|
+
if (!proxy && resolvedInfo.availablePort) {
|
|
6729
|
+
proxy = import_http_proxy.default.createProxyServer({
|
|
6730
|
+
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
6731
|
+
ws: true
|
|
6732
|
+
// changeOrigin: true, // Consider if you need this
|
|
6733
|
+
});
|
|
6734
|
+
proxy.on("error", (err, req2, res2) => {
|
|
6735
|
+
console.error("Proxy error:", err);
|
|
6736
|
+
if (res2 instanceof import_node_http3.ServerResponse) {
|
|
6737
|
+
if (!res2.headersSent) {
|
|
6738
|
+
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
6739
|
+
}
|
|
6740
|
+
res2.end(`Proxy error: ${err.message}`);
|
|
6741
|
+
} else if (res2 instanceof import_node_net2.Socket) {
|
|
6742
|
+
res2.destroy();
|
|
6743
|
+
}
|
|
6744
|
+
});
|
|
6745
|
+
if (req.socket.server) {
|
|
6746
|
+
req.socket.server.on("upgrade", handleUpgrade);
|
|
6747
|
+
}
|
|
6748
|
+
}
|
|
6749
|
+
if (proxy && ((_a5 = req.url) == null ? void 0 : _a5.startsWith("/__chii_proxy"))) {
|
|
6750
|
+
debug(req.url);
|
|
6751
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
6752
|
+
proxy.web(req, res);
|
|
6753
|
+
} else {
|
|
6754
|
+
next();
|
|
6755
|
+
}
|
|
6756
|
+
};
|
|
6757
|
+
};
|
|
6758
|
+
};
|
|
6759
|
+
var createProxyMiddleware = createProxyMiddleware2;
|
|
6698
6760
|
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
6699
6761
|
try {
|
|
6700
6762
|
const raw = await fetch(`http://localhost:${resovedInfo.availablePort}/targets`);
|
|
@@ -6713,6 +6775,8 @@ var unpluginFactory = (options) => {
|
|
|
6713
6775
|
res.end();
|
|
6714
6776
|
}
|
|
6715
6777
|
});
|
|
6778
|
+
const proxyMiddleware = createProxyMiddleware2();
|
|
6779
|
+
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
6716
6780
|
}
|
|
6717
6781
|
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
6718
6782
|
var _a5;
|