创建组件类

@param {Object} proto 组件类的方法表
@param {Function=} SuperComponent 父组件类
@return {Function}
499066
function defineComponent(proto, SuperComponent) {
    // 如果传入一个不是 san component 的 constructor，直接返回不是组件构造函数
    // 这种场景导致的错误 san 不予考虑
    if (typeof proto === 'function') {
        return proto;
    }

    // #[begin] error
    if (typeof proto !== 'object') {
        throw new Error('[SAN FATAL] defineComponent need a plain object.');
    }
    // #[end]

    function ComponentClass(option) { // eslint-disable-line
        Component.call(this, option);
    }

    ComponentClass.prototype = proto;
    inherits(ComponentClass, SuperComponent || Component);

    return ComponentClass;
}
408768
function instantiateReactComponent(node, shouldHaveDebugID) {
  var instance;

  if (node === null || node === false) {
    instance = ReactEmptyComponent.create(instantiateReactComponent);
  } else if (typeof node === 'object') {
    var element = node;
    var type = element.type;
    if (typeof type !== 'function' && typeof type !== 'string') {
      var info = '';
      if (process.env.NODE_ENV !== 'production') {
        if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
          info += ' You likely forgot to export your component from the file ' + "it's defined in.";
        }
      }
      info += getDeclarationErrorAddendum(element._owner);
       true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info) : _prodInvariant('130', type == null ? type : typeof type, info) : void 0;
    }

    // Special case string values
    if (typeof element.type === 'string') {
      instance = ReactHostComponent.createInternalComponent(element);
    } else if (isInternalComponentType(element.type)) {
      // This is temporarily available for custom components that are not string
      // representations. I.e. ART. Once those are updated to use the string
      // representation, we can drop this code path.
      instance = new element.type(element);

      // We renamed this. Allow the old name for compat. :(
      if (!instance.getHostNode) {
        instance.getHostNode = instance.getNativeNode;
      }
    } else {
      instance = new ReactCompositeComponentWrapper(element);
    }
  } else if (typeof node === 'string' || typeof node === 'number') {
    instance = ReactHostComponent.createInstanceForText(node);
  } else {
     true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : _prodInvariant('131', typeof node) : void 0;
  }

  if (process.env.NODE_ENV !== 'production') {
    process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getHostNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
  }

  // These two fields are used by the DOM and ART diffing algorithms
  // respectively. Instead of using expandos on components, we should be
  // storing the state needed by the diffing algorithms elsewhere.
  instance._mountIndex = 0;
  instance._mountImage = null;

  if (process.env.NODE_ENV !== 'production') {
    instance._debugID = shouldHaveDebugID ? getNextDebugID() : 0;
  }

  // Internal instances should fully constructed at this point, so they should
  // not get any new fields added to them at this point.
  if (process.env.NODE_ENV !== 'production') {
    if (Object.preventExtensions) {
      Object.preventExtensions(instance);
    }
  }

  return instance;
}
279815
function _gpfClassSuperCreateWeakBoundWithSameSignature (that, $super, superMethod) {
    var definition = _gpfFunctionDescribe(superMethod);
    definition.body = "return _superMethod_.apply(this === _$super_ ? _that_ : this, arguments);";
    return _gpfFunctionBuild(definition, {
        _that_: that,
        _$super_: $super,
        _superMethod_: superMethod
    });
}
1349968
function Component(options) { // eslint-disable-line

    // #[begin] error
    for (var key in Component.prototype) {
        if (this[key] !== Component.prototype[key]) {
            /* eslint-disable max-len */
            warn('\`' + key + '\` is a reserved key of san components. Overriding this property may cause unknown exceptions.');
            /* eslint-enable max-len */
        }
    }
    // #[end]


    options = options || {};

    this.lifeCycle = LifeCycle.start;
    this.children = [];
    this._elFns = [];
    this.listeners = {};
    this.slotChildren = [];
    this.implicitChildren = [];

    var clazz = this.constructor;

    this.filters = this.filters || clazz.filters || {};
    this.computed = this.computed || clazz.computed || {};
    this.messages = this.messages || clazz.messages || {};

    if (options.transition) {
        this.transition = options.transition;
    }

    this.subTag = options.subTag;

    // compile
    compileComponent(clazz);

    var protoANode = clazz.prototype.aNode;
    preheatANode(protoANode);


    this.tagName = protoANode.tagName;
    this.source = typeof options.source === 'string'
        ? parseTemplate(options.source).children[0]
        : options.source;
    preheatANode(this.source);


    this.sourceSlotNameProps = [];
    this.sourceSlots = {
        named: {}
    };


    this.owner = options.owner;
    this.scope = options.scope;
    this.el = options.el;

    var parent = options.parent;
    if (parent) {
        this.parent = parent;
        this.parentComponent = parent.nodeType === NodeType.CMPT
            ? parent
            : parent && parent.parentComponent;
    }
    else if (this.owner) {
        this.parentComponent = this.owner;
        this.scope = this.owner.data;
    }

    this.id = guid++;

    // #[begin] reverse
    if (this.el) {
        var firstCommentNode = this.el.firstChild;
        if (firstCommentNode && firstCommentNode.nodeType === 3) {
            firstCommentNode = firstCommentNode.nextSibling;
        }

        if (firstCommentNode && firstCommentNode.nodeType === 8) {
            var stumpMatch = firstCommentNode.data.match(/^\s*s-data:([\s\S]+)?$/);
            if (stumpMatch) {
                var stumpText = stumpMatch[1];

                // fill component data
                options.data = (new Function('return '
                    + stumpText
                        .replace(/^[\s\n]*/, '')
                        .replace(
                            /"(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.\d+Z"/g,
                            function (match, y, mon, d, h, m, s) {
                                return 'new Date(' + (+y) + ',' + (+mon) + ',' + (+d)
                                    + ',' + (+h) + ',' + (+m) + ',' + (+s) + ')';
                            }
                        )
                ))();

                if (firstCommentNode.previousSibling) {
                    removeEl(firstCommentNode.previousSibling);
                }
                removeEl(firstCommentNode);
            }
        }
    }
    // #[end]

    // native事件数组
    this.nativeEvents = [];

    if (this.source) {
        // 组件运行时传入的结构，做slot解析
        this._initSourceSlots(1);

        for (var i = 0, l = this.source.events.length; i < l; i++) {
            var eventBind = this.source.events[i];
            // 保存当前实例的native事件，下面创建aNode时候做合并
            if (eventBind.modifier.native) {
                this.nativeEvents.push(eventBind);
            }
            else {
                // #[begin] error
                warnEventListenMethod(eventBind, options.owner);
                // #[end]

                this.on(
                    eventBind.name,
                    getEventListener(eventBind.expr, options.owner, this.scope, 1),
                    eventBind
                );
            }
        }

        this.tagName = this.tagName || this.source.tagName;
        this.binds = camelComponentBinds(this.source.props);

        // init s-bind data
        nodeSBindInit(this, this.source.directives.bind);
    }

    this._toPhase('compiled');

    // init data
    this.data = new Data(
        extend(
            typeof this.initData === 'function' && this.initData() || {},
            options.data || this._sbindData
        )
    );

    this.tagName = this.tagName || 'div';

    // #[begin] allua
    // ie8- 不支持innerHTML输出自定义标签
    /* istanbul ignore if */
    if (ieOldThan9 && this.tagName.indexOf('-') > 0) {
        this.tagName = 'div';
    }
    // #[end]

    if (this.binds) {
        for (var i = 0, l = this.binds.length; i < l; i++) {
            var bindInfo = this.binds[i];
            postProp(bindInfo);

            if (this.scope) {
                var value = evalExpr(bindInfo.expr, this.scope, this.owner);
                if (typeof value !== 'undefined') {
                    // See: https://github.com/ecomfe/san/issues/191
                    this.data.set(bindInfo.name, value);
                }
            }
        }
    }

    // #[begin] error
    // 在初始化 + 数据绑定后，开始数据校验
    // NOTE: 只在开发版本中进行属性校验
    var dataTypes = this.dataTypes || clazz.dataTypes;
    if (dataTypes) {
        var dataTypeChecker = createDataTypesChecker(
            dataTypes,
            this.subTag || this.name || clazz.name
        );
        this.data.setTypeChecker(dataTypeChecker);
        this.data.checkDataTypes();
    }
    // #[end]

    this.computedDeps = {};
    for (var expr in this.computed) {
        if (this.computed.hasOwnProperty(expr) && !this.computedDeps[expr]) {
            this._calcComputed(expr);
        }
    }

    this.dataChanger = bind(this._dataChanger, this);
    this.data.listen(this.dataChanger);

    this._toPhase('inited');

    // #[begin] reverse
    if (this.el) {
        reverseElementChildren(this, this.data, this);
        this._toPhase('created');
        this._attached();
        this._toPhase('attached');
    }
    else {
        var walker = options.reverseWalker;
        if (walker) {
            var ifDirective = this.aNode.directives['if']; // eslint-disable-line dot-notation

            if (!ifDirective || evalExpr(ifDirective.value, this.data, this)) {
                var currentNode = walker.current;
                if (currentNode && currentNode.nodeType === 1) {
                    this.el = currentNode;
                    walker.goNext();
                }

                reverseElementChildren(this, this.data, this);
            }
            else {
                this.el = document.createComment(this.id);
                insertBefore(this.el, walker.target, walker.current);
            }

            this._toPhase('created');
            this._attached();
            this._toPhase('attached');
        }
    }
    // #[end]
}
1186772
function _gpfClassSuperCreateWithSameSignature (superMethod) {
    var definition = _gpfFunctionDescribe(superMethod);
    definition.body = "return _superMethod_.apply(this, arguments);";
    return _gpfFunctionBuild(definition, {
        _superMethod_: superMethod
    });
}
1006795
function (proto) {
            // Using push instead of resetting the reference because items are not copied from proto but from the
            // parameter of tplScriptDefinition directly
            proto.ICONS.push({
                type : ariaUtilsData.TYPE_ERROR,
                icon : "std:error"
            }, {
                type : ariaUtilsData.TYPE_WARNING,
                icon : "std:warning"
            }, {
                type : ariaUtilsData.TYPE_INFO,
                icon : "std:info"
            }, {
                type : ariaUtilsData.TYPE_FATAL,
                icon : "std:error"
            }, {
                type : ariaUtilsData.TYPE_NOTYPE,
                icon : "std:info"
            }, {
                type : ariaUtilsData.TYPE_CRITICAL_WARNING,
                icon : "std:warning"
            }, {
                type : ariaUtilsData.TYPE_CONFIRMATION,
                icon : "std:confirm"
            });
        }
824791
function genComponentContextCode(component, componentIdInContext) {
    var code = ['var componentCtx = {'];

    // proto
    code.push('proto: ' + componentIdInContext + 'Proto,');

    // sourceSlots
    code.push('sourceSlots: sourceSlots,');

    // data
    var defaultData = component.data.get();
    code.push('data: data || ' + stringifier.any(defaultData) + ',');

    // parentCtx
    code.push('owner: parentCtx,');

    // slotRenderers
    code.push('slotRenderers: {}');

    code.push('};');

    return code.join('\n');
}
1019938
function createComponent(Ctor, props, context) {
    var list = components[Ctor.name],
      inst;

    if (Ctor.prototype && Ctor.prototype.render) {
      inst = new Ctor(props, context);
      Component.call(inst, props, context);
    } else {
      inst = new Component(props, context);
      inst.constructor = Ctor;
      inst.render = doRender;
    }

    if (list) {
      for (var i = list.length; i--; ) {
        if (list[i].constructor === Ctor) {
          inst.nextBase = list[i].nextBase;
          list.splice(i, 1);
          break;
        }
      }
    }
    return inst;
  }
467637
function(cls,superClass) {
    var super_;
    while (lib.type.isFunction(cls.super_)) {
      if (cls.super_ === superClass) {
        super_ = cls.super_;
        break;
      }
      cls = cls.super_;
    }
    return super_;
  }
1181318
function getSuperType(subType) {
        if (subType) {
            return _global.type[_global.meta[subType.name].super];
        } else {
            return null;
        }
    }
411072
function(){

          // These will be worked out from `arguments`
          var SuperCtorList, protoMixin;

          var MixedClass, ResultClass;
          var list = [];
          var i, l, ii, ll;
          var proto;


          var r = workoutDeclareArguments( arguments );
          SuperCtorList = r.SuperCtorList;
          protoMixin = r.protoMixin;

          // No parameters: inheriting from Object directly, no multiple inheritance
          if( SuperCtorList.length === 0 ){
            MixedClass = Object;
          }
          // Only one parameter: straght single inheritance.
          else if( SuperCtorList.length === 1 ){
            MixedClass = SuperCtorList[ 0 ];

          // More than one parameter: multiple inheritance at work
          // MixedClass will end up being an artificially made constructor
          // where the prototype chain is the sum of _every_ prototype in
          // every element of SuperCtorList (taking out duplicates)
          } else {
            MixedClass = Object;

            // NOW:
            // Go through every __proto__ of every derivative class, and augment
            // MixedClass by inheriting from A COPY OF each one of them.

            list = [];
            for( i = 0, l = SuperCtorList.length; i < l; i ++ ){

              // Get the prototype list, in the right order
              // (the reversed discovery order)
              // The result will be placed in `subList`
              var subList = [];
              if( typeof SuperCtorList[ i ] === 'undefined' || typeof SuperCtorList[ i ].prototype === 'undefined'){
                throw new Error("Invalid constructor!")
              }

              proto = SuperCtorList[ i ].prototype;
              while( proto ){
                if( proto.constructor !== Object ) subList.push( proto );
                proto = Object.getPrototypeOf( proto );
              }
              subList = subList.reverse();

              // Add each element of sublist as long as it's not already in the main `list`
              for( ii = 0, ll = subList.length; ii < ll; ii ++ ){
                if( ! constructorAlreadyInList( subList[ ii ].constructor, list ) ) list.push( subList[ ii ] );
              }
            }

            // For each element in the prototype list that isn't Object(),
            // augment MixedClass with a copy of the new prototype
            for( ii = 0, ll = list.length; ii < ll; ii ++ ){
              proto = list[ ii ];

              var M = MixedClass;

              if( proto.constructor !== Object ){

                MixedClass = makeConstructor( MixedClass, proto, proto.constructor );
                copyClassMethods( M, MixedClass ); // Methods previously inherited

                copyClassMethods( proto.constructor, MixedClass ); // Extra methods from the father constructor
              }
            }
          }

          // Finally, inherit from the MixedClass, and add
          // class methods over
          // MixedClass might be:
          // * Object (coming from no inheritance),
          // * SuperCtorList[0] (coming from single inheritance)
          // * A constructor with the appropriate prototype chain (multiple inheritance)
          ResultClass = makeConstructor( MixedClass, protoMixin );
          copyClassMethods( MixedClass, ResultClass );

          // Add getInherited, inherited() and inheritedAsync() to the prototype
          // (only if they are not already there)
          if( ! ResultClass.prototype.getInherited ) {
            ResultClass.prototype.getInherited = getInherited;
          }
          if( ! ResultClass.prototype.inherited ) {
            ResultClass.prototype.inherited = makeInheritedFunction( 'sync' );
          }
          if( ! ResultClass.prototype.inheritedAsync ) {
            ResultClass.prototype.inheritedAsync = makeInheritedFunction( 'async' );
          }

          // Add instanceOf
          if( ! ResultClass.prototype.instanceOf ) {
            ResultClass.prototype.instanceOf = instanceOf;
          }

          // Add class-wide method `extend`
          ResultClass.extend = function(){
            return extend.apply( this, arguments );
          };

          // That's it!
          return ResultClass;
        }
381997
function extend(prototype, api) {
    if (prototype && api) {
      // use only own properties of 'api'
      Object.getOwnPropertyNames(api).forEach(function(n) {
        // acquire property descriptor
        var pd = Object.getOwnPropertyDescriptor(api, n);
        if (pd) {
          // clone property via descriptor
          Object.defineProperty(prototype, n, pd);
          // cache name-of-method for 'super' engine
          if (typeof pd.value == 'function') {
            // hint the 'super' engine
            pd.value.nom = n;
          }
        }
      });
    }
    return prototype;
  }
361692
function(name) {
       if ($caller !== null) {
            for(var $s = $caller.boundTo.$parent; $s !== null; $s = $s.$parent) {
                var m = $s.prototype[name];
                if (typeof m === 'function') {
                    return m;
                }
            }
            return null;
        }
        throw new Error("$super is called outside of class context");
    }
1360867
function(id, constructor, superklass) {
    if (superklass) {
      var ctor           = function() {};
          ctor.prototype = superklass.prototype;

      constructor.prototype = new ctor();
    }

    constructor.prototype.constructor = constructor;

    return constructor;
  }
504368
function protoWrap(proto, name, callback, isAsync) {
    proto[name] = function () {
      for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
        args[_key2] = arguments[_key2];
      }

      if (isAsync) {
        return callback.apply(this, args);
      } else {
        return this.then(function () {
          return callback.apply(this, args);
        });
      }
    };
  }
735147
function genComponentProtoCode(component) {
    var code = ['{'];

    // members for call expr
    var ComponentProto = component.constructor.prototype;
    Object.keys(ComponentProto).forEach(function (protoMemberKey) {
        var protoMember = ComponentProto[protoMemberKey];
        if (COMPONENT_RESERVED_MEMBERS[protoMemberKey] || !protoMember) {
            return;
        }

        switch (typeof protoMember) {
            case 'function':
                code.push(protoMemberKey + ': ' + protoMember.toString() + ',');
                break;

            case 'object':
                code.push(protoMemberKey + ':');

                if (protoMember instanceof Array) {
                    code.push('[');
                    protoMember.forEach(function (item) {
                        code.push(typeof item === 'function' ? item.toString() : '' + ',');
                    });
                    code.push(']');
                }
                else {
                    code.push('{');
                    Object.keys(protoMember).forEach(function (itemKey) {
                        var item = protoMember[itemKey];
                        if (typeof item === 'function') {
                            code.push(itemKey + ':' + item.toString() + ',');
                        }
                    });
                    code.push('}');
                }

                code.push(',');
        }
    });

    // filters
    code.push('filters: {');
    var filterCode = [];
    for (var key in component.filters) {
        if (component.filters.hasOwnProperty(key)) {
            var filter = component.filters[key];

            if (typeof filter === 'function') {
                filterCode.push(key + ': ' + filter.toString());
            }
        }
    }
    code.push(filterCode.join(','));
    code.push('},');

    /* eslint-disable no-redeclare */
    // computed obj
    code.push('computed: {');
    var computedCode = [];
    var computedNamesCode = [];
    var computedNamesIndex = {};
    for (var key in component.computed) {
        if (component.computed.hasOwnProperty(key)) {
            var computed = component.computed[key];

            if (typeof computed === 'function') {
                if (!computedNamesIndex[key]) {
                    computedNamesIndex[key] = 1;
                    computedNamesCode.push('"' + key + '"');
                }

                computedCode.push(key + ': '
                    + computed.toString()
                        .replace(/^\s*function\s*\(/, 'function (componentCtx')
                        .replace(
                            /this.data.get\(([^\)]+)\)/g,
                            function (match, exprLiteral) {
                                var exprStr = (new Function('return ' + exprLiteral))();
                                var expr = parseExpr(exprStr);

                                var ident = expr.paths[0].value;
                                if (component.computed.hasOwnProperty(ident)
                                    && !computedNamesIndex[ident]
                                ) {
                                    computedNamesIndex[ident] = 1;
                                    computedNamesCode.unshift('"' + ident + '"');
                                }

                                return compileExprSource.expr(expr);
                            }
                        )
                );
            }
        }
    }
    code.push(computedCode.join(','));
    code.push('},');

    // computed names
    code.push('computedNames: [');
    code.push(computedNamesCode.join(','));
    code.push('],');
    /* eslint-enable no-redeclare */

    // tagName
    code.push('tagName: "' + component.tagName + '"');
    code.push('};');

    return code.join('\n');
}
33804
function(SuperC, args) {
		args = this._breakdown_subs(args);
		return this._extendclass(
			SuperC,
			args.protos,
			args.recurring,
			args.statics,
			args.name
		);
	}