Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-boot-core

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-boot-core - npm Package Compare versions

Comparing version 1.0.16 to 1.0.17

cycles/LifeCycle.d.ts

3

decorators/event/EventListener.d.ts

@@ -1,4 +0,3 @@

import { FromEventTarget } from 'rxjs/internal/observable/fromEvent';
export interface EventListenerOption {
target: string | any | FromEventTarget<any>;
target: string | any;
name: string;

@@ -5,0 +4,0 @@ }

@@ -5,5 +5,16 @@ import { ConstructorType, GenericClassDecorator } from '../types/Types';

}
export declare const Sim: (config?: SimConfig | undefined) => GenericClassDecorator<ConstructorType<any>>;
export interface RouterConfig {
path: string;
childs: {
[name: string]: ConstructorType<Object>;
};
childRouters?: 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.getSim = exports.Sim = void 0;
exports.getPostConstruct = exports.PostConstruct = exports.getRouter = exports.Router = exports.RouterMetadataKey = exports.getSim = exports.Sim = exports.SimMetadataKey = void 0;
var SimGlobal_1 = require("../global/SimGlobal");
var ReflectUtils_1 = require("../utils/reflect/ReflectUtils");
var SimMetadataKey = Symbol('Sim');
exports.SimMetadataKey = Symbol('Sim');
var Sim = function (config) {
if (config === void 0) { config = {}; }
return function (target) {
ReflectUtils_1.ReflectUtils.defineMetadata(SimMetadataKey, config, target);
ReflectUtils_1.ReflectUtils.defineMetadata(exports.SimMetadataKey, config, target);
SimGlobal_1.SimGlobal().storage.add(target);

@@ -19,8 +20,24 @@ };

try {
return ReflectUtils_1.ReflectUtils.getMetadata(SimMetadataKey, target);
return ReflectUtils_1.ReflectUtils.getMetadata(exports.SimMetadataKey, target);
}
catch (e) {
catch (e) { }
};
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 (typeof target === 'object') {
target = target.constructor;
}
try {
return ReflectUtils_1.ReflectUtils.getMetadata(exports.RouterMetadataKey, target);
}
catch (e) { }
};
exports.getSim = getSim;
exports.getRouter = getRouter;
var PostConstructMetadataKey = Symbol('PostConstruct');

@@ -27,0 +44,0 @@ var PostConstruct = function (target, propertyKey, descriptor) {

@@ -67,3 +67,3 @@ "use strict";

var urlExpressions = urlExpression.split('/');
if (urls.length != urlExpressions.length) {
if (urls.length !== urlExpressions.length) {
return;

@@ -70,0 +70,0 @@ }

@@ -7,3 +7,3 @@ import 'reflect-metadata';

constructor(simstanceManager: SimstanceManager);
publish(it: Intent): void;
publish(it: Intent | string, data?: any): void;
}

@@ -5,2 +5,3 @@ "use strict";

require("reflect-metadata");
var Intent_1 = require("./Intent");
var IntentManager = (function () {

@@ -10,12 +11,16 @@ function IntentManager(simstanceManager) {

}
IntentManager.prototype.publish = function (it) {
IntentManager.prototype.publish = function (it, data) {
var _this = this;
this.simstanceManager.getSimConfig(it.scheme).forEach(function (data) {
if (typeof it === 'string') {
it = new Intent_1.Intent(it, data);
}
var intent = it;
this.simstanceManager.getSimConfig(intent.scheme).forEach(function (data) {
var _a, _b;
var orNewSim = (_a = _this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(data.type);
if (orNewSim) {
if (it.paths.length > 0) {
if (intent.paths.length > 0) {
var callthis_1 = orNewSim;
var lastProp_1 = '';
it.paths.filter(function (i) { return i; }).forEach(function (i) {
intent.paths.filter(function (i) { return i; }).forEach(function (i) {
callthis_1 = orNewSim;

@@ -26,10 +31,10 @@ orNewSim = orNewSim === null || orNewSim === void 0 ? void 0 : orNewSim[i];

if (orNewSim && typeof orNewSim === 'function') {
orNewSim.call(callthis_1, it);
orNewSim.call(callthis_1, intent);
}
else if (orNewSim) {
callthis_1[lastProp_1] = it.data;
callthis_1[lastProp_1] = intent.data;
}
}
else {
(_b = orNewSim === null || orNewSim === void 0 ? void 0 : orNewSim.subscribe) === null || _b === void 0 ? void 0 : _b.call(orNewSim, it);
(_b = orNewSim === null || orNewSim === void 0 ? void 0 : orNewSim.subscribe) === null || _b === void 0 ? void 0 : _b.call(orNewSim, intent);
}

@@ -36,0 +41,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = void 0;
var SimGlobal_1 = require("../global/SimGlobal");
var Module = (function () {
function Module() {
this._refModule = new Map();
}
Module.prototype.onCreate = function () {
};
Module.prototype.publish = function (intent) {
var _a;
(_a = SimGlobal_1.SimGlobal().application) === null || _a === void 0 ? void 0 : _a.publishIntent(intent);
};
Module.prototype.subscribe = function (intent) {
};
return Module;
}());
exports.Module = Module;
{
"name": "simple-boot-core",
"version": "1.0.16",
"version": "1.0.17",
"main": "SimpleApplication.js",

@@ -69,10 +69,7 @@ "license": "MIT",

"jest": "^26.6.3",
"reflect-metadata": "^0.1.13",
"supertest": "^6.1.3",
"ts-jest": "^26.5.4",
"typescript": "^4.2.3"
},
"dependencies": {
"reflect-metadata": "^0.1.13",
"rxjs": "^6.6.7"
}
}

@@ -1,7 +0,7 @@

import { SimProxy } from './SimProxy';
import { SimOption } from "../SimOption";
export declare class SimProxyHandler extends SimProxy {
import { SimstanceManager } from '../simstance/SimstanceManager';
import { SimOption } from '../SimOption';
export declare class SimProxyHandler implements ProxyHandler<any> {
private simstanceManager;
private simOption;
private simstanceManager?;
constructor(simOption: SimOption);
constructor(simstanceManager: SimstanceManager, simOption: SimOption);
get(target: any, name: string): any;

@@ -12,2 +12,3 @@ set(obj: any, prop: string, value: any, receiver: any): boolean;

private aopAfter;
has(target: any, key: PropertyKey): boolean;
}
"use strict";
var __extends = (this && this.__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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimProxyHandler = void 0;
var Module_1 = require("../module/Module");
var SimGlobal_1 = require("../global/SimGlobal");
var SimDecorator_1 = require("../decorators/SimDecorator");
var ExceptionDecorator_1 = require("../decorators/exception/ExceptionDecorator");
var AOPDecorator_1 = require("../decorators/aop/AOPDecorator");
var ObjectUtils_1 = require("../utils/object/ObjectUtils");
var SimProxy_1 = require("./SimProxy");
var SimOption_1 = require("../SimOption");
var SimProxyHandler = (function (_super) {
__extends(SimProxyHandler, _super);
function SimProxyHandler(simOption) {
var _a;
var _this = _super.call(this) || this;
_this.simOption = simOption;
_this.simstanceManager = (_a = SimGlobal_1.SimGlobal().application) === null || _a === void 0 ? void 0 : _a.simstanceManager;
return _this;
var SimProxyHandler = (function () {
function SimProxyHandler(simstanceManager, simOption) {
this.simstanceManager = simstanceManager;
this.simOption = simOption;
}

@@ -50,10 +17,5 @@ SimProxyHandler.prototype.get = function (target, name) {

var _a;
value = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.proxy(value, Module_1.Module);
value = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.proxy(value);
obj[prop] = value;
if (this.simOption.simProxy) {
return this.simOption.simProxy.set(obj, prop, value, receiver);
}
else {
return true;
}
return true;
};

@@ -119,8 +81,10 @@ SimProxyHandler.prototype.apply = function (target, thisArg, argumentsList) {

};
SimProxyHandler = __decorate([
SimDecorator_1.Sim(),
__metadata("design:paramtypes", [SimOption_1.SimOption])
], SimProxyHandler);
SimProxyHandler.prototype.has = function (target, key) {
if (key === 'isProxy') {
return true;
}
return key in target;
};
return SimProxyHandler;
}(SimProxy_1.SimProxy));
}());
exports.SimProxyHandler = SimProxyHandler;
import 'reflect-metadata';
import { SimstanceManager } from "../simstance/SimstanceManager";
import { Router } from "./Router";
import { Intent } from "../intent/Intent";
import { ConstructorType } from "../types/Types";
import { RouterModule } from "./RouterModule";
import { Intent } from '../intent/Intent';
import { ConstructorType } from '../types/Types';
import { RouterModule } from './RouterModule';
export declare class RouterManager {
private rootRouter;
private simstanceManager;
activeRouterModule?: RouterModule;
constructor(rootRouter: ConstructorType<Router>, simstanceManager: SimstanceManager);
routing(intent: Intent): Promise<RouterModule | undefined>;
constructor(rootRouter: ConstructorType<any>);
routing(intent: Intent): Promise<RouterModule<any, any> | undefined>;
private getExecuteModule;
private isRootUrl;
private findRouting;
}

@@ -42,46 +42,85 @@ "use strict";

var RouterModule_1 = require("./RouterModule");
var SimDecorator_1 = require("../decorators/SimDecorator");
var SimAtomic_1 = require("../simstance/SimAtomic");
var RouterManager = (function () {
function RouterManager(rootRouter, simstanceManager) {
function RouterManager(rootRouter) {
this.rootRouter = rootRouter;
this.simstanceManager = simstanceManager;
}
RouterManager.prototype.routing = function (intent) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var routers, rootRouter, executeModule, notFound, _i, _b, route, nf, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
routers = [];
rootRouter = this.simstanceManager.getOrNewSim(this.rootRouter);
executeModule = rootRouter === null || rootRouter === void 0 ? void 0 : rootRouter.getExecuteModule(intent, routers);
if (!executeModule) {
notFound = void 0;
for (_i = 0, _b = routers.slice().reverse(); _i < _b.length; _i++) {
route = _b[_i];
if (route !== rootRouter) {
nf = route.notFound(intent);
if (nf) {
notFound = nf;
break;
}
}
var routers, routerAtomic, rootRouterData, rootRouter, executeModule, notFound, _i, _a, route, nf;
return __generator(this, function (_b) {
routers = [];
routerAtomic = new SimAtomic_1.SimAtomic(this.rootRouter);
rootRouterData = routerAtomic.getConfig(SimDecorator_1.RouterMetadataKey);
rootRouter = routerAtomic.value;
executeModule = this.getExecuteModule(routerAtomic, intent, routers);
if (!executeModule) {
notFound = void 0;
for (_i = 0, _a = routers.slice().reverse(); _i < _a.length; _i++) {
route = _a[_i];
if (route !== rootRouter && route.notFound) {
nf = route.notFound(intent);
if (nf) {
notFound = nf;
break;
}
notFound = notFound !== null && notFound !== void 0 ? notFound : rootRouter === null || rootRouter === void 0 ? void 0 : rootRouter.notFound(intent);
return [2, this.activeRouterModule = new RouterModule_1.RouterModule(rootRouter, notFound, routers)];
}
if (!executeModule.router) return [3, 2];
executeModule.routerChains = routers;
_c = executeModule;
return [4, executeModule.router.canActivate(intent, executeModule)];
case 1:
_c.module = (_a = (_d.sent())) !== null && _a !== void 0 ? _a : executeModule.module;
return [2, this.activeRouterModule = executeModule];
case 2: return [2, undefined];
}
return [2, this.activeRouterModule = new RouterModule_1.RouterModule(rootRouter, notFound, routers)];
}
if (executeModule.router) {
executeModule.routerChains = routers;
return [2, this.activeRouterModule = executeModule];
}
else {
return [2, undefined];
}
return [2];
});
});
};
RouterManager.prototype.getExecuteModule = function (router, intent, parentRouters) {
var path = intent.pathname;
var routerConfig = router.getConfig(SimDecorator_1.RouterMetadataKey);
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 isRoot = this.isRootUrl(routerConfig.path, routerStrings, path);
if (isRoot) {
parentRouters.push(router);
var module_1 = this.findRouting(router, routerConfig, routerStrings, intent);
if (module_1 === null || module_1 === void 0 ? void 0 : module_1.module) {
return module_1;
}
else if (routerConfig.childRouters && routerConfig.childRouters.length > 0) {
for (var _i = 0, _a = routerConfig.childRouters; _i < _a.length; _i++) {
var child = _a[_i];
var routerAtomic = new SimAtomic_1.SimAtomic(child);
var rootRouterData = routerAtomic.getConfig(SimDecorator_1.RouterMetadataKey);
var router_1 = routerAtomic.value;
var executeModule = this.getExecuteModule(routerAtomic, intent, parentRouters);
if (router_1 && executeModule) {
return executeModule;
}
}
}
}
};
RouterManager.prototype.isRootUrl = function (path, parentRoots, url) {
return url.startsWith(parentRoots.join('') + (path || ''));
};
RouterManager.prototype.findRouting = function (router, routerData, parentRoots, intent) {
var urlRoot = parentRoots.join('') + routerData.path;
var regex = new RegExp('^' + urlRoot, 'i');
for (var _i = 0, _a = Object.keys(routerData.childs).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 rm = new RouterModule_1.RouterModule(router, routerData.childs[it_1]);
rm.pathData = pathnameData;
return rm;
}
}
};
return RouterManager;
}());
exports.RouterManager = RouterManager;

@@ -1,5 +0,4 @@

import { Router } from './Router';
import { Module } from "../module/Module";
import { ConstructorType } from "../types/Types";
export declare class RouterModule<R extends Router = Router, M extends Module = Module> {
import { ConstructorType } from '../types/Types';
import { SimAtomic } from '../simstance/SimAtomic';
export declare class RouterModule<R = SimAtomic, M = any> {
router?: R | undefined;

@@ -6,0 +5,0 @@ module?: ConstructorType<M> | undefined;

@@ -1,9 +0,12 @@

import { ConstructorType } from "./types/Types";
import { SimProxy } from "./proxy/SimProxy";
import { ConstructorType } from './types/Types';
export declare class SimOption {
advice: ConstructorType<any>[];
simProxy?: SimProxy | undefined;
constructor(advice?: ConstructorType<any>[], simProxy?: SimProxy | undefined);
proxy?: {
onProxy: <T>(it: T) => T;
} | undefined;
constructor(advice?: ConstructorType<any>[], proxy?: {
onProxy: <T>(it: T) => T;
} | undefined);
addAdvicce(advice: ConstructorType<any>): void;
setAdvice(...advice: ConstructorType<any>[]): SimOption;
}

@@ -5,6 +5,6 @@ "use strict";

var SimOption = (function () {
function SimOption(advice, simProxy) {
function SimOption(advice, proxy) {
if (advice === void 0) { advice = []; }
this.advice = advice;
this.simProxy = simProxy;
this.proxy = proxy;
}

@@ -11,0 +11,0 @@ SimOption.prototype.addAdvicce = function (advice) {

import { Runnable } from './run/Runnable';
import { SimstanceManager } from "./simstance/SimstanceManager";
import { SimOption } from "./SimOption";
import { Intent } from "./intent/Intent";
import { Router } from "./route/Router";
import { Module } from "./module/Module";
import { ConstructorType } from "./types/Types";
import { RouterModule } from "./route/RouterModule";
import { SimstanceManager } from './simstance/SimstanceManager';
import { SimOption } from './SimOption';
import { Intent } from './intent/Intent';
import { ConstructorType } from './types/Types';
import { RouterModule } from './route/RouterModule';
import { SimAtomic } from './simstance/SimAtomic';
export declare class SimpleApplication implements Runnable {
rootRouter: ConstructorType<Router>;
rootRouter: ConstructorType<Object>;
option: SimOption;

@@ -15,6 +14,6 @@ simstanceManager: SimstanceManager;

private routerManager;
constructor(rootRouter: ConstructorType<Router>, option?: SimOption);
constructor(rootRouter: ConstructorType<Object>, option?: SimOption);
run(): void;
publishIntent(i: Intent): void;
routing<R extends Router = Router, M extends Module = Module>(i: Intent): Promise<RouterModule<R, M>>;
routing<R = SimAtomic, M = any>(i: Intent): Promise<RouterModule<R, M> | undefined>;
}

@@ -52,3 +52,3 @@ "use strict";

this.intentManager = new IntentManager_1.IntentManager(this.simstanceManager);
this.routerManager = new RouterManager_1.RouterManager(this.rootRouter, this.simstanceManager);
this.routerManager = new RouterManager_1.RouterManager(this.rootRouter);
this.simstanceManager.storage.set(SimstanceManager_1.SimstanceManager, this.simstanceManager);

@@ -55,0 +55,0 @@ this.simstanceManager.storage.set(IntentManager_1.IntentManager, this.intentManager);

import { ConstructorType } from '../types/Types';
import { SimConfig } from '../decorators/SimDecorator';
import { SimstanceManager } from './SimstanceManager';
export declare class SimAtomic<T> {
export declare class SimAtomic<T extends Object = Object> {
type: ConstructorType<T>;
private simstanceManager;
constructor(type: ConstructorType<T>, simstanceManager?: SimstanceManager);
get config(): SimConfig | undefined;
getConfig<C = any>(key?: symbol): C | undefined;
getConfigs(): any[];
get value(): T | undefined;
}

@@ -6,2 +6,3 @@ "use strict";

var SimDecorator_1 = require("../decorators/SimDecorator");
var ReflectUtils_1 = require("../utils/reflect/ReflectUtils");
var SimAtomic = (function () {

@@ -14,9 +15,9 @@ function SimAtomic(type, simstanceManager) {

}
Object.defineProperty(SimAtomic.prototype, "config", {
get: function () {
return SimDecorator_1.getSim(this.type);
},
enumerable: false,
configurable: true
});
SimAtomic.prototype.getConfig = function (key) {
if (key === void 0) { key = SimDecorator_1.SimMetadataKey; }
return ReflectUtils_1.ReflectUtils.getMetadata(key, this.type);
};
SimAtomic.prototype.getConfigs = function () {
return ReflectUtils_1.ReflectUtils.getMetadatas(this.type);
};
Object.defineProperty(SimAtomic.prototype, "value", {

@@ -23,0 +24,0 @@ get: function () {

import 'reflect-metadata';
import { ConstructorType } from '../types/Types';
import { Module } from '../module/Module';
import { Runnable } from '../run/Runnable';
import { SimAtomic } from './SimAtomic';
import { SimProxy } from "../proxy/SimProxy";
import { SimOption } from "../SimOption";
import { SimProxyHandler } from "../proxy/SimProxyHandler";
import { SimOption } from '../SimOption';
export declare class SimstanceManager implements Runnable {
private option;
private _storage;

@@ -14,3 +12,3 @@ private simProxyHandler;

get storage(): Map<ConstructorType<any>, any>;
getSimAtomics(): SimAtomic<any>[];
getSimAtomics(): SimAtomic[];
getSimConfig(scheme: string | undefined): SimAtomic<any>[];

@@ -24,7 +22,4 @@ getOrNewSim<T>(k?: ConstructorType<T>): T | undefined;

getParameterSim(target: Object, targetKey?: string | symbol): any[];
getSimProxyHandler(): SimProxy | undefined;
post(simProxyHandler: SimProxyHandler): void;
proxy<T>(target: T, type?: ConstructorType<any>): T;
moduleObjectPropProxy(target: Module): Module;
proxy<T = any>(target: T): T;
run(): void;
}
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {

@@ -20,3 +11,2 @@ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)

var SimNoSuch_1 = require("../throwable/SimNoSuch");
var Module_1 = require("../module/Module");
var SimDecorator_1 = require("../decorators/SimDecorator");

@@ -28,4 +18,3 @@ var SimGlobal_1 = require("../global/SimGlobal");

var FunctionUtils_1 = require("../utils/function/FunctionUtils");
var Inject_1 = require("../decorators/Inject");
var SimObjectProxyHandler_1 = require("../proxy/SimObjectProxyHandler");
var Inject_1 = require("../decorators/inject/Inject");
var SimOption_1 = require("../SimOption");

@@ -35,2 +24,3 @@ var SimProxyHandler_1 = require("../proxy/SimProxyHandler");

function SimstanceManager(option) {
this.option = option;
this._storage = new Map();

@@ -40,2 +30,3 @@ this._storage.set(SimstanceManager, this);

this._storage.set(SimOption_1.SimOption, option);
this.simProxyHandler = new SimProxyHandler_1.SimProxyHandler(this, option);
}

@@ -50,7 +41,6 @@ Object.defineProperty(SimstanceManager.prototype, "storage", {

SimstanceManager.prototype.getSimAtomics = function () {
var _this = this;
return Array.from(this._storage.keys()).map(function (it) { return new SimAtomic_1.SimAtomic(it, _this); });
return Array.from(this._storage.keys()).map(function (it) { return new SimAtomic_1.SimAtomic(it); });
};
SimstanceManager.prototype.getSimConfig = function (scheme) {
var newVar = this.getSimAtomics().filter(function (it) { var _a; return scheme && it && scheme === ((_a = it === null || it === void 0 ? void 0 : it.config) === null || _a === void 0 ? void 0 : _a.scheme); }) || [];
var newVar = this.getSimAtomics().filter(function (it) { var _a; return scheme && it && scheme === ((_a = it === null || it === void 0 ? void 0 : it.getConfig()) === null || _a === void 0 ? void 0 : _a.scheme); }) || [];
return newVar;

@@ -109,8 +99,5 @@ };

var r = new (target.bind.apply(target, __spreadArray([void 0], this.getParameterSim(target))))();
this.callBindPostConstruct(r);
var p = this.proxy(r, Module_1.Module);
var p = this.proxy(r);
simCreateAfter === null || simCreateAfter === void 0 ? void 0 : simCreateAfter(p);
if (p instanceof Module_1.Module) {
this.moduleObjectPropProxy(p);
}
this.callBindPostConstruct(p);
return p;

@@ -140,38 +127,19 @@ };

};
SimstanceManager.prototype.getSimProxyHandler = function () {
return undefined;
};
SimstanceManager.prototype.post = function (simProxyHandler) {
this.simProxyHandler = simProxyHandler;
};
SimstanceManager.prototype.proxy = function (target, type) {
SimstanceManager.prototype.proxy = function (target) {
var _this = this;
if ((type ? target instanceof type : true) && (!('isProxy' in target))) {
if (SimDecorator_1.getSim(target) && (typeof target === 'object') && (!('isProxy' in target))) {
for (var key in target) {
target[key] = this.proxy(target[key], type);
target[key] = this.proxy(target[key]);
}
var protoTypeName = ObjectUtils_1.ObjectUtils.getProtoTypeName(target);
protoTypeName.forEach(function (it) {
protoTypeName.filter(function (it) { return typeof target[it] === 'function'; }).forEach(function (it) {
target[it] = new Proxy(target[it], _this.simProxyHandler);
});
target = new Proxy(target, this.simProxyHandler);
}
return target;
};
SimstanceManager.prototype.moduleObjectPropProxy = function (target) {
for (var key in target) {
var prop = target[key];
if (prop instanceof Module_1.Module) {
this.moduleObjectPropProxy(prop);
if (this.simProxyHandler) {
target = new Proxy(target, this.simProxyHandler);
}
else if (prop && typeof prop === 'object' && !(prop instanceof Map)) {
if (!('isProxy' in prop)) {
target[key] = new Proxy(prop, new SimObjectProxyHandler_1.SimObjectProxyHandler());
}
var _refModule = (target[key]).simObjectProxyHandler_refModule;
if (_refModule) {
_refModule.set(key, target);
}
}
}
if (this.option.proxy) {
target = this.option.proxy.onProxy(target);
}
return target;

@@ -186,10 +154,4 @@ };

};
__decorate([
SimDecorator_1.PostConstruct,
__metadata("design:type", Function),
__metadata("design:paramtypes", [SimProxyHandler_1.SimProxyHandler]),
__metadata("design:returntype", void 0)
], SimstanceManager.prototype, "post", null);
return SimstanceManager;
}());
exports.SimstanceManager = SimstanceManager;

@@ -1,2 +0,1 @@

import { Module } from '../module/Module';
export interface ConstructorType<T> {

@@ -7,4 +6,1 @@ new (...args: any[]): T;

export declare type MethodParameter = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
export interface ModuleProperty {
[name: string]: Module;
}
export declare class ReflectUtils {
static getParameterTypes(target: any, propertyKey?: string | symbol): any[];
static getMetadata(metadataKey: any, target: any, propertyKey?: string | symbol): any;
static getMetadataKeys(target: any): any[];
static getMetadatas(target: any): any[];
static metadata(metadataKey: any, data: any): {

@@ -5,0 +7,0 @@ (target: Function): void;

@@ -23,2 +23,8 @@ "use strict";

};
ReflectUtils.getMetadataKeys = function (target) {
return Reflect.getMetadataKeys(target);
};
ReflectUtils.getMetadatas = function (target) {
return this.getMetadataKeys(target).map(function (it) { return ReflectUtils.getMetadata(it, target); });
};
ReflectUtils.metadata = function (metadataKey, data) {

@@ -25,0 +31,0 @@ return Reflect.metadata(metadataKey, data);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc