Skip to main content

Overview

@morjs/runtime-web enables mini-programs written with Alipay or WeChat DSL to run in a standard web browser. It provides:
  • A web-compatible implementation of the mini-program API surface (my.*).
  • React-based implementations of built-in mini-program UI components.
  • A client-side router that emulates the mini-program page stack.
  • A DSL runtime that bridges AXML template semantics to React.
PropertyValue
Package@morjs/runtime-web
RendererReact

Installation

npm install @morjs/runtime-web

Exports

@morjs/runtime-web re-exports everything from four sub-modules:
export * from './api'
export * from './components'
export * from './router'
export * from './runtime'

API layer (./api)

Implements the Alipay my.* API surface for the browser. APIs are installed globally via appendApis.

Supported API categories

Storage

getStorage, setStorage, removeStorage, clearStorage and their sync variants.

Network

request, uploadFile, downloadFile.

Routing

navigateTo, redirectTo, navigateBack, switchTab, reLaunch.

UI / Interactive

showToast, hideToast, showLoading, hideLoading, showModal, showActionSheet, alert, confirm, prompt.

Device

getSystemInfo, getSystemInfoSync, getNetworkType, makePhoneCall.

Clipboard

getClipboardData, setClipboardData.

Location

getLocation, chooseLocation.

Image

chooseImage, previewImage, saveImageToPhotosAlbum.

Audio / Video

createInnerAudioContext, chooseVideo.

File

saveFile, getFileInfo, getSavedFileList, removeSavedFile, openDocument.

Keyboard

hideKeyboard, getSelectedTextRange.

Element Query

createSelectorQuery, createIntersectionObserver.

Tab Bar

showTabBar, hideTabBar, setTabBarItem, setTabBarStyle.

Canvas

createCanvasContext, canvasToTempFilePath.

Animation

createAnimation.

Map

createMapContext.

Exported symbols

SymbolDescription
default (named my)The global mini-program API object
appendApisAdd additional APIs to my without conflict
MobileDetectRe-exported mobile-detect instance for device detection
IntersectionObserverRe-exported intersection-observer polyfill

Components layer (./components)

Provides React Web Component implementations for native mini-program UI components registered as custom elements.

Base components

ComponentDescription
viewBasic block container
scroll-viewScrollable container with pull-down and bottom-reach events
swiper / swiper-itemCarousel / slideshow
movable-area / movable-viewDrag-and-drop container
textInline text
rich-textHTML-rich text renderer
iconMini-program icon set
progressProgress bar
navigatorDeclarative page navigation link
tabbar / tabbar-itemBottom tab bar

Open / extended components

Additional UI APIs registered via appendApis:
APIDescription
chooseCityCity picker modal
datePickerDate and time picker
optionSelectSingle/multi-option selector
multiLevelSelectCascading selector
canvas (UI)Canvas API bridge
map (UI)Map component bridge

Router (./router)

Implements a history-based client-side router that mirrors the mini-program page stack model.
SymbolDescription
routerSingleton router instance
pageStackObservable page stack
tabbar (router)Tab bar state management
historyUnderlying browser history wrapper
domDOM utilities used by the router
cachePage component cache
apiRoute API helpers (navigateTo, etc.)

Runtime (./runtime)

DSL execution engine that bridges AXML template semantics to React.
SymbolDescription
ComponentWeb component base class used by compiled components
PageWeb page base class used by compiled pages
createTemplateManagerFactory for TemplateManager instances (AXML <template> support)
SlotReact component implementing AXML <slot>
BlockReact component implementing AXML <block>
createStyleConverts inline style strings/objects for React
getEventResolves an AXML event name to a React event handler
bindThisBinds a method to its component instance
registEventsRegisters AXML event handlers on a component
refAXML ref binding helper
mergeConfigMerges global app config with page-level config
toJsonStringSerialises a value to a JSON string attribute
getStringRenders content to a string or React element
getForValueNormalises values for AXML a:for iteration
axmlApiSpecial API object available inside AXML expressions
setRootFontSizeForRemManually sets the root font-size for rpx conversion
autoSyncRootFontSizeAutomatically keeps root font-size in sync with viewport

Build docs developers (and LLMs) love