Entry add exports defination
This commit is contained in:
@@ -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 { }
|
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user