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