@vixt/core 0.13.3 → 0.13.5
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/client/index.d.ts +2356 -14
- package/dist/client/index.js +264 -72
- package/dist/node/index.d.mts +40 -41
- package/dist/node/index.mjs +10 -39
- package/package.json +7 -7
package/dist/client/index.js
CHANGED
|
@@ -28,60 +28,224 @@ function useVixtApp() {
|
|
|
28
28
|
return globalThis.useVixtApp?.();
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region ../../node_modules/.pnpm/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!baseHasTrailing && !pathHasLeading) return `${base}/${path}`;
|
|
42
|
-
return base + path;
|
|
31
|
+
//#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
|
|
32
|
+
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*:/;
|
|
33
|
+
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*:/;
|
|
34
|
+
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
35
|
+
function jsonParseTransform(key, value) {
|
|
36
|
+
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
37
|
+
warnKeyDropped(key);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function
|
|
48
|
-
if (
|
|
42
|
+
function warnKeyDropped(key) {
|
|
43
|
+
console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
|
|
44
|
+
}
|
|
45
|
+
function destr(value, options = {}) {
|
|
46
|
+
if (typeof value !== "string") return value;
|
|
47
|
+
if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
|
|
48
|
+
const _value = value.trim();
|
|
49
|
+
if (_value.length <= 9) switch (_value.toLowerCase()) {
|
|
50
|
+
case "true": return true;
|
|
51
|
+
case "false": return false;
|
|
52
|
+
case "undefined": return;
|
|
53
|
+
case "null": return null;
|
|
54
|
+
case "nan": return NaN;
|
|
55
|
+
case "infinity": return Number.POSITIVE_INFINITY;
|
|
56
|
+
case "-infinity": return Number.NEGATIVE_INFINITY;
|
|
57
|
+
}
|
|
58
|
+
if (!JsonSigRx.test(value)) {
|
|
59
|
+
if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
|
|
64
|
+
if (options.strict) throw new Error("[destr] Possible prototype pollution");
|
|
65
|
+
return JSON.parse(value, jsonParseTransform);
|
|
66
|
+
}
|
|
67
|
+
return JSON.parse(value);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (options.strict) throw error;
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
String.fromCharCode;
|
|
74
|
+
const HASH_RE = /#/g;
|
|
75
|
+
const AMPERSAND_RE = /&/g;
|
|
76
|
+
const SLASH_RE = /\//g;
|
|
77
|
+
const EQUAL_RE = /=/g;
|
|
78
|
+
const PLUS_RE = /\+/g;
|
|
79
|
+
const ENC_CARET_RE = /%5e/gi;
|
|
80
|
+
const ENC_BACKTICK_RE = /%60/gi;
|
|
81
|
+
const ENC_PIPE_RE = /%7c/gi;
|
|
82
|
+
const ENC_SPACE_RE = /%20/gi;
|
|
83
|
+
function encode(text) {
|
|
84
|
+
return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
|
|
85
|
+
}
|
|
86
|
+
function encodeQueryValue(input) {
|
|
87
|
+
return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
|
|
88
|
+
}
|
|
89
|
+
function encodeQueryKey(text) {
|
|
90
|
+
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
91
|
+
}
|
|
92
|
+
function decode(text = "") {
|
|
93
|
+
try {
|
|
94
|
+
return decodeURIComponent("" + text);
|
|
95
|
+
} catch {
|
|
96
|
+
return "" + text;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function decodeQueryKey(text) {
|
|
100
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
101
|
+
}
|
|
102
|
+
function decodeQueryValue(text) {
|
|
103
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
104
|
+
}
|
|
105
|
+
function parseQuery(parametersString = "") {
|
|
106
|
+
const object = /* @__PURE__ */ Object.create(null);
|
|
107
|
+
if (parametersString[0] === "?") parametersString = parametersString.slice(1);
|
|
108
|
+
for (const parameter of parametersString.split("&")) {
|
|
109
|
+
const s = parameter.match(/([^=]+)=?(.*)/) || [];
|
|
110
|
+
if (s.length < 2) continue;
|
|
111
|
+
const key = decodeQueryKey(s[1]);
|
|
112
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
113
|
+
const value = decodeQueryValue(s[2] || "");
|
|
114
|
+
if (object[key] === void 0) object[key] = value;
|
|
115
|
+
else if (Array.isArray(object[key])) object[key].push(value);
|
|
116
|
+
else object[key] = [object[key], value];
|
|
117
|
+
}
|
|
118
|
+
return object;
|
|
119
|
+
}
|
|
120
|
+
function encodeQueryItem(key, value) {
|
|
121
|
+
if (typeof value === "number" || typeof value === "boolean") value = String(value);
|
|
122
|
+
if (!value) return encodeQueryKey(key);
|
|
123
|
+
if (Array.isArray(value)) return value.map((_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`).join("&");
|
|
124
|
+
return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
|
|
125
|
+
}
|
|
126
|
+
function stringifyQuery(query) {
|
|
127
|
+
return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
|
|
128
|
+
}
|
|
129
|
+
const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
|
|
130
|
+
const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
|
|
131
|
+
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
|
|
132
|
+
const TRAILING_SLASH_RE = /\/$|\/\?|\/#/;
|
|
133
|
+
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
134
|
+
function hasProtocol(inputString, opts = {}) {
|
|
135
|
+
if (typeof opts === "boolean") opts = { acceptRelative: opts };
|
|
136
|
+
if (opts.strict) return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
137
|
+
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
138
|
+
}
|
|
139
|
+
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
140
|
+
if (!respectQueryAndFragment) return input.endsWith("/");
|
|
141
|
+
return TRAILING_SLASH_RE.test(input);
|
|
142
|
+
}
|
|
143
|
+
function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
|
144
|
+
if (!respectQueryAndFragment) return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
|
145
|
+
if (!hasTrailingSlash(input, true)) return input || "/";
|
|
146
|
+
let path = input;
|
|
147
|
+
let fragment = "";
|
|
148
|
+
const fragmentIndex = input.indexOf("#");
|
|
149
|
+
if (fragmentIndex !== -1) {
|
|
150
|
+
path = input.slice(0, fragmentIndex);
|
|
151
|
+
fragment = input.slice(fragmentIndex);
|
|
152
|
+
}
|
|
153
|
+
const [s0, ...s] = path.split("?");
|
|
154
|
+
return ((s0.endsWith("/") ? s0.slice(0, -1) : s0) || "/") + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
155
|
+
}
|
|
156
|
+
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
157
|
+
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
158
|
+
if (hasTrailingSlash(input, true)) return input || "/";
|
|
159
|
+
let path = input;
|
|
160
|
+
let fragment = "";
|
|
161
|
+
const fragmentIndex = input.indexOf("#");
|
|
162
|
+
if (fragmentIndex !== -1) {
|
|
163
|
+
path = input.slice(0, fragmentIndex);
|
|
164
|
+
fragment = input.slice(fragmentIndex);
|
|
165
|
+
if (!path) return fragment;
|
|
166
|
+
}
|
|
167
|
+
const [s0, ...s] = path.split("?");
|
|
168
|
+
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
169
|
+
}
|
|
170
|
+
function withBase(input, base) {
|
|
171
|
+
if (isEmptyURL(base) || hasProtocol(input)) return input;
|
|
49
172
|
const _base = withoutTrailingSlash(base);
|
|
50
|
-
if (input.startsWith(_base))
|
|
173
|
+
if (input.startsWith(_base)) {
|
|
174
|
+
const nextChar = input[_base.length];
|
|
175
|
+
if (!nextChar || nextChar === "/" || nextChar === "?") return input;
|
|
176
|
+
}
|
|
51
177
|
return joinURL(_base, input);
|
|
52
178
|
}
|
|
53
|
-
function withoutTrailingSlash(path) {
|
|
54
|
-
if (!path || path === "/") return "/";
|
|
55
|
-
return path[path.length - 1] === "/" ? path.slice(0, -1) : path;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Returns the URL with the given query parameters. If a query parameter is undefined, it is omitted.
|
|
59
|
-
*/
|
|
60
179
|
function withQuery(input, query) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
180
|
+
const parsed = parseURL(input);
|
|
181
|
+
parsed.search = stringifyQuery({
|
|
182
|
+
...parseQuery(parsed.search),
|
|
183
|
+
...query
|
|
184
|
+
});
|
|
185
|
+
return stringifyParsedURL(parsed);
|
|
186
|
+
}
|
|
187
|
+
function isEmptyURL(url) {
|
|
188
|
+
return !url || url === "/";
|
|
189
|
+
}
|
|
190
|
+
function isNonEmptyURL(url) {
|
|
191
|
+
return url && url !== "/";
|
|
192
|
+
}
|
|
193
|
+
function joinURL(base, ...input) {
|
|
194
|
+
let url = base || "";
|
|
195
|
+
for (const segment of input.filter((url2) => isNonEmptyURL(url2))) if (url) {
|
|
196
|
+
const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
|
|
197
|
+
url = withTrailingSlash(url) + _segment;
|
|
198
|
+
} else url = segment;
|
|
199
|
+
return url;
|
|
200
|
+
}
|
|
201
|
+
const protocolRelative = Symbol.for("ufo:protocolRelative");
|
|
202
|
+
function parseURL(input = "", defaultProto) {
|
|
203
|
+
const _specialProtoMatch = input.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);
|
|
204
|
+
if (_specialProtoMatch) {
|
|
205
|
+
const [, _proto, _pathname = ""] = _specialProtoMatch;
|
|
206
|
+
return {
|
|
207
|
+
protocol: _proto.toLowerCase(),
|
|
208
|
+
pathname: _pathname,
|
|
209
|
+
href: _proto + _pathname,
|
|
210
|
+
auth: "",
|
|
211
|
+
host: "",
|
|
212
|
+
search: "",
|
|
213
|
+
hash: ""
|
|
214
|
+
};
|
|
70
215
|
}
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
216
|
+
if (!hasProtocol(input, { acceptRelative: true })) return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
|
|
217
|
+
const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
|
|
218
|
+
let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
|
|
219
|
+
if (protocol === "file:") path = path.replace(/\/(?=[A-Za-z]:)/, "");
|
|
220
|
+
const { pathname, search, hash } = parsePath(path);
|
|
221
|
+
return {
|
|
222
|
+
protocol: protocol.toLowerCase(),
|
|
223
|
+
auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
|
|
224
|
+
host,
|
|
225
|
+
pathname,
|
|
226
|
+
search,
|
|
227
|
+
hash,
|
|
228
|
+
[protocolRelative]: !protocol
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function parsePath(input = "") {
|
|
232
|
+
const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
|
233
|
+
return {
|
|
234
|
+
pathname,
|
|
235
|
+
search,
|
|
236
|
+
hash
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function stringifyParsedURL(parsed) {
|
|
240
|
+
const pathname = parsed.pathname || "";
|
|
241
|
+
const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
|
|
242
|
+
const hash = parsed.hash || "";
|
|
243
|
+
const auth = parsed.auth ? parsed.auth + "@" : "";
|
|
244
|
+
const host = parsed.host || "";
|
|
245
|
+
return (parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "") + auth + host + pathname + search + hash;
|
|
84
246
|
}
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs
|
|
85
249
|
var FetchError = class extends Error {
|
|
86
250
|
constructor(message, opts) {
|
|
87
251
|
super(message, opts);
|
|
@@ -146,8 +310,8 @@ function detectResponseType(_contentType = "") {
|
|
|
146
310
|
if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
|
|
147
311
|
return "blob";
|
|
148
312
|
}
|
|
149
|
-
function resolveFetchOptions(request, input, defaults, Headers
|
|
150
|
-
const headers = mergeHeaders(input?.headers ?? request?.headers, defaults?.headers, Headers
|
|
313
|
+
function resolveFetchOptions(request, input, defaults, Headers) {
|
|
314
|
+
const headers = mergeHeaders(input?.headers ?? request?.headers, defaults?.headers, Headers);
|
|
151
315
|
let query;
|
|
152
316
|
if (defaults?.query || defaults?.params || input?.params || input?.query) query = {
|
|
153
317
|
...defaults?.params,
|
|
@@ -163,15 +327,17 @@ function resolveFetchOptions(request, input, defaults, Headers$1) {
|
|
|
163
327
|
headers
|
|
164
328
|
};
|
|
165
329
|
}
|
|
166
|
-
function mergeHeaders(input, defaults, Headers
|
|
167
|
-
if (!defaults) return new Headers
|
|
168
|
-
const headers = new Headers
|
|
169
|
-
if (input) for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers
|
|
330
|
+
function mergeHeaders(input, defaults, Headers) {
|
|
331
|
+
if (!defaults) return new Headers(input);
|
|
332
|
+
const headers = new Headers(defaults);
|
|
333
|
+
if (input) for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers(input)) headers.set(key, value);
|
|
170
334
|
return headers;
|
|
171
335
|
}
|
|
172
336
|
async function callHooks(context, hooks) {
|
|
173
|
-
if (hooks)
|
|
174
|
-
|
|
337
|
+
if (hooks) {
|
|
338
|
+
if (Array.isArray(hooks)) for (const hook of hooks) await hook(context);
|
|
339
|
+
else await hooks(context);
|
|
340
|
+
}
|
|
175
341
|
}
|
|
176
342
|
const retryStatusCodes = /* @__PURE__ */ new Set([
|
|
177
343
|
408,
|
|
@@ -190,7 +356,7 @@ const nullBodyResponses = /* @__PURE__ */ new Set([
|
|
|
190
356
|
304
|
|
191
357
|
]);
|
|
192
358
|
function createFetch(globalOptions = {}) {
|
|
193
|
-
const { fetch
|
|
359
|
+
const { fetch = globalThis.fetch, Headers = globalThis.Headers, AbortController = globalThis.AbortController } = globalOptions;
|
|
194
360
|
async function onError(context) {
|
|
195
361
|
const isAbort = context.error && context.error.name === "AbortError" && !context.options.timeout || false;
|
|
196
362
|
if (context.options.retry !== false && !isAbort) {
|
|
@@ -211,7 +377,7 @@ function createFetch(globalOptions = {}) {
|
|
|
211
377
|
if (Error.captureStackTrace) Error.captureStackTrace(error, $fetchRaw);
|
|
212
378
|
throw error;
|
|
213
379
|
}
|
|
214
|
-
const $fetchRaw = async function $
|
|
380
|
+
const $fetchRaw = async function $fetchRaw2(_request, _options = {}) {
|
|
215
381
|
const context = {
|
|
216
382
|
request: _request,
|
|
217
383
|
options: resolveFetchOptions(_request, _options, globalOptions.defaults, Headers),
|
|
@@ -219,7 +385,10 @@ function createFetch(globalOptions = {}) {
|
|
|
219
385
|
error: void 0
|
|
220
386
|
};
|
|
221
387
|
if (context.options.method) context.options.method = context.options.method.toUpperCase();
|
|
222
|
-
if (context.options.onRequest)
|
|
388
|
+
if (context.options.onRequest) {
|
|
389
|
+
await callHooks(context, context.options.onRequest);
|
|
390
|
+
if (!(context.options.headers instanceof Headers)) context.options.headers = new Headers(context.options.headers || {});
|
|
391
|
+
}
|
|
223
392
|
if (typeof context.request === "string") {
|
|
224
393
|
if (context.options.baseURL) context.request = withBase(context.request, context.options.baseURL);
|
|
225
394
|
if (context.options.query) {
|
|
@@ -233,30 +402,39 @@ function createFetch(globalOptions = {}) {
|
|
|
233
402
|
if (isJSONSerializable(context.options.body)) {
|
|
234
403
|
const contentType = context.options.headers.get("content-type");
|
|
235
404
|
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);
|
|
236
|
-
context.options.headers = new Headers(context.options.headers || {});
|
|
237
405
|
if (!contentType) context.options.headers.set("content-type", "application/json");
|
|
238
406
|
if (!context.options.headers.has("accept")) context.options.headers.set("accept", "application/json");
|
|
239
407
|
} else if ("pipeTo" in context.options.body && typeof context.options.body.pipeTo === "function" || typeof context.options.body.pipe === "function") {
|
|
240
408
|
if (!("duplex" in context.options)) context.options.duplex = "half";
|
|
241
409
|
}
|
|
242
410
|
}
|
|
243
|
-
|
|
411
|
+
let abortTimeout;
|
|
412
|
+
if (!context.options.signal && context.options.timeout) {
|
|
413
|
+
const controller = new AbortController();
|
|
414
|
+
abortTimeout = setTimeout(() => {
|
|
415
|
+
const error = /* @__PURE__ */ new Error("[TimeoutError]: The operation was aborted due to timeout");
|
|
416
|
+
error.name = "TimeoutError";
|
|
417
|
+
error.code = 23;
|
|
418
|
+
controller.abort(error);
|
|
419
|
+
}, context.options.timeout);
|
|
420
|
+
context.options.signal = controller.signal;
|
|
421
|
+
}
|
|
244
422
|
try {
|
|
245
|
-
context.response = await fetch
|
|
423
|
+
context.response = await fetch(context.request, context.options);
|
|
246
424
|
} catch (error) {
|
|
247
425
|
context.error = error;
|
|
248
426
|
if (context.options.onRequestError) await callHooks(context, context.options.onRequestError);
|
|
249
427
|
return await onError(context);
|
|
428
|
+
} finally {
|
|
429
|
+
if (abortTimeout) clearTimeout(abortTimeout);
|
|
250
430
|
}
|
|
251
431
|
if ((context.response.body || context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== "HEAD") {
|
|
252
432
|
const responseType = (context.options.parseResponse ? "json" : context.options.responseType) || detectResponseType(context.response.headers.get("content-type") || "");
|
|
253
433
|
switch (responseType) {
|
|
254
434
|
case "json": {
|
|
255
435
|
const data = await context.response.text();
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
context.response._data = parseFunction(data);
|
|
259
|
-
}
|
|
436
|
+
const parseFunction = context.options.parseResponse || destr;
|
|
437
|
+
context.response._data = parseFunction(data);
|
|
260
438
|
break;
|
|
261
439
|
}
|
|
262
440
|
case "stream":
|
|
@@ -272,12 +450,12 @@ function createFetch(globalOptions = {}) {
|
|
|
272
450
|
}
|
|
273
451
|
return context.response;
|
|
274
452
|
};
|
|
275
|
-
const $fetch
|
|
453
|
+
const $fetch = async function $fetch2(request, options) {
|
|
276
454
|
return (await $fetchRaw(request, options))._data;
|
|
277
455
|
};
|
|
278
|
-
$fetch
|
|
279
|
-
$fetch
|
|
280
|
-
$fetch
|
|
456
|
+
$fetch.raw = $fetchRaw;
|
|
457
|
+
$fetch.native = (...args) => fetch(...args);
|
|
458
|
+
$fetch.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({
|
|
281
459
|
...globalOptions,
|
|
282
460
|
...customGlobalOptions,
|
|
283
461
|
defaults: {
|
|
@@ -286,11 +464,25 @@ function createFetch(globalOptions = {}) {
|
|
|
286
464
|
...defaultOptions
|
|
287
465
|
}
|
|
288
466
|
});
|
|
289
|
-
return $fetch
|
|
467
|
+
return $fetch;
|
|
290
468
|
}
|
|
291
469
|
//#endregion
|
|
292
|
-
//#region
|
|
293
|
-
const
|
|
470
|
+
//#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/index.mjs
|
|
471
|
+
const _globalThis = (function() {
|
|
472
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
473
|
+
if (typeof self !== "undefined") return self;
|
|
474
|
+
if (typeof window !== "undefined") return window;
|
|
475
|
+
if (typeof global !== "undefined") return global;
|
|
476
|
+
throw new Error("unable to locate global object");
|
|
477
|
+
})();
|
|
478
|
+
const fetch = _globalThis.fetch ? (...args) => _globalThis.fetch(...args) : () => Promise.reject(/* @__PURE__ */ new Error("[ofetch] global.fetch is not supported!"));
|
|
479
|
+
const Headers = _globalThis.Headers;
|
|
480
|
+
const AbortController = _globalThis.AbortController;
|
|
481
|
+
const $fetch = createFetch({
|
|
482
|
+
fetch,
|
|
483
|
+
Headers,
|
|
484
|
+
AbortController
|
|
485
|
+
});
|
|
294
486
|
//#endregion
|
|
295
487
|
//#region src/client/plugin.ts
|
|
296
488
|
/**
|
package/dist/node/index.d.mts
CHANGED
|
@@ -8,54 +8,54 @@ import { NitroPluginConfig } from "nitro/vite";
|
|
|
8
8
|
import Checker from "vite-plugin-checker";
|
|
9
9
|
import { TSConfig } from "pkg-types";
|
|
10
10
|
//#region src/node/types/layer.d.ts
|
|
11
|
-
interface VixtConfigLayerMeta extends ConfigLayerMeta {
|
|
11
|
+
export interface VixtConfigLayerMeta extends ConfigLayerMeta {
|
|
12
12
|
/** layer name */
|
|
13
13
|
name?: string;
|
|
14
14
|
/** layer alias */
|
|
15
15
|
alias?: string;
|
|
16
16
|
}
|
|
17
|
-
interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta> {
|
|
17
|
+
export interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta> {
|
|
18
18
|
/** when layer is in node_modules, layer will copy to `<buildLayersDir>/<layerName>`, and change cwd */
|
|
19
19
|
cwd?: string;
|
|
20
20
|
}
|
|
21
|
-
interface LoadVixtConfigOptions extends LoadConfigOptions<VixtOptions, VixtConfigLayerMeta> {}
|
|
22
|
-
interface ResolvedVixtConfig extends ResolvedConfig<VixtOptions, VixtConfigLayerMeta> {}
|
|
21
|
+
export interface LoadVixtConfigOptions extends LoadConfigOptions<VixtOptions, VixtConfigLayerMeta> {}
|
|
22
|
+
export interface ResolvedVixtConfig extends ResolvedConfig<VixtOptions, VixtConfigLayerMeta> {}
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/node/types/vixt.d.ts
|
|
25
|
-
interface Vixt {
|
|
25
|
+
export interface Vixt {
|
|
26
26
|
options: VixtOptions;
|
|
27
27
|
_layers: VixtConfigLayer[];
|
|
28
28
|
_modules: VixtModule[];
|
|
29
29
|
}
|
|
30
|
-
type ExtractPluginOptions<Options = any> = Options extends ((...args: any[]) => any) ? Parameters<Options>[0] : Options;
|
|
30
|
+
export type ExtractPluginOptions<Options = any> = Options extends ((...args: any[]) => any) ? Parameters<Options>[0] : Options;
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/node/types/module.d.ts
|
|
33
|
-
type ModuleOptions = Record<string, any>;
|
|
34
|
-
interface ModuleMeta extends Record<string, any> {
|
|
33
|
+
export type ModuleOptions = Record<string, any>;
|
|
34
|
+
export interface ModuleMeta extends Record<string, any> {
|
|
35
35
|
name?: string;
|
|
36
36
|
configKey?: string;
|
|
37
37
|
}
|
|
38
|
-
interface ModuleDefinition<T extends ModuleOptions = ModuleOptions> {
|
|
38
|
+
export interface ModuleDefinition<T extends ModuleOptions = ModuleOptions> {
|
|
39
39
|
meta?: ModuleMeta;
|
|
40
40
|
defaults?: Partial<T> | ((vixt: Vixt) => Partial<T>);
|
|
41
41
|
setup?: (this: void, resolvedOptions: T, vixt: Vixt) => PluginOption | void;
|
|
42
42
|
}
|
|
43
|
-
interface VixtModule<T extends ModuleOptions = ModuleOptions> {
|
|
43
|
+
export interface VixtModule<T extends ModuleOptions = ModuleOptions> {
|
|
44
44
|
(this: void, resolvedOptions: T, vixt: Vixt): PluginOption;
|
|
45
45
|
getOptions?: (inlineOptions: Partial<T>, Vixt: Vixt) => T;
|
|
46
46
|
getMeta?: () => ModuleMeta;
|
|
47
47
|
}
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/node/types/options.d.ts
|
|
50
|
-
interface AliasOptions {
|
|
50
|
+
export interface AliasOptions {
|
|
51
51
|
[find: string]: string;
|
|
52
52
|
}
|
|
53
|
-
interface AppHeadAttrs {
|
|
53
|
+
export interface AppHeadAttrs {
|
|
54
54
|
children?: string;
|
|
55
55
|
injectTo?: HtmlTagDescriptor['injectTo'];
|
|
56
56
|
[key: string]: string | boolean | undefined;
|
|
57
57
|
}
|
|
58
|
-
interface AppHead {
|
|
58
|
+
export interface AppHead {
|
|
59
59
|
title?: AppHeadAttrs[];
|
|
60
60
|
link?: AppHeadAttrs[];
|
|
61
61
|
meta?: AppHeadAttrs[];
|
|
@@ -63,7 +63,7 @@ interface AppHead {
|
|
|
63
63
|
script?: AppHeadAttrs[];
|
|
64
64
|
noscript?: AppHeadAttrs[];
|
|
65
65
|
}
|
|
66
|
-
interface AppOptions {
|
|
66
|
+
export interface AppOptions {
|
|
67
67
|
/**
|
|
68
68
|
* The base path of your Vixt application.
|
|
69
69
|
* @default '/'
|
|
@@ -175,7 +175,7 @@ interface AppOptions {
|
|
|
175
175
|
*/
|
|
176
176
|
transformIndexHtml?: boolean;
|
|
177
177
|
}
|
|
178
|
-
interface BuildOptions {
|
|
178
|
+
export interface BuildOptions {
|
|
179
179
|
/**
|
|
180
180
|
* Set to true to enable bundle analysis, or pass an object with `enabled: true` and options: [vite-bundle-analyzer](https://github.com/nonzzz/vite-bundle-analyzer)
|
|
181
181
|
*/
|
|
@@ -189,7 +189,7 @@ interface BuildOptions {
|
|
|
189
189
|
enabled?: boolean;
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
interface DevServerOptions extends Pick<ServerOptions, 'port' | 'host' | 'cors'> {
|
|
192
|
+
export interface DevServerOptions extends Pick<ServerOptions, 'port' | 'host' | 'cors'> {
|
|
193
193
|
/**
|
|
194
194
|
* Whether to enable HTTPS by using [@vitejs/plugin-basic-ssl](https://github.com/vitejs/vite-plugin-basic-ssl).
|
|
195
195
|
* @default false
|
|
@@ -202,12 +202,12 @@ interface DevServerOptions extends Pick<ServerOptions, 'port' | 'host' | 'cors'>
|
|
|
202
202
|
*/
|
|
203
203
|
watch?: string[];
|
|
204
204
|
}
|
|
205
|
-
interface ImportsOptions extends ExtractPluginOptions<typeof AutoImport> {}
|
|
206
|
-
interface NitroOptions extends Omit<NitroPluginConfig, 'serverDir'> {
|
|
205
|
+
export interface ImportsOptions extends ExtractPluginOptions<typeof AutoImport> {}
|
|
206
|
+
export interface NitroOptions extends Omit<NitroPluginConfig, 'serverDir'> {
|
|
207
207
|
enabled?: boolean;
|
|
208
208
|
serverDir?: Exclude<NitroPluginConfig['serverDir'], boolean>;
|
|
209
209
|
}
|
|
210
|
-
interface TypescriptOptions {
|
|
210
|
+
export interface TypescriptOptions {
|
|
211
211
|
references?: (string | {
|
|
212
212
|
path?: string;
|
|
213
213
|
content?: string;
|
|
@@ -246,7 +246,7 @@ interface TypescriptOptions {
|
|
|
246
246
|
}
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/node/types/config.d.ts
|
|
249
|
-
interface VixtConfig {
|
|
249
|
+
export interface VixtConfig {
|
|
250
250
|
/**
|
|
251
251
|
* You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
|
|
252
252
|
* @default
|
|
@@ -386,7 +386,7 @@ interface VixtConfig {
|
|
|
386
386
|
* it includes some properties that declared in `VueVixtOptions`, `ReactVixtOptions`, etc.,
|
|
387
387
|
* see {@link VixtConfig} to view the common options.
|
|
388
388
|
*/
|
|
389
|
-
interface VixtOptions extends VixtConfig {
|
|
389
|
+
export interface VixtOptions extends VixtConfig {
|
|
390
390
|
/** custom options */
|
|
391
391
|
[key: string]: any;
|
|
392
392
|
}
|
|
@@ -404,27 +404,27 @@ interface VixtOptions extends VixtConfig {
|
|
|
404
404
|
* })
|
|
405
405
|
* ```
|
|
406
406
|
*/
|
|
407
|
-
declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
408
|
-
declare function loadVixtConfig(opts?: LoadVixtConfigOptions): Promise<ResolvedVixtConfig>;
|
|
409
|
-
declare function applyLayers({ config, layers }: ResolvedVixtConfig): VixtConfigLayer[];
|
|
410
|
-
declare function isSamePath(a: string, b: string): boolean;
|
|
411
|
-
declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
|
|
407
|
+
export declare function defineVixtConfig(input: VixtOptions): VixtOptions;
|
|
408
|
+
export declare function loadVixtConfig(opts?: LoadVixtConfigOptions): Promise<ResolvedVixtConfig>;
|
|
409
|
+
export declare function applyLayers({ config, layers }: ResolvedVixtConfig): VixtConfigLayer[];
|
|
410
|
+
export declare function isSamePath(a: string, b: string): boolean;
|
|
411
|
+
export declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
|
|
412
412
|
//#endregion
|
|
413
413
|
//#region src/node/env.d.ts
|
|
414
|
-
declare function loadCLIOptions(): Partial<import("@vixt/cli").VixtArgs>;
|
|
415
|
-
declare function loadMode(): string | undefined;
|
|
414
|
+
export declare function loadCLIOptions(): Partial<import("@vixt/cli").VixtArgs>;
|
|
415
|
+
export declare function loadMode(): string | undefined;
|
|
416
416
|
/**
|
|
417
417
|
* Load workspace and cwd env variables by default
|
|
418
418
|
*/
|
|
419
|
-
declare function loadEnv(mode?: string, envDir?: string | false, prefixes?: string | string[]): ImportMeta["env"];
|
|
419
|
+
export declare function loadEnv(mode?: string, envDir?: string | false, prefixes?: string | string[]): ImportMeta["env"];
|
|
420
420
|
/**
|
|
421
421
|
* find the workspace dir
|
|
422
422
|
*/
|
|
423
|
-
declare function findUpWorkspaceDir(): string | undefined;
|
|
423
|
+
export declare function findUpWorkspaceDir(): string | undefined;
|
|
424
424
|
/**
|
|
425
425
|
* Load workspace env variables
|
|
426
426
|
*/
|
|
427
|
-
declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]): Record<string, string>;
|
|
427
|
+
export declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]): Record<string, string>;
|
|
428
428
|
//#endregion
|
|
429
429
|
//#region src/node/module.d.ts
|
|
430
430
|
/**
|
|
@@ -448,7 +448,7 @@ declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]):
|
|
|
448
448
|
* })
|
|
449
449
|
* ```
|
|
450
450
|
*/
|
|
451
|
-
declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
451
|
+
export declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
|
|
452
452
|
/**
|
|
453
453
|
* Define a Vixt module.
|
|
454
454
|
* @example
|
|
@@ -482,20 +482,19 @@ declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) =
|
|
|
482
482
|
* })
|
|
483
483
|
* ```
|
|
484
484
|
*/
|
|
485
|
-
declare function defineVixtModule<T extends ModuleOptions = ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
486
|
-
declare function installModule<T extends ModuleOptions = ModuleOptions>(module: VixtModule<T>, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
487
|
-
declare function applyLayerModules({ config, layers }: ResolvedVixtConfig): Promise<VixtModule[]>;
|
|
485
|
+
export declare function defineVixtModule<T extends ModuleOptions = ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
|
|
486
|
+
export declare function installModule<T extends ModuleOptions = ModuleOptions>(module: VixtModule<T>, inlineOptions: any, vixt: Vixt): PluginOption;
|
|
487
|
+
export declare function applyLayerModules({ config, layers }: ResolvedVixtConfig): Promise<VixtModule[]>;
|
|
488
488
|
//#endregion
|
|
489
489
|
//#region src/node/modules/index.d.ts
|
|
490
|
-
declare const virtualModuleIds: {
|
|
490
|
+
export declare const virtualModuleIds: {
|
|
491
491
|
appConfig: string | undefined;
|
|
492
492
|
css: string | undefined;
|
|
493
493
|
plugins: string | undefined;
|
|
494
494
|
};
|
|
495
|
-
declare const builtinModules: (VixtModule<ModuleOptions> | VixtModule<AliasOptions> | VixtModule<AppOptions> | VixtModule<BuildOptions> | VixtModule<DevServerOptions> | VixtModule<ImportsOptions> | VixtModule<NitroOptions> | VixtModule<TypescriptOptions>)[];
|
|
495
|
+
export declare const builtinModules: (VixtModule<ModuleOptions> | VixtModule<AliasOptions> | VixtModule<AppOptions> | VixtModule<BuildOptions> | VixtModule<DevServerOptions> | VixtModule<ImportsOptions> | VixtModule<NitroOptions> | VixtModule<TypescriptOptions>)[];
|
|
496
496
|
//#endregion
|
|
497
497
|
//#region src/node/vixt.d.ts
|
|
498
|
-
declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
499
|
-
declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => import("vite").PluginOption;
|
|
500
|
-
//#endregion
|
|
501
|
-
export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, ImportsOptions, LoadVixtConfigOptions, ModuleDefinition, ModuleMeta, ModuleOptions, NitroOptions, ResolvedVixtConfig, TypescriptOptions, Vixt, VixtConfig, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, VixtOptions, applyLayerModules, applyLayers, builtinModules, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, findUpWorkspaceDir, installModule, isSamePath, loadCLIOptions, loadEnv, loadMode, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, virtualModuleIds };
|
|
498
|
+
export declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
|
|
499
|
+
export declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => import("vite").PluginOption;
|
|
500
|
+
//#endregion
|