fetch-xhr-shim 1.0.3 → 1.0.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/cjs/dev.js +1 -0
- package/dist/cjs/event-system/AbortSignalP.js +2 -2
- package/dist/cjs/fetch-api/BodyImpl.js +1 -1
- package/dist/cjs/fetch-api/HeadersP.js +3 -3
- package/dist/cjs/fetch-api/fetchP.js +2 -2
- package/dist/cjs/network/FormDataP.js +24 -4
- package/dist/cjs/network/URLSearchParamsP.js +3 -3
- package/dist/cjs/utils.js +15 -0
- package/dist/dev.d.ts +2 -1
- package/dist/esm/dev.js +1 -1
- package/dist/esm/event-system/AbortSignalP.js +2 -2
- package/dist/esm/fetch-api/BodyImpl.js +1 -1
- package/dist/esm/fetch-api/HeadersP.js +4 -4
- package/dist/esm/fetch-api/fetchP.js +2 -2
- package/dist/esm/network/FormDataP.js +25 -5
- package/dist/esm/network/URLSearchParamsP.js +4 -4
- package/dist/esm/utils.js +15 -1
- package/dist/fetch-xhr-shim.cjs.js +78 -23
- package/dist/fetch-xhr-shim.cjs.min.js +1 -1
- package/dist/fetch-xhr-shim.esm.js +78 -23
- package/dist/fetch-xhr-shim.esm.min.js +1 -1
- package/dist/fetch-xhr-shim.polyfill.iife.js +78 -23
- package/dist/fetch-xhr-shim.polyfill.iife.min.js +1 -1
- package/package.json +1 -1
- package/polyfill.js +78 -23
package/dist/cjs/dev.js
CHANGED
|
@@ -44,10 +44,10 @@ class AbortSignalP extends EventTargetP.EventTargetP {
|
|
|
44
44
|
}
|
|
45
45
|
/** @internal */
|
|
46
46
|
constructor() {
|
|
47
|
-
|
|
47
|
+
super();
|
|
48
|
+
if (this.constructor === AbortSignalP) {
|
|
48
49
|
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
49
50
|
}
|
|
50
|
-
super();
|
|
51
51
|
utils.setState(this, "__AbortSignal__", new AbortSignalState(this));
|
|
52
52
|
}
|
|
53
53
|
get aborted() { return state(this).aborted; }
|
|
@@ -69,7 +69,7 @@ class Payload {
|
|
|
69
69
|
class BodyImpl {
|
|
70
70
|
/** @internal */
|
|
71
71
|
constructor() {
|
|
72
|
-
if (
|
|
72
|
+
if (this.constructor === BodyImpl) {
|
|
73
73
|
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
74
74
|
}
|
|
75
75
|
utils.setState(this, "__Body__", new BodyState());
|
|
@@ -77,17 +77,17 @@ class HeadersP {
|
|
|
77
77
|
entries() {
|
|
78
78
|
let array = [];
|
|
79
79
|
this.forEach(function (value, name) { array.push([name, value]); });
|
|
80
|
-
return
|
|
80
|
+
return utils.makeIterator(array);
|
|
81
81
|
}
|
|
82
82
|
keys() {
|
|
83
83
|
let array = [];
|
|
84
84
|
this.forEach(function (value, name) { array.push([name, value]); });
|
|
85
|
-
return array.map(function (x) { return x[0]; })
|
|
85
|
+
return utils.makeIterator(array.map(function (x) { return x[0]; }));
|
|
86
86
|
}
|
|
87
87
|
values() {
|
|
88
88
|
let array = [];
|
|
89
89
|
this.forEach(function (value, name) { array.push([name, value]); });
|
|
90
|
-
return array.map(function (x) { return x[1]; })
|
|
90
|
+
return utils.makeIterator(array.map(function (x) { return x[1]; }));
|
|
91
91
|
}
|
|
92
92
|
// @ts-ignore
|
|
93
93
|
/** @internal */ [utils._Symbol.iterator]() {
|
|
@@ -9,8 +9,8 @@ var HeadersP = require('./HeadersP.js');
|
|
|
9
9
|
const mp = { XMLHttpRequest: (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || undefined };
|
|
10
10
|
function setXMLHttpRequestClass(XHRClass) { mp.XMLHttpRequest = XHRClass; }
|
|
11
11
|
function fetchP(input, init) {
|
|
12
|
-
utils.checkArgsLength(arguments.length, 1, "Window", "fetch");
|
|
13
|
-
if (
|
|
12
|
+
utils.checkArgsLength(arguments.length, 1, "Window", "fetch"); // @ts-expect-error
|
|
13
|
+
if (this instanceof fetchP) {
|
|
14
14
|
throw new TypeError("fetch is not a constructor");
|
|
15
15
|
}
|
|
16
16
|
return new Promise(function (resolve, reject) {
|
|
@@ -12,7 +12,7 @@ class FormDataP {
|
|
|
12
12
|
let elements = form.elements;
|
|
13
13
|
for (let i = 0; i < elements.length; ++i) {
|
|
14
14
|
let elm = elements[i];
|
|
15
|
-
if (!elm.name || elm.disabled || elm.type === "submit" || elm.type === "button" ||
|
|
15
|
+
if (!elm.name || elm.disabled || elm.type === "submit" || elm.type === "button" || matches(elm, "form fieldset[disabled] *"))
|
|
16
16
|
return;
|
|
17
17
|
if (elm.type === "file") {
|
|
18
18
|
let files = elm.files && elm.files.length
|
|
@@ -140,13 +140,13 @@ class FormDataP {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
entries() {
|
|
143
|
-
return state(this).array.map(function (x) { return [x[0], x[1]]; })
|
|
143
|
+
return utils.makeIterator(state(this).array.map(function (x) { return [x[0], x[1]]; }));
|
|
144
144
|
}
|
|
145
145
|
keys() {
|
|
146
|
-
return state(this).array.map(function (x) { return x[0]; })
|
|
146
|
+
return utils.makeIterator(state(this).array.map(function (x) { return x[0]; }));
|
|
147
147
|
}
|
|
148
148
|
values() {
|
|
149
|
-
return state(this).array.map(function (x) { return x[1]; })
|
|
149
|
+
return utils.makeIterator(state(this).array.map(function (x) { return x[1]; }));
|
|
150
150
|
}
|
|
151
151
|
// @ts-ignore
|
|
152
152
|
/** @internal */ [utils._Symbol.iterator]() {
|
|
@@ -183,6 +183,26 @@ function normalizeArgs(name, value, filename) {
|
|
|
183
183
|
}
|
|
184
184
|
return ["" + name, "" + value];
|
|
185
185
|
}
|
|
186
|
+
// Polyfill for Element.prototype.matches,
|
|
187
|
+
// tries native, then vendor prefixes, then querySelectorAll fallback.
|
|
188
|
+
function matches(elm, selectors) {
|
|
189
|
+
let proto = (typeof Element !== "undefined" && Element && Element.prototype);
|
|
190
|
+
if (proto && !proto.matches) {
|
|
191
|
+
proto.matches = // @ts-ignore
|
|
192
|
+
proto.matchesSelector || // @ts-ignore
|
|
193
|
+
proto.mozMatchesSelector || // @ts-ignore
|
|
194
|
+
proto.msMatchesSelector || // @ts-ignore
|
|
195
|
+
proto.oMatchesSelector || // @ts-ignore
|
|
196
|
+
proto.webkitMatchesSelector || // @ts-ignore
|
|
197
|
+
function (s) {
|
|
198
|
+
let matches = (this.ownerDocument || this.document).querySelectorAll(s);
|
|
199
|
+
let i = matches.length;
|
|
200
|
+
while (--i >= 0 && matches.item(i) !== this) { }
|
|
201
|
+
return i > -1;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return proto ? proto.matches.call(elm, selectors) : false;
|
|
205
|
+
}
|
|
186
206
|
function isFormData(value) {
|
|
187
207
|
return utils.isPolyfillType("FormData", value) || isExternalFormData(value);
|
|
188
208
|
}
|
|
@@ -160,13 +160,13 @@ class URLSearchParamsP {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
entries() {
|
|
163
|
-
return state(this).array.map(function (x) { return [x[0], x[1]]; })
|
|
163
|
+
return utils.makeIterator(state(this).array.map(function (x) { return [x[0], x[1]]; }));
|
|
164
164
|
}
|
|
165
165
|
keys() {
|
|
166
|
-
return state(this).array.map(function (x) { return x[0]; })
|
|
166
|
+
return utils.makeIterator(state(this).array.map(function (x) { return x[0]; }));
|
|
167
167
|
}
|
|
168
168
|
values() {
|
|
169
|
-
return state(this).array.map(function (x) { return x[1]; })
|
|
169
|
+
return utils.makeIterator(state(this).array.map(function (x) { return x[1]; }));
|
|
170
170
|
}
|
|
171
171
|
// @ts-ignore
|
|
172
172
|
/** @internal */ [utils._Symbol.iterator]() {
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// Safe fallback for Symbol.iterator and Symbol.toStringTag — uses native Symbol when available, string keys otherwise.
|
|
3
4
|
const _Symbol = {
|
|
4
5
|
iterator: ((typeof Symbol === "function" && Symbol.iterator) || "Symbol(Symbol.iterator)"),
|
|
5
6
|
toStringTag: ((typeof Symbol === "function" && Symbol.toStringTag) || "Symbol(Symbol.toStringTag)"),
|
|
@@ -53,6 +54,19 @@ function isSequence(value) {
|
|
|
53
54
|
&& Symbol.iterator in value
|
|
54
55
|
&& typeof value[Symbol.iterator] === "function");
|
|
55
56
|
}
|
|
57
|
+
function makeIterator(array) {
|
|
58
|
+
let index = 0;
|
|
59
|
+
let iterator = {
|
|
60
|
+
next: function () {
|
|
61
|
+
if (index < array.length) {
|
|
62
|
+
return { value: array[index++], done: false };
|
|
63
|
+
}
|
|
64
|
+
return { value: undefined, done: true };
|
|
65
|
+
},
|
|
66
|
+
[_Symbol.iterator]: function () { return iterator; },
|
|
67
|
+
};
|
|
68
|
+
return iterator;
|
|
69
|
+
}
|
|
56
70
|
function checkArgsLength(actual, expect, className, funcName) {
|
|
57
71
|
if (actual < expect) {
|
|
58
72
|
throw new TypeError(`Failed to ${funcName ? ("execute '" + funcName + "' on") : "construct"} '${className}': ${expect} argument${expect > 1 ? "s" : ""} required, but only ${actual} present.`);
|
|
@@ -67,4 +81,5 @@ exports.className = className;
|
|
|
67
81
|
exports.isObjectType = isObjectType;
|
|
68
82
|
exports.isPolyfillType = isPolyfillType;
|
|
69
83
|
exports.isSequence = isSequence;
|
|
84
|
+
exports.makeIterator = makeIterator;
|
|
70
85
|
exports.setState = setState;
|
package/dist/dev.d.ts
CHANGED
|
@@ -141,6 +141,7 @@ declare function setState<T extends object, K extends keyof T>(target: T, name:
|
|
|
141
141
|
declare function isObjectType<T>(name: string, value: unknown): value is T;
|
|
142
142
|
declare function isPolyfillType<T>(name: string, value: unknown, strict?: boolean): value is T;
|
|
143
143
|
declare function isSequence(value: unknown): value is any[];
|
|
144
|
+
declare function makeIterator<T>(array: T[]): IterableIterator<T>;
|
|
144
145
|
declare function checkArgsLength(actual: number, expect: number, className: string, funcName?: string): void;
|
|
145
146
|
|
|
146
|
-
export { AbortSignal_abort, BodyImpl, DOMExceptionE as DOMException, DOMExceptionP, EventTarget_dispatchEvent, Event_setTrusted, FormData_toBlob, Payload, ProgressEventP, Uint8Array_toBase64, _Symbol, attachFn, checkArgsLength, className, createAbortSignal, createFormDataFromBinaryText, createHeaders, createPhonyPayload, decode, emitProgressEvent, encode, executeFn, extractBoundary, initBody, isArrayBuffer, isBlob, isEventTarget, isFormData, isHeaders, isObjectType, isPolyfillType, isSequence, isURLSearchParams, normalizeMethod, normalizeName, normalizeValue, parseHeaders, setState };
|
|
147
|
+
export { AbortSignal_abort, BodyImpl, DOMExceptionE as DOMException, DOMExceptionP, EventTarget_dispatchEvent, Event_setTrusted, FormData_toBlob, Payload, ProgressEventP, Uint8Array_toBase64, _Symbol, attachFn, checkArgsLength, className, createAbortSignal, createFormDataFromBinaryText, createHeaders, createPhonyPayload, decode, emitProgressEvent, encode, executeFn, extractBoundary, initBody, isArrayBuffer, isBlob, isEventTarget, isFormData, isHeaders, isObjectType, isPolyfillType, isSequence, isURLSearchParams, makeIterator, normalizeMethod, normalizeName, normalizeValue, parseHeaders, setState };
|
package/dist/esm/dev.js
CHANGED
|
@@ -10,4 +10,4 @@ export { FormData_toBlob, createFormDataFromBinaryText, extractBoundary, isFormD
|
|
|
10
10
|
export { createHeaders, isHeaders, normalizeName, normalizeValue, parseHeaders } from './fetch-api/HeadersP.js';
|
|
11
11
|
export { BodyImpl, Payload, initBody } from './fetch-api/BodyImpl.js';
|
|
12
12
|
export { createPhonyPayload, normalizeMethod } from './fetch-api/RequestP.js';
|
|
13
|
-
export { DOMException, DOMExceptionP, _Symbol, checkArgsLength, className, isObjectType, isPolyfillType, isSequence, setState } from './utils.js';
|
|
13
|
+
export { DOMException, DOMExceptionP, _Symbol, checkArgsLength, className, isObjectType, isPolyfillType, isSequence, makeIterator, setState } from './utils.js';
|
|
@@ -42,10 +42,10 @@ class AbortSignalP extends EventTargetP {
|
|
|
42
42
|
}
|
|
43
43
|
/** @internal */
|
|
44
44
|
constructor() {
|
|
45
|
-
|
|
45
|
+
super();
|
|
46
|
+
if (this.constructor === AbortSignalP) {
|
|
46
47
|
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
47
48
|
}
|
|
48
|
-
super();
|
|
49
49
|
setState(this, "__AbortSignal__", new AbortSignalState(this));
|
|
50
50
|
}
|
|
51
51
|
get aborted() { return state(this).aborted; }
|
|
@@ -67,7 +67,7 @@ class Payload {
|
|
|
67
67
|
class BodyImpl {
|
|
68
68
|
/** @internal */
|
|
69
69
|
constructor() {
|
|
70
|
-
if (
|
|
70
|
+
if (this.constructor === BodyImpl) {
|
|
71
71
|
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
72
72
|
}
|
|
73
73
|
setState(this, "__Body__", new BodyState());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { setState, isSequence, _Symbol, isPolyfillType, checkArgsLength } from '../utils.js';
|
|
1
|
+
import { setState, isSequence, makeIterator, _Symbol, isPolyfillType, checkArgsLength } from '../utils.js';
|
|
2
2
|
|
|
3
3
|
class HeadersP {
|
|
4
4
|
constructor(init) {
|
|
@@ -75,17 +75,17 @@ class HeadersP {
|
|
|
75
75
|
entries() {
|
|
76
76
|
let array = [];
|
|
77
77
|
this.forEach(function (value, name) { array.push([name, value]); });
|
|
78
|
-
return array
|
|
78
|
+
return makeIterator(array);
|
|
79
79
|
}
|
|
80
80
|
keys() {
|
|
81
81
|
let array = [];
|
|
82
82
|
this.forEach(function (value, name) { array.push([name, value]); });
|
|
83
|
-
return array.map(function (x) { return x[0]; })
|
|
83
|
+
return makeIterator(array.map(function (x) { return x[0]; }));
|
|
84
84
|
}
|
|
85
85
|
values() {
|
|
86
86
|
let array = [];
|
|
87
87
|
this.forEach(function (value, name) { array.push([name, value]); });
|
|
88
|
-
return array.map(function (x) { return x[1]; })
|
|
88
|
+
return makeIterator(array.map(function (x) { return x[1]; }));
|
|
89
89
|
}
|
|
90
90
|
// @ts-ignore
|
|
91
91
|
/** @internal */ [_Symbol.iterator]() {
|
|
@@ -7,8 +7,8 @@ import { parseHeaders, isHeaders, normalizeName, normalizeValue } from './Header
|
|
|
7
7
|
const mp = { XMLHttpRequest: (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || undefined };
|
|
8
8
|
function setXMLHttpRequestClass(XHRClass) { mp.XMLHttpRequest = XHRClass; }
|
|
9
9
|
function fetchP(input, init) {
|
|
10
|
-
checkArgsLength(arguments.length, 1, "Window", "fetch");
|
|
11
|
-
if (
|
|
10
|
+
checkArgsLength(arguments.length, 1, "Window", "fetch"); // @ts-expect-error
|
|
11
|
+
if (this instanceof fetchP) {
|
|
12
12
|
throw new TypeError("fetch is not a constructor");
|
|
13
13
|
}
|
|
14
14
|
return new Promise(function (resolve, reject) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { File as FileE, FileP as FilePolyfill } from '../file-system/FileP.js';
|
|
2
2
|
import { Blob as BlobE, BlobP, isBlob } from '../file-system/BlobP.js';
|
|
3
|
-
import { setState, _Symbol, isPolyfillType, checkArgsLength } from '../utils.js';
|
|
3
|
+
import { setState, makeIterator, _Symbol, isPolyfillType, checkArgsLength } from '../utils.js';
|
|
4
4
|
|
|
5
5
|
class FormDataP {
|
|
6
6
|
constructor(form, submitter) {
|
|
@@ -10,7 +10,7 @@ class FormDataP {
|
|
|
10
10
|
let elements = form.elements;
|
|
11
11
|
for (let i = 0; i < elements.length; ++i) {
|
|
12
12
|
let elm = elements[i];
|
|
13
|
-
if (!elm.name || elm.disabled || elm.type === "submit" || elm.type === "button" ||
|
|
13
|
+
if (!elm.name || elm.disabled || elm.type === "submit" || elm.type === "button" || matches(elm, "form fieldset[disabled] *"))
|
|
14
14
|
return;
|
|
15
15
|
if (elm.type === "file") {
|
|
16
16
|
let files = elm.files && elm.files.length
|
|
@@ -138,13 +138,13 @@ class FormDataP {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
entries() {
|
|
141
|
-
return state(this).array.map(function (x) { return [x[0], x[1]]; })
|
|
141
|
+
return makeIterator(state(this).array.map(function (x) { return [x[0], x[1]]; }));
|
|
142
142
|
}
|
|
143
143
|
keys() {
|
|
144
|
-
return state(this).array.map(function (x) { return x[0]; })
|
|
144
|
+
return makeIterator(state(this).array.map(function (x) { return x[0]; }));
|
|
145
145
|
}
|
|
146
146
|
values() {
|
|
147
|
-
return state(this).array.map(function (x) { return x[1]; })
|
|
147
|
+
return makeIterator(state(this).array.map(function (x) { return x[1]; }));
|
|
148
148
|
}
|
|
149
149
|
// @ts-ignore
|
|
150
150
|
/** @internal */ [_Symbol.iterator]() {
|
|
@@ -181,6 +181,26 @@ function normalizeArgs(name, value, filename) {
|
|
|
181
181
|
}
|
|
182
182
|
return ["" + name, "" + value];
|
|
183
183
|
}
|
|
184
|
+
// Polyfill for Element.prototype.matches,
|
|
185
|
+
// tries native, then vendor prefixes, then querySelectorAll fallback.
|
|
186
|
+
function matches(elm, selectors) {
|
|
187
|
+
let proto = (typeof Element !== "undefined" && Element && Element.prototype);
|
|
188
|
+
if (proto && !proto.matches) {
|
|
189
|
+
proto.matches = // @ts-ignore
|
|
190
|
+
proto.matchesSelector || // @ts-ignore
|
|
191
|
+
proto.mozMatchesSelector || // @ts-ignore
|
|
192
|
+
proto.msMatchesSelector || // @ts-ignore
|
|
193
|
+
proto.oMatchesSelector || // @ts-ignore
|
|
194
|
+
proto.webkitMatchesSelector || // @ts-ignore
|
|
195
|
+
function (s) {
|
|
196
|
+
let matches = (this.ownerDocument || this.document).querySelectorAll(s);
|
|
197
|
+
let i = matches.length;
|
|
198
|
+
while (--i >= 0 && matches.item(i) !== this) { }
|
|
199
|
+
return i > -1;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return proto ? proto.matches.call(elm, selectors) : false;
|
|
203
|
+
}
|
|
184
204
|
function isFormData(value) {
|
|
185
205
|
return isPolyfillType("FormData", value) || isExternalFormData(value);
|
|
186
206
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { setState, isSequence, _Symbol, isPolyfillType, checkArgsLength, isObjectType } from '../utils.js';
|
|
1
|
+
import { setState, isSequence, makeIterator, _Symbol, isPolyfillType, checkArgsLength, isObjectType } from '../utils.js';
|
|
2
2
|
|
|
3
3
|
class URLSearchParamsP {
|
|
4
4
|
constructor(init) {
|
|
@@ -158,13 +158,13 @@ class URLSearchParamsP {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
entries() {
|
|
161
|
-
return state(this).array.map(function (x) { return [x[0], x[1]]; })
|
|
161
|
+
return makeIterator(state(this).array.map(function (x) { return [x[0], x[1]]; }));
|
|
162
162
|
}
|
|
163
163
|
keys() {
|
|
164
|
-
return state(this).array.map(function (x) { return x[0]; })
|
|
164
|
+
return makeIterator(state(this).array.map(function (x) { return x[0]; }));
|
|
165
165
|
}
|
|
166
166
|
values() {
|
|
167
|
-
return state(this).array.map(function (x) { return x[1]; })
|
|
167
|
+
return makeIterator(state(this).array.map(function (x) { return x[1]; }));
|
|
168
168
|
}
|
|
169
169
|
// @ts-ignore
|
|
170
170
|
/** @internal */ [_Symbol.iterator]() {
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Safe fallback for Symbol.iterator and Symbol.toStringTag — uses native Symbol when available, string keys otherwise.
|
|
1
2
|
const _Symbol = {
|
|
2
3
|
iterator: ((typeof Symbol === "function" && Symbol.iterator) || "Symbol(Symbol.iterator)"),
|
|
3
4
|
toStringTag: ((typeof Symbol === "function" && Symbol.toStringTag) || "Symbol(Symbol.toStringTag)"),
|
|
@@ -51,10 +52,23 @@ function isSequence(value) {
|
|
|
51
52
|
&& Symbol.iterator in value
|
|
52
53
|
&& typeof value[Symbol.iterator] === "function");
|
|
53
54
|
}
|
|
55
|
+
function makeIterator(array) {
|
|
56
|
+
let index = 0;
|
|
57
|
+
let iterator = {
|
|
58
|
+
next: function () {
|
|
59
|
+
if (index < array.length) {
|
|
60
|
+
return { value: array[index++], done: false };
|
|
61
|
+
}
|
|
62
|
+
return { value: undefined, done: true };
|
|
63
|
+
},
|
|
64
|
+
[_Symbol.iterator]: function () { return iterator; },
|
|
65
|
+
};
|
|
66
|
+
return iterator;
|
|
67
|
+
}
|
|
54
68
|
function checkArgsLength(actual, expect, className, funcName) {
|
|
55
69
|
if (actual < expect) {
|
|
56
70
|
throw new TypeError(`Failed to ${funcName ? ("execute '" + funcName + "' on") : "construct"} '${className}': ${expect} argument${expect > 1 ? "s" : ""} required, but only ${actual} present.`);
|
|
57
71
|
}
|
|
58
72
|
}
|
|
59
73
|
|
|
60
|
-
export { DOMExceptionE as DOMException, DOMExceptionP, _Symbol, checkArgsLength, className, isObjectType, isPolyfillType, isSequence, setState };
|
|
74
|
+
export { DOMExceptionE as DOMException, DOMExceptionP, _Symbol, checkArgsLength, className, isObjectType, isPolyfillType, isSequence, makeIterator, setState };
|
|
@@ -28,6 +28,14 @@ function _createClass(e, r, t) {
|
|
|
28
28
|
writable: false
|
|
29
29
|
}), e;
|
|
30
30
|
}
|
|
31
|
+
function _defineProperty(e, r, t) {
|
|
32
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
33
|
+
value: t,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
}) : e[r] = t, e;
|
|
38
|
+
}
|
|
31
39
|
function _getPrototypeOf(t) {
|
|
32
40
|
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
33
41
|
return t.__proto__ || Object.getPrototypeOf(t);
|
|
@@ -116,6 +124,7 @@ function _wrapNativeSuper(t) {
|
|
|
116
124
|
}, _wrapNativeSuper(t);
|
|
117
125
|
}
|
|
118
126
|
|
|
127
|
+
// Safe fallback for Symbol.iterator and Symbol.toStringTag — uses native Symbol when available, string keys otherwise.
|
|
119
128
|
var _Symbol = {
|
|
120
129
|
iterator: typeof Symbol === "function" && Symbol.iterator || "Symbol(Symbol.iterator)",
|
|
121
130
|
toStringTag: typeof Symbol === "function" && Symbol.toStringTag || "Symbol(Symbol.toStringTag)"
|
|
@@ -179,6 +188,26 @@ var iteratorSupported = typeof Symbol === "function" && !!Symbol.iterator;
|
|
|
179
188
|
function isSequence(value) {
|
|
180
189
|
return Array.isArray(value) || !!value && _typeof(value) === "object" && iteratorSupported && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
181
190
|
}
|
|
191
|
+
function makeIterator(array) {
|
|
192
|
+
var index = 0;
|
|
193
|
+
var iterator = _defineProperty({
|
|
194
|
+
next: function next() {
|
|
195
|
+
if (index < array.length) {
|
|
196
|
+
return {
|
|
197
|
+
value: array[index++],
|
|
198
|
+
done: false
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
value: undefined,
|
|
203
|
+
done: true
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}, _Symbol.iterator, function () {
|
|
207
|
+
return iterator;
|
|
208
|
+
});
|
|
209
|
+
return iterator;
|
|
210
|
+
}
|
|
182
211
|
function checkArgsLength(actual, expect, className, funcName) {
|
|
183
212
|
if (actual < expect) {
|
|
184
213
|
throw new TypeError("Failed to ".concat(funcName ? "execute '" + funcName + "' on" : "construct", " '").concat(className, "': ").concat(expect, " argument").concat(expect > 1 ? "s" : "", " required, but only ").concat(actual, " present."));
|
|
@@ -1042,10 +1071,10 @@ var AbortSignalP = /*#__PURE__*/function (_EventTargetP, _Symbol$toStringTag) {
|
|
|
1042
1071
|
function AbortSignalP() {
|
|
1043
1072
|
var _this;
|
|
1044
1073
|
_classCallCheck(this, AbortSignalP);
|
|
1045
|
-
|
|
1074
|
+
_this = _callSuper(this, AbortSignalP);
|
|
1075
|
+
if (_this.constructor === AbortSignalP) {
|
|
1046
1076
|
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
1047
1077
|
}
|
|
1048
|
-
_this = _callSuper(this, AbortSignalP);
|
|
1049
1078
|
setState(_this, "__AbortSignal__", new AbortSignalState(_this));
|
|
1050
1079
|
return _this;
|
|
1051
1080
|
}
|
|
@@ -2116,23 +2145,23 @@ var URLSearchParamsP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toString
|
|
|
2116
2145
|
}, {
|
|
2117
2146
|
key: "entries",
|
|
2118
2147
|
value: function entries() {
|
|
2119
|
-
return state$5(this).array.map(function (x) {
|
|
2148
|
+
return makeIterator(state$5(this).array.map(function (x) {
|
|
2120
2149
|
return [x[0], x[1]];
|
|
2121
|
-
})
|
|
2150
|
+
}));
|
|
2122
2151
|
}
|
|
2123
2152
|
}, {
|
|
2124
2153
|
key: "keys",
|
|
2125
2154
|
value: function keys() {
|
|
2126
|
-
return state$5(this).array.map(function (x) {
|
|
2155
|
+
return makeIterator(state$5(this).array.map(function (x) {
|
|
2127
2156
|
return x[0];
|
|
2128
|
-
})
|
|
2157
|
+
}));
|
|
2129
2158
|
}
|
|
2130
2159
|
}, {
|
|
2131
2160
|
key: "values",
|
|
2132
2161
|
value: function values() {
|
|
2133
|
-
return state$5(this).array.map(function (x) {
|
|
2162
|
+
return makeIterator(state$5(this).array.map(function (x) {
|
|
2134
2163
|
return x[1];
|
|
2135
|
-
})
|
|
2164
|
+
}));
|
|
2136
2165
|
}
|
|
2137
2166
|
// @ts-ignore
|
|
2138
2167
|
/** @internal */
|
|
@@ -2218,7 +2247,7 @@ var FormDataP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
|
2218
2247
|
var elements = form.elements;
|
|
2219
2248
|
for (var i = 0; i < elements.length; ++i) {
|
|
2220
2249
|
var elm = elements[i];
|
|
2221
|
-
if (!elm.name || elm.disabled || elm.type === "submit" || elm.type === "button" ||
|
|
2250
|
+
if (!elm.name || elm.disabled || elm.type === "submit" || elm.type === "button" || matches(elm, "form fieldset[disabled] *")) return;
|
|
2222
2251
|
if (elm.type === "file") {
|
|
2223
2252
|
var files = elm.files && elm.files.length ? elm.files : [new FileE([], "", {
|
|
2224
2253
|
type: "application/octet-stream"
|
|
@@ -2356,23 +2385,23 @@ var FormDataP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
|
2356
2385
|
}, {
|
|
2357
2386
|
key: "entries",
|
|
2358
2387
|
value: function entries() {
|
|
2359
|
-
return state$4(this).array.map(function (x) {
|
|
2388
|
+
return makeIterator(state$4(this).array.map(function (x) {
|
|
2360
2389
|
return [x[0], x[1]];
|
|
2361
|
-
})
|
|
2390
|
+
}));
|
|
2362
2391
|
}
|
|
2363
2392
|
}, {
|
|
2364
2393
|
key: "keys",
|
|
2365
2394
|
value: function keys() {
|
|
2366
|
-
return state$4(this).array.map(function (x) {
|
|
2395
|
+
return makeIterator(state$4(this).array.map(function (x) {
|
|
2367
2396
|
return x[0];
|
|
2368
|
-
})
|
|
2397
|
+
}));
|
|
2369
2398
|
}
|
|
2370
2399
|
}, {
|
|
2371
2400
|
key: "values",
|
|
2372
2401
|
value: function values() {
|
|
2373
|
-
return state$4(this).array.map(function (x) {
|
|
2402
|
+
return makeIterator(state$4(this).array.map(function (x) {
|
|
2374
2403
|
return x[1];
|
|
2375
|
-
})
|
|
2404
|
+
}));
|
|
2376
2405
|
}
|
|
2377
2406
|
// @ts-ignore
|
|
2378
2407
|
/** @internal */
|
|
@@ -2425,6 +2454,32 @@ function normalizeArgs(name, value, filename) {
|
|
|
2425
2454
|
}
|
|
2426
2455
|
return ["" + name, "" + value];
|
|
2427
2456
|
}
|
|
2457
|
+
// Polyfill for Element.prototype.matches,
|
|
2458
|
+
// tries native, then vendor prefixes, then querySelectorAll fallback.
|
|
2459
|
+
function matches(elm, selectors) {
|
|
2460
|
+
var proto = typeof Element !== "undefined" && Element && Element.prototype;
|
|
2461
|
+
if (proto && !proto.matches) {
|
|
2462
|
+
proto.matches =
|
|
2463
|
+
// @ts-ignore
|
|
2464
|
+
proto.matchesSelector ||
|
|
2465
|
+
// @ts-ignore
|
|
2466
|
+
proto.mozMatchesSelector ||
|
|
2467
|
+
// @ts-ignore
|
|
2468
|
+
proto.msMatchesSelector ||
|
|
2469
|
+
// @ts-ignore
|
|
2470
|
+
proto.oMatchesSelector ||
|
|
2471
|
+
// @ts-ignore
|
|
2472
|
+
proto.webkitMatchesSelector ||
|
|
2473
|
+
// @ts-ignore
|
|
2474
|
+
function (s) {
|
|
2475
|
+
var matches = (this.ownerDocument || this.document).querySelectorAll(s);
|
|
2476
|
+
var i = matches.length;
|
|
2477
|
+
while (--i >= 0 && matches.item(i) !== this) {}
|
|
2478
|
+
return i > -1;
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
return proto ? proto.matches.call(elm, selectors) : false;
|
|
2482
|
+
}
|
|
2428
2483
|
function isFormData(value) {
|
|
2429
2484
|
return isPolyfillType("FormData", value) || isExternalFormData(value);
|
|
2430
2485
|
}
|
|
@@ -2624,7 +2679,7 @@ var BodyImpl = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
|
2624
2679
|
/** @internal */
|
|
2625
2680
|
function BodyImpl() {
|
|
2626
2681
|
_classCallCheck(this, BodyImpl);
|
|
2627
|
-
if (
|
|
2682
|
+
if (this.constructor === BodyImpl) {
|
|
2628
2683
|
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
2629
2684
|
}
|
|
2630
2685
|
setState(this, "__Body__", new BodyState());
|
|
@@ -2848,7 +2903,7 @@ var HeadersP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
|
2848
2903
|
this.forEach(function (value, name) {
|
|
2849
2904
|
array.push([name, value]);
|
|
2850
2905
|
});
|
|
2851
|
-
return array
|
|
2906
|
+
return makeIterator(array);
|
|
2852
2907
|
}
|
|
2853
2908
|
}, {
|
|
2854
2909
|
key: "keys",
|
|
@@ -2857,9 +2912,9 @@ var HeadersP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
|
2857
2912
|
this.forEach(function (value, name) {
|
|
2858
2913
|
array.push([name, value]);
|
|
2859
2914
|
});
|
|
2860
|
-
return array.map(function (x) {
|
|
2915
|
+
return makeIterator(array.map(function (x) {
|
|
2861
2916
|
return x[0];
|
|
2862
|
-
})
|
|
2917
|
+
}));
|
|
2863
2918
|
}
|
|
2864
2919
|
}, {
|
|
2865
2920
|
key: "values",
|
|
@@ -2868,9 +2923,9 @@ var HeadersP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
|
2868
2923
|
this.forEach(function (value, name) {
|
|
2869
2924
|
array.push([name, value]);
|
|
2870
2925
|
});
|
|
2871
|
-
return array.map(function (x) {
|
|
2926
|
+
return makeIterator(array.map(function (x) {
|
|
2872
2927
|
return x[1];
|
|
2873
|
-
})
|
|
2928
|
+
}));
|
|
2874
2929
|
}
|
|
2875
2930
|
// @ts-ignore
|
|
2876
2931
|
/** @internal */
|
|
@@ -3371,8 +3426,8 @@ function setXMLHttpRequestClass(XHRClass) {
|
|
|
3371
3426
|
mp.XMLHttpRequest = XHRClass;
|
|
3372
3427
|
}
|
|
3373
3428
|
function fetchP(input, init) {
|
|
3374
|
-
checkArgsLength(arguments.length, 1, "Window", "fetch");
|
|
3375
|
-
if (
|
|
3429
|
+
checkArgsLength(arguments.length, 1, "Window", "fetch"); // @ts-expect-error
|
|
3430
|
+
if (this instanceof fetchP) {
|
|
3376
3431
|
throw new TypeError("fetch is not a constructor");
|
|
3377
3432
|
}
|
|
3378
3433
|
return new Promise(function (resolve, reject) {
|