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/nuxt.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 process4 = require("process");
4393
- const { emitWarning } = process4;
4392
+ const process3 = require("process");
4393
+ const { emitWarning } = process3;
4394
4394
  try {
4395
- process4.emitWarning = () => {
4395
+ process3.emitWarning = () => {
4396
4396
  };
4397
4397
  Object.assign(globalThis, require("stream/web"));
4398
- process4.emitWarning = emitWarning;
4398
+ process3.emitWarning = emitWarning;
4399
4399
  } catch (error) {
4400
- process4.emitWarning = emitWarning;
4400
+ process3.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, "-"), c3 = [], p = `--${b}\r
4710
+ var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c2 = [], p = `--${b}\r
4711
4711
  Content-Disposition: form-data; name="`;
4712
- F2.forEach((v, n) => typeof v == "string" ? c3.push(p + e(n) + `"\r
4712
+ F2.forEach((v, n) => typeof v == "string" ? c2.push(p + e(n) + `"\r
4713
4713
  \r
4714
4714
  ${v.replace(new RegExp("\\r(?!\\n)|(?<!\\r)\\n", "g"), "\r\n")}\r
4715
- `) : c3.push(p + e(n) + `"; filename="${e(v.name, 1)}"\r
4715
+ `) : c2.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
- c3.push(`--${b}--`);
4720
- return new B(c3, { type: "multipart/form-data; boundary=" + b });
4719
+ c2.push(`--${b}--`);
4720
+ return new B(c2, { 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, 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");
4731
+ f = (a, b, c2) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c2 = c2 !== void 0 ? c2 + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c2 || b[t] == "blob" ? new file_default([b], c2, b) : b] : [a, b + ""]);
4732
+ e = (c2, f3) => (f3 ? c2 : c2.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, c3 = 0; c3 < l; c3++) if (b[c3][0] === a) return b[c3][1];
4764
+ for (var b = __privateGet(this, _d), l = b.length, c2 = 0; c2 < l; c2++) if (b[c2][0] === a) return b[c2][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((c3) => c3[0] === a && b.push(c3[1]));
4771
+ __privateGet(this, _d).forEach((c2) => c2[0] === a && b.push(c2[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 [c3, d] of this) a.call(b, d, c3, this);
4781
+ for (var [c2, d] of this) a.call(b, d, c2, this);
4782
4782
  }
4783
4783
  set(...a) {
4784
4784
  x("set", arguments, 2);
4785
- var b = [], c3 = true;
4785
+ var b = [], c2 = true;
4786
4786
  a = f(...a);
4787
4787
  __privateGet(this, _d).forEach((d) => {
4788
- d[0] === a[0] ? c3 && (c3 = !b.push(a)) : b.push(d);
4788
+ d[0] === a[0] ? c2 && (c2 = !b.push(a)) : b.push(d);
4789
4789
  });
4790
- c3 && b.push(a);
4790
+ c2 && 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 = (c3) => c3 | 32;
4971
+ lower = (c2) => c2 | 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 c3;
5010
+ let c2;
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
- c3 = data[i2];
5037
+ c2 = data[i2];
5038
5038
  switch (state) {
5039
5039
  case S.START_BOUNDARY:
5040
5040
  if (index === boundary.length - 2) {
5041
- if (c3 === HYPHEN) {
5041
+ if (c2 === HYPHEN) {
5042
5042
  flags |= F.LAST_BOUNDARY;
5043
- } else if (c3 !== CR) {
5043
+ } else if (c2 !== 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 && c3 === HYPHEN) {
5049
+ if (flags & F.LAST_BOUNDARY && c2 === HYPHEN) {
5050
5050
  state = S.END;
5051
5051
  flags = 0;
5052
- } else if (!(flags & F.LAST_BOUNDARY) && c3 === LF) {
5052
+ } else if (!(flags & F.LAST_BOUNDARY) && c2 === 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 (c3 !== boundary[index + 2]) {
5061
+ if (c2 !== boundary[index + 2]) {
5062
5062
  index = -2;
5063
5063
  }
5064
- if (c3 === boundary[index + 2]) {
5064
+ if (c2 === 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 (c3 === CR) {
5073
+ if (c2 === CR) {
5074
5074
  clear("onHeaderField");
5075
5075
  state = S.HEADERS_ALMOST_DONE;
5076
5076
  break;
5077
5077
  }
5078
5078
  index++;
5079
- if (c3 === HYPHEN) {
5079
+ if (c2 === HYPHEN) {
5080
5080
  break;
5081
5081
  }
5082
- if (c3 === COLON) {
5082
+ if (c2 === 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(c3);
5090
+ cl = lower(c2);
5091
5091
  if (cl < A || cl > Z) {
5092
5092
  return;
5093
5093
  }
5094
5094
  break;
5095
5095
  case S.HEADER_VALUE_START:
5096
- if (c3 === SPACE) {
5096
+ if (c2 === SPACE) {
5097
5097
  break;
5098
5098
  }
5099
5099
  mark("onHeaderValue");
5100
5100
  state = S.HEADER_VALUE;
5101
5101
  case S.HEADER_VALUE:
5102
- if (c3 === CR) {
5102
+ if (c2 === 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 (c3 !== LF) {
5109
+ if (c2 !== 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 (c3 !== LF) {
5115
+ if (c2 !== 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
- c3 = data[i2];
5132
+ c2 = data[i2];
5133
5133
  }
5134
5134
  if (index < boundary.length) {
5135
- if (boundary[index] === c3) {
5135
+ if (boundary[index] === c2) {
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 (c3 === CR) {
5145
+ if (c2 === CR) {
5146
5146
  flags |= F.PART_BOUNDARY;
5147
- } else if (c3 === HYPHEN) {
5147
+ } else if (c2 === 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 (c3 === LF) {
5155
+ if (c2 === 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 (c3 === HYPHEN) {
5163
+ if (c2 === 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] = c3;
5175
+ lookbehind[index - 1] = c2;
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);
@@ -5215,6 +5215,7 @@ var import_kit = require("@nuxt/kit");
5215
5215
 
5216
5216
  // src/vite.ts
5217
5217
  var import_unplugin2 = require("unplugin");
5218
+ var import_vite_plugin_vconsole = __toESM(require("vite-plugin-vconsole"), 1);
5218
5219
 
5219
5220
  // src/index.ts
5220
5221
  var import_node_child_process = require("child_process");
@@ -5499,7 +5500,7 @@ async function consumeBody(data) {
5499
5500
  }
5500
5501
  if (body.readableEnded === true || body._readableState.ended === true) {
5501
5502
  try {
5502
- if (accum.every((c3) => typeof c3 === "string")) {
5503
+ if (accum.every((c2) => typeof c2 === "string")) {
5503
5504
  return import_node_buffer.Buffer.from(accum.join(""));
5504
5505
  }
5505
5506
  return import_node_buffer.Buffer.concat(accum, accumBytes);
@@ -6515,10 +6516,10 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6515
6516
  // src/index.ts
6516
6517
  var import_unplugin = require("unplugin");
6517
6518
  var import_picocolors = __toESM(require("picocolors"), 1);
6518
- var import_vite_plugin_vconsole = require("vite-plugin-vconsole");
6519
6519
  var import_cookie = __toESM(require("cookie"), 1);
6520
6520
  var import_chii = require("chii");
6521
6521
  var import_get_port_please = require("get-port-please");
6522
+ var cwd = import_node_process.default.cwd();
6522
6523
  var config;
6523
6524
  var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
6524
6525
  var resovedInfo = {
@@ -6535,7 +6536,6 @@ var unpluginFactory = (options) => {
6535
6536
  console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
6536
6537
  }
6537
6538
  }
6538
- const plugins = [];
6539
6539
  const unpluginDing = {
6540
6540
  name: "unplugin-dingtalk",
6541
6541
  enforce: "pre",
@@ -6548,20 +6548,22 @@ var unpluginFactory = (options) => {
6548
6548
  resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
6549
6549
  debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
6550
6550
  (0, import_chii.start)({
6551
+ host: "0.0.0.0",
6551
6552
  port: resovedInfo.availablePort
6552
6553
  });
6553
6554
  }
6554
- if ((options == null ? void 0 : options.enable) && ((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable)) {
6555
+ if (options == null ? void 0 : options.enable) {
6555
6556
  const codes = [
6556
- `/* eslint-disable */;
6557
- import { devtools } from '@vue/devtools'
6558
- 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});`,
6557
+ "/* eslint-disable */;",
6558
+ ((_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});` : "",
6559
6560
  (options == null ? void 0 : options.enable) && enableChii ? `(() => {
6560
6561
  const script = document.createElement('script');
6561
6562
  script.src="http://localhost:${resovedInfo.availablePort}/target.js";
6562
6563
  document.body.appendChild(script);
6563
6564
  })()` : "",
6564
- `/* eslint-enable */${_source};`
6565
+ "/* eslint-enable */",
6566
+ `${_source};`
6565
6567
  ];
6566
6568
  return {
6567
6569
  code: codes.join("\n"),
@@ -6580,23 +6582,19 @@ var unpluginFactory = (options) => {
6580
6582
  config = _config;
6581
6583
  },
6582
6584
  async configureServer(server) {
6583
- var _a4, _b, _c;
6585
+ var _a4, _b;
6584
6586
  if (!(options == null ? void 0 : options.enable)) {
6585
6587
  return;
6586
6588
  }
6587
- const availablePort = resovedInfo.availablePort;
6588
- if ((options == null ? void 0 : options.enable) && ((_a4 = options == null ? void 0 : options.vconsole) == null ? void 0 : _a4.enabled)) {
6589
- plugins.push((0, import_vite_plugin_vconsole.viteVConsole)(options == null ? void 0 : options.vconsole));
6590
- }
6591
6589
  const _printUrls = server.printUrls.bind(server);
6592
6590
  let source = `localhost:${config.server.port || 5173}`;
6593
- const url = (_b = server.resolvedUrls) == null ? void 0 : _b.local[0];
6591
+ const url = (_a4 = server.resolvedUrls) == null ? void 0 : _a4.local[0];
6594
6592
  if (url) {
6595
6593
  const u = new URL(url);
6596
6594
  source = u.host;
6597
6595
  }
6598
6596
  const base = server.config.base || "/";
6599
- const _targetUrl = (_c = options == null ? void 0 : options.targetUrl) != null ? _c : `http://${source}${base}`;
6597
+ const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
6600
6598
  server.printUrls = () => {
6601
6599
  var _a5;
6602
6600
  _printUrls();
@@ -6631,10 +6629,10 @@ var unpluginFactory = (options) => {
6631
6629
  if (enableChii) {
6632
6630
  server.middlewares.use("/__chrome_devtools", async (_req, res) => {
6633
6631
  try {
6634
- const raw = await fetch(`http://localhost:${availablePort}/targets`);
6632
+ const raw = await fetch(`http://localhost:${resovedInfo.availablePort}/targets`);
6635
6633
  const data = await raw.json();
6636
6634
  if ((data == null ? void 0 : data.targets.length) > 0) {
6637
- 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`;
6635
+ 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`;
6638
6636
  res.writeHead(302, { Location: devToolsUrl });
6639
6637
  res.end();
6640
6638
  }
@@ -6695,87 +6693,47 @@ var unpluginFactory = (options) => {
6695
6693
  if (options == null ? void 0 : options.corpId) {
6696
6694
  resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
6697
6695
  }
6696
+ },
6697
+ async rspack(compiler) {
6698
+ var _a4, _b, _c, _d2, _e;
6699
+ if (!(options == null ? void 0 : options.enable)) {
6700
+ return;
6701
+ }
6702
+ const devServerOptions = __spreadValues(__spreadValues({
6703
+ host: "localhost",
6704
+ port: 8080
6705
+ }, compiler.options.devServer), (_c = (_b = await ((_a4 = await import("@rsbuild/core")) == null ? void 0 : _a4.loadConfig({
6706
+ cwd
6707
+ }))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
6708
+ const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
6709
+ const base = compiler.options.output.publicPath || "/";
6710
+ const _targetUrl = (_d2 = options == null ? void 0 : options.targetUrl) != null ? _d2 : `http://${source}${base}`;
6711
+ resovedInfo.targetURL = new URL(_targetUrl);
6712
+ resovedInfo.targetURL.searchParams.append("ddtab", "true");
6713
+ if (options == null ? void 0 : options.corpId) {
6714
+ resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
6715
+ }
6716
+ console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
6717
+ `Open in dingtalk${((_e = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _e.enable) ? " (with vue-devtools)" : ""}`
6718
+ )}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
6719
+ if (enableChii) {
6720
+ console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
6721
+ "Click to open chrome devtools"
6722
+ )}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
6723
+ }
6698
6724
  }
6699
6725
  };
6700
- plugins.push(unpluginDing);
6701
- return plugins;
6726
+ return unpluginDing;
6702
6727
  };
6703
6728
 
6704
6729
  // src/vite.ts
6705
- var vite_default = (0, import_unplugin2.createVitePlugin)(unpluginFactory);
6706
-
6707
- // src/webpack.ts
6708
- var import_node_child_process2 = require("child_process");
6709
- var import_node_process2 = __toESM(require("process"), 1);
6710
- var import_unplugin3 = require("unplugin");
6711
- var import_cookie2 = __toESM(require("cookie"), 1);
6712
- var import_picocolors2 = __toESM(require("picocolors"), 1);
6713
- var webpack_default = (options) => {
6714
- function debug(...args) {
6715
- if (options == null ? void 0 : options.debug) {
6716
- console.log(` ${import_picocolors2.default.yellow("DEBUG")} `, ...args);
6717
- }
6730
+ var vite_default = (options) => {
6731
+ var _a4;
6732
+ const plugins = [(0, import_unplugin2.createVitePlugin)(unpluginFactory)(options)];
6733
+ if ((options == null ? void 0 : options.enable) && ((_a4 = options == null ? void 0 : options.vconsole) == null ? void 0 : _a4.enabled)) {
6734
+ plugins.push((0, import_vite_plugin_vconsole.default)(options == null ? void 0 : options.vconsole));
6718
6735
  }
6719
- const {
6720
- chii: enableChii = true
6721
- } = options || {};
6722
- const injectSetupMiddlewares = (middlewares, devServer) => {
6723
- if (options.debugCookies && options.debugCookies.length > 0) {
6724
- devServer.app.use((req, res, next) => {
6725
- const cookies = import_cookie2.default.parse(req.headers.cookie || "");
6726
- for (const [name, value] of Object.entries(cookies)) {
6727
- if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
6728
- const serializedCookie = import_cookie2.default.serialize(name, value, {
6729
- httpOnly: false
6730
- });
6731
- res.setHeader("Set-Cookie", serializedCookie);
6732
- }
6733
- }
6734
- next();
6735
- });
6736
- }
6737
- if (enableChii) {
6738
- devServer.app.get("/__chrome_devtools", async (_req, res) => {
6739
- const availablePort = resovedInfo.availablePort;
6740
- try {
6741
- const raw = await fetch(`http://localhost:${availablePort}/targets`);
6742
- const data = await raw.json();
6743
- if ((data == null ? void 0 : data.targets.length) > 0) {
6744
- 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`;
6745
- res.writeHead(302, { Location: devToolsUrl });
6746
- res.end();
6747
- }
6748
- } catch (error) {
6749
- debug(`${error}`);
6750
- res.writeHead(502);
6751
- res.end();
6752
- }
6753
- });
6754
- }
6755
- devServer.app.get("/open-dingtalk", (req, res) => {
6756
- var _a4;
6757
- const targetURL = resovedInfo.targetURL;
6758
- console.debug(targetURL.toString());
6759
- res.writeHead(302, {
6760
- Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
6761
- });
6762
- if (((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable) && !resovedInfo.devtoolsInstance) {
6763
- resovedInfo.devtoolsInstance = (0, import_node_child_process2.exec)("npx vue-devtools");
6764
- console.log(` ${import_picocolors2.default.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
6765
- resovedInfo.devtoolsInstance.on("exit", () => {
6766
- resovedInfo.devtoolsInstance = void 0;
6767
- });
6768
- import_node_process2.default.on("exit", () => {
6769
- if (resovedInfo.devtoolsInstance) {
6770
- resovedInfo.devtoolsInstance.kill();
6771
- }
6772
- });
6773
- }
6774
- res.end();
6775
- });
6776
- return middlewares;
6777
- };
6778
- return [injectSetupMiddlewares, (0, import_unplugin3.createWebpackPlugin)(unpluginFactory)(options)];
6736
+ return plugins;
6779
6737
  };
6780
6738
 
6781
6739
  // src/nuxt.ts
@@ -6790,7 +6748,6 @@ var nuxt_default = (0, import_kit.defineNuxtModule)({
6790
6748
  },
6791
6749
  setup(options, _nuxt) {
6792
6750
  (0, import_kit.addVitePlugin)(() => vite_default(options));
6793
- (0, import_kit.addWebpackPlugin)(() => webpack_default(options));
6794
6751
  }
6795
6752
  });
6796
6753
  /*! Bundled license information:
package/dist/nuxt.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { Options } from './types.cjs';
3
3
  import 'webpack-dev-server';
4
+ import 'node:http';
4
5
  import 'vite-plugin-vconsole';
5
6
 
6
7
  interface ModuleOptions extends Options {
package/dist/nuxt.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { Options } from './types.js';
3
3
  import 'webpack-dev-server';
4
+ import 'node:http';
4
5
  import 'vite-plugin-vconsole';
5
6
 
6
7
  interface ModuleOptions extends Options {
package/dist/nuxt.js CHANGED
@@ -1,14 +1,11 @@
1
- import {
2
- webpack_default
3
- } from "./chunk-FMGOYX4F.js";
4
1
  import {
5
2
  vite_default
6
- } from "./chunk-ZV272SZK.js";
7
- import "./chunk-XTDXIGYG.js";
3
+ } from "./chunk-2OB7UBRW.js";
4
+ import "./chunk-RDTWBIQD.js";
8
5
  import "./chunk-PMOTCIQR.js";
9
6
 
10
7
  // src/nuxt.ts
11
- import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
8
+ import { addVitePlugin, defineNuxtModule } from "@nuxt/kit";
12
9
  import "@nuxt/schema";
13
10
  var nuxt_default = defineNuxtModule({
14
11
  meta: {
@@ -20,7 +17,6 @@ var nuxt_default = defineNuxtModule({
20
17
  },
21
18
  setup(options, _nuxt) {
22
19
  addVitePlugin(() => vite_default(options));
23
- addWebpackPlugin(() => webpack_default(options));
24
20
  }
25
21
  });
26
22
  export {
package/dist/rollup.cjs CHANGED
@@ -6512,10 +6512,10 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6512
6512
  // src/index.ts
6513
6513
  var import_unplugin = require("unplugin");
6514
6514
  var import_picocolors = __toESM(require("picocolors"), 1);
6515
- var import_vite_plugin_vconsole = require("vite-plugin-vconsole");
6516
6515
  var import_cookie = __toESM(require("cookie"), 1);
6517
6516
  var import_chii = require("chii");
6518
6517
  var import_get_port_please = require("get-port-please");
6518
+ var cwd = import_node_process.default.cwd();
6519
6519
  var config;
6520
6520
  var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
6521
6521
  var resovedInfo = {
@@ -6532,7 +6532,6 @@ var unpluginFactory = (options) => {
6532
6532
  console.log(` ${import_picocolors.default.yellow("DEBUG")} `, ...args);
6533
6533
  }
6534
6534
  }
6535
- const plugins = [];
6536
6535
  const unpluginDing = {
6537
6536
  name: "unplugin-dingtalk",
6538
6537
  enforce: "pre",
@@ -6545,20 +6544,22 @@ var unpluginFactory = (options) => {
6545
6544
  resovedInfo.availablePort = await (0, import_get_port_please.getRandomPort)();
6546
6545
  debug(`chii server port: ${JSON.stringify({ availablePort: resovedInfo.availablePort })}`);
6547
6546
  (0, import_chii.start)({
6547
+ host: "0.0.0.0",
6548
6548
  port: resovedInfo.availablePort
6549
6549
  });
6550
6550
  }
6551
- if ((options == null ? void 0 : options.enable) && ((_a4 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a4.enable)) {
6551
+ if (options == null ? void 0 : options.enable) {
6552
6552
  const codes = [
6553
- `/* eslint-disable */;
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});`,
6553
+ "/* eslint-disable */;",
6554
+ ((_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});` : "",
6556
6556
  (options == null ? void 0 : options.enable) && enableChii ? `(() => {
6557
6557
  const script = document.createElement('script');
6558
6558
  script.src="http://localhost:${resovedInfo.availablePort}/target.js";
6559
6559
  document.body.appendChild(script);
6560
6560
  })()` : "",
6561
- `/* eslint-enable */${_source};`
6561
+ "/* eslint-enable */",
6562
+ `${_source};`
6562
6563
  ];
6563
6564
  return {
6564
6565
  code: codes.join("\n"),
@@ -6577,23 +6578,19 @@ var unpluginFactory = (options) => {
6577
6578
  config = _config;
6578
6579
  },
6579
6580
  async configureServer(server) {
6580
- var _a4, _b, _c;
6581
+ var _a4, _b;
6581
6582
  if (!(options == null ? void 0 : options.enable)) {
6582
6583
  return;
6583
6584
  }
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
6585
  const _printUrls = server.printUrls.bind(server);
6589
6586
  let source = `localhost:${config.server.port || 5173}`;
6590
- const url = (_b = server.resolvedUrls) == null ? void 0 : _b.local[0];
6587
+ const url = (_a4 = server.resolvedUrls) == null ? void 0 : _a4.local[0];
6591
6588
  if (url) {
6592
6589
  const u = new URL(url);
6593
6590
  source = u.host;
6594
6591
  }
6595
6592
  const base = server.config.base || "/";
6596
- const _targetUrl = (_c = options == null ? void 0 : options.targetUrl) != null ? _c : `http://${source}${base}`;
6593
+ const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
6597
6594
  server.printUrls = () => {
6598
6595
  var _a5;
6599
6596
  _printUrls();
@@ -6628,10 +6625,10 @@ var unpluginFactory = (options) => {
6628
6625
  if (enableChii) {
6629
6626
  server.middlewares.use("/__chrome_devtools", async (_req, res) => {
6630
6627
  try {
6631
- const raw = await fetch(`http://localhost:${availablePort}/targets`);
6628
+ const raw = await fetch(`http://localhost:${resovedInfo.availablePort}/targets`);
6632
6629
  const data = await raw.json();
6633
6630
  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`;
6631
+ 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
6632
  res.writeHead(302, { Location: devToolsUrl });
6636
6633
  res.end();
6637
6634
  }
@@ -6692,10 +6689,37 @@ var unpluginFactory = (options) => {
6692
6689
  if (options == null ? void 0 : options.corpId) {
6693
6690
  resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
6694
6691
  }
6692
+ },
6693
+ async rspack(compiler) {
6694
+ var _a4, _b, _c, _d2, _e;
6695
+ if (!(options == null ? void 0 : options.enable)) {
6696
+ return;
6697
+ }
6698
+ const devServerOptions = __spreadValues(__spreadValues({
6699
+ host: "localhost",
6700
+ port: 8080
6701
+ }, compiler.options.devServer), (_c = (_b = await ((_a4 = await import("@rsbuild/core")) == null ? void 0 : _a4.loadConfig({
6702
+ cwd
6703
+ }))) == null ? void 0 : _b.content) == null ? void 0 : _c.server);
6704
+ const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
6705
+ const base = compiler.options.output.publicPath || "/";
6706
+ const _targetUrl = (_d2 = options == null ? void 0 : options.targetUrl) != null ? _d2 : `http://${source}${base}`;
6707
+ resovedInfo.targetURL = new URL(_targetUrl);
6708
+ resovedInfo.targetURL.searchParams.append("ddtab", "true");
6709
+ if (options == null ? void 0 : options.corpId) {
6710
+ resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
6711
+ }
6712
+ console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
6713
+ `Open in dingtalk${((_e = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _e.enable) ? " (with vue-devtools)" : ""}`
6714
+ )}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
6715
+ if (enableChii) {
6716
+ console.log(` ${import_picocolors.default.green("\u279C")} ${import_picocolors.default.bold(
6717
+ "Click to open chrome devtools"
6718
+ )}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
6719
+ }
6695
6720
  }
6696
6721
  };
6697
- plugins.push(unpluginDing);
6698
- return plugins;
6722
+ return unpluginDing;
6699
6723
  };
6700
6724
 
6701
6725
  // src/rollup.ts