123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- /**
- * @license AngularJS v1.6.5
- * (c) 2010-2017 Google, Inc. http://angularjs.org
- * License: MIT
- */
- (function () {
- 'use strict';
- // NOTE:
- // These functions are copied here from `src/Angular.js`, because they are needed inside the
- // `angular-loader.js` closure and need to be available before the main `angular.js` script has
- // been loaded.
- function isFunction(value) {
- return typeof value === 'function';
- }
- function isDefined(value) {
- return typeof value !== 'undefined';
- }
- function isNumber(value) {
- return typeof value === 'number';
- }
- function isObject(value) {
- return value !== null && typeof value === 'object';
- }
- function isScope(obj) {
- return obj && obj.$evalAsync && obj.$watch;
- }
- function isUndefined(value) {
- return typeof value === 'undefined';
- }
- function isWindow(obj) {
- return obj && obj.window === obj;
- }
- function sliceArgs(args, startIndex) {
- return Array.prototype.slice.call(args, startIndex || 0);
- }
- function toJsonReplacer(key, value) {
- var val = value;
- if (typeof key === 'string' && key.charAt(0) === '$' && key.charAt(1) === '$') {
- val = undefined;
- } else if (isWindow(value)) {
- val = '$WINDOW';
- } else if (value && window.document === value) {
- val = '$DOCUMENT';
- } else if (isScope(value)) {
- val = '$SCOPE';
- }
- return val;
- }
- /* exported toDebugString */
- function serializeObject(obj, maxDepth) {
- var seen = [];
- // There is no direct way to stringify object until reaching a specific depth
- // and a very deep object can cause a performance issue, so we copy the object
- // based on this specific depth and then stringify it.
- if (isValidObjectMaxDepth(maxDepth)) {
- // This file is also included in `angular-loader`, so `copy()` might not always be available in
- // the closure. Therefore, it is lazily retrieved as `angular.copy()` when needed.
- obj = angular.copy(obj, null, maxDepth);
- }
- return JSON.stringify(obj, function (key, val) {
- val = toJsonReplacer(key, val);
- if (isObject(val)) {
- if (seen.indexOf(val) >= 0) return '...';
- seen.push(val);
- }
- return val;
- });
- }
- function toDebugString(obj, maxDepth) {
- if (typeof obj === 'function') {
- return obj.toString().replace(/ \{[\s\S]*$/, '');
- } else if (isUndefined(obj)) {
- return 'undefined';
- } else if (typeof obj !== 'string') {
- return serializeObject(obj, maxDepth);
- }
- return obj;
- }
- /* exported
- minErrConfig,
- errorHandlingConfig,
- isValidObjectMaxDepth
- */
- var minErrConfig = {
- objectMaxDepth: 5
- };
- /**
- * @ngdoc function
- * @name angular.errorHandlingConfig
- * @module ng
- * @kind function
- *
- * @description
- * Configure several aspects of error handling in AngularJS if used as a setter or return the
- * current configuration if used as a getter. The following options are supported:
- *
- * - **objectMaxDepth**: The maximum depth to which objects are traversed when stringified for error messages.
- *
- * Omitted or undefined options will leave the corresponding configuration values unchanged.
- *
- * @param {Object=} config - The configuration object. May only contain the options that need to be
- * updated. Supported keys:
- *
- * * `objectMaxDepth` **{Number}** - The max depth for stringifying objects. Setting to a
- * non-positive or non-numeric value, removes the max depth limit.
- * Default: 5
- */
- function errorHandlingConfig(config) {
- if (isObject(config)) {
- if (isDefined(config.objectMaxDepth)) {
- minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth) ? config.objectMaxDepth : NaN;
- }
- } else {
- return minErrConfig;
- }
- }
- /**
- * @private
- * @param {Number} maxDepth
- * @return {boolean}
- */
- function isValidObjectMaxDepth(maxDepth) {
- return isNumber(maxDepth) && maxDepth > 0;
- }
- /**
- * @description
- *
- * This object provides a utility for producing rich Error messages within
- * Angular. It can be called as follows:
- *
- * var exampleMinErr = minErr('example');
- * throw exampleMinErr('one', 'This {0} is {1}', foo, bar);
- *
- * The above creates an instance of minErr in the example namespace. The
- * resulting error will have a namespaced error code of example.one. The
- * resulting error will replace {0} with the value of foo, and {1} with the
- * value of bar. The object is not restricted in the number of arguments it can
- * take.
- *
- * If fewer arguments are specified than necessary for interpolation, the extra
- * interpolation markers will be preserved in the final string.
- *
- * Since data will be parsed statically during a build step, some restrictions
- * are applied with respect to how minErr instances are created and called.
- * Instances should have names of the form namespaceMinErr for a minErr created
- * using minErr('namespace') . Error codes, namespaces and template strings
- * should all be static strings, not variables or general expressions.
- *
- * @param {string} module The namespace to use for the new minErr instance.
- * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning
- * error from returned function, for cases when a particular type of error is useful.
- * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance
- */
- function minErr(module, ErrorConstructor) {
- ErrorConstructor = ErrorConstructor || Error;
- return function () {
- var code = arguments[0],
- template = arguments[1],
- message = '[' + (module ? module + ':' : '') + code + '] ',
- templateArgs = sliceArgs(arguments, 2).map(function (arg) {
- return toDebugString(arg, minErrConfig.objectMaxDepth);
- }),
- paramPrefix, i;
- message += template.replace(/\{\d+\}/g, function (match) {
- var index = +match.slice(1, -1);
- if (index < templateArgs.length) {
- return templateArgs[index];
- }
- return match;
- });
- message += '\nhttp://errors.angularjs.org/1.6.5/' +
- (module ? module + '/' : '') + code;
- for (i = 0, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
- message += paramPrefix + 'p' + i + '=' + encodeURIComponent(templateArgs[i]);
- }
- return new ErrorConstructor(message);
- };
- }
- /**
- * @ngdoc type
- * @name angular.Module
- * @module ng
- * @description
- *
- * Interface for configuring angular {@link angular.module modules}.
- */
- function setupModuleLoader(window) {
- var $injectorMinErr = minErr('$injector');
- var ngMinErr = minErr('ng');
- function ensure(obj, name, factory) {
- return obj[name] || (obj[name] = factory());
- }
- var angular = ensure(window, 'angular', Object);
- // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
- angular.$$minErr = angular.$$minErr || minErr;
- return ensure(angular, 'module', function () {
- /** @type {Object.<string, angular.Module>} */
- var modules = {};
- /**
- * @ngdoc function
- * @name angular.module
- * @module ng
- * @description
- *
- * The `angular.module` is a global place for creating, registering and retrieving Angular
- * modules.
- * All modules (angular core or 3rd party) that should be available to an application must be
- * registered using this mechanism.
- *
- * Passing one argument retrieves an existing {@link angular.Module},
- * whereas passing more than one argument creates a new {@link angular.Module}
- *
- *
- * # Module
- *
- * A module is a collection of services, directives, controllers, filters, and configuration information.
- * `angular.module` is used to configure the {@link auto.$injector $injector}.
- *
- * ```js
- * // Create a new module
- * var myModule = angular.module('myModule', []);
- *
- * // register a new service
- * myModule.value('appName', 'MyCoolApp');
- *
- * // configure existing services inside initialization blocks.
- * myModule.config(['$locationProvider', function($locationProvider) {
- * // Configure existing providers
- * $locationProvider.hashPrefix('!');
- * }]);
- * ```
- *
- * Then you can create an injector and load your modules like this:
- *
- * ```js
- * var injector = angular.injector(['ng', 'myModule'])
- * ```
- *
- * However it's more likely that you'll just use
- * {@link ng.directive:ngApp ngApp} or
- * {@link angular.bootstrap} to simplify this process for you.
- *
- * @param {!string} name The name of the module to create or retrieve.
- * @param {!Array.<string>=} requires If specified then new module is being created. If
- * unspecified then the module is being retrieved for further configuration.
- * @param {Function=} configFn Optional configuration function for the module. Same as
- * {@link angular.Module#config Module#config()}.
- * @returns {angular.Module} new module with the {@link angular.Module} api.
- */
- return function module(name, requires, configFn) {
- var info = {};
- var assertNotHasOwnProperty = function (name, context) {
- if (name === 'hasOwnProperty') {
- throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
- }
- };
- assertNotHasOwnProperty(name, 'module');
- if (requires && modules.hasOwnProperty(name)) {
- modules[name] = null;
- }
- return ensure(modules, name, function () {
- if (!requires) {
- throw $injectorMinErr('nomod', 'Module \'{0}\' is not available! You either misspelled ' +
- 'the module name or forgot to load it. If registering a module ensure that you ' +
- 'specify the dependencies as the second argument.', name);
- }
- /** @type {!Array.<Array.<*>>} */
- var invokeQueue = [];
- /** @type {!Array.<Function>} */
- var configBlocks = [];
- /** @type {!Array.<Function>} */
- var runBlocks = [];
- var config = invokeLater('$injector', 'invoke', 'push', configBlocks);
- /** @type {angular.Module} */
- var moduleInstance = {
- // Private state
- _invokeQueue: invokeQueue,
- _configBlocks: configBlocks,
- _runBlocks: runBlocks,
- /**
- * @ngdoc method
- * @name angular.Module#info
- * @module ng
- *
- * @param {Object=} info Information about the module
- * @returns {Object|Module} The current info object for this module if called as a getter,
- * or `this` if called as a setter.
- *
- * @description
- * Read and write custom information about this module.
- * For example you could put the version of the module in here.
- *
- * ```js
- * angular.module('myModule', []).info({ version: '1.0.0' });
- * ```
- *
- * The version could then be read back out by accessing the module elsewhere:
- *
- * ```
- * var version = angular.module('myModule').info().version;
- * ```
- *
- * You can also retrieve this information during runtime via the
- * {@link $injector#modules `$injector.modules`} property:
- *
- * ```js
- * var version = $injector.modules['myModule'].info().version;
- * ```
- */
- info: function (value) {
- if (isDefined(value)) {
- if (!isObject(value)) throw ngMinErr('aobj', 'Argument \'{0}\' must be an object', 'value');
- info = value;
- return this;
- }
- return info;
- },
- /**
- * @ngdoc property
- * @name angular.Module#requires
- * @module ng
- *
- * @description
- * Holds the list of modules which the injector will load before the current module is
- * loaded.
- */
- requires: requires,
- /**
- * @ngdoc property
- * @name angular.Module#name
- * @module ng
- *
- * @description
- * Name of the module.
- */
- name: name,
- /**
- * @ngdoc method
- * @name angular.Module#provider
- * @module ng
- * @param {string} name service name
- * @param {Function} providerType Construction function for creating new instance of the
- * service.
- * @description
- * See {@link auto.$provide#provider $provide.provider()}.
- */
- provider: invokeLaterAndSetModuleName('$provide', 'provider'),
- /**
- * @ngdoc method
- * @name angular.Module#factory
- * @module ng
- * @param {string} name service name
- * @param {Function} providerFunction Function for creating new instance of the service.
- * @description
- * See {@link auto.$provide#factory $provide.factory()}.
- */
- factory: invokeLaterAndSetModuleName('$provide', 'factory'),
- /**
- * @ngdoc method
- * @name angular.Module#service
- * @module ng
- * @param {string} name service name
- * @param {Function} constructor A constructor function that will be instantiated.
- * @description
- * See {@link auto.$provide#service $provide.service()}.
- */
- service: invokeLaterAndSetModuleName('$provide', 'service'),
- /**
- * @ngdoc method
- * @name angular.Module#value
- * @module ng
- * @param {string} name service name
- * @param {*} object Service instance object.
- * @description
- * See {@link auto.$provide#value $provide.value()}.
- */
- value: invokeLater('$provide', 'value'),
- /**
- * @ngdoc method
- * @name angular.Module#constant
- * @module ng
- * @param {string} name constant name
- * @param {*} object Constant value.
- * @description
- * Because the constants are fixed, they get applied before other provide methods.
- * See {@link auto.$provide#constant $provide.constant()}.
- */
- constant: invokeLater('$provide', 'constant', 'unshift'),
- /**
- * @ngdoc method
- * @name angular.Module#decorator
- * @module ng
- * @param {string} name The name of the service to decorate.
- * @param {Function} decorFn This function will be invoked when the service needs to be
- * instantiated and should return the decorated service instance.
- * @description
- * See {@link auto.$provide#decorator $provide.decorator()}.
- */
- decorator: invokeLaterAndSetModuleName('$provide', 'decorator', configBlocks),
- /**
- * @ngdoc method
- * @name angular.Module#animation
- * @module ng
- * @param {string} name animation name
- * @param {Function} animationFactory Factory function for creating new instance of an
- * animation.
- * @description
- *
- * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
- *
- *
- * Defines an animation hook that can be later used with
- * {@link $animate $animate} service and directives that use this service.
- *
- * ```js
- * module.animation('.animation-name', function($inject1, $inject2) {
- * return {
- * eventName : function(element, done) {
- * //code to run the animation
- * //once complete, then run done()
- * return function cancellationFunction(element) {
- * //code to cancel the animation
- * }
- * }
- * }
- * })
- * ```
- *
- * See {@link ng.$animateProvider#register $animateProvider.register()} and
- * {@link ngAnimate ngAnimate module} for more information.
- */
- animation: invokeLaterAndSetModuleName('$animateProvider', 'register'),
- /**
- * @ngdoc method
- * @name angular.Module#filter
- * @module ng
- * @param {string} name Filter name - this must be a valid angular expression identifier
- * @param {Function} filterFactory Factory function for creating new instance of filter.
- * @description
- * See {@link ng.$filterProvider#register $filterProvider.register()}.
- *
- * <div class="alert alert-warning">
- * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.
- * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
- * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
- * (`myapp_subsection_filterx`).
- * </div>
- */
- filter: invokeLaterAndSetModuleName('$filterProvider', 'register'),
- /**
- * @ngdoc method
- * @name angular.Module#controller
- * @module ng
- * @param {string|Object} name Controller name, or an object map of controllers where the
- * keys are the names and the values are the constructors.
- * @param {Function} constructor Controller constructor function.
- * @description
- * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
- */
- controller: invokeLaterAndSetModuleName('$controllerProvider', 'register'),
- /**
- * @ngdoc method
- * @name angular.Module#directive
- * @module ng
- * @param {string|Object} name Directive name, or an object map of directives where the
- * keys are the names and the values are the factories.
- * @param {Function} directiveFactory Factory function for creating new instance of
- * directives.
- * @description
- * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
- */
- directive: invokeLaterAndSetModuleName('$compileProvider', 'directive'),
- /**
- * @ngdoc method
- * @name angular.Module#component
- * @module ng
- * @param {string} name Name of the component in camel-case (i.e. myComp which will match as my-comp)
- * @param {Object} options Component definition object (a simplified
- * {@link ng.$compile#directive-definition-object directive definition object})
- *
- * @description
- * See {@link ng.$compileProvider#component $compileProvider.component()}.
- */
- component: invokeLaterAndSetModuleName('$compileProvider', 'component'),
- /**
- * @ngdoc method
- * @name angular.Module#config
- * @module ng
- * @param {Function} configFn Execute this function on module load. Useful for service
- * configuration.
- * @description
- * Use this method to register work which needs to be performed on module loading.
- * For more about how to configure services, see
- * {@link providers#provider-recipe Provider Recipe}.
- */
- config: config,
- /**
- * @ngdoc method
- * @name angular.Module#run
- * @module ng
- * @param {Function} initializationFn Execute this function after injector creation.
- * Useful for application initialization.
- * @description
- * Use this method to register work which should be performed when the injector is done
- * loading all modules.
- */
- run: function (block) {
- runBlocks.push(block);
- return this;
- }
- };
- if (configFn) {
- config(configFn);
- }
- return moduleInstance;
- /**
- * @param {string} provider
- * @param {string} method
- * @param {String=} insertMethod
- * @returns {angular.Module}
- */
- function invokeLater(provider, method, insertMethod, queue) {
- if (!queue) queue = invokeQueue;
- return function () {
- queue[insertMethod || 'push']([provider, method, arguments]);
- return moduleInstance;
- };
- }
- /**
- * @param {string} provider
- * @param {string} method
- * @returns {angular.Module}
- */
- function invokeLaterAndSetModuleName(provider, method, queue) {
- if (!queue) queue = invokeQueue;
- return function (recipeName, factoryFunction) {
- if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name;
- queue.push([provider, method, arguments]);
- return moduleInstance;
- };
- }
- });
- };
- });
- }
- setupModuleLoader(window);
- })(window);
- /**
- * Closure compiler type information
- *
- * @typedef { {
- * requires: !Array.<string>,
- * invokeQueue: !Array.<Array.<*>>,
- *
- * service: function(string, Function):angular.Module,
- * factory: function(string, Function):angular.Module,
- * value: function(string, *):angular.Module,
- *
- * filter: function(string, Function):angular.Module,
- *
- * init: function(Function):angular.Module
- * } }
- */
- angular.Module;
|