@wevu/web-apis 1.3.5 → 1.4.0
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/README.md +36 -8
- package/dist/abort.d.mts +2 -4
- package/dist/abort.mjs +2 -3
- package/dist/eventsource-DUCc1iHv.d.mts +82 -0
- package/dist/eventsource-ojngrwBI.mjs +340 -0
- package/dist/eventsource.d.mts +2 -0
- package/dist/eventsource.mjs +2 -0
- package/dist/fetch-CQoQx3mz.mjs +301 -0
- package/dist/fetch-CSESA-oq.d.mts +33 -0
- package/dist/fetch.d.mts +2 -35
- package/dist/fetch.mjs +1 -188
- package/dist/http-DCCqK1QL.mjs +505 -0
- package/dist/{http-CE8-CIHE.d.mts → http-Dd6YCSHK.d.mts} +6 -14
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/index.d.mts +19 -54
- package/dist/index.mjs +35 -104
- package/dist/networkDefaults.d.mts +5 -11
- package/dist/networkDefaults.mjs +1 -2
- package/dist/{shared-85INNxXV.mjs → shared-CARmZrDA.mjs} +5 -9
- package/dist/{shared-Dc42USJC.d.mts → shared-DfU0oEwy.d.mts} +0 -2
- package/dist/shared.d.mts +1 -1
- package/dist/shared.mjs +1 -1
- package/dist/streams-6m8eQfZM.mjs +84 -0
- package/dist/streams.d.mts +31 -0
- package/dist/streams.mjs +1 -0
- package/dist/textCodec-muWByCAW.mjs +132 -0
- package/dist/{url-D0ANYIyk.d.mts → url-CEgyUgm2.d.mts} +0 -2
- package/dist/url-DjMmeEth.mjs +285 -0
- package/dist/url.d.mts +1 -1
- package/dist/url.mjs +1 -229
- package/dist/{web-uZ-hezcd.mjs → web-DDzJNeV3.mjs} +6 -8
- package/dist/{web-DNBBg6y9.d.mts → web-DjLufM4u.d.mts} +1 -7
- package/dist/web.d.mts +1 -1
- package/dist/web.mjs +1 -1
- package/dist/websocket.d.mts +3 -4
- package/dist/websocket.mjs +4 -5
- package/dist/xhr.d.mts +2 -3
- package/dist/xhr.mjs +4 -5
- package/package.json +20 -6
- package/dist/http-mcdF3N9S.mjs +0 -303
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// src/url/decodeSearchParam.ts
|
|
2
|
+
const PLUS_REGEXP = /\+/g;
|
|
3
|
+
const ENCODED_BYTES_REGEXP = /(?:%[\da-f]{2})+/gi;
|
|
4
|
+
function decodePercentBytes(encoded) {
|
|
5
|
+
const bytes = [];
|
|
6
|
+
for (let index = 0; index < encoded.length; index += 3) bytes.push(Number.parseInt(encoded.slice(index + 1, index + 3), 16));
|
|
7
|
+
let result = "";
|
|
8
|
+
let index = 0;
|
|
9
|
+
while (index < bytes.length) {
|
|
10
|
+
const first = bytes[index++];
|
|
11
|
+
if (first < 128) {
|
|
12
|
+
result += String.fromCharCode(first);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
let remaining;
|
|
16
|
+
let point;
|
|
17
|
+
let lower = 128;
|
|
18
|
+
let upper = 191;
|
|
19
|
+
if (first >= 194 && first <= 223) {
|
|
20
|
+
remaining = 1;
|
|
21
|
+
point = first & 31;
|
|
22
|
+
} else if (first >= 224 && first <= 239) {
|
|
23
|
+
remaining = 2;
|
|
24
|
+
point = first & 15;
|
|
25
|
+
if (first === 224) lower = 160;
|
|
26
|
+
if (first === 237) upper = 159;
|
|
27
|
+
} else if (first >= 240 && first <= 244) {
|
|
28
|
+
remaining = 3;
|
|
29
|
+
point = first & 7;
|
|
30
|
+
if (first === 240) lower = 144;
|
|
31
|
+
if (first === 244) upper = 143;
|
|
32
|
+
} else {
|
|
33
|
+
result += "�";
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
while (remaining > 0 && index < bytes.length) {
|
|
37
|
+
const next = bytes[index];
|
|
38
|
+
if (next < lower || next > upper) break;
|
|
39
|
+
point = point << 6 | next & 63;
|
|
40
|
+
index++;
|
|
41
|
+
remaining--;
|
|
42
|
+
lower = 128;
|
|
43
|
+
upper = 191;
|
|
44
|
+
}
|
|
45
|
+
if (remaining > 0) result += "�";
|
|
46
|
+
else if (point <= 65535) result += String.fromCharCode(point);
|
|
47
|
+
else {
|
|
48
|
+
point -= 65536;
|
|
49
|
+
result += String.fromCharCode(55296 + (point >> 10), 56320 + (point & 1023));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function decodeSearchParam(value) {
|
|
55
|
+
const source = value.replace(PLUS_REGEXP, " ");
|
|
56
|
+
try {
|
|
57
|
+
return decodeURIComponent(source);
|
|
58
|
+
} catch {
|
|
59
|
+
return source.replace(ENCODED_BYTES_REGEXP, decodePercentBytes);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// src/url.ts
|
|
63
|
+
const LEADING_QUERY_REGEXP = /^\?/;
|
|
64
|
+
const ABSOLUTE_URL_REGEXP = /^([a-z][a-z\d+.-]*:)?\/\/([^/?#]+)(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i;
|
|
65
|
+
const ABSOLUTE_URL_PREFIX_REGEXP = /^[a-z][a-z\d+.-]*:\/\//i;
|
|
66
|
+
const ENCODED_SPACE_REGEXP = /%20/g;
|
|
67
|
+
const HOST_WITH_PORT_REGEXP = /^([^:]*)(?::(.*))?$/;
|
|
68
|
+
function encodeSearchParam(value) {
|
|
69
|
+
return encodeURIComponent(value).replace(ENCODED_SPACE_REGEXP, "+");
|
|
70
|
+
}
|
|
71
|
+
function normalizeSearchSource(input) {
|
|
72
|
+
return input.replace(LEADING_QUERY_REGEXP, "");
|
|
73
|
+
}
|
|
74
|
+
function parseSearchEntries(input) {
|
|
75
|
+
if (!input) return [];
|
|
76
|
+
return normalizeSearchSource(input).split("&").filter(Boolean).map((segment) => {
|
|
77
|
+
const separatorIndex = segment.indexOf("=");
|
|
78
|
+
if (separatorIndex === -1) return [decodeSearchParam(segment), ""];
|
|
79
|
+
return [decodeSearchParam(segment.slice(0, separatorIndex)), decodeSearchParam(segment.slice(separatorIndex + 1))];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function serializeSearchEntries(entries) {
|
|
83
|
+
return entries.map(([key, value]) => `${encodeSearchParam(key)}=${encodeSearchParam(value)}`).join("&");
|
|
84
|
+
}
|
|
85
|
+
function parseAbsoluteUrl(input) {
|
|
86
|
+
const match = input.match(ABSOLUTE_URL_REGEXP);
|
|
87
|
+
if (!match) return null;
|
|
88
|
+
const protocol = match[1] ?? "";
|
|
89
|
+
const host = match[2];
|
|
90
|
+
const pathname = match[3] || "/";
|
|
91
|
+
const search = match[4] ?? "";
|
|
92
|
+
const hash = match[5] ?? "";
|
|
93
|
+
const hostnameMatch = host.match(HOST_WITH_PORT_REGEXP);
|
|
94
|
+
return {
|
|
95
|
+
protocol,
|
|
96
|
+
host,
|
|
97
|
+
hostname: hostnameMatch[1],
|
|
98
|
+
port: hostnameMatch?.[2] ?? "",
|
|
99
|
+
pathname,
|
|
100
|
+
search,
|
|
101
|
+
hash,
|
|
102
|
+
origin: protocol && host ? `${protocol}//${host}` : "",
|
|
103
|
+
href: `${protocol}//${host}${pathname}${search}${hash}`
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function resolveRelativeUrl(input, base) {
|
|
107
|
+
const parsedBase = parseAbsoluteUrl(base);
|
|
108
|
+
if (!parsedBase) throw new TypeError(`Failed to construct URL from base ${base}`);
|
|
109
|
+
if (input.startsWith("//")) return `${parsedBase.protocol}${input}`;
|
|
110
|
+
if (input.startsWith("/")) return `${parsedBase.origin}${input}`;
|
|
111
|
+
if (input.startsWith("?") || input.startsWith("#")) return `${`${parsedBase.origin}${parsedBase.pathname}`}${input}`;
|
|
112
|
+
const basePathSegments = parsedBase.pathname.split("/").slice(0, -1);
|
|
113
|
+
for (const segment of input.split("/")) {
|
|
114
|
+
if (!segment || segment === ".") continue;
|
|
115
|
+
if (segment === "..") {
|
|
116
|
+
basePathSegments.pop();
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
basePathSegments.push(segment);
|
|
120
|
+
}
|
|
121
|
+
return `${parsedBase.origin}${basePathSegments.join("/")}`;
|
|
122
|
+
}
|
|
123
|
+
var URLSearchParamsPolyfill = class {
|
|
124
|
+
onChange;
|
|
125
|
+
entriesStore = [];
|
|
126
|
+
constructor(init, onChange) {
|
|
127
|
+
this.onChange = onChange;
|
|
128
|
+
if (init == null) return;
|
|
129
|
+
if (typeof init === "string") {
|
|
130
|
+
this.entriesStore.push(...parseSearchEntries(init));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (typeof init[Symbol.iterator] === "function") {
|
|
134
|
+
for (const [key, value] of init) this.append(key, value);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
for (const [key, value] of Object.entries(init)) {
|
|
138
|
+
if (Array.isArray(value)) {
|
|
139
|
+
for (const item of value) this.append(key, item);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
this.append(key, value);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
append(key, value) {
|
|
146
|
+
this.entriesStore.push([String(key), String(value)]);
|
|
147
|
+
this.onChange?.();
|
|
148
|
+
}
|
|
149
|
+
delete(key) {
|
|
150
|
+
const normalizedKey = String(key);
|
|
151
|
+
let changed = false;
|
|
152
|
+
for (let i = this.entriesStore.length - 1; i >= 0; i--) if (this.entriesStore[i]?.[0] === normalizedKey) {
|
|
153
|
+
this.entriesStore.splice(i, 1);
|
|
154
|
+
changed = true;
|
|
155
|
+
}
|
|
156
|
+
if (changed) this.onChange?.();
|
|
157
|
+
}
|
|
158
|
+
get(key) {
|
|
159
|
+
const normalizedKey = String(key);
|
|
160
|
+
const found = this.entriesStore.find(([entryKey]) => entryKey === normalizedKey);
|
|
161
|
+
return found ? found[1] : null;
|
|
162
|
+
}
|
|
163
|
+
getAll(key) {
|
|
164
|
+
const normalizedKey = String(key);
|
|
165
|
+
return this.entriesStore.filter(([entryKey]) => entryKey === normalizedKey).map(([, value]) => value);
|
|
166
|
+
}
|
|
167
|
+
has(key) {
|
|
168
|
+
return this.entriesStore.some(([entryKey]) => entryKey === String(key));
|
|
169
|
+
}
|
|
170
|
+
get size() {
|
|
171
|
+
return this.entriesStore.length;
|
|
172
|
+
}
|
|
173
|
+
set(key, value) {
|
|
174
|
+
this.delete(key);
|
|
175
|
+
this.append(key, value);
|
|
176
|
+
}
|
|
177
|
+
sort() {
|
|
178
|
+
this.entriesStore.sort(([leftKey], [rightKey]) => {
|
|
179
|
+
if (leftKey < rightKey) return -1;
|
|
180
|
+
if (leftKey > rightKey) return 1;
|
|
181
|
+
return 0;
|
|
182
|
+
});
|
|
183
|
+
this.onChange?.();
|
|
184
|
+
}
|
|
185
|
+
forEach(callback) {
|
|
186
|
+
for (const [key, value] of this.entriesStore) callback(value, key);
|
|
187
|
+
}
|
|
188
|
+
entries() {
|
|
189
|
+
return this.entriesStore[Symbol.iterator]();
|
|
190
|
+
}
|
|
191
|
+
keys() {
|
|
192
|
+
return this.entriesStore.map(([key]) => key)[Symbol.iterator]();
|
|
193
|
+
}
|
|
194
|
+
values() {
|
|
195
|
+
return this.entriesStore.map(([, value]) => value)[Symbol.iterator]();
|
|
196
|
+
}
|
|
197
|
+
toString() {
|
|
198
|
+
return serializeSearchEntries(this.entriesStore);
|
|
199
|
+
}
|
|
200
|
+
[Symbol.iterator]() {
|
|
201
|
+
return this.entries();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var URLPolyfill = class URLPolyfill {
|
|
205
|
+
hashValue = "";
|
|
206
|
+
hrefValue = "";
|
|
207
|
+
searchValue = "";
|
|
208
|
+
host = "";
|
|
209
|
+
hostname = "";
|
|
210
|
+
origin = "";
|
|
211
|
+
password = "";
|
|
212
|
+
pathname = "/";
|
|
213
|
+
port = "";
|
|
214
|
+
protocol = "";
|
|
215
|
+
username = "";
|
|
216
|
+
searchParams;
|
|
217
|
+
static canParse(input, base) {
|
|
218
|
+
return URLPolyfill.parse(input, base) !== null;
|
|
219
|
+
}
|
|
220
|
+
static parse(input, base) {
|
|
221
|
+
try {
|
|
222
|
+
return new URLPolyfill(input, base);
|
|
223
|
+
} catch {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
constructor(input, base) {
|
|
228
|
+
const inputString = typeof input === "string" ? input : input.toString();
|
|
229
|
+
const baseString = typeof base === "string" ? base : base ? base.toString() : void 0;
|
|
230
|
+
const parsed = parseAbsoluteUrl(ABSOLUTE_URL_PREFIX_REGEXP.test(inputString) ? inputString : baseString ? resolveRelativeUrl(inputString, baseString) : inputString);
|
|
231
|
+
if (!parsed) throw new TypeError(`Failed to construct URL from ${inputString}`);
|
|
232
|
+
this.protocol = parsed.protocol;
|
|
233
|
+
this.host = parsed.host;
|
|
234
|
+
this.hostname = parsed.hostname;
|
|
235
|
+
this.port = parsed.port;
|
|
236
|
+
this.pathname = parsed.pathname;
|
|
237
|
+
this.searchValue = parsed.search;
|
|
238
|
+
this.hashValue = parsed.hash;
|
|
239
|
+
this.origin = parsed.origin;
|
|
240
|
+
this.searchParams = new URLSearchParamsPolyfill(parsed.search, () => {
|
|
241
|
+
this.syncSearchFromParams();
|
|
242
|
+
});
|
|
243
|
+
this.updateHref();
|
|
244
|
+
}
|
|
245
|
+
get hash() {
|
|
246
|
+
return this.hashValue;
|
|
247
|
+
}
|
|
248
|
+
set hash(value) {
|
|
249
|
+
this.hashValue = value ? value.startsWith("#") ? value : `#${value}` : "";
|
|
250
|
+
this.updateHref();
|
|
251
|
+
}
|
|
252
|
+
get href() {
|
|
253
|
+
return this.hrefValue;
|
|
254
|
+
}
|
|
255
|
+
get search() {
|
|
256
|
+
return this.searchValue;
|
|
257
|
+
}
|
|
258
|
+
set search(value) {
|
|
259
|
+
this.searchValue = value ? value.startsWith("?") ? value : `?${value}` : "";
|
|
260
|
+
this.resetSearchParams(this.searchValue);
|
|
261
|
+
this.updateHref();
|
|
262
|
+
}
|
|
263
|
+
toString() {
|
|
264
|
+
return this.hrefValue;
|
|
265
|
+
}
|
|
266
|
+
toJSON() {
|
|
267
|
+
return this.toString();
|
|
268
|
+
}
|
|
269
|
+
resetSearchParams(value) {
|
|
270
|
+
const nextParams = new URLSearchParamsPolyfill(value);
|
|
271
|
+
this.searchParams.entriesStore.splice(0, this.searchParams.entriesStore.length);
|
|
272
|
+
nextParams.forEach((entryValue, entryKey) => {
|
|
273
|
+
this.searchParams.entriesStore.push([entryKey, entryValue]);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
updateHref() {
|
|
277
|
+
this.hrefValue = `${this.protocol}//${this.host}${this.pathname}${this.searchValue}${this.hashValue}`;
|
|
278
|
+
}
|
|
279
|
+
syncSearchFromParams() {
|
|
280
|
+
const search = this.searchParams.toString();
|
|
281
|
+
this.searchValue = search ? `?${search}` : "";
|
|
282
|
+
this.updateHref();
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
export { URLSearchParamsPolyfill as n, URLPolyfill as t };
|
package/dist/url.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as URLSearchParamsPolyfill, t as URLPolyfill } from "./url-
|
|
1
|
+
import { n as URLSearchParamsPolyfill, t as URLPolyfill } from "./url-CEgyUgm2.mjs";
|
|
2
2
|
export { URLPolyfill, URLSearchParamsPolyfill };
|
package/dist/url.mjs
CHANGED
|
@@ -1,229 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const PLUS_REGEXP = /\+/g;
|
|
3
|
-
const LEADING_QUERY_REGEXP = /^\?/;
|
|
4
|
-
const ABSOLUTE_URL_REGEXP = /^([a-z][a-z\d+.-]*:)?\/\/([^/?#]+)(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i;
|
|
5
|
-
const ABSOLUTE_URL_PREFIX_REGEXP = /^[a-z][a-z\d+.-]*:\/\//i;
|
|
6
|
-
const ENCODED_SPACE_REGEXP = /%20/g;
|
|
7
|
-
const HOST_WITH_PORT_REGEXP = /^([^:]*)(?::(.*))?$/;
|
|
8
|
-
function encodeSearchParam(value) {
|
|
9
|
-
return encodeURIComponent(value).replace(ENCODED_SPACE_REGEXP, "+");
|
|
10
|
-
}
|
|
11
|
-
function decodeSearchParam(value) {
|
|
12
|
-
return decodeURIComponent(value.replace(PLUS_REGEXP, " "));
|
|
13
|
-
}
|
|
14
|
-
function normalizeSearchSource(input) {
|
|
15
|
-
return input.replace(LEADING_QUERY_REGEXP, "");
|
|
16
|
-
}
|
|
17
|
-
function parseSearchEntries(input) {
|
|
18
|
-
if (!input) return [];
|
|
19
|
-
return normalizeSearchSource(input).split("&").filter(Boolean).map((segment) => {
|
|
20
|
-
const separatorIndex = segment.indexOf("=");
|
|
21
|
-
if (separatorIndex === -1) return [decodeSearchParam(segment), ""];
|
|
22
|
-
return [decodeSearchParam(segment.slice(0, separatorIndex)), decodeSearchParam(segment.slice(separatorIndex + 1))];
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function serializeSearchEntries(entries) {
|
|
26
|
-
return entries.map(([key, value]) => `${encodeSearchParam(key)}=${encodeSearchParam(value)}`).join("&");
|
|
27
|
-
}
|
|
28
|
-
function parseAbsoluteUrl(input) {
|
|
29
|
-
const match = input.match(ABSOLUTE_URL_REGEXP);
|
|
30
|
-
if (!match) return null;
|
|
31
|
-
const protocol = match[1] ?? "";
|
|
32
|
-
const host = match[2];
|
|
33
|
-
const pathname = match[3] || "/";
|
|
34
|
-
const search = match[4] ?? "";
|
|
35
|
-
const hash = match[5] ?? "";
|
|
36
|
-
const hostnameMatch = host.match(HOST_WITH_PORT_REGEXP);
|
|
37
|
-
return {
|
|
38
|
-
protocol,
|
|
39
|
-
host,
|
|
40
|
-
hostname: hostnameMatch[1],
|
|
41
|
-
port: hostnameMatch?.[2] ?? "",
|
|
42
|
-
pathname,
|
|
43
|
-
search,
|
|
44
|
-
hash,
|
|
45
|
-
origin: protocol && host ? `${protocol}//${host}` : "",
|
|
46
|
-
href: `${protocol}//${host}${pathname}${search}${hash}`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function resolveRelativeUrl(input, base) {
|
|
50
|
-
const parsedBase = parseAbsoluteUrl(base);
|
|
51
|
-
if (!parsedBase) throw new TypeError(`Failed to construct URL from base ${base}`);
|
|
52
|
-
if (input.startsWith("//")) return `${parsedBase.protocol}${input}`;
|
|
53
|
-
if (input.startsWith("/")) return `${parsedBase.origin}${input}`;
|
|
54
|
-
if (input.startsWith("?") || input.startsWith("#")) return `${`${parsedBase.origin}${parsedBase.pathname}`}${input}`;
|
|
55
|
-
const basePathSegments = parsedBase.pathname.split("/").slice(0, -1);
|
|
56
|
-
for (const segment of input.split("/")) {
|
|
57
|
-
if (!segment || segment === ".") continue;
|
|
58
|
-
if (segment === "..") {
|
|
59
|
-
basePathSegments.pop();
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
basePathSegments.push(segment);
|
|
63
|
-
}
|
|
64
|
-
return `${parsedBase.origin}${basePathSegments.join("/")}`;
|
|
65
|
-
}
|
|
66
|
-
var URLSearchParamsPolyfill = class {
|
|
67
|
-
onChange;
|
|
68
|
-
entriesStore = [];
|
|
69
|
-
constructor(init, onChange) {
|
|
70
|
-
this.onChange = onChange;
|
|
71
|
-
if (init == null) return;
|
|
72
|
-
if (typeof init === "string") {
|
|
73
|
-
this.entriesStore.push(...parseSearchEntries(init));
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (typeof init[Symbol.iterator] === "function") {
|
|
77
|
-
for (const [key, value] of init) this.append(key, value);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
for (const [key, value] of Object.entries(init)) {
|
|
81
|
-
if (Array.isArray(value)) {
|
|
82
|
-
for (const item of value) this.append(key, item);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
this.append(key, value);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
append(key, value) {
|
|
89
|
-
this.entriesStore.push([String(key), String(value)]);
|
|
90
|
-
this.onChange?.();
|
|
91
|
-
}
|
|
92
|
-
delete(key) {
|
|
93
|
-
const normalizedKey = String(key);
|
|
94
|
-
let changed = false;
|
|
95
|
-
for (let i = this.entriesStore.length - 1; i >= 0; i--) if (this.entriesStore[i]?.[0] === normalizedKey) {
|
|
96
|
-
this.entriesStore.splice(i, 1);
|
|
97
|
-
changed = true;
|
|
98
|
-
}
|
|
99
|
-
if (changed) this.onChange?.();
|
|
100
|
-
}
|
|
101
|
-
get(key) {
|
|
102
|
-
const normalizedKey = String(key);
|
|
103
|
-
const found = this.entriesStore.find(([entryKey]) => entryKey === normalizedKey);
|
|
104
|
-
return found ? found[1] : null;
|
|
105
|
-
}
|
|
106
|
-
getAll(key) {
|
|
107
|
-
const normalizedKey = String(key);
|
|
108
|
-
return this.entriesStore.filter(([entryKey]) => entryKey === normalizedKey).map(([, value]) => value);
|
|
109
|
-
}
|
|
110
|
-
has(key) {
|
|
111
|
-
return this.entriesStore.some(([entryKey]) => entryKey === String(key));
|
|
112
|
-
}
|
|
113
|
-
get size() {
|
|
114
|
-
return this.entriesStore.length;
|
|
115
|
-
}
|
|
116
|
-
set(key, value) {
|
|
117
|
-
this.delete(key);
|
|
118
|
-
this.append(key, value);
|
|
119
|
-
}
|
|
120
|
-
sort() {
|
|
121
|
-
this.entriesStore.sort(([leftKey], [rightKey]) => {
|
|
122
|
-
if (leftKey < rightKey) return -1;
|
|
123
|
-
if (leftKey > rightKey) return 1;
|
|
124
|
-
return 0;
|
|
125
|
-
});
|
|
126
|
-
this.onChange?.();
|
|
127
|
-
}
|
|
128
|
-
forEach(callback) {
|
|
129
|
-
for (const [key, value] of this.entriesStore) callback(value, key);
|
|
130
|
-
}
|
|
131
|
-
entries() {
|
|
132
|
-
return this.entriesStore[Symbol.iterator]();
|
|
133
|
-
}
|
|
134
|
-
keys() {
|
|
135
|
-
return this.entriesStore.map(([key]) => key)[Symbol.iterator]();
|
|
136
|
-
}
|
|
137
|
-
values() {
|
|
138
|
-
return this.entriesStore.map(([, value]) => value)[Symbol.iterator]();
|
|
139
|
-
}
|
|
140
|
-
toString() {
|
|
141
|
-
return serializeSearchEntries(this.entriesStore);
|
|
142
|
-
}
|
|
143
|
-
[Symbol.iterator]() {
|
|
144
|
-
return this.entries();
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var URLPolyfill = class URLPolyfill {
|
|
148
|
-
hashValue = "";
|
|
149
|
-
hrefValue = "";
|
|
150
|
-
searchValue = "";
|
|
151
|
-
host = "";
|
|
152
|
-
hostname = "";
|
|
153
|
-
origin = "";
|
|
154
|
-
password = "";
|
|
155
|
-
pathname = "/";
|
|
156
|
-
port = "";
|
|
157
|
-
protocol = "";
|
|
158
|
-
username = "";
|
|
159
|
-
searchParams;
|
|
160
|
-
static canParse(input, base) {
|
|
161
|
-
return URLPolyfill.parse(input, base) !== null;
|
|
162
|
-
}
|
|
163
|
-
static parse(input, base) {
|
|
164
|
-
try {
|
|
165
|
-
return new URLPolyfill(input, base);
|
|
166
|
-
} catch {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
constructor(input, base) {
|
|
171
|
-
const inputString = typeof input === "string" ? input : input.toString();
|
|
172
|
-
const baseString = typeof base === "string" ? base : base ? base.toString() : void 0;
|
|
173
|
-
const parsed = parseAbsoluteUrl(ABSOLUTE_URL_PREFIX_REGEXP.test(inputString) ? inputString : baseString ? resolveRelativeUrl(inputString, baseString) : inputString);
|
|
174
|
-
if (!parsed) throw new TypeError(`Failed to construct URL from ${inputString}`);
|
|
175
|
-
this.protocol = parsed.protocol;
|
|
176
|
-
this.host = parsed.host;
|
|
177
|
-
this.hostname = parsed.hostname;
|
|
178
|
-
this.port = parsed.port;
|
|
179
|
-
this.pathname = parsed.pathname;
|
|
180
|
-
this.searchValue = parsed.search;
|
|
181
|
-
this.hashValue = parsed.hash;
|
|
182
|
-
this.origin = parsed.origin;
|
|
183
|
-
this.searchParams = new URLSearchParamsPolyfill(parsed.search, () => {
|
|
184
|
-
this.syncSearchFromParams();
|
|
185
|
-
});
|
|
186
|
-
this.updateHref();
|
|
187
|
-
}
|
|
188
|
-
get hash() {
|
|
189
|
-
return this.hashValue;
|
|
190
|
-
}
|
|
191
|
-
set hash(value) {
|
|
192
|
-
this.hashValue = value ? value.startsWith("#") ? value : `#${value}` : "";
|
|
193
|
-
this.updateHref();
|
|
194
|
-
}
|
|
195
|
-
get href() {
|
|
196
|
-
return this.hrefValue;
|
|
197
|
-
}
|
|
198
|
-
get search() {
|
|
199
|
-
return this.searchValue;
|
|
200
|
-
}
|
|
201
|
-
set search(value) {
|
|
202
|
-
this.searchValue = value ? value.startsWith("?") ? value : `?${value}` : "";
|
|
203
|
-
this.resetSearchParams(this.searchValue);
|
|
204
|
-
this.updateHref();
|
|
205
|
-
}
|
|
206
|
-
toString() {
|
|
207
|
-
return this.hrefValue;
|
|
208
|
-
}
|
|
209
|
-
toJSON() {
|
|
210
|
-
return this.toString();
|
|
211
|
-
}
|
|
212
|
-
resetSearchParams(value) {
|
|
213
|
-
const nextParams = new URLSearchParamsPolyfill(value);
|
|
214
|
-
this.searchParams.entriesStore.splice(0, this.searchParams.entriesStore.length);
|
|
215
|
-
nextParams.forEach((entryValue, entryKey) => {
|
|
216
|
-
this.searchParams.entriesStore.push([entryKey, entryValue]);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
updateHref() {
|
|
220
|
-
this.hrefValue = `${this.protocol}//${this.host}${this.pathname}${this.searchValue}${this.hashValue}`;
|
|
221
|
-
}
|
|
222
|
-
syncSearchFromParams() {
|
|
223
|
-
const search = this.searchParams.toString();
|
|
224
|
-
this.searchValue = search ? `?${search}` : "";
|
|
225
|
-
this.updateHref();
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
//#endregion
|
|
229
|
-
export { URLPolyfill, URLSearchParamsPolyfill };
|
|
1
|
+
export { t as URLPolyfill, n as URLSearchParamsPolyfill } from "./url-DjMmeEth.mjs";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { l as isArrayBufferLike, n as cloneArrayBuffer, o as encodeText, r as cloneArrayBufferView, u as isBlobLike } from "./shared-CARmZrDA.mjs";
|
|
2
|
+
import { t as TextDecoderPolyfill } from "./textCodec-muWByCAW.mjs";
|
|
3
|
+
// src/web/blob.ts
|
|
3
4
|
const segments = /* @__PURE__ */ new WeakMap();
|
|
4
5
|
/** Blob 的 MIME 类型只接受可打印 ASCII,并按标准转换成小写。 */
|
|
5
6
|
function normalizeBlobType(type = "") {
|
|
@@ -61,7 +62,7 @@ var BlobPolyfill = class BlobPolyfill {
|
|
|
61
62
|
return new Uint8Array(await this.arrayBuffer());
|
|
62
63
|
}
|
|
63
64
|
async text() {
|
|
64
|
-
return
|
|
65
|
+
return new TextDecoderPolyfill().decode(await this.arrayBuffer());
|
|
65
66
|
}
|
|
66
67
|
slice(start = 0, end = this.size, contentType = "") {
|
|
67
68
|
const first = relativeIndex(start, this.size);
|
|
@@ -92,8 +93,7 @@ var BlobPolyfill = class BlobPolyfill {
|
|
|
92
93
|
return "Blob";
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
|
-
|
|
96
|
-
//#region src/web/file.ts
|
|
96
|
+
// src/web/file.ts
|
|
97
97
|
var FilePolyfill = class extends BlobPolyfill {
|
|
98
98
|
lastModified;
|
|
99
99
|
fileName;
|
|
@@ -109,8 +109,7 @@ var FilePolyfill = class extends BlobPolyfill {
|
|
|
109
109
|
return "File";
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
|
|
113
|
-
//#region src/web/formData.ts
|
|
112
|
+
// src/web/formData.ts
|
|
114
113
|
function isFileLikePart(value) {
|
|
115
114
|
return typeof value.name === "string" && typeof value.lastModified === "number";
|
|
116
115
|
}
|
|
@@ -174,5 +173,4 @@ var FormDataPolyfill = class {
|
|
|
174
173
|
return "FormData";
|
|
175
174
|
}
|
|
176
175
|
};
|
|
177
|
-
//#endregion
|
|
178
176
|
export { FilePolyfill as n, BlobPolyfill as r, FormDataPolyfill as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as RequestGlobalsBlobLike } from "./shared-
|
|
2
|
-
//#region src/web/blob.d.ts
|
|
1
|
+
import { t as RequestGlobalsBlobLike } from "./shared-DfU0oEwy.mjs";
|
|
3
2
|
type BlobLikePart = RequestGlobalsBlobLike;
|
|
4
3
|
type BlobPart = ArrayBuffer | ArrayBufferView | BlobLikePart | string;
|
|
5
4
|
interface BlobPropertyBag {
|
|
@@ -15,8 +14,6 @@ declare class BlobPolyfill {
|
|
|
15
14
|
slice(start?: number, end?: number, contentType?: string): BlobPolyfill;
|
|
16
15
|
get [Symbol.toStringTag](): string;
|
|
17
16
|
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/web/file.d.ts
|
|
20
17
|
interface FilePropertyBag extends BlobPropertyBag {
|
|
21
18
|
lastModified?: number;
|
|
22
19
|
}
|
|
@@ -27,8 +24,6 @@ declare class FilePolyfill extends BlobPolyfill {
|
|
|
27
24
|
get name(): string;
|
|
28
25
|
get [Symbol.toStringTag](): string;
|
|
29
26
|
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/web/formData.d.ts
|
|
32
27
|
type FormDataEntryValue = FilePolyfill | BlobPolyfill | string;
|
|
33
28
|
declare class FormDataPolyfill {
|
|
34
29
|
private readonly entriesList;
|
|
@@ -47,5 +42,4 @@ declare class FormDataPolyfill {
|
|
|
47
42
|
[Symbol.iterator](): Generator<[string, FormDataEntryValue], void, unknown>;
|
|
48
43
|
get [Symbol.toStringTag](): string;
|
|
49
44
|
}
|
|
50
|
-
//#endregion
|
|
51
45
|
export { BlobPart as a, BlobLikePart as i, FormDataPolyfill as n, BlobPolyfill as o, FilePolyfill as r, FormDataEntryValue as t };
|
package/dist/web.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as BlobPart, i as BlobLikePart, n as FormDataPolyfill, o as BlobPolyfill, r as FilePolyfill, t as FormDataEntryValue } from "./web-
|
|
1
|
+
import { a as BlobPart, i as BlobLikePart, n as FormDataPolyfill, o as BlobPolyfill, r as FilePolyfill, t as FormDataEntryValue } from "./web-DjLufM4u.mjs";
|
|
2
2
|
export { type BlobLikePart, type BlobPart, BlobPolyfill, FilePolyfill, type FormDataEntryValue, FormDataPolyfill };
|
package/dist/web.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { r as BlobPolyfill, n as FilePolyfill, t as FormDataPolyfill } from "./web-
|
|
1
|
+
export { r as BlobPolyfill, n as FilePolyfill, t as FormDataPolyfill } from "./web-DDzJNeV3.mjs";
|
package/dist/websocket.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { i as RequestGlobalsEventTarget, t as RequestGlobalsBlobLike } from "./shared-
|
|
1
|
+
import { i as RequestGlobalsEventTarget, t as RequestGlobalsBlobLike } from "./shared-DfU0oEwy.mjs";
|
|
2
2
|
import { WebSocketMiniProgramOptions } from "./networkDefaults.mjs";
|
|
3
|
-
import { o as BlobPolyfill } from "./web-
|
|
4
|
-
//#region src/websocket.d.ts
|
|
3
|
+
import { o as BlobPolyfill } from "./web-DjLufM4u.mjs";
|
|
5
4
|
type WebSocketBinaryType = 'blob' | 'arraybuffer';
|
|
6
5
|
type WebSocketSendData = string | ArrayBuffer | ArrayBufferView | Blob | RequestGlobalsBlobLike;
|
|
7
6
|
type WebSocketMessageData = string | ArrayBuffer | Blob | BlobPolyfill;
|
|
@@ -54,4 +53,4 @@ export declare class WebSocketPolyfill extends RequestGlobalsEventTarget {
|
|
|
54
53
|
private closeFromRuntime;
|
|
55
54
|
private emitError;
|
|
56
55
|
}
|
|
57
|
-
|
|
56
|
+
export {};
|
package/dist/websocket.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _ as resolveUrlConstructor$1, g as resolveTextEncoderConstructor, l as isArrayBufferLike, n as cloneArrayBuffer, r as cloneArrayBufferView, t as RequestGlobalsEventTarget, u as isBlobLike } from "./shared-
|
|
2
|
-
import { URLPolyfill } from "./url.mjs";
|
|
3
|
-
import { r as BlobPolyfill } from "./web-
|
|
1
|
+
import { _ as resolveUrlConstructor$1, g as resolveTextEncoderConstructor, l as isArrayBufferLike, n as cloneArrayBuffer, r as cloneArrayBufferView, t as RequestGlobalsEventTarget, u as isBlobLike } from "./shared-CARmZrDA.mjs";
|
|
2
|
+
import { t as URLPolyfill } from "./url-DjMmeEth.mjs";
|
|
3
|
+
import { r as BlobPolyfill } from "./web-DDzJNeV3.mjs";
|
|
4
4
|
import { resolveWebSocketMiniProgramOptions } from "./networkDefaults.mjs";
|
|
5
5
|
import { wpi } from "@wevu/api";
|
|
6
|
-
|
|
6
|
+
// src/websocket.ts
|
|
7
7
|
const WHITESPACE_RE = /\s/u;
|
|
8
8
|
function isValidProtocol(protocol) {
|
|
9
9
|
return [...protocol].every((char) => {
|
|
@@ -203,5 +203,4 @@ var WebSocketPolyfill = class WebSocketPolyfill extends RequestGlobalsEventTarge
|
|
|
203
203
|
this.dispatchEvent(createErrorEvent(error));
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
|
-
//#endregion
|
|
207
206
|
export { WebSocketPolyfill };
|
package/dist/xhr.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { i as RequestGlobalsEventTarget } from "./shared-
|
|
1
|
+
import { i as RequestGlobalsEventTarget } from "./shared-DfU0oEwy.mjs";
|
|
2
2
|
import { RequestGlobalsMiniProgramOptions } from "./networkDefaults.mjs";
|
|
3
|
-
//#region src/xhr.d.ts
|
|
4
3
|
type XhrBody = Document | XMLHttpRequestBodyInit | null | undefined;
|
|
5
4
|
export declare class XMLHttpRequestUploadPolyfill extends RequestGlobalsEventTarget {}
|
|
6
5
|
export declare class XMLHttpRequestPolyfill extends RequestGlobalsEventTarget {
|
|
@@ -65,4 +64,4 @@ export declare class XMLHttpRequestPolyfill extends RequestGlobalsEventTarget {
|
|
|
65
64
|
private finish;
|
|
66
65
|
private transitionTo;
|
|
67
66
|
}
|
|
68
|
-
|
|
67
|
+
export {};
|
package/dist/xhr.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as resolveRequestGlobalsHost, t as RequestGlobalsEventTarget } from "./shared-
|
|
1
|
+
import { f as resolveRequestGlobalsHost, t as RequestGlobalsEventTarget } from "./shared-CARmZrDA.mjs";
|
|
2
2
|
import { AbortControllerPolyfill } from "./abort.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { fetch } from "./fetch.mjs";
|
|
5
|
-
|
|
3
|
+
import { d as headersToObject, u as HeadersPolyfill } from "./http-DCCqK1QL.mjs";
|
|
4
|
+
import { t as fetch } from "./fetch-CQoQx3mz.mjs";
|
|
5
|
+
// src/xhr.ts
|
|
6
6
|
function createProgressEvent(type) {
|
|
7
7
|
return {
|
|
8
8
|
type,
|
|
@@ -159,5 +159,4 @@ var XMLHttpRequestPolyfill = class XMLHttpRequestPolyfill extends RequestGlobals
|
|
|
159
159
|
this.dispatchEvent({ type: "readystatechange" });
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
|
-
//#endregion
|
|
163
162
|
export { XMLHttpRequestPolyfill, XMLHttpRequestUploadPolyfill };
|