typeson-registry 13.1.0 → 13.2.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/README.md CHANGED
@@ -210,6 +210,7 @@ Note that the type name corresponds to the file name in the following manner:
210
210
 
211
211
  ### Types
212
212
 
213
+ - `audiodata`
213
214
  - `arraybuffer`
214
215
  - `bigintObject`
215
216
  - `bigint`
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,6 @@ 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
- //# sourceMappingURL=index.d.ts.map
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 };
50
+ //# sourceMappingURL=index.d.ts.map
51
+ export type * from 'typeson';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAGwB,wBAAwB;yBACvB,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"}
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
  */
@@ -1756,7 +1815,9 @@ const expObj = [
1756
1815
  /* c8 ignore next */
1757
1816
  typeof DOMQuad !== 'undefined' ? domquad : [],
1758
1817
  /* c8 ignore next */
1759
- typeof DOMMatrix !== 'undefined' ? dommatrix : []
1818
+ typeof DOMMatrix !== 'undefined' ? dommatrix : [],
1819
+ /* c8 ignore next */
1820
+ typeof AudioData !== 'undefined' ? audiodata : []
1760
1821
  );
1761
1822
 
1762
1823
  /**
@@ -1851,5 +1912,5 @@ const universal = [
1851
1912
  // built-in into ecmasript standard.
1852
1913
  ];
1853
1914
 
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 };
1915
+ 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
1916
  //# sourceMappingURL=index.js.map