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
package/dist/nuxt.cjs
CHANGED
|
@@ -1,409 +1,13 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
require('./__chrome_devtools-
|
|
3
|
-
const require_src = require('./src-
|
|
4
|
-
const require_utils = require('./utils-
|
|
5
|
-
const require_vite = require('./vite-
|
|
2
|
+
require('./__chrome_devtools-DXNY3hbb.cjs');
|
|
3
|
+
const require_src = require('./src-7U04DWRB.cjs');
|
|
4
|
+
const require_utils = require('./utils-3gBRwB2B.cjs');
|
|
5
|
+
const require_vite = require('./vite-Ds1Kt2Lk.cjs');
|
|
6
6
|
const http_proxy = require_chunk.__toESM(require("http-proxy"));
|
|
7
7
|
const picocolors = require_chunk.__toESM(require("picocolors"));
|
|
8
8
|
const __nuxt_kit = require_chunk.__toESM(require("@nuxt/kit"));
|
|
9
9
|
require("@nuxt/schema");
|
|
10
10
|
|
|
11
|
-
//#region node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
12
|
-
function isPlainObject(value) {
|
|
13
|
-
if (value === null || typeof value !== "object") return false;
|
|
14
|
-
const prototype = Object.getPrototypeOf(value);
|
|
15
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
|
|
16
|
-
if (Symbol.iterator in value) return false;
|
|
17
|
-
if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
21
|
-
if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
|
|
22
|
-
const object = Object.assign({}, defaults);
|
|
23
|
-
for (const key in baseObject) {
|
|
24
|
-
if (key === "__proto__" || key === "constructor") continue;
|
|
25
|
-
const value = baseObject[key];
|
|
26
|
-
if (value === null || value === void 0) continue;
|
|
27
|
-
if (merger && merger(object, key, value, namespace)) continue;
|
|
28
|
-
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
29
|
-
else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
30
|
-
else object[key] = value;
|
|
31
|
-
}
|
|
32
|
-
return object;
|
|
33
|
-
}
|
|
34
|
-
function createDefu(merger) {
|
|
35
|
-
return (...arguments_) => arguments_.reduce((p, c$1) => _defu(p, c$1, "", merger), {});
|
|
36
|
-
}
|
|
37
|
-
const defu = createDefu();
|
|
38
|
-
const defuFn = createDefu((object, key, currentValue) => {
|
|
39
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
40
|
-
object[key] = currentValue(object[key]);
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const defuArrayFn = createDefu((object, key, currentValue) => {
|
|
45
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
46
|
-
object[key] = currentValue(object[key]);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region node_modules/.pnpm/h3@1.15.4/node_modules/h3/dist/index.mjs
|
|
53
|
-
function hasProp(obj, prop) {
|
|
54
|
-
try {
|
|
55
|
-
return prop in obj;
|
|
56
|
-
} catch {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
var H3Error = class extends Error {
|
|
61
|
-
static __h3_error__ = true;
|
|
62
|
-
statusCode = 500;
|
|
63
|
-
fatal = false;
|
|
64
|
-
unhandled = false;
|
|
65
|
-
statusMessage;
|
|
66
|
-
data;
|
|
67
|
-
cause;
|
|
68
|
-
constructor(message, opts = {}) {
|
|
69
|
-
super(message, opts);
|
|
70
|
-
if (opts.cause && !this.cause) this.cause = opts.cause;
|
|
71
|
-
}
|
|
72
|
-
toJSON() {
|
|
73
|
-
const obj = {
|
|
74
|
-
message: this.message,
|
|
75
|
-
statusCode: sanitizeStatusCode(this.statusCode, 500)
|
|
76
|
-
};
|
|
77
|
-
if (this.statusMessage) obj.statusMessage = sanitizeStatusMessage(this.statusMessage);
|
|
78
|
-
if (this.data !== void 0) obj.data = this.data;
|
|
79
|
-
return obj;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
function createError(input) {
|
|
83
|
-
if (typeof input === "string") return new H3Error(input);
|
|
84
|
-
if (isError(input)) return input;
|
|
85
|
-
const err = new H3Error(input.message ?? input.statusMessage ?? "", { cause: input.cause || input });
|
|
86
|
-
if (hasProp(input, "stack")) try {
|
|
87
|
-
Object.defineProperty(err, "stack", { get() {
|
|
88
|
-
return input.stack;
|
|
89
|
-
} });
|
|
90
|
-
} catch {
|
|
91
|
-
try {
|
|
92
|
-
err.stack = input.stack;
|
|
93
|
-
} catch {}
|
|
94
|
-
}
|
|
95
|
-
if (input.data) err.data = input.data;
|
|
96
|
-
if (input.statusCode) err.statusCode = sanitizeStatusCode(input.statusCode, err.statusCode);
|
|
97
|
-
else if (input.status) err.statusCode = sanitizeStatusCode(input.status, err.statusCode);
|
|
98
|
-
if (input.statusMessage) err.statusMessage = input.statusMessage;
|
|
99
|
-
else if (input.statusText) err.statusMessage = input.statusText;
|
|
100
|
-
if (err.statusMessage) {
|
|
101
|
-
const originalMessage = err.statusMessage;
|
|
102
|
-
const sanitizedMessage = sanitizeStatusMessage(err.statusMessage);
|
|
103
|
-
if (sanitizedMessage !== originalMessage) console.warn("[h3] Please prefer using `message` for longer error messages instead of `statusMessage`. In the future, `statusMessage` will be sanitized by default.");
|
|
104
|
-
}
|
|
105
|
-
if (input.fatal !== void 0) err.fatal = input.fatal;
|
|
106
|
-
if (input.unhandled !== void 0) err.unhandled = input.unhandled;
|
|
107
|
-
return err;
|
|
108
|
-
}
|
|
109
|
-
function isError(input) {
|
|
110
|
-
return input?.constructor?.__h3_error__ === true;
|
|
111
|
-
}
|
|
112
|
-
function isMethod(event, expected, allowHead) {
|
|
113
|
-
if (allowHead && event.method === "HEAD") return true;
|
|
114
|
-
if (typeof expected === "string") {
|
|
115
|
-
if (event.method === expected) return true;
|
|
116
|
-
} else if (expected.includes(event.method)) return true;
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
function assertMethod(event, expected, allowHead) {
|
|
120
|
-
if (!isMethod(event, expected, allowHead)) throw createError({
|
|
121
|
-
statusCode: 405,
|
|
122
|
-
statusMessage: "HTTP method is not allowed."
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function getRequestHeaders(event) {
|
|
126
|
-
const _headers = {};
|
|
127
|
-
for (const key in event.node.req.headers) {
|
|
128
|
-
const val = event.node.req.headers[key];
|
|
129
|
-
_headers[key] = Array.isArray(val) ? val.filter(Boolean).join(", ") : val;
|
|
130
|
-
}
|
|
131
|
-
return _headers;
|
|
132
|
-
}
|
|
133
|
-
const RawBodySymbol = Symbol.for("h3RawBody");
|
|
134
|
-
const ParsedBodySymbol = Symbol.for("h3ParsedBody");
|
|
135
|
-
const PayloadMethods$1 = [
|
|
136
|
-
"PATCH",
|
|
137
|
-
"POST",
|
|
138
|
-
"PUT",
|
|
139
|
-
"DELETE"
|
|
140
|
-
];
|
|
141
|
-
function readRawBody(event, encoding = "utf8") {
|
|
142
|
-
assertMethod(event, PayloadMethods$1);
|
|
143
|
-
const _rawBody = event._requestBody || event.web?.request?.body || event.node.req[RawBodySymbol] || event.node.req.rawBody || event.node.req.body;
|
|
144
|
-
if (_rawBody) {
|
|
145
|
-
const promise2 = Promise.resolve(_rawBody).then((_resolved) => {
|
|
146
|
-
if (Buffer.isBuffer(_resolved)) return _resolved;
|
|
147
|
-
if (typeof _resolved.pipeTo === "function") return new Promise((resolve, reject) => {
|
|
148
|
-
const chunks = [];
|
|
149
|
-
_resolved.pipeTo(new WritableStream({
|
|
150
|
-
write(chunk) {
|
|
151
|
-
chunks.push(chunk);
|
|
152
|
-
},
|
|
153
|
-
close() {
|
|
154
|
-
resolve(Buffer.concat(chunks));
|
|
155
|
-
},
|
|
156
|
-
abort(reason) {
|
|
157
|
-
reject(reason);
|
|
158
|
-
}
|
|
159
|
-
})).catch(reject);
|
|
160
|
-
});
|
|
161
|
-
else if (typeof _resolved.pipe === "function") return new Promise((resolve, reject) => {
|
|
162
|
-
const chunks = [];
|
|
163
|
-
_resolved.on("data", (chunk) => {
|
|
164
|
-
chunks.push(chunk);
|
|
165
|
-
}).on("end", () => {
|
|
166
|
-
resolve(Buffer.concat(chunks));
|
|
167
|
-
}).on("error", reject);
|
|
168
|
-
});
|
|
169
|
-
if (_resolved.constructor === Object) return Buffer.from(JSON.stringify(_resolved));
|
|
170
|
-
if (_resolved instanceof URLSearchParams) return Buffer.from(_resolved.toString());
|
|
171
|
-
if (_resolved instanceof FormData) return new Response(_resolved).bytes().then((uint8arr) => Buffer.from(uint8arr));
|
|
172
|
-
return Buffer.from(_resolved);
|
|
173
|
-
});
|
|
174
|
-
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
|
175
|
-
}
|
|
176
|
-
if (!Number.parseInt(event.node.req.headers["content-length"] || "") && !String(event.node.req.headers["transfer-encoding"] ?? "").split(",").map((e) => e.trim()).filter(Boolean).includes("chunked")) return Promise.resolve(void 0);
|
|
177
|
-
const promise = event.node.req[RawBodySymbol] = new Promise((resolve, reject) => {
|
|
178
|
-
const bodyData = [];
|
|
179
|
-
event.node.req.on("error", (err) => {
|
|
180
|
-
reject(err);
|
|
181
|
-
}).on("data", (chunk) => {
|
|
182
|
-
bodyData.push(chunk);
|
|
183
|
-
}).on("end", () => {
|
|
184
|
-
resolve(Buffer.concat(bodyData));
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
const result = encoding ? promise.then((buff) => buff.toString(encoding)) : promise;
|
|
188
|
-
return result;
|
|
189
|
-
}
|
|
190
|
-
function getRequestWebStream(event) {
|
|
191
|
-
if (!PayloadMethods$1.includes(event.method)) return;
|
|
192
|
-
const bodyStream = event.web?.request?.body || event._requestBody;
|
|
193
|
-
if (bodyStream) return bodyStream;
|
|
194
|
-
const _hasRawBody = RawBodySymbol in event.node.req || "rawBody" in event.node.req || "body" in event.node.req || "__unenv__" in event.node.req;
|
|
195
|
-
if (_hasRawBody) return new ReadableStream({ async start(controller) {
|
|
196
|
-
const _rawBody = await readRawBody(event, false);
|
|
197
|
-
if (_rawBody) controller.enqueue(_rawBody);
|
|
198
|
-
controller.close();
|
|
199
|
-
} });
|
|
200
|
-
return new ReadableStream({ start: (controller) => {
|
|
201
|
-
event.node.req.on("data", (chunk) => {
|
|
202
|
-
controller.enqueue(chunk);
|
|
203
|
-
});
|
|
204
|
-
event.node.req.on("end", () => {
|
|
205
|
-
controller.close();
|
|
206
|
-
});
|
|
207
|
-
event.node.req.on("error", (err) => {
|
|
208
|
-
controller.error(err);
|
|
209
|
-
});
|
|
210
|
-
} });
|
|
211
|
-
}
|
|
212
|
-
const DISALLOWED_STATUS_CHARS = /[^\u0009\u0020-\u007E]/g;
|
|
213
|
-
function sanitizeStatusMessage(statusMessage = "") {
|
|
214
|
-
return statusMessage.replace(DISALLOWED_STATUS_CHARS, "");
|
|
215
|
-
}
|
|
216
|
-
function sanitizeStatusCode(statusCode, defaultStatusCode = 200) {
|
|
217
|
-
if (!statusCode) return defaultStatusCode;
|
|
218
|
-
if (typeof statusCode === "string") statusCode = Number.parseInt(statusCode, 10);
|
|
219
|
-
if (statusCode < 100 || statusCode > 999) return defaultStatusCode;
|
|
220
|
-
return statusCode;
|
|
221
|
-
}
|
|
222
|
-
function splitCookiesString(cookiesString) {
|
|
223
|
-
if (Array.isArray(cookiesString)) return cookiesString.flatMap((c$1) => splitCookiesString(c$1));
|
|
224
|
-
if (typeof cookiesString !== "string") return [];
|
|
225
|
-
const cookiesStrings = [];
|
|
226
|
-
let pos = 0;
|
|
227
|
-
let start;
|
|
228
|
-
let ch;
|
|
229
|
-
let lastComma;
|
|
230
|
-
let nextStart;
|
|
231
|
-
let cookiesSeparatorFound;
|
|
232
|
-
const skipWhitespace = () => {
|
|
233
|
-
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) pos += 1;
|
|
234
|
-
return pos < cookiesString.length;
|
|
235
|
-
};
|
|
236
|
-
const notSpecialChar = () => {
|
|
237
|
-
ch = cookiesString.charAt(pos);
|
|
238
|
-
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
239
|
-
};
|
|
240
|
-
while (pos < cookiesString.length) {
|
|
241
|
-
start = pos;
|
|
242
|
-
cookiesSeparatorFound = false;
|
|
243
|
-
while (skipWhitespace()) {
|
|
244
|
-
ch = cookiesString.charAt(pos);
|
|
245
|
-
if (ch === ",") {
|
|
246
|
-
lastComma = pos;
|
|
247
|
-
pos += 1;
|
|
248
|
-
skipWhitespace();
|
|
249
|
-
nextStart = pos;
|
|
250
|
-
while (pos < cookiesString.length && notSpecialChar()) pos += 1;
|
|
251
|
-
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
252
|
-
cookiesSeparatorFound = true;
|
|
253
|
-
pos = nextStart;
|
|
254
|
-
cookiesStrings.push(cookiesString.slice(start, lastComma));
|
|
255
|
-
start = pos;
|
|
256
|
-
} else pos = lastComma + 1;
|
|
257
|
-
} else pos += 1;
|
|
258
|
-
}
|
|
259
|
-
if (!cookiesSeparatorFound || pos >= cookiesString.length) cookiesStrings.push(cookiesString.slice(start));
|
|
260
|
-
}
|
|
261
|
-
return cookiesStrings;
|
|
262
|
-
}
|
|
263
|
-
const PayloadMethods = /* @__PURE__ */ new Set([
|
|
264
|
-
"PATCH",
|
|
265
|
-
"POST",
|
|
266
|
-
"PUT",
|
|
267
|
-
"DELETE"
|
|
268
|
-
]);
|
|
269
|
-
const ignoredHeaders = /* @__PURE__ */ new Set([
|
|
270
|
-
"transfer-encoding",
|
|
271
|
-
"accept-encoding",
|
|
272
|
-
"connection",
|
|
273
|
-
"keep-alive",
|
|
274
|
-
"upgrade",
|
|
275
|
-
"expect",
|
|
276
|
-
"host",
|
|
277
|
-
"accept"
|
|
278
|
-
]);
|
|
279
|
-
async function proxyRequest(event, target, opts = {}) {
|
|
280
|
-
let body;
|
|
281
|
-
let duplex;
|
|
282
|
-
if (PayloadMethods.has(event.method)) if (opts.streamRequest) {
|
|
283
|
-
body = getRequestWebStream(event);
|
|
284
|
-
duplex = "half";
|
|
285
|
-
} else body = await readRawBody(event, false).catch(() => void 0);
|
|
286
|
-
const method = opts.fetchOptions?.method || event.method;
|
|
287
|
-
const fetchHeaders = mergeHeaders(getProxyRequestHeaders(event, { host: target.startsWith("/") }), opts.fetchOptions?.headers, opts.headers);
|
|
288
|
-
return sendProxy(event, target, {
|
|
289
|
-
...opts,
|
|
290
|
-
fetchOptions: {
|
|
291
|
-
method,
|
|
292
|
-
body,
|
|
293
|
-
duplex,
|
|
294
|
-
...opts.fetchOptions,
|
|
295
|
-
headers: fetchHeaders
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
async function sendProxy(event, target, opts = {}) {
|
|
300
|
-
let response;
|
|
301
|
-
try {
|
|
302
|
-
response = await _getFetch(opts.fetch)(target, {
|
|
303
|
-
headers: opts.headers,
|
|
304
|
-
ignoreResponseError: true,
|
|
305
|
-
...opts.fetchOptions
|
|
306
|
-
});
|
|
307
|
-
} catch (error) {
|
|
308
|
-
throw createError({
|
|
309
|
-
status: 502,
|
|
310
|
-
statusMessage: "Bad Gateway",
|
|
311
|
-
cause: error
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
event.node.res.statusCode = sanitizeStatusCode(response.status, event.node.res.statusCode);
|
|
315
|
-
event.node.res.statusMessage = sanitizeStatusMessage(response.statusText);
|
|
316
|
-
const cookies = [];
|
|
317
|
-
for (const [key, value] of response.headers.entries()) {
|
|
318
|
-
if (key === "content-encoding") continue;
|
|
319
|
-
if (key === "content-length") continue;
|
|
320
|
-
if (key === "set-cookie") {
|
|
321
|
-
cookies.push(...splitCookiesString(value));
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
event.node.res.setHeader(key, value);
|
|
325
|
-
}
|
|
326
|
-
if (cookies.length > 0) event.node.res.setHeader("set-cookie", cookies.map((cookie) => {
|
|
327
|
-
if (opts.cookieDomainRewrite) cookie = rewriteCookieProperty(cookie, opts.cookieDomainRewrite, "domain");
|
|
328
|
-
if (opts.cookiePathRewrite) cookie = rewriteCookieProperty(cookie, opts.cookiePathRewrite, "path");
|
|
329
|
-
return cookie;
|
|
330
|
-
}));
|
|
331
|
-
if (opts.onResponse) await opts.onResponse(event, response);
|
|
332
|
-
if (response._data !== void 0) return response._data;
|
|
333
|
-
if (event.handled) return;
|
|
334
|
-
if (opts.sendStream === false) {
|
|
335
|
-
const data = new Uint8Array(await response.arrayBuffer());
|
|
336
|
-
return event.node.res.end(data);
|
|
337
|
-
}
|
|
338
|
-
if (response.body) for await (const chunk of response.body) event.node.res.write(chunk);
|
|
339
|
-
return event.node.res.end();
|
|
340
|
-
}
|
|
341
|
-
function getProxyRequestHeaders(event, opts) {
|
|
342
|
-
const headers = /* @__PURE__ */ Object.create(null);
|
|
343
|
-
const reqHeaders = getRequestHeaders(event);
|
|
344
|
-
for (const name in reqHeaders) if (!ignoredHeaders.has(name) || name === "host" && opts?.host) headers[name] = reqHeaders[name];
|
|
345
|
-
return headers;
|
|
346
|
-
}
|
|
347
|
-
function _getFetch(_fetch) {
|
|
348
|
-
if (_fetch) return _fetch;
|
|
349
|
-
if (globalThis.fetch) return globalThis.fetch;
|
|
350
|
-
throw new Error("fetch is not available. Try importing `node-fetch-native/polyfill` for Node.js.");
|
|
351
|
-
}
|
|
352
|
-
function rewriteCookieProperty(header, map, property) {
|
|
353
|
-
const _map = typeof map === "string" ? { "*": map } : map;
|
|
354
|
-
return header.replace(new RegExp(`(;\\s*${property}=)([^;]+)`, "gi"), (match, prefix, previousValue) => {
|
|
355
|
-
let newValue;
|
|
356
|
-
if (previousValue in _map) newValue = _map[previousValue];
|
|
357
|
-
else if ("*" in _map) newValue = _map["*"];
|
|
358
|
-
else return match;
|
|
359
|
-
return newValue ? prefix + newValue : "";
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
function mergeHeaders(defaults, ...inputs) {
|
|
363
|
-
const _inputs = inputs.filter(Boolean);
|
|
364
|
-
if (_inputs.length === 0) return defaults;
|
|
365
|
-
const merged = new Headers(defaults);
|
|
366
|
-
for (const input of _inputs) {
|
|
367
|
-
const entries = Array.isArray(input) ? input : typeof input.entries === "function" ? input.entries() : Object.entries(input);
|
|
368
|
-
for (const [key, value] of entries) if (value !== void 0) merged.set(key, value);
|
|
369
|
-
}
|
|
370
|
-
return merged;
|
|
371
|
-
}
|
|
372
|
-
const getSessionPromise = Symbol("getSession");
|
|
373
|
-
function defineEventHandler(handler) {
|
|
374
|
-
if (typeof handler === "function") {
|
|
375
|
-
handler.__is_handler__ = true;
|
|
376
|
-
return handler;
|
|
377
|
-
}
|
|
378
|
-
const _hooks = {
|
|
379
|
-
onRequest: _normalizeArray(handler.onRequest),
|
|
380
|
-
onBeforeResponse: _normalizeArray(handler.onBeforeResponse)
|
|
381
|
-
};
|
|
382
|
-
const _handler = (event) => {
|
|
383
|
-
return _callHandler(event, handler.handler, _hooks);
|
|
384
|
-
};
|
|
385
|
-
_handler.__is_handler__ = true;
|
|
386
|
-
_handler.__resolve__ = handler.handler.__resolve__;
|
|
387
|
-
_handler.__websocket__ = handler.websocket;
|
|
388
|
-
return _handler;
|
|
389
|
-
}
|
|
390
|
-
function _normalizeArray(input) {
|
|
391
|
-
return input ? Array.isArray(input) ? input : [input] : void 0;
|
|
392
|
-
}
|
|
393
|
-
async function _callHandler(event, handler, hooks) {
|
|
394
|
-
if (hooks.onRequest) for (const hook of hooks.onRequest) {
|
|
395
|
-
await hook(event);
|
|
396
|
-
if (event.handled) return;
|
|
397
|
-
}
|
|
398
|
-
const body = await handler(event);
|
|
399
|
-
const response = { body };
|
|
400
|
-
if (hooks.onBeforeResponse) for (const hook of hooks.onBeforeResponse) await hook(event, response);
|
|
401
|
-
return response.body;
|
|
402
|
-
}
|
|
403
|
-
const H3Headers = globalThis.Headers;
|
|
404
|
-
const H3Response = globalThis.Response;
|
|
405
|
-
|
|
406
|
-
//#endregion
|
|
407
11
|
//#region src/nuxt.ts
|
|
408
12
|
var nuxt_default = (0, __nuxt_kit.defineNuxtModule)({
|
|
409
13
|
meta: {
|
|
@@ -414,27 +18,31 @@ var nuxt_default = (0, __nuxt_kit.defineNuxtModule)({
|
|
|
414
18
|
async setup(options, _nuxt) {
|
|
415
19
|
if (!_nuxt.options.dev) return;
|
|
416
20
|
if (!options.enable) return;
|
|
21
|
+
const { defineEventHandler, proxyRequest } = await require_utils.interopDefault(await import("h3"));
|
|
417
22
|
function debug(...args) {
|
|
418
23
|
if (options?.debug) console.log(` ${picocolors.default.yellow("DEBUG")} `, ...args);
|
|
419
24
|
}
|
|
420
25
|
const { chii } = options || {};
|
|
421
26
|
const enableChii = chii?.enable !== false;
|
|
422
|
-
_nuxt.options.runtimeConfig.unpluginDingtalk = {
|
|
27
|
+
_nuxt.options.runtimeConfig.unpluginDingtalk = {
|
|
28
|
+
chiiEmbedded: chii?.embedded ?? false,
|
|
29
|
+
chiiProxyPath: require_src.CHII_PROXY_PATH
|
|
30
|
+
};
|
|
423
31
|
if (enableChii) {
|
|
424
32
|
const resolver = (0, __nuxt_kit.createResolver)(require("url").pathToFileURL(__filename).href);
|
|
425
33
|
(0, __nuxt_kit.addServerPlugin)(resolver.resolve("./inject-script"));
|
|
426
34
|
let proxy = null;
|
|
427
35
|
(0, __nuxt_kit.addDevServerHandler)({
|
|
428
|
-
route:
|
|
36
|
+
route: require_src.CHII_PROXY_PATH,
|
|
429
37
|
handler: defineEventHandler(async (event) => {
|
|
430
|
-
if (require_src.resovedInfo.availablePort) return proxyRequest(event, `http://localhost:${require_src.resovedInfo.availablePort}${event.path}`);
|
|
38
|
+
if (require_src.resovedInfo.availablePort) return proxyRequest(event, `http://localhost:${require_src.resovedInfo.availablePort}${event.path.replace(require_src.CHII_PROXY_PATH, "")}`);
|
|
431
39
|
})
|
|
432
40
|
});
|
|
433
41
|
_nuxt.hook("listen", (server) => {
|
|
434
42
|
const originalUpgradeListeners = server.listeners("upgrade").slice();
|
|
435
43
|
server.removeAllListeners("upgrade");
|
|
436
44
|
server.on("upgrade", (req, socket, head) => {
|
|
437
|
-
if (req.url?.startsWith(
|
|
45
|
+
if (req.url?.startsWith(require_src.CHII_PROXY_PATH)) {
|
|
438
46
|
debug("WS upgrade:", req.url);
|
|
439
47
|
if (!proxy && require_src.resovedInfo.availablePort) {
|
|
440
48
|
proxy = http_proxy.default.createProxyServer({
|
|
@@ -446,7 +54,7 @@ var nuxt_default = (0, __nuxt_kit.defineNuxtModule)({
|
|
|
446
54
|
});
|
|
447
55
|
}
|
|
448
56
|
if (proxy) {
|
|
449
|
-
req.url = req.url.replace(
|
|
57
|
+
req.url = req.url.replace(require_src.CHII_PROXY_PATH, "");
|
|
450
58
|
socket.on("error", (err) => {
|
|
451
59
|
debug("Socket error:", err.message);
|
|
452
60
|
});
|
|
@@ -462,14 +70,21 @@ var nuxt_default = (0, __nuxt_kit.defineNuxtModule)({
|
|
|
462
70
|
for (const listener of originalUpgradeListeners) listener.call(server, req, socket, head);
|
|
463
71
|
});
|
|
464
72
|
});
|
|
73
|
+
(0, __nuxt_kit.addDevServerHandler)({
|
|
74
|
+
route: require_src.CHII_DEVTOOLS_PATH,
|
|
75
|
+
handler: defineEventHandler(async (event) => {
|
|
76
|
+
if (!require_src.resovedInfo.availablePort) return "Server not started";
|
|
77
|
+
const { getChromeDevtoolsHtml } = await Promise.resolve().then(() => require("./__chrome_devtools.cjs"));
|
|
78
|
+
return getChromeDevtoolsHtml(require_src.resovedInfo.availablePort, require_src.CHII_PROXY_PATH);
|
|
79
|
+
})
|
|
80
|
+
});
|
|
465
81
|
}
|
|
466
82
|
const vitePlugins = await require_vite.vite_default(options);
|
|
467
83
|
(0, __nuxt_kit.addVitePlugin)(vitePlugins);
|
|
468
84
|
_nuxt.hook("listen", (_, listener) => {
|
|
469
85
|
const url = listener.url;
|
|
470
86
|
const source = new URL(url).host;
|
|
471
|
-
|
|
472
|
-
if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
87
|
+
if (enableChii) console.log(` ${picocolors.default.green("➜")} ${picocolors.default.bold("Click to open chrome devtools")}: ${require_utils.colorUrl(`http://${source.replace("0.0.0.0", "localhost")}${require_src.CHII_DEVTOOLS_PATH}`)}`);
|
|
473
88
|
});
|
|
474
89
|
}
|
|
475
90
|
});
|
package/dist/nuxt.d.cts
CHANGED
|
@@ -3,6 +3,6 @@ import * as _nuxt_schema0 from "@nuxt/schema";
|
|
|
3
3
|
|
|
4
4
|
//#region src/nuxt.d.ts
|
|
5
5
|
interface ModuleOptions extends Options {}
|
|
6
|
-
declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions
|
|
6
|
+
declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { ModuleOptions, _default as default };
|
package/dist/nuxt.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import * as _nuxt_schema0 from "@nuxt/schema";
|
|
|
3
3
|
|
|
4
4
|
//#region src/nuxt.d.ts
|
|
5
5
|
interface ModuleOptions extends Options {}
|
|
6
|
-
declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions
|
|
6
|
+
declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { ModuleOptions, _default as default };
|