Module: miot/Package

扩展程序包参数, 主要来自于packageInfo.json 的配置与系统本身的特性

Example
import {Package} from 'miot'
 import Package from 'miot/Package'

     Package.entrance
     Package.entryInfo
     Package.exitInfo={...}

    Package.pluginID
    Package.packageID
    Package.packageName
    Package.version
    Package.minApiLevel
    Package.buildType
    Package.isDebug
    Package.models

    Package.entry(App, ()=>{...});
    Package.exit({...});

Namespaces

Entrance
PackageEvent

Members

(static, constant) buildType :string

发布类型, debug | release

(static, constant) entrance :Entrance

入口类型,Main or Scene or 用户自定义(Host.ui.openPluginPage(did, pageName, pageParams) 中 pageName的值)

(static, constant) entryInfo :json

打开rn插件时,从native传递到RN的初始化数据信息

(static) exitInfo :json

退出后返回给调用者的信息, 例如自定义场景

Example
//自定义trigger场景保存退出 finishCustomSceneSetupWithTrigger
var trigger = Package.entryInfo;
trigger.payload = { 'xxx': 'xxx' };//trigger payload 数据
Package.exitInfo = trigger;

//自定义action场景保存退出 finishCustomSceneSetupWithAction
var action = Package.entryInfo;
action.payload = { 'xxx': 'xxx' };//action payload 数据
Package.exitInfo = action;
...
Package.exit();

(static, constant) isDebug :boolean

判断是否是调试版本

(static, constant) minApiLevel :int

扩展程序适用的最低 API level, 来自于project.json 的 min_api_level

(static, constant) models :string

适配的固件 model, 来自于@link packageInfo.json 的

(static, constant) packageID :int

小米开放平台生成的插件包 ID

(static, constant) packageName :string

程序包名, 来自于project.json 的 package_name

(static, constant) pageParams :object

入口类型参数, Host.ui.openPluginPage(did, pageName, pageParams) 中 pageParams的值

(static, constant) version :string

程序包的版本号, 来自于project.json 的 version

(inner, constant) EVENT_TYPE :number

JS端通知Native端的事件类型

Properties:
Name Type Description
NAVIGATION_STATE_CHANGE number

插件路由发生变化

(inner, constant) extra :Object

entryInfo={entrance:scene|main,info:{json}}

Methods

(static) entry(RootComponent, afterPackageEntry)

系统入口

Parameters:
Name Type Description
RootComponent React.Component

入口的React Component模块

afterPackageEntry function

进入后, RootComponent 加载之前执行, 缺省为空

Example
import SceneMain from '...';
import App from '...';

import {Package, Entrance} from 'miot';

switch(Package.entrance){
  case Entrance.Scene:
     Package.entry(SceneMain, ()=>{...});
     break;
  default:
     Package.entry(App, ()=>{...});
     break;
}

(static) exit(info)

强制退出插件

Parameters:
Name Type Description
info *

如果不为空, 则等同于设置 Package.exitInfo

Examples
Package.exit({...});
Package.exitInfo = {...}
 Package.exit();

(inner) onPluginEvent(type, data)

在插件端发生某些事件,通知native端

Parameters:
Name Type Description
type number

事件类型

data object

传入native的数据