@wevu/web-apis 1.2.22 → 1.2.24
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/abort.mjs +1 -1
- package/dist/{fetch-DlXT0r06.mjs → fetch-CKch4mSy.mjs} +3 -3
- package/dist/fetch.mjs +1 -1
- package/dist/http.d.mts +2 -1
- package/dist/http.mjs +5 -5
- package/dist/index.mjs +5 -9
- package/dist/{shared-B_5_ZEFl.mjs → shared-C4EOQbWG.mjs} +11 -2
- package/dist/shared.d.mts +8 -1
- package/dist/shared.mjs +2 -2
- package/dist/web.d.mts +3 -5
- package/dist/web.mjs +4 -4
- package/dist/websocket.d.mts +2 -2
- package/dist/websocket.mjs +3 -3
- package/dist/xhr.mjs +2 -2
- package/package.json +2 -2
package/dist/abort.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as normalizeHeaderName, h as isUrlSearchParamsInstance, l as isArrayBufferLike, m as isUrlInstance, n as cloneArrayBuffer, o as encodeText, r as cloneArrayBufferView, u as isBlobLike } from "./shared-C4EOQbWG.mjs";
|
|
2
2
|
import { FormDataPolyfill } from "./web.mjs";
|
|
3
3
|
import { HeadersPolyfill, RequestPolyfill, ResponsePolyfill, getRequestBodyValue } from "./http.mjs";
|
|
4
4
|
import { resolveRequestMiniProgramOptions } from "./networkDefaults.mjs";
|
|
@@ -150,9 +150,9 @@ async function normalizeRequestBody(body, headers) {
|
|
|
150
150
|
if (!hasHeader(headers, "content-type")) headers["content-type"] = "application/x-www-form-urlencoded;charset=UTF-8";
|
|
151
151
|
return body.toString();
|
|
152
152
|
}
|
|
153
|
-
if (body
|
|
153
|
+
if (isArrayBufferLike(body)) return cloneArrayBuffer(body);
|
|
154
154
|
if (ArrayBuffer.isView(body)) return cloneArrayBufferView(body);
|
|
155
|
-
if (
|
|
155
|
+
if (isBlobLike(body)) {
|
|
156
156
|
if (body.type && !hasHeader(headers, "content-type")) headers["content-type"] = body.type;
|
|
157
157
|
return body.arrayBuffer();
|
|
158
158
|
}
|
package/dist/fetch.mjs
CHANGED
package/dist/http.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestGlobalsBlobLike } from "./shared.mjs";
|
|
1
2
|
import { URLPolyfill } from "./url.mjs";
|
|
2
3
|
import { FormDataPolyfill } from "./web.mjs";
|
|
3
4
|
|
|
@@ -18,7 +19,7 @@ declare class HeadersPolyfill {
|
|
|
18
19
|
values(): ArrayIterator<string>;
|
|
19
20
|
[Symbol.iterator](): ArrayIterator<[string, string]>;
|
|
20
21
|
}
|
|
21
|
-
type RequestBodyLike = string | ArrayBuffer | ArrayBufferView | Blob | FormData | FormDataPolyfill | null | undefined;
|
|
22
|
+
type RequestBodyLike = string | ArrayBuffer | ArrayBufferView | Blob | RequestGlobalsBlobLike | FormData | FormDataPolyfill | null | undefined;
|
|
22
23
|
declare function getRequestBodyValue(request?: RequestPolyfill): RequestBodyLike;
|
|
23
24
|
declare class RequestPolyfill {
|
|
24
25
|
readonly url: string;
|
package/dist/http.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as normalizeHeaderName, i as decodeText, l as isArrayBufferLike, m as isUrlInstance, n as cloneArrayBuffer, o as encodeText, r as cloneArrayBufferView, u as isBlobLike } from "./shared-C4EOQbWG.mjs";
|
|
2
2
|
import { FormDataPolyfill } from "./web.mjs";
|
|
3
3
|
//#region src/http.ts
|
|
4
4
|
const SET_COOKIE_HEADER_NAME = "set-cookie";
|
|
@@ -78,8 +78,8 @@ const requestBodyUsedStore = /* @__PURE__ */ new WeakMap();
|
|
|
78
78
|
const responseBodyStore = /* @__PURE__ */ new WeakMap();
|
|
79
79
|
const responseBodyUsedStore = /* @__PURE__ */ new WeakMap();
|
|
80
80
|
function normalizeBody(body) {
|
|
81
|
-
if (body == null || typeof body === "string" || body
|
|
82
|
-
if (
|
|
81
|
+
if (body == null || typeof body === "string" || isArrayBufferLike(body) || ArrayBuffer.isView(body)) return body;
|
|
82
|
+
if (isBlobLike(body)) return body;
|
|
83
83
|
if (typeof FormData !== "undefined" && body instanceof FormData) return body;
|
|
84
84
|
if (body instanceof FormDataPolyfill) return body;
|
|
85
85
|
return String(body);
|
|
@@ -87,9 +87,9 @@ function normalizeBody(body) {
|
|
|
87
87
|
async function readBodyAsArrayBuffer(body) {
|
|
88
88
|
if (body == null) return /* @__PURE__ */ new ArrayBuffer(0);
|
|
89
89
|
if (typeof body === "string") return encodeText(body);
|
|
90
|
-
if (body
|
|
90
|
+
if (isArrayBufferLike(body)) return cloneArrayBuffer(body);
|
|
91
91
|
if (ArrayBuffer.isView(body)) return cloneArrayBufferView(body);
|
|
92
|
-
if (
|
|
92
|
+
if (isBlobLike(body)) return body.arrayBuffer();
|
|
93
93
|
return encodeText(String(body));
|
|
94
94
|
}
|
|
95
95
|
async function readBodyAsText(body) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { a as decodeTextFallback, c as installRequestGlobalBinding,
|
|
1
|
+
import { a as decodeTextFallback, c as installRequestGlobalBinding, f as resolveRequestGlobalsHost, l as isArrayBufferLike, n as cloneArrayBuffer, p as resolveRequestGlobalsHosts, r as cloneArrayBufferView, s as encodeTextFallback, t as RequestGlobalsEventTarget, v as getMiniProgramRuntimeGlobalKeys } from "./shared-C4EOQbWG.mjs";
|
|
2
2
|
import { URLPolyfill, URLSearchParamsPolyfill } from "./url.mjs";
|
|
3
3
|
import { AbortControllerPolyfill, AbortSignalPolyfill } from "./abort.mjs";
|
|
4
4
|
import { BlobPolyfill, FilePolyfill, FormDataPolyfill } from "./web.mjs";
|
|
5
5
|
import { HeadersPolyfill, RequestPolyfill, ResponsePolyfill } from "./http.mjs";
|
|
6
|
-
import { t as fetch } from "./fetch-
|
|
6
|
+
import { t as fetch } from "./fetch-CKch4mSy.mjs";
|
|
7
7
|
import { getMiniProgramNetworkDefaults, resetMiniProgramNetworkDefaults, setMiniProgramNetworkDefaults } from "./networkDefaults.mjs";
|
|
8
8
|
import { WebSocketPolyfill } from "./websocket.mjs";
|
|
9
9
|
import { XMLHttpRequestPolyfill } from "./xhr.mjs";
|
|
10
10
|
import { REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_PLACEHOLDER_KEY } from "@weapp-core/constants";
|
|
11
11
|
//#region src/base64.ts
|
|
12
12
|
const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
13
|
-
const BASE64_LOOKUP = new Uint8Array(256);
|
|
13
|
+
const BASE64_LOOKUP = /* @__PURE__ */ new Uint8Array(256);
|
|
14
14
|
const BASE64_INVALID_INPUT_RE = /[^A-Za-z\d+/=]/u;
|
|
15
15
|
for (let index = 0; index < BASE64_LOOKUP.length; index++) BASE64_LOOKUP[index] = 255;
|
|
16
16
|
for (let index = 0; index < 64; index++) BASE64_LOOKUP[BASE64_CHARS.charCodeAt(index)] = index;
|
|
@@ -174,12 +174,8 @@ function queueMicrotaskPolyfill(callback) {
|
|
|
174
174
|
//#region src/textCodec.ts
|
|
175
175
|
function normalizeTextDecoderInput(input) {
|
|
176
176
|
if (input == null) return /* @__PURE__ */ new ArrayBuffer(0);
|
|
177
|
-
if (input
|
|
178
|
-
if (ArrayBuffer.isView(input))
|
|
179
|
-
const copied = new Uint8Array(input.byteLength);
|
|
180
|
-
copied.set(new Uint8Array(input.buffer, input.byteOffset, input.byteLength));
|
|
181
|
-
return copied.buffer;
|
|
182
|
-
}
|
|
177
|
+
if (isArrayBufferLike(input)) return cloneArrayBuffer(input);
|
|
178
|
+
if (ArrayBuffer.isView(input)) return cloneArrayBufferView(input);
|
|
183
179
|
return /* @__PURE__ */ new ArrayBuffer(0);
|
|
184
180
|
}
|
|
185
181
|
var TextEncoderPolyfill = class {
|
|
@@ -631,8 +631,17 @@ function installRequestGlobalBinding(name, value) {
|
|
|
631
631
|
host[name] = value;
|
|
632
632
|
} catch {}
|
|
633
633
|
}
|
|
634
|
+
function isArrayBufferLike(value) {
|
|
635
|
+
return Object.prototype.toString.call(value) === "[object ArrayBuffer]" && typeof value.byteLength === "number";
|
|
636
|
+
}
|
|
637
|
+
function isBlobLike(value) {
|
|
638
|
+
return value != null && typeof value === "object" && typeof value.arrayBuffer === "function" && (typeof value.size === "number" || typeof value.type === "string");
|
|
639
|
+
}
|
|
634
640
|
function cloneArrayBuffer(buffer) {
|
|
635
|
-
return buffer.slice(0);
|
|
641
|
+
if (typeof buffer.slice === "function") return buffer.slice(0);
|
|
642
|
+
const copied = new Uint8Array(buffer.byteLength);
|
|
643
|
+
copied.set(new Uint8Array(buffer));
|
|
644
|
+
return copied.buffer;
|
|
636
645
|
}
|
|
637
646
|
function cloneArrayBufferView(view) {
|
|
638
647
|
const copied = new Uint8Array(view.byteLength);
|
|
@@ -669,4 +678,4 @@ function normalizeHeaderName(name) {
|
|
|
669
678
|
return name.trim().toLowerCase();
|
|
670
679
|
}
|
|
671
680
|
//#endregion
|
|
672
|
-
export { decodeTextFallback as a, installRequestGlobalBinding as c,
|
|
681
|
+
export { resolveUrlConstructor as _, decodeTextFallback as a, installRequestGlobalBinding as c, normalizeHeaderName as d, resolveRequestGlobalsHost as f, resolveTextEncoderConstructor as g, isUrlSearchParamsInstance as h, decodeText as i, isArrayBufferLike as l, isUrlInstance as m, cloneArrayBuffer as n, encodeText as o, resolveRequestGlobalsHosts as p, cloneArrayBufferView as r, encodeTextFallback as s, RequestGlobalsEventTarget as t, isBlobLike as u, getMiniProgramRuntimeGlobalKeys as v };
|
package/dist/shared.d.mts
CHANGED
|
@@ -19,6 +19,13 @@ declare class RequestGlobalsEventTarget implements RequestGlobalsEventTargetLike
|
|
|
19
19
|
declare function resolveRequestGlobalsHost(): Record<string, any>;
|
|
20
20
|
declare function resolveRequestGlobalsHosts(): Record<string, any>[];
|
|
21
21
|
declare function installRequestGlobalBinding(name: string, value: unknown): void;
|
|
22
|
+
declare function isArrayBufferLike(value: unknown): value is ArrayBuffer;
|
|
23
|
+
interface RequestGlobalsBlobLike {
|
|
24
|
+
readonly size?: number;
|
|
25
|
+
readonly type?: string;
|
|
26
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
27
|
+
}
|
|
28
|
+
declare function isBlobLike(value: unknown): value is RequestGlobalsBlobLike;
|
|
22
29
|
declare function cloneArrayBuffer(buffer: ArrayBuffer): ArrayBuffer;
|
|
23
30
|
declare function cloneArrayBufferView(view: ArrayBufferView): ArrayBuffer;
|
|
24
31
|
declare function encodeTextFallback(value: string): ArrayBuffer;
|
|
@@ -27,4 +34,4 @@ declare function decodeTextFallback(value: ArrayBuffer): string;
|
|
|
27
34
|
declare function decodeText(value: ArrayBuffer): string;
|
|
28
35
|
declare function normalizeHeaderName(name: string): string;
|
|
29
36
|
//#endregion
|
|
30
|
-
export { RequestGlobalsEventLike, RequestGlobalsEventTarget, RequestGlobalsEventTargetLike, cloneArrayBuffer, cloneArrayBufferView, decodeText, decodeTextFallback, encodeText, encodeTextFallback, installRequestGlobalBinding, normalizeHeaderName, resolveRequestGlobalsHost, resolveRequestGlobalsHosts };
|
|
37
|
+
export { RequestGlobalsBlobLike, RequestGlobalsEventLike, RequestGlobalsEventTarget, RequestGlobalsEventTargetLike, cloneArrayBuffer, cloneArrayBufferView, decodeText, decodeTextFallback, encodeText, encodeTextFallback, installRequestGlobalBinding, isArrayBufferLike, isBlobLike, normalizeHeaderName, resolveRequestGlobalsHost, resolveRequestGlobalsHosts };
|
package/dist/shared.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as decodeTextFallback, c as installRequestGlobalBinding, d as
|
|
2
|
-
export { RequestGlobalsEventTarget, cloneArrayBuffer, cloneArrayBufferView, decodeText, decodeTextFallback, encodeText, encodeTextFallback, installRequestGlobalBinding, normalizeHeaderName, resolveRequestGlobalsHost, resolveRequestGlobalsHosts };
|
|
1
|
+
import { a as decodeTextFallback, c as installRequestGlobalBinding, d as normalizeHeaderName, f as resolveRequestGlobalsHost, i as decodeText, l as isArrayBufferLike, n as cloneArrayBuffer, o as encodeText, p as resolveRequestGlobalsHosts, r as cloneArrayBufferView, s as encodeTextFallback, t as RequestGlobalsEventTarget, u as isBlobLike } from "./shared-C4EOQbWG.mjs";
|
|
2
|
+
export { RequestGlobalsEventTarget, cloneArrayBuffer, cloneArrayBufferView, decodeText, decodeTextFallback, encodeText, encodeTextFallback, installRequestGlobalBinding, isArrayBufferLike, isBlobLike, normalizeHeaderName, resolveRequestGlobalsHost, resolveRequestGlobalsHosts };
|
package/dist/web.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { RequestGlobalsBlobLike } from "./shared.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/web.d.ts
|
|
2
|
-
|
|
3
|
-
readonly size?: number;
|
|
4
|
-
readonly type?: string;
|
|
5
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
6
|
-
}
|
|
4
|
+
type BlobLikePart = RequestGlobalsBlobLike;
|
|
7
5
|
type BlobPart = ArrayBuffer | ArrayBufferView | BlobLikePart | string;
|
|
8
6
|
type FormDataEntryValue = FilePolyfill | BlobPolyfill | string;
|
|
9
7
|
interface BlobPropertyBag {
|
package/dist/web.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as decodeText, n as cloneArrayBuffer, o as encodeText, r as cloneArrayBufferView } from "./shared-
|
|
1
|
+
import { i as decodeText, l as isArrayBufferLike, n as cloneArrayBuffer, o as encodeText, r as cloneArrayBufferView, u as isBlobLike } from "./shared-C4EOQbWG.mjs";
|
|
2
2
|
//#region src/web.ts
|
|
3
3
|
function normalizeBlobPart(part) {
|
|
4
4
|
if (typeof part === "string") return Promise.resolve(encodeText(part));
|
|
5
|
-
if (part
|
|
6
|
-
if (part
|
|
5
|
+
if (isBlobLike(part)) return part.arrayBuffer();
|
|
6
|
+
if (isArrayBufferLike(part)) return Promise.resolve(cloneArrayBuffer(part));
|
|
7
7
|
if (ArrayBuffer.isView(part)) return Promise.resolve(cloneArrayBufferView(part));
|
|
8
8
|
return Promise.resolve(encodeText(String(part)));
|
|
9
9
|
}
|
|
@@ -17,7 +17,7 @@ var BlobPolyfill = class {
|
|
|
17
17
|
this.size = parts.reduce((total, part) => {
|
|
18
18
|
if (typeof part === "string") return total + String(part).length;
|
|
19
19
|
if (part && typeof part === "object" && typeof part.size === "number") return total + Number(part.size);
|
|
20
|
-
if (part
|
|
20
|
+
if (isArrayBufferLike(part)) return total + part.byteLength;
|
|
21
21
|
if (ArrayBuffer.isView(part)) return total + part.byteLength;
|
|
22
22
|
return total;
|
|
23
23
|
}, 0);
|
package/dist/websocket.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { RequestGlobalsEventTarget } from "./shared.mjs";
|
|
1
|
+
import { RequestGlobalsBlobLike, RequestGlobalsEventTarget } from "./shared.mjs";
|
|
2
2
|
import { WebSocketMiniProgramOptions } from "./networkDefaults.mjs";
|
|
3
3
|
import { BlobPolyfill } from "./web.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/websocket.d.ts
|
|
6
6
|
type WebSocketBinaryType = 'blob' | 'arraybuffer';
|
|
7
|
-
type WebSocketSendData = string | ArrayBuffer | ArrayBufferView | Blob;
|
|
7
|
+
type WebSocketSendData = string | ArrayBuffer | ArrayBufferView | Blob | RequestGlobalsBlobLike;
|
|
8
8
|
type WebSocketMessageData = string | ArrayBuffer | Blob | BlobPolyfill;
|
|
9
9
|
interface WebSocketCloseEventLike {
|
|
10
10
|
code: number;
|
package/dist/websocket.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-C4EOQbWG.mjs";
|
|
2
2
|
import { URLPolyfill } from "./url.mjs";
|
|
3
3
|
import { BlobPolyfill } from "./web.mjs";
|
|
4
4
|
import { resolveWebSocketMiniProgramOptions } from "./networkDefaults.mjs";
|
|
@@ -69,9 +69,9 @@ function isSocketTask(value) {
|
|
|
69
69
|
}
|
|
70
70
|
function toBinaryPayload(data) {
|
|
71
71
|
if (typeof data === "string") return data;
|
|
72
|
-
if (data
|
|
72
|
+
if (isArrayBufferLike(data)) return cloneArrayBuffer(data);
|
|
73
73
|
if (ArrayBuffer.isView(data)) return cloneArrayBufferView(data);
|
|
74
|
-
if (
|
|
74
|
+
if (isBlobLike(data)) return data.arrayBuffer();
|
|
75
75
|
throw new TypeError("Failed to execute send: data must be a string, ArrayBuffer, ArrayBufferView or Blob");
|
|
76
76
|
}
|
|
77
77
|
function createErrorEvent(error) {
|
package/dist/xhr.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as resolveRequestGlobalsHost, t as RequestGlobalsEventTarget } from "./shared-C4EOQbWG.mjs";
|
|
2
2
|
import { AbortControllerPolyfill } from "./abort.mjs";
|
|
3
3
|
import { HeadersPolyfill, headersToObject } from "./http.mjs";
|
|
4
|
-
import { t as fetch } from "./fetch-
|
|
4
|
+
import { t as fetch } from "./fetch-CKch4mSy.mjs";
|
|
5
5
|
//#region src/xhr.ts
|
|
6
6
|
function createProgressEvent(type) {
|
|
7
7
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/web-apis",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.24",
|
|
5
5
|
"description": "Web API polyfills and global installers for mini-program runtimes",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@weapp-core/constants": "0.1.12",
|
|
78
|
-
"@wevu/api": "0.2.
|
|
78
|
+
"@wevu/api": "0.2.10"
|
|
79
79
|
},
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public",
|