Context
Operator Prio-0 search-visibility directive (2026-11-16) under Cornerstone #20671. Directly unblocks neomjs/middleware-v2#21 ("every organic landing is 302-redirected off the URL that ranked") so human search visitors keep clean canonical URLs (/learn/*, /news/*, /examples/*) instead of bouncing 302 -> /#/..., which currently collapses every shared deep link back to /.
The Problem
As verified on neomjs/middleware-v2#21 (#issuecomment-6888508227) and Discussion #20920:
src/main/DomEvents.mjs:156, 653 listens strictly to window 'hashchange' and reads location.hash.substring(1).
src/Main.mjs:270, 286, 803 (editRoute, setRoute) writes exclusively to window.location.hash.
src/ contains zero history.pushState, history.replaceState, or 'popstate' handlers.
If middleware-v2 serves the interactive Portal shell (200 OK) directly at /learn/comparisons/NeoVsReact today, Neo boots at an empty route (/home) and navigation jumps back to #/....
The Architectural Reality
Design authority: neomjs/middleware-v2#21 (AC-1–AC-4), ROADMAP.md Cornerstone #4 (#20671), Discussion #20920 (Axis C1), and operator 2026-11-16 Prio-0 directive.
Neo.main.DomEvents forwards route transitions to the App Worker as {action: 'hashChange', value: {appName, hash, hashString, windowId}} (src/main/DomEvents.mjs:653-661), where Neo.util.HashHistory (src/util/HashHistory.mjs:98-113) and view controllers consume hashString and hash without reading window.location. Keeping the worker message contract identical while switching DomEvents and Main via an opt-in routerMode config ('hash' default | 'pathname') leaves every standalone app and controller untouched.
The Fix
- Add
routerMode: 'hash' ('hash' | 'pathname') and routerBasePath: '' configs in src/DefaultConfig.mjs ('hash' remains default across devmode, dist examples, and multi-window apps).
- In
src/main/DomEvents.mjs and src/Main.mjs: when Neo.config.routerMode === 'pathname':
- On boot (
handleDomContentLoaded / initial route emission), normalize incoming legacy /#/foo URLs via history.replaceState(null, '', normalizePath('/foo')) so shared old #/... bookmarks resolve cleanly, and otherwise derive hashString from window.location.pathname (stripping optional routerBasePath; mapping '/' to '/home' or Portal's root route consistently).
- Listen to
window.addEventListener('popstate', ...) in addition to hashchange so browser Back/Forward dispatches the same App Worker route update.
- Update
Main#setRoute and Main#editRoute in pathname mode to call history.pushState(null, '', targetPathname) and notify DomEvents so HashHistory / ViewportController stay in sync without touching window.location.hash.
- Enable opt-in
routerMode: 'pathname' for the deployed Portal build configuration (apps/portal/neo-config.json / build hook with companion root-anchored <base href="/dist/production/apps/portal/"> requirement noted for neomjs/pages/buildScripts/enhanceSeo.mjs) so neomjs/middleware-v2#21 can switch human deep routes from 302 to 200 OK.
- Add unit tests for
DomEvents / Main pathname mode (pushState, popstate, legacy /#/... upgrade via replaceState, and unaltered 'hash' default) plus a Playwright E2E test verifying direct deep-route boot and client navigation with zero # in location.href.
Contract Ledger Matrix
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback / Edge Case |
Docs |
Evidence |
Neo.config.routerMode / routerBasePath (src/DefaultConfig.mjs) |
middleware-v2#21 · #20671 |
Defaults to 'hash'; 'pathname' enables History API routing for Main + DomEvents |
Unset or 'hash' preserves existing hash behavior byte-for-byte |
@memberOf! module:Neo JSDoc |
Unit spec |
Neo.main.DomEvents & Neo.Main (setRoute, editRoute, initial route, popstate) |
src/util/HashHistory.mjs wire shape |
Emits identical {appName, hash, hashString, windowId} to App Worker from location.pathname; upgrades initial /#/... URLs via replaceState |
Unknown sub-path or empty pathname resolves safely without throwing; file:// stays 'hash' |
Method JSDoc |
Unit + Playwright E2E spec |
Decision Record impact: none (Discussion #20920 Axis C1 remains non-blocking post-cut for Docs v2, while this ticket supplies the opt-in engine routing toggle unblocking middleware-v2#21).
Acceptance Criteria
Out of Scope
- Prerendered
/docs/<ClassName> JSDoc v2 generation (ROADMAP.md post-14.0.0 scope; Discussion #20920).
neomjs/middleware-v2 server proxy switch (neomjs/middleware-v2#21 owns server-side 302 → 200 cutover once this engine toggle and root-anchored <base> land).
Avoided Traps
- Mutating default
routerMode to 'pathname' globally: standalone examples loaded via file:// or /dist/production/examples/* would break relative module/resource paths or hit static 404s on reload without middleware rewrites.
- Serving static HTML from
dist/seo/ directly without <script> tags (SsrService.mjs strips MicroLoader.mjs): interactive hydration requires serving the Portal SPA shell at 200 OK alongside this pathname bootstrap.
- Changing the
HashHistory / controller.Base App Worker hashChange contract: keeping DomEvents emitting normalized hashString makes all Portal controllers work without touching app-worker routing code.
Related
Parent: #20671 · neomjs/middleware-v2#21 · Discussion #20920 (Axis C1) · neomjs/pages#58.
unowned-rationale: Prio-0 team deliverable under operator 2026-11-16 directive; curated contributor labels omitted due to core Main/DomEvents architecture touch.
Live latest-open + closed sweep: checked latest 30 open issues (#21114 down to #21006, 59 open total — red band; filed under owning Epic #20671) + open & closed searches (seo OR sitemap OR Search Console OR canonical OR pathname) + neomjs/middleware-v2#21 conversation at 2026-11-16T08:48Z; no existing open or closed Engine ticket implements routerMode: 'pathname' in Main/DomEvents.
A2A in-flight claim sweep: list_messages({status: 'all', limit: 15}) at 2026-11-16T08:54Z; zero competing claims on pathname routing.
MC sweep: "pathname History routing middleware-v2#21 302 hash redirect DomEvents Main.mjs", 5 results (D#20920 DC_kwDODSospM4BKyBl identified the missing engine C1 pathname prerequisite; no Engine ticket existed yet).
Own-assignment sweep: 3 open in neomjs/neo (#21104, #20987, #20671, all bodies read; none implements routerMode: 'pathname').
Structure map: N/A (src/ core browser bootstrap + apps/portal/).
Origin Session ID: 1f283c86-c55b-4aa5-a291-0cbb3786c302
Retrieval Hint: "routerMode pathname History API pushState DomEvents Main.mjs middleware-v2#21 302"
Context
Operator Prio-0 search-visibility directive (
2026-11-16) under Cornerstone#20671. Directly unblocksneomjs/middleware-v2#21("every organic landing is 302-redirected off the URL that ranked") so human search visitors keep clean canonical URLs (/learn/*,/news/*,/examples/*) instead of bouncing302 -> /#/..., which currently collapses every shared deep link back to/.The Problem
As verified on
neomjs/middleware-v2#21(#issuecomment-6888508227) and Discussion #20920:src/main/DomEvents.mjs:156, 653listens strictly towindow'hashchange'and readslocation.hash.substring(1).src/Main.mjs:270, 286, 803(editRoute,setRoute) writes exclusively towindow.location.hash.src/contains zerohistory.pushState,history.replaceState, or'popstate'handlers.If
middleware-v2serves the interactive Portal shell (200 OK) directly at/learn/comparisons/NeoVsReacttoday, Neo boots at an empty route (/home) and navigation jumps back to#/....The Architectural Reality
Design authority:neomjs/middleware-v2#21(AC-1–AC-4),ROADMAP.mdCornerstone#4(#20671), Discussion #20920 (Axis C1), and operator2026-11-16Prio-0 directive.Neo.main.DomEventsforwards route transitions to the App Worker as{action: 'hashChange', value: {appName, hash, hashString, windowId}}(src/main/DomEvents.mjs:653-661), whereNeo.util.HashHistory(src/util/HashHistory.mjs:98-113) and view controllers consumehashStringandhashwithout readingwindow.location. Keeping the worker message contract identical while switchingDomEventsandMainvia an opt-inrouterModeconfig ('hash'default |'pathname') leaves every standalone app and controller untouched.The Fix
routerMode: 'hash'('hash' | 'pathname') androuterBasePath: ''configs insrc/DefaultConfig.mjs('hash'remains default across devmode, dist examples, and multi-window apps).src/main/DomEvents.mjsandsrc/Main.mjs: whenNeo.config.routerMode === 'pathname':handleDomContentLoaded/ initial route emission), normalize incoming legacy/#/fooURLs viahistory.replaceState(null, '', normalizePath('/foo'))so shared old#/...bookmarks resolve cleanly, and otherwise derivehashStringfromwindow.location.pathname(stripping optionalrouterBasePath; mapping'/'to'/home'or Portal's root route consistently).window.addEventListener('popstate', ...)in addition tohashchangeso browser Back/Forward dispatches the same App Worker route update.Main#setRouteandMain#editRouteinpathnamemode to callhistory.pushState(null, '', targetPathname)and notifyDomEventssoHashHistory/ViewportControllerstay in sync without touchingwindow.location.hash.routerMode: 'pathname'for the deployed Portal build configuration (apps/portal/neo-config.json/ build hook with companion root-anchored<base href="/dist/production/apps/portal/">requirement noted forneomjs/pages/buildScripts/enhanceSeo.mjs) soneomjs/middleware-v2#21can switch human deep routes from302to200 OK.DomEvents/Mainpathnamemode (pushState,popstate, legacy/#/...upgrade viareplaceState, and unaltered'hash'default) plus a Playwright E2E test verifying direct deep-route boot and client navigation with zero#inlocation.href.Contract Ledger Matrix
Neo.config.routerMode/routerBasePath(src/DefaultConfig.mjs)middleware-v2#21·#20671'hash';'pathname'enables History API routing forMain+DomEvents'hash'preserves existing hash behavior byte-for-byte@memberOf! module:NeoJSDocNeo.main.DomEvents&Neo.Main(setRoute,editRoute, initial route,popstate)src/util/HashHistory.mjswire shape{appName, hash, hashString, windowId}to App Worker fromlocation.pathname; upgrades initial/#/...URLs viareplaceStatefile://stays'hash'Decision Record impact: none (
Discussion #20920Axis C1remains non-blocking post-cut for Docs v2, while this ticket supplies the opt-in engine routing toggle unblockingmiddleware-v2#21).Acceptance Criteria
src/DefaultConfig.mjsdocumentsrouterMode(default'hash') androuterBasePath(default''), leaving all existing'hash'apps and standalonedist/examples unaffected by default.'pathname'mode, initial load at/learn/benefits/Introductiondispatches/learn/benefits/Introductionwithout rewritingwindow.locationto/#/..., navigation viasetRoute/editRouteupdates the URL withhistory.pushState, browser Back/Forward (popstate) updates the App Worker route, and incoming legacy/#/learn/benefits/Introductionupgrades cleanly viahistory.replaceState.'hash'default preservation and'pathname'deep-route boot + multi-step navigation with zero#inwindow.location.href.neomjs/middleware-v2#21/neomjs/pagesroot<base href>cutover steps are documented in the PR.Out of Scope
/docs/<ClassName>JSDoc v2 generation (ROADMAP.mdpost-14.0.0 scope;Discussion #20920).neomjs/middleware-v2server proxy switch (neomjs/middleware-v2#21owns server-side302→200cutover once this engine toggle and root-anchored<base>land).Avoided Traps
routerModeto'pathname'globally: standalone examples loaded viafile://or/dist/production/examples/*would break relative module/resource paths or hit static 404s on reload without middleware rewrites.dist/seo/directly without<script>tags (SsrService.mjsstripsMicroLoader.mjs): interactive hydration requires serving the Portal SPA shell at200 OKalongside thispathnamebootstrap.HashHistory/controller.BaseApp WorkerhashChangecontract: keepingDomEventsemitting normalizedhashStringmakes all Portal controllers work without touching app-worker routing code.Related
Parent:
#20671·neomjs/middleware-v2#21· Discussion #20920 (Axis C1) ·neomjs/pages#58.unowned-rationale: Prio-0 team deliverable under operator
2026-11-16directive; curated contributor labels omitted due to coreMain/DomEventsarchitecture touch.Live latest-open + closed sweep: checked latest 30 open issues (
#21114down to#21006,59open total — red band; filed under owning Epic#20671) + open & closed searches (seo OR sitemap OR Search Console OR canonical OR pathname) +neomjs/middleware-v2#21conversation at2026-11-16T08:48Z; no existing open or closed Engine ticket implementsrouterMode: 'pathname'inMain/DomEvents. A2A in-flight claim sweep:list_messages({status: 'all', limit: 15})at2026-11-16T08:54Z; zero competing claims on pathname routing. MC sweep:"pathname History routing middleware-v2#21 302 hash redirect DomEvents Main.mjs", 5 results (D#20920DC_kwDODSospM4BKyBlidentified the missing engineC1pathname prerequisite; no Engine ticket existed yet). Own-assignment sweep:3open inneomjs/neo(#21104,#20987,#20671, all bodies read; none implementsrouterMode: 'pathname'). Structure map: N/A (src/core browser bootstrap +apps/portal/).Origin Session ID: 1f283c86-c55b-4aa5-a291-0cbb3786c302 Retrieval Hint: "routerMode pathname History API pushState DomEvents Main.mjs middleware-v2#21 302"