update js

This commit is contained in:
pengfei.zhou
2020-01-03 16:35:04 +08:00
committed by osborn
parent 4b3a370f5f
commit 680b95f05d
18 changed files with 124 additions and 141 deletions

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

@@ -140,6 +140,13 @@ declare module 'doric/lib/src/ui/view' {
*/
rotation?: number;
}
export type NativeViewModel = {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
export abstract class View implements Modeling, IView {
width: number;
height: number;
@@ -193,24 +200,12 @@ declare module 'doric/lib/src/ui/view' {
get dirtyProps(): {
[index: string]: Model;
};
nativeViewModel: {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
nativeViewModel: NativeViewModel;
onPropertyChanged(propKey: string, oldV: Model, newV: Model): void;
clean(): void;
isDirty(): boolean;
responseCallback(id: string, ...args: any): any;
toModel(): {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
toModel(): NativeViewModel;
let(block: (it: this) => void): void;
also(block: (it: this) => void): this;
apply(config: IView): this;
@@ -238,13 +233,7 @@ declare module 'doric/lib/src/ui/view' {
abstract allSubviews(): Iterable<View>;
isDirty(): boolean;
clean(): void;
toModel(): {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
toModel(): NativeViewModel;
}
export abstract class Group extends Superview {
readonly children: View[];
@@ -481,7 +470,7 @@ declare module 'doric/lib/src/widget/image' {
}
declare module 'doric/lib/src/widget/list' {
import { View, Superview, IView } from "doric/lib/src/ui/view";
import { View, Superview, IView, NativeViewModel } from "doric/lib/src/ui/view";
import { Stack } from "doric/lib/src/widget/layouts";
export class ListItem extends Stack {
/**
@@ -504,13 +493,7 @@ declare module 'doric/lib/src/widget/list' {
loadMoreView?: ListItem;
reset(): void;
isDirty(): boolean;
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../..").Model;
};
};
toModel(): NativeViewModel;
}
export function list(config: IList): List;
export function listItem(item: View): ListItem;
@@ -547,7 +530,7 @@ declare module 'doric/lib/src/widget/slider' {
}
declare module 'doric/lib/src/widget/scroller' {
import { Superview, View, IView } from 'doric/lib/src/ui/view';
import { Superview, View, IView, NativeViewModel } from 'doric/lib/src/ui/view';
export function scroller(content: View): Scroller;
export interface IScroller extends IView {
content: View;
@@ -555,18 +538,12 @@ declare module 'doric/lib/src/widget/scroller' {
export class Scroller extends Superview implements IScroller {
content: View;
allSubviews(): View[];
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../..").Model;
};
};
toModel(): NativeViewModel;
}
}
declare module 'doric/lib/src/widget/refreshable' {
import { View, Superview, IView } from "doric/lib/src/ui/view";
import { View, Superview, IView, NativeViewModel } from "doric/lib/src/ui/view";
import { List } from "doric/lib/src/widget/list";
import { Scroller } from "doric/lib/src/widget/scroller";
import { BridgeContext } from "doric/lib/src/runtime/global";
@@ -584,13 +561,7 @@ declare module 'doric/lib/src/widget/refreshable' {
setRefreshing(context: BridgeContext, refreshing: boolean): Promise<any>;
isRefreshable(context: BridgeContext): Promise<boolean>;
isRefreshing(context: BridgeContext): Promise<boolean>;
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../..").Model;
};
};
toModel(): NativeViewModel;
}
export function refreshable(config: IRefreshable): Refreshable;
export interface IPullable {
@@ -603,7 +574,7 @@ declare module 'doric/lib/src/widget/refreshable' {
declare module 'doric/lib/src/widget/flowlayout' {
import { Stack } from 'doric/lib/src/widget/layouts';
import { IView, Superview, View } from 'doric/lib/src/ui/view';
import { IView, Superview, View, NativeViewModel } from 'doric/lib/src/ui/view';
export class FlowLayoutItem extends Stack {
/**
* Set to reuse native view
@@ -631,13 +602,7 @@ declare module 'doric/lib/src/widget/flowlayout' {
loadMoreView?: FlowLayoutItem;
reset(): void;
isDirty(): boolean;
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../util/types").Model;
};
};
toModel(): NativeViewModel;
}
export function flowlayout(config: IFlowLayout): FlowLayout;
export function flowItem(item: View): FlowLayoutItem;

View File

@@ -57,6 +57,13 @@ export interface IView {
*/
rotation?: number;
}
export declare type NativeViewModel = {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
export declare abstract class View implements Modeling, IView {
width: number;
height: number;
@@ -114,24 +121,12 @@ export declare abstract class View implements Modeling, IView {
get dirtyProps(): {
[index: string]: Model;
};
nativeViewModel: {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
nativeViewModel: NativeViewModel;
onPropertyChanged(propKey: string, oldV: Model, newV: Model): void;
clean(): void;
isDirty(): boolean;
responseCallback(id: string, ...args: any): any;
toModel(): {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
toModel(): NativeViewModel;
let(block: (it: this) => void): void;
also(block: (it: this) => void): this;
apply(config: IView): this;
@@ -159,13 +154,7 @@ export declare abstract class Superview extends View {
abstract allSubviews(): Iterable<View>;
isDirty(): boolean;
clean(): void;
toModel(): {
id: string;
type: string;
props: {
[index: string]: Model;
};
};
toModel(): NativeViewModel;
}
export declare abstract class Group extends Superview {
readonly children: View[];

View File

@@ -1,5 +1,5 @@
import { Stack } from './layouts';
import { IView, Superview, View } from '../ui/view';
import { IView, Superview, View, NativeViewModel } from '../ui/view';
export declare class FlowLayoutItem extends Stack {
/**
* Set to reuse native view
@@ -31,13 +31,7 @@ export declare class FlowLayout extends Superview implements IFlowLayout {
private getItem;
isDirty(): boolean;
private renderBunchedItems;
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../util/types").Model;
};
};
toModel(): NativeViewModel;
}
export declare function flowlayout(config: IFlowLayout): FlowLayout;
export declare function flowItem(item: View): FlowLayoutItem;

View File

@@ -1,4 +1,4 @@
import { View, Superview, IView } from "../ui/view";
import { View, Superview, IView, NativeViewModel } from "../ui/view";
import { Stack } from "./layouts";
export declare class ListItem extends Stack {
/**
@@ -25,13 +25,7 @@ export declare class List extends Superview implements IList {
private getItem;
isDirty(): boolean;
private renderBunchedItems;
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../..").Model;
};
};
toModel(): NativeViewModel;
}
export declare function list(config: IList): List;
export declare function listItem(item: View): ListItem;

View File

@@ -1,4 +1,4 @@
import { View, Superview, IView } from "../ui/view";
import { View, Superview, IView, NativeViewModel } from "../ui/view";
import { List } from "./list";
import { Scroller } from "./scroller";
import { BridgeContext } from "../runtime/global";
@@ -16,13 +16,7 @@ export declare class Refreshable extends Superview implements IRefreshable {
setRefreshing(context: BridgeContext, refreshing: boolean): Promise<any>;
isRefreshable(context: BridgeContext): Promise<boolean>;
isRefreshing(context: BridgeContext): Promise<boolean>;
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../..").Model;
};
};
toModel(): NativeViewModel;
}
export declare function refreshable(config: IRefreshable): Refreshable;
export interface IPullable {

View File

@@ -1,4 +1,4 @@
import { Superview, View, IView } from '../ui/view';
import { Superview, View, IView, NativeViewModel } from '../ui/view';
export declare function scroller(content: View): Scroller;
export interface IScroller extends IView {
content: View;
@@ -6,11 +6,5 @@ export interface IScroller extends IView {
export declare class Scroller extends Superview implements IScroller {
content: View;
allSubviews(): View[];
toModel(): {
id: string;
type: string;
props: {
[index: string]: import("../..").Model;
};
};
toModel(): NativeViewModel;
}

View File

@@ -1,6 +1,6 @@
{
"name": "doric",
"version": "0.2.2-alpha.2",
"version": "0.2.2-alpha.3",
"description": "The JS Framework of Doric",
"main": "bundle/doric-vm.js",
"types": "index.d.ts",

View File

@@ -70,6 +70,13 @@ export interface IView {
/**----------transform----------*/
}
export type NativeViewModel = {
id: string;
type: string;
props: {
[index: string]: Model;
};
}
export abstract class View implements Modeling, IView {
@Property
@@ -206,7 +213,7 @@ export abstract class View implements Modeling, IView {
return this.__dirty_props__
}
nativeViewModel = {
nativeViewModel: NativeViewModel = {
id: this.viewId,
type: this.constructor.name,
props: this.__dirty_props__,

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Stack } from './layouts'
import { Property, IView, Superview, View } from '../ui/view'
import { Property, IView, Superview, View, NativeViewModel } from '../ui/view'
import { layoutConfig } from '../util/index.util'
export class FlowLayoutItem extends Stack {
@@ -105,7 +105,7 @@ export class FlowLayout extends Superview implements IFlowLayout {
})
}
toModel() {
toModel(): NativeViewModel {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { View, Property, Superview, IView } from "../ui/view";
import { View, Property, Superview, IView, NativeViewModel } from "../ui/view";
import { Stack } from "./layouts";
import { layoutConfig, LayoutSpec } from "../util/layoutconfig";
@@ -93,7 +93,7 @@ export class List extends Superview implements IList {
})
}
toModel() {
toModel(): NativeViewModel {
if (this.loadMoreView) {
this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId
}

View File

@@ -1,4 +1,4 @@
import { View, Property, Superview, IView } from "../ui/view";
import { View, Property, Superview, IView, NativeViewModel } from "../ui/view";
import { List } from "./list";
import { Scroller } from "./scroller";
import { BridgeContext } from "../runtime/global";
@@ -43,7 +43,7 @@ export class Refreshable extends Superview implements IRefreshable {
return this.nativeChannel(context, 'isRefreshing')() as Promise<boolean>
}
toModel() {
toModel(): NativeViewModel {
this.dirtyProps.content = this.content.viewId
this.dirtyProps.header = ((this.header || {}) as any).viewId
return super.toModel()

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Superview, View, IView } from '../ui/view'
import { Superview, View, IView, NativeViewModel } from '../ui/view'
import { layoutConfig } from '../util/layoutconfig'
export function scroller(content: View) {
@@ -34,7 +34,7 @@ export class Scroller extends Superview implements IScroller {
return [this.content]
}
toModel() {
toModel(): NativeViewModel {
this.dirtyProps.content = this.content.viewId
return super.toModel()
}