hmrHandler.ts — vite Source File
Architecture documentation for hmrHandler.ts, a typescript file in the vite codebase. 1 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 028d7bbe_154e_0f3f_836a_0c92f8021168["hmrHandler.ts"] ccb8a028_b1ec_3743_cfbe_0ac5315bc7c3["hmrPayload"] 028d7bbe_154e_0f3f_836a_0c92f8021168 --> ccb8a028_b1ec_3743_cfbe_0ac5315bc7c3 85908ff5_4d12_826d_8235_531f91538758["client.ts"] 85908ff5_4d12_826d_8235_531f91538758 --> 028d7bbe_154e_0f3f_836a_0c92f8021168 569b12a9_015e_564e_efd3_205cedee54dd["hmrHandler.ts"] 569b12a9_015e_564e_efd3_205cedee54dd --> 028d7bbe_154e_0f3f_836a_0c92f8021168 style 028d7bbe_154e_0f3f_836a_0c92f8021168 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { HotPayload } from '#types/hmrPayload'
// updates to HMR should go one after another. It is possible to trigger another update during the invalidation for example.
export function createHMRHandler(
handler: (payload: HotPayload) => Promise<void>,
): (payload: HotPayload) => Promise<void> {
const queue = new Queue()
return (payload) => queue.enqueue(() => handler(payload))
}
class Queue {
private queue: {
promise: () => Promise<void>
resolve: (value?: unknown) => void
reject: (err?: unknown) => void
}[] = []
private pending = false
enqueue(promise: () => Promise<void>): Promise<void> {
return new Promise<any>((resolve, reject) => {
this.queue.push({
promise,
resolve,
reject,
})
this.dequeue()
})
}
dequeue(): boolean {
if (this.pending) {
return false
}
const item = this.queue.shift()
if (!item) {
return false
}
this.pending = true
item
.promise()
.then(item.resolve)
.catch(item.reject)
.finally(() => {
this.pending = false
this.dequeue()
})
return true
}
}
Domain
Subdomains
Functions
Classes
Dependencies
- hmrPayload
Source
Frequently Asked Questions
What does hmrHandler.ts do?
hmrHandler.ts is a source file in the vite codebase, written in typescript. It belongs to the HMRClient domain, HotRuntime subdomain.
What functions are defined in hmrHandler.ts?
hmrHandler.ts defines 1 function(s): createHMRHandler.
What does hmrHandler.ts depend on?
hmrHandler.ts imports 1 module(s): hmrPayload.
What files import hmrHandler.ts?
hmrHandler.ts is imported by 2 file(s): client.ts, hmrHandler.ts.
Where is hmrHandler.ts in the architecture?
hmrHandler.ts is located at packages/vite/src/shared/hmrHandler.ts (domain: HMRClient, subdomain: HotRuntime, directory: packages/vite/src/shared).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free