simple-boot-core
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -34,5 +34,5 @@ "use strict"; | ||
else { | ||
g; | ||
return g; | ||
} | ||
}; | ||
exports.SimGlobal = SimGlobal; |
export declare class Intent<T = any, E = any> { | ||
uri?: string | undefined; | ||
uri: string; | ||
data?: T | undefined; | ||
event?: E | undefined; | ||
constructor(uri?: string | undefined, data?: T | undefined, event?: E | undefined); | ||
get scheme(): string | undefined; | ||
constructor(uri: string, data?: T | undefined, event?: E | undefined); | ||
get scheme(): string; | ||
get paths(): string[]; | ||
get params(): { | ||
get fullPath(): string; | ||
get pathname(): string; | ||
get query(): string; | ||
get queryParams(): { | ||
[key: string]: string; | ||
}; | ||
} |
@@ -12,4 +12,3 @@ "use strict"; | ||
get: function () { | ||
var _a; | ||
return (_a = this.uri) === null || _a === void 0 ? void 0 : _a.split('://')[0]; | ||
return this.uri.split('://')[0]; | ||
}, | ||
@@ -21,4 +20,4 @@ enumerable: false, | ||
get: function () { | ||
var _a, _b, _c; | ||
return ((_c = (_b = (_a = this.uri) === null || _a === void 0 ? void 0 : _a.split('://')[1]) === null || _b === void 0 ? void 0 : _b.split('/')) !== null && _c !== void 0 ? _c : []).map(function (it) { return it.split('?')[0]; }); | ||
var _a; | ||
return ((_a = this.pathname.split('/')) !== null && _a !== void 0 ? _a : []); | ||
}, | ||
@@ -28,7 +27,33 @@ enumerable: false, | ||
}); | ||
Object.defineProperty(Intent.prototype, "params", { | ||
Object.defineProperty(Intent.prototype, "fullPath", { | ||
get: function () { | ||
var _a, _b, _c, _d; | ||
var _a; | ||
var paths = this.uri.split('://'); | ||
return (_a = paths[paths.length >= 2 ? 1 : 0]) !== null && _a !== void 0 ? _a : ''; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Intent.prototype, "pathname", { | ||
get: function () { | ||
var paths = this.fullPath.split('?'); | ||
return paths[0]; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Intent.prototype, "query", { | ||
get: function () { | ||
var _a; | ||
var paths = this.fullPath.split('?'); | ||
return (_a = paths[1]) !== null && _a !== void 0 ? _a : ''; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Intent.prototype, "queryParams", { | ||
get: function () { | ||
var _a; | ||
var param = {}; | ||
(_d = (_c = (_b = (_a = this.uri) === null || _a === void 0 ? void 0 : _a.split('://')[1]) === null || _b === void 0 ? void 0 : _b.split('?')[1]) === null || _c === void 0 ? void 0 : _c.split('&')) === null || _d === void 0 ? void 0 : _d.forEach(function (it) { | ||
(_a = this.query.split('&')) === null || _a === void 0 ? void 0 : _a.forEach(function (it) { | ||
var a = it.split('='); | ||
@@ -35,0 +60,0 @@ param[a[0]] = a[1]; |
import 'reflect-metadata'; | ||
import { Subject } from 'rxjs'; | ||
import { Intent } from './Intent'; | ||
import { SimstanceManager } from '../simstance/SimstanceManager'; | ||
import { Runnable } from '../run/Runnable'; | ||
export declare class IntentManager implements Runnable { | ||
export declare class IntentManager { | ||
simstanceManager: SimstanceManager; | ||
subject: Subject<Intent<any, any>>; | ||
constructor(simstanceManager: SimstanceManager); | ||
onNext(intent: Intent): void; | ||
run(): void; | ||
private extracted; | ||
publish(it: Intent): void; | ||
} |
@@ -5,43 +5,33 @@ "use strict"; | ||
require("reflect-metadata"); | ||
var rxjs_1 = require("rxjs"); | ||
var IntentManager = (function () { | ||
function IntentManager(simstanceManager) { | ||
this.simstanceManager = simstanceManager; | ||
this.subject = new rxjs_1.Subject(); | ||
} | ||
IntentManager.prototype.onNext = function (intent) { | ||
this.subject.next(intent); | ||
}; | ||
IntentManager.prototype.run = function () { | ||
IntentManager.prototype.publish = function (it) { | ||
var _this = this; | ||
this.subject.subscribe(function (it) { | ||
var _a; | ||
(_a = _this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getSimConfig(it.scheme).forEach(function (data) { | ||
_this.extracted(data.type, it); | ||
}); | ||
}); | ||
}; | ||
IntentManager.prototype.extracted = function (key, it) { | ||
var _a, _b; | ||
var orNewSim = (_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getOrNewSim(key); | ||
if (orNewSim) { | ||
if (it.paths.length > 0) { | ||
var callthis_1 = orNewSim; | ||
var lastProp_1 = ''; | ||
it.paths.filter(function (i) { return i; }).forEach(function (i) { | ||
callthis_1 = orNewSim; | ||
orNewSim = orNewSim === null || orNewSim === void 0 ? void 0 : orNewSim[i]; | ||
lastProp_1 = i; | ||
}); | ||
if (orNewSim && typeof orNewSim === 'function') { | ||
orNewSim.call(callthis_1, it); | ||
var _a; | ||
(_a = this.simstanceManager) === null || _a === void 0 ? void 0 : _a.getSimConfig(it.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) { | ||
var callthis_1 = orNewSim; | ||
var lastProp_1 = ''; | ||
it.paths.filter(function (i) { return i; }).forEach(function (i) { | ||
callthis_1 = orNewSim; | ||
orNewSim = orNewSim === null || orNewSim === void 0 ? void 0 : orNewSim[i]; | ||
lastProp_1 = i; | ||
}); | ||
if (orNewSim && typeof orNewSim === 'function') { | ||
orNewSim.call(callthis_1, it); | ||
} | ||
else if (orNewSim) { | ||
callthis_1[lastProp_1] = it.data; | ||
} | ||
} | ||
else if (orNewSim) { | ||
callthis_1[lastProp_1] = it.data; | ||
else { | ||
(_b = orNewSim === null || orNewSim === void 0 ? void 0 : orNewSim.subscribe) === null || _b === void 0 ? void 0 : _b.call(orNewSim, it); | ||
} | ||
} | ||
else { | ||
(_b = orNewSim === null || orNewSim === void 0 ? void 0 : orNewSim.subscribe) === null || _b === void 0 ? void 0 : _b.call(orNewSim, it); | ||
} | ||
} | ||
}); | ||
}; | ||
@@ -48,0 +38,0 @@ return IntentManager; |
@@ -19,3 +19,3 @@ "use strict"; | ||
var _a; | ||
(_a = SimGlobal_1.SimGlobal().application) === null || _a === void 0 ? void 0 : _a.intentManager.onNext(intent); | ||
(_a = SimGlobal_1.SimGlobal().application) === null || _a === void 0 ? void 0 : _a.publishSimIntent(intent); | ||
}; | ||
@@ -22,0 +22,0 @@ Module.prototype.subscribe = function (intent) { |
{ | ||
"name": "simple-boot-core", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"main": "SimpleApplication.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
import { Runnable } from './run/Runnable'; | ||
import { SimstanceManager } from "./simstance/SimstanceManager"; | ||
import { SimOption } from "./SimOption"; | ||
import { IntentManager } from "./intent/IntentManager"; | ||
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"; | ||
export declare class SimpleApplication implements Runnable { | ||
rootRouter: ConstructorType<Router>; | ||
option: SimOption; | ||
simstanceManager: SimstanceManager; | ||
intentManager: IntentManager; | ||
constructor(option: SimOption); | ||
private intentManager; | ||
private routerManager; | ||
constructor(rootRouter: ConstructorType<Router>, option?: SimOption); | ||
run(): void; | ||
publishIntent(i: Intent): void; | ||
routing<R extends Router = Router, M extends Module = Module>(i: Intent): Promise<RouterModule<R, M>>; | ||
} |
"use strict"; | ||
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 }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,8 +42,13 @@ exports.SimpleApplication = void 0; | ||
var SimstanceManager_1 = require("./simstance/SimstanceManager"); | ||
var SimOption_1 = require("./SimOption"); | ||
var IntentManager_1 = require("./intent/IntentManager"); | ||
var RouterManager_1 = require("./route/RouterManager"); | ||
var SimpleApplication = (function () { | ||
function SimpleApplication(option) { | ||
function SimpleApplication(rootRouter, option) { | ||
if (option === void 0) { option = new SimOption_1.SimOption(); } | ||
this.rootRouter = rootRouter; | ||
this.option = option; | ||
this.simstanceManager = new SimstanceManager_1.SimstanceManager(option); | ||
this.intentManager = new IntentManager_1.IntentManager(this.simstanceManager); | ||
this.routerManager = new RouterManager_1.RouterManager(this.rootRouter, this.simstanceManager); | ||
SimGlobal_1.SimGlobal().application = this; | ||
@@ -17,6 +58,21 @@ } | ||
this.simstanceManager.run(); | ||
this.intentManager.run(); | ||
}; | ||
SimpleApplication.prototype.publishIntent = function (i) { | ||
return this.intentManager.publish(i); | ||
}; | ||
SimpleApplication.prototype.routing = function (i) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var promise; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, this.routerManager.routing(i)]; | ||
case 1: | ||
promise = _a.sent(); | ||
return [2, promise]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return SimpleApplication; | ||
}()); | ||
exports.SimpleApplication = SimpleApplication; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79544
70
1829