@unocss/language-server 66.6.3

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.
@@ -0,0 +1,302 @@
1
+ import { n as withBase, r as withQuery } from "./dist-Dwf-d4OE.mjs";
2
+ import { a as le, c as ye, i as dt, n as Mn, o as qn, r as br, s as ut, t as Mi } from "./node-rKyHxxpg.mjs";
3
+ import http from "node:http";
4
+ import https from "node:https";
5
+
6
+ //#region ../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs
7
+ const o = !!globalThis.process?.env?.FORCE_NODE_FETCH, r = !o && globalThis.fetch || Mi, p = !o && globalThis.Blob || ut, F = !o && globalThis.File || qn, h = !o && globalThis.FormData || br, n = !o && globalThis.Headers || ye, c = !o && globalThis.Request || dt, R = !o && globalThis.Response || le, T = !o && globalThis.AbortController || Mn;
8
+
9
+ //#endregion
10
+ //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
11
+ const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
12
+ const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
13
+ const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
14
+ function jsonParseTransform(key, value) {
15
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
16
+ warnKeyDropped(key);
17
+ return;
18
+ }
19
+ return value;
20
+ }
21
+ function warnKeyDropped(key) {
22
+ console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
23
+ }
24
+ function destr(value, options = {}) {
25
+ if (typeof value !== "string") return value;
26
+ if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
27
+ const _value = value.trim();
28
+ if (_value.length <= 9) switch (_value.toLowerCase()) {
29
+ case "true": return true;
30
+ case "false": return false;
31
+ case "undefined": return;
32
+ case "null": return null;
33
+ case "nan": return NaN;
34
+ case "infinity": return Number.POSITIVE_INFINITY;
35
+ case "-infinity": return Number.NEGATIVE_INFINITY;
36
+ }
37
+ if (!JsonSigRx.test(value)) {
38
+ if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
39
+ return value;
40
+ }
41
+ try {
42
+ if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
43
+ if (options.strict) throw new Error("[destr] Possible prototype pollution");
44
+ return JSON.parse(value, jsonParseTransform);
45
+ }
46
+ return JSON.parse(value);
47
+ } catch (error) {
48
+ if (options.strict) throw error;
49
+ return value;
50
+ }
51
+ }
52
+
53
+ //#endregion
54
+ //#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs
55
+ var FetchError = class extends Error {
56
+ constructor(message, opts) {
57
+ super(message, opts);
58
+ this.name = "FetchError";
59
+ if (opts?.cause && !this.cause) this.cause = opts.cause;
60
+ }
61
+ };
62
+ function createFetchError(ctx) {
63
+ const errorMessage = ctx.error?.message || ctx.error?.toString() || "";
64
+ const method = ctx.request?.method || ctx.options?.method || "GET";
65
+ const url = ctx.request?.url || String(ctx.request) || "/";
66
+ const fetchError = new FetchError(`${`[${method}] ${JSON.stringify(url)}`}: ${ctx.response ? `${ctx.response.status} ${ctx.response.statusText}` : "<no response>"}${errorMessage ? ` ${errorMessage}` : ""}`, ctx.error ? { cause: ctx.error } : void 0);
67
+ for (const key of [
68
+ "request",
69
+ "options",
70
+ "response"
71
+ ]) Object.defineProperty(fetchError, key, { get() {
72
+ return ctx[key];
73
+ } });
74
+ for (const [key, refKey] of [
75
+ ["data", "_data"],
76
+ ["status", "status"],
77
+ ["statusCode", "status"],
78
+ ["statusText", "statusText"],
79
+ ["statusMessage", "statusText"]
80
+ ]) Object.defineProperty(fetchError, key, { get() {
81
+ return ctx.response && ctx.response[refKey];
82
+ } });
83
+ return fetchError;
84
+ }
85
+ const payloadMethods = new Set(Object.freeze([
86
+ "PATCH",
87
+ "POST",
88
+ "PUT",
89
+ "DELETE"
90
+ ]));
91
+ function isPayloadMethod(method = "GET") {
92
+ return payloadMethods.has(method.toUpperCase());
93
+ }
94
+ function isJSONSerializable(value) {
95
+ if (value === void 0) return false;
96
+ const t = typeof value;
97
+ if (t === "string" || t === "number" || t === "boolean" || t === null) return true;
98
+ if (t !== "object") return false;
99
+ if (Array.isArray(value)) return true;
100
+ if (value.buffer) return false;
101
+ if (value instanceof FormData || value instanceof URLSearchParams) return false;
102
+ return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
103
+ }
104
+ const textTypes = /* @__PURE__ */ new Set([
105
+ "image/svg",
106
+ "application/xml",
107
+ "application/xhtml",
108
+ "application/html"
109
+ ]);
110
+ const JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
111
+ function detectResponseType(_contentType = "") {
112
+ if (!_contentType) return "json";
113
+ const contentType = _contentType.split(";").shift() || "";
114
+ if (JSON_RE.test(contentType)) return "json";
115
+ if (contentType === "text/event-stream") return "stream";
116
+ if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
117
+ return "blob";
118
+ }
119
+ function resolveFetchOptions(request, input, defaults, Headers$1) {
120
+ const headers = mergeHeaders(input?.headers ?? request?.headers, defaults?.headers, Headers$1);
121
+ let query;
122
+ if (defaults?.query || defaults?.params || input?.params || input?.query) query = {
123
+ ...defaults?.params,
124
+ ...defaults?.query,
125
+ ...input?.params,
126
+ ...input?.query
127
+ };
128
+ return {
129
+ ...defaults,
130
+ ...input,
131
+ query,
132
+ params: query,
133
+ headers
134
+ };
135
+ }
136
+ function mergeHeaders(input, defaults, Headers$1) {
137
+ if (!defaults) return new Headers$1(input);
138
+ const headers = new Headers$1(defaults);
139
+ if (input) for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers$1(input)) headers.set(key, value);
140
+ return headers;
141
+ }
142
+ async function callHooks(context, hooks) {
143
+ if (hooks) if (Array.isArray(hooks)) for (const hook of hooks) await hook(context);
144
+ else await hooks(context);
145
+ }
146
+ const retryStatusCodes = /* @__PURE__ */ new Set([
147
+ 408,
148
+ 409,
149
+ 425,
150
+ 429,
151
+ 500,
152
+ 502,
153
+ 503,
154
+ 504
155
+ ]);
156
+ const nullBodyResponses = /* @__PURE__ */ new Set([
157
+ 101,
158
+ 204,
159
+ 205,
160
+ 304
161
+ ]);
162
+ function createFetch(globalOptions = {}) {
163
+ const { fetch: fetch$1 = globalThis.fetch, Headers: Headers$1 = globalThis.Headers, AbortController: AbortController$1 = globalThis.AbortController } = globalOptions;
164
+ async function onError(context) {
165
+ const isAbort = context.error && context.error.name === "AbortError" && !context.options.timeout || false;
166
+ if (context.options.retry !== false && !isAbort) {
167
+ let retries;
168
+ if (typeof context.options.retry === "number") retries = context.options.retry;
169
+ else retries = isPayloadMethod(context.options.method) ? 0 : 1;
170
+ const responseCode = context.response && context.response.status || 500;
171
+ if (retries > 0 && (Array.isArray(context.options.retryStatusCodes) ? context.options.retryStatusCodes.includes(responseCode) : retryStatusCodes.has(responseCode))) {
172
+ const retryDelay = typeof context.options.retryDelay === "function" ? context.options.retryDelay(context) : context.options.retryDelay || 0;
173
+ if (retryDelay > 0) await new Promise((resolve$1) => setTimeout(resolve$1, retryDelay));
174
+ return $fetchRaw(context.request, {
175
+ ...context.options,
176
+ retry: retries - 1
177
+ });
178
+ }
179
+ }
180
+ const error = createFetchError(context);
181
+ if (Error.captureStackTrace) Error.captureStackTrace(error, $fetchRaw);
182
+ throw error;
183
+ }
184
+ const $fetchRaw = async function $fetchRaw2(_request, _options = {}) {
185
+ const context = {
186
+ request: _request,
187
+ options: resolveFetchOptions(_request, _options, globalOptions.defaults, Headers$1),
188
+ response: void 0,
189
+ error: void 0
190
+ };
191
+ if (context.options.method) context.options.method = context.options.method.toUpperCase();
192
+ if (context.options.onRequest) {
193
+ await callHooks(context, context.options.onRequest);
194
+ if (!(context.options.headers instanceof Headers$1)) context.options.headers = new Headers$1(context.options.headers || {});
195
+ }
196
+ if (typeof context.request === "string") {
197
+ if (context.options.baseURL) context.request = withBase(context.request, context.options.baseURL);
198
+ if (context.options.query) {
199
+ context.request = withQuery(context.request, context.options.query);
200
+ delete context.options.query;
201
+ }
202
+ if ("query" in context.options) delete context.options.query;
203
+ if ("params" in context.options) delete context.options.params;
204
+ }
205
+ if (context.options.body && isPayloadMethod(context.options.method)) {
206
+ if (isJSONSerializable(context.options.body)) {
207
+ const contentType = context.options.headers.get("content-type");
208
+ if (typeof context.options.body !== "string") context.options.body = contentType === "application/x-www-form-urlencoded" ? new URLSearchParams(context.options.body).toString() : JSON.stringify(context.options.body);
209
+ if (!contentType) context.options.headers.set("content-type", "application/json");
210
+ if (!context.options.headers.has("accept")) context.options.headers.set("accept", "application/json");
211
+ } else if ("pipeTo" in context.options.body && typeof context.options.body.pipeTo === "function" || typeof context.options.body.pipe === "function") {
212
+ if (!("duplex" in context.options)) context.options.duplex = "half";
213
+ }
214
+ }
215
+ let abortTimeout;
216
+ if (!context.options.signal && context.options.timeout) {
217
+ const controller = new AbortController$1();
218
+ abortTimeout = setTimeout(() => {
219
+ const error = /* @__PURE__ */ new Error("[TimeoutError]: The operation was aborted due to timeout");
220
+ error.name = "TimeoutError";
221
+ error.code = 23;
222
+ controller.abort(error);
223
+ }, context.options.timeout);
224
+ context.options.signal = controller.signal;
225
+ }
226
+ try {
227
+ context.response = await fetch$1(context.request, context.options);
228
+ } catch (error) {
229
+ context.error = error;
230
+ if (context.options.onRequestError) await callHooks(context, context.options.onRequestError);
231
+ return await onError(context);
232
+ } finally {
233
+ if (abortTimeout) clearTimeout(abortTimeout);
234
+ }
235
+ if ((context.response.body || context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== "HEAD") {
236
+ const responseType = (context.options.parseResponse ? "json" : context.options.responseType) || detectResponseType(context.response.headers.get("content-type") || "");
237
+ switch (responseType) {
238
+ case "json": {
239
+ const data = await context.response.text();
240
+ const parseFunction = context.options.parseResponse || destr;
241
+ context.response._data = parseFunction(data);
242
+ break;
243
+ }
244
+ case "stream":
245
+ context.response._data = context.response.body || context.response._bodyInit;
246
+ break;
247
+ default: context.response._data = await context.response[responseType]();
248
+ }
249
+ }
250
+ if (context.options.onResponse) await callHooks(context, context.options.onResponse);
251
+ if (!context.options.ignoreResponseError && context.response.status >= 400 && context.response.status < 600) {
252
+ if (context.options.onResponseError) await callHooks(context, context.options.onResponseError);
253
+ return await onError(context);
254
+ }
255
+ return context.response;
256
+ };
257
+ const $fetch$1 = async function $fetch2(request, options) {
258
+ return (await $fetchRaw(request, options))._data;
259
+ };
260
+ $fetch$1.raw = $fetchRaw;
261
+ $fetch$1.native = (...args) => fetch$1(...args);
262
+ $fetch$1.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({
263
+ ...globalOptions,
264
+ ...customGlobalOptions,
265
+ defaults: {
266
+ ...globalOptions.defaults,
267
+ ...customGlobalOptions.defaults,
268
+ ...defaultOptions
269
+ }
270
+ });
271
+ return $fetch$1;
272
+ }
273
+
274
+ //#endregion
275
+ //#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs
276
+ function createNodeFetch() {
277
+ if (!JSON.parse(process.env.FETCH_KEEP_ALIVE || "false")) return r;
278
+ const agentOptions = { keepAlive: true };
279
+ const httpAgent = new http.Agent(agentOptions);
280
+ const httpsAgent = new https.Agent(agentOptions);
281
+ const nodeFetchOptions = { agent(parsedURL) {
282
+ return parsedURL.protocol === "http:" ? httpAgent : httpsAgent;
283
+ } };
284
+ return function nodeFetchWithKeepAlive(input, init) {
285
+ return r(input, {
286
+ ...nodeFetchOptions,
287
+ ...init
288
+ });
289
+ };
290
+ }
291
+ const fetch = globalThis.fetch ? (...args) => globalThis.fetch(...args) : createNodeFetch();
292
+ const Headers = globalThis.Headers || n;
293
+ const AbortController = globalThis.AbortController || T;
294
+ const ofetch = createFetch({
295
+ fetch,
296
+ Headers,
297
+ AbortController
298
+ });
299
+ const $fetch = ofetch;
300
+
301
+ //#endregion
302
+ export { $fetch };