PlatformAdapter
Defined in: platform/types.ts:361
Properties
Section titled “Properties”family?
Section titled “family?”
readonlyoptionalfamily?:"minigame"
Defined in: platform/types.ts:369
The capability family this platform belongs to, if any. Absent means the
platform stands alone (web, node, native). Set by the mini-game family
adapter — the single reason isMiniGame() needs no vendor list.
readonlyname:PlatformName
Defined in: platform/types.ts:362
Methods
Section titled “Methods”bindInputEvents()
Section titled “bindInputEvents()”bindInputEvents(
callbacks,target?):void
Defined in: platform/types.ts:412
Parameters
Section titled “Parameters”callbacks
Section titled “callbacks”InputEventCallbacks
target?
Section titled “target?”unknown
Returns
Section titled “Returns”void
clearStorage()
Section titled “clearStorage()”clearStorage(
prefix):void
Defined in: platform/types.ts:485
Parameters
Section titled “Parameters”prefix
Section titled “prefix”string
Returns
Section titled “Returns”void
createAudioBackend()?
Section titled “createAudioBackend()?”
optionalcreateAudioBackend():PlatformAudioBackend
Defined in: platform/types.ts:427
Create the platform audio backend (WebAudio on web, the mini-game audio API on WeChat). Optional — a host with no audio device (headless node, the unshipped native shell) omits it and the audio system falls back to the silent Null backend, exactly like createVideoBackend.
Returns
Section titled “Returns”createCanvas()
Section titled “createCanvas()”createCanvas(
width,height):PlatformCanvas
Defined in: platform/types.ts:386
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”createImage()
Section titled “createImage()”createImage():
PlatformImage
Defined in: platform/types.ts:410
Returns
Section titled “Returns”createSocket()?
Section titled “createSocket()?”
optionalcreateSocket(options):PlatformSocket
Defined in: platform/types.ts:461
Open a socket connection. Web → WebSocket, WeChat → wx.connectSocket,
Node → a ws wrapper. Optional — platforms without networking (playable
ads) omit it and createSocket() fails loud.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”createTextEditor()?
Section titled “createTextEditor()?”
optionalcreateTextEditor():PlatformTextEditor|null
Defined in: platform/types.ts:406
The OS text-editing surface for editable fields (see PlatformTextEditor). Optional — a host without one (a headless realm, the editor’s edit mode) renders fields but cannot type into them.
Returns
Section titled “Returns”PlatformTextEditor | null
createVideoBackend()?
Section titled “createVideoBackend()?”
optionalcreateVideoBackend(ctx):PlatformVideoBackend
Defined in: platform/types.ts:434
Create the platform video backend: HTMLVideoElement on web, the wasm software decoder (videodec side module) on WeChat. The choice is a static per-platform matrix — no runtime fallback chain. Optional — a platform without video (headless server) omits it and the video system uses the silent Null backend.
Parameters
Section titled “Parameters”VideoBackendContext
Returns
Section titled “Returns”devicePixelRatio()
Section titled “devicePixelRatio()”devicePixelRatio():
number
Defined in: platform/types.ts:480
Returns
Section titled “Returns”number
fetch()
Section titled “fetch()”fetch(
url,options?):Promise<PlatformResponse>
Defined in: platform/types.ts:371
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<PlatformResponse>
fileExists()
Section titled “fileExists()”fileExists(
path):Promise<boolean>
Defined in: platform/types.ts:377
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<boolean>
getStorageItem()
Section titled “getStorageItem()”getStorageItem(
key):string|null
Defined in: platform/types.ts:482
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string | null
instantiateWasm()
Section titled “instantiateWasm()”instantiateWasm(
pathOrBuffer,imports):Promise<WasmInstantiateResult>
Defined in: platform/types.ts:381
Parameters
Section titled “Parameters”pathOrBuffer
Section titled “pathOrBuffer”string | ArrayBuffer
imports
Section titled “imports”WebAssembly.Imports
Returns
Section titled “Returns”Promise<WasmInstantiateResult>
language()?
Section titled “language()?”
optionallanguage():string
Defined in: platform/types.ts:478
The host’s UI language tag (‘zh-CN’, ‘en-US’, …). WeChat reports
‘zh_CN’-style tags — platformLanguage() normalizes underscores.
Optional; web falls through to navigator.language.
Returns
Section titled “Returns”string
loadImagePixels()
Section titled “loadImagePixels()”loadImagePixels(
path):Promise<ImageLoadResult>
Defined in: platform/types.ts:379
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<ImageLoadResult>
loadSubpackage()?
Section titled “loadSubpackage()?”
optionalloadSubpackage(name):Promise<void>
Defined in: platform/types.ts:441
Download an on-demand asset subpackage by name and resolve when its files are available. WeChat → wx.loadSubpackage; platforms with no subpackage concept (web) omit it and lazy groups load directly from their URLs.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
now():
number
Defined in: platform/types.ts:408
Returns
Section titled “Returns”number
onAppHide()?
Section titled “onAppHide()?”
optionalonAppHide(callback): () =>void
Defined in: platform/types.ts:473
Parameters
Section titled “Parameters”callback
Section titled “callback”() => void
Returns
Section titled “Returns”() => void
onAppShow()?
Section titled “onAppShow()?”
optionalonAppShow(callback): () =>void
Defined in: platform/types.ts:472
App foreground/background signals, for platforms with no DOM visibility event. The native shell pushes them through its bridge; the Lifecycle plugin subscribes and auto-pauses on hide. Web/WeChat read visibility from their own globals (document/wx) and omit these. Each returns an unsubscribe.
Parameters
Section titled “Parameters”callback
Section titled “callback”() => void
Returns
Section titled “Returns”() => void
onMemoryWarning()?
Section titled “onMemoryWarning()?”
optionalonMemoryWarning(callback): () =>void
Defined in: platform/types.ts:466
Subscribe to OS memory-pressure warnings; returns an unsubscribe. WeChat → wx.onMemoryWarning; platforms without a pressure signal (web) omit it. Residency caches subscribe to drop their evictable entries.
Parameters
Section titled “Parameters”callback
Section titled “callback”() => void
Returns
Section titled “Returns”() => void
pollGamepads()?
Section titled “pollGamepads()?”
optionalpollGamepads():GamepadSnapshot[]
Defined in: platform/types.ts:421
Poll connected gamepads for this frame. Optional — platforms without gamepad support (WeChat, headless) omit it and the input plugin skips gamepad polling entirely.
Returns
Section titled “Returns”rasterizeGlyph()?
Section titled “rasterizeGlyph()?”
optionalrasterizeGlyph(request):PlatformGlyph|null
Defined in: platform/types.ts:399
Rasterize one glyph through the OS text stack, for a platform with no 2D canvas to draw it on. Synchronous: the dynamic glyph atlas fills cells during the frame it needs them.
Optional — a platform that has createCanvas omits it and the atlas
uses the Canvas2D rasterizer (web, WeChat). Native implements it (the
embedded-Dawn host has no DOM), and null means the font or the glyph was
unavailable, which the atlas treats as “no cell” exactly as it does a
canvas miss.
Parameters
Section titled “Parameters”request
Section titled “request”PlatformGlyphRequest
Returns
Section titled “Returns”PlatformGlyph | null
readCacheFile()?
Section titled “readCacheFile()?”
optionalreadCacheFile(key):Promise<ArrayBuffer|null>
Defined in: platform/types.ts:455
Persistent content-addressed byte cache — the offline/disk primitive behind
hot-update. key is an immutable content-addressed url (the asset’s <hash>.<ext>
CDN url), so an entry NEVER goes stale and needs no invalidation. Hot-update
writes each verified downloaded asset here; the http backend reads it first so
updated assets stay available offline and skip the CDN roundtrip.
Optional — a platform with no local storage (web relies on the browser HTTP
cache) omits BOTH; then platformReadCacheFile returns null (a miss → normal
fetch) and platformWriteCacheFile is a no-op. Node (fs) and native (the shell’s
on-disk store) implement them; WeChat may later back them with wx user storage.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<ArrayBuffer | null>
readFile()
Section titled “readFile()”readFile(
path):Promise<ArrayBuffer>
Defined in: platform/types.ts:373
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<ArrayBuffer>
readTextFile()
Section titled “readTextFile()”readTextFile(
path):Promise<string>
Defined in: platform/types.ts:375
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<string>
removeStorageItem()
Section titled “removeStorageItem()”removeStorageItem(
key):void
Defined in: platform/types.ts:484
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
setStorageItem()
Section titled “setStorageItem()”setStorageItem(
key,value):void
Defined in: platform/types.ts:483
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”void
unbindInputEvents()?
Section titled “unbindInputEvents()?”
optionalunbindInputEvents():void
Defined in: platform/types.ts:416
Tear down the listeners bindInputEvents registered. Optional — a headless host that never binds input (node) omits it.
Returns
Section titled “Returns”void
writeCacheFile()?
Section titled “writeCacheFile()?”
optionalwriteCacheFile(key,bytes):Promise<void>
Defined in: platform/types.ts:456
Parameters
Section titled “Parameters”string
ArrayBuffer
Returns
Section titled “Returns”Promise<void>