From 93587bdb28c833d9d579b19a6861b293bac15216 Mon Sep 17 00:00:00 2001 From: Offroaders123 <65947371+Offroaders123@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:15:44 -0800 Subject: [PATCH] CJS TS Export Default Syntax Moving this over to the proper was TS does things for CJS, rather than treating it like `export default`, which I was mistakenly doing previously. https://github.com/microsoft/TypeScript/issues/7185 Listening to Blackwater Park, Blackwater Park. --- src/ArrayBufferFileReader.ts | 2 +- src/ArrayFileReader.ts | 4 +++- src/BlobFileReader.ts | 4 +++- src/ChunkedFileData.ts | 4 +++- src/FLACTagContents.ts | 4 +++- src/FLACTagReader.ts | 4 +++- src/ID3v1TagReader.ts | 4 +++- src/ID3v2FrameReader.ts | 4 +++- src/ID3v2TagContents.ts | 4 +++- src/ID3v2TagReader.ts | 4 +++- src/MP4TagContents.ts | 4 +++- src/MP4TagReader.ts | 4 +++- src/MediaFileReader.ts | 4 +++- src/MediaTagReader.ts | 4 +++- src/NodeFileReader.ts | 4 +++- src/ReactNativeFileReader.ts | 4 +++- src/StringUtils.ts | 4 +++- src/XhrFileReader.ts | 4 ++-- 18 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/ArrayBufferFileReader.ts b/src/ArrayBufferFileReader.ts index eceae28..c6b5716 100644 --- a/src/ArrayBufferFileReader.ts +++ b/src/ArrayBufferFileReader.ts @@ -41,4 +41,4 @@ class ArrayBufferFileReader extends MediaFileReader { } } -module.exports = ArrayBufferFileReader; +export = ArrayBufferFileReader; diff --git a/src/ArrayFileReader.ts b/src/ArrayFileReader.ts index 762795a..bbb8bd1 100644 --- a/src/ArrayFileReader.ts +++ b/src/ArrayFileReader.ts @@ -11,7 +11,7 @@ import type { LoadCallbackType } from './FlowTypes'; -export = class ArrayFileReader extends MediaFileReader { +class ArrayFileReader extends MediaFileReader { _array: ByteArray; _size: number; @@ -44,3 +44,5 @@ export = class ArrayFileReader extends MediaFileReader { return this._array[offset]; } } + +export = ArrayFileReader; diff --git a/src/BlobFileReader.ts b/src/BlobFileReader.ts index e2af424..5cfcbb7 100644 --- a/src/BlobFileReader.ts +++ b/src/BlobFileReader.ts @@ -10,7 +10,7 @@ import type { LoadCallbackType } from './FlowTypes'; -export = class BlobFileReader extends MediaFileReader { +class BlobFileReader extends MediaFileReader { _blob: Blob; _fileData: ChunkedFileData; @@ -60,3 +60,5 @@ export = class BlobFileReader extends MediaFileReader { return this._fileData.getByteAt(offset); } } + +export = BlobFileReader; diff --git a/src/ChunkedFileData.ts b/src/ChunkedFileData.ts index f4e6f57..8e54e10 100644 --- a/src/ChunkedFileData.ts +++ b/src/ChunkedFileData.ts @@ -18,7 +18,7 @@ import type { DataType } from './FlowTypes'; -export = class ChunkedFileData { +class ChunkedFileData { // $FlowIssue - get/set properties not yet supported static get NOT_FOUND() { return NOT_FOUND; } _fileData: Array; @@ -213,3 +213,5 @@ export = class ChunkedFileData { throw new Error("Offset " + offset + " hasn't been loaded yet."); } } + +export = ChunkedFileData; diff --git a/src/FLACTagContents.ts b/src/FLACTagContents.ts index 9051526..e1add9f 100644 --- a/src/FLACTagContents.ts +++ b/src/FLACTagContents.ts @@ -8,7 +8,7 @@ import type { ByteArray } from './FlowTypes'; -export = class FLACTagContents { +class FLACTagContents { _blocks: Array; constructor(blocks?: Array) { @@ -74,3 +74,5 @@ class MetadataBlock { return [ this._type + (this._final ? 128 : 0) ].concat(this._data); } } + +export = FLACTagContents; diff --git a/src/FLACTagReader.ts b/src/FLACTagReader.ts index 784692d..7dd1938 100644 --- a/src/FLACTagReader.ts +++ b/src/FLACTagReader.ts @@ -60,7 +60,7 @@ import type { /** * Class representing a MediaTagReader that parses FLAC tags. */ -export = class FLACTagReader extends MediaTagReader { +class FLACTagReader extends MediaTagReader { _commentOffset: number; _pictureOffset: number; @@ -338,3 +338,5 @@ export = class FLACTagReader extends MediaTagReader { return tag; } } + +export = FLACTagReader; diff --git a/src/ID3v1TagReader.ts b/src/ID3v1TagReader.ts index 7b9a23d..4adad6a 100644 --- a/src/ID3v1TagReader.ts +++ b/src/ID3v1TagReader.ts @@ -12,7 +12,7 @@ import type { TagType } from './FlowTypes'; -export = class ID3v1TagReader extends MediaTagReader { +class ID3v1TagReader extends MediaTagReader { static getTagIdentifierByteRange(): ByteRange { // The identifier is TAG and is at offset: -128. However, to avoid a // fetch for the tag identifier and another for the data, we load the @@ -105,3 +105,5 @@ var GENRES = [ "Folklore","Ballad","Power Ballad","Rhythmic Soul","Freestyle", "Duet","Punk Rock","Drum Solo","Acapella","Euro-House","Dance Hall" ]; + +export = ID3v1TagReader; diff --git a/src/ID3v2FrameReader.ts b/src/ID3v2FrameReader.ts index 6d086f1..8b311f7 100644 --- a/src/ID3v2FrameReader.ts +++ b/src/ID3v2FrameReader.ts @@ -175,7 +175,7 @@ const FRAME_DESCRIPTIONS = { "WXXX" : "User defined URL link frame" }; -export = class ID3v2FrameReader { +class ID3v2FrameReader { static getFrameReaderFunction(frameId: string): ?FrameReaderSignature { if (frameId in frameReaderFunctions) { return frameReaderFunctions[frameId]; @@ -707,3 +707,5 @@ var PICTURE_TYPE = [ "Band/artist logotype", "Publisher/Studio logotype" ]; + +export = ID3v2FrameReader; diff --git a/src/ID3v2TagContents.ts b/src/ID3v2TagContents.ts index 06a8338..51917c9 100644 --- a/src/ID3v2TagContents.ts +++ b/src/ID3v2TagContents.ts @@ -35,7 +35,7 @@ import type { TagFrameFlags } from './FlowTypes'; -export = class ID3v2TagContents { +class ID3v2TagContents { _size: number; _major: number; _revision: number; @@ -399,3 +399,5 @@ export = class ID3v2TagContents { ].concat(data)); } } + +export = ID3v2TagContents; diff --git a/src/ID3v2TagReader.ts b/src/ID3v2TagReader.ts index eb629c6..3762966 100644 --- a/src/ID3v2TagReader.ts +++ b/src/ID3v2TagReader.ts @@ -21,7 +21,7 @@ import type { const ID3_HEADER_SIZE = 10; -export = class ID3v2TagReader extends MediaTagReader { +class ID3v2TagReader extends MediaTagReader { static getTagIdentifierByteRange(): ByteRange { // ID3 header return { @@ -149,3 +149,5 @@ const SHORTCUTS = { "picture" : ["APIC", "PIC"], "lyrics" : ["USLT", "ULT"] }; + +export = ID3v2TagReader; diff --git a/src/MP4TagContents.ts b/src/MP4TagContents.ts index 97b7342..d4e6f3e 100644 --- a/src/MP4TagContents.ts +++ b/src/MP4TagContents.ts @@ -18,7 +18,7 @@ import type { ByteArray } from './FlowTypes'; -export = class MP4TagContents { +class MP4TagContents { _atoms: Array; constructor(ftyp: string, atoms?: Array) { @@ -85,3 +85,5 @@ class Atom { ); } } + +export = MP4TagContents; diff --git a/src/MP4TagReader.ts b/src/MP4TagReader.ts index c0b9518..362fc30 100644 --- a/src/MP4TagReader.ts +++ b/src/MP4TagReader.ts @@ -20,7 +20,7 @@ import type { TagFrame } from './FlowTypes'; -export = class MP4TagReader extends MediaTagReader { +class MP4TagReader extends MediaTagReader { static getTagIdentifierByteRange(): ByteRange { // The tag identifier is located in [4, 8] but since we'll need to reader // the header of the first block anyway, we load it instead to avoid @@ -351,3 +351,5 @@ const SHORTCUTS = { "picture" : "covr", "lyrics" : "©lyr" }; + +export = MP4TagReader; diff --git a/src/MediaFileReader.ts b/src/MediaFileReader.ts index 9661ff6..da5045c 100644 --- a/src/MediaFileReader.ts +++ b/src/MediaFileReader.ts @@ -14,7 +14,7 @@ import type { CharsetType } from './FlowTypes'; -export = class MediaFileReader { +class MediaFileReader { _isInitialized: boolean; _size: number; @@ -220,3 +220,5 @@ export = class MediaFileReader { return size; } } + +export = MediaFileReader; diff --git a/src/MediaTagReader.ts b/src/MediaTagReader.ts index 9d17e6e..1c3bde8 100644 --- a/src/MediaTagReader.ts +++ b/src/MediaTagReader.ts @@ -12,7 +12,7 @@ import type { TagType } from './FlowTypes'; -export = class MediaTagReader { +class MediaTagReader { _mediaFileReader: MediaFileReader; _tags: ?Array; @@ -108,3 +108,5 @@ export = class MediaTagReader { return tags; } } + +export = MediaTagReader; diff --git a/src/NodeFileReader.ts b/src/NodeFileReader.ts index 8990a15..5b847c7 100644 --- a/src/NodeFileReader.ts +++ b/src/NodeFileReader.ts @@ -13,7 +13,7 @@ import type { } from './FlowTypes'; -export = class NodeFileReader extends MediaFileReader { +class NodeFileReader extends MediaFileReader { _path: string; _fileData: ChunkedFileData; @@ -100,3 +100,5 @@ export = class NodeFileReader extends MediaFileReader { fs.open(this._path, "r", undefined, readData); } } + +export = NodeFileReader; diff --git a/src/ReactNativeFileReader.ts b/src/ReactNativeFileReader.ts index 275efec..e3927c5 100644 --- a/src/ReactNativeFileReader.ts +++ b/src/ReactNativeFileReader.ts @@ -14,7 +14,7 @@ import type { } from './FlowTypes'; -export = class ReactNativeFileReader extends MediaFileReader { +class ReactNativeFileReader extends MediaFileReader { _path: string; _fileData: ChunkedFileData; @@ -69,3 +69,5 @@ export = class ReactNativeFileReader extends MediaFileReader { }); } } + +export = ReactNativeFileReader; diff --git a/src/StringUtils.ts b/src/StringUtils.ts index 3be3017..885b004 100644 --- a/src/StringUtils.ts +++ b/src/StringUtils.ts @@ -21,7 +21,7 @@ class InternalDecodedString { } } -export var StringUtils = { +var StringUtils = { readUTF16String: function( bytes: Array, bigEndian: boolean, @@ -120,3 +120,5 @@ export var StringUtils = { return new InternalDecodedString(arr.join(""), i); } }; + +export { StringUtils }; diff --git a/src/XhrFileReader.ts b/src/XhrFileReader.ts index 873a306..510fe9b 100644 --- a/src/XhrFileReader.ts +++ b/src/XhrFileReader.ts @@ -19,8 +19,6 @@ type ContentRangeType = { instanceLength: ?number, }; -export = XhrFileReader; - class XhrFileReader extends MediaFileReader { static _config: { avoidHeadRequests: boolean, @@ -318,3 +316,5 @@ XhrFileReader._config = { disallowedXhrHeaders: [], timeoutInSec: 30 }; + +export = XhrFileReader;