Repository navigation
Keep the router out of the embeddable diagram (#356) - #432
Conversation
The embed never routes, but carried @angular/router (67 KB): everything that
draws a pathway injects UrlStateService, and that class -- the token itself --
imported the Router to keep the state in the address bar. MemoryState, the
embed's in-memory state, also imported from that file.
- UrlStateService is now an abstract, router-free base: the state signals
(built by createStateValues, as before), the tab maps and the dbId lookup,
with section, settle, navigateTo and two new members abstract. It imports
only router *types*.
- RouterUrlStateService (router-url-state.service.ts) is the address-bar
implementation, moved unchanged apart from the base taking the shared
parts; the site provides it in src/app/app.config.ts.
- MemoryState extends the base, so its copy of every field is gone.
- The diagram's "first page opened" check and the species switch's query
parameters were the last direct router reads; they are now
state.isFirstNavigation() and state.queryParams() (the embed answers true
and {}, which is what it got before with no router injected).
- lodash's isArray/isNumber in the state service are now Array.isArray and
typeof.
The embed's initial JavaScript goes from 1.58 MB to 1.50 MB (all its
JavaScript: 1,650 KB -> 1,570 KB). The full e2e suite passes (401, 6 skipped).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ate says it is unchecked Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review (subagent, adversarial): no defects. The moved class is line-for-line the old one (bar Array.isArray, a type rename and Boolean(!x) -> !x); field order under useDefineForClassFields: false is safe (route before section, no base initialiser touches subclass fields); every injector resolves (site via app.config, embed via MemoryState/rootGuards, detail page its own provider, specs updated); isFirstNavigation/queryParams read the same root Router/ActivatedRoute as before; the embed stats show no @angular/router. Nits fixed in the latest commits: queryParams() returns a copy rather than the router's object, a stale comment above the removed Router injection is gone, and DetailUrlState now says plainly that it is a Partial, so nothing checks it has settle/navigateTo/isFirstNavigation/queryParams -- nothing on the content pages calls them. |
Part of #356: the embed should cost under a third of what the site's Pathway Browser costs for the same diagram.
Cause. The embed never routes, but it carried
@angular/router(67 KB).UrlStateService, and that class, the injection token itself, imported the Router to keep state in the address bar.MemoryStatealso imported from that file.diagram.componentandspecies.serviceinjectedRouter/ActivatedRouteoptionally, which still imports them.Change
UrlStateServiceis now an abstract, router-free base. It holds the state signals (built bycreateStateValues, as before), the tab maps and the dbId lookup.section,settle,navigateToand two new members are abstract. It imports only router types.RouterUrlStateService(router-url-state.service.ts) is the address-bar implementation. It's moved unchanged, except that the shared parts now come from the base. The site provides it insrc/app/app.config.ts, replacingprovidedIn: 'root'.MemoryStateextends the base, so its copy of every field is gone.state.isFirstNavigation()(the diagram's first-load check) andstate.queryParams()(the species switch). The embed answerstrueand{}, which is what it got before, with no router injected.isArray/isNumberin the state service are nowArray.isArrayandtypeof.DetailUrlState(aPartialof the state) is unaffected. Nothing on that page calls the two new members: its diagram is an image component, notcr-diagram.Size. The embed's initial JavaScript goes from 1.58 MB to 1.50 MB (all its JavaScript: 1,650 KB to 1,570 KB).
@angular/routeris at 0 bytes in the stats.Checks
entity.service.specnow provides the state itself, because it's no longer provided at the root automatically.Next for #356
🤖 Generated with Claude Code