unplugin-dingtalk 1006.0.0 → 1007.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.
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 +459 -825
  27. package/dist/nuxt.d.cts +7 -10
  28. package/dist/nuxt.d.ts +7 -10
  29. package/dist/nuxt.js +474 -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-BVX_Roo9.js +364 -0
  39. package/dist/src-hLDO4Q22.cjs +394 -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-CKIDsKJ-.cjs +24 -0
  53. package/dist/vite-DoBUfGyY.js +18 -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 +12 -10
  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,394 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require___chrome_devtools = require('./__chrome_devtools-CJ3sXpVj.cjs');
3
+ const require_utils = require('./utils-CmfBxo4J.cjs');
4
+ const node_http = require_chunk.__toESM(require("node:http"));
5
+ const node_net = require_chunk.__toESM(require("node:net"));
6
+ const node_process = require_chunk.__toESM(require("node:process"));
7
+ const cookie = require_chunk.__toESM(require("cookie"));
8
+ const node_os = require_chunk.__toESM(require("node:os"));
9
+ const http_proxy = require_chunk.__toESM(require("http-proxy"));
10
+ const picocolors = require_chunk.__toESM(require("picocolors"));
11
+ const unplugin = require_chunk.__toESM(require("unplugin"));
12
+ const z_chii = require_chunk.__toESM(require("z-chii"));
13
+
14
+ //#region node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
15
+ const unsafePorts = /* @__PURE__ */ new Set([
16
+ 1,
17
+ 7,
18
+ 9,
19
+ 11,
20
+ 13,
21
+ 15,
22
+ 17,
23
+ 19,
24
+ 20,
25
+ 21,
26
+ 22,
27
+ 23,
28
+ 25,
29
+ 37,
30
+ 42,
31
+ 43,
32
+ 53,
33
+ 69,
34
+ 77,
35
+ 79,
36
+ 87,
37
+ 95,
38
+ 101,
39
+ 102,
40
+ 103,
41
+ 104,
42
+ 109,
43
+ 110,
44
+ 111,
45
+ 113,
46
+ 115,
47
+ 117,
48
+ 119,
49
+ 123,
50
+ 135,
51
+ 137,
52
+ 139,
53
+ 143,
54
+ 161,
55
+ 179,
56
+ 389,
57
+ 427,
58
+ 465,
59
+ 512,
60
+ 513,
61
+ 514,
62
+ 515,
63
+ 526,
64
+ 530,
65
+ 531,
66
+ 532,
67
+ 540,
68
+ 548,
69
+ 554,
70
+ 556,
71
+ 563,
72
+ 587,
73
+ 601,
74
+ 636,
75
+ 989,
76
+ 990,
77
+ 993,
78
+ 995,
79
+ 1719,
80
+ 1720,
81
+ 1723,
82
+ 2049,
83
+ 3659,
84
+ 4045,
85
+ 5060,
86
+ 5061,
87
+ 6e3,
88
+ 6566,
89
+ 6665,
90
+ 6666,
91
+ 6667,
92
+ 6668,
93
+ 6669,
94
+ 6697,
95
+ 10080
96
+ ]);
97
+ function isUnsafePort(port) {
98
+ return unsafePorts.has(port);
99
+ }
100
+ function isSafePort(port) {
101
+ return !isUnsafePort(port);
102
+ }
103
+ var GetPortError = class extends Error {
104
+ constructor(message, opts) {
105
+ super(message, opts);
106
+ this.message = message;
107
+ }
108
+ name = "GetPortError";
109
+ };
110
+ function _log(verbose, message) {
111
+ if (verbose) console.log(`[get-port] ${message}`);
112
+ }
113
+ function _tryPort(port, host) {
114
+ return new Promise((resolve) => {
115
+ const server = (0, node_net.createServer)();
116
+ server.unref();
117
+ server.on("error", () => {
118
+ resolve(false);
119
+ });
120
+ server.listen({
121
+ port,
122
+ host
123
+ }, () => {
124
+ const { port: port2 } = server.address();
125
+ server.close(() => {
126
+ resolve(isSafePort(port2) && port2);
127
+ });
128
+ });
129
+ });
130
+ }
131
+ function _getLocalHosts(additional) {
132
+ const hosts = new Set(additional);
133
+ for (const _interface of Object.values((0, node_os.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);
134
+ return [...hosts];
135
+ }
136
+ function _fmtOnHost(hostname) {
137
+ return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
138
+ }
139
+ async function getRandomPort(host) {
140
+ const port = await checkPort(0, host);
141
+ if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
142
+ return port;
143
+ }
144
+ async function checkPort(port, host = process.env.HOST, verbose) {
145
+ if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
146
+ if (!Array.isArray(host)) return _tryPort(port, host);
147
+ for (const _host of host) {
148
+ const _port = await _tryPort(port, _host);
149
+ if (_port === false) {
150
+ if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
151
+ return false;
152
+ }
153
+ if (port === 0 && _port !== 0) port = _port;
154
+ }
155
+ return port;
156
+ }
157
+
158
+ //#endregion
159
+ //#region src/index.ts
160
+ const cwd = node_process.default.cwd();
161
+ let config;
162
+ const resovedInfo = {
163
+ availablePort: void 0,
164
+ targetURL: void 0
165
+ };
166
+ function createProxyMiddleware(debug) {
167
+ let proxy = null;
168
+ const handleUpgrade = (req, socket, head) => {
169
+ if (proxy && req.url?.startsWith("/__chii_proxy")) {
170
+ debug("WS upgrade:", req.url);
171
+ req.url = req.url.replace("/__chii_proxy", "");
172
+ proxy.ws(req, socket, head);
173
+ }
174
+ };
175
+ return (resolvedInfo) => {
176
+ return (req, res, next) => {
177
+ if (req.url?.startsWith("/__chii_proxy")) req._skip_transform = true;
178
+ if (!proxy && resolvedInfo.availablePort) {
179
+ proxy = http_proxy.default.createProxyServer({
180
+ target: `http://localhost:${resolvedInfo.availablePort}`,
181
+ ws: true
182
+ });
183
+ proxy.on("error", (err, req$1, res$1) => {
184
+ console.error("Proxy error:", err);
185
+ if (res$1 instanceof node_http.ServerResponse) {
186
+ if (!res$1.headersSent) res$1.writeHead(500, { "Content-Type": "text/plain" });
187
+ res$1.end(`Proxy error: ${err.message}`);
188
+ } else if (res$1 instanceof node_net.Socket) res$1.destroy();
189
+ });
190
+ if (req.socket.server) req.socket.server.on("upgrade", handleUpgrade);
191
+ }
192
+ if (proxy && req.url?.startsWith("/__chii_proxy")) {
193
+ debug(req.url);
194
+ req.url = req.url.replace("/__chii_proxy", "");
195
+ proxy.web(req, res);
196
+ } else next();
197
+ };
198
+ };
199
+ }
200
+ const unpluginFactory = (options) => {
201
+ const { chii } = options || {};
202
+ const enableChii = chii?.enable !== false;
203
+ function debug(...args) {
204
+ if (options?.debug) console.log(` ${picocolors.default.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
+ (0, z_chii.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$/)) 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) {
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(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Open in dingtalk")}: ${require_utils.colorUrl(`http://${source}${base}open-dingtalk`)}`);
284
+ if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.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.default.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.default.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(require___chrome_devtools.getChromeDevtoolsHtml(resovedInfo.availablePort));
306
+ res.end();
307
+ });
308
+ const isNuxt = require_utils.isNuxtProject();
309
+ console.log("isNuxt", isNuxt);
310
+ if (!isNuxt) {
311
+ const proxyMiddleware = createProxyMiddleware(debug);
312
+ server.middlewares.use(proxyMiddleware(resovedInfo));
313
+ }
314
+ }
315
+ server.middlewares.use("/open-dingtalk", (req, res) => {
316
+ debug(targetURL.toString());
317
+ res.writeHead(302, { Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}` });
318
+ res.end();
319
+ });
320
+ }
321
+ },
322
+ webpack(compiler) {
323
+ if (!options?.enable) return;
324
+ const devServerOptions = {
325
+ host: "localhost",
326
+ port: 8080,
327
+ ...compiler.options.devServer,
328
+ ...node_process.default.VUE_CLI_SERVICE?.projectOptions.devServer
329
+ };
330
+ const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
331
+ const base = compiler.options.output.publicPath || "/";
332
+ const _targetUrl = options?.targetUrl ?? `http://${source}${base}`;
333
+ compiler.hooks.done.tap("unplugin-dingtalk", () => {
334
+ console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Open in dingtalk")}: ${require_utils.colorUrl(`http://${source}${base}open-dingtalk`)}`);
335
+ if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.colorUrl(`http://${source}${base}__chrome_devtools`)}`);
336
+ });
337
+ resovedInfo.targetURL = new URL(_targetUrl);
338
+ resovedInfo.targetURL.searchParams.append("ddtab", "true");
339
+ if (options?.corpId) resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
340
+ },
341
+ async rspack(compiler) {
342
+ if (!options?.enable) return;
343
+ const devServerOptions = {
344
+ host: "localhost",
345
+ port: 8080,
346
+ ...compiler.options.devServer,
347
+ ...(await (await import("@rsbuild/core"))?.loadConfig({ cwd }))?.content?.server
348
+ };
349
+ const source = `${devServerOptions.host === "0.0.0.0" ? "127.0.0.1" : devServerOptions.host}:${devServerOptions.port}`;
350
+ const base = compiler.options.output.publicPath || "/";
351
+ const _targetUrl = options?.targetUrl ?? `http://${source}${base}`;
352
+ resovedInfo.targetURL = new URL(_targetUrl);
353
+ resovedInfo.targetURL.searchParams.append("ddtab", "true");
354
+ if (options?.corpId) resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
355
+ console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Open in dingtalk")}: ${require_utils.colorUrl(`http://${source}${base}open-dingtalk`)}`);
356
+ if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.colorUrl(`http://${source}${base}__chrome_devtools`)}`);
357
+ }
358
+ };
359
+ return unpluginDing;
360
+ };
361
+ const unplugin$1 = /* @__PURE__ */ (0, unplugin.createUnplugin)(unpluginFactory);
362
+ var src_default = unplugin$1;
363
+
364
+ //#endregion
365
+ Object.defineProperty(exports, 'createProxyMiddleware', {
366
+ enumerable: true,
367
+ get: function () {
368
+ return createProxyMiddleware;
369
+ }
370
+ });
371
+ Object.defineProperty(exports, 'resovedInfo', {
372
+ enumerable: true,
373
+ get: function () {
374
+ return resovedInfo;
375
+ }
376
+ });
377
+ Object.defineProperty(exports, 'src_default', {
378
+ enumerable: true,
379
+ get: function () {
380
+ return src_default;
381
+ }
382
+ });
383
+ Object.defineProperty(exports, 'unplugin', {
384
+ enumerable: true,
385
+ get: function () {
386
+ return unplugin$1;
387
+ }
388
+ });
389
+ Object.defineProperty(exports, 'unpluginFactory', {
390
+ enumerable: true,
391
+ get: function () {
392
+ return unpluginFactory;
393
+ }
394
+ });
@@ -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;