Add Load Internal Class Support
This commit is contained in:
10
doric-js/lib/src/runtime/sandbox.d.ts
vendored
10
doric-js/lib/src/runtime/sandbox.d.ts
vendored
@@ -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<T> = new (...args: any) => T;
|
||||
export declare function jsObtainEntry(contextId: string): () => ((constructor: ClassType<object>) => {
|
||||
new (...args: any): {
|
||||
context: Context | undefined;
|
||||
};
|
||||
}) | {
|
||||
new (...args: any): {
|
||||
context: Context | undefined;
|
||||
};
|
||||
};
|
||||
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
|
||||
export declare function jsCallbackTimer(timerId: number): void;
|
||||
export {};
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user