polyfill-library 4.6.0 → 4.7.0
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/CHANGELOG.md +4 -4
- package/package.json +1 -1
- package/polyfills/__dist/DocumentFragment.prototype.replaceChildren/meta.json +1 -0
- package/polyfills/__dist/DocumentFragment.prototype.replaceChildren/min.js +1 -0
- package/polyfills/__dist/DocumentFragment.prototype.replaceChildren/raw.js +15 -0
- package/polyfills/__dist/Element.prototype.replaceChildren/meta.json +1 -0
- package/polyfills/__dist/Element.prototype.replaceChildren/min.js +1 -0
- package/polyfills/__dist/Element.prototype.replaceChildren/raw.js +8 -0
- package/polyfills/__dist/Map/meta.json +1 -1
- package/polyfills/__dist/Map/min.js +1 -1
- package/polyfills/__dist/Map/raw.js +5 -2
- package/polyfills/__dist/aliases.json +1 -1
- package/polyfills/__dist/structuredClone/meta.json +1 -0
- package/polyfills/__dist/structuredClone/min.js +1 -0
- package/polyfills/__dist/structuredClone/raw.js +279 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"dependencies":["Map","Set","Object.keys","String.prototype.includes","RegExp.prototype.flags"],"spec":"https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone","docs":"https://developer.mozilla.org/en-US/docs/Web/API/structuredClone","license":"MIT","repo":"https://github.com/ungap/structured-clone/","notes":["This polyfill currently does not support cloning: Blob, File, FileList, ImageBitmap, ImageData, and ArrayBuffer. TypedArrays are supported without major issues, but int and uint 8/16/32 are the only safely supported TypedArrays."],"browsers":{"android":"*","bb":"*","chrome":"<98","edge":"*","edge_mob":"*","firefox":"<94","firefox_mob":"<94","ie":"*","ie_mob":"*","opera":"<84","op_mob":"<68","op_mini":"*","safari":"<15.4","ios_saf":"<15.4","samsung_mob":"<18.0"},"detectSource":"\"structuredClone\"in self&&\"function\"==typeof self.structuredClone\n","baseDir":"structuredClone","hasTests":true,"isTestable":true,"isPublic":true,"size":2490}
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";!function(e){function r(r,n){function t(e,n){return r.set(n,e),e}function a(u){var s,b;if(r.has(u))return r.get(u);var m=n[u][0],y=n[u][1];switch(m){case i:case c:return t(y,u);case o:var O=t([],u);for(s=0,b=y.length;s<b;++s)O.push(a(y[s]));return O;case f:var S=t({},u),d=Object.keys(y);for(s=0,b=d.length;s<b;++s){var E=y[d[s]];S[a(E[0])]=a(E[1])}return S;case g:return t(new Date(y),u);case l:return t(new RegExp(y.source,y.flags),u);case h:var j=t(new Map,u);for(s=0,b=y.length;s<b;++s){var B=y[s];j.set(a(B[0]),a(B[1]))}return j;case v:var I=t(new Set,u);for(s=0,b=y.length;s<b;++s)I.add(a(y[s]));return I;case p:return t(new e[y.name](y.message),u);case w:return t(BigInt(y),u);case"BigInt":return t(Object(BigInt(y)),u)}return t(new e[m](y),u)}return a}function n(e){return r(new Map,e)(0)}function t(e){if(e instanceof Map)return[h,b];if(e instanceof Set)return[v,b];var r=typeof e;if("object"!==r||!e)return[i,r];var n=m.toString.call(e).slice(8,-1);switch(n){case"Array":return[o,b];case"Object":return[f,b];case"Date":return[g,b];case"RegExp":return[l,b]}return-1!==n.indexOf("Array")?[o,n]:-1!==n.indexOf("Error")?[p,n]:[f,n]}function a(e){return e[0]===i&&("function"===e[1]||"symbol"===e[1])}function u(e,r){function n(n,t){var a=r.push(n)-1;return e.set(t,a),a}function u(r){if(e.has(r))return e.get(r);var s,p,b,m=t(r),y=m[0],O=m[1];switch(y){case i:var S=r;switch(O){case"bigint":y=w,S=r.toString();break;case"function":case"symbol":throw new TypeError("unable to serialize "+O);case"undefined":return n([c],r)}return n([y,S],r);case o:var d=[],E=n([O||y,d],r);if(O)for(s=0,p=r.length;s<p;++s)d.push(r[s]);else for(s=0,p=r.length;s<p;++s)d.push(u(r[s]));return E;case f:if(O)switch(O){case"BigInt":return n([O,r.toString()],r);case"Boolean":case"Number":case"String":return n([O,r.valueOf()],r)}var j=[],B=n([y,j],r);for(b=Object.keys(r),s=0,p=b.length;s<p;++s){var I=b[s];a(t(r[I]))||j.push([u(I),u(r[I])])}return B;case g:return n([y,r.toISOString()],r);case l:return n([y,{source:r.source,flags:(r.global?"g":"")+(r.ignoreCase?"i":"")+(r.multiline?"m":"")}],r);case h:var x=[],M=n([y,x],r);return r.forEach(function(e,r){a(t(r))||a(t(e))||x.push([u(r),u(e)])}),M;case v:var k=[],A=n([y,k],r);return r.forEach(function(e){a(t(e))||k.push(u(e))}),A}return n([y,{name:O,message:r.message}],r)}return u}function s(e){var r=[];return u(new Map,r)(e),r}var c=-1,i=0,o=1,f=2,g=3,l=4,h=5,v=6,p=7,w=8,b="",m={};e.structuredClone=function e(r){return n(s(r))}}(self);
|
@@ -0,0 +1,279 @@
|
|
1
|
+
|
2
|
+
// structuredClone
|
3
|
+
/* global Map, Set, BigInt */
|
4
|
+
"use strict";
|
5
|
+
|
6
|
+
(function (env) {
|
7
|
+
var VOID = -1;
|
8
|
+
var PRIMITIVE = 0;
|
9
|
+
var ARRAY = 1;
|
10
|
+
var OBJECT = 2;
|
11
|
+
var DATE = 3;
|
12
|
+
var REGEXP = 4;
|
13
|
+
var MAP = 5;
|
14
|
+
var SET = 6;
|
15
|
+
var ERROR = 7;
|
16
|
+
var BIGINT = 8;
|
17
|
+
|
18
|
+
function deserializer($, _) {
|
19
|
+
function as(out, index) {
|
20
|
+
$.set(index, out);
|
21
|
+
return out;
|
22
|
+
}
|
23
|
+
|
24
|
+
function unpair(index) {
|
25
|
+
var i, l;
|
26
|
+
|
27
|
+
if ($.has(index)) {
|
28
|
+
return $.get(index);
|
29
|
+
}
|
30
|
+
|
31
|
+
var type = _[index][0];
|
32
|
+
var value = _[index][1];
|
33
|
+
|
34
|
+
switch (type) {
|
35
|
+
case PRIMITIVE:
|
36
|
+
case VOID:
|
37
|
+
return as(value, index);
|
38
|
+
|
39
|
+
case ARRAY: {
|
40
|
+
var arr = as([], index);
|
41
|
+
for (i = 0, l = value.length; i < l; ++i) {
|
42
|
+
arr.push(unpair(value[i]));
|
43
|
+
}
|
44
|
+
return arr;
|
45
|
+
}
|
46
|
+
|
47
|
+
case OBJECT: {
|
48
|
+
var object = as({}, index);
|
49
|
+
var keys = Object.keys(value);
|
50
|
+
for (i = 0, l = keys.length; i < l; ++i) {
|
51
|
+
var entry = value[keys[i]];
|
52
|
+
object[unpair(entry[0])] = unpair(entry[1]);
|
53
|
+
}
|
54
|
+
|
55
|
+
return object;
|
56
|
+
}
|
57
|
+
|
58
|
+
case DATE:
|
59
|
+
return as(new Date(value), index);
|
60
|
+
|
61
|
+
case REGEXP: {
|
62
|
+
return as(new RegExp(value.source, value.flags), index);
|
63
|
+
}
|
64
|
+
|
65
|
+
case MAP: {
|
66
|
+
var map = as(new Map(), index);
|
67
|
+
for (i = 0, l = value.length; i < l; ++i) {
|
68
|
+
var mapEntry = value[i];
|
69
|
+
map.set(unpair(mapEntry[0]), unpair(mapEntry[1]));
|
70
|
+
}
|
71
|
+
|
72
|
+
return map;
|
73
|
+
}
|
74
|
+
|
75
|
+
case SET: {
|
76
|
+
var set = as(new Set(), index);
|
77
|
+
for (i = 0, l = value.length; i < l; ++i) {
|
78
|
+
set.add(unpair(value[i]));
|
79
|
+
}
|
80
|
+
return set;
|
81
|
+
}
|
82
|
+
|
83
|
+
case ERROR: {
|
84
|
+
return as(new env[value.name](value.message), index);
|
85
|
+
}
|
86
|
+
|
87
|
+
case BIGINT:
|
88
|
+
return as(BigInt(value), index);
|
89
|
+
|
90
|
+
case "BigInt":
|
91
|
+
return as(Object(BigInt(value)), index);
|
92
|
+
}
|
93
|
+
|
94
|
+
return as(new env[type](value), index);
|
95
|
+
}
|
96
|
+
|
97
|
+
return unpair;
|
98
|
+
}
|
99
|
+
|
100
|
+
function deserialize(serialized) {
|
101
|
+
return deserializer(new Map(), serialized)(0);
|
102
|
+
}
|
103
|
+
|
104
|
+
var EMPTY = "";
|
105
|
+
var emptyObject = {};
|
106
|
+
|
107
|
+
function typeOf(value) {
|
108
|
+
if (value instanceof Map) {
|
109
|
+
return [MAP, EMPTY];
|
110
|
+
}
|
111
|
+
|
112
|
+
if (value instanceof Set) {
|
113
|
+
return [SET, EMPTY];
|
114
|
+
}
|
115
|
+
|
116
|
+
var type = typeof value;
|
117
|
+
if (type !== "object" || !value) {
|
118
|
+
return [PRIMITIVE, type];
|
119
|
+
}
|
120
|
+
|
121
|
+
var asString = emptyObject.toString.call(value).slice(8, -1);
|
122
|
+
|
123
|
+
switch (asString) {
|
124
|
+
case "Array":
|
125
|
+
return [ARRAY, EMPTY];
|
126
|
+
|
127
|
+
case "Object":
|
128
|
+
return [OBJECT, EMPTY];
|
129
|
+
|
130
|
+
case "Date":
|
131
|
+
return [DATE, EMPTY];
|
132
|
+
|
133
|
+
case "RegExp":
|
134
|
+
return [REGEXP, EMPTY];
|
135
|
+
}
|
136
|
+
|
137
|
+
if (asString.indexOf("Array") !== -1) {
|
138
|
+
return [ARRAY, asString];
|
139
|
+
}
|
140
|
+
|
141
|
+
if (asString.indexOf("Error") !== -1) {
|
142
|
+
return [ERROR, asString];
|
143
|
+
}
|
144
|
+
|
145
|
+
return [OBJECT, asString];
|
146
|
+
}
|
147
|
+
|
148
|
+
function shouldSkip(type) {
|
149
|
+
return type[0] === PRIMITIVE && (type[1] === "function" || type[1] === "symbol");
|
150
|
+
}
|
151
|
+
|
152
|
+
function serializer($, _) {
|
153
|
+
function as(out, value) {
|
154
|
+
var index = _.push(out) - 1;
|
155
|
+
$.set(value, index);
|
156
|
+
return index;
|
157
|
+
}
|
158
|
+
|
159
|
+
function pair(value) {
|
160
|
+
if ($.has(value)) {
|
161
|
+
return $.get(value);
|
162
|
+
}
|
163
|
+
|
164
|
+
var i, l, keys;
|
165
|
+
var to = typeOf(value);
|
166
|
+
var TYPE = to[0];
|
167
|
+
var typeName = to[1];
|
168
|
+
|
169
|
+
switch (TYPE) {
|
170
|
+
case PRIMITIVE: {
|
171
|
+
var primitiveValue = value;
|
172
|
+
|
173
|
+
switch (typeName) {
|
174
|
+
case "bigint":
|
175
|
+
TYPE = BIGINT;
|
176
|
+
primitiveValue = value.toString();
|
177
|
+
break;
|
178
|
+
|
179
|
+
case "function":
|
180
|
+
case "symbol":
|
181
|
+
throw new TypeError("unable to serialize " + typeName);
|
182
|
+
|
183
|
+
case "undefined":
|
184
|
+
return as([VOID], value);
|
185
|
+
}
|
186
|
+
|
187
|
+
return as([TYPE, primitiveValue], value);
|
188
|
+
}
|
189
|
+
|
190
|
+
case ARRAY: {
|
191
|
+
var arr = [];
|
192
|
+
var arrayIndex = as([typeName || TYPE, arr], value);
|
193
|
+
|
194
|
+
if (typeName) {
|
195
|
+
for (i = 0, l = value.length; i < l; ++i) {
|
196
|
+
arr.push(value[i]);
|
197
|
+
}
|
198
|
+
|
199
|
+
} else {
|
200
|
+
for (i = 0, l = value.length; i < l; ++i) {
|
201
|
+
arr.push(pair(value[i]));
|
202
|
+
}
|
203
|
+
}
|
204
|
+
return arrayIndex;
|
205
|
+
}
|
206
|
+
|
207
|
+
case OBJECT: {
|
208
|
+
if (typeName) {
|
209
|
+
switch (typeName) {
|
210
|
+
case "BigInt":
|
211
|
+
return as([typeName, value.toString()], value);
|
212
|
+
|
213
|
+
case "Boolean":
|
214
|
+
case "Number":
|
215
|
+
case "String":
|
216
|
+
return as([typeName, value.valueOf()], value);
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
var objectEntries = [];
|
221
|
+
var index = as([TYPE, objectEntries], value);
|
222
|
+
keys = Object.keys(value);
|
223
|
+
for (i = 0, l = keys.length; i < l; ++i) {
|
224
|
+
var objectKey = keys[i];
|
225
|
+
if (!shouldSkip(typeOf(value[objectKey]))) {
|
226
|
+
objectEntries.push([pair(objectKey), pair(value[objectKey])]);
|
227
|
+
}
|
228
|
+
}
|
229
|
+
return index;
|
230
|
+
}
|
231
|
+
|
232
|
+
case DATE:
|
233
|
+
return as([TYPE, value.toISOString()], value);
|
234
|
+
|
235
|
+
case REGEXP: {
|
236
|
+
return as([TYPE, {source: value.source, flags: (value.global ? "g" : "") + (value.ignoreCase ? "i" : "") + (value.multiline ? "m" : "")}], value);
|
237
|
+
}
|
238
|
+
|
239
|
+
case MAP: {
|
240
|
+
var mapEntries = [];
|
241
|
+
var mapIndex = as([TYPE, mapEntries], value);
|
242
|
+
value.forEach(function (value, key) {
|
243
|
+
if (!(shouldSkip(typeOf(key)) || shouldSkip(typeOf(value)))) {
|
244
|
+
mapEntries.push([pair(key), pair(value)]);
|
245
|
+
}
|
246
|
+
})
|
247
|
+
|
248
|
+
return mapIndex;
|
249
|
+
}
|
250
|
+
|
251
|
+
case SET: {
|
252
|
+
var setEntries = [];
|
253
|
+
var setIndex = as([TYPE, setEntries], value);
|
254
|
+
value.forEach(function (value) {
|
255
|
+
if (!shouldSkip(typeOf(value))) {
|
256
|
+
setEntries.push(pair(value));
|
257
|
+
}
|
258
|
+
})
|
259
|
+
|
260
|
+
return setIndex;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
return as([TYPE, {name: typeName, message: value.message}], value);
|
265
|
+
}
|
266
|
+
|
267
|
+
return pair;
|
268
|
+
}
|
269
|
+
|
270
|
+
function serialize(value) {
|
271
|
+
var _ = [];
|
272
|
+
return serializer(new Map(), _)(value), _;
|
273
|
+
}
|
274
|
+
|
275
|
+
env.structuredClone = function structuredClone(any) {
|
276
|
+
return deserialize(serialize(any));
|
277
|
+
};
|
278
|
+
|
279
|
+
})(self);
|