forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.ts
More file actions
35 lines (28 loc) · 1.16 KB
/
runtime.ts
File metadata and controls
35 lines (28 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import RefreshRuntime from 'react-refresh/runtime'
import RefreshHelpers from './internal/helpers'
export type RefreshRuntimeGlobals = {
$RefreshReg$: (type: unknown, id: string) => void
$RefreshSig$: () => (type: unknown) => unknown
$RefreshInterceptModuleExecution$: (moduleId: string) => () => void
$RefreshHelpers$: typeof RefreshHelpers
}
declare const self: Window & RefreshRuntimeGlobals
// Hook into ReactDOM initialization
RefreshRuntime.injectIntoGlobalHook(self)
// Register global helpers
self.$RefreshHelpers$ = RefreshHelpers
// Register a helper for module execution interception
self.$RefreshInterceptModuleExecution$ = function (webpackModuleId) {
var prevRefreshReg = self.$RefreshReg$
var prevRefreshSig = self.$RefreshSig$
self.$RefreshReg$ = function (type, id) {
RefreshRuntime.register(type, webpackModuleId + ' ' + id)
}
self.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform
// Modeled after `useEffect` cleanup pattern:
// https://react.dev/learn/synchronizing-with-effects#step-3-add-cleanup-if-needed
return function () {
self.$RefreshReg$ = prevRefreshReg
self.$RefreshSig$ = prevRefreshSig
}
}