wevu 6.7.3 → 6.7.4
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/api.d.mts +1 -0
- package/dist/api.mjs +2 -0
- package/dist/compiler.mjs +2 -3
- package/dist/defineProperty-JH0tR899.mjs +39 -0
- package/dist/fetch.d.mts +26 -0
- package/dist/fetch.mjs +345 -0
- package/dist/index-Ciz2Ye1L.d.mts +246 -0
- package/dist/index.d.mts +238 -410
- package/dist/index.mjs +1609 -2560
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/ref-BeA_Is-2.mjs +804 -0
- package/dist/router-5qgy8oOS.mjs +329 -0
- package/dist/router-BxV0btOX.d.mts +46 -0
- package/dist/router.d.mts +192 -0
- package/dist/router.mjs +1412 -0
- package/dist/store-DFP_p2kt.mjs +504 -0
- package/dist/store.d.mts +2 -0
- package/dist/store.mjs +2 -0
- package/package.json +31 -2
- /package/dist/{weappIntrinsicElements-CihhL3Md.d.mts → weappIntrinsicElements-BKiRK0cC.d.mts} +0 -0
package/dist/api.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@wevu/api";
|
package/dist/api.mjs
ADDED
package/dist/compiler.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from "@wevu/compiler"
|
|
2
|
-
|
|
3
|
-
export { };
|
|
1
|
+
export * from "@wevu/compiler";
|
|
2
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
|
|
12
|
+
function toPrimitive(t, r) {
|
|
13
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
14
|
+
var e = t[Symbol.toPrimitive];
|
|
15
|
+
if (void 0 !== e) {
|
|
16
|
+
var i = e.call(t, r || "default");
|
|
17
|
+
if ("object" != _typeof(i)) return i;
|
|
18
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
19
|
+
}
|
|
20
|
+
return ("string" === r ? String : Number)(t);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
|
|
24
|
+
function toPropertyKey(t) {
|
|
25
|
+
var i = toPrimitive(t, "string");
|
|
26
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
|
|
30
|
+
function _defineProperty(e, r, t) {
|
|
31
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
32
|
+
value: t,
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
configurable: !0,
|
|
35
|
+
writable: !0
|
|
36
|
+
}) : e[r] = t, e;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { _defineProperty as t };
|
package/dist/fetch.d.mts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/fetch.d.ts
|
|
2
|
+
interface WevuFetchInit {
|
|
3
|
+
method?: string;
|
|
4
|
+
headers?: unknown;
|
|
5
|
+
body?: unknown;
|
|
6
|
+
signal?: AbortSignal | null;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
interface RequestLikeInput {
|
|
10
|
+
url: string;
|
|
11
|
+
method?: string;
|
|
12
|
+
headers?: unknown;
|
|
13
|
+
signal?: AbortSignal | null;
|
|
14
|
+
bodyUsed?: boolean;
|
|
15
|
+
clone?: () => {
|
|
16
|
+
arrayBuffer?: () => Promise<ArrayBuffer>;
|
|
17
|
+
text?: () => Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
type WevuFetchInput = string | URL | RequestLikeInput;
|
|
21
|
+
/**
|
|
22
|
+
* @description 使用 @wevu/api 的 request 能力实现 fetch 语义对齐
|
|
23
|
+
*/
|
|
24
|
+
declare function fetch(input: WevuFetchInput, init?: WevuFetchInit): Promise<Response>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { WevuFetchInit, fetch };
|
package/dist/fetch.mjs
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { t as _defineProperty } from "./defineProperty-JH0tR899.mjs";
|
|
2
|
+
import { wpi } from "@wevu/api";
|
|
3
|
+
//#region src/fetch.ts
|
|
4
|
+
let _Symbol$iterator, _Symbol$toStringTag;
|
|
5
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
6
|
+
const REQUEST_METHODS = [
|
|
7
|
+
"GET",
|
|
8
|
+
"HEAD",
|
|
9
|
+
"OPTIONS",
|
|
10
|
+
"POST",
|
|
11
|
+
"PUT",
|
|
12
|
+
"DELETE",
|
|
13
|
+
"TRACE",
|
|
14
|
+
"CONNECT"
|
|
15
|
+
];
|
|
16
|
+
function isObject(value) {
|
|
17
|
+
return typeof value === "object" && value !== null;
|
|
18
|
+
}
|
|
19
|
+
function createAbortError() {
|
|
20
|
+
if (typeof DOMException === "function") return new DOMException("The operation was aborted.", "AbortError");
|
|
21
|
+
const error = /* @__PURE__ */ new Error("The operation was aborted.");
|
|
22
|
+
error.name = "AbortError";
|
|
23
|
+
return error;
|
|
24
|
+
}
|
|
25
|
+
function normalizeMethod(method) {
|
|
26
|
+
const normalized = (method !== null && method !== void 0 ? method : "GET").toUpperCase();
|
|
27
|
+
if (REQUEST_METHODS.includes(normalized)) return normalized;
|
|
28
|
+
return "GET";
|
|
29
|
+
}
|
|
30
|
+
function setHeader(target, key, value) {
|
|
31
|
+
const headerName = key.trim();
|
|
32
|
+
if (!headerName) return;
|
|
33
|
+
const normalizedValue = String(value);
|
|
34
|
+
for (const existingKey of Object.keys(target)) if (existingKey.toLowerCase() === headerName.toLowerCase() && existingKey !== headerName) {
|
|
35
|
+
delete target[existingKey];
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
target[headerName] = normalizedValue;
|
|
39
|
+
}
|
|
40
|
+
function hasHeader(target, key) {
|
|
41
|
+
const normalized = key.toLowerCase();
|
|
42
|
+
return Object.keys(target).some((item) => item.toLowerCase() === normalized);
|
|
43
|
+
}
|
|
44
|
+
function mergeHeaderSource(target, source) {
|
|
45
|
+
if (!source) return;
|
|
46
|
+
if (typeof source.forEach === "function") {
|
|
47
|
+
source.forEach((value, key) => {
|
|
48
|
+
setHeader(target, key, value);
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (typeof source[Symbol.iterator] === "function") {
|
|
53
|
+
for (const item of source) {
|
|
54
|
+
if (!item || item.length < 2) continue;
|
|
55
|
+
setHeader(target, item[0], item[1]);
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (isObject(source)) for (const [key, value] of Object.entries(source)) {
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
setHeader(target, key, value.join(", "));
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
setHeader(target, key, value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function toHeaderMap(source) {
|
|
68
|
+
const headers = {};
|
|
69
|
+
mergeHeaderSource(headers, source);
|
|
70
|
+
return headers;
|
|
71
|
+
}
|
|
72
|
+
function encodeText(text) {
|
|
73
|
+
if (typeof TextEncoder === "function") return new TextEncoder().encode(text).buffer;
|
|
74
|
+
const bytes = new Uint8Array(text.length);
|
|
75
|
+
for (let i = 0; i < text.length; i++) bytes[i] = text.charCodeAt(i) & 255;
|
|
76
|
+
return bytes.buffer;
|
|
77
|
+
}
|
|
78
|
+
function decodeText(buffer) {
|
|
79
|
+
if (typeof TextDecoder === "function") return new TextDecoder().decode(buffer);
|
|
80
|
+
const view = new Uint8Array(buffer);
|
|
81
|
+
let text = "";
|
|
82
|
+
for (const byte of view) text += String.fromCharCode(byte);
|
|
83
|
+
return text;
|
|
84
|
+
}
|
|
85
|
+
function cloneBuffer(buffer) {
|
|
86
|
+
return buffer.slice(0);
|
|
87
|
+
}
|
|
88
|
+
function cloneViewBuffer(view) {
|
|
89
|
+
const copied = new Uint8Array(view.byteLength);
|
|
90
|
+
copied.set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
|
|
91
|
+
return copied.buffer;
|
|
92
|
+
}
|
|
93
|
+
function isRequestLikeInput(input) {
|
|
94
|
+
return isObject(input) && typeof input.url === "string";
|
|
95
|
+
}
|
|
96
|
+
async function extractRequestBodyFromInput(input) {
|
|
97
|
+
if (!input || typeof input.clone !== "function") return;
|
|
98
|
+
if (input.bodyUsed) throw new TypeError("Failed to execute fetch: request body is already used");
|
|
99
|
+
const cloned = input.clone();
|
|
100
|
+
if (cloned === null || cloned === void 0 ? void 0 : cloned.arrayBuffer) return cloned.arrayBuffer();
|
|
101
|
+
if (cloned === null || cloned === void 0 ? void 0 : cloned.text) return cloned.text();
|
|
102
|
+
}
|
|
103
|
+
async function normalizeRequestBody(body, headers) {
|
|
104
|
+
if (body == null) return;
|
|
105
|
+
if (typeof body === "string") {
|
|
106
|
+
if (!hasHeader(headers, "content-type")) headers["content-type"] = "text/plain;charset=UTF-8";
|
|
107
|
+
return body;
|
|
108
|
+
}
|
|
109
|
+
if (typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams) {
|
|
110
|
+
if (!hasHeader(headers, "content-type")) headers["content-type"] = "application/x-www-form-urlencoded;charset=UTF-8";
|
|
111
|
+
return body.toString();
|
|
112
|
+
}
|
|
113
|
+
if (body instanceof ArrayBuffer) return cloneBuffer(body);
|
|
114
|
+
if (ArrayBuffer.isView(body)) return cloneViewBuffer(body);
|
|
115
|
+
if (typeof Blob !== "undefined" && body instanceof Blob) {
|
|
116
|
+
if (body.type && !hasHeader(headers, "content-type")) headers["content-type"] = body.type;
|
|
117
|
+
return body.arrayBuffer();
|
|
118
|
+
}
|
|
119
|
+
if (typeof FormData !== "undefined" && body instanceof FormData) throw new TypeError("Failed to execute fetch: FormData body is not supported in wevu/fetch");
|
|
120
|
+
return String(body);
|
|
121
|
+
}
|
|
122
|
+
async function resolveRequestMeta(input, init = {}) {
|
|
123
|
+
var _init$method, _ref, _init$signal;
|
|
124
|
+
const requestInput = isRequestLikeInput(input) ? input : void 0;
|
|
125
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : requestInput === null || requestInput === void 0 ? void 0 : requestInput.url;
|
|
126
|
+
if (!url) throw new TypeError("Failed to execute fetch: invalid request url");
|
|
127
|
+
const method = normalizeMethod((_init$method = init.method) !== null && _init$method !== void 0 ? _init$method : requestInput === null || requestInput === void 0 ? void 0 : requestInput.method);
|
|
128
|
+
const headers = toHeaderMap(requestInput === null || requestInput === void 0 ? void 0 : requestInput.headers);
|
|
129
|
+
mergeHeaderSource(headers, init.headers);
|
|
130
|
+
const rawBody = hasOwn.call(init, "body") ? init.body : await extractRequestBodyFromInput(requestInput);
|
|
131
|
+
if ((method === "GET" || method === "HEAD") && rawBody != null) throw new TypeError("Failed to execute fetch: GET/HEAD request cannot have body");
|
|
132
|
+
return {
|
|
133
|
+
url,
|
|
134
|
+
method,
|
|
135
|
+
headers,
|
|
136
|
+
body: await normalizeRequestBody(rawBody, headers),
|
|
137
|
+
signal: (_ref = (_init$signal = init.signal) !== null && _init$signal !== void 0 ? _init$signal : requestInput === null || requestInput === void 0 ? void 0 : requestInput.signal) !== null && _ref !== void 0 ? _ref : null
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function readResponseDataAsArrayBuffer(data) {
|
|
141
|
+
if (data == null) return Promise.resolve(/* @__PURE__ */ new ArrayBuffer(0));
|
|
142
|
+
if (data instanceof ArrayBuffer) return Promise.resolve(cloneBuffer(data));
|
|
143
|
+
if (ArrayBuffer.isView(data)) {
|
|
144
|
+
const view = data;
|
|
145
|
+
return Promise.resolve(cloneViewBuffer(view));
|
|
146
|
+
}
|
|
147
|
+
if (typeof data === "string") return Promise.resolve(encodeText(data));
|
|
148
|
+
if (typeof Blob !== "undefined" && data instanceof Blob) return data.arrayBuffer();
|
|
149
|
+
return Promise.resolve(encodeText(JSON.stringify(data)));
|
|
150
|
+
}
|
|
151
|
+
_Symbol$iterator = Symbol.iterator;
|
|
152
|
+
var WevuHeadersFallback = class {
|
|
153
|
+
constructor(init) {
|
|
154
|
+
_defineProperty(this, "store", /* @__PURE__ */ new Map());
|
|
155
|
+
if (!init) return;
|
|
156
|
+
for (const [key, value] of Object.entries(init)) this.set(key, value);
|
|
157
|
+
}
|
|
158
|
+
append(key, value) {
|
|
159
|
+
const current = this.get(key);
|
|
160
|
+
if (!current) {
|
|
161
|
+
this.set(key, value);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.set(key, `${current}, ${value}`);
|
|
165
|
+
}
|
|
166
|
+
set(key, value) {
|
|
167
|
+
const normalized = key.toLowerCase();
|
|
168
|
+
this.store.set(normalized, {
|
|
169
|
+
key,
|
|
170
|
+
value
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
get(key) {
|
|
174
|
+
var _this$store$get$value, _this$store$get;
|
|
175
|
+
return (_this$store$get$value = (_this$store$get = this.store.get(key.toLowerCase())) === null || _this$store$get === void 0 ? void 0 : _this$store$get.value) !== null && _this$store$get$value !== void 0 ? _this$store$get$value : null;
|
|
176
|
+
}
|
|
177
|
+
has(key) {
|
|
178
|
+
return this.store.has(key.toLowerCase());
|
|
179
|
+
}
|
|
180
|
+
delete(key) {
|
|
181
|
+
this.store.delete(key.toLowerCase());
|
|
182
|
+
}
|
|
183
|
+
forEach(callback) {
|
|
184
|
+
for (const item of this.store.values()) callback(item.value, item.key);
|
|
185
|
+
}
|
|
186
|
+
entries() {
|
|
187
|
+
return Array.from(this.store.values(), (item) => [item.key, item.value])[Symbol.iterator]();
|
|
188
|
+
}
|
|
189
|
+
keys() {
|
|
190
|
+
return Array.from(this.store.values(), (item) => item.key)[Symbol.iterator]();
|
|
191
|
+
}
|
|
192
|
+
values() {
|
|
193
|
+
return Array.from(this.store.values(), (item) => item.value)[Symbol.iterator]();
|
|
194
|
+
}
|
|
195
|
+
[_Symbol$iterator]() {
|
|
196
|
+
return this.entries();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
function createHeadersContainer(headers) {
|
|
200
|
+
if (typeof Headers === "function") return new Headers(headers);
|
|
201
|
+
return new WevuHeadersFallback(headers);
|
|
202
|
+
}
|
|
203
|
+
function cloneHeadersToMap(headers) {
|
|
204
|
+
const result = {};
|
|
205
|
+
headers.forEach((value, key) => {
|
|
206
|
+
setHeader(result, key, value);
|
|
207
|
+
});
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
211
|
+
var WevuResponseFallback = class WevuResponseFallback {
|
|
212
|
+
constructor(data, options) {
|
|
213
|
+
_defineProperty(this, "consumed", false);
|
|
214
|
+
_defineProperty(this, "responseData", void 0);
|
|
215
|
+
_defineProperty(this, "headers", void 0);
|
|
216
|
+
_defineProperty(this, "ok", void 0);
|
|
217
|
+
_defineProperty(this, "redirected", false);
|
|
218
|
+
_defineProperty(this, "status", void 0);
|
|
219
|
+
_defineProperty(this, "statusText", "");
|
|
220
|
+
_defineProperty(this, "type", "basic");
|
|
221
|
+
_defineProperty(this, "url", void 0);
|
|
222
|
+
_defineProperty(this, "body", null);
|
|
223
|
+
_defineProperty(this, _Symbol$toStringTag, "Response");
|
|
224
|
+
this.responseData = data;
|
|
225
|
+
this.status = options.status;
|
|
226
|
+
this.url = options.url;
|
|
227
|
+
this.ok = this.status >= 200 && this.status < 300;
|
|
228
|
+
this.headers = createHeadersContainer(options.headers);
|
|
229
|
+
}
|
|
230
|
+
get bodyUsed() {
|
|
231
|
+
return this.consumed;
|
|
232
|
+
}
|
|
233
|
+
consumeBody(reader) {
|
|
234
|
+
if (this.consumed) return Promise.reject(/* @__PURE__ */ new TypeError("Failed to execute fetch: body stream already read"));
|
|
235
|
+
this.consumed = true;
|
|
236
|
+
return reader();
|
|
237
|
+
}
|
|
238
|
+
arrayBuffer() {
|
|
239
|
+
return this.consumeBody(() => readResponseDataAsArrayBuffer(this.responseData));
|
|
240
|
+
}
|
|
241
|
+
blob() {
|
|
242
|
+
return this.consumeBody(async () => {
|
|
243
|
+
if (typeof Blob !== "function") throw new TypeError("Blob is unavailable in current runtime");
|
|
244
|
+
const arrayBuffer = await readResponseDataAsArrayBuffer(this.responseData);
|
|
245
|
+
return new Blob([arrayBuffer]);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
formData() {
|
|
249
|
+
return this.consumeBody(async () => {
|
|
250
|
+
throw new TypeError("formData is not supported in wevu/fetch response fallback");
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
json() {
|
|
254
|
+
return this.consumeBody(async () => {
|
|
255
|
+
if (isObject(this.responseData) || Array.isArray(this.responseData)) return this.responseData;
|
|
256
|
+
const text = await this.textFromRaw();
|
|
257
|
+
return JSON.parse(text);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
text() {
|
|
261
|
+
return this.consumeBody(() => this.textFromRaw());
|
|
262
|
+
}
|
|
263
|
+
clone() {
|
|
264
|
+
return new WevuResponseFallback(this.responseData, {
|
|
265
|
+
headers: cloneHeadersToMap(this.headers),
|
|
266
|
+
status: this.status,
|
|
267
|
+
url: this.url
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
async textFromRaw() {
|
|
271
|
+
if (typeof this.responseData === "string") return this.responseData;
|
|
272
|
+
return decodeText(await readResponseDataAsArrayBuffer(this.responseData));
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
function createFetchResponse(data, status, headers, url) {
|
|
276
|
+
if (typeof Response === "function") {
|
|
277
|
+
const nativeBody = typeof data === "string" ? data : data instanceof ArrayBuffer ? data : ArrayBuffer.isView(data) ? cloneViewBuffer(data) : JSON.stringify(data !== null && data !== void 0 ? data : "");
|
|
278
|
+
const normalizedStatus = Number.isFinite(status) && status >= 200 && status <= 599 ? status : 200;
|
|
279
|
+
try {
|
|
280
|
+
return new Response(nativeBody, {
|
|
281
|
+
status: normalizedStatus,
|
|
282
|
+
headers
|
|
283
|
+
});
|
|
284
|
+
} catch (_unused) {}
|
|
285
|
+
}
|
|
286
|
+
return new WevuResponseFallback(data, {
|
|
287
|
+
headers,
|
|
288
|
+
status,
|
|
289
|
+
url
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function isRequestTask(value) {
|
|
293
|
+
return isObject(value) && typeof value.abort === "function";
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* @description 使用 @wevu/api 的 request 能力实现 fetch 语义对齐
|
|
297
|
+
*/
|
|
298
|
+
function fetch(input, init) {
|
|
299
|
+
return resolveRequestMeta(input, init).then((meta) => {
|
|
300
|
+
var _meta$signal;
|
|
301
|
+
if ((_meta$signal = meta.signal) === null || _meta$signal === void 0 ? void 0 : _meta$signal.aborted) return Promise.reject(createAbortError());
|
|
302
|
+
return new Promise((resolve, reject) => {
|
|
303
|
+
let settled = false;
|
|
304
|
+
let aborted = false;
|
|
305
|
+
const onAbort = () => {
|
|
306
|
+
if (settled) return;
|
|
307
|
+
aborted = true;
|
|
308
|
+
requestTask === null || requestTask === void 0 || requestTask.abort();
|
|
309
|
+
settled = true;
|
|
310
|
+
reject(createAbortError());
|
|
311
|
+
};
|
|
312
|
+
if (meta.signal) meta.signal.addEventListener("abort", onAbort, { once: true });
|
|
313
|
+
const cleanup = () => {
|
|
314
|
+
if (meta.signal) meta.signal.removeEventListener("abort", onAbort);
|
|
315
|
+
};
|
|
316
|
+
const requestResult = wpi.request({
|
|
317
|
+
url: meta.url,
|
|
318
|
+
method: meta.method,
|
|
319
|
+
header: meta.headers,
|
|
320
|
+
data: meta.body,
|
|
321
|
+
responseType: "arraybuffer",
|
|
322
|
+
success: (res) => {
|
|
323
|
+
if (settled) return;
|
|
324
|
+
settled = true;
|
|
325
|
+
cleanup();
|
|
326
|
+
resolve(createFetchResponse(res.data, res.statusCode, toHeaderMap(res.header), meta.url));
|
|
327
|
+
},
|
|
328
|
+
fail: (err) => {
|
|
329
|
+
if (settled) return;
|
|
330
|
+
settled = true;
|
|
331
|
+
cleanup();
|
|
332
|
+
if (aborted) {
|
|
333
|
+
reject(createAbortError());
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const message = isObject(err) && typeof err.errMsg === "string" ? err.errMsg : String(err);
|
|
337
|
+
reject(new TypeError(message));
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
const requestTask = isRequestTask(requestResult) ? requestResult : void 0;
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
//#endregion
|
|
345
|
+
export { fetch };
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { AllowedComponentProps, ComponentCustomProps, ComponentOptionsMixin, ComputedOptions, DefineComponent, EmitsOptions, MethodOptions, ObjectDirective, PublicProps, Ref, ShallowRef, ShallowUnwrapRef, SlotsType, VNode, VNodeProps } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/types/props/propTypes.d.ts
|
|
4
|
+
type PropMethod<T, TConstructor = any> = [T] extends [((...args: any) => any) | undefined] ? {
|
|
5
|
+
new (): TConstructor;
|
|
6
|
+
(): T;
|
|
7
|
+
readonly prototype: TConstructor;
|
|
8
|
+
} : never;
|
|
9
|
+
type PropConstructor<T = any> = {
|
|
10
|
+
new (...args: any[]): T & {};
|
|
11
|
+
} | {
|
|
12
|
+
(): T;
|
|
13
|
+
} | PropMethod<T>;
|
|
14
|
+
type PropType<T> = PropConstructor<T> | (PropConstructor<T> | null)[];
|
|
15
|
+
type Prop<T, D = T> = PropOptions<T, D> | PropType<T>;
|
|
16
|
+
type ComponentPropsOptions = Record<string, PropOptions<any> | PropType<any> | null>;
|
|
17
|
+
interface NativeTypeHint<T = any> {
|
|
18
|
+
readonly __wevuNativeType?: T;
|
|
19
|
+
}
|
|
20
|
+
type NativePropsOptions = Record<string, WechatMiniprogram.Component.AllProperty | NativeTypeHint<any>>;
|
|
21
|
+
type NativePropType<T = any, C extends WechatMiniprogram.Component.ShortProperty = StringConstructor> = C & NativeTypeHint<T>;
|
|
22
|
+
type NativeTypedProperty<T = any, P extends WechatMiniprogram.Component.AllProperty = WechatMiniprogram.Component.AllProperty> = P & NativeTypeHint<T>;
|
|
23
|
+
interface PropOptions<T = any, D = T> {
|
|
24
|
+
type?: PropType<T> | true | null;
|
|
25
|
+
optionalTypes?: Array<WechatMiniprogram.Component.ShortProperty | PropConstructor<any>>;
|
|
26
|
+
/**
|
|
27
|
+
* 默认值(对齐 Vue 的 `default`;会被赋给小程序 property 的 `value`)
|
|
28
|
+
*/
|
|
29
|
+
default?: D | (() => D);
|
|
30
|
+
/**
|
|
31
|
+
* 小程序 `value` 的别名
|
|
32
|
+
*/
|
|
33
|
+
value?: D | (() => D);
|
|
34
|
+
observer?: string | ((newVal: T, oldVal: T, changedPath: Array<string | number>) => void);
|
|
35
|
+
required?: boolean;
|
|
36
|
+
}
|
|
37
|
+
type HasDefault<T> = T extends {
|
|
38
|
+
default: infer D;
|
|
39
|
+
} ? D extends (() => undefined) | undefined ? false : true : T extends {
|
|
40
|
+
value: infer V;
|
|
41
|
+
} ? V extends (() => undefined) | undefined ? false : true : false;
|
|
42
|
+
type IsBooleanProp<T> = T extends {
|
|
43
|
+
type?: infer U;
|
|
44
|
+
} ? IsBooleanProp<U> : T extends readonly any[] ? true extends IsBooleanProp<T[number]> ? true : false : T extends BooleanConstructor ? true : false;
|
|
45
|
+
type RequiredKeys<T> = { [K in keyof T]: T[K] extends {
|
|
46
|
+
required: true;
|
|
47
|
+
} ? K : HasDefault<T[K]> extends true ? K : IsBooleanProp<T[K]> extends true ? K : never }[keyof T];
|
|
48
|
+
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
|
|
49
|
+
type DefaultKeys<T> = { [K in keyof T]: HasDefault<T[K]> extends true ? K : IsBooleanProp<T[K]> extends true ? K : never }[keyof T];
|
|
50
|
+
type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N;
|
|
51
|
+
type InferPropType<O, NullAsAny = true> = [O] extends [null] ? NullAsAny extends true ? any : null : [O] extends [{
|
|
52
|
+
type: null | true;
|
|
53
|
+
}] ? any : [O] extends [ObjectConstructor | {
|
|
54
|
+
type: ObjectConstructor;
|
|
55
|
+
}] ? Record<string, any> : [O] extends [BooleanConstructor | {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
}] ? boolean : [O] extends [DateConstructor | {
|
|
58
|
+
type: DateConstructor;
|
|
59
|
+
}] ? Date : [O] extends [(infer U)[] | {
|
|
60
|
+
type: (infer U)[];
|
|
61
|
+
}] ? U extends DateConstructor ? Date | InferPropType<U, false> : InferPropType<U, false> : [O] extends [Prop<infer V, infer D>] ? unknown extends V ? keyof V extends never ? IfAny<V, V, D> : V : V : O;
|
|
62
|
+
type IsUnion<T, U = T> = T extends any ? ([U] extends [T] ? false : true) : never;
|
|
63
|
+
type WidenLiteral<T> = T extends string ? string extends T ? string : IsUnion<T> extends true ? T : string : T extends number ? number extends T ? number : IsUnion<T> extends true ? T : number : T extends boolean ? boolean extends T ? boolean : IsUnion<T> extends true ? T : boolean : T;
|
|
64
|
+
type NativeInferByCtor<C> = C extends readonly any[] ? NativeInferByCtor<C[number]> : C extends StringConstructor ? string : C extends NumberConstructor ? number : C extends BooleanConstructor ? boolean : C extends DateConstructor ? Date : C extends ArrayConstructor ? any[] : C extends ObjectConstructor ? Record<string, any> : C extends null ? any : C extends PropConstructor<infer V> ? V : any;
|
|
65
|
+
type MergeNativeType<Base, V> = Base extends string ? Exclude<Extract<WidenLiteral<V>, string>, never> | (Extract<WidenLiteral<V>, string> extends never ? string : never) : Base extends number ? Exclude<Extract<WidenLiteral<V>, number>, never> | (Extract<WidenLiteral<V>, number> extends never ? number : never) : Base extends boolean ? Exclude<Extract<WidenLiteral<V>, boolean>, never> | (Extract<WidenLiteral<V>, boolean> extends never ? boolean : never) : Base;
|
|
66
|
+
type InferNativeByOption<O extends {
|
|
67
|
+
type?: any;
|
|
68
|
+
}> = O['type'] extends NativeTypeHint<infer THint> ? THint : O extends {
|
|
69
|
+
value: infer V;
|
|
70
|
+
} ? MergeNativeType<NativeInferByCtor<O['type']>, V> : NativeInferByCtor<O['type']>;
|
|
71
|
+
type InferNativePropType<O> = O extends NativeTypeHint<infer T> ? T : O extends {
|
|
72
|
+
type?: any;
|
|
73
|
+
} ? InferNativeByOption<O> : NativeInferByCtor<O>;
|
|
74
|
+
type InferNativeProps<P extends NativePropsOptions = NativePropsOptions> = { readonly [K in keyof P]?: InferNativePropType<P[K]> };
|
|
75
|
+
type InferProps<P extends ComponentPropsOptions = ComponentPropsOptions> = { [K in keyof Pick<P, RequiredKeys<P>>]: HasDefault<P[K]> extends true ? Exclude<InferPropType<P[K]>, undefined> : InferPropType<P[K]> } & { [K in keyof Pick<P, OptionalKeys<P>>]?: InferPropType<P[K]> };
|
|
76
|
+
type ExtractPropTypes<P extends ComponentPropsOptions = ComponentPropsOptions> = InferProps<P>;
|
|
77
|
+
type ExtractPublicPropTypes<P extends ComponentPropsOptions = ComponentPropsOptions> = InferProps<P>;
|
|
78
|
+
type ExtractDefaultPropTypes<P extends ComponentPropsOptions = ComponentPropsOptions> = { [K in keyof Pick<P, DefaultKeys<P>>]: InferPropType<P[K]> };
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/reactivity/ref.d.ts
|
|
81
|
+
type Ref$2<T = any, S = T> = Ref$1<T, S>;
|
|
82
|
+
type ShallowRef$2<T = any> = ShallowRef$1<T>;
|
|
83
|
+
type MaybeRef<T = any> = T | Ref$2<T> | ShallowRef$2<T> | WritableComputedRef<T>;
|
|
84
|
+
type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
|
|
85
|
+
declare function isRef(value: unknown): value is Ref$2<any>;
|
|
86
|
+
declare function ref<T = any>(): Ref$2<T | undefined>;
|
|
87
|
+
declare function ref<T>(value: T): Ref$2<T>;
|
|
88
|
+
declare function unref<T>(value: MaybeRef<T> | ComputedRef<T>): T;
|
|
89
|
+
declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
|
|
90
|
+
/**
|
|
91
|
+
* 自定义 ref 工厂:用于创建可显式控制 track/trigger 的自定义 ref
|
|
92
|
+
*/
|
|
93
|
+
type CustomRefFactory<T> = (track: () => void, trigger: () => void) => {
|
|
94
|
+
get: () => T;
|
|
95
|
+
set: (value: T) => void;
|
|
96
|
+
};
|
|
97
|
+
interface CustomRefOptions<T> {
|
|
98
|
+
get: () => T;
|
|
99
|
+
set: (value: T) => void;
|
|
100
|
+
}
|
|
101
|
+
type CustomRefSource<T> = CustomRefFactory<T> | CustomRefOptions<T>;
|
|
102
|
+
declare function customRef<T>(factory: CustomRefSource<T>, defaultValue?: T): Ref$2<T>;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/reactivity/computed.d.ts
|
|
105
|
+
type ComputedGetter<T> = () => T;
|
|
106
|
+
type ComputedSetter<T> = (value: T) => void;
|
|
107
|
+
interface BaseComputedRef<T, S = T> extends Ref$2<T, S> {
|
|
108
|
+
[key: symbol]: any;
|
|
109
|
+
}
|
|
110
|
+
interface ComputedRef<T = any> extends BaseComputedRef<T> {
|
|
111
|
+
readonly value: T;
|
|
112
|
+
}
|
|
113
|
+
interface WritableComputedRef<T, S = T> extends BaseComputedRef<T, S> {
|
|
114
|
+
value: T;
|
|
115
|
+
}
|
|
116
|
+
interface WritableComputedOptions<T> {
|
|
117
|
+
get: ComputedGetter<T>;
|
|
118
|
+
set: ComputedSetter<T>;
|
|
119
|
+
}
|
|
120
|
+
declare function computed<T>(getter: ComputedGetter<T>): ComputedRef<T>;
|
|
121
|
+
declare function computed<T>(options: WritableComputedOptions<T>): WritableComputedRef<T>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/vue-types.d.ts
|
|
124
|
+
type Ref$1<T = any, S = T> = Ref<T, S>;
|
|
125
|
+
type ShallowRef$1<T = any, S = T> = ShallowRef<T, S>;
|
|
126
|
+
type AllowedComponentProps$1 = AllowedComponentProps;
|
|
127
|
+
type ComponentCustomProps$1 = ComponentCustomProps;
|
|
128
|
+
type ComponentOptionsMixin$1 = ComponentOptionsMixin;
|
|
129
|
+
type DefineComponent$1<PropsOrPropOptions = ComponentPropsOptions, RawBindings = Record<string, any>, D = Record<string, any>, C extends ComputedOptions = ComputedOptions, M extends MethodOptions = MethodOptions, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, PP = PublicProps, Props = (PropsOrPropOptions extends ComponentPropsOptions ? ExtractPropTypes<PropsOrPropOptions> : PropsOrPropOptions), Defaults = (PropsOrPropOptions extends ComponentPropsOptions ? ExtractDefaultPropTypes<PropsOrPropOptions> : {}), S extends SlotsType = SlotsType> = DefineComponent<PropsOrPropOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, PP, Props, Defaults, S>;
|
|
130
|
+
type NativeComponent<Props = Record<string, any>> = new (...args: any[]) => InstanceType<DefineComponent$1<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Props, {}>>;
|
|
131
|
+
type ObjectDirective$1<HostElement = any, Value = any, Modifiers extends string = string, Arg = any> = ObjectDirective<HostElement, Value, Modifiers, Arg>;
|
|
132
|
+
type PublicProps$1 = PublicProps;
|
|
133
|
+
type ShallowUnwrapRef$1<T> = ShallowUnwrapRef<T>;
|
|
134
|
+
type VNode$1<HostNode = any, HostElement = any, ExtraProps = Record<string, any>> = VNode<HostNode, HostElement, ExtraProps>;
|
|
135
|
+
type VNodeProps$1 = VNodeProps;
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/store/types.d.ts
|
|
138
|
+
/**
|
|
139
|
+
* @description Store 变更类型
|
|
140
|
+
*/
|
|
141
|
+
type MutationType = 'patch object' | 'patch function' | 'direct';
|
|
142
|
+
/**
|
|
143
|
+
* @description Store 订阅回调签名
|
|
144
|
+
*/
|
|
145
|
+
interface SubscriptionCallback<S = any> {
|
|
146
|
+
(mutation: {
|
|
147
|
+
type: MutationType;
|
|
148
|
+
storeId: string;
|
|
149
|
+
}, state: S): void;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @description Store 订阅选项
|
|
153
|
+
*/
|
|
154
|
+
interface StoreSubscribeOptions {
|
|
155
|
+
/**
|
|
156
|
+
* @description 是否在卸载后仍保留订阅(适用于跨页面生命周期的订阅)
|
|
157
|
+
*/
|
|
158
|
+
detached?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @description Action 订阅回调上下文
|
|
162
|
+
*/
|
|
163
|
+
interface ActionContext<TStore = any> {
|
|
164
|
+
name: string;
|
|
165
|
+
store: TStore;
|
|
166
|
+
args: any[];
|
|
167
|
+
after: (cb: (result: any) => void) => void;
|
|
168
|
+
onError: (cb: (error: any) => void) => void;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @description Action 订阅回调类型
|
|
172
|
+
*/
|
|
173
|
+
interface ActionSubscriber<TStore = any> {
|
|
174
|
+
(context: ActionContext<TStore>): void;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @description Store 管理器(插件与共享实例)
|
|
178
|
+
*/
|
|
179
|
+
interface StoreManager {
|
|
180
|
+
install: (app: any) => void;
|
|
181
|
+
_stores: Map<string, any>;
|
|
182
|
+
use: (plugin: (context: {
|
|
183
|
+
store: any;
|
|
184
|
+
}) => void) => StoreManager;
|
|
185
|
+
_plugins: Array<(context: {
|
|
186
|
+
store: any;
|
|
187
|
+
}) => void>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* @description Getter 定义集合
|
|
191
|
+
*/
|
|
192
|
+
type GetterTree<S extends Record<string, any>> = Record<string, (state: S) => any>;
|
|
193
|
+
/**
|
|
194
|
+
* @description 从 Getter 定义中推导返回类型
|
|
195
|
+
*/
|
|
196
|
+
type StoreGetters<G extends GetterTree<any>> = { [K in keyof G]: G[K] extends ((...args: any[]) => infer R) ? R : never };
|
|
197
|
+
/**
|
|
198
|
+
* @description defineStore(options) 的配置类型
|
|
199
|
+
*/
|
|
200
|
+
interface DefineStoreOptions<S extends Record<string, any>, G extends GetterTree<S>, A extends Record<string, any>> {
|
|
201
|
+
state: () => S;
|
|
202
|
+
getters?: G & Record<string, (state: S) => any> & ThisType<S & StoreGetters<G> & A>;
|
|
203
|
+
actions?: A & ThisType<S & StoreGetters<G> & A>;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/store/define.d.ts
|
|
207
|
+
type SetupDefinition<T> = () => T;
|
|
208
|
+
/**
|
|
209
|
+
* @description 定义一个 setup 风格的 store
|
|
210
|
+
*/
|
|
211
|
+
declare function defineStore<T extends Record<string, any>>(id: string, setup: SetupDefinition<T>): () => T & {
|
|
212
|
+
$id: string;
|
|
213
|
+
$patch: (patch: Record<string, any> | ((state: any) => void)) => void;
|
|
214
|
+
$reset: () => void;
|
|
215
|
+
$subscribe: (cb: SubscriptionCallback<any>, opts?: StoreSubscribeOptions) => () => void;
|
|
216
|
+
$onAction: (cb: ActionSubscriber<any>) => () => void;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* @description 定义一个 options 风格的 store
|
|
220
|
+
*/
|
|
221
|
+
declare function defineStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>>(id: string, options: DefineStoreOptions<S, G, A>): () => S & StoreGetters<G> & A & {
|
|
222
|
+
$id: string;
|
|
223
|
+
$state: S;
|
|
224
|
+
$patch: (patch: Partial<S> | ((state: S) => void)) => void;
|
|
225
|
+
$reset: () => void;
|
|
226
|
+
$subscribe: (cb: SubscriptionCallback<S>, opts?: StoreSubscribeOptions) => () => void;
|
|
227
|
+
$onAction: (cb: ActionSubscriber<S & StoreGetters<G> & A>) => () => void;
|
|
228
|
+
};
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/store/manager.d.ts
|
|
231
|
+
/**
|
|
232
|
+
* @description 创建 store 管理器(插件与共享实例入口)
|
|
233
|
+
*/
|
|
234
|
+
declare function createStore(): StoreManager;
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/store/storeToRefs.d.ts
|
|
237
|
+
/**
|
|
238
|
+
* @description storeToRefs 返回类型推导
|
|
239
|
+
*/
|
|
240
|
+
type StoreToRefsResult<T extends Record<string, any>> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? T[K] : T[K] extends Ref$2<infer V> ? Ref$2<V> : Ref$2<T[K]> };
|
|
241
|
+
/**
|
|
242
|
+
* @description 将 store 状态转换为 Ref
|
|
243
|
+
*/
|
|
244
|
+
declare function storeToRefs<T extends Record<string, any>>(store: T): StoreToRefsResult<T>;
|
|
245
|
+
//#endregion
|
|
246
|
+
export { PropOptions as $, CustomRefSource as A, ComponentPropsOptions as B, ComputedRef as C, computed as D, WritableComputedRef as E, customRef as F, InferNativeProps as G, ExtractPropTypes as H, isRef as I, NativePropType as J, InferPropType as K, ref as L, MaybeRefOrGetter as M, Ref$2 as N, CustomRefFactory as O, ShallowRef$2 as P, PropConstructor as Q, toValue as R, ComputedGetter as S, WritableComputedOptions as T, ExtractPublicPropTypes as U, ExtractDefaultPropTypes as V, InferNativePropType as W, NativeTypeHint as X, NativePropsOptions as Y, NativeTypedProperty as Z, ObjectDirective$1 as _, ActionContext as a, VNode$1 as b, MutationType as c, SubscriptionCallback as d, PropType as et, AllowedComponentProps$1 as f, NativeComponent as g, DefineComponent$1 as h, defineStore as i, MaybeRef as j, CustomRefOptions as k, StoreManager as l, ComponentOptionsMixin$1 as m, storeToRefs as n, ActionSubscriber as o, ComponentCustomProps$1 as p, InferProps as q, createStore as r, DefineStoreOptions as s, StoreToRefsResult as t, StoreSubscribeOptions as u, PublicProps$1 as v, ComputedSetter as w, VNodeProps$1 as x, ShallowUnwrapRef$1 as y, unref as z };
|