Skip to content

ID3v2 | Remove FrameClassType#141

Merged
benrr101 merged 9 commits into
developfrom
feat/id3v2/drop-classtype
Jul 2, 2026
Merged

ID3v2 | Remove FrameClassType#141
benrr101 merged 9 commits into
developfrom
feat/id3v2/drop-classtype

Conversation

@benrr101

@benrr101 benrr101 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Description

The ID3v2 frame classes used to implement a FrameClassType enum that enabled checking frames all over the ID3v2 classes. However, it really isn't necessary, not is it all that strong. This PR removed FrameClassType and replaces checks for frame type with instanceof checks. Additionally, the Find methods in each frame class has been replaced with FilterFrames methods. These are not 1:1 replacements, but help to easily filter a Frame[] into a XyzFrame[].

Testing

New tests are added where necessary, old tests are removed where necessary, broken tests have been fixed.

@benrr101 benrr101 added this to the v7.0.0 milestone Jul 1, 2026
@benrr101 benrr101 requested a review from Copilot July 1, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the FrameClassType enum and the abstract frameClassType getter from the ID3v2 frame hierarchy, replacing runtime frame-type checks with instanceof-based filtering. A new ArrayUtils.ofType(array, Constructor) helper (backed by a TypeReference<T> type) centralizes the pattern, and each concrete frame class now exposes a static filterFrames(frames: Frame[]) method in place of the old bespoke find*/findPreferred methods. Frame is converted from a named to a default export, and the preferred-frame selection logic for comments and unsynchronized lyrics is moved directly into Id3v2Tag. UrlLinkFrame.fromIdentity is also renamed to fromIdentifier.

Changes:

  • Remove FrameClassType/frameClassType and the Id3v2FrameClassType public export; make Frame a default export.
  • Add ArrayUtils.ofType + TypeReference<T> and replace per-class find* methods with filterFrames; move comment/lyrics preferred-frame selection into Id3v2Tag.
  • Update the test suite to use instanceof/filterFrames and rename fromIdentityfromIdentifier.

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/utils.ts Adds TypeReference<T> and ArrayUtils.ofType filtering helper.
src/index.ts Exports Frame as default (Id3v2Frame); drops Id3v2FrameClassType.
src/id3v2/frames/frame.ts Removes FrameClassType enum and frameClassType getter; Frame becomes default export.
src/id3v2/id3v2Tag.ts Removes getFramesByClassType/getFramesByIdentifier; inlines comment/lyrics preferred logic; uses filterFrames. Has the two behavior regressions noted below and minor style nits.
src/id3v2/frames/urlLinkFrame.ts Renames fromIdentityfromIdentifier; adds filterFrames with optional identifier.
src/id3v2/frames/userUrlLinkFrame.ts Adds filterFrames; new Frame default import is misordered.
src/id3v2/frames/textInformationFrame.ts Adds filterFrames with optional identifier filtering.
src/id3v2/frames/*.ts (attachment, comments, eventTimeCode, genre, musicCdIdentifier, playCount, popularimeter, private, relativeVolume, synchronizedLyrics, termsOfUse, uniqueFileIdentifier, unknown, unsynchronizedLyrics, userTextInformation) Remove frameClassType getter and find* methods; add filterFrames via ArrayUtils.ofType.
test-unit/id3v2/genreFrameTests.ts Switches to instanceof/filterFrames; clone test asserts on the wrong object.
test-unit/id3v2/userUrlLinkFrameTests.ts, userTextInformationFrameTests.ts Add shared assertFrame helpers and filterFrames_* tests; use default Frame import.
test-unit/id3v2/{privateFrameTests, unsynchronizedLyricsFrameTests, uniqueFileIdentifierFrameTests, unknownFrameTests}.ts Add filterFrames_* tests; contain CI-breaking trailing whitespace.
test-unit/id3v2/id3v2TagTests.ts, frameFactoryTests.ts, other frame tests Replace FrameClassType assertions with assert.instanceOf; add multi-frame lyrics test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/id3v2/id3v2Tag.ts
Comment thread src/id3v2/id3v2Tag.ts Outdated
Comment thread test-unit/id3v2/genreFrameTests.ts Outdated
Comment thread test-unit/id3v2/privateFrameTests.ts Outdated
Comment thread test-unit/id3v2/unsynchronizedLyricsFrameTests.ts Outdated
Comment thread test-unit/id3v2/uniqueFileIdentifierFrameTests.ts Outdated
Comment thread test-unit/id3v2/unknownFrameTests.ts Outdated
Comment thread src/id3v2/id3v2Tag.ts Outdated
Comment thread src/id3v2/frames/userUrlLinkFrame.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 45 out of 45 changed files in this pull request and generated 3 comments.

Comment thread test-unit/id3v2/unknownFrameTests.ts Outdated
Comment thread src/id3v2/id3v2Tag.ts
Comment thread src/id3v2/id3v2Tag.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 45 out of 45 changed files in this pull request and generated 4 comments.

Comment thread src/id3v2/frames/userTextInformationFrame.ts Outdated
Comment thread test-unit/id3v2/id3v2TagTests.ts Outdated
Comment thread test-unit/id3v2/urlLinkFrameTests.ts Outdated
Comment thread test-unit/id3v2/urlLinkFrameTests.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.

Comment thread src/id3v2/frames/urlLinkFrame.ts
@benrr101 benrr101 merged commit c040a8c into develop Jul 2, 2026
5 checks passed
@benrr101 benrr101 deleted the feat/id3v2/drop-classtype branch July 2, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants