This page documents the runtime plugin API (
@morjs/core). For the build-time framework plugin API used with Takin, see the Takin package reference.Functions
createPlugin
Creates a MorJS mini-program plugin object. The returned object handles two-way communication between the plugin mini-program and its host.
The platform
getApp function available inside the plugin. MorJS uses it to access the plugin’s own app instance and inject host events.Any additional properties are spread onto the returned plugin object.
aPlugin
Alias for createPlugin. Use when your plugin source DSL is Alipay.
wPlugin
Alias for createPlugin. Use when your plugin source DSL is WeChat.
PageToComponent
Converts a page options object into a component options object. Useful for rendering a page inside another page or component.
The page configuration to convert.
DSL source type (
SOURCE_TYPE.ALIPAY or SOURCE_TYPE.WECHAT).Component enhancement feature flags.
invokeComponentHooks defaults to false when using PageToComponent.Enhanced component options ready to pass to
Component().| Page lifetime | Component lifetime (Alipay) | Component lifetime (WeChat) |
|---|---|---|
onLoad | onInit | attached |
onReady | didMount | ready |
onUnload | didUnmount | detached |
onShow | pageLifetimes.show | pageLifetimes.show |
onHide | pageLifetimes.hide | pageLifetimes.hide |
onResize | pageLifetimes.resize | pageLifetimes.resize |
aPageToComponent
Converts an Alipay-style page into component options.
wPageToComponent
Converts a WeChat-style page into component options.
init
Initialises the MorJS runtime by loading solutions and returning the resulting hooks and plugin names. Called internally by createApp but can also be called manually in environments without a native App() constructor.
One or more runtime solutions to load.
The initialised hooks instance used by App, Page, and Component.
Names of all plugins that were loaded.
Types
CreateMorPluginResult
The plugin’s own event emitter (the
$event from the plugin’s app instance), set at creation time if the plugin app already has $event.The host mini-program’s event emitter. Set when
internalInit is called by the host.Marker flag that identifies this object as a MorJS plugin.
Reference to the platform
getApp function scoped to the plugin.Called by the host mini-program to inject its
$event emitter into the plugin. Sets $hostEvent on both the plugin object and the plugin’s app instance.Called by the host to inject capabilities into the plugin. Properties in
extend are merged onto app.$host.