diff --git a/doric-demo/src/MultiPanelDemo.ts b/doric-demo/src/MultiPanelDemo.ts index c7f0e608..b1521f43 100644 --- a/doric-demo/src/MultiPanelDemo.ts +++ b/doric-demo/src/MultiPanelDemo.ts @@ -32,6 +32,17 @@ class MultiPanelDemo extends Panel { navigator(context).push(CounterPage) } }), + label('Multi Panel').apply({ + width: 200, + height: 50, + backgroundColor: colors[0], + textSize: 30, + textColor: Color.WHITE, + layoutConfig: layoutConfig().just(), + onClick: () => { + navigator(context).push(MultiPanelDemo) + } + }), ], { layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT), diff --git a/doric-js/bundle/doric-sandbox.es5.js b/doric-js/bundle/doric-sandbox.es5.js index eab49ee8..beff7d39 100644 --- a/doric-js/bundle/doric-sandbox.es5.js +++ b/doric-js/bundle/doric-sandbox.es5.js @@ -1205,19 +1205,21 @@ var doric = (function (exports) { }); })(Reflect$1 || (Reflect$1 = {})); - var __extends = (undefined && undefined.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - })(); + /* + * 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. + */ function hookBeforeNativeCall(context) { if (context) { Reflect.defineMetadata('__doric_context__', context, global$1); @@ -1396,19 +1398,11 @@ var doric = (function (exports) { function jsObtainEntry(contextId) { var context = jsObtainContext(contextId); var exportFunc = function (constructor) { - var _a; - (_a = context === null || context === void 0 ? void 0 : context.classes) === null || _a === void 0 ? void 0 : _a.set(constructor.name, constructor); - var ret = /** @class */ (function (_super) { - __extends(class_1, _super); - function class_1() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.context = context; - return _this; - } - return class_1; - }(constructor)); - context === null || context === void 0 ? void 0 : context.register(new ret); - return ret; + context === null || context === void 0 ? void 0 : context.classes.set(constructor.name, constructor); + var ret = new constructor; + Reflect.set(ret, 'context', context); + context === null || context === void 0 ? void 0 : context.register(ret); + return constructor; }; return function () { if (arguments.length === 1) { diff --git a/doric-js/bundle/doric-sandbox.js b/doric-js/bundle/doric-sandbox.js index 52d375a7..182a9265 100644 --- a/doric-js/bundle/doric-sandbox.js +++ b/doric-js/bundle/doric-sandbox.js @@ -1397,24 +1397,18 @@ var doric = (function (exports) { function jsObtainEntry(contextId) { const context = jsObtainContext(contextId); const exportFunc = (constructor) => { - var _a; - (_a = context === null || context === void 0 ? void 0 : context.classes) === null || _a === void 0 ? void 0 : _a.set(constructor.name, constructor); - const ret = class extends constructor { - constructor() { - super(...arguments); - this.context = context; - } - }; - context === null || context === void 0 ? void 0 : context.register(new ret); - return ret; + context === null || context === void 0 ? void 0 : context.classes.set(constructor.name, constructor); + const ret = new constructor; + Reflect.set(ret, 'context', context); + context === null || context === void 0 ? void 0 : context.register(ret); + return constructor; }; return function () { if (arguments.length === 1) { const args = arguments[0]; if (args instanceof Array) { args.forEach(clz => { - var _a; - (_a = context === null || context === void 0 ? void 0 : context.classes) === null || _a === void 0 ? void 0 : _a.set(clz.name, clz); + context === null || context === void 0 ? void 0 : context.classes.set(clz.name, clz); }); return exportFunc; } diff --git a/doric-js/bundle/doric-vm.js b/doric-js/bundle/doric-vm.js index dd5fad09..5f96efe6 100644 --- a/doric-js/bundle/doric-vm.js +++ b/doric-js/bundle/doric-vm.js @@ -1420,24 +1420,18 @@ function jsCallEntityMethod(contextId, methodName, args) { function jsObtainEntry(contextId) { const context = jsObtainContext(contextId); const exportFunc = (constructor) => { - var _a; - (_a = context === null || context === void 0 ? void 0 : context.classes) === null || _a === void 0 ? void 0 : _a.set(constructor.name, constructor); - const ret = class extends constructor { - constructor() { - super(...arguments); - this.context = context; - } - }; - context === null || context === void 0 ? void 0 : context.register(new ret); - return ret; + context === null || context === void 0 ? void 0 : context.classes.set(constructor.name, constructor); + const ret = new constructor; + Reflect.set(ret, 'context', context); + context === null || context === void 0 ? void 0 : context.register(ret); + return constructor; }; return function () { if (arguments.length === 1) { const args = arguments[0]; if (args instanceof Array) { args.forEach(clz => { - var _a; - (_a = context === null || context === void 0 ? void 0 : context.classes) === null || _a === void 0 ? void 0 : _a.set(clz.name, clz); + context === null || context === void 0 ? void 0 : context.classes.set(clz.name, clz); }); return exportFunc; } diff --git a/doric-js/lib/src/runtime/sandbox.d.ts b/doric-js/lib/src/runtime/sandbox.d.ts index 6620fcf4..694dae80 100644 --- a/doric-js/lib/src/runtime/sandbox.d.ts +++ b/doric-js/lib/src/runtime/sandbox.d.ts @@ -23,14 +23,6 @@ export declare function __require__(name: string): any; export declare function jsRegisterModule(name: string, moduleObject: any): void; export declare function jsCallEntityMethod(contextId: string, methodName: string, args?: any): any; declare type ClassType = new (...args: any) => T; -export declare function jsObtainEntry(contextId: string): () => ((constructor: ClassType) => { - new (...args: any): { - context: Context | undefined; - }; -}) | { - new (...args: any): { - context: Context | undefined; - }; -}; +export declare function jsObtainEntry(contextId: string): () => ClassType | ((constructor: ClassType) => ClassType); export declare function jsCallbackTimer(timerId: number): void; export {}; diff --git a/doric-js/lib/src/runtime/sandbox.js b/doric-js/lib/src/runtime/sandbox.js index 6d2808b8..ed2b22e0 100644 --- a/doric-js/lib/src/runtime/sandbox.js +++ b/doric-js/lib/src/runtime/sandbox.js @@ -215,24 +215,18 @@ export function jsCallEntityMethod(contextId, methodName, args) { export function jsObtainEntry(contextId) { const context = jsObtainContext(contextId); const exportFunc = (constructor) => { - var _a; - (_a = context === null || context === void 0 ? void 0 : context.classes) === null || _a === void 0 ? void 0 : _a.set(constructor.name, constructor); - const ret = class extends constructor { - constructor() { - super(...arguments); - this.context = context; - } - }; - context === null || context === void 0 ? void 0 : context.register(new ret); - return ret; + context === null || context === void 0 ? void 0 : context.classes.set(constructor.name, constructor); + const ret = new constructor; + Reflect.set(ret, 'context', context); + context === null || context === void 0 ? void 0 : context.register(ret); + return constructor; }; return function () { if (arguments.length === 1) { const args = arguments[0]; if (args instanceof Array) { args.forEach(clz => { - var _a; - (_a = context === null || context === void 0 ? void 0 : context.classes) === null || _a === void 0 ? void 0 : _a.set(clz.name, clz); + context === null || context === void 0 ? void 0 : context.classes.set(clz.name, clz); }); return exportFunc; } diff --git a/doric-js/src/runtime/sandbox.es5.ts b/doric-js/src/runtime/sandbox.es5.ts index 1f447206..ad284320 100644 --- a/doric-js/src/runtime/sandbox.es5.ts +++ b/doric-js/src/runtime/sandbox.es5.ts @@ -240,12 +240,11 @@ type ClassType = new (...args: any) => T export function jsObtainEntry(contextId: string) { const context = jsObtainContext(contextId) const exportFunc = (constructor: ClassType) => { - context?.classes?.set(constructor.name, constructor) - const ret = class extends constructor { - context = context - } - context?.register(new ret) - return ret + context?.classes.set(constructor.name, constructor) + const ret = new constructor + Reflect.set(ret, 'context', context) + context?.register(ret) + return constructor } return function () { if (arguments.length === 1) { diff --git a/doric-js/src/runtime/sandbox.ts b/doric-js/src/runtime/sandbox.ts index 3eca3eee..d4cc7ef2 100644 --- a/doric-js/src/runtime/sandbox.ts +++ b/doric-js/src/runtime/sandbox.ts @@ -278,19 +278,18 @@ type ClassType = new (...args: any) => T export function jsObtainEntry(contextId: string) { const context = jsObtainContext(contextId) const exportFunc = (constructor: ClassType) => { - context?.classes?.set(constructor.name, constructor) - const ret = class extends constructor { - context = context - } - context?.register(new ret) - return ret + context?.classes.set(constructor.name, constructor) + const ret = new constructor + Reflect.set(ret, 'context', context) + context?.register(ret) + return constructor } return function () { if (arguments.length === 1) { const args = arguments[0] if (args instanceof Array) { args.forEach(clz => { - context?.classes?.set(clz.name, clz) + context?.classes.set(clz.name, clz) }) return exportFunc } else {