Entry add exports defination

This commit is contained in:
pengfei.zhou
2020-09-04 17:05:51 +08:00
committed by osborn
parent f14017281e
commit a211ac8acb
10 changed files with 126 additions and 65 deletions

View File

@@ -1,3 +1,5 @@
import { Panel } from "../ui/panel";
import { ClassType } from "../pattern/mvvm";
export declare type BridgeContext = {
/**
* The identify of current context
@@ -48,8 +50,7 @@ declare global {
deviceModel: string;
[index: string]: number | string | boolean | object | undefined;
};
function Entry(constructor: {
new (...args: any[]): {};
}): any;
function Entry(constructor: ClassType<Panel>): void;
function Entry(exports: ClassType<Panel>[]): (constructor: ClassType<Panel>) => void;
}
export {};

View File

@@ -21,9 +21,15 @@ export declare function jsReleaseContext(id: string): void;
export declare function __require__(name: string): any;
export declare function jsRegisterModule(name: string, moduleObject: any): void;
export declare function jsCallEntityMethod(contextId: string, methodName: string, args?: any): any;
export declare function jsObtainEntry(contextId: string): <T extends new (...args: any[]) => {}>(constructor: T) => {
new (...args: any[]): {
declare type ClassType<T> = new (...args: any) => T;
export declare function jsObtainEntry(contextId: string): (args: ClassType<object> | ClassType<object>[]) => ((constructor: ClassType<object>) => {
new (...args: any): {
context: Context | undefined;
};
} & T;
}) | {
new (...args: any): {
context: Context | undefined;
};
};
export declare function jsCallbackTimer(timerId: number): void;
export {};

View File

@@ -213,7 +213,7 @@ export function jsCallEntityMethod(contextId, methodName, args) {
}
export function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId);
return (constructor) => {
const exportFunc = (constructor) => {
const ret = class extends constructor {
constructor() {
super(...arguments);
@@ -225,6 +225,14 @@ export function jsObtainEntry(contextId) {
}
return ret;
};
return (args) => {
if (args instanceof Array) {
return exportFunc;
}
else {
return exportFunc(args);
}
};
}
const global = Function('return this')();
let __timerId__ = 0;