Packaging · interface
Host
Every capability the engine takes, chosen for wherever this build is running.
Explained in Packaging an application.
interface Hostimport type { Host } from '@driftengine/package';In depth
One call, at boot, and no platform test anywhere else. A game shipped to a browser and
packaged for a desktop is one bundle; the difference between them is which objects these five
fields hold, and finding that out is this function's job rather than a game's. What a game
writes against is the interfaces — so its own settings menu calls display.setMode,
display.setSize and display.displays() the same way in both, and reads false from the ones
a browser genuinely cannot do rather than discovering nothing happened.
const host = createHost(canvas);
const { renderer } = await createRenderer(canvas, quality);
const settings = loadPreferences(host.store, SCHEMA);
await host.display.setMode(settings.fullscreen ? 'fullscreen' : 'windowed');screen is the browser implementation on every platform including the shell, and that is
not an omission: orientation, safe-area insets and the wake lock are answered by Chromium
itself, so a native override would be a second implementation of the same answers. A phone host
supplies its own where the WebView cannot answer — see the mobile plan.
native is for telling somebody, not for branching: a build badge, a bug report, a
"restart required" line. A game that branches on it is doing what this function exists to
prevent.
Properties
| Name | Type | Description |
|---|---|---|
nativereadonly | boolean | Whether a shell supplied these, rather than the browser. |
displayreadonly | DisplayControl | |
lifecyclereadonly | Lifecycle | |
filesreadonly | FileDialogs | |
storereadonly | KeyValueStore | |
screenreadonly | ScreenPresentation | |
servicesreadonly | PlatformServices | null | A store's own features, or null where there is no store.MoreNull in a browser, null in a shell whose manifest named no app, and null when the copy was launched outside the store — a game checks once and never calls it, rather than calling into something that quietly does nothing. |