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

@ -1394,7 +1394,7 @@ var doric = (function (exports) {
}
function jsObtainEntry(contextId) {
var context = jsObtainContext(contextId);
return function (constructor) {
var exportFunc = function (constructor) {
var ret = /** @class */ (function (_super) {
__extends(class_1, _super);
function class_1() {
@ -1409,6 +1409,14 @@ var doric = (function (exports) {
}
return ret;
};
return function (args) {
if (args instanceof Array) {
return exportFunc;
}
else {
return exportFunc(args);
}
};
}
var global$1 = Function('return this')();
var __timerId__ = 0;

View File

@ -1395,7 +1395,7 @@ var doric = (function (exports) {
}
function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId);
return (constructor) => {
const exportFunc = (constructor) => {
const ret = class extends constructor {
constructor() {
super(...arguments);
@ -1407,6 +1407,14 @@ var doric = (function (exports) {
}
return ret;
};
return (args) => {
if (args instanceof Array) {
return exportFunc;
}
else {
return exportFunc(args);
}
};
}
const global$1 = Function('return this')();
let __timerId__ = 0;

View File

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

103
doric-js/index.d.ts vendored
View File

@ -10,6 +10,8 @@ declare module 'doric' {
}
declare module 'doric/lib/src/runtime/global' {
import { Panel } from "doric/lib/src/ui/panel";
import { ClassType } from "doric/lib/src/pattern/mvvm";
export type BridgeContext = {
/**
* The identify of current context
@ -60,9 +62,8 @@ declare module 'doric/lib/src/runtime/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 {};
}
@ -118,6 +119,54 @@ declare module 'doric/lib/src/pattern/index.pattern' {
export * from 'doric/lib/src/pattern/mvvm';
}
declare module 'doric/lib/src/ui/panel' {
import { View, Group } from "doric/lib/src/ui/view";
import { Root } from 'doric/lib/src/widget/layouts';
import { BridgeContext } from 'doric/lib/src/runtime/global';
export function NativeCall(target: Panel, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
export abstract class Panel {
context: BridgeContext;
onCreate(): void;
onDestroy(): void;
onShow(): void;
onHidden(): void;
abstract build(rootView: Group): void;
addHeadView(type: string, v: View): void;
allHeadViews(): IterableIterator<Map<string, View>>;
removeHeadView(type: string, v: View | string): void;
clearHeadViews(type: string): void;
getRootView(): Root;
getInitData(): object | undefined;
addOnRenderFinishedCallback(cb: () => void): void;
}
}
declare module 'doric/lib/src/pattern/mvvm' {
import { Group } from "doric/lib/src/ui/view";
import { Panel } from "doric/lib/src/ui/panel";
export abstract class ViewHolder {
abstract build(root: Group): void;
}
export type Setter<M> = (state: M) => void;
export abstract class ViewModel<M extends Object, V extends ViewHolder> {
constructor(obj: M, v: V);
getState(): M;
getViewHolder(): V;
updateState(setter: Setter<M>): void;
attach(view: Group): void;
abstract onAttached(state: M, vh: V): void;
abstract onBind(state: M, vh: V): void;
}
export type ClassType<T> = new (...args: any) => T;
export abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
abstract getViewModelClass(): ClassType<ViewModel<M, V>>;
abstract getState(): M;
abstract getViewHolderClass(): ClassType<V>;
getViewModel(): ViewModel<M, V> | undefined;
build(root: Group): void;
}
}
declare module 'doric/lib/src/ui/view' {
import { Color, GradientColor } from "doric/lib/src/util/color";
import { Modeling, Model } from "doric/lib/src/util/types";
@ -263,28 +312,6 @@ declare module 'doric/lib/src/ui/view' {
}
}
declare module 'doric/lib/src/ui/panel' {
import { View, Group } from "doric/lib/src/ui/view";
import { Root } from 'doric/lib/src/widget/layouts';
import { BridgeContext } from 'doric/lib/src/runtime/global';
export function NativeCall(target: Panel, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
export abstract class Panel {
context: BridgeContext;
onCreate(): void;
onDestroy(): void;
onShow(): void;
onHidden(): void;
abstract build(rootView: Group): void;
addHeadView(type: string, v: View): void;
allHeadViews(): IterableIterator<Map<string, View>>;
removeHeadView(type: string, v: View | string): void;
clearHeadViews(type: string): void;
getRootView(): Root;
getInitData(): object | undefined;
addOnRenderFinishedCallback(cb: () => void): void;
}
}
declare module 'doric/lib/src/ui/animation' {
import { Modeling, Model } from "doric/lib/src/util/types";
export type AnimatedKey = "translationX" | "translationY" | "scaleX" | "scaleY" | "rotation" | "pivotX" | "pivotY" | "rotationX" | "rotationY";
@ -1323,32 +1350,6 @@ declare module 'doric/lib/src/pattern/provider' {
}
}
declare module 'doric/lib/src/pattern/mvvm' {
import { Group } from "doric/lib/src/ui/view";
import { Panel } from "doric/lib/src/ui/panel";
export abstract class ViewHolder {
abstract build(root: Group): void;
}
export type Setter<M> = (state: M) => void;
export abstract class ViewModel<M extends Object, V extends ViewHolder> {
constructor(obj: M, v: V);
getState(): M;
getViewHolder(): V;
updateState(setter: Setter<M>): void;
attach(view: Group): void;
abstract onAttached(state: M, vh: V): void;
abstract onBind(state: M, vh: V): void;
}
export type ClassType<T> = new (...args: any) => T;
export abstract class VMPanel<M extends Object, V extends ViewHolder> extends Panel {
abstract getViewModelClass(): ClassType<ViewModel<M, V>>;
abstract getState(): M;
abstract getViewHolderClass(): ClassType<V>;
getViewModel(): ViewModel<M, V> | undefined;
build(root: Group): void;
}
}
declare module '*.png' {
const value: any;
export default value;

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;

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