@wular/pnext 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/client/router/hub.ts
CHANGED
|
@@ -14,7 +14,13 @@ import type { EntryModule } from './types'
|
|
|
14
14
|
// region (install, soft nav, popstate), so it lives on one record: a module-level `let` can only be
|
|
15
15
|
// reassigned inside the module that declares it. State only the runtime touches stays in ./runtime.
|
|
16
16
|
|
|
17
|
-
export const routerState
|
|
17
|
+
export const routerState: {
|
|
18
|
+
observedLocationKey: string
|
|
19
|
+
activeRouteKey: string | undefined
|
|
20
|
+
renderedEntryId: string | undefined
|
|
21
|
+
/** The navigation that last painted a fallback, and when. */
|
|
22
|
+
fallbackPaint?: [sequence: number, at: number]
|
|
23
|
+
} = {
|
|
18
24
|
// pathname+search of the URL the router last observed. A popstate that leaves both unchanged is a
|
|
19
25
|
// same-document FRAGMENT traversal - Chrome fires popstate, not just hashchange, for those - and
|
|
20
26
|
// treating one as a history traversal would refetch and swap the body, remounting the live tree
|
|
@@ -5217,6 +5217,8 @@ export async function softNavigate(href: string, options: SoftNavigateOptions =
|
|
|
5217
5217
|
// A painted loading boundary or stage is a committed navigation state.
|
|
5218
5218
|
const commitPaint = () => {
|
|
5219
5219
|
paintedRoute = window.__PNEXT_ROUTE__
|
|
5220
|
+
if (typeof __PNEXT_NEXT_ROUTER__ === 'undefined')
|
|
5221
|
+
routerState.fallbackPaint = [sequence, performance.now()]
|
|
5220
5222
|
pushOptimisticUrl()
|
|
5221
5223
|
scheduleNavigationScroll(url, options)
|
|
5222
5224
|
}
|
|
@@ -5416,6 +5418,14 @@ export async function softNavigate(href: string, options: SoftNavigateOptions =
|
|
|
5416
5418
|
])
|
|
5417
5419
|
if (sequence !== navigationSequence) return abandonFetchedPage(page)
|
|
5418
5420
|
}
|
|
5421
|
+
// React's FALLBACK_THROTTLE_MS: content replacing a committed fallback reveals no sooner than 300 ms after it.
|
|
5422
|
+
if (typeof __PNEXT_NEXT_ROUTER__ === 'undefined' && routerState.fallbackPaint?.[0] === sequence) {
|
|
5423
|
+
const wait = routerState.fallbackPaint[1] + 300 - performance.now()
|
|
5424
|
+
if (wait > 10) {
|
|
5425
|
+
await new Promise(resolve => setTimeout(resolve, wait))
|
|
5426
|
+
if (sequence !== navigationSequence) return abandonFetchedPage(page)
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5419
5429
|
|
|
5420
5430
|
if (!options.pop) {
|
|
5421
5431
|
const bfcacheId = optimisticBfcacheId ?? nextBfcacheIdForNavigation(targetUrl, previousPathname)
|