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,6 @@
import { Panel } from "../ui/panel"
import { ClassType } from "../pattern/mvvm"
/*
* Copyright [2019] [Doric.Pub]
*
@@ -74,6 +77,9 @@ 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

@@ -233,10 +233,11 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
}
}
type ClassType<T> = new (...args: any) => T
export function jsObtainEntry(contextId: string) {
const context = jsObtainContext(contextId)
return <T extends { new(...args: any[]): {} }>(constructor: T) => {
const exportFunc = (constructor: ClassType<object>) => {
const ret = class extends constructor {
context = context
}
@@ -245,6 +246,13 @@ export function jsObtainEntry(contextId: string) {
}
return ret
}
return (args: ClassType<object> | ClassType<object>[]) => {
if (args instanceof Array) {
return exportFunc
} else {
return exportFunc(args)
}
}
}

View File

@@ -260,10 +260,11 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
}
}
type ClassType<T> = new (...args: any) => T
export function jsObtainEntry(contextId: string) {
const context = jsObtainContext(contextId)
return <T extends { new(...args: any[]): {} }>(constructor: T) => {
const exportFunc = (constructor: ClassType<object>) => {
const ret = class extends constructor {
context = context
}
@@ -272,9 +273,15 @@ export function jsObtainEntry(contextId: string) {
}
return ret
}
return (args: ClassType<object> | ClassType<object>[]) => {
if (args instanceof Array) {
return exportFunc
} else {
return exportFunc(args)
}
}
}
const global = Function('return this')()
let __timerId__ = 0