js:compat es5,use context.sendNative to replace Proxy

This commit is contained in:
pengfei.zhou
2020-01-17 16:51:17 +08:00
committed by osborn
parent c813787318
commit b6f7588321
30 changed files with 461 additions and 414 deletions

View File

@@ -205,6 +205,9 @@ var View = /** @class */ (function () {
return id;
};
View.prototype.id2Callback = function (id) {
if (this.callbacks === undefined) {
this.callbacks = new Map;
}
var f = this.callbacks.get(id);
if (f === undefined) {
f = Reflect.get(this, id);
@@ -345,7 +348,6 @@ var View = /** @class */ (function () {
var thisView = this;
return function (args) {
if (args === void 0) { args = undefined; }
var func = context.shader.command;
var viewIds = [];
while (thisView != undefined) {
viewIds.push(thisView.viewId);
@@ -356,7 +358,7 @@ var View = /** @class */ (function () {
name: name,
args: args,
};
return Reflect.apply(func, undefined, [params]);
return context.callNative('shader', 'command', params);
};
};
View.prototype.getWidth = function (context) {
@@ -418,10 +420,6 @@ var View = /** @class */ (function () {
Property,
__metadata("design:type", Boolean)
], View.prototype, "hidden", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "viewId", void 0);
__decorate([
Property,
__metadata("design:type", Object)
@@ -2441,29 +2439,29 @@ function modal(context) {
return {
toast: function (msg, gravity) {
if (gravity === void 0) { gravity = Gravity.Bottom; }
context.modal.toast({
context.callNative('modal', 'toast', {
msg: msg,
gravity: gravity.toModel(),
});
},
alert: function (arg) {
if (typeof arg === 'string') {
return context.modal.alert({ msg: arg });
return context.callNative('modal', 'alert', { msg: arg });
}
else {
return context.modal.alert(arg);
return context.callNative('modal', 'alert', arg);
}
},
confirm: function (arg) {
if (typeof arg === 'string') {
return context.modal.confirm({ msg: arg });
return context.callNative('modal', 'confirm', { msg: arg });
}
else {
return context.modal.confirm(arg);
return context.callNative('modal', 'confirm', arg);
}
},
prompt: function (arg) {
return context.modal.prompt(arg);
return context.callNative('modal', 'prompt', arg);
},
};
}
@@ -2476,36 +2474,30 @@ function navbar(context) {
}
return {
isHidden: function () {
return context.navbar.isHidden();
return context.callNative('navbar', 'isHidden');
},
setHidden: function (hidden) {
return context.navbar.setHidden({
hidden: hidden,
});
return context.callNative('navbar', 'setHidden', { hidden: hidden, });
},
setTitle: function (title) {
return context.navbar.setTitle({
title: title,
});
return context.callNative('navbar', 'setTitle', { title: title, });
},
setBgColor: function (color) {
return context.navbar.setBgColor({
color: color.toModel(),
});
return context.callNative('navbar', 'setBgColor', { color: color.toModel(), });
},
setLeft: function (view) {
if (panel) {
panel.clearHeadViews("navbar_left");
panel.addHeadView("navbar_left", view);
}
return context.navbar.setLeft(view.toModel());
return context.callNative('navbar', 'setLeft', view.toModel());
},
setRight: function (view) {
if (panel) {
panel.clearHeadViews("navbar_right");
panel.addHeadView("navbar_right", view);
}
return context.navbar.setRight(view.toModel());
return context.callNative('navbar', 'setRight', view.toModel());
}
};
}
@@ -2516,13 +2508,13 @@ function navigator(context) {
if (config && config.extra) {
config.extra = JSON.stringify(config.extra);
}
return context.navigator.push({
return context.callNative('navigator', 'push', {
scheme: scheme, config: config
});
},
pop: function (animated) {
if (animated === void 0) { animated = true; }
return context.navigator.pop({ animated: animated });
return context.callNative('navigator', 'pop', { animated: animated });
},
};
}
@@ -2544,7 +2536,7 @@ function transformRequest(request) {
function network(context) {
return {
request: function (config) {
return context.network.request(transformRequest(config));
return context.callNative('network', 'request', transformRequest(config));
},
get: function (url, config) {
var finalConfig = config;
@@ -2553,7 +2545,7 @@ function network(context) {
}
finalConfig.url = url;
finalConfig.method = "get";
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
post: function (url, data, config) {
var finalConfig = config;
@@ -2565,7 +2557,7 @@ function network(context) {
if (data !== undefined) {
finalConfig.data = data;
}
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
put: function (url, data, config) {
var finalConfig = config;
@@ -2577,7 +2569,7 @@ function network(context) {
if (data !== undefined) {
finalConfig.data = data;
}
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
delete: function (url, data, config) {
var finalConfig = config;
@@ -2586,7 +2578,7 @@ function network(context) {
}
finalConfig.url = url;
finalConfig.method = "delete";
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
};
}
@@ -2594,16 +2586,16 @@ function network(context) {
function storage(context) {
return {
setItem: function (key, value, zone) {
return context.storage.setItem({ key: key, value: value, zone: zone });
return context.callNative('storage', 'setItem', { key: key, value: value, zone: zone });
},
getItem: function (key, zone) {
return context.storage.getItem({ key: key, zone: zone });
return context.callNative('storage', 'getItem', { key: key, zone: zone });
},
remove: function (key, zone) {
return context.storage.remove({ key: key, zone: zone });
return context.callNative('storage', 'remove', { key: key, zone: zone });
},
clear: function (zone) {
return context.storage.clear({ zone: zone });
return context.callNative('storage', 'clear', { zone: zone });
},
};
}
@@ -2619,7 +2611,7 @@ function popover(context) {
if (panel) {
panel.addHeadView("popover", view);
}
return context.popover.show(view.toModel());
return context.callNative('popover', 'show', view.toModel());
},
dismiss: function (view) {
if (view === void 0) { view = undefined; }
@@ -2631,7 +2623,7 @@ function popover(context) {
panel.clearHeadViews("popover");
}
}
return context.popover.dismiss(view ? { id: view.viewId } : undefined);
return context.callNative('popover', 'dismiss', view ? { id: view.viewId } : undefined);
},
};
}
@@ -2699,6 +2691,42 @@ function repeat(action) {
};
}
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) { throw t[1]; } return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) { throw new TypeError("Generator is already executing."); }
while (_) { try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }
if (y = 0, t) { op = [op[0] & 2, t.value]; }
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) { _.ops.pop(); }
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } }
if (op[0] & 5) { throw op[1]; } return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __values$4 = (undefined && undefined.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) { return m.call(o); }
@@ -2715,57 +2743,61 @@ var __values$4 = (undefined && undefined.__values) || function(o) {
* @param panel @see Panel
*/
function animate(context) {
var _this = this;
var entity = context.entity;
if (entity instanceof Panel) {
var panel_1 = entity;
return function (args) {
return takeLet(panel_1.context.animate)(function (it) {
return it.submit().then(function () {
args.animations();
return takeLet(panel_1.getRootView())(function (root) {
var e_1, _a, e_2, _b;
if (root.isDirty()) {
var model = root.toModel();
model.duration = args.duration;
var ret = it.animateRender(model);
root.clean();
return ret;
}
try {
for (var _c = __values$4(panel_1.allHeadViews()), _d = _c.next(); !_d.done; _d = _c.next()) {
var map = _d.value;
return function (args) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, context.callNative('animate', 'submit')];
case 1:
_a.sent();
args.animations();
return [2 /*return*/, takeLet(panel_1.getRootView())(function (root) {
var e_1, _a, e_2, _b;
if (root.isDirty()) {
var model = root.toModel();
model.duration = args.duration;
var ret = context.callNative('animate', 'animateRender', model);
root.clean();
return ret;
}
try {
for (var _e = (e_2 = void 0, __values$4(map.values())), _f = _e.next(); !_f.done; _f = _e.next()) {
var v = _f.value;
if (v.isDirty()) {
var model = v.toModel();
var ret = it.animateRender(model);
it.clean();
return ret;
for (var _c = __values$4(panel_1.allHeadViews()), _d = _c.next(); !_d.done; _d = _c.next()) {
var map = _d.value;
try {
for (var _e = (e_2 = void 0, __values$4(map.values())), _f = _e.next(); !_f.done; _f = _e.next()) {
var v = _f.value;
if (v.isDirty()) {
var model_1 = v.toModel();
var ret_1 = context.callNative('animate', 'animateRender', model_1);
v.clean();
return ret_1;
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) { _b.call(_e); }
}
finally { if (e_2) { throw e_2.error; } }
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) { _b.call(_e); }
if (_d && !_d.done && (_a = _c.return)) { _a.call(_c); }
}
finally { if (e_2) { throw e_2.error; } }
finally { if (e_1) { throw e_1.error; } }
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) { _a.call(_c); }
}
finally { if (e_1) { throw e_1.error; } }
}
throw new Error('Cannot find any animated elements');
});
});
throw new Error('Cannot find any animated elements');
})];
}
});
};
}); };
}
else {
return function (args) {
@@ -2780,15 +2812,15 @@ function notification(context) {
if (args.data !== undefined) {
args.data = JSON.stringify(args.data);
}
return context.notification.publish(args);
return context.callNative('notification', 'publish', args);
},
subscribe: function (args) {
args.callback = context.function2Id(args.callback);
return context.notification.subscribe(args);
return context.callNative('notification', 'subscribe', args);
},
unsubscribe: function (subscribeId) {
context.removeFuncById(subscribeId);
return context.notification.unsubscribe(subscribeId);
return context.callNative('notification', 'unsubscribe', subscribeId);
}
};
}
@@ -2800,13 +2832,13 @@ function notification(context) {
function statusbar(context) {
return {
setHidden: function (hidden) {
return context.statusbar.setHidden({ hidden: hidden });
return context.callNative('statusbar', 'setHidden', { hidden: hidden });
},
setMode: function (mode) {
return context.statusbar.setMode({ mode: mode });
return context.callNative('statusbar', 'setMode', { mode: mode });
},
setColor: function (color) {
return context.statusbar.setColor({ color: color.toModel() });
return context.callNative('statusbar', 'setColor', { color: color.toModel() });
},
};
}

View File

@@ -264,7 +264,6 @@ class View {
nativeChannel(context, name) {
let thisView = this;
return function (args = undefined) {
const func = context.shader.command;
const viewIds = [];
while (thisView != undefined) {
viewIds.push(thisView.viewId);
@@ -275,7 +274,7 @@ class View {
name,
args,
};
return Reflect.apply(func, undefined, [params]);
return context.callNative('shader', 'command', params);
};
}
getWidth(context) {
@@ -337,10 +336,6 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], View.prototype, "hidden", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "viewId", void 0);
__decorate([
Property,
__metadata("design:type", Object)
@@ -1819,29 +1814,29 @@ function draggable(views, config) {
function modal(context) {
return {
toast: (msg, gravity = Gravity.Bottom) => {
context.modal.toast({
context.callNative('modal', 'toast', {
msg,
gravity: gravity.toModel(),
});
},
alert: (arg) => {
if (typeof arg === 'string') {
return context.modal.alert({ msg: arg });
return context.callNative('modal', 'alert', { msg: arg });
}
else {
return context.modal.alert(arg);
return context.callNative('modal', 'alert', arg);
}
},
confirm: (arg) => {
if (typeof arg === 'string') {
return context.modal.confirm({ msg: arg });
return context.callNative('modal', 'confirm', { msg: arg });
}
else {
return context.modal.confirm(arg);
return context.callNative('modal', 'confirm', arg);
}
},
prompt: (arg) => {
return context.modal.prompt(arg);
return context.callNative('modal', 'prompt', arg);
},
};
}
@@ -1854,36 +1849,30 @@ function navbar(context) {
}
return {
isHidden: () => {
return context.navbar.isHidden();
return context.callNative('navbar', 'isHidden');
},
setHidden: (hidden) => {
return context.navbar.setHidden({
hidden,
});
return context.callNative('navbar', 'setHidden', { hidden, });
},
setTitle: (title) => {
return context.navbar.setTitle({
title,
});
return context.callNative('navbar', 'setTitle', { title, });
},
setBgColor: (color) => {
return context.navbar.setBgColor({
color: color.toModel(),
});
return context.callNative('navbar', 'setBgColor', { color: color.toModel(), });
},
setLeft: (view) => {
if (panel) {
panel.clearHeadViews("navbar_left");
panel.addHeadView("navbar_left", view);
}
return context.navbar.setLeft(view.toModel());
return context.callNative('navbar', 'setLeft', view.toModel());
},
setRight: (view) => {
if (panel) {
panel.clearHeadViews("navbar_right");
panel.addHeadView("navbar_right", view);
}
return context.navbar.setRight(view.toModel());
return context.callNative('navbar', 'setRight', view.toModel());
}
};
}
@@ -1894,12 +1883,12 @@ function navigator(context) {
if (config && config.extra) {
config.extra = JSON.stringify(config.extra);
}
return context.navigator.push({
return context.callNative('navigator', 'push', {
scheme, config
});
},
pop: (animated = true) => {
return context.navigator.pop({ animated });
return context.callNative('navigator', 'pop', { animated });
},
};
}
@@ -1921,7 +1910,7 @@ function transformRequest(request) {
function network(context) {
return {
request: (config) => {
return context.network.request(transformRequest(config));
return context.callNative('network', 'request', transformRequest(config));
},
get: (url, config) => {
let finalConfig = config;
@@ -1930,7 +1919,7 @@ function network(context) {
}
finalConfig.url = url;
finalConfig.method = "get";
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
post: (url, data, config) => {
let finalConfig = config;
@@ -1942,7 +1931,7 @@ function network(context) {
if (data !== undefined) {
finalConfig.data = data;
}
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
put: (url, data, config) => {
let finalConfig = config;
@@ -1954,7 +1943,7 @@ function network(context) {
if (data !== undefined) {
finalConfig.data = data;
}
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
delete: (url, data, config) => {
let finalConfig = config;
@@ -1963,7 +1952,7 @@ function network(context) {
}
finalConfig.url = url;
finalConfig.method = "delete";
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
};
}
@@ -1971,16 +1960,16 @@ function network(context) {
function storage(context) {
return {
setItem: (key, value, zone) => {
return context.storage.setItem({ key, value, zone });
return context.callNative('storage', 'setItem', { key, value, zone });
},
getItem: (key, zone) => {
return context.storage.getItem({ key, zone });
return context.callNative('storage', 'getItem', { key, zone });
},
remove: (key, zone) => {
return context.storage.remove({ key, zone });
return context.callNative('storage', 'remove', { key, zone });
},
clear: (zone) => {
return context.storage.clear({ zone });
return context.callNative('storage', 'clear', { zone });
},
};
}
@@ -1996,7 +1985,7 @@ function popover(context) {
if (panel) {
panel.addHeadView("popover", view);
}
return context.popover.show(view.toModel());
return context.callNative('popover', 'show', view.toModel());
},
dismiss: (view = undefined) => {
if (panel) {
@@ -2007,7 +1996,7 @@ function popover(context) {
panel.clearHeadViews("popover");
}
}
return context.popover.dismiss(view ? { id: view.viewId } : undefined);
return context.callNative('popover', 'dismiss', view ? { id: view.viewId } : undefined);
},
};
}
@@ -2075,21 +2064,15 @@ function repeat(action) {
};
}
/*
* 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.
*/
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* Only supports x,y,width,height,corner(just for four corners),rotation,bgColor,
* @param panel @see Panel
@@ -2098,33 +2081,30 @@ function animate(context) {
const entity = context.entity;
if (entity instanceof Panel) {
let panel = entity;
return (args) => {
return takeLet(panel.context.animate)(it => {
return it.submit().then(() => {
args.animations();
return takeLet(panel.getRootView())(root => {
if (root.isDirty()) {
const model = root.toModel();
model.duration = args.duration;
const ret = it.animateRender(model);
root.clean();
return ret;
return (args) => __awaiter(this, void 0, void 0, function* () {
yield context.callNative('animate', 'submit');
args.animations();
return takeLet(panel.getRootView())(root => {
if (root.isDirty()) {
const model = root.toModel();
model.duration = args.duration;
const ret = context.callNative('animate', 'animateRender', model);
root.clean();
return ret;
}
for (let map of panel.allHeadViews()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model_1 = v.toModel();
const ret_1 = context.callNative('animate', 'animateRender', model_1);
v.clean();
return ret_1;
}
for (let map of panel.allHeadViews()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel();
const ret = it.animateRender(model);
it.clean();
return ret;
}
}
}
throw new Error('Cannot find any animated elements');
});
});
}
}
throw new Error('Cannot find any animated elements');
});
};
});
}
else {
return (args) => {
@@ -2139,15 +2119,15 @@ function notification(context) {
if (args.data !== undefined) {
args.data = JSON.stringify(args.data);
}
return context.notification.publish(args);
return context.callNative('notification', 'publish', args);
},
subscribe: (args) => {
args.callback = context.function2Id(args.callback);
return context.notification.subscribe(args);
return context.callNative('notification', 'subscribe', args);
},
unsubscribe: (subscribeId) => {
context.removeFuncById(subscribeId);
return context.notification.unsubscribe(subscribeId);
return context.callNative('notification', 'unsubscribe', subscribeId);
}
};
}
@@ -2159,13 +2139,13 @@ function notification(context) {
function statusbar(context) {
return {
setHidden: (hidden) => {
return context.statusbar.setHidden({ hidden });
return context.callNative('statusbar', 'setHidden', { hidden });
},
setMode: (mode) => {
return context.statusbar.setMode({ mode });
return context.callNative('statusbar', 'setMode', { mode });
},
setColor: (color) => {
return context.statusbar.setColor({ color: color.toModel() });
return context.callNative('statusbar', 'setColor', { color: color.toModel() });
},
};
}

View File

@@ -1723,7 +1723,6 @@ class View {
nativeChannel(context, name) {
let thisView = this;
return function (args = undefined) {
const func = context.shader.command;
const viewIds = [];
while (thisView != undefined) {
viewIds.push(thisView.viewId);
@@ -1734,7 +1733,7 @@ class View {
name,
args,
};
return Reflect.apply(func, undefined, [params]);
return context.callNative('shader', 'command', params);
};
}
getWidth(context) {
@@ -1796,10 +1795,6 @@ __decorate([
Property,
__metadata("design:type", Boolean)
], View.prototype, "hidden", void 0);
__decorate([
Property,
__metadata("design:type", Object)
], View.prototype, "viewId", void 0);
__decorate([
Property,
__metadata("design:type", Object)
@@ -3278,29 +3273,29 @@ function draggable(views, config) {
function modal(context) {
return {
toast: (msg, gravity = Gravity.Bottom) => {
context.modal.toast({
context.callNative('modal', 'toast', {
msg,
gravity: gravity.toModel(),
});
},
alert: (arg) => {
if (typeof arg === 'string') {
return context.modal.alert({ msg: arg });
return context.callNative('modal', 'alert', { msg: arg });
}
else {
return context.modal.alert(arg);
return context.callNative('modal', 'alert', arg);
}
},
confirm: (arg) => {
if (typeof arg === 'string') {
return context.modal.confirm({ msg: arg });
return context.callNative('modal', 'confirm', { msg: arg });
}
else {
return context.modal.confirm(arg);
return context.callNative('modal', 'confirm', arg);
}
},
prompt: (arg) => {
return context.modal.prompt(arg);
return context.callNative('modal', 'prompt', arg);
},
};
}
@@ -3313,36 +3308,30 @@ function navbar(context) {
}
return {
isHidden: () => {
return context.navbar.isHidden();
return context.callNative('navbar', 'isHidden');
},
setHidden: (hidden) => {
return context.navbar.setHidden({
hidden,
});
return context.callNative('navbar', 'setHidden', { hidden, });
},
setTitle: (title) => {
return context.navbar.setTitle({
title,
});
return context.callNative('navbar', 'setTitle', { title, });
},
setBgColor: (color) => {
return context.navbar.setBgColor({
color: color.toModel(),
});
return context.callNative('navbar', 'setBgColor', { color: color.toModel(), });
},
setLeft: (view) => {
if (panel) {
panel.clearHeadViews("navbar_left");
panel.addHeadView("navbar_left", view);
}
return context.navbar.setLeft(view.toModel());
return context.callNative('navbar', 'setLeft', view.toModel());
},
setRight: (view) => {
if (panel) {
panel.clearHeadViews("navbar_right");
panel.addHeadView("navbar_right", view);
}
return context.navbar.setRight(view.toModel());
return context.callNative('navbar', 'setRight', view.toModel());
}
};
}
@@ -3353,12 +3342,12 @@ function navigator(context) {
if (config && config.extra) {
config.extra = JSON.stringify(config.extra);
}
return context.navigator.push({
return context.callNative('navigator', 'push', {
scheme, config
});
},
pop: (animated = true) => {
return context.navigator.pop({ animated });
return context.callNative('navigator', 'pop', { animated });
},
};
}
@@ -3380,7 +3369,7 @@ function transformRequest(request) {
function network(context) {
return {
request: (config) => {
return context.network.request(transformRequest(config));
return context.callNative('network', 'request', transformRequest(config));
},
get: (url, config) => {
let finalConfig = config;
@@ -3389,7 +3378,7 @@ function network(context) {
}
finalConfig.url = url;
finalConfig.method = "get";
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
post: (url, data, config) => {
let finalConfig = config;
@@ -3401,7 +3390,7 @@ function network(context) {
if (data !== undefined) {
finalConfig.data = data;
}
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
put: (url, data, config) => {
let finalConfig = config;
@@ -3413,7 +3402,7 @@ function network(context) {
if (data !== undefined) {
finalConfig.data = data;
}
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
delete: (url, data, config) => {
let finalConfig = config;
@@ -3422,7 +3411,7 @@ function network(context) {
}
finalConfig.url = url;
finalConfig.method = "delete";
return context.network.request(transformRequest(finalConfig));
return context.callNative('network', 'request', transformRequest(finalConfig));
},
};
}
@@ -3430,16 +3419,16 @@ function network(context) {
function storage(context) {
return {
setItem: (key, value, zone) => {
return context.storage.setItem({ key, value, zone });
return context.callNative('storage', 'setItem', { key, value, zone });
},
getItem: (key, zone) => {
return context.storage.getItem({ key, zone });
return context.callNative('storage', 'getItem', { key, zone });
},
remove: (key, zone) => {
return context.storage.remove({ key, zone });
return context.callNative('storage', 'remove', { key, zone });
},
clear: (zone) => {
return context.storage.clear({ zone });
return context.callNative('storage', 'clear', { zone });
},
};
}
@@ -3455,7 +3444,7 @@ function popover(context) {
if (panel) {
panel.addHeadView("popover", view);
}
return context.popover.show(view.toModel());
return context.callNative('popover', 'show', view.toModel());
},
dismiss: (view = undefined) => {
if (panel) {
@@ -3466,7 +3455,7 @@ function popover(context) {
panel.clearHeadViews("popover");
}
}
return context.popover.dismiss(view ? { id: view.viewId } : undefined);
return context.callNative('popover', 'dismiss', view ? { id: view.viewId } : undefined);
},
};
}
@@ -3534,21 +3523,15 @@ function repeat(action) {
};
}
/*
* 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.
*/
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* Only supports x,y,width,height,corner(just for four corners),rotation,bgColor,
* @param panel @see Panel
@@ -3557,33 +3540,30 @@ function animate(context) {
const entity = context.entity;
if (entity instanceof Panel) {
let panel = entity;
return (args) => {
return takeLet(panel.context.animate)(it => {
return it.submit().then(() => {
args.animations();
return takeLet(panel.getRootView())(root => {
if (root.isDirty()) {
const model = root.toModel();
model.duration = args.duration;
const ret = it.animateRender(model);
root.clean();
return ret;
return (args) => __awaiter(this, void 0, void 0, function* () {
yield context.callNative('animate', 'submit');
args.animations();
return takeLet(panel.getRootView())(root => {
if (root.isDirty()) {
const model = root.toModel();
model.duration = args.duration;
const ret = context.callNative('animate', 'animateRender', model);
root.clean();
return ret;
}
for (let map of panel.allHeadViews()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model_1 = v.toModel();
const ret_1 = context.callNative('animate', 'animateRender', model_1);
v.clean();
return ret_1;
}
for (let map of panel.allHeadViews()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel();
const ret = it.animateRender(model);
it.clean();
return ret;
}
}
}
throw new Error('Cannot find any animated elements');
});
});
}
}
throw new Error('Cannot find any animated elements');
});
};
});
}
else {
return (args) => {
@@ -3598,15 +3578,15 @@ function notification(context) {
if (args.data !== undefined) {
args.data = JSON.stringify(args.data);
}
return context.notification.publish(args);
return context.callNative('notification', 'publish', args);
},
subscribe: (args) => {
args.callback = context.function2Id(args.callback);
return context.notification.subscribe(args);
return context.callNative('notification', 'subscribe', args);
},
unsubscribe: (subscribeId) => {
context.removeFuncById(subscribeId);
return context.notification.unsubscribe(subscribeId);
return context.callNative('notification', 'unsubscribe', subscribeId);
}
};
}
@@ -3618,13 +3598,13 @@ function notification(context) {
function statusbar(context) {
return {
setHidden: (hidden) => {
return context.statusbar.setHidden({ hidden });
return context.callNative('statusbar', 'setHidden', { hidden });
},
setMode: (mode) => {
return context.statusbar.setMode({ mode });
return context.callNative('statusbar', 'setMode', { mode });
},
setColor: (color) => {
return context.statusbar.setColor({ color: color.toModel() });
return context.callNative('statusbar', 'setColor', { color: color.toModel() });
},
};
}