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

simple-boot-front

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-boot-front - npm Package Compare versions

Comparing version 1.0.44 to 1.0.46

router/FrontRouter.d.ts

5

option/SimFrontOption.d.ts

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

import { Router } from '../router/Router';
import { SimOption } from 'simple-boot-core/SimOption';

@@ -9,9 +8,7 @@ import { ConstructorType } from 'simple-boot-core/types/Types';

export declare class SimFrontOption extends SimOption {
rootRouter: ConstructorType<Router>;
selector: string;
urlType: UrlType;
constructor(rootRouter: ConstructorType<Router>, advice: ConstructorType<any>[]);
constructor(advice: ConstructorType<any>[]);
setSelector(selector: string): SimFrontOption;
setUrlType(urlType: UrlType): SimFrontOption;
setRootRouter(rootRouter: ConstructorType<Router>): SimFrontOption;
}

7

option/SimFrontOption.js

@@ -24,5 +24,4 @@ var __extends = (this && this.__extends) || (function () {

__extends(SimFrontOption, _super);
function SimFrontOption(rootRouter, advice) {
function SimFrontOption(advice) {
var _this = _super.call(this, advice) || this;
_this.rootRouter = rootRouter;
_this.selector = '#app';

@@ -40,8 +39,4 @@ _this.urlType = UrlType.path;

};
SimFrontOption.prototype.setRootRouter = function (rootRouter) {
this.rootRouter = rootRouter;
return this;
};
return SimFrontOption;
}(SimOption));
export { SimFrontOption };
{
"name": "simple-boot-front",
"version": "1.0.44",
"version": "1.0.46",
"main": "SimpleApplication.js",

@@ -34,2 +34,3 @@ "license": "MIT",

"workspaces": [
"./",
"examples/dev",

@@ -57,2 +58,3 @@ "templates/parcel-bundler"

"build": "rm -rf dist && tsc --outDir dist --declarationDir dist",
"dev:serve": "npm run serve --workspace=dev",
"npm-build": "rm -rf dist && tsc --outDir dist --declarationDir dist && cp package.json dist && cp README.MD dist",

@@ -80,4 +82,4 @@ "npm-publish": "npm run npm-build && npm publish ./dist",

"rxjs": "^6.6.7",
"simple-boot-core": "^1.0.4"
"simple-boot-core": "^1.0.10"
}
}

@@ -7,8 +7,3 @@ import { SimFrontOption } from '../option/SimFrontOption';

constructor(simOption: SimFrontOption);
get(target: any, name: string): any;
set(obj: any, prop: string, value: any): boolean;
defineProperty?(target: any, p: PropertyKey, attributes: PropertyDescriptor): boolean;
apply(target: Function, thisArg: any, argumentsList?: any): any;
private aopBefore;
private aopAfter;
}

@@ -17,5 +17,2 @@ var __extends = (this && this.__extends) || (function () {

import { SimGlobal } from 'simple-boot-core/global/SimGlobal';
import { getTargetAndIncludeNullAndSortExceptionHandlers } from 'simple-boot-core/decorators/exception/ExceptionDecorator';
import { getProtoAfters, getProtoBefores } from 'simple-boot-core/decorators/aop/AOPDecorator';
import { ObjectUtils } from 'simple-boot-core/utils/object/ObjectUtils';
import { SimProxy } from 'simple-boot-core/proxy/SimProxy';

@@ -32,5 +29,2 @@ import { FrontModule } from '../module/FrontModule';

}
SimFrontProxyHandler.prototype.get = function (target, name) {
return target[name];
};
SimFrontProxyHandler.prototype.set = function (obj, prop, value) {

@@ -57,66 +51,4 @@ var _a, _b;

};
SimFrontProxyHandler.prototype.defineProperty = function (target, p, attributes) {
return true;
};
SimFrontProxyHandler.prototype.apply = function (target, thisArg, argumentsList) {
var _a;
var r;
try {
this.aopBefore(thisArg, target);
r = target.apply(thisArg, argumentsList);
this.aopAfter(thisArg, target);
}
catch (e) {
var inHandler = getTargetAndIncludeNullAndSortExceptionHandlers(thisArg, e);
if (inHandler.length > 0) {
inHandler[inHandler.length - 1].call(e, thisArg, target, argumentsList);
}
else {
for (var i = 0; i < this.simOption.advice.length; i++) {
var sim = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(this.simOption.advice[i]);
var inHandler_1 = getTargetAndIncludeNullAndSortExceptionHandlers(sim, e);
if (inHandler_1.length > 0) {
inHandler_1[inHandler_1.length - 1].call(e, thisArg, target, argumentsList);
break;
}
}
}
console.error(e);
}
return r;
};
SimFrontProxyHandler.prototype.aopBefore = function (obj, protoType) {
var _a;
var propertyName = ObjectUtils.getPrototypeName(obj, protoType);
if (propertyName) {
getProtoBefores(obj, propertyName).forEach(function (it) {
it.call(obj, protoType, propertyName);
});
for (var i = 0; i < this.simOption.advice.length; i++) {
var sim = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(this.simOption.advice[i]);
var protoBefores = getProtoBefores(sim, propertyName, Object.getPrototypeOf(obj));
protoBefores.forEach(function (it) {
it.call(obj, protoType, propertyName);
});
}
}
};
SimFrontProxyHandler.prototype.aopAfter = function (obj, protoType) {
var _a;
var propertyName = ObjectUtils.getPrototypeName(obj, protoType);
if (propertyName) {
getProtoAfters(obj, propertyName).forEach(function (it) {
it.call(obj, protoType, propertyName);
});
for (var i = 0; i < this.simOption.advice.length; i++) {
var sim = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(this.simOption.advice[i]);
var protoBefores = getProtoAfters(sim, propertyName, Object.getPrototypeOf(obj));
protoBefores.forEach(function (it) {
it.call(obj, protoType, propertyName);
});
}
}
};
return SimFrontProxyHandler;
}(SimProxy));
export { SimFrontProxyHandler };
import { SimFrontOption } from '../option/SimFrontOption';
import { Url } from '../model/Url';
export declare class Navigation {

@@ -8,4 +7,7 @@ private option;

get queryParams(): Map<string, string>;
get pathInfo(): Url;
get pathInfo(): {
path: string;
queryParams: Map<string, string>;
};
go(path: string, data?: {}, title?: string): void;
}

@@ -49,3 +49,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

get: function () {
return { path: this.path, params: this.queryParams };
return { path: this.path, queryParams: this.queryParams };
},

@@ -52,0 +52,0 @@ enumerable: false,

import { SimFrontOption } from './option/SimFrontOption';
import { RouterManager } from './router/RouterManager';
import { SimpleApplication } from 'simple-boot-core/SimpleApplication';
import { ConstructorType } from 'simple-boot-core/types/Types';
import { FrontRouter } from './router/FrontRouter';
import { FrontModule } from './module/FrontModule';
export declare class SimpleBootFront extends SimpleApplication {
rootRouter: ConstructorType<FrontRouter>;
option: SimFrontOption;
routerManager: RouterManager;
constructor(option: SimFrontOption);
constructor(rootRouter: ConstructorType<FrontRouter>, option: SimFrontOption);
run(): void;
renderd(): void;
procAttr(attrName: string, f: (h: HTMLElement, value: string | null) => void): void;
render(module: FrontModule | undefined, targetSelector: Node | null): boolean;
}

@@ -16,20 +16,90 @@ var __extends = (this && this.__extends) || (function () {

})();
import { RouterManager } from './router/RouterManager';
import { SimpleApplication } from 'simple-boot-core/SimpleApplication';
import { SimFrontProxyHandler } from './proxy/SimFrontProxyHandler';
import { Navigation } from './service/Navigation';
import { Intent } from 'simple-boot-core/intent/Intent';
import { FrontModule } from './module/FrontModule';
import { FunctionUtils } from 'simple-boot-core/utils/function/FunctionUtils';
import { TargetNode, TargetNodeMode } from './render/compile/RootScope';
import { fromEvent } from 'rxjs';
var SimpleBootFront = (function (_super) {
__extends(SimpleBootFront, _super);
function SimpleBootFront(option) {
var _this = _super.call(this, option) || this;
function SimpleBootFront(rootRouter, option) {
var _this = _super.call(this, rootRouter, option) || this;
_this.rootRouter = rootRouter;
_this.option = option;
option.simProxy = new SimFrontProxyHandler(option);
_this.routerManager = new RouterManager(_this.option, _this.simstanceManager);
return _this;
}
SimpleBootFront.prototype.run = function () {
var _this = this;
_super.prototype.run.call(this);
this.routerManager.run();
var navigation = this.simstanceManager.getOrNewSim(Navigation);
fromEvent(window, 'popstate').subscribe(function (_) {
var _a;
var intent = new Intent((_a = navigation.path) !== null && _a !== void 0 ? _a : '');
_this.routing(intent).then(function (it) {
var _a;
var lastRouterSelector = (_a = _this.option) === null || _a === void 0 ? void 0 : _a.selector;
it.routerChains.forEach(function (it) {
var _a;
var moduleObj = (_a = _this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(it.module);
if (moduleObj instanceof FrontModule) {
if (!document.querySelector("[module-id='" + (moduleObj === null || moduleObj === void 0 ? void 0 : moduleObj.id) + "']")) {
_this.render(moduleObj, document.querySelector(lastRouterSelector));
}
if (moduleObj === null || moduleObj === void 0 ? void 0 : moduleObj._router_outlet_id) {
lastRouterSelector = '#' + (moduleObj === null || moduleObj === void 0 ? void 0 : moduleObj._router_outlet_id);
}
else {
lastRouterSelector = '#' + (moduleObj === null || moduleObj === void 0 ? void 0 : moduleObj.id);
}
}
});
var module = it.getModuleInstance();
_this.render(module, document.querySelector(lastRouterSelector));
_this.renderd();
module._onInitedChild();
it.routerChains.reverse().forEach(function (it) { var _a, _b; return (_b = (_a = _this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(it.module)) === null || _b === void 0 ? void 0 : _b._onInitedChild(); });
});
});
window.dispatchEvent(new Event('popstate'));
};
SimpleBootFront.prototype.renderd = function () {
var _a;
var attr = 'router-active-class';
var navigation = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(Navigation);
this.procAttr(attr, function (it, value) {
var _a, _b;
var _c;
var actives = FunctionUtils.eval(value !== null && value !== void 0 ? value : '[]');
if (!actives)
return;
var hrefAttr = ((_c = it.getAttribute('router-link')) !== null && _c !== void 0 ? _c : '');
if (hrefAttr === (navigation === null || navigation === void 0 ? void 0 : navigation.path)) {
(_a = it.classList).add.apply(_a, actives);
}
else {
(_b = it.classList).remove.apply(_b, actives);
}
});
};
SimpleBootFront.prototype.procAttr = function (attrName, f) {
document.querySelectorAll("[" + attrName + "]").forEach(function (it) {
f(it, it.getAttribute(attrName));
});
};
SimpleBootFront.prototype.render = function (module, targetSelector) {
if (module && targetSelector) {
module._onInit();
module.setScope(new TargetNode(targetSelector, TargetNodeMode.child));
module.renderWrap();
return true;
}
else {
return false;
}
};
return SimpleBootFront;
}(SimpleApplication));
export { SimpleBootFront };
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