-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
63 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/next/src/client/dev/dev-build-indicator/initialize-for-page-router.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../server/dev/hot-reloader-types' | ||
import { addMessageListener } from '../../components/react-dev-overlay/pages/websocket' | ||
import { devBuildIndicator } from './internal/dev-build-indicator' | ||
|
||
/** Integrates the generic dev build indicator with the Pages Router. */ | ||
export const initializeDevBuildIndicatorForPageRouter = () => { | ||
if (!process.env.__NEXT_BUILD_INDICATOR) { | ||
return | ||
} | ||
|
||
devBuildIndicator.initialize(process.env.__NEXT_BUILD_INDICATOR_POSITION) | ||
|
||
// Add message listener specifically for Pages Router to handle lifecycle events | ||
// related to dev builds (building, built, sync) | ||
addMessageListener((obj) => { | ||
try { | ||
if (!('action' in obj)) { | ||
return | ||
} | ||
|
||
// eslint-disable-next-line default-case | ||
switch (obj.action) { | ||
case HMR_ACTIONS_SENT_TO_BROWSER.BUILDING: | ||
devBuildIndicator.show() | ||
break | ||
case HMR_ACTIONS_SENT_TO_BROWSER.BUILT: | ||
case HMR_ACTIONS_SENT_TO_BROWSER.SYNC: | ||
devBuildIndicator.hide() | ||
break | ||
} | ||
} catch {} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters