Entry add exports defination
This commit is contained in:
7
doric-js/lib/src/runtime/global.d.ts
vendored
7
doric-js/lib/src/runtime/global.d.ts
vendored
@@ -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 {};
|
||||
|
12
doric-js/lib/src/runtime/sandbox.d.ts
vendored
12
doric-js/lib/src/runtime/sandbox.d.ts
vendored
@@ -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 {};
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user