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.22 to 1.0.23

model/Url.d.ts

10

option/SimOption.d.ts
import { ConstructorType } from '../types/Types';
import { Router } from '../router/Router';
import { RootRouter } from '../router/RootRouter';
export declare enum UrlType {

@@ -8,11 +8,11 @@ path = "path",

export declare class SimOption {
rootRouter: ConstructorType<Router>;
rootRouter: ConstructorType<RootRouter>;
selector: string;
urlType: UrlType;
advice: ConstructorType<Router>[];
constructor(rootRouter: ConstructorType<Router>);
advice: ConstructorType<RootRouter>[];
constructor(rootRouter: ConstructorType<RootRouter>);
setSelector(selector: string): SimOption;
setUrlType(urlType: UrlType): SimOption;
setRootRouter(rootRouter: ConstructorType<Router>): SimOption;
setRootRouter(rootRouter: ConstructorType<RootRouter>): SimOption;
setAdvice(...advice: ConstructorType<any>[]): SimOption;
}
{
"name": "simple-boot-front",
"version": "1.0.22",
"version": "1.0.23",
"main": "SimpleApplication.js",

@@ -5,0 +5,0 @@ "license": "MIT",

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

import { getProtoAfters, getProtoBefores } from '../decorators/aop/AOPDecorator';
import { ObjectUtils } from "../util/object/ObjectUtils";
import { ObjectUtils } from '../util/object/ObjectUtils';
var SimProxyHandler = (function () {

@@ -20,0 +20,0 @@ function SimProxyHandler(simOption, renderer) {

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

simple-boot-front [v1.0.22]
simple-boot-front [v1.0.23]
===========

@@ -51,3 +51,3 @@

@Sim({scheme: 'layout-router'})
export class AppRouter extends Router {
export class AppRouter extends RootRouter {
module = App;

@@ -61,3 +61,18 @@ '' = Index;

'views' = Views;
async canActivate(url: Url, module: Module): Promise<Module | ConstructorType<Module>> {
if (url.path === 'views' && url.params.get('auth') === 'false') {
return Forbidden;
} else {
return module;
}
}
notFound(url: Url): ConstructorType<Module> {
console.log(url.path)
return Notfound;
}
}
```

@@ -84,3 +99,3 @@ * index.ts

```
* index.html (handlebars)
* index.html
```html

@@ -135,2 +150,15 @@ <h1>index</h1>

## View template engine
```html
<div>{%write(this.data)%}</div>
<div>
{%
for (let i of this.datas) {
write('<li>' + i + '</li>');
}
%}
</div>
```
- write: write string
## Module LifeCycle

@@ -137,0 +165,0 @@ * onInit(): module load event

import { Module } from '../module/Module';
import { ConstructorType } from '../types/Types';
import { SimBase } from '../base/SimBase';
import { Renderer } from '../render/Renderer';
import { Navigation } from '../service/Navigation';
import { RouterModule } from './RouterModule';
import { Url } from '../model/Url';
export interface Routers {
[name: string]: ConstructorType<any> | any;
[name: string]: ConstructorType<Module> | any;
}

@@ -13,9 +14,10 @@ export declare class Router extends SimBase implements Routers {

childs: ConstructorType<Router>[];
private _renderer;
private _simstanceManager;
private _navigation;
constructor(path: string, module?: ConstructorType<Module> | undefined, childs?: ConstructorType<Router>[], _renderer?: Renderer, _navigation?: Navigation);
getExecuteModule(parentRouters: Router[]): Module | undefined;
constructor(path: string, module?: ConstructorType<Module> | undefined, childs?: ConstructorType<Router>[], _simstanceManager?: import("../simstance/SimstanceManager").SimstanceManager, _navigation?: Navigation);
getExecuteModule(parentRouters: Router[]): RouterModule | undefined;
get moduleObject(): Module | undefined;
isRootUrl(parentRoots: string[], hashUrl: string): boolean;
routing(parentRoots: string[], path: string): Module | undefined;
canActivate(url: Url, module: Module): Promise<Module | ConstructorType<Module>>;
}

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

})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { SimBase } from '../base/SimBase';
import { SimGlobal } from '../global/SimGlobal';
import { Renderer } from '../render/Renderer';
import { Navigation } from '../service/Navigation';
import { RouterModule } from './RouterModule';
var Router = (function (_super) {
__extends(Router, _super);
function Router(path, module, childs, _renderer, _navigation) {
function Router(path, module, childs, _simstanceManager, _navigation) {
if (childs === void 0) { childs = []; }
if (_renderer === void 0) { _renderer = (_a = SimGlobal.application) === null || _a === void 0 ? void 0 : _a.simstanceManager.getOrNewSim(Renderer); }
if (_navigation === void 0) { _navigation = (_b = SimGlobal.application) === null || _b === void 0 ? void 0 : _b.simstanceManager.getOrNewSim(Navigation); }
var _a, _b;
if (_simstanceManager === void 0) { _simstanceManager = (_a = SimGlobal.application) === null || _a === void 0 ? void 0 : _a.simstanceManager; }
if (_navigation === void 0) { _navigation = _simstanceManager.getOrNewSim(Navigation); }
var _a;
var _this = _super.call(this) || this;

@@ -32,3 +68,3 @@ _this.path = path;

_this.childs = childs;
_this._renderer = _renderer;
_this._simstanceManager = _simstanceManager;
_this._navigation = _navigation;

@@ -38,4 +74,3 @@ return _this;

Router.prototype.getExecuteModule = function (parentRouters) {
var _a;
var path = this._navigation.url;
var path = this._navigation.path;
var routerStrings = parentRouters.map(function (it) { return it.path || ''; });

@@ -45,10 +80,10 @@ var isRoot = this.isRootUrl(routerStrings, path);

parentRouters.push(this);
var fieldModule = this.routing(routerStrings, path);
if (fieldModule) {
return fieldModule;
var module_1 = this.routing(routerStrings, path);
if (module_1) {
return new RouterModule(this, module_1);
}
else {
for (var _i = 0, _b = this.childs; _i < _b.length; _i++) {
var child = _b[_i];
var route = (_a = SimGlobal.application) === null || _a === void 0 ? void 0 : _a.simstanceManager.getOrNewSim(child);
for (var _i = 0, _a = this.childs; _i < _a.length; _i++) {
var child = _a[_i];
var route = this._simstanceManager.getOrNewSim(child);
var executeModule = route === null || route === void 0 ? void 0 : route.getExecuteModule(parentRouters);

@@ -86,2 +121,9 @@ if (route && executeModule) {

};
Router.prototype.canActivate = function (url, module) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, module];
});
});
};
return Router;

@@ -88,0 +130,0 @@ }(SimBase));

@@ -5,2 +5,3 @@ import 'reflect-metadata';

import { Navigation } from '../service/Navigation';
import { RouterModule } from './RouterModule';
var RouterManager = (function () {

@@ -20,19 +21,29 @@ function RouterManager() {

var _this = this;
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f, _g, _h;
var routers = [];
var executeModule = (_c = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim((_b = this.option) === null || _b === void 0 ? void 0 : _b.rootRouter)) === null || _c === void 0 ? void 0 : _c.getExecuteModule(routers);
if (executeModule) {
var lastRouterSelector_1 = (_d = this.option) === null || _d === void 0 ? void 0 : _d.selector;
routers.forEach(function (it) {
var navigation = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(Navigation);
var rootRouter = (_b = this.simstanceManager) === null || _b === void 0 ? void 0 : _b.getOrNewSim((_c = this.option) === null || _c === void 0 ? void 0 : _c.rootRouter);
var executeModule = ((_f = (_d = this.simstanceManager) === null || _d === void 0 ? void 0 : _d.getOrNewSim((_e = this.option) === null || _e === void 0 ? void 0 : _e.rootRouter)) === null || _f === void 0 ? void 0 : _f.getExecuteModule(routers)) || new RouterModule(rootRouter, (_g = this.simstanceManager) === null || _g === void 0 ? void 0 : _g.getOrNewSim(rootRouter === null || rootRouter === void 0 ? void 0 : rootRouter.notFound(navigation === null || navigation === void 0 ? void 0 : navigation.pathInfo)));
if (executeModule && executeModule.module) {
(_h = executeModule.router) === null || _h === void 0 ? void 0 : _h.canActivate(navigation === null || navigation === void 0 ? void 0 : navigation.pathInfo, executeModule.module).then(function (targetModule) {
var _a, _b;
_this.renderRouterModule(it.moduleObject, lastRouterSelector_1);
var selctor = ((_a = it === null || it === void 0 ? void 0 : it.moduleObject) === null || _a === void 0 ? void 0 : _a.router_outlet_selector) || ((_b = it === null || it === void 0 ? void 0 : it.moduleObject) === null || _b === void 0 ? void 0 : _b.selector);
if (selctor) {
lastRouterSelector_1 = selctor;
if (targetModule) {
var lastRouterSelector_1 = (_a = _this.option) === null || _a === void 0 ? void 0 : _a.selector;
routers.forEach(function (it) {
var _a, _b;
_this.renderRouterModule(it.moduleObject, lastRouterSelector_1);
var selctor = ((_a = it === null || it === void 0 ? void 0 : it.moduleObject) === null || _a === void 0 ? void 0 : _a.router_outlet_selector) || ((_b = it === null || it === void 0 ? void 0 : it.moduleObject) === null || _b === void 0 ? void 0 : _b.selector);
if (selctor) {
lastRouterSelector_1 = selctor;
}
});
if (typeof targetModule === 'function') {
targetModule = (_b = _this.simstanceManager) === null || _b === void 0 ? void 0 : _b.getOrNewSim(targetModule);
}
_this.render(targetModule, lastRouterSelector_1);
_this.renderd();
targetModule._onInitedChild();
routers.reverse().forEach(function (it) { var _a; return (_a = it.moduleObject) === null || _a === void 0 ? void 0 : _a._onInitedChild(); });
}
});
this.render(executeModule, lastRouterSelector_1);
this.renderd();
executeModule._onInitedChild();
routers.reverse().forEach(function (it) { var _a; return (_a = it.moduleObject) === null || _a === void 0 ? void 0 : _a._onInitedChild(); });
}

@@ -53,3 +64,3 @@ else {

var hrefAttr = ((_c = it.getAttribute('router-link')) !== null && _c !== void 0 ? _c : '');
if (hrefAttr === (navigation === null || navigation === void 0 ? void 0 : navigation.url)) {
if (hrefAttr === (navigation === null || navigation === void 0 ? void 0 : navigation.path)) {
(_a = it.classList).add.apply(_a, actives);

@@ -56,0 +67,0 @@ }

import { SimOption } from '../option/SimOption';
import { Url } from "../model/Url";
export declare class Navigation {
private option;
constructor(option: SimOption);
get url(): string;
get path(): string;
get queryParams(): Map<string, string>;
get pathInfo(): Url;
go(path: string, data?: {}, title?: string): void;
}

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

}
Object.defineProperty(Navigation.prototype, "url", {
Object.defineProperty(Navigation.prototype, "path", {
get: function () {

@@ -24,3 +24,3 @@ if (UrlType.path === this.option.urlType) {

else if (UrlType.hash === this.option.urlType) {
return LocationUtils.hash();
return LocationUtils.hashPath();
}

@@ -34,2 +34,24 @@ else {

});
Object.defineProperty(Navigation.prototype, "queryParams", {
get: function () {
if (UrlType.path === this.option.urlType) {
return LocationUtils.pathQueryParams();
}
else if (UrlType.hash === this.option.urlType) {
return LocationUtils.hashQueryParams();
}
else {
return new Map();
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(Navigation.prototype, "pathInfo", {
get: function () {
return { path: this.path, params: this.queryParams };
},
enumerable: false,
configurable: true
});
Navigation.prototype.go = function (path, data, title) {

@@ -36,0 +58,0 @@ if (data === void 0) { data = {}; }

export declare class LocationUtils {
static hash(): string;
static hashPath(): string;
static hashQueryParams(): Map<string, string>;
static path(): string;
static pathQueryParams(): Map<string, string>;
private static queryStringToMap;
}

@@ -7,5 +7,24 @@ var LocationUtils = (function () {

};
LocationUtils.hashPath = function () {
return window.location.hash.replace('#', '').split('?')[0];
};
LocationUtils.hashQueryParams = function () {
var s = window.location.hash.replace('#', '').split('?')[1] || '';
return this.queryStringToMap(s);
};
LocationUtils.path = function () {
return window.location.pathname.substring(1);
};
LocationUtils.pathQueryParams = function () {
return this.queryStringToMap(window.location.search.substring(1));
};
LocationUtils.queryStringToMap = function (s) {
var params = new Map();
var vars = s.split('&') || [];
vars.forEach(function (it) {
var kv = it.split('=') || [];
params.set(kv[0], kv[1]);
});
return params;
};
return LocationUtils;

@@ -12,0 +31,0 @@ }());

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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