typeson-registry 13.1.0 → 13.2.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 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +113 -7
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.cjs +111 -8
- package/dist/index.umd.cjs.map +1 -1
- package/dist/index.umd.min.cjs +2 -2
- package/dist/index.umd.min.cjs.map +1 -1
- package/dist/presets/structured-cloning-throwing.d.ts.map +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.map +1 -1
- package/dist/presets/structured-cloning.umd.cjs +1 -1
- package/dist/presets/structured-cloning.umd.cjs.map +1 -1
- package/dist/types/audiodata.d.ts +6 -0
- package/dist/types/audiodata.d.ts.map +1 -0
- package/dist/types/audiodata.umd.cjs +2 -0
- package/dist/types/audiodata.umd.cjs.map +1 -0
- package/dist/types/filelist.d.ts.map +1 -1
- package/dist/types/filelist.umd.cjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "typeson";
|
|
2
2
|
import arraybuffer from './types/arraybuffer.js';
|
|
3
|
+
import audiodata from './types/audiodata.js';
|
|
3
4
|
import bigintObject from './types/bigint-object.js';
|
|
4
5
|
import bigint from './types/bigint.js';
|
|
5
6
|
import blob from './types/blob.js';
|
|
@@ -45,5 +46,5 @@ import structuredCloningThrowing from './presets/structured-cloning-throwing.js'
|
|
|
45
46
|
import structuredCloning from './presets/structured-cloning.js';
|
|
46
47
|
import undefPreset from './presets/undef.js';
|
|
47
48
|
import universal from './presets/universal.js';
|
|
48
|
-
export { arraybuffer, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, promise, regexp, resurrectable, set, symbol, typedArraysSocketio, typedArrays, undef, userObject, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
|
|
49
|
+
export { arraybuffer, audiodata, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, promise, regexp, resurrectable, set, symbol, typedArraysSocketio, typedArrays, undef, userObject, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
|
|
49
50
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAGwB,wBAAwB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAGwB,wBAAwB;sBAC1B,sBAAsB;yBACnB,0BAA0B;mBAChC,mBAAmB;iBACrB,iBAAiB;sBACZ,sBAAsB;sBACtB,sBAAsB;qBACvB,qBAAqB;iBACzB,iBAAiB;yBACT,yBAAyB;sBAC5B,sBAAsB;qBACvB,qBAAqB;oBACtB,oBAAoB;oBACpB,oBAAoB;kBACtB,kBAAkB;mBACjB,mBAAmB;iBACrB,iBAAiB;qBACb,qBAAqB;wBAClB,wBAAwB;sBAC1B,sBAAsB;qBACvB,qBAAqB;sBACpB,uBAAuB;gBAC7B,gBAAgB;gBAChB,gBAAgB;6BACH,8BAA8B;yBAClC,0BAA0B;6BACtB,8BAA8B;6BAC9B,8BAA8B;oBACvC,oBAAoB;mBACrB,mBAAmB;0BACZ,0BAA0B;gBACpC,gBAAgB;mBACb,mBAAmB;gCACN,kCAAkC;wBAC1C,yBAAyB;kBAC/B,kBAAkB;uBACb,wBAAwB;8BAGjB,kCAAkC;oBAC5C,sBAAsB;wBAClB,0BAA0B;qBAC7B,uBAAuB;4BAChB,+BAA+B;2BAChC,8BAA8B;sCAErD,0CAA0C;8BAChB,iCAAiC;wBACvC,oBAAoB;sBACtB,wBAAwB"}
|
package/dist/index.js
CHANGED
|
@@ -155,6 +155,65 @@ const arraybuffer = {
|
|
|
155
155
|
|
|
156
156
|
// See also typed-arrays!
|
|
157
157
|
|
|
158
|
+
/* globals AudioData -- Polyfills */
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @type {import('typeson').TypeSpecSet}
|
|
162
|
+
*/
|
|
163
|
+
const audiodata = {
|
|
164
|
+
audiodata: {
|
|
165
|
+
test (x) {
|
|
166
|
+
return toStringTag(x) === 'AudioData';
|
|
167
|
+
},
|
|
168
|
+
replace (audioData) {
|
|
169
|
+
const {
|
|
170
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
171
|
+
timestamp
|
|
172
|
+
} = audioData;
|
|
173
|
+
|
|
174
|
+
// 2. Determine plane layout based on audio format
|
|
175
|
+
const isPlanar = format.endsWith('-planar');
|
|
176
|
+
const numPlanes = isPlanar ? numberOfChannels : 1;
|
|
177
|
+
|
|
178
|
+
// 3. Per the AudioData API, planes are laid out back-to-back
|
|
179
|
+
// within a single buffer, so compute their sizes up front
|
|
180
|
+
const planeSizes = [];
|
|
181
|
+
let totalSize = 0;
|
|
182
|
+
for (let i = 0; i < numPlanes; i++) {
|
|
183
|
+
const size = audioData.allocationSize({planeIndex: i});
|
|
184
|
+
planeSizes.push(size);
|
|
185
|
+
totalSize += size;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 4. Copy the raw binary data out of each plane into its slot
|
|
189
|
+
const data = new ArrayBuffer(totalSize);
|
|
190
|
+
let offset = 0;
|
|
191
|
+
for (let i = 0; i < numPlanes; i++) {
|
|
192
|
+
const planeView = new Uint8Array(data, offset, planeSizes[i]);
|
|
193
|
+
audioData.copyTo(planeView, {planeIndex: i});
|
|
194
|
+
offset += planeSizes[i];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 5. Return a clean, serializable manifest
|
|
198
|
+
return {
|
|
199
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
200
|
+
timestamp,
|
|
201
|
+
data
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
revive ({
|
|
205
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
206
|
+
timestamp, data
|
|
207
|
+
}) {
|
|
208
|
+
return new AudioData({
|
|
209
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
210
|
+
timestamp,
|
|
211
|
+
data: new Uint8Array(data)
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
158
217
|
/**
|
|
159
218
|
* @type {import('typeson').TypeSpecSet}
|
|
160
219
|
*/
|
|
@@ -923,6 +982,8 @@ const filelist = {
|
|
|
923
982
|
return 'FileList';
|
|
924
983
|
}
|
|
925
984
|
}
|
|
985
|
+
|
|
986
|
+
// @ts-ignore Override API
|
|
926
987
|
return new FileList(o);
|
|
927
988
|
}
|
|
928
989
|
}
|
|
@@ -1756,9 +1817,39 @@ const expObj = [
|
|
|
1756
1817
|
/* c8 ignore next */
|
|
1757
1818
|
typeof DOMQuad !== 'undefined' ? domquad : [],
|
|
1758
1819
|
/* c8 ignore next */
|
|
1759
|
-
typeof DOMMatrix !== 'undefined' ? dommatrix : []
|
|
1820
|
+
typeof DOMMatrix !== 'undefined' ? dommatrix : [],
|
|
1821
|
+
/* c8 ignore next */
|
|
1822
|
+
typeof AudioData !== 'undefined' ? audiodata : []
|
|
1760
1823
|
);
|
|
1761
1824
|
|
|
1825
|
+
/**
|
|
1826
|
+
* @param {BufferSource} buffer
|
|
1827
|
+
* @returns {boolean}
|
|
1828
|
+
*/
|
|
1829
|
+
function isBufferDetached (buffer) {
|
|
1830
|
+
// Use the standard property if available
|
|
1831
|
+
// @ts-expect-error - More recent API
|
|
1832
|
+
if (typeof buffer.detached === 'boolean') {
|
|
1833
|
+
// @ts-expect-error - More recent API
|
|
1834
|
+
return buffer.detached;
|
|
1835
|
+
}
|
|
1836
|
+
/* c8 ignore next 14 -- Older browsers */
|
|
1837
|
+
|
|
1838
|
+
// Fallback check via byteLength and constructor test
|
|
1839
|
+
if (buffer.byteLength !== 0) {
|
|
1840
|
+
return false;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
try {
|
|
1844
|
+
// @ts-expect-error Ok
|
|
1845
|
+
// eslint-disable-next-line no-new -- Throwaway
|
|
1846
|
+
new Uint8Array(buffer);
|
|
1847
|
+
return false;
|
|
1848
|
+
} catch {
|
|
1849
|
+
return true;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1762
1853
|
/**
|
|
1763
1854
|
* @type {import('typeson').Preset}
|
|
1764
1855
|
*/
|
|
@@ -1766,13 +1857,11 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1766
1857
|
checkDataCloneException: {
|
|
1767
1858
|
test (val) {
|
|
1768
1859
|
// Should also throw with:
|
|
1769
|
-
// 1. `
|
|
1770
|
-
// ECMAScript spec)
|
|
1771
|
-
// 2. `IsCallable` (covered by `typeof === 'function'` or a
|
|
1860
|
+
// 1. `IsCallable` (covered by `typeof === 'function'` or a
|
|
1772
1861
|
// function's `toStringTag`)
|
|
1773
|
-
//
|
|
1862
|
+
// 2. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
|
|
1774
1863
|
// [[PromiseState]] or [[WeakMapData]])
|
|
1775
|
-
//
|
|
1864
|
+
// 3. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
|
|
1776
1865
|
// intrinsic object) (which does not have default
|
|
1777
1866
|
// behavior for one or more of the essential internal methods
|
|
1778
1867
|
// that are limited to the following for non-function objects
|
|
@@ -1814,6 +1903,23 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1814
1903
|
// Also in Node `worker_threads` (currently experimental)
|
|
1815
1904
|
'MessageChannel'
|
|
1816
1905
|
].includes(stringTag) ||
|
|
1906
|
+
// 1. `IsDetachedBuffer` (a process not called within the
|
|
1907
|
+
// ECMAScript spec)
|
|
1908
|
+
([
|
|
1909
|
+
'ArrayBuffer',
|
|
1910
|
+
'DataView',
|
|
1911
|
+
'Int8Array',
|
|
1912
|
+
'Uint8Array',
|
|
1913
|
+
'Uint8ClampedArray',
|
|
1914
|
+
'Int16Array',
|
|
1915
|
+
'Uint16Array',
|
|
1916
|
+
'Int32Array',
|
|
1917
|
+
'Uint32Array',
|
|
1918
|
+
'Float32Array',
|
|
1919
|
+
'Float64Array',
|
|
1920
|
+
'BigInt64Array',
|
|
1921
|
+
'BigUint64Array'
|
|
1922
|
+
].includes(stringTag) && isBufferDetached(val)) ||
|
|
1817
1923
|
/*
|
|
1818
1924
|
// isClosed is no longer documented
|
|
1819
1925
|
((stringTag === 'Blob' || stringTag === 'File') &&
|
|
@@ -1851,5 +1957,5 @@ const universal = [
|
|
|
1851
1957
|
// built-in into ecmasript standard.
|
|
1852
1958
|
];
|
|
1853
1959
|
|
|
1854
|
-
export { i$1 as JSON_TYPES, Typeson, TypesonPromise, Undefined, arrayNonindexKeys, arraybuffer, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, promise, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, symbol, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
|
|
1960
|
+
export { i$1 as JSON_TYPES, Typeson, TypesonPromise, Undefined, arrayNonindexKeys, arraybuffer, audiodata, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, promise, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, symbol, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
|
|
1855
1961
|
//# sourceMappingURL=index.js.map
|