unplugin-dingtalk 0.3.0 → 0.4.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 +42 -18
- package/dist/astro.d.cts +1 -0
- package/dist/astro.d.ts +1 -0
- package/dist/astro.js +1 -1
- package/dist/chunk-2OB7UBRW.js +19 -0
- package/dist/{chunk-XTDXIGYG.js → chunk-RDTWBIQD.js} +42 -18
- package/dist/esbuild.cjs +42 -18
- package/dist/esbuild.d.cts +1 -0
- package/dist/esbuild.d.ts +1 -0
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +42 -18
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +92 -135
- package/dist/nuxt.d.cts +1 -0
- package/dist/nuxt.d.ts +1 -0
- package/dist/nuxt.js +3 -7
- package/dist/rollup.cjs +42 -18
- package/dist/rollup.d.cts +1 -0
- package/dist/rollup.d.ts +1 -0
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +164 -66
- package/dist/rspack.d.cts +4 -2
- package/dist/rspack.d.ts +4 -2
- package/dist/rspack.js +80 -2
- package/dist/types.d.cts +15 -1
- package/dist/types.d.ts +15 -1
- package/dist/vite.cjs +51 -19
- package/dist/vite.d.cts +3 -2
- package/dist/vite.d.ts +3 -2
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +43 -19
- package/dist/webpack.d.cts +1 -0
- package/dist/webpack.d.ts +1 -0
- package/dist/webpack.js +78 -3
- package/package.json +5 -1
- package/dist/chunk-FMGOYX4F.js +0 -83
- package/dist/chunk-ZV272SZK.js +0 -11
package/dist/rollup.d.cts
CHANGED
package/dist/rollup.d.ts
CHANGED
package/dist/rollup.js
CHANGED
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 process4 = require("process");
|
|
4393
|
+
const { emitWarning } = process4;
|
|
4394
4394
|
try {
|
|
4395
|
-
|
|
4395
|
+
process4.emitWarning = () => {
|
|
4396
4396
|
};
|
|
4397
4397
|
Object.assign(globalThis, require("stream/web"));
|
|
4398
|
-
|
|
4398
|
+
process4.emitWarning = emitWarning;
|
|
4399
4399
|
} catch (error) {
|
|
4400
|
-
|
|
4400
|
+
process4.emitWarning = emitWarning;
|
|
4401
4401
|
throw error;
|
|
4402
4402
|
}
|
|
4403
4403
|
} catch (error) {
|
|
@@ -4707,17 +4707,17 @@ var init_file = __esm({
|
|
|
4707
4707
|
|
|
4708
4708
|
// node_modules/.pnpm/formdata-polyfill@4.0.10/node_modules/formdata-polyfill/esm.min.js
|
|
4709
4709
|
function formDataToBlob(F2, B = fetch_blob_default) {
|
|
4710
|
-
var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"),
|
|
4710
|
+
var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c3 = [], p = `--${b}\r
|
|
4711
4711
|
Content-Disposition: form-data; name="`;
|
|
4712
|
-
F2.forEach((v, n) => typeof v == "string" ?
|
|
4712
|
+
F2.forEach((v, n) => typeof v == "string" ? c3.push(p + e(n) + `"\r
|
|
4713
4713
|
\r
|
|
4714
4714
|
${v.replace(new RegExp("\\r(?!\\n)|(?<!\\r)\\n", "g"), "\r\n")}\r
|
|
4715
|
-
`) :
|
|
4715
|
+
`) : c3.push(p + e(n) + `"; filename="${e(v.name, 1)}"\r
|
|
4716
4716
|
Content-Type: ${v.type || "application/octet-stream"}\r
|
|
4717
4717
|
\r
|
|
4718
4718
|
`, v, "\r\n"));
|
|
4719
|
-
|
|
4720
|
-
return new B(
|
|
4719
|
+
c3.push(`--${b}--`);
|
|
4720
|
+
return new B(c3, { type: "multipart/form-data; boundary=" + b });
|
|
4721
4721
|
}
|
|
4722
4722
|
var t, i, h, r, m, f, e, x, _d, _a3, FormData;
|
|
4723
4723
|
var init_esm_min = __esm({
|
|
@@ -4728,8 +4728,8 @@ var init_esm_min = __esm({
|
|
|
4728
4728
|
({ toStringTag: t, iterator: i, hasInstance: h } = Symbol);
|
|
4729
4729
|
r = Math.random;
|
|
4730
4730
|
m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(",");
|
|
4731
|
-
f = (a, b,
|
|
4732
|
-
e = (
|
|
4731
|
+
f = (a, b, c3) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c3 = c3 !== void 0 ? c3 + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c3 || b[t] == "blob" ? new file_default([b], c3, b) : b] : [a, b + ""]);
|
|
4732
|
+
e = (c3, f3) => (f3 ? c3 : c3.replace(/\r?\n|\r/g, "\r\n")).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
4733
4733
|
x = (n, a, e2) => {
|
|
4734
4734
|
if (a.length < e2) {
|
|
4735
4735
|
throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
|
|
@@ -4761,14 +4761,14 @@ var init_esm_min = __esm({
|
|
|
4761
4761
|
get(a) {
|
|
4762
4762
|
x("get", arguments, 1);
|
|
4763
4763
|
a += "";
|
|
4764
|
-
for (var b = __privateGet(this, _d), l = b.length,
|
|
4764
|
+
for (var b = __privateGet(this, _d), l = b.length, c3 = 0; c3 < l; c3++) if (b[c3][0] === a) return b[c3][1];
|
|
4765
4765
|
return null;
|
|
4766
4766
|
}
|
|
4767
4767
|
getAll(a, b) {
|
|
4768
4768
|
x("getAll", arguments, 1);
|
|
4769
4769
|
b = [];
|
|
4770
4770
|
a += "";
|
|
4771
|
-
__privateGet(this, _d).forEach((
|
|
4771
|
+
__privateGet(this, _d).forEach((c3) => c3[0] === a && b.push(c3[1]));
|
|
4772
4772
|
return b;
|
|
4773
4773
|
}
|
|
4774
4774
|
has(a) {
|
|
@@ -4778,16 +4778,16 @@ var init_esm_min = __esm({
|
|
|
4778
4778
|
}
|
|
4779
4779
|
forEach(a, b) {
|
|
4780
4780
|
x("forEach", arguments, 1);
|
|
4781
|
-
for (var [
|
|
4781
|
+
for (var [c3, d] of this) a.call(b, d, c3, this);
|
|
4782
4782
|
}
|
|
4783
4783
|
set(...a) {
|
|
4784
4784
|
x("set", arguments, 2);
|
|
4785
|
-
var b = [],
|
|
4785
|
+
var b = [], c3 = true;
|
|
4786
4786
|
a = f(...a);
|
|
4787
4787
|
__privateGet(this, _d).forEach((d) => {
|
|
4788
|
-
d[0] === a[0] ?
|
|
4788
|
+
d[0] === a[0] ? c3 && (c3 = !b.push(a)) : b.push(d);
|
|
4789
4789
|
});
|
|
4790
|
-
|
|
4790
|
+
c3 && b.push(a);
|
|
4791
4791
|
__privateSet(this, _d, b);
|
|
4792
4792
|
}
|
|
4793
4793
|
*entries() {
|
|
@@ -4968,7 +4968,7 @@ var init_multipart_parser = __esm({
|
|
|
4968
4968
|
COLON = 58;
|
|
4969
4969
|
A = 97;
|
|
4970
4970
|
Z = 122;
|
|
4971
|
-
lower = (
|
|
4971
|
+
lower = (c3) => c3 | 32;
|
|
4972
4972
|
noop = () => {
|
|
4973
4973
|
};
|
|
4974
4974
|
MultipartParser = class {
|
|
@@ -5007,7 +5007,7 @@ var init_multipart_parser = __esm({
|
|
|
5007
5007
|
const boundaryLength = this.boundary.length;
|
|
5008
5008
|
const boundaryEnd = boundaryLength - 1;
|
|
5009
5009
|
const bufferLength = data.length;
|
|
5010
|
-
let
|
|
5010
|
+
let c3;
|
|
5011
5011
|
let cl;
|
|
5012
5012
|
const mark = (name) => {
|
|
5013
5013
|
this[name + "Mark"] = i2;
|
|
@@ -5034,22 +5034,22 @@ var init_multipart_parser = __esm({
|
|
|
5034
5034
|
}
|
|
5035
5035
|
};
|
|
5036
5036
|
for (i2 = 0; i2 < length_; i2++) {
|
|
5037
|
-
|
|
5037
|
+
c3 = data[i2];
|
|
5038
5038
|
switch (state) {
|
|
5039
5039
|
case S.START_BOUNDARY:
|
|
5040
5040
|
if (index === boundary.length - 2) {
|
|
5041
|
-
if (
|
|
5041
|
+
if (c3 === HYPHEN) {
|
|
5042
5042
|
flags |= F.LAST_BOUNDARY;
|
|
5043
|
-
} else if (
|
|
5043
|
+
} else if (c3 !== CR) {
|
|
5044
5044
|
return;
|
|
5045
5045
|
}
|
|
5046
5046
|
index++;
|
|
5047
5047
|
break;
|
|
5048
5048
|
} else if (index - 1 === boundary.length - 2) {
|
|
5049
|
-
if (flags & F.LAST_BOUNDARY &&
|
|
5049
|
+
if (flags & F.LAST_BOUNDARY && c3 === HYPHEN) {
|
|
5050
5050
|
state = S.END;
|
|
5051
5051
|
flags = 0;
|
|
5052
|
-
} else if (!(flags & F.LAST_BOUNDARY) &&
|
|
5052
|
+
} else if (!(flags & F.LAST_BOUNDARY) && c3 === LF) {
|
|
5053
5053
|
index = 0;
|
|
5054
5054
|
callback("onPartBegin");
|
|
5055
5055
|
state = S.HEADER_FIELD_START;
|
|
@@ -5058,10 +5058,10 @@ var init_multipart_parser = __esm({
|
|
|
5058
5058
|
}
|
|
5059
5059
|
break;
|
|
5060
5060
|
}
|
|
5061
|
-
if (
|
|
5061
|
+
if (c3 !== boundary[index + 2]) {
|
|
5062
5062
|
index = -2;
|
|
5063
5063
|
}
|
|
5064
|
-
if (
|
|
5064
|
+
if (c3 === boundary[index + 2]) {
|
|
5065
5065
|
index++;
|
|
5066
5066
|
}
|
|
5067
5067
|
break;
|
|
@@ -5070,16 +5070,16 @@ var init_multipart_parser = __esm({
|
|
|
5070
5070
|
mark("onHeaderField");
|
|
5071
5071
|
index = 0;
|
|
5072
5072
|
case S.HEADER_FIELD:
|
|
5073
|
-
if (
|
|
5073
|
+
if (c3 === CR) {
|
|
5074
5074
|
clear("onHeaderField");
|
|
5075
5075
|
state = S.HEADERS_ALMOST_DONE;
|
|
5076
5076
|
break;
|
|
5077
5077
|
}
|
|
5078
5078
|
index++;
|
|
5079
|
-
if (
|
|
5079
|
+
if (c3 === HYPHEN) {
|
|
5080
5080
|
break;
|
|
5081
5081
|
}
|
|
5082
|
-
if (
|
|
5082
|
+
if (c3 === COLON) {
|
|
5083
5083
|
if (index === 1) {
|
|
5084
5084
|
return;
|
|
5085
5085
|
}
|
|
@@ -5087,32 +5087,32 @@ var init_multipart_parser = __esm({
|
|
|
5087
5087
|
state = S.HEADER_VALUE_START;
|
|
5088
5088
|
break;
|
|
5089
5089
|
}
|
|
5090
|
-
cl = lower(
|
|
5090
|
+
cl = lower(c3);
|
|
5091
5091
|
if (cl < A || cl > Z) {
|
|
5092
5092
|
return;
|
|
5093
5093
|
}
|
|
5094
5094
|
break;
|
|
5095
5095
|
case S.HEADER_VALUE_START:
|
|
5096
|
-
if (
|
|
5096
|
+
if (c3 === SPACE) {
|
|
5097
5097
|
break;
|
|
5098
5098
|
}
|
|
5099
5099
|
mark("onHeaderValue");
|
|
5100
5100
|
state = S.HEADER_VALUE;
|
|
5101
5101
|
case S.HEADER_VALUE:
|
|
5102
|
-
if (
|
|
5102
|
+
if (c3 === CR) {
|
|
5103
5103
|
dataCallback("onHeaderValue", true);
|
|
5104
5104
|
callback("onHeaderEnd");
|
|
5105
5105
|
state = S.HEADER_VALUE_ALMOST_DONE;
|
|
5106
5106
|
}
|
|
5107
5107
|
break;
|
|
5108
5108
|
case S.HEADER_VALUE_ALMOST_DONE:
|
|
5109
|
-
if (
|
|
5109
|
+
if (c3 !== LF) {
|
|
5110
5110
|
return;
|
|
5111
5111
|
}
|
|
5112
5112
|
state = S.HEADER_FIELD_START;
|
|
5113
5113
|
break;
|
|
5114
5114
|
case S.HEADERS_ALMOST_DONE:
|
|
5115
|
-
if (
|
|
5115
|
+
if (c3 !== LF) {
|
|
5116
5116
|
return;
|
|
5117
5117
|
}
|
|
5118
5118
|
callback("onHeadersEnd");
|
|
@@ -5129,10 +5129,10 @@ var init_multipart_parser = __esm({
|
|
|
5129
5129
|
i2 += boundaryLength;
|
|
5130
5130
|
}
|
|
5131
5131
|
i2 -= boundaryEnd;
|
|
5132
|
-
|
|
5132
|
+
c3 = data[i2];
|
|
5133
5133
|
}
|
|
5134
5134
|
if (index < boundary.length) {
|
|
5135
|
-
if (boundary[index] ===
|
|
5135
|
+
if (boundary[index] === c3) {
|
|
5136
5136
|
if (index === 0) {
|
|
5137
5137
|
dataCallback("onPartData", true);
|
|
5138
5138
|
}
|
|
@@ -5142,9 +5142,9 @@ var init_multipart_parser = __esm({
|
|
|
5142
5142
|
}
|
|
5143
5143
|
} else if (index === boundary.length) {
|
|
5144
5144
|
index++;
|
|
5145
|
-
if (
|
|
5145
|
+
if (c3 === CR) {
|
|
5146
5146
|
flags |= F.PART_BOUNDARY;
|
|
5147
|
-
} else if (
|
|
5147
|
+
} else if (c3 === HYPHEN) {
|
|
5148
5148
|
flags |= F.LAST_BOUNDARY;
|
|
5149
5149
|
} else {
|
|
5150
5150
|
index = 0;
|
|
@@ -5152,7 +5152,7 @@ var init_multipart_parser = __esm({
|
|
|
5152
5152
|
} else if (index - 1 === boundary.length) {
|
|
5153
5153
|
if (flags & F.PART_BOUNDARY) {
|
|
5154
5154
|
index = 0;
|
|
5155
|
-
if (
|
|
5155
|
+
if (c3 === LF) {
|
|
5156
5156
|
flags &= ~F.PART_BOUNDARY;
|
|
5157
5157
|
callback("onPartEnd");
|
|
5158
5158
|
callback("onPartBegin");
|
|
@@ -5160,7 +5160,7 @@ var init_multipart_parser = __esm({
|
|
|
5160
5160
|
break;
|
|
5161
5161
|
}
|
|
5162
5162
|
} else if (flags & F.LAST_BOUNDARY) {
|
|
5163
|
-
if (
|
|
5163
|
+
if (c3 === HYPHEN) {
|
|
5164
5164
|
callback("onPartEnd");
|
|
5165
5165
|
state = S.END;
|
|
5166
5166
|
flags = 0;
|
|
@@ -5172,7 +5172,7 @@ var init_multipart_parser = __esm({
|
|
|
5172
5172
|
}
|
|
5173
5173
|
}
|
|
5174
5174
|
if (index > 0) {
|
|
5175
|
-
lookbehind[index - 1] =
|
|
5175
|
+
lookbehind[index - 1] = c3;
|
|
5176
5176
|
} else if (previousIndex > 0) {
|
|
5177
5177
|
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
|
5178
5178
|
callback("onPartData", 0, previousIndex, _lookbehind);
|
|
@@ -5211,11 +5211,11 @@ __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);
|
|
5214
5216
|
var import_unplugin2 = require("unplugin");
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
var import_node_child_process = require("child_process");
|
|
5218
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
5217
|
+
var import_cookie2 = __toESM(require("cookie"), 1);
|
|
5218
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
5219
5219
|
|
|
5220
5220
|
// node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
|
|
5221
5221
|
var import_node_http2 = __toESM(require("http"), 1);
|
|
@@ -5496,7 +5496,7 @@ async function consumeBody(data) {
|
|
|
5496
5496
|
}
|
|
5497
5497
|
if (body.readableEnded === true || body._readableState.ended === true) {
|
|
5498
5498
|
try {
|
|
5499
|
-
if (accum.every((
|
|
5499
|
+
if (accum.every((c3) => typeof c3 === "string")) {
|
|
5500
5500
|
return import_node_buffer.Buffer.from(accum.join(""));
|
|
5501
5501
|
}
|
|
5502
5502
|
return import_node_buffer.Buffer.concat(accum, accumBytes);
|
|
@@ -6510,12 +6510,14 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6510
6510
|
}
|
|
6511
6511
|
|
|
6512
6512
|
// src/index.ts
|
|
6513
|
+
var import_node_child_process = require("child_process");
|
|
6514
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
6513
6515
|
var import_unplugin = require("unplugin");
|
|
6514
6516
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
6515
|
-
var import_vite_plugin_vconsole = require("vite-plugin-vconsole");
|
|
6516
6517
|
var import_cookie = __toESM(require("cookie"), 1);
|
|
6517
6518
|
var import_chii = require("chii");
|
|
6518
6519
|
var import_get_port_please = require("get-port-please");
|
|
6520
|
+
var cwd = import_node_process.default.cwd();
|
|
6519
6521
|
var config;
|
|
6520
6522
|
var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
|
|
6521
6523
|
var resovedInfo = {
|
|
@@ -6532,7 +6534,6 @@ var unpluginFactory = (options) => {
|
|
|
6532
6534
|
console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
|
|
6533
6535
|
}
|
|
6534
6536
|
}
|
|
6535
|
-
const plugins = [];
|
|
6536
6537
|
const unpluginDing = {
|
|
6537
6538
|
name: "unplugin-dingtalk",
|
|
6538
6539
|
enforce: "pre",
|
|
@@ -6545,20 +6546,22 @@ var unpluginFactory = (options) => {
|
|
|
6545
6546
|
resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
|
|
6546
6547
|
debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
|
|
6547
6548
|
(0, import_chii.start)({
|
|
6549
|
+
host: "0.0.0.0",
|
|
6548
6550
|
port: resovedInfo.availablePort
|
|
6549
6551
|
});
|
|
6550
6552
|
}
|
|
6551
|
-
if (
|
|
6553
|
+
if (options == null ? void 0 : options.enable) {
|
|
6552
6554
|
const codes = [
|
|
6553
|
-
|
|
6554
|
-
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})
|
|
6555
|
+
"/* eslint-disable */;",
|
|
6556
|
+
((_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});` : "",
|
|
6556
6558
|
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
6557
6559
|
const script = document.createElement('script');
|
|
6558
6560
|
script.src="http://localhost:${resovedInfo.availablePort}/target.js";
|
|
6559
6561
|
document.body.appendChild(script);
|
|
6560
6562
|
})()` : "",
|
|
6561
|
-
|
|
6563
|
+
"/* eslint-enable */",
|
|
6564
|
+
`${_source};`
|
|
6562
6565
|
];
|
|
6563
6566
|
return {
|
|
6564
6567
|
code: codes.join("\n"),
|
|
@@ -6577,23 +6580,19 @@ var unpluginFactory = (options) => {
|
|
|
6577
6580
|
config = _config;
|
|
6578
6581
|
},
|
|
6579
6582
|
async configureServer(server) {
|
|
6580
|
-
var _a4, _b
|
|
6583
|
+
var _a4, _b;
|
|
6581
6584
|
if (!(options == null ? void 0 : options.enable)) {
|
|
6582
6585
|
return;
|
|
6583
6586
|
}
|
|
6584
|
-
const availablePort = resovedInfo.availablePort;
|
|
6585
|
-
if ((options == null ? void 0 : options.enable) && ((_a4 = options == null ? void 0 : options.vconsole) == null ? void 0 : _a4.enabled)) {
|
|
6586
|
-
plugins.push((0, import_vite_plugin_vconsole.viteVConsole)(options == null ? void 0 : options.vconsole));
|
|
6587
|
-
}
|
|
6588
6587
|
const _printUrls = server.printUrls.bind(server);
|
|
6589
6588
|
let source = `localhost:${config.server.port || 5173}`;
|
|
6590
|
-
const url = (
|
|
6589
|
+
const url = (_a4 = server.resolvedUrls) == null ? void 0 : _a4.local[0];
|
|
6591
6590
|
if (url) {
|
|
6592
6591
|
const u = new URL(url);
|
|
6593
6592
|
source = u.host;
|
|
6594
6593
|
}
|
|
6595
6594
|
const base = server.config.base || "/";
|
|
6596
|
-
const _targetUrl = (
|
|
6595
|
+
const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
|
|
6597
6596
|
server.printUrls = () => {
|
|
6598
6597
|
var _a5;
|
|
6599
6598
|
_printUrls();
|
|
@@ -6628,10 +6627,10 @@ var unpluginFactory = (options) => {
|
|
|
6628
6627
|
if (enableChii) {
|
|
6629
6628
|
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
6630
6629
|
try {
|
|
6631
|
-
const raw = await fetch(`http://localhost:${availablePort}/targets`);
|
|
6630
|
+
const raw = await fetch(`http://localhost:${resovedInfo.availablePort}/targets`);
|
|
6632
6631
|
const data = await raw.json();
|
|
6633
6632
|
if ((data == null ? void 0 : data.targets.length) > 0) {
|
|
6634
|
-
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`;
|
|
6633
|
+
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`;
|
|
6635
6634
|
res.writeHead(302, { Location: devToolsUrl });
|
|
6636
6635
|
res.end();
|
|
6637
6636
|
}
|
|
@@ -6692,14 +6691,113 @@ var unpluginFactory = (options) => {
|
|
|
6692
6691
|
if (options == null ? void 0 : options.corpId) {
|
|
6693
6692
|
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6694
6693
|
}
|
|
6694
|
+
},
|
|
6695
|
+
async rspack(compiler) {
|
|
6696
|
+
var _a4, _b, _c, _d2, _e;
|
|
6697
|
+
if (!(options == null ? void 0 : options.enable)) {
|
|
6698
|
+
return;
|
|
6699
|
+
}
|
|
6700
|
+
const devServerOptions = __spreadValues(__spreadValues({
|
|
6701
|
+
host: "localhost",
|
|
6702
|
+
port: 8080
|
|
6703
|
+
}, compiler.options.devServer), (_c = (_b = await ((_a4 = await import("@rsbuild/core")) == null ? void 0 : _a4.loadConfig({
|
|
6704
|
+
cwd
|
|
6705
|
+
}))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
|
|
6706
|
+
const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
|
|
6707
|
+
const base = compiler.options.output.publicPath || "/";
|
|
6708
|
+
const _targetUrl = (_d2 = options == null ? void 0 : options.targetUrl) != null ? _d2 : `http://${source}${base}`;
|
|
6709
|
+
resovedInfo.targetURL = new URL(_targetUrl);
|
|
6710
|
+
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
6711
|
+
if (options == null ? void 0 : options.corpId) {
|
|
6712
|
+
resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
6713
|
+
}
|
|
6714
|
+
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
6715
|
+
`Open in dingtalk${((_e = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _e.enable) ? " (with vue-devtools)" : ""}`
|
|
6716
|
+
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
6717
|
+
if (enableChii) {
|
|
6718
|
+
console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
|
|
6719
|
+
"Click to open chrome devtools"
|
|
6720
|
+
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
6721
|
+
}
|
|
6695
6722
|
}
|
|
6696
6723
|
};
|
|
6697
|
-
|
|
6698
|
-
return plugins;
|
|
6724
|
+
return unpluginDing;
|
|
6699
6725
|
};
|
|
6700
6726
|
|
|
6701
6727
|
// src/rspack.ts
|
|
6702
|
-
var rspack_default = (
|
|
6728
|
+
var rspack_default = (options) => {
|
|
6729
|
+
function debug(...args) {
|
|
6730
|
+
if (options == null ? void 0 : options.debug) {
|
|
6731
|
+
console.log(` ${import_picocolors2.default.yellow("DEBUG")} `, ...args);
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
const {
|
|
6735
|
+
chii: enableChii = true
|
|
6736
|
+
} = options || {};
|
|
6737
|
+
const injectSetupMiddlewares = (middlewares, _devServer) => {
|
|
6738
|
+
if (options.debugCookies && options.debugCookies.length > 0) {
|
|
6739
|
+
middlewares.unshift((req, res, next) => {
|
|
6740
|
+
const cookies = import_cookie2.default.parse(req.headers.cookie || "");
|
|
6741
|
+
for (const [name, value] of Object.entries(cookies)) {
|
|
6742
|
+
if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
6743
|
+
const serializedCookie = import_cookie2.default.serialize(name, value, {
|
|
6744
|
+
httpOnly: false
|
|
6745
|
+
});
|
|
6746
|
+
res.setHeader("Set-Cookie", serializedCookie);
|
|
6747
|
+
}
|
|
6748
|
+
}
|
|
6749
|
+
next();
|
|
6750
|
+
});
|
|
6751
|
+
}
|
|
6752
|
+
if (enableChii) {
|
|
6753
|
+
middlewares.unshift(async (req, res, next) => {
|
|
6754
|
+
if (req.url !== "/__chrome_devtools") {
|
|
6755
|
+
return next();
|
|
6756
|
+
}
|
|
6757
|
+
const availablePort = resovedInfo.availablePort;
|
|
6758
|
+
try {
|
|
6759
|
+
const raw = await fetch(`http://localhost:${availablePort}/targets`);
|
|
6760
|
+
const data = await raw.json();
|
|
6761
|
+
if ((data == null ? void 0 : data.targets.length) > 0) {
|
|
6762
|
+
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
|
+
res.writeHead(302, { Location: devToolsUrl });
|
|
6764
|
+
res.end();
|
|
6765
|
+
}
|
|
6766
|
+
} catch (error) {
|
|
6767
|
+
debug(`${error}`);
|
|
6768
|
+
res.writeHead(502);
|
|
6769
|
+
res.end();
|
|
6770
|
+
}
|
|
6771
|
+
});
|
|
6772
|
+
}
|
|
6773
|
+
middlewares.unshift((req, res, next) => {
|
|
6774
|
+
var _a4;
|
|
6775
|
+
if (req.url !== "/open-dingtalk") {
|
|
6776
|
+
return next();
|
|
6777
|
+
}
|
|
6778
|
+
const targetURL = resovedInfo.targetURL;
|
|
6779
|
+
debug(targetURL.toString());
|
|
6780
|
+
res.writeHead(302, {
|
|
6781
|
+
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
6782
|
+
});
|
|
6783
|
+
if (((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) && !resovedInfo.devtoolsInstance) {
|
|
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
|
+
}
|
|
6795
|
+
res.end();
|
|
6796
|
+
});
|
|
6797
|
+
return middlewares;
|
|
6798
|
+
};
|
|
6799
|
+
return [injectSetupMiddlewares, (0, import_unplugin2.createRspackPlugin)(unpluginFactory)(options)];
|
|
6800
|
+
};
|
|
6703
6801
|
/*! Bundled license information:
|
|
6704
6802
|
|
|
6705
6803
|
web-streams-polyfill/dist/ponyfill.es2018.js:
|
package/dist/rspack.d.cts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
|
+
import { Options, RspackSetupMiddlewares } from './types.cjs';
|
|
2
3
|
import 'webpack-dev-server';
|
|
4
|
+
import 'node:http';
|
|
3
5
|
import 'vite-plugin-vconsole';
|
|
4
6
|
|
|
5
|
-
declare const _default: (options
|
|
7
|
+
declare const _default: (options: Options) => readonly [RspackSetupMiddlewares, _unplugin.RspackPluginInstance];
|
|
6
8
|
|
|
7
9
|
export { _default as default };
|
package/dist/rspack.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
|
+
import { Options, RspackSetupMiddlewares } from './types.js';
|
|
2
3
|
import 'webpack-dev-server';
|
|
4
|
+
import 'node:http';
|
|
3
5
|
import 'vite-plugin-vconsole';
|
|
4
6
|
|
|
5
|
-
declare const _default: (options
|
|
7
|
+
declare const _default: (options: Options) => readonly [RspackSetupMiddlewares, _unplugin.RspackPluginInstance];
|
|
6
8
|
|
|
7
9
|
export { _default as default };
|
package/dist/rspack.js
CHANGED
|
@@ -1,11 +1,89 @@
|
|
|
1
1
|
import {
|
|
2
|
+
fetch,
|
|
3
|
+
resovedInfo,
|
|
2
4
|
unpluginFactory
|
|
3
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RDTWBIQD.js";
|
|
4
6
|
import "./chunk-PMOTCIQR.js";
|
|
5
7
|
|
|
6
8
|
// src/rspack.ts
|
|
9
|
+
import { exec } from "child_process";
|
|
10
|
+
import process from "process";
|
|
7
11
|
import { createRspackPlugin } from "unplugin";
|
|
8
|
-
|
|
12
|
+
import cookie from "cookie";
|
|
13
|
+
import c from "picocolors";
|
|
14
|
+
var rspack_default = (options) => {
|
|
15
|
+
function debug(...args) {
|
|
16
|
+
if (options == null ? void 0 : options.debug) {
|
|
17
|
+
console.log(` ${c.yellow("DEBUG")} `, ...args);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const {
|
|
21
|
+
chii: enableChii = true
|
|
22
|
+
} = options || {};
|
|
23
|
+
const injectSetupMiddlewares = (middlewares, _devServer) => {
|
|
24
|
+
if (options.debugCookies && options.debugCookies.length > 0) {
|
|
25
|
+
middlewares.unshift((req, res, next) => {
|
|
26
|
+
const cookies = cookie.parse(req.headers.cookie || "");
|
|
27
|
+
for (const [name, value] of Object.entries(cookies)) {
|
|
28
|
+
if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
29
|
+
const serializedCookie = cookie.serialize(name, value, {
|
|
30
|
+
httpOnly: false
|
|
31
|
+
});
|
|
32
|
+
res.setHeader("Set-Cookie", serializedCookie);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
next();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (enableChii) {
|
|
39
|
+
middlewares.unshift(async (req, res, next) => {
|
|
40
|
+
if (req.url !== "/__chrome_devtools") {
|
|
41
|
+
return next();
|
|
42
|
+
}
|
|
43
|
+
const availablePort = resovedInfo.availablePort;
|
|
44
|
+
try {
|
|
45
|
+
const raw = await fetch(`http://localhost:${availablePort}/targets`);
|
|
46
|
+
const data = await raw.json();
|
|
47
|
+
if ((data == null ? void 0 : data.targets.length) > 0) {
|
|
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
|
+
res.writeHead(302, { Location: devToolsUrl });
|
|
50
|
+
res.end();
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
debug(`${error}`);
|
|
54
|
+
res.writeHead(502);
|
|
55
|
+
res.end();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
middlewares.unshift((req, res, next) => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (req.url !== "/open-dingtalk") {
|
|
62
|
+
return next();
|
|
63
|
+
}
|
|
64
|
+
const targetURL = resovedInfo.targetURL;
|
|
65
|
+
debug(targetURL.toString());
|
|
66
|
+
res.writeHead(302, {
|
|
67
|
+
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
68
|
+
});
|
|
69
|
+
if (((_a = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a.enable) && !resovedInfo.devtoolsInstance) {
|
|
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
|
+
}
|
|
81
|
+
res.end();
|
|
82
|
+
});
|
|
83
|
+
return middlewares;
|
|
84
|
+
};
|
|
85
|
+
return [injectSetupMiddlewares, createRspackPlugin(unpluginFactory)(options)];
|
|
86
|
+
};
|
|
9
87
|
export {
|
|
10
88
|
rspack_default as default
|
|
11
89
|
};
|
package/dist/types.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as webpack_dev_server from 'webpack-dev-server';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
3
|
import { viteVConsoleOptions } from 'vite-plugin-vconsole';
|
|
3
4
|
|
|
4
5
|
interface Options {
|
|
@@ -18,5 +19,18 @@ interface Options {
|
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
type SetupMiddlewares = (middlewares: webpack_dev_server.Middleware[], devServer: webpack_dev_server) => webpack_dev_server.Middleware[];
|
|
22
|
+
type NextFunction = () => void;
|
|
23
|
+
type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
|
|
24
|
+
interface ServerAPIs {
|
|
25
|
+
sockWrite: (type: string, data?: string | boolean | Record<string, any>) => void;
|
|
26
|
+
}
|
|
27
|
+
type RspackSetupMiddlewares = (
|
|
28
|
+
/** Order: `unshift` => internal middlewares => `push` */
|
|
29
|
+
middlewares: {
|
|
30
|
+
/** Use the `unshift` method if you want to run a middleware before all other middlewares */
|
|
31
|
+
unshift: (...handlers: RequestHandler[]) => void;
|
|
32
|
+
/** Use the `push` method if you want to run a middleware after all other middlewares */
|
|
33
|
+
push: (...handlers: RequestHandler[]) => void;
|
|
34
|
+
}, server: ServerAPIs) => void;
|
|
21
35
|
|
|
22
|
-
export type { Options, SetupMiddlewares };
|
|
36
|
+
export type { Options, RspackSetupMiddlewares, SetupMiddlewares };
|