fix: revert client segment route changes for sub shell generation (#81740)
### What?
Implements a new sortable routes system that distinguishes between
source pages and rendered pages for sub-shell generation.
### Why?
The existing route sorting logic in Next.js doesn't account for the
distinction between the original page definition (`sourcePage`) and the
final rendered route (`page`). This is critical for sub-shell
generation, given this example:
| Page | Source Page |
|--------|--------|
| `/en/[teamSlug]/[projectSlug]/monitoring` |
`/[lang]/[teamSlug]/[projectSlug]/monitoring` |
| `/fr/[teamSlug]/[projectSlug]/monitoring` |
`/[lang]/[teamSlug]/[projectSlug]/monitoring` |
| `/[lang]/[teamSlug]/~/monitoring` | `/[lang]/[teamSlug]/~/monitoring`
|
And a request to `/en/vercel/~/monitoring` that it will hit the
`/[lang]/[teamSlug]/~/monitoring` page instead of the
`/en/[teamSlug]/[projectSlug]/monitoring`. This is because we first need
to sort by the Source Page and then the Page to ensure that the correct
route ordering is respected.
### How?
- Adds new `SortableRoute` type that tracks both `sourcePage` and `page`
- Implements depth-first route comparison algorithm that properly
handles segment specificity
- Refactors build process to use the new sorting functions instead of
legacy `getSortedRoutes`
- Adds source page tracking for PPR-enabled routes with
`clientSegmentEnabled`
- Includes comprehensive test coverage for all route sorting scenarios
The new sorting algorithm ensures consistent route ordering across
builds and proper sub-shell generation behavior.