Module

@accedo/xdk-core/device

device module The bootstrap part.

Members

# static config

Configuration module

# static extensionManager

ExtensionManager of the detected device

# static platform

Platform name of the detected device

# static system

System of the detected device.

Methods

# async inner detectDevice() → {Promise.<pkgConfig>}

Step 2 An async function that goes through all devices package configs and load their corresponding detection modules. Once all of them are loaded, inspect them and return the first device package config where the detection return a true to the caller.

If all detection module return a false, error will be thrown.

To prevent pre-mature termination of Promise.all, all dynamic import promises are wrapped so that a rejection due to loading failure will simply be considered as device not matched.

Native Promise. When a matching device is found, the pkgConfig of the matching device will be returned in the resolved promise. A rejected promise will be returned if there are any error; a rejected promise will also be returned if no matching devices can be found within the device.packages array.

Promise.<pkgConfig>

# async inner isDeviceMatched(pkgConfig)

Utility function of getCurrentDevicePackageConfig. This is the callback function used when the function getCurrentDevicePackageConfig maps the device.packages array in xdk.config.js to an array of promises, where each promise will resolve to the detection results of the specific devices.

To prevent pre-mature termination of Promise.all in the caller, the promise of the dynamic import of device detection are wrapped such that the error will be logged in device console, but will still resolve to a false to indicate the device package does not match the current device.

Parameters:
Name Type Description
pkgConfig Object

The device package configuration.

detection function

A function that returns the dynamic import promise of detection result of the device.

# async inner mergeConfigurations(pkgConfig) → {Promise.<void>}

An async function that takes the pkgConfig and backfilled the device configuration with the default configuration of the current device. This means any config properties that is already defined in xdk.config.js will not be overridden by those in the default configuration, but anything that is defined in the default config but not in xdk.config.js will be copied across.

A copy of the default config will also be created in the config system.

Parameters:
Name Type Description
pkgConfig Object

The device package configuration.

id String

The XDK device package ID.

Native Promise.

Promise.<void>

# async inner resolveWhenDomIsReady() → {Promise.<void>}

Wrap DOM ready in a promise.

Native Promise. Resolved when DOM is ready.

Promise.<void>

# async inner setupDevicePackage(pkgConfig) → {Promise.<DevicePackage>}

Step 4 An async function that takes the pkgConfig and setup the Device Package instance. When the setup complete successfully, the following device module properties will be updated to reflect the instantiated device package.

  • config
  • extensionManager
  • system
  • storageManager
  • platform

The function will also resolve with the properly set up device package returned.

Parameters:
Name Type Description
pkgConfig Object

The device package configuration.

id String

The XDK device package ID.

Native Promise. instance. The promise will be rejected if there are any error during the import, setup, assignment process.

Promise.<DevicePackage>