mphttpx 1.1.0 → 1.2.0-beta.2

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.
Files changed (59) hide show
  1. package/README.zh-CN.md +982 -0
  2. package/dist/cjs/AbortControllerP.js +31 -0
  3. package/dist/cjs/AbortSignalP.js +126 -0
  4. package/dist/cjs/BlobP.js +131 -0
  5. package/dist/cjs/BodyImpl.js +142 -0
  6. package/dist/cjs/CloseEventP.js +38 -0
  7. package/dist/cjs/CustomEventP.js +35 -0
  8. package/dist/cjs/EventP.js +173 -0
  9. package/dist/cjs/EventTargetP.js +176 -0
  10. package/dist/cjs/FileP.js +36 -0
  11. package/dist/cjs/FileReaderP.js +151 -0
  12. package/dist/cjs/FormDataP.js +250 -0
  13. package/dist/cjs/HeadersP.js +176 -0
  14. package/dist/cjs/MessageEventP.js +64 -0
  15. package/dist/cjs/ProgressEventP.js +69 -0
  16. package/dist/cjs/RequestP.js +158 -0
  17. package/dist/cjs/ResponseP.js +102 -0
  18. package/dist/cjs/TextDecoderP.js +186 -0
  19. package/dist/cjs/TextEncoderP.js +122 -0
  20. package/dist/cjs/URLSearchParamsP.js +230 -0
  21. package/dist/cjs/WebSocketP.js +238 -0
  22. package/dist/cjs/XMLHttpRequestP.js +567 -0
  23. package/dist/cjs/convertor.js +83 -0
  24. package/dist/cjs/fetchP.js +115 -0
  25. package/dist/cjs/index.js +80 -0
  26. package/dist/cjs/isPolyfill.js +56 -0
  27. package/dist/cjs/platform.js +33 -0
  28. package/dist/esm/AbortControllerP.js +28 -0
  29. package/dist/esm/AbortSignalP.js +121 -0
  30. package/dist/esm/BlobP.js +124 -0
  31. package/dist/esm/BodyImpl.js +137 -0
  32. package/dist/esm/CloseEventP.js +35 -0
  33. package/dist/esm/CustomEventP.js +32 -0
  34. package/dist/esm/EventP.js +165 -0
  35. package/dist/esm/EventTargetP.js +168 -0
  36. package/dist/esm/FileP.js +33 -0
  37. package/dist/esm/FileReaderP.js +148 -0
  38. package/dist/esm/FormDataP.js +245 -0
  39. package/dist/esm/HeadersP.js +170 -0
  40. package/dist/esm/MessageEventP.js +61 -0
  41. package/dist/esm/ProgressEventP.js +65 -0
  42. package/dist/esm/RequestP.js +153 -0
  43. package/dist/esm/ResponseP.js +98 -0
  44. package/dist/esm/TextDecoderP.js +183 -0
  45. package/dist/esm/TextEncoderP.js +119 -0
  46. package/dist/esm/URLSearchParamsP.js +227 -0
  47. package/dist/esm/WebSocketP.js +234 -0
  48. package/dist/esm/XMLHttpRequestP.js +563 -0
  49. package/dist/esm/convertor.js +80 -0
  50. package/dist/esm/fetchP.js +111 -0
  51. package/dist/esm/index.js +25 -0
  52. package/dist/esm/isPolyfill.js +48 -0
  53. package/dist/esm/platform.js +31 -0
  54. package/dist/index.d.ts +33 -37
  55. package/package.json +7 -9
  56. package/dist/index.cjs.js +0 -3291
  57. package/dist/index.cjs.min.js +0 -1
  58. package/dist/index.esm.js +0 -3251
  59. package/dist/index.esm.min.js +0 -1
@@ -0,0 +1,186 @@
1
+ 'use strict';
2
+
3
+ var isPolyfill = require('./isPolyfill.js');
4
+
5
+ var _a, _b;
6
+ /** @internal */
7
+ const state = Symbol( /* "TextDecoderState" */);
8
+ class TextDecoderP {
9
+ constructor(label = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
10
+ let _label = "" + label;
11
+ if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_label.toLowerCase()) === -1) {
12
+ throw new RangeError(`Failed to construct 'TextDecoder': encoding ('${_label}') not implemented.`);
13
+ }
14
+ this[state] = new TextDecoderState();
15
+ this[state].fatal = !!fatal;
16
+ this[state].ignoreBOM = !!ignoreBOM;
17
+ }
18
+ get encoding() { return "utf-8"; }
19
+ get fatal() { return this[state].fatal; }
20
+ get ignoreBOM() { return this[state].ignoreBOM; }
21
+ decode(input, { stream = false } = {}) {
22
+ const s = this[state];
23
+ let bytes;
24
+ if (input !== undefined) {
25
+ if (isPolyfill.isArrayBuffer(input)) {
26
+ bytes = new Uint8Array(input);
27
+ }
28
+ else if (input instanceof Uint8Array || isPolyfill.isObjectType("Uint8Array", input)) {
29
+ bytes = input;
30
+ }
31
+ else if (ArrayBuffer.isView(input)) {
32
+ bytes = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
33
+ }
34
+ else {
35
+ throw new TypeError("Failed to execute 'decode' on 'TextDecoder': parameter 1 is not of type 'ArrayBuffer'.");
36
+ }
37
+ }
38
+ else {
39
+ if (s[_partial].length > 0) {
40
+ if (this.fatal) {
41
+ s[_partial] = [];
42
+ throw new TypeError("TextDecoder: Incomplete UTF-8 sequence.");
43
+ }
44
+ }
45
+ return "";
46
+ }
47
+ if (s[_bomDone] < 3) {
48
+ s[_bomDone] += bytes.length;
49
+ if (bytes.length >= 3) {
50
+ if (bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf) {
51
+ bytes = bytes.subarray(3); // × WeChat 2.5.0
52
+ }
53
+ }
54
+ }
55
+ if (s[_partial].length > 0) {
56
+ let merged = new Uint8Array(s[_partial].length + bytes.length);
57
+ merged.set(s[_partial], 0);
58
+ merged.set(bytes, s[_partial].length);
59
+ bytes = merged;
60
+ s[_partial] = [];
61
+ }
62
+ let end = bytes.length;
63
+ let res = [];
64
+ if (stream && bytes.length > 0) {
65
+ let i = bytes.length;
66
+ while (i > 0 && i > bytes.length - 4) {
67
+ let byte = bytes[i - 1];
68
+ if ((byte & 0b11000000) !== 0b10000000) {
69
+ let len = getBytesPerSequence(byte);
70
+ if (len > bytes.length - (i - 1)) {
71
+ end = i - 1;
72
+ }
73
+ break;
74
+ }
75
+ i--;
76
+ }
77
+ s[_partial] = Array.from(bytes.slice(end)); // save tail // × WeChat 2.5.0
78
+ bytes = bytes.slice(0, end); // × WeChat 2.5.0
79
+ }
80
+ let i = 0;
81
+ while (i < end) {
82
+ let codePoint = null;
83
+ let firstByte = bytes[i];
84
+ let bytesPerSequence = getBytesPerSequence(firstByte);
85
+ if (i + bytesPerSequence <= end) {
86
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
87
+ switch (bytesPerSequence) {
88
+ case 1:
89
+ if (firstByte < 0x80) {
90
+ codePoint = firstByte;
91
+ }
92
+ break;
93
+ case 2:
94
+ secondByte = bytes[i + 1];
95
+ if ((secondByte & 0xC0) === 0x80) {
96
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
97
+ if (tempCodePoint > 0x7F) {
98
+ codePoint = tempCodePoint;
99
+ }
100
+ }
101
+ break;
102
+ case 3:
103
+ secondByte = bytes[i + 1];
104
+ thirdByte = bytes[i + 2];
105
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
106
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
107
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
108
+ codePoint = tempCodePoint;
109
+ }
110
+ }
111
+ break;
112
+ case 4:
113
+ secondByte = bytes[i + 1];
114
+ thirdByte = bytes[i + 2];
115
+ fourthByte = bytes[i + 3];
116
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
117
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
118
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
119
+ codePoint = tempCodePoint;
120
+ }
121
+ }
122
+ break;
123
+ }
124
+ }
125
+ if (codePoint === null) {
126
+ if (this.fatal) {
127
+ s[_partial] = [];
128
+ throw new TypeError("TextDecoder.decode: Decoding failed.");
129
+ }
130
+ let skip = 1;
131
+ while (i + skip < end && (bytes[i + skip] & 0b11000000) === 0b10000000) {
132
+ skip += 1;
133
+ }
134
+ // we did not generate a valid codePoint so insert a replacement char (U+FFFD)
135
+ res.push(0xFFFD);
136
+ i += skip;
137
+ continue;
138
+ }
139
+ else if (codePoint > 0xFFFF) {
140
+ // encode to utf16 (surrogate pair dance)
141
+ codePoint -= 0x10000;
142
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800);
143
+ codePoint = 0xDC00 | codePoint & 0x3FF;
144
+ }
145
+ res.push(codePoint);
146
+ i += bytesPerSequence;
147
+ }
148
+ return res.length > 0x4000 ? buildString(res) : concatString(res);
149
+ }
150
+ /** @internal */ toString() { return "[object TextDecoder]"; }
151
+ /** @internal */ get [Symbol.toStringTag]() { return "TextDecoder"; }
152
+ /** @internal */ get isPolyfill() { return { symbol: isPolyfill.polyfill, hierarchy: ["TextDecoder"] }; }
153
+ }
154
+ /** @internal */ const _bomDone = Symbol();
155
+ /** @internal */ const _partial = Symbol();
156
+ /** @internal */
157
+ class TextDecoderState {
158
+ constructor() {
159
+ this.fatal = false;
160
+ this.ignoreBOM = false;
161
+ this[_a] = 0;
162
+ this[_b] = [];
163
+ }
164
+ }
165
+ _a = _bomDone, _b = _partial;
166
+ function getBytesPerSequence(byte) {
167
+ return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
168
+ }
169
+ const buildString = (res) => {
170
+ let arr = [];
171
+ for (let i = 0, len = res.length; i < len; i += 0x1000) {
172
+ arr.push(String.fromCharCode.apply(String, res.slice(i, i + 0x1000)));
173
+ }
174
+ return arr.join("");
175
+ };
176
+ const concatString = (res) => {
177
+ let str = "";
178
+ for (let i = 0, len = res.length; i < len; i += 0x1000) {
179
+ str += String.fromCharCode.apply(String, res.slice(i, i + 0x1000));
180
+ }
181
+ return str;
182
+ };
183
+ const TextDecoderE = isPolyfill.g["TextDecoder"] || TextDecoderP;
184
+
185
+ exports.TextDecoder = TextDecoderE;
186
+ exports.TextDecoderP = TextDecoderP;
@@ -0,0 +1,122 @@
1
+ 'use strict';
2
+
3
+ var isPolyfill = require('./isPolyfill.js');
4
+
5
+ class TextEncoderP {
6
+ get encoding() { return "utf-8"; }
7
+ encode(input = "") {
8
+ let _input = "" + input;
9
+ return encodeText(_input).encoded;
10
+ }
11
+ encodeInto(...args) {
12
+ const [source, destination] = args;
13
+ isPolyfill.checkArgsLength(args, 2, "TextEncoder", "encodeInto");
14
+ let _source = "" + source;
15
+ if (!(destination instanceof Uint8Array || isPolyfill.isObjectType("Uint8Array", destination))) {
16
+ throw new TypeError("Failed to execute 'encodeInto' on 'TextEncoder': parameter 2 is not of type 'Uint8Array'.");
17
+ }
18
+ let result = encodeText(_source, destination);
19
+ return { read: result.read, written: result.written };
20
+ }
21
+ /** @internal */ toString() { return "[object TextEncoder]"; }
22
+ /** @internal */ get [Symbol.toStringTag]() { return "TextEncoder"; }
23
+ /** @internal */ get isPolyfill() { return { symbol: isPolyfill.polyfill, hierarchy: ["TextEncoder"] }; }
24
+ }
25
+ function encodeText(input, destination) {
26
+ const HAS_DESTINATION = typeof destination !== "undefined";
27
+ let pos = 0;
28
+ let read = 0;
29
+ let len = input.length;
30
+ let at = 0; // output position
31
+ let tlen = Math.max(32, len + (len >> 1) + 7); // 1.5x size
32
+ let target = HAS_DESTINATION ? destination : new Uint8Array((tlen >> 3) << 3); // ... but at 8 byte offset
33
+ while (pos < len) {
34
+ let value = input.charCodeAt(pos);
35
+ let codeUnitCount = 1;
36
+ if (value >= 0xd800 && value <= 0xdbff) {
37
+ // high surrogate
38
+ if (pos + 1 < len) {
39
+ let extra = input.charCodeAt(pos + 1);
40
+ if ((extra & 0xfc00) === 0xdc00) {
41
+ codeUnitCount = 2;
42
+ pos += 2;
43
+ value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
44
+ }
45
+ else {
46
+ pos += 1;
47
+ value = 0xfffd;
48
+ }
49
+ }
50
+ else {
51
+ pos += 1;
52
+ value = 0xfffd;
53
+ }
54
+ }
55
+ else if (value >= 0xdc00 && value <= 0xdfff) {
56
+ pos += 1;
57
+ value = 0xfffd;
58
+ }
59
+ else {
60
+ pos += 1;
61
+ }
62
+ // expand the buffer if we couldn't write 4 bytes
63
+ if (!HAS_DESTINATION && at + 4 > target.length) {
64
+ tlen += 8; // minimum extra
65
+ tlen *= (1.0 + (pos / input.length) * 2); // take 2x the remaining
66
+ tlen = (tlen >> 3) << 3; // 8 byte offset
67
+ let update = new Uint8Array(tlen);
68
+ update.set(target);
69
+ target = update;
70
+ }
71
+ let byteCount;
72
+ if ((value & 0xffffff80) === 0) { // 1-byte
73
+ byteCount = 1;
74
+ }
75
+ else if ((value & 0xfffff800) === 0) { // 2-byte
76
+ byteCount = 2;
77
+ }
78
+ else if ((value & 0xffff0000) === 0) { // 3-byte
79
+ byteCount = 3;
80
+ }
81
+ else if ((value & 0xffe00000) === 0) { // 4-byte
82
+ byteCount = 4;
83
+ }
84
+ else {
85
+ value = 0xfffd;
86
+ byteCount = 3;
87
+ }
88
+ if (HAS_DESTINATION && at + byteCount > target.length) {
89
+ break;
90
+ }
91
+ switch (byteCount) {
92
+ case 1: // 1-byte
93
+ target[at++] = value; // ASCII
94
+ break;
95
+ case 2: // 2-byte
96
+ target[at++] = ((value >> 6) & 0x1f) | 0xc0;
97
+ target[at++] = (value & 0x3f) | 0x80;
98
+ break;
99
+ case 3: // 3-byte
100
+ target[at++] = ((value >> 12) & 0x0f) | 0xe0;
101
+ target[at++] = ((value >> 6) & 0x3f) | 0x80;
102
+ target[at++] = (value & 0x3f) | 0x80;
103
+ break;
104
+ case 4: // 4-byte
105
+ target[at++] = ((value >> 18) & 0x07) | 0xf0;
106
+ target[at++] = ((value >> 12) & 0x3f) | 0x80;
107
+ target[at++] = ((value >> 6) & 0x3f) | 0x80;
108
+ target[at++] = (value & 0x3f) | 0x80;
109
+ break;
110
+ }
111
+ read += codeUnitCount;
112
+ }
113
+ return {
114
+ encoded: !HAS_DESTINATION ? target.slice(0, at) : destination,
115
+ read: read,
116
+ written: at,
117
+ };
118
+ }
119
+ const TextEncoderE = isPolyfill.g["TextEncoder"] || TextEncoderP;
120
+
121
+ exports.TextEncoder = TextEncoderE;
122
+ exports.TextEncoderP = TextEncoderP;
@@ -0,0 +1,230 @@
1
+ 'use strict';
2
+
3
+ var isPolyfill = require('./isPolyfill.js');
4
+
5
+ var _a;
6
+ /** @internal */ const state = Symbol( /* "URLSearchParamsState" */);
7
+ const checkArgsFn = (args, required, funcName) => { isPolyfill.checkArgsLength(args, required, "URLSearchParams", funcName); };
8
+ class URLSearchParamsP {
9
+ constructor(init) {
10
+ this[state] = new URLSearchParamsState();
11
+ if (init !== undefined) {
12
+ if (isPolyfill.isObjectType("URLSearchParams", init) || isPolyfill.isPolyfillType("URLSearchParams", init)) {
13
+ init.forEach((value, name) => { this.append(name, value); }, this);
14
+ }
15
+ else if (init && typeof init === "object") {
16
+ if (Array.isArray(init) || Symbol.iterator in init) {
17
+ let _init = Array.isArray(init) ? init : Array.from(init);
18
+ for (let i = 0; i < _init.length; ++i) {
19
+ let item = _init[i];
20
+ if (Array.isArray(item) || (item && typeof item === "object" && Symbol.iterator in item)) {
21
+ let pair = Array.isArray(item) ? item : Array.from(item);
22
+ if (pair.length === 2) {
23
+ this.append(pair[0], pair[1]);
24
+ }
25
+ else {
26
+ throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
27
+ }
28
+ }
29
+ else {
30
+ throw new TypeError("Failed to construct 'URLSearchParams': The provided value cannot be converted to a sequence.");
31
+ }
32
+ }
33
+ }
34
+ else {
35
+ Object.getOwnPropertyNames(init).forEach(name => { this.append(name, init[name]); }, this);
36
+ }
37
+ }
38
+ else {
39
+ let _init = "" + init;
40
+ if (_init.indexOf("?") === 0) {
41
+ _init = _init.slice(1);
42
+ }
43
+ let pairs = _init.split("&");
44
+ for (let i = 0; i < pairs.length; ++i) {
45
+ let pair = pairs[i], separatorIndex = pair.indexOf("=");
46
+ if (separatorIndex > -1) {
47
+ this.append(decode(pair.slice(0, separatorIndex)), decode(pair.slice(separatorIndex + 1)));
48
+ }
49
+ else {
50
+ if (pair) {
51
+ this.append(decode(pair), "");
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ get size() { return this[state][_urlspArray].length; }
59
+ append(...args) {
60
+ const [name, value] = args;
61
+ checkArgsFn(args, 2, "append");
62
+ this[state][_urlspArray].push(["" + name, normalizeValue(value)]);
63
+ }
64
+ delete(...args) {
65
+ const [name, value] = args;
66
+ checkArgsFn(args, 1, "delete");
67
+ let _name = "" + name;
68
+ let index = -1;
69
+ let array = this[state][_urlspArray];
70
+ let result = [];
71
+ for (let i = 0; i < array.length; ++i) {
72
+ let item = array[i];
73
+ if (item[0] === _name) {
74
+ if (args.length !== 1 && item[1] !== normalizeValue(value)) {
75
+ result.push(item);
76
+ }
77
+ index = i;
78
+ continue;
79
+ }
80
+ result.push(item);
81
+ }
82
+ if (index > -1) {
83
+ this[state][_urlspArray] = result;
84
+ }
85
+ }
86
+ get(...args) {
87
+ const [name] = args;
88
+ checkArgsFn(args, 1, "get");
89
+ let _name = "" + name;
90
+ let array = this[state][_urlspArray];
91
+ for (let i = 0; i < array.length; ++i) {
92
+ let item = array[i];
93
+ if (item[0] === _name) {
94
+ return item[1];
95
+ }
96
+ }
97
+ return null;
98
+ }
99
+ getAll(...args) {
100
+ const [name] = args;
101
+ checkArgsFn(args, 1, "getAll");
102
+ let _name = "" + name;
103
+ let array = this[state][_urlspArray];
104
+ let result = [];
105
+ for (let i = 0; i < array.length; ++i) {
106
+ let item = array[i];
107
+ if (item[0] === _name) {
108
+ result.push(item[1]);
109
+ }
110
+ }
111
+ return result;
112
+ }
113
+ has(...args) {
114
+ const [name, value] = args;
115
+ checkArgsFn(args, 1, "has");
116
+ let _name = "" + name;
117
+ let array = this[state][_urlspArray];
118
+ for (let i = 0; i < array.length; ++i) {
119
+ let item = array[i];
120
+ if (item[0] === _name) {
121
+ if (args.length === 1) {
122
+ return true;
123
+ }
124
+ else {
125
+ if (item[1] === normalizeValue(value)) {
126
+ return true;
127
+ }
128
+ }
129
+ }
130
+ }
131
+ return false;
132
+ }
133
+ set(...args) {
134
+ const [name, value] = args;
135
+ checkArgsFn(args, 2, "set");
136
+ let _name = "" + name;
137
+ let _value = normalizeValue(value);
138
+ let index = -1;
139
+ let array = this[state][_urlspArray];
140
+ let result = [];
141
+ for (let i = 0; i < array.length; ++i) {
142
+ let item = array[i];
143
+ if (item[0] === _name) {
144
+ if (index === -1) {
145
+ index = i;
146
+ result.push([_name, _value]);
147
+ }
148
+ continue;
149
+ }
150
+ result.push(item);
151
+ }
152
+ if (index === -1) {
153
+ result.push([_name, _value]);
154
+ }
155
+ this[state][_urlspArray] = result;
156
+ }
157
+ sort() {
158
+ this[state][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
159
+ }
160
+ forEach(...args) {
161
+ const [callbackfn, thisArg] = args;
162
+ checkArgsFn(args, 1, "forEach");
163
+ if (typeof callbackfn !== "function") {
164
+ throw new TypeError("Failed to execute 'forEach' on 'URLSearchParams': parameter 1 is not of type 'Function'.");
165
+ }
166
+ let array = this[state][_urlspArray];
167
+ for (let i = 0; i < array.length; ++i) {
168
+ let item = array[i];
169
+ callbackfn.call(thisArg, item[1], item[0], this);
170
+ }
171
+ }
172
+ entries() {
173
+ return this[state][_urlspArray].map(x => [x[0], x[1]]).values();
174
+ }
175
+ keys() {
176
+ return this[state][_urlspArray].map(x => x[0]).values();
177
+ }
178
+ values() {
179
+ return this[state][_urlspArray].map(x => x[1]).values();
180
+ }
181
+ [Symbol.iterator]() {
182
+ return this.entries();
183
+ }
184
+ toString() {
185
+ let array = this[state][_urlspArray];
186
+ let result = [];
187
+ for (let i = 0; i < array.length; ++i) {
188
+ let item = array[i];
189
+ result.push(encode(item[0]) + "=" + encode(item[1]));
190
+ }
191
+ return result.join("&");
192
+ }
193
+ /** @internal */ get [Symbol.toStringTag]() { return "URLSearchParams"; }
194
+ /** @internal */ get isPolyfill() { return { symbol: isPolyfill.polyfill, hierarchy: ["URLSearchParams"] }; }
195
+ }
196
+ /** @internal */
197
+ const _urlspArray = Symbol();
198
+ /** @internal */
199
+ class URLSearchParamsState {
200
+ constructor() {
201
+ this[_a] = [];
202
+ }
203
+ }
204
+ _a = _urlspArray;
205
+ function normalizeValue(value) {
206
+ return typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function"
207
+ ? value.toString()
208
+ : JSON.stringify(value));
209
+ }
210
+ function encode(str) {
211
+ const replace = {
212
+ "!": "%21",
213
+ "'": "%27",
214
+ "(": "%28",
215
+ ")": "%29",
216
+ "~": "%7E",
217
+ "%20": "+",
218
+ "%00": "\x00",
219
+ };
220
+ return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, match => replace[match]);
221
+ }
222
+ function decode(str) {
223
+ return str
224
+ .replace(/[ +]/g, "%20")
225
+ .replace(/(%[a-f0-9]{2})+/ig, match => decodeURIComponent(match));
226
+ }
227
+ const URLSearchParamsE = isPolyfill.g["URLSearchParams"] || URLSearchParamsP;
228
+
229
+ exports.URLSearchParams = URLSearchParamsE;
230
+ exports.URLSearchParamsP = URLSearchParamsP;