@powerlines/plugin-automd 0.1.128 → 0.1.129

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.
Files changed (80) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +2 -0
  2. package/dist/_virtual/rolldown_runtime.mjs +32 -0
  3. package/dist/index.cjs +5 -5
  4. package/dist/index.d.mts +1 -1
  5. package/dist/index.mjs +7 -7
  6. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +78 -0
  7. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +77 -0
  8. package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.cjs +5032 -0
  9. package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.mjs +5031 -0
  10. package/dist/node_modules/.pnpm/automd@0.4.2_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/shared/automd.CjwUz8DJ.cjs +593 -0
  11. package/dist/node_modules/.pnpm/automd@0.4.2_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/shared/automd.CjwUz8DJ.mjs +590 -0
  12. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.cjs +23 -0
  13. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.mjs +22 -0
  14. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.cjs +405 -0
  15. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.mjs +404 -0
  16. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +46 -0
  17. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +45 -0
  18. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.cjs +204 -0
  19. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs +202 -0
  20. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +1013 -0
  21. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +1007 -0
  22. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.cjs +128 -0
  23. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs +123 -0
  24. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.cjs +41464 -0
  25. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.mjs +41461 -0
  26. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.cjs +4387 -0
  27. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.mjs +4384 -0
  28. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.cjs +26 -0
  29. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.mjs +26 -0
  30. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.cjs +370 -0
  31. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs +367 -0
  32. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +939 -0
  33. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +939 -0
  34. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.cjs +67 -0
  35. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.mjs +64 -0
  36. package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.cjs +1292 -0
  37. package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs +1284 -0
  38. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +179 -0
  39. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +179 -0
  40. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +20 -0
  41. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +18 -0
  42. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +3975 -0
  43. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +3961 -0
  44. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.cjs +16 -0
  45. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +14 -0
  46. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.cjs +36 -0
  47. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs +33 -0
  48. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.cjs +227 -0
  49. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs +225 -0
  50. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +139 -0
  51. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +133 -0
  52. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +77 -0
  53. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +76 -0
  54. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.cjs +72 -0
  55. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs +69 -0
  56. package/dist/node_modules/.pnpm/ufo@1.6.2/node_modules/ufo/dist/index.cjs +178 -0
  57. package/dist/node_modules/.pnpm/ufo@1.6.2/node_modules/ufo/dist/index.mjs +175 -0
  58. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.cjs +12337 -0
  59. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.mjs +12337 -0
  60. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.cjs +19 -0
  61. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs +18 -0
  62. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.cjs +71 -0
  63. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs +71 -0
  64. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.cjs +110 -0
  65. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs +100 -0
  66. package/dist/types/plugin.d.mts +3 -3
  67. package/package.json +4 -5
  68. /package/dist/{powerlines → packages/powerlines}/src/internal/helpers/hooks.d.mts +0 -0
  69. /package/dist/{powerlines → packages/powerlines}/src/types/api.d.mts +0 -0
  70. /package/dist/{powerlines → packages/powerlines}/src/types/babel.d.mts +0 -0
  71. /package/dist/{powerlines → packages/powerlines}/src/types/build.d.mts +0 -0
  72. /package/dist/{powerlines → packages/powerlines}/src/types/commands.d.mts +0 -0
  73. /package/dist/{powerlines → packages/powerlines}/src/types/config.d.mts +0 -0
  74. /package/dist/{powerlines → packages/powerlines}/src/types/context.d.mts +0 -0
  75. /package/dist/{powerlines → packages/powerlines}/src/types/fs.d.mts +0 -0
  76. /package/dist/{powerlines → packages/powerlines}/src/types/hooks.d.mts +0 -0
  77. /package/dist/{powerlines → packages/powerlines}/src/types/plugin.d.mts +0 -0
  78. /package/dist/{powerlines → packages/powerlines}/src/types/resolved.d.mts +0 -0
  79. /package/dist/{powerlines → packages/powerlines}/src/types/tsconfig.d.mts +0 -0
  80. /package/dist/{powerlines → packages/powerlines}/src/types/unplugin.d.mts +0 -0
@@ -0,0 +1,16 @@
1
+
2
+ //#region ../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs
3
+ var t = Object.defineProperty;
4
+ var o = (e, l) => t(e, "name", {
5
+ value: l,
6
+ configurable: !0
7
+ });
8
+ var n = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
9
+ function f(e) {
10
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
11
+ }
12
+ o(f, "getDefaultExportFromCjs");
13
+
14
+ //#endregion
15
+ exports.f = f;
16
+ exports.n = n;
@@ -0,0 +1,14 @@
1
+ //#region ../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs
2
+ var t = Object.defineProperty;
3
+ var o = (e, l) => t(e, "name", {
4
+ value: l,
5
+ configurable: !0
6
+ });
7
+ var n = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
8
+ function f(e) {
9
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
10
+ }
11
+ o(f, "getDefaultExportFromCjs");
12
+
13
+ //#endregion
14
+ export { f, n };
@@ -0,0 +1,36 @@
1
+ const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_index = require('../../../../node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs');
3
+ const require_ofetch_CWycOUEr = require('./shared/ofetch.CWycOUEr.cjs');
4
+ let node_http = require("node:http");
5
+ node_http = require_rolldown_runtime.__toESM(node_http);
6
+ let node_https = require("node:https");
7
+ node_https = require_rolldown_runtime.__toESM(node_https);
8
+
9
+ //#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs
10
+ function createNodeFetch() {
11
+ if (!JSON.parse(process.env.FETCH_KEEP_ALIVE || "false")) return require_index.r;
12
+ const agentOptions = { keepAlive: true };
13
+ const httpAgent = new node_http.default.Agent(agentOptions);
14
+ const httpsAgent = new node_https.default.Agent(agentOptions);
15
+ const nodeFetchOptions = { agent(parsedURL) {
16
+ return parsedURL.protocol === "http:" ? httpAgent : httpsAgent;
17
+ } };
18
+ return function nodeFetchWithKeepAlive(input, init) {
19
+ return require_index.r(input, {
20
+ ...nodeFetchOptions,
21
+ ...init
22
+ });
23
+ };
24
+ }
25
+ const fetch = globalThis.fetch ? (...args) => globalThis.fetch(...args) : createNodeFetch();
26
+ const Headers = globalThis.Headers || require_index.n;
27
+ const AbortController = globalThis.AbortController || require_index.T;
28
+ const ofetch = require_ofetch_CWycOUEr.createFetch({
29
+ fetch,
30
+ Headers,
31
+ AbortController
32
+ });
33
+ const $fetch = ofetch;
34
+
35
+ //#endregion
36
+ exports.$fetch = $fetch;
@@ -0,0 +1,33 @@
1
+ import { T, n, r } from "../../../../node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs";
2
+ import { FetchError, createFetch, createFetchError } from "./shared/ofetch.CWycOUEr.mjs";
3
+ import http from "node:http";
4
+ import https from "node:https";
5
+
6
+ //#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs
7
+ function createNodeFetch() {
8
+ if (!JSON.parse(process.env.FETCH_KEEP_ALIVE || "false")) return r;
9
+ const agentOptions = { keepAlive: true };
10
+ const httpAgent = new http.Agent(agentOptions);
11
+ const httpsAgent = new https.Agent(agentOptions);
12
+ const nodeFetchOptions = { agent(parsedURL) {
13
+ return parsedURL.protocol === "http:" ? httpAgent : httpsAgent;
14
+ } };
15
+ return function nodeFetchWithKeepAlive(input, init) {
16
+ return r(input, {
17
+ ...nodeFetchOptions,
18
+ ...init
19
+ });
20
+ };
21
+ }
22
+ const fetch = globalThis.fetch ? (...args) => globalThis.fetch(...args) : createNodeFetch();
23
+ const Headers = globalThis.Headers || n;
24
+ const AbortController = globalThis.AbortController || T;
25
+ const ofetch = createFetch({
26
+ fetch,
27
+ Headers,
28
+ AbortController
29
+ });
30
+ const $fetch = ofetch;
31
+
32
+ //#endregion
33
+ export { $fetch };
@@ -0,0 +1,227 @@
1
+ const require_index = require('../../../../../ufo@1.6.2/node_modules/ufo/dist/index.cjs');
2
+ const require_index$1 = require('../../../../../destr@2.0.5/node_modules/destr/dist/index.cjs');
3
+
4
+ //#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs
5
+ var FetchError = class extends Error {
6
+ constructor(message, opts) {
7
+ super(message, opts);
8
+ this.name = "FetchError";
9
+ if (opts?.cause && !this.cause) this.cause = opts.cause;
10
+ }
11
+ };
12
+ function createFetchError(ctx) {
13
+ const errorMessage = ctx.error?.message || ctx.error?.toString() || "";
14
+ const method = ctx.request?.method || ctx.options?.method || "GET";
15
+ const url = ctx.request?.url || String(ctx.request) || "/";
16
+ 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);
17
+ for (const key of [
18
+ "request",
19
+ "options",
20
+ "response"
21
+ ]) Object.defineProperty(fetchError, key, { get() {
22
+ return ctx[key];
23
+ } });
24
+ for (const [key, refKey] of [
25
+ ["data", "_data"],
26
+ ["status", "status"],
27
+ ["statusCode", "status"],
28
+ ["statusText", "statusText"],
29
+ ["statusMessage", "statusText"]
30
+ ]) Object.defineProperty(fetchError, key, { get() {
31
+ return ctx.response && ctx.response[refKey];
32
+ } });
33
+ return fetchError;
34
+ }
35
+ const payloadMethods = new Set(Object.freeze([
36
+ "PATCH",
37
+ "POST",
38
+ "PUT",
39
+ "DELETE"
40
+ ]));
41
+ function isPayloadMethod(method = "GET") {
42
+ return payloadMethods.has(method.toUpperCase());
43
+ }
44
+ function isJSONSerializable(value) {
45
+ if (value === void 0) return false;
46
+ const t = typeof value;
47
+ if (t === "string" || t === "number" || t === "boolean" || t === null) return true;
48
+ if (t !== "object") return false;
49
+ if (Array.isArray(value)) return true;
50
+ if (value.buffer) return false;
51
+ if (value instanceof FormData || value instanceof URLSearchParams) return false;
52
+ return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
53
+ }
54
+ const textTypes = /* @__PURE__ */ new Set([
55
+ "image/svg",
56
+ "application/xml",
57
+ "application/xhtml",
58
+ "application/html"
59
+ ]);
60
+ const JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
61
+ function detectResponseType(_contentType = "") {
62
+ if (!_contentType) return "json";
63
+ const contentType = _contentType.split(";").shift() || "";
64
+ if (JSON_RE.test(contentType)) return "json";
65
+ if (contentType === "text/event-stream") return "stream";
66
+ if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
67
+ return "blob";
68
+ }
69
+ function resolveFetchOptions(request, input, defaults, Headers) {
70
+ const headers = mergeHeaders(input?.headers ?? request?.headers, defaults?.headers, Headers);
71
+ let query;
72
+ if (defaults?.query || defaults?.params || input?.params || input?.query) query = {
73
+ ...defaults?.params,
74
+ ...defaults?.query,
75
+ ...input?.params,
76
+ ...input?.query
77
+ };
78
+ return {
79
+ ...defaults,
80
+ ...input,
81
+ query,
82
+ params: query,
83
+ headers
84
+ };
85
+ }
86
+ function mergeHeaders(input, defaults, Headers) {
87
+ if (!defaults) return new Headers(input);
88
+ const headers = new Headers(defaults);
89
+ if (input) for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers(input)) headers.set(key, value);
90
+ return headers;
91
+ }
92
+ async function callHooks(context, hooks) {
93
+ if (hooks) if (Array.isArray(hooks)) for (const hook of hooks) await hook(context);
94
+ else await hooks(context);
95
+ }
96
+ const retryStatusCodes = /* @__PURE__ */ new Set([
97
+ 408,
98
+ 409,
99
+ 425,
100
+ 429,
101
+ 500,
102
+ 502,
103
+ 503,
104
+ 504
105
+ ]);
106
+ const nullBodyResponses = /* @__PURE__ */ new Set([
107
+ 101,
108
+ 204,
109
+ 205,
110
+ 304
111
+ ]);
112
+ function createFetch(globalOptions = {}) {
113
+ const { fetch = globalThis.fetch, Headers = globalThis.Headers, AbortController = globalThis.AbortController } = globalOptions;
114
+ async function onError(context) {
115
+ const isAbort = context.error && context.error.name === "AbortError" && !context.options.timeout || false;
116
+ if (context.options.retry !== false && !isAbort) {
117
+ let retries;
118
+ if (typeof context.options.retry === "number") retries = context.options.retry;
119
+ else retries = isPayloadMethod(context.options.method) ? 0 : 1;
120
+ const responseCode = context.response && context.response.status || 500;
121
+ if (retries > 0 && (Array.isArray(context.options.retryStatusCodes) ? context.options.retryStatusCodes.includes(responseCode) : retryStatusCodes.has(responseCode))) {
122
+ const retryDelay = typeof context.options.retryDelay === "function" ? context.options.retryDelay(context) : context.options.retryDelay || 0;
123
+ if (retryDelay > 0) await new Promise((resolve) => setTimeout(resolve, retryDelay));
124
+ return $fetchRaw(context.request, {
125
+ ...context.options,
126
+ retry: retries - 1
127
+ });
128
+ }
129
+ }
130
+ const error = createFetchError(context);
131
+ if (Error.captureStackTrace) Error.captureStackTrace(error, $fetchRaw);
132
+ throw error;
133
+ }
134
+ const $fetchRaw = async function $fetchRaw2(_request, _options = {}) {
135
+ const context = {
136
+ request: _request,
137
+ options: resolveFetchOptions(_request, _options, globalOptions.defaults, Headers),
138
+ response: void 0,
139
+ error: void 0
140
+ };
141
+ if (context.options.method) context.options.method = context.options.method.toUpperCase();
142
+ if (context.options.onRequest) {
143
+ await callHooks(context, context.options.onRequest);
144
+ if (!(context.options.headers instanceof Headers)) context.options.headers = new Headers(context.options.headers || {});
145
+ }
146
+ if (typeof context.request === "string") {
147
+ if (context.options.baseURL) context.request = require_index.withBase(context.request, context.options.baseURL);
148
+ if (context.options.query) {
149
+ context.request = require_index.withQuery(context.request, context.options.query);
150
+ delete context.options.query;
151
+ }
152
+ if ("query" in context.options) delete context.options.query;
153
+ if ("params" in context.options) delete context.options.params;
154
+ }
155
+ if (context.options.body && isPayloadMethod(context.options.method)) {
156
+ if (isJSONSerializable(context.options.body)) {
157
+ const contentType = context.options.headers.get("content-type");
158
+ 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);
159
+ if (!contentType) context.options.headers.set("content-type", "application/json");
160
+ if (!context.options.headers.has("accept")) context.options.headers.set("accept", "application/json");
161
+ } else if ("pipeTo" in context.options.body && typeof context.options.body.pipeTo === "function" || typeof context.options.body.pipe === "function") {
162
+ if (!("duplex" in context.options)) context.options.duplex = "half";
163
+ }
164
+ }
165
+ let abortTimeout;
166
+ if (!context.options.signal && context.options.timeout) {
167
+ const controller = new AbortController();
168
+ abortTimeout = setTimeout(() => {
169
+ const error = /* @__PURE__ */ new Error("[TimeoutError]: The operation was aborted due to timeout");
170
+ error.name = "TimeoutError";
171
+ error.code = 23;
172
+ controller.abort(error);
173
+ }, context.options.timeout);
174
+ context.options.signal = controller.signal;
175
+ }
176
+ try {
177
+ context.response = await fetch(context.request, context.options);
178
+ } catch (error) {
179
+ context.error = error;
180
+ if (context.options.onRequestError) await callHooks(context, context.options.onRequestError);
181
+ return await onError(context);
182
+ } finally {
183
+ if (abortTimeout) clearTimeout(abortTimeout);
184
+ }
185
+ if ((context.response.body || context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== "HEAD") {
186
+ const responseType = (context.options.parseResponse ? "json" : context.options.responseType) || detectResponseType(context.response.headers.get("content-type") || "");
187
+ switch (responseType) {
188
+ case "json": {
189
+ const data = await context.response.text();
190
+ const parseFunction = context.options.parseResponse || require_index$1.destr;
191
+ context.response._data = parseFunction(data);
192
+ break;
193
+ }
194
+ case "stream":
195
+ context.response._data = context.response.body || context.response._bodyInit;
196
+ break;
197
+ default: context.response._data = await context.response[responseType]();
198
+ }
199
+ }
200
+ if (context.options.onResponse) await callHooks(context, context.options.onResponse);
201
+ if (!context.options.ignoreResponseError && context.response.status >= 400 && context.response.status < 600) {
202
+ if (context.options.onResponseError) await callHooks(context, context.options.onResponseError);
203
+ return await onError(context);
204
+ }
205
+ return context.response;
206
+ };
207
+ const $fetch = async function $fetch2(request, options) {
208
+ return (await $fetchRaw(request, options))._data;
209
+ };
210
+ $fetch.raw = $fetchRaw;
211
+ $fetch.native = (...args) => fetch(...args);
212
+ $fetch.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({
213
+ ...globalOptions,
214
+ ...customGlobalOptions,
215
+ defaults: {
216
+ ...globalOptions.defaults,
217
+ ...customGlobalOptions.defaults,
218
+ ...defaultOptions
219
+ }
220
+ });
221
+ return $fetch;
222
+ }
223
+
224
+ //#endregion
225
+ exports.FetchError = FetchError;
226
+ exports.createFetch = createFetch;
227
+ exports.createFetchError = createFetchError;
@@ -0,0 +1,225 @@
1
+ import { withBase, withQuery } from "../../../../../ufo@1.6.2/node_modules/ufo/dist/index.mjs";
2
+ import { destr } from "../../../../../destr@2.0.5/node_modules/destr/dist/index.mjs";
3
+
4
+ //#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs
5
+ var FetchError = class extends Error {
6
+ constructor(message, opts) {
7
+ super(message, opts);
8
+ this.name = "FetchError";
9
+ if (opts?.cause && !this.cause) this.cause = opts.cause;
10
+ }
11
+ };
12
+ function createFetchError(ctx) {
13
+ const errorMessage = ctx.error?.message || ctx.error?.toString() || "";
14
+ const method = ctx.request?.method || ctx.options?.method || "GET";
15
+ const url = ctx.request?.url || String(ctx.request) || "/";
16
+ 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);
17
+ for (const key of [
18
+ "request",
19
+ "options",
20
+ "response"
21
+ ]) Object.defineProperty(fetchError, key, { get() {
22
+ return ctx[key];
23
+ } });
24
+ for (const [key, refKey] of [
25
+ ["data", "_data"],
26
+ ["status", "status"],
27
+ ["statusCode", "status"],
28
+ ["statusText", "statusText"],
29
+ ["statusMessage", "statusText"]
30
+ ]) Object.defineProperty(fetchError, key, { get() {
31
+ return ctx.response && ctx.response[refKey];
32
+ } });
33
+ return fetchError;
34
+ }
35
+ const payloadMethods = new Set(Object.freeze([
36
+ "PATCH",
37
+ "POST",
38
+ "PUT",
39
+ "DELETE"
40
+ ]));
41
+ function isPayloadMethod(method = "GET") {
42
+ return payloadMethods.has(method.toUpperCase());
43
+ }
44
+ function isJSONSerializable(value) {
45
+ if (value === void 0) return false;
46
+ const t = typeof value;
47
+ if (t === "string" || t === "number" || t === "boolean" || t === null) return true;
48
+ if (t !== "object") return false;
49
+ if (Array.isArray(value)) return true;
50
+ if (value.buffer) return false;
51
+ if (value instanceof FormData || value instanceof URLSearchParams) return false;
52
+ return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
53
+ }
54
+ const textTypes = /* @__PURE__ */ new Set([
55
+ "image/svg",
56
+ "application/xml",
57
+ "application/xhtml",
58
+ "application/html"
59
+ ]);
60
+ const JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
61
+ function detectResponseType(_contentType = "") {
62
+ if (!_contentType) return "json";
63
+ const contentType = _contentType.split(";").shift() || "";
64
+ if (JSON_RE.test(contentType)) return "json";
65
+ if (contentType === "text/event-stream") return "stream";
66
+ if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
67
+ return "blob";
68
+ }
69
+ function resolveFetchOptions(request, input, defaults, Headers) {
70
+ const headers = mergeHeaders(input?.headers ?? request?.headers, defaults?.headers, Headers);
71
+ let query;
72
+ if (defaults?.query || defaults?.params || input?.params || input?.query) query = {
73
+ ...defaults?.params,
74
+ ...defaults?.query,
75
+ ...input?.params,
76
+ ...input?.query
77
+ };
78
+ return {
79
+ ...defaults,
80
+ ...input,
81
+ query,
82
+ params: query,
83
+ headers
84
+ };
85
+ }
86
+ function mergeHeaders(input, defaults, Headers) {
87
+ if (!defaults) return new Headers(input);
88
+ const headers = new Headers(defaults);
89
+ if (input) for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers(input)) headers.set(key, value);
90
+ return headers;
91
+ }
92
+ async function callHooks(context, hooks) {
93
+ if (hooks) if (Array.isArray(hooks)) for (const hook of hooks) await hook(context);
94
+ else await hooks(context);
95
+ }
96
+ const retryStatusCodes = /* @__PURE__ */ new Set([
97
+ 408,
98
+ 409,
99
+ 425,
100
+ 429,
101
+ 500,
102
+ 502,
103
+ 503,
104
+ 504
105
+ ]);
106
+ const nullBodyResponses = /* @__PURE__ */ new Set([
107
+ 101,
108
+ 204,
109
+ 205,
110
+ 304
111
+ ]);
112
+ function createFetch(globalOptions = {}) {
113
+ const { fetch = globalThis.fetch, Headers = globalThis.Headers, AbortController = globalThis.AbortController } = globalOptions;
114
+ async function onError(context) {
115
+ const isAbort = context.error && context.error.name === "AbortError" && !context.options.timeout || false;
116
+ if (context.options.retry !== false && !isAbort) {
117
+ let retries;
118
+ if (typeof context.options.retry === "number") retries = context.options.retry;
119
+ else retries = isPayloadMethod(context.options.method) ? 0 : 1;
120
+ const responseCode = context.response && context.response.status || 500;
121
+ if (retries > 0 && (Array.isArray(context.options.retryStatusCodes) ? context.options.retryStatusCodes.includes(responseCode) : retryStatusCodes.has(responseCode))) {
122
+ const retryDelay = typeof context.options.retryDelay === "function" ? context.options.retryDelay(context) : context.options.retryDelay || 0;
123
+ if (retryDelay > 0) await new Promise((resolve) => setTimeout(resolve, retryDelay));
124
+ return $fetchRaw(context.request, {
125
+ ...context.options,
126
+ retry: retries - 1
127
+ });
128
+ }
129
+ }
130
+ const error = createFetchError(context);
131
+ if (Error.captureStackTrace) Error.captureStackTrace(error, $fetchRaw);
132
+ throw error;
133
+ }
134
+ const $fetchRaw = async function $fetchRaw2(_request, _options = {}) {
135
+ const context = {
136
+ request: _request,
137
+ options: resolveFetchOptions(_request, _options, globalOptions.defaults, Headers),
138
+ response: void 0,
139
+ error: void 0
140
+ };
141
+ if (context.options.method) context.options.method = context.options.method.toUpperCase();
142
+ if (context.options.onRequest) {
143
+ await callHooks(context, context.options.onRequest);
144
+ if (!(context.options.headers instanceof Headers)) context.options.headers = new Headers(context.options.headers || {});
145
+ }
146
+ if (typeof context.request === "string") {
147
+ if (context.options.baseURL) context.request = withBase(context.request, context.options.baseURL);
148
+ if (context.options.query) {
149
+ context.request = withQuery(context.request, context.options.query);
150
+ delete context.options.query;
151
+ }
152
+ if ("query" in context.options) delete context.options.query;
153
+ if ("params" in context.options) delete context.options.params;
154
+ }
155
+ if (context.options.body && isPayloadMethod(context.options.method)) {
156
+ if (isJSONSerializable(context.options.body)) {
157
+ const contentType = context.options.headers.get("content-type");
158
+ 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);
159
+ if (!contentType) context.options.headers.set("content-type", "application/json");
160
+ if (!context.options.headers.has("accept")) context.options.headers.set("accept", "application/json");
161
+ } else if ("pipeTo" in context.options.body && typeof context.options.body.pipeTo === "function" || typeof context.options.body.pipe === "function") {
162
+ if (!("duplex" in context.options)) context.options.duplex = "half";
163
+ }
164
+ }
165
+ let abortTimeout;
166
+ if (!context.options.signal && context.options.timeout) {
167
+ const controller = new AbortController();
168
+ abortTimeout = setTimeout(() => {
169
+ const error = /* @__PURE__ */ new Error("[TimeoutError]: The operation was aborted due to timeout");
170
+ error.name = "TimeoutError";
171
+ error.code = 23;
172
+ controller.abort(error);
173
+ }, context.options.timeout);
174
+ context.options.signal = controller.signal;
175
+ }
176
+ try {
177
+ context.response = await fetch(context.request, context.options);
178
+ } catch (error) {
179
+ context.error = error;
180
+ if (context.options.onRequestError) await callHooks(context, context.options.onRequestError);
181
+ return await onError(context);
182
+ } finally {
183
+ if (abortTimeout) clearTimeout(abortTimeout);
184
+ }
185
+ if ((context.response.body || context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== "HEAD") {
186
+ const responseType = (context.options.parseResponse ? "json" : context.options.responseType) || detectResponseType(context.response.headers.get("content-type") || "");
187
+ switch (responseType) {
188
+ case "json": {
189
+ const data = await context.response.text();
190
+ const parseFunction = context.options.parseResponse || destr;
191
+ context.response._data = parseFunction(data);
192
+ break;
193
+ }
194
+ case "stream":
195
+ context.response._data = context.response.body || context.response._bodyInit;
196
+ break;
197
+ default: context.response._data = await context.response[responseType]();
198
+ }
199
+ }
200
+ if (context.options.onResponse) await callHooks(context, context.options.onResponse);
201
+ if (!context.options.ignoreResponseError && context.response.status >= 400 && context.response.status < 600) {
202
+ if (context.options.onResponseError) await callHooks(context, context.options.onResponseError);
203
+ return await onError(context);
204
+ }
205
+ return context.response;
206
+ };
207
+ const $fetch = async function $fetch2(request, options) {
208
+ return (await $fetchRaw(request, options))._data;
209
+ };
210
+ $fetch.raw = $fetchRaw;
211
+ $fetch.native = (...args) => fetch(...args);
212
+ $fetch.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({
213
+ ...globalOptions,
214
+ ...customGlobalOptions,
215
+ defaults: {
216
+ ...globalOptions.defaults,
217
+ ...customGlobalOptions.defaults,
218
+ ...defaultOptions
219
+ }
220
+ });
221
+ return $fetch;
222
+ }
223
+
224
+ //#endregion
225
+ export { FetchError, createFetch, createFetchError };