WeSDK - The SDK Noone Asked For

API: Runtime and Capabilities

This section documents the APIs that help you safely detect runtime constraints.

getRuntimeInfo()

Returns bridge/runtime metadata immediately.

Signature

getRuntimeInfo(): RuntimeInfo

Response

{
  hasBridge: boolean;
  bridgeName: string | null;
  bridgeCandidates: string[];
  readyEvents: string[];
  isMiniProgramUA: boolean;
  userAgent: string;
}

Example

const info = sdk.getRuntimeInfo();
if (!info.hasBridge) {
	console.log("No native bridge available", info);
}

getCapabilities(options?)

Checks support for one or more APIs.

Signature

getCapabilities(options?: { jsApiList?: string[] }): Promise<CapabilitiesResult>

Behavior

Response

{
	errMsg: string;
	checkResult: Record<string, boolean>;
	details: Record<string, { supported: boolean; reason: string }>;
	runtime: RuntimeInfo;
}

Example

const caps = await sdk.getCapabilities({
	jsApiList: ["scanCode", "chooseImage", "startRecord"],
});

for (const name of Object.keys(caps.checkResult)) {
	if (!caps.checkResult[name]) {
		console.warn(name, caps.details[name].reason);
	}
}

isApiSupported(apiName)

Fast boolean helper for single API checks.

Signature

isApiSupported(apiName: string): Promise<boolean>

Example

if (await sdk.isApiSupported("getLocation")) {
	const loc = await sdk.getLocation();
	renderLocation(loc);
} else {
	renderManualLocationInput();
}

checkJsApi(options?)

Compatibility-facing capability call.

Signature

checkJsApi(options?: { jsApiList?: string[]; success?; fail?; complete? }): Promise<CallbackPayload>

Notes

Capability Reason Semantics

Migration Notes

Legacy capability checks only provided boolean maps and weak context.

v2 adds reasoned results and runtime metadata so feature gating can be explicit.