Skip to content

refactor(images): extract client-safe variant tier constants#479

Merged
Zheaoli merged 1 commit into
mainfrom
refactor/client-safe-variant-tiers
May 30, 2026
Merged

refactor(images): extract client-safe variant tier constants#479
Zheaoli merged 1 commit into
mainfrom
refactor/client-safe-variant-tiers

Conversation

@Zheaoli

@Zheaoli Zheaoli commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Extract client-safe variant tier constants

Follow-up to the variant work (parent task #1), coordinated with @Picimpact-Design.

FE-3's gallery loader (lib/image/loader.ts) currently mirrors the variant tier ladder and buildVariantKey by hand, because they lived in server/lib/image-variants.ts which is server-only and can't be imported client-side. That's two sources of truth that can drift.

Change

  • New lib/image/variant-tiers.ts (client-safe, no server-only/sharp/AWS deps): VARIANT_TIER_WIDTHS, VARIANT_FORMATS, VariantFormat, variantContentType, buildVariantKey, tierWidthsForSource.
  • server/lib/image-variants.ts imports + re-exports them (behavior-preserving — its public import surface is unchanged, so the pipeline keeps working).

Follow-up

@Picimpact-Design will then update lib/image/loader.ts to import from this shared module and delete its mirrored constants, removing the drift caveat noted in FE-3 review.

Verification

  • tsc --noEmit: no errors. eslint --fix: clean. Pure move + re-export, no logic change.

🤖 Generated with Claude Code

Move the variant tier ladder (VARIANT_TIER_WIDTHS), format helpers
(VARIANT_FORMATS, variantContentType), key builder (buildVariantKey) and
tierWidthsForSource into a new client-safe module ~/lib/image/variant-tiers
with no server-only dependencies.

server/lib/image-variants.ts re-exports them (behavior-preserving), so the
preprocessing pipeline keeps its existing import surface. The client-side
gallery loader (lib/image/loader.ts) can now import the same module instead
of mirroring the constants, eliminating the duplicated source of truth that
FE-3 had to maintain by hand.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented May 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
picimpact Ready Ready Preview, Comment May 30, 2026 11:46am

@Zheaoli Zheaoli merged commit 8dd2b58 into main May 30, 2026
6 checks passed
pull Bot pushed a commit to xqd922/PicImpact that referenced this pull request May 30, 2026
besscroft#479 extracted the client-safe variant tier ladder and key helpers into
lib/image/variant-tiers.ts (the single source of truth, re-exported by the
server-only image-variants.ts). Switch the client loader to import
VARIANT_TIER_WIDTHS / buildVariantKey / VariantFormat from it instead of the
previously mirrored local copies, eliminating the dual source of truth flagged
in the FE-3 review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant