@wevu/web-apis 1.2.24 → 1.2.26

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.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { RequestGlobalsEventTarget } from "./shared.mjs";
2
-
3
2
  //#region src/abort.d.ts
4
3
  declare class AbortSignalPolyfill extends RequestGlobalsEventTarget {
5
4
  aborted: boolean;
package/dist/fetch.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { RequestGlobalsMiniProgramOptions } from "./networkDefaults.mjs";
2
2
  import { URLPolyfill } from "./url.mjs";
3
-
4
3
  //#region src/fetch.d.ts
5
4
  interface RequestLikeInput {
6
5
  url: string;
package/dist/http.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { RequestGlobalsBlobLike } from "./shared.mjs";
2
2
  import { URLPolyfill } from "./url.mjs";
3
3
  import { FormDataPolyfill } from "./web.mjs";
4
-
5
4
  //#region src/http.d.ts
6
5
  type HeaderRecord = Record<string, string>;
7
6
  declare class HeadersPolyfill {
package/dist/index.d.mts CHANGED
@@ -7,7 +7,6 @@ import { BlobPolyfill, FilePolyfill, FormDataPolyfill } from "./web.mjs";
7
7
  import { HeadersPolyfill, RequestPolyfill, ResponsePolyfill } from "./http.mjs";
8
8
  import { WebSocketPolyfill } from "./websocket.mjs";
9
9
  import { XMLHttpRequestPolyfill } from "./xhr.mjs";
10
-
11
10
  //#region src/base64.d.ts
12
11
  declare function btoaPolyfill(input?: string): string;
13
12
  declare function atobPolyfill(input?: string): string;
package/dist/index.mjs CHANGED
@@ -223,6 +223,14 @@ function hasUsableConstructor(value, args = []) {
223
223
  return false;
224
224
  }
225
225
  }
226
+ function hasWebCompatibleUrlConstructor(value) {
227
+ if (!hasUsableConstructor(value, ["https://request-globals.invalid"])) return false;
228
+ try {
229
+ return new value("123", "fake://abc").href === "fake://abc/123";
230
+ } catch {
231
+ return false;
232
+ }
233
+ }
226
234
  function assignHostGlobal(host, key, value) {
227
235
  try {
228
236
  host[key] = value;
@@ -381,7 +389,7 @@ function installSingleTarget(host, target) {
381
389
  if (target === "XMLHttpRequest" && (typeof host.XMLHttpRequest !== "function" || isPlaceholderRequestGlobal(host.XMLHttpRequest))) assignHostGlobal(host, "XMLHttpRequest", XMLHttpRequestPolyfill);
382
390
  }
383
391
  function installUrlGlobals(host) {
384
- if (!hasUsableConstructor(host.URL, ["https://request-globals.invalid"]) || !patchUrlConstructor(host)) assignHostGlobal(host, "URL", URLPolyfill);
392
+ if (!hasWebCompatibleUrlConstructor(host.URL) || !patchUrlConstructor(host)) assignHostGlobal(host, "URL", URLPolyfill);
385
393
  if (!hasUsableConstructor(host.URLSearchParams, ["client=graphql-request"]) || !patchUrlSearchParamsConstructor(host)) assignHostGlobal(host, "URLSearchParams", URLSearchParamsPolyfill);
386
394
  if (!hasUsableConstructor(host.Blob)) assignHostGlobal(host, "Blob", BlobPolyfill);
387
395
  if (!hasUsableConstructor(host.File, [[], "request-globals.bin"])) assignHostGlobal(host, "File", FilePolyfill);
@@ -1,5 +1,4 @@
1
1
  import { WeapiMiniProgramConnectSocketOption, WeapiMiniProgramRequestOption } from "@wevu/api";
2
-
3
2
  //#region src/networkDefaults.d.ts
4
3
  declare const MINI_PROGRAM_REQUEST_OPTION_KEYS: readonly ["enableCache", "enableChunked", "enableHttp2", "enableHttpDNS", "enableProfile", "enableQuic", "forceCellularNetwork", "httpDNSServiceId", "httpDNSTimeout", "redirect", "timeout", "useHighPerformanceMode"];
5
4
  declare const MINI_PROGRAM_SOCKET_OPTION_KEYS: readonly ["forceCellularNetwork", "header", "perMessageDeflate", "timeout"];
package/dist/url.mjs CHANGED
@@ -64,7 +64,7 @@ function resolveRelativeUrl(input, base) {
64
64
  }
65
65
  basePathSegments.push(segment);
66
66
  }
67
- return `${parsedBase.origin}/${basePathSegments.join("/")}`;
67
+ return `${parsedBase.origin}${basePathSegments.join("/")}`;
68
68
  }
69
69
  var URLSearchParamsPolyfill = class {
70
70
  onChange;
package/dist/web.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { RequestGlobalsBlobLike } from "./shared.mjs";
2
-
3
2
  //#region src/web.d.ts
4
3
  type BlobLikePart = RequestGlobalsBlobLike;
5
4
  type BlobPart = ArrayBuffer | ArrayBufferView | BlobLikePart | string;
@@ -1,7 +1,6 @@
1
1
  import { RequestGlobalsBlobLike, RequestGlobalsEventTarget } from "./shared.mjs";
2
2
  import { WebSocketMiniProgramOptions } from "./networkDefaults.mjs";
3
3
  import { BlobPolyfill } from "./web.mjs";
4
-
5
4
  //#region src/websocket.d.ts
6
5
  type WebSocketBinaryType = 'blob' | 'arraybuffer';
7
6
  type WebSocketSendData = string | ArrayBuffer | ArrayBufferView | Blob | RequestGlobalsBlobLike;
package/dist/xhr.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { RequestGlobalsEventTarget } from "./shared.mjs";
2
2
  import { RequestGlobalsMiniProgramOptions } from "./networkDefaults.mjs";
3
-
4
3
  //#region src/xhr.d.ts
5
4
  type XhrBody = Document | XMLHttpRequestBodyInit | null | undefined;
6
5
  declare class XMLHttpRequestUploadPolyfill extends RequestGlobalsEventTarget {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/web-apis",
3
3
  "type": "module",
4
- "version": "1.2.24",
4
+ "version": "1.2.26",
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.10"
78
+ "@wevu/api": "0.2.11"
79
79
  },
80
80
  "publishConfig": {
81
81
  "access": "public",