Skip to content

Move bulk of title formatting logic to separate library#242

Open
netux wants to merge 6 commits into
ajayyy:masterfrom
netux:feature/title-formatting-in-maze-utils
Open

Move bulk of title formatting logic to separate library#242
netux wants to merge 6 commits into
ajayyy:masterfrom
netux:feature/title-formatting-in-maze-utils

Conversation

@netux

@netux netux commented Apr 10, 2024

Copy link
Copy Markdown
  • Bump maze-utils to commit 02978e01, which contains the moved title formatter logic

  • Uninstall cld3-asm, as all code using it is now in maze-utils

  • Change imports throughout to use types and methods from maze-utils

  • Delete title formatter tests. These now live in maze-utils

  • I agree to license my contribution under GPL-3.0 and agree to allow distribution on app stores as outlined in LICENSE-APPSTORE

To test this pull request, follow the instructions in the wiki.


Second half of #241.

Footnotes

  1. I'm not 100% sure how cross-gitmodule changes should work. In theory, if the maze-utils submodule is pinned to a specific commit then this should be fine, right?

- Bump maze-utils to commit 02978e0, which contains the moved title formatter logic
- Uninstall cld3-asm, as all code using it is now in maze-utils
- Change imports throughout
- Delete title formatter tests. These now live in maze-utils
@ajayyy

ajayyy commented Apr 10, 2024

Copy link
Copy Markdown
Owner

At the moment maze utils is not imported as a module, but a folder, so I'm not sure it would work to delete the cld-3 dependency. I think it won't compile

@ajayyy

ajayyy commented Apr 10, 2024

Copy link
Copy Markdown
Owner

Your understanding of submodules is correct

@netux

netux commented Apr 10, 2024

Copy link
Copy Markdown
Author

At the moment maze utils is not imported as a module, but a folder, so I'm not sure it would work to delete the cld-3 dependency. I think it won't compile

Hmm, it was working on my machine. I guess I'll add that dependency back then.

@netux

netux commented Apr 11, 2024

Copy link
Copy Markdown
Author

Hmm, it was working on my machine. I guess I'll add that dependency back then.

I'm now looking for a way to make the dependency optional. I was thinking putting it in peer dependencies of maze-utils and wrapping the import in a try...catch so SponsorBlock could compile without it, but...

  1. Webpack complains about the import when cld3-asm is not installed, even when LOAD_CLD = false
  2. Even if that's somehow solved, there is yet another import of cld3-asm, but only for one of its types. I doubt there is any way to conditionally exclude type imports in Webpack

So I'll now look into moving all of the title formatting stuff into its own library.
@ajayyy could you create a repo for this? It makes more sense if its under your name and control.

@ajayyy

ajayyy commented Apr 11, 2024

Copy link
Copy Markdown
Owner

Created a repo: https://github.com/ajayyy/DeArrowFormatting

@netux netux changed the title Move bulk of title formatting logic to maze-utils Move bulk of title formatting logic to separate library Apr 12, 2024
@netux

netux commented May 8, 2024

Copy link
Copy Markdown
Author

Hello. Any hopes of this getting looked at anytime soon? 😄

const text = "text" in props ? props.text : chrome.i18n.getMessage(props.langKey);

setLabel(await formatTitleInternal(text, false, props.titleFormatting!, false));
setLabel(await formatTitle(text, false, props.titleFormatting!, false, Config.config!.onlyTitleCaseInEnglish));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What's the reason for this change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

There are two changes here:

  1. Replace formatTitleInternalformatTitle: note that formatTitle comes from DeArrowFormatting, not from titles/titleFormatter.ts. I just moved formatTitleInternal in DeArrowFormatting, and renamed it to formatTitle.
    • As to why I changed the name: I thought it didn't make sense to label the function "internal" when, from the PoV of DeArrowFormatting, it was the function being exposed to the outside.
      From the PoV of DeArrow, the function is used internally (which is part of the reason why I aliased it to formatTitleInternal in src/titles/titleFormatter.ts)
  2. Added Config.config!.onlyTitleCaseInEnglish parameter: DeArrowFormatting doesn't know about DeArrow's Config object anymore, so we have to pass it manually.

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