Skip to main content

Overview

@morjs/core is the runtime foundation of every MorJS mini-program. It wraps the native App(), Page(), and Component() constructors with a unified hook and adapter system so that plugins and cross-platform logic can intercept every lifecycle event.
PropertyValue
Package@morjs/core
Version1.0.86
LicenseISC
Node>= 12.13.0
Module formatsCommonJS (lib/), ES modules (esm/)

Installation

npm install @morjs/core

Exports

All public symbols exported from @morjs/core:

App

ExportTypeDescription
createAppfunctionRegister an app with the MorJS runtime
aAppfunctionAlias of createApp for Alipay DSL
wAppfunctionAlias of createApp for WeChat DSL
registerAppAdaptersfunctionRegister app-level platform adapters
MorAppInstanceinterfaceShape of the extended app instance ($morHooks, $event, $context, $morPluginsNames)
GetAppFunctiontypeExtended getApp return type

Page

ExportTypeDescription
createPagefunctionRegister a page with the MorJS runtime
aPagefunctionAlipay-style page registration
wPagefunctionWeChat-style page registration
enhancePagefunctionApply MorJS enhancements without registering
registerPageAdaptersfunctionRegister page-level platform adapters
MorPageAdapterinterfacePage adapter interface

Component

ExportTypeDescription
createComponentfunctionRegister a component with the MorJS runtime
aComponentfunctionAlipay-style component registration
wComponentfunctionWeChat-style component registration
enhanceComponentfunctionApply MorJS enhancements without registering
registerComponentAdaptersfunctionRegister component-level platform adapters
MorComponentAdapterinterfaceComponent adapter interface

Plugin & utilities

ExportTypeDescription
createPluginfunctionCreate a mini-program plugin object
aPluginfunctionAlias of createPlugin for Alipay
wPluginfunctionAlias of createPlugin for WeChat
PageToComponentfunctionConvert page options to component options
aPageToComponentfunctionAlipay-style PageToComponent
wPageToComponentfunctionWeChat-style PageToComponent
initfunctionInitialise the MorJS runtime (hooks + plugins)

Quick start

import { createApp } from '@morjs/core'

createApp({
  globalData: {},
  onLaunch(options) {
    console.log('launch', options)
  }
})

Peer dependencies

PackageVersion
@morjs/api1.0.69
mini-types^0.1.7
miniprogram-api-typings^3.4.4
tslib^2.3.1

See also

Build docs developers (and LLMs) love