Repository navigation
Closed
Description
Part of #769. Small; ship with other hyperlink work. Touches the same file as #774 site 3.
Summary
The special-URL catalog (extensions/extension-hyperlink/src/utils/specialUrls.ts:66-170) is seven Record objects joined by a spread. Typed rows carry the same data in fewer bytes. Every user of the extension pays the catalog. Behaviour and the public SpecialUrlType union stay the same.
Review numbers (2026-11-12, prototype; this issue takes its own before and after)
| Row | Today | Typed rows |
|---|---|---|
| A StarterKit app pays (min / gzip) | 70,854 / 25,213 B | −1,303 / −97 B |
| The webapp-like app pays | 54,947 / 19,144 B | −1,303 / −111 B |
Fix
- Replace the seven objects and the spread with
toEntries([...] as const satisfies readonly Row[]), wheretype Row = readonly [string, SpecialUrlType, string, SpecialUrlInfo['category']]. - Iterate the entry arrays, not
Object.entries, and keep today's lookup order. - Keep the
SpecialUrlTypeunion (lines 7-51) and theSpecialUrlInfotext byte-identical. Both are public:src/utils/index.ts:11anddocs/api.md:233; the webapp'sspecialUrlIcon.ts:11usesRecord<SpecialUrlType, ...>. - Use
satisfies, not a cast. In the review, a typo (emial) failedtscwith TS2820 in thesatisfiesform. In the cast form it passedtsc, and only 2 of 71 tests caught it.
Benchmark
| Field | Value |
|---|---|
| Metric | Package bench byte rows. |
| Before | 70,854 / 25,213 B (StarterKit app, main, 2026-11-12). |
| After | not measured yet |
| Confounds | #774 (site 3 lives here). |
| Condition | esbuild minify, ESM, browser, Bun zlib level 9, exact. |
| How to run | NODE_ENV=production bun scripts/bench/run.ts --ref <commit before this issue> |
| Pass rule | At least −1,000 B min for a StarterKit app; behaviour unchanged; speed inside the control band. |
| Guard | The UX contract below. |
| Owner | Agent in the repo. |
| Claim | None for users (too small to promote). Note it as Internal. |
UX contract
- An equivalence check over every catalog key and at least 161 inputs: the same icon, label, category and order as today, 0 differences. When two rows match one URL, the same row wins.
-
dist/index.d.tsbyte-identical, so the union is unchanged. - Pad: special-URL icons (mail, Zoom, GitHub and so on) look as before.
Acceptance checks
-
bun test src/utils/__tests__/specialUrls.test.ts src/utils/__tests__/validateURL.test.ts: all pass (166 today). - A one-row typo fails
tsc(sabotage). -
bun run test:unit, typecheck, lint. - Before and after bench posted here. CHANGELOG
Internalline.
Out of scope
- Widening
SpecialUrlTypetostring.
Activity
HMarzban commentedon Nov 12, 2026
Measured (2026-11-12, working tree, not committed yet)
Change:
src/utils/specialUrls.tsstores the catalog astoEntries([...] as const satisfies readonly Row[])rows and loops over the entry arrays. TheSpecialUrlTypeunion andSpecialUrlInfoare unchanged.Package bench, base = a copy of
src/with #770 and #772, head = that plus this change:dist/index.js(min / gz)normalizeHref-only import (min / gz)jsdom on Bun 1.4.4, darwin arm64, 9 rounds.
boldPartOfLinkis about 0.1 ms, so its percentages are timer noise (thecontrolcopy moved +31 %).Checks run:
getSpecialUrlInfobefore and after over all 63 catalog keys and 161 derived inputs: 0 differences.specialUrls.test.ts+validateURL.test.ts: 166 / 166.emialin one row failstscwith TS2820.bun run typecheck, ESLint and Prettier clean. CHANGELOGInternalline.Still owed: the full package Cypress suite (runs once with #772 and #773), a glance at special-URL icons on the pad, the commit.
HMarzban commentedon Nov 12, 2026
Pad check (local
dev-local, 2026-11-12)On a local pad with this change built in: a
mailto:link shows its special-URL icon, andgithub.comlinks show the GitHub icon, as before.HMarzban commentedon Nov 12, 2026
Committed
c9cd2c98aonmain, 2026-11-12, not pushed yet. One commit holds #770, #772, #773 and #776 together, by the maintainer's choice, so it cites each withRefs, and none closes on push. It is the same code the measured comments above describe.Open before this issue closes:
fix(extension-hyperlink): keep links intact when autolink runs
HMarzban commentedon Nov 16, 2026
Production check, 2026-11-16. docs.plus at
b7888dce1(deployed 2026-11-15). Chrome on macOS, signed in. One scratch pad, never/demo. Each result was read from the editor DOM after the action. n = 1.A pad with a
mailto:link and agithub.comlink shows both special-URL icons: the mail glyph (hyperlink-icon) and the GitHub icon from the icon route. The per-modulespecialUrlsd.ts emit is identical (1,243 B), unit tests are 474/474 and Cypress 289/289 (#770, #773). The change isc9cd2c98a, live since3d90636a9and still inb7888dce1. Release credit v2.3.8. Closing as done.