Skip to content

feat(wasm): options(), the keys of optimize and encode with their defaults and help - #60

Merged
vlad-salone merged 1 commit into
mainfrom
feat/wasm-options-listing
Oct 13, 2026
Merged

vlad-salone merged 1 commit into
mainfrom
feat/wasm-options-listing

Conversation

@vlad-salone

Copy link
Copy Markdown
Collaborator

Closes #57. One entry per key of Options, in the shape of CodecOption, from a new options() export.

options();
// [{ key: "format", default: "auto", help: "output format: jpeg, png, webp, avif or jxl. ..." },
//  { key: "target", default: "70", help: "SSIMULACRA2 score to reach by searching encoder quality, up to 100. ..." },
//  { key: "effort", default: "6", help: "0 to 10. Higher is slower and smaller" },
//  { key: "width", help: "target width in pixels. ..." },   // no default: left out, nothing is resized
//  ...]

The defaults are not written down a second time. The listing reads them from the builder an encode without options starts from, params() and resize_bounds() of the package's Sqzer, and spells them the way the options take them, so effort says 6 because EncodeParams::default does. Where the default depends on the image or the format, format and background, the entry says auto, as avif:alpha_quality does. Where leaving the key out means not doing the thing, width, scale, preset, quality, codecOpts, onTrial, the entry has no default rather than an invented one, and sqzer.d.ts has it as optional.

The key list that options() walks is the same one a misspelt key is refused against, so the two cannot drift; the test checks that the refusal for an unknown key names every listed key, that the listed defaults are the ones above, and that an encode with no options lands on them.

Not done here: sqzer-dev/sqzer.dev#19 drops the page's defaults.ts once this is released.

Checked locally: cargo clippy --workspace --all-targets --all-features, cargo doc with warnings denied, and wasm-pack test --node, 17 tests. pack.sh and the tarball run are left to the wasm job of CI.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Adds options() with the accepted encode keys, their help, and their defaults.

  • JavaScript callers can list encode options with help and defaults.

vlad-salone explicitly chose auto to describe defaults that depend on the image or format. These values are display metadata, not a ready-to-send options object. vlad-salone also explicitly deferred removing the page’s defaults.ts to sqzer-dev/sqzer.dev#19.

Reviews (1) · Last reviewed commit: "feat(wasm): options(), the keys of optim..." · Reviewed by Greptile

…aults and help

The page at sqzer.dev shows each control at the package's default and
read the defaults from the README by hand. `codecs()` already reports
every backend option with its default and help; `options()` does the
same for the keys of `optimize` and `encode`, in the shape of
`CodecOption`. The defaults are read from the builder an encode without
options uses, so they cannot drift; a key whose default depends on the
image or the format says `auto`, and one that does nothing when left out
has none. The key table that feeds the listing is the one a misspelt key
is checked against.

Closes #57

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@vlad-salone
vlad-salone force-pushed the feat/wasm-options-listing branch 2 times, most recently from fabc59f to a1bf71a Compare October 13, 2026 13:06
@vlad-salone
vlad-salone merged commit 7769f48 into main Oct 13, 2026
29 of 44 checks passed
@vlad-salone
vlad-salone deleted the feat/wasm-options-listing branch October 13, 2026 13:14
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.

A call that reports the defaults of every option, as codecs() reports the backend options

1 participant