@wevu/web-apis 1.2.27 → 1.2.29

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { t as RequestGlobalsEventTarget } from "./shared-C4EOQbWG.mjs";
1
+ import { t as RequestGlobalsEventTarget } from "./shared-L1rGUbe0.mjs";
2
2
  //#region src/abort.ts
3
3
  function createAbortError(reason) {
4
4
  if (reason instanceof Error) return reason;
@@ -1,4 +1,4 @@
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";
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-L1rGUbe0.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";
@@ -99,12 +99,6 @@ function hasHeader(target, key) {
99
99
  }
100
100
  function mergeHeaderSource(target, source) {
101
101
  if (!source) return;
102
- if (typeof source.forEach === "function") {
103
- source.forEach((value, key) => {
104
- setHeader(target, key, value);
105
- });
106
- return;
107
- }
108
102
  if (typeof source[Symbol.iterator] === "function") {
109
103
  for (const entry of source) {
110
104
  if (!entry || entry.length < 2) continue;
@@ -112,6 +106,12 @@ function mergeHeaderSource(target, source) {
112
106
  }
113
107
  return;
114
108
  }
109
+ if (typeof source.forEach === "function") {
110
+ source.forEach((value, key) => {
111
+ setHeader(target, key, value);
112
+ });
113
+ return;
114
+ }
115
115
  if (!isObject(source)) return;
116
116
  for (const [key, value] of Object.entries(source)) {
117
117
  if (Array.isArray(value)) {
@@ -201,11 +201,9 @@ function fetch(input, init) {
201
201
  if (meta.signal?.aborted) return Promise.reject(createAbortError());
202
202
  return new Promise((resolve, reject) => {
203
203
  let settled = false;
204
- let aborted = false;
205
204
  let requestTask;
206
205
  function onAbort() {
207
206
  if (settled) return;
208
- aborted = true;
209
207
  requestTask?.abort();
210
208
  settled = true;
211
209
  if (meta.signal) meta.signal.removeEventListener("abort", onAbort);
@@ -232,10 +230,6 @@ function fetch(input, init) {
232
230
  if (settled) return;
233
231
  settled = true;
234
232
  cleanup();
235
- if (aborted) {
236
- reject(createAbortError());
237
- return;
238
- }
239
233
  const message = isObject(error) && typeof error.errMsg === "string" ? error.errMsg : String(error);
240
234
  reject(new TypeError(message));
241
235
  }
package/dist/fetch.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./http.mjs";
2
- import { t as fetch } from "./fetch-CKch4mSy.mjs";
2
+ import { t as fetch } from "./fetch-CAk2XQY6.mjs";
3
3
  export { fetch };
package/dist/http.mjs CHANGED
@@ -1,4 +1,4 @@
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";
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-L1rGUbe0.mjs";
2
2
  import { FormDataPolyfill } from "./web.mjs";
3
3
  //#region src/http.ts
4
4
  const SET_COOKIE_HEADER_NAME = "set-cookie";
@@ -12,16 +12,16 @@ var HeadersPolyfill = class {
12
12
  store = /* @__PURE__ */ new Map();
13
13
  constructor(init) {
14
14
  if (!init) return;
15
+ if (isIterableHeaders(init)) {
16
+ for (const [key, value] of init) this.append(key, value);
17
+ return;
18
+ }
15
19
  if (typeof init.forEach === "function") {
16
20
  init.forEach((value, key) => {
17
21
  this.set(key, value);
18
22
  });
19
23
  return;
20
24
  }
21
- if (isIterableHeaders(init)) {
22
- for (const [key, value] of init) this.append(key, value);
23
- return;
24
- }
25
25
  if (isHeaderObject(init)) for (const [key, value] of Object.entries(init)) this.append(key, Array.isArray(value) ? value.join(", ") : String(value));
26
26
  }
27
27
  append(key, value) {
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
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";
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-L1rGUbe0.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-CKch4mSy.mjs";
6
+ import { t as fetch } from "./fetch-CAk2XQY6.mjs";
7
7
  import { getMiniProgramNetworkDefaults, resetMiniProgramNetworkDefaults, setMiniProgramNetworkDefaults } from "./networkDefaults.mjs";
8
8
  import { WebSocketPolyfill } from "./websocket.mjs";
9
9
  import { XMLHttpRequestPolyfill } from "./xhr.mjs";
@@ -43,15 +43,15 @@ function atobPolyfill(input = "") {
43
43
  const char1 = source.charCodeAt(index + 1);
44
44
  const char2 = source.charAt(index + 2);
45
45
  const char3 = source.charAt(index + 3);
46
- const sextet0 = BASE64_LOOKUP[char0] ?? 255;
47
- const sextet1 = BASE64_LOOKUP[char1] ?? 255;
48
- const sextet2 = char2 === "=" ? 64 : BASE64_LOOKUP[source.charCodeAt(index + 2)] ?? 255;
49
- const sextet3 = char3 === "=" ? 64 : BASE64_LOOKUP[source.charCodeAt(index + 3)] ?? 255;
46
+ const sextet0 = BASE64_LOOKUP[char0];
47
+ const sextet1 = BASE64_LOOKUP[char1];
48
+ const sextet2 = !char2 || char2 === "=" ? 64 : BASE64_LOOKUP[source.charCodeAt(index + 2)];
49
+ const sextet3 = !char3 || char3 === "=" ? 64 : BASE64_LOOKUP[source.charCodeAt(index + 3)];
50
50
  if (sextet0 > 63 || sextet1 > 63 || sextet2 > 64 || sextet3 > 64) throw new TypeError("Failed to execute 'atob': the input is not correctly encoded");
51
51
  const triplet = sextet0 << 18 | sextet1 << 12 | (sextet2 & 63) << 6 | sextet3 & 63;
52
52
  output += String.fromCharCode(triplet >> 16 & 255);
53
- if (char2 !== "=") output += String.fromCharCode(triplet >> 8 & 255);
54
- if (char3 !== "=") output += String.fromCharCode(triplet & 255);
53
+ if (char2 && char2 !== "=") output += String.fromCharCode(triplet >> 8 & 255);
54
+ if (char3 && char3 !== "=") output += String.fromCharCode(triplet & 255);
55
55
  }
56
56
  return output;
57
57
  }
@@ -212,7 +212,7 @@ function resolveActualBindingTargets(targets) {
212
212
  return [...new Set(bindingTargets)];
213
213
  }
214
214
  function isPlaceholderRequestGlobal(value) {
215
- return Boolean(value && typeof value === "function" && value[REQUEST_GLOBAL_PLACEHOLDER_KEY] === true);
215
+ return Boolean(value && (typeof value === "function" || typeof value === "object") && value[REQUEST_GLOBAL_PLACEHOLDER_KEY] === true);
216
216
  }
217
217
  function hasUsableConstructor(value, args = []) {
218
218
  if (typeof value !== "function" || isPlaceholderRequestGlobal(value)) return false;
@@ -271,7 +271,6 @@ function createUrlCanParser(URLConstructor) {
271
271
  }
272
272
  function patchUrlConstructor(host) {
273
273
  const URLConstructor = host.URL;
274
- if (typeof URLConstructor !== "function" || isPlaceholderRequestGlobal(URLConstructor)) return false;
275
274
  let patched = true;
276
275
  if (typeof URLConstructor.parse !== "function") patched = assignHostGlobal(URLConstructor, "parse", createUrlParser(URLConstructor)) && patched;
277
276
  if (typeof URLConstructor.canParse !== "function") patched = assignHostGlobal(URLConstructor, "canParse", createUrlCanParser(URLConstructor)) && patched;
@@ -289,9 +288,8 @@ function sortUrlSearchParams() {
289
288
  for (const [key, value] of entries) this.append(key, value);
290
289
  }
291
290
  function patchUrlSearchParamsConstructor(host) {
292
- const URLSearchParamsConstructor = host.URLSearchParams;
293
- const prototype = URLSearchParamsConstructor?.prototype;
294
- if (typeof URLSearchParamsConstructor !== "function" || isPlaceholderRequestGlobal(URLSearchParamsConstructor) || !prototype) return false;
291
+ const prototype = host.URLSearchParams?.prototype;
292
+ if (!prototype) return false;
295
293
  let patched = true;
296
294
  if (!("size" in prototype)) patched = defineHostGlobal(prototype, "size", { get() {
297
295
  let size = 0;
@@ -304,9 +302,8 @@ function patchUrlSearchParamsConstructor(host) {
304
302
  return patched;
305
303
  }
306
304
  function patchHeadersConstructor(host) {
307
- const HeadersConstructor = host.Headers;
308
- const prototype = HeadersConstructor?.prototype;
309
- if (typeof HeadersConstructor !== "function" || isPlaceholderRequestGlobal(HeadersConstructor) || !prototype) return false;
305
+ const prototype = host.Headers?.prototype;
306
+ if (!prototype) return false;
310
307
  if (typeof prototype.getSetCookie === "function") return true;
311
308
  return assignHostGlobal(prototype, "getSetCookie", function getSetCookie() {
312
309
  const value = this.get("set-cookie");
@@ -315,7 +312,6 @@ function patchHeadersConstructor(host) {
315
312
  }
316
313
  function patchResponseConstructor(host) {
317
314
  const ResponseConstructor = host.Response;
318
- if (typeof ResponseConstructor !== "function" || isPlaceholderRequestGlobal(ResponseConstructor)) return false;
319
315
  let patched = true;
320
316
  if (typeof ResponseConstructor.json !== "function") patched = assignHostGlobal(ResponseConstructor, "json", ResponsePolyfill.json) && patched;
321
317
  if (typeof ResponseConstructor.error !== "function") patched = assignHostGlobal(ResponseConstructor, "error", ResponsePolyfill.error) && patched;
@@ -371,11 +367,11 @@ function installSingleTarget(host, target) {
371
367
  return;
372
368
  }
373
369
  if (target === "performance") {
374
- if (!host.performance || typeof host.performance.now !== "function") assignHostGlobal(host, "performance", performancePolyfill);
370
+ if (!host.performance || isPlaceholderRequestGlobal(host.performance) || typeof host.performance.now !== "function") assignHostGlobal(host, "performance", performancePolyfill);
375
371
  return;
376
372
  }
377
373
  if (target === "crypto") {
378
- if (!host.crypto || typeof host.crypto.getRandomValues !== "function") assignHostGlobal(host, "crypto", cryptoPolyfill);
374
+ if (!host.crypto || isPlaceholderRequestGlobal(host.crypto) || typeof host.crypto.getRandomValues !== "function") assignHostGlobal(host, "crypto", cryptoPolyfill);
379
375
  return;
380
376
  }
381
377
  if (target === "Event") {
@@ -413,11 +409,10 @@ function ensureRuntimeHostAliases(host) {
413
409
  }
414
410
  }
415
411
  function syncWeappViteRequestGlobalsActuals(host, targets) {
416
- const globalObject = host != null && (typeof host === "object" || typeof host === "function") ? host : resolveRequestGlobalsHost();
417
- let actuals = globalObject[REQUEST_GLOBAL_ACTUALS_KEY];
412
+ let actuals = host[REQUEST_GLOBAL_ACTUALS_KEY];
418
413
  if (!actuals || typeof actuals !== "object") {
419
414
  actuals = Object.create(null);
420
- assignHostGlobal(globalObject, REQUEST_GLOBAL_ACTUALS_KEY, actuals);
415
+ assignHostGlobal(host, REQUEST_GLOBAL_ACTUALS_KEY, actuals);
421
416
  }
422
417
  for (const target of resolveActualBindingTargets(targets)) {
423
418
  const value = host[target];
@@ -1,48 +1,5 @@
1
1
  import { URLPolyfill, URLSearchParamsPolyfill } from "./url.mjs";
2
- //#region ../../@weapp-core/shared/dist/index.js
3
- var __create = Object.create;
4
- var __defProp$1 = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp$1(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
24
- function isPlainObject(value) {
25
- if (value === null || typeof value !== "object") return false;
26
- const prototype = Object.getPrototypeOf(value);
27
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
28
- if (Symbol.iterator in value) return false;
29
- if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
30
- return true;
31
- }
32
- function _defu(baseObject, defaults, namespace = ".", merger) {
33
- if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
34
- const object = { ...defaults };
35
- for (const key of Object.keys(baseObject)) {
36
- if (key === "__proto__" || key === "constructor") continue;
37
- const value = baseObject[key];
38
- if (value === null || value === void 0) continue;
39
- if (merger && merger(object, key, value, namespace)) continue;
40
- if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
41
- else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
42
- else object[key] = value;
43
- }
44
- return object;
45
- }
2
+ //#region ../../@weapp-core/shared/dist/platforms-CoAy6Y88.js
46
3
  const DEFAULT_PROJECT_CONFIG_ROOT_KEYS = ["miniprogramRoot", "srcMiniprogramRoot"];
47
4
  const DEFAULT_RUNTIME_CAPABILITIES = Object.freeze({
48
5
  globalPageStack: true,
@@ -392,168 +349,6 @@ function getMiniProgramRuntimeGlobalKeys(platform) {
392
349
  if (platform) return [getMiniProgramRuntimeGlobalKey(platform)];
393
350
  return ORDERED_RUNTIME_GLOBAL_KEYS;
394
351
  }
395
- /*!
396
- * get-value <https://github.com/jonschlinkert/get-value>
397
- *
398
- * Copyright (c) 2014-present, Jon Schlinkert.
399
- * Released under the MIT License.
400
- */
401
- /*!
402
- * is-primitive <https://github.com/jonschlinkert/is-primitive>
403
- *
404
- * Copyright (c) 2014-present, Jon Schlinkert.
405
- * Released under the MIT License.
406
- */
407
- var require_is_primitive = /* @__PURE__ */ __commonJSMin(((exports, module) => {
408
- module.exports = function isPrimitive(val) {
409
- if (typeof val === "object") return val === null;
410
- return typeof val !== "function";
411
- };
412
- }));
413
- /*!
414
- * isobject <https://github.com/jonschlinkert/isobject>
415
- *
416
- * Copyright (c) 2014-2017, Jon Schlinkert.
417
- * Released under the MIT License.
418
- */
419
- var require_isobject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
420
- module.exports = function isObject(val) {
421
- return val != null && typeof val === "object" && Array.isArray(val) === false;
422
- };
423
- }));
424
- /*!
425
- * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
426
- *
427
- * Copyright (c) 2014-2017, Jon Schlinkert.
428
- * Released under the MIT License.
429
- */
430
- var require_is_plain_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
431
- var isObject = require_isobject();
432
- function isObjectObject(o) {
433
- return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
434
- }
435
- module.exports = function isPlainObject(o) {
436
- var ctor, prot;
437
- if (isObjectObject(o) === false) return false;
438
- ctor = o.constructor;
439
- if (typeof ctor !== "function") return false;
440
- prot = ctor.prototype;
441
- if (isObjectObject(prot) === false) return false;
442
- if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
443
- return true;
444
- };
445
- }));
446
- /*!
447
- * set-value <https://github.com/jonschlinkert/set-value>
448
- *
449
- * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
450
- * Released under the MIT License.
451
- */
452
- (/* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
453
- const { deleteProperty } = Reflect;
454
- const isPrimitive = require_is_primitive();
455
- const isPlainObject = require_is_plain_object();
456
- const isObject = (value) => {
457
- return typeof value === "object" && value !== null || typeof value === "function";
458
- };
459
- const isUnsafeKey = (key) => {
460
- return key === "__proto__" || key === "constructor" || key === "prototype";
461
- };
462
- const validateKey = (key) => {
463
- if (!isPrimitive(key)) throw new TypeError("Object keys must be strings or symbols");
464
- if (isUnsafeKey(key)) throw new Error(`Cannot set unsafe key: "${key}"`);
465
- };
466
- const toStringKey = (input) => {
467
- return Array.isArray(input) ? input.flat().map(String).join(",") : input;
468
- };
469
- const createMemoKey = (input, options) => {
470
- if (typeof input !== "string" || !options) return input;
471
- let key = input + ";";
472
- if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
473
- if (options.separator !== void 0) key += `separator=${options.separator};`;
474
- if (options.split !== void 0) key += `split=${options.split};`;
475
- if (options.merge !== void 0) key += `merge=${options.merge};`;
476
- if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
477
- return key;
478
- };
479
- const memoize = (input, options, fn) => {
480
- const key = toStringKey(options ? createMemoKey(input, options) : input);
481
- validateKey(key);
482
- const value = setValue.cache.get(key) || fn();
483
- setValue.cache.set(key, value);
484
- return value;
485
- };
486
- const splitString = (input, options = {}) => {
487
- const sep = options.separator || ".";
488
- const preserve = sep === "/" ? false : options.preservePaths;
489
- if (typeof input === "string" && preserve !== false && /\//.test(input)) return [input];
490
- const parts = [];
491
- let part = "";
492
- const push = (part) => {
493
- let number;
494
- if (part.trim() !== "" && Number.isInteger(number = Number(part))) parts.push(number);
495
- else parts.push(part);
496
- };
497
- for (let i = 0; i < input.length; i++) {
498
- const value = input[i];
499
- if (value === "\\") {
500
- part += input[++i];
501
- continue;
502
- }
503
- if (value === sep) {
504
- push(part);
505
- part = "";
506
- continue;
507
- }
508
- part += value;
509
- }
510
- if (part) push(part);
511
- return parts;
512
- };
513
- const split = (input, options) => {
514
- if (options && typeof options.split === "function") return options.split(input);
515
- if (typeof input === "symbol") return [input];
516
- if (Array.isArray(input)) return input;
517
- return memoize(input, options, () => splitString(input, options));
518
- };
519
- const assignProp = (obj, prop, value, options) => {
520
- validateKey(prop);
521
- if (value === void 0) deleteProperty(obj, prop);
522
- else if (options && options.merge) {
523
- const merge = options.merge === "function" ? options.merge : Object.assign;
524
- if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) obj[prop] = merge(obj[prop], value);
525
- else obj[prop] = value;
526
- } else obj[prop] = value;
527
- return obj;
528
- };
529
- const setValue = (target, path, value, options) => {
530
- if (!path || !isObject(target)) return target;
531
- const keys = split(path, options);
532
- let obj = target;
533
- for (let i = 0; i < keys.length; i++) {
534
- const key = keys[i];
535
- const next = keys[i + 1];
536
- validateKey(key);
537
- if (next === void 0) {
538
- assignProp(obj, key, value, options);
539
- break;
540
- }
541
- if (typeof next === "number" && !Array.isArray(obj[key])) {
542
- obj = obj[key] = [];
543
- continue;
544
- }
545
- if (!isObject(obj[key])) obj[key] = {};
546
- obj = obj[key];
547
- }
548
- return target;
549
- };
550
- setValue.split = split;
551
- setValue.cache = /* @__PURE__ */ new Map();
552
- setValue.clear = () => {
553
- setValue.cache = /* @__PURE__ */ new Map();
554
- };
555
- module.exports = setValue;
556
- })))(), 1)).default;
557
352
  //#endregion
558
353
  //#region src/constructors.ts
559
354
  function resolveUrlConstructor() {
@@ -602,8 +397,7 @@ var RequestGlobalsEventTarget = class {
602
397
  }
603
398
  };
604
399
  function resolveRequestGlobalsHost() {
605
- if (typeof globalThis !== "undefined") return globalThis;
606
- return {};
400
+ return globalThis;
607
401
  }
608
402
  function isRequestGlobalsHostCandidate(value) {
609
403
  return value != null && (typeof value === "object" || typeof value === "function");
package/dist/shared.mjs CHANGED
@@ -1,2 +1,2 @@
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";
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-L1rGUbe0.mjs";
2
2
  export { RequestGlobalsEventTarget, cloneArrayBuffer, cloneArrayBufferView, decodeText, decodeTextFallback, encodeText, encodeTextFallback, installRequestGlobalBinding, isArrayBufferLike, isBlobLike, normalizeHeaderName, resolveRequestGlobalsHost, resolveRequestGlobalsHosts };
package/dist/url.mjs CHANGED
@@ -29,7 +29,7 @@ function parseAbsoluteUrl(input) {
29
29
  const match = input.match(ABSOLUTE_URL_REGEXP);
30
30
  if (!match) return null;
31
31
  const protocol = match[1] ?? "";
32
- const host = match[2] ?? "";
32
+ const host = match[2];
33
33
  const pathname = match[3] || "/";
34
34
  const search = match[4] ?? "";
35
35
  const hash = match[5] ?? "";
@@ -37,7 +37,7 @@ function parseAbsoluteUrl(input) {
37
37
  return {
38
38
  protocol,
39
39
  host,
40
- hostname: hostnameMatch?.[1] ?? host,
40
+ hostname: hostnameMatch[1],
41
41
  port: hostnameMatch?.[2] ?? "",
42
42
  pathname,
43
43
  search,
@@ -51,10 +51,7 @@ function resolveRelativeUrl(input, base) {
51
51
  if (!parsedBase) throw new TypeError(`Failed to construct URL from base ${base}`);
52
52
  if (input.startsWith("//")) return `${parsedBase.protocol}${input}`;
53
53
  if (input.startsWith("/")) return `${parsedBase.origin}${input}`;
54
- if (input.startsWith("?") || input.startsWith("#")) {
55
- const pathname = parsedBase.pathname || "/";
56
- return `${`${parsedBase.origin}${pathname}`}${input}`;
57
- }
54
+ if (input.startsWith("?") || input.startsWith("#")) return `${`${parsedBase.origin}${parsedBase.pathname}`}${input}`;
58
55
  const basePathSegments = parsedBase.pathname.split("/").slice(0, -1);
59
56
  for (const segment of input.split("/")) {
60
57
  if (!segment || segment === ".") continue;
@@ -71,7 +68,7 @@ var URLSearchParamsPolyfill = class {
71
68
  entriesStore = [];
72
69
  constructor(init, onChange) {
73
70
  this.onChange = onChange;
74
- if (!init) return;
71
+ if (init == null) return;
75
72
  if (typeof init === "string") {
76
73
  this.entriesStore.push(...parseSearchEntries(init));
77
74
  return;
@@ -103,7 +100,8 @@ var URLSearchParamsPolyfill = class {
103
100
  }
104
101
  get(key) {
105
102
  const normalizedKey = String(key);
106
- return this.entriesStore.find(([entryKey]) => entryKey === normalizedKey)?.[1] ?? null;
103
+ const found = this.entriesStore.find(([entryKey]) => entryKey === normalizedKey);
104
+ return found ? found[1] : null;
107
105
  }
108
106
  getAll(key) {
109
107
  const normalizedKey = String(key);
package/dist/web.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as decodeText, l as isArrayBufferLike, n as cloneArrayBuffer, o as encodeText, r as cloneArrayBufferView, u as isBlobLike } from "./shared-C4EOQbWG.mjs";
1
+ import { i as decodeText, l as isArrayBufferLike, n as cloneArrayBuffer, o as encodeText, r as cloneArrayBufferView, u as isBlobLike } from "./shared-L1rGUbe0.mjs";
2
2
  //#region src/web.ts
3
3
  function normalizeBlobPart(part) {
4
4
  if (typeof part === "string") return Promise.resolve(encodeText(part));
@@ -1,4 +1,4 @@
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";
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-L1rGUbe0.mjs";
2
2
  import { URLPolyfill } from "./url.mjs";
3
3
  import { BlobPolyfill } from "./web.mjs";
4
4
  import { resolveWebSocketMiniProgramOptions } from "./networkDefaults.mjs";
package/dist/xhr.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { f as resolveRequestGlobalsHost, t as RequestGlobalsEventTarget } from "./shared-C4EOQbWG.mjs";
1
+ import { f as resolveRequestGlobalsHost, t as RequestGlobalsEventTarget } from "./shared-L1rGUbe0.mjs";
2
2
  import { AbortControllerPolyfill } from "./abort.mjs";
3
3
  import { HeadersPolyfill, headersToObject } from "./http.mjs";
4
- import { t as fetch } from "./fetch-CKch4mSy.mjs";
4
+ import { t as fetch } from "./fetch-CAk2XQY6.mjs";
5
5
  //#region src/xhr.ts
6
6
  function createProgressEvent(type) {
7
7
  return {
@@ -11,9 +11,9 @@ function createProgressEvent(type) {
11
11
  total: 0
12
12
  };
13
13
  }
14
- function createError(type) {
15
- const error = new Error(type);
16
- error.name = type === "abort" ? "AbortError" : type === "timeout" ? "TimeoutError" : "NetworkError";
14
+ function createTimeoutError() {
15
+ const error = /* @__PURE__ */ new Error("timeout");
16
+ error.name = "TimeoutError";
17
17
  return error;
18
18
  }
19
19
  function resolveFetch() {
@@ -98,7 +98,7 @@ var XMLHttpRequestPolyfill = class XMLHttpRequestPolyfill extends RequestGlobals
98
98
  const controller = new (typeof AbortController === "function" ? AbortController : AbortControllerPolyfill)();
99
99
  this.requestController = controller;
100
100
  if (this.timeout > 0) this.timeoutId = setTimeout(() => {
101
- controller.abort(createError("timeout"));
101
+ controller.abort(createTimeoutError());
102
102
  }, this.timeout);
103
103
  try {
104
104
  const response = await resolveFetch()(this.url, {
@@ -122,7 +122,7 @@ var XMLHttpRequestPolyfill = class XMLHttpRequestPolyfill extends RequestGlobals
122
122
  }
123
123
  this.finish("load");
124
124
  } catch (error) {
125
- const reason = controller.signal && "reason" in controller.signal ? controller.signal.reason : void 0;
125
+ const reason = controller.signal.reason;
126
126
  if (controller.signal?.aborted) {
127
127
  const type = reason instanceof Error && reason.name === "TimeoutError" ? "timeout" : "abort";
128
128
  this.finish(type);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/web-apis",
3
3
  "type": "module",
4
- "version": "1.2.27",
4
+ "version": "1.2.29",
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",
@@ -74,8 +74,8 @@
74
74
  "node": "^20.19.0 || >=22.12.0"
75
75
  },
76
76
  "dependencies": {
77
- "@weapp-core/constants": "0.1.13",
78
- "@wevu/api": "0.2.11"
77
+ "@weapp-core/constants": "0.1.15",
78
+ "@wevu/api": "0.2.13"
79
79
  },
80
80
  "publishConfig": {
81
81
  "access": "public",
@@ -85,6 +85,7 @@
85
85
  "dev": "tsdown -w --sourcemap",
86
86
  "build": "tsdown",
87
87
  "test": "vitest run",
88
+ "test:coverage": "cross-env WEAPP_VITE_WEB_COVERAGE_STRICT=1 vitest run --coverage",
88
89
  "test:dev": "vitest",
89
90
  "pretest:types": "pnpm build",
90
91
  "test:types": "tsd",