Comparing version 6.11.0 to 6.12.0
@@ -48,126 +48,123 @@ "use strict"; | ||
exports.createModuleProxy = createModuleProxy; | ||
let ModuleProxy = (() => { | ||
let ModuleProxy = class ModuleProxy extends di_1.Injectable { | ||
get exports() { | ||
if (typeof this.loader.extension === "string") { | ||
return this.loader.load(this.path + this.loader.extension); | ||
} | ||
else { | ||
let dir = path_1.dirname(this.path); | ||
let name = path_1.basename(this.path); | ||
let files = fs_1.readdirSync(dir); | ||
for (let file of files) { | ||
let ext = path_1.extname(file); | ||
let _name = path_1.basename(file, ext); | ||
if (_name === name && this.loader.extension.includes(ext)) { | ||
return this.loader.load(this.path + ext); | ||
} | ||
} | ||
throw new Error(`Cannot find module '${this.path}'`); | ||
} | ||
let ModuleProxy = class ModuleProxy extends di_1.Injectable { | ||
get exports() { | ||
if (typeof this.loader.extension === "string") { | ||
return this.loader.load(this.path + this.loader.extension); | ||
} | ||
get proto() { | ||
let { exports } = this; | ||
if (typeof exports === "object") { | ||
if (typeof exports.default === "object") { | ||
return exports.default; | ||
else { | ||
let dir = path_1.dirname(this.path); | ||
let name = path_1.basename(this.path); | ||
let files = fs_1.readdirSync(dir); | ||
for (let file of files) { | ||
let ext = path_1.extname(file); | ||
let _name = path_1.basename(file, ext); | ||
if (_name === name && this.loader.extension.includes(ext)) { | ||
return this.loader.load(this.path + ext); | ||
} | ||
else if (typeOf_1.default(exports.default) === "class") { | ||
return exports.default.prototype; | ||
} | ||
return exports; | ||
} | ||
else if (typeOf_1.default(exports) === "class") { | ||
return exports.prototype; | ||
} | ||
else { | ||
return null; | ||
} | ||
throw new Error(`Cannot find module '${this.path}'`); | ||
} | ||
get ctor() { | ||
let { exports } = this; | ||
if (typeof exports === "object" && typeOf_1.default(exports.default) === "class") { | ||
} | ||
get proto() { | ||
let { exports } = this; | ||
if (typeof exports === "object") { | ||
if (typeof exports.default === "object") { | ||
return exports.default; | ||
} | ||
else if (typeOf_1.default(exports) === "class") { | ||
return exports; | ||
else if (typeOf_1.default(exports.default) === "class") { | ||
return exports.default.prototype; | ||
} | ||
else { | ||
return null; | ||
} | ||
return exports; | ||
} | ||
create(...args) { | ||
if (this.ctor) { | ||
return new this.ctor(...args); | ||
} | ||
else if (this.proto) { | ||
return merge(cloneDeep(this.proto), args[0]); | ||
} | ||
else { | ||
throw new TypeError(`${this.name} is not a valid module`); | ||
} | ||
else if (typeOf_1.default(exports) === "class") { | ||
return exports.prototype; | ||
} | ||
instance(route = util_1.local) { | ||
if (route === util_1.local) { | ||
return this.singletons[this.name] || (this.singletons[this.name] = util_1.getInstance(this)); | ||
} | ||
if (typeof route === "string" && this.remoteSingletons[route]) { | ||
return this.remoteSingletons[route]; | ||
} | ||
let singletons = values(this.remoteSingletons); | ||
if (singletons.length > 0) { | ||
let id = util_1.evalRouteId(route); | ||
let availableSingletons = singletons.filter(item => { | ||
return item[util_1.readyState] === 2; | ||
}); | ||
if (availableSingletons.length > 0) { | ||
return availableSingletons[id % availableSingletons.length]; | ||
} | ||
else { | ||
return singletons[id % singletons.length]; | ||
} | ||
} | ||
else { | ||
util_1.throwUnavailableError(this.name); | ||
} | ||
else { | ||
return null; | ||
} | ||
fallbackToLocal(enable = void 0) { | ||
if (enable === void 0) { | ||
return this[fallbackToLocal]; | ||
} | ||
get ctor() { | ||
let { exports } = this; | ||
if (typeof exports === "object" && typeOf_1.default(exports.default) === "class") { | ||
return exports.default; | ||
} | ||
else if (typeOf_1.default(exports) === "class") { | ||
return exports; | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
create(...args) { | ||
if (this.ctor) { | ||
return new this.ctor(...args); | ||
} | ||
else if (this.proto) { | ||
return merge(cloneDeep(this.proto), args[0]); | ||
} | ||
else { | ||
throw new TypeError(`${this.name} is not a valid module`); | ||
} | ||
} | ||
instance(route = util_1.local) { | ||
if (route === util_1.local) { | ||
return this.singletons[this.name] || (this.singletons[this.name] = util_1.getInstance(this)); | ||
} | ||
if (typeof route === "string" && this.remoteSingletons[route]) { | ||
return this.remoteSingletons[route]; | ||
} | ||
let singletons = values(this.remoteSingletons); | ||
if (singletons.length > 0) { | ||
let id = util_1.evalRouteId(route); | ||
let availableSingletons = singletons.filter(item => { | ||
return item[util_1.readyState] === 2; | ||
}); | ||
if (availableSingletons.length > 0) { | ||
return availableSingletons[id % availableSingletons.length]; | ||
} | ||
else { | ||
this[fallbackToLocal] = Boolean(enable); | ||
return this; | ||
return singletons[id % singletons.length]; | ||
} | ||
} | ||
noLocal() { | ||
return this.fallbackToLocal(false); | ||
else { | ||
util_1.throwUnavailableError(this.name); | ||
} | ||
__get(prop) { | ||
if (prop in this) { | ||
return this[prop]; | ||
} | ||
else if (prop in this.children) { | ||
return this.children[prop]; | ||
} | ||
else if (typeof prop != "symbol") { | ||
return this.children[prop] = createModuleProxy(this.name + "." + String(prop), this.path + path_1.sep + String(prop), this.loader, this.singletons, this[util_1.proxyRoot] || this); | ||
} | ||
} | ||
fallbackToLocal(enable = void 0) { | ||
if (enable === void 0) { | ||
return this[fallbackToLocal]; | ||
} | ||
__has(prop) { | ||
return (prop in this) || (prop in this.children); | ||
else { | ||
this[fallbackToLocal] = Boolean(enable); | ||
return this; | ||
} | ||
toString() { | ||
return this.name; | ||
} | ||
noLocal() { | ||
return this.fallbackToLocal(false); | ||
} | ||
__get(prop) { | ||
if (prop in this) { | ||
return this[prop]; | ||
} | ||
toJSON() { | ||
return this.name; | ||
else if (prop in this.children) { | ||
return this.children[prop]; | ||
} | ||
}; | ||
ModuleProxy = tslib_1.__decorate([ | ||
js_magic_1.applyMagic | ||
], ModuleProxy); | ||
return ModuleProxy; | ||
})(); | ||
else if (typeof prop != "symbol") { | ||
return this.children[prop] = createModuleProxy(this.name + "." + String(prop), this.path + path_1.sep + String(prop), this.loader, this.singletons, this[util_1.proxyRoot] || this); | ||
} | ||
} | ||
__has(prop) { | ||
return (prop in this) || (prop in this.children); | ||
} | ||
toString() { | ||
return this.name; | ||
} | ||
toJSON() { | ||
return this.name; | ||
} | ||
}; | ||
ModuleProxy = tslib_1.__decorate([ | ||
js_magic_1.applyMagic | ||
], ModuleProxy); | ||
exports.ModuleProxy = ModuleProxy; | ||
//# sourceMappingURL=proxy.js.map |
{ | ||
"name": "alar", | ||
"version": "6.11.0", | ||
"version": "6.12.0", | ||
"description": "Auto-Load And Remote.", | ||
@@ -24,3 +24,3 @@ "main": "dist/index.js", | ||
"auto-load", | ||
"hot-realod", | ||
"hot-reload", | ||
"micro-service", | ||
@@ -44,3 +44,3 @@ "ipc", | ||
"backoff": "^2.5.0", | ||
"bsp": "^1.2.0", | ||
"bsp": "^1.3.0", | ||
"check-iterable": "^1.0.2", | ||
@@ -58,12 +58,11 @@ "chokidar": "^3.4.0", | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.152", | ||
"@types/lodash": "^4.14.155", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.12.42", | ||
"@types/node": "^14.0.11", | ||
"bson": "^4.0.4", | ||
"fron": "^0.2.4", | ||
"mocha": "^5.2.0", | ||
"sleep-promise": "^8.0.1", | ||
"source-map-support": "^0.5.19", | ||
"typescript": "^3.9.3" | ||
"typescript": "^3.9.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
8
215929
3549
Updatedbsp@^1.3.0