Skip to content

build: use an npm font package instead of bundling#238

Open
SlayerOrnstein wants to merge 8 commits intoWFCD:mainfrom
SlayerOrnstein:unbundle-font
Open

build: use an npm font package instead of bundling#238
SlayerOrnstein wants to merge 8 commits intoWFCD:mainfrom
SlayerOrnstein:unbundle-font

Conversation

@SlayerOrnstein
Copy link
Member

@SlayerOrnstein SlayerOrnstein commented Feb 26, 2026

What did you fix?

Pretty much the title, import fonts from a package and move warframe-items to the @wfcd namespace


Reproduction steps


Evidence/screenshot/link to line

Considerations

  • Does this contain a new dependency? Yes
  • Does this introduce opinionated data formatting or manual data entry? No
  • Does this pr include updated data files in a separate commit that can be reverted for a clean code-only pr? Yes
  • Have I run the linter? Yes
  • Is is a bug fix, feature request, or enhancement? Enhancement

Summary by CodeRabbit

  • New Features

    • Integrated variable Roboto font support for improved typography.
  • Dependencies

    • Replaced legacy items package with a newer items package.
    • Added the Roboto variable font package and removed an outdated linting config.
  • Testing

    • Added Mocha configuration and simplified test scripts for TypeScript tests.
  • Chores

    • Removed pretest hook, enabled publish provenance, streamlined config formatting, adjusted lint-staged tooling, and updated asset copy settings.

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaced warframe-items imports with @wfcd/items, added @fontsource-variable/roboto, switched font registration to dynamic resolution via createRequire, removed the pretest script, added a Mocha config, adjusted tooling configs (biome, lint-staged, tsdown), and updated tests to new import paths.

Changes

Cohort / File(s) Summary
Manifest / Dependencies
package.json
Added @fontsource-variable/roboto; replaced warframe-items with @wfcd/items; removed warframe-items from peerDependencies; removed pretest script; added publishConfig.provenance; compacted some config blocks.
Source — imports & fonts
src/utils.ts, src/drawers.ts, src/generator.ts
Switched type/utility imports from warframe-items@wfcd/items. src/utils.ts now uses createRequire and dynamically requires/registers Roboto from @fontsource-variable/roboto instead of registering local font assets.
Tests
tests/generator.spec.ts
Updated imports to use @wfcd/items and @wfcd/items/utilities instead of warframe-items paths.
Test runtime config
.mocharc.yml
Added Mocha config: exit: true, extension: ['ts'], spec: 'tests/**/*.spec.ts', timeout: 20000, node-option: ['import=tsx/esm'].
Tooling / Lint & Format
biome.json, lint-staged.config.js
Added package*.json to biome.json includes; changed lint-staged pipeline for package*.json to run biome format --write (replacing prettier).
Docs/Build assets
tsdown.config.ts
Removed fonts directory from the copy list so assets/fonts are no longer copied.
New configs
.babelrc.json, .c8rc.json
Added Babel config enabling env preset and class/private transforms; added c8 config with reporters and skip-full.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • TobiTenno

Poem

"I hopped through code with careful paws,
swapped item paths and fixed the fonts' laws.
Roboto snug where assets once lay,
tests updated, linted away.
A carrot hop — commit hooray! 🥕"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'build: use an npm font package instead of bundling' accurately describes the primary change: replacing bundled font files with an npm package dependency.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/generator.ts (1)

1-234: ⚠️ Potential issue | 🟡 Minor

Formatter mismatch is currently CI-blocking.

The pipeline reports formatting drift. Please run the formatter and commit the result before merge.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/generator.ts` around lines 1 - 234, The CI failure is due to formatting
drift in src/generator.ts (affecting functions generateCollapsed and generate);
run the project's formatter (e.g., the repo's configured prettier/format script
such as npm run format or yarn format), apply the formatted changes to this file
and any others the formatter updates, then commit those changes so the file
(including generateCollapsed and generate) matches the repository formatting
rules and clears the CI check.
src/utils.ts (1)

123-136: ⚠️ Potential issue | 🟡 Minor

wrapText can emit empty first lines and mis-measure the first token.

The current concatenation always prefixes a space, and when the first word exceeds maxWidth, it pushes an empty line.

💡 Proposed fix
-  words.forEach((word) => {
-    const line = `${currentLine} ${word}`;
+  words.forEach((word) => {
+    const line = currentLine ? `${currentLine} ${word}` : word;
     const lineWidth = context.measureText(line).width;

-    if (lineWidth > maxWidth) {
+    if (lineWidth > maxWidth && currentLine) {
       lines.push(currentLine);
       currentLine = word;
     } else {
       currentLine = line;
     }
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils.ts` around lines 123 - 136, In wrapText, avoid always prefixing a
space and handle the case where the first token itself exceeds maxWidth: build
the candidate string as (currentLine ? `${currentLine} ${word}` : word) before
measuring, and when lineWidth > maxWidth push currentLine only if it is
non-empty; if currentLine is empty push the word (or start a new line with the
word) and reset currentLine appropriately; reference variables/functions:
wrapText, words, currentLine, line, lineWidth, maxWidth, context.measureText.
🧹 Nitpick comments (1)
src/utils.ts (1)

143-148: Clean up dead commented code in registerFonts.

Leaving the old implementation commented out makes font-loading behavior unclear. Prefer a concise no-op with an explicit comment (or a real implementation).

♻️ Suggested cleanup
 export const registerFonts = () => {
-  // const fontPath = join('.', 'assets', 'fonts');
-  // GlobalFonts.registerFromPath(join(fontPath, 'Roboto-Light.ttf'), 'Roboto');
-  // GlobalFonts.registerFromPath(join(fontPath, 'Roboto-Regular.ttf'), 'Roboto');
-  // GlobalFonts.registerFromPath(join(fontPath, 'Roboto-Bold.ttf'), 'Roboto');
+  // Intentionally blank: font setup handled by runtime/package integration.
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils.ts` around lines 143 - 148, Remove the dead commented-out
font-loading code inside the registerFonts function and replace it with a clear
no-op comment or a real implementation; locate the registerFonts function and
either (a) leave it as an explicit no-op with a short comment like "no fonts to
register in this environment" or (b) implement actual font registration using
GlobalFonts.registerFromPath and join if you intend to enable fonts, making sure
to reference GlobalFonts and join where appropriate so the function's behavior
is unambiguous.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/generator.ts`:
- Line 4: The bare import of "@fontsource-variable/roboto" should be removed and
real canvas font registration must be implemented in registerFonts(): obtain the
actual font file(s) (.ttf/.woff2/.otf), call GlobalFonts.registerFromPath(path,
"Roboto") or GlobalFonts.register(buffer, "Roboto") from `@napi-rs/canvas` before
any canvas creation (reference the registerFonts() function), and make sure the
family name "Roboto" matches the family used in ctx.font where text is drawn;
alternatively remove the registerFonts() call entirely if you choose to rely on
system fonts.

---

Outside diff comments:
In `@src/generator.ts`:
- Around line 1-234: The CI failure is due to formatting drift in
src/generator.ts (affecting functions generateCollapsed and generate); run the
project's formatter (e.g., the repo's configured prettier/format script such as
npm run format or yarn format), apply the formatted changes to this file and any
others the formatter updates, then commit those changes so the file (including
generateCollapsed and generate) matches the repository formatting rules and
clears the CI check.

In `@src/utils.ts`:
- Around line 123-136: In wrapText, avoid always prefixing a space and handle
the case where the first token itself exceeds maxWidth: build the candidate
string as (currentLine ? `${currentLine} ${word}` : word) before measuring, and
when lineWidth > maxWidth push currentLine only if it is non-empty; if
currentLine is empty push the word (or start a new line with the word) and reset
currentLine appropriately; reference variables/functions: wrapText, words,
currentLine, line, lineWidth, maxWidth, context.measureText.

---

Nitpick comments:
In `@src/utils.ts`:
- Around line 143-148: Remove the dead commented-out font-loading code inside
the registerFonts function and replace it with a clear no-op comment or a real
implementation; locate the registerFonts function and either (a) leave it as an
explicit no-op with a short comment like "no fonts to register in this
environment" or (b) implement actual font registration using
GlobalFonts.registerFromPath and join if you intend to enable fonts, making sure
to reference GlobalFonts and join where appropriate so the function's behavior
is unambiguous.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6dfb556 and 696cd5b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • package.json
  • src/drawers.ts
  • src/generator.ts
  • src/utils.ts
  • tests/generator.spec.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
package.json (1)

19-19: Minor: Spec pattern inconsistency with Mocha config.

The test command uses tests/*.spec.ts (non-recursive), while .mocharc.yml specifies tests/**/*.spec.ts (recursive). If Mocha reads from .mocharc.yml, the command-line pattern may be overridden, but it's cleaner to keep them consistent.

Suggested fix
-    "test": "c8 mocha tests/*.spec.ts",
+    "test": "c8 mocha",

Since .mocharc.yml already defines the spec pattern, the command-line argument can be omitted to avoid duplication.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 19, The package.json "test" script currently specifies
a non-recursive pattern ("tests/*.spec.ts") that conflicts with the recursive
pattern in .mocharc.yml; remove the explicit pattern from the "test" script so
it simply runs the test runner (e.g., change the value of the "test" script to
"c8 mocha" or equivalent) and rely on .mocharc.yml's tests/**/*.spec.ts pattern
to keep patterns consistent and avoid duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@package.json`:
- Line 19: The package.json "test" script currently specifies a non-recursive
pattern ("tests/*.spec.ts") that conflicts with the recursive pattern in
.mocharc.yml; remove the explicit pattern from the "test" script so it simply
runs the test runner (e.g., change the value of the "test" script to "c8 mocha"
or equivalent) and rely on .mocharc.yml's tests/**/*.spec.ts pattern to keep
patterns consistent and avoid duplication.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e2e714 and 947c1ab.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .mocharc.yml
  • biome.json
  • lint-staged.config.js
  • package.json
  • src/generator.ts
  • src/utils.ts
  • tsdown.config.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/generator.ts
  • src/utils.ts

@SlayerOrnstein SlayerOrnstein enabled auto-merge (squash) February 26, 2026 16:57
SlayerOrnstein and others added 2 commits February 26, 2026 12:38
Co-authored-by: Matt <7128721+TobiTenno@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.babelrc.json:
- Around line 3-7: The .babelrc.json references three Babel packages that are
not declared in package.json; add `@babel/preset-env`,
`@babel/plugin-transform-class-properties`, and
`@babel/plugin-transform-private-methods` to package.json's devDependencies so
installs/CI succeed; update the devDependencies section to include those exact
package names (with appropriate versions or use a caret range) and run npm/yarn
install to verify resolution.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1957e36 and 7076216.

📒 Files selected for processing (3)
  • .babelrc.json
  • .c8rc.json
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • .c8rc.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

Don't think its being used transitive and I'm pretty sure tsdown already does some of this
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