unplugin-dingtalk 1004.0.0 → 1005.0.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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChromeDevtoolsHtml
3
- } from "./chunk-DZEMXGMI.js";
3
+ } from "./chunk-2YQKM4BX.js";
4
4
  import "./chunk-5JBD5THX.js";
5
5
  export {
6
6
  getChromeDevtoolsHtml
package/dist/astro.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  index_default
3
- } from "./chunk-5U7LETMH.js";
4
- import "./chunk-DZEMXGMI.js";
3
+ } from "./chunk-ZLK5HLCO.js";
4
+ import "./chunk-2YQKM4BX.js";
5
5
  import "./chunk-5JBD5THX.js";
6
6
 
7
7
  // src/astro.ts
@@ -76,9 +76,9 @@ function getChromeDevtoolsHtml(targetPort) {
76
76
  list.innerHTML = "<li>\u83B7\u53D6\u8C03\u8BD5\u76EE\u6807\u5931\u8D25</li>";
77
77
  }
78
78
  }
79
- document.getElementById("refresh").onclick = fetchTargets;
79
+ document.getElementById("refresh").onclick = () => window.location.reload();
80
80
  window.onload = fetchTargets;
81
- document.addEventListener('visibilitychange', fetchTargets);
81
+ document.addEventListener('visibilitychange', window.location.reload);
82
82
  </script>
83
83
  </body>
84
84
 
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-KQOHODTC.js";
4
4
  import {
5
5
  unpluginFactory
6
- } from "./chunk-5U7LETMH.js";
6
+ } from "./chunk-ZLK5HLCO.js";
7
7
 
8
8
  // src/vite.ts
9
9
  import { createVitePlugin } from "unplugin";
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  getChromeDevtoolsHtml
3
- } from "./chunk-DZEMXGMI.js";
3
+ } from "./chunk-2YQKM4BX.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-5JBD5THX.js";
7
7
 
8
8
  // src/index.ts
9
- import process2 from "node:process";
10
- import { ServerResponse } from "node:http";
11
- import { Socket } from "node:net";
9
+ import process2 from "process";
10
+ import { ServerResponse } from "http";
11
+ import { Socket } from "net";
12
12
  import { createUnplugin } from "unplugin";
13
13
  import c from "picocolors";
14
14
  import cookie from "cookie";
15
15
  import { start } from "z-chii";
16
16
 
17
17
  // node_modules/.pnpm/get-port-please@3.1.2/node_modules/get-port-please/dist/index.mjs
18
- import { createServer } from "node:net";
19
- import { networkInterfaces } from "node:os";
18
+ import { createServer } from "net";
19
+ import { networkInterfaces } from "os";
20
20
  var unsafePorts = /* @__PURE__ */ new Set([
21
21
  1,
22
22
  // tcpmux
@@ -289,44 +289,71 @@ var unpluginFactory = (options) => {
289
289
  const unpluginDing = {
290
290
  name: "unplugin-dingtalk",
291
291
  enforce: "pre",
292
- transformInclude(id) {
293
- return (id.endsWith("main.ts") || id.endsWith("main.js")) && !id.includes("node_modules");
292
+ resolveId(source) {
293
+ if (source === "virtual:chii-client") {
294
+ return source;
295
+ }
296
+ },
297
+ load(id) {
298
+ var _a, _b;
299
+ if (id === "virtual:chii-client") {
300
+ return `
301
+ ;(function(){
302
+ if (document.getElementById('__chii_client')) return;
303
+ const script = document.createElement('script');
304
+ script.id = '__chii_client';
305
+ script.src="/__chii_proxy/target.js";
306
+ ${((_a = options == null ? void 0 : options.chii) == null ? void 0 : _a.embedded) ? "script.setAttribute('embedded','true');" : ""}
307
+ document.body.appendChild(script);
308
+ })();
309
+ if (import.meta.hot) {
310
+ import.meta.hot.accept(() => {
311
+ const old = document.getElementById('__chii_client');
312
+ if (old) old.remove();
313
+ const script = document.createElement('script');
314
+ script.id = '__chii_client';
315
+ script.src="/__chii_proxy/target.js";
316
+ ${((_b = options == null ? void 0 : options.chii) == null ? void 0 : _b.embedded) ? "script.setAttribute('embedded','true');" : ""}
317
+ document.body.appendChild(script);
318
+ });
319
+ }
320
+ `;
321
+ }
294
322
  },
295
- async transform(_source) {
323
+ async transform(source, id) {
296
324
  if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
297
325
  resovedInfo.availablePort = await getRandomPort();
298
- start({
299
- port: resovedInfo.availablePort
300
- });
326
+ start({ port: resovedInfo.availablePort });
301
327
  debug(`chii server port: ${resovedInfo.availablePort}`);
302
328
  }
303
- return {
304
- code: _source,
305
- map: null
306
- // support source map
307
- };
329
+ if ((options == null ? void 0 : options.enable) && enableChii) {
330
+ const file = id.split("?")[0];
331
+ if (file.startsWith(config.root) && !file.includes("node_modules") && file.match(/\.[t|j]s$/)) {
332
+ return {
333
+ code: `import 'virtual:chii-client';
334
+ ${source}`,
335
+ map: null
336
+ };
337
+ }
338
+ }
339
+ return { code: source, map: null };
308
340
  },
309
341
  vite: {
310
342
  configResolved(_config) {
311
343
  config = _config;
312
344
  },
313
345
  transformIndexHtml(html) {
314
- var _a;
315
346
  if ((options == null ? void 0 : options.enable) && enableChii) {
316
- return html.replace(
317
- "</body>",
318
- `</body>
319
- <script>
320
- (() => {
321
- const script = document.createElement('script');
322
- script.src="/__chii_proxy/target.js";
323
- ${((_a = options == null ? void 0 : options.chii) == null ? void 0 : _a.embedded) ? 'script.setAttribute("embedded", "true");' : ""}
324
- document.body.appendChild(script);
325
- })()
326
- </script>
347
+ const tag = `<script type="module">import 'virtual:chii-client';</script>`;
348
+ if (!html.includes(tag)) {
349
+ return html.replace(
350
+ "</body>",
351
+ `</body>${tag}
327
352
  `
328
- );
353
+ );
354
+ }
329
355
  }
356
+ return html;
330
357
  },
331
358
  async configureServer(server) {
332
359
  var _a, _b;
@@ -419,6 +446,11 @@ var unpluginFactory = (options) => {
419
446
  };
420
447
  var createProxyMiddleware = createProxyMiddleware2;
421
448
  server.middlewares.use("/__chrome_devtools", async (_req, res) => {
449
+ if (!resovedInfo.availablePort) {
450
+ res.writeHead(500, { "Content-Type": "text/plain" });
451
+ res.end("Server not started");
452
+ return;
453
+ }
422
454
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
423
455
  res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
424
456
  res.end();
package/dist/esbuild.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-5U7LETMH.js";
4
- import "./chunk-DZEMXGMI.js";
3
+ } from "./chunk-ZLK5HLCO.js";
4
+ import "./chunk-2YQKM4BX.js";
5
5
  import "./chunk-5JBD5THX.js";
6
6
 
7
7
  // src/esbuild.ts
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  resovedInfo,
4
4
  unplugin,
5
5
  unpluginFactory
6
- } from "./chunk-5U7LETMH.js";
7
- import "./chunk-DZEMXGMI.js";
6
+ } from "./chunk-ZLK5HLCO.js";
7
+ import "./chunk-2YQKM4BX.js";
8
8
  import "./chunk-5JBD5THX.js";
9
9
  export {
10
10
  index_default as default,
package/dist/nuxt.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-7VYUT3GL.js";
3
+ } from "./chunk-D63IDACA.js";
4
4
  import "./chunk-KQOHODTC.js";
5
- import "./chunk-5U7LETMH.js";
6
- import "./chunk-DZEMXGMI.js";
5
+ import "./chunk-ZLK5HLCO.js";
6
+ import "./chunk-2YQKM4BX.js";
7
7
  import "./chunk-5JBD5THX.js";
8
8
 
9
9
  // src/nuxt.ts
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-5U7LETMH.js";
4
- import "./chunk-DZEMXGMI.js";
3
+ } from "./chunk-ZLK5HLCO.js";
4
+ import "./chunk-2YQKM4BX.js";
5
5
  import "./chunk-5JBD5THX.js";
6
6
 
7
7
  // src/rollup.ts
package/dist/rspack.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resovedInfo,
3
3
  unpluginFactory
4
- } from "./chunk-5U7LETMH.js";
4
+ } from "./chunk-ZLK5HLCO.js";
5
5
  import {
6
6
  getChromeDevtoolsHtml
7
- } from "./chunk-DZEMXGMI.js";
7
+ } from "./chunk-2YQKM4BX.js";
8
8
  import "./chunk-5JBD5THX.js";
9
9
 
10
10
  // src/rspack.ts
package/dist/vite.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-7VYUT3GL.js";
3
+ } from "./chunk-D63IDACA.js";
4
4
  import "./chunk-KQOHODTC.js";
5
- import "./chunk-5U7LETMH.js";
6
- import "./chunk-DZEMXGMI.js";
5
+ import "./chunk-ZLK5HLCO.js";
6
+ import "./chunk-2YQKM4BX.js";
7
7
  import "./chunk-5JBD5THX.js";
8
8
  export {
9
9
  vite_default as default
package/dist/webpack.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resovedInfo,
3
3
  unpluginFactory
4
- } from "./chunk-5U7LETMH.js";
4
+ } from "./chunk-ZLK5HLCO.js";
5
5
  import {
6
6
  getChromeDevtoolsHtml
7
- } from "./chunk-DZEMXGMI.js";
7
+ } from "./chunk-2YQKM4BX.js";
8
8
  import "./chunk-5JBD5THX.js";
9
9
 
10
10
  // src/webpack.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-dingtalk",
3
3
  "type": "module",
4
- "version": "1004.0.0",
4
+ "version": "1005.0.0",
5
5
  "description": "",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/zcf0508/unplugin-dingtalk#readme",