unplugin-dingtalk 1005.0.0 → 1006.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.
- package/dist/__chrome_devtools.cjs +115 -0
- package/dist/__chrome_devtools.d.cts +3 -0
- package/dist/astro.cjs +679 -0
- package/dist/astro.d.cts +13 -0
- package/dist/astro.js +1 -1
- package/dist/{chunk-ZLK5HLCO.js → chunk-EG2ZYJ3S.js} +56 -51
- package/dist/{chunk-D63IDACA.js → chunk-LMNMIIAV.js} +2 -2
- package/dist/esbuild.cjs +669 -0
- package/dist/esbuild.d.cts +9 -0
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +676 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -1
- package/dist/main-Q4R5NCQC.js +129 -0
- package/dist/nuxt.cjs +844 -0
- package/dist/nuxt.d.cts +11 -0
- package/dist/nuxt.js +2 -2
- package/dist/rollup.cjs +669 -0
- package/dist/rollup.d.cts +9 -0
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +729 -0
- package/dist/rspack.d.cts +9 -0
- package/dist/rspack.d.ts +2 -1
- package/dist/rspack.js +7 -1
- package/dist/types.cjs +19 -0
- package/dist/types.d.cts +38 -0
- package/dist/utils.cjs +34 -0
- package/dist/utils.d.cts +6 -0
- package/dist/vite.cjs +825 -0
- package/dist/vite.d.cts +9 -0
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +723 -0
- package/dist/webpack.d.cts +9 -0
- package/dist/webpack.js +7 -1
- package/package.json +55 -14
|
@@ -276,6 +276,49 @@ var resovedInfo = {
|
|
|
276
276
|
availablePort: void 0,
|
|
277
277
|
targetURL: void 0
|
|
278
278
|
};
|
|
279
|
+
function createProxyMiddleware(debug) {
|
|
280
|
+
let proxy = null;
|
|
281
|
+
const handleUpgrade = (req, socket, head) => {
|
|
282
|
+
var _a;
|
|
283
|
+
if (proxy && ((_a = req.url) == null ? void 0 : _a.startsWith("/__chii_proxy"))) {
|
|
284
|
+
debug("WS upgrade:", req.url);
|
|
285
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
286
|
+
proxy.ws(req, socket, head);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
return (resolvedInfo) => {
|
|
290
|
+
return (req, res, next) => {
|
|
291
|
+
var _a;
|
|
292
|
+
if (!proxy && resolvedInfo.availablePort) {
|
|
293
|
+
proxy = httpProxy.createProxyServer({
|
|
294
|
+
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
295
|
+
ws: true
|
|
296
|
+
});
|
|
297
|
+
proxy.on("error", (err, req2, res2) => {
|
|
298
|
+
console.error("Proxy error:", err);
|
|
299
|
+
if (res2 instanceof ServerResponse) {
|
|
300
|
+
if (!res2.headersSent) {
|
|
301
|
+
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
302
|
+
}
|
|
303
|
+
res2.end(`Proxy error: ${err.message}`);
|
|
304
|
+
} else if (res2 instanceof Socket) {
|
|
305
|
+
res2.destroy();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
if (req.socket.server) {
|
|
309
|
+
req.socket.server.on("upgrade", handleUpgrade);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (proxy && ((_a = req.url) == null ? void 0 : _a.startsWith("/__chii_proxy"))) {
|
|
313
|
+
debug(req.url);
|
|
314
|
+
req.url = req.url.replace("/__chii_proxy", "");
|
|
315
|
+
proxy.web(req, res);
|
|
316
|
+
} else {
|
|
317
|
+
next();
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
}
|
|
279
322
|
var unpluginFactory = (options) => {
|
|
280
323
|
const {
|
|
281
324
|
chii
|
|
@@ -290,13 +333,16 @@ var unpluginFactory = (options) => {
|
|
|
290
333
|
name: "unplugin-dingtalk",
|
|
291
334
|
enforce: "pre",
|
|
292
335
|
resolveId(source) {
|
|
293
|
-
if (source === "
|
|
336
|
+
if (source === "chii-client") {
|
|
294
337
|
return source;
|
|
295
338
|
}
|
|
296
339
|
},
|
|
340
|
+
loadInclude(id) {
|
|
341
|
+
return id === "chii-client";
|
|
342
|
+
},
|
|
297
343
|
load(id) {
|
|
298
344
|
var _a, _b;
|
|
299
|
-
if (id === "
|
|
345
|
+
if (id === "chii-client") {
|
|
300
346
|
return `
|
|
301
347
|
;(function(){
|
|
302
348
|
if (document.getElementById('__chii_client')) return;
|
|
@@ -320,6 +366,9 @@ if (import.meta.hot) {
|
|
|
320
366
|
`;
|
|
321
367
|
}
|
|
322
368
|
},
|
|
369
|
+
transformInclude(id) {
|
|
370
|
+
return !!id.split("?")[0].match(/\.[t|j]s$/);
|
|
371
|
+
},
|
|
323
372
|
async transform(source, id) {
|
|
324
373
|
if ((options == null ? void 0 : options.enable) && enableChii && !resovedInfo.availablePort) {
|
|
325
374
|
resovedInfo.availablePort = await getRandomPort();
|
|
@@ -328,9 +377,9 @@ if (import.meta.hot) {
|
|
|
328
377
|
}
|
|
329
378
|
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
330
379
|
const file = id.split("?")[0];
|
|
331
|
-
if (file.startsWith(config.root) && !file.includes("node_modules") && file.match(/\.[t|j]s$/)) {
|
|
380
|
+
if (file.startsWith((config == null ? void 0 : config.root) || cwd) && !file.includes("node_modules") && file.match(/\.[t|j]s$/)) {
|
|
332
381
|
return {
|
|
333
|
-
code: `import '
|
|
382
|
+
code: `import 'chii-client';
|
|
334
383
|
${source}`,
|
|
335
384
|
map: null
|
|
336
385
|
};
|
|
@@ -344,7 +393,7 @@ ${source}`,
|
|
|
344
393
|
},
|
|
345
394
|
transformIndexHtml(html) {
|
|
346
395
|
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
347
|
-
const tag = `<script type="module">import '
|
|
396
|
+
const tag = `<script type="module">import 'chii-client';</script>`;
|
|
348
397
|
if (!html.includes(tag)) {
|
|
349
398
|
return html.replace(
|
|
350
399
|
"</body>",
|
|
@@ -400,51 +449,6 @@ ${source}`,
|
|
|
400
449
|
});
|
|
401
450
|
}
|
|
402
451
|
if (enableChii) {
|
|
403
|
-
let createProxyMiddleware2 = function() {
|
|
404
|
-
let proxy = null;
|
|
405
|
-
const handleUpgrade = (req, socket, head) => {
|
|
406
|
-
var _a2;
|
|
407
|
-
if (proxy && ((_a2 = req.url) == null ? void 0 : _a2.startsWith("/__chii_proxy"))) {
|
|
408
|
-
debug("WS upgrade:", req.url);
|
|
409
|
-
req.url = req.url.replace("/__chii_proxy", "");
|
|
410
|
-
proxy.ws(req, socket, head);
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
return (resolvedInfo) => {
|
|
414
|
-
return (req, res, next) => {
|
|
415
|
-
var _a2;
|
|
416
|
-
if (!proxy && resolvedInfo.availablePort) {
|
|
417
|
-
proxy = httpProxy.createProxyServer({
|
|
418
|
-
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
419
|
-
ws: true
|
|
420
|
-
// changeOrigin: true, // Consider if you need this
|
|
421
|
-
});
|
|
422
|
-
proxy.on("error", (err, req2, res2) => {
|
|
423
|
-
console.error("Proxy error:", err);
|
|
424
|
-
if (res2 instanceof ServerResponse) {
|
|
425
|
-
if (!res2.headersSent) {
|
|
426
|
-
res2.writeHead(500, { "Content-Type": "text/plain" });
|
|
427
|
-
}
|
|
428
|
-
res2.end(`Proxy error: ${err.message}`);
|
|
429
|
-
} else if (res2 instanceof Socket) {
|
|
430
|
-
res2.destroy();
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
if (req.socket.server) {
|
|
434
|
-
req.socket.server.on("upgrade", handleUpgrade);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
if (proxy && ((_a2 = req.url) == null ? void 0 : _a2.startsWith("/__chii_proxy"))) {
|
|
438
|
-
debug(req.url);
|
|
439
|
-
req.url = req.url.replace("/__chii_proxy", "");
|
|
440
|
-
proxy.web(req, res);
|
|
441
|
-
} else {
|
|
442
|
-
next();
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
};
|
|
446
|
-
};
|
|
447
|
-
var createProxyMiddleware = createProxyMiddleware2;
|
|
448
452
|
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
449
453
|
if (!resovedInfo.availablePort) {
|
|
450
454
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
@@ -455,7 +459,7 @@ ${source}`,
|
|
|
455
459
|
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
|
|
456
460
|
res.end();
|
|
457
461
|
});
|
|
458
|
-
const proxyMiddleware =
|
|
462
|
+
const proxyMiddleware = createProxyMiddleware(debug);
|
|
459
463
|
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
460
464
|
}
|
|
461
465
|
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
@@ -531,6 +535,7 @@ var index_default = unplugin;
|
|
|
531
535
|
|
|
532
536
|
export {
|
|
533
537
|
resovedInfo,
|
|
538
|
+
createProxyMiddleware,
|
|
534
539
|
unpluginFactory,
|
|
535
540
|
unplugin,
|
|
536
541
|
index_default
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KQOHODTC.js";
|
|
4
4
|
import {
|
|
5
5
|
unpluginFactory
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EG2ZYJ3S.js";
|
|
7
7
|
|
|
8
8
|
// src/vite.ts
|
|
9
9
|
import { createVitePlugin } from "unplugin";
|
|
@@ -12,7 +12,7 @@ var vite_default = async (options) => {
|
|
|
12
12
|
const plugins = [createVitePlugin(unpluginFactory)(options)];
|
|
13
13
|
if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
|
|
14
14
|
try {
|
|
15
|
-
const viteVConsilePlugin = await interopDefault(import("
|
|
15
|
+
const viteVConsilePlugin = await interopDefault(import("./main-Q4R5NCQC.js"));
|
|
16
16
|
plugins.push(viteVConsilePlugin(options == null ? void 0 : options.vconsole));
|
|
17
17
|
} catch (e) {
|
|
18
18
|
console.error("vite-plugin-vconsole not found");
|