Skip to content

feat: batch decompress and URL input for WOFF/WOFF2#691

Merged
jimmyandrade merged 1 commit into
masterfrom
feat/batch-decompress-url-input
Jul 2, 2026
Merged

feat: batch decompress and URL input for WOFF/WOFF2#691
jimmyandrade merged 1 commit into
masterfrom
feat/batch-decompress-url-input

Conversation

@jimmyandrade

@jimmyandrade jimmyandrade commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Proposed changes

This PR brings the following changes:

  • Allow multiple .woff / .woff2 inputs in one webfont decompress run (paths, globs, and/or http(s) URLs).
  • Expose per-input results on result.decompressedFonts ({ source, ttf?, otf? }[]); a single input still sets result.ttf / result.otf at the top level for backward compatibility.
  • Add fetchWebfontFromUrl with WOFF/WOFF2 validation for remote sources (query strings in URLs supported).
  • CLI writes {basename}.ttf / .otf per input; colliding basenames get -woff / -woff2 suffixes. Single-input runs still honor -u / fontName.
  • Update FEATURES.md, README.md, NOTICE.md, and CLI help for batch + URL behavior.

Related issue

N/A

Dependencies added/removed (if applicable)

N/A


Testing

  • I have added or updated tests that prove my fix is effective or that my feature works (if applicable)
    • Unit test
    • Manual test

How to test

  1. Run npm test — 271 tests pass.
  2. Batch: node dist/cli.mjs "src/fixtures/fonts/*.woff2" -f ttf — one .ttf per matched file.
  3. URL (with mock or real CDN): webfont({ files: "https://…/font.woff2", formats: ["ttf"] }).

Test configuration

N/A


Checklist

  • I have added corresponding labels to this PR (like bug, enhancement...);
  • My commits follow the Conventional Commits 1.0 Guidelines;
  • My code follows the style guidelines of this project;
  • I have performed a self-review of my own code;
  • I have mapped technical debts found on my changes;
  • I have made changes to the documentation (if applicable);
  • My changes generate no new warnings or errors;

Made with Cursor

Allow multiple local paths, globs, or http(s) URLs in one webfont
decompress run with per-input TTF/OTF output on result.decompressedFonts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jimmyandrade jimmyandrade self-assigned this Jul 2, 2026
@jimmyandrade jimmyandrade requested a review from Copilot July 2, 2026 17:43
@jimmyandrade jimmyandrade added this to the 12.0 milestone Jul 2, 2026
@jimmyandrade jimmyandrade merged commit 4bd4400 into master Jul 2, 2026
3 checks passed
@jimmyandrade jimmyandrade deleted the feat/batch-decompress-url-input branch July 2, 2026 17:47

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 expands the “webfont decompress” pipeline to support batch .woff/.woff2 inputs (including http(s) URLs), returning per-input outputs via result.decompressedFonts while preserving backward compatibility for single-input runs (result.ttf / result.otf). It also updates the CLI to write one decompressed output per input and refreshes user-facing documentation and tests accordingly.

Changes:

  • Add batch + URL input resolution for WOFF/WOFF2 decompression, including new URL fetch helper with container validation.
  • Introduce DecompressedFont and surface batch results via result.decompressedFonts, keeping single-input root outputs for compatibility.
  • Update CLI output naming/writing for batch runs and update docs/tests to cover the new behavior.

Reviewed changes

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

Show a summary per file
File Description
types/is-woff.d.ts Adds TS module declarations for is-woff / is-woff2.
src/types/Result.ts Extends Result with optional decompressedFonts and re-exports DecompressedFont.
src/types/DecompressedFont.ts Introduces DecompressedFont shape for per-input decompression results.
src/standalone/webfontConversion.integration.test.ts Updates integration coverage for multi-input decompression and HTTPS URL input.
src/standalone/inputMode.ts Uses URL-aware extension parsing for input classification/filtering.
src/standalone/index.ts Switches from raw globby to resolveInputSources to support URLs.
src/standalone/fetchWebfontUrl.ts Adds fetchWebfontFromUrl for downloading and validating remote WOFF/WOFF2.
src/standalone/fetchWebfontUrl.test.ts Adds unit tests for fetchWebfontFromUrl.
src/standalone/convertWebfontInput.ts Implements multi-source decompression and populates decompressedFonts (+ single-input compatibility).
src/standalone/convertWebfontInput.test.ts Updates unit tests for batch decompression and backward compatibility behavior.
src/lib/inputSource.ts Adds URL detection, URL-safe extension parsing, and basename disambiguation helpers for batch outputs.
src/lib/inputSource.test.ts Adds unit tests for URL/extension parsing and basename collision handling.
src/cli/program.ts Writes per-input decompressed outputs for batch runs and adds basename resolution helper(s).
src/cli/program.test.ts Adds tests for basename resolution and batch decompressed output writing.
src/cli/meow/cliOptions.ts Updates CLI help text to describe batch + URL decompression inputs.
src/cli/index.test.ts Adds CLI integration test for batch decompression output files.
README.md Updates docs/examples to describe batch + URL decompression behavior and outputs.
NOTICE.md Updates legal notice text to cover batch + URL decompression implications.
FEATURES.md Updates feature spec + test criteria for batch + URL decompression support.

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

Comment on lines +5 to +19
const assertWebfontContainer = (buffer: Buffer, source: string): void => {
const extension = getInputExtension(source);

if (extension === ".woff2" && !isWoff2(buffer)) {
throw new Error(`URL did not return a valid WOFF2 font: ${source}`);
}

if (extension === ".woff" && !isWoff(buffer)) {
throw new Error(`URL did not return a valid WOFF font: ${source}`);
}

if (buffer.length === 0) {
throw new Error(`URL returned an empty response: ${source}`);
}
};
Comment thread src/lib/inputSource.ts
Comment on lines +37 to +39
if (isHttpUrl(source)) {
pathname = new URL(source).pathname;
}
Comment on lines 91 to +94
const formats = resolveWebfontConversionFormats(options.formats);
const decompressedFonts = await Promise.all(
fontFiles.map((source) => decompressWebfontSource(source, formats, options.verbose)),
);
Comment thread src/cli/program.ts
Comment on lines +273 to +294
export const writeDecompressedFontFiles = async (
fonts: readonly DecompressedFont[],
config: ResultConfig,
dest: string,
): Promise<void> => {
await Promise.all(
fonts.flatMap((font) => {
const basename = getDecompressedFontOutputBasename(fonts, font, config);
const writes: Promise<void>[] = [];

if (font.ttf) {
writes.push(fs.promises.writeFile(path.resolve(path.join(dest, `${basename}.ttf`)), font.ttf));
}

if (font.otf) {
writes.push(fs.promises.writeFile(path.resolve(path.join(dest, `${basename}.otf`)), font.otf));
}

return writes;
}),
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants