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()
}

View File

@ -3664,7 +3664,7 @@ return __module.exports;
},this,[{exports:{}}])]);
/**--------Lib--------*/
(function (axios, sandbox) {
var doric_web = (function (exports, axios, sandbox) {
'use strict';
axios = axios && axios.hasOwnProperty('default') ? axios['default'] : axios;
@ -3698,12 +3698,11 @@ return __module.exports;
}
}
var LayoutSpec;
(function (LayoutSpec) {
LayoutSpec[LayoutSpec["EXACTLY"] = 0] = "EXACTLY";
LayoutSpec[LayoutSpec["WRAP_CONTENT"] = 1] = "WRAP_CONTENT";
LayoutSpec[LayoutSpec["AT_MOST"] = 2] = "AT_MOST";
})(LayoutSpec || (LayoutSpec = {}));
})(exports.LayoutSpec || (exports.LayoutSpec = {}));
const SPECIFIED = 1;
const START = 1 << 1;
const END = 1 << 2;
@ -3715,6 +3714,7 @@ return __module.exports;
const BOTTOM = (END | SPECIFIED) << SHIFT_Y;
const CENTER_X = SPECIFIED << SHIFT_X;
const CENTER_Y = SPECIFIED << SHIFT_Y;
const CENTER = CENTER_X | CENTER_Y;
function toPixelString(v) {
return `${v}px`;
}
@ -3737,8 +3737,8 @@ return __module.exports;
this.viewId = "";
this.viewType = "View";
this.layoutConfig = {
widthSpec: LayoutSpec.EXACTLY,
heightSpec: LayoutSpec.EXACTLY,
widthSpec: exports.LayoutSpec.EXACTLY,
heightSpec: exports.LayoutSpec.EXACTLY,
alignment: 0,
weight: 0,
margin: {
@ -3804,13 +3804,13 @@ return __module.exports;
}
configWidth() {
switch (this.layoutConfig.widthSpec) {
case LayoutSpec.WRAP_CONTENT:
case exports.LayoutSpec.WRAP_CONTENT:
this.view.style.width = "max-content";
break;
case LayoutSpec.AT_MOST:
case exports.LayoutSpec.AT_MOST:
this.view.style.width = "100%";
break;
case LayoutSpec.EXACTLY:
case exports.LayoutSpec.EXACTLY:
default:
this.view.style.width = toPixelString(this.frameWidth
- this.paddingLeft - this.paddingRight
@ -3820,13 +3820,13 @@ return __module.exports;
}
configHeight() {
switch (this.layoutConfig.heightSpec) {
case LayoutSpec.WRAP_CONTENT:
case exports.LayoutSpec.WRAP_CONTENT:
this.view.style.height = "max-content";
break;
case LayoutSpec.AT_MOST:
case exports.LayoutSpec.AT_MOST:
this.view.style.height = "100%";
break;
case LayoutSpec.EXACTLY:
case exports.LayoutSpec.EXACTLY:
default:
this.view.style.height = toPixelString(this.frameHeight
- this.paddingTop - this.paddingBottom
@ -4135,13 +4135,13 @@ return __module.exports;
});
}
configSize() {
if (this.layoutConfig.widthSpec === LayoutSpec.WRAP_CONTENT) {
if (this.layoutConfig.widthSpec === exports.LayoutSpec.WRAP_CONTENT) {
const width = this.childNodes.reduce((prev, current) => {
return Math.max(prev, current.view.offsetWidth);
}, 0);
this.view.style.width = toPixelString(width);
}
if (this.layoutConfig.heightSpec === LayoutSpec.WRAP_CONTENT) {
if (this.layoutConfig.heightSpec === exports.LayoutSpec.WRAP_CONTENT) {
const height = this.childNodes.reduce((prev, current) => {
return Math.max(prev, current.view.offsetHeight);
}, 0);
@ -4762,6 +4762,9 @@ return __module.exports;
function acquireJSBundle(name) {
return bundles.get(name);
}
function registerJSBundle(name, bundle) {
bundles.set(name, bundle);
}
function registerPlugin(name, plugin) {
plugins.set(name, plugin);
}
@ -4978,9 +4981,14 @@ ${content}
}
connectedCallback() {
if (this.src && this.context === undefined) {
axios.get(this.src).then(result => {
this.load(result.data);
});
if (this.src.startsWith("http")) {
axios.get(this.src).then(result => {
this.load(result.data);
});
}
else {
this.load(this.src);
}
}
}
disconnectedCallback() {
@ -5046,5 +5054,33 @@ ${content}
window.customElements.define('doric-div', DoricElement);
window.customElements.define('doric-navigation', NavigationElement);
}(axios, doric));
exports.BOTTOM = BOTTOM;
exports.CENTER = CENTER;
exports.CENTER_X = CENTER_X;
exports.CENTER_Y = CENTER_Y;
exports.DoricElement = DoricElement;
exports.DoricGroupViewNode = DoricGroupViewNode;
exports.DoricPlugin = DoricPlugin;
exports.DoricSuperNode = DoricSuperNode;
exports.DoricViewNode = DoricViewNode;
exports.LEFT = LEFT;
exports.NavigationElement = NavigationElement;
exports.RIGHT = RIGHT;
exports.TOP = TOP;
exports.acquireJSBundle = acquireJSBundle;
exports.acquirePlugin = acquirePlugin;
exports.acquireViewNode = acquireViewNode;
exports.createContext = createContext;
exports.destroyContext = destroyContext;
exports.injectGlobalObject = injectGlobalObject;
exports.loadJS = loadJS;
exports.registerJSBundle = registerJSBundle;
exports.registerPlugin = registerPlugin;
exports.registerViewNode = registerViewNode;
exports.toPixelString = toPixelString;
exports.toRGBAString = toRGBAString;
return exports;
}({}, axios, doric));
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,10 @@
import { DoricElement } from './src/DoricElement'
import { NavigationElement } from './src/navigate/NavigationElement'
window.customElements.define('doric-div', DoricElement);
window.customElements.define('doric-navigation', NavigationElement);
window.customElements.define('doric-navigation', NavigationElement);
export * from './src/DoricElement'
export * from './src/navigate/NavigationElement'
export * from './src/DoricPlugin'
export * from './src/DoricRegistry'
export * from './src/DoricDriver'
export * from './src/shader/DoricViewNode'

View File

@ -1,6 +1,6 @@
{
"name": "doric-web",
"version": "0.1.0",
"version": "0.1.1",
"description": "Doric library for Web",
"main": "build/index.js",
"scripts": {
@ -26,4 +26,4 @@
"@rollup/plugin-node-resolve": "^6.0.0",
"typescript": "^3.7.4"
}
}
}

View File

@ -26,7 +26,7 @@ export default {
input: `build/index.js`,
output: {
format: "iife",
name: "index",
name: "doric_web",
file: `dist/index.js`,
sourcemap: true,
banner: builtinScript,

View File

@ -23,9 +23,13 @@ export class DoricElement extends HTMLElement {
connectedCallback() {
if (this.src && this.context === undefined) {
axios.get<string>(this.src).then(result => {
this.load(result.data)
})
if (this.src.startsWith("http")) {
axios.get<string>(this.src).then(result => {
this.load(result.data)
})
} else {
this.load(this.src)
}
}
}