unplugin-dingtalk 1007.0.0 → 1007.0.2
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/README.md +1 -0
- package/dist/{__chrome_devtools-CJ3sXpVj.cjs → __chrome_devtools-DXNY3hbb.cjs} +2 -2
- package/dist/{__chrome_devtools-CIQ5zFZx.js → __chrome_devtools-DtQ6IXAu.js} +2 -2
- package/dist/__chrome_devtools.cjs +1 -1
- package/dist/__chrome_devtools.d.cts +1 -1
- package/dist/__chrome_devtools.d.ts +1 -1
- package/dist/__chrome_devtools.js +1 -1
- package/dist/astro.cjs +3 -3
- package/dist/astro.js +3 -3
- package/dist/esbuild.cjs +3 -3
- package/dist/esbuild.js +3 -3
- package/dist/index.cjs +5 -3
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -4
- package/dist/inject-script.cjs +2 -1
- package/dist/inject-script.js +2 -1
- package/dist/nuxt.cjs +22 -407
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +22 -407
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.js +3 -3
- package/dist/rspack.cjs +6 -6
- package/dist/rspack.js +6 -6
- package/dist/{src-hLDO4Q22.cjs → src-7U04DWRB.cjs} +54 -28
- package/dist/{src-BVX_Roo9.js → src-DD2TG884.js} +43 -29
- package/dist/{utils-CmfBxo4J.cjs → utils-3gBRwB2B.cjs} +10 -0
- package/dist/{utils-Chlbb6jf.js → utils-DORRNjr1.js} +5 -1
- package/dist/utils.cjs +2 -1
- package/dist/utils.d.cts +2 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +2 -2
- package/dist/{vite-DoBUfGyY.js → vite-BqXPfqlC.js} +2 -2
- package/dist/{vite-CKIDsKJ-.cjs → vite-Ds1Kt2Lk.cjs} +2 -2
- package/dist/vite.cjs +4 -4
- package/dist/vite.js +4 -4
- package/dist/webpack.cjs +6 -6
- package/dist/webpack.js +6 -6
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require___chrome_devtools = require('./__chrome_devtools-
|
|
3
|
-
const require_utils = require('./utils-
|
|
2
|
+
const require___chrome_devtools = require('./__chrome_devtools-DXNY3hbb.cjs');
|
|
3
|
+
const require_utils = require('./utils-3gBRwB2B.cjs');
|
|
4
4
|
const node_http = require_chunk.__toESM(require("node:http"));
|
|
5
5
|
const node_net = require_chunk.__toESM(require("node:net"));
|
|
6
6
|
const node_process = require_chunk.__toESM(require("node:process"));
|
|
@@ -11,7 +11,7 @@ const picocolors = require_chunk.__toESM(require("picocolors"));
|
|
|
11
11
|
const unplugin = require_chunk.__toESM(require("unplugin"));
|
|
12
12
|
const z_chii = require_chunk.__toESM(require("z-chii"));
|
|
13
13
|
|
|
14
|
-
//#region node_modules/.pnpm/get-port-please@3.2
|
|
14
|
+
//#region node_modules/.pnpm/get-port-please@3.1.2/node_modules/get-port-please/dist/index.mjs
|
|
15
15
|
const unsafePorts = /* @__PURE__ */ new Set([
|
|
16
16
|
1,
|
|
17
17
|
7,
|
|
@@ -100,12 +100,23 @@ function isUnsafePort(port) {
|
|
|
100
100
|
function isSafePort(port) {
|
|
101
101
|
return !isUnsafePort(port);
|
|
102
102
|
}
|
|
103
|
+
var __defProp = Object.defineProperty;
|
|
104
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
value
|
|
109
|
+
}) : obj[key] = value;
|
|
110
|
+
var __publicField = (obj, key, value) => {
|
|
111
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
112
|
+
return value;
|
|
113
|
+
};
|
|
103
114
|
var GetPortError = class extends Error {
|
|
104
115
|
constructor(message, opts) {
|
|
105
116
|
super(message, opts);
|
|
106
117
|
this.message = message;
|
|
118
|
+
__publicField(this, "name", "GetPortError");
|
|
107
119
|
}
|
|
108
|
-
name = "GetPortError";
|
|
109
120
|
};
|
|
110
121
|
function _log(verbose, message) {
|
|
111
122
|
if (verbose) console.log(`[get-port] ${message}`);
|
|
@@ -130,7 +141,7 @@ function _tryPort(port, host) {
|
|
|
130
141
|
}
|
|
131
142
|
function _getLocalHosts(additional) {
|
|
132
143
|
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::")
|
|
144
|
+
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::")) hosts.add(config$1.address);
|
|
134
145
|
return [...hosts];
|
|
135
146
|
}
|
|
136
147
|
function _fmtOnHost(hostname) {
|
|
@@ -158,23 +169,27 @@ async function checkPort(port, host = process.env.HOST, verbose) {
|
|
|
158
169
|
//#endregion
|
|
159
170
|
//#region src/index.ts
|
|
160
171
|
const cwd = node_process.default.cwd();
|
|
172
|
+
const projectHash = require_utils.getProjectHash();
|
|
173
|
+
const CHII_PROXY_PATH = `/__chii_proxy_${projectHash}`;
|
|
174
|
+
const CHII_DEVTOOLS_PATH = `/__chrome_devtools_${projectHash}`;
|
|
175
|
+
const VIRTUAL_CHII_CLIENT = `/__chii_client_${projectHash}.js`;
|
|
161
176
|
let config;
|
|
162
177
|
const resovedInfo = {
|
|
163
178
|
availablePort: void 0,
|
|
164
179
|
targetURL: void 0
|
|
165
180
|
};
|
|
166
|
-
function createProxyMiddleware(debug) {
|
|
181
|
+
function createProxyMiddleware(debug, proxyPath) {
|
|
167
182
|
let proxy = null;
|
|
168
183
|
const handleUpgrade = (req, socket, head) => {
|
|
169
|
-
if (proxy && req.url?.startsWith(
|
|
184
|
+
if (proxy && req.url?.startsWith(proxyPath)) {
|
|
170
185
|
debug("WS upgrade:", req.url);
|
|
171
|
-
req.url = req.url.replace(
|
|
186
|
+
req.url = req.url.replace(proxyPath, "");
|
|
172
187
|
proxy.ws(req, socket, head);
|
|
173
188
|
}
|
|
174
189
|
};
|
|
175
190
|
return (resolvedInfo) => {
|
|
176
191
|
return (req, res, next) => {
|
|
177
|
-
if (req.url?.startsWith(
|
|
192
|
+
if (req.url?.startsWith(proxyPath)) req._skip_transform = true;
|
|
178
193
|
if (!proxy && resolvedInfo.availablePort) {
|
|
179
194
|
proxy = http_proxy.default.createProxyServer({
|
|
180
195
|
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
@@ -189,14 +204,15 @@ function createProxyMiddleware(debug) {
|
|
|
189
204
|
});
|
|
190
205
|
if (req.socket.server) req.socket.server.on("upgrade", handleUpgrade);
|
|
191
206
|
}
|
|
192
|
-
if (proxy && req.url?.startsWith(
|
|
207
|
+
if (proxy && req.url?.startsWith(proxyPath)) {
|
|
193
208
|
debug(req.url);
|
|
194
|
-
req.url = req.url.replace(
|
|
209
|
+
req.url = req.url.replace(proxyPath, "");
|
|
195
210
|
proxy.web(req, res);
|
|
196
211
|
} else next();
|
|
197
212
|
};
|
|
198
213
|
};
|
|
199
214
|
}
|
|
215
|
+
const isNuxt = require_utils.isNuxtProject();
|
|
200
216
|
const unpluginFactory = (options) => {
|
|
201
217
|
const { chii } = options || {};
|
|
202
218
|
const enableChii = chii?.enable !== false;
|
|
@@ -207,18 +223,18 @@ const unpluginFactory = (options) => {
|
|
|
207
223
|
name: "unplugin-dingtalk",
|
|
208
224
|
enforce: "pre",
|
|
209
225
|
resolveId(source) {
|
|
210
|
-
if (source === "chii-client") return
|
|
226
|
+
if (source === "chii-client" || source === VIRTUAL_CHII_CLIENT) return VIRTUAL_CHII_CLIENT;
|
|
211
227
|
},
|
|
212
228
|
loadInclude(id) {
|
|
213
|
-
return id ===
|
|
229
|
+
return id === VIRTUAL_CHII_CLIENT;
|
|
214
230
|
},
|
|
215
231
|
load(id) {
|
|
216
|
-
if (id ===
|
|
232
|
+
if (id === VIRTUAL_CHII_CLIENT) return `
|
|
217
233
|
;(function(){
|
|
218
234
|
if (document.getElementById('__chii_client')) return;
|
|
219
235
|
const script = document.createElement('script');
|
|
220
236
|
script.id = '__chii_client';
|
|
221
|
-
script.src="/
|
|
237
|
+
script.src="${CHII_PROXY_PATH}/target.js";
|
|
222
238
|
${options?.chii?.embedded ? "script.setAttribute('embedded','true');" : ""}
|
|
223
239
|
document.body.appendChild(script);
|
|
224
240
|
})();
|
|
@@ -228,7 +244,7 @@ if (import.meta.hot) {
|
|
|
228
244
|
if (old) old.remove();
|
|
229
245
|
const script = document.createElement('script');
|
|
230
246
|
script.id = '__chii_client';
|
|
231
|
-
script.src="/
|
|
247
|
+
script.src="${CHII_PROXY_PATH}/target.js";
|
|
232
248
|
${options?.chii?.embedded ? "script.setAttribute('embedded','true');" : ""}
|
|
233
249
|
document.body.appendChild(script);
|
|
234
250
|
});
|
|
@@ -246,8 +262,8 @@ if (import.meta.hot) {
|
|
|
246
262
|
}
|
|
247
263
|
if (options?.enable && enableChii) {
|
|
248
264
|
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 '
|
|
265
|
+
if (file.startsWith(config?.root || cwd) && !file.includes("node_modules") && file.match(/\.[t|j]s$/) && !isNuxt) return {
|
|
266
|
+
code: `import '${VIRTUAL_CHII_CLIENT}';\n${source}`,
|
|
251
267
|
map: null
|
|
252
268
|
};
|
|
253
269
|
}
|
|
@@ -261,8 +277,8 @@ if (import.meta.hot) {
|
|
|
261
277
|
config = _config;
|
|
262
278
|
},
|
|
263
279
|
transformIndexHtml(html) {
|
|
264
|
-
if (options?.enable && enableChii) {
|
|
265
|
-
const tag =
|
|
280
|
+
if (options?.enable && enableChii && !isNuxt) {
|
|
281
|
+
const tag = `<script type="module">import '${VIRTUAL_CHII_CLIENT}';<\/script>`;
|
|
266
282
|
if (!html.includes(tag)) return html.replace("</body>", `</body>${tag}\n`);
|
|
267
283
|
}
|
|
268
284
|
return html;
|
|
@@ -281,7 +297,7 @@ if (import.meta.hot) {
|
|
|
281
297
|
server.printUrls = () => {
|
|
282
298
|
_printUrls();
|
|
283
299
|
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}
|
|
300
|
+
if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.colorUrl(`http://${source}${base}${CHII_DEVTOOLS_PATH.replace(/^\//, "")}`)}`);
|
|
285
301
|
};
|
|
286
302
|
const targetURL = new URL(_targetUrl);
|
|
287
303
|
targetURL.searchParams.append("ddtab", "true");
|
|
@@ -295,20 +311,18 @@ if (import.meta.hot) {
|
|
|
295
311
|
next();
|
|
296
312
|
});
|
|
297
313
|
if (enableChii) {
|
|
298
|
-
server.middlewares.use(
|
|
314
|
+
server.middlewares.use(CHII_DEVTOOLS_PATH, async (_req, res) => {
|
|
299
315
|
if (!resovedInfo.availablePort) {
|
|
300
316
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
301
317
|
res.end("Server not started");
|
|
302
318
|
return;
|
|
303
319
|
}
|
|
304
320
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
305
|
-
res.write(require___chrome_devtools.getChromeDevtoolsHtml(resovedInfo.availablePort));
|
|
321
|
+
res.write(require___chrome_devtools.getChromeDevtoolsHtml(resovedInfo.availablePort, CHII_PROXY_PATH));
|
|
306
322
|
res.end();
|
|
307
323
|
});
|
|
308
|
-
const isNuxt = require_utils.isNuxtProject();
|
|
309
|
-
console.log("isNuxt", isNuxt);
|
|
310
324
|
if (!isNuxt) {
|
|
311
|
-
const proxyMiddleware = createProxyMiddleware(debug);
|
|
325
|
+
const proxyMiddleware = createProxyMiddleware(debug, CHII_PROXY_PATH);
|
|
312
326
|
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
313
327
|
}
|
|
314
328
|
}
|
|
@@ -332,7 +346,7 @@ if (import.meta.hot) {
|
|
|
332
346
|
const _targetUrl = options?.targetUrl ?? `http://${source}${base}`;
|
|
333
347
|
compiler.hooks.done.tap("unplugin-dingtalk", () => {
|
|
334
348
|
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}
|
|
349
|
+
if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.colorUrl(`http://${source}${base}${CHII_DEVTOOLS_PATH.replace(/^\//, "")}`)}`);
|
|
336
350
|
});
|
|
337
351
|
resovedInfo.targetURL = new URL(_targetUrl);
|
|
338
352
|
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
@@ -353,7 +367,7 @@ if (import.meta.hot) {
|
|
|
353
367
|
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
354
368
|
if (options?.corpId) resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
355
369
|
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}
|
|
370
|
+
if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.colorUrl(`http://${source}${base}${CHII_DEVTOOLS_PATH.replace(/^\//, "")}`)}`);
|
|
357
371
|
}
|
|
358
372
|
};
|
|
359
373
|
return unpluginDing;
|
|
@@ -362,6 +376,18 @@ const unplugin$1 = /* @__PURE__ */ (0, unplugin.createUnplugin)(unpluginFactory)
|
|
|
362
376
|
var src_default = unplugin$1;
|
|
363
377
|
|
|
364
378
|
//#endregion
|
|
379
|
+
Object.defineProperty(exports, 'CHII_DEVTOOLS_PATH', {
|
|
380
|
+
enumerable: true,
|
|
381
|
+
get: function () {
|
|
382
|
+
return CHII_DEVTOOLS_PATH;
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
Object.defineProperty(exports, 'CHII_PROXY_PATH', {
|
|
386
|
+
enumerable: true,
|
|
387
|
+
get: function () {
|
|
388
|
+
return CHII_PROXY_PATH;
|
|
389
|
+
}
|
|
390
|
+
});
|
|
365
391
|
Object.defineProperty(exports, 'createProxyMiddleware', {
|
|
366
392
|
enumerable: true,
|
|
367
393
|
get: function () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getChromeDevtoolsHtml } from "./__chrome_devtools-
|
|
2
|
-
import { colorUrl, isNuxtProject } from "./utils-
|
|
1
|
+
import { getChromeDevtoolsHtml } from "./__chrome_devtools-DtQ6IXAu.js";
|
|
2
|
+
import { colorUrl, getProjectHash, isNuxtProject } from "./utils-DORRNjr1.js";
|
|
3
3
|
import { ServerResponse } from "node:http";
|
|
4
4
|
import { Socket, createServer } from "node:net";
|
|
5
5
|
import process$1 from "node:process";
|
|
@@ -10,7 +10,7 @@ import c from "picocolors";
|
|
|
10
10
|
import { createUnplugin } from "unplugin";
|
|
11
11
|
import { start } from "z-chii";
|
|
12
12
|
|
|
13
|
-
//#region node_modules/.pnpm/get-port-please@3.2
|
|
13
|
+
//#region node_modules/.pnpm/get-port-please@3.1.2/node_modules/get-port-please/dist/index.mjs
|
|
14
14
|
const unsafePorts = /* @__PURE__ */ new Set([
|
|
15
15
|
1,
|
|
16
16
|
7,
|
|
@@ -99,12 +99,23 @@ function isUnsafePort(port) {
|
|
|
99
99
|
function isSafePort(port) {
|
|
100
100
|
return !isUnsafePort(port);
|
|
101
101
|
}
|
|
102
|
+
var __defProp = Object.defineProperty;
|
|
103
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value
|
|
108
|
+
}) : obj[key] = value;
|
|
109
|
+
var __publicField = (obj, key, value) => {
|
|
110
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
111
|
+
return value;
|
|
112
|
+
};
|
|
102
113
|
var GetPortError = class extends Error {
|
|
103
114
|
constructor(message, opts) {
|
|
104
115
|
super(message, opts);
|
|
105
116
|
this.message = message;
|
|
117
|
+
__publicField(this, "name", "GetPortError");
|
|
106
118
|
}
|
|
107
|
-
name = "GetPortError";
|
|
108
119
|
};
|
|
109
120
|
function _log(verbose, message) {
|
|
110
121
|
if (verbose) console.log(`[get-port] ${message}`);
|
|
@@ -129,7 +140,7 @@ function _tryPort(port, host) {
|
|
|
129
140
|
}
|
|
130
141
|
function _getLocalHosts(additional) {
|
|
131
142
|
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::")
|
|
143
|
+
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::")) hosts.add(config$1.address);
|
|
133
144
|
return [...hosts];
|
|
134
145
|
}
|
|
135
146
|
function _fmtOnHost(hostname) {
|
|
@@ -157,23 +168,27 @@ async function checkPort(port, host = process.env.HOST, verbose) {
|
|
|
157
168
|
//#endregion
|
|
158
169
|
//#region src/index.ts
|
|
159
170
|
const cwd = process$1.cwd();
|
|
171
|
+
const projectHash = getProjectHash();
|
|
172
|
+
const CHII_PROXY_PATH = `/__chii_proxy_${projectHash}`;
|
|
173
|
+
const CHII_DEVTOOLS_PATH = `/__chrome_devtools_${projectHash}`;
|
|
174
|
+
const VIRTUAL_CHII_CLIENT = `/__chii_client_${projectHash}.js`;
|
|
160
175
|
let config;
|
|
161
176
|
const resovedInfo = {
|
|
162
177
|
availablePort: void 0,
|
|
163
178
|
targetURL: void 0
|
|
164
179
|
};
|
|
165
|
-
function createProxyMiddleware(debug) {
|
|
180
|
+
function createProxyMiddleware(debug, proxyPath) {
|
|
166
181
|
let proxy = null;
|
|
167
182
|
const handleUpgrade = (req, socket, head) => {
|
|
168
|
-
if (proxy && req.url?.startsWith(
|
|
183
|
+
if (proxy && req.url?.startsWith(proxyPath)) {
|
|
169
184
|
debug("WS upgrade:", req.url);
|
|
170
|
-
req.url = req.url.replace(
|
|
185
|
+
req.url = req.url.replace(proxyPath, "");
|
|
171
186
|
proxy.ws(req, socket, head);
|
|
172
187
|
}
|
|
173
188
|
};
|
|
174
189
|
return (resolvedInfo) => {
|
|
175
190
|
return (req, res, next) => {
|
|
176
|
-
if (req.url?.startsWith(
|
|
191
|
+
if (req.url?.startsWith(proxyPath)) req._skip_transform = true;
|
|
177
192
|
if (!proxy && resolvedInfo.availablePort) {
|
|
178
193
|
proxy = httpProxy.createProxyServer({
|
|
179
194
|
target: `http://localhost:${resolvedInfo.availablePort}`,
|
|
@@ -188,14 +203,15 @@ function createProxyMiddleware(debug) {
|
|
|
188
203
|
});
|
|
189
204
|
if (req.socket.server) req.socket.server.on("upgrade", handleUpgrade);
|
|
190
205
|
}
|
|
191
|
-
if (proxy && req.url?.startsWith(
|
|
206
|
+
if (proxy && req.url?.startsWith(proxyPath)) {
|
|
192
207
|
debug(req.url);
|
|
193
|
-
req.url = req.url.replace(
|
|
208
|
+
req.url = req.url.replace(proxyPath, "");
|
|
194
209
|
proxy.web(req, res);
|
|
195
210
|
} else next();
|
|
196
211
|
};
|
|
197
212
|
};
|
|
198
213
|
}
|
|
214
|
+
const isNuxt = isNuxtProject();
|
|
199
215
|
const unpluginFactory = (options) => {
|
|
200
216
|
const { chii } = options || {};
|
|
201
217
|
const enableChii = chii?.enable !== false;
|
|
@@ -206,18 +222,18 @@ const unpluginFactory = (options) => {
|
|
|
206
222
|
name: "unplugin-dingtalk",
|
|
207
223
|
enforce: "pre",
|
|
208
224
|
resolveId(source) {
|
|
209
|
-
if (source === "chii-client") return
|
|
225
|
+
if (source === "chii-client" || source === VIRTUAL_CHII_CLIENT) return VIRTUAL_CHII_CLIENT;
|
|
210
226
|
},
|
|
211
227
|
loadInclude(id) {
|
|
212
|
-
return id ===
|
|
228
|
+
return id === VIRTUAL_CHII_CLIENT;
|
|
213
229
|
},
|
|
214
230
|
load(id) {
|
|
215
|
-
if (id ===
|
|
231
|
+
if (id === VIRTUAL_CHII_CLIENT) return `
|
|
216
232
|
;(function(){
|
|
217
233
|
if (document.getElementById('__chii_client')) return;
|
|
218
234
|
const script = document.createElement('script');
|
|
219
235
|
script.id = '__chii_client';
|
|
220
|
-
script.src="/
|
|
236
|
+
script.src="${CHII_PROXY_PATH}/target.js";
|
|
221
237
|
${options?.chii?.embedded ? "script.setAttribute('embedded','true');" : ""}
|
|
222
238
|
document.body.appendChild(script);
|
|
223
239
|
})();
|
|
@@ -227,7 +243,7 @@ if (import.meta.hot) {
|
|
|
227
243
|
if (old) old.remove();
|
|
228
244
|
const script = document.createElement('script');
|
|
229
245
|
script.id = '__chii_client';
|
|
230
|
-
script.src="/
|
|
246
|
+
script.src="${CHII_PROXY_PATH}/target.js";
|
|
231
247
|
${options?.chii?.embedded ? "script.setAttribute('embedded','true');" : ""}
|
|
232
248
|
document.body.appendChild(script);
|
|
233
249
|
});
|
|
@@ -245,8 +261,8 @@ if (import.meta.hot) {
|
|
|
245
261
|
}
|
|
246
262
|
if (options?.enable && enableChii) {
|
|
247
263
|
const file = id.split("?")[0];
|
|
248
|
-
if (file.startsWith(config?.root || cwd) && !file.includes("node_modules") && file.match(/\.[t|j]s$/)) return {
|
|
249
|
-
code: `import '
|
|
264
|
+
if (file.startsWith(config?.root || cwd) && !file.includes("node_modules") && file.match(/\.[t|j]s$/) && !isNuxt) return {
|
|
265
|
+
code: `import '${VIRTUAL_CHII_CLIENT}';\n${source}`,
|
|
250
266
|
map: null
|
|
251
267
|
};
|
|
252
268
|
}
|
|
@@ -260,8 +276,8 @@ if (import.meta.hot) {
|
|
|
260
276
|
config = _config;
|
|
261
277
|
},
|
|
262
278
|
transformIndexHtml(html) {
|
|
263
|
-
if (options?.enable && enableChii) {
|
|
264
|
-
const tag =
|
|
279
|
+
if (options?.enable && enableChii && !isNuxt) {
|
|
280
|
+
const tag = `<script type="module">import '${VIRTUAL_CHII_CLIENT}';<\/script>`;
|
|
265
281
|
if (!html.includes(tag)) return html.replace("</body>", `</body>${tag}\n`);
|
|
266
282
|
}
|
|
267
283
|
return html;
|
|
@@ -280,7 +296,7 @@ if (import.meta.hot) {
|
|
|
280
296
|
server.printUrls = () => {
|
|
281
297
|
_printUrls();
|
|
282
298
|
console.log(` ${c.green("➜")} ${c.bold("Open in dingtalk")}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
283
|
-
if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}
|
|
299
|
+
if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}${CHII_DEVTOOLS_PATH.replace(/^\//, "")}`)}`);
|
|
284
300
|
};
|
|
285
301
|
const targetURL = new URL(_targetUrl);
|
|
286
302
|
targetURL.searchParams.append("ddtab", "true");
|
|
@@ -294,20 +310,18 @@ if (import.meta.hot) {
|
|
|
294
310
|
next();
|
|
295
311
|
});
|
|
296
312
|
if (enableChii) {
|
|
297
|
-
server.middlewares.use(
|
|
313
|
+
server.middlewares.use(CHII_DEVTOOLS_PATH, async (_req, res) => {
|
|
298
314
|
if (!resovedInfo.availablePort) {
|
|
299
315
|
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
300
316
|
res.end("Server not started");
|
|
301
317
|
return;
|
|
302
318
|
}
|
|
303
319
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
304
|
-
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
|
|
320
|
+
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort, CHII_PROXY_PATH));
|
|
305
321
|
res.end();
|
|
306
322
|
});
|
|
307
|
-
const isNuxt = isNuxtProject();
|
|
308
|
-
console.log("isNuxt", isNuxt);
|
|
309
323
|
if (!isNuxt) {
|
|
310
|
-
const proxyMiddleware = createProxyMiddleware(debug);
|
|
324
|
+
const proxyMiddleware = createProxyMiddleware(debug, CHII_PROXY_PATH);
|
|
311
325
|
server.middlewares.use(proxyMiddleware(resovedInfo));
|
|
312
326
|
}
|
|
313
327
|
}
|
|
@@ -331,7 +345,7 @@ if (import.meta.hot) {
|
|
|
331
345
|
const _targetUrl = options?.targetUrl ?? `http://${source}${base}`;
|
|
332
346
|
compiler.hooks.done.tap("unplugin-dingtalk", () => {
|
|
333
347
|
console.log(` ${c.green("➜")} ${c.bold("Open in dingtalk")}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
334
|
-
if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}
|
|
348
|
+
if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}${CHII_DEVTOOLS_PATH.replace(/^\//, "")}`)}`);
|
|
335
349
|
});
|
|
336
350
|
resovedInfo.targetURL = new URL(_targetUrl);
|
|
337
351
|
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
@@ -352,7 +366,7 @@ if (import.meta.hot) {
|
|
|
352
366
|
resovedInfo.targetURL.searchParams.append("ddtab", "true");
|
|
353
367
|
if (options?.corpId) resovedInfo.targetURL.searchParams.append("corpId", options.corpId);
|
|
354
368
|
console.log(` ${c.green("➜")} ${c.bold("Open in dingtalk")}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
355
|
-
if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}
|
|
369
|
+
if (enableChii) console.log(` ${c.green("➜")} ${c.bold("Click to open chrome devtools")}: ${colorUrl(`http://${source}${base}${CHII_DEVTOOLS_PATH.replace(/^\//, "")}`)}`);
|
|
356
370
|
}
|
|
357
371
|
};
|
|
358
372
|
return unpluginDing;
|
|
@@ -361,4 +375,4 @@ const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
|
361
375
|
var src_default = unplugin;
|
|
362
376
|
|
|
363
377
|
//#endregion
|
|
364
|
-
export { createProxyMiddleware, resovedInfo, src_default, unplugin, unpluginFactory };
|
|
378
|
+
export { CHII_DEVTOOLS_PATH, CHII_PROXY_PATH, createProxyMiddleware, resovedInfo, src_default, unplugin, unpluginFactory };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
const node_process = require_chunk.__toESM(require("node:process"));
|
|
3
3
|
const picocolors = require_chunk.__toESM(require("picocolors"));
|
|
4
|
+
const node_crypto = require_chunk.__toESM(require("node:crypto"));
|
|
4
5
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
5
6
|
|
|
6
7
|
//#region src/utils.ts
|
|
8
|
+
function getProjectHash() {
|
|
9
|
+
return (0, node_crypto.createHash)("md5").update(node_process.default.cwd()).digest("hex").slice(0, 8);
|
|
10
|
+
}
|
|
7
11
|
async function interopDefault(m) {
|
|
8
12
|
const resolved = await m;
|
|
9
13
|
return resolved.default || resolved;
|
|
@@ -27,6 +31,12 @@ Object.defineProperty(exports, 'colorUrl', {
|
|
|
27
31
|
return colorUrl;
|
|
28
32
|
}
|
|
29
33
|
});
|
|
34
|
+
Object.defineProperty(exports, 'getProjectHash', {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return getProjectHash;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
30
40
|
Object.defineProperty(exports, 'interopDefault', {
|
|
31
41
|
enumerable: true,
|
|
32
42
|
get: function () {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
2
|
import c from "picocolors";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
|
|
5
6
|
//#region src/utils.ts
|
|
7
|
+
function getProjectHash() {
|
|
8
|
+
return createHash("md5").update(process.cwd()).digest("hex").slice(0, 8);
|
|
9
|
+
}
|
|
6
10
|
async function interopDefault(m) {
|
|
7
11
|
const resolved = await m;
|
|
8
12
|
return resolved.default || resolved;
|
|
@@ -20,4 +24,4 @@ function isNuxtProject() {
|
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
//#endregion
|
|
23
|
-
export { colorUrl, interopDefault, isNuxtProject };
|
|
27
|
+
export { colorUrl, getProjectHash, interopDefault, isNuxtProject };
|
package/dist/utils.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const require_utils = require('./utils-
|
|
1
|
+
const require_utils = require('./utils-3gBRwB2B.cjs');
|
|
2
2
|
|
|
3
3
|
exports.colorUrl = require_utils.colorUrl;
|
|
4
|
+
exports.getProjectHash = require_utils.getProjectHash;
|
|
4
5
|
exports.interopDefault = require_utils.interopDefault;
|
|
5
6
|
exports.isNuxtProject = require_utils.isNuxtProject;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
//#region src/utils.d.ts
|
|
2
2
|
type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
declare function getProjectHash(): string;
|
|
3
4
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
4
5
|
default: infer U;
|
|
5
6
|
} ? U : T>;
|
|
6
7
|
declare const colorUrl: (url: string) => string;
|
|
7
8
|
declare function isNuxtProject(): boolean;
|
|
8
9
|
//#endregion
|
|
9
|
-
export { Awaitable, colorUrl, interopDefault, isNuxtProject };
|
|
10
|
+
export { Awaitable, colorUrl, getProjectHash, interopDefault, isNuxtProject };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
//#region src/utils.d.ts
|
|
2
2
|
type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
declare function getProjectHash(): string;
|
|
3
4
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
4
5
|
default: infer U;
|
|
5
6
|
} ? U : T>;
|
|
6
7
|
declare const colorUrl: (url: string) => string;
|
|
7
8
|
declare function isNuxtProject(): boolean;
|
|
8
9
|
//#endregion
|
|
9
|
-
export { Awaitable, colorUrl, interopDefault, isNuxtProject };
|
|
10
|
+
export { Awaitable, colorUrl, getProjectHash, interopDefault, isNuxtProject };
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { colorUrl, interopDefault, isNuxtProject } from "./utils-
|
|
1
|
+
import { colorUrl, getProjectHash, interopDefault, isNuxtProject } from "./utils-DORRNjr1.js";
|
|
2
2
|
|
|
3
|
-
export { colorUrl, interopDefault, isNuxtProject };
|
|
3
|
+
export { colorUrl, getProjectHash, interopDefault, isNuxtProject };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { unpluginFactory } from "./src-
|
|
2
|
-
import { interopDefault } from "./utils-
|
|
1
|
+
import { unpluginFactory } from "./src-DD2TG884.js";
|
|
2
|
+
import { interopDefault } from "./utils-DORRNjr1.js";
|
|
3
3
|
import { createVitePlugin } from "unplugin";
|
|
4
4
|
|
|
5
5
|
//#region src/vite.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_src = require('./src-
|
|
3
|
-
const require_utils = require('./utils-
|
|
2
|
+
const require_src = require('./src-7U04DWRB.cjs');
|
|
3
|
+
const require_utils = require('./utils-3gBRwB2B.cjs');
|
|
4
4
|
const unplugin = require_chunk.__toESM(require("unplugin"));
|
|
5
5
|
|
|
6
6
|
//#region src/vite.ts
|
package/dist/vite.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require('./__chrome_devtools-
|
|
2
|
-
require('./src-
|
|
3
|
-
require('./utils-
|
|
4
|
-
const require_vite = require('./vite-
|
|
1
|
+
require('./__chrome_devtools-DXNY3hbb.cjs');
|
|
2
|
+
require('./src-7U04DWRB.cjs');
|
|
3
|
+
require('./utils-3gBRwB2B.cjs');
|
|
4
|
+
const require_vite = require('./vite-Ds1Kt2Lk.cjs');
|
|
5
5
|
|
|
6
6
|
module.exports = require_vite.vite_default;
|
package/dist/vite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./__chrome_devtools-
|
|
2
|
-
import "./src-
|
|
3
|
-
import "./utils-
|
|
4
|
-
import { vite_default } from "./vite-
|
|
1
|
+
import "./__chrome_devtools-DtQ6IXAu.js";
|
|
2
|
+
import "./src-DD2TG884.js";
|
|
3
|
+
import "./utils-DORRNjr1.js";
|
|
4
|
+
import { vite_default } from "./vite-BqXPfqlC.js";
|
|
5
5
|
|
|
6
6
|
export { vite_default as default };
|
package/dist/webpack.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require___chrome_devtools = require('./__chrome_devtools-
|
|
3
|
-
const require_src = require('./src-
|
|
4
|
-
require('./utils-
|
|
2
|
+
const require___chrome_devtools = require('./__chrome_devtools-DXNY3hbb.cjs');
|
|
3
|
+
const require_src = require('./src-7U04DWRB.cjs');
|
|
4
|
+
require('./utils-3gBRwB2B.cjs');
|
|
5
5
|
const cookie = require_chunk.__toESM(require("cookie"));
|
|
6
6
|
const picocolors = require_chunk.__toESM(require("picocolors"));
|
|
7
7
|
const unplugin = require_chunk.__toESM(require("unplugin"));
|
|
@@ -24,10 +24,10 @@ var webpack_default = (options) => {
|
|
|
24
24
|
next();
|
|
25
25
|
});
|
|
26
26
|
if (enableChii) {
|
|
27
|
-
devServer.app.get(
|
|
27
|
+
devServer.app.get(require_src.CHII_DEVTOOLS_PATH, async (_req, res) => {
|
|
28
28
|
try {
|
|
29
29
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
30
|
-
res.write(require___chrome_devtools.getChromeDevtoolsHtml(require_src.resovedInfo.availablePort));
|
|
30
|
+
res.write(require___chrome_devtools.getChromeDevtoolsHtml(require_src.resovedInfo.availablePort, require_src.CHII_PROXY_PATH));
|
|
31
31
|
res.end();
|
|
32
32
|
} catch (error) {
|
|
33
33
|
debug(`${error}`);
|
|
@@ -35,7 +35,7 @@ var webpack_default = (options) => {
|
|
|
35
35
|
res.end();
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
const proxyMiddleware = require_src.createProxyMiddleware(debug);
|
|
38
|
+
const proxyMiddleware = require_src.createProxyMiddleware(debug, require_src.CHII_PROXY_PATH);
|
|
39
39
|
devServer.app.use(proxyMiddleware(require_src.resovedInfo));
|
|
40
40
|
}
|
|
41
41
|
devServer.app.get("/open-dingtalk", (req, res) => {
|
package/dist/webpack.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getChromeDevtoolsHtml } from "./__chrome_devtools-
|
|
2
|
-
import { createProxyMiddleware, resovedInfo, unpluginFactory } from "./src-
|
|
3
|
-
import "./utils-
|
|
1
|
+
import { getChromeDevtoolsHtml } from "./__chrome_devtools-DtQ6IXAu.js";
|
|
2
|
+
import { CHII_DEVTOOLS_PATH, CHII_PROXY_PATH, createProxyMiddleware, resovedInfo, unpluginFactory } from "./src-DD2TG884.js";
|
|
3
|
+
import "./utils-DORRNjr1.js";
|
|
4
4
|
import cookie from "cookie";
|
|
5
5
|
import c from "picocolors";
|
|
6
6
|
import { createWebpackPlugin } from "unplugin";
|
|
@@ -23,10 +23,10 @@ var webpack_default = (options) => {
|
|
|
23
23
|
next();
|
|
24
24
|
});
|
|
25
25
|
if (enableChii) {
|
|
26
|
-
devServer.app.get(
|
|
26
|
+
devServer.app.get(CHII_DEVTOOLS_PATH, async (_req, res) => {
|
|
27
27
|
try {
|
|
28
28
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
29
|
-
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort));
|
|
29
|
+
res.write(getChromeDevtoolsHtml(resovedInfo.availablePort, CHII_PROXY_PATH));
|
|
30
30
|
res.end();
|
|
31
31
|
} catch (error) {
|
|
32
32
|
debug(`${error}`);
|
|
@@ -34,7 +34,7 @@ var webpack_default = (options) => {
|
|
|
34
34
|
res.end();
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
const proxyMiddleware = createProxyMiddleware(debug);
|
|
37
|
+
const proxyMiddleware = createProxyMiddleware(debug, CHII_PROXY_PATH);
|
|
38
38
|
devServer.app.use(proxyMiddleware(resovedInfo));
|
|
39
39
|
}
|
|
40
40
|
devServer.app.get("/open-dingtalk", (req, res) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-dingtalk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1007.0.
|
|
4
|
+
"version": "1007.0.2",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/zcf0508/unplugin-dingtalk#readme",
|
|
@@ -120,10 +120,11 @@
|
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
122
|
"cookie": "^1.0.2",
|
|
123
|
+
"h3": "^1.15.4",
|
|
123
124
|
"http-proxy": "^1.18.1",
|
|
124
125
|
"picocolors": "^1.0.1",
|
|
125
126
|
"unplugin": "2.2.0",
|
|
126
|
-
"z-chii": "1.15.5-beta.
|
|
127
|
+
"z-chii": "1.15.5-beta.5"
|
|
127
128
|
},
|
|
128
129
|
"devDependencies": {
|
|
129
130
|
"@antfu/eslint-config": "^6.0.0",
|
|
@@ -138,7 +139,6 @@
|
|
|
138
139
|
"eslint-plugin-security": "^3.0.1",
|
|
139
140
|
"fast-glob": "^3.3.2",
|
|
140
141
|
"get-port-please": "^3.1.2",
|
|
141
|
-
"h3": "^1.15.4",
|
|
142
142
|
"nodemon": "^3.0.2",
|
|
143
143
|
"proper-lockfile": "^4.1.2",
|
|
144
144
|
"rimraf": "^5.0.5",
|