From 0633c1c19d45434a30dd5b9747a41f7b754f9226 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Sat, 16 May 2020 18:58:32 +0800 Subject: [PATCH] update typescript and remove reflect-metadata lib --- doric-js/bundle/doric-lib.es5.js | 39 +- doric-js/bundle/doric-lib.js | 2273 +++++++++++---------- doric-js/bundle/doric-sandbox.es5.js | 18 +- doric-js/bundle/doric-vm.js | 2273 +++++++++++---------- doric-js/index.d.ts | 31 +- doric-js/lib/index.js | 16 + doric-js/lib/src/native/coordinator.d.ts | 4 +- doric-js/lib/src/native/modal.d.ts | 18 +- doric-js/lib/src/native/notification.d.ts | 6 +- doric-js/lib/src/runtime/global.d.ts | 1 - doric-js/lib/src/ui/panel.js | 396 ++-- doric-js/lib/src/ui/view.js | 512 ++--- doric-js/lib/src/util/color.js | 96 +- doric-js/lib/src/util/flexbox.js | 48 +- doric-js/lib/src/util/gravity.js | 118 +- doric-js/lib/src/widget/draggable.js | 16 +- doric-js/lib/src/widget/flowlayout.js | 196 +- doric-js/lib/src/widget/image.js | 138 +- doric-js/lib/src/widget/input.js | 116 +- doric-js/lib/src/widget/layouts.js | 23 +- doric-js/lib/src/widget/list.js | 187 +- doric-js/lib/src/widget/nestedSlider.js | 32 +- doric-js/lib/src/widget/refreshable.js | 60 +- doric-js/lib/src/widget/scroller.js | 56 +- doric-js/lib/src/widget/slider.js | 130 +- doric-js/lib/src/widget/switch.js | 48 +- doric-js/lib/src/widget/text.js | 120 +- doric-js/package.json | 2 +- doric-js/rollup.config.js | 2 - doric-js/src/runtime/global.ts | 2 - 30 files changed, 3593 insertions(+), 3384 deletions(-) diff --git a/doric-js/bundle/doric-lib.es5.js b/doric-js/bundle/doric-lib.es5.js index d26278d5..146a1596 100644 --- a/doric-js/bundle/doric-lib.es5.js +++ b/doric-js/bundle/doric-lib.es5.js @@ -222,7 +222,7 @@ var View = /** @class */ (function () { set: function (v) { this.x = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(View.prototype, "right", { @@ -232,7 +232,7 @@ var View = /** @class */ (function () { set: function (v) { this.x = v - this.width; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(View.prototype, "top", { @@ -242,7 +242,7 @@ var View = /** @class */ (function () { set: function (v) { this.y = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(View.prototype, "bottom", { @@ -252,7 +252,7 @@ var View = /** @class */ (function () { set: function (v) { this.y = v - this.height; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(View.prototype, "centerX", { @@ -262,7 +262,7 @@ var View = /** @class */ (function () { set: function (v) { this.x = v - this.width / 2; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(View.prototype, "centerY", { @@ -272,7 +272,7 @@ var View = /** @class */ (function () { set: function (v) { this.y = v - this.height / 2; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(View.prototype, "dirtyProps", { @@ -280,7 +280,7 @@ var View = /** @class */ (function () { get: function () { return this.__dirty_props__; }, - enumerable: true, + enumerable: false, configurable: true }); View.prototype.onPropertyChanged = function (propKey, oldV, newV) { @@ -1396,7 +1396,7 @@ var ScaleAnimation = /** @class */ (function (_super) { set: function (v) { this.scaleXChangeable.fromValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(ScaleAnimation.prototype, "toScaleX", { @@ -1406,7 +1406,7 @@ var ScaleAnimation = /** @class */ (function (_super) { set: function (v) { this.scaleXChangeable.toValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(ScaleAnimation.prototype, "fromScaleY", { @@ -1416,7 +1416,7 @@ var ScaleAnimation = /** @class */ (function (_super) { set: function (v) { this.scaleYChangeable.fromValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(ScaleAnimation.prototype, "toScaleY", { @@ -1426,7 +1426,7 @@ var ScaleAnimation = /** @class */ (function (_super) { set: function (v) { this.scaleYChangeable.toValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); return ScaleAnimation; @@ -1456,7 +1456,7 @@ var TranslationAnimation = /** @class */ (function (_super) { set: function (v) { this.translationXChangeable.fromValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(TranslationAnimation.prototype, "toTranslationX", { @@ -1466,7 +1466,7 @@ var TranslationAnimation = /** @class */ (function (_super) { set: function (v) { this.translationXChangeable.toValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(TranslationAnimation.prototype, "fromTranslationY", { @@ -1476,7 +1476,7 @@ var TranslationAnimation = /** @class */ (function (_super) { set: function (v) { this.translationYChangeable.fromValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(TranslationAnimation.prototype, "toTranslationY", { @@ -1486,7 +1486,7 @@ var TranslationAnimation = /** @class */ (function (_super) { set: function (v) { this.translationYChangeable.toValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); return TranslationAnimation; @@ -1510,7 +1510,7 @@ var RotationAnimation = /** @class */ (function (_super) { set: function (v) { this.rotationChaneable.fromValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); Object.defineProperty(RotationAnimation.prototype, "toRotation", { @@ -1520,7 +1520,7 @@ var RotationAnimation = /** @class */ (function (_super) { set: function (v) { this.rotationChaneable.toValue = v; }, - enumerable: true, + enumerable: false, configurable: true }); return RotationAnimation; @@ -1541,7 +1541,7 @@ var AnimationSet = /** @class */ (function () { this._duration = v; this.animations.forEach(function (e) { return e.duration = v; }); }, - enumerable: true, + enumerable: false, configurable: true }); AnimationSet.prototype.toModel = function () { @@ -1927,8 +1927,7 @@ var List = /** @class */ (function (_super) { } }; List.prototype.scrollToItem = function (context, index, config) { - var _a; - var animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated; + var animated = config === null || config === void 0 ? void 0 : config.animated; return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, }); }; List.prototype.reset = function () { diff --git a/doric-js/bundle/doric-lib.js b/doric-js/bundle/doric-lib.js index 141b6e5b..47337831 100644 --- a/doric-js/bundle/doric-lib.js +++ b/doric-js/bundle/doric-lib.js @@ -128,263 +128,266 @@ var __metadata = (undefined && undefined.__metadata) || function (k, v) { function Property(target, propKey) { Reflect.defineMetadata(propKey, true, target); } -class View { - constructor() { - this.width = 0; - this.height = 0; - this.x = 0; - this.y = 0; - this.viewId = uniqueId('ViewId'); - this.callbacks = new Map; - /** Anchor end*/ - this.__dirty_props__ = {}; - this.nativeViewModel = { - id: this.viewId, - type: this.constructor.name, - props: this.__dirty_props__, - }; - return new Proxy(this, { - get: (target, p, receiver) => { - return Reflect.get(target, p, receiver); - }, - set: (target, p, v, receiver) => { - const oldV = Reflect.get(target, p, receiver); - const ret = Reflect.set(target, p, v, receiver); - if (Reflect.getMetadata(p, target) && oldV !== v) { - receiver.onPropertyChanged(p.toString(), oldV, v); - } - return ret; - } - }); - } - callback2Id(f) { - const id = uniqueId('Function'); - this.callbacks.set(id, f); - return id; - } - id2Callback(id) { - let f = this.callbacks.get(id); - if (f === undefined) { - f = Reflect.get(this, id); - } - return f; - } - /** Anchor start*/ - get left() { - return this.x; - } - set left(v) { - this.x = v; - } - get right() { - return this.x + this.width; - } - set right(v) { - this.x = v - this.width; - } - get top() { - return this.y; - } - set top(v) { - this.y = v; - } - get bottom() { - return this.y + this.height; - } - set bottom(v) { - this.y = v - this.height; - } - get centerX() { - return this.x + this.width / 2; - } - get centerY() { - return this.y + this.height / 2; - } - set centerX(v) { - this.x = v - this.width / 2; - } - set centerY(v) { - this.y = v - this.height / 2; - } - get dirtyProps() { - return this.__dirty_props__; - } - onPropertyChanged(propKey, oldV, newV) { - if (newV instanceof Function) { - newV = this.callback2Id(newV); - } - else { - newV = obj2Model(newV); - } - this.__dirty_props__[propKey] = newV; - } - clean() { - for (const key in this.__dirty_props__) { - if (Reflect.has(this.__dirty_props__, key)) { - Reflect.deleteProperty(this.__dirty_props__, key); - } - } - } - isDirty() { - return Reflect.ownKeys(this.__dirty_props__).length !== 0; - } - responseCallback(id, ...args) { - const f = this.id2Callback(id); - if (f instanceof Function) { - const argumentsList = []; - for (let i = 1; i < arguments.length; i++) { - argumentsList.push(arguments[i]); - } - return Reflect.apply(f, this, argumentsList); - } - else { - loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`); - } - } - toModel() { - return this.nativeViewModel; - } - let(block) { - block(this); - } - also(block) { - block(this); - return this; - } - apply(config) { - for (let key in config) { - Reflect.set(this, key, Reflect.get(config, key, config), this); - } - return this; - } - in(group) { - group.addChild(this); - return this; - } - nativeChannel(context, name) { - let thisView = this; - return function (args = undefined) { - const viewIds = []; - while (thisView != undefined) { - viewIds.push(thisView.viewId); - thisView = thisView.superview; - } - const params = { - viewIds: viewIds.reverse(), - name, - args, +let View = /** @class */ (() => { + class View { + constructor() { + this.width = 0; + this.height = 0; + this.x = 0; + this.y = 0; + this.viewId = uniqueId('ViewId'); + this.callbacks = new Map; + /** Anchor end*/ + this.__dirty_props__ = {}; + this.nativeViewModel = { + id: this.viewId, + type: this.constructor.name, + props: this.__dirty_props__, }; - return context.callNative('shader', 'command', params); - }; - } - getWidth(context) { - return this.nativeChannel(context, 'getWidth')(); - } - getHeight(context) { - return this.nativeChannel(context, 'getHeight')(); - } - getX(context) { - return this.nativeChannel(context, 'getX')(); - } - getY(context) { - return this.nativeChannel(context, 'getY')(); - } - getLocationOnScreen(context) { - return this.nativeChannel(context, "getLocationOnScreen")(); - } - doAnimation(context, animation) { - return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => { - for (let key in args) { - Reflect.set(this, key, Reflect.get(args, key, args), this); - Reflect.deleteProperty(this.__dirty_props__, key); + return new Proxy(this, { + get: (target, p, receiver) => { + return Reflect.get(target, p, receiver); + }, + set: (target, p, v, receiver) => { + const oldV = Reflect.get(target, p, receiver); + const ret = Reflect.set(target, p, v, receiver); + if (Reflect.getMetadata(p, target) && oldV !== v) { + receiver.onPropertyChanged(p.toString(), oldV, v); + } + return ret; + } + }); + } + callback2Id(f) { + const id = uniqueId('Function'); + this.callbacks.set(id, f); + return id; + } + id2Callback(id) { + let f = this.callbacks.get(id); + if (f === undefined) { + f = Reflect.get(this, id); } - }); + return f; + } + /** Anchor start*/ + get left() { + return this.x; + } + set left(v) { + this.x = v; + } + get right() { + return this.x + this.width; + } + set right(v) { + this.x = v - this.width; + } + get top() { + return this.y; + } + set top(v) { + this.y = v; + } + get bottom() { + return this.y + this.height; + } + set bottom(v) { + this.y = v - this.height; + } + get centerX() { + return this.x + this.width / 2; + } + get centerY() { + return this.y + this.height / 2; + } + set centerX(v) { + this.x = v - this.width / 2; + } + set centerY(v) { + this.y = v - this.height / 2; + } + get dirtyProps() { + return this.__dirty_props__; + } + onPropertyChanged(propKey, oldV, newV) { + if (newV instanceof Function) { + newV = this.callback2Id(newV); + } + else { + newV = obj2Model(newV); + } + this.__dirty_props__[propKey] = newV; + } + clean() { + for (const key in this.__dirty_props__) { + if (Reflect.has(this.__dirty_props__, key)) { + Reflect.deleteProperty(this.__dirty_props__, key); + } + } + } + isDirty() { + return Reflect.ownKeys(this.__dirty_props__).length !== 0; + } + responseCallback(id, ...args) { + const f = this.id2Callback(id); + if (f instanceof Function) { + const argumentsList = []; + for (let i = 1; i < arguments.length; i++) { + argumentsList.push(arguments[i]); + } + return Reflect.apply(f, this, argumentsList); + } + else { + loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`); + } + } + toModel() { + return this.nativeViewModel; + } + let(block) { + block(this); + } + also(block) { + block(this); + return this; + } + apply(config) { + for (let key in config) { + Reflect.set(this, key, Reflect.get(config, key, config), this); + } + return this; + } + in(group) { + group.addChild(this); + return this; + } + nativeChannel(context, name) { + let thisView = this; + return function (args = undefined) { + const viewIds = []; + while (thisView != undefined) { + viewIds.push(thisView.viewId); + thisView = thisView.superview; + } + const params = { + viewIds: viewIds.reverse(), + name, + args, + }; + return context.callNative('shader', 'command', params); + }; + } + getWidth(context) { + return this.nativeChannel(context, 'getWidth')(); + } + getHeight(context) { + return this.nativeChannel(context, 'getHeight')(); + } + getX(context) { + return this.nativeChannel(context, 'getX')(); + } + getY(context) { + return this.nativeChannel(context, 'getY')(); + } + getLocationOnScreen(context) { + return this.nativeChannel(context, "getLocationOnScreen")(); + } + doAnimation(context, animation) { + return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => { + for (let key in args) { + Reflect.set(this, key, Reflect.get(args, key, args), this); + Reflect.deleteProperty(this.__dirty_props__, key); + } + }); + } } -} -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "width", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "height", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "x", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "y", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "backgroundColor", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "corners", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "border", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "shadow", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "alpha", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], View.prototype, "hidden", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "padding", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "layoutConfig", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], View.prototype, "onClick", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "translationX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "translationY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "scaleX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "scaleY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "pivotX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "pivotY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "rotation", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "flexConfig", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "width", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "height", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "x", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "y", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "backgroundColor", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "corners", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "border", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "shadow", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "alpha", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], View.prototype, "hidden", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "padding", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "layoutConfig", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], View.prototype, "onClick", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "translationX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "translationY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "scaleX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "scaleY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "pivotX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "pivotY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "rotation", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "flexConfig", void 0); + return View; +})(); class Superview extends View { subviewById(id) { for (let v of this.allSubviews()) { @@ -466,64 +469,67 @@ const BOTTOM = (END | SPECIFIED) << SHIFT_Y; const CENTER_X = SPECIFIED << SHIFT_X; const CENTER_Y = SPECIFIED << SHIFT_Y; const CENTER = CENTER_X | CENTER_Y; -class Gravity { - constructor() { - this.val = 0; +let Gravity = /** @class */ (() => { + class Gravity { + constructor() { + this.val = 0; + } + left() { + const val = this.val | LEFT; + const ret = new Gravity; + ret.val = val; + return ret; + } + right() { + const val = this.val | RIGHT; + const ret = new Gravity; + ret.val = val; + return ret; + } + top() { + const val = this.val | TOP; + const ret = new Gravity; + ret.val = val; + return ret; + } + bottom() { + const val = this.val | BOTTOM; + const ret = new Gravity; + ret.val = val; + return ret; + } + center() { + const val = this.val | CENTER; + const ret = new Gravity; + ret.val = val; + return ret; + } + centerX() { + const val = this.val | CENTER_X; + const ret = new Gravity; + ret.val = val; + return ret; + } + centerY() { + const val = this.val | CENTER_Y; + const ret = new Gravity; + ret.val = val; + return ret; + } + toModel() { + return this.val; + } } - left() { - const val = this.val | LEFT; - const ret = new Gravity; - ret.val = val; - return ret; - } - right() { - const val = this.val | RIGHT; - const ret = new Gravity; - ret.val = val; - return ret; - } - top() { - const val = this.val | TOP; - const ret = new Gravity; - ret.val = val; - return ret; - } - bottom() { - const val = this.val | BOTTOM; - const ret = new Gravity; - ret.val = val; - return ret; - } - center() { - const val = this.val | CENTER; - const ret = new Gravity; - ret.val = val; - return ret; - } - centerX() { - const val = this.val | CENTER_X; - const ret = new Gravity; - ret.val = val; - return ret; - } - centerY() { - const val = this.val | CENTER_Y; - const ret = new Gravity; - ret.val = val; - return ret; - } - toModel() { - return this.val; - } -} -Gravity.origin = new Gravity; -Gravity.Center = Gravity.origin.center(); -Gravity.CenterX = Gravity.origin.centerX(); -Gravity.CenterY = Gravity.origin.centerY(); -Gravity.Left = Gravity.origin.left(); -Gravity.Right = Gravity.origin.right(); -Gravity.Top = Gravity.origin.top(); -Gravity.Bottom = Gravity.origin.bottom(); + Gravity.origin = new Gravity; + Gravity.Center = Gravity.origin.center(); + Gravity.CenterX = Gravity.origin.centerX(); + Gravity.CenterY = Gravity.origin.centerY(); + Gravity.Left = Gravity.origin.left(); + Gravity.Right = Gravity.origin.right(); + Gravity.Top = Gravity.origin.top(); + Gravity.Bottom = Gravity.origin.bottom(); + return Gravity; +})(); function gravity() { return new Gravity; } @@ -621,16 +627,19 @@ class Stack extends Group { } class Root extends Stack { } -class LinearLayout extends Group { -} -__decorate$1([ - Property, - __metadata$1("design:type", Number) -], LinearLayout.prototype, "space", void 0); -__decorate$1([ - Property, - __metadata$1("design:type", Gravity) -], LinearLayout.prototype, "gravity", void 0); +let LinearLayout = /** @class */ (() => { + class LinearLayout extends Group { + } + __decorate$1([ + Property, + __metadata$1("design:type", Number) + ], LinearLayout.prototype, "space", void 0); + __decorate$1([ + Property, + __metadata$1("design:type", Gravity) + ], LinearLayout.prototype, "gravity", void 0); + return LinearLayout; +})(); class VLayout extends LinearLayout { } class HLayout extends LinearLayout { @@ -707,231 +716,234 @@ function NativeCall(target, propertyKey, descriptor) { }; return descriptor; } -class Panel { - constructor() { - this.destroyed = false; - this.__root__ = new Root; - this.headviews = new Map; - this.onRenderFinishedCallback = []; - this.__rendering__ = false; - } - onCreate() { } - onDestroy() { } - onShow() { } - onHidden() { } - addHeadView(type, v) { - let map = this.headviews.get(type); - if (map) { - map.set(v.viewId, v); +let Panel = /** @class */ (() => { + class Panel { + constructor() { + this.destroyed = false; + this.__root__ = new Root; + this.headviews = new Map; + this.onRenderFinishedCallback = []; + this.__rendering__ = false; } - else { - map = new Map; - map.set(v.viewId, v); - this.headviews.set(type, map); - } - } - allHeadViews() { - return this.headviews.values(); - } - removeHeadView(type, v) { - if (this.headviews.has(type)) { + onCreate() { } + onDestroy() { } + onShow() { } + onHidden() { } + addHeadView(type, v) { let map = this.headviews.get(type); if (map) { - if (v instanceof View) { - map.delete(v.viewId); - } - else { - map.delete(v); - } - } - } - } - clearHeadViews(type) { - if (this.headviews.has(type)) { - this.headviews.delete(type); - } - } - getRootView() { - return this.__root__; - } - getInitData() { - return this.__data__; - } - __init__(data) { - if (data) { - this.__data__ = JSON.parse(data); - } - } - __onCreate__() { - this.onCreate(); - } - __onDestroy__() { - this.destroyed = true; - this.onDestroy(); - } - __onShow__() { - this.onShow(); - } - __onHidden__() { - this.onHidden(); - } - __build__(frame) { - this.__root__.width = frame.width; - this.__root__.height = frame.height; - this.__root__.children.length = 0; - this.build(this.__root__); - } - __response__(viewIds, callbackId) { - const v = this.retrospectView(viewIds); - if (v === undefined) { - loge(`Cannot find view for ${viewIds}`); - } - else { - const argumentsList = [callbackId]; - for (let i = 2; i < arguments.length; i++) { - argumentsList.push(arguments[i]); - } - return Reflect.apply(v.responseCallback, v, argumentsList); - } - } - retrospectView(ids) { - return ids.reduce((acc, cur) => { - if (acc === undefined) { - if (cur === this.__root__.viewId) { - return this.__root__; - } - for (let map of this.headviews.values()) { - if (map.has(cur)) { - return map.get(cur); - } - } - return undefined; + map.set(v.viewId, v); } else { - if (Reflect.has(acc, "subviewById")) { - return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]); - } - return acc; - } - }, undefined); - } - nativeRender(model) { - return this.context.callNative("shader", "render", model); - } - hookBeforeNativeCall() { - if (Environment.platform !== 'web') { - this.__root__.clean(); - for (let map of this.headviews.values()) { - for (let v of map.values()) { - v.clean(); - } + map = new Map; + map.set(v.viewId, v); + this.headviews.set(type, map); } } - } - hookAfterNativeCall() { - if (this.destroyed) { - return; + allHeadViews() { + return this.headviews.values(); } - const promises = []; - if (Environment.platform !== 'web') { - //Here insert a native call to ensure the promise is resolved done. - nativeEmpty(); - if (this.__root__.isDirty()) { - const model = this.__root__.toModel(); - promises.push(this.nativeRender(model)); - } - for (let map of this.headviews.values()) { - for (let v of map.values()) { - if (v.isDirty()) { - const model = v.toModel(); - promises.push(this.nativeRender(model)); + removeHeadView(type, v) { + if (this.headviews.has(type)) { + let map = this.headviews.get(type); + if (map) { + if (v instanceof View) { + map.delete(v.viewId); + } + else { + map.delete(v); } } } } - else { - Promise.resolve().then(() => { + clearHeadViews(type) { + if (this.headviews.has(type)) { + this.headviews.delete(type); + } + } + getRootView() { + return this.__root__; + } + getInitData() { + return this.__data__; + } + __init__(data) { + if (data) { + this.__data__ = JSON.parse(data); + } + } + __onCreate__() { + this.onCreate(); + } + __onDestroy__() { + this.destroyed = true; + this.onDestroy(); + } + __onShow__() { + this.onShow(); + } + __onHidden__() { + this.onHidden(); + } + __build__(frame) { + this.__root__.width = frame.width; + this.__root__.height = frame.height; + this.__root__.children.length = 0; + this.build(this.__root__); + } + __response__(viewIds, callbackId) { + const v = this.retrospectView(viewIds); + if (v === undefined) { + loge(`Cannot find view for ${viewIds}`); + } + else { + const argumentsList = [callbackId]; + for (let i = 2; i < arguments.length; i++) { + argumentsList.push(arguments[i]); + } + return Reflect.apply(v.responseCallback, v, argumentsList); + } + } + retrospectView(ids) { + return ids.reduce((acc, cur) => { + if (acc === undefined) { + if (cur === this.__root__.viewId) { + return this.__root__; + } + for (let map of this.headviews.values()) { + if (map.has(cur)) { + return map.get(cur); + } + } + return undefined; + } + else { + if (Reflect.has(acc, "subviewById")) { + return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]); + } + return acc; + } + }, undefined); + } + nativeRender(model) { + return this.context.callNative("shader", "render", model); + } + hookBeforeNativeCall() { + if (Environment.platform !== 'web') { + this.__root__.clean(); + for (let map of this.headviews.values()) { + for (let v of map.values()) { + v.clean(); + } + } + } + } + hookAfterNativeCall() { + if (this.destroyed) { + return; + } + const promises = []; + if (Environment.platform !== 'web') { + //Here insert a native call to ensure the promise is resolved done. + nativeEmpty(); if (this.__root__.isDirty()) { const model = this.__root__.toModel(); promises.push(this.nativeRender(model)); - this.__root__.clean(); } for (let map of this.headviews.values()) { for (let v of map.values()) { if (v.isDirty()) { const model = v.toModel(); promises.push(this.nativeRender(model)); - v.clean(); } } } - }); + } + else { + Promise.resolve().then(() => { + if (this.__root__.isDirty()) { + const model = this.__root__.toModel(); + promises.push(this.nativeRender(model)); + this.__root__.clean(); + } + for (let map of this.headviews.values()) { + for (let v of map.values()) { + if (v.isDirty()) { + const model = v.toModel(); + promises.push(this.nativeRender(model)); + v.clean(); + } + } + } + }); + } + if (this.__rendering__) { + //skip + Promise.all(promises).then(_ => { + }); + } + else { + this.__rendering__ = true; + Promise.all(promises).then(_ => { + this.__rendering__ = false; + this.onRenderFinished(); + }); + } } - if (this.__rendering__) { - //skip - Promise.all(promises).then(_ => { + onRenderFinished() { + this.onRenderFinishedCallback.forEach(e => { + e(); }); + this.onRenderFinishedCallback.length = 0; } - else { - this.__rendering__ = true; - Promise.all(promises).then(_ => { - this.__rendering__ = false; - this.onRenderFinished(); - }); + addOnRenderFinishedCallback(cb) { + this.onRenderFinishedCallback.push(cb); } } - onRenderFinished() { - this.onRenderFinishedCallback.forEach(e => { - e(); - }); - this.onRenderFinishedCallback.length = 0; - } - addOnRenderFinishedCallback(cb) { - this.onRenderFinishedCallback.push(cb); - } -} -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", [String]), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__init__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onCreate__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onDestroy__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onShow__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onHidden__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", [Object]), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__build__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", [Array, String]), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__response__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", [String]), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__init__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onCreate__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onDestroy__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onShow__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onHidden__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", [Object]), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__build__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", [Array, String]), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__response__", null); + return Panel; +})(); /* * Copyright [2019] [Doric.Pub] @@ -1152,57 +1164,60 @@ class AnimationSet { /** * Store color as format AARRGGBB or RRGGBB */ -class Color { - constructor(v) { - this._value = 0; - this._value = v | 0x0; - } - static parse(str) { - if (!str.startsWith("#")) { - throw new Error(`Parse color error with ${str}`); +let Color = /** @class */ (() => { + class Color { + constructor(v) { + this._value = 0; + this._value = v | 0x0; } - const val = parseInt(str.substr(1), 16); - if (str.length === 7) { - return new Color(val | 0xff000000); + static parse(str) { + if (!str.startsWith("#")) { + throw new Error(`Parse color error with ${str}`); + } + const val = parseInt(str.substr(1), 16); + if (str.length === 7) { + return new Color(val | 0xff000000); + } + else if (str.length === 9) { + return new Color(val); + } + else { + throw new Error(`Parse color error with ${str}`); + } } - else if (str.length === 9) { - return new Color(val); + static safeParse(str, defVal = Color.TRANSPARENT) { + let color = defVal; + try { + color = Color.parse(str); + } + catch (e) { + } + finally { + return color; + } } - else { - throw new Error(`Parse color error with ${str}`); + alpha(v) { + v = v * 255; + return new Color((this._value & 0xffffff) | ((v & 0xff) << 24)); + } + toModel() { + return this._value; } } - static safeParse(str, defVal = Color.TRANSPARENT) { - let color = defVal; - try { - color = Color.parse(str); - } - catch (e) { - } - finally { - return color; - } - } - alpha(v) { - v = v * 255; - return new Color((this._value & 0xffffff) | ((v & 0xff) << 24)); - } - toModel() { - return this._value; - } -} -Color.BLACK = new Color(0xFF000000); -Color.DKGRAY = new Color(0xFF444444); -Color.GRAY = new Color(0xFF888888); -Color.LTGRAY = new Color(0xFFCCCCCC); -Color.WHITE = new Color(0xFFFFFFFF); -Color.RED = new Color(0xFFFF0000); -Color.GREEN = new Color(0xFF00FF00); -Color.BLUE = new Color(0xFF0000FF); -Color.YELLOW = new Color(0xFFFFFF00); -Color.CYAN = new Color(0xFF00FFFF); -Color.MAGENTA = new Color(0xFFFF00FF); -Color.TRANSPARENT = new Color(0); + Color.BLACK = new Color(0xFF000000); + Color.DKGRAY = new Color(0xFF444444); + Color.GRAY = new Color(0xFF888888); + Color.LTGRAY = new Color(0xFFCCCCCC); + Color.WHITE = new Color(0xFFFFFFFF); + Color.RED = new Color(0xFFFF0000); + Color.GREEN = new Color(0xFF00FF00); + Color.BLUE = new Color(0xFF0000FF); + Color.YELLOW = new Color(0xFFFFFF00); + Color.CYAN = new Color(0xFF00FFFF); + Color.MAGENTA = new Color(0xFFFF00FF); + Color.TRANSPARENT = new Color(0); + return Color; +})(); (function (GradientOrientation) { /** draw the gradient from the top to the bottom */ GradientOrientation[GradientOrientation["TOP_BOTTOM"] = 0] = "TOP_BOTTOM"; @@ -1237,64 +1252,67 @@ var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { TruncateAt[TruncateAt["Start"] = 2] = "Start"; TruncateAt[TruncateAt["Clip"] = 3] = "Clip"; })(exports.TruncateAt || (exports.TruncateAt = {})); -class Text extends View { -} -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "text", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Color) -], Text.prototype, "textColor", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "textSize", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "maxLines", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Gravity) -], Text.prototype, "textAlignment", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "fontStyle", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "font", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "maxWidth", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "maxHeight", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "lineSpacing", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Boolean) -], Text.prototype, "strikethrough", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Boolean) -], Text.prototype, "underline", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "htmlText", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "truncateAt", void 0); +let Text = /** @class */ (() => { + class Text extends View { + } + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "text", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Color) + ], Text.prototype, "textColor", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "textSize", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "maxLines", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Gravity) + ], Text.prototype, "textAlignment", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "fontStyle", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "font", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "maxWidth", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "maxHeight", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "lineSpacing", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Boolean) + ], Text.prototype, "strikethrough", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Boolean) + ], Text.prototype, "underline", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "htmlText", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "truncateAt", void 0); + return Text; +})(); function text(config) { const ret = new Text; ret.layoutConfig = layoutConfig().fit(); @@ -1318,73 +1336,76 @@ var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { ScaleType[ScaleType["ScaleAspectFit"] = 1] = "ScaleAspectFit"; ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill"; })(exports.ScaleType || (exports.ScaleType = {})); -class Image extends View { -} -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imageUrl", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imagePath", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imageRes", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imageBase64", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Number) -], Image.prototype, "scaleType", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Boolean) -], Image.prototype, "isBlur", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "placeHolderImage", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "placeHolderImageBase64", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Color - /** - * Display while image is failed to load - * It can be file name in local path - */ - ) -], Image.prototype, "placeHolderColor", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "errorImage", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "errorImageBase64", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Color) -], Image.prototype, "errorColor", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Function) -], Image.prototype, "loadCallback", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Number) -], Image.prototype, "imageScale", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Object) -], Image.prototype, "stretchInset", void 0); +let Image = /** @class */ (() => { + class Image extends View { + } + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imageUrl", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imagePath", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imageRes", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imageBase64", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Number) + ], Image.prototype, "scaleType", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Boolean) + ], Image.prototype, "isBlur", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "placeHolderImage", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "placeHolderImageBase64", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Color + /** + * Display while image is failed to load + * It can be file name in local path + */ + ) + ], Image.prototype, "placeHolderColor", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "errorImage", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "errorImageBase64", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Color) + ], Image.prototype, "errorColor", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Function) + ], Image.prototype, "loadCallback", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Number) + ], Image.prototype, "imageScale", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Object) + ], Image.prototype, "stretchInset", void 0); + return Image; +})(); function image(config) { const ret = new Image; ret.layoutConfig = layoutConfig().fit(); @@ -1418,101 +1439,106 @@ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, var __metadata$5 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class ListItem extends Stack { -} -__decorate$5([ - Property, - __metadata$5("design:type", String) -], ListItem.prototype, "identifier", void 0); -class List extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.itemCount = 0; - this.batchCount = 15; +let ListItem = /** @class */ (() => { + class ListItem extends Stack { } - allSubviews() { - if (this.loadMoreView) { - return [...this.cachedViews.values(), this.loadMoreView]; - } - else { - return this.cachedViews.values(); - } - } - scrollToItem(context, index, config) { - var _a; - const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated; - return this.nativeChannel(context, 'scrollToItem')({ index, animated, }); - } - reset() { - this.cachedViews.clear(); - this.itemCount = 0; - } - getItem(itemIdx) { - let view = this.renderItem(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate$5([ + Property, + __metadata$5("design:type", String) + ], ListItem.prototype, "identifier", void 0); + return ListItem; +})(); +let List = /** @class */ (() => { + class List extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.itemCount = 0; + this.batchCount = 15; } - return super.isDirty(); - } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { - const listItem = this.getItem(start + idx); - return listItem.toModel(); - }); - } - toModel() { - if (this.loadMoreView) { - this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + allSubviews() { + if (this.loadMoreView) { + return [...this.cachedViews.values(), this.loadMoreView]; + } + else { + return this.cachedViews.values(); + } + } + scrollToItem(context, index, config) { + const animated = config === null || config === void 0 ? void 0 : config.animated; + return this.nativeChannel(context, 'scrollToItem')({ index, animated, }); + } + reset() { + this.cachedViews.clear(); + this.itemCount = 0; + } + getItem(itemIdx) { + let view = this.renderItem(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { + const listItem = this.getItem(start + idx); + return listItem.toModel(); + }); + } + toModel() { + if (this.loadMoreView) { + this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + } + return super.toModel(); } - return super.toModel(); } -} -__decorate$5([ - Property, - __metadata$5("design:type", Object) -], List.prototype, "itemCount", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "renderItem", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Object) -], List.prototype, "batchCount", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "onLoadMore", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Boolean) -], List.prototype, "loadMore", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", ListItem) -], List.prototype, "loadMoreView", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "onScroll", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "onScrollEnd", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Number) -], List.prototype, "scrolledPosition", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Object) + ], List.prototype, "itemCount", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "renderItem", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Object) + ], List.prototype, "batchCount", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "onLoadMore", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Boolean) + ], List.prototype, "loadMore", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", ListItem) + ], List.prototype, "loadMoreView", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "onScroll", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "onScrollEnd", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Number) + ], List.prototype, "scrolledPosition", void 0); + return List; +})(); function list(config) { const ret = new List; for (let key in config) { @@ -1548,71 +1574,77 @@ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, var __metadata$6 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class SlideItem extends Stack { -} -__decorate$6([ - Property, - __metadata$6("design:type", String) -], SlideItem.prototype, "identifier", void 0); -class Slider extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.itemCount = 0; - this.batchCount = 3; +let SlideItem = /** @class */ (() => { + class SlideItem extends Stack { } - allSubviews() { - return this.cachedViews.values(); - } - getItem(itemIdx) { - let view = this.renderPage(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate$6([ + Property, + __metadata$6("design:type", String) + ], SlideItem.prototype, "identifier", void 0); + return SlideItem; +})(); +let Slider = /** @class */ (() => { + class Slider extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.itemCount = 0; + this.batchCount = 3; + } + allSubviews() { + return this.cachedViews.values(); + } + getItem(itemIdx) { + let view = this.renderPage(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { + const slideItem = this.getItem(start + idx); + return slideItem.toModel(); + }); + } + slidePage(context, page, smooth = false) { + return this.nativeChannel(context, "slidePage")({ page, smooth }); + } + getSlidedPage(context) { + return this.nativeChannel(context, "getSlidedPage")(); } - return super.isDirty(); } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { - const slideItem = this.getItem(start + idx); - return slideItem.toModel(); - }); - } - slidePage(context, page, smooth = false) { - return this.nativeChannel(context, "slidePage")({ page, smooth }); - } - getSlidedPage(context) { - return this.nativeChannel(context, "getSlidedPage")(); - } -} -__decorate$6([ - Property, - __metadata$6("design:type", Object) -], Slider.prototype, "itemCount", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Function) -], Slider.prototype, "renderPage", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Object) -], Slider.prototype, "batchCount", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Function) -], Slider.prototype, "onPageSlided", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Boolean) -], Slider.prototype, "loop", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Object) + ], Slider.prototype, "itemCount", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Function) + ], Slider.prototype, "renderPage", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Object) + ], Slider.prototype, "batchCount", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Function) + ], Slider.prototype, "onPageSlided", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Boolean) + ], Slider.prototype, "loop", void 0); + return Slider; +})(); function slider(config) { const ret = new Slider; for (let key in config) { @@ -1659,33 +1691,36 @@ function scroller(content, config) { v.content = content; }); } -class Scroller extends Superview { - allSubviews() { - return [this.content]; +let Scroller = /** @class */ (() => { + class Scroller extends Superview { + allSubviews() { + return [this.content]; + } + toModel() { + this.dirtyProps.content = this.content.viewId; + return super.toModel(); + } + scrollTo(context, offset, animated) { + return this.nativeChannel(context, "scrollTo")({ offset, animated }); + } + scrollBy(context, offset, animated) { + return this.nativeChannel(context, "scrollBy")({ offset, animated }); + } } - toModel() { - this.dirtyProps.content = this.content.viewId; - return super.toModel(); - } - scrollTo(context, offset, animated) { - return this.nativeChannel(context, "scrollTo")({ offset, animated }); - } - scrollBy(context, offset, animated) { - return this.nativeChannel(context, "scrollBy")({ offset, animated }); - } -} -__decorate$7([ - Property, - __metadata$7("design:type", Object) -], Scroller.prototype, "contentOffset", void 0); -__decorate$7([ - Property, - __metadata$7("design:type", Function) -], Scroller.prototype, "onScroll", void 0); -__decorate$7([ - Property, - __metadata$7("design:type", Function) -], Scroller.prototype, "onScrollEnd", void 0); + __decorate$7([ + Property, + __metadata$7("design:type", Object) + ], Scroller.prototype, "contentOffset", void 0); + __decorate$7([ + Property, + __metadata$7("design:type", Function) + ], Scroller.prototype, "onScroll", void 0); + __decorate$7([ + Property, + __metadata$7("design:type", Function) + ], Scroller.prototype, "onScrollEnd", void 0); + return Scroller; +})(); var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; @@ -1696,36 +1731,39 @@ var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, var __metadata$8 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Refreshable extends Superview { - allSubviews() { - const ret = [this.content]; - if (this.header) { - ret.push(this.header); +let Refreshable = /** @class */ (() => { + class Refreshable extends Superview { + allSubviews() { + const ret = [this.content]; + if (this.header) { + ret.push(this.header); + } + return ret; + } + setRefreshable(context, refreshable) { + return this.nativeChannel(context, 'setRefreshable')(refreshable); + } + setRefreshing(context, refreshing) { + return this.nativeChannel(context, 'setRefreshing')(refreshing); + } + isRefreshable(context) { + return this.nativeChannel(context, 'isRefreshable')(); + } + isRefreshing(context) { + return this.nativeChannel(context, 'isRefreshing')(); + } + toModel() { + this.dirtyProps.content = this.content.viewId; + this.dirtyProps.header = (this.header || {}).viewId; + return super.toModel(); } - return ret; } - setRefreshable(context, refreshable) { - return this.nativeChannel(context, 'setRefreshable')(refreshable); - } - setRefreshing(context, refreshing) { - return this.nativeChannel(context, 'setRefreshing')(refreshing); - } - isRefreshable(context) { - return this.nativeChannel(context, 'isRefreshable')(); - } - isRefreshing(context) { - return this.nativeChannel(context, 'isRefreshing')(); - } - toModel() { - this.dirtyProps.content = this.content.viewId; - this.dirtyProps.header = (this.header || {}).viewId; - return super.toModel(); - } -} -__decorate$8([ - Property, - __metadata$8("design:type", Function) -], Refreshable.prototype, "onRefresh", void 0); + __decorate$8([ + Property, + __metadata$8("design:type", Function) + ], Refreshable.prototype, "onRefresh", void 0); + return Refreshable; +})(); function refreshable(config) { const ret = new Refreshable; ret.layoutConfig = layoutConfig().fit(); @@ -1748,29 +1786,32 @@ var ValueType; ValueType[ValueType["Percent"] = 2] = "Percent"; ValueType[ValueType["Auto"] = 3] = "Auto"; })(ValueType || (ValueType = {})); -class FlexTypedValue { - constructor(type) { - this.value = 0; - this.type = type; +let FlexTypedValue = /** @class */ (() => { + class FlexTypedValue { + constructor(type) { + this.value = 0; + this.type = type; + } + static percent(v) { + const ret = new FlexTypedValue(ValueType.Percent); + ret.value = v; + return ret; + } + static point(v) { + const ret = new FlexTypedValue(ValueType.Point); + ret.value = v; + return ret; + } + toModel() { + return { + type: this.type, + value: this.value, + }; + } } - static percent(v) { - const ret = new FlexTypedValue(ValueType.Percent); - ret.value = v; - return ret; - } - static point(v) { - const ret = new FlexTypedValue(ValueType.Point); - ret.value = v; - return ret; - } - toModel() { - return { - type: this.type, - value: this.value, - }; - } -} -FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto); + FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto); + return FlexTypedValue; +})(); (function (FlexDirection) { FlexDirection[FlexDirection["COLUMN"] = 0] = "COLUMN"; FlexDirection[FlexDirection["COLUMN_REVERSE"] = 1] = "COLUMN_REVERSE"; @@ -1828,105 +1869,111 @@ var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, var __metadata$9 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class FlowLayoutItem extends Stack { -} -__decorate$9([ - Property, - __metadata$9("design:type", String) -], FlowLayoutItem.prototype, "identifier", void 0); -class FlowLayout extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.columnCount = 2; - this.itemCount = 0; - this.batchCount = 15; +let FlowLayoutItem = /** @class */ (() => { + class FlowLayoutItem extends Stack { } - allSubviews() { - if (this.loadMoreView) { - return [...this.cachedViews.values(), this.loadMoreView]; - } - else { - return this.cachedViews.values(); - } - } - reset() { - this.cachedViews.clear(); - this.itemCount = 0; - } - getItem(itemIdx) { - let view = this.renderItem(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate$9([ + Property, + __metadata$9("design:type", String) + ], FlowLayoutItem.prototype, "identifier", void 0); + return FlowLayoutItem; +})(); +let FlowLayout = /** @class */ (() => { + class FlowLayout extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.columnCount = 2; + this.itemCount = 0; + this.batchCount = 15; } - return super.isDirty(); - } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { - const listItem = this.getItem(start + idx); - return listItem.toModel(); - }); - } - toModel() { - if (this.loadMoreView) { - this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + allSubviews() { + if (this.loadMoreView) { + return [...this.cachedViews.values(), this.loadMoreView]; + } + else { + return this.cachedViews.values(); + } + } + reset() { + this.cachedViews.clear(); + this.itemCount = 0; + } + getItem(itemIdx) { + let view = this.renderItem(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { + const listItem = this.getItem(start + idx); + return listItem.toModel(); + }); + } + toModel() { + if (this.loadMoreView) { + this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + } + return super.toModel(); } - return super.toModel(); } -} -__decorate$9([ - Property, - __metadata$9("design:type", Object) -], FlowLayout.prototype, "columnCount", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Number) -], FlowLayout.prototype, "columnSpace", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Number) -], FlowLayout.prototype, "rowSpace", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Object) -], FlowLayout.prototype, "itemCount", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "renderItem", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Object) -], FlowLayout.prototype, "batchCount", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "onLoadMore", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Boolean) -], FlowLayout.prototype, "loadMore", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", FlowLayoutItem) -], FlowLayout.prototype, "loadMoreView", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "onScroll", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "onScrollEnd", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Object) + ], FlowLayout.prototype, "columnCount", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Number) + ], FlowLayout.prototype, "columnSpace", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Number) + ], FlowLayout.prototype, "rowSpace", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Object) + ], FlowLayout.prototype, "itemCount", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "renderItem", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Object) + ], FlowLayout.prototype, "batchCount", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "onLoadMore", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Boolean) + ], FlowLayout.prototype, "loadMore", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", FlowLayoutItem) + ], FlowLayout.prototype, "loadMoreView", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "onScroll", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "onScrollEnd", void 0); + return FlowLayout; +})(); function flowlayout(config) { const ret = new FlowLayout; for (let key in config) { @@ -1962,63 +2009,66 @@ var __decorate$a = (undefined && undefined.__decorate) || function (decorators, var __metadata$a = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Input extends View { - getText(context) { - return this.nativeChannel(context, 'getText')(); +let Input = /** @class */ (() => { + class Input extends View { + getText(context) { + return this.nativeChannel(context, 'getText')(); + } + setSelection(context, start, end = start) { + return this.nativeChannel(context, 'setSelection')({ + start, + end, + }); + } + requestFocus(context) { + return this.nativeChannel(context, 'requestFocus')(); + } + releaseFocus(context) { + return this.nativeChannel(context, 'releaseFocus')(); + } } - setSelection(context, start, end = start) { - return this.nativeChannel(context, 'setSelection')({ - start, - end, - }); - } - requestFocus(context) { - return this.nativeChannel(context, 'requestFocus')(); - } - releaseFocus(context) { - return this.nativeChannel(context, 'releaseFocus')(); - } -} -__decorate$a([ - Property, - __metadata$a("design:type", String) -], Input.prototype, "text", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Color) -], Input.prototype, "textColor", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Number) -], Input.prototype, "textSize", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", String) -], Input.prototype, "hintText", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Color) -], Input.prototype, "hintTextColor", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Boolean) -], Input.prototype, "multiline", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Gravity) -], Input.prototype, "textAlignment", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Function) -], Input.prototype, "onTextChange", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Function) -], Input.prototype, "onFocusChange", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Number) -], Input.prototype, "maxLength", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", String) + ], Input.prototype, "text", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Color) + ], Input.prototype, "textColor", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Number) + ], Input.prototype, "textSize", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", String) + ], Input.prototype, "hintText", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Color) + ], Input.prototype, "hintTextColor", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Boolean) + ], Input.prototype, "multiline", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Gravity) + ], Input.prototype, "textAlignment", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Function) + ], Input.prototype, "onTextChange", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Function) + ], Input.prototype, "onFocusChange", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Number) + ], Input.prototype, "maxLength", void 0); + return Input; +})(); function input(config) { const ret = new Input; ret.layoutConfig = layoutConfig().just(); @@ -2037,21 +2087,24 @@ var __decorate$b = (undefined && undefined.__decorate) || function (decorators, var __metadata$b = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class NestedSlider extends Group { - addSlideItem(view) { - this.addChild(view); +let NestedSlider = /** @class */ (() => { + class NestedSlider extends Group { + addSlideItem(view) { + this.addChild(view); + } + slidePage(context, page, smooth = false) { + return this.nativeChannel(context, "slidePage")({ page, smooth }); + } + getSlidedPage(context) { + return this.nativeChannel(context, "getSlidedPage")(); + } } - slidePage(context, page, smooth = false) { - return this.nativeChannel(context, "slidePage")({ page, smooth }); - } - getSlidedPage(context) { - return this.nativeChannel(context, "getSlidedPage")(); - } -} -__decorate$b([ - Property, - __metadata$b("design:type", Function) -], NestedSlider.prototype, "onPageSlided", void 0); + __decorate$b([ + Property, + __metadata$b("design:type", Function) + ], NestedSlider.prototype, "onPageSlided", void 0); + return NestedSlider; +})(); var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; @@ -2062,12 +2115,15 @@ var __decorate$c = (undefined && undefined.__decorate) || function (decorators, var __metadata$c = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Draggable extends Stack { -} -__decorate$c([ - Property, - __metadata$c("design:type", Function) -], Draggable.prototype, "onDrag", void 0); +let Draggable = /** @class */ (() => { + class Draggable extends Stack { + } + __decorate$c([ + Property, + __metadata$c("design:type", Function) + ], Draggable.prototype, "onDrag", void 0); + return Draggable; +})(); function draggable(views, config) { const ret = new Draggable; ret.layoutConfig = layoutConfig().fit(); @@ -2096,28 +2152,31 @@ var __decorate$d = (undefined && undefined.__decorate) || function (decorators, var __metadata$d = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Switch extends View { -} -__decorate$d([ - Property, - __metadata$d("design:type", Boolean) -], Switch.prototype, "state", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Function) -], Switch.prototype, "onSwitch", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Color) -], Switch.prototype, "offTintColor", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Color) -], Switch.prototype, "onTintColor", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Color) -], Switch.prototype, "thumbTintColor", void 0); +let Switch = /** @class */ (() => { + class Switch extends View { + } + __decorate$d([ + Property, + __metadata$d("design:type", Boolean) + ], Switch.prototype, "state", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Function) + ], Switch.prototype, "onSwitch", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Color) + ], Switch.prototype, "offTintColor", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Color) + ], Switch.prototype, "onTintColor", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Color) + ], Switch.prototype, "thumbTintColor", void 0); + return Switch; +})(); function switchView(config) { const ret = new Switch; ret.layoutConfig = layoutConfig().just(); diff --git a/doric-js/bundle/doric-sandbox.es5.js b/doric-js/bundle/doric-sandbox.es5.js index 7dbc0c03..66ad4758 100644 --- a/doric-js/bundle/doric-sandbox.es5.js +++ b/doric-js/bundle/doric-sandbox.es5.js @@ -1705,7 +1705,7 @@ var doric = (function (exports) { (module.exports = function (key, value) { return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); })('versions', []).push({ - version: '3.6.4', + version: '3.6.5', mode: 'global', copyright: '© 2020 Denis Pushkarev (zloirock.ru)' }); @@ -6489,7 +6489,13 @@ var doric = (function (exports) { defer = functionBindContext(port.postMessage, port, 1); // Browsers with postMessage, skip WebWorkers // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' - } else if (global_1.addEventListener && typeof postMessage == 'function' && !global_1.importScripts && !fails(post)) { + } else if ( + global_1.addEventListener && + typeof postMessage == 'function' && + !global_1.importScripts && + !fails(post) && + location.protocol !== 'file:' + ) { defer = post; global_1.addEventListener('message', listener, false); // IE8- @@ -9861,7 +9867,7 @@ var doric = (function (exports) { var INVALID_PORT = 'Invalid port'; var ALPHA = /[A-Za-z]/; - var ALPHANUMERIC = /[\d+\-.A-Za-z]/; + var ALPHANUMERIC = /[\d+-.A-Za-z]/; var DIGIT = /\d/; var HEX_START = /^(0x|0X)/; var OCT = /^[0-7]+$/; @@ -11672,8 +11678,8 @@ var doric = (function (exports) { if (cleanup != null) { subscriptionState.cleanup = typeof cleanup.unsubscribe === 'function' ? function () { subscription.unsubscribe(); } : aFunction$1(cleanup); } - } catch (error) { - subscriptionObserver.error(error); + } catch (error$1) { + subscriptionObserver.error(error$1); return; } if (subscriptionClosed(subscriptionState)) { cleanupSubscription(subscriptionState); } }; @@ -13173,7 +13179,7 @@ var doric = (function (exports) { // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype$1[METHOD_NAME] !== es_array_iterator[METHOD_NAME]) { try { createNonEnumerableProperty(CollectionPrototype$1, METHOD_NAME, es_array_iterator[METHOD_NAME]); - } catch (error) { + } catch (error$1) { CollectionPrototype$1[METHOD_NAME] = es_array_iterator[METHOD_NAME]; } } } } diff --git a/doric-js/bundle/doric-vm.js b/doric-js/bundle/doric-vm.js index 2e5fced3..25cb0d8e 100644 --- a/doric-js/bundle/doric-vm.js +++ b/doric-js/bundle/doric-vm.js @@ -1587,263 +1587,266 @@ var __metadata = (undefined && undefined.__metadata) || function (k, v) { function Property(target, propKey) { Reflect.defineMetadata(propKey, true, target); } -class View { - constructor() { - this.width = 0; - this.height = 0; - this.x = 0; - this.y = 0; - this.viewId = uniqueId('ViewId'); - this.callbacks = new Map; - /** Anchor end*/ - this.__dirty_props__ = {}; - this.nativeViewModel = { - id: this.viewId, - type: this.constructor.name, - props: this.__dirty_props__, - }; - return new Proxy(this, { - get: (target, p, receiver) => { - return Reflect.get(target, p, receiver); - }, - set: (target, p, v, receiver) => { - const oldV = Reflect.get(target, p, receiver); - const ret = Reflect.set(target, p, v, receiver); - if (Reflect.getMetadata(p, target) && oldV !== v) { - receiver.onPropertyChanged(p.toString(), oldV, v); - } - return ret; - } - }); - } - callback2Id(f) { - const id = uniqueId('Function'); - this.callbacks.set(id, f); - return id; - } - id2Callback(id) { - let f = this.callbacks.get(id); - if (f === undefined) { - f = Reflect.get(this, id); - } - return f; - } - /** Anchor start*/ - get left() { - return this.x; - } - set left(v) { - this.x = v; - } - get right() { - return this.x + this.width; - } - set right(v) { - this.x = v - this.width; - } - get top() { - return this.y; - } - set top(v) { - this.y = v; - } - get bottom() { - return this.y + this.height; - } - set bottom(v) { - this.y = v - this.height; - } - get centerX() { - return this.x + this.width / 2; - } - get centerY() { - return this.y + this.height / 2; - } - set centerX(v) { - this.x = v - this.width / 2; - } - set centerY(v) { - this.y = v - this.height / 2; - } - get dirtyProps() { - return this.__dirty_props__; - } - onPropertyChanged(propKey, oldV, newV) { - if (newV instanceof Function) { - newV = this.callback2Id(newV); - } - else { - newV = obj2Model(newV); - } - this.__dirty_props__[propKey] = newV; - } - clean() { - for (const key in this.__dirty_props__) { - if (Reflect.has(this.__dirty_props__, key)) { - Reflect.deleteProperty(this.__dirty_props__, key); - } - } - } - isDirty() { - return Reflect.ownKeys(this.__dirty_props__).length !== 0; - } - responseCallback(id, ...args) { - const f = this.id2Callback(id); - if (f instanceof Function) { - const argumentsList = []; - for (let i = 1; i < arguments.length; i++) { - argumentsList.push(arguments[i]); - } - return Reflect.apply(f, this, argumentsList); - } - else { - loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`); - } - } - toModel() { - return this.nativeViewModel; - } - let(block) { - block(this); - } - also(block) { - block(this); - return this; - } - apply(config) { - for (let key in config) { - Reflect.set(this, key, Reflect.get(config, key, config), this); - } - return this; - } - in(group) { - group.addChild(this); - return this; - } - nativeChannel(context, name) { - let thisView = this; - return function (args = undefined) { - const viewIds = []; - while (thisView != undefined) { - viewIds.push(thisView.viewId); - thisView = thisView.superview; - } - const params = { - viewIds: viewIds.reverse(), - name, - args, +let View = /** @class */ (() => { + class View { + constructor() { + this.width = 0; + this.height = 0; + this.x = 0; + this.y = 0; + this.viewId = uniqueId('ViewId'); + this.callbacks = new Map; + /** Anchor end*/ + this.__dirty_props__ = {}; + this.nativeViewModel = { + id: this.viewId, + type: this.constructor.name, + props: this.__dirty_props__, }; - return context.callNative('shader', 'command', params); - }; - } - getWidth(context) { - return this.nativeChannel(context, 'getWidth')(); - } - getHeight(context) { - return this.nativeChannel(context, 'getHeight')(); - } - getX(context) { - return this.nativeChannel(context, 'getX')(); - } - getY(context) { - return this.nativeChannel(context, 'getY')(); - } - getLocationOnScreen(context) { - return this.nativeChannel(context, "getLocationOnScreen")(); - } - doAnimation(context, animation) { - return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => { - for (let key in args) { - Reflect.set(this, key, Reflect.get(args, key, args), this); - Reflect.deleteProperty(this.__dirty_props__, key); + return new Proxy(this, { + get: (target, p, receiver) => { + return Reflect.get(target, p, receiver); + }, + set: (target, p, v, receiver) => { + const oldV = Reflect.get(target, p, receiver); + const ret = Reflect.set(target, p, v, receiver); + if (Reflect.getMetadata(p, target) && oldV !== v) { + receiver.onPropertyChanged(p.toString(), oldV, v); + } + return ret; + } + }); + } + callback2Id(f) { + const id = uniqueId('Function'); + this.callbacks.set(id, f); + return id; + } + id2Callback(id) { + let f = this.callbacks.get(id); + if (f === undefined) { + f = Reflect.get(this, id); } - }); + return f; + } + /** Anchor start*/ + get left() { + return this.x; + } + set left(v) { + this.x = v; + } + get right() { + return this.x + this.width; + } + set right(v) { + this.x = v - this.width; + } + get top() { + return this.y; + } + set top(v) { + this.y = v; + } + get bottom() { + return this.y + this.height; + } + set bottom(v) { + this.y = v - this.height; + } + get centerX() { + return this.x + this.width / 2; + } + get centerY() { + return this.y + this.height / 2; + } + set centerX(v) { + this.x = v - this.width / 2; + } + set centerY(v) { + this.y = v - this.height / 2; + } + get dirtyProps() { + return this.__dirty_props__; + } + onPropertyChanged(propKey, oldV, newV) { + if (newV instanceof Function) { + newV = this.callback2Id(newV); + } + else { + newV = obj2Model(newV); + } + this.__dirty_props__[propKey] = newV; + } + clean() { + for (const key in this.__dirty_props__) { + if (Reflect.has(this.__dirty_props__, key)) { + Reflect.deleteProperty(this.__dirty_props__, key); + } + } + } + isDirty() { + return Reflect.ownKeys(this.__dirty_props__).length !== 0; + } + responseCallback(id, ...args) { + const f = this.id2Callback(id); + if (f instanceof Function) { + const argumentsList = []; + for (let i = 1; i < arguments.length; i++) { + argumentsList.push(arguments[i]); + } + return Reflect.apply(f, this, argumentsList); + } + else { + loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`); + } + } + toModel() { + return this.nativeViewModel; + } + let(block) { + block(this); + } + also(block) { + block(this); + return this; + } + apply(config) { + for (let key in config) { + Reflect.set(this, key, Reflect.get(config, key, config), this); + } + return this; + } + in(group) { + group.addChild(this); + return this; + } + nativeChannel(context, name) { + let thisView = this; + return function (args = undefined) { + const viewIds = []; + while (thisView != undefined) { + viewIds.push(thisView.viewId); + thisView = thisView.superview; + } + const params = { + viewIds: viewIds.reverse(), + name, + args, + }; + return context.callNative('shader', 'command', params); + }; + } + getWidth(context) { + return this.nativeChannel(context, 'getWidth')(); + } + getHeight(context) { + return this.nativeChannel(context, 'getHeight')(); + } + getX(context) { + return this.nativeChannel(context, 'getX')(); + } + getY(context) { + return this.nativeChannel(context, 'getY')(); + } + getLocationOnScreen(context) { + return this.nativeChannel(context, "getLocationOnScreen")(); + } + doAnimation(context, animation) { + return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => { + for (let key in args) { + Reflect.set(this, key, Reflect.get(args, key, args), this); + Reflect.deleteProperty(this.__dirty_props__, key); + } + }); + } } -} -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "width", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "height", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "x", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "y", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "backgroundColor", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "corners", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "border", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "shadow", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "alpha", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], View.prototype, "hidden", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "padding", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "layoutConfig", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], View.prototype, "onClick", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "translationX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "translationY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "scaleX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "scaleY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "pivotX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "pivotY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "rotation", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "flexConfig", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "width", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "height", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "x", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "y", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "backgroundColor", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "corners", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "border", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "shadow", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "alpha", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], View.prototype, "hidden", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "padding", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "layoutConfig", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], View.prototype, "onClick", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "translationX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "translationY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "scaleX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "scaleY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "pivotX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "pivotY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "rotation", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "flexConfig", void 0); + return View; +})(); class Superview extends View { subviewById(id) { for (let v of this.allSubviews()) { @@ -1925,64 +1928,67 @@ const BOTTOM = (END | SPECIFIED) << SHIFT_Y; const CENTER_X = SPECIFIED << SHIFT_X; const CENTER_Y = SPECIFIED << SHIFT_Y; const CENTER = CENTER_X | CENTER_Y; -class Gravity { - constructor() { - this.val = 0; +let Gravity = /** @class */ (() => { + class Gravity { + constructor() { + this.val = 0; + } + left() { + const val = this.val | LEFT; + const ret = new Gravity; + ret.val = val; + return ret; + } + right() { + const val = this.val | RIGHT; + const ret = new Gravity; + ret.val = val; + return ret; + } + top() { + const val = this.val | TOP; + const ret = new Gravity; + ret.val = val; + return ret; + } + bottom() { + const val = this.val | BOTTOM; + const ret = new Gravity; + ret.val = val; + return ret; + } + center() { + const val = this.val | CENTER; + const ret = new Gravity; + ret.val = val; + return ret; + } + centerX() { + const val = this.val | CENTER_X; + const ret = new Gravity; + ret.val = val; + return ret; + } + centerY() { + const val = this.val | CENTER_Y; + const ret = new Gravity; + ret.val = val; + return ret; + } + toModel() { + return this.val; + } } - left() { - const val = this.val | LEFT; - const ret = new Gravity; - ret.val = val; - return ret; - } - right() { - const val = this.val | RIGHT; - const ret = new Gravity; - ret.val = val; - return ret; - } - top() { - const val = this.val | TOP; - const ret = new Gravity; - ret.val = val; - return ret; - } - bottom() { - const val = this.val | BOTTOM; - const ret = new Gravity; - ret.val = val; - return ret; - } - center() { - const val = this.val | CENTER; - const ret = new Gravity; - ret.val = val; - return ret; - } - centerX() { - const val = this.val | CENTER_X; - const ret = new Gravity; - ret.val = val; - return ret; - } - centerY() { - const val = this.val | CENTER_Y; - const ret = new Gravity; - ret.val = val; - return ret; - } - toModel() { - return this.val; - } -} -Gravity.origin = new Gravity; -Gravity.Center = Gravity.origin.center(); -Gravity.CenterX = Gravity.origin.centerX(); -Gravity.CenterY = Gravity.origin.centerY(); -Gravity.Left = Gravity.origin.left(); -Gravity.Right = Gravity.origin.right(); -Gravity.Top = Gravity.origin.top(); -Gravity.Bottom = Gravity.origin.bottom(); + Gravity.origin = new Gravity; + Gravity.Center = Gravity.origin.center(); + Gravity.CenterX = Gravity.origin.centerX(); + Gravity.CenterY = Gravity.origin.centerY(); + Gravity.Left = Gravity.origin.left(); + Gravity.Right = Gravity.origin.right(); + Gravity.Top = Gravity.origin.top(); + Gravity.Bottom = Gravity.origin.bottom(); + return Gravity; +})(); function gravity() { return new Gravity; } @@ -2080,16 +2086,19 @@ class Stack extends Group { } class Root extends Stack { } -class LinearLayout extends Group { -} -__decorate$1([ - Property, - __metadata$1("design:type", Number) -], LinearLayout.prototype, "space", void 0); -__decorate$1([ - Property, - __metadata$1("design:type", Gravity) -], LinearLayout.prototype, "gravity", void 0); +let LinearLayout = /** @class */ (() => { + class LinearLayout extends Group { + } + __decorate$1([ + Property, + __metadata$1("design:type", Number) + ], LinearLayout.prototype, "space", void 0); + __decorate$1([ + Property, + __metadata$1("design:type", Gravity) + ], LinearLayout.prototype, "gravity", void 0); + return LinearLayout; +})(); class VLayout extends LinearLayout { } class HLayout extends LinearLayout { @@ -2166,231 +2175,234 @@ function NativeCall(target, propertyKey, descriptor) { }; return descriptor; } -class Panel { - constructor() { - this.destroyed = false; - this.__root__ = new Root; - this.headviews = new Map; - this.onRenderFinishedCallback = []; - this.__rendering__ = false; - } - onCreate() { } - onDestroy() { } - onShow() { } - onHidden() { } - addHeadView(type, v) { - let map = this.headviews.get(type); - if (map) { - map.set(v.viewId, v); +let Panel = /** @class */ (() => { + class Panel { + constructor() { + this.destroyed = false; + this.__root__ = new Root; + this.headviews = new Map; + this.onRenderFinishedCallback = []; + this.__rendering__ = false; } - else { - map = new Map; - map.set(v.viewId, v); - this.headviews.set(type, map); - } - } - allHeadViews() { - return this.headviews.values(); - } - removeHeadView(type, v) { - if (this.headviews.has(type)) { + onCreate() { } + onDestroy() { } + onShow() { } + onHidden() { } + addHeadView(type, v) { let map = this.headviews.get(type); if (map) { - if (v instanceof View) { - map.delete(v.viewId); - } - else { - map.delete(v); - } - } - } - } - clearHeadViews(type) { - if (this.headviews.has(type)) { - this.headviews.delete(type); - } - } - getRootView() { - return this.__root__; - } - getInitData() { - return this.__data__; - } - __init__(data) { - if (data) { - this.__data__ = JSON.parse(data); - } - } - __onCreate__() { - this.onCreate(); - } - __onDestroy__() { - this.destroyed = true; - this.onDestroy(); - } - __onShow__() { - this.onShow(); - } - __onHidden__() { - this.onHidden(); - } - __build__(frame) { - this.__root__.width = frame.width; - this.__root__.height = frame.height; - this.__root__.children.length = 0; - this.build(this.__root__); - } - __response__(viewIds, callbackId) { - const v = this.retrospectView(viewIds); - if (v === undefined) { - loge(`Cannot find view for ${viewIds}`); - } - else { - const argumentsList = [callbackId]; - for (let i = 2; i < arguments.length; i++) { - argumentsList.push(arguments[i]); - } - return Reflect.apply(v.responseCallback, v, argumentsList); - } - } - retrospectView(ids) { - return ids.reduce((acc, cur) => { - if (acc === undefined) { - if (cur === this.__root__.viewId) { - return this.__root__; - } - for (let map of this.headviews.values()) { - if (map.has(cur)) { - return map.get(cur); - } - } - return undefined; + map.set(v.viewId, v); } else { - if (Reflect.has(acc, "subviewById")) { - return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]); - } - return acc; - } - }, undefined); - } - nativeRender(model) { - return this.context.callNative("shader", "render", model); - } - hookBeforeNativeCall() { - if (Environment.platform !== 'web') { - this.__root__.clean(); - for (let map of this.headviews.values()) { - for (let v of map.values()) { - v.clean(); - } + map = new Map; + map.set(v.viewId, v); + this.headviews.set(type, map); } } - } - hookAfterNativeCall() { - if (this.destroyed) { - return; + allHeadViews() { + return this.headviews.values(); } - const promises = []; - if (Environment.platform !== 'web') { - //Here insert a native call to ensure the promise is resolved done. - nativeEmpty(); - if (this.__root__.isDirty()) { - const model = this.__root__.toModel(); - promises.push(this.nativeRender(model)); - } - for (let map of this.headviews.values()) { - for (let v of map.values()) { - if (v.isDirty()) { - const model = v.toModel(); - promises.push(this.nativeRender(model)); + removeHeadView(type, v) { + if (this.headviews.has(type)) { + let map = this.headviews.get(type); + if (map) { + if (v instanceof View) { + map.delete(v.viewId); + } + else { + map.delete(v); } } } } - else { - Promise.resolve().then(() => { + clearHeadViews(type) { + if (this.headviews.has(type)) { + this.headviews.delete(type); + } + } + getRootView() { + return this.__root__; + } + getInitData() { + return this.__data__; + } + __init__(data) { + if (data) { + this.__data__ = JSON.parse(data); + } + } + __onCreate__() { + this.onCreate(); + } + __onDestroy__() { + this.destroyed = true; + this.onDestroy(); + } + __onShow__() { + this.onShow(); + } + __onHidden__() { + this.onHidden(); + } + __build__(frame) { + this.__root__.width = frame.width; + this.__root__.height = frame.height; + this.__root__.children.length = 0; + this.build(this.__root__); + } + __response__(viewIds, callbackId) { + const v = this.retrospectView(viewIds); + if (v === undefined) { + loge(`Cannot find view for ${viewIds}`); + } + else { + const argumentsList = [callbackId]; + for (let i = 2; i < arguments.length; i++) { + argumentsList.push(arguments[i]); + } + return Reflect.apply(v.responseCallback, v, argumentsList); + } + } + retrospectView(ids) { + return ids.reduce((acc, cur) => { + if (acc === undefined) { + if (cur === this.__root__.viewId) { + return this.__root__; + } + for (let map of this.headviews.values()) { + if (map.has(cur)) { + return map.get(cur); + } + } + return undefined; + } + else { + if (Reflect.has(acc, "subviewById")) { + return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]); + } + return acc; + } + }, undefined); + } + nativeRender(model) { + return this.context.callNative("shader", "render", model); + } + hookBeforeNativeCall() { + if (Environment.platform !== 'web') { + this.__root__.clean(); + for (let map of this.headviews.values()) { + for (let v of map.values()) { + v.clean(); + } + } + } + } + hookAfterNativeCall() { + if (this.destroyed) { + return; + } + const promises = []; + if (Environment.platform !== 'web') { + //Here insert a native call to ensure the promise is resolved done. + nativeEmpty(); if (this.__root__.isDirty()) { const model = this.__root__.toModel(); promises.push(this.nativeRender(model)); - this.__root__.clean(); } for (let map of this.headviews.values()) { for (let v of map.values()) { if (v.isDirty()) { const model = v.toModel(); promises.push(this.nativeRender(model)); - v.clean(); } } } - }); + } + else { + Promise.resolve().then(() => { + if (this.__root__.isDirty()) { + const model = this.__root__.toModel(); + promises.push(this.nativeRender(model)); + this.__root__.clean(); + } + for (let map of this.headviews.values()) { + for (let v of map.values()) { + if (v.isDirty()) { + const model = v.toModel(); + promises.push(this.nativeRender(model)); + v.clean(); + } + } + } + }); + } + if (this.__rendering__) { + //skip + Promise.all(promises).then(_ => { + }); + } + else { + this.__rendering__ = true; + Promise.all(promises).then(_ => { + this.__rendering__ = false; + this.onRenderFinished(); + }); + } } - if (this.__rendering__) { - //skip - Promise.all(promises).then(_ => { + onRenderFinished() { + this.onRenderFinishedCallback.forEach(e => { + e(); }); + this.onRenderFinishedCallback.length = 0; } - else { - this.__rendering__ = true; - Promise.all(promises).then(_ => { - this.__rendering__ = false; - this.onRenderFinished(); - }); + addOnRenderFinishedCallback(cb) { + this.onRenderFinishedCallback.push(cb); } } - onRenderFinished() { - this.onRenderFinishedCallback.forEach(e => { - e(); - }); - this.onRenderFinishedCallback.length = 0; - } - addOnRenderFinishedCallback(cb) { - this.onRenderFinishedCallback.push(cb); - } -} -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", [String]), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__init__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onCreate__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onDestroy__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onShow__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", []), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__onHidden__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", [Object]), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__build__", null); -__decorate$2([ - NativeCall, - __metadata$2("design:type", Function), - __metadata$2("design:paramtypes", [Array, String]), - __metadata$2("design:returntype", void 0) -], Panel.prototype, "__response__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", [String]), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__init__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onCreate__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onDestroy__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onShow__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", []), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__onHidden__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", [Object]), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__build__", null); + __decorate$2([ + NativeCall, + __metadata$2("design:type", Function), + __metadata$2("design:paramtypes", [Array, String]), + __metadata$2("design:returntype", void 0) + ], Panel.prototype, "__response__", null); + return Panel; +})(); /* * Copyright [2019] [Doric.Pub] @@ -2611,57 +2623,60 @@ class AnimationSet { /** * Store color as format AARRGGBB or RRGGBB */ -class Color { - constructor(v) { - this._value = 0; - this._value = v | 0x0; - } - static parse(str) { - if (!str.startsWith("#")) { - throw new Error(`Parse color error with ${str}`); +let Color = /** @class */ (() => { + class Color { + constructor(v) { + this._value = 0; + this._value = v | 0x0; } - const val = parseInt(str.substr(1), 16); - if (str.length === 7) { - return new Color(val | 0xff000000); + static parse(str) { + if (!str.startsWith("#")) { + throw new Error(`Parse color error with ${str}`); + } + const val = parseInt(str.substr(1), 16); + if (str.length === 7) { + return new Color(val | 0xff000000); + } + else if (str.length === 9) { + return new Color(val); + } + else { + throw new Error(`Parse color error with ${str}`); + } } - else if (str.length === 9) { - return new Color(val); + static safeParse(str, defVal = Color.TRANSPARENT) { + let color = defVal; + try { + color = Color.parse(str); + } + catch (e) { + } + finally { + return color; + } } - else { - throw new Error(`Parse color error with ${str}`); + alpha(v) { + v = v * 255; + return new Color((this._value & 0xffffff) | ((v & 0xff) << 24)); + } + toModel() { + return this._value; } } - static safeParse(str, defVal = Color.TRANSPARENT) { - let color = defVal; - try { - color = Color.parse(str); - } - catch (e) { - } - finally { - return color; - } - } - alpha(v) { - v = v * 255; - return new Color((this._value & 0xffffff) | ((v & 0xff) << 24)); - } - toModel() { - return this._value; - } -} -Color.BLACK = new Color(0xFF000000); -Color.DKGRAY = new Color(0xFF444444); -Color.GRAY = new Color(0xFF888888); -Color.LTGRAY = new Color(0xFFCCCCCC); -Color.WHITE = new Color(0xFFFFFFFF); -Color.RED = new Color(0xFFFF0000); -Color.GREEN = new Color(0xFF00FF00); -Color.BLUE = new Color(0xFF0000FF); -Color.YELLOW = new Color(0xFFFFFF00); -Color.CYAN = new Color(0xFF00FFFF); -Color.MAGENTA = new Color(0xFFFF00FF); -Color.TRANSPARENT = new Color(0); + Color.BLACK = new Color(0xFF000000); + Color.DKGRAY = new Color(0xFF444444); + Color.GRAY = new Color(0xFF888888); + Color.LTGRAY = new Color(0xFFCCCCCC); + Color.WHITE = new Color(0xFFFFFFFF); + Color.RED = new Color(0xFFFF0000); + Color.GREEN = new Color(0xFF00FF00); + Color.BLUE = new Color(0xFF0000FF); + Color.YELLOW = new Color(0xFFFFFF00); + Color.CYAN = new Color(0xFF00FFFF); + Color.MAGENTA = new Color(0xFFFF00FF); + Color.TRANSPARENT = new Color(0); + return Color; +})(); (function (GradientOrientation) { /** draw the gradient from the top to the bottom */ GradientOrientation[GradientOrientation["TOP_BOTTOM"] = 0] = "TOP_BOTTOM"; @@ -2696,64 +2711,67 @@ var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) { TruncateAt[TruncateAt["Start"] = 2] = "Start"; TruncateAt[TruncateAt["Clip"] = 3] = "Clip"; })(exports.TruncateAt || (exports.TruncateAt = {})); -class Text extends View { -} -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "text", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Color) -], Text.prototype, "textColor", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "textSize", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "maxLines", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Gravity) -], Text.prototype, "textAlignment", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "fontStyle", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "font", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "maxWidth", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "maxHeight", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "lineSpacing", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Boolean) -], Text.prototype, "strikethrough", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Boolean) -], Text.prototype, "underline", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", String) -], Text.prototype, "htmlText", void 0); -__decorate$3([ - Property, - __metadata$3("design:type", Number) -], Text.prototype, "truncateAt", void 0); +let Text = /** @class */ (() => { + class Text extends View { + } + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "text", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Color) + ], Text.prototype, "textColor", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "textSize", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "maxLines", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Gravity) + ], Text.prototype, "textAlignment", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "fontStyle", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "font", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "maxWidth", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "maxHeight", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "lineSpacing", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Boolean) + ], Text.prototype, "strikethrough", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Boolean) + ], Text.prototype, "underline", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", String) + ], Text.prototype, "htmlText", void 0); + __decorate$3([ + Property, + __metadata$3("design:type", Number) + ], Text.prototype, "truncateAt", void 0); + return Text; +})(); function text(config) { const ret = new Text; ret.layoutConfig = layoutConfig().fit(); @@ -2777,73 +2795,76 @@ var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) { ScaleType[ScaleType["ScaleAspectFit"] = 1] = "ScaleAspectFit"; ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill"; })(exports.ScaleType || (exports.ScaleType = {})); -class Image extends View { -} -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imageUrl", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imagePath", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imageRes", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "imageBase64", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Number) -], Image.prototype, "scaleType", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Boolean) -], Image.prototype, "isBlur", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "placeHolderImage", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "placeHolderImageBase64", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Color - /** - * Display while image is failed to load - * It can be file name in local path - */ - ) -], Image.prototype, "placeHolderColor", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "errorImage", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", String) -], Image.prototype, "errorImageBase64", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Color) -], Image.prototype, "errorColor", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Function) -], Image.prototype, "loadCallback", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Number) -], Image.prototype, "imageScale", void 0); -__decorate$4([ - Property, - __metadata$4("design:type", Object) -], Image.prototype, "stretchInset", void 0); +let Image = /** @class */ (() => { + class Image extends View { + } + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imageUrl", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imagePath", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imageRes", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "imageBase64", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Number) + ], Image.prototype, "scaleType", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Boolean) + ], Image.prototype, "isBlur", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "placeHolderImage", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "placeHolderImageBase64", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Color + /** + * Display while image is failed to load + * It can be file name in local path + */ + ) + ], Image.prototype, "placeHolderColor", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "errorImage", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", String) + ], Image.prototype, "errorImageBase64", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Color) + ], Image.prototype, "errorColor", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Function) + ], Image.prototype, "loadCallback", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Number) + ], Image.prototype, "imageScale", void 0); + __decorate$4([ + Property, + __metadata$4("design:type", Object) + ], Image.prototype, "stretchInset", void 0); + return Image; +})(); function image(config) { const ret = new Image; ret.layoutConfig = layoutConfig().fit(); @@ -2877,101 +2898,106 @@ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, var __metadata$5 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class ListItem extends Stack { -} -__decorate$5([ - Property, - __metadata$5("design:type", String) -], ListItem.prototype, "identifier", void 0); -class List extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.itemCount = 0; - this.batchCount = 15; +let ListItem = /** @class */ (() => { + class ListItem extends Stack { } - allSubviews() { - if (this.loadMoreView) { - return [...this.cachedViews.values(), this.loadMoreView]; - } - else { - return this.cachedViews.values(); - } - } - scrollToItem(context, index, config) { - var _a; - const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated; - return this.nativeChannel(context, 'scrollToItem')({ index, animated, }); - } - reset() { - this.cachedViews.clear(); - this.itemCount = 0; - } - getItem(itemIdx) { - let view = this.renderItem(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate$5([ + Property, + __metadata$5("design:type", String) + ], ListItem.prototype, "identifier", void 0); + return ListItem; +})(); +let List = /** @class */ (() => { + class List extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.itemCount = 0; + this.batchCount = 15; } - return super.isDirty(); - } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { - const listItem = this.getItem(start + idx); - return listItem.toModel(); - }); - } - toModel() { - if (this.loadMoreView) { - this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + allSubviews() { + if (this.loadMoreView) { + return [...this.cachedViews.values(), this.loadMoreView]; + } + else { + return this.cachedViews.values(); + } + } + scrollToItem(context, index, config) { + const animated = config === null || config === void 0 ? void 0 : config.animated; + return this.nativeChannel(context, 'scrollToItem')({ index, animated, }); + } + reset() { + this.cachedViews.clear(); + this.itemCount = 0; + } + getItem(itemIdx) { + let view = this.renderItem(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { + const listItem = this.getItem(start + idx); + return listItem.toModel(); + }); + } + toModel() { + if (this.loadMoreView) { + this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + } + return super.toModel(); } - return super.toModel(); } -} -__decorate$5([ - Property, - __metadata$5("design:type", Object) -], List.prototype, "itemCount", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "renderItem", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Object) -], List.prototype, "batchCount", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "onLoadMore", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Boolean) -], List.prototype, "loadMore", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", ListItem) -], List.prototype, "loadMoreView", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "onScroll", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Function) -], List.prototype, "onScrollEnd", void 0); -__decorate$5([ - Property, - __metadata$5("design:type", Number) -], List.prototype, "scrolledPosition", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Object) + ], List.prototype, "itemCount", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "renderItem", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Object) + ], List.prototype, "batchCount", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "onLoadMore", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Boolean) + ], List.prototype, "loadMore", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", ListItem) + ], List.prototype, "loadMoreView", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "onScroll", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Function) + ], List.prototype, "onScrollEnd", void 0); + __decorate$5([ + Property, + __metadata$5("design:type", Number) + ], List.prototype, "scrolledPosition", void 0); + return List; +})(); function list(config) { const ret = new List; for (let key in config) { @@ -3007,71 +3033,77 @@ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, var __metadata$6 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class SlideItem extends Stack { -} -__decorate$6([ - Property, - __metadata$6("design:type", String) -], SlideItem.prototype, "identifier", void 0); -class Slider extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.itemCount = 0; - this.batchCount = 3; +let SlideItem = /** @class */ (() => { + class SlideItem extends Stack { } - allSubviews() { - return this.cachedViews.values(); - } - getItem(itemIdx) { - let view = this.renderPage(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate$6([ + Property, + __metadata$6("design:type", String) + ], SlideItem.prototype, "identifier", void 0); + return SlideItem; +})(); +let Slider = /** @class */ (() => { + class Slider extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.itemCount = 0; + this.batchCount = 3; + } + allSubviews() { + return this.cachedViews.values(); + } + getItem(itemIdx) { + let view = this.renderPage(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { + const slideItem = this.getItem(start + idx); + return slideItem.toModel(); + }); + } + slidePage(context, page, smooth = false) { + return this.nativeChannel(context, "slidePage")({ page, smooth }); + } + getSlidedPage(context) { + return this.nativeChannel(context, "getSlidedPage")(); } - return super.isDirty(); } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { - const slideItem = this.getItem(start + idx); - return slideItem.toModel(); - }); - } - slidePage(context, page, smooth = false) { - return this.nativeChannel(context, "slidePage")({ page, smooth }); - } - getSlidedPage(context) { - return this.nativeChannel(context, "getSlidedPage")(); - } -} -__decorate$6([ - Property, - __metadata$6("design:type", Object) -], Slider.prototype, "itemCount", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Function) -], Slider.prototype, "renderPage", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Object) -], Slider.prototype, "batchCount", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Function) -], Slider.prototype, "onPageSlided", void 0); -__decorate$6([ - Property, - __metadata$6("design:type", Boolean) -], Slider.prototype, "loop", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Object) + ], Slider.prototype, "itemCount", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Function) + ], Slider.prototype, "renderPage", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Object) + ], Slider.prototype, "batchCount", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Function) + ], Slider.prototype, "onPageSlided", void 0); + __decorate$6([ + Property, + __metadata$6("design:type", Boolean) + ], Slider.prototype, "loop", void 0); + return Slider; +})(); function slider(config) { const ret = new Slider; for (let key in config) { @@ -3118,33 +3150,36 @@ function scroller(content, config) { v.content = content; }); } -class Scroller extends Superview { - allSubviews() { - return [this.content]; +let Scroller = /** @class */ (() => { + class Scroller extends Superview { + allSubviews() { + return [this.content]; + } + toModel() { + this.dirtyProps.content = this.content.viewId; + return super.toModel(); + } + scrollTo(context, offset, animated) { + return this.nativeChannel(context, "scrollTo")({ offset, animated }); + } + scrollBy(context, offset, animated) { + return this.nativeChannel(context, "scrollBy")({ offset, animated }); + } } - toModel() { - this.dirtyProps.content = this.content.viewId; - return super.toModel(); - } - scrollTo(context, offset, animated) { - return this.nativeChannel(context, "scrollTo")({ offset, animated }); - } - scrollBy(context, offset, animated) { - return this.nativeChannel(context, "scrollBy")({ offset, animated }); - } -} -__decorate$7([ - Property, - __metadata$7("design:type", Object) -], Scroller.prototype, "contentOffset", void 0); -__decorate$7([ - Property, - __metadata$7("design:type", Function) -], Scroller.prototype, "onScroll", void 0); -__decorate$7([ - Property, - __metadata$7("design:type", Function) -], Scroller.prototype, "onScrollEnd", void 0); + __decorate$7([ + Property, + __metadata$7("design:type", Object) + ], Scroller.prototype, "contentOffset", void 0); + __decorate$7([ + Property, + __metadata$7("design:type", Function) + ], Scroller.prototype, "onScroll", void 0); + __decorate$7([ + Property, + __metadata$7("design:type", Function) + ], Scroller.prototype, "onScrollEnd", void 0); + return Scroller; +})(); var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; @@ -3155,36 +3190,39 @@ var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, var __metadata$8 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Refreshable extends Superview { - allSubviews() { - const ret = [this.content]; - if (this.header) { - ret.push(this.header); +let Refreshable = /** @class */ (() => { + class Refreshable extends Superview { + allSubviews() { + const ret = [this.content]; + if (this.header) { + ret.push(this.header); + } + return ret; + } + setRefreshable(context, refreshable) { + return this.nativeChannel(context, 'setRefreshable')(refreshable); + } + setRefreshing(context, refreshing) { + return this.nativeChannel(context, 'setRefreshing')(refreshing); + } + isRefreshable(context) { + return this.nativeChannel(context, 'isRefreshable')(); + } + isRefreshing(context) { + return this.nativeChannel(context, 'isRefreshing')(); + } + toModel() { + this.dirtyProps.content = this.content.viewId; + this.dirtyProps.header = (this.header || {}).viewId; + return super.toModel(); } - return ret; } - setRefreshable(context, refreshable) { - return this.nativeChannel(context, 'setRefreshable')(refreshable); - } - setRefreshing(context, refreshing) { - return this.nativeChannel(context, 'setRefreshing')(refreshing); - } - isRefreshable(context) { - return this.nativeChannel(context, 'isRefreshable')(); - } - isRefreshing(context) { - return this.nativeChannel(context, 'isRefreshing')(); - } - toModel() { - this.dirtyProps.content = this.content.viewId; - this.dirtyProps.header = (this.header || {}).viewId; - return super.toModel(); - } -} -__decorate$8([ - Property, - __metadata$8("design:type", Function) -], Refreshable.prototype, "onRefresh", void 0); + __decorate$8([ + Property, + __metadata$8("design:type", Function) + ], Refreshable.prototype, "onRefresh", void 0); + return Refreshable; +})(); function refreshable(config) { const ret = new Refreshable; ret.layoutConfig = layoutConfig().fit(); @@ -3207,29 +3245,32 @@ var ValueType; ValueType[ValueType["Percent"] = 2] = "Percent"; ValueType[ValueType["Auto"] = 3] = "Auto"; })(ValueType || (ValueType = {})); -class FlexTypedValue { - constructor(type) { - this.value = 0; - this.type = type; +let FlexTypedValue = /** @class */ (() => { + class FlexTypedValue { + constructor(type) { + this.value = 0; + this.type = type; + } + static percent(v) { + const ret = new FlexTypedValue(ValueType.Percent); + ret.value = v; + return ret; + } + static point(v) { + const ret = new FlexTypedValue(ValueType.Point); + ret.value = v; + return ret; + } + toModel() { + return { + type: this.type, + value: this.value, + }; + } } - static percent(v) { - const ret = new FlexTypedValue(ValueType.Percent); - ret.value = v; - return ret; - } - static point(v) { - const ret = new FlexTypedValue(ValueType.Point); - ret.value = v; - return ret; - } - toModel() { - return { - type: this.type, - value: this.value, - }; - } -} -FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto); + FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto); + return FlexTypedValue; +})(); (function (FlexDirection) { FlexDirection[FlexDirection["COLUMN"] = 0] = "COLUMN"; FlexDirection[FlexDirection["COLUMN_REVERSE"] = 1] = "COLUMN_REVERSE"; @@ -3287,105 +3328,111 @@ var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, var __metadata$9 = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class FlowLayoutItem extends Stack { -} -__decorate$9([ - Property, - __metadata$9("design:type", String) -], FlowLayoutItem.prototype, "identifier", void 0); -class FlowLayout extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.columnCount = 2; - this.itemCount = 0; - this.batchCount = 15; +let FlowLayoutItem = /** @class */ (() => { + class FlowLayoutItem extends Stack { } - allSubviews() { - if (this.loadMoreView) { - return [...this.cachedViews.values(), this.loadMoreView]; - } - else { - return this.cachedViews.values(); - } - } - reset() { - this.cachedViews.clear(); - this.itemCount = 0; - } - getItem(itemIdx) { - let view = this.renderItem(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate$9([ + Property, + __metadata$9("design:type", String) + ], FlowLayoutItem.prototype, "identifier", void 0); + return FlowLayoutItem; +})(); +let FlowLayout = /** @class */ (() => { + class FlowLayout extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.columnCount = 2; + this.itemCount = 0; + this.batchCount = 15; } - return super.isDirty(); - } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { - const listItem = this.getItem(start + idx); - return listItem.toModel(); - }); - } - toModel() { - if (this.loadMoreView) { - this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + allSubviews() { + if (this.loadMoreView) { + return [...this.cachedViews.values(), this.loadMoreView]; + } + else { + return this.cachedViews.values(); + } + } + reset() { + this.cachedViews.clear(); + this.itemCount = 0; + } + getItem(itemIdx) { + let view = this.renderItem(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { + const listItem = this.getItem(start + idx); + return listItem.toModel(); + }); + } + toModel() { + if (this.loadMoreView) { + this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + } + return super.toModel(); } - return super.toModel(); } -} -__decorate$9([ - Property, - __metadata$9("design:type", Object) -], FlowLayout.prototype, "columnCount", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Number) -], FlowLayout.prototype, "columnSpace", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Number) -], FlowLayout.prototype, "rowSpace", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Object) -], FlowLayout.prototype, "itemCount", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "renderItem", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Object) -], FlowLayout.prototype, "batchCount", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "onLoadMore", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Boolean) -], FlowLayout.prototype, "loadMore", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", FlowLayoutItem) -], FlowLayout.prototype, "loadMoreView", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "onScroll", void 0); -__decorate$9([ - Property, - __metadata$9("design:type", Function) -], FlowLayout.prototype, "onScrollEnd", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Object) + ], FlowLayout.prototype, "columnCount", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Number) + ], FlowLayout.prototype, "columnSpace", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Number) + ], FlowLayout.prototype, "rowSpace", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Object) + ], FlowLayout.prototype, "itemCount", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "renderItem", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Object) + ], FlowLayout.prototype, "batchCount", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "onLoadMore", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Boolean) + ], FlowLayout.prototype, "loadMore", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", FlowLayoutItem) + ], FlowLayout.prototype, "loadMoreView", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "onScroll", void 0); + __decorate$9([ + Property, + __metadata$9("design:type", Function) + ], FlowLayout.prototype, "onScrollEnd", void 0); + return FlowLayout; +})(); function flowlayout(config) { const ret = new FlowLayout; for (let key in config) { @@ -3421,63 +3468,66 @@ var __decorate$a = (undefined && undefined.__decorate) || function (decorators, var __metadata$a = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Input extends View { - getText(context) { - return this.nativeChannel(context, 'getText')(); +let Input = /** @class */ (() => { + class Input extends View { + getText(context) { + return this.nativeChannel(context, 'getText')(); + } + setSelection(context, start, end = start) { + return this.nativeChannel(context, 'setSelection')({ + start, + end, + }); + } + requestFocus(context) { + return this.nativeChannel(context, 'requestFocus')(); + } + releaseFocus(context) { + return this.nativeChannel(context, 'releaseFocus')(); + } } - setSelection(context, start, end = start) { - return this.nativeChannel(context, 'setSelection')({ - start, - end, - }); - } - requestFocus(context) { - return this.nativeChannel(context, 'requestFocus')(); - } - releaseFocus(context) { - return this.nativeChannel(context, 'releaseFocus')(); - } -} -__decorate$a([ - Property, - __metadata$a("design:type", String) -], Input.prototype, "text", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Color) -], Input.prototype, "textColor", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Number) -], Input.prototype, "textSize", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", String) -], Input.prototype, "hintText", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Color) -], Input.prototype, "hintTextColor", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Boolean) -], Input.prototype, "multiline", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Gravity) -], Input.prototype, "textAlignment", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Function) -], Input.prototype, "onTextChange", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Function) -], Input.prototype, "onFocusChange", void 0); -__decorate$a([ - Property, - __metadata$a("design:type", Number) -], Input.prototype, "maxLength", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", String) + ], Input.prototype, "text", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Color) + ], Input.prototype, "textColor", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Number) + ], Input.prototype, "textSize", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", String) + ], Input.prototype, "hintText", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Color) + ], Input.prototype, "hintTextColor", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Boolean) + ], Input.prototype, "multiline", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Gravity) + ], Input.prototype, "textAlignment", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Function) + ], Input.prototype, "onTextChange", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Function) + ], Input.prototype, "onFocusChange", void 0); + __decorate$a([ + Property, + __metadata$a("design:type", Number) + ], Input.prototype, "maxLength", void 0); + return Input; +})(); function input(config) { const ret = new Input; ret.layoutConfig = layoutConfig().just(); @@ -3496,21 +3546,24 @@ var __decorate$b = (undefined && undefined.__decorate) || function (decorators, var __metadata$b = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class NestedSlider extends Group { - addSlideItem(view) { - this.addChild(view); +let NestedSlider = /** @class */ (() => { + class NestedSlider extends Group { + addSlideItem(view) { + this.addChild(view); + } + slidePage(context, page, smooth = false) { + return this.nativeChannel(context, "slidePage")({ page, smooth }); + } + getSlidedPage(context) { + return this.nativeChannel(context, "getSlidedPage")(); + } } - slidePage(context, page, smooth = false) { - return this.nativeChannel(context, "slidePage")({ page, smooth }); - } - getSlidedPage(context) { - return this.nativeChannel(context, "getSlidedPage")(); - } -} -__decorate$b([ - Property, - __metadata$b("design:type", Function) -], NestedSlider.prototype, "onPageSlided", void 0); + __decorate$b([ + Property, + __metadata$b("design:type", Function) + ], NestedSlider.prototype, "onPageSlided", void 0); + return NestedSlider; +})(); var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; @@ -3521,12 +3574,15 @@ var __decorate$c = (undefined && undefined.__decorate) || function (decorators, var __metadata$c = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Draggable extends Stack { -} -__decorate$c([ - Property, - __metadata$c("design:type", Function) -], Draggable.prototype, "onDrag", void 0); +let Draggable = /** @class */ (() => { + class Draggable extends Stack { + } + __decorate$c([ + Property, + __metadata$c("design:type", Function) + ], Draggable.prototype, "onDrag", void 0); + return Draggable; +})(); function draggable(views, config) { const ret = new Draggable; ret.layoutConfig = layoutConfig().fit(); @@ -3555,28 +3611,31 @@ var __decorate$d = (undefined && undefined.__decorate) || function (decorators, var __metadata$d = (undefined && undefined.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -class Switch extends View { -} -__decorate$d([ - Property, - __metadata$d("design:type", Boolean) -], Switch.prototype, "state", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Function) -], Switch.prototype, "onSwitch", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Color) -], Switch.prototype, "offTintColor", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Color) -], Switch.prototype, "onTintColor", void 0); -__decorate$d([ - Property, - __metadata$d("design:type", Color) -], Switch.prototype, "thumbTintColor", void 0); +let Switch = /** @class */ (() => { + class Switch extends View { + } + __decorate$d([ + Property, + __metadata$d("design:type", Boolean) + ], Switch.prototype, "state", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Function) + ], Switch.prototype, "onSwitch", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Color) + ], Switch.prototype, "offTintColor", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Color) + ], Switch.prototype, "onTintColor", void 0); + __decorate$d([ + Property, + __metadata$d("design:type", Color) + ], Switch.prototype, "thumbTintColor", void 0); + return Switch; +})(); function switchView(config) { const ret = new Switch; ret.layoutConfig = layoutConfig().just(); diff --git a/doric-js/index.d.ts b/doric-js/index.d.ts index 58a0336e..6f0a00f1 100644 --- a/doric-js/index.d.ts +++ b/doric-js/index.d.ts @@ -1,6 +1,4 @@ // Generated by dts-bundle v0.7.3 -// Dependencies for this module: -// reflect-metadata declare module 'doric' { export * from 'doric/lib/src/runtime/global'; @@ -12,7 +10,6 @@ declare module 'doric' { } declare module 'doric/lib/src/runtime/global' { - export * from 'reflect-metadata'; export type BridgeContext = { /** * The identify of current context @@ -739,21 +736,21 @@ declare module 'doric/lib/src/native/modal' { alert: (arg: string | { title: string; msg: string; - okLabel?: string | undefined; + okLabel?: string; }) => Promise; confirm: (arg: string | { title: string; msg: string; - okLabel?: string | undefined; - cancelLabel?: string | undefined; + okLabel?: string; + cancelLabel?: string; }) => Promise; prompt: (arg: { - title?: string | undefined; - msg?: string | undefined; - okLabel?: string | undefined; - cancelLabel?: string | undefined; - text?: string | undefined; - defaultText?: string | undefined; + title?: string; + msg?: string; + okLabel?: string; + cancelLabel?: string; + text?: string; + defaultText?: string; }) => Promise; }; } @@ -851,10 +848,10 @@ declare module 'doric/lib/src/native/notification' { import { BridgeContext } from "doric/lib/src/runtime/global"; export function notification(context: BridgeContext): { publish: (args: { - biz?: string | undefined; + biz?: string; name: string; - data?: object | undefined; - androidSystem?: boolean | undefined; + data?: object; + androidSystem?: boolean; }) => Promise; subscribe: (args: { biz?: string | undefined; @@ -889,14 +886,14 @@ declare module 'doric/lib/src/native/coordinator' { import { Color } from "doric/lib/src/util/color"; export function coordinator(context: BridgeContext): { verticalScrolling: (argument: { - scrollable: List | Scroller | FlowLayout; + scrollable: Scroller | List | FlowLayout; scrollRange: { start: number; end: number; }; target: View | "NavBar"; changing: { - name: "width" | "height" | "x" | "y" | "backgroundColor" | "alpha"; + name: "backgroundColor" | "width" | "height" | "x" | "y" | "alpha"; start: number | Color; end: number | Color; }; diff --git a/doric-js/lib/index.js b/doric-js/lib/index.js index 05294bd7..25d3980d 100644 --- a/doric-js/lib/index.js +++ b/doric-js/lib/index.js @@ -1,3 +1,19 @@ +/* + * Copyright [2019] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from './src/runtime/global'; export * from './src/ui/index.ui'; export * from "./src/widget/index.widget"; export * from './src/native/index.native'; diff --git a/doric-js/lib/src/native/coordinator.d.ts b/doric-js/lib/src/native/coordinator.d.ts index b0888a4b..2c275901 100644 --- a/doric-js/lib/src/native/coordinator.d.ts +++ b/doric-js/lib/src/native/coordinator.d.ts @@ -6,14 +6,14 @@ import { View } from "../ui/view"; import { Color } from "../util/color"; export declare function coordinator(context: BridgeContext): { verticalScrolling: (argument: { - scrollable: List | Scroller | FlowLayout; + scrollable: Scroller | List | FlowLayout; scrollRange: { start: number; end: number; }; target: View | "NavBar"; changing: { - name: "width" | "height" | "x" | "y" | "backgroundColor" | "alpha"; + name: "backgroundColor" | "width" | "height" | "x" | "y" | "alpha"; start: number | Color; end: number | Color; }; diff --git a/doric-js/lib/src/native/modal.d.ts b/doric-js/lib/src/native/modal.d.ts index 05cb00cb..0178c305 100644 --- a/doric-js/lib/src/native/modal.d.ts +++ b/doric-js/lib/src/native/modal.d.ts @@ -5,20 +5,20 @@ export declare function modal(context: BridgeContext): { alert: (arg: string | { title: string; msg: string; - okLabel?: string | undefined; + okLabel?: string; }) => Promise; confirm: (arg: string | { title: string; msg: string; - okLabel?: string | undefined; - cancelLabel?: string | undefined; + okLabel?: string; + cancelLabel?: string; }) => Promise; prompt: (arg: { - title?: string | undefined; - msg?: string | undefined; - okLabel?: string | undefined; - cancelLabel?: string | undefined; - text?: string | undefined; - defaultText?: string | undefined; + title?: string; + msg?: string; + okLabel?: string; + cancelLabel?: string; + text?: string; + defaultText?: string; }) => Promise; }; diff --git a/doric-js/lib/src/native/notification.d.ts b/doric-js/lib/src/native/notification.d.ts index 68f40fd7..98a2f410 100644 --- a/doric-js/lib/src/native/notification.d.ts +++ b/doric-js/lib/src/native/notification.d.ts @@ -1,10 +1,10 @@ import { BridgeContext } from "../runtime/global"; export declare function notification(context: BridgeContext): { publish: (args: { - biz?: string | undefined; + biz?: string; name: string; - data?: object | undefined; - androidSystem?: boolean | undefined; + data?: object; + androidSystem?: boolean; }) => Promise; subscribe: (args: { biz?: string | undefined; diff --git a/doric-js/lib/src/runtime/global.d.ts b/doric-js/lib/src/runtime/global.d.ts index 008b7bd9..f29aaec8 100644 --- a/doric-js/lib/src/runtime/global.d.ts +++ b/doric-js/lib/src/runtime/global.d.ts @@ -1,4 +1,3 @@ -export * from 'reflect-metadata'; export declare type BridgeContext = { /** * The identify of current context diff --git a/doric-js/lib/src/ui/panel.js b/doric-js/lib/src/ui/panel.js index 84f5afe9..87a85c63 100644 --- a/doric-js/lib/src/ui/panel.js +++ b/doric-js/lib/src/ui/panel.js @@ -33,228 +33,232 @@ export function NativeCall(target, propertyKey, descriptor) { }; return descriptor; } -export class Panel { - constructor() { - this.destroyed = false; - this.__root__ = new Root; - this.headviews = new Map; - this.onRenderFinishedCallback = []; - this.__rendering__ = false; - } - onCreate() { } - onDestroy() { } - onShow() { } - onHidden() { } - addHeadView(type, v) { - let map = this.headviews.get(type); - if (map) { - map.set(v.viewId, v); +let Panel = /** @class */ (() => { + class Panel { + constructor() { + this.destroyed = false; + this.__root__ = new Root; + this.headviews = new Map; + this.onRenderFinishedCallback = []; + this.__rendering__ = false; } - else { - map = new Map; - map.set(v.viewId, v); - this.headviews.set(type, map); - } - } - allHeadViews() { - return this.headviews.values(); - } - removeHeadView(type, v) { - if (this.headviews.has(type)) { + onCreate() { } + onDestroy() { } + onShow() { } + onHidden() { } + addHeadView(type, v) { let map = this.headviews.get(type); if (map) { - if (v instanceof View) { - map.delete(v.viewId); - } - else { - map.delete(v); - } - } - } - } - clearHeadViews(type) { - if (this.headviews.has(type)) { - this.headviews.delete(type); - } - } - getRootView() { - return this.__root__; - } - getInitData() { - return this.__data__; - } - __init__(data) { - if (data) { - this.__data__ = JSON.parse(data); - } - } - __onCreate__() { - this.onCreate(); - } - __onDestroy__() { - this.destroyed = true; - this.onDestroy(); - } - __onShow__() { - this.onShow(); - } - __onHidden__() { - this.onHidden(); - } - __build__(frame) { - this.__root__.width = frame.width; - this.__root__.height = frame.height; - this.__root__.children.length = 0; - this.build(this.__root__); - } - __response__(viewIds, callbackId) { - const v = this.retrospectView(viewIds); - if (v === undefined) { - loge(`Cannot find view for ${viewIds}`); - } - else { - const argumentsList = [callbackId]; - for (let i = 2; i < arguments.length; i++) { - argumentsList.push(arguments[i]); - } - return Reflect.apply(v.responseCallback, v, argumentsList); - } - } - retrospectView(ids) { - return ids.reduce((acc, cur) => { - if (acc === undefined) { - if (cur === this.__root__.viewId) { - return this.__root__; - } - for (let map of this.headviews.values()) { - if (map.has(cur)) { - return map.get(cur); - } - } - return undefined; + map.set(v.viewId, v); } else { - if (Reflect.has(acc, "subviewById")) { - return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]); - } - return acc; - } - }, undefined); - } - nativeRender(model) { - return this.context.callNative("shader", "render", model); - } - hookBeforeNativeCall() { - if (Environment.platform !== 'web') { - this.__root__.clean(); - for (let map of this.headviews.values()) { - for (let v of map.values()) { - v.clean(); - } + map = new Map; + map.set(v.viewId, v); + this.headviews.set(type, map); } } - } - hookAfterNativeCall() { - if (this.destroyed) { - return; + allHeadViews() { + return this.headviews.values(); } - const promises = []; - if (Environment.platform !== 'web') { - //Here insert a native call to ensure the promise is resolved done. - nativeEmpty(); - if (this.__root__.isDirty()) { - const model = this.__root__.toModel(); - promises.push(this.nativeRender(model)); - } - for (let map of this.headviews.values()) { - for (let v of map.values()) { - if (v.isDirty()) { - const model = v.toModel(); - promises.push(this.nativeRender(model)); + removeHeadView(type, v) { + if (this.headviews.has(type)) { + let map = this.headviews.get(type); + if (map) { + if (v instanceof View) { + map.delete(v.viewId); + } + else { + map.delete(v); } } } } - else { - Promise.resolve().then(() => { + clearHeadViews(type) { + if (this.headviews.has(type)) { + this.headviews.delete(type); + } + } + getRootView() { + return this.__root__; + } + getInitData() { + return this.__data__; + } + __init__(data) { + if (data) { + this.__data__ = JSON.parse(data); + } + } + __onCreate__() { + this.onCreate(); + } + __onDestroy__() { + this.destroyed = true; + this.onDestroy(); + } + __onShow__() { + this.onShow(); + } + __onHidden__() { + this.onHidden(); + } + __build__(frame) { + this.__root__.width = frame.width; + this.__root__.height = frame.height; + this.__root__.children.length = 0; + this.build(this.__root__); + } + __response__(viewIds, callbackId) { + const v = this.retrospectView(viewIds); + if (v === undefined) { + loge(`Cannot find view for ${viewIds}`); + } + else { + const argumentsList = [callbackId]; + for (let i = 2; i < arguments.length; i++) { + argumentsList.push(arguments[i]); + } + return Reflect.apply(v.responseCallback, v, argumentsList); + } + } + retrospectView(ids) { + return ids.reduce((acc, cur) => { + if (acc === undefined) { + if (cur === this.__root__.viewId) { + return this.__root__; + } + for (let map of this.headviews.values()) { + if (map.has(cur)) { + return map.get(cur); + } + } + return undefined; + } + else { + if (Reflect.has(acc, "subviewById")) { + return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur]); + } + return acc; + } + }, undefined); + } + nativeRender(model) { + return this.context.callNative("shader", "render", model); + } + hookBeforeNativeCall() { + if (Environment.platform !== 'web') { + this.__root__.clean(); + for (let map of this.headviews.values()) { + for (let v of map.values()) { + v.clean(); + } + } + } + } + hookAfterNativeCall() { + if (this.destroyed) { + return; + } + const promises = []; + if (Environment.platform !== 'web') { + //Here insert a native call to ensure the promise is resolved done. + nativeEmpty(); if (this.__root__.isDirty()) { const model = this.__root__.toModel(); promises.push(this.nativeRender(model)); - this.__root__.clean(); } for (let map of this.headviews.values()) { for (let v of map.values()) { if (v.isDirty()) { const model = v.toModel(); promises.push(this.nativeRender(model)); - v.clean(); } } } - }); + } + else { + Promise.resolve().then(() => { + if (this.__root__.isDirty()) { + const model = this.__root__.toModel(); + promises.push(this.nativeRender(model)); + this.__root__.clean(); + } + for (let map of this.headviews.values()) { + for (let v of map.values()) { + if (v.isDirty()) { + const model = v.toModel(); + promises.push(this.nativeRender(model)); + v.clean(); + } + } + } + }); + } + if (this.__rendering__) { + //skip + Promise.all(promises).then(_ => { + }); + } + else { + this.__rendering__ = true; + Promise.all(promises).then(_ => { + this.__rendering__ = false; + this.onRenderFinished(); + }); + } } - if (this.__rendering__) { - //skip - Promise.all(promises).then(_ => { + onRenderFinished() { + this.onRenderFinishedCallback.forEach(e => { + e(); }); + this.onRenderFinishedCallback.length = 0; } - else { - this.__rendering__ = true; - Promise.all(promises).then(_ => { - this.__rendering__ = false; - this.onRenderFinished(); - }); + addOnRenderFinishedCallback(cb) { + this.onRenderFinishedCallback.push(cb); } } - onRenderFinished() { - this.onRenderFinishedCallback.forEach(e => { - e(); - }); - this.onRenderFinishedCallback.length = 0; - } - addOnRenderFinishedCallback(cb) { - this.onRenderFinishedCallback.push(cb); - } -} -__decorate([ - NativeCall, - __metadata("design:type", Function), - __metadata("design:paramtypes", [String]), - __metadata("design:returntype", void 0) -], Panel.prototype, "__init__", null); -__decorate([ - NativeCall, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) -], Panel.prototype, "__onCreate__", null); -__decorate([ - NativeCall, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) -], Panel.prototype, "__onDestroy__", null); -__decorate([ - NativeCall, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) -], Panel.prototype, "__onShow__", null); -__decorate([ - NativeCall, - __metadata("design:type", Function), - __metadata("design:paramtypes", []), - __metadata("design:returntype", void 0) -], Panel.prototype, "__onHidden__", null); -__decorate([ - NativeCall, - __metadata("design:type", Function), - __metadata("design:paramtypes", [Object]), - __metadata("design:returntype", void 0) -], Panel.prototype, "__build__", null); -__decorate([ - NativeCall, - __metadata("design:type", Function), - __metadata("design:paramtypes", [Array, String]), - __metadata("design:returntype", void 0) -], Panel.prototype, "__response__", null); + __decorate([ + NativeCall, + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", void 0) + ], Panel.prototype, "__init__", null); + __decorate([ + NativeCall, + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", void 0) + ], Panel.prototype, "__onCreate__", null); + __decorate([ + NativeCall, + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", void 0) + ], Panel.prototype, "__onDestroy__", null); + __decorate([ + NativeCall, + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", void 0) + ], Panel.prototype, "__onShow__", null); + __decorate([ + NativeCall, + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", void 0) + ], Panel.prototype, "__onHidden__", null); + __decorate([ + NativeCall, + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", void 0) + ], Panel.prototype, "__build__", null); + __decorate([ + NativeCall, + __metadata("design:type", Function), + __metadata("design:paramtypes", [Array, String]), + __metadata("design:returntype", void 0) + ], Panel.prototype, "__response__", null); + return Panel; +})(); +export { Panel }; diff --git a/doric-js/lib/src/ui/view.js b/doric-js/lib/src/ui/view.js index 72ab6abe..b8578272 100644 --- a/doric-js/lib/src/ui/view.js +++ b/doric-js/lib/src/ui/view.js @@ -13,263 +13,267 @@ import { loge } from "../util/log"; export function Property(target, propKey) { Reflect.defineMetadata(propKey, true, target); } -export class View { - constructor() { - this.width = 0; - this.height = 0; - this.x = 0; - this.y = 0; - this.viewId = uniqueId('ViewId'); - this.callbacks = new Map; - /** Anchor end*/ - this.__dirty_props__ = {}; - this.nativeViewModel = { - id: this.viewId, - type: this.constructor.name, - props: this.__dirty_props__, - }; - return new Proxy(this, { - get: (target, p, receiver) => { - return Reflect.get(target, p, receiver); - }, - set: (target, p, v, receiver) => { - const oldV = Reflect.get(target, p, receiver); - const ret = Reflect.set(target, p, v, receiver); - if (Reflect.getMetadata(p, target) && oldV !== v) { - receiver.onPropertyChanged(p.toString(), oldV, v); - } - return ret; - } - }); - } - callback2Id(f) { - const id = uniqueId('Function'); - this.callbacks.set(id, f); - return id; - } - id2Callback(id) { - let f = this.callbacks.get(id); - if (f === undefined) { - f = Reflect.get(this, id); - } - return f; - } - /** Anchor start*/ - get left() { - return this.x; - } - set left(v) { - this.x = v; - } - get right() { - return this.x + this.width; - } - set right(v) { - this.x = v - this.width; - } - get top() { - return this.y; - } - set top(v) { - this.y = v; - } - get bottom() { - return this.y + this.height; - } - set bottom(v) { - this.y = v - this.height; - } - get centerX() { - return this.x + this.width / 2; - } - get centerY() { - return this.y + this.height / 2; - } - set centerX(v) { - this.x = v - this.width / 2; - } - set centerY(v) { - this.y = v - this.height / 2; - } - get dirtyProps() { - return this.__dirty_props__; - } - onPropertyChanged(propKey, oldV, newV) { - if (newV instanceof Function) { - newV = this.callback2Id(newV); - } - else { - newV = obj2Model(newV); - } - this.__dirty_props__[propKey] = newV; - } - clean() { - for (const key in this.__dirty_props__) { - if (Reflect.has(this.__dirty_props__, key)) { - Reflect.deleteProperty(this.__dirty_props__, key); - } - } - } - isDirty() { - return Reflect.ownKeys(this.__dirty_props__).length !== 0; - } - responseCallback(id, ...args) { - const f = this.id2Callback(id); - if (f instanceof Function) { - const argumentsList = []; - for (let i = 1; i < arguments.length; i++) { - argumentsList.push(arguments[i]); - } - return Reflect.apply(f, this, argumentsList); - } - else { - loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`); - } - } - toModel() { - return this.nativeViewModel; - } - let(block) { - block(this); - } - also(block) { - block(this); - return this; - } - apply(config) { - for (let key in config) { - Reflect.set(this, key, Reflect.get(config, key, config), this); - } - return this; - } - in(group) { - group.addChild(this); - return this; - } - nativeChannel(context, name) { - let thisView = this; - return function (args = undefined) { - const viewIds = []; - while (thisView != undefined) { - viewIds.push(thisView.viewId); - thisView = thisView.superview; - } - const params = { - viewIds: viewIds.reverse(), - name, - args, +let View = /** @class */ (() => { + class View { + constructor() { + this.width = 0; + this.height = 0; + this.x = 0; + this.y = 0; + this.viewId = uniqueId('ViewId'); + this.callbacks = new Map; + /** Anchor end*/ + this.__dirty_props__ = {}; + this.nativeViewModel = { + id: this.viewId, + type: this.constructor.name, + props: this.__dirty_props__, }; - return context.callNative('shader', 'command', params); - }; - } - getWidth(context) { - return this.nativeChannel(context, 'getWidth')(); - } - getHeight(context) { - return this.nativeChannel(context, 'getHeight')(); - } - getX(context) { - return this.nativeChannel(context, 'getX')(); - } - getY(context) { - return this.nativeChannel(context, 'getY')(); - } - getLocationOnScreen(context) { - return this.nativeChannel(context, "getLocationOnScreen")(); - } - doAnimation(context, animation) { - return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => { - for (let key in args) { - Reflect.set(this, key, Reflect.get(args, key, args), this); - Reflect.deleteProperty(this.__dirty_props__, key); + return new Proxy(this, { + get: (target, p, receiver) => { + return Reflect.get(target, p, receiver); + }, + set: (target, p, v, receiver) => { + const oldV = Reflect.get(target, p, receiver); + const ret = Reflect.set(target, p, v, receiver); + if (Reflect.getMetadata(p, target) && oldV !== v) { + receiver.onPropertyChanged(p.toString(), oldV, v); + } + return ret; + } + }); + } + callback2Id(f) { + const id = uniqueId('Function'); + this.callbacks.set(id, f); + return id; + } + id2Callback(id) { + let f = this.callbacks.get(id); + if (f === undefined) { + f = Reflect.get(this, id); } - }); + return f; + } + /** Anchor start*/ + get left() { + return this.x; + } + set left(v) { + this.x = v; + } + get right() { + return this.x + this.width; + } + set right(v) { + this.x = v - this.width; + } + get top() { + return this.y; + } + set top(v) { + this.y = v; + } + get bottom() { + return this.y + this.height; + } + set bottom(v) { + this.y = v - this.height; + } + get centerX() { + return this.x + this.width / 2; + } + get centerY() { + return this.y + this.height / 2; + } + set centerX(v) { + this.x = v - this.width / 2; + } + set centerY(v) { + this.y = v - this.height / 2; + } + get dirtyProps() { + return this.__dirty_props__; + } + onPropertyChanged(propKey, oldV, newV) { + if (newV instanceof Function) { + newV = this.callback2Id(newV); + } + else { + newV = obj2Model(newV); + } + this.__dirty_props__[propKey] = newV; + } + clean() { + for (const key in this.__dirty_props__) { + if (Reflect.has(this.__dirty_props__, key)) { + Reflect.deleteProperty(this.__dirty_props__, key); + } + } + } + isDirty() { + return Reflect.ownKeys(this.__dirty_props__).length !== 0; + } + responseCallback(id, ...args) { + const f = this.id2Callback(id); + if (f instanceof Function) { + const argumentsList = []; + for (let i = 1; i < arguments.length; i++) { + argumentsList.push(arguments[i]); + } + return Reflect.apply(f, this, argumentsList); + } + else { + loge(`Cannot find callback:${id} for ${JSON.stringify(this.toModel())}`); + } + } + toModel() { + return this.nativeViewModel; + } + let(block) { + block(this); + } + also(block) { + block(this); + return this; + } + apply(config) { + for (let key in config) { + Reflect.set(this, key, Reflect.get(config, key, config), this); + } + return this; + } + in(group) { + group.addChild(this); + return this; + } + nativeChannel(context, name) { + let thisView = this; + return function (args = undefined) { + const viewIds = []; + while (thisView != undefined) { + viewIds.push(thisView.viewId); + thisView = thisView.superview; + } + const params = { + viewIds: viewIds.reverse(), + name, + args, + }; + return context.callNative('shader', 'command', params); + }; + } + getWidth(context) { + return this.nativeChannel(context, 'getWidth')(); + } + getHeight(context) { + return this.nativeChannel(context, 'getHeight')(); + } + getX(context) { + return this.nativeChannel(context, 'getX')(); + } + getY(context) { + return this.nativeChannel(context, 'getY')(); + } + getLocationOnScreen(context) { + return this.nativeChannel(context, "getLocationOnScreen")(); + } + doAnimation(context, animation) { + return this.nativeChannel(context, "doAnimation")(animation.toModel()).then((args) => { + for (let key in args) { + Reflect.set(this, key, Reflect.get(args, key, args), this); + Reflect.deleteProperty(this.__dirty_props__, key); + } + }); + } } -} -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "width", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "height", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "x", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "y", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "backgroundColor", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "corners", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "border", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "shadow", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "alpha", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], View.prototype, "hidden", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "padding", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "layoutConfig", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], View.prototype, "onClick", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "translationX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "translationY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "scaleX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "scaleY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "pivotX", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "pivotY", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], View.prototype, "rotation", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], View.prototype, "flexConfig", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "width", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "height", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "x", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "y", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "backgroundColor", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "corners", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "border", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "shadow", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "alpha", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], View.prototype, "hidden", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "padding", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "layoutConfig", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], View.prototype, "onClick", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "translationX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "translationY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "scaleX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "scaleY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "pivotX", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "pivotY", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], View.prototype, "rotation", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], View.prototype, "flexConfig", void 0); + return View; +})(); +export { View }; export class Superview extends View { subviewById(id) { for (let v of this.allSubviews()) { diff --git a/doric-js/lib/src/util/color.js b/doric-js/lib/src/util/color.js index be1820cc..6e0b47c2 100644 --- a/doric-js/lib/src/util/color.js +++ b/doric-js/lib/src/util/color.js @@ -1,57 +1,61 @@ /** * Store color as format AARRGGBB or RRGGBB */ -export class Color { - constructor(v) { - this._value = 0; - this._value = v | 0x0; - } - static parse(str) { - if (!str.startsWith("#")) { - throw new Error(`Parse color error with ${str}`); +let Color = /** @class */ (() => { + class Color { + constructor(v) { + this._value = 0; + this._value = v | 0x0; } - const val = parseInt(str.substr(1), 16); - if (str.length === 7) { - return new Color(val | 0xff000000); + static parse(str) { + if (!str.startsWith("#")) { + throw new Error(`Parse color error with ${str}`); + } + const val = parseInt(str.substr(1), 16); + if (str.length === 7) { + return new Color(val | 0xff000000); + } + else if (str.length === 9) { + return new Color(val); + } + else { + throw new Error(`Parse color error with ${str}`); + } } - else if (str.length === 9) { - return new Color(val); + static safeParse(str, defVal = Color.TRANSPARENT) { + let color = defVal; + try { + color = Color.parse(str); + } + catch (e) { + } + finally { + return color; + } } - else { - throw new Error(`Parse color error with ${str}`); + alpha(v) { + v = v * 255; + return new Color((this._value & 0xffffff) | ((v & 0xff) << 24)); + } + toModel() { + return this._value; } } - static safeParse(str, defVal = Color.TRANSPARENT) { - let color = defVal; - try { - color = Color.parse(str); - } - catch (e) { - } - finally { - return color; - } - } - alpha(v) { - v = v * 255; - return new Color((this._value & 0xffffff) | ((v & 0xff) << 24)); - } - toModel() { - return this._value; - } -} -Color.BLACK = new Color(0xFF000000); -Color.DKGRAY = new Color(0xFF444444); -Color.GRAY = new Color(0xFF888888); -Color.LTGRAY = new Color(0xFFCCCCCC); -Color.WHITE = new Color(0xFFFFFFFF); -Color.RED = new Color(0xFFFF0000); -Color.GREEN = new Color(0xFF00FF00); -Color.BLUE = new Color(0xFF0000FF); -Color.YELLOW = new Color(0xFFFFFF00); -Color.CYAN = new Color(0xFF00FFFF); -Color.MAGENTA = new Color(0xFFFF00FF); -Color.TRANSPARENT = new Color(0); + Color.BLACK = new Color(0xFF000000); + Color.DKGRAY = new Color(0xFF444444); + Color.GRAY = new Color(0xFF888888); + Color.LTGRAY = new Color(0xFFCCCCCC); + Color.WHITE = new Color(0xFFFFFFFF); + Color.RED = new Color(0xFFFF0000); + Color.GREEN = new Color(0xFF00FF00); + Color.BLUE = new Color(0xFF0000FF); + Color.YELLOW = new Color(0xFFFFFF00); + Color.CYAN = new Color(0xFF00FFFF); + Color.MAGENTA = new Color(0xFFFF00FF); + Color.TRANSPARENT = new Color(0); + return Color; +})(); +export { Color }; export var GradientOrientation; (function (GradientOrientation) { /** draw the gradient from the top to the bottom */ diff --git a/doric-js/lib/src/util/flexbox.js b/doric-js/lib/src/util/flexbox.js index cff12a70..b2f634d9 100644 --- a/doric-js/lib/src/util/flexbox.js +++ b/doric-js/lib/src/util/flexbox.js @@ -5,29 +5,33 @@ var ValueType; ValueType[ValueType["Percent"] = 2] = "Percent"; ValueType[ValueType["Auto"] = 3] = "Auto"; })(ValueType || (ValueType = {})); -export class FlexTypedValue { - constructor(type) { - this.value = 0; - this.type = type; +let FlexTypedValue = /** @class */ (() => { + class FlexTypedValue { + constructor(type) { + this.value = 0; + this.type = type; + } + static percent(v) { + const ret = new FlexTypedValue(ValueType.Percent); + ret.value = v; + return ret; + } + static point(v) { + const ret = new FlexTypedValue(ValueType.Point); + ret.value = v; + return ret; + } + toModel() { + return { + type: this.type, + value: this.value, + }; + } } - static percent(v) { - const ret = new FlexTypedValue(ValueType.Percent); - ret.value = v; - return ret; - } - static point(v) { - const ret = new FlexTypedValue(ValueType.Point); - ret.value = v; - return ret; - } - toModel() { - return { - type: this.type, - value: this.value, - }; - } -} -FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto); + FlexTypedValue.Auto = new FlexTypedValue(ValueType.Auto); + return FlexTypedValue; +})(); +export { FlexTypedValue }; export var FlexDirection; (function (FlexDirection) { FlexDirection[FlexDirection["COLUMN"] = 0] = "COLUMN"; diff --git a/doric-js/lib/src/util/gravity.js b/doric-js/lib/src/util/gravity.js index 8c4c9486..514c200f 100644 --- a/doric-js/lib/src/util/gravity.js +++ b/doric-js/lib/src/util/gravity.js @@ -10,64 +10,68 @@ export const BOTTOM = (END | SPECIFIED) << SHIFT_Y; export const CENTER_X = SPECIFIED << SHIFT_X; export const CENTER_Y = SPECIFIED << SHIFT_Y; export const CENTER = CENTER_X | CENTER_Y; -export class Gravity { - constructor() { - this.val = 0; +let Gravity = /** @class */ (() => { + class Gravity { + constructor() { + this.val = 0; + } + left() { + const val = this.val | LEFT; + const ret = new Gravity; + ret.val = val; + return ret; + } + right() { + const val = this.val | RIGHT; + const ret = new Gravity; + ret.val = val; + return ret; + } + top() { + const val = this.val | TOP; + const ret = new Gravity; + ret.val = val; + return ret; + } + bottom() { + const val = this.val | BOTTOM; + const ret = new Gravity; + ret.val = val; + return ret; + } + center() { + const val = this.val | CENTER; + const ret = new Gravity; + ret.val = val; + return ret; + } + centerX() { + const val = this.val | CENTER_X; + const ret = new Gravity; + ret.val = val; + return ret; + } + centerY() { + const val = this.val | CENTER_Y; + const ret = new Gravity; + ret.val = val; + return ret; + } + toModel() { + return this.val; + } } - left() { - const val = this.val | LEFT; - const ret = new Gravity; - ret.val = val; - return ret; - } - right() { - const val = this.val | RIGHT; - const ret = new Gravity; - ret.val = val; - return ret; - } - top() { - const val = this.val | TOP; - const ret = new Gravity; - ret.val = val; - return ret; - } - bottom() { - const val = this.val | BOTTOM; - const ret = new Gravity; - ret.val = val; - return ret; - } - center() { - const val = this.val | CENTER; - const ret = new Gravity; - ret.val = val; - return ret; - } - centerX() { - const val = this.val | CENTER_X; - const ret = new Gravity; - ret.val = val; - return ret; - } - centerY() { - const val = this.val | CENTER_Y; - const ret = new Gravity; - ret.val = val; - return ret; - } - toModel() { - return this.val; - } -} -Gravity.origin = new Gravity; -Gravity.Center = Gravity.origin.center(); -Gravity.CenterX = Gravity.origin.centerX(); -Gravity.CenterY = Gravity.origin.centerY(); -Gravity.Left = Gravity.origin.left(); -Gravity.Right = Gravity.origin.right(); -Gravity.Top = Gravity.origin.top(); -Gravity.Bottom = Gravity.origin.bottom(); + Gravity.origin = new Gravity; + Gravity.Center = Gravity.origin.center(); + Gravity.CenterX = Gravity.origin.centerX(); + Gravity.CenterY = Gravity.origin.centerY(); + Gravity.Left = Gravity.origin.left(); + Gravity.Right = Gravity.origin.right(); + Gravity.Top = Gravity.origin.top(); + Gravity.Bottom = Gravity.origin.bottom(); + return Gravity; +})(); +export { Gravity }; export function gravity() { return new Gravity; } diff --git a/doric-js/lib/src/widget/draggable.js b/doric-js/lib/src/widget/draggable.js index c83c7436..867d76b9 100644 --- a/doric-js/lib/src/widget/draggable.js +++ b/doric-js/lib/src/widget/draggable.js @@ -25,12 +25,16 @@ var __metadata = (this && this.__metadata) || function (k, v) { import { Property, View } from "../ui/view"; import { Stack } from "../widget/layouts"; import { layoutConfig } from "../util/layoutconfig"; -export class Draggable extends Stack { -} -__decorate([ - Property, - __metadata("design:type", Function) -], Draggable.prototype, "onDrag", void 0); +let Draggable = /** @class */ (() => { + class Draggable extends Stack { + } + __decorate([ + Property, + __metadata("design:type", Function) + ], Draggable.prototype, "onDrag", void 0); + return Draggable; +})(); +export { Draggable }; export function draggable(views, config) { const ret = new Draggable; ret.layoutConfig = layoutConfig().fit(); diff --git a/doric-js/lib/src/widget/flowlayout.js b/doric-js/lib/src/widget/flowlayout.js index 32b84bac..f76a9dc6 100644 --- a/doric-js/lib/src/widget/flowlayout.js +++ b/doric-js/lib/src/widget/flowlayout.js @@ -25,105 +25,113 @@ var __metadata = (this && this.__metadata) || function (k, v) { import { Stack } from './layouts'; import { Property, Superview, View } from '../ui/view'; import { layoutConfig } from '../util/index.util'; -export class FlowLayoutItem extends Stack { -} -__decorate([ - Property, - __metadata("design:type", String) -], FlowLayoutItem.prototype, "identifier", void 0); -export class FlowLayout extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.columnCount = 2; - this.itemCount = 0; - this.batchCount = 15; +let FlowLayoutItem = /** @class */ (() => { + class FlowLayoutItem extends Stack { } - allSubviews() { - if (this.loadMoreView) { - return [...this.cachedViews.values(), this.loadMoreView]; - } - else { - return this.cachedViews.values(); - } - } - reset() { - this.cachedViews.clear(); - this.itemCount = 0; - } - getItem(itemIdx) { - let view = this.renderItem(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate([ + Property, + __metadata("design:type", String) + ], FlowLayoutItem.prototype, "identifier", void 0); + return FlowLayoutItem; +})(); +export { FlowLayoutItem }; +let FlowLayout = /** @class */ (() => { + class FlowLayout extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.columnCount = 2; + this.itemCount = 0; + this.batchCount = 15; } - return super.isDirty(); - } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { - const listItem = this.getItem(start + idx); - return listItem.toModel(); - }); - } - toModel() { - if (this.loadMoreView) { - this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + allSubviews() { + if (this.loadMoreView) { + return [...this.cachedViews.values(), this.loadMoreView]; + } + else { + return this.cachedViews.values(); + } + } + reset() { + this.cachedViews.clear(); + this.itemCount = 0; + } + getItem(itemIdx) { + let view = this.renderItem(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { + const listItem = this.getItem(start + idx); + return listItem.toModel(); + }); + } + toModel() { + if (this.loadMoreView) { + this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + } + return super.toModel(); } - return super.toModel(); } -} -__decorate([ - Property, - __metadata("design:type", Object) -], FlowLayout.prototype, "columnCount", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], FlowLayout.prototype, "columnSpace", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], FlowLayout.prototype, "rowSpace", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], FlowLayout.prototype, "itemCount", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], FlowLayout.prototype, "renderItem", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], FlowLayout.prototype, "batchCount", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], FlowLayout.prototype, "onLoadMore", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], FlowLayout.prototype, "loadMore", void 0); -__decorate([ - Property, - __metadata("design:type", FlowLayoutItem) -], FlowLayout.prototype, "loadMoreView", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], FlowLayout.prototype, "onScroll", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], FlowLayout.prototype, "onScrollEnd", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], FlowLayout.prototype, "columnCount", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], FlowLayout.prototype, "columnSpace", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], FlowLayout.prototype, "rowSpace", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], FlowLayout.prototype, "itemCount", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], FlowLayout.prototype, "renderItem", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], FlowLayout.prototype, "batchCount", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], FlowLayout.prototype, "onLoadMore", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], FlowLayout.prototype, "loadMore", void 0); + __decorate([ + Property, + __metadata("design:type", FlowLayoutItem) + ], FlowLayout.prototype, "loadMoreView", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], FlowLayout.prototype, "onScroll", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], FlowLayout.prototype, "onScrollEnd", void 0); + return FlowLayout; +})(); +export { FlowLayout }; export function flowlayout(config) { const ret = new FlowLayout; for (let key in config) { diff --git a/doric-js/lib/src/widget/image.js b/doric-js/lib/src/widget/image.js index ea0c7cfd..bccb5314 100644 --- a/doric-js/lib/src/widget/image.js +++ b/doric-js/lib/src/widget/image.js @@ -31,73 +31,77 @@ export var ScaleType; ScaleType[ScaleType["ScaleAspectFit"] = 1] = "ScaleAspectFit"; ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill"; })(ScaleType || (ScaleType = {})); -export class Image extends View { -} -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "imageUrl", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "imagePath", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "imageRes", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "imageBase64", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Image.prototype, "scaleType", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], Image.prototype, "isBlur", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "placeHolderImage", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "placeHolderImageBase64", void 0); -__decorate([ - Property, - __metadata("design:type", Color - /** - * Display while image is failed to load - * It can be file name in local path - */ - ) -], Image.prototype, "placeHolderColor", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "errorImage", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Image.prototype, "errorImageBase64", void 0); -__decorate([ - Property, - __metadata("design:type", Color) -], Image.prototype, "errorColor", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Image.prototype, "loadCallback", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Image.prototype, "imageScale", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], Image.prototype, "stretchInset", void 0); +let Image = /** @class */ (() => { + class Image extends View { + } + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "imageUrl", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "imagePath", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "imageRes", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "imageBase64", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Image.prototype, "scaleType", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], Image.prototype, "isBlur", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "placeHolderImage", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "placeHolderImageBase64", void 0); + __decorate([ + Property, + __metadata("design:type", Color + /** + * Display while image is failed to load + * It can be file name in local path + */ + ) + ], Image.prototype, "placeHolderColor", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "errorImage", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Image.prototype, "errorImageBase64", void 0); + __decorate([ + Property, + __metadata("design:type", Color) + ], Image.prototype, "errorColor", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Image.prototype, "loadCallback", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Image.prototype, "imageScale", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], Image.prototype, "stretchInset", void 0); + return Image; +})(); +export { Image }; export function image(config) { const ret = new Image; ret.layoutConfig = layoutConfig().fit(); diff --git a/doric-js/lib/src/widget/input.js b/doric-js/lib/src/widget/input.js index 3d566a35..6d9ab10b 100644 --- a/doric-js/lib/src/widget/input.js +++ b/doric-js/lib/src/widget/input.js @@ -26,63 +26,67 @@ import { View, Property } from "../ui/view"; import { Color } from "../util/color"; import { Gravity } from "../util/gravity"; import { layoutConfig } from "../util/index.util"; -export class Input extends View { - getText(context) { - return this.nativeChannel(context, 'getText')(); +let Input = /** @class */ (() => { + class Input extends View { + getText(context) { + return this.nativeChannel(context, 'getText')(); + } + setSelection(context, start, end = start) { + return this.nativeChannel(context, 'setSelection')({ + start, + end, + }); + } + requestFocus(context) { + return this.nativeChannel(context, 'requestFocus')(); + } + releaseFocus(context) { + return this.nativeChannel(context, 'releaseFocus')(); + } } - setSelection(context, start, end = start) { - return this.nativeChannel(context, 'setSelection')({ - start, - end, - }); - } - requestFocus(context) { - return this.nativeChannel(context, 'requestFocus')(); - } - releaseFocus(context) { - return this.nativeChannel(context, 'releaseFocus')(); - } -} -__decorate([ - Property, - __metadata("design:type", String) -], Input.prototype, "text", void 0); -__decorate([ - Property, - __metadata("design:type", Color) -], Input.prototype, "textColor", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Input.prototype, "textSize", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Input.prototype, "hintText", void 0); -__decorate([ - Property, - __metadata("design:type", Color) -], Input.prototype, "hintTextColor", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], Input.prototype, "multiline", void 0); -__decorate([ - Property, - __metadata("design:type", Gravity) -], Input.prototype, "textAlignment", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Input.prototype, "onTextChange", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Input.prototype, "onFocusChange", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Input.prototype, "maxLength", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Input.prototype, "text", void 0); + __decorate([ + Property, + __metadata("design:type", Color) + ], Input.prototype, "textColor", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Input.prototype, "textSize", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Input.prototype, "hintText", void 0); + __decorate([ + Property, + __metadata("design:type", Color) + ], Input.prototype, "hintTextColor", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], Input.prototype, "multiline", void 0); + __decorate([ + Property, + __metadata("design:type", Gravity) + ], Input.prototype, "textAlignment", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Input.prototype, "onTextChange", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Input.prototype, "onFocusChange", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Input.prototype, "maxLength", void 0); + return Input; +})(); +export { Input }; export function input(config) { const ret = new Input; ret.layoutConfig = layoutConfig().just(); diff --git a/doric-js/lib/src/widget/layouts.js b/doric-js/lib/src/widget/layouts.js index 52fb5820..a872e6d6 100644 --- a/doric-js/lib/src/widget/layouts.js +++ b/doric-js/lib/src/widget/layouts.js @@ -29,16 +29,19 @@ export class Stack extends Group { } export class Root extends Stack { } -class LinearLayout extends Group { -} -__decorate([ - Property, - __metadata("design:type", Number) -], LinearLayout.prototype, "space", void 0); -__decorate([ - Property, - __metadata("design:type", Gravity) -], LinearLayout.prototype, "gravity", void 0); +let LinearLayout = /** @class */ (() => { + class LinearLayout extends Group { + } + __decorate([ + Property, + __metadata("design:type", Number) + ], LinearLayout.prototype, "space", void 0); + __decorate([ + Property, + __metadata("design:type", Gravity) + ], LinearLayout.prototype, "gravity", void 0); + return LinearLayout; +})(); export class VLayout extends LinearLayout { } export class HLayout extends LinearLayout { diff --git a/doric-js/lib/src/widget/list.js b/doric-js/lib/src/widget/list.js index ce16f632..e95d94f0 100644 --- a/doric-js/lib/src/widget/list.js +++ b/doric-js/lib/src/widget/list.js @@ -25,101 +25,108 @@ var __metadata = (this && this.__metadata) || function (k, v) { import { View, Property, Superview } from "../ui/view"; import { Stack } from "./layouts"; import { layoutConfig } from "../util/layoutconfig"; -export class ListItem extends Stack { -} -__decorate([ - Property, - __metadata("design:type", String) -], ListItem.prototype, "identifier", void 0); -export class List extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.itemCount = 0; - this.batchCount = 15; +let ListItem = /** @class */ (() => { + class ListItem extends Stack { } - allSubviews() { - if (this.loadMoreView) { - return [...this.cachedViews.values(), this.loadMoreView]; - } - else { - return this.cachedViews.values(); - } - } - scrollToItem(context, index, config) { - var _a; - const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated; - return this.nativeChannel(context, 'scrollToItem')({ index, animated, }); - } - reset() { - this.cachedViews.clear(); - this.itemCount = 0; - } - getItem(itemIdx) { - let view = this.renderItem(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate([ + Property, + __metadata("design:type", String) + ], ListItem.prototype, "identifier", void 0); + return ListItem; +})(); +export { ListItem }; +let List = /** @class */ (() => { + class List extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.itemCount = 0; + this.batchCount = 15; } - return super.isDirty(); - } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { - const listItem = this.getItem(start + idx); - return listItem.toModel(); - }); - } - toModel() { - if (this.loadMoreView) { - this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + allSubviews() { + if (this.loadMoreView) { + return [...this.cachedViews.values(), this.loadMoreView]; + } + else { + return this.cachedViews.values(); + } + } + scrollToItem(context, index, config) { + const animated = config === null || config === void 0 ? void 0 : config.animated; + return this.nativeChannel(context, 'scrollToItem')({ index, animated, }); + } + reset() { + this.cachedViews.clear(); + this.itemCount = 0; + } + getItem(itemIdx) { + let view = this.renderItem(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { + const listItem = this.getItem(start + idx); + return listItem.toModel(); + }); + } + toModel() { + if (this.loadMoreView) { + this.dirtyProps['loadMoreView'] = this.loadMoreView.viewId; + } + return super.toModel(); } - return super.toModel(); } -} -__decorate([ - Property, - __metadata("design:type", Object) -], List.prototype, "itemCount", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], List.prototype, "renderItem", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], List.prototype, "batchCount", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], List.prototype, "onLoadMore", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], List.prototype, "loadMore", void 0); -__decorate([ - Property, - __metadata("design:type", ListItem) -], List.prototype, "loadMoreView", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], List.prototype, "onScroll", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], List.prototype, "onScrollEnd", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], List.prototype, "scrolledPosition", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], List.prototype, "itemCount", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], List.prototype, "renderItem", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], List.prototype, "batchCount", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], List.prototype, "onLoadMore", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], List.prototype, "loadMore", void 0); + __decorate([ + Property, + __metadata("design:type", ListItem) + ], List.prototype, "loadMoreView", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], List.prototype, "onScroll", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], List.prototype, "onScrollEnd", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], List.prototype, "scrolledPosition", void 0); + return List; +})(); +export { List }; export function list(config) { const ret = new List; for (let key in config) { diff --git a/doric-js/lib/src/widget/nestedSlider.js b/doric-js/lib/src/widget/nestedSlider.js index 8c52facc..0ce80a60 100644 --- a/doric-js/lib/src/widget/nestedSlider.js +++ b/doric-js/lib/src/widget/nestedSlider.js @@ -23,18 +23,22 @@ var __metadata = (this && this.__metadata) || function (k, v) { * limitations under the License. */ import { Group, Property } from '../ui/view'; -export class NestedSlider extends Group { - addSlideItem(view) { - this.addChild(view); +let NestedSlider = /** @class */ (() => { + class NestedSlider extends Group { + addSlideItem(view) { + this.addChild(view); + } + slidePage(context, page, smooth = false) { + return this.nativeChannel(context, "slidePage")({ page, smooth }); + } + getSlidedPage(context) { + return this.nativeChannel(context, "getSlidedPage")(); + } } - slidePage(context, page, smooth = false) { - return this.nativeChannel(context, "slidePage")({ page, smooth }); - } - getSlidedPage(context) { - return this.nativeChannel(context, "getSlidedPage")(); - } -} -__decorate([ - Property, - __metadata("design:type", Function) -], NestedSlider.prototype, "onPageSlided", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], NestedSlider.prototype, "onPageSlided", void 0); + return NestedSlider; +})(); +export { NestedSlider }; diff --git a/doric-js/lib/src/widget/refreshable.js b/doric-js/lib/src/widget/refreshable.js index 2d502d6d..7240f321 100644 --- a/doric-js/lib/src/widget/refreshable.js +++ b/doric-js/lib/src/widget/refreshable.js @@ -9,36 +9,40 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; import { Property, Superview } from "../ui/view"; import { layoutConfig } from "../util/layoutconfig"; -export class Refreshable extends Superview { - allSubviews() { - const ret = [this.content]; - if (this.header) { - ret.push(this.header); +let Refreshable = /** @class */ (() => { + class Refreshable extends Superview { + allSubviews() { + const ret = [this.content]; + if (this.header) { + ret.push(this.header); + } + return ret; + } + setRefreshable(context, refreshable) { + return this.nativeChannel(context, 'setRefreshable')(refreshable); + } + setRefreshing(context, refreshing) { + return this.nativeChannel(context, 'setRefreshing')(refreshing); + } + isRefreshable(context) { + return this.nativeChannel(context, 'isRefreshable')(); + } + isRefreshing(context) { + return this.nativeChannel(context, 'isRefreshing')(); + } + toModel() { + this.dirtyProps.content = this.content.viewId; + this.dirtyProps.header = (this.header || {}).viewId; + return super.toModel(); } - return ret; } - setRefreshable(context, refreshable) { - return this.nativeChannel(context, 'setRefreshable')(refreshable); - } - setRefreshing(context, refreshing) { - return this.nativeChannel(context, 'setRefreshing')(refreshing); - } - isRefreshable(context) { - return this.nativeChannel(context, 'isRefreshable')(); - } - isRefreshing(context) { - return this.nativeChannel(context, 'isRefreshing')(); - } - toModel() { - this.dirtyProps.content = this.content.viewId; - this.dirtyProps.header = (this.header || {}).viewId; - return super.toModel(); - } -} -__decorate([ - Property, - __metadata("design:type", Function) -], Refreshable.prototype, "onRefresh", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Refreshable.prototype, "onRefresh", void 0); + return Refreshable; +})(); +export { Refreshable }; export function refreshable(config) { const ret = new Refreshable; ret.layoutConfig = layoutConfig().fit(); diff --git a/doric-js/lib/src/widget/scroller.js b/doric-js/lib/src/widget/scroller.js index 07c9c1af..ef68d7d9 100644 --- a/doric-js/lib/src/widget/scroller.js +++ b/doric-js/lib/src/widget/scroller.js @@ -35,30 +35,34 @@ export function scroller(content, config) { v.content = content; }); } -export class Scroller extends Superview { - allSubviews() { - return [this.content]; +let Scroller = /** @class */ (() => { + class Scroller extends Superview { + allSubviews() { + return [this.content]; + } + toModel() { + this.dirtyProps.content = this.content.viewId; + return super.toModel(); + } + scrollTo(context, offset, animated) { + return this.nativeChannel(context, "scrollTo")({ offset, animated }); + } + scrollBy(context, offset, animated) { + return this.nativeChannel(context, "scrollBy")({ offset, animated }); + } } - toModel() { - this.dirtyProps.content = this.content.viewId; - return super.toModel(); - } - scrollTo(context, offset, animated) { - return this.nativeChannel(context, "scrollTo")({ offset, animated }); - } - scrollBy(context, offset, animated) { - return this.nativeChannel(context, "scrollBy")({ offset, animated }); - } -} -__decorate([ - Property, - __metadata("design:type", Object) -], Scroller.prototype, "contentOffset", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Scroller.prototype, "onScroll", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Scroller.prototype, "onScrollEnd", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], Scroller.prototype, "contentOffset", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Scroller.prototype, "onScroll", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Scroller.prototype, "onScrollEnd", void 0); + return Scroller; +})(); +export { Scroller }; diff --git a/doric-js/lib/src/widget/slider.js b/doric-js/lib/src/widget/slider.js index 0b9ff28e..1647fb91 100644 --- a/doric-js/lib/src/widget/slider.js +++ b/doric-js/lib/src/widget/slider.js @@ -25,71 +25,79 @@ var __metadata = (this && this.__metadata) || function (k, v) { import { Superview, View, Property } from "../ui/view"; import { Stack } from "./layouts"; import { layoutConfig } from "../util/layoutconfig"; -export class SlideItem extends Stack { -} -__decorate([ - Property, - __metadata("design:type", String) -], SlideItem.prototype, "identifier", void 0); -export class Slider extends Superview { - constructor() { - super(...arguments); - this.cachedViews = new Map; - this.ignoreDirtyCallOnce = false; - this.itemCount = 0; - this.batchCount = 3; +let SlideItem = /** @class */ (() => { + class SlideItem extends Stack { } - allSubviews() { - return this.cachedViews.values(); - } - getItem(itemIdx) { - let view = this.renderPage(itemIdx); - view.superview = this; - this.cachedViews.set(`${itemIdx}`, view); - return view; - } - isDirty() { - if (this.ignoreDirtyCallOnce) { + __decorate([ + Property, + __metadata("design:type", String) + ], SlideItem.prototype, "identifier", void 0); + return SlideItem; +})(); +export { SlideItem }; +let Slider = /** @class */ (() => { + class Slider extends Superview { + constructor() { + super(...arguments); + this.cachedViews = new Map; this.ignoreDirtyCallOnce = false; - //Ignore the dirty call once. - return false; + this.itemCount = 0; + this.batchCount = 3; + } + allSubviews() { + return this.cachedViews.values(); + } + getItem(itemIdx) { + let view = this.renderPage(itemIdx); + view.superview = this; + this.cachedViews.set(`${itemIdx}`, view); + return view; + } + isDirty() { + if (this.ignoreDirtyCallOnce) { + this.ignoreDirtyCallOnce = false; + //Ignore the dirty call once. + return false; + } + return super.isDirty(); + } + renderBunchedItems(start, length) { + this.ignoreDirtyCallOnce = true; + return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { + const slideItem = this.getItem(start + idx); + return slideItem.toModel(); + }); + } + slidePage(context, page, smooth = false) { + return this.nativeChannel(context, "slidePage")({ page, smooth }); + } + getSlidedPage(context) { + return this.nativeChannel(context, "getSlidedPage")(); } - return super.isDirty(); } - renderBunchedItems(start, length) { - this.ignoreDirtyCallOnce = true; - return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { - const slideItem = this.getItem(start + idx); - return slideItem.toModel(); - }); - } - slidePage(context, page, smooth = false) { - return this.nativeChannel(context, "slidePage")({ page, smooth }); - } - getSlidedPage(context) { - return this.nativeChannel(context, "getSlidedPage")(); - } -} -__decorate([ - Property, - __metadata("design:type", Object) -], Slider.prototype, "itemCount", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Slider.prototype, "renderPage", void 0); -__decorate([ - Property, - __metadata("design:type", Object) -], Slider.prototype, "batchCount", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Slider.prototype, "onPageSlided", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], Slider.prototype, "loop", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], Slider.prototype, "itemCount", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Slider.prototype, "renderPage", void 0); + __decorate([ + Property, + __metadata("design:type", Object) + ], Slider.prototype, "batchCount", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Slider.prototype, "onPageSlided", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], Slider.prototype, "loop", void 0); + return Slider; +})(); +export { Slider }; export function slider(config) { const ret = new Slider; for (let key in config) { diff --git a/doric-js/lib/src/widget/switch.js b/doric-js/lib/src/widget/switch.js index 9d34c4b8..05881f0a 100644 --- a/doric-js/lib/src/widget/switch.js +++ b/doric-js/lib/src/widget/switch.js @@ -25,28 +25,32 @@ var __metadata = (this && this.__metadata) || function (k, v) { import { View, Property } from "../ui/view"; import { Color } from "../util/color"; import { layoutConfig } from "../util/index.util"; -export class Switch extends View { -} -__decorate([ - Property, - __metadata("design:type", Boolean) -], Switch.prototype, "state", void 0); -__decorate([ - Property, - __metadata("design:type", Function) -], Switch.prototype, "onSwitch", void 0); -__decorate([ - Property, - __metadata("design:type", Color) -], Switch.prototype, "offTintColor", void 0); -__decorate([ - Property, - __metadata("design:type", Color) -], Switch.prototype, "onTintColor", void 0); -__decorate([ - Property, - __metadata("design:type", Color) -], Switch.prototype, "thumbTintColor", void 0); +let Switch = /** @class */ (() => { + class Switch extends View { + } + __decorate([ + Property, + __metadata("design:type", Boolean) + ], Switch.prototype, "state", void 0); + __decorate([ + Property, + __metadata("design:type", Function) + ], Switch.prototype, "onSwitch", void 0); + __decorate([ + Property, + __metadata("design:type", Color) + ], Switch.prototype, "offTintColor", void 0); + __decorate([ + Property, + __metadata("design:type", Color) + ], Switch.prototype, "onTintColor", void 0); + __decorate([ + Property, + __metadata("design:type", Color) + ], Switch.prototype, "thumbTintColor", void 0); + return Switch; +})(); +export { Switch }; export function switchView(config) { const ret = new Switch; ret.layoutConfig = layoutConfig().just(); diff --git a/doric-js/lib/src/widget/text.js b/doric-js/lib/src/widget/text.js index 6bfb51f7..3f7c82f1 100644 --- a/doric-js/lib/src/widget/text.js +++ b/doric-js/lib/src/widget/text.js @@ -33,64 +33,68 @@ export var TruncateAt; TruncateAt[TruncateAt["Start"] = 2] = "Start"; TruncateAt[TruncateAt["Clip"] = 3] = "Clip"; })(TruncateAt || (TruncateAt = {})); -export class Text extends View { -} -__decorate([ - Property, - __metadata("design:type", String) -], Text.prototype, "text", void 0); -__decorate([ - Property, - __metadata("design:type", Color) -], Text.prototype, "textColor", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Text.prototype, "textSize", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Text.prototype, "maxLines", void 0); -__decorate([ - Property, - __metadata("design:type", Gravity) -], Text.prototype, "textAlignment", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Text.prototype, "fontStyle", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Text.prototype, "font", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Text.prototype, "maxWidth", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Text.prototype, "maxHeight", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Text.prototype, "lineSpacing", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], Text.prototype, "strikethrough", void 0); -__decorate([ - Property, - __metadata("design:type", Boolean) -], Text.prototype, "underline", void 0); -__decorate([ - Property, - __metadata("design:type", String) -], Text.prototype, "htmlText", void 0); -__decorate([ - Property, - __metadata("design:type", Number) -], Text.prototype, "truncateAt", void 0); +let Text = /** @class */ (() => { + class Text extends View { + } + __decorate([ + Property, + __metadata("design:type", String) + ], Text.prototype, "text", void 0); + __decorate([ + Property, + __metadata("design:type", Color) + ], Text.prototype, "textColor", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Text.prototype, "textSize", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Text.prototype, "maxLines", void 0); + __decorate([ + Property, + __metadata("design:type", Gravity) + ], Text.prototype, "textAlignment", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Text.prototype, "fontStyle", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Text.prototype, "font", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Text.prototype, "maxWidth", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Text.prototype, "maxHeight", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Text.prototype, "lineSpacing", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], Text.prototype, "strikethrough", void 0); + __decorate([ + Property, + __metadata("design:type", Boolean) + ], Text.prototype, "underline", void 0); + __decorate([ + Property, + __metadata("design:type", String) + ], Text.prototype, "htmlText", void 0); + __decorate([ + Property, + __metadata("design:type", Number) + ], Text.prototype, "truncateAt", void 0); + return Text; +})(); +export { Text }; export function text(config) { const ret = new Text; ret.layoutConfig = layoutConfig().fit(); diff --git a/doric-js/package.json b/doric-js/package.json index 2ddeb2cd..85bc9183 100644 --- a/doric-js/package.json +++ b/doric-js/package.json @@ -29,7 +29,7 @@ "reflect-metadata": "^0.1.13", "rollup": "^1.29.0", "tslib": "^1.10.0", - "typescript": "^3.7.4", + "typescript": "^3.9.2", "ws": "^7.2.1" }, "publishConfig": { diff --git a/doric-js/rollup.config.js b/doric-js/rollup.config.js index 54090942..7affb998 100644 --- a/doric-js/rollup.config.js +++ b/doric-js/rollup.config.js @@ -27,7 +27,6 @@ export default [ plugins: [ resolve({ mainFields: ["jsnext"] }), ], - external: ['reflect-metadata'], onwarn: function (warning) { if (warning.code === 'THIS_IS_UNDEFINED') { return; } console.warn(warning.message); @@ -80,7 +79,6 @@ export default [ transforms: { dangerousForOf: true } }), ], - external: ['reflect-metadata'], onwarn: function (warning) { if (warning.code === 'THIS_IS_UNDEFINED') { return; } console.warn(warning.message); diff --git a/doric-js/src/runtime/global.ts b/doric-js/src/runtime/global.ts index 68870bbd..00170254 100644 --- a/doric-js/src/runtime/global.ts +++ b/doric-js/src/runtime/global.ts @@ -13,8 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from 'reflect-metadata' - export type BridgeContext = { /** * The identify of current context