diff --git a/client/src/modules/reflection/index.js b/client/src/modules/reflection/index.js index 6d5db3b2..51d6d804 100644 --- a/client/src/modules/reflection/index.js +++ b/client/src/modules/reflection/index.js @@ -22,6 +22,14 @@ export default class Reflection { return Modules; } + static get resolve() { + return Resolver.resolve; + } + + static get resolveAsync() { + return Resolver.resolveAsync; + } + static get resolver() { return Resolver; } @@ -29,5 +37,4 @@ export default class Reflection { static get DOM() { return DOM; } - } diff --git a/client/src/modules/reflection/resolver.js b/client/src/modules/reflection/resolver.js index 5e45d431..a1f94d0d 100644 --- a/client/src/modules/reflection/resolver.js +++ b/client/src/modules/reflection/resolver.js @@ -8,9 +8,35 @@ * LICENSE file in the root directory of this source tree. */ -import Modules from './modules'; +import { Module } from './modules'; -export class Resolver { +class Resolved { + + constructor(module, ...classes) { + this.module = Module.byProps(...classes); + this.classes = classes; + } + + get className() { + return this.module && this.module[this.classes[0]] ? this.module[this.classes[0]].split(' ')[0] : this.classes[0]; + } + + get selector() { + return `.${this.className}`; + } + +} + +export default class Resolver { + + static resolve(...classes) { + return new Resolved(Module.byProps(...classes), ...classes); + } + + static async resolveAsync(...classes) { + const module = await Module.waitForModuleByProps([...classes]); + return new Resolved(module, ...classes); + } /** * Searches for a class module and returns a class from it. @@ -19,11 +45,11 @@ export class Resolver { * @return {String} */ static getClassName(base, ...additional_classes) { - const class_module = Modules.getModuleByProps([base, ...additional_classes]); + const class_module = Module.byProps([base, ...additional_classes]); if (class_module && class_module[base]) return class_module[base].split(' ')[0]; } static async waitForClassName(base, ...additional_classes) { - const class_module = await Modules.waitForModuleByProps([base, ...additional_classes]); + const class_module = await Module.waitForModuleByProps([base, ...additional_classes]); if (class_module && class_module[base]) return class_module[base].split(' ')[0]; } static getSelector(base, ...additional_classes) {