simple-boot-front
Advanced tools
Comparing version 1.0.49 to 1.0.50
@@ -11,2 +11,11 @@ import { FrontModuleOption } from './FrontModuleOption'; | ||
export declare class FrontModule extends Module { | ||
_inputOption: { | ||
template?: string | Promise<string | void>; | ||
styleImports?: (string | Promise<string | void>)[]; | ||
modules?: { | ||
[name: string]: ConstructorType<FrontModule>; | ||
}; | ||
value?: any; | ||
name?: string; | ||
}; | ||
_router_outlet_id?: string; | ||
@@ -20,5 +29,5 @@ id: string; | ||
private _navigation; | ||
constructor(option?: { | ||
template?: string; | ||
styleImports?: string[]; | ||
constructor(_inputOption?: { | ||
template?: string | Promise<string | void>; | ||
styleImports?: (string | Promise<string | void>)[]; | ||
modules?: { | ||
@@ -30,3 +39,3 @@ [name: string]: ConstructorType<FrontModule>; | ||
}); | ||
private init; | ||
init(): Promise<FrontModuleOption>; | ||
getValue<T = any>(name: string, value?: any): T; | ||
@@ -33,0 +42,0 @@ setValue(name: string, value?: any): void; |
@@ -16,2 +16,38 @@ 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 { Renderer } from '../render/Renderer'; | ||
@@ -34,6 +70,7 @@ import { fromEvent } from 'rxjs'; | ||
__extends(FrontModule, _super); | ||
function FrontModule(option) { | ||
if (option === void 0) { option = {}; } | ||
function FrontModule(_inputOption) { | ||
if (_inputOption === void 0) { _inputOption = {}; } | ||
var _a, _b; | ||
var _this = _super.call(this) || this; | ||
_this._inputOption = _inputOption; | ||
_this._refModule = new Map(); | ||
@@ -43,13 +80,62 @@ _this._scopes = new Map(); | ||
_this._navigation = (_b = SimGlobal().application) === null || _b === void 0 ? void 0 : _b.simstanceManager.getOrNewSim(Navigation); | ||
_this.value = option.value; | ||
_this._option = Object.assign(new FrontModuleOption(), option); | ||
_this.value = _inputOption.value; | ||
var option = new FrontModuleOption(); | ||
if (_inputOption.modules) { | ||
option.modules = _inputOption.modules; | ||
} | ||
_this._option = option; | ||
_this.id = "___Module__" + _this.constructor.name + "_" + RandomUtils.uuid(); | ||
_this.init(); | ||
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.uuid(); | ||
this._option.template = this._option.template.replace('[router-outlet]', " id='" + this._router_outlet_id + "' "); | ||
} | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _d, i, sp, _e, _f; | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
if (!this._inputOption.template) return [3, 4]; | ||
if (!(this._inputOption.template instanceof Promise)) return [3, 2]; | ||
_d = this._option; | ||
return [4, this._inputOption.template]; | ||
case 1: | ||
_d.template = (_a = (_g.sent())) !== null && _a !== void 0 ? _a : ''; | ||
return [3, 3]; | ||
case 2: | ||
this._option.template = (_b = this._inputOption.template) !== null && _b !== void 0 ? _b : ''; | ||
_g.label = 3; | ||
case 3: | ||
if (this._option.template.search('\\[router-outlet\\]')) { | ||
this._router_outlet_id = "___Module__" + this.constructor.name + "_router-outlet_" + this.id + "_" + RandomUtils.uuid(); | ||
this._option.template = this._option.template.replace('[router-outlet]', " id='" + this._router_outlet_id + "' "); | ||
} | ||
delete this._inputOption.template; | ||
_g.label = 4; | ||
case 4: | ||
i = 0; | ||
_g.label = 5; | ||
case 5: | ||
if (!(this._inputOption.styleImports && i < this._inputOption.styleImports.length)) return [3, 10]; | ||
if (!this._inputOption.styleImports[i]) return [3, 9]; | ||
sp = this._inputOption.styleImports[i]; | ||
if (!(sp instanceof Promise)) return [3, 7]; | ||
_e = this._option.styleImports; | ||
_f = i; | ||
return [4, sp]; | ||
case 6: | ||
_e[_f] = (_c = (_g.sent())) !== null && _c !== void 0 ? _c : ''; | ||
return [3, 8]; | ||
case 7: | ||
this._option.styleImports[i] = sp !== null && sp !== void 0 ? sp : ''; | ||
_g.label = 8; | ||
case 8: | ||
delete this._inputOption.styleImports[i]; | ||
_g.label = 9; | ||
case 9: | ||
i++; | ||
return [3, 5]; | ||
case 10: return [2, this._option]; | ||
} | ||
}); | ||
}); | ||
}; | ||
@@ -56,0 +142,0 @@ FrontModule.prototype.getValue = function (name, value) { |
{ | ||
"name": "simple-boot-front", | ||
"version": "1.0.49", | ||
"version": "1.0.50", | ||
"main": "SimpleApplication.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
 | ||
[](https://www.npmjs.com/package/simple-boot-front) [](LICENSE.md) [](https://discord.gg/PW56dpns) [](https://github.com/visualkhh/simple-boot-front) | ||
[](https://www.npmjs.com/package/simple-boot-front) [](LICENSE.md) [](https://discord.gg/PW56dpns) [](https://github.com/visualkhh/simple-boot-front) | ||
@@ -4,0 +4,0 @@ Single Page Application Framworks for Web |
@@ -30,2 +30,3 @@ var __extends = (this && this.__extends) || (function () { | ||
_this.option = option; | ||
window.__dirname = 'simple-boot-front__dirname'; | ||
option.simProxy = new SimFrontProxyHandler(option); | ||
@@ -48,18 +49,22 @@ return _this; | ||
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); | ||
} | ||
moduleObj.init().then(function (_) { | ||
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(); }); | ||
module.init().then(function (_) { | ||
_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(); }); | ||
}); | ||
}); | ||
@@ -66,0 +71,0 @@ }); |
76723
1410