Add Pretext-powered R3F typography lab and million-row Pretext/TanStack demo#173
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7a79297dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const prepared = preparedSummaryCache.get(cacheKey) ?? prepare(candidate, SUMMARY_FONT) | ||
| if (!preparedSummaryCache.has(cacheKey)) { | ||
| preparedSummaryCache.set(cacheKey, prepared) | ||
| } |
There was a problem hiding this comment.
Bound utility text cache growth
preparedSummaryCache is a module-level Map with no eviction, and this block adds new prepared entries for each candidate string generated in fitUtilityText. Because the million-row demo includes per-user fields like name and lastActive in those candidates, scrolling deeply can accumulate a very large number of cached prepare(...) results and steadily grow memory usage until the page becomes sluggish. Please cap this cache (for example with LRU eviction) or scope it to currently visible rows.
Useful? React with 👍 / 👎.
Motivation
@chenglou/pretextcan drive precise line layout for 3D article typography and for fit-aware utility boxes inside a large virtualized dataset.Description
pages/pretext-lab.tsxthat dynamically loads a lab component withssr: falseso Pretext can use the browser canvas context.components/labs/PretextLab.tsxwhich contains two demos:ArticlePlane(scanline image analysis →prepareWithSegments+layoutNextLine→ canvas → R3F plane texture) andMillionUserUtilityTable(1,000,000 synthetic records virtualized with@tanstack/react-virtual+@tanstack/react-table, and afitUtilityTextroutine that usesprepare+layoutwith a small cache to select readable summary text for visible rows).@chenglou/pretext,@tanstack/react-table, and@tanstack/react-virtualand update the lockfile accordingly.analyzeImageForScanlineshelper that produces horizontal spans per scanline (y-band) to feed variable-width line layout, and a seeded user generator for the million-row simulation.Testing
pnpm add(succeeded) and verified@chenglou/pretextexports vianode -e 'require(...)'(succeeded).prepare()in a Node-only environment and observed the expected failure due to missing OffscreenCanvas / DOM canvas context (this confirms Pretext must be used in a browser or with OffscreenCanvas).pnpm type-checkwhich failed due to pre-existing test typing issues (missing Jest globals) in unrelated test files; this is not caused by the new demo.tscagainst the new demo files which surfaced a TypeScript/JSX styling typing complaint (style jsxprop) and an import resolution error for the dynamic client import in this environment; these are environment/type-config issues and do not affect the demo running in a browser.pnpm installandpnpm devand will work in a browser where canvas measurement is available.Codex Task