@zerolith/vite/runtime
Import from @zerolith/vite/runtime. Generated from the source; every signature below is what the published types declare.
Functions
component
function component<T extends AnyFunction>(hot: HotContext | undefined, name: string, impl: T): TRegisters a component under its module's hot context and returns the
proxy that stands in for it. The proxy is created once per module and
name and kept in hot.data, so importers that are not re-executed keep
calling the latest version. Without a hot context the function itself
is returned.
Source: packages/vite/src/runtime.ts:46
render
function render(factory: () => unknown, target: core.MountTarget, site?: string): core.RootRenders what factory returns into container and remembers the factory,
so the root can be rendered again after an update. The core calls the
factory inside the root's owner, so components own their effects and
cleanups as they do without the plugin, and calls once more a factory
whose expression was itself a function, as in render(() => App(), "#app").
A root that the same call, site, mounted into the same container before
is replaced, which is what happens when the entry module itself is
re-executed; roots from other calls stay, as they do in production.
Source: packages/vite/src/runtime.ts:108
hydrate
function hydrate(factory: () => unknown, target: core.MountTarget, site?: string): core.HydrateResultThe hydrate counterpart of render: hydrates once, then re-renders on updates.
Source: packages/vite/src/runtime.ts:119
save
function save(): voidSaves the value of every named state signal so the signals created by the
next render take them over. The plugin wires this to import.meta.hot.dispose,
which runs just before a module's new version is evaluated.
Source: packages/vite/src/runtime.ts:140
accept
function accept(): voidRenders every recorded root again with its factory and then drops any
saved values no signal claimed. The plugin wires this to
import.meta.hot.accept, which runs after the module's new version has
been evaluated and its components re-registered. A root mounted since the
last save() was rendered by that evaluation itself, when the entry
module is the one that changed, and is left as it is. Each root's new
view is rendered before its old one is disposed, so an edit that throws
leaves the old view on the page and reports the error.
Source: packages/vite/src/runtime.ts:172
Interfaces
HotContext
interface HotContextThe part of import.meta.hot the runtime relies on: the object that survives a module's replacement.
readonly data: Record<string, unknown>: Survives each new version of the module; the runtime stores the module's component proxies here under thezerolithkey, so a new version updates the proxies its importers already hold.
Source: packages/vite/src/runtime.ts:11