How to use the aurelia-metadata.Origin.get function in aurelia-metadata

To help you get started, we’ve selected a few aurelia-metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / templating-router / dist / es2015 / route-loader.js View on Github external
loadRoute(router, config) {
    let childContainer = router.container.createChild();

    let viewModel;
    if (config.moduleId === null) {
      viewModel = EmptyClass;
    } else if (/\.html/i.test(config.moduleId)) {
      viewModel = createDynamicClass(config.moduleId);
    } else {
      viewModel = relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
    }

    let instruction = {
      viewModel: viewModel,
      childContainer: childContainer,
      view: config.view || config.viewStrategy,
      router: router
    };

    childContainer.registerSingleton(RouterViewLocator);

    childContainer.getChildRouter = function () {
      let childRouter;

      childContainer.registerHandler(Router, c => {
        return childRouter || (childRouter = router.createChild(childContainer));
github aurelia / templating / dist / es6 / custom-element.js View on Github external
load(container, target, viewStrategy){
    var annotation, options;

    configureBehavior(this, container, target);

    this.targetShadowDOM = getAnnotation(target, UseShadowDOM) !== null;
    this.usesShadowDOM = this.targetShadowDOM && hasShadowDOM;

    viewStrategy = viewStrategy || ViewStrategy.getDefault(target);
    options = { targetShadowDOM:this.targetShadowDOM };

    if(!viewStrategy.moduleId){
      viewStrategy.moduleId = Origin.get(target).moduleId;
    }

    return viewStrategy.loadViewFactory(container.get(ViewEngine), options).then(viewFactory => {
      this.viewFactory = viewFactory;
      return this;
    });
  }
github MarcScheib / aurelia-notify / dist / aurelia-notify.js View on Github external
function _getViewModel(container, childContainer, compositionEngine, notificationController) {
  let compositionContext = {
    container: container,
    childContainer: childContainer,
    model: notificationController.settings.model,
    viewModel: notificationController.settings.viewModel
  };

  if (typeof compositionContext.viewModel === 'function') {
    compositionContext.viewModel = Origin.get(compositionContext.viewModel).moduleId;
  }

  if (typeof compositionContext.viewModel === 'string') {
    return compositionEngine.ensureViewModel(compositionContext);
  }

  return Promise.resolve(compositionContext);
}
github aurelia / templating / src / resource-coordinator.js View on Github external
importResourcesFromModules(imports, importIds){
    var loads = [], i, ii, analysis, type, key, annotation,
                j, jj, resources, current,
                existing = this.importedModules,
                container = this.container,
                allAnalysis = new Array(imports.length);

    if(!importIds){
      importIds = new Array(imports.length);

      for(i = 0, ii = imports.length; i < ii; ++i){
        current = imports[i];

        for(key in current){
          type = current[key];
          annotation = Origin.get(type);
          if(annotation){
            importIds[i] = annotation.moduleId;
            break;
          }
        }
      }
    }

    for(i = 0, ii = imports.length; i < ii; ++i){
      analysis = existing[importIds[i]];

      if(analysis){
        allAnalysis[i] = analysis;
        continue;
      }
github adarshpastakia / aurelia-ui-framework / src / resources / utils / ui-dialog.ts View on Github external
private getViewModel(instruction) {
    if (typeof instruction.viewModel === 'function') {
      instruction.viewModel = Origin.get(instruction.viewModel).moduleId;
    }
    if (typeof instruction.viewModel === 'string') {
      return this.compositionEngine.ensureViewModel(instruction);
    }
    return Promise.resolve(instruction);
  }
github aurelia / ux / dist / es2015 / styles / style-resource.js View on Github external
load(container) {
        const styleStrategy = container.get(StyleLocator)
            .getStyleStrategy(this.styleObjectType);
        if (!styleStrategy.moduleId) {
            styleStrategy.moduleId = Origin.get(this.styleObjectType).moduleId;
        }
        return styleStrategy.loadStyleFactory(container, this.styleObjectType).then(styleFactory => {
            this.factory = styleFactory;
            this.hooks.factory = this.factory;
            return this;
        });
    }
}
github aurelia / templating / src / view-locator.js View on Github external
getViewStrategy(value: any): ViewStrategy {
    if (!value) {
      return null;
    }

    if (typeof value === 'object' && 'getViewStrategy' in value) {
      let origin = Origin.get(value.constructor);

      value = value.getViewStrategy();

      if (typeof value === 'string') {
        value = new RelativeViewStrategy(value);
      }

      viewStrategy.assert(value);

      if (origin.moduleId) {
        value.makeRelativeTo(origin.moduleId);
      }

      return value;
    }
github MarcScheib / aurelia-notify / dist / es2015 / notification-service.js View on Github external
function _getViewModel(container, childContainer, compositionEngine, notificationController) {
  let compositionContext = {
    container: container,
    childContainer: childContainer,
    model: notificationController.settings.model,
    viewModel: notificationController.settings.viewModel
  };

  if (typeof compositionContext.viewModel === 'function') {
    compositionContext.viewModel = Origin.get(compositionContext.viewModel).moduleId;
  }

  if (typeof compositionContext.viewModel === 'string') {
    return compositionEngine.ensureViewModel(compositionContext);
  }

  return Promise.resolve(compositionContext);
}