unplugin-dingtalk 1006.0.0 → 1007.0.1

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.
Files changed (67) hide show
  1. package/dist/{chunk-2YQKM4BX.js → __chrome_devtools-CIQ5zFZx.js} +11 -12
  2. package/dist/__chrome_devtools-CJ3sXpVj.cjs +95 -0
  3. package/dist/__chrome_devtools.cjs +2 -114
  4. package/dist/__chrome_devtools.d.cts +3 -2
  5. package/dist/__chrome_devtools.d.ts +3 -2
  6. package/dist/__chrome_devtools.js +3 -7
  7. package/dist/astro.cjs +12 -676
  8. package/dist/astro.d.cts +7 -10
  9. package/dist/astro.d.ts +8 -10
  10. package/dist/astro.js +12 -17
  11. package/dist/chunk-CUT6urMc.cjs +30 -0
  12. package/dist/esbuild.cjs +9 -667
  13. package/dist/esbuild.d.cts +5 -8
  14. package/dist/esbuild.d.ts +6 -8
  15. package/dist/esbuild.js +8 -10
  16. package/dist/index.cjs +10 -676
  17. package/dist/index.d.cts +11 -13
  18. package/dist/index.d.ts +11 -13
  19. package/dist/index.js +5 -16
  20. package/dist/inject-script.cjs +15 -0
  21. package/dist/inject-script.d.cts +3 -0
  22. package/dist/inject-script.d.ts +4 -0
  23. package/dist/inject-script.js +14 -0
  24. package/dist/main-BvTybYko.js +99 -0
  25. package/dist/main-DQgEHuwp.cjs +101 -0
  26. package/dist/nuxt.cjs +80 -842
  27. package/dist/nuxt.d.cts +7 -10
  28. package/dist/nuxt.d.ts +7 -10
  29. package/dist/nuxt.js +78 -24
  30. package/dist/rollup.cjs +9 -667
  31. package/dist/rollup.d.cts +5 -8
  32. package/dist/rollup.d.ts +6 -8
  33. package/dist/rollup.js +8 -10
  34. package/dist/rspack.cjs +54 -728
  35. package/dist/rspack.d.cts +5 -8
  36. package/dist/rspack.d.ts +6 -8
  37. package/dist/rspack.js +50 -74
  38. package/dist/src-CXHMJspk.cjs +393 -0
  39. package/dist/src-DJcUe9oP.js +363 -0
  40. package/dist/types-D6mfGNG_.d.ts +38 -0
  41. package/dist/types-DodDHiEA.d.cts +38 -0
  42. package/dist/types.cjs +0 -19
  43. package/dist/types.d.cts +2 -38
  44. package/dist/types.d.ts +2 -38
  45. package/dist/types.js +1 -0
  46. package/dist/utils-Chlbb6jf.js +23 -0
  47. package/dist/utils-CmfBxo4J.cjs +41 -0
  48. package/dist/utils.cjs +4 -33
  49. package/dist/utils.d.cts +6 -3
  50. package/dist/utils.d.ts +6 -3
  51. package/dist/utils.js +3 -7
  52. package/dist/vite-qeAmx9J4.js +18 -0
  53. package/dist/vite-ytxVicjL.cjs +24 -0
  54. package/dist/vite.cjs +5 -824
  55. package/dist/vite.d.cts +4 -7
  56. package/dist/vite.d.ts +5 -7
  57. package/dist/vite.js +6 -10
  58. package/dist/webpack.cjs +52 -722
  59. package/dist/webpack.d.cts +5 -8
  60. package/dist/webpack.d.ts +6 -8
  61. package/dist/webpack.js +48 -68
  62. package/package.json +13 -11
  63. package/dist/chunk-5JBD5THX.js +0 -20
  64. package/dist/chunk-EG2ZYJ3S.js +0 -542
  65. package/dist/chunk-KQOHODTC.js +0 -9
  66. package/dist/chunk-LMNMIIAV.js +0 -26
  67. package/dist/main-Q4R5NCQC.js +0 -129
@@ -0,0 +1,363 @@
1
+ import { getChromeDevtoolsHtml } from "./__chrome_devtools-CIQ5zFZx.js";
2
+ import { colorUrl, isNuxtProject } from "./utils-Chlbb6jf.js";
3
+ import { ServerResponse } from "node:http";
4
+ import { Socket, createServer } from "node:net";
5
+ import process$1 from "node:process";
6
+ import cookie from "cookie";
7
+ import { networkInterfaces } from "node:os";
8
+ import httpProxy from "http-proxy";
9
+ import c from "picocolors";
10
+ import { createUnplugin } from "unplugin";
11
+ import { start } from "z-chii";
12
+
13
+ //#region node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
14
+ const unsafePorts = /* @__PURE__ */ new Set([
15
+ 1,
16
+ 7,
17
+ 9,
18
+ 11,
19
+ 13,
20
+ 15,
21
+ 17,
22
+ 19,
23
+ 20,
24
+ 21,
25
+ 22,
26
+ 23,
27
+ 25,
28
+ 37,
29
+ 42,
30
+ 43,
31
+ 53,
32
+ 69,
33
+ 77,
34
+ 79,
35
+ 87,
36
+ 95,
37
+ 101,
38
+ 102,
39
+ 103,
40
+ 104,
41
+ 109,
42
+ 110,
43
+ 111,
44
+ 113,
45
+ 115,
46
+ 117,
47
+ 119,
48
+ 123,
49
+ 135,
50
+ 137,
51
+ 139,
52
+ 143,
53
+ 161,
54
+ 179,
55
+ 389,
56
+ 427,
57
+ 465,
58
+ 512,
59
+ 513,
60
+ 514,
61
+ 515,
62
+ 526,
63
+ 530,
64
+ 531,
65
+ 532,
66
+ 540,
67
+ 548,
68
+ 554,
69
+ 556,
70
+ 563,
71
+ 587,
72
+ 601,
73
+ 636,
74
+ 989,
75
+ 990,
76
+ 993,
77
+ 995,
78
+ 1719,
79
+ 1720,
80
+ 1723,
81
+ 2049,
82
+ 3659,
83
+ 4045,
84
+ 5060,
85
+ 5061,
86
+ 6e3,
87
+ 6566,
88
+ 6665,
89
+ 6666,
90
+ 6667,
91
+ 6668,
92
+ 6669,
93
+ 6697,
94
+ 10080
95
+ ]);
96
+ function isUnsafePort(port) {
97
+ return unsafePorts.has(port);
98
+ }
99
+ function isSafePort(port) {
100
+ return !isUnsafePort(port);
101
+ }
102
+ var GetPortError = class extends Error {
103
+ constructor(message, opts) {
104
+ super(message, opts);
105
+ this.message = message;
106
+ }
107
+ name = "GetPortError";
108
+ };
109
+ function _log(verbose, message) {
110
+ if (verbose) console.log(`[get-port] ${message}`);
111
+ }
112
+ function _tryPort(port, host) {
113
+ return new Promise((resolve) => {
114
+ const server = createServer();
115
+ server.unref();
116
+ server.on("error", () => {
117
+ resolve(false);
118
+ });
119
+ server.listen({
120
+ port,
121
+ host
122
+ }, () => {
123
+ const { port: port2 } = server.address();
124
+ server.close(() => {
125
+ resolve(isSafePort(port2) && port2);
126
+ });
127
+ });
128
+ });
129
+ }
130
+ function _getLocalHosts(additional) {
131
+ const hosts = new Set(additional);
132
+ for (const _interface of Object.values(networkInterfaces())) for (const config$1 of _interface || []) if (config$1.address && !config$1.internal && !config$1.address.startsWith("fe80::") && !config$1.address.startsWith("169.254")) hosts.add(config$1.address);
133
+ return [...hosts];
134
+ }
135
+ function _fmtOnHost(hostname) {
136
+ return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
137
+ }
138
+ async function getRandomPort(host) {
139
+ const port = await checkPort(0, host);
140
+ if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
141
+ return port;
142
+ }
143
+ async function checkPort(port, host = process.env.HOST, verbose) {
144
+ if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
145
+ if (!Array.isArray(host)) return _tryPort(port, host);
146
+ for (const _host of host) {
147
+ const _port = await _tryPort(port, _host);
148
+ if (_port === false) {
149
+ if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
150
+ return false;
151
+ }
152
+ if (port === 0 && _port !== 0) port = _port;
153
+ }
154
+ return port;
155
+ }
156
+
157
+ //#endregion
158
+ //#region src/index.ts
159
+ const cwd = process$1.cwd();
160
+ let config;
161
+ const resovedInfo = {
162
+ availablePort: void 0,
163
+ targetURL: void 0
164
+ };
165
+ function createProxyMiddleware(debug) {
166
+ let proxy = null;
167
+ const handleUpgrade = (req, socket, head) => {
168
+ if (proxy && req.url?.startsWith("/__chii_proxy")) {
169
+ debug("WS upgrade:", req.url);
170
+ req.url = req.url.replace("/__chii_proxy", "");
171
+ proxy.ws(req, socket, head);
172
+ }
173
+ };
174
+ return (resolvedInfo) => {
175
+ return (req, res, next) => {
176
+ if (req.url?.startsWith("/__chii_proxy")) req._skip_transform = true;
177
+ if (!proxy && resolvedInfo.availablePort) {
178
+ proxy = httpProxy.createProxyServer({
179
+ target: `http://localhost:${resolvedInfo.availablePort}`,
180
+ ws: true
181
+ });
182
+ proxy.on("error", (err, req$1, res$1) => {
183
+ console.error("Proxy error:", err);
184
+ if (res$1 instanceof ServerResponse) {
185
+ if (!res$1.headersSent) res$1.writeHead(500, { "Content-Type": "text/plain" });
186
+ res$1.end(`Proxy error: ${err.message}`);
187
+ } else if (res$1 instanceof Socket) res$1.destroy();
188
+ });
189
+ if (req.socket.server) req.socket.server.on("upgrade", handleUpgrade);
190
+ }
191
+ if (proxy && req.url?.startsWith("/__chii_proxy")) {
192
+ debug(req.url);
193
+ req.url = req.url.replace("/__chii_proxy", "");
194
+ proxy.web(req, res);
195
+ } else next();
196
+ };
197
+ };
198
+ }
199
+ const isNuxt = isNuxtProject();
200
+ const unpluginFactory = (options) => {
201
+ const { chii } = options || {};
202
+ const enableChii = chii?.enable !== false;
203
+ function debug(...args) {
204
+ if (options?.debug) console.log(` ${c.yellow("DEBUG")} `, ...args);
205
+ }
206
+ const unpluginDing = {
207
+ name: "unplugin-dingtalk",
208
+ enforce: "pre",
209
+ resolveId(source) {
210
+ if (source === "chii-client") return source;
211
+ },
212
+ loadInclude(id) {
213
+ return id === "chii-client";
214
+ },
215
+ load(id) {
216
+ if (id === "chii-client") return `
217
+ ;(function(){
218
+ if (document.getElementById('__chii_client')) return;
219
+ const script = document.createElement('script');
220
+ script.id = '__chii_client';
221
+ script.src="/__chii_proxy/target.js";
222
+ ${options?.chii?.embedded ? "script.setAttribute('embedded','true');" : ""}
223
+ document.body.appendChild(script);
224
+ })();
225
+ if (import.meta.hot) {
226
+ import.meta.hot.accept(() => {
227
+ const old = document.getElementById('__chii_client');
228
+ if (old) old.remove();
229
+ const script = document.createElement('script');
230
+ script.id = '__chii_client';
231
+ script.src="/__chii_proxy/target.js";
232
+ ${options?.chii?.embedded ? "script.setAttribute('embedded','true');" : ""}
233
+ document.body.appendChild(script);
234
+ });
235
+ }
236
+ `;
237
+ },
238
+ transformInclude(id) {
239
+ return !!id.split("?")[0].match(/\.[t|j]s$/);
240
+ },
241
+ async transform(source, id) {
242
+ if (options?.enable && enableChii && !resovedInfo.availablePort) {
243
+ resovedInfo.availablePort = await getRandomPort();
244
+ start({ port: resovedInfo.availablePort });
245
+ debug(`chii server port: ${resovedInfo.availablePort}`);
246
+ }
247
+ if (options?.enable && enableChii) {
248
+ const file = id.split("?")[0];
249
+ if (file.startsWith(config?.root || cwd) && !file.includes("node_modules") && file.match(/\.[t|j]s$/) && !isNuxt) return {
250
+ code: `import 'chii-client';\n${source}`,
251
+ map: null
252
+ };
253
+ }
254
+ return {
255
+ code: source,
256
+ map: null
257
+ };
258
+ },
259
+ vite: {
260
+ configResolved(_config) {
261
+ config = _config;
262
+ },
263
+ transformIndexHtml(html) {
264
+ if (options?.enable && enableChii && !isNuxt) {
265
+ const tag = "<script type=\"module\">import 'chii-client';<\/script>";
266
+ if (!html.includes(tag)) return html.replace("</body>", `</body>${tag}\n`);
267
+ }
268
+ return html;
269
+ },
270
+ async configureServer(server) {
271
+ if (!options?.enable) return;
272
+ const _printUrls = server.printUrls.bind(server);
273
+ let source = `localhost:${config.server.port || 5173}`;
274
+ const url = server.resolvedUrls?.local[0];
275
+ if (url) {
276
+ const u = new URL(url);
277
+ source = u.host;
278
+ }
279
+ const base = server.config.base || "/";
280
+ const _targetUrl = options?.targetUrl ?? `http://${source}${base}`;
281
+ server.printUrls = () => {
282
+ _printUrls();
283
+ console.log(` ${c.green("➜")} ${c.bold("Open in dingtalk")}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
284
+ if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
285
+ };
286
+ const targetURL = new URL(_targetUrl);
287
+ targetURL.searchParams.append("ddtab", "true");
288
+ if (options?.corpId) targetURL.searchParams.append("corpId", options.corpId);
289
+ if (options.debugCookies && options.debugCookies.length > 0) server.middlewares.use((req, res, next) => {
290
+ const cookies = cookie.parse(req.headers.cookie || "");
291
+ for (const [name, value] of Object.entries(cookies)) if (value && options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
292
+ const serializedCookie = cookie.serialize(name, value, { httpOnly: false });
293
+ res.setHeader("Set-Cookie", serializedCookie);
294
+ }
295
+ next();
296
+ });
297
+ if (enableChii) {
298
+ server.middlewares.use("/__chrome_devtools", async (_req, res) => {
299
+ if (!resovedInfo.availablePort) {
300
+ res.writeHead(500, { "Content-Type": "text/plain" });
301
+ res.end("Server not started");
302
+ return;
303
+ }
304
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
305
+ res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
306
+ res.end();
307
+ });
308
+ if (!isNuxt) {
309
+ const proxyMiddleware = createProxyMiddleware(debug);
310
+ server.middlewares.use(proxyMiddleware(resovedInfo));
311
+ }
312
+ }
313
+ server.middlewares.use("/open-dingtalk", (req, res) => {
314
+ debug(targetURL.toString());
315
+ res.writeHead(302, { Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}` });
316
+ res.end();
317
+ });
318
+ }
319
+ },
320
+ webpack(compiler) {
321
+ if (!options?.enable) return;
322
+ const devServerOptions = {
323
+ host: "localhost",
324
+ port: 8080,
325
+ ...compiler.options.devServer,
326
+ ...process$1.VUE_CLI_SERVICE?.projectOptions.devServer
327
+ };
328
+ const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
329
+ const base = compiler.options.output.publicPath || "/";
330
+ const _targetUrl = options?.targetUrl ?? `http://${source}${base}`;
331
+ compiler.hooks.done.tap("unplugin-dingtalk", () => {
332
+ console.log(` ${c.green("➜")} ${c.bold("Open in dingtalk")}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
333
+ if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
334
+ });
335
+ resovedInfo.targetURL = new URL(_targetUrl);
336
+ resovedInfo.targetURL.searchParams.append("ddtab", "true");
337
+ if (options?.corpId) resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
338
+ },
339
+ async rspack(compiler) {
340
+ if (!options?.enable) return;
341
+ const devServerOptions = {
342
+ host: "localhost",
343
+ port: 8080,
344
+ ...compiler.options.devServer,
345
+ ...(await (await import("@rsbuild/core"))?.loadConfig({ cwd }))?.content?.server
346
+ };
347
+ const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
348
+ const base = compiler.options.output.publicPath || "/";
349
+ const _targetUrl = options?.targetUrl ?? `http://${source}${base}`;
350
+ resovedInfo.targetURL = new URL(_targetUrl);
351
+ resovedInfo.targetURL.searchParams.append("ddtab", "true");
352
+ if (options?.corpId) resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
353
+ console.log(` ${c.green("➜")} ${c.bold("Open in dingtalk")}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
354
+ if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
355
+ }
356
+ };
357
+ return unpluginDing;
358
+ };
359
+ const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
360
+ var src_default = unplugin;
361
+
362
+ //#endregion
363
+ export { createProxyMiddleware, resovedInfo, src_default, unplugin, unpluginFactory };
@@ -0,0 +1,38 @@
1
+ import { IncomingMessage, ServerResponse } from "node:http";
2
+ import * as webpack_dev_server0 from "webpack-dev-server";
3
+ import { viteVConsoleOptions } from "vite-plugin-vconsole";
4
+
5
+ //#region src/types.d.ts
6
+ interface Options {
7
+ enable?: boolean;
8
+ targetUrl?: string;
9
+ corpId?: string;
10
+ debug?: boolean;
11
+ /** only support vite */
12
+ vconsole?: viteVConsoleOptions;
13
+ chii?: {
14
+ /** default true */
15
+ enable?: boolean;
16
+ /**
17
+ * default false
18
+ * @link [chii embedded](https://chii.liriliri.io/docs/#usage)
19
+ */
20
+ embedded?: boolean;
21
+ };
22
+ debugCookies?: string[];
23
+ }
24
+ type SetupMiddlewares = (middlewares: webpack_dev_server0.Middleware[], devServer: webpack_dev_server0) => webpack_dev_server0.Middleware[];
25
+ type NextFunction = () => void;
26
+ type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
27
+ interface ServerAPIs {
28
+ sockWrite: (type: string, data?: string | boolean | Record<string, any>) => void;
29
+ }
30
+ type RspackSetupMiddlewares = (/** Order: `unshift` => internal middlewares => `push` */
31
+ middlewares: {
32
+ /** Use the `unshift` method if you want to run a middleware before all other middlewares */
33
+ unshift: (...handlers: RequestHandler[]) => void;
34
+ /** Use the `push` method if you want to run a middleware after all other middlewares */
35
+ push: (...handlers: RequestHandler[]) => void;
36
+ }, server: ServerAPIs) => void;
37
+ //#endregion
38
+ export { Options, RspackSetupMiddlewares, SetupMiddlewares };
@@ -0,0 +1,38 @@
1
+ import * as webpack_dev_server0 from "webpack-dev-server";
2
+ import { IncomingMessage, ServerResponse } from "node:http";
3
+ import { viteVConsoleOptions } from "vite-plugin-vconsole";
4
+
5
+ //#region src/types.d.ts
6
+ interface Options {
7
+ enable?: boolean;
8
+ targetUrl?: string;
9
+ corpId?: string;
10
+ debug?: boolean;
11
+ /** only support vite */
12
+ vconsole?: viteVConsoleOptions;
13
+ chii?: {
14
+ /** default true */
15
+ enable?: boolean;
16
+ /**
17
+ * default false
18
+ * @link [chii embedded](https://chii.liriliri.io/docs/#usage)
19
+ */
20
+ embedded?: boolean;
21
+ };
22
+ debugCookies?: string[];
23
+ }
24
+ type SetupMiddlewares = (middlewares: webpack_dev_server0.Middleware[], devServer: webpack_dev_server0) => webpack_dev_server0.Middleware[];
25
+ type NextFunction = () => void;
26
+ type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
27
+ interface ServerAPIs {
28
+ sockWrite: (type: string, data?: string | boolean | Record<string, any>) => void;
29
+ }
30
+ type RspackSetupMiddlewares = (/** Order: `unshift` => internal middlewares => `push` */
31
+ middlewares: {
32
+ /** Use the `unshift` method if you want to run a middleware before all other middlewares */
33
+ unshift: (...handlers: RequestHandler[]) => void;
34
+ /** Use the `push` method if you want to run a middleware after all other middlewares */
35
+ push: (...handlers: RequestHandler[]) => void;
36
+ }, server: ServerAPIs) => void;
37
+ //#endregion
38
+ export { Options, RspackSetupMiddlewares, SetupMiddlewares };
package/dist/types.cjs CHANGED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/types.ts
17
- var types_exports = {};
18
- module.exports = __toCommonJS(types_exports);
19
- exports.default = module.exports;
package/dist/types.d.cts CHANGED
@@ -1,38 +1,2 @@
1
- import * as webpack_dev_server from 'webpack-dev-server';
2
- import { IncomingMessage, ServerResponse } from 'node:http';
3
- import { viteVConsoleOptions } from 'vite-plugin-vconsole';
4
-
5
- interface Options {
6
- enable?: boolean;
7
- targetUrl?: string;
8
- corpId?: string;
9
- debug?: boolean;
10
- /** only support vite */
11
- vconsole?: viteVConsoleOptions;
12
- chii?: {
13
- /** default true */
14
- enable?: boolean;
15
- /**
16
- * default false
17
- * @link [chii embedded](https://chii.liriliri.io/docs/#usage)
18
- */
19
- embedded?: boolean;
20
- };
21
- debugCookies?: string[];
22
- }
23
- type SetupMiddlewares = (middlewares: webpack_dev_server.Middleware[], devServer: webpack_dev_server) => webpack_dev_server.Middleware[];
24
- type NextFunction = () => void;
25
- type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
26
- interface ServerAPIs {
27
- sockWrite: (type: string, data?: string | boolean | Record<string, any>) => void;
28
- }
29
- type RspackSetupMiddlewares = (
30
- /** Order: `unshift` => internal middlewares => `push` */
31
- middlewares: {
32
- /** Use the `unshift` method if you want to run a middleware before all other middlewares */
33
- unshift: (...handlers: RequestHandler[]) => void;
34
- /** Use the `push` method if you want to run a middleware after all other middlewares */
35
- push: (...handlers: RequestHandler[]) => void;
36
- }, server: ServerAPIs) => void;
37
-
38
- export type { Options, RspackSetupMiddlewares, SetupMiddlewares };
1
+ import { Options, RspackSetupMiddlewares, SetupMiddlewares } from "./types-DodDHiEA.cjs";
2
+ export { Options, RspackSetupMiddlewares, SetupMiddlewares };
package/dist/types.d.ts CHANGED
@@ -1,38 +1,2 @@
1
- import * as webpack_dev_server from 'webpack-dev-server';
2
- import { IncomingMessage, ServerResponse } from 'node:http';
3
- import { viteVConsoleOptions } from 'vite-plugin-vconsole';
4
-
5
- interface Options {
6
- enable?: boolean;
7
- targetUrl?: string;
8
- corpId?: string;
9
- debug?: boolean;
10
- /** only support vite */
11
- vconsole?: viteVConsoleOptions;
12
- chii?: {
13
- /** default true */
14
- enable?: boolean;
15
- /**
16
- * default false
17
- * @link [chii embedded](https://chii.liriliri.io/docs/#usage)
18
- */
19
- embedded?: boolean;
20
- };
21
- debugCookies?: string[];
22
- }
23
- type SetupMiddlewares = (middlewares: webpack_dev_server.Middleware[], devServer: webpack_dev_server) => webpack_dev_server.Middleware[];
24
- type NextFunction = () => void;
25
- type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
26
- interface ServerAPIs {
27
- sockWrite: (type: string, data?: string | boolean | Record<string, any>) => void;
28
- }
29
- type RspackSetupMiddlewares = (
30
- /** Order: `unshift` => internal middlewares => `push` */
31
- middlewares: {
32
- /** Use the `unshift` method if you want to run a middleware before all other middlewares */
33
- unshift: (...handlers: RequestHandler[]) => void;
34
- /** Use the `push` method if you want to run a middleware after all other middlewares */
35
- push: (...handlers: RequestHandler[]) => void;
36
- }, server: ServerAPIs) => void;
37
-
38
- export type { Options, RspackSetupMiddlewares, SetupMiddlewares };
1
+ import { Options, RspackSetupMiddlewares, SetupMiddlewares } from "./types-D6mfGNG_.js";
2
+ export { Options, RspackSetupMiddlewares, SetupMiddlewares };
package/dist/types.js CHANGED
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,23 @@
1
+ import process from "node:process";
2
+ import c from "picocolors";
3
+ import { existsSync } from "node:fs";
4
+
5
+ //#region src/utils.ts
6
+ async function interopDefault(m) {
7
+ const resolved = await m;
8
+ return resolved.default || resolved;
9
+ }
10
+ const colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
11
+ function isNuxtProject() {
12
+ const names = ["nuxt.config.ts", "nuxt.config.js"];
13
+ for (const name of names) {
14
+ const path = `${process.cwd()}/${name}`;
15
+ const result = existsSync(path);
16
+ if (result) return true;
17
+ else continue;
18
+ }
19
+ return false;
20
+ }
21
+
22
+ //#endregion
23
+ export { colorUrl, interopDefault, isNuxtProject };
@@ -0,0 +1,41 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const node_process = require_chunk.__toESM(require("node:process"));
3
+ const picocolors = require_chunk.__toESM(require("picocolors"));
4
+ const node_fs = require_chunk.__toESM(require("node:fs"));
5
+
6
+ //#region src/utils.ts
7
+ async function interopDefault(m) {
8
+ const resolved = await m;
9
+ return resolved.default || resolved;
10
+ }
11
+ const colorUrl = (url) => picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${picocolors.default.bold(port)}/`));
12
+ function isNuxtProject() {
13
+ const names = ["nuxt.config.ts", "nuxt.config.js"];
14
+ for (const name of names) {
15
+ const path = `${node_process.default.cwd()}/${name}`;
16
+ const result = (0, node_fs.existsSync)(path);
17
+ if (result) return true;
18
+ else continue;
19
+ }
20
+ return false;
21
+ }
22
+
23
+ //#endregion
24
+ Object.defineProperty(exports, 'colorUrl', {
25
+ enumerable: true,
26
+ get: function () {
27
+ return colorUrl;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, 'interopDefault', {
31
+ enumerable: true,
32
+ get: function () {
33
+ return interopDefault;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, 'isNuxtProject', {
37
+ enumerable: true,
38
+ get: function () {
39
+ return isNuxtProject;
40
+ }
41
+ });
package/dist/utils.cjs CHANGED
@@ -1,34 +1,5 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ const require_utils = require('./utils-CmfBxo4J.cjs');
19
2
 
20
- // src/utils.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- interopDefault: () => interopDefault
24
- });
25
- module.exports = __toCommonJS(utils_exports);
26
- async function interopDefault(m) {
27
- const resolved = await m;
28
- return resolved.default || resolved;
29
- }
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- interopDefault
33
- });
34
- exports.default = module.exports;
3
+ exports.colorUrl = require_utils.colorUrl;
4
+ exports.interopDefault = require_utils.interopDefault;
5
+ exports.isNuxtProject = require_utils.isNuxtProject;
package/dist/utils.d.cts CHANGED
@@ -1,6 +1,9 @@
1
+ //#region src/utils.d.ts
1
2
  type Awaitable<T> = T | Promise<T>;
2
3
  declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
3
- default: infer U;
4
+ default: infer U;
4
5
  } ? U : T>;
5
-
6
- export { type Awaitable, interopDefault };
6
+ declare const colorUrl: (url: string) => string;
7
+ declare function isNuxtProject(): boolean;
8
+ //#endregion
9
+ export { Awaitable, colorUrl, interopDefault, isNuxtProject };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,9 @@
1
+ //#region src/utils.d.ts
1
2
  type Awaitable<T> = T | Promise<T>;
2
3
  declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
3
- default: infer U;
4
+ default: infer U;
4
5
  } ? U : T>;
5
-
6
- export { type Awaitable, interopDefault };
6
+ declare const colorUrl: (url: string) => string;
7
+ declare function isNuxtProject(): boolean;
8
+ //#endregion
9
+ export { Awaitable, colorUrl, interopDefault, isNuxtProject };
package/dist/utils.js CHANGED
@@ -1,7 +1,3 @@
1
- import {
2
- interopDefault
3
- } from "./chunk-KQOHODTC.js";
4
- import "./chunk-5JBD5THX.js";
5
- export {
6
- interopDefault
7
- };
1
+ import { colorUrl, interopDefault, isNuxtProject } from "./utils-Chlbb6jf.js";
2
+
3
+ export { colorUrl, interopDefault, isNuxtProject };