miot-dsl
v1.0.1
Published
miot-dsl runtime — DSL-driven RN plugin framework
Downloads
383
Maintainers
Readme
miot-dsl
DSL 驱动的米家 RN 插件框架运行时。
安装
npm install miot-dsl
# peer deps (RN 环境自带)
npm install react react-native
# 用到 SVG 图标时
npm install react-native-svg-uri快速开始
import { App, createTemplate, Layout, Home, Setting, fetchInstanceData, fetchI18nData } from 'miot-dsl';
App({
templates: [/* createTemplate({ name: 'base', modules: [Layout, Home, Setting, ...] }) */],
async getAppData() {
const [instance, i18n] = await Promise.all([fetchInstanceData(), fetchI18nData()]);
return { instance, i18n, config: require('./template.config.json') };
},
});API
顶层 22 个 + 5 个命名空间:
- 入口:
App,FRAMEWORK_VERSION - 声明:
createModule,createTemplate - 内置模块:
Layout,Home,Setting - 资源:
Icon,getIcon,getImage,getColor,getI18n - globalConfig:
getGlobalConfig,getGlobalConfigs - getAppData 依赖:
fetchInstanceData,fetchI18nData - Virtual Props:
generateVirtualProps,proxySpec
命名空间:
Spec— get/getMany/getCached/getCachedMany/set/setMany/setCache/setCacheMany/subscribe/emit/doAction/updateTime/isValidSpecI18n— forSpecs/forValue/valueList/transformUnitInstance— data/version/query/queryOnly/getSpec/lookup/valueList/valueRange/indexOf/descOf/valueOfDescNav— to/push/replace/back/pop/popToTop/reset/current/param/paramsDialog— loading/message/toast/selector/custom/error/tip/hide/has
详见 monorepo 根目录 docs/ 下各 guide。
仓库
本包是 miot.dsl monorepo 的一部分,源码位于 packages/miot-dsl/。
