typeson-registry 10.0.0 → 11.0.1
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/README.md +1 -5
- package/dist/index.js +40 -42
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.cjs +32 -31
- package/dist/index.umd.cjs.map +1 -1
- package/dist/index.umd.min.cjs +1 -1
- package/dist/index.umd.min.cjs.map +1 -1
- package/dist/polyfills/createObjectURL.d.ts.map +1 -1
- package/dist/presets/array-nonindex-keys.d.ts +1 -1
- package/dist/presets/array-nonindex-keys.umd.cjs.map +1 -1
- package/dist/presets/builtin.d.ts +1 -1
- package/dist/presets/builtin.umd.cjs +1 -1
- package/dist/presets/builtin.umd.cjs.map +1 -1
- package/dist/presets/postmessage.d.ts +1 -1
- package/dist/presets/postmessage.umd.cjs.map +1 -1
- package/dist/presets/socketio.d.ts +1 -1
- package/dist/presets/socketio.umd.cjs +1 -1
- package/dist/presets/socketio.umd.cjs.map +1 -1
- package/dist/presets/sparse-undefined.d.ts +1 -1
- package/dist/presets/sparse-undefined.umd.cjs.map +1 -1
- package/dist/presets/special-numbers.d.ts +1 -1
- package/dist/presets/special-numbers.umd.cjs.map +1 -1
- package/dist/presets/structured-cloning-throwing.d.ts +1 -1
- package/dist/presets/structured-cloning-throwing.umd.cjs +1 -1
- package/dist/presets/structured-cloning-throwing.umd.cjs.map +1 -1
- package/dist/presets/structured-cloning.d.ts +1 -1
- package/dist/presets/structured-cloning.umd.cjs +1 -1
- package/dist/presets/structured-cloning.umd.cjs.map +1 -1
- package/dist/presets/undef.d.ts +1 -1
- package/dist/presets/undef.umd.cjs.map +1 -1
- package/dist/presets/universal.d.ts +1 -1
- package/dist/presets/universal.umd.cjs +1 -1
- package/dist/presets/universal.umd.cjs.map +1 -1
- package/dist/types/arraybuffer.d.ts +1 -1
- package/dist/types/arraybuffer.umd.cjs.map +1 -1
- package/dist/types/bigint-object.d.ts +1 -1
- package/dist/types/bigint-object.d.ts.map +1 -1
- package/dist/types/bigint-object.umd.cjs.map +1 -1
- package/dist/types/bigint.d.ts +1 -1
- package/dist/types/bigint.d.ts.map +1 -1
- package/dist/types/bigint.umd.cjs.map +1 -1
- package/dist/types/blob.d.ts +1 -1
- package/dist/types/blob.d.ts.map +1 -1
- package/dist/types/blob.umd.cjs +1 -1
- package/dist/types/blob.umd.cjs.map +1 -1
- package/dist/types/cloneable.d.ts +1 -1
- package/dist/types/cloneable.umd.cjs +1 -1
- package/dist/types/cloneable.umd.cjs.map +1 -1
- package/dist/types/cryptokey.d.ts +1 -1
- package/dist/types/cryptokey.d.ts.map +1 -1
- package/dist/types/cryptokey.umd.cjs.map +1 -1
- package/dist/types/dataview.d.ts +1 -1
- package/dist/types/dataview.umd.cjs.map +1 -1
- package/dist/types/date.d.ts +1 -1
- package/dist/types/date.umd.cjs.map +1 -1
- package/dist/types/domexception.d.ts +1 -1
- package/dist/types/domexception.umd.cjs.map +1 -1
- package/dist/types/dommatrix.d.ts +1 -1
- package/dist/types/dommatrix.umd.cjs.map +1 -1
- package/dist/types/dompoint.d.ts +1 -1
- package/dist/types/dompoint.umd.cjs.map +1 -1
- package/dist/types/domquad.d.ts +1 -1
- package/dist/types/domquad.umd.cjs.map +1 -1
- package/dist/types/domrect.d.ts +1 -1
- package/dist/types/domrect.umd.cjs.map +1 -1
- package/dist/types/error.d.ts +1 -1
- package/dist/types/error.umd.cjs.map +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.umd.cjs.map +1 -1
- package/dist/types/file.d.ts +1 -1
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.umd.cjs +1 -1
- package/dist/types/file.umd.cjs.map +1 -1
- package/dist/types/filelist.d.ts +1 -1
- package/dist/types/filelist.umd.cjs +1 -1
- package/dist/types/filelist.umd.cjs.map +1 -1
- package/dist/types/imagebitmap.d.ts +1 -1
- package/dist/types/imagebitmap.umd.cjs.map +1 -1
- package/dist/types/imagedata.d.ts +1 -1
- package/dist/types/imagedata.umd.cjs.map +1 -1
- package/dist/types/infinity.d.ts +1 -1
- package/dist/types/infinity.umd.cjs.map +1 -1
- package/dist/types/intl-types.d.ts +3 -3
- package/dist/types/intl-types.umd.cjs.map +1 -1
- package/dist/types/map.d.ts +1 -1
- package/dist/types/map.umd.cjs.map +1 -1
- package/dist/types/nan.d.ts +1 -1
- package/dist/types/nan.umd.cjs.map +1 -1
- package/dist/types/negative-infinity.d.ts +1 -1
- package/dist/types/negative-infinity.umd.cjs.map +1 -1
- package/dist/types/negative-zero.d.ts +1 -1
- package/dist/types/negative-zero.umd.cjs.map +1 -1
- package/dist/types/nonbuiltin-ignore.d.ts +1 -1
- package/dist/types/nonbuiltin-ignore.umd.cjs.map +1 -1
- package/dist/types/primitive-objects.d.ts +1 -1
- package/dist/types/primitive-objects.d.ts.map +1 -1
- package/dist/types/primitive-objects.umd.cjs +1 -1
- package/dist/types/primitive-objects.umd.cjs.map +1 -1
- package/dist/types/regexp.d.ts +1 -1
- package/dist/types/regexp.umd.cjs.map +1 -1
- package/dist/types/resurrectable.d.ts +1 -1
- package/dist/types/resurrectable.umd.cjs +1 -1
- package/dist/types/resurrectable.umd.cjs.map +1 -1
- package/dist/types/set.d.ts +1 -1
- package/dist/types/set.umd.cjs.map +1 -1
- package/dist/types/typed-arrays-socketio.d.ts +1 -1
- package/dist/types/typed-arrays-socketio.d.ts.map +1 -1
- package/dist/types/typed-arrays-socketio.umd.cjs.map +1 -1
- package/dist/types/typed-arrays.d.ts +1 -1
- package/dist/types/typed-arrays.d.ts.map +1 -1
- package/dist/types/typed-arrays.umd.cjs.map +1 -1
- package/dist/types/undef.d.ts +1 -1
- package/dist/types/undef.umd.cjs.map +1 -1
- package/dist/types/user-object.d.ts +1 -1
- package/dist/types/user-object.umd.cjs.map +1 -1
- package/dist/utils/generateUUID.d.ts.map +1 -1
- package/package.json +34 -53
- package/polyfills/createObjectURL.js +8 -13
- package/polyfills/createObjectURL.umd.cjs +1 -1
- package/polyfills/createObjectURL.umd.cjs.map +1 -1
- package/utils/generateUUID.js +3 -13
- package/tools/append-to-declaration-files.js +0 -13
package/README.md
CHANGED
|
@@ -50,10 +50,6 @@ The `imagedata` type requires a global `ImageData` polyfill (including an
|
|
|
50
50
|
You may wish to see our `test-environment.js` file for how some
|
|
51
51
|
polyfilling may be done (largely using `jsdom`).
|
|
52
52
|
|
|
53
|
-
The `cloneable` and `resurrectable` types (and the `createObjectURL`
|
|
54
|
-
polyill) each accept an optional global `performance` polyfill (through
|
|
55
|
-
the common file `utils/generateUUID.js`).
|
|
56
|
-
|
|
57
53
|
### Building files from Git clone (as opposed to npm installs)
|
|
58
54
|
|
|
59
55
|
If you have cloned the repo (and not the npm package), you must run
|
|
@@ -317,7 +313,7 @@ another context).
|
|
|
317
313
|
const functionType = {functionType: [
|
|
318
314
|
function (x) { return typeof x === 'function'; },
|
|
319
315
|
function (funcType) { return '(' + funcType.toString() + ')'; },
|
|
320
|
-
// eslint-disable-next-line no-eval
|
|
316
|
+
// eslint-disable-next-line no-eval -- Demonstrating
|
|
321
317
|
function (o) { return eval(o); }
|
|
322
318
|
]};
|
|
323
319
|
|
package/dist/index.js
CHANGED
|
@@ -157,8 +157,6 @@ const bigintObject = {
|
|
|
157
157
|
},
|
|
158
158
|
replace: String,
|
|
159
159
|
revive (s) {
|
|
160
|
-
// Filed this to avoid error: https://github.com/eslint/eslint/issues/11810
|
|
161
|
-
// eslint-disable-next-line no-new-object
|
|
162
160
|
return new Object(BigInt(/** @type {string} */ (s)));
|
|
163
161
|
}
|
|
164
162
|
}
|
|
@@ -173,7 +171,8 @@ const bigint = {
|
|
|
173
171
|
return typeof x === 'bigint';
|
|
174
172
|
},
|
|
175
173
|
replace: String,
|
|
176
|
-
// eslint-disable-next-line
|
|
174
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
175
|
+
// eslint-disable-next-line unicorn/prefer-native-coercion-functions -- Clearer
|
|
177
176
|
revive (s) {
|
|
178
177
|
return BigInt(/** @type {string} */ (s));
|
|
179
178
|
}
|
|
@@ -185,6 +184,11 @@ const bigint = {
|
|
|
185
184
|
* @param {ArrayBuffer} buf
|
|
186
185
|
* @returns {string}
|
|
187
186
|
*/
|
|
187
|
+
function arraybuffer2string (buf) {
|
|
188
|
+
return new Uint8Array(buf).reduce(
|
|
189
|
+
(s, byte) => s + String.fromCodePoint(byte), ''
|
|
190
|
+
);
|
|
191
|
+
}
|
|
188
192
|
|
|
189
193
|
/**
|
|
190
194
|
*
|
|
@@ -247,7 +251,7 @@ function string2arraybuffer (str) {
|
|
|
247
251
|
return array.buffer;
|
|
248
252
|
}
|
|
249
253
|
|
|
250
|
-
/* globals XMLHttpRequest,
|
|
254
|
+
/* globals XMLHttpRequest, FileReader -- Polyfills */
|
|
251
255
|
|
|
252
256
|
/**
|
|
253
257
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -289,7 +293,9 @@ const blob = {
|
|
|
289
293
|
reader.addEventListener('load', () => {
|
|
290
294
|
resolve({
|
|
291
295
|
type: b.type,
|
|
292
|
-
stringContents:
|
|
296
|
+
stringContents: arraybuffer2string(
|
|
297
|
+
/** @type {ArrayBuffer} */ (reader.result)
|
|
298
|
+
)
|
|
293
299
|
});
|
|
294
300
|
});
|
|
295
301
|
// Seems not feasible to accurately simulate
|
|
@@ -297,14 +303,14 @@ const blob = {
|
|
|
297
303
|
reader.addEventListener('error', () => {
|
|
298
304
|
reject(reader.error);
|
|
299
305
|
});
|
|
300
|
-
|
|
306
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
307
|
+
// eslint-disable-next-line unicorn/prefer-blob-reading-methods -- Too new?
|
|
308
|
+
reader.readAsArrayBuffer(b);
|
|
301
309
|
});
|
|
302
310
|
}
|
|
303
311
|
}
|
|
304
312
|
};
|
|
305
313
|
|
|
306
|
-
// The `performance` global is optional
|
|
307
|
-
|
|
308
314
|
/**
|
|
309
315
|
* @todo We could use `import generateUUID from 'uuid/v4';` (but it needs
|
|
310
316
|
* crypto library, etc.; `rollup-plugin-node-builtins` doesn't recommend
|
|
@@ -314,22 +320,14 @@ const blob = {
|
|
|
314
320
|
*/
|
|
315
321
|
function generateUUID () { // Adapted from original: public domain/MIT: http://stackoverflow.com/a/8809472/271577
|
|
316
322
|
/* c8 ignore next */
|
|
317
|
-
let d = Date.now()
|
|
318
|
-
|
|
319
|
-
/* c8 ignore next 4 */
|
|
320
|
-
(typeof performance !== 'undefined' &&
|
|
321
|
-
typeof performance.now === 'function'
|
|
322
|
-
? performance.now()
|
|
323
|
-
: 0);
|
|
324
|
-
|
|
325
|
-
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
326
|
-
// eslint-disable-next-line no-use-extend-native/no-use-extend-native -- Need to update plugin
|
|
323
|
+
let d = Date.now();
|
|
324
|
+
|
|
327
325
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/gu, function (c) {
|
|
328
|
-
/* eslint-disable no-bitwise */
|
|
326
|
+
/* eslint-disable no-bitwise -- Convenient */
|
|
329
327
|
const r = Math.trunc((d + (Math.random() * 16)) % 16);
|
|
330
328
|
d = Math.floor(d / 16);
|
|
331
329
|
return (c === 'x' ? r : ((r & 0x3) | 0x8)).toString(16);
|
|
332
|
-
/* eslint-enable no-bitwise */
|
|
330
|
+
/* eslint-enable no-bitwise -- Convenient */
|
|
333
331
|
});
|
|
334
332
|
}
|
|
335
333
|
|
|
@@ -365,8 +363,6 @@ const cloneable = {
|
|
|
365
363
|
}
|
|
366
364
|
};
|
|
367
365
|
|
|
368
|
-
/* globals crypto */
|
|
369
|
-
|
|
370
366
|
/**
|
|
371
367
|
* @type {import('typeson').TypeSpecSet}
|
|
372
368
|
*/
|
|
@@ -520,7 +516,7 @@ const domexception = {
|
|
|
520
516
|
}
|
|
521
517
|
};
|
|
522
518
|
|
|
523
|
-
/* globals DOMMatrix, DOMMatrixReadOnly */
|
|
519
|
+
/* globals DOMMatrix, DOMMatrixReadOnly -- Polyfills */
|
|
524
520
|
|
|
525
521
|
/**
|
|
526
522
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -587,7 +583,7 @@ function create$5 (Ctor) {
|
|
|
587
583
|
};
|
|
588
584
|
}
|
|
589
585
|
|
|
590
|
-
/* globals DOMPoint, DOMPointReadOnly */
|
|
586
|
+
/* globals DOMPoint, DOMPointReadOnly -- Polyfills */
|
|
591
587
|
|
|
592
588
|
/**
|
|
593
589
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -624,7 +620,7 @@ function create$4 (Ctor) {
|
|
|
624
620
|
};
|
|
625
621
|
}
|
|
626
622
|
|
|
627
|
-
/* globals DOMQuad */
|
|
623
|
+
/* globals DOMQuad -- Polyfills */
|
|
628
624
|
|
|
629
625
|
/**
|
|
630
626
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -646,7 +642,7 @@ const domquad = {
|
|
|
646
642
|
}
|
|
647
643
|
};
|
|
648
644
|
|
|
649
|
-
/* globals DOMRect, DOMRectReadOnly */
|
|
645
|
+
/* globals DOMRect, DOMRectReadOnly -- Polyfills */
|
|
650
646
|
|
|
651
647
|
/**
|
|
652
648
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -719,8 +715,7 @@ const error = {
|
|
|
719
715
|
}
|
|
720
716
|
};
|
|
721
717
|
|
|
722
|
-
/* globals InternalError */
|
|
723
|
-
/* eslint-env browser, node */
|
|
718
|
+
/* globals InternalError -- Optional */
|
|
724
719
|
|
|
725
720
|
/**
|
|
726
721
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -811,7 +806,7 @@ function create$2 (Ctor) {
|
|
|
811
806
|
};
|
|
812
807
|
}
|
|
813
808
|
|
|
814
|
-
/* globals XMLHttpRequest,
|
|
809
|
+
/* globals XMLHttpRequest, FileReader -- Polyfills */
|
|
815
810
|
|
|
816
811
|
/**
|
|
817
812
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -855,7 +850,9 @@ const file = {
|
|
|
855
850
|
reader.addEventListener('load', function () {
|
|
856
851
|
resolve({
|
|
857
852
|
type: f.type,
|
|
858
|
-
stringContents:
|
|
853
|
+
stringContents: arraybuffer2string(
|
|
854
|
+
/** @type {ArrayBuffer} */ (reader.result)
|
|
855
|
+
),
|
|
859
856
|
name: f.name,
|
|
860
857
|
lastModified: f.lastModified
|
|
861
858
|
});
|
|
@@ -865,7 +862,9 @@ const file = {
|
|
|
865
862
|
reader.addEventListener('error', function () {
|
|
866
863
|
reject(reader.error);
|
|
867
864
|
});
|
|
868
|
-
|
|
865
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
866
|
+
// eslint-disable-next-line unicorn/prefer-blob-reading-methods -- Too new?
|
|
867
|
+
reader.readAsArrayBuffer(f);
|
|
869
868
|
});
|
|
870
869
|
}
|
|
871
870
|
}
|
|
@@ -894,7 +893,7 @@ const filelist = {
|
|
|
894
893
|
* Set private properties and length.
|
|
895
894
|
*/
|
|
896
895
|
constructor () {
|
|
897
|
-
// eslint-disable-next-line prefer-rest-params
|
|
896
|
+
// eslint-disable-next-line prefer-rest-params -- API
|
|
898
897
|
this._files = arguments[0];
|
|
899
898
|
this.length = this._files.length;
|
|
900
899
|
}
|
|
@@ -905,12 +904,12 @@ const filelist = {
|
|
|
905
904
|
item (index) {
|
|
906
905
|
return this._files[index];
|
|
907
906
|
}
|
|
908
|
-
/* eslint-disable class-methods-use-this */
|
|
907
|
+
/* eslint-disable class-methods-use-this -- Not needed */
|
|
909
908
|
/**
|
|
910
909
|
* @returns {"FileList"}
|
|
911
910
|
*/
|
|
912
911
|
get [Symbol.toStringTag] () {
|
|
913
|
-
/* eslint-enable class-methods-use-this */
|
|
912
|
+
/* eslint-enable class-methods-use-this -- Not needed */
|
|
914
913
|
return 'FileList';
|
|
915
914
|
}
|
|
916
915
|
}
|
|
@@ -919,7 +918,7 @@ const filelist = {
|
|
|
919
918
|
}
|
|
920
919
|
};
|
|
921
920
|
|
|
922
|
-
/* globals document, OffscreenCanvas, createImageBitmap */
|
|
921
|
+
/* globals document, OffscreenCanvas, createImageBitmap -- Polyfills */
|
|
923
922
|
// `ImageBitmap` is browser / DOM specific. It also can only work
|
|
924
923
|
// same-domain (or CORS)
|
|
925
924
|
|
|
@@ -1002,7 +1001,7 @@ const imagebitmap = {
|
|
|
1002
1001
|
}
|
|
1003
1002
|
};
|
|
1004
1003
|
|
|
1005
|
-
/* globals ImageData */
|
|
1004
|
+
/* globals ImageData -- Polyfills */
|
|
1006
1005
|
// `ImageData` is browser / DOM specific (though `node-canvas` has it
|
|
1007
1006
|
// available on `Canvas`).
|
|
1008
1007
|
|
|
@@ -1160,7 +1159,7 @@ const nonbuiltinIgnore = {
|
|
|
1160
1159
|
|
|
1161
1160
|
// This module is for objectified primitives (such as `new Number(3)` or
|
|
1162
1161
|
// `new String("foo")`)
|
|
1163
|
-
/* eslint-disable no-new-wrappers, unicorn/new-for-builtins */
|
|
1162
|
+
/* eslint-disable no-new-wrappers, unicorn/new-for-builtins -- Deliberate */
|
|
1164
1163
|
|
|
1165
1164
|
/**
|
|
1166
1165
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -1180,7 +1179,10 @@ const primitiveObjects = {
|
|
|
1180
1179
|
return toStringTag(x) === 'Boolean' &&
|
|
1181
1180
|
typeof x === 'object';
|
|
1182
1181
|
},
|
|
1183
|
-
replace
|
|
1182
|
+
replace (o) {
|
|
1183
|
+
// convert to primitive boolean
|
|
1184
|
+
return o.valueOf();
|
|
1185
|
+
},
|
|
1184
1186
|
revive (b) {
|
|
1185
1187
|
// Revive to an objectified Boolean
|
|
1186
1188
|
return new Boolean(b);
|
|
@@ -1263,8 +1265,6 @@ const set = {
|
|
|
1263
1265
|
}
|
|
1264
1266
|
};
|
|
1265
1267
|
|
|
1266
|
-
/* eslint-env browser, node */
|
|
1267
|
-
|
|
1268
1268
|
// Support all kinds of typed arrays (views of ArrayBuffers)
|
|
1269
1269
|
|
|
1270
1270
|
/**
|
|
@@ -1331,8 +1331,6 @@ if (typeof Int8Array === 'function') {
|
|
|
1331
1331
|
].forEach((TypedArray) => create$1(TypedArray));
|
|
1332
1332
|
}
|
|
1333
1333
|
|
|
1334
|
-
/* eslint-env browser, node */
|
|
1335
|
-
|
|
1336
1334
|
/**
|
|
1337
1335
|
* @type {import('typeson').TypeSpecSet}
|
|
1338
1336
|
*/
|