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.53 to 1.0.54

module/FrontLifeCycle.d.ts

2

fetch/Fetcher.d.ts
export declare abstract class Fetcher {
abstract text(path: string, param?: any): Promise<string | void>;
abstract text(path: string, param?: any, dname?: string): Promise<string | void>;
abstract json<T = any>(url: string, param?: any): Promise<T | void>;
}

@@ -6,2 +6,3 @@ import { FrontModuleOption } from './FrontModuleOption';

import { Fetcher } from '../fetch/Fetcher';
import { FrontLifeCycle } from './FrontLifeCycle';
export declare type RefModuleItem = {

@@ -12,3 +13,3 @@ dest?: any;

};
export declare class FrontModule extends Module {
export declare class FrontModule extends Module implements FrontLifeCycle {
_inputOption: {

@@ -42,3 +43,4 @@ template?: string;

});
init(param?: any): Promise<FrontModuleOption>;
private _init;
init(param?: any): Promise<this>;
getValue<T = any>(name: string, value?: any): T;

@@ -60,3 +62,3 @@ setValue(name: string, value?: any): void;

refModuleClean(): void;
setScope(targetNode: TargetNode, uuid?: string): RootScope | undefined;
setScope(document: Document, targetNode: TargetNode, uuid?: string): RootScope | undefined;
renderToScope(varName: string): void;

@@ -63,0 +65,0 @@ renderWrap(): void;

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

if (_inputOption === void 0) { _inputOption = {}; }
var _a, _b;
var _a, _b, _c, _d;
var _this = _super.call(this) || this;

@@ -87,6 +87,22 @@ _this._inputOption = _inputOption;

}
_this._option = option;
if (!_inputOption.fetcher) {
option.template = (_c = _inputOption.template) !== null && _c !== void 0 ? _c : option.template;
option.styleImports = (_d = _inputOption.styleImports) !== null && _d !== void 0 ? _d : option.styleImports;
_this._option = option;
delete _inputOption.template;
delete _inputOption.styleImports;
_this._init();
}
else {
_this._option = option;
}
_this.id = "___Module__" + _this.constructor.name + "_" + RandomUtils_1.RandomUtils.uuid();
return _this;
}
FrontModule.prototype._init = function () {
if (this._option.template.search('\\[router-outlet\\]')) {
this._router_outlet_id = "___Module__" + this.constructor.name + "_router-outlet_" + this.id + "_" + RandomUtils_1.RandomUtils.uuid();
this._option.template = this._option.template.replace('[router-outlet]', " id='" + this._router_outlet_id + "' ");
}
};
FrontModule.prototype.init = function (param) {

@@ -102,3 +118,3 @@ var _a, _b, _c;

_d = this._option;
return [4, this._inputOption.fetcher.text(this._inputOption.template.replace('fetch://', ''), param)];
return [4, this._inputOption.fetcher.text(this._inputOption.template.replace('fetch://', ''), param, this._inputOption.name)];
case 1:

@@ -111,6 +127,3 @@ _d.template = (_a = (_g.sent())) !== null && _a !== void 0 ? _a : '';

case 3:
if (this._option.template.search('\\[router-outlet\\]')) {
this._router_outlet_id = "___Module__" + this.constructor.name + "_router-outlet_" + this.id + "_" + RandomUtils_1.RandomUtils.uuid();
this._option.template = this._option.template.replace('[router-outlet]', " id='" + this._router_outlet_id + "' ");
}
this._init();
delete this._inputOption.template;

@@ -128,3 +141,3 @@ _g.label = 4;

_f = i;
return [4, this._inputOption.fetcher.text(sp.replace('fetch://', ''), param)];
return [4, this._inputOption.fetcher.text(sp.replace('fetch://', ''), param, this._inputOption.name)];
case 6:

@@ -142,3 +155,3 @@ _e[_f] = (_c = (_g.sent())) !== null && _c !== void 0 ? _c : '';

return [3, 5];
case 10: return [2, this._option];
case 10: return [2, this];
}

@@ -354,7 +367,7 @@ });

};
FrontModule.prototype.setScope = function (targetNode, uuid) {
FrontModule.prototype.setScope = function (document, targetNode, uuid) {
var _a;
if (uuid === void 0) { uuid = RandomUtils_1.RandomUtils.uuid(); }
var rawSet = new ScopeRawSet_1.ScopeRawSet(this.templateString, this._option.styleImports);
var scope = (_a = this._renderer) === null || _a === void 0 ? void 0 : _a.compileScope(rawSet, this, targetNode, uuid);
var scope = (_a = this._renderer) === null || _a === void 0 ? void 0 : _a.compileScope(document, rawSet, this, targetNode, uuid);
if (scope) {

@@ -361,0 +374,0 @@ this._scopes.set(scope.uuid, scope);

{
"name": "simple-boot-front",
"version": "1.0.53",
"version": "1.0.54",
"main": "SimpleApplication.js",

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

"examples/dev",
"examples/dev-onepage",
"templates/parcel-bundler"

@@ -59,2 +60,3 @@ ],

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

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

"dependencies": {
"dom-render": "^1.0.8",
"dom-render": "^1.0.10",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.6.7",
"simple-boot-core": "^1.0.13"
"simple-boot-core": "^1.0.16"
}
}

@@ -181,2 +181,3 @@ ![Single Page Application Framworks](assets/banner.png)

## Module LifeCycle
* onCreate(): Sim onCreate just one call
* onInit(): module load event

@@ -183,0 +184,0 @@ * onChangedRender(): change rended in module event

@@ -6,10 +6,15 @@ import { FrontModule } from '../module/FrontModule';

import { ScopeRawSet } from 'dom-render/ScopeRawSet';
export declare class Renderer {
import { FrontLifeCycle } from '../module/FrontLifeCycle';
export declare class Renderer implements FrontLifeCycle {
private option;
constructor(option: SimFrontOption);
compileScope(rawSet: ScopeRawSet, obj: any, targetNode: TargetNode, rootUUID?: string): RootScope | undefined;
render(module: FrontModule | string): void;
onInit(): void;
onChangedRender(): void;
onInitedChild(): void;
onFinish(): void;
onCreate(): void;
compileScope(document: Document, rawSet: ScopeRawSet, obj: any, targetNode: TargetNode, rootUUID?: string): RootScope | undefined;
render(module: FrontModule | string, document: Document): void;
renderToScope(scope: Scope, module: FrontModule, varName: string): void;
renderToByScopes(scope: RootScope, module: FrontModule): void;
prependStyle(selector: string, style: string | undefined): void;
}

@@ -26,3 +26,13 @@ "use strict";

}
Renderer.prototype.compileScope = function (rawSet, obj, targetNode, rootUUID) {
Renderer.prototype.onInit = function () {
};
Renderer.prototype.onChangedRender = function () {
};
Renderer.prototype.onInitedChild = function () {
};
Renderer.prototype.onFinish = function () {
};
Renderer.prototype.onCreate = function () {
};
Renderer.prototype.compileScope = function (document, rawSet, obj, targetNode, rootUUID) {
if (rootUUID === void 0) { rootUUID = RandomUtils_1.RandomUtils.uuid(); }

@@ -34,3 +44,3 @@ var config = new Config_1.Config(document, function (scope) { return new ScopeFrontObject_1.ScopeFrontObject(scope.config); });

};
Renderer.prototype.render = function (module) {
Renderer.prototype.render = function (module, document) {
var targetElement = document.querySelector(this.option.selector);

@@ -59,3 +69,4 @@ if (targetElement && module instanceof FrontModule_1.FrontModule) {

it.scopeResult.calls.filter(function (it) { return it.name === 'module'; }).map(function (it) { return it.result; }).forEach(function (it) {
it.renderWrap();
var _a;
(_a = it) === null || _a === void 0 ? void 0 : _a.renderWrap();
});

@@ -84,3 +95,4 @@ }

(_a = it.scopeResult) === null || _a === void 0 ? void 0 : _a.calls.filter(function (it) { return it.name === 'module'; }).map(function (it) { return it.result; }).forEach(function (it) {
it.renderWrap();
var _a;
(_a = it) === null || _a === void 0 ? void 0 : _a.renderWrap();
});

@@ -90,10 +102,2 @@ });

};
Renderer.prototype.prependStyle = function (selector, style) {
var targetElement = document.querySelector(selector);
if (targetElement && style) {
var htmlStyleElement = document.createElement('style');
htmlStyleElement.innerHTML = style;
targetElement.prepend(htmlStyleElement);
}
};
Renderer = __decorate([

@@ -100,0 +104,0 @@ SimDecorator_1.Sim(),

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

var targetNode = new RootScope_1.TargetNode(targetSelecotr, RootScope_1.TargetNodeMode.replace);
var scope = module.setScope(targetNode, uuid);
var scope = module.setScope(this.config.document, targetNode, uuid);
if (scope) {

@@ -54,0 +54,0 @@ this.appendWrite((_a = module.getTemplateElementString(scope.uuid)) !== null && _a !== void 0 ? _a : '');

@@ -5,11 +5,9 @@ import { SimFrontOption } from './option/SimFrontOption';

import { FrontRouter } from './router/FrontRouter';
import { FrontModule } from './module/FrontModule';
import { RouteRender } from './router/RouteRender';
export declare class SimpleBootFront extends SimpleApplication {
rootRouter: ConstructorType<FrontRouter>;
option: SimFrontOption;
routeRender: RouteRender;
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;
}

@@ -59,6 +59,4 @@ "use strict";

var Intent_1 = require("simple-boot-core/intent/Intent");
var FrontModule_1 = require("./module/FrontModule");
var FunctionUtils_1 = require("simple-boot-core/utils/function/FunctionUtils");
var rxjs_1 = require("rxjs");
var RootScope_1 = require("dom-render/RootScope");
var RouteRender_1 = require("./router/RouteRender");
var SimpleBootFront = (function (_super) {

@@ -72,2 +70,3 @@ __extends(SimpleBootFront, _super);

option.simProxy = new SimFrontProxyHandler_1.SimFrontProxyHandler(option);
_this.routeRender = new RouteRender_1.RouteRender(_this.option, _this.simstanceManager);
return _this;

@@ -83,43 +82,5 @@ }

_this.routing(intent).then(function (it) { return __awaiter(_this, void 0, void 0, function () {
var lastRouterSelector, _i, _a, routerChain, moduleObj, option_1, module, option;
var _this = this;
var _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
lastRouterSelector = (_b = this.option) === null || _b === void 0 ? void 0 : _b.selector;
_i = 0, _a = it.routerChains;
_d.label = 1;
case 1:
if (!(_i < _a.length)) return [3, 4];
routerChain = _a[_i];
moduleObj = (_c = this.simstanceManager) === null || _c === void 0 ? void 0 : _c.getOrNewSim(routerChain.module);
if (!(moduleObj instanceof FrontModule_1.FrontModule)) return [3, 3];
return [4, moduleObj.init({ router: 'true' })];
case 2:
option_1 = _d.sent();
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);
}
_d.label = 3;
case 3:
_i++;
return [3, 1];
case 4:
module = it.getModuleInstance();
return [4, module.init()];
case 5:
option = _d.sent();
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(); });
return [2];
}
return __generator(this, function (_a) {
this.routeRender.routeRender(it, document);
return [2];
});

@@ -130,39 +91,4 @@ }); });

};
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_1.Navigation);
this.procAttr(attr, function (it, value) {
var _a, _b;
var _c;
var actives = FunctionUtils_1.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 RootScope_1.TargetNode(targetSelector, RootScope_1.TargetNodeMode.child));
module.renderWrap();
return true;
}
else {
return false;
}
};
return SimpleBootFront;
}(SimpleApplication_1.SimpleApplication));
exports.SimpleBootFront = 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