simple-boot-core
Advanced tools
Comparing version 1.0.26 to 1.0.27
import { ReflectMethod } from '../../types/Types'; | ||
export declare type InjectionConfig = {}; | ||
export declare const Injection: (config?: InjectionConfig | undefined) => ReflectMethod; | ||
export declare const getInjection: (target: any, propertyKey: string) => any; | ||
export declare const getInjection: (target: any, propertyKey: string | symbol) => InjectionConfig | undefined; |
@@ -8,3 +8,3 @@ "use strict"; | ||
return function (target, propertyKey, descriptor) { | ||
ReflectUtils_1.ReflectUtils.defineMetadata(InjectionMetadataKey, config, target, propertyKey); | ||
ReflectUtils_1.ReflectUtils.defineMetadata(InjectionMetadataKey, config !== null && config !== void 0 ? config : {}, target, propertyKey); | ||
}; | ||
@@ -11,0 +11,0 @@ }; |
@@ -7,18 +7,6 @@ import "reflect-metadata"; | ||
} | ||
export declare type RouteProperty = ConstructorType<Object> | [ConstructorType<Object>, any] | string; | ||
export declare type Route = { | ||
[name: string]: RouteProperty; | ||
}; | ||
export interface RouterConfig { | ||
path: string; | ||
route: Route; | ||
routers?: ConstructorType<Object>[]; | ||
} | ||
export declare const SimMetadataKey: unique symbol; | ||
export declare const Sim: (config?: SimConfig) => GenericClassDecorator<ConstructorType<any>>; | ||
export declare const getSim: (target: ConstructorType<any> | Function | any) => SimConfig | undefined; | ||
export declare const RouterMetadataKey: unique symbol; | ||
export declare const Router: (config?: RouterConfig | undefined) => GenericClassDecorator<ConstructorType<any>>; | ||
export declare const getRouter: (target: ConstructorType<any> | Function | any) => RouterConfig | undefined; | ||
export declare const PostConstruct: (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; | ||
export declare const getPostConstruct: (target: any, propertyKey: string) => any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPostConstruct = exports.PostConstruct = exports.getRouter = exports.Router = exports.RouterMetadataKey = exports.getSim = exports.Sim = exports.SimMetadataKey = exports.sims = void 0; | ||
exports.getPostConstruct = exports.PostConstruct = exports.getSim = exports.Sim = exports.SimMetadataKey = exports.sims = void 0; | ||
require("reflect-metadata"); | ||
@@ -26,19 +26,2 @@ var ReflectUtils_1 = require("../utils/reflect/ReflectUtils"); | ||
exports.getSim = getSim; | ||
exports.RouterMetadataKey = Symbol('Router'); | ||
var Router = function (config) { | ||
return function (target) { | ||
ReflectUtils_1.ReflectUtils.defineMetadata(exports.RouterMetadataKey, config, target); | ||
}; | ||
}; | ||
exports.Router = Router; | ||
var getRouter = function (target) { | ||
if (null != target && undefined != target && typeof target === 'object') { | ||
target = target.constructor; | ||
} | ||
try { | ||
return ReflectUtils_1.ReflectUtils.getMetadata(exports.RouterMetadataKey, target); | ||
} | ||
catch (e) { } | ||
}; | ||
exports.getRouter = getRouter; | ||
var PostConstructMetadataKey = Symbol('PostConstruct'); | ||
@@ -45,0 +28,0 @@ var PostConstruct = function (target, propertyKey, descriptor) { |
{ | ||
"name": "simple-boot-core", | ||
"version": "1.0.26", | ||
"version": "1.0.27", | ||
"main": "SimpleApplication.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -51,3 +51,3 @@ "use strict"; | ||
var RouterModule_1 = require("./RouterModule"); | ||
var SimDecorator_1 = require("../decorators/SimDecorator"); | ||
var Router_1 = require("../decorators/route/Router"); | ||
var SimAtomic_1 = require("../simstance/SimAtomic"); | ||
@@ -67,9 +67,11 @@ var OnRoute_1 = require("../decorators/route/OnRoute"); | ||
var routerAtomic = new SimAtomic_1.SimAtomic(router, this.simstanceManager); | ||
var routerData = routerAtomic.getConfig(SimDecorator_1.RouterMetadataKey); | ||
var routerData = routerAtomic.getConfig(Router_1.RouterMetadataKey); | ||
if (routerData) { | ||
var currentPrefix_1 = prefix + routerData.path; | ||
Object.entries(routerData.route).forEach(function (_a) { | ||
var key = _a[0], value = _a[1]; | ||
map[currentPrefix_1 + key] = value; | ||
}); | ||
if (routerData.route) { | ||
Object.entries(routerData.route).forEach(function (_a) { | ||
var key = _a[0], value = _a[1]; | ||
map[currentPrefix_1 + key] = value; | ||
}); | ||
} | ||
(_a = routerData.routers) === null || _a === void 0 ? void 0 : _a.forEach(function (it) { | ||
@@ -203,5 +205,5 @@ Object.assign(map, _this.routingMap(currentPrefix_1, it)); | ||
var path = intent.pathname; | ||
var routerConfig = router.getConfig(SimDecorator_1.RouterMetadataKey); | ||
var routerConfig = router.getConfig(Router_1.RouterMetadataKey); | ||
if (routerConfig) { | ||
var routerStrings = parentRouters.slice(1).map(function (it) { var _a; return ((_a = it.getConfig(SimDecorator_1.RouterMetadataKey)) === null || _a === void 0 ? void 0 : _a.path) || ''; }); | ||
var routerStrings = parentRouters.slice(1).map(function (it) { var _a; return ((_a = it.getConfig(Router_1.RouterMetadataKey)) === null || _a === void 0 ? void 0 : _a.path) || ''; }); | ||
var isRoot = this.isRootUrl(routerConfig.path, routerStrings, path); | ||
@@ -234,11 +236,14 @@ if (isRoot) { | ||
var urlRoot = parentRoots.join('') + routerData.path; | ||
for (var _i = 0, _a = Object.keys(routerData.route).filter(function (it) { return !it.startsWith('_'); }); _i < _a.length; _i++) { | ||
var it_1 = _a[_i]; | ||
var pathnameData = intent.getPathnameData(urlRoot + it_1); | ||
if (pathnameData) { | ||
var _b = this.findRouteProperty(routerData.route, it_1), child = _b.child, data = _b.data; | ||
var rm = new RouterModule_1.RouterModule(this.simstanceManager, router, child); | ||
rm.data = data; | ||
rm.pathData = pathnameData; | ||
return rm; | ||
if (routerData.route) { | ||
for (var _i = 0, _a = Object.keys(routerData.route).filter(function (it) { return !it.startsWith('_'); }); _i < _a.length; _i++) { | ||
var it_1 = _a[_i]; | ||
var pathnameData = intent.getPathnameData(urlRoot + it_1); | ||
if (pathnameData) { | ||
var _b = this.findRouteProperty(routerData.route, it_1), child = _b.child, data = _b.data, propertyKeys = _b.propertyKeys; | ||
var rm = new RouterModule_1.RouterModule(this.simstanceManager, router, child); | ||
rm.data = data; | ||
rm.pathData = pathnameData; | ||
rm.propertyKeys = propertyKeys; | ||
return rm; | ||
} | ||
} | ||
@@ -250,2 +255,3 @@ } | ||
var data; | ||
var propertyKeys; | ||
var routeElement = route[propertyName]; | ||
@@ -262,5 +268,10 @@ if (typeof routeElement === 'function') { | ||
} | ||
else if (typeof routeElement === 'object' && 'target' in routeElement && 'propertyKeys' in routeElement) { | ||
child = routeElement.target; | ||
propertyKeys = routeElement.propertyKeys; | ||
} | ||
return { | ||
child: child, | ||
data: data | ||
data: data, | ||
propertyKeys: propertyKeys | ||
}; | ||
@@ -267,0 +278,0 @@ }; |
@@ -15,4 +15,6 @@ import { ConstructorType } from '../types/Types'; | ||
intent?: Intent; | ||
propertyKeys?: (string | symbol)[]; | ||
constructor(simstanceManager: SimstanceManager, router?: R | undefined, module?: ConstructorType<M> | undefined, routerChains?: R[]); | ||
getModuleInstance<T = M>(): T | undefined; | ||
executeModuleProperty(propertyKey: string | symbol, ...param: any[]): any; | ||
get lastRouteChain(): R; | ||
@@ -19,0 +21,0 @@ get lastRouteChainValue(): any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RouterModule = void 0; | ||
var Injection_1 = require("../decorators/inject/Injection"); | ||
var RouterModule = (function () { | ||
@@ -15,2 +16,20 @@ function RouterModule(simstanceManager, router, module, routerChains) { | ||
}; | ||
RouterModule.prototype.executeModuleProperty = function (propertyKey) { | ||
var param = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
param[_i - 1] = arguments[_i]; | ||
} | ||
var target = this.getModuleInstance(); | ||
if (propertyKey) { | ||
var config = (0, Injection_1.getInjection)(target, propertyKey); | ||
if (config) { | ||
var other_1 = new Map(); | ||
param.forEach(function (it) { return other_1.set(it.constructor, it); }); | ||
return this.simstanceManager.executeBindParameterSim({ target: target, targetKey: propertyKey }, other_1); | ||
} | ||
else { | ||
return target[propertyKey].apply(target, param); | ||
} | ||
} | ||
}; | ||
Object.defineProperty(RouterModule.prototype, "lastRouteChain", { | ||
@@ -17,0 +36,0 @@ get: function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123414
80
2632