How to use the aurelia-metadata.Metadata 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 / dependency-injection / dist / commonjs / container.js View on Github external
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _coreJs = require('core-js');

var _coreJs2 = _interopRequireDefault(_coreJs);

var _aureliaMetadata = require('aurelia-metadata');

var _aureliaLogging = require('aurelia-logging');

var _metadata = require('./metadata');

_aureliaMetadata.Metadata.registration = 'aurelia:registration';
_aureliaMetadata.Metadata.instanceActivator = 'aurelia:instance-activator';

function test() {}
if (!test.name) {
  Object.defineProperty(Function.prototype, 'name', {
    get: function get() {
      var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];

      Object.defineProperty(this, 'name', { value: name });
      return name;
    }
  });
}

var emptyParameters = Object.freeze([]);
github aurelia / dependency-injection / dist / commonjs / container.js View on Github external
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _coreJs = require('core-js');

var _coreJs2 = _interopRequireDefault(_coreJs);

var _aureliaMetadata = require('aurelia-metadata');

var _aureliaLogging = require('aurelia-logging');

var _metadata = require('./metadata');

_aureliaMetadata.Metadata.registration = 'aurelia:registration';
_aureliaMetadata.Metadata.instanceActivator = 'aurelia:instance-activator';

function test() {}
if (!test.name) {
  Object.defineProperty(Function.prototype, 'name', {
    get: function get() {
      var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];

      Object.defineProperty(this, 'name', { value: name });
      return name;
    }
  });
}

var emptyParameters = Object.freeze([]);

exports.emptyParameters = emptyParameters;
github aurelia / templating / dist / commonjs / behaviors.js View on Github external
"use strict";

exports.configureBehavior = configureBehavior;

var Metadata = require("aurelia-metadata").Metadata;

var TaskQueue = require("aurelia-task-queue").TaskQueue;

var ObserverLocator = require("aurelia-binding").ObserverLocator;

var ChildObserver = require("./children").ChildObserver;

var BehaviorProperty = require("./property").BehaviorProperty;

var hyphenate = require("./util").hyphenate;

function configureBehavior(container, behavior, target, valuePropertyName) {
  var proto = target.prototype,
      taskQueue = container.get(TaskQueue),
      meta = Metadata.on(target),
      observerLocator = container.get(ObserverLocator),
github aurelia / templating / dist / commonjs / module-analyzer.js View on Github external
} else if (exportedValue instanceof _viewStrategy.ViewStrategy) {
        viewStrategy = exportedValue;
      } else if (exportedValue instanceof _aureliaLoader.TemplateRegistryEntry) {
        viewStrategy = new _viewStrategy.TemplateRegistryViewStrategy(moduleId, exportedValue);
      } else {
        if (conventional = _htmlBehavior.HtmlBehaviorResource.convention(key)) {
          if (conventional.elementName !== null && !mainResource) {
            mainResource = new ResourceDescription(key, exportedValue, conventional);
          } else {
            resources.push(new ResourceDescription(key, exportedValue, conventional));
          }

          Reflect.defineMetadata(_aureliaMetadata.Metadata.resource, conventional, exportedValue);
        } else if (conventional = _aureliaBinding.ValueConverterResource.convention(key)) {
          resources.push(new ResourceDescription(key, exportedValue, conventional));
          Reflect.defineMetadata(_aureliaMetadata.Metadata.resource, conventional, exportedValue);
        } else if (!fallbackValue) {
          fallbackValue = exportedValue;
          fallbackKey = key;
        }
      }
    }

    if (!mainResource && fallbackValue) {
      mainResource = new ResourceDescription(fallbackKey, fallbackValue);
    }

    resourceModule.moduleInstance = moduleInstance;
    resourceModule.mainResource = mainResource;
    resourceModule.resources = resources;
    resourceModule.viewStrategy = viewStrategy;
github cmichaelgraham / aurelia-ts-port / dist / commonjs / templating / decorators.js View on Github external
var deco = function (target, key, descriptor) {
        var actualTarget = key ? target.constructor : target, resource = aurelia_metadata_1.Metadata.getOrCreateOwn(aurelia_metadata_1.Metadata.resource, html_behavior_1.HtmlBehaviorResource, actualTarget), prop;
        if (key) {
            nameOrConfigOrTarget = nameOrConfigOrTarget || {};
            nameOrConfigOrTarget.name = key;
        }
        prop = new bindable_property_1.BindableProperty(nameOrConfigOrTarget);
        return prop.registerWith(actualTarget, resource, descriptor);
    };
    if (!nameOrConfigOrTarget) {
github aurelia / templating / dist / commonjs / decorators.js View on Github external
return function (target) {
    if (override instanceof _htmlBehavior.HtmlBehaviorResource) {
      Reflect.defineMetadata(_aureliaMetadata.Metadata.resource, override, target);
    } else {
      var resource = _aureliaMetadata.Metadata.getOrCreateOwn(_aureliaMetadata.Metadata.resource, _htmlBehavior.HtmlBehaviorResource, target);
      Object.assign(resource, override);
    }
  };
}
github aurelia / templating / dist / commonjs / module-analyzer.js View on Github external
if (typeof moduleInstance === 'function') {
      moduleInstance = { 'default': moduleInstance };
    }

    if (viewModelMember) {
      mainResource = new ResourceDescription(viewModelMember, moduleInstance[viewModelMember]);
    }

    for (key in moduleInstance) {
      exportedValue = moduleInstance[key];

      if (key === viewModelMember || typeof exportedValue !== 'function') {
        continue;
      }

      resourceTypeMeta = _aureliaMetadata.Metadata.get(_aureliaMetadata.Metadata.resource, exportedValue);

      if (resourceTypeMeta) {
        if (resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null) {
          _htmlBehavior.HtmlBehaviorResource.convention(key, resourceTypeMeta);
        }

        if (resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null) {
          resourceTypeMeta.elementName = (0, _util.hyphenate)(key);
        }

        if (!mainResource && resourceTypeMeta instanceof _htmlBehavior.HtmlBehaviorResource && resourceTypeMeta.elementName !== null) {
          mainResource = new ResourceDescription(key, exportedValue, resourceTypeMeta);
        } else {
          resources.push(new ResourceDescription(key, exportedValue, resourceTypeMeta));
        }
      } else if (exportedValue instanceof _viewStrategy.ViewStrategy) {
github aurelia / templating / dist / commonjs / decorators.js View on Github external
return function (target) {
    var resource = _aureliaMetadata.Metadata.getOrCreateOwn(_aureliaMetadata.Metadata.resource, _htmlBehavior.HtmlBehaviorResource, target);
    resource.attributeName = name;
    resource.attributeDefaultBindingMode = defaultBindingMode;
  };
}
github aurelia / dependency-injection / dist / commonjs / container.js View on Github external
Container.prototype.autoRegister = function autoRegister(fn, key) {
    var registration;

    if (fn === null || fn === undefined) {
      throw new Error('fn cannot be null or undefined.');
    }

    if (typeof fn === 'function') {
      registration = _aureliaMetadata.Metadata.get(_aureliaMetadata.Metadata.registration, fn);

      if (registration !== undefined) {
        registration.register(this, key || fn, fn);
      } else {
        this.registerSingleton(key || fn, fn);
      }
    } else {
      this.registerInstance(fn, fn);
    }
  };
github aurelia / templating / dist / commonjs / resource-coordinator.js View on Github external
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };

var Loader = require("aurelia-loader").Loader;

var _aureliaPath = require("aurelia-path");

var relativeToFile = _aureliaPath.relativeToFile;
var join = _aureliaPath.join;

var Container = require("aurelia-dependency-injection").Container;

var _aureliaMetadata = require("aurelia-metadata");

var Metadata = _aureliaMetadata.Metadata;
var ResourceType = _aureliaMetadata.ResourceType;
var Origin = _aureliaMetadata.Origin;

var ValueConverter = require("aurelia-binding").ValueConverter;

var CustomElement = require("./custom-element").CustomElement;

var AttachedBehavior = require("./attached-behavior").AttachedBehavior;

var TemplateController = require("./template-controller").TemplateController;

var ViewEngine = require("./view-engine").ViewEngine;

var ResourceRegistry = require("./resource-registry").ResourceRegistry;

var id = 0;