webpackJsonp([4],{
/***/ "./node_modules/@angular/common/@angular/common.es5.js":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("./node_modules/@angular/core/@angular/core.es5.js");
/* unused harmony export NgLocaleLocalization */
/* unused harmony export NgLocalization */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CommonModule; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return NgClass; });
/* unused harmony export NgFor */
/* unused harmony export NgForOf */
/* unused harmony export NgForOfContext */
/* unused harmony export NgIf */
/* unused harmony export NgIfContext */
/* unused harmony export NgPlural */
/* unused harmony export NgPluralCase */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return NgStyle; });
/* unused harmony export NgSwitch */
/* unused harmony export NgSwitchCase */
/* unused harmony export NgSwitchDefault */
/* unused harmony export NgTemplateOutlet */
/* unused harmony export NgComponentOutlet */
/* unused harmony export AsyncPipe */
/* unused harmony export DatePipe */
/* unused harmony export I18nPluralPipe */
/* unused harmony export I18nSelectPipe */
/* unused harmony export JsonPipe */
/* unused harmony export LowerCasePipe */
/* unused harmony export CurrencyPipe */
/* unused harmony export DecimalPipe */
/* unused harmony export PercentPipe */
/* unused harmony export SlicePipe */
/* unused harmony export UpperCasePipe */
/* unused harmony export TitleCasePipe */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return PLATFORM_BROWSER_ID; });
/* unused harmony export ɵPLATFORM_SERVER_ID */
/* unused harmony export ɵPLATFORM_WORKER_APP_ID */
/* unused harmony export ɵPLATFORM_WORKER_UI_ID */
/* unused harmony export isPlatformBrowser */
/* unused harmony export isPlatformServer */
/* unused harmony export isPlatformWorkerApp */
/* unused harmony export isPlatformWorkerUi */
/* unused harmony export VERSION */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return PlatformLocation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return LOCATION_INITIALIZED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return LocationStrategy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return APP_BASE_HREF; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return HashLocationStrategy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return PathLocationStrategy; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return Location; });
/* unused harmony export ɵa */
/* unused harmony export ɵb */
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* @license Angular v4.1.3
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* This class should not be used directly by an application developer. Instead, use
* {\@link Location}.
*
* `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
* agnostic.
* This means that we can have different implementation of `PlatformLocation` for the different
* platforms that angular supports. For example, `\@angular/platform-browser` provides an
* implementation specific to the browser environment, while `\@angular/platform-webworker` provides
* one suitable for use with web workers.
*
* The `PlatformLocation` class is used directly by all implementations of {\@link LocationStrategy}
* when they need to interact with the DOM apis like pushState, popState, etc...
*
* {\@link LocationStrategy} in turn is used by the {\@link Location} service which is used directly
* by the {\@link Router} in order to navigate between routes. Since all interactions between {\@link
* Router} /
* {\@link Location} / {\@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
* class they are all platform independent.
*
* \@stable
* @abstract
*/
var PlatformLocation = (function () {
function PlatformLocation() {
}
/**
* @abstract
* @return {?}
*/
PlatformLocation.prototype.getBaseHrefFromDOM = function () { };
/**
* @abstract
* @param {?} fn
* @return {?}
*/
PlatformLocation.prototype.onPopState = function (fn) { };
/**
* @abstract
* @param {?} fn
* @return {?}
*/
PlatformLocation.prototype.onHashChange = function (fn) { };
/**
* @abstract
* @return {?}
*/
PlatformLocation.prototype.pathname = function () { };
/**
* @abstract
* @return {?}
*/
PlatformLocation.prototype.search = function () { };
/**
* @abstract
* @return {?}
*/
PlatformLocation.prototype.hash = function () { };
/**
* @abstract
* @param {?} state
* @param {?} title
* @param {?} url
* @return {?}
*/
PlatformLocation.prototype.replaceState = function (state, title, url) { };
/**
* @abstract
* @param {?} state
* @param {?} title
* @param {?} url
* @return {?}
*/
PlatformLocation.prototype.pushState = function (state, title, url) { };
/**
* @abstract
* @return {?}
*/
PlatformLocation.prototype.forward = function () { };
/**
* @abstract
* @return {?}
*/
PlatformLocation.prototype.back = function () { };
return PlatformLocation;
}());
/**
* \@whatItDoes indicates when a location is initialized
* \@experimental
*/
var LOCATION_INITIALIZED = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["h" /* InjectionToken */]('Location Initialized');
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* `LocationStrategy` is responsible for representing and reading route state
* from the browser's URL. Angular provides two strategies:
* {\@link HashLocationStrategy} and {\@link PathLocationStrategy}.
*
* This is used under the hood of the {\@link Location} service.
*
* Applications should use the {\@link Router} or {\@link Location} services to
* interact with application route state.
*
* For instance, {\@link HashLocationStrategy} produces URLs like
* `http://example.com#/foo`, and {\@link PathLocationStrategy} produces
* `http://example.com/foo` as an equivalent URL.
*
* See these two classes for more.
*
* \@stable
* @abstract
*/
var LocationStrategy = (function () {
function LocationStrategy() {
}
/**
* @abstract
* @param {?=} includeHash
* @return {?}
*/
LocationStrategy.prototype.path = function (includeHash) { };
/**
* @abstract
* @param {?} internal
* @return {?}
*/
LocationStrategy.prototype.prepareExternalUrl = function (internal) { };
/**
* @abstract
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
LocationStrategy.prototype.pushState = function (state, title, url, queryParams) { };
/**
* @abstract
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
LocationStrategy.prototype.replaceState = function (state, title, url, queryParams) { };
/**
* @abstract
* @return {?}
*/
LocationStrategy.prototype.forward = function () { };
/**
* @abstract
* @return {?}
*/
LocationStrategy.prototype.back = function () { };
/**
* @abstract
* @param {?} fn
* @return {?}
*/
LocationStrategy.prototype.onPopState = function (fn) { };
/**
* @abstract
* @return {?}
*/
LocationStrategy.prototype.getBaseHref = function () { };
return LocationStrategy;
}());
/**
* The `APP_BASE_HREF` token represents the base href to be used with the
* {\@link PathLocationStrategy}.
*
* If you're using {\@link PathLocationStrategy}, you must provide a provider to a string
* representing the URL prefix that should be preserved when generating and recognizing
* URLs.
*
* ### Example
*
* ```typescript
* import {Component, NgModule} from '\@angular/core';
* import {APP_BASE_HREF} from '\@angular/common';
*
* \@NgModule({
* providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
* })
* class AppModule {}
* ```
*
* \@stable
*/
var APP_BASE_HREF = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["h" /* InjectionToken */]('appBaseHref');
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes `Location` is a service that applications can use to interact with a browser's URL.
* \@description
* Depending on which {\@link LocationStrategy} is used, `Location` will either persist
* to the URL's path or the URL's hash segment.
*
* Note: it's better to use {\@link Router#navigate} service to trigger route changes. Use
* `Location` only if you need to interact with or create normalized URLs outside of
* routing.
*
* `Location` is responsible for normalizing the URL against the application's base href.
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
* trailing slash:
* - `/my/app/user/123` is normalized
* - `my/app/user/123` **is not** normalized
* - `/my/app/user/123/` **is not** normalized
*
* ### Example
* {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
* \@stable
*/
var Location = (function () {
/**
* @param {?} platformStrategy
*/
function Location(platformStrategy) {
var _this = this;
/**
* \@internal
*/
this._subject = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["H" /* EventEmitter */]();
this._platformStrategy = platformStrategy;
var browserBaseHref = this._platformStrategy.getBaseHref();
this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
this._platformStrategy.onPopState(function (ev) {
_this._subject.emit({
'url': _this.path(true),
'pop': true,
'type': ev.type,
});
});
}
/**
* @param {?=} includeHash
* @return {?}
*/
Location.prototype.path = function (includeHash) {
if (includeHash === void 0) { includeHash = false; }
return this.normalize(this._platformStrategy.path(includeHash));
};
/**
* Normalizes the given path and compares to the current normalized path.
* @param {?} path
* @param {?=} query
* @return {?}
*/
Location.prototype.isCurrentPathEqualTo = function (path, query) {
if (query === void 0) { query = ''; }
return this.path() == this.normalize(path + Location.normalizeQueryParams(query));
};
/**
* Given a string representing a URL, returns the normalized URL path without leading or
* trailing slashes.
* @param {?} url
* @return {?}
*/
Location.prototype.normalize = function (url) {
return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
};
/**
* Given a string representing a URL, returns the platform-specific external URL path.
* If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
* before normalizing. This method will also add a hash if `HashLocationStrategy` is
* used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
* @param {?} url
* @return {?}
*/
Location.prototype.prepareExternalUrl = function (url) {
if (url && url[0] !== '/') {
url = '/' + url;
}
return this._platformStrategy.prepareExternalUrl(url);
};
/**
* Changes the browsers URL to the normalized version of the given URL, and pushes a
* new item onto the platform's history.
* @param {?} path
* @param {?=} query
* @return {?}
*/
Location.prototype.go = function (path, query) {
if (query === void 0) { query = ''; }
this._platformStrategy.pushState(null, '', path, query);
};
/**
* Changes the browsers URL to the normalized version of the given URL, and replaces
* the top item on the platform's history stack.
* @param {?} path
* @param {?=} query
* @return {?}
*/
Location.prototype.replaceState = function (path, query) {
if (query === void 0) { query = ''; }
this._platformStrategy.replaceState(null, '', path, query);
};
/**
* Navigates forward in the platform's history.
* @return {?}
*/
Location.prototype.forward = function () { this._platformStrategy.forward(); };
/**
* Navigates back in the platform's history.
* @return {?}
*/
Location.prototype.back = function () { this._platformStrategy.back(); };
/**
* Subscribe to the platform's `popState` events.
* @param {?} onNext
* @param {?=} onThrow
* @param {?=} onReturn
* @return {?}
*/
Location.prototype.subscribe = function (onNext, onThrow, onReturn) {
return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn });
};
/**
* Given a string of url parameters, prepend with '?' if needed, otherwise return parameters as
* is.
* @param {?} params
* @return {?}
*/
Location.normalizeQueryParams = function (params) {
return params && params[0] !== '?' ? '?' + params : params;
};
/**
* Given 2 parts of a url, join them with a slash if needed.
* @param {?} start
* @param {?} end
* @return {?}
*/
Location.joinWithSlash = function (start, end) {
if (start.length == 0) {
return end;
}
if (end.length == 0) {
return start;
}
var /** @type {?} */ slashes = 0;
if (start.endsWith('/')) {
slashes++;
}
if (end.startsWith('/')) {
slashes++;
}
if (slashes == 2) {
return start + end.substring(1);
}
if (slashes == 1) {
return start + end;
}
return start + '/' + end;
};
/**
* If url has a trailing slash, remove it, otherwise return url as is.
* @param {?} url
* @return {?}
*/
Location.stripTrailingSlash = function (url) { return url.replace(/\/$/, ''); };
return Location;
}());
Location.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["d" /* Injectable */] },
];
/**
* @nocollapse
*/
Location.ctorParameters = function () { return [
{ type: LocationStrategy, },
]; };
/**
* @param {?} baseHref
* @param {?} url
* @return {?}
*/
function _stripBaseHref(baseHref, url) {
return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url;
}
/**
* @param {?} url
* @return {?}
*/
function _stripIndexHtml(url) {
return url.replace(/\/index.html$/, '');
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Use URL hash for storing application location data.
* \@description
* `HashLocationStrategy` is a {\@link LocationStrategy} used to configure the
* {\@link Location} service to represent its state in the
* [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
* of the browser's URL.
*
* For instance, if you call `location.go('/foo')`, the browser's URL will become
* `example.com#/foo`.
*
* ### Example
*
* {\@example common/location/ts/hash_location_component.ts region='LocationComponent'}
*
* \@stable
*/
var HashLocationStrategy = (function (_super) {
__extends(HashLocationStrategy, _super);
/**
* @param {?} _platformLocation
* @param {?=} _baseHref
*/
function HashLocationStrategy(_platformLocation, _baseHref) {
var _this = _super.call(this) || this;
_this._platformLocation = _platformLocation;
_this._baseHref = '';
if (_baseHref != null) {
_this._baseHref = _baseHref;
}
return _this;
}
/**
* @param {?} fn
* @return {?}
*/
HashLocationStrategy.prototype.onPopState = function (fn) {
this._platformLocation.onPopState(fn);
this._platformLocation.onHashChange(fn);
};
/**
* @return {?}
*/
HashLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
/**
* @param {?=} includeHash
* @return {?}
*/
HashLocationStrategy.prototype.path = function (includeHash) {
if (includeHash === void 0) { includeHash = false; }
// the hash value is always prefixed with a `#`
// and if it is empty then it will stay empty
var /** @type {?} */ path = this._platformLocation.hash;
if (path == null)
path = '#';
return path.length > 0 ? path.substring(1) : path;
};
/**
* @param {?} internal
* @return {?}
*/
HashLocationStrategy.prototype.prepareExternalUrl = function (internal) {
var /** @type {?} */ url = Location.joinWithSlash(this._baseHref, internal);
return url.length > 0 ? ('#' + url) : url;
};
/**
* @param {?} state
* @param {?} title
* @param {?} path
* @param {?} queryParams
* @return {?}
*/
HashLocationStrategy.prototype.pushState = function (state, title, path, queryParams) {
var /** @type {?} */ url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
if (url.length == 0) {
url = this._platformLocation.pathname;
}
this._platformLocation.pushState(state, title, url);
};
/**
* @param {?} state
* @param {?} title
* @param {?} path
* @param {?} queryParams
* @return {?}
*/
HashLocationStrategy.prototype.replaceState = function (state, title, path, queryParams) {
var /** @type {?} */ url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
if (url.length == 0) {
url = this._platformLocation.pathname;
}
this._platformLocation.replaceState(state, title, url);
};
/**
* @return {?}
*/
HashLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
/**
* @return {?}
*/
HashLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
return HashLocationStrategy;
}(LocationStrategy));
HashLocationStrategy.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["d" /* Injectable */] },
];
/**
* @nocollapse
*/
HashLocationStrategy.ctorParameters = function () { return [
{ type: PlatformLocation, },
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Optional */] }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [APP_BASE_HREF,] },] },
]; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@whatItDoes Use URL for storing application location data.
* \@description
* `PathLocationStrategy` is a {\@link LocationStrategy} used to configure the
* {\@link Location} service to represent its state in the
* [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
* browser's URL.
*
* If you're using `PathLocationStrategy`, you must provide a {\@link APP_BASE_HREF}
* or add a base element to the document. This URL prefix that will be preserved
* when generating and recognizing URLs.
*
* For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
* `location.go('/foo')`, the browser's URL will become
* `example.com/my/app/foo`.
*
* Similarly, if you add `` to the document and call
* `location.go('/foo')`, the browser's URL will become
* `example.com/my/app/foo`.
*
* ### Example
*
* {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
*
* \@stable
*/
var PathLocationStrategy = (function (_super) {
__extends(PathLocationStrategy, _super);
/**
* @param {?} _platformLocation
* @param {?=} href
*/
function PathLocationStrategy(_platformLocation, href) {
var _this = _super.call(this) || this;
_this._platformLocation = _platformLocation;
if (href == null) {
href = _this._platformLocation.getBaseHrefFromDOM();
}
if (href == null) {
throw new Error("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
}
_this._baseHref = href;
return _this;
}
/**
* @param {?} fn
* @return {?}
*/
PathLocationStrategy.prototype.onPopState = function (fn) {
this._platformLocation.onPopState(fn);
this._platformLocation.onHashChange(fn);
};
/**
* @return {?}
*/
PathLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
/**
* @param {?} internal
* @return {?}
*/
PathLocationStrategy.prototype.prepareExternalUrl = function (internal) {
return Location.joinWithSlash(this._baseHref, internal);
};
/**
* @param {?=} includeHash
* @return {?}
*/
PathLocationStrategy.prototype.path = function (includeHash) {
if (includeHash === void 0) { includeHash = false; }
var /** @type {?} */ pathname = this._platformLocation.pathname +
Location.normalizeQueryParams(this._platformLocation.search);
var /** @type {?} */ hash = this._platformLocation.hash;
return hash && includeHash ? "" + pathname + hash : pathname;
};
/**
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
PathLocationStrategy.prototype.pushState = function (state, title, url, queryParams) {
var /** @type {?} */ externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
this._platformLocation.pushState(state, title, externalUrl);
};
/**
* @param {?} state
* @param {?} title
* @param {?} url
* @param {?} queryParams
* @return {?}
*/
PathLocationStrategy.prototype.replaceState = function (state, title, url, queryParams) {
var /** @type {?} */ externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
this._platformLocation.replaceState(state, title, externalUrl);
};
/**
* @return {?}
*/
PathLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
/**
* @return {?}
*/
PathLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
return PathLocationStrategy;
}(LocationStrategy));
PathLocationStrategy.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["d" /* Injectable */] },
];
/**
* @nocollapse
*/
PathLocationStrategy.ctorParameters = function () { return [
{ type: PlatformLocation, },
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Optional */] }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [APP_BASE_HREF,] },] },
]; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@experimental
* @abstract
*/
var NgLocalization = (function () {
function NgLocalization() {
}
/**
* @abstract
* @param {?} value
* @return {?}
*/
NgLocalization.prototype.getPluralCategory = function (value) { };
return NgLocalization;
}());
/**
* Returns the plural category for a given value.
* - "=value" when the case exists,
* - the plural category otherwise
*
* \@internal
* @param {?} value
* @param {?} cases
* @param {?} ngLocalization
* @return {?}
*/
function getPluralCategory(value, cases, ngLocalization) {
var /** @type {?} */ key = "=" + value;
if (cases.indexOf(key) > -1) {
return key;
}
key = ngLocalization.getPluralCategory(value);
if (cases.indexOf(key) > -1) {
return key;
}
if (cases.indexOf('other') > -1) {
return 'other';
}
throw new Error("No plural message found for value \"" + value + "\"");
}
/**
* Returns the plural case based on the locale
*
* \@experimental
*/
var NgLocaleLocalization = (function (_super) {
__extends(NgLocaleLocalization, _super);
/**
* @param {?} locale
*/
function NgLocaleLocalization(locale) {
var _this = _super.call(this) || this;
_this.locale = locale;
return _this;
}
/**
* @param {?} value
* @return {?}
*/
NgLocaleLocalization.prototype.getPluralCategory = function (value) {
var /** @type {?} */ plural = getPluralCase(this.locale, value);
switch (plural) {
case Plural.Zero:
return 'zero';
case Plural.One:
return 'one';
case Plural.Two:
return 'two';
case Plural.Few:
return 'few';
case Plural.Many:
return 'many';
default:
return 'other';
}
};
return NgLocaleLocalization;
}(NgLocalization));
NgLocaleLocalization.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["d" /* Injectable */] },
];
/**
* @nocollapse
*/
NgLocaleLocalization.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["I" /* LOCALE_ID */],] },] },
]; };
var Plural = {};
Plural.Zero = 0;
Plural.One = 1;
Plural.Two = 2;
Plural.Few = 3;
Plural.Many = 4;
Plural.Other = 5;
Plural[Plural.Zero] = "Zero";
Plural[Plural.One] = "One";
Plural[Plural.Two] = "Two";
Plural[Plural.Few] = "Few";
Plural[Plural.Many] = "Many";
Plural[Plural.Other] = "Other";
/**
* Returns the plural case based on the locale
*
* \@experimental
* @param {?} locale
* @param {?} nLike
* @return {?}
*/
function getPluralCase(locale, nLike) {
// TODO(vicb): lazy compute
if (typeof nLike === 'string') {
nLike = parseInt(/** @type {?} */ (nLike), 10);
}
var /** @type {?} */ n = (nLike);
var /** @type {?} */ nDecimal = n.toString().replace(/^[^.]*\.?/, '');
var /** @type {?} */ i = Math.floor(Math.abs(n));
var /** @type {?} */ v = nDecimal.length;
var /** @type {?} */ f = parseInt(nDecimal, 10);
var /** @type {?} */ t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0;
var /** @type {?} */ lang = locale.split('-')[0].toLowerCase();
switch (lang) {
case 'af':
case 'asa':
case 'az':
case 'bem':
case 'bez':
case 'bg':
case 'brx':
case 'ce':
case 'cgg':
case 'chr':
case 'ckb':
case 'ee':
case 'el':
case 'eo':
case 'es':
case 'eu':
case 'fo':
case 'fur':
case 'gsw':
case 'ha':
case 'haw':
case 'hu':
case 'jgo':
case 'jmc':
case 'ka':
case 'kk':
case 'kkj':
case 'kl':
case 'ks':
case 'ksb':
case 'ky':
case 'lb':
case 'lg':
case 'mas':
case 'mgo':
case 'ml':
case 'mn':
case 'nb':
case 'nd':
case 'ne':
case 'nn':
case 'nnh':
case 'nyn':
case 'om':
case 'or':
case 'os':
case 'ps':
case 'rm':
case 'rof':
case 'rwk':
case 'saq':
case 'seh':
case 'sn':
case 'so':
case 'sq':
case 'ta':
case 'te':
case 'teo':
case 'tk':
case 'tr':
case 'ug':
case 'uz':
case 'vo':
case 'vun':
case 'wae':
case 'xog':
if (n === 1)
return Plural.One;
return Plural.Other;
case 'agq':
case 'bas':
case 'cu':
case 'dav':
case 'dje':
case 'dua':
case 'dyo':
case 'ebu':
case 'ewo':
case 'guz':
case 'kam':
case 'khq':
case 'ki':
case 'kln':
case 'kok':
case 'ksf':
case 'lrc':
case 'lu':
case 'luo':
case 'luy':
case 'mer':
case 'mfe':
case 'mgh':
case 'mua':
case 'mzn':
case 'nmg':
case 'nus':
case 'qu':
case 'rn':
case 'rw':
case 'sbp':
case 'twq':
case 'vai':
case 'yav':
case 'yue':
case 'zgh':
case 'ak':
case 'ln':
case 'mg':
case 'pa':
case 'ti':
if (n === Math.floor(n) && n >= 0 && n <= 1)
return Plural.One;
return Plural.Other;
case 'am':
case 'as':
case 'bn':
case 'fa':
case 'gu':
case 'hi':
case 'kn':
case 'mr':
case 'zu':
if (i === 0 || n === 1)
return Plural.One;
return Plural.Other;
case 'ar':
if (n === 0)
return Plural.Zero;
if (n === 1)
return Plural.One;
if (n === 2)
return Plural.Two;
if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10)
return Plural.Few;
if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99)
return Plural.Many;
return Plural.Other;
case 'ast':
case 'ca':
case 'de':
case 'en':
case 'et':
case 'fi':
case 'fy':
case 'gl':
case 'it':
case 'nl':
case 'sv':
case 'sw':
case 'ur':
case 'yi':
if (i === 1 && v === 0)
return Plural.One;
return Plural.Other;
case 'be':
if (n % 10 === 1 && !(n % 100 === 11))
return Plural.One;
if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 &&
!(n % 100 >= 12 && n % 100 <= 14))
return Plural.Few;
if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 ||
n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14)
return Plural.Many;
return Plural.Other;
case 'br':
if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91))
return Plural.One;
if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92))
return Plural.Two;
if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) &&
!(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 ||
n % 100 >= 90 && n % 100 <= 99))
return Plural.Few;
if (!(n === 0) && n % 1e6 === 0)
return Plural.Many;
return Plural.Other;
case 'bs':
case 'hr':
case 'sr':
if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11))
return Plural.One;
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
!(i % 100 >= 12 && i % 100 <= 14) ||
f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 &&
!(f % 100 >= 12 && f % 100 <= 14))
return Plural.Few;
return Plural.Other;
case 'cs':
case 'sk':
if (i === 1 && v === 0)
return Plural.One;
if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0)
return Plural.Few;
if (!(v === 0))
return Plural.Many;
return Plural.Other;
case 'cy':
if (n === 0)
return Plural.Zero;
if (n === 1)
return Plural.One;
if (n === 2)
return Plural.Two;
if (n === 3)
return Plural.Few;
if (n === 6)
return Plural.Many;
return Plural.Other;
case 'da':
if (n === 1 || !(t === 0) && (i === 0 || i === 1))
return Plural.One;
return Plural.Other;
case 'dsb':
case 'hsb':
if (v === 0 && i % 100 === 1 || f % 100 === 1)
return Plural.One;
if (v === 0 && i % 100 === 2 || f % 100 === 2)
return Plural.Two;
if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 ||
f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4)
return Plural.Few;
return Plural.Other;
case 'ff':
case 'fr':
case 'hy':
case 'kab':
if (i === 0 || i === 1)
return Plural.One;
return Plural.Other;
case 'fil':
if (v === 0 && (i === 1 || i === 2 || i === 3) ||
v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) ||
!(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9))
return Plural.One;
return Plural.Other;
case 'ga':
if (n === 1)
return Plural.One;
if (n === 2)
return Plural.Two;
if (n === Math.floor(n) && n >= 3 && n <= 6)
return Plural.Few;
if (n === Math.floor(n) && n >= 7 && n <= 10)
return Plural.Many;
return Plural.Other;
case 'gd':
if (n === 1 || n === 11)
return Plural.One;
if (n === 2 || n === 12)
return Plural.Two;
if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19))
return Plural.Few;
return Plural.Other;
case 'gv':
if (v === 0 && i % 10 === 1)
return Plural.One;
if (v === 0 && i % 10 === 2)
return Plural.Two;
if (v === 0 &&
(i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80))
return Plural.Few;
if (!(v === 0))
return Plural.Many;
return Plural.Other;
case 'he':
if (i === 1 && v === 0)
return Plural.One;
if (i === 2 && v === 0)
return Plural.Two;
if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0)
return Plural.Many;
return Plural.Other;
case 'is':
if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0))
return Plural.One;
return Plural.Other;
case 'ksh':
if (n === 0)
return Plural.Zero;
if (n === 1)
return Plural.One;
return Plural.Other;
case 'kw':
case 'naq':
case 'se':
case 'smn':
if (n === 1)
return Plural.One;
if (n === 2)
return Plural.Two;
return Plural.Other;
case 'lag':
if (n === 0)
return Plural.Zero;
if ((i === 0 || i === 1) && !(n === 0))
return Plural.One;
return Plural.Other;
case 'lt':
if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19))
return Plural.One;
if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 &&
!(n % 100 >= 11 && n % 100 <= 19))
return Plural.Few;
if (!(f === 0))
return Plural.Many;
return Plural.Other;
case 'lv':
case 'prg':
if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 ||
v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19)
return Plural.Zero;
if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) ||
!(v === 2) && f % 10 === 1)
return Plural.One;
return Plural.Other;
case 'mk':
if (v === 0 && i % 10 === 1 || f % 10 === 1)
return Plural.One;
return Plural.Other;
case 'mt':
if (n === 1)
return Plural.One;
if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10)
return Plural.Few;
if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19)
return Plural.Many;
return Plural.Other;
case 'pl':
if (i === 1 && v === 0)
return Plural.One;
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
!(i % 100 >= 12 && i % 100 <= 14))
return Plural.Few;
if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 ||
v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14)
return Plural.Many;
return Plural.Other;
case 'pt':
if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2))
return Plural.One;
return Plural.Other;
case 'ro':
if (i === 1 && v === 0)
return Plural.One;
if (!(v === 0) || n === 0 ||
!(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19)
return Plural.Few;
return Plural.Other;
case 'ru':
case 'uk':
if (v === 0 && i % 10 === 1 && !(i % 100 === 11))
return Plural.One;
if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
!(i % 100 >= 12 && i % 100 <= 14))
return Plural.Few;
if (v === 0 && i % 10 === 0 ||
v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14)
return Plural.Many;
return Plural.Other;
case 'shi':
if (i === 0 || n === 1)
return Plural.One;
if (n === Math.floor(n) && n >= 2 && n <= 10)
return Plural.Few;
return Plural.Other;
case 'si':
if (n === 0 || n === 1 || i === 0 && f === 1)
return Plural.One;
return Plural.Other;
case 'sl':
if (v === 0 && i % 100 === 1)
return Plural.One;
if (v === 0 && i % 100 === 2)
return Plural.Two;
if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0))
return Plural.Few;
return Plural.Other;
case 'tzm':
if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99)
return Plural.One;
return Plural.Other;
default:
return Plural.Other;
}
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Adds and removes CSS classes on an HTML element.
*
* \@howToUse
* ```
* ...
*
* ...
*
* ...
*
* ...
*
* ...
* ```
*
* \@description
*
* The CSS classes are updated as follows, depending on the type of the expression evaluation:
* - `string` - the CSS classes listed in the string (space delimited) are added,
* - `Array` - the CSS classes declared as Array elements are added,
* - `Object` - keys are CSS classes that get added when the expression given in the value
* evaluates to a truthy value, otherwise they are removed.
*
* \@stable
*/
var NgClass = (function () {
/**
* @param {?} _iterableDiffers
* @param {?} _keyValueDiffers
* @param {?} _ngEl
* @param {?} _renderer
*/
function NgClass(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
this._iterableDiffers = _iterableDiffers;
this._keyValueDiffers = _keyValueDiffers;
this._ngEl = _ngEl;
this._renderer = _renderer;
this._initialClasses = [];
}
Object.defineProperty(NgClass.prototype, "klass", {
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
this._applyInitialClasses(true);
this._initialClasses = typeof v === 'string' ? v.split(/\s+/) : [];
this._applyInitialClasses(false);
this._applyClasses(this._rawClass, false);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgClass.prototype, "ngClass", {
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
this._cleanupClasses(this._rawClass);
this._iterableDiffer = null;
this._keyValueDiffer = null;
this._rawClass = typeof v === 'string' ? v.split(/\s+/) : v;
if (this._rawClass) {
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["J" /* ɵisListLikeIterable */])(this._rawClass)) {
this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create();
}
else {
this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create();
}
}
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgClass.prototype.ngDoCheck = function () {
if (this._iterableDiffer) {
var /** @type {?} */ iterableChanges = this._iterableDiffer.diff(/** @type {?} */ (this._rawClass));
if (iterableChanges) {
this._applyIterableChanges(iterableChanges);
}
}
else if (this._keyValueDiffer) {
var /** @type {?} */ keyValueChanges = this._keyValueDiffer.diff(/** @type {?} */ (this._rawClass));
if (keyValueChanges) {
this._applyKeyValueChanges(keyValueChanges);
}
}
};
/**
* @param {?} rawClassVal
* @return {?}
*/
NgClass.prototype._cleanupClasses = function (rawClassVal) {
this._applyClasses(rawClassVal, true);
this._applyInitialClasses(false);
};
/**
* @param {?} changes
* @return {?}
*/
NgClass.prototype._applyKeyValueChanges = function (changes) {
var _this = this;
changes.forEachAddedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
changes.forEachChangedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
changes.forEachRemovedItem(function (record) {
if (record.previousValue) {
_this._toggleClass(record.key, false);
}
});
};
/**
* @param {?} changes
* @return {?}
*/
NgClass.prototype._applyIterableChanges = function (changes) {
var _this = this;
changes.forEachAddedItem(function (record) {
if (typeof record.item === 'string') {
_this._toggleClass(record.item, true);
}
else {
throw new Error("NgClass can only toggle CSS classes expressed as strings, got " + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["K" /* ɵstringify */])(record.item));
}
});
changes.forEachRemovedItem(function (record) { return _this._toggleClass(record.item, false); });
};
/**
* @param {?} isCleanup
* @return {?}
*/
NgClass.prototype._applyInitialClasses = function (isCleanup) {
var _this = this;
this._initialClasses.forEach(function (klass) { return _this._toggleClass(klass, !isCleanup); });
};
/**
* @param {?} rawClassVal
* @param {?} isCleanup
* @return {?}
*/
NgClass.prototype._applyClasses = function (rawClassVal, isCleanup) {
var _this = this;
if (rawClassVal) {
if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
((rawClassVal)).forEach(function (klass) { return _this._toggleClass(klass, !isCleanup); });
}
else {
Object.keys(rawClassVal).forEach(function (klass) {
if (rawClassVal[klass] != null)
_this._toggleClass(klass, !isCleanup);
});
}
}
};
/**
* @param {?} klass
* @param {?} enabled
* @return {?}
*/
NgClass.prototype._toggleClass = function (klass, enabled) {
var _this = this;
klass = klass.trim();
if (klass) {
klass.split(/\s+/g).forEach(function (klass) { _this._renderer.setElementClass(_this._ngEl.nativeElement, klass, !!enabled); });
}
};
return NgClass;
}());
NgClass.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngClass]' },] },
];
/**
* @nocollapse
*/
NgClass.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["M" /* IterableDiffers */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["N" /* KeyValueDiffers */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* ElementRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["P" /* Renderer */], },
]; };
NgClass.propDecorators = {
'klass': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */], args: ['class',] },],
'ngClass': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Instantiates a single {\@link Component} type and inserts its Host View into current View.
* `NgComponentOutlet` provides a declarative approach for dynamic component creation.
*
* `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
* any existing component will get destroyed.
*
* ### Fine tune control
*
* You can control the component creation process by using the following optional attributes:
*
* * `ngComponentOutletInjector`: Optional custom {\@link Injector} that will be used as parent for
* the Component. Defaults to the injector of the current view container.
*
* * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
* section of the component, if exists.
*
* * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other
* module, then load a component from that module.
*
* ### Syntax
*
* Simple
* ```
*
* ```
*
* Customized injector/content
* ```
*
*
* ```
*
* Customized ngModuleFactory
* ```
*
*
* ```
* ## Example
*
* {\@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
*
* A more complete example with additional options:
*
* {\@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
* A more complete example with ngModuleFactory:
*
* {\@example common/ngComponentOutlet/ts/module.ts region='NgModuleFactoryExample'}
*
* \@experimental
*/
var NgComponentOutlet = (function () {
/**
* @param {?} _viewContainerRef
*/
function NgComponentOutlet(_viewContainerRef) {
this._viewContainerRef = _viewContainerRef;
this._componentRef = null;
this._moduleRef = null;
}
/**
* @param {?} changes
* @return {?}
*/
NgComponentOutlet.prototype.ngOnChanges = function (changes) {
this._viewContainerRef.clear();
this._componentRef = null;
if (this.ngComponentOutlet) {
var /** @type {?} */ elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
if (changes['ngComponentOutletNgModuleFactory']) {
if (this._moduleRef)
this._moduleRef.destroy();
if (this.ngComponentOutletNgModuleFactory) {
var /** @type {?} */ parentModule = elInjector.get(__WEBPACK_IMPORTED_MODULE_0__angular_core__["R" /* NgModuleRef */]);
this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector);
}
else {
this._moduleRef = null;
}
}
var /** @type {?} */ componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver :
elInjector.get(__WEBPACK_IMPORTED_MODULE_0__angular_core__["S" /* ComponentFactoryResolver */]);
var /** @type {?} */ componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet);
this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent);
}
};
/**
* @return {?}
*/
NgComponentOutlet.prototype.ngOnDestroy = function () {
if (this._moduleRef)
this._moduleRef.destroy();
};
return NgComponentOutlet;
}());
NgComponentOutlet.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngComponentOutlet]' },] },
];
/**
* @nocollapse
*/
NgComponentOutlet.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */], },
]; };
NgComponentOutlet.propDecorators = {
'ngComponentOutlet': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngComponentOutletInjector': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngComponentOutletContent': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngComponentOutletNgModuleFactory': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@stable
*/
var NgForOfContext = (function () {
/**
* @param {?} $implicit
* @param {?} ngForOf
* @param {?} index
* @param {?} count
*/
function NgForOfContext($implicit, ngForOf, index, count) {
this.$implicit = $implicit;
this.ngForOf = ngForOf;
this.index = index;
this.count = count;
}
Object.defineProperty(NgForOfContext.prototype, "first", {
/**
* @return {?}
*/
get: function () { return this.index === 0; },
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOfContext.prototype, "last", {
/**
* @return {?}
*/
get: function () { return this.index === this.count - 1; },
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOfContext.prototype, "even", {
/**
* @return {?}
*/
get: function () { return this.index % 2 === 0; },
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOfContext.prototype, "odd", {
/**
* @return {?}
*/
get: function () { return !this.even; },
enumerable: true,
configurable: true
});
return NgForOfContext;
}());
/**
* The `NgForOf` directive instantiates a template once per item from an iterable. The context
* for each instantiated template inherits from the outer context with the given loop variable
* set to the current item from the iterable.
*
* ### Local Variables
*
* `NgForOf` provides several exported values that can be aliased to local variables:
*
* - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
* - `ngForOf: NgIterable`: The value of the iterable expression. Useful when the expression is
* more complex then a property access, for example when using the async pipe (`userStreams |
* async`).
* - `index: number`: The index of the current item in the iterable.
* - `first: boolean`: True when the item is the first item in the iterable.
* - `last: boolean`: True when the item is the last item in the iterable.
* - `even: boolean`: True when the item has an even index in the iterable.
* - `odd: boolean`: True when the item has an odd index in the iterable.
*
* ```
*
* {{i}}/{{users.length}}. {{user}} default
*
* ```
*
* ### Change Propagation
*
* When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
*
* * When an item is added, a new instance of the template is added to the DOM.
* * When an item is removed, its template instance is removed from the DOM.
* * When items are reordered, their respective templates are reordered in the DOM.
* * Otherwise, the DOM element for that item will remain the same.
*
* Angular uses object identity to track insertions and deletions within the iterator and reproduce
* those changes in the DOM. This has important implications for animations and any stateful
* controls (such as `` elements which accept user input) that are present. Inserted rows can
* be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
* such as user input.
*
* It is possible for the identities of elements in the iterator to change while the data does not.
* This can happen, for example, if the iterator produced from an RPC to the server, and that
* RPC is re-run. Even if the data hasn't changed, the second response will produce objects with
* different identities, and Angular will tear down the entire DOM and rebuild it (as if all old
* elements were deleted and all new elements inserted). This is an expensive operation and should
* be avoided if possible.
*
* To customize the default tracking algorithm, `NgForOf` supports `trackBy` option.
* `trackBy` takes a function which has two arguments: `index` and `item`.
* If `trackBy` is given, Angular tracks changes by the return value of the function.
*
* ### Syntax
*
* - `
...
`
* - `
...
`
*
* With `` element:
*
* ```
*
*
...
*
* ```
*
* ### Example
*
* See a [live demo](http://plnkr.co/edit/KVuXxDp0qinGDyo307QW?p=preview) for a more detailed
* example.
*
* \@stable
*/
var NgForOf = (function () {
/**
* @param {?} _viewContainer
* @param {?} _template
* @param {?} _differs
*/
function NgForOf(_viewContainer, _template, _differs) {
this._viewContainer = _viewContainer;
this._template = _template;
this._differs = _differs;
this._differ = null;
}
Object.defineProperty(NgForOf.prototype, "ngForTrackBy", {
/**
* @return {?}
*/
get: function () { return this._trackByFn; },
/**
* @param {?} fn
* @return {?}
*/
set: function (fn) {
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["u" /* isDevMode */])() && fn != null && typeof fn !== 'function') {
// TODO(vicb): use a log service once there is a public one available
if ((console) && (console.warn)) {
console.warn("trackBy must be a function, but received " + JSON.stringify(fn) + ". " +
"See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information.");
}
}
this._trackByFn = fn;
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgForOf.prototype, "ngForTemplate", {
/**
* @param {?} value
* @return {?}
*/
set: function (value) {
// TODO(TS2.1): make TemplateRef>> once we move to TS v2.1
// The current type is too restrictive; a template that just uses index, for example,
// should be acceptable.
if (value) {
this._template = value;
}
},
enumerable: true,
configurable: true
});
/**
* @param {?} changes
* @return {?}
*/
NgForOf.prototype.ngOnChanges = function (changes) {
if ('ngForOf' in changes) {
// React on ngForOf changes only once all inputs have been initialized
var /** @type {?} */ value = changes['ngForOf'].currentValue;
if (!this._differ && value) {
try {
this._differ = this._differs.find(value).create(this.ngForTrackBy);
}
catch (e) {
throw new Error("Cannot find a differ supporting object '" + value + "' of type '" + getTypeNameForDebugging(value) + "'. NgFor only supports binding to Iterables such as Arrays.");
}
}
}
};
/**
* @return {?}
*/
NgForOf.prototype.ngDoCheck = function () {
if (this._differ) {
var /** @type {?} */ changes = this._differ.diff(this.ngForOf);
if (changes)
this._applyChanges(changes);
}
};
/**
* @param {?} changes
* @return {?}
*/
NgForOf.prototype._applyChanges = function (changes) {
var _this = this;
var /** @type {?} */ insertTuples = [];
changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) {
if (item.previousIndex == null) {
var /** @type {?} */ view = _this._viewContainer.createEmbeddedView(_this._template, new NgForOfContext(/** @type {?} */ ((null)), _this.ngForOf, -1, -1), currentIndex);
var /** @type {?} */ tuple = new RecordViewTuple(item, view);
insertTuples.push(tuple);
}
else if (currentIndex == null) {
_this._viewContainer.remove(adjustedPreviousIndex);
}
else {
var /** @type {?} */ view = ((_this._viewContainer.get(adjustedPreviousIndex)));
_this._viewContainer.move(view, currentIndex);
var /** @type {?} */ tuple = new RecordViewTuple(item, /** @type {?} */ (view));
insertTuples.push(tuple);
}
});
for (var /** @type {?} */ i = 0; i < insertTuples.length; i++) {
this._perViewChange(insertTuples[i].view, insertTuples[i].record);
}
for (var /** @type {?} */ i = 0, /** @type {?} */ ilen = this._viewContainer.length; i < ilen; i++) {
var /** @type {?} */ viewRef = (this._viewContainer.get(i));
viewRef.context.index = i;
viewRef.context.count = ilen;
}
changes.forEachIdentityChange(function (record) {
var /** @type {?} */ viewRef = (_this._viewContainer.get(record.currentIndex));
viewRef.context.$implicit = record.item;
});
};
/**
* @param {?} view
* @param {?} record
* @return {?}
*/
NgForOf.prototype._perViewChange = function (view, record) {
view.context.$implicit = record.item;
};
return NgForOf;
}());
NgForOf.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngFor][ngForOf]' },] },
];
/**
* @nocollapse
*/
NgForOf.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* TemplateRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["M" /* IterableDiffers */], },
]; };
NgForOf.propDecorators = {
'ngForOf': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngForTrackBy': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngForTemplate': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
var RecordViewTuple = (function () {
/**
* @param {?} record
* @param {?} view
*/
function RecordViewTuple(record, view) {
this.record = record;
this.view = view;
}
return RecordViewTuple;
}());
/**
* @deprecated from v4.0.0 - Use NgForOf instead.
*/
var NgFor = NgForOf;
/**
* @param {?} type
* @return {?}
*/
function getTypeNameForDebugging(type) {
return type['name'] || typeof type;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Conditionally includes a template based on the value of an `expression`.
*
* `ngIf` evaluates the `expression` and then renders the `then` or `else` template in its place
* when expression is truthy or falsy respectively. Typically the:
* - `then` template is the inline template of `ngIf` unless bound to a different value.
* - `else` template is blank unless it is bound.
*
* ## Most common usage
*
* The most common usage of the `ngIf` directive is to conditionally show the inline template as
* seen in this example:
* {\@example common/ngIf/ts/module.ts region='NgIfSimple'}
*
* ## Showing an alternative template using `else`
*
* If it is necessary to display a template when the `expression` is falsy use the `else` template
* binding as shown. Note that the `else` binding points to a `` labeled `#elseBlock`.
* The template can be defined anywhere in the component view but is typically placed right after
* `ngIf` for readability.
*
* {\@example common/ngIf/ts/module.ts region='NgIfElse'}
*
* ## Using non-inlined `then` template
*
* Usually the `then` template is the inlined template of the `ngIf`, but it can be changed using
* a binding (just like `else`). Because `then` and `else` are bindings, the template references can
* change at runtime as shown in this example.
*
* {\@example common/ngIf/ts/module.ts region='NgIfThenElse'}
*
* ## Storing conditional result in a variable
*
* A common pattern is that we need to show a set of properties from the same object. If the
* object is undefined, then we have to use the safe-traversal-operator `?.` to guard against
* dereferencing a `null` value. This is especially the case when waiting on async data such as
* when using the `async` pipe as shown in folowing example:
*
* ```
* Hello {{ (userStream|async)?.last }}, {{ (userStream|async)?.first }}!
* ```
*
* There are several inefficiencies in the above example:
* - We create multiple subscriptions on `userStream`. One for each `async` pipe, or two in the
* example above.
* - We cannot display an alternative screen while waiting for the data to arrive asynchronously.
* - We have to use the safe-traversal-operator `?.` to access properties, which is cumbersome.
* - We have to place the `async` pipe in parenthesis.
*
* A better way to do this is to use `ngIf` and store the result of the condition in a local
* variable as shown in the the example below:
*
* {\@example common/ngIf/ts/module.ts region='NgIfAs'}
*
* Notice that:
* - We use only one `async` pipe and hence only one subscription gets created.
* - `ngIf` stores the result of the `userStream|async` in the local variable `user`.
* - The local `user` can then be bound repeatedly in a more efficient way.
* - No need to use the safe-traversal-operator `?.` to access properties as `ngIf` will only
* display the data if `userStream` returns a value.
* - We can display an alternative template while waiting for the data.
*
* ### Syntax
*
* Simple form:
* - `
...
`
* - `
...
`
* - `
...
`
*
* Form with an else block:
* ```
*
...
* ...
* ```
*
* Form with a `then` and `else` block:
* ```
*
* ...
* ...
* ```
*
* Form with storing the value locally:
* ```
*
{{value}}
* ...
* ```
*
* \@stable
*/
var NgIf = (function () {
/**
* @param {?} _viewContainer
* @param {?} templateRef
*/
function NgIf(_viewContainer, templateRef) {
this._viewContainer = _viewContainer;
this._context = new NgIfContext();
this._thenTemplateRef = null;
this._elseTemplateRef = null;
this._thenViewRef = null;
this._elseViewRef = null;
this._thenTemplateRef = templateRef;
}
Object.defineProperty(NgIf.prototype, "ngIf", {
/**
* @param {?} condition
* @return {?}
*/
set: function (condition) {
this._context.$implicit = this._context.ngIf = condition;
this._updateView();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgIf.prototype, "ngIfThen", {
/**
* @param {?} templateRef
* @return {?}
*/
set: function (templateRef) {
this._thenTemplateRef = templateRef;
this._thenViewRef = null; // clear previous view if any.
this._updateView();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgIf.prototype, "ngIfElse", {
/**
* @param {?} templateRef
* @return {?}
*/
set: function (templateRef) {
this._elseTemplateRef = templateRef;
this._elseViewRef = null; // clear previous view if any.
this._updateView();
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgIf.prototype._updateView = function () {
if (this._context.$implicit) {
if (!this._thenViewRef) {
this._viewContainer.clear();
this._elseViewRef = null;
if (this._thenTemplateRef) {
this._thenViewRef =
this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
}
}
}
else {
if (!this._elseViewRef) {
this._viewContainer.clear();
this._thenViewRef = null;
if (this._elseTemplateRef) {
this._elseViewRef =
this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
}
}
}
};
return NgIf;
}());
NgIf.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngIf]' },] },
];
/**
* @nocollapse
*/
NgIf.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* TemplateRef */], },
]; };
NgIf.propDecorators = {
'ngIf': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngIfThen': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngIfElse': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* \@stable
*/
var NgIfContext = (function () {
function NgIfContext() {
this.$implicit = null;
this.ngIf = null;
}
return NgIfContext;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var SwitchView = (function () {
/**
* @param {?} _viewContainerRef
* @param {?} _templateRef
*/
function SwitchView(_viewContainerRef, _templateRef) {
this._viewContainerRef = _viewContainerRef;
this._templateRef = _templateRef;
this._created = false;
}
/**
* @return {?}
*/
SwitchView.prototype.create = function () {
this._created = true;
this._viewContainerRef.createEmbeddedView(this._templateRef);
};
/**
* @return {?}
*/
SwitchView.prototype.destroy = function () {
this._created = false;
this._viewContainerRef.clear();
};
/**
* @param {?} created
* @return {?}
*/
SwitchView.prototype.enforceState = function (created) {
if (created && !this._created) {
this.create();
}
else if (!created && this._created) {
this.destroy();
}
};
return SwitchView;
}());
/**
* \@ngModule CommonModule
*
* \@whatItDoes Adds / removes DOM sub-trees when the nest match expressions matches the switch
* expression.
*
* \@howToUse
* ```
*
* ...
* ...
* ...
*
*
*
*
*
* ...
*
* ```
* \@description
*
* `NgSwitch` stamps out nested views when their match expression value matches the value of the
* switch expression.
*
* In other words:
* - you define a container element (where you place the directive with a switch expression on the
* `[ngSwitch]="..."` attribute)
* - you define inner views inside the `NgSwitch` and place a `*ngSwitchCase` attribute on the view
* root elements.
*
* Elements within `NgSwitch` but outside of a `NgSwitchCase` or `NgSwitchDefault` directives will
* be preserved at the location.
*
* The `ngSwitchCase` directive informs the parent `NgSwitch` of which view to display when the
* expression is evaluated.
* When no matching expression is found on a `ngSwitchCase` view, the `ngSwitchDefault` view is
* stamped out.
*
* \@stable
*/
var NgSwitch = (function () {
function NgSwitch() {
this._defaultUsed = false;
this._caseCount = 0;
this._lastCaseCheckIndex = 0;
this._lastCasesMatched = false;
}
Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
/**
* @param {?} newValue
* @return {?}
*/
set: function (newValue) {
this._ngSwitch = newValue;
if (this._caseCount === 0) {
this._updateDefaultCases(true);
}
},
enumerable: true,
configurable: true
});
/**
* \@internal
* @return {?}
*/
NgSwitch.prototype._addCase = function () { return this._caseCount++; };
/**
* \@internal
* @param {?} view
* @return {?}
*/
NgSwitch.prototype._addDefault = function (view) {
if (!this._defaultViews) {
this._defaultViews = [];
}
this._defaultViews.push(view);
};
/**
* \@internal
* @param {?} value
* @return {?}
*/
NgSwitch.prototype._matchCase = function (value) {
var /** @type {?} */ matched = value == this._ngSwitch;
this._lastCasesMatched = this._lastCasesMatched || matched;
this._lastCaseCheckIndex++;
if (this._lastCaseCheckIndex === this._caseCount) {
this._updateDefaultCases(!this._lastCasesMatched);
this._lastCaseCheckIndex = 0;
this._lastCasesMatched = false;
}
return matched;
};
/**
* @param {?} useDefault
* @return {?}
*/
NgSwitch.prototype._updateDefaultCases = function (useDefault) {
if (this._defaultViews && useDefault !== this._defaultUsed) {
this._defaultUsed = useDefault;
for (var /** @type {?} */ i = 0; i < this._defaultViews.length; i++) {
var /** @type {?} */ defaultView = this._defaultViews[i];
defaultView.enforceState(useDefault);
}
}
};
return NgSwitch;
}());
NgSwitch.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngSwitch]' },] },
];
/**
* @nocollapse
*/
NgSwitch.ctorParameters = function () { return []; };
NgSwitch.propDecorators = {
'ngSwitch': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* \@ngModule CommonModule
*
* \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgSwitch} when the
* given expression evaluate to respectively the same/different value as the switch
* expression.
*
* \@howToUse
* ```
*
* ...
*
* ```
* \@description
*
* Insert the sub-tree when the expression evaluates to the same value as the enclosing switch
* expression.
*
* If multiple match expressions match the switch expression value, all of them are displayed.
*
* See {\@link NgSwitch} for more details and example.
*
* \@stable
*/
var NgSwitchCase = (function () {
/**
* @param {?} viewContainer
* @param {?} templateRef
* @param {?} ngSwitch
*/
function NgSwitchCase(viewContainer, templateRef, ngSwitch) {
this.ngSwitch = ngSwitch;
ngSwitch._addCase();
this._view = new SwitchView(viewContainer, templateRef);
}
/**
* @return {?}
*/
NgSwitchCase.prototype.ngDoCheck = function () { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); };
return NgSwitchCase;
}());
NgSwitchCase.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngSwitchCase]' },] },
];
/**
* @nocollapse
*/
NgSwitchCase.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* TemplateRef */], },
{ type: NgSwitch, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["V" /* Host */] },] },
]; };
NgSwitchCase.propDecorators = {
'ngSwitchCase': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* \@ngModule CommonModule
* \@whatItDoes Creates a view that is added to the parent {\@link NgSwitch} when no case expressions
* match the
* switch expression.
*
* \@howToUse
* ```
*
* ...
* ...
*
* ```
*
* \@description
*
* Insert the sub-tree when no case expressions evaluate to the same value as the enclosing switch
* expression.
*
* See {\@link NgSwitch} for more details and example.
*
* \@stable
*/
var NgSwitchDefault = (function () {
/**
* @param {?} viewContainer
* @param {?} templateRef
* @param {?} ngSwitch
*/
function NgSwitchDefault(viewContainer, templateRef, ngSwitch) {
ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
}
return NgSwitchDefault;
}());
NgSwitchDefault.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngSwitchDefault]' },] },
];
/**
* @nocollapse
*/
NgSwitchDefault.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* TemplateRef */], },
{ type: NgSwitch, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["V" /* Host */] },] },
]; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
*
* \@howToUse
* ```
*
* there is nothing
* there is one
* there are a few
*
* ```
*
* \@description
*
* Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
* that match the switch expression's pluralization category.
*
* To use this directive you must provide a container element that sets the `[ngPlural]` attribute
* to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
* expression:
* - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
* matches the switch expression exactly,
* - otherwise, the view will be treated as a "category match", and will only display if exact
* value matches aren't found and the value maps to its category for the defined locale.
*
* See http://cldr.unicode.org/index/cldr-spec/plural-rules
*
* \@experimental
*/
var NgPlural = (function () {
/**
* @param {?} _localization
*/
function NgPlural(_localization) {
this._localization = _localization;
this._caseViews = {};
}
Object.defineProperty(NgPlural.prototype, "ngPlural", {
/**
* @param {?} value
* @return {?}
*/
set: function (value) {
this._switchValue = value;
this._updateView();
},
enumerable: true,
configurable: true
});
/**
* @param {?} value
* @param {?} switchView
* @return {?}
*/
NgPlural.prototype.addCase = function (value, switchView) { this._caseViews[value] = switchView; };
/**
* @return {?}
*/
NgPlural.prototype._updateView = function () {
this._clearViews();
var /** @type {?} */ cases = Object.keys(this._caseViews);
var /** @type {?} */ key = getPluralCategory(this._switchValue, cases, this._localization);
this._activateView(this._caseViews[key]);
};
/**
* @return {?}
*/
NgPlural.prototype._clearViews = function () {
if (this._activeView)
this._activeView.destroy();
};
/**
* @param {?} view
* @return {?}
*/
NgPlural.prototype._activateView = function (view) {
if (view) {
this._activeView = view;
this._activeView.create();
}
};
return NgPlural;
}());
NgPlural.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngPlural]' },] },
];
/**
* @nocollapse
*/
NgPlural.ctorParameters = function () { return [
{ type: NgLocalization, },
]; };
NgPlural.propDecorators = {
'ngPlural': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* \@ngModule CommonModule
*
* \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgPlural} when the
* given expression matches the plural expression according to CLDR rules.
*
* \@howToUse
* ```
*
* ...
* ...
*
* ```
*
* See {\@link NgPlural} for more details and example.
*
* \@experimental
*/
var NgPluralCase = (function () {
/**
* @param {?} value
* @param {?} template
* @param {?} viewContainer
* @param {?} ngPlural
*/
function NgPluralCase(value, template, viewContainer, ngPlural) {
this.value = value;
var isANumber = !isNaN(Number(value));
ngPlural.addCase(isANumber ? "=" + value : value, new SwitchView(viewContainer, template));
}
return NgPluralCase;
}());
NgPluralCase.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngPluralCase]' },] },
];
/**
* @nocollapse
*/
NgPluralCase.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["W" /* Attribute */], args: ['ngPluralCase',] },] },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* TemplateRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */], },
{ type: NgPlural, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["V" /* Host */] },] },
]; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Update an HTML element styles.
*
* \@howToUse
* ```
* ...
*
* ...
*
* ...
* ```
*
* \@description
*
* The styles are updated according to the value of the expression evaluation:
* - keys are style names with an optional `.` suffix (ie 'top.px', 'font-style.em'),
* - values are the values assigned to those properties (expressed in the given unit).
*
* \@stable
*/
var NgStyle = (function () {
/**
* @param {?} _differs
* @param {?} _ngEl
* @param {?} _renderer
*/
function NgStyle(_differs, _ngEl, _renderer) {
this._differs = _differs;
this._ngEl = _ngEl;
this._renderer = _renderer;
}
Object.defineProperty(NgStyle.prototype, "ngStyle", {
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
this._ngStyle = v;
if (!this._differ && v) {
this._differ = this._differs.find(v).create();
}
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgStyle.prototype.ngDoCheck = function () {
if (this._differ) {
var /** @type {?} */ changes = this._differ.diff(this._ngStyle);
if (changes) {
this._applyChanges(changes);
}
}
};
/**
* @param {?} changes
* @return {?}
*/
NgStyle.prototype._applyChanges = function (changes) {
var _this = this;
changes.forEachRemovedItem(function (record) { return _this._setStyle(record.key, null); });
changes.forEachAddedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
changes.forEachChangedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
};
/**
* @param {?} nameAndUnit
* @param {?} value
* @return {?}
*/
NgStyle.prototype._setStyle = function (nameAndUnit, value) {
var _a = nameAndUnit.split('.'), name = _a[0], unit = _a[1];
value = value != null && unit ? "" + value + unit : value;
this._renderer.setElementStyle(this._ngEl.nativeElement, name, /** @type {?} */ (value));
};
return NgStyle;
}());
NgStyle.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngStyle]' },] },
];
/**
* @nocollapse
*/
NgStyle.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["N" /* KeyValueDiffers */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* ElementRef */], },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["P" /* Renderer */], },
]; };
NgStyle.propDecorators = {
'ngStyle': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
*
* \@whatItDoes Inserts an embedded view from a prepared `TemplateRef`
*
* \@howToUse
* ```
*
* ```
*
* \@description
*
* You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
* `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
* by the local template `let` declarations.
*
* Note: using the key `$implicit` in the context object will set it's value as default.
*
* ## Example
*
* {\@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
*
* \@experimental
*/
var NgTemplateOutlet = (function () {
/**
* @param {?} _viewContainerRef
*/
function NgTemplateOutlet(_viewContainerRef) {
this._viewContainerRef = _viewContainerRef;
}
Object.defineProperty(NgTemplateOutlet.prototype, "ngOutletContext", {
/**
* @deprecated v4.0.0 - Renamed to ngTemplateOutletContext.
* @param {?} context
* @return {?}
*/
set: function (context) { this.ngTemplateOutletContext = context; },
enumerable: true,
configurable: true
});
/**
* @param {?} changes
* @return {?}
*/
NgTemplateOutlet.prototype.ngOnChanges = function (changes) {
if (this._viewRef) {
this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
}
if (this.ngTemplateOutlet) {
this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext);
}
};
return NgTemplateOutlet;
}());
NgTemplateOutlet.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["L" /* Directive */], args: [{ selector: '[ngTemplateOutlet]' },] },
];
/**
* @nocollapse
*/
NgTemplateOutlet.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */], },
]; };
NgTemplateOutlet.propDecorators = {
'ngTemplateOutletContext': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngTemplateOutlet': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
'ngOutletContext': [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["Q" /* Input */] },],
};
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A collection of Angular directives that are likely to be used in each and every Angular
* application.
*/
var COMMON_DIRECTIVES = [
NgClass,
NgComponentOutlet,
NgForOf,
NgIf,
NgTemplateOutlet,
NgStyle,
NgSwitch,
NgSwitchCase,
NgSwitchDefault,
NgPlural,
NgPluralCase,
];
/**
* A collection of deprecated directives that are no longer part of the core module.
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} type
* @param {?} value
* @return {?}
*/
function invalidPipeArgumentError(type, value) {
return Error("InvalidPipeArgument: '" + value + "' for pipe '" + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["K" /* ɵstringify */])(type) + "'");
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ObservableStrategy = (function () {
function ObservableStrategy() {
}
/**
* @param {?} async
* @param {?} updateLatestValue
* @return {?}
*/
ObservableStrategy.prototype.createSubscription = function (async, updateLatestValue) {
return async.subscribe({ next: updateLatestValue, error: function (e) { throw e; } });
};
/**
* @param {?} subscription
* @return {?}
*/
ObservableStrategy.prototype.dispose = function (subscription) { subscription.unsubscribe(); };
/**
* @param {?} subscription
* @return {?}
*/
ObservableStrategy.prototype.onDestroy = function (subscription) { subscription.unsubscribe(); };
return ObservableStrategy;
}());
var PromiseStrategy = (function () {
function PromiseStrategy() {
}
/**
* @param {?} async
* @param {?} updateLatestValue
* @return {?}
*/
PromiseStrategy.prototype.createSubscription = function (async, updateLatestValue) {
return async.then(updateLatestValue, function (e) { throw e; });
};
/**
* @param {?} subscription
* @return {?}
*/
PromiseStrategy.prototype.dispose = function (subscription) { };
/**
* @param {?} subscription
* @return {?}
*/
PromiseStrategy.prototype.onDestroy = function (subscription) { };
return PromiseStrategy;
}());
var _promiseStrategy = new PromiseStrategy();
var _observableStrategy = new ObservableStrategy();
/**
* \@ngModule CommonModule
* \@whatItDoes Unwraps a value from an asynchronous primitive.
* \@howToUse `observable_or_promise_expression | async`
* \@description
* The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
* emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
* changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
* potential memory leaks.
*
*
* ## Examples
*
* This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
* promise.
*
* {\@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
*
* It's also possible to use `async` with Observables. The example below binds the `time` Observable
* to the view. The Observable continuously updates the view with the current time.
*
* {\@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
*
* \@stable
*/
var AsyncPipe = (function () {
/**
* @param {?} _ref
*/
function AsyncPipe(_ref) {
this._ref = _ref;
this._latestValue = null;
this._latestReturnedValue = null;
this._subscription = null;
this._obj = null;
this._strategy = ((null));
}
/**
* @return {?}
*/
AsyncPipe.prototype.ngOnDestroy = function () {
if (this._subscription) {
this._dispose();
}
};
/**
* @param {?} obj
* @return {?}
*/
AsyncPipe.prototype.transform = function (obj) {
if (!this._obj) {
if (obj) {
this._subscribe(obj);
}
this._latestReturnedValue = this._latestValue;
return this._latestValue;
}
if (obj !== this._obj) {
this._dispose();
return this.transform(/** @type {?} */ (obj));
}
if (this._latestValue === this._latestReturnedValue) {
return this._latestReturnedValue;
}
this._latestReturnedValue = this._latestValue;
return __WEBPACK_IMPORTED_MODULE_0__angular_core__["X" /* WrappedValue */].wrap(this._latestValue);
};
/**
* @param {?} obj
* @return {?}
*/
AsyncPipe.prototype._subscribe = function (obj) {
var _this = this;
this._obj = obj;
this._strategy = this._selectStrategy(obj);
this._subscription = this._strategy.createSubscription(obj, function (value) { return _this._updateLatestValue(obj, value); });
};
/**
* @param {?} obj
* @return {?}
*/
AsyncPipe.prototype._selectStrategy = function (obj) {
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Y" /* ɵisPromise */])(obj)) {
return _promiseStrategy;
}
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Z" /* ɵisObservable */])(obj)) {
return _observableStrategy;
}
throw invalidPipeArgumentError(AsyncPipe, obj);
};
/**
* @return {?}
*/
AsyncPipe.prototype._dispose = function () {
this._strategy.dispose(/** @type {?} */ ((this._subscription)));
this._latestValue = null;
this._latestReturnedValue = null;
this._subscription = null;
this._obj = null;
};
/**
* @param {?} async
* @param {?} value
* @return {?}
*/
AsyncPipe.prototype._updateLatestValue = function (async, value) {
if (async === this._obj) {
this._latestValue = value;
this._ref.markForCheck();
}
};
return AsyncPipe;
}());
AsyncPipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'async', pure: false },] },
];
/**
* @nocollapse
*/
AsyncPipe.ctorParameters = function () { return [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_1" /* ChangeDetectorRef */], },
]; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Transforms text to lowercase.
*
* {\@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe' }
*
* \@stable
*/
var LowerCasePipe = (function () {
function LowerCasePipe() {
}
/**
* @param {?} value
* @return {?}
*/
LowerCasePipe.prototype.transform = function (value) {
if (!value)
return value;
if (typeof value !== 'string') {
throw invalidPipeArgumentError(LowerCasePipe, value);
}
return value.toLowerCase();
};
return LowerCasePipe;
}());
LowerCasePipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'lowercase' },] },
];
/**
* @nocollapse
*/
LowerCasePipe.ctorParameters = function () { return []; };
/**
* Helper method to transform a single word to titlecase.
*
* \@stable
* @param {?} word
* @return {?}
*/
function titleCaseWord(word) {
if (!word)
return word;
return word[0].toUpperCase() + word.substr(1).toLowerCase();
}
/**
* Transforms text to titlecase.
*
* \@stable
*/
var TitleCasePipe = (function () {
function TitleCasePipe() {
}
/**
* @param {?} value
* @return {?}
*/
TitleCasePipe.prototype.transform = function (value) {
if (!value)
return value;
if (typeof value !== 'string') {
throw invalidPipeArgumentError(TitleCasePipe, value);
}
return value.split(/\b/g).map(function (word) { return titleCaseWord(word); }).join('');
};
return TitleCasePipe;
}());
TitleCasePipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'titlecase' },] },
];
/**
* @nocollapse
*/
TitleCasePipe.ctorParameters = function () { return []; };
/**
* Transforms text to uppercase.
*
* \@stable
*/
var UpperCasePipe = (function () {
function UpperCasePipe() {
}
/**
* @param {?} value
* @return {?}
*/
UpperCasePipe.prototype.transform = function (value) {
if (!value)
return value;
if (typeof value !== 'string') {
throw invalidPipeArgumentError(UpperCasePipe, value);
}
return value.toUpperCase();
};
return UpperCasePipe;
}());
UpperCasePipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'uppercase' },] },
];
/**
* @nocollapse
*/
UpperCasePipe.ctorParameters = function () { return []; };
var NumberFormatStyle = {};
NumberFormatStyle.Decimal = 0;
NumberFormatStyle.Percent = 1;
NumberFormatStyle.Currency = 2;
NumberFormatStyle[NumberFormatStyle.Decimal] = "Decimal";
NumberFormatStyle[NumberFormatStyle.Percent] = "Percent";
NumberFormatStyle[NumberFormatStyle.Currency] = "Currency";
var NumberFormatter = (function () {
function NumberFormatter() {
}
/**
* @param {?} num
* @param {?} locale
* @param {?} style
* @param {?=} __3
* @return {?}
*/
NumberFormatter.format = function (num, locale, style, _a) {
var _b = _a === void 0 ? {} : _a, minimumIntegerDigits = _b.minimumIntegerDigits, minimumFractionDigits = _b.minimumFractionDigits, maximumFractionDigits = _b.maximumFractionDigits, currency = _b.currency, _c = _b.currencyAsSymbol, currencyAsSymbol = _c === void 0 ? false : _c;
var /** @type {?} */ options = {
minimumIntegerDigits: minimumIntegerDigits,
minimumFractionDigits: minimumFractionDigits,
maximumFractionDigits: maximumFractionDigits,
style: NumberFormatStyle[style].toLowerCase()
};
if (style == NumberFormatStyle.Currency) {
options.currency = typeof currency == 'string' ? currency : undefined;
options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
}
return new Intl.NumberFormat(locale, options).format(num);
};
return NumberFormatter;
}());
var DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
var PATTERN_ALIASES = {
// Keys are quoted so they do not get renamed during closure compilation.
'yMMMdjms': datePartGetterFactory(combine([
digitCondition('year', 1),
nameCondition('month', 3),
digitCondition('day', 1),
digitCondition('hour', 1),
digitCondition('minute', 1),
digitCondition('second', 1),
])),
'yMdjm': datePartGetterFactory(combine([
digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1),
digitCondition('hour', 1), digitCondition('minute', 1)
])),
'yMMMMEEEEd': datePartGetterFactory(combine([
digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4),
digitCondition('day', 1)
])),
'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])),
'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])),
'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])),
'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])),
'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)]))
};
var DATE_FORMATS = {
// Keys are quoted so they do not get renamed.
'yyyy': datePartGetterFactory(digitCondition('year', 4)),
'yy': datePartGetterFactory(digitCondition('year', 2)),
'y': datePartGetterFactory(digitCondition('year', 1)),
'MMMM': datePartGetterFactory(nameCondition('month', 4)),
'MMM': datePartGetterFactory(nameCondition('month', 3)),
'MM': datePartGetterFactory(digitCondition('month', 2)),
'M': datePartGetterFactory(digitCondition('month', 1)),
'LLLL': datePartGetterFactory(nameCondition('month', 4)),
'L': datePartGetterFactory(nameCondition('month', 1)),
'dd': datePartGetterFactory(digitCondition('day', 2)),
'd': datePartGetterFactory(digitCondition('day', 1)),
'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
'jj': datePartGetterFactory(digitCondition('hour', 2)),
'j': datePartGetterFactory(digitCondition('hour', 1)),
'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
'm': datePartGetterFactory(digitCondition('minute', 1)),
'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
's': datePartGetterFactory(digitCondition('second', 1)),
// while ISO 8601 requires fractions to be prefixed with `.` or `,`
// we can be just safely rely on using `sss` since we currently don't support single or two digit
// fractions
'sss': datePartGetterFactory(digitCondition('second', 3)),
'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
'EE': datePartGetterFactory(nameCondition('weekday', 2)),
'E': datePartGetterFactory(nameCondition('weekday', 1)),
'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
'Z': timeZoneGetter('short'),
'z': timeZoneGetter('long'),
'ww': datePartGetterFactory({}),
// first Thursday of the year. not support ?
'w': datePartGetterFactory({}),
// of the year not support ?
'G': datePartGetterFactory(nameCondition('era', 1)),
'GG': datePartGetterFactory(nameCondition('era', 2)),
'GGG': datePartGetterFactory(nameCondition('era', 3)),
'GGGG': datePartGetterFactory(nameCondition('era', 4))
};
/**
* @param {?} inner
* @return {?}
*/
function digitModifier(inner) {
return function (date, locale) {
var /** @type {?} */ result = inner(date, locale);
return result.length == 1 ? '0' + result : result;
};
}
/**
* @param {?} inner
* @return {?}
*/
function hourClockExtractor(inner) {
return function (date, locale) { return inner(date, locale).split(' ')[1]; };
}
/**
* @param {?} inner
* @return {?}
*/
function hourExtractor(inner) {
return function (date, locale) { return inner(date, locale).split(' ')[0]; };
}
/**
* @param {?} date
* @param {?} locale
* @param {?} options
* @return {?}
*/
function intlDateFormat(date, locale, options) {
return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, '');
}
/**
* @param {?} timezone
* @return {?}
*/
function timeZoneGetter(timezone) {
// To workaround `Intl` API restriction for single timezone let format with 24 hours
var /** @type {?} */ options = { hour: '2-digit', hour12: false, timeZoneName: timezone };
return function (date, locale) {
var /** @type {?} */ result = intlDateFormat(date, locale, options);
// Then extract first 3 letters that related to hours
return result ? result.substring(3) : '';
};
}
/**
* @param {?} options
* @param {?} value
* @return {?}
*/
function hour12Modify(options, value) {
options.hour12 = value;
return options;
}
/**
* @param {?} prop
* @param {?} len
* @return {?}
*/
function digitCondition(prop, len) {
var /** @type {?} */ result = {};
result[prop] = len === 2 ? '2-digit' : 'numeric';
return result;
}
/**
* @param {?} prop
* @param {?} len
* @return {?}
*/
function nameCondition(prop, len) {
var /** @type {?} */ result = {};
if (len < 4) {
result[prop] = len > 1 ? 'short' : 'narrow';
}
else {
result[prop] = 'long';
}
return result;
}
/**
* @param {?} options
* @return {?}
*/
function combine(options) {
return ((Object)).assign.apply(((Object)), [{}].concat(options));
}
/**
* @param {?} ret
* @return {?}
*/
function datePartGetterFactory(ret) {
return function (date, locale) { return intlDateFormat(date, locale, ret); };
}
var DATE_FORMATTER_CACHE = new Map();
/**
* @param {?} format
* @param {?} date
* @param {?} locale
* @return {?}
*/
function dateFormatter(format, date, locale) {
var /** @type {?} */ fn = PATTERN_ALIASES[format];
if (fn)
return fn(date, locale);
var /** @type {?} */ cacheKey = format;
var /** @type {?} */ parts = DATE_FORMATTER_CACHE.get(cacheKey);
if (!parts) {
parts = [];
var /** @type {?} */ match = void 0;
DATE_FORMATS_SPLIT.exec(format);
var /** @type {?} */ _format = format;
while (_format) {
match = DATE_FORMATS_SPLIT.exec(_format);
if (match) {
parts = parts.concat(match.slice(1));
_format = ((parts.pop()));
}
else {
parts.push(_format);
_format = null;
}
}
DATE_FORMATTER_CACHE.set(cacheKey, parts);
}
return parts.reduce(function (text, part) {
var /** @type {?} */ fn = DATE_FORMATS[part];
return text + (fn ? fn(date, locale) : partToTime(part));
}, '');
}
/**
* @param {?} part
* @return {?}
*/
function partToTime(part) {
return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
}
var DateFormatter = (function () {
function DateFormatter() {
}
/**
* @param {?} date
* @param {?} locale
* @param {?} pattern
* @return {?}
*/
DateFormatter.format = function (date, locale, pattern) {
return dateFormatter(pattern, date, locale);
};
return DateFormatter;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
/**
* @param {?} pipe
* @param {?} locale
* @param {?} value
* @param {?} style
* @param {?=} digits
* @param {?=} currency
* @param {?=} currencyAsSymbol
* @return {?}
*/
function formatNumber(pipe, locale, value, style, digits, currency, currencyAsSymbol) {
if (currency === void 0) { currency = null; }
if (currencyAsSymbol === void 0) { currencyAsSymbol = false; }
if (value == null)
return null;
// Convert strings to numbers
value = typeof value === 'string' && isNumeric(value) ? +value : value;
if (typeof value !== 'number') {
throw invalidPipeArgumentError(pipe, value);
}
var /** @type {?} */ minInt = undefined;
var /** @type {?} */ minFraction = undefined;
var /** @type {?} */ maxFraction = undefined;
if (style !== NumberFormatStyle.Currency) {
// rely on Intl default for currency
minInt = 1;
minFraction = 0;
maxFraction = 3;
}
if (digits) {
var /** @type {?} */ parts = digits.match(_NUMBER_FORMAT_REGEXP);
if (parts === null) {
throw new Error(digits + " is not a valid digit info for number pipes");
}
if (parts[1] != null) {
minInt = parseIntAutoRadix(parts[1]);
}
if (parts[3] != null) {
minFraction = parseIntAutoRadix(parts[3]);
}
if (parts[5] != null) {
maxFraction = parseIntAutoRadix(parts[5]);
}
}
return NumberFormatter.format(/** @type {?} */ (value), locale, style, {
minimumIntegerDigits: minInt,
minimumFractionDigits: minFraction,
maximumFractionDigits: maxFraction,
currency: currency,
currencyAsSymbol: currencyAsSymbol,
});
}
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number according to locale rules.
* \@howToUse `number_expression | number[:digitInfo]`
*
* Formats a number as text. Group sizing and separator and other locale-specific
* configurations are based on the active locale.
*
* where `expression` is a number:
* - `digitInfo` is a `string` which has a following format:
* {minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
* - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
* - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
* - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
*
* For more information on the acceptable range for each of these numbers and other
* details see your native internationalization library.
*
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
* and may require a polyfill. See {\@linkDocs guide/browser-support} for details.
*
* ### Example
*
* {\@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
*
* \@stable
*/
var DecimalPipe = (function () {
/**
* @param {?} _locale
*/
function DecimalPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} digits
* @return {?}
*/
DecimalPipe.prototype.transform = function (value, digits) {
return formatNumber(DecimalPipe, this._locale, value, NumberFormatStyle.Decimal, digits);
};
return DecimalPipe;
}());
DecimalPipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'number' },] },
];
/**
* @nocollapse
*/
DecimalPipe.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["I" /* LOCALE_ID */],] },] },
]; };
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number as a percentage according to locale rules.
* \@howToUse `number_expression | percent[:digitInfo]`
*
* \@description
*
* Formats a number as percentage.
*
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
*
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
* and may require a polyfill. See {\@linkDocs guide/browser-support} for details.
*
* ### Example
*
* {\@example common/pipes/ts/number_pipe.ts region='PercentPipe'}
*
* \@stable
*/
var PercentPipe = (function () {
/**
* @param {?} _locale
*/
function PercentPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} digits
* @return {?}
*/
PercentPipe.prototype.transform = function (value, digits) {
return formatNumber(PercentPipe, this._locale, value, NumberFormatStyle.Percent, digits);
};
return PercentPipe;
}());
PercentPipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'percent' },] },
];
/**
* @nocollapse
*/
PercentPipe.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["I" /* LOCALE_ID */],] },] },
]; };
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a number as currency using locale rules.
* \@howToUse `number_expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]`
* \@description
*
* Use `currency` to format a number as currency.
*
* - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
* as `USD` for the US dollar and `EUR` for the euro.
* - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code.
* - `true`: use symbol (e.g. `$`).
* - `false`(default): use code (e.g. `USD`).
* - `digitInfo` See {\@link DecimalPipe} for detailed description.
*
* WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
* and may require a polyfill. See {\@linkDocs guide/browser-support} for details.
*
* ### Example
*
* {\@example common/pipes/ts/number_pipe.ts region='CurrencyPipe'}
*
* \@stable
*/
var CurrencyPipe = (function () {
/**
* @param {?} _locale
*/
function CurrencyPipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} currencyCode
* @param {?=} symbolDisplay
* @param {?=} digits
* @return {?}
*/
CurrencyPipe.prototype.transform = function (value, currencyCode, symbolDisplay, digits) {
if (currencyCode === void 0) { currencyCode = 'USD'; }
if (symbolDisplay === void 0) { symbolDisplay = false; }
return formatNumber(CurrencyPipe, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
};
return CurrencyPipe;
}());
CurrencyPipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'currency' },] },
];
/**
* @nocollapse
*/
CurrencyPipe.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["I" /* LOCALE_ID */],] },] },
]; };
/**
* @param {?} text
* @return {?}
*/
function parseIntAutoRadix(text) {
var /** @type {?} */ result = parseInt(text);
if (isNaN(result)) {
throw new Error('Invalid integer literal when parsing ' + text);
}
return result;
}
/**
* @param {?} value
* @return {?}
*/
function isNumeric(value) {
return !isNaN(value - parseFloat(value));
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
/**
* \@ngModule CommonModule
* \@whatItDoes Formats a date according to locale rules.
* \@howToUse `date_expression | date[:format]`
* \@description
*
* Where:
* - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
* (https://www.w3.org/TR/NOTE-datetime).
* - `format` indicates which date/time components to include. The format can be predefined as
* shown below or custom as shown in the table.
* - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
* - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
* - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
* - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
* - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
* - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
* - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
* - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
*
*
* | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit |
* |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
* | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - |
* | year | y | - | - | - | y (2015) | yy (15) |
* | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
* | day | d | - | - | - | d (3) | dd (03) |
* | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - |
* | hour | j | - | - | - | j (13) | jj (13) |
* | hour12 | h | - | - | - | h (1 PM) | hh (01 PM)|
* | hour24 | H | - | - | - | H (13) | HH (13) |
* | minute | m | - | - | - | m (5) | mm (05) |
* | second | s | - | - | - | s (9) | ss (09) |
* | timezone | z | - | - | z (Pacific Standard Time)| - | - |
* | timezone | Z | - | Z (GMT-8:00) | - | - | - |
* | timezone | a | - | a (PM) | - | - | - |
*
* In javascript, only the components specified will be respected (not the ordering,
* punctuations, ...) and details of the formatting will be dependent on the locale.
*
* Timezone of the formatted text will be the local system timezone of the end-user's machine.
*
* When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
* applied and the formatted text will have the same day, month and year of the expression.
*
* WARNINGS:
* - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
* Instead users should treat the date as an immutable object and change the reference when the
* pipe needs to re-run (this is to avoid reformatting the date on every change detection run
* which would be an expensive operation).
* - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
* browsers.
*
* ### Examples
*
* Assuming `dateObj` is (year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11)
* in the _local_ time and locale is 'en-US':
*
* ```
* {{ dateObj | date }} // output is 'Jun 15, 2015'
* {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
* {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
* {{ dateObj | date:'mmss' }} // output is '43:11'
* ```
*
* {\@example common/pipes/ts/date_pipe.ts region='DatePipe'}
*
* \@stable
*/
var DatePipe = (function () {
/**
* @param {?} _locale
*/
function DatePipe(_locale) {
this._locale = _locale;
}
/**
* @param {?} value
* @param {?=} pattern
* @return {?}
*/
DatePipe.prototype.transform = function (value, pattern) {
if (pattern === void 0) { pattern = 'mediumDate'; }
var /** @type {?} */ date;
if (isBlank(value) || value !== value)
return null;
if (typeof value === 'string') {
value = value.trim();
}
if (isDate(value)) {
date = value;
}
else if (isNumeric(value)) {
date = new Date(parseFloat(value));
}
else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
/**
* For ISO Strings without time the day, month and year must be extracted from the ISO String
* before Date creation to avoid time offset and errors in the new Date.
* If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
* date, some browsers (e.g. IE 9) will throw an invalid Date error
* If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
* is applied
* Note: ISO months are 0 for January, 1 for February, ...
*/
var _a = value.split('-').map(function (val) { return parseInt(val, 10); }), y = _a[0], m = _a[1], d = _a[2];
date = new Date(y, m - 1, d);
}
else {
date = new Date(value);
}
if (!isDate(date)) {
var /** @type {?} */ match = void 0;
if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) {
date = isoStringToDate(match);
}
else {
throw invalidPipeArgumentError(DatePipe, value);
}
}
return DateFormatter.format(date, this._locale, DatePipe._ALIASES[pattern] || pattern);
};
return DatePipe;
}());
/**
* \@internal
*/
DatePipe._ALIASES = {
'medium': 'yMMMdjms',
'short': 'yMdjm',
'fullDate': 'yMMMMEEEEd',
'longDate': 'yMMMMd',
'mediumDate': 'yMMMd',
'shortDate': 'yMd',
'mediumTime': 'jms',
'shortTime': 'jm'
};
DatePipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'date', pure: true },] },
];
/**
* @nocollapse
*/
DatePipe.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [__WEBPACK_IMPORTED_MODULE_0__angular_core__["I" /* LOCALE_ID */],] },] },
]; };
/**
* @param {?} obj
* @return {?}
*/
function isBlank(obj) {
return obj == null || obj === '';
}
/**
* @param {?} obj
* @return {?}
*/
function isDate(obj) {
return obj instanceof Date && !isNaN(obj.valueOf());
}
/**
* @param {?} match
* @return {?}
*/
function isoStringToDate(match) {
var /** @type {?} */ date = new Date(0);
var /** @type {?} */ tzHour = 0;
var /** @type {?} */ tzMin = 0;
var /** @type {?} */ dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
var /** @type {?} */ timeSetter = match[8] ? date.setUTCHours : date.setHours;
if (match[9]) {
tzHour = toInt(match[9] + match[10]);
tzMin = toInt(match[9] + match[11]);
}
dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
var /** @type {?} */ h = toInt(match[4] || '0') - tzHour;
var /** @type {?} */ m = toInt(match[5] || '0') - tzMin;
var /** @type {?} */ s = toInt(match[6] || '0');
var /** @type {?} */ ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
timeSetter.call(date, h, m, s, ms);
return date;
}
/**
* @param {?} str
* @return {?}
*/
function toInt(str) {
return parseInt(str, 10);
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _INTERPOLATION_REGEXP = /#/g;
/**
* \@ngModule CommonModule
* \@whatItDoes Maps a value to a string that pluralizes the value according to locale rules.
* \@howToUse `expression | i18nPlural:mapping`
* \@description
*
* Where:
* - `expression` is a number.
* - `mapping` is an object that mimics the ICU format, see
* http://userguide.icu-project.org/formatparse/messages
*
* ## Example
*
* {\@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
*
* \@experimental
*/
var I18nPluralPipe = (function () {
/**
* @param {?} _localization
*/
function I18nPluralPipe(_localization) {
this._localization = _localization;
}
/**
* @param {?} value
* @param {?} pluralMap
* @return {?}
*/
I18nPluralPipe.prototype.transform = function (value, pluralMap) {
if (value == null)
return '';
if (typeof pluralMap !== 'object' || pluralMap === null) {
throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
}
var /** @type {?} */ key = getPluralCategory(value, Object.keys(pluralMap), this._localization);
return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
};
return I18nPluralPipe;
}());
I18nPluralPipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'i18nPlural', pure: true },] },
];
/**
* @nocollapse
*/
I18nPluralPipe.ctorParameters = function () { return [
{ type: NgLocalization, },
]; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Generic selector that displays the string that matches the current value.
* \@howToUse `expression | i18nSelect:mapping`
* \@description
*
* Where `mapping` is an object that indicates the text that should be displayed
* for different values of the provided `expression`.
* If none of the keys of the mapping match the value of the `expression`, then the content
* of the `other` key is returned when present, otherwise an empty string is returned.
*
* ## Example
*
* {\@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
*
* \@experimental
*/
var I18nSelectPipe = (function () {
function I18nSelectPipe() {
}
/**
* @param {?} value
* @param {?} mapping
* @return {?}
*/
I18nSelectPipe.prototype.transform = function (value, mapping) {
if (value == null)
return '';
if (typeof mapping !== 'object' || typeof value !== 'string') {
throw invalidPipeArgumentError(I18nSelectPipe, mapping);
}
if (mapping.hasOwnProperty(value)) {
return mapping[value];
}
if (mapping.hasOwnProperty('other')) {
return mapping['other'];
}
return '';
};
return I18nSelectPipe;
}());
I18nSelectPipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'i18nSelect', pure: true },] },
];
/**
* @nocollapse
*/
I18nSelectPipe.ctorParameters = function () { return []; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Converts value into JSON string.
* \@howToUse `expression | json`
* \@description
*
* Converts value into string using `JSON.stringify`. Useful for debugging.
*
* ### Example
* {\@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
*
* \@stable
*/
var JsonPipe = (function () {
function JsonPipe() {
}
/**
* @param {?} value
* @return {?}
*/
JsonPipe.prototype.transform = function (value) { return JSON.stringify(value, null, 2); };
return JsonPipe;
}());
JsonPipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'json', pure: false },] },
];
/**
* @nocollapse
*/
JsonPipe.ctorParameters = function () { return []; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* \@ngModule CommonModule
* \@whatItDoes Creates a new List or String containing a subset (slice) of the elements.
* \@howToUse `array_or_string_expression | slice:start[:end]`
* \@description
*
* Where the input expression is a `List` or `String`, and:
* - `start`: The starting index of the subset to return.
* - **a positive integer**: return the item at `start` index and all items after
* in the list or string expression.
* - **a negative integer**: return the item at `start` index from the end and all items after
* in the list or string expression.
* - **if positive and greater than the size of the expression**: return an empty list or string.
* - **if negative and greater than the size of the expression**: return entire list or string.
* - `end`: The ending index of the subset to return.
* - **omitted**: return all items until the end.
* - **if positive**: return all items before `end` index of the list or string.
* - **if negative**: return all items before `end` index from the end of the list or string.
*
* All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
* and `String.prototype.slice()`.
*
* When operating on a [List], the returned list is always a copy even when all
* the elements are being returned.
*
* When operating on a blank value, the pipe returns the blank value.
*
* ## List Example
*
* This `ngFor` example:
*
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
*
* produces the following:
*
*
b
*
c
*
* ## String Examples
*
* {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
*
* \@stable
*/
var SlicePipe = (function () {
function SlicePipe() {
}
/**
* @param {?} value
* @param {?} start
* @param {?=} end
* @return {?}
*/
SlicePipe.prototype.transform = function (value, start, end) {
if (value == null)
return value;
if (!this.supports(value)) {
throw invalidPipeArgumentError(SlicePipe, value);
}
return value.slice(start, end);
};
/**
* @param {?} obj
* @return {?}
*/
SlicePipe.prototype.supports = function (obj) { return typeof obj === 'string' || Array.isArray(obj); };
return SlicePipe;
}());
SlicePipe.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_0" /* Pipe */], args: [{ name: 'slice', pure: false },] },
];
/**
* @nocollapse
*/
SlicePipe.ctorParameters = function () { return []; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* This module provides a set of common Pipes.
*/
/**
* A collection of Angular pipes that are likely to be used in each and every application.
*/
var COMMON_PIPES = [
AsyncPipe,
UpperCasePipe,
LowerCasePipe,
JsonPipe,
SlicePipe,
DecimalPipe,
PercentPipe,
TitleCasePipe,
CurrencyPipe,
DatePipe,
I18nPluralPipe,
I18nSelectPipe,
];
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* The module that includes all the basic Angular directives like {\@link NgIf}, {\@link NgForOf}, ...
*
* \@stable
*/
var CommonModule = (function () {
function CommonModule() {
}
return CommonModule;
}());
CommonModule.decorators = [
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["c" /* NgModule */], args: [{
declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
exports: [COMMON_DIRECTIVES, COMMON_PIPES],
providers: [
{ provide: NgLocalization, useClass: NgLocaleLocalization },
],
},] },
];
/**
* @nocollapse
*/
CommonModule.ctorParameters = function () { return []; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var PLATFORM_BROWSER_ID = 'browser';
var PLATFORM_SERVER_ID = 'server';
var PLATFORM_WORKER_APP_ID = 'browserWorkerApp';
var PLATFORM_WORKER_UI_ID = 'browserWorkerUi';
/**
* Returns whether a platform id represents a browser platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformBrowser(platformId) {
return platformId === PLATFORM_BROWSER_ID;
}
/**
* Returns whether a platform id represents a server platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformServer(platformId) {
return platformId === PLATFORM_SERVER_ID;
}
/**
* Returns whether a platform id represents a web worker app platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformWorkerApp(platformId) {
return platformId === PLATFORM_WORKER_APP_ID;
}
/**
* Returns whether a platform id represents a web worker UI platform.
* \@experimental
* @param {?} platformId
* @return {?}
*/
function isPlatformWorkerUi(platformId) {
return platformId === PLATFORM_WORKER_UI_ID;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of the common package.
*/
/**
* \@stable
*/
var VERSION = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["f" /* Version */]('4.1.3');
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of the common package.
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of the common package.
*/
// This file only reexports content of the `src` folder. Keep it that way.
/**
* Generated bundle index. Do not edit.
*/
//# sourceMappingURL=common.es5.js.map
/***/ }),
/***/ "./node_modules/@angular/compiler/@angular/compiler.es5.js":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("./node_modules/@angular/core/@angular/core.es5.js");
/* unused harmony export VERSION */
/* unused harmony export TEMPLATE_TRANSFORMS */
/* unused harmony export CompilerConfig */
/* unused harmony export JitCompiler */
/* unused harmony export DirectiveResolver */
/* unused harmony export PipeResolver */
/* unused harmony export NgModuleResolver */
/* unused harmony export DEFAULT_INTERPOLATION_CONFIG */
/* unused harmony export InterpolationConfig */
/* unused harmony export NgModuleCompiler */
/* unused harmony export ViewCompiler */
/* unused harmony export isSyntaxError */
/* unused harmony export syntaxError */
/* unused harmony export TextAst */
/* unused harmony export BoundTextAst */
/* unused harmony export AttrAst */
/* unused harmony export BoundElementPropertyAst */
/* unused harmony export BoundEventAst */
/* unused harmony export ReferenceAst */
/* unused harmony export VariableAst */
/* unused harmony export ElementAst */
/* unused harmony export EmbeddedTemplateAst */
/* unused harmony export BoundDirectivePropertyAst */
/* unused harmony export DirectiveAst */
/* unused harmony export ProviderAst */
/* unused harmony export ProviderAstType */
/* unused harmony export NgContentAst */
/* unused harmony export PropertyBindingType */
/* unused harmony export templateVisitAll */
/* unused harmony export CompileAnimationEntryMetadata */
/* unused harmony export CompileAnimationStateMetadata */
/* unused harmony export CompileAnimationStateDeclarationMetadata */
/* unused harmony export CompileAnimationStateTransitionMetadata */
/* unused harmony export CompileAnimationMetadata */
/* unused harmony export CompileAnimationKeyframesSequenceMetadata */
/* unused harmony export CompileAnimationStyleMetadata */
/* unused harmony export CompileAnimationAnimateMetadata */
/* unused harmony export CompileAnimationWithStepsMetadata */
/* unused harmony export CompileAnimationSequenceMetadata */
/* unused harmony export CompileAnimationGroupMetadata */
/* unused harmony export identifierName */
/* unused harmony export identifierModuleUrl */
/* unused harmony export viewClassName */
/* unused harmony export rendererTypeName */
/* unused harmony export hostViewClassName */
/* unused harmony export dirWrapperClassName */
/* unused harmony export componentFactoryName */
/* unused harmony export CompileSummaryKind */
/* unused harmony export tokenName */
/* unused harmony export tokenReference */
/* unused harmony export CompileStylesheetMetadata */
/* unused harmony export CompileTemplateMetadata */
/* unused harmony export CompileDirectiveMetadata */
/* unused harmony export createHostComponentMeta */
/* unused harmony export CompilePipeMetadata */
/* unused harmony export CompileNgModuleMetadata */
/* unused harmony export TransitiveCompileNgModuleMetadata */
/* unused harmony export ProviderMeta */
/* unused harmony export flatten */
/* unused harmony export sourceUrl */
/* unused harmony export templateSourceUrl */
/* unused harmony export sharedStylesheetJitUrl */
/* unused harmony export ngModuleJitUrl */
/* unused harmony export templateJitUrl */
/* unused harmony export createAotCompiler */
/* unused harmony export AotCompiler */
/* unused harmony export analyzeNgModules */
/* unused harmony export analyzeAndValidateNgModules */
/* unused harmony export extractProgramSymbols */
/* unused harmony export GeneratedFile */
/* unused harmony export StaticReflector */
/* unused harmony export StaticAndDynamicReflectionCapabilities */
/* unused harmony export StaticSymbol */
/* unused harmony export StaticSymbolCache */
/* unused harmony export ResolvedStaticSymbol */
/* unused harmony export StaticSymbolResolver */
/* unused harmony export unescapeIdentifier */
/* unused harmony export AotSummaryResolver */
/* unused harmony export SummaryResolver */
/* unused harmony export i18nHtmlParserFactory */
/* unused harmony export COMPILER_PROVIDERS */
/* unused harmony export JitCompilerFactory */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return platformCoreDynamic; });
/* unused harmony export createUrlResolverWithoutPackagePrefix */
/* unused harmony export createOfflineCompileUrlResolver */
/* unused harmony export DEFAULT_PACKAGE_URL_PROVIDER */
/* unused harmony export UrlResolver */
/* unused harmony export getUrlScheme */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ResourceLoader; });
/* unused harmony export ElementSchemaRegistry */
/* unused harmony export Extractor */
/* unused harmony export I18NHtmlParser */
/* unused harmony export MessageBundle */
/* unused harmony export Serializer */
/* unused harmony export Xliff */
/* unused harmony export Xliff2 */
/* unused harmony export Xmb */
/* unused harmony export Xtb */
/* unused harmony export DirectiveNormalizer */
/* unused harmony export ParserError */
/* unused harmony export ParseSpan */
/* unused harmony export AST */
/* unused harmony export Quote */
/* unused harmony export EmptyExpr */
/* unused harmony export ImplicitReceiver */
/* unused harmony export Chain */
/* unused harmony export Conditional */
/* unused harmony export PropertyRead */
/* unused harmony export PropertyWrite */
/* unused harmony export SafePropertyRead */
/* unused harmony export KeyedRead */
/* unused harmony export KeyedWrite */
/* unused harmony export BindingPipe */
/* unused harmony export LiteralPrimitive */
/* unused harmony export LiteralArray */
/* unused harmony export LiteralMap */
/* unused harmony export Interpolation */
/* unused harmony export Binary */
/* unused harmony export PrefixNot */
/* unused harmony export MethodCall */
/* unused harmony export SafeMethodCall */
/* unused harmony export FunctionCall */
/* unused harmony export ASTWithSource */
/* unused harmony export TemplateBinding */
/* unused harmony export RecursiveAstVisitor */
/* unused harmony export AstTransformer */
/* unused harmony export TokenType */
/* unused harmony export Lexer */
/* unused harmony export Token */
/* unused harmony export EOF */
/* unused harmony export isIdentifier */
/* unused harmony export isQuote */
/* unused harmony export SplitInterpolation */
/* unused harmony export TemplateBindingParseResult */
/* unused harmony export Parser */
/* unused harmony export _ParseAST */
/* unused harmony export ERROR_COLLECTOR_TOKEN */
/* unused harmony export CompileMetadataResolver */
/* unused harmony export componentModuleUrl */
/* unused harmony export Text */
/* unused harmony export Expansion */
/* unused harmony export ExpansionCase */
/* unused harmony export Attribute */
/* unused harmony export Element */
/* unused harmony export Comment */
/* unused harmony export visitAll */
/* unused harmony export ParseTreeResult */
/* unused harmony export TreeError */
/* unused harmony export HtmlParser */
/* unused harmony export HtmlTagDefinition */
/* unused harmony export getHtmlTagDefinition */
/* unused harmony export TagContentType */
/* unused harmony export splitNsName */
/* unused harmony export isNgContainer */
/* unused harmony export isNgContent */
/* unused harmony export isNgTemplate */
/* unused harmony export getNsPrefix */
/* unused harmony export mergeNsAndName */
/* unused harmony export NAMED_ENTITIES */
/* unused harmony export ImportResolver */
/* unused harmony export debugOutputAstAsTypeScript */
/* unused harmony export TypeScriptEmitter */
/* unused harmony export ParseLocation */
/* unused harmony export ParseSourceFile */
/* unused harmony export ParseSourceSpan */
/* unused harmony export ParseErrorLevel */
/* unused harmony export ParseError */
/* unused harmony export typeSourceSpan */
/* unused harmony export DomElementSchemaRegistry */
/* unused harmony export CssSelector */
/* unused harmony export SelectorMatcher */
/* unused harmony export SelectorListContext */
/* unused harmony export SelectorContext */
/* unused harmony export StylesCompileDependency */
/* unused harmony export StylesCompileResult */
/* unused harmony export CompiledStylesheet */
/* unused harmony export StyleCompiler */
/* unused harmony export TemplateParseError */
/* unused harmony export TemplateParseResult */
/* unused harmony export TemplateParser */
/* unused harmony export splitClasses */
/* unused harmony export createElementCssSelector */
/* unused harmony export removeSummaryDuplicates */
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* @license Angular v4.1.3
* (c) 2010-2017 Google, Inc. https://angular.io/
* License: MIT
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of the common package.
*/
/**
* \@stable
*/
var VERSION = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["f" /* Version */]('4.1.3');
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A segment of text within the template.
*/
var TextAst = (function () {
/**
* @param {?} value
* @param {?} ngContentIndex
* @param {?} sourceSpan
*/
function TextAst(value, ngContentIndex, sourceSpan) {
this.value = value;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
TextAst.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); };
return TextAst;
}());
/**
* A bound expression within the text of a template.
*/
var BoundTextAst = (function () {
/**
* @param {?} value
* @param {?} ngContentIndex
* @param {?} sourceSpan
*/
function BoundTextAst(value, ngContentIndex, sourceSpan) {
this.value = value;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundTextAst.prototype.visit = function (visitor, context) {
return visitor.visitBoundText(this, context);
};
return BoundTextAst;
}());
/**
* A plain attribute on an element.
*/
var AttrAst = (function () {
/**
* @param {?} name
* @param {?} value
* @param {?} sourceSpan
*/
function AttrAst(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
AttrAst.prototype.visit = function (visitor, context) { return visitor.visitAttr(this, context); };
return AttrAst;
}());
/**
* A binding for an element property (e.g. `[property]="expression"`) or an animation trigger (e.g.
* `[\@trigger]="stateExp"`)
*/
var BoundElementPropertyAst = (function () {
/**
* @param {?} name
* @param {?} type
* @param {?} securityContext
* @param {?} value
* @param {?} unit
* @param {?} sourceSpan
*/
function BoundElementPropertyAst(name, type, securityContext, value, unit, sourceSpan) {
this.name = name;
this.type = type;
this.securityContext = securityContext;
this.value = value;
this.unit = unit;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundElementPropertyAst.prototype.visit = function (visitor, context) {
return visitor.visitElementProperty(this, context);
};
Object.defineProperty(BoundElementPropertyAst.prototype, "isAnimation", {
/**
* @return {?}
*/
get: function () { return this.type === PropertyBindingType.Animation; },
enumerable: true,
configurable: true
});
return BoundElementPropertyAst;
}());
/**
* A binding for an element event (e.g. `(event)="handler()"`) or an animation trigger event (e.g.
* `(\@trigger.phase)="callback($event)"`).
*/
var BoundEventAst = (function () {
/**
* @param {?} name
* @param {?} target
* @param {?} phase
* @param {?} handler
* @param {?} sourceSpan
*/
function BoundEventAst(name, target, phase, handler, sourceSpan) {
this.name = name;
this.target = target;
this.phase = phase;
this.handler = handler;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} name
* @param {?} target
* @param {?} phase
* @return {?}
*/
BoundEventAst.calcFullName = function (name, target, phase) {
if (target) {
return target + ":" + name;
}
else if (phase) {
return "@" + name + "." + phase;
}
else {
return name;
}
};
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundEventAst.prototype.visit = function (visitor, context) {
return visitor.visitEvent(this, context);
};
Object.defineProperty(BoundEventAst.prototype, "fullName", {
/**
* @return {?}
*/
get: function () { return BoundEventAst.calcFullName(this.name, this.target, this.phase); },
enumerable: true,
configurable: true
});
Object.defineProperty(BoundEventAst.prototype, "isAnimation", {
/**
* @return {?}
*/
get: function () { return !!this.phase; },
enumerable: true,
configurable: true
});
return BoundEventAst;
}());
/**
* A reference declaration on an element (e.g. `let someName="expression"`).
*/
var ReferenceAst = (function () {
/**
* @param {?} name
* @param {?} value
* @param {?} sourceSpan
*/
function ReferenceAst(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
ReferenceAst.prototype.visit = function (visitor, context) {
return visitor.visitReference(this, context);
};
return ReferenceAst;
}());
/**
* A variable declaration on a (e.g. `var-someName="someLocalName"`).
*/
var VariableAst = (function () {
/**
* @param {?} name
* @param {?} value
* @param {?} sourceSpan
*/
function VariableAst(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
VariableAst.prototype.visit = function (visitor, context) {
return visitor.visitVariable(this, context);
};
return VariableAst;
}());
/**
* An element declaration in a template.
*/
var ElementAst = (function () {
/**
* @param {?} name
* @param {?} attrs
* @param {?} inputs
* @param {?} outputs
* @param {?} references
* @param {?} directives
* @param {?} providers
* @param {?} hasViewContainer
* @param {?} queryMatches
* @param {?} children
* @param {?} ngContentIndex
* @param {?} sourceSpan
* @param {?} endSourceSpan
*/
function ElementAst(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan, endSourceSpan) {
this.name = name;
this.attrs = attrs;
this.inputs = inputs;
this.outputs = outputs;
this.references = references;
this.directives = directives;
this.providers = providers;
this.hasViewContainer = hasViewContainer;
this.queryMatches = queryMatches;
this.children = children;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
this.endSourceSpan = endSourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
ElementAst.prototype.visit = function (visitor, context) {
return visitor.visitElement(this, context);
};
return ElementAst;
}());
/**
* A `` element included in an Angular template.
*/
var EmbeddedTemplateAst = (function () {
/**
* @param {?} attrs
* @param {?} outputs
* @param {?} references
* @param {?} variables
* @param {?} directives
* @param {?} providers
* @param {?} hasViewContainer
* @param {?} queryMatches
* @param {?} children
* @param {?} ngContentIndex
* @param {?} sourceSpan
*/
function EmbeddedTemplateAst(attrs, outputs, references, variables, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan) {
this.attrs = attrs;
this.outputs = outputs;
this.references = references;
this.variables = variables;
this.directives = directives;
this.providers = providers;
this.hasViewContainer = hasViewContainer;
this.queryMatches = queryMatches;
this.children = children;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
EmbeddedTemplateAst.prototype.visit = function (visitor, context) {
return visitor.visitEmbeddedTemplate(this, context);
};
return EmbeddedTemplateAst;
}());
/**
* A directive property with a bound value (e.g. `*ngIf="condition").
*/
var BoundDirectivePropertyAst = (function () {
/**
* @param {?} directiveName
* @param {?} templateName
* @param {?} value
* @param {?} sourceSpan
*/
function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) {
this.directiveName = directiveName;
this.templateName = templateName;
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
BoundDirectivePropertyAst.prototype.visit = function (visitor, context) {
return visitor.visitDirectiveProperty(this, context);
};
return BoundDirectivePropertyAst;
}());
/**
* A directive declared on an element.
*/
var DirectiveAst = (function () {
/**
* @param {?} directive
* @param {?} inputs
* @param {?} hostProperties
* @param {?} hostEvents
* @param {?} contentQueryStartId
* @param {?} sourceSpan
*/
function DirectiveAst(directive, inputs, hostProperties, hostEvents, contentQueryStartId, sourceSpan) {
this.directive = directive;
this.inputs = inputs;
this.hostProperties = hostProperties;
this.hostEvents = hostEvents;
this.contentQueryStartId = contentQueryStartId;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
DirectiveAst.prototype.visit = function (visitor, context) {
return visitor.visitDirective(this, context);
};
return DirectiveAst;
}());
/**
* A provider declared on an element
*/
var ProviderAst = (function () {
/**
* @param {?} token
* @param {?} multiProvider
* @param {?} eager
* @param {?} providers
* @param {?} providerType
* @param {?} lifecycleHooks
* @param {?} sourceSpan
*/
function ProviderAst(token, multiProvider, eager, providers, providerType, lifecycleHooks, sourceSpan) {
this.token = token;
this.multiProvider = multiProvider;
this.eager = eager;
this.providers = providers;
this.providerType = providerType;
this.lifecycleHooks = lifecycleHooks;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
ProviderAst.prototype.visit = function (visitor, context) {
// No visit method in the visitor for now...
return null;
};
return ProviderAst;
}());
var ProviderAstType = {};
ProviderAstType.PublicService = 0;
ProviderAstType.PrivateService = 1;
ProviderAstType.Component = 2;
ProviderAstType.Directive = 3;
ProviderAstType.Builtin = 4;
ProviderAstType[ProviderAstType.PublicService] = "PublicService";
ProviderAstType[ProviderAstType.PrivateService] = "PrivateService";
ProviderAstType[ProviderAstType.Component] = "Component";
ProviderAstType[ProviderAstType.Directive] = "Directive";
ProviderAstType[ProviderAstType.Builtin] = "Builtin";
/**
* Position where content is to be projected (instance of `` in a template).
*/
var NgContentAst = (function () {
/**
* @param {?} index
* @param {?} ngContentIndex
* @param {?} sourceSpan
*/
function NgContentAst(index, ngContentIndex, sourceSpan) {
this.index = index;
this.ngContentIndex = ngContentIndex;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
NgContentAst.prototype.visit = function (visitor, context) {
return visitor.visitNgContent(this, context);
};
return NgContentAst;
}());
var PropertyBindingType = {};
PropertyBindingType.Property = 0;
PropertyBindingType.Attribute = 1;
PropertyBindingType.Class = 2;
PropertyBindingType.Style = 3;
PropertyBindingType.Animation = 4;
PropertyBindingType[PropertyBindingType.Property] = "Property";
PropertyBindingType[PropertyBindingType.Attribute] = "Attribute";
PropertyBindingType[PropertyBindingType.Class] = "Class";
PropertyBindingType[PropertyBindingType.Style] = "Style";
PropertyBindingType[PropertyBindingType.Animation] = "Animation";
/**
* Visit every node in a list of {\@link TemplateAst}s with the given {\@link TemplateAstVisitor}.
* @param {?} visitor
* @param {?} asts
* @param {?=} context
* @return {?}
*/
function templateVisitAll(visitor, asts, context) {
if (context === void 0) { context = null; }
var /** @type {?} */ result = [];
var /** @type {?} */ visit = visitor.visit ?
function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
function (ast) { return ast.visit(visitor, context); };
asts.forEach(function (ast) {
var /** @type {?} */ astResult = visit(ast);
if (astResult) {
result.push(astResult);
}
});
return result;
}
/**
* A token representing the a reference to a static type.
*
* This token is unique for a filePath and name and can be used as a hash table key.
*/
var StaticSymbol = (function () {
/**
* @param {?} filePath
* @param {?} name
* @param {?} members
*/
function StaticSymbol(filePath, name, members) {
this.filePath = filePath;
this.name = name;
this.members = members;
}
/**
* @return {?}
*/
StaticSymbol.prototype.assertNoMembers = function () {
if (this.members.length) {
throw new Error("Illegal state: symbol without members expected, but got " + JSON.stringify(this) + ".");
}
};
return StaticSymbol;
}());
/**
* A cache of static symbol used by the StaticReflector to return the same symbol for the
* same symbol values.
*/
var StaticSymbolCache = (function () {
function StaticSymbolCache() {
this.cache = new Map();
}
/**
* @param {?} declarationFile
* @param {?} name
* @param {?=} members
* @return {?}
*/
StaticSymbolCache.prototype.get = function (declarationFile, name, members) {
members = members || [];
var /** @type {?} */ memberSuffix = members.length ? "." + members.join('.') : '';
var /** @type {?} */ key = "\"" + declarationFile + "\"." + name + memberSuffix;
var /** @type {?} */ result = this.cache.get(key);
if (!result) {
result = new StaticSymbol(declarationFile, name, members);
this.cache.set(key, result);
}
return result;
};
return StaticSymbolCache;
}());
var TagContentType = {};
TagContentType.RAW_TEXT = 0;
TagContentType.ESCAPABLE_RAW_TEXT = 1;
TagContentType.PARSABLE_DATA = 2;
TagContentType[TagContentType.RAW_TEXT] = "RAW_TEXT";
TagContentType[TagContentType.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
TagContentType[TagContentType.PARSABLE_DATA] = "PARSABLE_DATA";
/**
* @param {?} elementName
* @return {?}
*/
function splitNsName(elementName) {
if (elementName[0] != ':') {
return [null, elementName];
}
var /** @type {?} */ colonIndex = elementName.indexOf(':', 1);
if (colonIndex == -1) {
throw new Error("Unsupported format \"" + elementName + "\" expecting \":namespace:name\"");
}
return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
}
/**
* @param {?} tagName
* @return {?}
*/
function isNgContainer(tagName) {
return splitNsName(tagName)[1] === 'ng-container';
}
/**
* @param {?} tagName
* @return {?}
*/
function isNgContent(tagName) {
return splitNsName(tagName)[1] === 'ng-content';
}
/**
* @param {?} tagName
* @return {?}
*/
function isNgTemplate(tagName) {
return splitNsName(tagName)[1] === 'ng-template';
}
/**
* @param {?} fullName
* @return {?}
*/
function getNsPrefix(fullName) {
return fullName === null ? null : splitNsName(fullName)[0];
}
/**
* @param {?} prefix
* @param {?} localName
* @return {?}
*/
function mergeNsAndName(prefix, localName) {
return prefix ? ":" + prefix + ":" + localName : localName;
}
// see http://www.w3.org/TR/html51/syntax.html#named-character-references
// see https://html.spec.whatwg.org/multipage/entities.json
// This list is not exhaustive to keep the compiler footprint low.
// The `{` / `ƫ` syntax should be used when the named character reference does not
// exist.
var NAMED_ENTITIES = {
'Aacute': '\u00C1',
'aacute': '\u00E1',
'Acirc': '\u00C2',
'acirc': '\u00E2',
'acute': '\u00B4',
'AElig': '\u00C6',
'aelig': '\u00E6',
'Agrave': '\u00C0',
'agrave': '\u00E0',
'alefsym': '\u2135',
'Alpha': '\u0391',
'alpha': '\u03B1',
'amp': '&',
'and': '\u2227',
'ang': '\u2220',
'apos': '\u0027',
'Aring': '\u00C5',
'aring': '\u00E5',
'asymp': '\u2248',
'Atilde': '\u00C3',
'atilde': '\u00E3',
'Auml': '\u00C4',
'auml': '\u00E4',
'bdquo': '\u201E',
'Beta': '\u0392',
'beta': '\u03B2',
'brvbar': '\u00A6',
'bull': '\u2022',
'cap': '\u2229',
'Ccedil': '\u00C7',
'ccedil': '\u00E7',
'cedil': '\u00B8',
'cent': '\u00A2',
'Chi': '\u03A7',
'chi': '\u03C7',
'circ': '\u02C6',
'clubs': '\u2663',
'cong': '\u2245',
'copy': '\u00A9',
'crarr': '\u21B5',
'cup': '\u222A',
'curren': '\u00A4',
'dagger': '\u2020',
'Dagger': '\u2021',
'darr': '\u2193',
'dArr': '\u21D3',
'deg': '\u00B0',
'Delta': '\u0394',
'delta': '\u03B4',
'diams': '\u2666',
'divide': '\u00F7',
'Eacute': '\u00C9',
'eacute': '\u00E9',
'Ecirc': '\u00CA',
'ecirc': '\u00EA',
'Egrave': '\u00C8',
'egrave': '\u00E8',
'empty': '\u2205',
'emsp': '\u2003',
'ensp': '\u2002',
'Epsilon': '\u0395',
'epsilon': '\u03B5',
'equiv': '\u2261',
'Eta': '\u0397',
'eta': '\u03B7',
'ETH': '\u00D0',
'eth': '\u00F0',
'Euml': '\u00CB',
'euml': '\u00EB',
'euro': '\u20AC',
'exist': '\u2203',
'fnof': '\u0192',
'forall': '\u2200',
'frac12': '\u00BD',
'frac14': '\u00BC',
'frac34': '\u00BE',
'frasl': '\u2044',
'Gamma': '\u0393',
'gamma': '\u03B3',
'ge': '\u2265',
'gt': '>',
'harr': '\u2194',
'hArr': '\u21D4',
'hearts': '\u2665',
'hellip': '\u2026',
'Iacute': '\u00CD',
'iacute': '\u00ED',
'Icirc': '\u00CE',
'icirc': '\u00EE',
'iexcl': '\u00A1',
'Igrave': '\u00CC',
'igrave': '\u00EC',
'image': '\u2111',
'infin': '\u221E',
'int': '\u222B',
'Iota': '\u0399',
'iota': '\u03B9',
'iquest': '\u00BF',
'isin': '\u2208',
'Iuml': '\u00CF',
'iuml': '\u00EF',
'Kappa': '\u039A',
'kappa': '\u03BA',
'Lambda': '\u039B',
'lambda': '\u03BB',
'lang': '\u27E8',
'laquo': '\u00AB',
'larr': '\u2190',
'lArr': '\u21D0',
'lceil': '\u2308',
'ldquo': '\u201C',
'le': '\u2264',
'lfloor': '\u230A',
'lowast': '\u2217',
'loz': '\u25CA',
'lrm': '\u200E',
'lsaquo': '\u2039',
'lsquo': '\u2018',
'lt': '<',
'macr': '\u00AF',
'mdash': '\u2014',
'micro': '\u00B5',
'middot': '\u00B7',
'minus': '\u2212',
'Mu': '\u039C',
'mu': '\u03BC',
'nabla': '\u2207',
'nbsp': '\u00A0',
'ndash': '\u2013',
'ne': '\u2260',
'ni': '\u220B',
'not': '\u00AC',
'notin': '\u2209',
'nsub': '\u2284',
'Ntilde': '\u00D1',
'ntilde': '\u00F1',
'Nu': '\u039D',
'nu': '\u03BD',
'Oacute': '\u00D3',
'oacute': '\u00F3',
'Ocirc': '\u00D4',
'ocirc': '\u00F4',
'OElig': '\u0152',
'oelig': '\u0153',
'Ograve': '\u00D2',
'ograve': '\u00F2',
'oline': '\u203E',
'Omega': '\u03A9',
'omega': '\u03C9',
'Omicron': '\u039F',
'omicron': '\u03BF',
'oplus': '\u2295',
'or': '\u2228',
'ordf': '\u00AA',
'ordm': '\u00BA',
'Oslash': '\u00D8',
'oslash': '\u00F8',
'Otilde': '\u00D5',
'otilde': '\u00F5',
'otimes': '\u2297',
'Ouml': '\u00D6',
'ouml': '\u00F6',
'para': '\u00B6',
'permil': '\u2030',
'perp': '\u22A5',
'Phi': '\u03A6',
'phi': '\u03C6',
'Pi': '\u03A0',
'pi': '\u03C0',
'piv': '\u03D6',
'plusmn': '\u00B1',
'pound': '\u00A3',
'prime': '\u2032',
'Prime': '\u2033',
'prod': '\u220F',
'prop': '\u221D',
'Psi': '\u03A8',
'psi': '\u03C8',
'quot': '\u0022',
'radic': '\u221A',
'rang': '\u27E9',
'raquo': '\u00BB',
'rarr': '\u2192',
'rArr': '\u21D2',
'rceil': '\u2309',
'rdquo': '\u201D',
'real': '\u211C',
'reg': '\u00AE',
'rfloor': '\u230B',
'Rho': '\u03A1',
'rho': '\u03C1',
'rlm': '\u200F',
'rsaquo': '\u203A',
'rsquo': '\u2019',
'sbquo': '\u201A',
'Scaron': '\u0160',
'scaron': '\u0161',
'sdot': '\u22C5',
'sect': '\u00A7',
'shy': '\u00AD',
'Sigma': '\u03A3',
'sigma': '\u03C3',
'sigmaf': '\u03C2',
'sim': '\u223C',
'spades': '\u2660',
'sub': '\u2282',
'sube': '\u2286',
'sum': '\u2211',
'sup': '\u2283',
'sup1': '\u00B9',
'sup2': '\u00B2',
'sup3': '\u00B3',
'supe': '\u2287',
'szlig': '\u00DF',
'Tau': '\u03A4',
'tau': '\u03C4',
'there4': '\u2234',
'Theta': '\u0398',
'theta': '\u03B8',
'thetasym': '\u03D1',
'thinsp': '\u2009',
'THORN': '\u00DE',
'thorn': '\u00FE',
'tilde': '\u02DC',
'times': '\u00D7',
'trade': '\u2122',
'Uacute': '\u00DA',
'uacute': '\u00FA',
'uarr': '\u2191',
'uArr': '\u21D1',
'Ucirc': '\u00DB',
'ucirc': '\u00FB',
'Ugrave': '\u00D9',
'ugrave': '\u00F9',
'uml': '\u00A8',
'upsih': '\u03D2',
'Upsilon': '\u03A5',
'upsilon': '\u03C5',
'Uuml': '\u00DC',
'uuml': '\u00FC',
'weierp': '\u2118',
'Xi': '\u039E',
'xi': '\u03BE',
'Yacute': '\u00DD',
'yacute': '\u00FD',
'yen': '\u00A5',
'yuml': '\u00FF',
'Yuml': '\u0178',
'Zeta': '\u0396',
'zeta': '\u03B6',
'zwj': '\u200D',
'zwnj': '\u200C',
};
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var HtmlTagDefinition = (function () {
/**
* @param {?=} __0
*/
function HtmlTagDefinition(_a) {
var _b = _a === void 0 ? {} : _a, closedByChildren = _b.closedByChildren, requiredParents = _b.requiredParents, implicitNamespacePrefix = _b.implicitNamespacePrefix, _c = _b.contentType, contentType = _c === void 0 ? TagContentType.PARSABLE_DATA : _c, _d = _b.closedByParent, closedByParent = _d === void 0 ? false : _d, _e = _b.isVoid, isVoid = _e === void 0 ? false : _e, _f = _b.ignoreFirstLf, ignoreFirstLf = _f === void 0 ? false : _f;
var _this = this;
this.closedByChildren = {};
this.closedByParent = false;
this.canSelfClose = false;
if (closedByChildren && closedByChildren.length > 0) {
closedByChildren.forEach(function (tagName) { return _this.closedByChildren[tagName] = true; });
}
this.isVoid = isVoid;
this.closedByParent = closedByParent || isVoid;
if (requiredParents && requiredParents.length > 0) {
this.requiredParents = {};
// The first parent is the list is automatically when none of the listed parents are present
this.parentToAdd = requiredParents[0];
requiredParents.forEach(function (tagName) { return _this.requiredParents[tagName] = true; });
}
this.implicitNamespacePrefix = implicitNamespacePrefix || null;
this.contentType = contentType;
this.ignoreFirstLf = ignoreFirstLf;
}
/**
* @param {?} currentParent
* @return {?}
*/
HtmlTagDefinition.prototype.requireExtraParent = function (currentParent) {
if (!this.requiredParents) {
return false;
}
if (!currentParent) {
return true;
}
var /** @type {?} */ lcParent = currentParent.toLowerCase();
var /** @type {?} */ isParentTemplate = lcParent === 'template' || currentParent === 'ng-template';
return !isParentTemplate && this.requiredParents[lcParent] != true;
};
/**
* @param {?} name
* @return {?}
*/
HtmlTagDefinition.prototype.isClosedByChild = function (name) {
return this.isVoid || name.toLowerCase() in this.closedByChildren;
};
return HtmlTagDefinition;
}());
// see http://www.w3.org/TR/html51/syntax.html#optional-tags
// This implementation does not fully conform to the HTML5 spec.
var TAG_DEFINITIONS = {
'base': new HtmlTagDefinition({ isVoid: true }),
'meta': new HtmlTagDefinition({ isVoid: true }),
'area': new HtmlTagDefinition({ isVoid: true }),
'embed': new HtmlTagDefinition({ isVoid: true }),
'link': new HtmlTagDefinition({ isVoid: true }),
'img': new HtmlTagDefinition({ isVoid: true }),
'input': new HtmlTagDefinition({ isVoid: true }),
'param': new HtmlTagDefinition({ isVoid: true }),
'hr': new HtmlTagDefinition({ isVoid: true }),
'br': new HtmlTagDefinition({ isVoid: true }),
'source': new HtmlTagDefinition({ isVoid: true }),
'track': new HtmlTagDefinition({ isVoid: true }),
'wbr': new HtmlTagDefinition({ isVoid: true }),
'p': new HtmlTagDefinition({
closedByChildren: [
'address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr',
'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'
],
closedByParent: true
}),
'thead': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'] }),
'tbody': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'], closedByParent: true }),
'tfoot': new HtmlTagDefinition({ closedByChildren: ['tbody'], closedByParent: true }),
'tr': new HtmlTagDefinition({
closedByChildren: ['tr'],
requiredParents: ['tbody', 'tfoot', 'thead'],
closedByParent: true
}),
'td': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
'th': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
'col': new HtmlTagDefinition({ requiredParents: ['colgroup'], isVoid: true }),
'svg': new HtmlTagDefinition({ implicitNamespacePrefix: 'svg' }),
'math': new HtmlTagDefinition({ implicitNamespacePrefix: 'math' }),
'li': new HtmlTagDefinition({ closedByChildren: ['li'], closedByParent: true }),
'dt': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'] }),
'dd': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'], closedByParent: true }),
'rb': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
'rt': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
'rtc': new HtmlTagDefinition({ closedByChildren: ['rb', 'rtc', 'rp'], closedByParent: true }),
'rp': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
'optgroup': new HtmlTagDefinition({ closedByChildren: ['optgroup'], closedByParent: true }),
'option': new HtmlTagDefinition({ closedByChildren: ['option', 'optgroup'], closedByParent: true }),
'pre': new HtmlTagDefinition({ ignoreFirstLf: true }),
'listing': new HtmlTagDefinition({ ignoreFirstLf: true }),
'style': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
'script': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
'title': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT }),
'textarea': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true }),
};
var _DEFAULT_TAG_DEFINITION = new HtmlTagDefinition();
/**
* @param {?} tagName
* @return {?}
*/
function getHtmlTagDefinition(tagName) {
return TAG_DEFINITIONS[tagName.toLowerCase()] || _DEFAULT_TAG_DEFINITION;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' +
'([-\\w]+)|' +
'(?:\\.([-\\w]+))|' +
// "-" should appear first in the regexp below as FF31 parses "[.-\w]" as a range
'(?:\\[([-.\\w*]+)(?:=([\"\']?)([^\\]\"\']*)\\5)?\\])|' +
// "[name="value"]",
// "[name='value']"
'(\\))|' +
'(\\s*,\\s*)', // ","
'g');
/**
* A css selector contains an element name,
* css classes and attribute/value pairs with the purpose
* of selecting subsets out of them.
*/
var CssSelector = (function () {
function CssSelector() {
this.element = null;
this.classNames = [];
this.attrs = [];
this.notSelectors = [];
}
/**
* @param {?} selector
* @return {?}
*/
CssSelector.parse = function (selector) {
var /** @type {?} */ results = [];
var /** @type {?} */ _addResult = function (res, cssSel) {
if (cssSel.notSelectors.length > 0 && !cssSel.element && cssSel.classNames.length == 0 &&
cssSel.attrs.length == 0) {
cssSel.element = '*';
}
res.push(cssSel);
};
var /** @type {?} */ cssSelector = new CssSelector();
var /** @type {?} */ match;
var /** @type {?} */ current = cssSelector;
var /** @type {?} */ inNot = false;
_SELECTOR_REGEXP.lastIndex = 0;
while (match = _SELECTOR_REGEXP.exec(selector)) {
if (match[1]) {
if (inNot) {
throw new Error('Nesting :not is not allowed in a selector');
}
inNot = true;
current = new CssSelector();
cssSelector.notSelectors.push(current);
}
if (match[2]) {
current.setElement(match[2]);
}
if (match[3]) {
current.addClassName(match[3]);
}
if (match[4]) {
current.addAttribute(match[4], match[6]);
}
if (match[7]) {
inNot = false;
current = cssSelector;
}
if (match[8]) {
if (inNot) {
throw new Error('Multiple selectors in :not are not supported');
}
_addResult(results, cssSelector);
cssSelector = current = new CssSelector();
}
}
_addResult(results, cssSelector);
return results;
};
/**
* @return {?}
*/
CssSelector.prototype.isElementSelector = function () {
return this.hasElementSelector() && this.classNames.length == 0 && this.attrs.length == 0 &&
this.notSelectors.length === 0;
};
/**
* @return {?}
*/
CssSelector.prototype.hasElementSelector = function () { return !!this.element; };
/**
* @param {?=} element
* @return {?}
*/
CssSelector.prototype.setElement = function (element) {
if (element === void 0) { element = null; }
this.element = element;
};
/**
* Gets a template string for an element that matches the selector.
* @return {?}
*/
CssSelector.prototype.getMatchingElementTemplate = function () {
var /** @type {?} */ tagName = this.element || 'div';
var /** @type {?} */ classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : '';
var /** @type {?} */ attrs = '';
for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
var /** @type {?} */ attrName = this.attrs[i];
var /** @type {?} */ attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : '';
attrs += " " + attrName + attrValue;
}
return getHtmlTagDefinition(tagName).isVoid ? "<" + tagName + classAttr + attrs + "/>" :
"<" + tagName + classAttr + attrs + ">" + tagName + ">";
};
/**
* @param {?} name
* @param {?=} value
* @return {?}
*/
CssSelector.prototype.addAttribute = function (name, value) {
if (value === void 0) { value = ''; }
this.attrs.push(name, value && value.toLowerCase() || '');
};
/**
* @param {?} name
* @return {?}
*/
CssSelector.prototype.addClassName = function (name) { this.classNames.push(name.toLowerCase()); };
/**
* @return {?}
*/
CssSelector.prototype.toString = function () {
var /** @type {?} */ res = this.element || '';
if (this.classNames) {
this.classNames.forEach(function (klass) { return res += "." + klass; });
}
if (this.attrs) {
for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
var /** @type {?} */ name = this.attrs[i];
var /** @type {?} */ value = this.attrs[i + 1];
res += "[" + name + (value ? '=' + value : '') + "]";
}
}
this.notSelectors.forEach(function (notSelector) { return res += ":not(" + notSelector + ")"; });
return res;
};
return CssSelector;
}());
/**
* Reads a list of CssSelectors and allows to calculate which ones
* are contained in a given CssSelector.
*/
var SelectorMatcher = (function () {
function SelectorMatcher() {
this._elementMap = new Map();
this._elementPartialMap = new Map();
this._classMap = new Map();
this._classPartialMap = new Map();
this._attrValueMap = new Map();
this._attrValuePartialMap = new Map();
this._listContexts = [];
}
/**
* @param {?} notSelectors
* @return {?}
*/
SelectorMatcher.createNotMatcher = function (notSelectors) {
var /** @type {?} */ notMatcher = new SelectorMatcher();
notMatcher.addSelectables(notSelectors, null);
return notMatcher;
};
/**
* @param {?} cssSelectors
* @param {?=} callbackCtxt
* @return {?}
*/
SelectorMatcher.prototype.addSelectables = function (cssSelectors, callbackCtxt) {
var /** @type {?} */ listContext = ((null));
if (cssSelectors.length > 1) {
listContext = new SelectorListContext(cssSelectors);
this._listContexts.push(listContext);
}
for (var /** @type {?} */ i = 0; i < cssSelectors.length; i++) {
this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
}
};
/**
* Add an object that can be found later on by calling `match`.
* @param {?} cssSelector A css selector
* @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function
* @param {?} listContext
* @return {?}
*/
SelectorMatcher.prototype._addSelectable = function (cssSelector, callbackCtxt, listContext) {
var /** @type {?} */ matcher = this;
var /** @type {?} */ element = cssSelector.element;
var /** @type {?} */ classNames = cssSelector.classNames;
var /** @type {?} */ attrs = cssSelector.attrs;
var /** @type {?} */ selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
if (element) {
var /** @type {?} */ isTerminal = attrs.length === 0 && classNames.length === 0;
if (isTerminal) {
this._addTerminal(matcher._elementMap, element, selectable);
}
else {
matcher = this._addPartial(matcher._elementPartialMap, element);
}
}
if (classNames) {
for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
var /** @type {?} */ isTerminal = attrs.length === 0 && i === classNames.length - 1;
var /** @type {?} */ className = classNames[i];
if (isTerminal) {
this._addTerminal(matcher._classMap, className, selectable);
}
else {
matcher = this._addPartial(matcher._classPartialMap, className);
}
}
}
if (attrs) {
for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
var /** @type {?} */ isTerminal = i === attrs.length - 2;
var /** @type {?} */ name = attrs[i];
var /** @type {?} */ value = attrs[i + 1];
if (isTerminal) {
var /** @type {?} */ terminalMap = matcher._attrValueMap;
var /** @type {?} */ terminalValuesMap = terminalMap.get(name);
if (!terminalValuesMap) {
terminalValuesMap = new Map();
terminalMap.set(name, terminalValuesMap);
}
this._addTerminal(terminalValuesMap, value, selectable);
}
else {
var /** @type {?} */ partialMap = matcher._attrValuePartialMap;
var /** @type {?} */ partialValuesMap = partialMap.get(name);
if (!partialValuesMap) {
partialValuesMap = new Map();
partialMap.set(name, partialValuesMap);
}
matcher = this._addPartial(partialValuesMap, value);
}
}
}
};
/**
* @param {?} map
* @param {?} name
* @param {?} selectable
* @return {?}
*/
SelectorMatcher.prototype._addTerminal = function (map, name, selectable) {
var /** @type {?} */ terminalList = map.get(name);
if (!terminalList) {
terminalList = [];
map.set(name, terminalList);
}
terminalList.push(selectable);
};
/**
* @param {?} map
* @param {?} name
* @return {?}
*/
SelectorMatcher.prototype._addPartial = function (map, name) {
var /** @type {?} */ matcher = map.get(name);
if (!matcher) {
matcher = new SelectorMatcher();
map.set(name, matcher);
}
return matcher;
};
/**
* Find the objects that have been added via `addSelectable`
* whose css selector is contained in the given css selector.
* @param {?} cssSelector A css selector
* @param {?} matchedCallback This callback will be called with the object handed into `addSelectable`
* @return {?} boolean true if a match was found
*/
SelectorMatcher.prototype.match = function (cssSelector, matchedCallback) {
var /** @type {?} */ result = false;
var /** @type {?} */ element = ((cssSelector.element));
var /** @type {?} */ classNames = cssSelector.classNames;
var /** @type {?} */ attrs = cssSelector.attrs;
for (var /** @type {?} */ i = 0; i < this._listContexts.length; i++) {
this._listContexts[i].alreadyMatched = false;
}
result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) ||
result;
if (classNames) {
for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
var /** @type {?} */ className = classNames[i];
result =
this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
result =
this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||
result;
}
}
if (attrs) {
for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
var /** @type {?} */ name = attrs[i];
var /** @type {?} */ value = attrs[i + 1];
var /** @type {?} */ terminalValuesMap = ((this._attrValueMap.get(name)));
if (value) {
result =
this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result;
}
result =
this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result;
var /** @type {?} */ partialValuesMap = ((this._attrValuePartialMap.get(name)));
if (value) {
result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result;
}
result =
this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result;
}
}
return result;
};
/**
* \@internal
* @param {?} map
* @param {?} name
* @param {?} cssSelector
* @param {?} matchedCallback
* @return {?}
*/
SelectorMatcher.prototype._matchTerminal = function (map, name, cssSelector, matchedCallback) {
if (!map || typeof name !== 'string') {
return false;
}
var /** @type {?} */ selectables = map.get(name) || [];
var /** @type {?} */ starSelectables = ((map.get('*')));
if (starSelectables) {
selectables = selectables.concat(starSelectables);
}
if (selectables.length === 0) {
return false;
}
var /** @type {?} */ selectable;
var /** @type {?} */ result = false;
for (var /** @type {?} */ i = 0; i < selectables.length; i++) {
selectable = selectables[i];
result = selectable.finalize(cssSelector, matchedCallback) || result;
}
return result;
};
/**
* \@internal
* @param {?} map
* @param {?} name
* @param {?} cssSelector
* @param {?} matchedCallback
* @return {?}
*/
SelectorMatcher.prototype._matchPartial = function (map, name, cssSelector, matchedCallback) {
if (!map || typeof name !== 'string') {
return false;
}
var /** @type {?} */ nestedSelector = map.get(name);
if (!nestedSelector) {
return false;
}
// TODO(perf): get rid of recursion and measure again
// TODO(perf): don't pass the whole selector into the recursion,
// but only the not processed parts
return nestedSelector.match(cssSelector, matchedCallback);
};
return SelectorMatcher;
}());
var SelectorListContext = (function () {
/**
* @param {?} selectors
*/
function SelectorListContext(selectors) {
this.selectors = selectors;
this.alreadyMatched = false;
}
return SelectorListContext;
}());
var SelectorContext = (function () {
/**
* @param {?} selector
* @param {?} cbContext
* @param {?} listContext
*/
function SelectorContext(selector, cbContext, listContext) {
this.selector = selector;
this.cbContext = cbContext;
this.listContext = listContext;
this.notSelectors = selector.notSelectors;
}
/**
* @param {?} cssSelector
* @param {?} callback
* @return {?}
*/
SelectorContext.prototype.finalize = function (cssSelector, callback) {
var /** @type {?} */ result = true;
if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) {
var /** @type {?} */ notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);
result = !notMatcher.match(cssSelector, null);
}
if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) {
if (this.listContext) {
this.listContext.alreadyMatched = true;
}
callback(this.selector, this.cbContext);
}
return result;
};
return SelectorContext;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var MODULE_SUFFIX = '';
var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
/**
* @param {?} input
* @return {?}
*/
/**
* @param {?} input
* @return {?}
*/
function dashCaseToCamelCase(input) {
return input.replace(DASH_CASE_REGEXP, function () {
var m = [];
for (var _i = 0; _i < arguments.length; _i++) {
m[_i] = arguments[_i];
}
return m[1].toUpperCase();
});
}
/**
* @param {?} input
* @param {?} defaultValues
* @return {?}
*/
function splitAtColon(input, defaultValues) {
return _splitAt(input, ':', defaultValues);
}
/**
* @param {?} input
* @param {?} defaultValues
* @return {?}
*/
function splitAtPeriod(input, defaultValues) {
return _splitAt(input, '.', defaultValues);
}
/**
* @param {?} input
* @param {?} character
* @param {?} defaultValues
* @return {?}
*/
function _splitAt(input, character, defaultValues) {
var /** @type {?} */ characterIndex = input.indexOf(character);
if (characterIndex == -1)
return defaultValues;
return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
}
/**
* @param {?} value
* @param {?} visitor
* @param {?} context
* @return {?}
*/
function visitValue(value, visitor, context) {
if (Array.isArray(value)) {
return visitor.visitArray(/** @type {?} */ (value), context);
}
if (isStrictStringMap(value)) {
return visitor.visitStringMap(/** @type {?} */ (value), context);
}
if (value == null || typeof value == 'string' || typeof value == 'number' ||
typeof value == 'boolean') {
return visitor.visitPrimitive(value, context);
}
return visitor.visitOther(value, context);
}
/**
* @param {?} val
* @return {?}
*/
function isDefined(val) {
return val !== null && val !== undefined;
}
/**
* @template T
* @param {?} val
* @return {?}
*/
function noUndefined(val) {
return val === undefined ? ((null)) : val;
}
var ValueTransformer = (function () {
function ValueTransformer() {
}
/**
* @param {?} arr
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitArray = function (arr, context) {
var _this = this;
return arr.map(function (value) { return visitValue(value, _this, context); });
};
/**
* @param {?} map
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitStringMap = function (map, context) {
var _this = this;
var /** @type {?} */ result = {};
Object.keys(map).forEach(function (key) { result[key] = visitValue(map[key], _this, context); });
return result;
};
/**
* @param {?} value
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitPrimitive = function (value, context) { return value; };
/**
* @param {?} value
* @param {?} context
* @return {?}
*/
ValueTransformer.prototype.visitOther = function (value, context) { return value; };
return ValueTransformer;
}());
var SyncAsyncResult = (function () {
/**
* @param {?} syncResult
* @param {?=} asyncResult
*/
function SyncAsyncResult(syncResult, asyncResult) {
if (asyncResult === void 0) { asyncResult = null; }
this.syncResult = syncResult;
this.asyncResult = asyncResult;
if (!asyncResult) {
this.asyncResult = Promise.resolve(syncResult);
}
}
return SyncAsyncResult;
}());
/**
* @param {?} msg
* @return {?}
*/
function syntaxError(msg) {
var /** @type {?} */ error = Error(msg);
((error))[ERROR_SYNTAX_ERROR] = true;
return error;
}
var ERROR_SYNTAX_ERROR = 'ngSyntaxError';
/**
* @param {?} error
* @return {?}
*/
function isSyntaxError(error) {
return ((error))[ERROR_SYNTAX_ERROR];
}
/**
* @param {?} s
* @return {?}
*/
function escapeRegExp(s) {
return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
}
var STRING_MAP_PROTO = Object.getPrototypeOf({});
/**
* @param {?} obj
* @return {?}
*/
function isStrictStringMap(obj) {
return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
}
/**
* @param {?} str
* @return {?}
*/
function utf8Encode(str) {
var /** @type {?} */ encoded = '';
for (var /** @type {?} */ index = 0; index < str.length; index++) {
var /** @type {?} */ codePoint = str.charCodeAt(index);
// decode surrogate
// see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) {
var /** @type {?} */ low = str.charCodeAt(index + 1);
if (low >= 0xdc00 && low <= 0xdfff) {
index++;
codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;
}
}
if (codePoint <= 0x7f) {
encoded += String.fromCharCode(codePoint);
}
else if (codePoint <= 0x7ff) {
encoded += String.fromCharCode(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80);
}
else if (codePoint <= 0xffff) {
encoded += String.fromCharCode((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
}
else if (codePoint <= 0x1fffff) {
encoded += String.fromCharCode(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
}
}
return encoded;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// group 0: "[prop] or (event) or @trigger"
// group 1: "prop" from "[prop]"
// group 2: "event" from "(event)"
// group 3: "@trigger" from "@trigger"
var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
var CompileAnimationEntryMetadata = (function () {
/**
* @param {?=} name
* @param {?=} definitions
*/
function CompileAnimationEntryMetadata(name, definitions) {
if (name === void 0) { name = null; }
if (definitions === void 0) { definitions = null; }
this.name = name;
this.definitions = definitions;
}
return CompileAnimationEntryMetadata;
}());
/**
* @abstract
*/
var CompileAnimationStateMetadata = (function () {
function CompileAnimationStateMetadata() {
}
return CompileAnimationStateMetadata;
}());
var CompileAnimationStateDeclarationMetadata = (function (_super) {
__extends(CompileAnimationStateDeclarationMetadata, _super);
/**
* @param {?} stateNameExpr
* @param {?} styles
*/
function CompileAnimationStateDeclarationMetadata(stateNameExpr, styles) {
var _this = _super.call(this) || this;
_this.stateNameExpr = stateNameExpr;
_this.styles = styles;
return _this;
}
return CompileAnimationStateDeclarationMetadata;
}(CompileAnimationStateMetadata));
var CompileAnimationStateTransitionMetadata = (function (_super) {
__extends(CompileAnimationStateTransitionMetadata, _super);
/**
* @param {?} stateChangeExpr
* @param {?} steps
*/
function CompileAnimationStateTransitionMetadata(stateChangeExpr, steps) {
var _this = _super.call(this) || this;
_this.stateChangeExpr = stateChangeExpr;
_this.steps = steps;
return _this;
}
return CompileAnimationStateTransitionMetadata;
}(CompileAnimationStateMetadata));
/**
* @abstract
*/
var CompileAnimationMetadata = (function () {
function CompileAnimationMetadata() {
}
return CompileAnimationMetadata;
}());
var CompileAnimationKeyframesSequenceMetadata = (function (_super) {
__extends(CompileAnimationKeyframesSequenceMetadata, _super);
/**
* @param {?=} steps
*/
function CompileAnimationKeyframesSequenceMetadata(steps) {
if (steps === void 0) { steps = []; }
var _this = _super.call(this) || this;
_this.steps = steps;
return _this;
}
return CompileAnimationKeyframesSequenceMetadata;
}(CompileAnimationMetadata));
var CompileAnimationStyleMetadata = (function (_super) {
__extends(CompileAnimationStyleMetadata, _super);
/**
* @param {?} offset
* @param {?=} styles
*/
function CompileAnimationStyleMetadata(offset, styles) {
if (styles === void 0) { styles = null; }
var _this = _super.call(this) || this;
_this.offset = offset;
_this.styles = styles;
return _this;
}
return CompileAnimationStyleMetadata;
}(CompileAnimationMetadata));
var CompileAnimationAnimateMetadata = (function (_super) {
__extends(CompileAnimationAnimateMetadata, _super);
/**
* @param {?=} timings
* @param {?=} styles
*/
function CompileAnimationAnimateMetadata(timings, styles) {
if (timings === void 0) { timings = 0; }
if (styles === void 0) { styles = null; }
var _this = _super.call(this) || this;
_this.timings = timings;
_this.styles = styles;
return _this;
}
return CompileAnimationAnimateMetadata;
}(CompileAnimationMetadata));
/**
* @abstract
*/
var CompileAnimationWithStepsMetadata = (function (_super) {
__extends(CompileAnimationWithStepsMetadata, _super);
/**
* @param {?=} steps
*/
function CompileAnimationWithStepsMetadata(steps) {
if (steps === void 0) { steps = null; }
var _this = _super.call(this) || this;
_this.steps = steps;
return _this;
}
return CompileAnimationWithStepsMetadata;
}(CompileAnimationMetadata));
var CompileAnimationSequenceMetadata = (function (_super) {
__extends(CompileAnimationSequenceMetadata, _super);
/**
* @param {?=} steps
*/
function CompileAnimationSequenceMetadata(steps) {
if (steps === void 0) { steps = null; }
return _super.call(this, steps) || this;
}
return CompileAnimationSequenceMetadata;
}(CompileAnimationWithStepsMetadata));
var CompileAnimationGroupMetadata = (function (_super) {
__extends(CompileAnimationGroupMetadata, _super);
/**
* @param {?=} steps
*/
function CompileAnimationGroupMetadata(steps) {
if (steps === void 0) { steps = null; }
return _super.call(this, steps) || this;
}
return CompileAnimationGroupMetadata;
}(CompileAnimationWithStepsMetadata));
/**
* @param {?} name
* @return {?}
*/
function _sanitizeIdentifier(name) {
return name.replace(/\W/g, '_');
}
var _anonymousTypeIndex = 0;
/**
* @param {?} compileIdentifier
* @return {?}
*/
function identifierName(compileIdentifier) {
if (!compileIdentifier || !compileIdentifier.reference) {
return null;
}
var /** @type {?} */ ref = compileIdentifier.reference;
if (ref instanceof StaticSymbol) {
return ref.name;
}
if (ref['__anonymousType']) {
return ref['__anonymousType'];
}
var /** @type {?} */ identifier = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["K" /* ɵstringify */])(ref);
if (identifier.indexOf('(') >= 0) {
// case: anonymous functions!
identifier = "anonymous_" + _anonymousTypeIndex++;
ref['__anonymousType'] = identifier;
}
else {
identifier = _sanitizeIdentifier(identifier);
}
return identifier;
}
/**
* @param {?} compileIdentifier
* @return {?}
*/
function identifierModuleUrl(compileIdentifier) {
var /** @type {?} */ ref = compileIdentifier.reference;
if (ref instanceof StaticSymbol) {
return ref.filePath;
}
return __WEBPACK_IMPORTED_MODULE_0__angular_core__["_23" /* ɵreflector */].importUri(ref);
}
/**
* @param {?} compType
* @param {?} embeddedTemplateIndex
* @return {?}
*/
function viewClassName(compType, embeddedTemplateIndex) {
return "View_" + identifierName({ reference: compType }) + "_" + embeddedTemplateIndex;
}
/**
* @param {?} compType
* @return {?}
*/
function rendererTypeName(compType) {
return "RenderType_" + identifierName({ reference: compType });
}
/**
* @param {?} compType
* @return {?}
*/
function hostViewClassName(compType) {
return "HostView_" + identifierName({ reference: compType });
}
/**
* @param {?} dirType
* @return {?}
*/
function dirWrapperClassName(dirType) {
return "Wrapper_" + identifierName({ reference: dirType });
}
/**
* @param {?} compType
* @return {?}
*/
function componentFactoryName(compType) {
return identifierName({ reference: compType }) + "NgFactory";
}
var CompileSummaryKind = {};
CompileSummaryKind.Pipe = 0;
CompileSummaryKind.Directive = 1;
CompileSummaryKind.NgModule = 2;
CompileSummaryKind.Injectable = 3;
CompileSummaryKind[CompileSummaryKind.Pipe] = "Pipe";
CompileSummaryKind[CompileSummaryKind.Directive] = "Directive";
CompileSummaryKind[CompileSummaryKind.NgModule] = "NgModule";
CompileSummaryKind[CompileSummaryKind.Injectable] = "Injectable";
/**
* @param {?} token
* @return {?}
*/
function tokenName(token) {
return token.value != null ? _sanitizeIdentifier(token.value) : identifierName(token.identifier);
}
/**
* @param {?} token
* @return {?}
*/
function tokenReference(token) {
if (token.identifier != null) {
return token.identifier.reference;
}
else {
return token.value;
}
}
/**
* Metadata about a stylesheet
*/
var CompileStylesheetMetadata = (function () {
/**
* @param {?=} __0
*/
function CompileStylesheetMetadata(_a) {
var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls;
this.moduleUrl = moduleUrl || null;
this.styles = _normalizeArray(styles);
this.styleUrls = _normalizeArray(styleUrls);
}
return CompileStylesheetMetadata;
}());
/**
* Metadata regarding compilation of a template.
*/
var CompileTemplateMetadata = (function () {
/**
* @param {?} __0
*/
function CompileTemplateMetadata(_a) {
var encapsulation = _a.encapsulation, template = _a.template, templateUrl = _a.templateUrl, styles = _a.styles, styleUrls = _a.styleUrls, externalStylesheets = _a.externalStylesheets, animations = _a.animations, ngContentSelectors = _a.ngContentSelectors, interpolation = _a.interpolation, isInline = _a.isInline;
this.encapsulation = encapsulation;
this.template = template;
this.templateUrl = templateUrl;
this.styles = _normalizeArray(styles);
this.styleUrls = _normalizeArray(styleUrls);
this.externalStylesheets = _normalizeArray(externalStylesheets);
this.animations = animations ? flatten(animations) : [];
this.ngContentSelectors = ngContentSelectors || [];
if (interpolation && interpolation.length != 2) {
throw new Error("'interpolation' should have a start and an end symbol.");
}
this.interpolation = interpolation;
this.isInline = isInline;
}
/**
* @return {?}
*/
CompileTemplateMetadata.prototype.toSummary = function () {
return {
animations: this.animations.map(function (anim) { return anim.name; }),
ngContentSelectors: this.ngContentSelectors,
encapsulation: this.encapsulation,
};
};
return CompileTemplateMetadata;
}());
/**
* Metadata regarding compilation of a directive.
*/
var CompileDirectiveMetadata = (function () {
/**
* @param {?} __0
*/
function CompileDirectiveMetadata(_a) {
var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, hostListeners = _a.hostListeners, hostProperties = _a.hostProperties, hostAttributes = _a.hostAttributes, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
this.isHost = !!isHost;
this.type = type;
this.isComponent = isComponent;
this.selector = selector;
this.exportAs = exportAs;
this.changeDetection = changeDetection;
this.inputs = inputs;
this.outputs = outputs;
this.hostListeners = hostListeners;
this.hostProperties = hostProperties;
this.hostAttributes = hostAttributes;
this.providers = _normalizeArray(providers);
this.viewProviders = _normalizeArray(viewProviders);
this.queries = _normalizeArray(queries);
this.viewQueries = _normalizeArray(viewQueries);
this.entryComponents = _normalizeArray(entryComponents);
this.template = template;
this.componentViewType = componentViewType;
this.rendererType = rendererType;
this.componentFactory = componentFactory;
}
/**
* @param {?} __0
* @return {?}
*/
CompileDirectiveMetadata.create = function (_a) {
var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, host = _a.host, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
var /** @type {?} */ hostListeners = {};
var /** @type {?} */ hostProperties = {};
var /** @type {?} */ hostAttributes = {};
if (host != null) {
Object.keys(host).forEach(function (key) {
var /** @type {?} */ value = host[key];
var /** @type {?} */ matches = key.match(HOST_REG_EXP);
if (matches === null) {
hostAttributes[key] = value;
}
else if (matches[1] != null) {
hostProperties[matches[1]] = value;
}
else if (matches[2] != null) {
hostListeners[matches[2]] = value;
}
});
}
var /** @type {?} */ inputsMap = {};
if (inputs != null) {
inputs.forEach(function (bindConfig) {
// canonical syntax: `dirProp: elProp`
// if there is no `:`, use dirProp = elProp
var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
inputsMap[parts[0]] = parts[1];
});
}
var /** @type {?} */ outputsMap = {};
if (outputs != null) {
outputs.forEach(function (bindConfig) {
// canonical syntax: `dirProp: elProp`
// if there is no `:`, use dirProp = elProp
var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
outputsMap[parts[0]] = parts[1];
});
}
return new CompileDirectiveMetadata({
isHost: isHost,
type: type,
isComponent: !!isComponent, selector: selector, exportAs: exportAs, changeDetection: changeDetection,
inputs: inputsMap,
outputs: outputsMap,
hostListeners: hostListeners,
hostProperties: hostProperties,
hostAttributes: hostAttributes,
providers: providers,
viewProviders: viewProviders,
queries: queries,
viewQueries: viewQueries,
entryComponents: entryComponents,
template: template,
componentViewType: componentViewType,
rendererType: rendererType,
componentFactory: componentFactory,
});
};
/**
* @return {?}
*/
CompileDirectiveMetadata.prototype.toSummary = function () {
return {
summaryKind: CompileSummaryKind.Directive,
type: this.type,
isComponent: this.isComponent,
selector: this.selector,
exportAs: this.exportAs,
inputs: this.inputs,
outputs: this.outputs,
hostListeners: this.hostListeners,
hostProperties: this.hostProperties,
hostAttributes: this.hostAttributes,
providers: this.providers,
viewProviders: this.viewProviders,
queries: this.queries,
viewQueries: this.viewQueries,
entryComponents: this.entryComponents,
changeDetection: this.changeDetection,
template: this.template && this.template.toSummary(),
componentViewType: this.componentViewType,
rendererType: this.rendererType,
componentFactory: this.componentFactory
};
};
return CompileDirectiveMetadata;
}());
/**
* Construct {\@link CompileDirectiveMetadata} from {\@link ComponentTypeMetadata} and a selector.
* @param {?} hostTypeReference
* @param {?} compMeta
* @param {?} hostViewType
* @return {?}
*/
function createHostComponentMeta(hostTypeReference, compMeta, hostViewType) {
var /** @type {?} */ template = CssSelector.parse(/** @type {?} */ ((compMeta.selector)))[0].getMatchingElementTemplate();
return CompileDirectiveMetadata.create({
isHost: true,
type: { reference: hostTypeReference, diDeps: [], lifecycleHooks: [] },
template: new CompileTemplateMetadata({
encapsulation: __WEBPACK_IMPORTED_MODULE_0__angular_core__["s" /* ViewEncapsulation */].None,
template: template,
templateUrl: '',
styles: [],
styleUrls: [],
ngContentSelectors: [],
animations: [],
isInline: true,
externalStylesheets: [],
interpolation: null
}),
exportAs: null,
changeDetection: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_6" /* ChangeDetectionStrategy */].Default,
inputs: [],
outputs: [],
host: {},
isComponent: true,
selector: '*',
providers: [],
viewProviders: [],
queries: [],
viewQueries: [],
componentViewType: hostViewType,
rendererType: { id: '__Host__', encapsulation: __WEBPACK_IMPORTED_MODULE_0__angular_core__["s" /* ViewEncapsulation */].None, styles: [], data: {} },
entryComponents: [],
componentFactory: null
});
}
var CompilePipeMetadata = (function () {
/**
* @param {?} __0
*/
function CompilePipeMetadata(_a) {
var type = _a.type, name = _a.name, pure = _a.pure;
this.type = type;
this.name = name;
this.pure = !!pure;
}
/**
* @return {?}
*/
CompilePipeMetadata.prototype.toSummary = function () {
return {
summaryKind: CompileSummaryKind.Pipe,
type: this.type,
name: this.name,
pure: this.pure
};
};
return CompilePipeMetadata;
}());
/**
* Metadata regarding compilation of a module.
*/
var CompileNgModuleMetadata = (function () {
/**
* @param {?} __0
*/
function CompileNgModuleMetadata(_a) {
var type = _a.type, providers = _a.providers, declaredDirectives = _a.declaredDirectives, exportedDirectives = _a.exportedDirectives, declaredPipes = _a.declaredPipes, exportedPipes = _a.exportedPipes, entryComponents = _a.entryComponents, bootstrapComponents = _a.bootstrapComponents, importedModules = _a.importedModules, exportedModules = _a.exportedModules, schemas = _a.schemas, transitiveModule = _a.transitiveModule, id = _a.id;
this.type = type || null;
this.declaredDirectives = _normalizeArray(declaredDirectives);
this.exportedDirectives = _normalizeArray(exportedDirectives);
this.declaredPipes = _normalizeArray(declaredPipes);
this.exportedPipes = _normalizeArray(exportedPipes);
this.providers = _normalizeArray(providers);
this.entryComponents = _normalizeArray(entryComponents);
this.bootstrapComponents = _normalizeArray(bootstrapComponents);
this.importedModules = _normalizeArray(importedModules);
this.exportedModules = _normalizeArray(exportedModules);
this.schemas = _normalizeArray(schemas);
this.id = id || null;
this.transitiveModule = transitiveModule || null;
}
/**
* @return {?}
*/
CompileNgModuleMetadata.prototype.toSummary = function () {
var /** @type {?} */ module = ((this.transitiveModule));
return {
summaryKind: CompileSummaryKind.NgModule,
type: this.type,
entryComponents: module.entryComponents,
providers: module.providers,
modules: module.modules,
exportedDirectives: module.exportedDirectives,
exportedPipes: module.exportedPipes
};
};
return CompileNgModuleMetadata;
}());
var TransitiveCompileNgModuleMetadata = (function () {
function TransitiveCompileNgModuleMetadata() {
this.directivesSet = new Set();
this.directives = [];
this.exportedDirectivesSet = new Set();
this.exportedDirectives = [];
this.pipesSet = new Set();
this.pipes = [];
this.exportedPipesSet = new Set();
this.exportedPipes = [];
this.modulesSet = new Set();
this.modules = [];
this.entryComponentsSet = new Set();
this.entryComponents = [];
this.providers = [];
}
/**
* @param {?} provider
* @param {?} module
* @return {?}
*/
TransitiveCompileNgModuleMetadata.prototype.addProvider = function (provider, module) {
this.providers.push({ provider: provider, module: module });
};
/**
* @param {?} id
* @return {?}
*/
TransitiveCompileNgModuleMetadata.prototype.addDirective = function (id) {
if (!this.directivesSet.has(id.reference)) {
this.directivesSet.add(id.reference);
this.directives.push(id);
}
};
/**
* @param {?} id
* @return {?}
*/
TransitiveCompileNgModuleMetadata.prototype.addExportedDirective = function (id) {
if (!this.exportedDirectivesSet.has(id.reference)) {
this.exportedDirectivesSet.add(id.reference);
this.exportedDirectives.push(id);
}
};
/**
* @param {?} id
* @return {?}
*/
TransitiveCompileNgModuleMetadata.prototype.addPipe = function (id) {
if (!this.pipesSet.has(id.reference)) {
this.pipesSet.add(id.reference);
this.pipes.push(id);
}
};
/**
* @param {?} id
* @return {?}
*/
TransitiveCompileNgModuleMetadata.prototype.addExportedPipe = function (id) {
if (!this.exportedPipesSet.has(id.reference)) {
this.exportedPipesSet.add(id.reference);
this.exportedPipes.push(id);
}
};
/**
* @param {?} id
* @return {?}
*/
TransitiveCompileNgModuleMetadata.prototype.addModule = function (id) {
if (!this.modulesSet.has(id.reference)) {
this.modulesSet.add(id.reference);
this.modules.push(id);
}
};
/**
* @param {?} ec
* @return {?}
*/
TransitiveCompileNgModuleMetadata.prototype.addEntryComponent = function (ec) {
if (!this.entryComponentsSet.has(ec.componentType)) {
this.entryComponentsSet.add(ec.componentType);
this.entryComponents.push(ec);
}
};
return TransitiveCompileNgModuleMetadata;
}());
/**
* @param {?} obj
* @return {?}
*/
function _normalizeArray(obj) {
return obj || [];
}
var ProviderMeta = (function () {
/**
* @param {?} token
* @param {?} __1
*/
function ProviderMeta(token, _a) {
var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi;
this.token = token;
this.useClass = useClass || null;
this.useValue = useValue;
this.useExisting = useExisting;
this.useFactory = useFactory || null;
this.dependencies = deps || null;
this.multi = !!multi;
}
return ProviderMeta;
}());
/**
* @template T
* @param {?} list
* @return {?}
*/
function flatten(list) {
return list.reduce(function (flat, item) {
var /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
return ((flat)).concat(flatItem);
}, []);
}
/**
* @param {?} url
* @return {?}
*/
function sourceUrl(url) {
// Note: We need 3 "/" so that ng shows up as a separate domain
// in the chrome dev tools.
return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///');
}
/**
* @param {?} ngModuleType
* @param {?} compMeta
* @param {?} templateMeta
* @return {?}
*/
function templateSourceUrl(ngModuleType, compMeta, templateMeta) {
var /** @type {?} */ url;
if (templateMeta.isInline) {
if (compMeta.type.reference instanceof StaticSymbol) {
// Note: a .ts file might contain multiple components with inline templates,
// so we need to give them unique urls, as these will be used for sourcemaps.
url = compMeta.type.reference.filePath + "." + compMeta.type.reference.name + ".html";
}
else {
url = identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".html";
}
}
else {
url = ((templateMeta.templateUrl));
}
// always prepend ng:// to make angular resources easy to find and not clobber
// user resources.
return sourceUrl(url);
}
/**
* @param {?} meta
* @param {?} id
* @return {?}
*/
function sharedStylesheetJitUrl(meta, id) {
var /** @type {?} */ pathParts = ((meta.moduleUrl)).split(/\/\\/g);
var /** @type {?} */ baseName = pathParts[pathParts.length - 1];
return sourceUrl("css/" + id + baseName + ".ngstyle.js");
}
/**
* @param {?} moduleMeta
* @return {?}
*/
function ngModuleJitUrl(moduleMeta) {
return sourceUrl(identifierName(moduleMeta.type) + "/module.ngfactory.js");
}
/**
* @param {?} ngModuleType
* @param {?} compMeta
* @return {?}
*/
function templateJitUrl(ngModuleType, compMeta) {
return sourceUrl(identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".ngfactory.js");
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var CompilerConfig = (function () {
/**
* @param {?=} __0
*/
function CompilerConfig(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.defaultEncapsulation, defaultEncapsulation = _c === void 0 ? __WEBPACK_IMPORTED_MODULE_0__angular_core__["s" /* ViewEncapsulation */].Emulated : _c, _d = _b.useJit, useJit = _d === void 0 ? true : _d, missingTranslation = _b.missingTranslation, enableLegacyTemplate = _b.enableLegacyTemplate;
this.defaultEncapsulation = defaultEncapsulation;
this.useJit = !!useJit;
this.missingTranslation = missingTranslation || null;
this.enableLegacyTemplate = enableLegacyTemplate !== false;
}
return CompilerConfig;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ParserError = (function () {
/**
* @param {?} message
* @param {?} input
* @param {?} errLocation
* @param {?=} ctxLocation
*/
function ParserError(message, input, errLocation, ctxLocation) {
this.input = input;
this.errLocation = errLocation;
this.ctxLocation = ctxLocation;
this.message = "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation;
}
return ParserError;
}());
var ParseSpan = (function () {
/**
* @param {?} start
* @param {?} end
*/
function ParseSpan(start, end) {
this.start = start;
this.end = end;
}
return ParseSpan;
}());
var AST = (function () {
/**
* @param {?} span
*/
function AST(span) {
this.span = span;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
AST.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return null;
};
/**
* @return {?}
*/
AST.prototype.toString = function () { return 'AST'; };
return AST;
}());
/**
* Represents a quoted expression of the form:
*
* quote = prefix `:` uninterpretedExpression
* prefix = identifier
* uninterpretedExpression = arbitrary string
*
* A quoted expression is meant to be pre-processed by an AST transformer that
* converts it into another AST that no longer contains quoted expressions.
* It is meant to allow third-party developers to extend Angular template
* expression language. The `uninterpretedExpression` part of the quote is
* therefore not interpreted by the Angular's own expression parser.
*/
var Quote = (function (_super) {
__extends(Quote, _super);
/**
* @param {?} span
* @param {?} prefix
* @param {?} uninterpretedExpression
* @param {?} location
*/
function Quote(span, prefix, uninterpretedExpression, location) {
var _this = _super.call(this, span) || this;
_this.prefix = prefix;
_this.uninterpretedExpression = uninterpretedExpression;
_this.location = location;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Quote.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitQuote(this, context);
};
/**
* @return {?}
*/
Quote.prototype.toString = function () { return 'Quote'; };
return Quote;
}(AST));
var EmptyExpr = (function (_super) {
__extends(EmptyExpr, _super);
function EmptyExpr() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
EmptyExpr.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
// do nothing
};
return EmptyExpr;
}(AST));
var ImplicitReceiver = (function (_super) {
__extends(ImplicitReceiver, _super);
function ImplicitReceiver() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
ImplicitReceiver.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitImplicitReceiver(this, context);
};
return ImplicitReceiver;
}(AST));
/**
* Multiple expressions separated by a semicolon.
*/
var Chain = (function (_super) {
__extends(Chain, _super);
/**
* @param {?} span
* @param {?} expressions
*/
function Chain(span, expressions) {
var _this = _super.call(this, span) || this;
_this.expressions = expressions;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Chain.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitChain(this, context);
};
return Chain;
}(AST));
var Conditional = (function (_super) {
__extends(Conditional, _super);
/**
* @param {?} span
* @param {?} condition
* @param {?} trueExp
* @param {?} falseExp
*/
function Conditional(span, condition, trueExp, falseExp) {
var _this = _super.call(this, span) || this;
_this.condition = condition;
_this.trueExp = trueExp;
_this.falseExp = falseExp;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Conditional.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitConditional(this, context);
};
return Conditional;
}(AST));
var PropertyRead = (function (_super) {
__extends(PropertyRead, _super);
/**
* @param {?} span
* @param {?} receiver
* @param {?} name
*/
function PropertyRead(span, receiver, name) {
var _this = _super.call(this, span) || this;
_this.receiver = receiver;
_this.name = name;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
PropertyRead.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitPropertyRead(this, context);
};
return PropertyRead;
}(AST));
var PropertyWrite = (function (_super) {
__extends(PropertyWrite, _super);
/**
* @param {?} span
* @param {?} receiver
* @param {?} name
* @param {?} value
*/
function PropertyWrite(span, receiver, name, value) {
var _this = _super.call(this, span) || this;
_this.receiver = receiver;
_this.name = name;
_this.value = value;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
PropertyWrite.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitPropertyWrite(this, context);
};
return PropertyWrite;
}(AST));
var SafePropertyRead = (function (_super) {
__extends(SafePropertyRead, _super);
/**
* @param {?} span
* @param {?} receiver
* @param {?} name
*/
function SafePropertyRead(span, receiver, name) {
var _this = _super.call(this, span) || this;
_this.receiver = receiver;
_this.name = name;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
SafePropertyRead.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitSafePropertyRead(this, context);
};
return SafePropertyRead;
}(AST));
var KeyedRead = (function (_super) {
__extends(KeyedRead, _super);
/**
* @param {?} span
* @param {?} obj
* @param {?} key
*/
function KeyedRead(span, obj, key) {
var _this = _super.call(this, span) || this;
_this.obj = obj;
_this.key = key;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
KeyedRead.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitKeyedRead(this, context);
};
return KeyedRead;
}(AST));
var KeyedWrite = (function (_super) {
__extends(KeyedWrite, _super);
/**
* @param {?} span
* @param {?} obj
* @param {?} key
* @param {?} value
*/
function KeyedWrite(span, obj, key, value) {
var _this = _super.call(this, span) || this;
_this.obj = obj;
_this.key = key;
_this.value = value;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
KeyedWrite.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitKeyedWrite(this, context);
};
return KeyedWrite;
}(AST));
var BindingPipe = (function (_super) {
__extends(BindingPipe, _super);
/**
* @param {?} span
* @param {?} exp
* @param {?} name
* @param {?} args
*/
function BindingPipe(span, exp, name, args) {
var _this = _super.call(this, span) || this;
_this.exp = exp;
_this.name = name;
_this.args = args;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
BindingPipe.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitPipe(this, context);
};
return BindingPipe;
}(AST));
var LiteralPrimitive = (function (_super) {
__extends(LiteralPrimitive, _super);
/**
* @param {?} span
* @param {?} value
*/
function LiteralPrimitive(span, value) {
var _this = _super.call(this, span) || this;
_this.value = value;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
LiteralPrimitive.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitLiteralPrimitive(this, context);
};
return LiteralPrimitive;
}(AST));
var LiteralArray = (function (_super) {
__extends(LiteralArray, _super);
/**
* @param {?} span
* @param {?} expressions
*/
function LiteralArray(span, expressions) {
var _this = _super.call(this, span) || this;
_this.expressions = expressions;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
LiteralArray.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitLiteralArray(this, context);
};
return LiteralArray;
}(AST));
var LiteralMap = (function (_super) {
__extends(LiteralMap, _super);
/**
* @param {?} span
* @param {?} keys
* @param {?} values
*/
function LiteralMap(span, keys, values) {
var _this = _super.call(this, span) || this;
_this.keys = keys;
_this.values = values;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
LiteralMap.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitLiteralMap(this, context);
};
return LiteralMap;
}(AST));
var Interpolation = (function (_super) {
__extends(Interpolation, _super);
/**
* @param {?} span
* @param {?} strings
* @param {?} expressions
*/
function Interpolation(span, strings, expressions) {
var _this = _super.call(this, span) || this;
_this.strings = strings;
_this.expressions = expressions;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Interpolation.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitInterpolation(this, context);
};
return Interpolation;
}(AST));
var Binary = (function (_super) {
__extends(Binary, _super);
/**
* @param {?} span
* @param {?} operation
* @param {?} left
* @param {?} right
*/
function Binary(span, operation, left, right) {
var _this = _super.call(this, span) || this;
_this.operation = operation;
_this.left = left;
_this.right = right;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Binary.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitBinary(this, context);
};
return Binary;
}(AST));
var PrefixNot = (function (_super) {
__extends(PrefixNot, _super);
/**
* @param {?} span
* @param {?} expression
*/
function PrefixNot(span, expression) {
var _this = _super.call(this, span) || this;
_this.expression = expression;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
PrefixNot.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitPrefixNot(this, context);
};
return PrefixNot;
}(AST));
var MethodCall = (function (_super) {
__extends(MethodCall, _super);
/**
* @param {?} span
* @param {?} receiver
* @param {?} name
* @param {?} args
*/
function MethodCall(span, receiver, name, args) {
var _this = _super.call(this, span) || this;
_this.receiver = receiver;
_this.name = name;
_this.args = args;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
MethodCall.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitMethodCall(this, context);
};
return MethodCall;
}(AST));
var SafeMethodCall = (function (_super) {
__extends(SafeMethodCall, _super);
/**
* @param {?} span
* @param {?} receiver
* @param {?} name
* @param {?} args
*/
function SafeMethodCall(span, receiver, name, args) {
var _this = _super.call(this, span) || this;
_this.receiver = receiver;
_this.name = name;
_this.args = args;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
SafeMethodCall.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitSafeMethodCall(this, context);
};
return SafeMethodCall;
}(AST));
var FunctionCall = (function (_super) {
__extends(FunctionCall, _super);
/**
* @param {?} span
* @param {?} target
* @param {?} args
*/
function FunctionCall(span, target, args) {
var _this = _super.call(this, span) || this;
_this.target = target;
_this.args = args;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
FunctionCall.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return visitor.visitFunctionCall(this, context);
};
return FunctionCall;
}(AST));
var ASTWithSource = (function (_super) {
__extends(ASTWithSource, _super);
/**
* @param {?} ast
* @param {?} source
* @param {?} location
* @param {?} errors
*/
function ASTWithSource(ast, source, location, errors) {
var _this = _super.call(this, new ParseSpan(0, source == null ? 0 : source.length)) || this;
_this.ast = ast;
_this.source = source;
_this.location = location;
_this.errors = errors;
return _this;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
ASTWithSource.prototype.visit = function (visitor, context) {
if (context === void 0) { context = null; }
return this.ast.visit(visitor, context);
};
/**
* @return {?}
*/
ASTWithSource.prototype.toString = function () { return this.source + " in " + this.location; };
return ASTWithSource;
}(AST));
var TemplateBinding = (function () {
/**
* @param {?} span
* @param {?} key
* @param {?} keyIsVar
* @param {?} name
* @param {?} expression
*/
function TemplateBinding(span, key, keyIsVar, name, expression) {
this.span = span;
this.key = key;
this.keyIsVar = keyIsVar;
this.name = name;
this.expression = expression;
}
return TemplateBinding;
}());
var RecursiveAstVisitor = (function () {
function RecursiveAstVisitor() {
}
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitBinary = function (ast, context) {
ast.left.visit(this);
ast.right.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitChain = function (ast, context) { return this.visitAll(ast.expressions, context); };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitConditional = function (ast, context) {
ast.condition.visit(this);
ast.trueExp.visit(this);
ast.falseExp.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitPipe = function (ast, context) {
ast.exp.visit(this);
this.visitAll(ast.args, context);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitFunctionCall = function (ast, context) {
((ast.target)).visit(this);
this.visitAll(ast.args, context);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitImplicitReceiver = function (ast, context) { return null; };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitInterpolation = function (ast, context) {
return this.visitAll(ast.expressions, context);
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitKeyedRead = function (ast, context) {
ast.obj.visit(this);
ast.key.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitKeyedWrite = function (ast, context) {
ast.obj.visit(this);
ast.key.visit(this);
ast.value.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitLiteralArray = function (ast, context) {
return this.visitAll(ast.expressions, context);
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitLiteralMap = function (ast, context) { return this.visitAll(ast.values, context); };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitLiteralPrimitive = function (ast, context) { return null; };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitMethodCall = function (ast, context) {
ast.receiver.visit(this);
return this.visitAll(ast.args, context);
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitPrefixNot = function (ast, context) {
ast.expression.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitPropertyRead = function (ast, context) {
ast.receiver.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitPropertyWrite = function (ast, context) {
ast.receiver.visit(this);
ast.value.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitSafePropertyRead = function (ast, context) {
ast.receiver.visit(this);
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitSafeMethodCall = function (ast, context) {
ast.receiver.visit(this);
return this.visitAll(ast.args, context);
};
/**
* @param {?} asts
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitAll = function (asts, context) {
var _this = this;
asts.forEach(function (ast) { return ast.visit(_this, context); });
return null;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
RecursiveAstVisitor.prototype.visitQuote = function (ast, context) { return null; };
return RecursiveAstVisitor;
}());
var AstTransformer = (function () {
function AstTransformer() {
}
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitImplicitReceiver = function (ast, context) { return ast; };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitInterpolation = function (ast, context) {
return new Interpolation(ast.span, ast.strings, this.visitAll(ast.expressions));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitLiteralPrimitive = function (ast, context) {
return new LiteralPrimitive(ast.span, ast.value);
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitPropertyRead = function (ast, context) {
return new PropertyRead(ast.span, ast.receiver.visit(this), ast.name);
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitPropertyWrite = function (ast, context) {
return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitSafePropertyRead = function (ast, context) {
return new SafePropertyRead(ast.span, ast.receiver.visit(this), ast.name);
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitMethodCall = function (ast, context) {
return new MethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitSafeMethodCall = function (ast, context) {
return new SafeMethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitFunctionCall = function (ast, context) {
return new FunctionCall(ast.span, /** @type {?} */ ((ast.target)).visit(this), this.visitAll(ast.args));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitLiteralArray = function (ast, context) {
return new LiteralArray(ast.span, this.visitAll(ast.expressions));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitLiteralMap = function (ast, context) {
return new LiteralMap(ast.span, ast.keys, this.visitAll(ast.values));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitBinary = function (ast, context) {
return new Binary(ast.span, ast.operation, ast.left.visit(this), ast.right.visit(this));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitPrefixNot = function (ast, context) {
return new PrefixNot(ast.span, ast.expression.visit(this));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitConditional = function (ast, context) {
return new Conditional(ast.span, ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitPipe = function (ast, context) {
return new BindingPipe(ast.span, ast.exp.visit(this), ast.name, this.visitAll(ast.args));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitKeyedRead = function (ast, context) {
return new KeyedRead(ast.span, ast.obj.visit(this), ast.key.visit(this));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitKeyedWrite = function (ast, context) {
return new KeyedWrite(ast.span, ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this));
};
/**
* @param {?} asts
* @return {?}
*/
AstTransformer.prototype.visitAll = function (asts) {
var /** @type {?} */ res = new Array(asts.length);
for (var /** @type {?} */ i = 0; i < asts.length; ++i) {
res[i] = asts[i].visit(this);
}
return res;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitChain = function (ast, context) {
return new Chain(ast.span, this.visitAll(ast.expressions));
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
AstTransformer.prototype.visitQuote = function (ast, context) {
return new Quote(ast.span, ast.prefix, ast.uninterpretedExpression, ast.location);
};
return AstTransformer;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var $EOF = 0;
var $TAB = 9;
var $LF = 10;
var $VTAB = 11;
var $FF = 12;
var $CR = 13;
var $SPACE = 32;
var $BANG = 33;
var $DQ = 34;
var $HASH = 35;
var $$ = 36;
var $PERCENT = 37;
var $AMPERSAND = 38;
var $SQ = 39;
var $LPAREN = 40;
var $RPAREN = 41;
var $STAR = 42;
var $PLUS = 43;
var $COMMA = 44;
var $MINUS = 45;
var $PERIOD = 46;
var $SLASH = 47;
var $COLON = 58;
var $SEMICOLON = 59;
var $LT = 60;
var $EQ = 61;
var $GT = 62;
var $QUESTION = 63;
var $0 = 48;
var $9 = 57;
var $A = 65;
var $E = 69;
var $F = 70;
var $X = 88;
var $Z = 90;
var $LBRACKET = 91;
var $BACKSLASH = 92;
var $RBRACKET = 93;
var $CARET = 94;
var $_ = 95;
var $a = 97;
var $e = 101;
var $f = 102;
var $n = 110;
var $r = 114;
var $t = 116;
var $u = 117;
var $v = 118;
var $x = 120;
var $z = 122;
var $LBRACE = 123;
var $BAR = 124;
var $RBRACE = 125;
var $NBSP = 160;
var $BT = 96;
/**
* @param {?} code
* @return {?}
*/
function isWhitespace(code) {
return (code >= $TAB && code <= $SPACE) || (code == $NBSP);
}
/**
* @param {?} code
* @return {?}
*/
function isDigit(code) {
return $0 <= code && code <= $9;
}
/**
* @param {?} code
* @return {?}
*/
function isAsciiLetter(code) {
return code >= $a && code <= $z || code >= $A && code <= $Z;
}
/**
* @param {?} code
* @return {?}
*/
function isAsciiHexDigit(code) {
return code >= $a && code <= $f || code >= $A && code <= $F || isDigit(code);
}
/**
* A replacement for \@Injectable to be used in the compiler, so that
* we don't try to evaluate the metadata in the compiler during AoT.
* This decorator is enough to make the compiler work with the ReflectiveInjector though.
* \@Annotation
* @return {?}
*/
function CompilerInjectable() {
return function (x) { return x; };
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} identifier
* @param {?} value
* @return {?}
*/
function assertArrayOfStrings(identifier, value) {
if (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["u" /* isDevMode */])() || value == null) {
return;
}
if (!Array.isArray(value)) {
throw new Error("Expected '" + identifier + "' to be an array of strings.");
}
for (var /** @type {?} */ i = 0; i < value.length; i += 1) {
if (typeof value[i] !== 'string') {
throw new Error("Expected '" + identifier + "' to be an array of strings.");
}
}
}
var INTERPOLATION_BLACKLIST_REGEXPS = [
/^\s*$/,
/[<>]/,
/^[{}]$/,
/&(#|[a-z])/i,
/^\/\//,
];
/**
* @param {?} identifier
* @param {?} value
* @return {?}
*/
function assertInterpolationSymbols(identifier, value) {
if (value != null && !(Array.isArray(value) && value.length == 2)) {
throw new Error("Expected '" + identifier + "' to be an array, [start, end].");
}
else if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["u" /* isDevMode */])() && value != null) {
var /** @type {?} */ start_1 = (value[0]);
var /** @type {?} */ end_1 = (value[1]);
// black list checking
INTERPOLATION_BLACKLIST_REGEXPS.forEach(function (regexp) {
if (regexp.test(start_1) || regexp.test(end_1)) {
throw new Error("['" + start_1 + "', '" + end_1 + "'] contains unusable interpolation symbol.");
}
});
}
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var InterpolationConfig = (function () {
/**
* @param {?} start
* @param {?} end
*/
function InterpolationConfig(start, end) {
this.start = start;
this.end = end;
}
/**
* @param {?} markers
* @return {?}
*/
InterpolationConfig.fromArray = function (markers) {
if (!markers) {
return DEFAULT_INTERPOLATION_CONFIG;
}
assertInterpolationSymbols('interpolation', markers);
return new InterpolationConfig(markers[0], markers[1]);
};
;
return InterpolationConfig;
}());
var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig('{{', '}}');
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var TokenType = {};
TokenType.Character = 0;
TokenType.Identifier = 1;
TokenType.Keyword = 2;
TokenType.String = 3;
TokenType.Operator = 4;
TokenType.Number = 5;
TokenType.Error = 6;
TokenType[TokenType.Character] = "Character";
TokenType[TokenType.Identifier] = "Identifier";
TokenType[TokenType.Keyword] = "Keyword";
TokenType[TokenType.String] = "String";
TokenType[TokenType.Operator] = "Operator";
TokenType[TokenType.Number] = "Number";
TokenType[TokenType.Error] = "Error";
var KEYWORDS = ['var', 'let', 'as', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this'];
var Lexer = (function () {
function Lexer() {
}
/**
* @param {?} text
* @return {?}
*/
Lexer.prototype.tokenize = function (text) {
var /** @type {?} */ scanner = new _Scanner(text);
var /** @type {?} */ tokens = [];
var /** @type {?} */ token = scanner.scanToken();
while (token != null) {
tokens.push(token);
token = scanner.scanToken();
}
return tokens;
};
return Lexer;
}());
Lexer.decorators = [
{ type: CompilerInjectable },
];
/**
* @nocollapse
*/
Lexer.ctorParameters = function () { return []; };
var Token = (function () {
/**
* @param {?} index
* @param {?} type
* @param {?} numValue
* @param {?} strValue
*/
function Token(index, type, numValue, strValue) {
this.index = index;
this.type = type;
this.numValue = numValue;
this.strValue = strValue;
}
/**
* @param {?} code
* @return {?}
*/
Token.prototype.isCharacter = function (code) {
return this.type == TokenType.Character && this.numValue == code;
};
/**
* @return {?}
*/
Token.prototype.isNumber = function () { return this.type == TokenType.Number; };
/**
* @return {?}
*/
Token.prototype.isString = function () { return this.type == TokenType.String; };
/**
* @param {?} operater
* @return {?}
*/
Token.prototype.isOperator = function (operater) {
return this.type == TokenType.Operator && this.strValue == operater;
};
/**
* @return {?}
*/
Token.prototype.isIdentifier = function () { return this.type == TokenType.Identifier; };
/**
* @return {?}
*/
Token.prototype.isKeyword = function () { return this.type == TokenType.Keyword; };
/**
* @return {?}
*/
Token.prototype.isKeywordLet = function () { return this.type == TokenType.Keyword && this.strValue == 'let'; };
/**
* @return {?}
*/
Token.prototype.isKeywordAs = function () { return this.type == TokenType.Keyword && this.strValue == 'as'; };
/**
* @return {?}
*/
Token.prototype.isKeywordNull = function () { return this.type == TokenType.Keyword && this.strValue == 'null'; };
/**
* @return {?}
*/
Token.prototype.isKeywordUndefined = function () {
return this.type == TokenType.Keyword && this.strValue == 'undefined';
};
/**
* @return {?}
*/
Token.prototype.isKeywordTrue = function () { return this.type == TokenType.Keyword && this.strValue == 'true'; };
/**
* @return {?}
*/
Token.prototype.isKeywordFalse = function () { return this.type == TokenType.Keyword && this.strValue == 'false'; };
/**
* @return {?}
*/
Token.prototype.isKeywordThis = function () { return this.type == TokenType.Keyword && this.strValue == 'this'; };
/**
* @return {?}
*/
Token.prototype.isError = function () { return this.type == TokenType.Error; };
/**
* @return {?}
*/
Token.prototype.toNumber = function () { return this.type == TokenType.Number ? this.numValue : -1; };
/**
* @return {?}
*/
Token.prototype.toString = function () {
switch (this.type) {
case TokenType.Character:
case TokenType.Identifier:
case TokenType.Keyword:
case TokenType.Operator:
case TokenType.String:
case TokenType.Error:
return this.strValue;
case TokenType.Number:
return this.numValue.toString();
default:
return null;
}
};
return Token;
}());
/**
* @param {?} index
* @param {?} code
* @return {?}
*/
function newCharacterToken(index, code) {
return new Token(index, TokenType.Character, code, String.fromCharCode(code));
}
/**
* @param {?} index
* @param {?} text
* @return {?}
*/
function newIdentifierToken(index, text) {
return new Token(index, TokenType.Identifier, 0, text);
}
/**
* @param {?} index
* @param {?} text
* @return {?}
*/
function newKeywordToken(index, text) {
return new Token(index, TokenType.Keyword, 0, text);
}
/**
* @param {?} index
* @param {?} text
* @return {?}
*/
function newOperatorToken(index, text) {
return new Token(index, TokenType.Operator, 0, text);
}
/**
* @param {?} index
* @param {?} text
* @return {?}
*/
function newStringToken(index, text) {
return new Token(index, TokenType.String, 0, text);
}
/**
* @param {?} index
* @param {?} n
* @return {?}
*/
function newNumberToken(index, n) {
return new Token(index, TokenType.Number, n, '');
}
/**
* @param {?} index
* @param {?} message
* @return {?}
*/
function newErrorToken(index, message) {
return new Token(index, TokenType.Error, 0, message);
}
var EOF = new Token(-1, TokenType.Character, 0, '');
var _Scanner = (function () {
/**
* @param {?} input
*/
function _Scanner(input) {
this.input = input;
this.peek = 0;
this.index = -1;
this.length = input.length;
this.advance();
}
/**
* @return {?}
*/
_Scanner.prototype.advance = function () {
this.peek = ++this.index >= this.length ? $EOF : this.input.charCodeAt(this.index);
};
/**
* @return {?}
*/
_Scanner.prototype.scanToken = function () {
var /** @type {?} */ input = this.input, /** @type {?} */ length = this.length;
var /** @type {?} */ peek = this.peek, /** @type {?} */ index = this.index;
// Skip whitespace.
while (peek <= $SPACE) {
if (++index >= length) {
peek = $EOF;
break;
}
else {
peek = input.charCodeAt(index);
}
}
this.peek = peek;
this.index = index;
if (index >= length) {
return null;
}
// Handle identifiers and numbers.
if (isIdentifierStart(peek))
return this.scanIdentifier();
if (isDigit(peek))
return this.scanNumber(index);
var /** @type {?} */ start = index;
switch (peek) {
case $PERIOD:
this.advance();
return isDigit(this.peek) ? this.scanNumber(start) :
newCharacterToken(start, $PERIOD);
case $LPAREN:
case $RPAREN:
case $LBRACE:
case $RBRACE:
case $LBRACKET:
case $RBRACKET:
case $COMMA:
case $COLON:
case $SEMICOLON:
return this.scanCharacter(start, peek);
case $SQ:
case $DQ:
return this.scanString();
case $HASH:
case $PLUS:
case $MINUS:
case $STAR:
case $SLASH:
case $PERCENT:
case $CARET:
return this.scanOperator(start, String.fromCharCode(peek));
case $QUESTION:
return this.scanComplexOperator(start, '?', $PERIOD, '.');
case $LT:
case $GT:
return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=');
case $BANG:
case $EQ:
return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=', $EQ, '=');
case $AMPERSAND:
return this.scanComplexOperator(start, '&', $AMPERSAND, '&');
case $BAR:
return this.scanComplexOperator(start, '|', $BAR, '|');
case $NBSP:
while (isWhitespace(this.peek))
this.advance();
return this.scanToken();
}
this.advance();
return this.error("Unexpected character [" + String.fromCharCode(peek) + "]", 0);
};
/**
* @param {?} start
* @param {?} code
* @return {?}
*/
_Scanner.prototype.scanCharacter = function (start, code) {
this.advance();
return newCharacterToken(start, code);
};
/**
* @param {?} start
* @param {?} str
* @return {?}
*/
_Scanner.prototype.scanOperator = function (start, str) {
this.advance();
return newOperatorToken(start, str);
};
/**
* Tokenize a 2/3 char long operator
*
* @param {?} start start index in the expression
* @param {?} one first symbol (always part of the operator)
* @param {?} twoCode code point for the second symbol
* @param {?} two second symbol (part of the operator when the second code point matches)
* @param {?=} threeCode code point for the third symbol
* @param {?=} three third symbol (part of the operator when provided and matches source expression)
* @return {?}
*/
_Scanner.prototype.scanComplexOperator = function (start, one, twoCode, two, threeCode, three) {
this.advance();
var /** @type {?} */ str = one;
if (this.peek == twoCode) {
this.advance();
str += two;
}
if (threeCode != null && this.peek == threeCode) {
this.advance();
str += three;
}
return newOperatorToken(start, str);
};
/**
* @return {?}
*/
_Scanner.prototype.scanIdentifier = function () {
var /** @type {?} */ start = this.index;
this.advance();
while (isIdentifierPart(this.peek))
this.advance();
var /** @type {?} */ str = this.input.substring(start, this.index);
return KEYWORDS.indexOf(str) > -1 ? newKeywordToken(start, str) :
newIdentifierToken(start, str);
};
/**
* @param {?} start
* @return {?}
*/
_Scanner.prototype.scanNumber = function (start) {
var /** @type {?} */ simple = (this.index === start);
this.advance(); // Skip initial digit.
while (true) {
if (isDigit(this.peek)) {
}
else if (this.peek == $PERIOD) {
simple = false;
}
else if (isExponentStart(this.peek)) {
this.advance();
if (isExponentSign(this.peek))
this.advance();
if (!isDigit(this.peek))
return this.error('Invalid exponent', -1);
simple = false;
}
else {
break;
}
this.advance();
}
var /** @type {?} */ str = this.input.substring(start, this.index);
var /** @type {?} */ value = simple ? parseIntAutoRadix(str) : parseFloat(str);
return newNumberToken(start, value);
};
/**
* @return {?}
*/
_Scanner.prototype.scanString = function () {
var /** @type {?} */ start = this.index;
var /** @type {?} */ quote = this.peek;
this.advance(); // Skip initial quote.
var /** @type {?} */ buffer = '';
var /** @type {?} */ marker = this.index;
var /** @type {?} */ input = this.input;
while (this.peek != quote) {
if (this.peek == $BACKSLASH) {
buffer += input.substring(marker, this.index);
this.advance();
var /** @type {?} */ unescapedCode = void 0;
// Workaround for TS2.1-introduced type strictness
this.peek = this.peek;
if (this.peek == $u) {
// 4 character hex code for unicode character.
var /** @type {?} */ hex = input.substring(this.index + 1, this.index + 5);
if (/^[0-9a-f]+$/i.test(hex)) {
unescapedCode = parseInt(hex, 16);
}
else {
return this.error("Invalid unicode escape [\\u" + hex + "]", 0);
}
for (var /** @type {?} */ i = 0; i < 5; i++) {
this.advance();
}
}
else {
unescapedCode = unescape(this.peek);
this.advance();
}
buffer += String.fromCharCode(unescapedCode);
marker = this.index;
}
else if (this.peek == $EOF) {
return this.error('Unterminated quote', 0);
}
else {
this.advance();
}
}
var /** @type {?} */ last = input.substring(marker, this.index);
this.advance(); // Skip terminating quote.
return newStringToken(start, buffer + last);
};
/**
* @param {?} message
* @param {?} offset
* @return {?}
*/
_Scanner.prototype.error = function (message, offset) {
var /** @type {?} */ position = this.index + offset;
return newErrorToken(position, "Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]");
};
return _Scanner;
}());
/**
* @param {?} code
* @return {?}
*/
function isIdentifierStart(code) {
return ($a <= code && code <= $z) || ($A <= code && code <= $Z) ||
(code == $_) || (code == $$);
}
/**
* @param {?} input
* @return {?}
*/
function isIdentifier(input) {
if (input.length == 0)
return false;
var /** @type {?} */ scanner = new _Scanner(input);
if (!isIdentifierStart(scanner.peek))
return false;
scanner.advance();
while (scanner.peek !== $EOF) {
if (!isIdentifierPart(scanner.peek))
return false;
scanner.advance();
}
return true;
}
/**
* @param {?} code
* @return {?}
*/
function isIdentifierPart(code) {
return isAsciiLetter(code) || isDigit(code) || (code == $_) ||
(code == $$);
}
/**
* @param {?} code
* @return {?}
*/
function isExponentStart(code) {
return code == $e || code == $E;
}
/**
* @param {?} code
* @return {?}
*/
function isExponentSign(code) {
return code == $MINUS || code == $PLUS;
}
/**
* @param {?} code
* @return {?}
*/
function isQuote(code) {
return code === $SQ || code === $DQ || code === $BT;
}
/**
* @param {?} code
* @return {?}
*/
function unescape(code) {
switch (code) {
case $n:
return $LF;
case $f:
return $FF;
case $r:
return $CR;
case $t:
return $TAB;
case $v:
return $VTAB;
default:
return code;
}
}
/**
* @param {?} text
* @return {?}
*/
function parseIntAutoRadix(text) {
var /** @type {?} */ result = parseInt(text);
if (isNaN(result)) {
throw new Error('Invalid integer literal when parsing ' + text);
}
return result;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var SplitInterpolation = (function () {
/**
* @param {?} strings
* @param {?} expressions
* @param {?} offsets
*/
function SplitInterpolation(strings, expressions, offsets) {
this.strings = strings;
this.expressions = expressions;
this.offsets = offsets;
}
return SplitInterpolation;
}());
var TemplateBindingParseResult = (function () {
/**
* @param {?} templateBindings
* @param {?} warnings
* @param {?} errors
*/
function TemplateBindingParseResult(templateBindings, warnings, errors) {
this.templateBindings = templateBindings;
this.warnings = warnings;
this.errors = errors;
}
return TemplateBindingParseResult;
}());
/**
* @param {?} config
* @return {?}
*/
function _createInterpolateRegExp(config) {
var /** @type {?} */ pattern = escapeRegExp(config.start) + '([\\s\\S]*?)' + escapeRegExp(config.end);
return new RegExp(pattern, 'g');
}
var Parser = (function () {
/**
* @param {?} _lexer
*/
function Parser(_lexer) {
this._lexer = _lexer;
this.errors = [];
}
/**
* @param {?} input
* @param {?} location
* @param {?=} interpolationConfig
* @return {?}
*/
Parser.prototype.parseAction = function (input, location, interpolationConfig) {
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
this._checkNoInterpolation(input, location, interpolationConfig);
var /** @type {?} */ sourceToLex = this._stripComments(input);
var /** @type {?} */ tokens = this._lexer.tokenize(this._stripComments(input));
var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, true, this.errors, input.length - sourceToLex.length)
.parseChain();
return new ASTWithSource(ast, input, location, this.errors);
};
/**
* @param {?} input
* @param {?} location
* @param {?=} interpolationConfig
* @return {?}
*/
Parser.prototype.parseBinding = function (input, location, interpolationConfig) {
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
return new ASTWithSource(ast, input, location, this.errors);
};
/**
* @param {?} input
* @param {?} location
* @param {?=} interpolationConfig
* @return {?}
*/
Parser.prototype.parseSimpleBinding = function (input, location, interpolationConfig) {
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
var /** @type {?} */ errors = SimpleExpressionChecker.check(ast);
if (errors.length > 0) {
this._reportError("Host binding expression cannot contain " + errors.join(' '), input, location);
}
return new ASTWithSource(ast, input, location, this.errors);
};
/**
* @param {?} message
* @param {?} input
* @param {?} errLocation
* @param {?=} ctxLocation
* @return {?}
*/
Parser.prototype._reportError = function (message, input, errLocation, ctxLocation) {
this.errors.push(new ParserError(message, input, errLocation, ctxLocation));
};
/**
* @param {?} input
* @param {?} location
* @param {?} interpolationConfig
* @return {?}
*/
Parser.prototype._parseBindingAst = function (input, location, interpolationConfig) {
// Quotes expressions use 3rd-party expression language. We don't want to use
// our lexer or parser for that, so we check for that ahead of time.
var /** @type {?} */ quote = this._parseQuote(input, location);
if (quote != null) {
return quote;
}
this._checkNoInterpolation(input, location, interpolationConfig);
var /** @type {?} */ sourceToLex = this._stripComments(input);
var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex);
return new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, input.length - sourceToLex.length)
.parseChain();
};
/**
* @param {?} input
* @param {?} location
* @return {?}
*/
Parser.prototype._parseQuote = function (input, location) {
if (input == null)
return null;
var /** @type {?} */ prefixSeparatorIndex = input.indexOf(':');
if (prefixSeparatorIndex == -1)
return null;
var /** @type {?} */ prefix = input.substring(0, prefixSeparatorIndex).trim();
if (!isIdentifier(prefix))
return null;
var /** @type {?} */ uninterpretedExpression = input.substring(prefixSeparatorIndex + 1);
return new Quote(new ParseSpan(0, input.length), prefix, uninterpretedExpression, location);
};
/**
* @param {?} prefixToken
* @param {?} input
* @param {?} location
* @return {?}
*/
Parser.prototype.parseTemplateBindings = function (prefixToken, input, location) {
var /** @type {?} */ tokens = this._lexer.tokenize(input);
if (prefixToken) {
// Prefix the tokens with the tokens from prefixToken but have them take no space (0 index).
var /** @type {?} */ prefixTokens = this._lexer.tokenize(prefixToken).map(function (t) {
t.index = 0;
return t;
});
tokens.unshift.apply(tokens, prefixTokens);
}
return new _ParseAST(input, location, tokens, input.length, false, this.errors, 0)
.parseTemplateBindings();
};
/**
* @param {?} input
* @param {?} location
* @param {?=} interpolationConfig
* @return {?}
*/
Parser.prototype.parseInterpolation = function (input, location, interpolationConfig) {
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
var /** @type {?} */ split = this.splitInterpolation(input, location, interpolationConfig);
if (split == null)
return null;
var /** @type {?} */ expressions = [];
for (var /** @type {?} */ i = 0; i < split.expressions.length; ++i) {
var /** @type {?} */ expressionText = split.expressions[i];
var /** @type {?} */ sourceToLex = this._stripComments(expressionText);
var /** @type {?} */ tokens = this._lexer.tokenize(this._stripComments(split.expressions[i]));
var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, split.offsets[i] + (expressionText.length - sourceToLex.length))
.parseChain();
expressions.push(ast);
}
return new ASTWithSource(new Interpolation(new ParseSpan(0, input == null ? 0 : input.length), split.strings, expressions), input, location, this.errors);
};
/**
* @param {?} input
* @param {?} location
* @param {?=} interpolationConfig
* @return {?}
*/
Parser.prototype.splitInterpolation = function (input, location, interpolationConfig) {
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
var /** @type {?} */ parts = input.split(regexp);
if (parts.length <= 1) {
return null;
}
var /** @type {?} */ strings = [];
var /** @type {?} */ expressions = [];
var /** @type {?} */ offsets = [];
var /** @type {?} */ offset = 0;
for (var /** @type {?} */ i = 0; i < parts.length; i++) {
var /** @type {?} */ part = parts[i];
if (i % 2 === 0) {
// fixed string
strings.push(part);
offset += part.length;
}
else if (part.trim().length > 0) {
offset += interpolationConfig.start.length;
expressions.push(part);
offsets.push(offset);
offset += part.length + interpolationConfig.end.length;
}
else {
this._reportError('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i, interpolationConfig) + " in", location);
expressions.push('$implict');
offsets.push(offset);
}
}
return new SplitInterpolation(strings, expressions, offsets);
};
/**
* @param {?} input
* @param {?} location
* @return {?}
*/
Parser.prototype.wrapLiteralPrimitive = function (input, location) {
return new ASTWithSource(new LiteralPrimitive(new ParseSpan(0, input == null ? 0 : input.length), input), input, location, this.errors);
};
/**
* @param {?} input
* @return {?}
*/
Parser.prototype._stripComments = function (input) {
var /** @type {?} */ i = this._commentStart(input);
return i != null ? input.substring(0, i).trim() : input;
};
/**
* @param {?} input
* @return {?}
*/
Parser.prototype._commentStart = function (input) {
var /** @type {?} */ outerQuote = null;
for (var /** @type {?} */ i = 0; i < input.length - 1; i++) {
var /** @type {?} */ char = input.charCodeAt(i);
var /** @type {?} */ nextChar = input.charCodeAt(i + 1);
if (char === $SLASH && nextChar == $SLASH && outerQuote == null)
return i;
if (outerQuote === char) {
outerQuote = null;
}
else if (outerQuote == null && isQuote(char)) {
outerQuote = char;
}
}
return null;
};
/**
* @param {?} input
* @param {?} location
* @param {?} interpolationConfig
* @return {?}
*/
Parser.prototype._checkNoInterpolation = function (input, location, interpolationConfig) {
var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
var /** @type {?} */ parts = input.split(regexp);
if (parts.length > 1) {
this._reportError("Got interpolation (" + interpolationConfig.start + interpolationConfig.end + ") where expression was expected", input, "at column " + this._findInterpolationErrorColumn(parts, 1, interpolationConfig) + " in", location);
}
};
/**
* @param {?} parts
* @param {?} partInErrIdx
* @param {?} interpolationConfig
* @return {?}
*/
Parser.prototype._findInterpolationErrorColumn = function (parts, partInErrIdx, interpolationConfig) {
var /** @type {?} */ errLocation = '';
for (var /** @type {?} */ j = 0; j < partInErrIdx; j++) {
errLocation += j % 2 === 0 ?
parts[j] :
"" + interpolationConfig.start + parts[j] + interpolationConfig.end;
}
return errLocation.length;
};
return Parser;
}());
Parser.decorators = [
{ type: CompilerInjectable },
];
/**
* @nocollapse
*/
Parser.ctorParameters = function () { return [
{ type: Lexer, },
]; };
var _ParseAST = (function () {
/**
* @param {?} input
* @param {?} location
* @param {?} tokens
* @param {?} inputLength
* @param {?} parseAction
* @param {?} errors
* @param {?} offset
*/
function _ParseAST(input, location, tokens, inputLength, parseAction, errors, offset) {
this.input = input;
this.location = location;
this.tokens = tokens;
this.inputLength = inputLength;
this.parseAction = parseAction;
this.errors = errors;
this.offset = offset;
this.rparensExpected = 0;
this.rbracketsExpected = 0;
this.rbracesExpected = 0;
this.index = 0;
}
/**
* @param {?} offset
* @return {?}
*/
_ParseAST.prototype.peek = function (offset) {
var /** @type {?} */ i = this.index + offset;
return i < this.tokens.length ? this.tokens[i] : EOF;
};
Object.defineProperty(_ParseAST.prototype, "next", {
/**
* @return {?}
*/
get: function () { return this.peek(0); },
enumerable: true,
configurable: true
});
Object.defineProperty(_ParseAST.prototype, "inputIndex", {
/**
* @return {?}
*/
get: function () {
return (this.index < this.tokens.length) ? this.next.index + this.offset :
this.inputLength + this.offset;
},
enumerable: true,
configurable: true
});
/**
* @param {?} start
* @return {?}
*/
_ParseAST.prototype.span = function (start) { return new ParseSpan(start, this.inputIndex); };
/**
* @return {?}
*/
_ParseAST.prototype.advance = function () { this.index++; };
/**
* @param {?} code
* @return {?}
*/
_ParseAST.prototype.optionalCharacter = function (code) {
if (this.next.isCharacter(code)) {
this.advance();
return true;
}
else {
return false;
}
};
/**
* @return {?}
*/
_ParseAST.prototype.peekKeywordLet = function () { return this.next.isKeywordLet(); };
/**
* @return {?}
*/
_ParseAST.prototype.peekKeywordAs = function () { return this.next.isKeywordAs(); };
/**
* @param {?} code
* @return {?}
*/
_ParseAST.prototype.expectCharacter = function (code) {
if (this.optionalCharacter(code))
return;
this.error("Missing expected " + String.fromCharCode(code));
};
/**
* @param {?} op
* @return {?}
*/
_ParseAST.prototype.optionalOperator = function (op) {
if (this.next.isOperator(op)) {
this.advance();
return true;
}
else {
return false;
}
};
/**
* @param {?} operator
* @return {?}
*/
_ParseAST.prototype.expectOperator = function (operator) {
if (this.optionalOperator(operator))
return;
this.error("Missing expected operator " + operator);
};
/**
* @return {?}
*/
_ParseAST.prototype.expectIdentifierOrKeyword = function () {
var /** @type {?} */ n = this.next;
if (!n.isIdentifier() && !n.isKeyword()) {
this.error("Unexpected token " + n + ", expected identifier or keyword");
return '';
}
this.advance();
return n.toString();
};
/**
* @return {?}
*/
_ParseAST.prototype.expectIdentifierOrKeywordOrString = function () {
var /** @type {?} */ n = this.next;
if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
this.error("Unexpected token " + n + ", expected identifier, keyword, or string");
return '';
}
this.advance();
return n.toString();
};
/**
* @return {?}
*/
_ParseAST.prototype.parseChain = function () {
var /** @type {?} */ exprs = [];
var /** @type {?} */ start = this.inputIndex;
while (this.index < this.tokens.length) {
var /** @type {?} */ expr = this.parsePipe();
exprs.push(expr);
if (this.optionalCharacter($SEMICOLON)) {
if (!this.parseAction) {
this.error('Binding expression cannot contain chained expression');
}
while (this.optionalCharacter($SEMICOLON)) {
} // read all semicolons
}
else if (this.index < this.tokens.length) {
this.error("Unexpected token '" + this.next + "'");
}
}
if (exprs.length == 0)
return new EmptyExpr(this.span(start));
if (exprs.length == 1)
return exprs[0];
return new Chain(this.span(start), exprs);
};
/**
* @return {?}
*/
_ParseAST.prototype.parsePipe = function () {
var /** @type {?} */ result = this.parseExpression();
if (this.optionalOperator('|')) {
if (this.parseAction) {
this.error('Cannot have a pipe in an action expression');
}
do {
var /** @type {?} */ name = ((this.expectIdentifierOrKeyword()));
var /** @type {?} */ args = [];
while (this.optionalCharacter($COLON)) {
args.push(this.parseExpression());
}
result = new BindingPipe(this.span(result.span.start), result, name, args);
} while (this.optionalOperator('|'));
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parseExpression = function () { return this.parseConditional(); };
/**
* @return {?}
*/
_ParseAST.prototype.parseConditional = function () {
var /** @type {?} */ start = this.inputIndex;
var /** @type {?} */ result = this.parseLogicalOr();
if (this.optionalOperator('?')) {
var /** @type {?} */ yes = this.parsePipe();
var /** @type {?} */ no = void 0;
if (!this.optionalCharacter($COLON)) {
var /** @type {?} */ end = this.inputIndex;
var /** @type {?} */ expression = this.input.substring(start, end);
this.error("Conditional expression " + expression + " requires all 3 expressions");
no = new EmptyExpr(this.span(start));
}
else {
no = this.parsePipe();
}
return new Conditional(this.span(start), result, yes, no);
}
else {
return result;
}
};
/**
* @return {?}
*/
_ParseAST.prototype.parseLogicalOr = function () {
// '||'
var /** @type {?} */ result = this.parseLogicalAnd();
while (this.optionalOperator('||')) {
var /** @type {?} */ right = this.parseLogicalAnd();
result = new Binary(this.span(result.span.start), '||', result, right);
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parseLogicalAnd = function () {
// '&&'
var /** @type {?} */ result = this.parseEquality();
while (this.optionalOperator('&&')) {
var /** @type {?} */ right = this.parseEquality();
result = new Binary(this.span(result.span.start), '&&', result, right);
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parseEquality = function () {
// '==','!=','===','!=='
var /** @type {?} */ result = this.parseRelational();
while (this.next.type == TokenType.Operator) {
var /** @type {?} */ operator = this.next.strValue;
switch (operator) {
case '==':
case '===':
case '!=':
case '!==':
this.advance();
var /** @type {?} */ right = this.parseRelational();
result = new Binary(this.span(result.span.start), operator, result, right);
continue;
}
break;
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parseRelational = function () {
// '<', '>', '<=', '>='
var /** @type {?} */ result = this.parseAdditive();
while (this.next.type == TokenType.Operator) {
var /** @type {?} */ operator = this.next.strValue;
switch (operator) {
case '<':
case '>':
case '<=':
case '>=':
this.advance();
var /** @type {?} */ right = this.parseAdditive();
result = new Binary(this.span(result.span.start), operator, result, right);
continue;
}
break;
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parseAdditive = function () {
// '+', '-'
var /** @type {?} */ result = this.parseMultiplicative();
while (this.next.type == TokenType.Operator) {
var /** @type {?} */ operator = this.next.strValue;
switch (operator) {
case '+':
case '-':
this.advance();
var /** @type {?} */ right = this.parseMultiplicative();
result = new Binary(this.span(result.span.start), operator, result, right);
continue;
}
break;
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parseMultiplicative = function () {
// '*', '%', '/'
var /** @type {?} */ result = this.parsePrefix();
while (this.next.type == TokenType.Operator) {
var /** @type {?} */ operator = this.next.strValue;
switch (operator) {
case '*':
case '%':
case '/':
this.advance();
var /** @type {?} */ right = this.parsePrefix();
result = new Binary(this.span(result.span.start), operator, result, right);
continue;
}
break;
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parsePrefix = function () {
if (this.next.type == TokenType.Operator) {
var /** @type {?} */ start = this.inputIndex;
var /** @type {?} */ operator = this.next.strValue;
var /** @type {?} */ result = void 0;
switch (operator) {
case '+':
this.advance();
return this.parsePrefix();
case '-':
this.advance();
result = this.parsePrefix();
return new Binary(this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0), result);
case '!':
this.advance();
result = this.parsePrefix();
return new PrefixNot(this.span(start), result);
}
}
return this.parseCallChain();
};
/**
* @return {?}
*/
_ParseAST.prototype.parseCallChain = function () {
var /** @type {?} */ result = this.parsePrimary();
while (true) {
if (this.optionalCharacter($PERIOD)) {
result = this.parseAccessMemberOrMethodCall(result, false);
}
else if (this.optionalOperator('?.')) {
result = this.parseAccessMemberOrMethodCall(result, true);
}
else if (this.optionalCharacter($LBRACKET)) {
this.rbracketsExpected++;
var /** @type {?} */ key = this.parsePipe();
this.rbracketsExpected--;
this.expectCharacter($RBRACKET);
if (this.optionalOperator('=')) {
var /** @type {?} */ value = this.parseConditional();
result = new KeyedWrite(this.span(result.span.start), result, key, value);
}
else {
result = new KeyedRead(this.span(result.span.start), result, key);
}
}
else if (this.optionalCharacter($LPAREN)) {
this.rparensExpected++;
var /** @type {?} */ args = this.parseCallArguments();
this.rparensExpected--;
this.expectCharacter($RPAREN);
result = new FunctionCall(this.span(result.span.start), result, args);
}
else {
return result;
}
}
};
/**
* @return {?}
*/
_ParseAST.prototype.parsePrimary = function () {
var /** @type {?} */ start = this.inputIndex;
if (this.optionalCharacter($LPAREN)) {
this.rparensExpected++;
var /** @type {?} */ result = this.parsePipe();
this.rparensExpected--;
this.expectCharacter($RPAREN);
return result;
}
else if (this.next.isKeywordNull()) {
this.advance();
return new LiteralPrimitive(this.span(start), null);
}
else if (this.next.isKeywordUndefined()) {
this.advance();
return new LiteralPrimitive(this.span(start), void 0);
}
else if (this.next.isKeywordTrue()) {
this.advance();
return new LiteralPrimitive(this.span(start), true);
}
else if (this.next.isKeywordFalse()) {
this.advance();
return new LiteralPrimitive(this.span(start), false);
}
else if (this.next.isKeywordThis()) {
this.advance();
return new ImplicitReceiver(this.span(start));
}
else if (this.optionalCharacter($LBRACKET)) {
this.rbracketsExpected++;
var /** @type {?} */ elements = this.parseExpressionList($RBRACKET);
this.rbracketsExpected--;
this.expectCharacter($RBRACKET);
return new LiteralArray(this.span(start), elements);
}
else if (this.next.isCharacter($LBRACE)) {
return this.parseLiteralMap();
}
else if (this.next.isIdentifier()) {
return this.parseAccessMemberOrMethodCall(new ImplicitReceiver(this.span(start)), false);
}
else if (this.next.isNumber()) {
var /** @type {?} */ value = this.next.toNumber();
this.advance();
return new LiteralPrimitive(this.span(start), value);
}
else if (this.next.isString()) {
var /** @type {?} */ literalValue = this.next.toString();
this.advance();
return new LiteralPrimitive(this.span(start), literalValue);
}
else if (this.index >= this.tokens.length) {
this.error("Unexpected end of expression: " + this.input);
return new EmptyExpr(this.span(start));
}
else {
this.error("Unexpected token " + this.next);
return new EmptyExpr(this.span(start));
}
};
/**
* @param {?} terminator
* @return {?}
*/
_ParseAST.prototype.parseExpressionList = function (terminator) {
var /** @type {?} */ result = [];
if (!this.next.isCharacter(terminator)) {
do {
result.push(this.parsePipe());
} while (this.optionalCharacter($COMMA));
}
return result;
};
/**
* @return {?}
*/
_ParseAST.prototype.parseLiteralMap = function () {
var /** @type {?} */ keys = [];
var /** @type {?} */ values = [];
var /** @type {?} */ start = this.inputIndex;
this.expectCharacter($LBRACE);
if (!this.optionalCharacter($RBRACE)) {
this.rbracesExpected++;
do {
var /** @type {?} */ key = ((this.expectIdentifierOrKeywordOrString()));
keys.push(key);
this.expectCharacter($COLON);
values.push(this.parsePipe());
} while (this.optionalCharacter($COMMA));
this.rbracesExpected--;
this.expectCharacter($RBRACE);
}
return new LiteralMap(this.span(start), keys, values);
};
/**
* @param {?} receiver
* @param {?=} isSafe
* @return {?}
*/
_ParseAST.prototype.parseAccessMemberOrMethodCall = function (receiver, isSafe) {
if (isSafe === void 0) { isSafe = false; }
var /** @type {?} */ start = receiver.span.start;
var /** @type {?} */ id = ((this.expectIdentifierOrKeyword()));
if (this.optionalCharacter($LPAREN)) {
this.rparensExpected++;
var /** @type {?} */ args = this.parseCallArguments();
this.expectCharacter($RPAREN);
this.rparensExpected--;
var /** @type {?} */ span = this.span(start);
return isSafe ? new SafeMethodCall(span, receiver, id, args) :
new MethodCall(span, receiver, id, args);
}
else {
if (isSafe) {
if (this.optionalOperator('=')) {
this.error('The \'?.\' operator cannot be used in the assignment');
return new EmptyExpr(this.span(start));
}
else {
return new SafePropertyRead(this.span(start), receiver, id);
}
}
else {
if (this.optionalOperator('=')) {
if (!this.parseAction) {
this.error('Bindings cannot contain assignments');
return new EmptyExpr(this.span(start));
}
var /** @type {?} */ value = this.parseConditional();
return new PropertyWrite(this.span(start), receiver, id, value);
}
else {
return new PropertyRead(this.span(start), receiver, id);
}
}
}
};
/**
* @return {?}
*/
_ParseAST.prototype.parseCallArguments = function () {
if (this.next.isCharacter($RPAREN))
return [];
var /** @type {?} */ positionals = [];
do {
positionals.push(this.parsePipe());
} while (this.optionalCharacter($COMMA));
return (positionals);
};
/**
* An identifier, a keyword, a string with an optional `-` inbetween.
* @return {?}
*/
_ParseAST.prototype.expectTemplateBindingKey = function () {
var /** @type {?} */ result = '';
var /** @type {?} */ operatorFound = false;
do {
result += this.expectIdentifierOrKeywordOrString();
operatorFound = this.optionalOperator('-');
if (operatorFound) {
result += '-';
}
} while (operatorFound);
return result.toString();
};
/**
* @return {?}
*/
_ParseAST.prototype.parseTemplateBindings = function () {
var /** @type {?} */ bindings = [];
var /** @type {?} */ prefix = ((null));
var /** @type {?} */ warnings = [];
while (this.index < this.tokens.length) {
var /** @type {?} */ start = this.inputIndex;
var /** @type {?} */ keyIsVar = this.peekKeywordLet();
if (keyIsVar) {
this.advance();
}
var /** @type {?} */ rawKey = this.expectTemplateBindingKey();
var /** @type {?} */ key = rawKey;
if (!keyIsVar) {
if (prefix == null) {
prefix = key;
}
else {
key = prefix + key[0].toUpperCase() + key.substring(1);
}
}
this.optionalCharacter($COLON);
var /** @type {?} */ name = ((null));
var /** @type {?} */ expression = ((null));
if (keyIsVar) {
if (this.optionalOperator('=')) {
name = this.expectTemplateBindingKey();
}
else {
name = '\$implicit';
}
}
else if (this.peekKeywordAs()) {
var /** @type {?} */ letStart = this.inputIndex;
this.advance(); // consume `as`
name = rawKey;
key = this.expectTemplateBindingKey(); // read local var name
keyIsVar = true;
}
else if (this.next !== EOF && !this.peekKeywordLet()) {
var /** @type {?} */ start_2 = this.inputIndex;
var /** @type {?} */ ast = this.parsePipe();
var /** @type {?} */ source = this.input.substring(start_2 - this.offset, this.inputIndex - this.offset);
expression = new ASTWithSource(ast, source, this.location, this.errors);
}
bindings.push(new TemplateBinding(this.span(start), key, keyIsVar, name, expression));
if (this.peekKeywordAs() && !keyIsVar) {
var /** @type {?} */ letStart = this.inputIndex;
this.advance(); // consume `as`
var /** @type {?} */ letName = this.expectTemplateBindingKey(); // read local var name
bindings.push(new TemplateBinding(this.span(letStart), letName, true, key, /** @type {?} */ ((null))));
}
if (!this.optionalCharacter($SEMICOLON)) {
this.optionalCharacter($COMMA);
}
}
return new TemplateBindingParseResult(bindings, warnings, this.errors);
};
/**
* @param {?} message
* @param {?=} index
* @return {?}
*/
_ParseAST.prototype.error = function (message, index) {
if (index === void 0) { index = null; }
this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location));
this.skip();
};
/**
* @param {?=} index
* @return {?}
*/
_ParseAST.prototype.locationText = function (index) {
if (index === void 0) { index = null; }
if (index == null)
index = this.index;
return (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" :
"at the end of the expression";
};
/**
* @return {?}
*/
_ParseAST.prototype.skip = function () {
var /** @type {?} */ n = this.next;
while (this.index < this.tokens.length && !n.isCharacter($SEMICOLON) &&
(this.rparensExpected <= 0 || !n.isCharacter($RPAREN)) &&
(this.rbracesExpected <= 0 || !n.isCharacter($RBRACE)) &&
(this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET))) {
if (this.next.isError()) {
this.errors.push(new ParserError(/** @type {?} */ ((this.next.toString())), this.input, this.locationText(), this.location));
}
this.advance();
n = this.next;
}
};
return _ParseAST;
}());
var SimpleExpressionChecker = (function () {
function SimpleExpressionChecker() {
this.errors = [];
}
/**
* @param {?} ast
* @return {?}
*/
SimpleExpressionChecker.check = function (ast) {
var /** @type {?} */ s = new SimpleExpressionChecker();
ast.visit(s);
return s.errors;
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitImplicitReceiver = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitInterpolation = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitLiteralPrimitive = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitPropertyRead = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitPropertyWrite = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitSafePropertyRead = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitMethodCall = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitSafeMethodCall = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitFunctionCall = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitLiteralArray = function (ast, context) { this.visitAll(ast.expressions); };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitLiteralMap = function (ast, context) { this.visitAll(ast.values); };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitBinary = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitPrefixNot = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitConditional = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitPipe = function (ast, context) { this.errors.push('pipes'); };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitKeyedRead = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitKeyedWrite = function (ast, context) { };
/**
* @param {?} asts
* @return {?}
*/
SimpleExpressionChecker.prototype.visitAll = function (asts) {
var _this = this;
return asts.map(function (node) { return node.visit(_this); });
};
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitChain = function (ast, context) { };
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
SimpleExpressionChecker.prototype.visitQuote = function (ast, context) { };
return SimpleExpressionChecker;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ParseLocation = (function () {
/**
* @param {?} file
* @param {?} offset
* @param {?} line
* @param {?} col
*/
function ParseLocation(file, offset, line, col) {
this.file = file;
this.offset = offset;
this.line = line;
this.col = col;
}
/**
* @return {?}
*/
ParseLocation.prototype.toString = function () {
return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url;
};
/**
* @param {?} delta
* @return {?}
*/
ParseLocation.prototype.moveBy = function (delta) {
var /** @type {?} */ source = this.file.content;
var /** @type {?} */ len = source.length;
var /** @type {?} */ offset = this.offset;
var /** @type {?} */ line = this.line;
var /** @type {?} */ col = this.col;
while (offset > 0 && delta < 0) {
offset--;
delta++;
var /** @type {?} */ ch = source.charCodeAt(offset);
if (ch == $LF) {
line--;
var /** @type {?} */ priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode($LF));
col = priorLine > 0 ? offset - priorLine : offset;
}
else {
col--;
}
}
while (offset < len && delta > 0) {
var /** @type {?} */ ch = source.charCodeAt(offset);
offset++;
delta--;
if (ch == $LF) {
line++;
col = 0;
}
else {
col++;
}
}
return new ParseLocation(this.file, offset, line, col);
};
/**
* @param {?} maxChars
* @param {?} maxLines
* @return {?}
*/
ParseLocation.prototype.getContext = function (maxChars, maxLines) {
var /** @type {?} */ content = this.file.content;
var /** @type {?} */ startOffset = this.offset;
if (startOffset != null) {
if (startOffset > content.length - 1) {
startOffset = content.length - 1;
}
var /** @type {?} */ endOffset = startOffset;
var /** @type {?} */ ctxChars = 0;
var /** @type {?} */ ctxLines = 0;
while (ctxChars < maxChars && startOffset > 0) {
startOffset--;
ctxChars++;
if (content[startOffset] == '\n') {
if (++ctxLines == maxLines) {
break;
}
}
}
ctxChars = 0;
ctxLines = 0;
while (ctxChars < maxChars && endOffset < content.length - 1) {
endOffset++;
ctxChars++;
if (content[endOffset] == '\n') {
if (++ctxLines == maxLines) {
break;
}
}
}
return {
before: content.substring(startOffset, this.offset),
after: content.substring(this.offset, endOffset + 1),
};
}
return null;
};
return ParseLocation;
}());
var ParseSourceFile = (function () {
/**
* @param {?} content
* @param {?} url
*/
function ParseSourceFile(content, url) {
this.content = content;
this.url = url;
}
return ParseSourceFile;
}());
var ParseSourceSpan = (function () {
/**
* @param {?} start
* @param {?} end
* @param {?=} details
*/
function ParseSourceSpan(start, end, details) {
if (details === void 0) { details = null; }
this.start = start;
this.end = end;
this.details = details;
}
/**
* @return {?}
*/
ParseSourceSpan.prototype.toString = function () {
return this.start.file.content.substring(this.start.offset, this.end.offset);
};
return ParseSourceSpan;
}());
var ParseErrorLevel = {};
ParseErrorLevel.WARNING = 0;
ParseErrorLevel.ERROR = 1;
ParseErrorLevel[ParseErrorLevel.WARNING] = "WARNING";
ParseErrorLevel[ParseErrorLevel.ERROR] = "ERROR";
var ParseError = (function () {
/**
* @param {?} span
* @param {?} msg
* @param {?=} level
*/
function ParseError(span, msg, level) {
if (level === void 0) { level = ParseErrorLevel.ERROR; }
this.span = span;
this.msg = msg;
this.level = level;
}
/**
* @return {?}
*/
ParseError.prototype.toString = function () {
var /** @type {?} */ ctx = this.span.start.getContext(100, 3);
var /** @type {?} */ contextStr = ctx ? " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" : '';
var /** @type {?} */ details = this.span.details ? ", " + this.span.details : '';
return "" + this.msg + contextStr + ": " + this.span.start + details;
};
return ParseError;
}());
/**
* @param {?} kind
* @param {?} type
* @return {?}
*/
function typeSourceSpan(kind, type) {
var /** @type {?} */ moduleUrl = identifierModuleUrl(type);
var /** @type {?} */ sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl :
"in " + kind + " " + identifierName(type);
var /** @type {?} */ sourceFile = new ParseSourceFile('', sourceFileName);
return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var Text = (function () {
/**
* @param {?} value
* @param {?} sourceSpan
*/
function Text(value, sourceSpan) {
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
Text.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); };
return Text;
}());
var Expansion = (function () {
/**
* @param {?} switchValue
* @param {?} type
* @param {?} cases
* @param {?} sourceSpan
* @param {?} switchValueSourceSpan
*/
function Expansion(switchValue, type, cases, sourceSpan, switchValueSourceSpan) {
this.switchValue = switchValue;
this.type = type;
this.cases = cases;
this.sourceSpan = sourceSpan;
this.switchValueSourceSpan = switchValueSourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
Expansion.prototype.visit = function (visitor, context) { return visitor.visitExpansion(this, context); };
return Expansion;
}());
var ExpansionCase = (function () {
/**
* @param {?} value
* @param {?} expression
* @param {?} sourceSpan
* @param {?} valueSourceSpan
* @param {?} expSourceSpan
*/
function ExpansionCase(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) {
this.value = value;
this.expression = expression;
this.sourceSpan = sourceSpan;
this.valueSourceSpan = valueSourceSpan;
this.expSourceSpan = expSourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
ExpansionCase.prototype.visit = function (visitor, context) { return visitor.visitExpansionCase(this, context); };
return ExpansionCase;
}());
var Attribute$1 = (function () {
/**
* @param {?} name
* @param {?} value
* @param {?} sourceSpan
* @param {?=} valueSpan
*/
function Attribute$1(name, value, sourceSpan, valueSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
this.valueSpan = valueSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
Attribute$1.prototype.visit = function (visitor, context) { return visitor.visitAttribute(this, context); };
return Attribute$1;
}());
var Element = (function () {
/**
* @param {?} name
* @param {?} attrs
* @param {?} children
* @param {?} sourceSpan
* @param {?=} startSourceSpan
* @param {?=} endSourceSpan
*/
function Element(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan) {
if (startSourceSpan === void 0) { startSourceSpan = null; }
if (endSourceSpan === void 0) { endSourceSpan = null; }
this.name = name;
this.attrs = attrs;
this.children = children;
this.sourceSpan = sourceSpan;
this.startSourceSpan = startSourceSpan;
this.endSourceSpan = endSourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
Element.prototype.visit = function (visitor, context) { return visitor.visitElement(this, context); };
return Element;
}());
var Comment = (function () {
/**
* @param {?} value
* @param {?} sourceSpan
*/
function Comment(value, sourceSpan) {
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?} context
* @return {?}
*/
Comment.prototype.visit = function (visitor, context) { return visitor.visitComment(this, context); };
return Comment;
}());
/**
* @param {?} visitor
* @param {?} nodes
* @param {?=} context
* @return {?}
*/
function visitAll(visitor, nodes, context) {
if (context === void 0) { context = null; }
var /** @type {?} */ result = [];
var /** @type {?} */ visit = visitor.visit ?
function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
function (ast) { return ast.visit(visitor, context); };
nodes.forEach(function (ast) {
var /** @type {?} */ astResult = visit(ast);
if (astResult) {
result.push(astResult);
}
});
return result;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var TokenType$1 = {};
TokenType$1.TAG_OPEN_START = 0;
TokenType$1.TAG_OPEN_END = 1;
TokenType$1.TAG_OPEN_END_VOID = 2;
TokenType$1.TAG_CLOSE = 3;
TokenType$1.TEXT = 4;
TokenType$1.ESCAPABLE_RAW_TEXT = 5;
TokenType$1.RAW_TEXT = 6;
TokenType$1.COMMENT_START = 7;
TokenType$1.COMMENT_END = 8;
TokenType$1.CDATA_START = 9;
TokenType$1.CDATA_END = 10;
TokenType$1.ATTR_NAME = 11;
TokenType$1.ATTR_VALUE = 12;
TokenType$1.DOC_TYPE = 13;
TokenType$1.EXPANSION_FORM_START = 14;
TokenType$1.EXPANSION_CASE_VALUE = 15;
TokenType$1.EXPANSION_CASE_EXP_START = 16;
TokenType$1.EXPANSION_CASE_EXP_END = 17;
TokenType$1.EXPANSION_FORM_END = 18;
TokenType$1.EOF = 19;
TokenType$1[TokenType$1.TAG_OPEN_START] = "TAG_OPEN_START";
TokenType$1[TokenType$1.TAG_OPEN_END] = "TAG_OPEN_END";
TokenType$1[TokenType$1.TAG_OPEN_END_VOID] = "TAG_OPEN_END_VOID";
TokenType$1[TokenType$1.TAG_CLOSE] = "TAG_CLOSE";
TokenType$1[TokenType$1.TEXT] = "TEXT";
TokenType$1[TokenType$1.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
TokenType$1[TokenType$1.RAW_TEXT] = "RAW_TEXT";
TokenType$1[TokenType$1.COMMENT_START] = "COMMENT_START";
TokenType$1[TokenType$1.COMMENT_END] = "COMMENT_END";
TokenType$1[TokenType$1.CDATA_START] = "CDATA_START";
TokenType$1[TokenType$1.CDATA_END] = "CDATA_END";
TokenType$1[TokenType$1.ATTR_NAME] = "ATTR_NAME";
TokenType$1[TokenType$1.ATTR_VALUE] = "ATTR_VALUE";
TokenType$1[TokenType$1.DOC_TYPE] = "DOC_TYPE";
TokenType$1[TokenType$1.EXPANSION_FORM_START] = "EXPANSION_FORM_START";
TokenType$1[TokenType$1.EXPANSION_CASE_VALUE] = "EXPANSION_CASE_VALUE";
TokenType$1[TokenType$1.EXPANSION_CASE_EXP_START] = "EXPANSION_CASE_EXP_START";
TokenType$1[TokenType$1.EXPANSION_CASE_EXP_END] = "EXPANSION_CASE_EXP_END";
TokenType$1[TokenType$1.EXPANSION_FORM_END] = "EXPANSION_FORM_END";
TokenType$1[TokenType$1.EOF] = "EOF";
var Token$1 = (function () {
/**
* @param {?} type
* @param {?} parts
* @param {?} sourceSpan
*/
function Token$1(type, parts, sourceSpan) {
this.type = type;
this.parts = parts;
this.sourceSpan = sourceSpan;
}
return Token$1;
}());
var TokenError = (function (_super) {
__extends(TokenError, _super);
/**
* @param {?} errorMsg
* @param {?} tokenType
* @param {?} span
*/
function TokenError(errorMsg, tokenType, span) {
var _this = _super.call(this, span, errorMsg) || this;
_this.tokenType = tokenType;
return _this;
}
return TokenError;
}(ParseError));
var TokenizeResult = (function () {
/**
* @param {?} tokens
* @param {?} errors
*/
function TokenizeResult(tokens, errors) {
this.tokens = tokens;
this.errors = errors;
}
return TokenizeResult;
}());
/**
* @param {?} source
* @param {?} url
* @param {?} getTagDefinition
* @param {?=} tokenizeExpansionForms
* @param {?=} interpolationConfig
* @return {?}
*/
function tokenize(source, url, getTagDefinition, tokenizeExpansionForms, interpolationConfig) {
if (tokenizeExpansionForms === void 0) { tokenizeExpansionForms = false; }
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
return new _Tokenizer(new ParseSourceFile(source, url), getTagDefinition, tokenizeExpansionForms, interpolationConfig)
.tokenize();
}
var _CR_OR_CRLF_REGEXP = /\r\n?/g;
/**
* @param {?} charCode
* @return {?}
*/
function _unexpectedCharacterErrorMsg(charCode) {
var /** @type {?} */ char = charCode === $EOF ? 'EOF' : String.fromCharCode(charCode);
return "Unexpected character \"" + char + "\"";
}
/**
* @param {?} entitySrc
* @return {?}
*/
function _unknownEntityErrorMsg(entitySrc) {
return "Unknown entity \"" + entitySrc + "\" - use the \";\" or \";\" syntax";
}
var _ControlFlowError = (function () {
/**
* @param {?} error
*/
function _ControlFlowError(error) {
this.error = error;
}
return _ControlFlowError;
}());
var _Tokenizer = (function () {
/**
* @param {?} _file The html source
* @param {?} _getTagDefinition
* @param {?} _tokenizeIcu Whether to tokenize ICU messages (considered as text nodes when false)
* @param {?=} _interpolationConfig
*/
function _Tokenizer(_file, _getTagDefinition, _tokenizeIcu, _interpolationConfig) {
if (_interpolationConfig === void 0) { _interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
this._file = _file;
this._getTagDefinition = _getTagDefinition;
this._tokenizeIcu = _tokenizeIcu;
this._interpolationConfig = _interpolationConfig;
this._peek = -1;
this._nextPeek = -1;
this._index = -1;
this._line = 0;
this._column = -1;
this._expansionCaseStack = [];
this._inInterpolation = false;
this.tokens = [];
this.errors = [];
this._input = _file.content;
this._length = _file.content.length;
this._advance();
}
/**
* @param {?} content
* @return {?}
*/
_Tokenizer.prototype._processCarriageReturns = function (content) {
// http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream
// In order to keep the original position in the source, we can not
// pre-process it.
// Instead CRs are processed right before instantiating the tokens.
return content.replace(_CR_OR_CRLF_REGEXP, '\n');
};
/**
* @return {?}
*/
_Tokenizer.prototype.tokenize = function () {
while (this._peek !== $EOF) {
var /** @type {?} */ start = this._getLocation();
try {
if (this._attemptCharCode($LT)) {
if (this._attemptCharCode($BANG)) {
if (this._attemptCharCode($LBRACKET)) {
this._consumeCdata(start);
}
else if (this._attemptCharCode($MINUS)) {
this._consumeComment(start);
}
else {
this._consumeDocType(start);
}
}
else if (this._attemptCharCode($SLASH)) {
this._consumeTagClose(start);
}
else {
this._consumeTagOpen(start);
}
}
else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
this._consumeText();
}
}
catch (e) {
if (e instanceof _ControlFlowError) {
this.errors.push(e.error);
}
else {
throw e;
}
}
}
this._beginToken(TokenType$1.EOF);
this._endToken([]);
return new TokenizeResult(mergeTextTokens(this.tokens), this.errors);
};
/**
* \@internal
* @return {?}
*/
_Tokenizer.prototype._tokenizeExpansionForm = function () {
if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
this._consumeExpansionFormStart();
return true;
}
if (isExpansionCaseStart(this._peek) && this._isInExpansionForm()) {
this._consumeExpansionCaseStart();
return true;
}
if (this._peek === $RBRACE) {
if (this._isInExpansionCase()) {
this._consumeExpansionCaseEnd();
return true;
}
if (this._isInExpansionForm()) {
this._consumeExpansionFormEnd();
return true;
}
}
return false;
};
/**
* @return {?}
*/
_Tokenizer.prototype._getLocation = function () {
return new ParseLocation(this._file, this._index, this._line, this._column);
};
/**
* @param {?=} start
* @param {?=} end
* @return {?}
*/
_Tokenizer.prototype._getSpan = function (start, end) {
if (start === void 0) { start = this._getLocation(); }
if (end === void 0) { end = this._getLocation(); }
return new ParseSourceSpan(start, end);
};
/**
* @param {?} type
* @param {?=} start
* @return {?}
*/
_Tokenizer.prototype._beginToken = function (type, start) {
if (start === void 0) { start = this._getLocation(); }
this._currentTokenStart = start;
this._currentTokenType = type;
};
/**
* @param {?} parts
* @param {?=} end
* @return {?}
*/
_Tokenizer.prototype._endToken = function (parts, end) {
if (end === void 0) { end = this._getLocation(); }
var /** @type {?} */ token = new Token$1(this._currentTokenType, parts, new ParseSourceSpan(this._currentTokenStart, end));
this.tokens.push(token);
this._currentTokenStart = ((null));
this._currentTokenType = ((null));
return token;
};
/**
* @param {?} msg
* @param {?} span
* @return {?}
*/
_Tokenizer.prototype._createError = function (msg, span) {
if (this._isInExpansionForm()) {
msg += " (Do you have an unescaped \"{\" in your template? Use \"{{ '{' }}\") to escape it.)";
}
var /** @type {?} */ error = new TokenError(msg, this._currentTokenType, span);
this._currentTokenStart = ((null));
this._currentTokenType = ((null));
return new _ControlFlowError(error);
};
/**
* @return {?}
*/
_Tokenizer.prototype._advance = function () {
if (this._index >= this._length) {
throw this._createError(_unexpectedCharacterErrorMsg($EOF), this._getSpan());
}
if (this._peek === $LF) {
this._line++;
this._column = 0;
}
else if (this._peek !== $LF && this._peek !== $CR) {
this._column++;
}
this._index++;
this._peek = this._index >= this._length ? $EOF : this._input.charCodeAt(this._index);
this._nextPeek =
this._index + 1 >= this._length ? $EOF : this._input.charCodeAt(this._index + 1);
};
/**
* @param {?} charCode
* @return {?}
*/
_Tokenizer.prototype._attemptCharCode = function (charCode) {
if (this._peek === charCode) {
this._advance();
return true;
}
return false;
};
/**
* @param {?} charCode
* @return {?}
*/
_Tokenizer.prototype._attemptCharCodeCaseInsensitive = function (charCode) {
if (compareCharCodeCaseInsensitive(this._peek, charCode)) {
this._advance();
return true;
}
return false;
};
/**
* @param {?} charCode
* @return {?}
*/
_Tokenizer.prototype._requireCharCode = function (charCode) {
var /** @type {?} */ location = this._getLocation();
if (!this._attemptCharCode(charCode)) {
throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location, location));
}
};
/**
* @param {?} chars
* @return {?}
*/
_Tokenizer.prototype._attemptStr = function (chars) {
var /** @type {?} */ len = chars.length;
if (this._index + len > this._length) {
return false;
}
var /** @type {?} */ initialPosition = this._savePosition();
for (var /** @type {?} */ i = 0; i < len; i++) {
if (!this._attemptCharCode(chars.charCodeAt(i))) {
// If attempting to parse the string fails, we want to reset the parser
// to where it was before the attempt
this._restorePosition(initialPosition);
return false;
}
}
return true;
};
/**
* @param {?} chars
* @return {?}
*/
_Tokenizer.prototype._attemptStrCaseInsensitive = function (chars) {
for (var /** @type {?} */ i = 0; i < chars.length; i++) {
if (!this._attemptCharCodeCaseInsensitive(chars.charCodeAt(i))) {
return false;
}
}
return true;
};
/**
* @param {?} chars
* @return {?}
*/
_Tokenizer.prototype._requireStr = function (chars) {
var /** @type {?} */ location = this._getLocation();
if (!this._attemptStr(chars)) {
throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location));
}
};
/**
* @param {?} predicate
* @return {?}
*/
_Tokenizer.prototype._attemptCharCodeUntilFn = function (predicate) {
while (!predicate(this._peek)) {
this._advance();
}
};
/**
* @param {?} predicate
* @param {?} len
* @return {?}
*/
_Tokenizer.prototype._requireCharCodeUntilFn = function (predicate, len) {
var /** @type {?} */ start = this._getLocation();
this._attemptCharCodeUntilFn(predicate);
if (this._index - start.offset < len) {
throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(start, start));
}
};
/**
* @param {?} char
* @return {?}
*/
_Tokenizer.prototype._attemptUntilChar = function (char) {
while (this._peek !== char) {
this._advance();
}
};
/**
* @param {?} decodeEntities
* @return {?}
*/
_Tokenizer.prototype._readChar = function (decodeEntities) {
if (decodeEntities && this._peek === $AMPERSAND) {
return this._decodeEntity();
}
else {
var /** @type {?} */ index = this._index;
this._advance();
return this._input[index];
}
};
/**
* @return {?}
*/
_Tokenizer.prototype._decodeEntity = function () {
var /** @type {?} */ start = this._getLocation();
this._advance();
if (this._attemptCharCode($HASH)) {
var /** @type {?} */ isHex = this._attemptCharCode($x) || this._attemptCharCode($X);
var /** @type {?} */ numberStart = this._getLocation().offset;
this._attemptCharCodeUntilFn(isDigitEntityEnd);
if (this._peek != $SEMICOLON) {
throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
}
this._advance();
var /** @type {?} */ strNum = this._input.substring(numberStart, this._index - 1);
try {
var /** @type {?} */ charCode = parseInt(strNum, isHex ? 16 : 10);
return String.fromCharCode(charCode);
}
catch (e) {
var /** @type {?} */ entity = this._input.substring(start.offset + 1, this._index - 1);
throw this._createError(_unknownEntityErrorMsg(entity), this._getSpan(start));
}
}
else {
var /** @type {?} */ startPosition = this._savePosition();
this._attemptCharCodeUntilFn(isNamedEntityEnd);
if (this._peek != $SEMICOLON) {
this._restorePosition(startPosition);
return '&';
}
this._advance();
var /** @type {?} */ name = this._input.substring(start.offset + 1, this._index - 1);
var /** @type {?} */ char = NAMED_ENTITIES[name];
if (!char) {
throw this._createError(_unknownEntityErrorMsg(name), this._getSpan(start));
}
return char;
}
};
/**
* @param {?} decodeEntities
* @param {?} firstCharOfEnd
* @param {?} attemptEndRest
* @return {?}
*/
_Tokenizer.prototype._consumeRawText = function (decodeEntities, firstCharOfEnd, attemptEndRest) {
var /** @type {?} */ tagCloseStart;
var /** @type {?} */ textStart = this._getLocation();
this._beginToken(decodeEntities ? TokenType$1.ESCAPABLE_RAW_TEXT : TokenType$1.RAW_TEXT, textStart);
var /** @type {?} */ parts = [];
while (true) {
tagCloseStart = this._getLocation();
if (this._attemptCharCode(firstCharOfEnd) && attemptEndRest()) {
break;
}
if (this._index > tagCloseStart.offset) {
// add the characters consumed by the previous if statement to the output
parts.push(this._input.substring(tagCloseStart.offset, this._index));
}
while (this._peek !== firstCharOfEnd) {
parts.push(this._readChar(decodeEntities));
}
}
return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart);
};
/**
* @param {?} start
* @return {?}
*/
_Tokenizer.prototype._consumeComment = function (start) {
var _this = this;
this._beginToken(TokenType$1.COMMENT_START, start);
this._requireCharCode($MINUS);
this._endToken([]);
var /** @type {?} */ textToken = this._consumeRawText(false, $MINUS, function () { return _this._attemptStr('->'); });
this._beginToken(TokenType$1.COMMENT_END, textToken.sourceSpan.end);
this._endToken([]);
};
/**
* @param {?} start
* @return {?}
*/
_Tokenizer.prototype._consumeCdata = function (start) {
var _this = this;
this._beginToken(TokenType$1.CDATA_START, start);
this._requireStr('CDATA[');
this._endToken([]);
var /** @type {?} */ textToken = this._consumeRawText(false, $RBRACKET, function () { return _this._attemptStr(']>'); });
this._beginToken(TokenType$1.CDATA_END, textToken.sourceSpan.end);
this._endToken([]);
};
/**
* @param {?} start
* @return {?}
*/
_Tokenizer.prototype._consumeDocType = function (start) {
this._beginToken(TokenType$1.DOC_TYPE, start);
this._attemptUntilChar($GT);
this._advance();
this._endToken([this._input.substring(start.offset + 2, this._index - 1)]);
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumePrefixAndName = function () {
var /** @type {?} */ nameOrPrefixStart = this._index;
var /** @type {?} */ prefix = ((null));
while (this._peek !== $COLON && !isPrefixEnd(this._peek)) {
this._advance();
}
var /** @type {?} */ nameStart;
if (this._peek === $COLON) {
this._advance();
prefix = this._input.substring(nameOrPrefixStart, this._index - 1);
nameStart = this._index;
}
else {
nameStart = nameOrPrefixStart;
}
this._requireCharCodeUntilFn(isNameEnd, this._index === nameStart ? 1 : 0);
var /** @type {?} */ name = this._input.substring(nameStart, this._index);
return [prefix, name];
};
/**
* @param {?} start
* @return {?}
*/
_Tokenizer.prototype._consumeTagOpen = function (start) {
var /** @type {?} */ savedPos = this._savePosition();
var /** @type {?} */ tagName;
var /** @type {?} */ lowercaseTagName;
try {
if (!isAsciiLetter(this._peek)) {
throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
}
var /** @type {?} */ nameStart = this._index;
this._consumeTagOpenStart(start);
tagName = this._input.substring(nameStart, this._index);
lowercaseTagName = tagName.toLowerCase();
this._attemptCharCodeUntilFn(isNotWhitespace);
while (this._peek !== $SLASH && this._peek !== $GT) {
this._consumeAttributeName();
this._attemptCharCodeUntilFn(isNotWhitespace);
if (this._attemptCharCode($EQ)) {
this._attemptCharCodeUntilFn(isNotWhitespace);
this._consumeAttributeValue();
}
this._attemptCharCodeUntilFn(isNotWhitespace);
}
this._consumeTagOpenEnd();
}
catch (e) {
if (e instanceof _ControlFlowError) {
// When the start tag is invalid, assume we want a "<"
this._restorePosition(savedPos);
// Back to back text tokens are merged at the end
this._beginToken(TokenType$1.TEXT, start);
this._endToken(['<']);
return;
}
throw e;
}
var /** @type {?} */ contentTokenType = this._getTagDefinition(tagName).contentType;
if (contentTokenType === TagContentType.RAW_TEXT) {
this._consumeRawTextWithTagClose(lowercaseTagName, false);
}
else if (contentTokenType === TagContentType.ESCAPABLE_RAW_TEXT) {
this._consumeRawTextWithTagClose(lowercaseTagName, true);
}
};
/**
* @param {?} lowercaseTagName
* @param {?} decodeEntities
* @return {?}
*/
_Tokenizer.prototype._consumeRawTextWithTagClose = function (lowercaseTagName, decodeEntities) {
var _this = this;
var /** @type {?} */ textToken = this._consumeRawText(decodeEntities, $LT, function () {
if (!_this._attemptCharCode($SLASH))
return false;
_this._attemptCharCodeUntilFn(isNotWhitespace);
if (!_this._attemptStrCaseInsensitive(lowercaseTagName))
return false;
_this._attemptCharCodeUntilFn(isNotWhitespace);
return _this._attemptCharCode($GT);
});
this._beginToken(TokenType$1.TAG_CLOSE, textToken.sourceSpan.end);
this._endToken([/** @type {?} */ ((null)), lowercaseTagName]);
};
/**
* @param {?} start
* @return {?}
*/
_Tokenizer.prototype._consumeTagOpenStart = function (start) {
this._beginToken(TokenType$1.TAG_OPEN_START, start);
var /** @type {?} */ parts = this._consumePrefixAndName();
this._endToken(parts);
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeAttributeName = function () {
this._beginToken(TokenType$1.ATTR_NAME);
var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
this._endToken(prefixAndName);
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeAttributeValue = function () {
this._beginToken(TokenType$1.ATTR_VALUE);
var /** @type {?} */ value;
if (this._peek === $SQ || this._peek === $DQ) {
var /** @type {?} */ quoteChar = this._peek;
this._advance();
var /** @type {?} */ parts = [];
while (this._peek !== quoteChar) {
parts.push(this._readChar(true));
}
value = parts.join('');
this._advance();
}
else {
var /** @type {?} */ valueStart = this._index;
this._requireCharCodeUntilFn(isNameEnd, 1);
value = this._input.substring(valueStart, this._index);
}
this._endToken([this._processCarriageReturns(value)]);
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeTagOpenEnd = function () {
var /** @type {?} */ tokenType = this._attemptCharCode($SLASH) ? TokenType$1.TAG_OPEN_END_VOID : TokenType$1.TAG_OPEN_END;
this._beginToken(tokenType);
this._requireCharCode($GT);
this._endToken([]);
};
/**
* @param {?} start
* @return {?}
*/
_Tokenizer.prototype._consumeTagClose = function (start) {
this._beginToken(TokenType$1.TAG_CLOSE, start);
this._attemptCharCodeUntilFn(isNotWhitespace);
var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
this._attemptCharCodeUntilFn(isNotWhitespace);
this._requireCharCode($GT);
this._endToken(prefixAndName);
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeExpansionFormStart = function () {
this._beginToken(TokenType$1.EXPANSION_FORM_START, this._getLocation());
this._requireCharCode($LBRACE);
this._endToken([]);
this._expansionCaseStack.push(TokenType$1.EXPANSION_FORM_START);
this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
var /** @type {?} */ condition = this._readUntil($COMMA);
this._endToken([condition], this._getLocation());
this._requireCharCode($COMMA);
this._attemptCharCodeUntilFn(isNotWhitespace);
this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
var /** @type {?} */ type = this._readUntil($COMMA);
this._endToken([type], this._getLocation());
this._requireCharCode($COMMA);
this._attemptCharCodeUntilFn(isNotWhitespace);
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeExpansionCaseStart = function () {
this._beginToken(TokenType$1.EXPANSION_CASE_VALUE, this._getLocation());
var /** @type {?} */ value = this._readUntil($LBRACE).trim();
this._endToken([value], this._getLocation());
this._attemptCharCodeUntilFn(isNotWhitespace);
this._beginToken(TokenType$1.EXPANSION_CASE_EXP_START, this._getLocation());
this._requireCharCode($LBRACE);
this._endToken([], this._getLocation());
this._attemptCharCodeUntilFn(isNotWhitespace);
this._expansionCaseStack.push(TokenType$1.EXPANSION_CASE_EXP_START);
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeExpansionCaseEnd = function () {
this._beginToken(TokenType$1.EXPANSION_CASE_EXP_END, this._getLocation());
this._requireCharCode($RBRACE);
this._endToken([], this._getLocation());
this._attemptCharCodeUntilFn(isNotWhitespace);
this._expansionCaseStack.pop();
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeExpansionFormEnd = function () {
this._beginToken(TokenType$1.EXPANSION_FORM_END, this._getLocation());
this._requireCharCode($RBRACE);
this._endToken([]);
this._expansionCaseStack.pop();
};
/**
* @return {?}
*/
_Tokenizer.prototype._consumeText = function () {
var /** @type {?} */ start = this._getLocation();
this._beginToken(TokenType$1.TEXT, start);
var /** @type {?} */ parts = [];
do {
if (this._interpolationConfig && this._attemptStr(this._interpolationConfig.start)) {
parts.push(this._interpolationConfig.start);
this._inInterpolation = true;
}
else if (this._interpolationConfig && this._inInterpolation &&
this._attemptStr(this._interpolationConfig.end)) {
parts.push(this._interpolationConfig.end);
this._inInterpolation = false;
}
else {
parts.push(this._readChar(true));
}
} while (!this._isTextEnd());
this._endToken([this._processCarriageReturns(parts.join(''))]);
};
/**
* @return {?}
*/
_Tokenizer.prototype._isTextEnd = function () {
if (this._peek === $LT || this._peek === $EOF) {
return true;
}
if (this._tokenizeIcu && !this._inInterpolation) {
if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
// start of an expansion form
return true;
}
if (this._peek === $RBRACE && this._isInExpansionCase()) {
// end of and expansion case
return true;
}
}
return false;
};
/**
* @return {?}
*/
_Tokenizer.prototype._savePosition = function () {
return [this._peek, this._index, this._column, this._line, this.tokens.length];
};
/**
* @param {?} char
* @return {?}
*/
_Tokenizer.prototype._readUntil = function (char) {
var /** @type {?} */ start = this._index;
this._attemptUntilChar(char);
return this._input.substring(start, this._index);
};
/**
* @param {?} position
* @return {?}
*/
_Tokenizer.prototype._restorePosition = function (position) {
this._peek = position[0];
this._index = position[1];
this._column = position[2];
this._line = position[3];
var /** @type {?} */ nbTokens = position[4];
if (nbTokens < this.tokens.length) {
// remove any extra tokens
this.tokens = this.tokens.slice(0, nbTokens);
}
};
/**
* @return {?}
*/
_Tokenizer.prototype._isInExpansionCase = function () {
return this._expansionCaseStack.length > 0 &&
this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
TokenType$1.EXPANSION_CASE_EXP_START;
};
/**
* @return {?}
*/
_Tokenizer.prototype._isInExpansionForm = function () {
return this._expansionCaseStack.length > 0 &&
this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
TokenType$1.EXPANSION_FORM_START;
};
return _Tokenizer;
}());
/**
* @param {?} code
* @return {?}
*/
function isNotWhitespace(code) {
return !isWhitespace(code) || code === $EOF;
}
/**
* @param {?} code
* @return {?}
*/
function isNameEnd(code) {
return isWhitespace(code) || code === $GT || code === $SLASH ||
code === $SQ || code === $DQ || code === $EQ;
}
/**
* @param {?} code
* @return {?}
*/
function isPrefixEnd(code) {
return (code < $a || $z < code) && (code < $A || $Z < code) &&
(code < $0 || code > $9);
}
/**
* @param {?} code
* @return {?}
*/
function isDigitEntityEnd(code) {
return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code);
}
/**
* @param {?} code
* @return {?}
*/
function isNamedEntityEnd(code) {
return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code);
}
/**
* @param {?} input
* @param {?} offset
* @param {?} interpolationConfig
* @return {?}
*/
function isExpansionFormStart(input, offset, interpolationConfig) {
var /** @type {?} */ isInterpolationStart = interpolationConfig ? input.indexOf(interpolationConfig.start, offset) == offset : false;
return input.charCodeAt(offset) == $LBRACE && !isInterpolationStart;
}
/**
* @param {?} peek
* @return {?}
*/
function isExpansionCaseStart(peek) {
return peek === $EQ || isAsciiLetter(peek);
}
/**
* @param {?} code1
* @param {?} code2
* @return {?}
*/
function compareCharCodeCaseInsensitive(code1, code2) {
return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2);
}
/**
* @param {?} code
* @return {?}
*/
function toUpperCaseCharCode(code) {
return code >= $a && code <= $z ? code - $a + $A : code;
}
/**
* @param {?} srcTokens
* @return {?}
*/
function mergeTextTokens(srcTokens) {
var /** @type {?} */ dstTokens = [];
var /** @type {?} */ lastDstToken = undefined;
for (var /** @type {?} */ i = 0; i < srcTokens.length; i++) {
var /** @type {?} */ token = srcTokens[i];
if (lastDstToken && lastDstToken.type == TokenType$1.TEXT && token.type == TokenType$1.TEXT) {
lastDstToken.parts[0] += token.parts[0];
lastDstToken.sourceSpan.end = token.sourceSpan.end;
}
else {
lastDstToken = token;
dstTokens.push(lastDstToken);
}
}
return dstTokens;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var TreeError = (function (_super) {
__extends(TreeError, _super);
/**
* @param {?} elementName
* @param {?} span
* @param {?} msg
*/
function TreeError(elementName, span, msg) {
var _this = _super.call(this, span, msg) || this;
_this.elementName = elementName;
return _this;
}
/**
* @param {?} elementName
* @param {?} span
* @param {?} msg
* @return {?}
*/
TreeError.create = function (elementName, span, msg) {
return new TreeError(elementName, span, msg);
};
return TreeError;
}(ParseError));
var ParseTreeResult = (function () {
/**
* @param {?} rootNodes
* @param {?} errors
*/
function ParseTreeResult(rootNodes, errors) {
this.rootNodes = rootNodes;
this.errors = errors;
}
return ParseTreeResult;
}());
var Parser$1 = (function () {
/**
* @param {?} getTagDefinition
*/
function Parser$1(getTagDefinition) {
this.getTagDefinition = getTagDefinition;
}
/**
* @param {?} source
* @param {?} url
* @param {?=} parseExpansionForms
* @param {?=} interpolationConfig
* @return {?}
*/
Parser$1.prototype.parse = function (source, url, parseExpansionForms, interpolationConfig) {
if (parseExpansionForms === void 0) { parseExpansionForms = false; }
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
var /** @type {?} */ tokensAndErrors = tokenize(source, url, this.getTagDefinition, parseExpansionForms, interpolationConfig);
var /** @type {?} */ treeAndErrors = new _TreeBuilder(tokensAndErrors.tokens, this.getTagDefinition).build();
return new ParseTreeResult(treeAndErrors.rootNodes, ((tokensAndErrors.errors)).concat(treeAndErrors.errors));
};
return Parser$1;
}());
var _TreeBuilder = (function () {
/**
* @param {?} tokens
* @param {?} getTagDefinition
*/
function _TreeBuilder(tokens, getTagDefinition) {
this.tokens = tokens;
this.getTagDefinition = getTagDefinition;
this._index = -1;
this._rootNodes = [];
this._errors = [];
this._elementStack = [];
this._advance();
}
/**
* @return {?}
*/
_TreeBuilder.prototype.build = function () {
while (this._peek.type !== TokenType$1.EOF) {
if (this._peek.type === TokenType$1.TAG_OPEN_START) {
this._consumeStartTag(this._advance());
}
else if (this._peek.type === TokenType$1.TAG_CLOSE) {
this._consumeEndTag(this._advance());
}
else if (this._peek.type === TokenType$1.CDATA_START) {
this._closeVoidElement();
this._consumeCdata(this._advance());
}
else if (this._peek.type === TokenType$1.COMMENT_START) {
this._closeVoidElement();
this._consumeComment(this._advance());
}
else if (this._peek.type === TokenType$1.TEXT || this._peek.type === TokenType$1.RAW_TEXT ||
this._peek.type === TokenType$1.ESCAPABLE_RAW_TEXT) {
this._closeVoidElement();
this._consumeText(this._advance());
}
else if (this._peek.type === TokenType$1.EXPANSION_FORM_START) {
this._consumeExpansion(this._advance());
}
else {
// Skip all other tokens...
this._advance();
}
}
return new ParseTreeResult(this._rootNodes, this._errors);
};
/**
* @return {?}
*/
_TreeBuilder.prototype._advance = function () {
var /** @type {?} */ prev = this._peek;
if (this._index < this.tokens.length - 1) {
// Note: there is always an EOF token at the end
this._index++;
}
this._peek = this.tokens[this._index];
return prev;
};
/**
* @param {?} type
* @return {?}
*/
_TreeBuilder.prototype._advanceIf = function (type) {
if (this._peek.type === type) {
return this._advance();
}
return null;
};
/**
* @param {?} startToken
* @return {?}
*/
_TreeBuilder.prototype._consumeCdata = function (startToken) {
this._consumeText(this._advance());
this._advanceIf(TokenType$1.CDATA_END);
};
/**
* @param {?} token
* @return {?}
*/
_TreeBuilder.prototype._consumeComment = function (token) {
var /** @type {?} */ text = this._advanceIf(TokenType$1.RAW_TEXT);
this._advanceIf(TokenType$1.COMMENT_END);
var /** @type {?} */ value = text != null ? text.parts[0].trim() : null;
this._addToParent(new Comment(value, token.sourceSpan));
};
/**
* @param {?} token
* @return {?}
*/
_TreeBuilder.prototype._consumeExpansion = function (token) {
var /** @type {?} */ switchValue = this._advance();
var /** @type {?} */ type = this._advance();
var /** @type {?} */ cases = [];
// read =
while (this._peek.type === TokenType$1.EXPANSION_CASE_VALUE) {
var /** @type {?} */ expCase = this._parseExpansionCase();
if (!expCase)
return; // error
cases.push(expCase);
}
// read the final }
if (this._peek.type !== TokenType$1.EXPANSION_FORM_END) {
this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '}'."));
return;
}
var /** @type {?} */ sourceSpan = new ParseSourceSpan(token.sourceSpan.start, this._peek.sourceSpan.end);
this._addToParent(new Expansion(switchValue.parts[0], type.parts[0], cases, sourceSpan, switchValue.sourceSpan));
this._advance();
};
/**
* @return {?}
*/
_TreeBuilder.prototype._parseExpansionCase = function () {
var /** @type {?} */ value = this._advance();
// read {
if (this._peek.type !== TokenType$1.EXPANSION_CASE_EXP_START) {
this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '{'."));
return null;
}
// read until }
var /** @type {?} */ start = this._advance();
var /** @type {?} */ exp = this._collectExpansionExpTokens(start);
if (!exp)
return null;
var /** @type {?} */ end = this._advance();
exp.push(new Token$1(TokenType$1.EOF, [], end.sourceSpan));
// parse everything in between { and }
var /** @type {?} */ parsedExp = new _TreeBuilder(exp, this.getTagDefinition).build();
if (parsedExp.errors.length > 0) {
this._errors = this._errors.concat(/** @type {?} */ (parsedExp.errors));
return null;
}
var /** @type {?} */ sourceSpan = new ParseSourceSpan(value.sourceSpan.start, end.sourceSpan.end);
var /** @type {?} */ expSourceSpan = new ParseSourceSpan(start.sourceSpan.start, end.sourceSpan.end);
return new ExpansionCase(value.parts[0], parsedExp.rootNodes, sourceSpan, value.sourceSpan, expSourceSpan);
};
/**
* @param {?} start
* @return {?}
*/
_TreeBuilder.prototype._collectExpansionExpTokens = function (start) {
var /** @type {?} */ exp = [];
var /** @type {?} */ expansionFormStack = [TokenType$1.EXPANSION_CASE_EXP_START];
while (true) {
if (this._peek.type === TokenType$1.EXPANSION_FORM_START ||
this._peek.type === TokenType$1.EXPANSION_CASE_EXP_START) {
expansionFormStack.push(this._peek.type);
}
if (this._peek.type === TokenType$1.EXPANSION_CASE_EXP_END) {
if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_CASE_EXP_START)) {
expansionFormStack.pop();
if (expansionFormStack.length == 0)
return exp;
}
else {
this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
return null;
}
}
if (this._peek.type === TokenType$1.EXPANSION_FORM_END) {
if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_FORM_START)) {
expansionFormStack.pop();
}
else {
this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
return null;
}
}
if (this._peek.type === TokenType$1.EOF) {
this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
return null;
}
exp.push(this._advance());
}
};
/**
* @param {?} token
* @return {?}
*/
_TreeBuilder.prototype._consumeText = function (token) {
var /** @type {?} */ text = token.parts[0];
if (text.length > 0 && text[0] == '\n') {
var /** @type {?} */ parent = this._getParentElement();
if (parent != null && parent.children.length == 0 &&
this.getTagDefinition(parent.name).ignoreFirstLf) {
text = text.substring(1);
}
}
if (text.length > 0) {
this._addToParent(new Text(text, token.sourceSpan));
}
};
/**
* @return {?}
*/
_TreeBuilder.prototype._closeVoidElement = function () {
if (this._elementStack.length > 0) {
var /** @type {?} */ el = this._elementStack[this._elementStack.length - 1];
if (this.getTagDefinition(el.name).isVoid) {
this._elementStack.pop();
}
}
};
/**
* @param {?} startTagToken
* @return {?}
*/
_TreeBuilder.prototype._consumeStartTag = function (startTagToken) {
var /** @type {?} */ prefix = startTagToken.parts[0];
var /** @type {?} */ name = startTagToken.parts[1];
var /** @type {?} */ attrs = [];
while (this._peek.type === TokenType$1.ATTR_NAME) {
attrs.push(this._consumeAttr(this._advance()));
}
var /** @type {?} */ fullName = this._getElementFullName(prefix, name, this._getParentElement());
var /** @type {?} */ selfClosing = false;
// Note: There could have been a tokenizer error
// so that we don't get a token for the end tag...
if (this._peek.type === TokenType$1.TAG_OPEN_END_VOID) {
this._advance();
selfClosing = true;
var /** @type {?} */ tagDef = this.getTagDefinition(fullName);
if (!(tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) {
this._errors.push(TreeError.create(fullName, startTagToken.sourceSpan, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\""));
}
}
else if (this._peek.type === TokenType$1.TAG_OPEN_END) {
this._advance();
selfClosing = false;
}
var /** @type {?} */ end = this._peek.sourceSpan.start;
var /** @type {?} */ span = new ParseSourceSpan(startTagToken.sourceSpan.start, end);
var /** @type {?} */ el = new Element(fullName, attrs, [], span, span, undefined);
this._pushElement(el);
if (selfClosing) {
this._popElement(fullName);
el.endSourceSpan = span;
}
};
/**
* @param {?} el
* @return {?}
*/
_TreeBuilder.prototype._pushElement = function (el) {
if (this._elementStack.length > 0) {
var /** @type {?} */ parentEl = this._elementStack[this._elementStack.length - 1];
if (this.getTagDefinition(parentEl.name).isClosedByChild(el.name)) {
this._elementStack.pop();
}
}
var /** @type {?} */ tagDef = this.getTagDefinition(el.name);
var _a = this._getParentElementSkippingContainers(), parent = _a.parent, container = _a.container;
if (parent && tagDef.requireExtraParent(parent.name)) {
var /** @type {?} */ newParent = new Element(tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
this._insertBeforeContainer(parent, container, newParent);
}
this._addToParent(el);
this._elementStack.push(el);
};
/**
* @param {?} endTagToken
* @return {?}
*/
_TreeBuilder.prototype._consumeEndTag = function (endTagToken) {
var /** @type {?} */ fullName = this._getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
if (this._getParentElement()) {
((this._getParentElement())).endSourceSpan = endTagToken.sourceSpan;
}
if (this.getTagDefinition(fullName).isVoid) {
this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\""));
}
else if (!this._popElement(fullName)) {
var /** @type {?} */ errMsg = "Unexpected closing tag \"" + fullName + "\". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags";
this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg));
}
};
/**
* @param {?} fullName
* @return {?}
*/
_TreeBuilder.prototype._popElement = function (fullName) {
for (var /** @type {?} */ stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
var /** @type {?} */ el = this._elementStack[stackIndex];
if (el.name == fullName) {
this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex);
return true;
}
if (!this.getTagDefinition(el.name).closedByParent) {
return false;
}
}
return false;
};
/**
* @param {?} attrName
* @return {?}
*/
_TreeBuilder.prototype._consumeAttr = function (attrName) {
var /** @type {?} */ fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
var /** @type {?} */ end = attrName.sourceSpan.end;
var /** @type {?} */ value = '';
var /** @type {?} */ valueSpan = ((undefined));
if (this._peek.type === TokenType$1.ATTR_VALUE) {
var /** @type {?} */ valueToken = this._advance();
value = valueToken.parts[0];
end = valueToken.sourceSpan.end;
valueSpan = valueToken.sourceSpan;
}
return new Attribute$1(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end), valueSpan);
};
/**
* @return {?}
*/
_TreeBuilder.prototype._getParentElement = function () {
return this._elementStack.length > 0 ? this._elementStack[this._elementStack.length - 1] : null;
};
/**
* Returns the parent in the DOM and the container.
*
* `` elements are skipped as they are not rendered as DOM element.
* @return {?}
*/
_TreeBuilder.prototype._getParentElementSkippingContainers = function () {
var /** @type {?} */ container = null;
for (var /** @type {?} */ i = this._elementStack.length - 1; i >= 0; i--) {
if (!isNgContainer(this._elementStack[i].name)) {
return { parent: this._elementStack[i], container: container };
}
container = this._elementStack[i];
}
return { parent: this._elementStack[this._elementStack.length - 1], container: container };
};
/**
* @param {?} node
* @return {?}
*/
_TreeBuilder.prototype._addToParent = function (node) {
var /** @type {?} */ parent = this._getParentElement();
if (parent != null) {
parent.children.push(node);
}
else {
this._rootNodes.push(node);
}
};
/**
* Insert a node between the parent and the container.
* When no container is given, the node is appended as a child of the parent.
* Also updates the element stack accordingly.
*
* \@internal
* @param {?} parent
* @param {?} container
* @param {?} node
* @return {?}
*/
_TreeBuilder.prototype._insertBeforeContainer = function (parent, container, node) {
if (!container) {
this._addToParent(node);
this._elementStack.push(node);
}
else {
if (parent) {
// replace the container with the new node in the children
var /** @type {?} */ index = parent.children.indexOf(container);
parent.children[index] = node;
}
else {
this._rootNodes.push(node);
}
node.children.push(container);
this._elementStack.splice(this._elementStack.indexOf(container), 0, node);
}
};
/**
* @param {?} prefix
* @param {?} localName
* @param {?} parentElement
* @return {?}
*/
_TreeBuilder.prototype._getElementFullName = function (prefix, localName, parentElement) {
if (prefix == null) {
prefix = ((this.getTagDefinition(localName).implicitNamespacePrefix));
if (prefix == null && parentElement != null) {
prefix = getNsPrefix(parentElement.name);
}
}
return mergeNsAndName(prefix, localName);
};
return _TreeBuilder;
}());
/**
* @param {?} stack
* @param {?} element
* @return {?}
*/
function lastOnStack(stack, element) {
return stack.length > 0 && stack[stack.length - 1] === element;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var Message = (function () {
/**
* @param {?} nodes message AST
* @param {?} placeholders maps placeholder names to static content
* @param {?} placeholderToMessage maps placeholder names to messages (used for nested ICU messages)
* @param {?} meaning
* @param {?} description
* @param {?} id
*/
function Message(nodes, placeholders, placeholderToMessage, meaning, description, id) {
this.nodes = nodes;
this.placeholders = placeholders;
this.placeholderToMessage = placeholderToMessage;
this.meaning = meaning;
this.description = description;
this.id = id;
if (nodes.length) {
this.sources = [{
filePath: nodes[0].sourceSpan.start.file.url,
startLine: nodes[0].sourceSpan.start.line + 1,
startCol: nodes[0].sourceSpan.start.col + 1,
endLine: nodes[nodes.length - 1].sourceSpan.end.line + 1,
endCol: nodes[0].sourceSpan.start.col + 1
}];
}
else {
this.sources = [];
}
}
return Message;
}());
var Text$1 = (function () {
/**
* @param {?} value
* @param {?} sourceSpan
*/
function Text$1(value, sourceSpan) {
this.value = value;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Text$1.prototype.visit = function (visitor, context) { return visitor.visitText(this, context); };
return Text$1;
}());
var Container = (function () {
/**
* @param {?} children
* @param {?} sourceSpan
*/
function Container(children, sourceSpan) {
this.children = children;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Container.prototype.visit = function (visitor, context) { return visitor.visitContainer(this, context); };
return Container;
}());
var Icu = (function () {
/**
* @param {?} expression
* @param {?} type
* @param {?} cases
* @param {?} sourceSpan
*/
function Icu(expression, type, cases, sourceSpan) {
this.expression = expression;
this.type = type;
this.cases = cases;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Icu.prototype.visit = function (visitor, context) { return visitor.visitIcu(this, context); };
return Icu;
}());
var TagPlaceholder = (function () {
/**
* @param {?} tag
* @param {?} attrs
* @param {?} startName
* @param {?} closeName
* @param {?} children
* @param {?} isVoid
* @param {?} sourceSpan
*/
function TagPlaceholder(tag, attrs, startName, closeName, children, isVoid, sourceSpan) {
this.tag = tag;
this.attrs = attrs;
this.startName = startName;
this.closeName = closeName;
this.children = children;
this.isVoid = isVoid;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
TagPlaceholder.prototype.visit = function (visitor, context) { return visitor.visitTagPlaceholder(this, context); };
return TagPlaceholder;
}());
var Placeholder = (function () {
/**
* @param {?} value
* @param {?} name
* @param {?} sourceSpan
*/
function Placeholder(value, name, sourceSpan) {
this.value = value;
this.name = name;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
Placeholder.prototype.visit = function (visitor, context) { return visitor.visitPlaceholder(this, context); };
return Placeholder;
}());
var IcuPlaceholder = (function () {
/**
* @param {?} value
* @param {?} name
* @param {?} sourceSpan
*/
function IcuPlaceholder(value, name, sourceSpan) {
this.value = value;
this.name = name;
this.sourceSpan = sourceSpan;
}
/**
* @param {?} visitor
* @param {?=} context
* @return {?}
*/
IcuPlaceholder.prototype.visit = function (visitor, context) { return visitor.visitIcuPlaceholder(this, context); };
return IcuPlaceholder;
}());
var CloneVisitor = (function () {
function CloneVisitor() {
}
/**
* @param {?} text
* @param {?=} context
* @return {?}
*/
CloneVisitor.prototype.visitText = function (text, context) { return new Text$1(text.value, text.sourceSpan); };
/**
* @param {?} container
* @param {?=} context
* @return {?}
*/
CloneVisitor.prototype.visitContainer = function (container, context) {
var _this = this;
var /** @type {?} */ children = container.children.map(function (n) { return n.visit(_this, context); });
return new Container(children, container.sourceSpan);
};
/**
* @param {?} icu
* @param {?=} context
* @return {?}
*/
CloneVisitor.prototype.visitIcu = function (icu, context) {
var _this = this;
var /** @type {?} */ cases = {};
Object.keys(icu.cases).forEach(function (key) { return cases[key] = icu.cases[key].visit(_this, context); });
var /** @type {?} */ msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan);
msg.expressionPlaceholder = icu.expressionPlaceholder;
return msg;
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
CloneVisitor.prototype.visitTagPlaceholder = function (ph, context) {
var _this = this;
var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, context); });
return new TagPlaceholder(ph.tag, ph.attrs, ph.startName, ph.closeName, children, ph.isVoid, ph.sourceSpan);
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
CloneVisitor.prototype.visitPlaceholder = function (ph, context) {
return new Placeholder(ph.value, ph.name, ph.sourceSpan);
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
CloneVisitor.prototype.visitIcuPlaceholder = function (ph, context) {
return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan);
};
return CloneVisitor;
}());
var RecurseVisitor = (function () {
function RecurseVisitor() {
}
/**
* @param {?} text
* @param {?=} context
* @return {?}
*/
RecurseVisitor.prototype.visitText = function (text, context) { };
;
/**
* @param {?} container
* @param {?=} context
* @return {?}
*/
RecurseVisitor.prototype.visitContainer = function (container, context) {
var _this = this;
container.children.forEach(function (child) { return child.visit(_this); });
};
/**
* @param {?} icu
* @param {?=} context
* @return {?}
*/
RecurseVisitor.prototype.visitIcu = function (icu, context) {
var _this = this;
Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); });
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
RecurseVisitor.prototype.visitTagPlaceholder = function (ph, context) {
var _this = this;
ph.children.forEach(function (child) { return child.visit(_this); });
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
RecurseVisitor.prototype.visitPlaceholder = function (ph, context) { };
;
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
RecurseVisitor.prototype.visitIcuPlaceholder = function (ph, context) { };
;
return RecurseVisitor;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var TAG_TO_PLACEHOLDER_NAMES = {
'A': 'LINK',
'B': 'BOLD_TEXT',
'BR': 'LINE_BREAK',
'EM': 'EMPHASISED_TEXT',
'H1': 'HEADING_LEVEL1',
'H2': 'HEADING_LEVEL2',
'H3': 'HEADING_LEVEL3',
'H4': 'HEADING_LEVEL4',
'H5': 'HEADING_LEVEL5',
'H6': 'HEADING_LEVEL6',
'HR': 'HORIZONTAL_RULE',
'I': 'ITALIC_TEXT',
'LI': 'LIST_ITEM',
'LINK': 'MEDIA_LINK',
'OL': 'ORDERED_LIST',
'P': 'PARAGRAPH',
'Q': 'QUOTATION',
'S': 'STRIKETHROUGH_TEXT',
'SMALL': 'SMALL_TEXT',
'SUB': 'SUBSTRIPT',
'SUP': 'SUPERSCRIPT',
'TBODY': 'TABLE_BODY',
'TD': 'TABLE_CELL',
'TFOOT': 'TABLE_FOOTER',
'TH': 'TABLE_HEADER_CELL',
'THEAD': 'TABLE_HEADER',
'TR': 'TABLE_ROW',
'TT': 'MONOSPACED_TEXT',
'U': 'UNDERLINED_TEXT',
'UL': 'UNORDERED_LIST',
};
/**
* Creates unique names for placeholder with different content.
*
* Returns the same placeholder name when the content is identical.
*
* \@internal
*/
var PlaceholderRegistry = (function () {
function PlaceholderRegistry() {
this._placeHolderNameCounts = {};
this._signatureToName = {};
}
/**
* @param {?} tag
* @param {?} attrs
* @param {?} isVoid
* @return {?}
*/
PlaceholderRegistry.prototype.getStartTagPlaceholderName = function (tag, attrs, isVoid) {
var /** @type {?} */ signature = this._hashTag(tag, attrs, isVoid);
if (this._signatureToName[signature]) {
return this._signatureToName[signature];
}
var /** @type {?} */ upperTag = tag.toUpperCase();
var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
var /** @type {?} */ name = this._generateUniqueName(isVoid ? baseName : "START_" + baseName);
this._signatureToName[signature] = name;
return name;
};
/**
* @param {?} tag
* @return {?}
*/
PlaceholderRegistry.prototype.getCloseTagPlaceholderName = function (tag) {
var /** @type {?} */ signature = this._hashClosingTag(tag);
if (this._signatureToName[signature]) {
return this._signatureToName[signature];
}
var /** @type {?} */ upperTag = tag.toUpperCase();
var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
var /** @type {?} */ name = this._generateUniqueName("CLOSE_" + baseName);
this._signatureToName[signature] = name;
return name;
};
/**
* @param {?} name
* @param {?} content
* @return {?}
*/
PlaceholderRegistry.prototype.getPlaceholderName = function (name, content) {
var /** @type {?} */ upperName = name.toUpperCase();
var /** @type {?} */ signature = "PH: " + upperName + "=" + content;
if (this._signatureToName[signature]) {
return this._signatureToName[signature];
}
var /** @type {?} */ uniqueName = this._generateUniqueName(upperName);
this._signatureToName[signature] = uniqueName;
return uniqueName;
};
/**
* @param {?} name
* @return {?}
*/
PlaceholderRegistry.prototype.getUniquePlaceholder = function (name) {
return this._generateUniqueName(name.toUpperCase());
};
/**
* @param {?} tag
* @param {?} attrs
* @param {?} isVoid
* @return {?}
*/
PlaceholderRegistry.prototype._hashTag = function (tag, attrs, isVoid) {
var /** @type {?} */ start = "<" + tag;
var /** @type {?} */ strAttrs = Object.keys(attrs).sort().map(function (name) { return " " + name + "=" + attrs[name]; }).join('');
var /** @type {?} */ end = isVoid ? '/>' : ">" + tag + ">";
return start + strAttrs + end;
};
/**
* @param {?} tag
* @return {?}
*/
PlaceholderRegistry.prototype._hashClosingTag = function (tag) { return this._hashTag("/" + tag, {}, false); };
/**
* @param {?} base
* @return {?}
*/
PlaceholderRegistry.prototype._generateUniqueName = function (base) {
var /** @type {?} */ seen = this._placeHolderNameCounts.hasOwnProperty(base);
if (!seen) {
this._placeHolderNameCounts[base] = 1;
return base;
}
var /** @type {?} */ id = this._placeHolderNameCounts[base];
this._placeHolderNameCounts[base] = id + 1;
return base + "_" + id;
};
return PlaceholderRegistry;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _expParser = new Parser(new Lexer());
/**
* Returns a function converting html nodes to an i18n Message given an interpolationConfig
* @param {?} interpolationConfig
* @return {?}
*/
function createI18nMessageFactory(interpolationConfig) {
var /** @type {?} */ visitor = new _I18nVisitor(_expParser, interpolationConfig);
return function (nodes, meaning, description, id) { return visitor.toI18nMessage(nodes, meaning, description, id); };
}
var _I18nVisitor = (function () {
/**
* @param {?} _expressionParser
* @param {?} _interpolationConfig
*/
function _I18nVisitor(_expressionParser, _interpolationConfig) {
this._expressionParser = _expressionParser;
this._interpolationConfig = _interpolationConfig;
}
/**
* @param {?} nodes
* @param {?} meaning
* @param {?} description
* @param {?} id
* @return {?}
*/
_I18nVisitor.prototype.toI18nMessage = function (nodes, meaning, description, id) {
this._isIcu = nodes.length == 1 && nodes[0] instanceof Expansion;
this._icuDepth = 0;
this._placeholderRegistry = new PlaceholderRegistry();
this._placeholderToContent = {};
this._placeholderToMessage = {};
var /** @type {?} */ i18nodes = visitAll(this, nodes, {});
return new Message(i18nodes, this._placeholderToContent, this._placeholderToMessage, meaning, description, id);
};
/**
* @param {?} el
* @param {?} context
* @return {?}
*/
_I18nVisitor.prototype.visitElement = function (el, context) {
var /** @type {?} */ children = visitAll(this, el.children);
var /** @type {?} */ attrs = {};
el.attrs.forEach(function (attr) {
// Do not visit the attributes, translatable ones are top-level ASTs
attrs[attr.name] = attr.value;
});
var /** @type {?} */ isVoid = getHtmlTagDefinition(el.name).isVoid;
var /** @type {?} */ startPhName = this._placeholderRegistry.getStartTagPlaceholderName(el.name, attrs, isVoid);
this._placeholderToContent[startPhName] = ((el.sourceSpan)).toString();
var /** @type {?} */ closePhName = '';
if (!isVoid) {
closePhName = this._placeholderRegistry.getCloseTagPlaceholderName(el.name);
this._placeholderToContent[closePhName] = "" + el.name + ">";
}
return new TagPlaceholder(el.name, attrs, startPhName, closePhName, children, isVoid, /** @type {?} */ ((el.sourceSpan)));
};
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
_I18nVisitor.prototype.visitAttribute = function (attribute, context) {
return this._visitTextWithInterpolation(attribute.value, attribute.sourceSpan);
};
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
_I18nVisitor.prototype.visitText = function (text, context) {
return this._visitTextWithInterpolation(text.value, /** @type {?} */ ((text.sourceSpan)));
};
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
_I18nVisitor.prototype.visitComment = function (comment, context) { return null; };
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
_I18nVisitor.prototype.visitExpansion = function (icu, context) {
var _this = this;
this._icuDepth++;
var /** @type {?} */ i18nIcuCases = {};
var /** @type {?} */ i18nIcu = new Icu(icu.switchValue, icu.type, i18nIcuCases, icu.sourceSpan);
icu.cases.forEach(function (caze) {
i18nIcuCases[caze.value] = new Container(caze.expression.map(function (node) { return node.visit(_this, {}); }), caze.expSourceSpan);
});
this._icuDepth--;
if (this._isIcu || this._icuDepth > 0) {
// Returns an ICU node when:
// - the message (vs a part of the message) is an ICU message, or
// - the ICU message is nested.
var /** @type {?} */ expPh = this._placeholderRegistry.getUniquePlaceholder("VAR_" + icu.type);
i18nIcu.expressionPlaceholder = expPh;
this._placeholderToContent[expPh] = icu.switchValue;
return i18nIcu;
}
// Else returns a placeholder
// ICU placeholders should not be replaced with their original content but with the their
// translations. We need to create a new visitor (they are not re-entrant) to compute the
// message id.
// TODO(vicb): add a html.Node -> i18n.Message cache to avoid having to re-create the msg
var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName('ICU', icu.sourceSpan.toString());
var /** @type {?} */ visitor = new _I18nVisitor(this._expressionParser, this._interpolationConfig);
this._placeholderToMessage[phName] = visitor.toI18nMessage([icu], '', '', '');
return new IcuPlaceholder(i18nIcu, phName, icu.sourceSpan);
};
/**
* @param {?} icuCase
* @param {?} context
* @return {?}
*/
_I18nVisitor.prototype.visitExpansionCase = function (icuCase, context) {
throw new Error('Unreachable code');
};
/**
* @param {?} text
* @param {?} sourceSpan
* @return {?}
*/
_I18nVisitor.prototype._visitTextWithInterpolation = function (text, sourceSpan) {
var /** @type {?} */ splitInterpolation = this._expressionParser.splitInterpolation(text, sourceSpan.start.toString(), this._interpolationConfig);
if (!splitInterpolation) {
// No expression, return a single text
return new Text$1(text, sourceSpan);
}
// Return a group of text + expressions
var /** @type {?} */ nodes = [];
var /** @type {?} */ container = new Container(nodes, sourceSpan);
var _a = this._interpolationConfig, sDelimiter = _a.start, eDelimiter = _a.end;
for (var /** @type {?} */ i = 0; i < splitInterpolation.strings.length - 1; i++) {
var /** @type {?} */ expression = splitInterpolation.expressions[i];
var /** @type {?} */ baseName = _extractPlaceholderName(expression) || 'INTERPOLATION';
var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName(baseName, expression);
if (splitInterpolation.strings[i].length) {
// No need to add empty strings
nodes.push(new Text$1(splitInterpolation.strings[i], sourceSpan));
}
nodes.push(new Placeholder(expression, phName, sourceSpan));
this._placeholderToContent[phName] = sDelimiter + expression + eDelimiter;
}
// The last index contains no expression
var /** @type {?} */ lastStringIdx = splitInterpolation.strings.length - 1;
if (splitInterpolation.strings[lastStringIdx].length) {
nodes.push(new Text$1(splitInterpolation.strings[lastStringIdx], sourceSpan));
}
return container;
};
return _I18nVisitor;
}());
var _CUSTOM_PH_EXP = /\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*("|')([\s\S]*?)\1[\s\S]*\)/g;
/**
* @param {?} input
* @return {?}
*/
function _extractPlaceholderName(input) {
return input.split(_CUSTOM_PH_EXP)[2];
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* An i18n error.
*/
var I18nError = (function (_super) {
__extends(I18nError, _super);
/**
* @param {?} span
* @param {?} msg
*/
function I18nError(span, msg) {
return _super.call(this, span, msg) || this;
}
return I18nError;
}(ParseError));
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _I18N_ATTR = 'i18n';
var _I18N_ATTR_PREFIX = 'i18n-';
var _I18N_COMMENT_PREFIX_REGEXP = /^i18n:?/;
var MEANING_SEPARATOR = '|';
var ID_SEPARATOR = '@@';
/**
* Extract translatable messages from an html AST
* @param {?} nodes
* @param {?} interpolationConfig
* @param {?} implicitTags
* @param {?} implicitAttrs
* @return {?}
*/
function extractMessages(nodes, interpolationConfig, implicitTags, implicitAttrs) {
var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
return visitor.extract(nodes, interpolationConfig);
}
/**
* @param {?} nodes
* @param {?} translations
* @param {?} interpolationConfig
* @param {?} implicitTags
* @param {?} implicitAttrs
* @return {?}
*/
function mergeTranslations(nodes, translations, interpolationConfig, implicitTags, implicitAttrs) {
var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
return visitor.merge(nodes, translations, interpolationConfig);
}
var ExtractionResult = (function () {
/**
* @param {?} messages
* @param {?} errors
*/
function ExtractionResult(messages, errors) {
this.messages = messages;
this.errors = errors;
}
return ExtractionResult;
}());
var _VisitorMode = {};
_VisitorMode.Extract = 0;
_VisitorMode.Merge = 1;
_VisitorMode[_VisitorMode.Extract] = "Extract";
_VisitorMode[_VisitorMode.Merge] = "Merge";
/**
* This Visitor is used:
* 1. to extract all the translatable strings from an html AST (see `extract()`),
* 2. to replace the translatable strings with the actual translations (see `merge()`)
*
* \@internal
*/
var _Visitor = (function () {
/**
* @param {?} _implicitTags
* @param {?} _implicitAttrs
*/
function _Visitor(_implicitTags, _implicitAttrs) {
this._implicitTags = _implicitTags;
this._implicitAttrs = _implicitAttrs;
}
/**
* Extracts the messages from the tree
* @param {?} nodes
* @param {?} interpolationConfig
* @return {?}
*/
_Visitor.prototype.extract = function (nodes, interpolationConfig) {
var _this = this;
this._init(_VisitorMode.Extract, interpolationConfig);
nodes.forEach(function (node) { return node.visit(_this, null); });
if (this._inI18nBlock) {
this._reportError(nodes[nodes.length - 1], 'Unclosed block');
}
return new ExtractionResult(this._messages, this._errors);
};
/**
* Returns a tree where all translatable nodes are translated
* @param {?} nodes
* @param {?} translations
* @param {?} interpolationConfig
* @return {?}
*/
_Visitor.prototype.merge = function (nodes, translations, interpolationConfig) {
this._init(_VisitorMode.Merge, interpolationConfig);
this._translations = translations;
// Construct a single fake root element
var /** @type {?} */ wrapper = new Element('wrapper', [], nodes, /** @type {?} */ ((undefined)), undefined, undefined);
var /** @type {?} */ translatedNode = wrapper.visit(this, null);
if (this._inI18nBlock) {
this._reportError(nodes[nodes.length - 1], 'Unclosed block');
}
return new ParseTreeResult(translatedNode.children, this._errors);
};
/**
* @param {?} icuCase
* @param {?} context
* @return {?}
*/
_Visitor.prototype.visitExpansionCase = function (icuCase, context) {
// Parse cases for translatable html attributes
var /** @type {?} */ expression = visitAll(this, icuCase.expression, context);
if (this._mode === _VisitorMode.Merge) {
return new ExpansionCase(icuCase.value, expression, icuCase.sourceSpan, icuCase.valueSourceSpan, icuCase.expSourceSpan);
}
};
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
_Visitor.prototype.visitExpansion = function (icu, context) {
this._mayBeAddBlockChildren(icu);
var /** @type {?} */ wasInIcu = this._inIcu;
if (!this._inIcu) {
// nested ICU messages should not be extracted but top-level translated as a whole
if (this._isInTranslatableSection) {
this._addMessage([icu]);
}
this._inIcu = true;
}
var /** @type {?} */ cases = visitAll(this, icu.cases, context);
if (this._mode === _VisitorMode.Merge) {
icu = new Expansion(icu.switchValue, icu.type, cases, icu.sourceSpan, icu.switchValueSourceSpan);
}
this._inIcu = wasInIcu;
return icu;
};
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
_Visitor.prototype.visitComment = function (comment, context) {
var /** @type {?} */ isOpening = _isOpeningComment(comment);
if (isOpening && this._isInTranslatableSection) {
this._reportError(comment, 'Could not start a block inside a translatable section');
return;
}
var /** @type {?} */ isClosing = _isClosingComment(comment);
if (isClosing && !this._inI18nBlock) {
this._reportError(comment, 'Trying to close an unopened block');
return;
}
if (!this._inI18nNode && !this._inIcu) {
if (!this._inI18nBlock) {
if (isOpening) {
this._inI18nBlock = true;
this._blockStartDepth = this._depth;
this._blockChildren = [];
this._blockMeaningAndDesc = ((comment.value)).replace(_I18N_COMMENT_PREFIX_REGEXP, '').trim();
this._openTranslatableSection(comment);
}
}
else {
if (isClosing) {
if (this._depth == this._blockStartDepth) {
this._closeTranslatableSection(comment, this._blockChildren);
this._inI18nBlock = false;
var /** @type {?} */ message = ((this._addMessage(this._blockChildren, this._blockMeaningAndDesc)));
// merge attributes in sections
var /** @type {?} */ nodes = this._translateMessage(comment, message);
return visitAll(this, nodes);
}
else {
this._reportError(comment, 'I18N blocks should not cross element boundaries');
return;
}
}
}
}
};
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
_Visitor.prototype.visitText = function (text, context) {
if (this._isInTranslatableSection) {
this._mayBeAddBlockChildren(text);
}
return text;
};
/**
* @param {?} el
* @param {?} context
* @return {?}
*/
_Visitor.prototype.visitElement = function (el, context) {
var _this = this;
this._mayBeAddBlockChildren(el);
this._depth++;
var /** @type {?} */ wasInI18nNode = this._inI18nNode;
var /** @type {?} */ wasInImplicitNode = this._inImplicitNode;
var /** @type {?} */ childNodes = [];
var /** @type {?} */ translatedChildNodes = ((undefined));
// Extract:
// - top level nodes with the (implicit) "i18n" attribute if not already in a section
// - ICU messages
var /** @type {?} */ i18nAttr = _getI18nAttr(el);
var /** @type {?} */ i18nMeta = i18nAttr ? i18nAttr.value : '';
var /** @type {?} */ isImplicit = this._implicitTags.some(function (tag) { return el.name === tag; }) && !this._inIcu &&
!this._isInTranslatableSection;
var /** @type {?} */ isTopLevelImplicit = !wasInImplicitNode && isImplicit;
this._inImplicitNode = wasInImplicitNode || isImplicit;
if (!this._isInTranslatableSection && !this._inIcu) {
if (i18nAttr || isTopLevelImplicit) {
this._inI18nNode = true;
var /** @type {?} */ message = ((this._addMessage(el.children, i18nMeta)));
translatedChildNodes = this._translateMessage(el, message);
}
if (this._mode == _VisitorMode.Extract) {
var /** @type {?} */ isTranslatable = i18nAttr || isTopLevelImplicit;
if (isTranslatable)
this._openTranslatableSection(el);
visitAll(this, el.children);
if (isTranslatable)
this._closeTranslatableSection(el, el.children);
}
}
else {
if (i18nAttr || isTopLevelImplicit) {
this._reportError(el, 'Could not mark an element as translatable inside a translatable section');
}
if (this._mode == _VisitorMode.Extract) {
// Descend into child nodes for extraction
visitAll(this, el.children);
}
}
if (this._mode === _VisitorMode.Merge) {
var /** @type {?} */ visitNodes = translatedChildNodes || el.children;
visitNodes.forEach(function (child) {
var /** @type {?} */ visited = child.visit(_this, context);
if (visited && !_this._isInTranslatableSection) {
// Do not add the children from translatable sections (= i18n blocks here)
// They will be added later in this loop when the block closes (i.e. on ``)
childNodes = childNodes.concat(visited);
}
});
}
this._visitAttributesOf(el);
this._depth--;
this._inI18nNode = wasInI18nNode;
this._inImplicitNode = wasInImplicitNode;
if (this._mode === _VisitorMode.Merge) {
var /** @type {?} */ translatedAttrs = this._translateAttributes(el);
return new Element(el.name, translatedAttrs, childNodes, el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
}
return null;
};
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
_Visitor.prototype.visitAttribute = function (attribute, context) {
throw new Error('unreachable code');
};
/**
* @param {?} mode
* @param {?} interpolationConfig
* @return {?}
*/
_Visitor.prototype._init = function (mode, interpolationConfig) {
this._mode = mode;
this._inI18nBlock = false;
this._inI18nNode = false;
this._depth = 0;
this._inIcu = false;
this._msgCountAtSectionStart = undefined;
this._errors = [];
this._messages = [];
this._inImplicitNode = false;
this._createI18nMessage = createI18nMessageFactory(interpolationConfig);
};
/**
* @param {?} el
* @return {?}
*/
_Visitor.prototype._visitAttributesOf = function (el) {
var _this = this;
var /** @type {?} */ explicitAttrNameToValue = {};
var /** @type {?} */ implicitAttrNames = this._implicitAttrs[el.name] || [];
el.attrs.filter(function (attr) { return attr.name.startsWith(_I18N_ATTR_PREFIX); })
.forEach(function (attr) { return explicitAttrNameToValue[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
attr.value; });
el.attrs.forEach(function (attr) {
if (attr.name in explicitAttrNameToValue) {
_this._addMessage([attr], explicitAttrNameToValue[attr.name]);
}
else if (implicitAttrNames.some(function (name) { return attr.name === name; })) {
_this._addMessage([attr]);
}
});
};
/**
* @param {?} ast
* @param {?=} msgMeta
* @return {?}
*/
_Visitor.prototype._addMessage = function (ast, msgMeta) {
if (ast.length == 0 ||
ast.length == 1 && ast[0] instanceof Attribute$1 && !((ast[0])).value) {
// Do not create empty messages
return null;
}
var _a = _parseMessageMeta(msgMeta), meaning = _a.meaning, description = _a.description, id = _a.id;
var /** @type {?} */ message = this._createI18nMessage(ast, meaning, description, id);
this._messages.push(message);
return message;
};
/**
* @param {?} el
* @param {?} message
* @return {?}
*/
_Visitor.prototype._translateMessage = function (el, message) {
if (message && this._mode === _VisitorMode.Merge) {
var /** @type {?} */ nodes = this._translations.get(message);
if (nodes) {
return nodes;
}
this._reportError(el, "Translation unavailable for message id=\"" + this._translations.digest(message) + "\"");
}
return [];
};
/**
* @param {?} el
* @return {?}
*/
_Visitor.prototype._translateAttributes = function (el) {
var _this = this;
var /** @type {?} */ attributes = el.attrs;
var /** @type {?} */ i18nParsedMessageMeta = {};
attributes.forEach(function (attr) {
if (attr.name.startsWith(_I18N_ATTR_PREFIX)) {
i18nParsedMessageMeta[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
_parseMessageMeta(attr.value);
}
});
var /** @type {?} */ translatedAttributes = [];
attributes.forEach(function (attr) {
if (attr.name === _I18N_ATTR || attr.name.startsWith(_I18N_ATTR_PREFIX)) {
// strip i18n specific attributes
return;
}
if (attr.value && attr.value != '' && i18nParsedMessageMeta.hasOwnProperty(attr.name)) {
var _a = i18nParsedMessageMeta[attr.name], meaning = _a.meaning, description = _a.description, id = _a.id;
var /** @type {?} */ message = _this._createI18nMessage([attr], meaning, description, id);
var /** @type {?} */ nodes = _this._translations.get(message);
if (nodes) {
if (nodes.length == 0) {
translatedAttributes.push(new Attribute$1(attr.name, '', attr.sourceSpan));
}
else if (nodes[0] instanceof Text) {
var /** @type {?} */ value = ((nodes[0])).value;
translatedAttributes.push(new Attribute$1(attr.name, value, attr.sourceSpan));
}
else {
_this._reportError(el, "Unexpected translation for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
}
}
else {
_this._reportError(el, "Translation unavailable for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
}
}
else {
translatedAttributes.push(attr);
}
});
return translatedAttributes;
};
/**
* Add the node as a child of the block when:
* - we are in a block,
* - we are not inside a ICU message (those are handled separately),
* - the node is a "direct child" of the block
* @param {?} node
* @return {?}
*/
_Visitor.prototype._mayBeAddBlockChildren = function (node) {
if (this._inI18nBlock && !this._inIcu && this._depth == this._blockStartDepth) {
this._blockChildren.push(node);
}
};
/**
* Marks the start of a section, see `_closeTranslatableSection`
* @param {?} node
* @return {?}
*/
_Visitor.prototype._openTranslatableSection = function (node) {
if (this._isInTranslatableSection) {
this._reportError(node, 'Unexpected section start');
}
else {
this._msgCountAtSectionStart = this._messages.length;
}
};
Object.defineProperty(_Visitor.prototype, "_isInTranslatableSection", {
/**
* A translatable section could be:
* - the content of translatable element,
* - nodes between `` and `` comments
* @return {?}
*/
get: function () {
return this._msgCountAtSectionStart !== void 0;
},
enumerable: true,
configurable: true
});
/**
* Terminates a section.
*
* If a section has only one significant children (comments not significant) then we should not
* keep the message from this children:
*
* `
{ICU message}
` would produce two messages:
* - one for the
content with meaning and description,
* - another one for the ICU message.
*
* In this case the last message is discarded as it contains less information (the AST is
* otherwise identical).
*
* Note that we should still keep messages extracted from attributes inside the section (ie in the
* ICU message here)
* @param {?} node
* @param {?} directChildren
* @return {?}
*/
_Visitor.prototype._closeTranslatableSection = function (node, directChildren) {
if (!this._isInTranslatableSection) {
this._reportError(node, 'Unexpected section end');
return;
}
var /** @type {?} */ startIndex = this._msgCountAtSectionStart;
var /** @type {?} */ significantChildren = directChildren.reduce(function (count, node) { return count + (node instanceof Comment ? 0 : 1); }, 0);
if (significantChildren == 1) {
for (var /** @type {?} */ i = this._messages.length - 1; i >= startIndex; i--) {
var /** @type {?} */ ast = this._messages[i].nodes;
if (!(ast.length == 1 && ast[0] instanceof Text$1)) {
this._messages.splice(i, 1);
break;
}
}
}
this._msgCountAtSectionStart = undefined;
};
/**
* @param {?} node
* @param {?} msg
* @return {?}
*/
_Visitor.prototype._reportError = function (node, msg) {
this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), msg));
};
return _Visitor;
}());
/**
* @param {?} n
* @return {?}
*/
function _isOpeningComment(n) {
return !!(n instanceof Comment && n.value && n.value.startsWith('i18n'));
}
/**
* @param {?} n
* @return {?}
*/
function _isClosingComment(n) {
return !!(n instanceof Comment && n.value && n.value === '/i18n');
}
/**
* @param {?} p
* @return {?}
*/
function _getI18nAttr(p) {
return p.attrs.find(function (attr) { return attr.name === _I18N_ATTR; }) || null;
}
/**
* @param {?=} i18n
* @return {?}
*/
function _parseMessageMeta(i18n) {
if (!i18n)
return { meaning: '', description: '', id: '' };
var /** @type {?} */ idIndex = i18n.indexOf(ID_SEPARATOR);
var /** @type {?} */ descIndex = i18n.indexOf(MEANING_SEPARATOR);
var _a = (idIndex > -1) ? [i18n.slice(0, idIndex), i18n.slice(idIndex + 2)] : [i18n, ''], meaningAndDesc = _a[0], id = _a[1];
var _b = (descIndex > -1) ?
[meaningAndDesc.slice(0, descIndex), meaningAndDesc.slice(descIndex + 1)] :
['', meaningAndDesc], meaning = _b[0], description = _b[1];
return { meaning: meaning, description: description, id: id };
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var XmlTagDefinition = (function () {
function XmlTagDefinition() {
this.closedByParent = false;
this.contentType = TagContentType.PARSABLE_DATA;
this.isVoid = false;
this.ignoreFirstLf = false;
this.canSelfClose = true;
}
/**
* @param {?} currentParent
* @return {?}
*/
XmlTagDefinition.prototype.requireExtraParent = function (currentParent) { return false; };
/**
* @param {?} name
* @return {?}
*/
XmlTagDefinition.prototype.isClosedByChild = function (name) { return false; };
return XmlTagDefinition;
}());
var _TAG_DEFINITION = new XmlTagDefinition();
/**
* @param {?} tagName
* @return {?}
*/
function getXmlTagDefinition(tagName) {
return _TAG_DEFINITION;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var XmlParser = (function (_super) {
__extends(XmlParser, _super);
function XmlParser() {
return _super.call(this, getXmlTagDefinition) || this;
}
/**
* @param {?} source
* @param {?} url
* @param {?=} parseExpansionForms
* @return {?}
*/
XmlParser.prototype.parse = function (source, url, parseExpansionForms) {
if (parseExpansionForms === void 0) { parseExpansionForms = false; }
return _super.prototype.parse.call(this, source, url, parseExpansionForms);
};
return XmlParser;
}(Parser$1));
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @param {?} message
* @return {?}
*/
function digest(message) {
return message.id || sha1(serializeNodes(message.nodes).join('') + ("[" + message.meaning + "]"));
}
/**
* @param {?} message
* @return {?}
*/
function decimalDigest(message) {
if (message.id) {
return message.id;
}
var /** @type {?} */ visitor = new _SerializerIgnoreIcuExpVisitor();
var /** @type {?} */ parts = message.nodes.map(function (a) { return a.visit(visitor, null); });
return computeMsgId(parts.join(''), message.meaning);
}
/**
* Serialize the i18n ast to something xml-like in order to generate an UID.
*
* The visitor is also used in the i18n parser tests
*
* \@internal
*/
var _SerializerVisitor = (function () {
function _SerializerVisitor() {
}
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
_SerializerVisitor.prototype.visitText = function (text, context) { return text.value; };
/**
* @param {?} container
* @param {?} context
* @return {?}
*/
_SerializerVisitor.prototype.visitContainer = function (container, context) {
var _this = this;
return "[" + container.children.map(function (child) { return child.visit(_this); }).join(', ') + "]";
};
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
_SerializerVisitor.prototype.visitIcu = function (icu, context) {
var _this = this;
var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
return "{" + icu.expression + ", " + icu.type + ", " + strCases.join(', ') + "}";
};
/**
* @param {?} ph
* @param {?} context
* @return {?}
*/
_SerializerVisitor.prototype.visitTagPlaceholder = function (ph, context) {
var _this = this;
return ph.isVoid ?
"" :
"" + ph.children.map(function (child) { return child.visit(_this); }).join(', ') + "";
};
/**
* @param {?} ph
* @param {?} context
* @return {?}
*/
_SerializerVisitor.prototype.visitPlaceholder = function (ph, context) {
return ph.value ? "" + ph.value + "" : "";
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_SerializerVisitor.prototype.visitIcuPlaceholder = function (ph, context) {
return "" + ph.value.visit(this) + "";
};
return _SerializerVisitor;
}());
var serializerVisitor = new _SerializerVisitor();
/**
* @param {?} nodes
* @return {?}
*/
function serializeNodes(nodes) {
return nodes.map(function (a) { return a.visit(serializerVisitor, null); });
}
/**
* Serialize the i18n ast to something xml-like in order to generate an UID.
*
* Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
*
* \@internal
*/
var _SerializerIgnoreIcuExpVisitor = (function (_super) {
__extends(_SerializerIgnoreIcuExpVisitor, _super);
function _SerializerIgnoreIcuExpVisitor() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
_SerializerIgnoreIcuExpVisitor.prototype.visitIcu = function (icu, context) {
var _this = this;
var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
// Do not take the expression into account
return "{" + icu.type + ", " + strCases.join(', ') + "}";
};
return _SerializerIgnoreIcuExpVisitor;
}(_SerializerVisitor));
/**
* Compute the SHA1 of the given string
*
* see http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
*
* WARNING: this function has not been designed not tested with security in mind.
* DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
* @param {?} str
* @return {?}
*/
function sha1(str) {
var /** @type {?} */ utf8 = utf8Encode(str);
var /** @type {?} */ words32 = stringToWords32(utf8, Endian.Big);
var /** @type {?} */ len = utf8.length * 8;
var /** @type {?} */ w = new Array(80);
var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4];
words32[len >> 5] |= 0x80 << (24 - len % 32);
words32[((len + 64 >> 9) << 4) + 15] = len;
for (var /** @type {?} */ i = 0; i < words32.length; i += 16) {
var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4];
for (var /** @type {?} */ j = 0; j < 80; j++) {
if (j < 16) {
w[j] = words32[i + j];
}
else {
w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
}
var _c = fk(j, b, c, d), f = _c[0], k = _c[1];
var /** @type {?} */ temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
_d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4];
}
_e = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], a = _e[0], b = _e[1], c = _e[2], d = _e[3], e = _e[4];
}
return byteStringToHexString(words32ToByteString([a, b, c, d, e]));
var _d, _e;
}
/**
* @param {?} index
* @param {?} b
* @param {?} c
* @param {?} d
* @return {?}
*/
function fk(index, b, c, d) {
if (index < 20) {
return [(b & c) | (~b & d), 0x5a827999];
}
if (index < 40) {
return [b ^ c ^ d, 0x6ed9eba1];
}
if (index < 60) {
return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
}
return [b ^ c ^ d, 0xca62c1d6];
}
/**
* Compute the fingerprint of the given string
*
* The output is 64 bit number encoded as a decimal string
*
* based on:
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
* @param {?} str
* @return {?}
*/
function fingerprint(str) {
var /** @type {?} */ utf8 = utf8Encode(str);
var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
if (hi == 0 && (lo == 0 || lo == 1)) {
hi = hi ^ 0x130f9bef;
lo = lo ^ -0x6b5f56d8;
}
return [hi, lo];
}
/**
* @param {?} msg
* @param {?} meaning
* @return {?}
*/
function computeMsgId(msg, meaning) {
var _a = fingerprint(msg), hi = _a[0], lo = _a[1];
if (meaning) {
var _b = fingerprint(meaning), him = _b[0], lom = _b[1];
_c = add64(rol64([hi, lo], 1), [him, lom]), hi = _c[0], lo = _c[1];
}
return byteStringToDecString(words32ToByteString([hi & 0x7fffffff, lo]));
var _c;
}
/**
* @param {?} str
* @param {?} c
* @return {?}
*/
function hash32(str, c) {
var _a = [0x9e3779b9, 0x9e3779b9], a = _a[0], b = _a[1];
var /** @type {?} */ i;
var /** @type {?} */ len = str.length;
for (i = 0; i + 12 <= len; i += 12) {
a = add32(a, wordAt(str, i, Endian.Little));
b = add32(b, wordAt(str, i + 4, Endian.Little));
c = add32(c, wordAt(str, i + 8, Endian.Little));
_b = mix([a, b, c]), a = _b[0], b = _b[1], c = _b[2];
}
a = add32(a, wordAt(str, i, Endian.Little));
b = add32(b, wordAt(str, i + 4, Endian.Little));
// the first byte of c is reserved for the length
c = add32(c, len);
c = add32(c, wordAt(str, i + 8, Endian.Little) << 8);
return mix([a, b, c])[2];
var _b;
}
/**
* @param {?} __0
* @return {?}
*/
function mix(_a) {
var a = _a[0], b = _a[1], c = _a[2];
a = sub32(a, b);
a = sub32(a, c);
a ^= c >>> 13;
b = sub32(b, c);
b = sub32(b, a);
b ^= a << 8;
c = sub32(c, a);
c = sub32(c, b);
c ^= b >>> 13;
a = sub32(a, b);
a = sub32(a, c);
a ^= c >>> 12;
b = sub32(b, c);
b = sub32(b, a);
b ^= a << 16;
c = sub32(c, a);
c = sub32(c, b);
c ^= b >>> 5;
a = sub32(a, b);
a = sub32(a, c);
a ^= c >>> 3;
b = sub32(b, c);
b = sub32(b, a);
b ^= a << 10;
c = sub32(c, a);
c = sub32(c, b);
c ^= b >>> 15;
return [a, b, c];
}
var Endian = {};
Endian.Little = 0;
Endian.Big = 1;
Endian[Endian.Little] = "Little";
Endian[Endian.Big] = "Big";
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function add32(a, b) {
return add32to64(a, b)[1];
}
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function add32to64(a, b) {
var /** @type {?} */ low = (a & 0xffff) + (b & 0xffff);
var /** @type {?} */ high = (a >>> 16) + (b >>> 16) + (low >>> 16);
return [high >>> 16, (high << 16) | (low & 0xffff)];
}
/**
* @param {?} __0
* @param {?} __1
* @return {?}
*/
function add64(_a, _b) {
var ah = _a[0], al = _a[1];
var bh = _b[0], bl = _b[1];
var _c = add32to64(al, bl), carry = _c[0], l = _c[1];
var /** @type {?} */ h = add32(add32(ah, bh), carry);
return [h, l];
}
/**
* @param {?} a
* @param {?} b
* @return {?}
*/
function sub32(a, b) {
var /** @type {?} */ low = (a & 0xffff) - (b & 0xffff);
var /** @type {?} */ high = (a >> 16) - (b >> 16) + (low >> 16);
return (high << 16) | (low & 0xffff);
}
/**
* @param {?} a
* @param {?} count
* @return {?}
*/
function rol32(a, count) {
return (a << count) | (a >>> (32 - count));
}
/**
* @param {?} __0
* @param {?} count
* @return {?}
*/
function rol64(_a, count) {
var hi = _a[0], lo = _a[1];
var /** @type {?} */ h = (hi << count) | (lo >>> (32 - count));
var /** @type {?} */ l = (lo << count) | (hi >>> (32 - count));
return [h, l];
}
/**
* @param {?} str
* @param {?} endian
* @return {?}
*/
function stringToWords32(str, endian) {
var /** @type {?} */ words32 = Array((str.length + 3) >>> 2);
for (var /** @type {?} */ i = 0; i < words32.length; i++) {
words32[i] = wordAt(str, i * 4, endian);
}
return words32;
}
/**
* @param {?} str
* @param {?} index
* @return {?}
*/
function byteAt(str, index) {
return index >= str.length ? 0 : str.charCodeAt(index) & 0xff;
}
/**
* @param {?} str
* @param {?} index
* @param {?} endian
* @return {?}
*/
function wordAt(str, index, endian) {
var /** @type {?} */ word = 0;
if (endian === Endian.Big) {
for (var /** @type {?} */ i = 0; i < 4; i++) {
word += byteAt(str, index + i) << (24 - 8 * i);
}
}
else {
for (var /** @type {?} */ i = 0; i < 4; i++) {
word += byteAt(str, index + i) << 8 * i;
}
}
return word;
}
/**
* @param {?} words32
* @return {?}
*/
function words32ToByteString(words32) {
return words32.reduce(function (str, word) { return str + word32ToByteString(word); }, '');
}
/**
* @param {?} word
* @return {?}
*/
function word32ToByteString(word) {
var /** @type {?} */ str = '';
for (var /** @type {?} */ i = 0; i < 4; i++) {
str += String.fromCharCode((word >>> 8 * (3 - i)) & 0xff);
}
return str;
}
/**
* @param {?} str
* @return {?}
*/
function byteStringToHexString(str) {
var /** @type {?} */ hex = '';
for (var /** @type {?} */ i = 0; i < str.length; i++) {
var /** @type {?} */ b = byteAt(str, i);
hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
}
return hex.toLowerCase();
}
/**
* @param {?} str
* @return {?}
*/
function byteStringToDecString(str) {
var /** @type {?} */ decimal = '';
var /** @type {?} */ toThePower = '1';
for (var /** @type {?} */ i = str.length - 1; i >= 0; i--) {
decimal = addBigInt(decimal, numberTimesBigInt(byteAt(str, i), toThePower));
toThePower = numberTimesBigInt(256, toThePower);
}
return decimal.split('').reverse().join('');
}
/**
* @param {?} x
* @param {?} y
* @return {?}
*/
function addBigInt(x, y) {
var /** @type {?} */ sum = '';
var /** @type {?} */ len = Math.max(x.length, y.length);
for (var /** @type {?} */ i = 0, /** @type {?} */ carry = 0; i < len || carry; i++) {
var /** @type {?} */ tmpSum = carry + +(x[i] || 0) + +(y[i] || 0);
if (tmpSum >= 10) {
carry = 1;
sum += tmpSum - 10;
}
else {
carry = 0;
sum += tmpSum;
}
}
return sum;
}
/**
* @param {?} num
* @param {?} b
* @return {?}
*/
function numberTimesBigInt(num, b) {
var /** @type {?} */ product = '';
var /** @type {?} */ bToThePower = b;
for (; num !== 0; num = num >>> 1) {
if (num & 1)
product = addBigInt(product, bToThePower);
bToThePower = addBigInt(bToThePower, bToThePower);
}
return product;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @abstract
*/
var Serializer = (function () {
function Serializer() {
}
/**
* @abstract
* @param {?} messages
* @param {?} locale
* @return {?}
*/
Serializer.prototype.write = function (messages, locale) { };
/**
* @abstract
* @param {?} content
* @param {?} url
* @return {?}
*/
Serializer.prototype.load = function (content, url) { };
/**
* @abstract
* @param {?} message
* @return {?}
*/
Serializer.prototype.digest = function (message) { };
/**
* @param {?} message
* @return {?}
*/
Serializer.prototype.createNameMapper = function (message) { return null; };
return Serializer;
}());
/**
* A simple mapper that take a function to transform an internal name to a public name
*/
var SimplePlaceholderMapper = (function (_super) {
__extends(SimplePlaceholderMapper, _super);
/**
* @param {?} message
* @param {?} mapName
*/
function SimplePlaceholderMapper(message, mapName) {
var _this = _super.call(this) || this;
_this.mapName = mapName;
_this.internalToPublic = {};
_this.publicToNextId = {};
_this.publicToInternal = {};
message.nodes.forEach(function (node) { return node.visit(_this); });
return _this;
}
/**
* @param {?} internalName
* @return {?}
*/
SimplePlaceholderMapper.prototype.toPublicName = function (internalName) {
return this.internalToPublic.hasOwnProperty(internalName) ?
this.internalToPublic[internalName] :
null;
};
/**
* @param {?} publicName
* @return {?}
*/
SimplePlaceholderMapper.prototype.toInternalName = function (publicName) {
return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] :
null;
};
/**
* @param {?} text
* @param {?=} context
* @return {?}
*/
SimplePlaceholderMapper.prototype.visitText = function (text, context) { return null; };
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
SimplePlaceholderMapper.prototype.visitTagPlaceholder = function (ph, context) {
this.visitPlaceholderName(ph.startName);
_super.prototype.visitTagPlaceholder.call(this, ph, context);
this.visitPlaceholderName(ph.closeName);
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
SimplePlaceholderMapper.prototype.visitPlaceholder = function (ph, context) { this.visitPlaceholderName(ph.name); };
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
SimplePlaceholderMapper.prototype.visitIcuPlaceholder = function (ph, context) {
this.visitPlaceholderName(ph.name);
};
/**
* @param {?} internalName
* @return {?}
*/
SimplePlaceholderMapper.prototype.visitPlaceholderName = function (internalName) {
if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) {
return;
}
var /** @type {?} */ publicName = this.mapName(internalName);
if (this.publicToInternal.hasOwnProperty(publicName)) {
// Create a new XMB when it has already been used
var /** @type {?} */ nextId = this.publicToNextId[publicName];
this.publicToNextId[publicName] = nextId + 1;
publicName = publicName + "_" + nextId;
}
else {
this.publicToNextId[publicName] = 1;
}
this.internalToPublic[internalName] = publicName;
this.publicToInternal[publicName] = internalName;
};
return SimplePlaceholderMapper;
}(RecurseVisitor));
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _Visitor$1 = (function () {
function _Visitor$1() {
}
/**
* @param {?} tag
* @return {?}
*/
_Visitor$1.prototype.visitTag = function (tag) {
var _this = this;
var /** @type {?} */ strAttrs = this._serializeAttributes(tag.attrs);
if (tag.children.length == 0) {
return "<" + tag.name + strAttrs + "/>";
}
var /** @type {?} */ strChildren = tag.children.map(function (node) { return node.visit(_this); });
return "<" + tag.name + strAttrs + ">" + strChildren.join('') + "" + tag.name + ">";
};
/**
* @param {?} text
* @return {?}
*/
_Visitor$1.prototype.visitText = function (text) { return text.value; };
/**
* @param {?} decl
* @return {?}
*/
_Visitor$1.prototype.visitDeclaration = function (decl) {
return "";
};
/**
* @param {?} attrs
* @return {?}
*/
_Visitor$1.prototype._serializeAttributes = function (attrs) {
var /** @type {?} */ strAttrs = Object.keys(attrs).map(function (name) { return name + "=\"" + attrs[name] + "\""; }).join(' ');
return strAttrs.length > 0 ? ' ' + strAttrs : '';
};
/**
* @param {?} doctype
* @return {?}
*/
_Visitor$1.prototype.visitDoctype = function (doctype) {
return "";
};
return _Visitor$1;
}());
var _visitor = new _Visitor$1();
/**
* @param {?} nodes
* @return {?}
*/
function serialize(nodes) {
return nodes.map(function (node) { return node.visit(_visitor); }).join('');
}
var Declaration = (function () {
/**
* @param {?} unescapedAttrs
*/
function Declaration(unescapedAttrs) {
var _this = this;
this.attrs = {};
Object.keys(unescapedAttrs).forEach(function (k) {
_this.attrs[k] = _escapeXml(unescapedAttrs[k]);
});
}
/**
* @param {?} visitor
* @return {?}
*/
Declaration.prototype.visit = function (visitor) { return visitor.visitDeclaration(this); };
return Declaration;
}());
var Doctype = (function () {
/**
* @param {?} rootTag
* @param {?} dtd
*/
function Doctype(rootTag, dtd) {
this.rootTag = rootTag;
this.dtd = dtd;
}
;
/**
* @param {?} visitor
* @return {?}
*/
Doctype.prototype.visit = function (visitor) { return visitor.visitDoctype(this); };
return Doctype;
}());
var Tag = (function () {
/**
* @param {?} name
* @param {?=} unescapedAttrs
* @param {?=} children
*/
function Tag(name, unescapedAttrs, children) {
if (unescapedAttrs === void 0) { unescapedAttrs = {}; }
if (children === void 0) { children = []; }
var _this = this;
this.name = name;
this.children = children;
this.attrs = {};
Object.keys(unescapedAttrs).forEach(function (k) {
_this.attrs[k] = _escapeXml(unescapedAttrs[k]);
});
}
/**
* @param {?} visitor
* @return {?}
*/
Tag.prototype.visit = function (visitor) { return visitor.visitTag(this); };
return Tag;
}());
var Text$2 = (function () {
/**
* @param {?} unescapedValue
*/
function Text$2(unescapedValue) {
this.value = _escapeXml(unescapedValue);
}
;
/**
* @param {?} visitor
* @return {?}
*/
Text$2.prototype.visit = function (visitor) { return visitor.visitText(this); };
return Text$2;
}());
var CR = (function (_super) {
__extends(CR, _super);
/**
* @param {?=} ws
*/
function CR(ws) {
if (ws === void 0) { ws = 0; }
return _super.call(this, "\n" + new Array(ws + 1).join(' ')) || this;
}
return CR;
}(Text$2));
var _ESCAPED_CHARS = [
[/&/g, '&'],
[/"/g, '"'],
[/'/g, '''],
[//g, '>'],
];
/**
* @param {?} text
* @return {?}
*/
function _escapeXml(text) {
return _ESCAPED_CHARS.reduce(function (text, entry) { return text.replace(entry[0], entry[1]); }, text);
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _VERSION = '1.2';
var _XMLNS = 'urn:oasis:names:tc:xliff:document:1.2';
// TODO(vicb): make this a param (s/_/-/)
var _DEFAULT_SOURCE_LANG = 'en';
var _PLACEHOLDER_TAG = 'x';
var _FILE_TAG = 'file';
var _SOURCE_TAG = 'source';
var _TARGET_TAG = 'target';
var _UNIT_TAG = 'trans-unit';
var _CONTEXT_GROUP_TAG = 'context-group';
var _CONTEXT_TAG = 'context';
var Xliff = (function (_super) {
__extends(Xliff, _super);
function Xliff() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} messages
* @param {?} locale
* @return {?}
*/
Xliff.prototype.write = function (messages, locale) {
var /** @type {?} */ visitor = new _WriteVisitor();
var /** @type {?} */ transUnits = [];
messages.forEach(function (message) {
var /** @type {?} */ contextTags = [];
message.sources.forEach(function (source) {
var /** @type {?} */ contextGroupTag = new Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' });
contextGroupTag.children.push(new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'sourcefile' }, [new Text$2(source.filePath)]), new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'linenumber' }, [new Text$2("" + source.startLine)]), new CR(8));
contextTags.push(new CR(8), contextGroupTag);
});
var /** @type {?} */ transUnit = new Tag(_UNIT_TAG, { id: message.id, datatype: 'html' });
(_a = transUnit.children).push.apply(_a, [new CR(8), new Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes)), new CR(8), new Tag(_TARGET_TAG)].concat(contextTags));
if (message.description) {
transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'description' }, [new Text$2(message.description)]));
}
if (message.meaning) {
transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'meaning' }, [new Text$2(message.meaning)]));
}
transUnit.children.push(new CR(6));
transUnits.push(new CR(6), transUnit);
var _a;
});
var /** @type {?} */ body = new Tag('body', {}, transUnits.concat([new CR(4)]));
var /** @type {?} */ file = new Tag('file', {
'source-language': locale || _DEFAULT_SOURCE_LANG,
datatype: 'plaintext',
original: 'ng2.template',
}, [new CR(4), body, new CR(2)]);
var /** @type {?} */ xliff = new Tag('xliff', { version: _VERSION, xmlns: _XMLNS }, [new CR(2), file, new CR()]);
return serialize([
new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
]);
};
/**
* @param {?} content
* @param {?} url
* @return {?}
*/
Xliff.prototype.load = function (content, url) {
// xliff to xml nodes
var /** @type {?} */ xliffParser = new XliffParser();
var _a = xliffParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
// xml nodes to i18n nodes
var /** @type {?} */ i18nNodesByMsgId = {};
var /** @type {?} */ converter = new XmlToI18n();
Object.keys(msgIdToHtml).forEach(function (msgId) {
var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
errors.push.apply(errors, e);
i18nNodesByMsgId[msgId] = i18nNodes;
});
if (errors.length) {
throw new Error("xliff parse errors:\n" + errors.join('\n'));
}
return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
};
/**
* @param {?} message
* @return {?}
*/
Xliff.prototype.digest = function (message) { return digest(message); };
return Xliff;
}(Serializer));
var _WriteVisitor = (function () {
function _WriteVisitor() {
}
/**
* @param {?} text
* @param {?=} context
* @return {?}
*/
_WriteVisitor.prototype.visitText = function (text, context) { return [new Text$2(text.value)]; };
/**
* @param {?} container
* @param {?=} context
* @return {?}
*/
_WriteVisitor.prototype.visitContainer = function (container, context) {
var _this = this;
var /** @type {?} */ nodes = [];
container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
return nodes;
};
/**
* @param {?} icu
* @param {?=} context
* @return {?}
*/
_WriteVisitor.prototype.visitIcu = function (icu, context) {
var _this = this;
var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
Object.keys(icu.cases).forEach(function (c) {
nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
});
nodes.push(new Text$2("}"));
return nodes;
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_WriteVisitor.prototype.visitTagPlaceholder = function (ph, context) {
var /** @type {?} */ ctype = getCtypeForTag(ph.tag);
var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype });
if (ph.isVoid) {
// void tags have no children nor closing tags
return [startTagPh];
}
var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.closeName, ctype: ctype });
return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_WriteVisitor.prototype.visitPlaceholder = function (ph, context) {
return [new Tag(_PLACEHOLDER_TAG, { id: ph.name })];
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_WriteVisitor.prototype.visitIcuPlaceholder = function (ph, context) {
return [new Tag(_PLACEHOLDER_TAG, { id: ph.name })];
};
/**
* @param {?} nodes
* @return {?}
*/
_WriteVisitor.prototype.serialize = function (nodes) {
var _this = this;
return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
};
return _WriteVisitor;
}());
var XliffParser = (function () {
function XliffParser() {
this._locale = null;
}
/**
* @param {?} xliff
* @param {?} url
* @return {?}
*/
XliffParser.prototype.parse = function (xliff, url) {
this._unitMlString = null;
this._msgIdToHtml = {};
var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
this._errors = xml.errors;
visitAll(this, xml.rootNodes, null);
return {
msgIdToHtml: this._msgIdToHtml,
errors: this._errors,
locale: this._locale,
};
};
/**
* @param {?} element
* @param {?} context
* @return {?}
*/
XliffParser.prototype.visitElement = function (element, context) {
switch (element.name) {
case _UNIT_TAG:
this._unitMlString = ((null));
var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
if (!idAttr) {
this._addError(element, "<" + _UNIT_TAG + "> misses the \"id\" attribute");
}
else {
var /** @type {?} */ id = idAttr.value;
if (this._msgIdToHtml.hasOwnProperty(id)) {
this._addError(element, "Duplicated translations for msg " + id);
}
else {
visitAll(this, element.children, null);
if (typeof this._unitMlString === 'string') {
this._msgIdToHtml[id] = this._unitMlString;
}
else {
this._addError(element, "Message " + id + " misses a translation");
}
}
}
break;
case _SOURCE_TAG:
// ignore source message
break;
case _TARGET_TAG:
var /** @type {?} */ innerTextStart = ((element.startSourceSpan)).end.offset;
var /** @type {?} */ innerTextEnd = ((element.endSourceSpan)).start.offset;
var /** @type {?} */ content = ((element.startSourceSpan)).start.file.content;
var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
this._unitMlString = innerText;
break;
case _FILE_TAG:
var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'target-language'; });
if (localeAttr) {
this._locale = localeAttr.value;
}
visitAll(this, element.children, null);
break;
default:
// TODO(vicb): assert file structure, xliff version
// For now only recurse on unhandled nodes
visitAll(this, element.children, null);
}
};
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
XliffParser.prototype.visitAttribute = function (attribute, context) { };
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
XliffParser.prototype.visitText = function (text, context) { };
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
XliffParser.prototype.visitComment = function (comment, context) { };
/**
* @param {?} expansion
* @param {?} context
* @return {?}
*/
XliffParser.prototype.visitExpansion = function (expansion, context) { };
/**
* @param {?} expansionCase
* @param {?} context
* @return {?}
*/
XliffParser.prototype.visitExpansionCase = function (expansionCase, context) { };
/**
* @param {?} node
* @param {?} message
* @return {?}
*/
XliffParser.prototype._addError = function (node, message) {
this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
};
return XliffParser;
}());
var XmlToI18n = (function () {
function XmlToI18n() {
}
/**
* @param {?} message
* @param {?} url
* @return {?}
*/
XmlToI18n.prototype.convert = function (message, url) {
var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
this._errors = xmlIcu.errors;
var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
[] :
visitAll(this, xmlIcu.rootNodes);
return {
i18nNodes: i18nNodes,
errors: this._errors,
};
};
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
XmlToI18n.prototype.visitText = function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
/**
* @param {?} el
* @param {?} context
* @return {?}
*/
XmlToI18n.prototype.visitElement = function (el, context) {
if (el.name === _PLACEHOLDER_TAG) {
var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'id'; });
if (nameAttr) {
return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
}
this._addError(el, "<" + _PLACEHOLDER_TAG + "> misses the \"id\" attribute");
}
else {
this._addError(el, "Unexpected tag");
}
return null;
};
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
XmlToI18n.prototype.visitExpansion = function (icu, context) {
var /** @type {?} */ caseMap = {};
visitAll(this, icu.cases).forEach(function (c) {
caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
});
return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
};
/**
* @param {?} icuCase
* @param {?} context
* @return {?}
*/
XmlToI18n.prototype.visitExpansionCase = function (icuCase, context) {
return {
value: icuCase.value,
nodes: visitAll(this, icuCase.expression),
};
};
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
XmlToI18n.prototype.visitComment = function (comment, context) { };
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
XmlToI18n.prototype.visitAttribute = function (attribute, context) { };
/**
* @param {?} node
* @param {?} message
* @return {?}
*/
XmlToI18n.prototype._addError = function (node, message) {
this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
};
return XmlToI18n;
}());
/**
* @param {?} tag
* @return {?}
*/
function getCtypeForTag(tag) {
switch (tag.toLowerCase()) {
case 'br':
return 'lb';
case 'img':
return 'image';
default:
return "x-" + tag;
}
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _VERSION$1 = '2.0';
var _XMLNS$1 = 'urn:oasis:names:tc:xliff:document:2.0';
// TODO(vicb): make this a param (s/_/-/)
var _DEFAULT_SOURCE_LANG$1 = 'en';
var _PLACEHOLDER_TAG$1 = 'ph';
var _PLACEHOLDER_SPANNING_TAG = 'pc';
var _XLIFF_TAG = 'xliff';
var _SOURCE_TAG$1 = 'source';
var _TARGET_TAG$1 = 'target';
var _UNIT_TAG$1 = 'unit';
var Xliff2 = (function (_super) {
__extends(Xliff2, _super);
function Xliff2() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} messages
* @param {?} locale
* @return {?}
*/
Xliff2.prototype.write = function (messages, locale) {
var /** @type {?} */ visitor = new _WriteVisitor$1();
var /** @type {?} */ units = [];
messages.forEach(function (message) {
var /** @type {?} */ unit = new Tag(_UNIT_TAG$1, { id: message.id });
if (message.description || message.meaning) {
var /** @type {?} */ notes = new Tag('notes');
if (message.description) {
notes.children.push(new CR(8), new Tag('note', { category: 'description' }, [new Text$2(message.description)]));
}
if (message.meaning) {
notes.children.push(new CR(8), new Tag('note', { category: 'meaning' }, [new Text$2(message.meaning)]));
}
notes.children.push(new CR(6));
unit.children.push(new CR(6), notes);
}
var /** @type {?} */ segment = new Tag('segment');
segment.children.push(new CR(8), new Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), new CR(6));
unit.children.push(new CR(6), segment, new CR(4));
units.push(new CR(4), unit);
});
var /** @type {?} */ file = new Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, units.concat([new CR(2)]));
var /** @type {?} */ xliff = new Tag(_XLIFF_TAG, { version: _VERSION$1, xmlns: _XMLNS$1, srcLang: locale || _DEFAULT_SOURCE_LANG$1 }, [new CR(2), file, new CR()]);
return serialize([
new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
]);
};
/**
* @param {?} content
* @param {?} url
* @return {?}
*/
Xliff2.prototype.load = function (content, url) {
// xliff to xml nodes
var /** @type {?} */ xliff2Parser = new Xliff2Parser();
var _a = xliff2Parser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
// xml nodes to i18n nodes
var /** @type {?} */ i18nNodesByMsgId = {};
var /** @type {?} */ converter = new XmlToI18n$1();
Object.keys(msgIdToHtml).forEach(function (msgId) {
var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
errors.push.apply(errors, e);
i18nNodesByMsgId[msgId] = i18nNodes;
});
if (errors.length) {
throw new Error("xliff2 parse errors:\n" + errors.join('\n'));
}
return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
};
/**
* @param {?} message
* @return {?}
*/
Xliff2.prototype.digest = function (message) { return decimalDigest(message); };
return Xliff2;
}(Serializer));
var _WriteVisitor$1 = (function () {
function _WriteVisitor$1() {
}
/**
* @param {?} text
* @param {?=} context
* @return {?}
*/
_WriteVisitor$1.prototype.visitText = function (text, context) { return [new Text$2(text.value)]; };
/**
* @param {?} container
* @param {?=} context
* @return {?}
*/
_WriteVisitor$1.prototype.visitContainer = function (container, context) {
var _this = this;
var /** @type {?} */ nodes = [];
container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
return nodes;
};
/**
* @param {?} icu
* @param {?=} context
* @return {?}
*/
_WriteVisitor$1.prototype.visitIcu = function (icu, context) {
var _this = this;
var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
Object.keys(icu.cases).forEach(function (c) {
nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
});
nodes.push(new Text$2("}"));
return nodes;
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_WriteVisitor$1.prototype.visitTagPlaceholder = function (ph, context) {
var _this = this;
var /** @type {?} */ type = getTypeForTag(ph.tag);
if (ph.isVoid) {
var /** @type {?} */ tagPh = new Tag(_PLACEHOLDER_TAG$1, {
id: (this._nextPlaceholderId++).toString(),
equiv: ph.startName,
type: type,
disp: "<" + ph.tag + "/>",
});
return [tagPh];
}
var /** @type {?} */ tagPc = new Tag(_PLACEHOLDER_SPANNING_TAG, {
id: (this._nextPlaceholderId++).toString(),
equivStart: ph.startName,
equivEnd: ph.closeName,
type: type,
dispStart: "<" + ph.tag + ">",
dispEnd: "" + ph.tag + ">",
});
var /** @type {?} */ nodes = [].concat.apply([], ph.children.map(function (node) { return node.visit(_this); }));
if (nodes.length) {
nodes.forEach(function (node) { return tagPc.children.push(node); });
}
else {
tagPc.children.push(new Text$2(''));
}
return [tagPc];
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_WriteVisitor$1.prototype.visitPlaceholder = function (ph, context) {
return [new Tag(_PLACEHOLDER_TAG$1, {
id: (this._nextPlaceholderId++).toString(),
equiv: ph.name,
disp: "{{" + ph.value + "}}",
})];
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_WriteVisitor$1.prototype.visitIcuPlaceholder = function (ph, context) {
return [new Tag(_PLACEHOLDER_TAG$1, { id: (this._nextPlaceholderId++).toString() })];
};
/**
* @param {?} nodes
* @return {?}
*/
_WriteVisitor$1.prototype.serialize = function (nodes) {
var _this = this;
this._nextPlaceholderId = 0;
return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
};
return _WriteVisitor$1;
}());
var Xliff2Parser = (function () {
function Xliff2Parser() {
this._locale = null;
}
/**
* @param {?} xliff
* @param {?} url
* @return {?}
*/
Xliff2Parser.prototype.parse = function (xliff, url) {
this._unitMlString = null;
this._msgIdToHtml = {};
var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
this._errors = xml.errors;
visitAll(this, xml.rootNodes, null);
return {
msgIdToHtml: this._msgIdToHtml,
errors: this._errors,
locale: this._locale,
};
};
/**
* @param {?} element
* @param {?} context
* @return {?}
*/
Xliff2Parser.prototype.visitElement = function (element, context) {
switch (element.name) {
case _UNIT_TAG$1:
this._unitMlString = null;
var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
if (!idAttr) {
this._addError(element, "<" + _UNIT_TAG$1 + "> misses the \"id\" attribute");
}
else {
var /** @type {?} */ id = idAttr.value;
if (this._msgIdToHtml.hasOwnProperty(id)) {
this._addError(element, "Duplicated translations for msg " + id);
}
else {
visitAll(this, element.children, null);
if (typeof this._unitMlString === 'string') {
this._msgIdToHtml[id] = this._unitMlString;
}
else {
this._addError(element, "Message " + id + " misses a translation");
}
}
}
break;
case _SOURCE_TAG$1:
// ignore source message
break;
case _TARGET_TAG$1:
var /** @type {?} */ innerTextStart = ((element.startSourceSpan)).end.offset;
var /** @type {?} */ innerTextEnd = ((element.endSourceSpan)).start.offset;
var /** @type {?} */ content = ((element.startSourceSpan)).start.file.content;
var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
this._unitMlString = innerText;
break;
case _XLIFF_TAG:
var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'trgLang'; });
if (localeAttr) {
this._locale = localeAttr.value;
}
var /** @type {?} */ versionAttr = element.attrs.find(function (attr) { return attr.name === 'version'; });
if (versionAttr) {
var /** @type {?} */ version = versionAttr.value;
if (version !== '2.0') {
this._addError(element, "The XLIFF file version " + version + " is not compatible with XLIFF 2.0 serializer");
}
else {
visitAll(this, element.children, null);
}
}
break;
default:
visitAll(this, element.children, null);
}
};
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
Xliff2Parser.prototype.visitAttribute = function (attribute, context) { };
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
Xliff2Parser.prototype.visitText = function (text, context) { };
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
Xliff2Parser.prototype.visitComment = function (comment, context) { };
/**
* @param {?} expansion
* @param {?} context
* @return {?}
*/
Xliff2Parser.prototype.visitExpansion = function (expansion, context) { };
/**
* @param {?} expansionCase
* @param {?} context
* @return {?}
*/
Xliff2Parser.prototype.visitExpansionCase = function (expansionCase, context) { };
/**
* @param {?} node
* @param {?} message
* @return {?}
*/
Xliff2Parser.prototype._addError = function (node, message) {
this._errors.push(new I18nError(node.sourceSpan, message));
};
return Xliff2Parser;
}());
var XmlToI18n$1 = (function () {
function XmlToI18n$1() {
}
/**
* @param {?} message
* @param {?} url
* @return {?}
*/
XmlToI18n$1.prototype.convert = function (message, url) {
var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
this._errors = xmlIcu.errors;
var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
[] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes));
return {
i18nNodes: i18nNodes,
errors: this._errors,
};
};
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
XmlToI18n$1.prototype.visitText = function (text, context) { return new Text$1(text.value, text.sourceSpan); };
/**
* @param {?} el
* @param {?} context
* @return {?}
*/
XmlToI18n$1.prototype.visitElement = function (el, context) {
var _this = this;
switch (el.name) {
case _PLACEHOLDER_TAG$1:
var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'equiv'; });
if (nameAttr) {
return [new Placeholder('', nameAttr.value, el.sourceSpan)];
}
this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equiv\" attribute");
break;
case _PLACEHOLDER_SPANNING_TAG:
var /** @type {?} */ startAttr = el.attrs.find(function (attr) { return attr.name === 'equivStart'; });
var /** @type {?} */ endAttr = el.attrs.find(function (attr) { return attr.name === 'equivEnd'; });
if (!startAttr) {
this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivStart\" attribute");
}
else if (!endAttr) {
this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivEnd\" attribute");
}
else {
var /** @type {?} */ startId = startAttr.value;
var /** @type {?} */ endId = endAttr.value;
var /** @type {?} */ nodes = [];
return nodes.concat.apply(nodes, [new Placeholder('', startId, el.sourceSpan)].concat(el.children.map(function (node) { return node.visit(_this, null); }), [new Placeholder('', endId, el.sourceSpan)]));
}
break;
default:
this._addError(el, "Unexpected tag");
}
return null;
};
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
XmlToI18n$1.prototype.visitExpansion = function (icu, context) {
var /** @type {?} */ caseMap = {};
visitAll(this, icu.cases).forEach(function (c) {
caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
});
return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
};
/**
* @param {?} icuCase
* @param {?} context
* @return {?}
*/
XmlToI18n$1.prototype.visitExpansionCase = function (icuCase, context) {
return {
value: icuCase.value,
nodes: [].concat.apply([], visitAll(this, icuCase.expression)),
};
};
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
XmlToI18n$1.prototype.visitComment = function (comment, context) { };
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
XmlToI18n$1.prototype.visitAttribute = function (attribute, context) { };
/**
* @param {?} node
* @param {?} message
* @return {?}
*/
XmlToI18n$1.prototype._addError = function (node, message) {
this._errors.push(new I18nError(node.sourceSpan, message));
};
return XmlToI18n$1;
}());
/**
* @param {?} tag
* @return {?}
*/
function getTypeForTag(tag) {
switch (tag.toLowerCase()) {
case 'br':
case 'b':
case 'i':
case 'u':
return 'fmt';
case 'img':
return 'image';
case 'a':
return 'link';
default:
return 'other';
}
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _MESSAGES_TAG = 'messagebundle';
var _MESSAGE_TAG = 'msg';
var _PLACEHOLDER_TAG$2 = 'ph';
var _EXEMPLE_TAG = 'ex';
var _SOURCE_TAG$2 = 'source';
var _DOCTYPE = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
var Xmb = (function (_super) {
__extends(Xmb, _super);
function Xmb() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} messages
* @param {?} locale
* @return {?}
*/
Xmb.prototype.write = function (messages, locale) {
var /** @type {?} */ exampleVisitor = new ExampleVisitor();
var /** @type {?} */ visitor = new _Visitor$2();
var /** @type {?} */ rootNode = new Tag(_MESSAGES_TAG);
messages.forEach(function (message) {
var /** @type {?} */ attrs = { id: message.id };
if (message.description) {
attrs['desc'] = message.description;
}
if (message.meaning) {
attrs['meaning'] = message.meaning;
}
var /** @type {?} */ sourceTags = [];
message.sources.forEach(function (source) {
sourceTags.push(new Tag(_SOURCE_TAG$2, {}, [
new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : ''))
]));
});
rootNode.children.push(new CR(2), new Tag(_MESSAGE_TAG, attrs, sourceTags.concat(visitor.serialize(message.nodes))));
});
rootNode.children.push(new CR());
return serialize([
new Declaration({ version: '1.0', encoding: 'UTF-8' }),
new CR(),
new Doctype(_MESSAGES_TAG, _DOCTYPE),
new CR(),
exampleVisitor.addDefaultExamples(rootNode),
new CR(),
]);
};
/**
* @param {?} content
* @param {?} url
* @return {?}
*/
Xmb.prototype.load = function (content, url) {
throw new Error('Unsupported');
};
/**
* @param {?} message
* @return {?}
*/
Xmb.prototype.digest = function (message) { return digest$1(message); };
/**
* @param {?} message
* @return {?}
*/
Xmb.prototype.createNameMapper = function (message) {
return new SimplePlaceholderMapper(message, toPublicName);
};
return Xmb;
}(Serializer));
var _Visitor$2 = (function () {
function _Visitor$2() {
}
/**
* @param {?} text
* @param {?=} context
* @return {?}
*/
_Visitor$2.prototype.visitText = function (text, context) { return [new Text$2(text.value)]; };
/**
* @param {?} container
* @param {?} context
* @return {?}
*/
_Visitor$2.prototype.visitContainer = function (container, context) {
var _this = this;
var /** @type {?} */ nodes = [];
container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
return nodes;
};
/**
* @param {?} icu
* @param {?=} context
* @return {?}
*/
_Visitor$2.prototype.visitIcu = function (icu, context) {
var _this = this;
var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
Object.keys(icu.cases).forEach(function (c) {
nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
});
nodes.push(new Text$2("}"));
return nodes;
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_Visitor$2.prototype.visitTagPlaceholder = function (ph, context) {
var /** @type {?} */ startEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("<" + ph.tag + ">")]);
var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.startName }, [startEx]);
if (ph.isVoid) {
// void tags have no children nor closing tags
return [startTagPh];
}
var /** @type {?} */ closeEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("" + ph.tag + ">")]);
var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.closeName }, [closeEx]);
return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_Visitor$2.prototype.visitPlaceholder = function (ph, context) {
return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name })];
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
_Visitor$2.prototype.visitIcuPlaceholder = function (ph, context) {
return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name })];
};
/**
* @param {?} nodes
* @return {?}
*/
_Visitor$2.prototype.serialize = function (nodes) {
var _this = this;
return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
};
return _Visitor$2;
}());
/**
* @param {?} message
* @return {?}
*/
function digest$1(message) {
return decimalDigest(message);
}
var ExampleVisitor = (function () {
function ExampleVisitor() {
}
/**
* @param {?} node
* @return {?}
*/
ExampleVisitor.prototype.addDefaultExamples = function (node) {
node.visit(this);
return node;
};
/**
* @param {?} tag
* @return {?}
*/
ExampleVisitor.prototype.visitTag = function (tag) {
var _this = this;
if (tag.name === _PLACEHOLDER_TAG$2) {
if (!tag.children || tag.children.length == 0) {
var /** @type {?} */ exText = new Text$2(tag.attrs['name'] || '...');
tag.children = [new Tag(_EXEMPLE_TAG, {}, [exText])];
}
}
else if (tag.children) {
tag.children.forEach(function (node) { return node.visit(_this); });
}
};
/**
* @param {?} text
* @return {?}
*/
ExampleVisitor.prototype.visitText = function (text) { };
/**
* @param {?} decl
* @return {?}
*/
ExampleVisitor.prototype.visitDeclaration = function (decl) { };
/**
* @param {?} doctype
* @return {?}
*/
ExampleVisitor.prototype.visitDoctype = function (doctype) { };
return ExampleVisitor;
}());
/**
* @param {?} internalName
* @return {?}
*/
function toPublicName(internalName) {
return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var _TRANSLATIONS_TAG = 'translationbundle';
var _TRANSLATION_TAG = 'translation';
var _PLACEHOLDER_TAG$3 = 'ph';
var Xtb = (function (_super) {
__extends(Xtb, _super);
function Xtb() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} messages
* @param {?} locale
* @return {?}
*/
Xtb.prototype.write = function (messages, locale) { throw new Error('Unsupported'); };
/**
* @param {?} content
* @param {?} url
* @return {?}
*/
Xtb.prototype.load = function (content, url) {
// xtb to xml nodes
var /** @type {?} */ xtbParser = new XtbParser();
var _a = xtbParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
// xml nodes to i18n nodes
var /** @type {?} */ i18nNodesByMsgId = {};
var /** @type {?} */ converter = new XmlToI18n$2();
// Because we should be able to load xtb files that rely on features not supported by angular,
// we need to delay the conversion of html to i18n nodes so that non angular messages are not
// converted
Object.keys(msgIdToHtml).forEach(function (msgId) {
var /** @type {?} */ valueFn = function () {
var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, errors = _a.errors;
if (errors.length) {
throw new Error("xtb parse errors:\n" + errors.join('\n'));
}
return i18nNodes;
};
createLazyProperty(i18nNodesByMsgId, msgId, valueFn);
});
if (errors.length) {
throw new Error("xtb parse errors:\n" + errors.join('\n'));
}
return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
};
/**
* @param {?} message
* @return {?}
*/
Xtb.prototype.digest = function (message) { return digest$1(message); };
/**
* @param {?} message
* @return {?}
*/
Xtb.prototype.createNameMapper = function (message) {
return new SimplePlaceholderMapper(message, toPublicName);
};
return Xtb;
}(Serializer));
/**
* @param {?} messages
* @param {?} id
* @param {?} valueFn
* @return {?}
*/
function createLazyProperty(messages, id, valueFn) {
Object.defineProperty(messages, id, {
configurable: true,
enumerable: true,
get: function () {
var /** @type {?} */ value = valueFn();
Object.defineProperty(messages, id, { enumerable: true, value: value });
return value;
},
set: function (_) { throw new Error('Could not overwrite an XTB translation'); },
});
}
var XtbParser = (function () {
function XtbParser() {
this._locale = null;
}
/**
* @param {?} xtb
* @param {?} url
* @return {?}
*/
XtbParser.prototype.parse = function (xtb, url) {
this._bundleDepth = 0;
this._msgIdToHtml = {};
// We can not parse the ICU messages at this point as some messages might not originate
// from Angular that could not be lex'd.
var /** @type {?} */ xml = new XmlParser().parse(xtb, url, false);
this._errors = xml.errors;
visitAll(this, xml.rootNodes);
return {
msgIdToHtml: this._msgIdToHtml,
errors: this._errors,
locale: this._locale,
};
};
/**
* @param {?} element
* @param {?} context
* @return {?}
*/
XtbParser.prototype.visitElement = function (element, context) {
switch (element.name) {
case _TRANSLATIONS_TAG:
this._bundleDepth++;
if (this._bundleDepth > 1) {
this._addError(element, "<" + _TRANSLATIONS_TAG + "> elements can not be nested");
}
var /** @type {?} */ langAttr = element.attrs.find(function (attr) { return attr.name === 'lang'; });
if (langAttr) {
this._locale = langAttr.value;
}
visitAll(this, element.children, null);
this._bundleDepth--;
break;
case _TRANSLATION_TAG:
var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
if (!idAttr) {
this._addError(element, "<" + _TRANSLATION_TAG + "> misses the \"id\" attribute");
}
else {
var /** @type {?} */ id = idAttr.value;
if (this._msgIdToHtml.hasOwnProperty(id)) {
this._addError(element, "Duplicated translations for msg " + id);
}
else {
var /** @type {?} */ innerTextStart = ((element.startSourceSpan)).end.offset;
var /** @type {?} */ innerTextEnd = ((element.endSourceSpan)).start.offset;
var /** @type {?} */ content = ((element.startSourceSpan)).start.file.content;
var /** @type {?} */ innerText = content.slice(/** @type {?} */ ((innerTextStart)), /** @type {?} */ ((innerTextEnd)));
this._msgIdToHtml[id] = innerText;
}
}
break;
default:
this._addError(element, 'Unexpected tag');
}
};
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
XtbParser.prototype.visitAttribute = function (attribute, context) { };
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
XtbParser.prototype.visitText = function (text, context) { };
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
XtbParser.prototype.visitComment = function (comment, context) { };
/**
* @param {?} expansion
* @param {?} context
* @return {?}
*/
XtbParser.prototype.visitExpansion = function (expansion, context) { };
/**
* @param {?} expansionCase
* @param {?} context
* @return {?}
*/
XtbParser.prototype.visitExpansionCase = function (expansionCase, context) { };
/**
* @param {?} node
* @param {?} message
* @return {?}
*/
XtbParser.prototype._addError = function (node, message) {
this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
};
return XtbParser;
}());
var XmlToI18n$2 = (function () {
function XmlToI18n$2() {
}
/**
* @param {?} message
* @param {?} url
* @return {?}
*/
XmlToI18n$2.prototype.convert = function (message, url) {
var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
this._errors = xmlIcu.errors;
var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
[] :
visitAll(this, xmlIcu.rootNodes);
return {
i18nNodes: i18nNodes,
errors: this._errors,
};
};
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
XmlToI18n$2.prototype.visitText = function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
XmlToI18n$2.prototype.visitExpansion = function (icu, context) {
var /** @type {?} */ caseMap = {};
visitAll(this, icu.cases).forEach(function (c) {
caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
});
return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
};
/**
* @param {?} icuCase
* @param {?} context
* @return {?}
*/
XmlToI18n$2.prototype.visitExpansionCase = function (icuCase, context) {
return {
value: icuCase.value,
nodes: visitAll(this, icuCase.expression),
};
};
/**
* @param {?} el
* @param {?} context
* @return {?}
*/
XmlToI18n$2.prototype.visitElement = function (el, context) {
if (el.name === _PLACEHOLDER_TAG$3) {
var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'name'; });
if (nameAttr) {
return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
}
this._addError(el, "<" + _PLACEHOLDER_TAG$3 + "> misses the \"name\" attribute");
}
else {
this._addError(el, "Unexpected tag");
}
return null;
};
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
XmlToI18n$2.prototype.visitComment = function (comment, context) { };
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
XmlToI18n$2.prototype.visitAttribute = function (attribute, context) { };
/**
* @param {?} node
* @param {?} message
* @return {?}
*/
XmlToI18n$2.prototype._addError = function (node, message) {
this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
};
return XmlToI18n$2;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var HtmlParser = (function (_super) {
__extends(HtmlParser, _super);
function HtmlParser() {
return _super.call(this, getHtmlTagDefinition) || this;
}
/**
* @param {?} source
* @param {?} url
* @param {?=} parseExpansionForms
* @param {?=} interpolationConfig
* @return {?}
*/
HtmlParser.prototype.parse = function (source, url, parseExpansionForms, interpolationConfig) {
if (parseExpansionForms === void 0) { parseExpansionForms = false; }
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
return _super.prototype.parse.call(this, source, url, parseExpansionForms, interpolationConfig);
};
return HtmlParser;
}(Parser$1));
HtmlParser.decorators = [
{ type: CompilerInjectable },
];
/**
* @nocollapse
*/
HtmlParser.ctorParameters = function () { return []; };
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A container for translated messages
*/
var TranslationBundle = (function () {
/**
* @param {?=} _i18nNodesByMsgId
* @param {?=} locale
* @param {?=} digest
* @param {?=} mapperFactory
* @param {?=} missingTranslationStrategy
* @param {?=} console
*/
function TranslationBundle(_i18nNodesByMsgId, locale, digest, mapperFactory, missingTranslationStrategy, console) {
if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
if (missingTranslationStrategy === void 0) { missingTranslationStrategy = __WEBPACK_IMPORTED_MODULE_0__angular_core__["_24" /* MissingTranslationStrategy */].Warning; }
this._i18nNodesByMsgId = _i18nNodesByMsgId;
this.digest = digest;
this.mapperFactory = mapperFactory;
this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, locale, digest, mapperFactory, missingTranslationStrategy, console);
}
/**
* @param {?} content
* @param {?} url
* @param {?} serializer
* @param {?} missingTranslationStrategy
* @param {?=} console
* @return {?}
*/
TranslationBundle.load = function (content, url, serializer, missingTranslationStrategy, console) {
var _a = serializer.load(content, url), locale = _a.locale, i18nNodesByMsgId = _a.i18nNodesByMsgId;
var /** @type {?} */ digestFn = function (m) { return serializer.digest(m); };
var /** @type {?} */ mapperFactory = function (m) { return ((serializer.createNameMapper(m))); };
return new TranslationBundle(i18nNodesByMsgId, locale, digestFn, mapperFactory, missingTranslationStrategy, console);
};
/**
* @param {?} srcMsg
* @return {?}
*/
TranslationBundle.prototype.get = function (srcMsg) {
var /** @type {?} */ html = this._i18nToHtml.convert(srcMsg);
if (html.errors.length) {
throw new Error(html.errors.join('\n'));
}
return html.nodes;
};
/**
* @param {?} srcMsg
* @return {?}
*/
TranslationBundle.prototype.has = function (srcMsg) { return this.digest(srcMsg) in this._i18nNodesByMsgId; };
return TranslationBundle;
}());
var I18nToHtmlVisitor = (function () {
/**
* @param {?=} _i18nNodesByMsgId
* @param {?=} _locale
* @param {?=} _digest
* @param {?=} _mapperFactory
* @param {?=} _missingTranslationStrategy
* @param {?=} _console
*/
function I18nToHtmlVisitor(_i18nNodesByMsgId, _locale, _digest, _mapperFactory, _missingTranslationStrategy, _console) {
if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
this._i18nNodesByMsgId = _i18nNodesByMsgId;
this._locale = _locale;
this._digest = _digest;
this._mapperFactory = _mapperFactory;
this._missingTranslationStrategy = _missingTranslationStrategy;
this._console = _console;
this._contextStack = [];
this._errors = [];
}
/**
* @param {?} srcMsg
* @return {?}
*/
I18nToHtmlVisitor.prototype.convert = function (srcMsg) {
this._contextStack.length = 0;
this._errors.length = 0;
// i18n to text
var /** @type {?} */ text = this._convertToText(srcMsg);
// text to html
var /** @type {?} */ url = srcMsg.nodes[0].sourceSpan.start.file.url;
var /** @type {?} */ html = new HtmlParser().parse(text, url, true);
return {
nodes: html.rootNodes,
errors: this._errors.concat(html.errors),
};
};
/**
* @param {?} text
* @param {?=} context
* @return {?}
*/
I18nToHtmlVisitor.prototype.visitText = function (text, context) { return text.value; };
/**
* @param {?} container
* @param {?=} context
* @return {?}
*/
I18nToHtmlVisitor.prototype.visitContainer = function (container, context) {
var _this = this;
return container.children.map(function (n) { return n.visit(_this); }).join('');
};
/**
* @param {?} icu
* @param {?=} context
* @return {?}
*/
I18nToHtmlVisitor.prototype.visitIcu = function (icu, context) {
var _this = this;
var /** @type {?} */ cases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
// TODO(vicb): Once all format switch to using expression placeholders
// we should throw when the placeholder is not in the source message
var /** @type {?} */ exp = this._srcMsg.placeholders.hasOwnProperty(icu.expression) ?
this._srcMsg.placeholders[icu.expression] :
icu.expression;
return "{" + exp + ", " + icu.type + ", " + cases.join(' ') + "}";
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
I18nToHtmlVisitor.prototype.visitPlaceholder = function (ph, context) {
var /** @type {?} */ phName = this._mapper(ph.name);
if (this._srcMsg.placeholders.hasOwnProperty(phName)) {
return this._srcMsg.placeholders[phName];
}
if (this._srcMsg.placeholderToMessage.hasOwnProperty(phName)) {
return this._convertToText(this._srcMsg.placeholderToMessage[phName]);
}
this._addError(ph, "Unknown placeholder \"" + ph.name + "\"");
return '';
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
I18nToHtmlVisitor.prototype.visitTagPlaceholder = function (ph, context) {
var _this = this;
var /** @type {?} */ tag = "" + ph.tag;
var /** @type {?} */ attrs = Object.keys(ph.attrs).map(function (name) { return name + "=\"" + ph.attrs[name] + "\""; }).join(' ');
if (ph.isVoid) {
return "<" + tag + " " + attrs + "/>";
}
var /** @type {?} */ children = ph.children.map(function (c) { return c.visit(_this); }).join('');
return "<" + tag + " " + attrs + ">" + children + "" + tag + ">";
};
/**
* @param {?} ph
* @param {?=} context
* @return {?}
*/
I18nToHtmlVisitor.prototype.visitIcuPlaceholder = function (ph, context) {
// An ICU placeholder references the source message to be serialized
return this._convertToText(this._srcMsg.placeholderToMessage[ph.name]);
};
/**
* Convert a source message to a translated text string:
* - text nodes are replaced with their translation,
* - placeholders are replaced with their content,
* - ICU nodes are converted to ICU expressions.
* @param {?} srcMsg
* @return {?}
*/
I18nToHtmlVisitor.prototype._convertToText = function (srcMsg) {
var _this = this;
var /** @type {?} */ id = this._digest(srcMsg);
var /** @type {?} */ mapper = this._mapperFactory ? this._mapperFactory(srcMsg) : null;
var /** @type {?} */ nodes;
this._contextStack.push({ msg: this._srcMsg, mapper: this._mapper });
this._srcMsg = srcMsg;
if (this._i18nNodesByMsgId.hasOwnProperty(id)) {
// When there is a translation use its nodes as the source
// And create a mapper to convert serialized placeholder names to internal names
nodes = this._i18nNodesByMsgId[id];
this._mapper = function (name) { return mapper ? ((mapper.toInternalName(name))) : name; };
}
else {
// When no translation has been found
// - report an error / a warning / nothing,
// - use the nodes from the original message
// - placeholders are already internal and need no mapper
if (this._missingTranslationStrategy === __WEBPACK_IMPORTED_MODULE_0__angular_core__["_24" /* MissingTranslationStrategy */].Error) {
var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
this._addError(srcMsg.nodes[0], "Missing translation for message \"" + id + "\"" + ctx);
}
else if (this._console &&
this._missingTranslationStrategy === __WEBPACK_IMPORTED_MODULE_0__angular_core__["_24" /* MissingTranslationStrategy */].Warning) {
var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
this._console.warn("Missing translation for message \"" + id + "\"" + ctx);
}
nodes = srcMsg.nodes;
this._mapper = function (name) { return name; };
}
var /** @type {?} */ text = nodes.map(function (node) { return node.visit(_this); }).join('');
var /** @type {?} */ context = ((this._contextStack.pop()));
this._srcMsg = context.msg;
this._mapper = context.mapper;
return text;
};
/**
* @param {?} el
* @param {?} msg
* @return {?}
*/
I18nToHtmlVisitor.prototype._addError = function (el, msg) {
this._errors.push(new I18nError(el.sourceSpan, msg));
};
return I18nToHtmlVisitor;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var I18NHtmlParser = (function () {
/**
* @param {?} _htmlParser
* @param {?=} translations
* @param {?=} translationsFormat
* @param {?=} missingTranslation
* @param {?=} console
*/
function I18NHtmlParser(_htmlParser, translations, translationsFormat, missingTranslation, console) {
if (missingTranslation === void 0) { missingTranslation = __WEBPACK_IMPORTED_MODULE_0__angular_core__["_24" /* MissingTranslationStrategy */].Warning; }
this._htmlParser = _htmlParser;
if (translations) {
var serializer = createSerializer(translationsFormat);
this._translationBundle =
TranslationBundle.load(translations, 'i18n', serializer, missingTranslation, console);
}
}
/**
* @param {?} source
* @param {?} url
* @param {?=} parseExpansionForms
* @param {?=} interpolationConfig
* @return {?}
*/
I18NHtmlParser.prototype.parse = function (source, url, parseExpansionForms, interpolationConfig) {
if (parseExpansionForms === void 0) { parseExpansionForms = false; }
if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
var /** @type {?} */ parseResult = this._htmlParser.parse(source, url, parseExpansionForms, interpolationConfig);
if (!this._translationBundle) {
// Do not enable i18n when no translation bundle is provided
return parseResult;
}
if (parseResult.errors.length) {
return new ParseTreeResult(parseResult.rootNodes, parseResult.errors);
}
return mergeTranslations(parseResult.rootNodes, this._translationBundle, interpolationConfig, [], {});
};
return I18NHtmlParser;
}());
/**
* @param {?=} format
* @return {?}
*/
function createSerializer(format) {
format = (format || 'xlf').toLowerCase();
switch (format) {
case 'xmb':
return new Xmb();
case 'xtb':
return new Xtb();
case 'xliff2':
case 'xlf2':
return new Xliff2();
case 'xliff':
case 'xlf':
default:
return new Xliff();
}
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var CORE = assetUrl('core');
var Identifiers = (function () {
function Identifiers() {
}
return Identifiers;
}());
Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS = {
name: 'ANALYZE_FOR_ENTRY_COMPONENTS',
moduleUrl: CORE,
runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_20" /* ANALYZE_FOR_ENTRY_COMPONENTS */]
};
Identifiers.ElementRef = { name: 'ElementRef', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["O" /* ElementRef */] };
Identifiers.NgModuleRef = { name: 'NgModuleRef', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["R" /* NgModuleRef */] };
Identifiers.ViewContainerRef = { name: 'ViewContainerRef', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["T" /* ViewContainerRef */] };
Identifiers.ChangeDetectorRef = { name: 'ChangeDetectorRef', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_1" /* ChangeDetectorRef */] };
Identifiers.QueryList = { name: 'QueryList', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_10" /* QueryList */] };
Identifiers.TemplateRef = { name: 'TemplateRef', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* TemplateRef */] };
Identifiers.CodegenComponentFactoryResolver = {
name: 'ɵCodegenComponentFactoryResolver',
moduleUrl: CORE,
runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_25" /* ɵCodegenComponentFactoryResolver */]
};
Identifiers.ComponentFactoryResolver = {
name: 'ComponentFactoryResolver',
moduleUrl: CORE,
runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["S" /* ComponentFactoryResolver */]
};
Identifiers.ComponentFactory = { name: 'ComponentFactory', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_26" /* ComponentFactory */] };
Identifiers.ComponentRef = { name: 'ComponentRef', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_27" /* ComponentRef */] };
Identifiers.NgModuleFactory = { name: 'NgModuleFactory', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_13" /* NgModuleFactory */] };
Identifiers.NgModuleInjector = {
name: 'ɵNgModuleInjector',
moduleUrl: CORE,
runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_28" /* ɵNgModuleInjector */],
};
Identifiers.RegisterModuleFactoryFn = {
name: 'ɵregisterModuleFactory',
moduleUrl: CORE,
runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_29" /* ɵregisterModuleFactory */],
};
Identifiers.Injector = { name: 'Injector', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["l" /* Injector */] };
Identifiers.ViewEncapsulation = { name: 'ViewEncapsulation', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["s" /* ViewEncapsulation */] };
Identifiers.ChangeDetectionStrategy = {
name: 'ChangeDetectionStrategy',
moduleUrl: CORE,
runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_6" /* ChangeDetectionStrategy */]
};
Identifiers.SecurityContext = {
name: 'SecurityContext',
moduleUrl: CORE,
runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["v" /* SecurityContext */],
};
Identifiers.LOCALE_ID = { name: 'LOCALE_ID', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["I" /* LOCALE_ID */] };
Identifiers.TRANSLATIONS_FORMAT = { name: 'TRANSLATIONS_FORMAT', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_30" /* TRANSLATIONS_FORMAT */] };
Identifiers.inlineInterpolate = { name: 'ɵinlineInterpolate', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_31" /* ɵinlineInterpolate */] };
Identifiers.interpolate = { name: 'ɵinterpolate', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_32" /* ɵinterpolate */] };
Identifiers.EMPTY_ARRAY = { name: 'ɵEMPTY_ARRAY', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_33" /* ɵEMPTY_ARRAY */] };
Identifiers.EMPTY_MAP = { name: 'ɵEMPTY_MAP', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_34" /* ɵEMPTY_MAP */] };
Identifiers.Renderer = { name: 'Renderer', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["P" /* Renderer */] };
Identifiers.viewDef = { name: 'ɵvid', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_35" /* ɵvid */] };
Identifiers.elementDef = { name: 'ɵeld', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_36" /* ɵeld */] };
Identifiers.anchorDef = { name: 'ɵand', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_37" /* ɵand */] };
Identifiers.textDef = { name: 'ɵted', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_38" /* ɵted */] };
Identifiers.directiveDef = { name: 'ɵdid', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_39" /* ɵdid */] };
Identifiers.providerDef = { name: 'ɵprd', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_40" /* ɵprd */] };
Identifiers.queryDef = { name: 'ɵqud', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_41" /* ɵqud */] };
Identifiers.pureArrayDef = { name: 'ɵpad', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_42" /* ɵpad */] };
Identifiers.pureObjectDef = { name: 'ɵpod', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_43" /* ɵpod */] };
Identifiers.purePipeDef = { name: 'ɵppd', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_44" /* ɵppd */] };
Identifiers.pipeDef = { name: 'ɵpid', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_45" /* ɵpid */] };
Identifiers.nodeValue = { name: 'ɵnov', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_46" /* ɵnov */] };
Identifiers.ngContentDef = { name: 'ɵncd', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_47" /* ɵncd */] };
Identifiers.unwrapValue = { name: 'ɵunv', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_48" /* ɵunv */] };
Identifiers.createRendererType2 = { name: 'ɵcrt', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_49" /* ɵcrt */] };
Identifiers.RendererType2 = {
name: 'RendererType2',
moduleUrl: CORE,
// type only
runtime: null
};
Identifiers.ViewDefinition = {
name: 'ɵViewDefinition',
moduleUrl: CORE,
// type only
runtime: null
};
Identifiers.createComponentFactory = { name: 'ɵccf', moduleUrl: CORE, runtime: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_50" /* ɵccf */] };
/**
* @param {?} pkg
* @param {?=} path
* @param {?=} type
* @return {?}
*/
function assetUrl(pkg, path, type) {
if (path === void 0) { path = null; }
if (type === void 0) { type = 'src'; }
if (path == null) {
return "@angular/" + pkg;
}
else {
return "@angular/" + pkg + "/" + type + "/" + path;
}
}
/**
* @param {?} identifier
* @return {?}
*/
function resolveIdentifier(identifier) {
var /** @type {?} */ name = identifier.name;
return __WEBPACK_IMPORTED_MODULE_0__angular_core__["_23" /* ɵreflector */].resolveIdentifier(name, identifier.moduleUrl, null, identifier.runtime);
}
/**
* @param {?} identifier
* @return {?}
*/
function createIdentifier(identifier) {
return { reference: resolveIdentifier(identifier) };
}
/**
* @param {?} identifier
* @return {?}
*/
function identifierToken(identifier) {
return { identifier: identifier };
}
/**
* @param {?} identifier
* @return {?}
*/
function createIdentifierToken(identifier) {
return identifierToken(createIdentifier(identifier));
}
/**
* @param {?} enumType
* @param {?} name
* @return {?}
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// http://cldr.unicode.org/index/cldr-spec/plural-rules
var PLURAL_CASES = ['zero', 'one', 'two', 'few', 'many', 'other'];
/**
* Expands special forms into elements.
*
* For example,
*
* ```
* { messages.length, plural,
* =0 {zero}
* =1 {one}
* other {more than one}
* }
* ```
*
* will be expanded into
*
* ```
*
* zero
* one
* more than one
*
* ```
* @param {?} nodes
* @return {?}
*/
function expandNodes(nodes) {
var /** @type {?} */ expander = new _Expander();
return new ExpansionResult(visitAll(expander, nodes), expander.isExpanded, expander.errors);
}
var ExpansionResult = (function () {
/**
* @param {?} nodes
* @param {?} expanded
* @param {?} errors
*/
function ExpansionResult(nodes, expanded, errors) {
this.nodes = nodes;
this.expanded = expanded;
this.errors = errors;
}
return ExpansionResult;
}());
var ExpansionError = (function (_super) {
__extends(ExpansionError, _super);
/**
* @param {?} span
* @param {?} errorMsg
*/
function ExpansionError(span, errorMsg) {
return _super.call(this, span, errorMsg) || this;
}
return ExpansionError;
}(ParseError));
/**
* Expand expansion forms (plural, select) to directives
*
* \@internal
*/
var _Expander = (function () {
function _Expander() {
this.isExpanded = false;
this.errors = [];
}
/**
* @param {?} element
* @param {?} context
* @return {?}
*/
_Expander.prototype.visitElement = function (element, context) {
return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
};
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
_Expander.prototype.visitAttribute = function (attribute, context) { return attribute; };
/**
* @param {?} text
* @param {?} context
* @return {?}
*/
_Expander.prototype.visitText = function (text, context) { return text; };
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
_Expander.prototype.visitComment = function (comment, context) { return comment; };
/**
* @param {?} icu
* @param {?} context
* @return {?}
*/
_Expander.prototype.visitExpansion = function (icu, context) {
this.isExpanded = true;
return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) :
_expandDefaultForm(icu, this.errors);
};
/**
* @param {?} icuCase
* @param {?} context
* @return {?}
*/
_Expander.prototype.visitExpansionCase = function (icuCase, context) {
throw new Error('Should not be reached');
};
return _Expander;
}());
/**
* @param {?} ast
* @param {?} errors
* @return {?}
*/
function _expandPluralForm(ast, errors) {
var /** @type {?} */ children = ast.cases.map(function (c) {
if (PLURAL_CASES.indexOf(c.value) == -1 && !c.value.match(/^=\d+$/)) {
errors.push(new ExpansionError(c.valueSourceSpan, "Plural cases should be \"=\" or one of " + PLURAL_CASES.join(", ")));
}
var /** @type {?} */ expansionResult = expandNodes(c.expression);
errors.push.apply(errors, expansionResult.errors);
return new Element("ng-template", [new Attribute$1('ngPluralCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
});
var /** @type {?} */ switchAttr = new Attribute$1('[ngPlural]', ast.switchValue, ast.switchValueSourceSpan);
return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
}
/**
* @param {?} ast
* @param {?} errors
* @return {?}
*/
function _expandDefaultForm(ast, errors) {
var /** @type {?} */ children = ast.cases.map(function (c) {
var /** @type {?} */ expansionResult = expandNodes(c.expression);
errors.push.apply(errors, expansionResult.errors);
if (c.value === 'other') {
// other is the default case when no values match
return new Element("ng-template", [new Attribute$1('ngSwitchDefault', '', c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
}
return new Element("ng-template", [new Attribute$1('ngSwitchCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
});
var /** @type {?} */ switchAttr = new Attribute$1('[ngSwitch]', ast.switchValue, ast.switchValueSourceSpan);
return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ProviderError = (function (_super) {
__extends(ProviderError, _super);
/**
* @param {?} message
* @param {?} span
*/
function ProviderError(message, span) {
return _super.call(this, span, message) || this;
}
return ProviderError;
}(ParseError));
var ProviderViewContext = (function () {
/**
* @param {?} component
*/
function ProviderViewContext(component) {
var _this = this;
this.component = component;
this.errors = [];
this.viewQueries = _getViewQueries(component);
this.viewProviders = new Map();
component.viewProviders.forEach(function (provider) {
if (_this.viewProviders.get(tokenReference(provider.token)) == null) {
_this.viewProviders.set(tokenReference(provider.token), true);
}
});
}
return ProviderViewContext;
}());
var ProviderElementContext = (function () {
/**
* @param {?} viewContext
* @param {?} _parent
* @param {?} _isViewRoot
* @param {?} _directiveAsts
* @param {?} attrs
* @param {?} refs
* @param {?} isTemplate
* @param {?} contentQueryStartId
* @param {?} _sourceSpan
*/
function ProviderElementContext(viewContext, _parent, _isViewRoot, _directiveAsts, attrs, refs, isTemplate, contentQueryStartId, _sourceSpan) {
var _this = this;
this.viewContext = viewContext;
this._parent = _parent;
this._isViewRoot = _isViewRoot;
this._directiveAsts = _directiveAsts;
this._sourceSpan = _sourceSpan;
this._transformedProviders = new Map();
this._seenProviders = new Map();
this._hasViewContainer = false;
this._queriedTokens = new Map();
this._attrs = {};
attrs.forEach(function (attrAst) { return _this._attrs[attrAst.name] = attrAst.value; });
var directivesMeta = _directiveAsts.map(function (directiveAst) { return directiveAst.directive; });
this._allProviders =
_resolveProvidersFromDirectives(directivesMeta, _sourceSpan, viewContext.errors);
this._contentQueries = _getContentQueries(contentQueryStartId, directivesMeta);
Array.from(this._allProviders.values()).forEach(function (provider) {
_this._addQueryReadsTo(provider.token, provider.token, _this._queriedTokens);
});
if (isTemplate) {
var templateRefId = createIdentifierToken(Identifiers.TemplateRef);
this._addQueryReadsTo(templateRefId, templateRefId, this._queriedTokens);
}
refs.forEach(function (refAst) {
var defaultQueryValue = refAst.value || createIdentifierToken(Identifiers.ElementRef);
_this._addQueryReadsTo({ value: refAst.name }, defaultQueryValue, _this._queriedTokens);
});
if (this._queriedTokens.get(resolveIdentifier(Identifiers.ViewContainerRef))) {
this._hasViewContainer = true;
}
// create the providers that we know are eager first
Array.from(this._allProviders.values()).forEach(function (provider) {
var eager = provider.eager || _this._queriedTokens.get(tokenReference(provider.token));
if (eager) {
_this._getOrCreateLocalProvider(provider.providerType, provider.token, true);
}
});
}
/**
* @return {?}
*/
ProviderElementContext.prototype.afterElement = function () {
var _this = this;
// collect lazy providers
Array.from(this._allProviders.values()).forEach(function (provider) {
_this._getOrCreateLocalProvider(provider.providerType, provider.token, false);
});
};
Object.defineProperty(ProviderElementContext.prototype, "transformProviders", {
/**
* @return {?}
*/
get: function () {
return Array.from(this._transformedProviders.values());
},
enumerable: true,
configurable: true
});
Object.defineProperty(ProviderElementContext.prototype, "transformedDirectiveAsts", {
/**
* @return {?}
*/
get: function () {
var /** @type {?} */ sortedProviderTypes = this.transformProviders.map(function (provider) { return provider.token.identifier; });
var /** @type {?} */ sortedDirectives = this._directiveAsts.slice();
sortedDirectives.sort(function (dir1, dir2) { return sortedProviderTypes.indexOf(dir1.directive.type) -
sortedProviderTypes.indexOf(dir2.directive.type); });
return sortedDirectives;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ProviderElementContext.prototype, "transformedHasViewContainer", {
/**
* @return {?}
*/
get: function () { return this._hasViewContainer; },
enumerable: true,
configurable: true
});
Object.defineProperty(ProviderElementContext.prototype, "queryMatches", {
/**
* @return {?}
*/
get: function () {
var /** @type {?} */ allMatches = [];
this._queriedTokens.forEach(function (matches) { allMatches.push.apply(allMatches, matches); });
return allMatches;
},
enumerable: true,
configurable: true
});
/**
* @param {?} token
* @param {?} defaultValue
* @param {?} queryReadTokens
* @return {?}
*/
ProviderElementContext.prototype._addQueryReadsTo = function (token, defaultValue, queryReadTokens) {
this._getQueriesFor(token).forEach(function (query) {
var /** @type {?} */ queryValue = query.meta.read || defaultValue;
var /** @type {?} */ tokenRef = tokenReference(queryValue);
var /** @type {?} */ queryMatches = queryReadTokens.get(tokenRef);
if (!queryMatches) {
queryMatches = [];
queryReadTokens.set(tokenRef, queryMatches);
}
queryMatches.push({ queryId: query.queryId, value: queryValue });
});
};
/**
* @param {?} token
* @return {?}
*/
ProviderElementContext.prototype._getQueriesFor = function (token) {
var /** @type {?} */ result = [];
var /** @type {?} */ currentEl = this;
var /** @type {?} */ distance = 0;
var /** @type {?} */ queries;
while (currentEl !== null) {
queries = currentEl._contentQueries.get(tokenReference(token));
if (queries) {
result.push.apply(result, queries.filter(function (query) { return query.meta.descendants || distance <= 1; }));
}
if (currentEl._directiveAsts.length > 0) {
distance++;
}
currentEl = currentEl._parent;
}
queries = this.viewContext.viewQueries.get(tokenReference(token));
if (queries) {
result.push.apply(result, queries);
}
return result;
};
/**
* @param {?} requestingProviderType
* @param {?} token
* @param {?} eager
* @return {?}
*/
ProviderElementContext.prototype._getOrCreateLocalProvider = function (requestingProviderType, token, eager) {
var _this = this;
var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
if (!resolvedProvider || ((requestingProviderType === ProviderAstType.Directive ||
requestingProviderType === ProviderAstType.PublicService) &&
resolvedProvider.providerType === ProviderAstType.PrivateService) ||
((requestingProviderType === ProviderAstType.PrivateService ||
requestingProviderType === ProviderAstType.PublicService) &&
resolvedProvider.providerType === ProviderAstType.Builtin)) {
return null;
}
var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
if (transformedProviderAst) {
return transformedProviderAst;
}
if (this._seenProviders.get(tokenReference(token)) != null) {
this.viewContext.errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), this._sourceSpan));
return null;
}
this._seenProviders.set(tokenReference(token), true);
var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
var /** @type {?} */ transformedUseValue = provider.useValue;
var /** @type {?} */ transformedUseExisting = ((provider.useExisting));
var /** @type {?} */ transformedDeps = ((undefined));
if (provider.useExisting != null) {
var /** @type {?} */ existingDiDep = ((_this._getDependency(resolvedProvider.providerType, { token: provider.useExisting }, eager)));
if (existingDiDep.token != null) {
transformedUseExisting = existingDiDep.token;
}
else {
transformedUseExisting = ((null));
transformedUseValue = existingDiDep.value;
}
}
else if (provider.useFactory) {
var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
transformedDeps =
deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
}
else if (provider.useClass) {
var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
transformedDeps =
deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
}
return _transformProvider(provider, {
useExisting: transformedUseExisting,
useValue: transformedUseValue,
deps: transformedDeps
});
});
transformedProviderAst =
_transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
this._transformedProviders.set(tokenReference(token), transformedProviderAst);
return transformedProviderAst;
};
/**
* @param {?} requestingProviderType
* @param {?} dep
* @param {?=} eager
* @return {?}
*/
ProviderElementContext.prototype._getLocalDependency = function (requestingProviderType, dep, eager) {
if (eager === void 0) { eager = false; }
if (dep.isAttribute) {
var /** @type {?} */ attrValue = this._attrs[((dep.token)).value];
return { isValue: true, value: attrValue == null ? null : attrValue };
}
if (dep.token != null) {
// access builtints
if ((requestingProviderType === ProviderAstType.Directive ||
requestingProviderType === ProviderAstType.Component)) {
if (tokenReference(dep.token) === resolveIdentifier(Identifiers.Renderer) ||
tokenReference(dep.token) === resolveIdentifier(Identifiers.ElementRef) ||
tokenReference(dep.token) === resolveIdentifier(Identifiers.ChangeDetectorRef) ||
tokenReference(dep.token) === resolveIdentifier(Identifiers.TemplateRef)) {
return dep;
}
if (tokenReference(dep.token) === resolveIdentifier(Identifiers.ViewContainerRef)) {
this._hasViewContainer = true;
}
}
// access the injector
if (tokenReference(dep.token) === resolveIdentifier(Identifiers.Injector)) {
return dep;
}
// access providers
if (this._getOrCreateLocalProvider(requestingProviderType, dep.token, eager) != null) {
return dep;
}
}
return null;
};
/**
* @param {?} requestingProviderType
* @param {?} dep
* @param {?=} eager
* @return {?}
*/
ProviderElementContext.prototype._getDependency = function (requestingProviderType, dep, eager) {
if (eager === void 0) { eager = false; }
var /** @type {?} */ currElement = this;
var /** @type {?} */ currEager = eager;
var /** @type {?} */ result = null;
if (!dep.isSkipSelf) {
result = this._getLocalDependency(requestingProviderType, dep, eager);
}
if (dep.isSelf) {
if (!result && dep.isOptional) {
result = { isValue: true, value: null };
}
}
else {
// check parent elements
while (!result && currElement._parent) {
var /** @type {?} */ prevElement = currElement;
currElement = currElement._parent;
if (prevElement._isViewRoot) {
currEager = false;
}
result = currElement._getLocalDependency(ProviderAstType.PublicService, dep, currEager);
}
// check @Host restriction
if (!result) {
if (!dep.isHost || this.viewContext.component.isHost ||
this.viewContext.component.type.reference === tokenReference(/** @type {?} */ ((dep.token))) ||
this.viewContext.viewProviders.get(tokenReference(/** @type {?} */ ((dep.token)))) != null) {
result = dep;
}
else {
result = dep.isOptional ? result = { isValue: true, value: null } : null;
}
}
}
if (!result) {
this.viewContext.errors.push(new ProviderError("No provider for " + tokenName(/** @type {?} */ ((dep.token))), this._sourceSpan));
}
return result;
};
return ProviderElementContext;
}());
var NgModuleProviderAnalyzer = (function () {
/**
* @param {?} ngModule
* @param {?} extraProviders
* @param {?} sourceSpan
*/
function NgModuleProviderAnalyzer(ngModule, extraProviders, sourceSpan) {
var _this = this;
this._transformedProviders = new Map();
this._seenProviders = new Map();
this._errors = [];
this._allProviders = new Map();
ngModule.transitiveModule.modules.forEach(function (ngModuleType) {
var ngModuleProvider = { token: { identifier: ngModuleType }, useClass: ngModuleType };
_resolveProviders([ngModuleProvider], ProviderAstType.PublicService, true, sourceSpan, _this._errors, _this._allProviders);
});
_resolveProviders(ngModule.transitiveModule.providers.map(function (entry) { return entry.provider; }).concat(extraProviders), ProviderAstType.PublicService, false, sourceSpan, this._errors, this._allProviders);
}
/**
* @return {?}
*/
NgModuleProviderAnalyzer.prototype.parse = function () {
var _this = this;
Array.from(this._allProviders.values()).forEach(function (provider) {
_this._getOrCreateLocalProvider(provider.token, provider.eager);
});
if (this._errors.length > 0) {
var /** @type {?} */ errorString = this._errors.join('\n');
throw new Error("Provider parse errors:\n" + errorString);
}
return Array.from(this._transformedProviders.values());
};
/**
* @param {?} token
* @param {?} eager
* @return {?}
*/
NgModuleProviderAnalyzer.prototype._getOrCreateLocalProvider = function (token, eager) {
var _this = this;
var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
if (!resolvedProvider) {
return null;
}
var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
if (transformedProviderAst) {
return transformedProviderAst;
}
if (this._seenProviders.get(tokenReference(token)) != null) {
this._errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), resolvedProvider.sourceSpan));
return null;
}
this._seenProviders.set(tokenReference(token), true);
var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
var /** @type {?} */ transformedUseValue = provider.useValue;
var /** @type {?} */ transformedUseExisting = ((provider.useExisting));
var /** @type {?} */ transformedDeps = ((undefined));
if (provider.useExisting != null) {
var /** @type {?} */ existingDiDep = _this._getDependency({ token: provider.useExisting }, eager, resolvedProvider.sourceSpan);
if (existingDiDep.token != null) {
transformedUseExisting = existingDiDep.token;
}
else {
transformedUseExisting = ((null));
transformedUseValue = existingDiDep.value;
}
}
else if (provider.useFactory) {
var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
transformedDeps =
deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
}
else if (provider.useClass) {
var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
transformedDeps =
deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
}
return _transformProvider(provider, {
useExisting: transformedUseExisting,
useValue: transformedUseValue,
deps: transformedDeps
});
});
transformedProviderAst =
_transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
this._transformedProviders.set(tokenReference(token), transformedProviderAst);
return transformedProviderAst;
};
/**
* @param {?} dep
* @param {?=} eager
* @param {?=} requestorSourceSpan
* @return {?}
*/
NgModuleProviderAnalyzer.prototype._getDependency = function (dep, eager, requestorSourceSpan) {
if (eager === void 0) { eager = false; }
var /** @type {?} */ foundLocal = false;
if (!dep.isSkipSelf && dep.token != null) {
// access the injector
if (tokenReference(dep.token) === resolveIdentifier(Identifiers.Injector) ||
tokenReference(dep.token) === resolveIdentifier(Identifiers.ComponentFactoryResolver)) {
foundLocal = true;
}
else if (this._getOrCreateLocalProvider(dep.token, eager) != null) {
foundLocal = true;
}
}
var /** @type {?} */ result = dep;
if (dep.isSelf && !foundLocal) {
if (dep.isOptional) {
result = { isValue: true, value: null };
}
else {
this._errors.push(new ProviderError("No provider for " + tokenName(/** @type {?} */ ((dep.token))), requestorSourceSpan));
}
}
return result;
};
return NgModuleProviderAnalyzer;
}());
/**
* @param {?} provider
* @param {?} __1
* @return {?}
*/
function _transformProvider(provider, _a) {
var useExisting = _a.useExisting, useValue = _a.useValue, deps = _a.deps;
return {
token: provider.token,
useClass: provider.useClass,
useExisting: useExisting,
useFactory: provider.useFactory,
useValue: useValue,
deps: deps,
multi: provider.multi
};
}
/**
* @param {?} provider
* @param {?} __1
* @return {?}
*/
function _transformProviderAst(provider, _a) {
var eager = _a.eager, providers = _a.providers;
return new ProviderAst(provider.token, provider.multiProvider, provider.eager || eager, providers, provider.providerType, provider.lifecycleHooks, provider.sourceSpan);
}
/**
* @param {?} directives
* @param {?} sourceSpan
* @param {?} targetErrors
* @return {?}
*/
function _resolveProvidersFromDirectives(directives, sourceSpan, targetErrors) {
var /** @type {?} */ providersByToken = new Map();
directives.forEach(function (directive) {
var /** @type {?} */ dirProvider = { token: { identifier: directive.type }, useClass: directive.type };
_resolveProviders([dirProvider], directive.isComponent ? ProviderAstType.Component : ProviderAstType.Directive, true, sourceSpan, targetErrors, providersByToken);
});
// Note: directives need to be able to overwrite providers of a component!
var /** @type {?} */ directivesWithComponentFirst = directives.filter(function (dir) { return dir.isComponent; }).concat(directives.filter(function (dir) { return !dir.isComponent; }));
directivesWithComponentFirst.forEach(function (directive) {
_resolveProviders(directive.providers, ProviderAstType.PublicService, false, sourceSpan, targetErrors, providersByToken);
_resolveProviders(directive.viewProviders, ProviderAstType.PrivateService, false, sourceSpan, targetErrors, providersByToken);
});
return providersByToken;
}
/**
* @param {?} providers
* @param {?} providerType
* @param {?} eager
* @param {?} sourceSpan
* @param {?} targetErrors
* @param {?} targetProvidersByToken
* @return {?}
*/
function _resolveProviders(providers, providerType, eager, sourceSpan, targetErrors, targetProvidersByToken) {
providers.forEach(function (provider) {
var /** @type {?} */ resolvedProvider = targetProvidersByToken.get(tokenReference(provider.token));
if (resolvedProvider != null && !!resolvedProvider.multiProvider !== !!provider.multi) {
targetErrors.push(new ProviderError("Mixing multi and non multi provider is not possible for token " + tokenName(resolvedProvider.token), sourceSpan));
}
if (!resolvedProvider) {
var /** @type {?} */ lifecycleHooks = provider.token.identifier &&
((provider.token.identifier)).lifecycleHooks ?
((provider.token.identifier)).lifecycleHooks :
[];
var /** @type {?} */ isUseValue = !(provider.useClass || provider.useExisting || provider.useFactory);
resolvedProvider = new ProviderAst(provider.token, !!provider.multi, eager || isUseValue, [provider], providerType, lifecycleHooks, sourceSpan);
targetProvidersByToken.set(tokenReference(provider.token), resolvedProvider);
}
else {
if (!provider.multi) {
resolvedProvider.providers.length = 0;
}
resolvedProvider.providers.push(provider);
}
});
}
/**
* @param {?} component
* @return {?}
*/
function _getViewQueries(component) {
// Note: queries start with id 1 so we can use the number in a Bloom filter!
var /** @type {?} */ viewQueryId = 1;
var /** @type {?} */ viewQueries = new Map();
if (component.viewQueries) {
component.viewQueries.forEach(function (query) { return _addQueryToTokenMap(viewQueries, { meta: query, queryId: viewQueryId++ }); });
}
return viewQueries;
}
/**
* @param {?} contentQueryStartId
* @param {?} directives
* @return {?}
*/
function _getContentQueries(contentQueryStartId, directives) {
var /** @type {?} */ contentQueryId = contentQueryStartId;
var /** @type {?} */ contentQueries = new Map();
directives.forEach(function (directive, directiveIndex) {
if (directive.queries) {
directive.queries.forEach(function (query) { return _addQueryToTokenMap(contentQueries, { meta: query, queryId: contentQueryId++ }); });
}
});
return contentQueries;
}
/**
* @param {?} map
* @param {?} query
* @return {?}
*/
function _addQueryToTokenMap(map, query) {
query.meta.selectors.forEach(function (token) {
var /** @type {?} */ entry = map.get(tokenReference(token));
if (!entry) {
entry = [];
map.set(tokenReference(token), entry);
}
entry.push(query);
});
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @abstract
*/
var ElementSchemaRegistry = (function () {
function ElementSchemaRegistry() {
}
/**
* @abstract
* @param {?} tagName
* @param {?} propName
* @param {?} schemaMetas
* @return {?}
*/
ElementSchemaRegistry.prototype.hasProperty = function (tagName, propName, schemaMetas) { };
/**
* @abstract
* @param {?} tagName
* @param {?} schemaMetas
* @return {?}
*/
ElementSchemaRegistry.prototype.hasElement = function (tagName, schemaMetas) { };
/**
* @abstract
* @param {?} elementName
* @param {?} propName
* @param {?} isAttribute
* @return {?}
*/
ElementSchemaRegistry.prototype.securityContext = function (elementName, propName, isAttribute) { };
/**
* @abstract
* @return {?}
*/
ElementSchemaRegistry.prototype.allKnownElementNames = function () { };
/**
* @abstract
* @param {?} propName
* @return {?}
*/
ElementSchemaRegistry.prototype.getMappedPropName = function (propName) { };
/**
* @abstract
* @return {?}
*/
ElementSchemaRegistry.prototype.getDefaultComponentElementName = function () { };
/**
* @abstract
* @param {?} name
* @return {?}
*/
ElementSchemaRegistry.prototype.validateProperty = function (name) { };
/**
* @abstract
* @param {?} name
* @return {?}
*/
ElementSchemaRegistry.prototype.validateAttribute = function (name) { };
/**
* @abstract
* @param {?} propName
* @return {?}
*/
ElementSchemaRegistry.prototype.normalizeAnimationStyleProperty = function (propName) { };
/**
* @abstract
* @param {?} camelCaseProp
* @param {?} userProvidedProp
* @param {?} val
* @return {?}
*/
ElementSchemaRegistry.prototype.normalizeAnimationStyleValue = function (camelCaseProp, userProvidedProp, val) { };
return ElementSchemaRegistry;
}());
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var StyleWithImports = (function () {
/**
* @param {?} style
* @param {?} styleUrls
*/
function StyleWithImports(style$$1, styleUrls) {
this.style = style$$1;
this.styleUrls = styleUrls;
}
return StyleWithImports;
}());
/**
* @param {?} url
* @return {?}
*/
function isStyleUrlResolvable(url) {
if (url == null || url.length === 0 || url[0] == '/')
return false;
var /** @type {?} */ schemeMatch = url.match(URL_WITH_SCHEMA_REGEXP);
return schemeMatch === null || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset';
}
/**
* Rewrites stylesheets by resolving and removing the \@import urls that
* are either relative or don't have a `package:` scheme
* @param {?} resolver
* @param {?} baseUrl
* @param {?} cssText
* @return {?}
*/
function extractStyleUrls(resolver, baseUrl, cssText) {
var /** @type {?} */ foundUrls = [];
var /** @type {?} */ modifiedCssText = cssText.replace(CSS_COMMENT_REGEXP, '').replace(CSS_IMPORT_REGEXP, function () {
var m = [];
for (var _i = 0; _i < arguments.length; _i++) {
m[_i] = arguments[_i];
}
var /** @type {?} */ url = m[1] || m[2];
if (!isStyleUrlResolvable(url)) {
// Do not attempt to resolve non-package absolute URLs with URI scheme
return m[0];
}
foundUrls.push(resolver.resolve(baseUrl, url));
return '';
});
return new StyleWithImports(modifiedCssText, foundUrls);
}
var CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g;
var CSS_COMMENT_REGEXP = /\/\*.+?\*\//g;
var URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/;
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var PROPERTY_PARTS_SEPARATOR = '.';
var ATTRIBUTE_PREFIX = 'attr';
var CLASS_PREFIX = 'class';
var STYLE_PREFIX = 'style';
var ANIMATE_PROP_PREFIX = 'animate-';
var BoundPropertyType = {};
BoundPropertyType.DEFAULT = 0;
BoundPropertyType.LITERAL_ATTR = 1;
BoundPropertyType.ANIMATION = 2;
BoundPropertyType[BoundPropertyType.DEFAULT] = "DEFAULT";
BoundPropertyType[BoundPropertyType.LITERAL_ATTR] = "LITERAL_ATTR";
BoundPropertyType[BoundPropertyType.ANIMATION] = "ANIMATION";
/**
* Represents a parsed property.
*/
var BoundProperty = (function () {
/**
* @param {?} name
* @param {?} expression
* @param {?} type
* @param {?} sourceSpan
*/
function BoundProperty(name, expression, type, sourceSpan) {
this.name = name;
this.expression = expression;
this.type = type;
this.sourceSpan = sourceSpan;
}
Object.defineProperty(BoundProperty.prototype, "isLiteral", {
/**
* @return {?}
*/
get: function () { return this.type === BoundPropertyType.LITERAL_ATTR; },
enumerable: true,
configurable: true
});
Object.defineProperty(BoundProperty.prototype, "isAnimation", {
/**
* @return {?}
*/
get: function () { return this.type === BoundPropertyType.ANIMATION; },
enumerable: true,
configurable: true
});
return BoundProperty;
}());
/**
* Parses bindings in templates and in the directive host area.
*/
var BindingParser = (function () {
/**
* @param {?} _exprParser
* @param {?} _interpolationConfig
* @param {?} _schemaRegistry
* @param {?} pipes
* @param {?} _targetErrors
*/
function BindingParser(_exprParser, _interpolationConfig, _schemaRegistry, pipes, _targetErrors) {
var _this = this;
this._exprParser = _exprParser;
this._interpolationConfig = _interpolationConfig;
this._schemaRegistry = _schemaRegistry;
this._targetErrors = _targetErrors;
this.pipesByName = new Map();
this._usedPipes = new Map();
pipes.forEach(function (pipe) { return _this.pipesByName.set(pipe.name, pipe); });
}
/**
* @return {?}
*/
BindingParser.prototype.getUsedPipes = function () { return Array.from(this._usedPipes.values()); };
/**
* @param {?} dirMeta
* @param {?} elementSelector
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype.createDirectiveHostPropertyAsts = function (dirMeta, elementSelector, sourceSpan) {
var _this = this;
if (dirMeta.hostProperties) {
var /** @type {?} */ boundProps_1 = [];
Object.keys(dirMeta.hostProperties).forEach(function (propName) {
var /** @type {?} */ expression = dirMeta.hostProperties[propName];
if (typeof expression === 'string') {
_this.parsePropertyBinding(propName, expression, true, sourceSpan, [], boundProps_1);
}
else {
_this._reportError("Value of the host property binding \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
}
});
return boundProps_1.map(function (prop) { return _this.createElementPropertyAst(elementSelector, prop); });
}
return null;
};
/**
* @param {?} dirMeta
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype.createDirectiveHostEventAsts = function (dirMeta, sourceSpan) {
var _this = this;
if (dirMeta.hostListeners) {
var /** @type {?} */ targetEventAsts_1 = [];
Object.keys(dirMeta.hostListeners).forEach(function (propName) {
var /** @type {?} */ expression = dirMeta.hostListeners[propName];
if (typeof expression === 'string') {
_this.parseEvent(propName, expression, sourceSpan, [], targetEventAsts_1);
}
else {
_this._reportError("Value of the host listener \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
}
});
return targetEventAsts_1;
}
return null;
};
/**
* @param {?} value
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype.parseInterpolation = function (value, sourceSpan) {
var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
try {
var /** @type {?} */ ast = ((this._exprParser.parseInterpolation(value, sourceInfo, this._interpolationConfig)));
if (ast)
this._reportExpressionParserErrors(ast.errors, sourceSpan);
this._checkPipes(ast, sourceSpan);
return ast;
}
catch (e) {
this._reportError("" + e, sourceSpan);
return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
}
};
/**
* @param {?} prefixToken
* @param {?} value
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetProps
* @param {?} targetVars
* @return {?}
*/
BindingParser.prototype.parseInlineTemplateBinding = function (prefixToken, value, sourceSpan, targetMatchableAttrs, targetProps, targetVars) {
var /** @type {?} */ bindings = this._parseTemplateBindings(prefixToken, value, sourceSpan);
for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
var /** @type {?} */ binding = bindings[i];
if (binding.keyIsVar) {
targetVars.push(new VariableAst(binding.key, binding.name, sourceSpan));
}
else if (binding.expression) {
this._parsePropertyAst(binding.key, binding.expression, sourceSpan, targetMatchableAttrs, targetProps);
}
else {
targetMatchableAttrs.push([binding.key, '']);
this.parseLiteralAttr(binding.key, null, sourceSpan, targetMatchableAttrs, targetProps);
}
}
};
/**
* @param {?} prefixToken
* @param {?} value
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype._parseTemplateBindings = function (prefixToken, value, sourceSpan) {
var _this = this;
var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
try {
var /** @type {?} */ bindingsResult = this._exprParser.parseTemplateBindings(prefixToken, value, sourceInfo);
this._reportExpressionParserErrors(bindingsResult.errors, sourceSpan);
bindingsResult.templateBindings.forEach(function (binding) {
if (binding.expression) {
_this._checkPipes(binding.expression, sourceSpan);
}
});
bindingsResult.warnings.forEach(function (warning) { _this._reportError(warning, sourceSpan, ParseErrorLevel.WARNING); });
return bindingsResult.templateBindings;
}
catch (e) {
this._reportError("" + e, sourceSpan);
return [];
}
};
/**
* @param {?} name
* @param {?} value
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetProps
* @return {?}
*/
BindingParser.prototype.parseLiteralAttr = function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
if (_isAnimationLabel(name)) {
name = name.substring(1);
if (value) {
this._reportError("Assigning animation triggers via @prop=\"exp\" attributes with an expression is invalid." +
" Use property bindings (e.g. [@prop]=\"exp\") or use an attribute without a value (e.g. @prop) instead.", sourceSpan, ParseErrorLevel.ERROR);
}
this._parseAnimation(name, value, sourceSpan, targetMatchableAttrs, targetProps);
}
else {
targetProps.push(new BoundProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), BoundPropertyType.LITERAL_ATTR, sourceSpan));
}
};
/**
* @param {?} name
* @param {?} expression
* @param {?} isHost
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetProps
* @return {?}
*/
BindingParser.prototype.parsePropertyBinding = function (name, expression, isHost, sourceSpan, targetMatchableAttrs, targetProps) {
var /** @type {?} */ isAnimationProp = false;
if (name.startsWith(ANIMATE_PROP_PREFIX)) {
isAnimationProp = true;
name = name.substring(ANIMATE_PROP_PREFIX.length);
}
else if (_isAnimationLabel(name)) {
isAnimationProp = true;
name = name.substring(1);
}
if (isAnimationProp) {
this._parseAnimation(name, expression, sourceSpan, targetMatchableAttrs, targetProps);
}
else {
this._parsePropertyAst(name, this._parseBinding(expression, isHost, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);
}
};
/**
* @param {?} name
* @param {?} value
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetProps
* @return {?}
*/
BindingParser.prototype.parsePropertyInterpolation = function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
var /** @type {?} */ expr = this.parseInterpolation(value, sourceSpan);
if (expr) {
this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps);
return true;
}
return false;
};
/**
* @param {?} name
* @param {?} ast
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetProps
* @return {?}
*/
BindingParser.prototype._parsePropertyAst = function (name, ast, sourceSpan, targetMatchableAttrs, targetProps) {
targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
targetProps.push(new BoundProperty(name, ast, BoundPropertyType.DEFAULT, sourceSpan));
};
/**
* @param {?} name
* @param {?} expression
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetProps
* @return {?}
*/
BindingParser.prototype._parseAnimation = function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) {
// This will occur when a @trigger is not paired with an expression.
// For animations it is valid to not have an expression since */void
// states will be applied by angular when the element is attached/detached
var /** @type {?} */ ast = this._parseBinding(expression || 'null', false, sourceSpan);
targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
targetProps.push(new BoundProperty(name, ast, BoundPropertyType.ANIMATION, sourceSpan));
};
/**
* @param {?} value
* @param {?} isHostBinding
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype._parseBinding = function (value, isHostBinding, sourceSpan) {
var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
try {
var /** @type {?} */ ast = isHostBinding ?
this._exprParser.parseSimpleBinding(value, sourceInfo, this._interpolationConfig) :
this._exprParser.parseBinding(value, sourceInfo, this._interpolationConfig);
if (ast)
this._reportExpressionParserErrors(ast.errors, sourceSpan);
this._checkPipes(ast, sourceSpan);
return ast;
}
catch (e) {
this._reportError("" + e, sourceSpan);
return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
}
};
/**
* @param {?} elementSelector
* @param {?} boundProp
* @return {?}
*/
BindingParser.prototype.createElementPropertyAst = function (elementSelector, boundProp) {
if (boundProp.isAnimation) {
return new BoundElementPropertyAst(boundProp.name, PropertyBindingType.Animation, __WEBPACK_IMPORTED_MODULE_0__angular_core__["v" /* SecurityContext */].NONE, boundProp.expression, null, boundProp.sourceSpan);
}
var /** @type {?} */ unit = null;
var /** @type {?} */ bindingType = ((undefined));
var /** @type {?} */ boundPropertyName = null;
var /** @type {?} */ parts = boundProp.name.split(PROPERTY_PARTS_SEPARATOR);
var /** @type {?} */ securityContexts = ((undefined));
// Check check for special cases (prefix style, attr, class)
if (parts.length > 1) {
if (parts[0] == ATTRIBUTE_PREFIX) {
boundPropertyName = parts[1];
this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, true);
securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, true);
var /** @type {?} */ nsSeparatorIdx = boundPropertyName.indexOf(':');
if (nsSeparatorIdx > -1) {
var /** @type {?} */ ns = boundPropertyName.substring(0, nsSeparatorIdx);
var /** @type {?} */ name = boundPropertyName.substring(nsSeparatorIdx + 1);
boundPropertyName = mergeNsAndName(ns, name);
}
bindingType = PropertyBindingType.Attribute;
}
else if (parts[0] == CLASS_PREFIX) {
boundPropertyName = parts[1];
bindingType = PropertyBindingType.Class;
securityContexts = [__WEBPACK_IMPORTED_MODULE_0__angular_core__["v" /* SecurityContext */].NONE];
}
else if (parts[0] == STYLE_PREFIX) {
unit = parts.length > 2 ? parts[2] : null;
boundPropertyName = parts[1];
bindingType = PropertyBindingType.Style;
securityContexts = [__WEBPACK_IMPORTED_MODULE_0__angular_core__["v" /* SecurityContext */].STYLE];
}
}
// If not a special case, use the full property name
if (boundPropertyName === null) {
boundPropertyName = this._schemaRegistry.getMappedPropName(boundProp.name);
securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, false);
bindingType = PropertyBindingType.Property;
this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, false);
}
return new BoundElementPropertyAst(boundPropertyName, bindingType, securityContexts[0], boundProp.expression, unit, boundProp.sourceSpan);
};
/**
* @param {?} name
* @param {?} expression
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetEvents
* @return {?}
*/
BindingParser.prototype.parseEvent = function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
if (_isAnimationLabel(name)) {
name = name.substr(1);
this._parseAnimationEvent(name, expression, sourceSpan, targetEvents);
}
else {
this._parseEvent(name, expression, sourceSpan, targetMatchableAttrs, targetEvents);
}
};
/**
* @param {?} name
* @param {?} expression
* @param {?} sourceSpan
* @param {?} targetEvents
* @return {?}
*/
BindingParser.prototype._parseAnimationEvent = function (name, expression, sourceSpan, targetEvents) {
var /** @type {?} */ matches = splitAtPeriod(name, [name, '']);
var /** @type {?} */ eventName = matches[0];
var /** @type {?} */ phase = matches[1].toLowerCase();
if (phase) {
switch (phase) {
case 'start':
case 'done':
var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
targetEvents.push(new BoundEventAst(eventName, null, phase, ast, sourceSpan));
break;
default:
this._reportError("The provided animation output phase value \"" + phase + "\" for \"@" + eventName + "\" is not supported (use start or done)", sourceSpan);
break;
}
}
else {
this._reportError("The animation trigger output event (@" + eventName + ") is missing its phase value name (start or done are currently supported)", sourceSpan);
}
};
/**
* @param {?} name
* @param {?} expression
* @param {?} sourceSpan
* @param {?} targetMatchableAttrs
* @param {?} targetEvents
* @return {?}
*/
BindingParser.prototype._parseEvent = function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
// long format: 'target: eventName'
var _a = splitAtColon(name, [/** @type {?} */ ((null)), name]), target = _a[0], eventName = _a[1];
var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
targetMatchableAttrs.push([/** @type {?} */ ((name)), /** @type {?} */ ((ast.source))]);
targetEvents.push(new BoundEventAst(eventName, target, null, ast, sourceSpan));
// Don't detect directives for event names for now,
// so don't add the event name to the matchableAttrs
};
/**
* @param {?} value
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype._parseAction = function (value, sourceSpan) {
var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
try {
var /** @type {?} */ ast = this._exprParser.parseAction(value, sourceInfo, this._interpolationConfig);
if (ast) {
this._reportExpressionParserErrors(ast.errors, sourceSpan);
}
if (!ast || ast.ast instanceof EmptyExpr) {
this._reportError("Empty expressions are not allowed", sourceSpan);
return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
}
this._checkPipes(ast, sourceSpan);
return ast;
}
catch (e) {
this._reportError("" + e, sourceSpan);
return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
}
};
/**
* @param {?} message
* @param {?} sourceSpan
* @param {?=} level
* @return {?}
*/
BindingParser.prototype._reportError = function (message, sourceSpan, level) {
if (level === void 0) { level = ParseErrorLevel.ERROR; }
this._targetErrors.push(new ParseError(sourceSpan, message, level));
};
/**
* @param {?} errors
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype._reportExpressionParserErrors = function (errors, sourceSpan) {
for (var _i = 0, errors_1 = errors; _i < errors_1.length; _i++) {
var error = errors_1[_i];
this._reportError(error.message, sourceSpan);
}
};
/**
* @param {?} ast
* @param {?} sourceSpan
* @return {?}
*/
BindingParser.prototype._checkPipes = function (ast, sourceSpan) {
var _this = this;
if (ast) {
var /** @type {?} */ collector = new PipeCollector();
ast.visit(collector);
collector.pipes.forEach(function (ast, pipeName) {
var /** @type {?} */ pipeMeta = _this.pipesByName.get(pipeName);
if (!pipeMeta) {
_this._reportError("The pipe '" + pipeName + "' could not be found", new ParseSourceSpan(sourceSpan.start.moveBy(ast.span.start), sourceSpan.start.moveBy(ast.span.end)));
}
else {
_this._usedPipes.set(pipeName, pipeMeta);
}
});
}
};
/**
* @param {?} propName the name of the property / attribute
* @param {?} sourceSpan
* @param {?} isAttr true when binding to an attribute
* @return {?}
*/
BindingParser.prototype._validatePropertyOrAttributeName = function (propName, sourceSpan, isAttr) {
var /** @type {?} */ report = isAttr ? this._schemaRegistry.validateAttribute(propName) :
this._schemaRegistry.validateProperty(propName);
if (report.error) {
this._reportError(/** @type {?} */ ((report.msg)), sourceSpan, ParseErrorLevel.ERROR);
}
};
return BindingParser;
}());
var PipeCollector = (function (_super) {
__extends(PipeCollector, _super);
function PipeCollector() {
var _this = _super.apply(this, arguments) || this;
_this.pipes = new Map();
return _this;
}
/**
* @param {?} ast
* @param {?} context
* @return {?}
*/
PipeCollector.prototype.visitPipe = function (ast, context) {
this.pipes.set(ast.name, ast);
ast.exp.visit(this);
this.visitAll(ast.args, context);
return null;
};
return PipeCollector;
}(RecursiveAstVisitor));
/**
* @param {?} name
* @return {?}
*/
function _isAnimationLabel(name) {
return name[0] == '@';
}
/**
* @param {?} registry
* @param {?} selector
* @param {?} propName
* @param {?} isAttribute
* @return {?}
*/
function calcPossibleSecurityContexts(registry, selector, propName, isAttribute) {
var /** @type {?} */ ctxs = [];
CssSelector.parse(selector).forEach(function (selector) {
var /** @type {?} */ elementNames = selector.element ? [selector.element] : registry.allKnownElementNames();
var /** @type {?} */ notElementNames = new Set(selector.notSelectors.filter(function (selector) { return selector.isElementSelector(); })
.map(function (selector) { return selector.element; }));
var /** @type {?} */ possibleElementNames = elementNames.filter(function (elementName) { return !notElementNames.has(elementName); });
ctxs.push.apply(ctxs, possibleElementNames.map(function (elementName) { return registry.securityContext(elementName, propName, isAttribute); }));
});
return ctxs.length === 0 ? [__WEBPACK_IMPORTED_MODULE_0__angular_core__["v" /* SecurityContext */].NONE] : Array.from(new Set(ctxs)).sort();
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var NG_CONTENT_SELECT_ATTR = 'select';
var LINK_ELEMENT = 'link';
var LINK_STYLE_REL_ATTR = 'rel';
var LINK_STYLE_HREF_ATTR = 'href';
var LINK_STYLE_REL_VALUE = 'stylesheet';
var STYLE_ELEMENT = 'style';
var SCRIPT_ELEMENT = 'script';
var NG_NON_BINDABLE_ATTR = 'ngNonBindable';
var NG_PROJECT_AS = 'ngProjectAs';
/**
* @param {?} ast
* @return {?}
*/
function preparseElement(ast) {
var /** @type {?} */ selectAttr = ((null));
var /** @type {?} */ hrefAttr = ((null));
var /** @type {?} */ relAttr = ((null));
var /** @type {?} */ nonBindable = false;
var /** @type {?} */ projectAs = ((null));
ast.attrs.forEach(function (attr) {
var /** @type {?} */ lcAttrName = attr.name.toLowerCase();
if (lcAttrName == NG_CONTENT_SELECT_ATTR) {
selectAttr = attr.value;
}
else if (lcAttrName == LINK_STYLE_HREF_ATTR) {
hrefAttr = attr.value;
}
else if (lcAttrName == LINK_STYLE_REL_ATTR) {
relAttr = attr.value;
}
else if (attr.name == NG_NON_BINDABLE_ATTR) {
nonBindable = true;
}
else if (attr.name == NG_PROJECT_AS) {
if (attr.value.length > 0) {
projectAs = attr.value;
}
}
});
selectAttr = normalizeNgContentSelect(selectAttr);
var /** @type {?} */ nodeName = ast.name.toLowerCase();
var /** @type {?} */ type = PreparsedElementType.OTHER;
if (isNgContent(nodeName)) {
type = PreparsedElementType.NG_CONTENT;
}
else if (nodeName == STYLE_ELEMENT) {
type = PreparsedElementType.STYLE;
}
else if (nodeName == SCRIPT_ELEMENT) {
type = PreparsedElementType.SCRIPT;
}
else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) {
type = PreparsedElementType.STYLESHEET;
}
return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs);
}
var PreparsedElementType = {};
PreparsedElementType.NG_CONTENT = 0;
PreparsedElementType.STYLE = 1;
PreparsedElementType.STYLESHEET = 2;
PreparsedElementType.SCRIPT = 3;
PreparsedElementType.OTHER = 4;
PreparsedElementType[PreparsedElementType.NG_CONTENT] = "NG_CONTENT";
PreparsedElementType[PreparsedElementType.STYLE] = "STYLE";
PreparsedElementType[PreparsedElementType.STYLESHEET] = "STYLESHEET";
PreparsedElementType[PreparsedElementType.SCRIPT] = "SCRIPT";
PreparsedElementType[PreparsedElementType.OTHER] = "OTHER";
var PreparsedElement = (function () {
/**
* @param {?} type
* @param {?} selectAttr
* @param {?} hrefAttr
* @param {?} nonBindable
* @param {?} projectAs
*/
function PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs) {
this.type = type;
this.selectAttr = selectAttr;
this.hrefAttr = hrefAttr;
this.nonBindable = nonBindable;
this.projectAs = projectAs;
}
return PreparsedElement;
}());
/**
* @param {?} selectAttr
* @return {?}
*/
function normalizeNgContentSelect(selectAttr) {
if (selectAttr === null || selectAttr.length === 0) {
return '*';
}
return selectAttr;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/;
// Group 1 = "bind-"
var KW_BIND_IDX = 1;
// Group 2 = "let-"
var KW_LET_IDX = 2;
// Group 3 = "ref-/#"
var KW_REF_IDX = 3;
// Group 4 = "on-"
var KW_ON_IDX = 4;
// Group 5 = "bindon-"
var KW_BINDON_IDX = 5;
// Group 6 = "@"
var KW_AT_IDX = 6;
// Group 7 = the identifier after "bind-", "let-", "ref-/#", "on-", "bindon-" or "@"
var IDENT_KW_IDX = 7;
// Group 8 = identifier inside [()]
var IDENT_BANANA_BOX_IDX = 8;
// Group 9 = identifier inside []
var IDENT_PROPERTY_IDX = 9;
// Group 10 = identifier inside ()
var IDENT_EVENT_IDX = 10;
// deprecated in 4.x
var TEMPLATE_ELEMENT = 'template';
// deprecated in 4.x
var TEMPLATE_ATTR = 'template';
var TEMPLATE_ATTR_PREFIX = '*';
var CLASS_ATTR = 'class';
var TEXT_CSS_SELECTOR = CssSelector.parse('*')[0];
var TEMPLATE_ELEMENT_DEPRECATION_WARNING = 'The element is deprecated. Use instead';
var TEMPLATE_ATTR_DEPRECATION_WARNING = 'The template attribute is deprecated. Use an ng-template element instead.';
var warningCounts = {};
/**
* @param {?} warnings
* @return {?}
*/
function warnOnlyOnce(warnings) {
return function (error) {
if (warnings.indexOf(error.msg) !== -1) {
warningCounts[error.msg] = (warningCounts[error.msg] || 0) + 1;
return warningCounts[error.msg] <= 1;
}
return true;
};
}
/**
* Provides an array of {@link TemplateAstVisitor}s which will be used to transform
* parsed templates before compilation is invoked, allowing custom expression syntax
* and other advanced transformations.
*
* This is currently an internal-only feature and not meant for general use.
*/
var TEMPLATE_TRANSFORMS = new __WEBPACK_IMPORTED_MODULE_0__angular_core__["h" /* InjectionToken */]('TemplateTransforms');
var TemplateParseError = (function (_super) {
__extends(TemplateParseError, _super);
/**
* @param {?} message
* @param {?} span
* @param {?} level
*/
function TemplateParseError(message, span, level) {
return _super.call(this, span, message, level) || this;
}
return TemplateParseError;
}(ParseError));
var TemplateParseResult = (function () {
/**
* @param {?=} templateAst
* @param {?=} usedPipes
* @param {?=} errors
*/
function TemplateParseResult(templateAst, usedPipes, errors) {
this.templateAst = templateAst;
this.usedPipes = usedPipes;
this.errors = errors;
}
return TemplateParseResult;
}());
var TemplateParser = (function () {
/**
* @param {?} _config
* @param {?} _exprParser
* @param {?} _schemaRegistry
* @param {?} _htmlParser
* @param {?} _console
* @param {?} transforms
*/
function TemplateParser(_config, _exprParser, _schemaRegistry, _htmlParser, _console, transforms) {
this._config = _config;
this._exprParser = _exprParser;
this._schemaRegistry = _schemaRegistry;
this._htmlParser = _htmlParser;
this._console = _console;
this.transforms = transforms;
}
/**
* @param {?} component
* @param {?} template
* @param {?} directives
* @param {?} pipes
* @param {?} schemas
* @param {?} templateUrl
* @return {?}
*/
TemplateParser.prototype.parse = function (component, template, directives, pipes, schemas, templateUrl) {
var /** @type {?} */ result = this.tryParse(component, template, directives, pipes, schemas, templateUrl);
var /** @type {?} */ warnings = ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.WARNING; })
.filter(warnOnlyOnce([TEMPLATE_ATTR_DEPRECATION_WARNING, TEMPLATE_ELEMENT_DEPRECATION_WARNING]));
var /** @type {?} */ errors = ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.ERROR; });
if (warnings.length > 0) {
this._console.warn("Template parse warnings:\n" + warnings.join('\n'));
}
if (errors.length > 0) {
var /** @type {?} */ errorString = errors.join('\n');
throw syntaxError("Template parse errors:\n" + errorString);
}
return { template: /** @type {?} */ ((result.templateAst)), pipes: /** @type {?} */ ((result.usedPipes)) };
};
/**
* @param {?} component
* @param {?} template
* @param {?} directives
* @param {?} pipes
* @param {?} schemas
* @param {?} templateUrl
* @return {?}
*/
TemplateParser.prototype.tryParse = function (component, template, directives, pipes, schemas, templateUrl) {
return this.tryParseHtml(this.expandHtml(/** @type {?} */ ((this._htmlParser)).parse(template, templateUrl, true, this.getInterpolationConfig(component))), component, directives, pipes, schemas);
};
/**
* @param {?} htmlAstWithErrors
* @param {?} component
* @param {?} directives
* @param {?} pipes
* @param {?} schemas
* @return {?}
*/
TemplateParser.prototype.tryParseHtml = function (htmlAstWithErrors, component, directives, pipes, schemas) {
var /** @type {?} */ result;
var /** @type {?} */ errors = htmlAstWithErrors.errors;
var /** @type {?} */ usedPipes = [];
if (htmlAstWithErrors.rootNodes.length > 0) {
var /** @type {?} */ uniqDirectives = removeSummaryDuplicates(directives);
var /** @type {?} */ uniqPipes = removeSummaryDuplicates(pipes);
var /** @type {?} */ providerViewContext = new ProviderViewContext(component);
var /** @type {?} */ interpolationConfig = ((undefined));
if (component.template && component.template.interpolation) {
interpolationConfig = {
start: component.template.interpolation[0],
end: component.template.interpolation[1]
};
}
var /** @type {?} */ bindingParser = new BindingParser(this._exprParser, /** @type {?} */ ((interpolationConfig)), this._schemaRegistry, uniqPipes, errors);
var /** @type {?} */ parseVisitor = new TemplateParseVisitor(this._config, providerViewContext, uniqDirectives, bindingParser, this._schemaRegistry, schemas, errors);
result = visitAll(parseVisitor, htmlAstWithErrors.rootNodes, EMPTY_ELEMENT_CONTEXT);
errors.push.apply(errors, providerViewContext.errors);
usedPipes.push.apply(usedPipes, bindingParser.getUsedPipes());
}
else {
result = [];
}
this._assertNoReferenceDuplicationOnTemplate(result, errors);
if (errors.length > 0) {
return new TemplateParseResult(result, usedPipes, errors);
}
if (this.transforms) {
this.transforms.forEach(function (transform) { result = templateVisitAll(transform, result); });
}
return new TemplateParseResult(result, usedPipes, errors);
};
/**
* @param {?} htmlAstWithErrors
* @param {?=} forced
* @return {?}
*/
TemplateParser.prototype.expandHtml = function (htmlAstWithErrors, forced) {
if (forced === void 0) { forced = false; }
var /** @type {?} */ errors = htmlAstWithErrors.errors;
if (errors.length == 0 || forced) {
// Transform ICU messages to angular directives
var /** @type {?} */ expandedHtmlAst = expandNodes(htmlAstWithErrors.rootNodes);
errors.push.apply(errors, expandedHtmlAst.errors);
htmlAstWithErrors = new ParseTreeResult(expandedHtmlAst.nodes, errors);
}
return htmlAstWithErrors;
};
/**
* @param {?} component
* @return {?}
*/
TemplateParser.prototype.getInterpolationConfig = function (component) {
if (component.template) {
return InterpolationConfig.fromArray(component.template.interpolation);
}
return undefined;
};
/**
* \@internal
* @param {?} result
* @param {?} errors
* @return {?}
*/
TemplateParser.prototype._assertNoReferenceDuplicationOnTemplate = function (result, errors) {
var /** @type {?} */ existingReferences = [];
result.filter(function (element) { return !!((element)).references; })
.forEach(function (element) { return ((element)).references.forEach(function (reference) {
var /** @type {?} */ name = reference.name;
if (existingReferences.indexOf(name) < 0) {
existingReferences.push(name);
}
else {
var /** @type {?} */ error = new TemplateParseError("Reference \"#" + name + "\" is defined several times", reference.sourceSpan, ParseErrorLevel.ERROR);
errors.push(error);
}
}); });
};
return TemplateParser;
}());
TemplateParser.decorators = [
{ type: CompilerInjectable },
];
/**
* @nocollapse
*/
TemplateParser.ctorParameters = function () { return [
{ type: CompilerConfig, },
{ type: Parser, },
{ type: ElementSchemaRegistry, },
{ type: I18NHtmlParser, },
{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["_51" /* ɵConsole */], },
{ type: Array, decorators: [{ type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["q" /* Optional */] }, { type: __WEBPACK_IMPORTED_MODULE_0__angular_core__["i" /* Inject */], args: [TEMPLATE_TRANSFORMS,] },] },
]; };
var TemplateParseVisitor = (function () {
/**
* @param {?} config
* @param {?} providerViewContext
* @param {?} directives
* @param {?} _bindingParser
* @param {?} _schemaRegistry
* @param {?} _schemas
* @param {?} _targetErrors
*/
function TemplateParseVisitor(config, providerViewContext, directives, _bindingParser, _schemaRegistry, _schemas, _targetErrors) {
var _this = this;
this.config = config;
this.providerViewContext = providerViewContext;
this._bindingParser = _bindingParser;
this._schemaRegistry = _schemaRegistry;
this._schemas = _schemas;
this._targetErrors = _targetErrors;
this.selectorMatcher = new SelectorMatcher();
this.directivesIndex = new Map();
this.ngContentCount = 0;
// Note: queries start with id 1 so we can use the number in a Bloom filter!
this.contentQueryStartId = providerViewContext.component.viewQueries.length + 1;
directives.forEach(function (directive, index) {
var selector = CssSelector.parse(directive.selector);
_this.selectorMatcher.addSelectables(selector, directive);
_this.directivesIndex.set(directive, index);
});
}
/**
* @param {?} expansion
* @param {?} context
* @return {?}
*/
TemplateParseVisitor.prototype.visitExpansion = function (expansion, context) { return null; };
/**
* @param {?} expansionCase
* @param {?} context
* @return {?}
*/
TemplateParseVisitor.prototype.visitExpansionCase = function (expansionCase, context) { return null; };
/**
* @param {?} text
* @param {?} parent
* @return {?}
*/
TemplateParseVisitor.prototype.visitText = function (text, parent) {
var /** @type {?} */ ngContentIndex = ((parent.findNgContentIndex(TEXT_CSS_SELECTOR)));
var /** @type {?} */ expr = this._bindingParser.parseInterpolation(text.value, /** @type {?} */ ((text.sourceSpan)));
return expr ? new BoundTextAst(expr, ngContentIndex, /** @type {?} */ ((text.sourceSpan))) :
new TextAst(text.value, ngContentIndex, /** @type {?} */ ((text.sourceSpan)));
};
/**
* @param {?} attribute
* @param {?} context
* @return {?}
*/
TemplateParseVisitor.prototype.visitAttribute = function (attribute, context) {
return new AttrAst(attribute.name, attribute.value, attribute.sourceSpan);
};
/**
* @param {?} comment
* @param {?} context
* @return {?}
*/
TemplateParseVisitor.prototype.visitComment = function (comment, context) { return null; };
/**
* @param {?} element
* @param {?} parent
* @return {?}
*/
TemplateParseVisitor.prototype.visitElement = function (element, parent) {
var _this = this;
var /** @type {?} */ queryStartIndex = this.contentQueryStartId;
var /** @type {?} */ nodeName = element.name;
var /** @type {?} */ preparsedElement = preparseElement(element);
if (preparsedElement.type === PreparsedElementType.SCRIPT ||
preparsedElement.type === PreparsedElementType.STYLE) {
// Skipping
*/
var ndf1 = 0; ndf2 = 0; ndf = 0;
var lookup = {};
var ntc = {
init: function() {
var color, rgb, hsl;
for(var i = 0; i < ntc.names.length; i++)
{
color = "#" + ntc.names[i][0];
rgb = ntc.rgb(color);
hsl = ntc.hsl(color);
lookup[ntc.names[i][1]] = parseInt(ntc.names[i][0], 16);
ntc.names[i].push(rgb[0], rgb[1], rgb[2], hsl[0], hsl[1], hsl[2]);
}
},
value: function(name) {
return lookup[name];
},
name: function(color) {
color = color.toUpperCase();
if(color.length < 3 || color.length > 7)
return ["#000000", "Invalid Color: " + color, false];
if(color.length % 3 == 0)
color = "#" + color;
if(color.length == 4)
color = "#" + color.substr(1, 1) + color.substr(1, 1) + color.substr(2, 1) + color.substr(2, 1) + color.substr(3, 1) + color.substr(3, 1);
var rgb = ntc.rgb(color);
var r = rgb[0], g = rgb[1], b = rgb[2];
var hsl = ntc.hsl(color);
var h = hsl[0], s = hsl[1], l = hsl[2];
var cl = -1, df = -1;
for(var i = 0; i < ntc.names.length; i++)
{
if(color == "#" + ntc.names[i][0])
return ["#" + ntc.names[i][0], ntc.names[i][1], true];
ndf1 = Math.pow(r - ntc.names[i][2], 2) + Math.pow(g - ntc.names[i][3], 2) + Math.pow(b - ntc.names[i][4], 2);
ndf2 = Math.pow(h - ntc.names[i][5], 2) + Math.pow(s - ntc.names[i][6], 2) + Math.pow(l - ntc.names[i][7], 2);
ndf = ndf1 + ndf2 * 2;
if(df < 0 || df > ndf)
{
df = ndf;
cl = i;
}
}
return (cl < 0 ? ["#000000", "Invalid Color: " + color, false] : ["#" + ntc.names[cl][0], ntc.names[cl][1], false]);
},
// adopted from: Farbtastic 1.2
// http://acko.net/dev/farbtastic
hsl: function (color) {
var rgb = [parseInt('0x' + color.substring(1, 3)) / 255, parseInt('0x' + color.substring(3, 5)) / 255, parseInt('0x' + color.substring(5, 7)) / 255];
var min, max, delta, h, s, l;
var r = rgb[0], g = rgb[1], b = rgb[2];
min = Math.min(r, Math.min(g, b));
max = Math.max(r, Math.max(g, b));
delta = max - min;
l = (min + max) / 2;
s = 0;
if(l > 0 && l < 1)
s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
h = 0;
if(delta > 0)
{
if (max == r && max != g) h += (g - b) / delta;
if (max == g && max != b) h += (2 + (b - r) / delta);
if (max == b && max != r) h += (4 + (r - g) / delta);
h /= 6;
}
return [parseInt(h * 255), parseInt(s * 255), parseInt(l * 255)];
},
// adopted from: Farbtastic 1.2
// http://acko.net/dev/farbtastic
rgb: function(color) {
return [parseInt('0x' + color.substring(1, 3)), parseInt('0x' + color.substring(3, 5)), parseInt('0x' + color.substring(5, 7))];
},
names: [
["000000", "Black"],
["000080", "Navy Blue"],
["0000C8", "Dark Blue"],
["0000FF", "Blue"],
["000741", "Stratos"],
["001B1C", "Swamp"],
["002387", "Resolution Blue"],
["002900", "Deep Fir"],
["002E20", "Burnham"],
["002FA7", "International Klein Blue"],
["003153", "Prussian Blue"],
["003366", "Midnight Blue"],
["003399", "Smalt"],
["003532", "Deep Teal"],
["003E40", "Cyprus"],
["004620", "Kaitoke Green"],
["0047AB", "Cobalt"],
["004816", "Crusoe"],
["004950", "Sherpa Blue"],
["0056A7", "Endeavour"],
["00581A", "Camarone"],
["0066CC", "Science Blue"],
["0066FF", "Blue Ribbon"],
["00755E", "Tropical Rain Forest"],
["0076A3", "Allports"],
["007BA7", "Deep Cerulean"],
["007EC7", "Lochmara"],
["007FFF", "Azure Radiance"],
["008080", "Teal"],
["0095B6", "Bondi Blue"],
["009DC4", "Pacific Blue"],
["00A693", "Persian Green"],
["00A86B", "Jade"],
["00CC99", "Caribbean Green"],
["00CCCC", "Robin's Egg Blue"],
["00FF00", "Green"],
["00FF7F", "Spring Green"],
["00FFFF", "Cyan / Aqua"],
["010D1A", "Blue Charcoal"],
["011635", "Midnight"],
["011D13", "Holly"],
["012731", "Daintree"],
["01361C", "Cardin Green"],
["01371A", "County Green"],
["013E62", "Astronaut Blue"],
["013F6A", "Regal Blue"],
["014B43", "Aqua Deep"],
["015E85", "Orient"],
["016162", "Blue Stone"],
["016D39", "Fun Green"],
["01796F", "Pine Green"],
["017987", "Blue Lagoon"],
["01826B", "Deep Sea"],
["01A368", "Green Haze"],
["022D15", "English Holly"],
["02402C", "Sherwood Green"],
["02478E", "Congress Blue"],
["024E46", "Evening Sea"],
["026395", "Bahama Blue"],
["02866F", "Observatory"],
["02A4D3", "Cerulean"],
["03163C", "Tangaroa"],
["032B52", "Green Vogue"],
["036A6E", "Mosque"],
["041004", "Midnight Moss"],
["041322", "Black Pearl"],
["042E4C", "Blue Whale"],
["044022", "Zuccini"],
["044259", "Teal Blue"],
["051040", "Deep Cove"],
["051657", "Gulf Blue"],
["055989", "Venice Blue"],
["056F57", "Watercourse"],
["062A78", "Catalina Blue"],
["063537", "Tiber"],
["069B81", "Gossamer"],
["06A189", "Niagara"],
["073A50", "Tarawera"],
["080110", "Jaguar"],
["081910", "Black Bean"],
["082567", "Deep Sapphire"],
["088370", "Elf Green"],
["08E8DE", "Bright Turquoise"],
["092256", "Downriver"],
["09230F", "Palm Green"],
["09255D", "Madison"],
["093624", "Bottle Green"],
["095859", "Deep Sea Green"],
["097F4B", "Salem"],
["0A001C", "Black Russian"],
["0A480D", "Dark Fern"],
["0A6906", "Japanese Laurel"],
["0A6F75", "Atoll"],
["0B0B0B", "Cod Gray"],
["0B0F08", "Marshland"],
["0B1107", "Gordons Green"],
["0B1304", "Black Forest"],
["0B6207", "San Felix"],
["0BDA51", "Malachite"],
["0C0B1D", "Ebony"],
["0C0D0F", "Woodsmoke"],
["0C1911", "Racing Green"],
["0C7A79", "Surfie Green"],
["0C8990", "Blue Chill"],
["0D0332", "Black Rock"],
["0D1117", "Bunker"],
["0D1C19", "Aztec"],
["0D2E1C", "Bush"],
["0E0E18", "Cinder"],
["0E2A30", "Firefly"],
["0F2D9E", "Torea Bay"],
["10121D", "Vulcan"],
["101405", "Green Waterloo"],
["105852", "Eden"],
["110C6C", "Arapawa"],
["120A8F", "Ultramarine"],
["123447", "Elephant"],
["126B40", "Jewel"],
["130000", "Diesel"],
["130A06", "Asphalt"],
["13264D", "Blue Zodiac"],
["134F19", "Parsley"],
["140600", "Nero"],
["1450AA", "Tory Blue"],
["151F4C", "Bunting"],
["1560BD", "Denim"],
["15736B", "Genoa"],
["161928", "Mirage"],
["161D10", "Hunter Green"],
["162A40", "Big Stone"],
["163222", "Celtic"],
["16322C", "Timber Green"],
["163531", "Gable Green"],
["171F04", "Pine Tree"],
["175579", "Chathams Blue"],
["182D09", "Deep Forest Green"],
["18587A", "Blumine"],
["19330E", "Palm Leaf"],
["193751", "Nile Blue"],
["1959A8", "Fun Blue"],
["1A1A68", "Lucky Point"],
["1AB385", "Mountain Meadow"],
["1B0245", "Tolopea"],
["1B1035", "Haiti"],
["1B127B", "Deep Koamaru"],
["1B1404", "Acadia"],
["1B2F11", "Seaweed"],
["1B3162", "Biscay"],
["1B659D", "Matisse"],
["1C1208", "Crowshead"],
["1C1E13", "Rangoon Green"],
["1C39BB", "Persian Blue"],
["1C402E", "Everglade"],
["1C7C7D", "Elm"],
["1D6142", "Green Pea"],
["1E0F04", "Creole"],
["1E1609", "Karaka"],
["1E1708", "El Paso"],
["1E385B", "Cello"],
["1E433C", "Te Papa Green"],
["1E90FF", "Dodger Blue"],
["1E9AB0", "Eastern Blue"],
["1F120F", "Night Rider"],
["1FC2C2", "Java"],
["20208D", "Jacksons Purple"],
["202E54", "Cloud Burst"],
["204852", "Blue Dianne"],
["211A0E", "Eternity"],
["220878", "Deep Blue"],
["228B22", "Forest Green"],
["233418", "Mallard"],
["240A40", "Violet"],
["240C02", "Kilamanjaro"],
["242A1D", "Log Cabin"],
["242E16", "Black Olive"],
["24500F", "Green House"],
["251607", "Graphite"],
["251706", "Cannon Black"],
["251F4F", "Port Gore"],
["25272C", "Shark"],
["25311C", "Green Kelp"],
["2596D1", "Curious Blue"],
["260368", "Paua"],
["26056A", "Paris M"],
["261105", "Wood Bark"],
["261414", "Gondola"],
["262335", "Steel Gray"],
["26283B", "Ebony Clay"],
["273A81", "Bay of Many"],
["27504B", "Plantation"],
["278A5B", "Eucalyptus"],
["281E15", "Oil"],
["283A77", "Astronaut"],
["286ACD", "Mariner"],
["290C5E", "Violent Violet"],
["292130", "Bastille"],
["292319", "Zeus"],
["292937", "Charade"],
["297B9A", "Jelly Bean"],
["29AB87", "Jungle Green"],
["2A0359", "Cherry Pie"],
["2A140E", "Coffee Bean"],
["2A2630", "Baltic Sea"],
["2A380B", "Turtle Green"],
["2A52BE", "Cerulean Blue"],
["2B0202", "Sepia Black"],
["2B194F", "Valhalla"],
["2B3228", "Heavy Metal"],
["2C0E8C", "Blue Gem"],
["2C1632", "Revolver"],
["2C2133", "Bleached Cedar"],
["2C8C84", "Lochinvar"],
["2D2510", "Mikado"],
["2D383A", "Outer Space"],
["2D569B", "St Tropaz"],
["2E0329", "Jacaranda"],
["2E1905", "Jacko Bean"],
["2E3222", "Rangitoto"],
["2E3F62", "Rhino"],
["2E8B57", "Sea Green"],
["2EBFD4", "Scooter"],
["2F270E", "Onion"],
["2F3CB3", "Governor Bay"],
["2F519E", "Sapphire"],
["2F5A57", "Spectra"],
["2F6168", "Casal"],
["300529", "Melanzane"],
["301F1E", "Cocoa Brown"],
["302A0F", "Woodrush"],
["304B6A", "San Juan"],
["30D5C8", "Turquoise"],
["311C17", "Eclipse"],
["314459", "Pickled Bluewood"],
["315BA1", "Azure"],
["31728D", "Calypso"],
["317D82", "Paradiso"],
["32127A", "Persian Indigo"],
["32293A", "Blackcurrant"],
["323232", "Mine Shaft"],
["325D52", "Stromboli"],
["327C14", "Bilbao"],
["327DA0", "Astral"],
["33036B", "Christalle"],
["33292F", "Thunder"],
["33CC99", "Shamrock"],
["341515", "Tamarind"],
["350036", "Mardi Gras"],
["350E42", "Valentino"],
["350E57", "Jagger"],
["353542", "Tuna"],
["354E8C", "Chambray"],
["363050", "Martinique"],
["363534", "Tuatara"],
["363C0D", "Waiouru"],
["36747D", "Ming"],
["368716", "La Palma"],
["370202", "Chocolate"],
["371D09", "Clinker"],
["37290E", "Brown Tumbleweed"],
["373021", "Birch"],
["377475", "Oracle"],
["380474", "Blue Diamond"],
["381A51", "Grape"],
["383533", "Dune"],
["384555", "Oxford Blue"],
["384910", "Clover"],
["394851", "Limed Spruce"],
["396413", "Dell"],
["3A0020", "Toledo"],
["3A2010", "Sambuca"],
["3A2A6A", "Jacarta"],
["3A686C", "William"],
["3A6A47", "Killarney"],
["3AB09E", "Keppel"],
["3B000B", "Temptress"],
["3B0910", "Aubergine"],
["3B1F1F", "Jon"],
["3B2820", "Treehouse"],
["3B7A57", "Amazon"],
["3B91B4", "Boston Blue"],
["3C0878", "Windsor"],
["3C1206", "Rebel"],
["3C1F76", "Meteorite"],
["3C2005", "Dark Ebony"],
["3C3910", "Camouflage"],
["3C4151", "Bright Gray"],
["3C4443", "Cape Cod"],
["3C493A", "Lunar Green"],
["3D0C02", "Bean "],
["3D2B1F", "Bistre"],
["3D7D52", "Goblin"],
["3E0480", "Kingfisher Daisy"],
["3E1C14", "Cedar"],
["3E2B23", "English Walnut"],
["3E2C1C", "Black Marlin"],
["3E3A44", "Ship Gray"],
["3EABBF", "Pelorous"],
["3F2109", "Bronze"],
["3F2500", "Cola"],
["3F3002", "Madras"],
["3F307F", "Minsk"],
["3F4C3A", "Cabbage Pont"],
["3F583B", "Tom Thumb"],
["3F5D53", "Mineral Green"],
["3FC1AA", "Puerto Rico"],
["3FFF00", "Harlequin"],
["401801", "Brown Pod"],
["40291D", "Cork"],
["403B38", "Masala"],
["403D19", "Thatch Green"],
["405169", "Fiord"],
["40826D", "Viridian"],
["40A860", "Chateau Green"],
["410056", "Ripe Plum"],
["411F10", "Paco"],
["412010", "Deep Oak"],
["413C37", "Merlin"],
["414257", "Gun Powder"],
["414C7D", "East Bay"],
["4169E1", "Royal Blue"],
["41AA78", "Ocean Green"],
["420303", "Burnt Maroon"],
["423921", "Lisbon Brown"],
["427977", "Faded Jade"],
["431560", "Scarlet Gum"],
["433120", "Iroko"],
["433E37", "Armadillo"],
["434C59", "River Bed"],
["436A0D", "Green Leaf"],
["44012D", "Barossa"],
["441D00", "Morocco Brown"],
["444954", "Mako"],
["454936", "Kelp"],
["456CAC", "San Marino"],
["45B1E8", "Picton Blue"],
["460B41", "Loulou"],
["462425", "Crater Brown"],
["465945", "Gray Asparagus"],
["4682B4", "Steel Blue"],
["480404", "Rustic Red"],
["480607", "Bulgarian Rose"],
["480656", "Clairvoyant"],
["481C1C", "Cocoa Bean"],
["483131", "Woody Brown"],
["483C32", "Taupe"],
["49170C", "Van Cleef"],
["492615", "Brown Derby"],
["49371B", "Metallic Bronze"],
["495400", "Verdun Green"],
["496679", "Blue Bayoux"],
["497183", "Bismark"],
["4A2A04", "Bracken"],
["4A3004", "Deep Bronze"],
["4A3C30", "Mondo"],
["4A4244", "Tundora"],
["4A444B", "Gravel"],
["4A4E5A", "Trout"],
["4B0082", "Pigment Indigo"],
["4B5D52", "Nandor"],
["4C3024", "Saddle"],
["4C4F56", "Abbey"],
["4D0135", "Blackberry"],
["4D0A18", "Cab Sav"],
["4D1E01", "Indian Tan"],
["4D282D", "Cowboy"],
["4D282E", "Livid Brown"],
["4D3833", "Rock"],
["4D3D14", "Punga"],
["4D400F", "Bronzetone"],
["4D5328", "Woodland"],
["4E0606", "Mahogany"],
["4E2A5A", "Bossanova"],
["4E3B41", "Matterhorn"],
["4E420C", "Bronze Olive"],
["4E4562", "Mulled Wine"],
["4E6649", "Axolotl"],
["4E7F9E", "Wedgewood"],
["4EABD1", "Shakespeare"],
["4F1C70", "Honey Flower"],
["4F2398", "Daisy Bush"],
["4F69C6", "Indigo"],
["4F7942", "Fern Green"],
["4F9D5D", "Fruit Salad"],
["4FA83D", "Apple"],
["504351", "Mortar"],
["507096", "Kashmir Blue"],
["507672", "Cutty Sark"],
["50C878", "Emerald"],
["514649", "Emperor"],
["516E3D", "Chalet Green"],
["517C66", "Como"],
["51808F", "Smalt Blue"],
["52001F", "Castro"],
["520C17", "Maroon Oak"],
["523C94", "Gigas"],
["533455", "Voodoo"],
["534491", "Victoria"],
["53824B", "Hippie Green"],
["541012", "Heath"],
["544333", "Judge Gray"],
["54534D", "Fuscous Gray"],
["549019", "Vida Loca"],
["55280C", "Cioccolato"],
["555B10", "Saratoga"],
["556D56", "Finlandia"],
["5590D9", "Havelock Blue"],
["56B4BE", "Fountain Blue"],
["578363", "Spring Leaves"],
["583401", "Saddle Brown"],
["585562", "Scarpa Flow"],
["587156", "Cactus"],
["589AAF", "Hippie Blue"],
["591D35", "Wine Berry"],
["592804", "Brown Bramble"],
["593737", "Congo Brown"],
["594433", "Millbrook"],
["5A6E9C", "Waikawa Gray"],
["5A87A0", "Horizon"],
["5B3013", "Jambalaya"],
["5C0120", "Bordeaux"],
["5C0536", "Mulberry Wood"],
["5C2E01", "Carnaby Tan"],
["5C5D75", "Comet"],
["5D1E0F", "Redwood"],
["5D4C51", "Don Juan"],
["5D5C58", "Chicago"],
["5D5E37", "Verdigris"],
["5D7747", "Dingley"],
["5DA19F", "Breaker Bay"],
["5E483E", "Kabul"],
["5E5D3B", "Hemlock"],
["5F3D26", "Irish Coffee"],
["5F5F6E", "Mid Gray"],
["5F6672", "Shuttle Gray"],
["5FA777", "Aqua Forest"],
["5FB3AC", "Tradewind"],
["604913", "Horses Neck"],
["605B73", "Smoky"],
["606E68", "Corduroy"],
["6093D1", "Danube"],
["612718", "Espresso"],
["614051", "Eggplant"],
["615D30", "Costa Del Sol"],
["61845F", "Glade Green"],
["622F30", "Buccaneer"],
["623F2D", "Quincy"],
["624E9A", "Butterfly Bush"],
["625119", "West Coast"],
["626649", "Finch"],
["639A8F", "Patina"],
["63B76C", "Fern"],
["6456B7", "Blue Violet"],
["646077", "Dolphin"],
["646463", "Storm Dust"],
["646A54", "Siam"],
["646E75", "Nevada"],
["6495ED", "Cornflower Blue"],
["64CCDB", "Viking"],
["65000B", "Rosewood"],
["651A14", "Cherrywood"],
["652DC1", "Purple Heart"],
["657220", "Fern Frond"],
["65745D", "Willow Grove"],
["65869F", "Hoki"],
["660045", "Pompadour"],
["660099", "Purple"],
["66023C", "Tyrian Purple"],
["661010", "Dark Tan"],
["66B58F", "Silver Tree"],
["66FF00", "Bright Green"],
["66FF66", "Screamin' Green"],
["67032D", "Black Rose"],
["675FA6", "Scampi"],
["676662", "Ironside Gray"],
["678975", "Viridian Green"],
["67A712", "Christi"],
["683600", "Nutmeg Wood Finish"],
["685558", "Zambezi"],
["685E6E", "Salt Box"],
["692545", "Tawny Port"],
["692D54", "Finn"],
["695F62", "Scorpion"],
["697E9A", "Lynch"],
["6A442E", "Spice"],
["6A5D1B", "Himalaya"],
["6A6051", "Soya Bean"],
["6B2A14", "Hairy Heath"],
["6B3FA0", "Royal Purple"],
["6B4E31", "Shingle Fawn"],
["6B5755", "Dorado"],
["6B8BA2", "Bermuda Gray"],
["6B8E23", "Olive Drab"],
["6C3082", "Eminence"],
["6CDAE7", "Turquoise Blue"],
["6D0101", "Lonestar"],
["6D5E54", "Pine Cone"],
["6D6C6C", "Dove Gray"],
["6D9292", "Juniper"],
["6D92A1", "Gothic"],
["6E0902", "Red Oxide"],
["6E1D14", "Moccaccino"],
["6E4826", "Pickled Bean"],
["6E4B26", "Dallas"],
["6E6D57", "Kokoda"],
["6E7783", "Pale Sky"],
["6F440C", "Cafe Royale"],
["6F6A61", "Flint"],
["6F8E63", "Highland"],
["6F9D02", "Limeade"],
["6FD0C5", "Downy"],
["701C1C", "Persian Plum"],
["704214", "Sepia"],
["704A07", "Antique Bronze"],
["704F50", "Ferra"],
["706555", "Coffee"],
["708090", "Slate Gray"],
["711A00", "Cedar Wood Finish"],
["71291D", "Metallic Copper"],
["714693", "Affair"],
["714AB2", "Studio"],
["715D47", "Tobacco Brown"],
["716338", "Yellow Metal"],
["716B56", "Peat"],
["716E10", "Olivetone"],
["717486", "Storm Gray"],
["718080", "Sirocco"],
["71D9E2", "Aquamarine Blue"],
["72010F", "Venetian Red"],
["724A2F", "Old Copper"],
["726D4E", "Go Ben"],
["727B89", "Raven"],
["731E8F", "Seance"],
["734A12", "Raw Umber"],
["736C9F", "Kimberly"],
["736D58", "Crocodile"],
["737829", "Crete"],
["738678", "Xanadu"],
["74640D", "Spicy Mustard"],
["747D63", "Limed Ash"],
["747D83", "Rolling Stone"],
["748881", "Blue Smoke"],
["749378", "Laurel"],
["74C365", "Mantis"],
["755A57", "Russett"],
["7563A8", "Deluge"],
["76395D", "Cosmic"],
["7666C6", "Blue Marguerite"],
["76BD17", "Lima"],
["76D7EA", "Sky Blue"],
["770F05", "Dark Burgundy"],
["771F1F", "Crown of Thorns"],
["773F1A", "Walnut"],
["776F61", "Pablo"],
["778120", "Pacifika"],
["779E86", "Oxley"],
["77DD77", "Pastel Green"],
["780109", "Japanese Maple"],
["782D19", "Mocha"],
["782F16", "Peanut"],
["78866B", "Camouflage Green"],
["788A25", "Wasabi"],
["788BBA", "Ship Cove"],
["78A39C", "Sea Nymph"],
["795D4C", "Roman Coffee"],
["796878", "Old Lavender"],
["796989", "Rum"],
["796A78", "Fedora"],
["796D62", "Sandstone"],
["79DEEC", "Spray"],
["7A013A", "Siren"],
["7A58C1", "Fuchsia Blue"],
["7A7A7A", "Boulder"],
["7A89B8", "Wild Blue Yonder"],
["7AC488", "De York"],
["7B3801", "Red Beech"],
["7B3F00", "Cinnamon"],
["7B6608", "Yukon Gold"],
["7B7874", "Tapa"],
["7B7C94", "Waterloo "],
["7B8265", "Flax Smoke"],
["7B9F80", "Amulet"],
["7BA05B", "Asparagus"],
["7C1C05", "Kenyan Copper"],
["7C7631", "Pesto"],
["7C778A", "Topaz"],
["7C7B7A", "Concord"],
["7C7B82", "Jumbo"],
["7C881A", "Trendy Green"],
["7CA1A6", "Gumbo"],
["7CB0A1", "Acapulco"],
["7CB7BB", "Neptune"],
["7D2C14", "Pueblo"],
["7DA98D", "Bay Leaf"],
["7DC8F7", "Malibu"],
["7DD8C6", "Bermuda"],
["7E3A15", "Copper Canyon"],
["7F1734", "Claret"],
["7F3A02", "Peru Tan"],
["7F626D", "Falcon"],
["7F7589", "Mobster"],
["7F76D3", "Moody Blue"],
["7FFF00", "Chartreuse"],
["7FFFD4", "Aquamarine"],
["800000", "Maroon"],
["800B47", "Rose Bud Cherry"],
["801818", "Falu Red"],
["80341F", "Red Robin"],
["803790", "Vivid Violet"],
["80461B", "Russet"],
["807E79", "Friar Gray"],
["808000", "Olive"],
["808080", "Gray"],
["80B3AE", "Gulf Stream"],
["80B3C4", "Glacier"],
["80CCEA", "Seagull"],
["81422C", "Nutmeg"],
["816E71", "Spicy Pink"],
["817377", "Empress"],
["819885", "Spanish Green"],
["826F65", "Sand Dune"],
["828685", "Gunsmoke"],
["828F72", "Battleship Gray"],
["831923", "Merlot"],
["837050", "Shadow"],
["83AA5D", "Chelsea Cucumber"],
["83D0C6", "Monte Carlo"],
["843179", "Plum"],
["84A0A0", "Granny Smith"],
["8581D9", "Chetwode Blue"],
["858470", "Bandicoot"],
["859FAF", "Bali Hai"],
["85C4CC", "Half Baked"],
["860111", "Red Devil"],
["863C3C", "Lotus"],
["86483C", "Ironstone"],
["864D1E", "Bull Shot"],
["86560A", "Rusty Nail"],
["868974", "Bitter"],
["86949F", "Regent Gray"],
["871550", "Disco"],
["87756E", "Americano"],
["877C7B", "Hurricane"],
["878D91", "Oslo Gray"],
["87AB39", "Sushi"],
["885342", "Spicy Mix"],
["886221", "Kumera"],
["888387", "Suva Gray"],
["888D65", "Avocado"],
["893456", "Camelot"],
["893843", "Solid Pink"],
["894367", "Cannon Pink"],
["897D6D", "Makara"],
["8A3324", "Burnt Umber"],
["8A73D6", "True V"],
["8A8360", "Clay Creek"],
["8A8389", "Monsoon"],
["8A8F8A", "Stack"],
["8AB9F1", "Jordy Blue"],
["8B00FF", "Electric Violet"],
["8B0723", "Monarch"],
["8B6B0B", "Corn Harvest"],
["8B8470", "Olive Haze"],
["8B847E", "Schooner"],
["8B8680", "Natural Gray"],
["8B9C90", "Mantle"],
["8B9FEE", "Portage"],
["8BA690", "Envy"],
["8BA9A5", "Cascade"],
["8BE6D8", "Riptide"],
["8C055E", "Cardinal Pink"],
["8C472F", "Mule Fawn"],
["8C5738", "Potters Clay"],
["8C6495", "Trendy Pink"],
["8D0226", "Paprika"],
["8D3D38", "Sanguine Brown"],
["8D3F3F", "Tosca"],
["8D7662", "Cement"],
["8D8974", "Granite Green"],
["8D90A1", "Manatee"],
["8DA8CC", "Polo Blue"],
["8E0000", "Red Berry"],
["8E4D1E", "Rope"],
["8E6F70", "Opium"],
["8E775E", "Domino"],
["8E8190", "Mamba"],
["8EABC1", "Nepal"],
["8F021C", "Pohutukawa"],
["8F3E33", "El Salva"],
["8F4B0E", "Korma"],
["8F8176", "Squirrel"],
["8FD6B4", "Vista Blue"],
["900020", "Burgundy"],
["901E1E", "Old Brick"],
["907874", "Hemp"],
["907B71", "Almond Frost"],
["908D39", "Sycamore"],
["92000A", "Sangria"],
["924321", "Cumin"],
["926F5B", "Beaver"],
["928573", "Stonewall"],
["928590", "Venus"],
["9370DB", "Medium Purple"],
["93CCEA", "Cornflower"],
["93DFB8", "Algae Green"],
["944747", "Copper Rust"],
["948771", "Arrowtown"],
["950015", "Scarlett"],
["956387", "Strikemaster"],
["959396", "Mountain Mist"],
["960018", "Carmine"],
["964B00", "Brown"],
["967059", "Leather"],
["9678B6", "Purple Mountain's Majesty"],
["967BB6", "Lavender Purple"],
["96A8A1", "Pewter"],
["96BBAB", "Summer Green"],
["97605D", "Au Chico"],
["9771B5", "Wisteria"],
["97CD2D", "Atlantis"],
["983D61", "Vin Rouge"],
["9874D3", "Lilac Bush"],
["98777B", "Bazaar"],
["98811B", "Hacienda"],
["988D77", "Pale Oyster"],
["98FF98", "Mint Green"],
["990066", "Fresh Eggplant"],
["991199", "Violet Eggplant"],
["991613", "Tamarillo"],
["991B07", "Totem Pole"],
["996666", "Copper Rose"],
["9966CC", "Amethyst"],
["997A8D", "Mountbatten Pink"],
["9999CC", "Blue Bell"],
["9A3820", "Prairie Sand"],
["9A6E61", "Toast"],
["9A9577", "Gurkha"],
["9AB973", "Olivine"],
["9AC2B8", "Shadow Green"],
["9B4703", "Oregon"],
["9B9E8F", "Lemon Grass"],
["9C3336", "Stiletto"],
["9D5616", "Hawaiian Tan"],
["9DACB7", "Gull Gray"],
["9DC209", "Pistachio"],
["9DE093", "Granny Smith Apple"],
["9DE5FF", "Anakiwa"],
["9E5302", "Chelsea Gem"],
["9E5B40", "Sepia Skin"],
["9EA587", "Sage"],
["9EA91F", "Citron"],
["9EB1CD", "Rock Blue"],
["9EDEE0", "Morning Glory"],
["9F381D", "Cognac"],
["9F821C", "Reef Gold"],
["9F9F9C", "Star Dust"],
["9FA0B1", "Santas Gray"],
["9FD7D3", "Sinbad"],
["9FDD8C", "Feijoa"],
["A02712", "Tabasco"],
["A1750D", "Buttered Rum"],
["A1ADB5", "Hit Gray"],
["A1C50A", "Citrus"],
["A1DAD7", "Aqua Island"],
["A1E9DE", "Water Leaf"],
["A2006D", "Flirt"],
["A23B6C", "Rouge"],
["A26645", "Cape Palliser"],
["A2AAB3", "Gray Chateau"],
["A2AEAB", "Edward"],
["A3807B", "Pharlap"],
["A397B4", "Amethyst Smoke"],
["A3E3ED", "Blizzard Blue"],
["A4A49D", "Delta"],
["A4A6D3", "Wistful"],
["A4AF6E", "Green Smoke"],
["A50B5E", "Jazzberry Jam"],
["A59B91", "Zorba"],
["A5CB0C", "Bahia"],
["A62F20", "Roof Terracotta"],
["A65529", "Paarl"],
["A68B5B", "Barley Corn"],
["A69279", "Donkey Brown"],
["A6A29A", "Dawn"],
["A72525", "Mexican Red"],
["A7882C", "Luxor Gold"],
["A85307", "Rich Gold"],
["A86515", "Reno Sand"],
["A86B6B", "Coral Tree"],
["A8989B", "Dusty Gray"],
["A899E6", "Dull Lavender"],
["A8A589", "Tallow"],
["A8AE9C", "Bud"],
["A8AF8E", "Locust"],
["A8BD9F", "Norway"],
["A8E3BD", "Chinook"],
["A9A491", "Gray Olive"],
["A9ACB6", "Aluminium"],
["A9B2C3", "Cadet Blue"],
["A9B497", "Schist"],
["A9BDBF", "Tower Gray"],
["A9BEF2", "Perano"],
["A9C6C2", "Opal"],
["AA375A", "Night Shadz"],
["AA4203", "Fire"],
["AA8B5B", "Muesli"],
["AA8D6F", "Sandal"],
["AAA5A9", "Shady Lady"],
["AAA9CD", "Logan"],
["AAABB7", "Spun Pearl"],
["AAD6E6", "Regent St Blue"],
["AAF0D1", "Magic Mint"],
["AB0563", "Lipstick"],
["AB3472", "Royal Heath"],
["AB917A", "Sandrift"],
["ABA0D9", "Cold Purple"],
["ABA196", "Bronco"],
["AC8A56", "Limed Oak"],
["AC91CE", "East Side"],
["AC9E22", "Lemon Ginger"],
["ACA494", "Napa"],
["ACA586", "Hillary"],
["ACA59F", "Cloudy"],
["ACACAC", "Silver Chalice"],
["ACB78E", "Swamp Green"],
["ACCBB1", "Spring Rain"],
["ACDD4D", "Conifer"],
["ACE1AF", "Celadon"],
["AD781B", "Mandalay"],
["ADBED1", "Casper"],
["ADDFAD", "Moss Green"],
["ADE6C4", "Padua"],
["ADFF2F", "Green Yellow"],
["AE4560", "Hippie Pink"],
["AE6020", "Desert"],
["AE809E", "Bouquet"],
["AF4035", "Medium Carmine"],
["AF4D43", "Apple Blossom"],
["AF593E", "Brown Rust"],
["AF8751", "Driftwood"],
["AF8F2C", "Alpine"],
["AF9F1C", "Lucky"],
["AFA09E", "Martini"],
["AFB1B8", "Bombay"],
["AFBDD9", "Pigeon Post"],
["B04C6A", "Cadillac"],
["B05D54", "Matrix"],
["B05E81", "Tapestry"],
["B06608", "Mai Tai"],
["B09A95", "Del Rio"],
["B0E0E6", "Powder Blue"],
["B0E313", "Inch Worm"],
["B10000", "Bright Red"],
["B14A0B", "Vesuvius"],
["B1610B", "Pumpkin Skin"],
["B16D52", "Santa Fe"],
["B19461", "Teak"],
["B1E2C1", "Fringy Flower"],
["B1F4E7", "Ice Cold"],
["B20931", "Shiraz"],
["B2A1EA", "Biloba Flower"],
["B32D29", "Tall Poppy"],
["B35213", "Fiery Orange"],
["B38007", "Hot Toddy"],
["B3AF95", "Taupe Gray"],
["B3C110", "La Rioja"],
["B43332", "Well Read"],
["B44668", "Blush"],
["B4CFD3", "Jungle Mist"],
["B57281", "Turkish Rose"],
["B57EDC", "Lavender"],
["B5A27F", "Mongoose"],
["B5B35C", "Olive Green"],
["B5D2CE", "Jet Stream"],
["B5ECDF", "Cruise"],
["B6316C", "Hibiscus"],
["B69D98", "Thatch"],
["B6B095", "Heathered Gray"],
["B6BAA4", "Eagle"],
["B6D1EA", "Spindle"],
["B6D3BF", "Gum Leaf"],
["B7410E", "Rust"],
["B78E5C", "Muddy Waters"],
["B7A214", "Sahara"],
["B7A458", "Husk"],
["B7B1B1", "Nobel"],
["B7C3D0", "Heather"],
["B7F0BE", "Madang"],
["B81104", "Milano Red"],
["B87333", "Copper"],
["B8B56A", "Gimblet"],
["B8C1B1", "Green Spring"],
["B8C25D", "Celery"],
["B8E0F9", "Sail"],
["B94E48", "Chestnut"],
["B95140", "Crail"],
["B98D28", "Marigold"],
["B9C46A", "Wild Willow"],
["B9C8AC", "Rainee"],
["BA0101", "Guardsman Red"],
["BA450C", "Rock Spray"],
["BA6F1E", "Bourbon"],
["BA7F03", "Pirate Gold"],
["BAB1A2", "Nomad"],
["BAC7C9", "Submarine"],
["BAEEF9", "Charlotte"],
["BB3385", "Medium Red Violet"],
["BB8983", "Brandy Rose"],
["BBD009", "Rio Grande"],
["BBD7C1", "Surf"],
["BCC9C2", "Powder Ash"],
["BD5E2E", "Tuscany"],
["BD978E", "Quicksand"],
["BDB1A8", "Silk"],
["BDB2A1", "Malta"],
["BDB3C7", "Chatelle"],
["BDBBD7", "Lavender Gray"],
["BDBDC6", "French Gray"],
["BDC8B3", "Clay Ash"],
["BDC9CE", "Loblolly"],
["BDEDFD", "French Pass"],
["BEA6C3", "London Hue"],
["BEB5B7", "Pink Swan"],
["BEDE0D", "Fuego"],
["BF5500", "Rose of Sharon"],
["BFB8B0", "Tide"],
["BFBED8", "Blue Haze"],
["BFC1C2", "Silver Sand"],
["BFC921", "Key Lime Pie"],
["BFDBE2", "Ziggurat"],
["BFFF00", "Lime"],
["C02B18", "Thunderbird"],
["C04737", "Mojo"],
["C08081", "Old Rose"],
["C0C0C0", "Silver"],
["C0D3B9", "Pale Leaf"],
["C0D8B6", "Pixie Green"],
["C1440E", "Tia Maria"],
["C154C1", "Fuchsia Pink"],
["C1A004", "Buddha Gold"],
["C1B7A4", "Bison Hide"],
["C1BAB0", "Tea"],
["C1BECD", "Gray Suit"],
["C1D7B0", "Sprout"],
["C1F07C", "Sulu"],
["C26B03", "Indochine"],
["C2955D", "Twine"],
["C2BDB6", "Cotton Seed"],
["C2CAC4", "Pumice"],
["C2E8E5", "Jagged Ice"],
["C32148", "Maroon Flush"],
["C3B091", "Indian Khaki"],
["C3BFC1", "Pale Slate"],
["C3C3BD", "Gray Nickel"],
["C3CDE6", "Periwinkle Gray"],
["C3D1D1", "Tiara"],
["C3DDF9", "Tropical Blue"],
["C41E3A", "Cardinal"],
["C45655", "Fuzzy Wuzzy Brown"],
["C45719", "Orange Roughy"],
["C4C4BC", "Mist Gray"],
["C4D0B0", "Coriander"],
["C4F4EB", "Mint Tulip"],
["C54B8C", "Mulberry"],
["C59922", "Nugget"],
["C5994B", "Tussock"],
["C5DBCA", "Sea Mist"],
["C5E17A", "Yellow Green"],
["C62D42", "Brick Red"],
["C6726B", "Contessa"],
["C69191", "Oriental Pink"],
["C6A84B", "Roti"],
["C6C3B5", "Ash"],
["C6C8BD", "Kangaroo"],
["C6E610", "Las Palmas"],
["C7031E", "Monza"],
["C71585", "Red Violet"],
["C7BCA2", "Coral Reef"],
["C7C1FF", "Melrose"],
["C7C4BF", "Cloud"],
["C7C9D5", "Ghost"],
["C7CD90", "Pine Glade"],
["C7DDE5", "Botticelli"],
["C88A65", "Antique Brass"],
["C8A2C8", "Lilac"],
["C8A528", "Hokey Pokey"],
["C8AABF", "Lily"],
["C8B568", "Laser"],
["C8E3D7", "Edgewater"],
["C96323", "Piper"],
["C99415", "Pizza"],
["C9A0DC", "Light Wisteria"],
["C9B29B", "Rodeo Dust"],
["C9B35B", "Sundance"],
["C9B93B", "Earls Green"],
["C9C0BB", "Silver Rust"],
["C9D9D2", "Conch"],
["C9FFA2", "Reef"],
["C9FFE5", "Aero Blue"],
["CA3435", "Flush Mahogany"],
["CABB48", "Turmeric"],
["CADCD4", "Paris White"],
["CAE00D", "Bitter Lemon"],
["CAE6DA", "Skeptic"],
["CB8FA9", "Viola"],
["CBCAB6", "Foggy Gray"],
["CBD3B0", "Green Mist"],
["CBDBD6", "Nebula"],
["CC3333", "Persian Red"],
["CC5500", "Burnt Orange"],
["CC7722", "Ochre"],
["CC8899", "Puce"],
["CCCAA8", "Thistle Green"],
["CCCCFF", "Periwinkle"],
["CCFF00", "Electric Lime"],
["CD5700", "Tenn"],
["CD5C5C", "Chestnut Rose"],
["CD8429", "Brandy Punch"],
["CDF4FF", "Onahau"],
["CEB98F", "Sorrell Brown"],
["CEBABA", "Cold Turkey"],
["CEC291", "Yuma"],
["CEC7A7", "Chino"],
["CFA39D", "Eunry"],
["CFB53B", "Old Gold"],
["CFDCCF", "Tasman"],
["CFE5D2", "Surf Crest"],
["CFF9F3", "Humming Bird"],
["CFFAF4", "Scandal"],
["D05F04", "Red Stage"],
["D06DA1", "Hopbush"],
["D07D12", "Meteor"],
["D0BEF8", "Perfume"],
["D0C0E5", "Prelude"],
["D0F0C0", "Tea Green"],
["D18F1B", "Geebung"],
["D1BEA8", "Vanilla"],
["D1C6B4", "Soft Amber"],
["D1D2CA", "Celeste"],
["D1D2DD", "Mischka"],
["D1E231", "Pear"],
["D2691E", "Hot Cinnamon"],
["D27D46", "Raw Sienna"],
["D29EAA", "Careys Pink"],
["D2B48C", "Tan"],
["D2DA97", "Deco"],
["D2F6DE", "Blue Romance"],
["D2F8B0", "Gossip"],
["D3CBBA", "Sisal"],
["D3CDC5", "Swirl"],
["D47494", "Charm"],
["D4B6AF", "Clam Shell"],
["D4BF8D", "Straw"],
["D4C4A8", "Akaroa"],
["D4CD16", "Bird Flower"],
["D4D7D9", "Iron"],
["D4DFE2", "Geyser"],
["D4E2FC", "Hawkes Blue"],
["D54600", "Grenadier"],
["D591A4", "Can Can"],
["D59A6F", "Whiskey"],
["D5D195", "Winter Hazel"],
["D5F6E3", "Granny Apple"],
["D69188", "My Pink"],
["D6C562", "Tacha"],
["D6CEF6", "Moon Raker"],
["D6D6D1", "Quill Gray"],
["D6FFDB", "Snowy Mint"],
["D7837F", "New York Pink"],
["D7C498", "Pavlova"],
["D7D0FF", "Fog"],
["D84437", "Valencia"],
["D87C63", "Japonica"],
["D8BFD8", "Thistle"],
["D8C2D5", "Maverick"],
["D8FCFA", "Foam"],
["D94972", "Cabaret"],
["D99376", "Burning Sand"],
["D9B99B", "Cameo"],
["D9D6CF", "Timberwolf"],
["D9DCC1", "Tana"],
["D9E4F5", "Link Water"],
["D9F7FF", "Mabel"],
["DA3287", "Cerise"],
["DA5B38", "Flame Pea"],
["DA6304", "Bamboo"],
["DA6A41", "Red Damask"],
["DA70D6", "Orchid"],
["DA8A67", "Copperfield"],
["DAA520", "Golden Grass"],
["DAECD6", "Zanah"],
["DAF4F0", "Iceberg"],
["DAFAFF", "Oyster Bay"],
["DB5079", "Cranberry"],
["DB9690", "Petite Orchid"],
["DB995E", "Di Serria"],
["DBDBDB", "Alto"],
["DBFFF8", "Frosted Mint"],
["DC143C", "Crimson"],
["DC4333", "Punch"],
["DCB20C", "Galliano"],
["DCB4BC", "Blossom"],
["DCD747", "Wattle"],
["DCD9D2", "Westar"],
["DCDDCC", "Moon Mist"],
["DCEDB4", "Caper"],
["DCF0EA", "Swans Down"],
["DDD6D5", "Swiss Coffee"],
["DDF9F1", "White Ice"],
["DE3163", "Cerise Red"],
["DE6360", "Roman"],
["DEA681", "Tumbleweed"],
["DEBA13", "Gold Tips"],
["DEC196", "Brandy"],
["DECBC6", "Wafer"],
["DED4A4", "Sapling"],
["DED717", "Barberry"],
["DEE5C0", "Beryl Green"],
["DEF5FF", "Pattens Blue"],
["DF73FF", "Heliotrope"],
["DFBE6F", "Apache"],
["DFCD6F", "Chenin"],
["DFCFDB", "Lola"],
["DFECDA", "Willow Brook"],
["DFFF00", "Chartreuse Yellow"],
["E0B0FF", "Mauve"],
["E0B646", "Anzac"],
["E0B974", "Harvest Gold"],
["E0C095", "Calico"],
["E0FFFF", "Baby Blue"],
["E16865", "Sunglo"],
["E1BC64", "Equator"],
["E1C0C8", "Pink Flare"],
["E1E6D6", "Periglacial Blue"],
["E1EAD4", "Kidnapper"],
["E1F6E8", "Tara"],
["E25465", "Mandy"],
["E2725B", "Terracotta"],
["E28913", "Golden Bell"],
["E292C0", "Shocking"],
["E29418", "Dixie"],
["E29CD2", "Light Orchid"],
["E2D8ED", "Snuff"],
["E2EBED", "Mystic"],
["E2F3EC", "Apple Green"],
["E30B5C", "Razzmatazz"],
["E32636", "Alizarin Crimson"],
["E34234", "Cinnabar"],
["E3BEBE", "Cavern Pink"],
["E3F5E1", "Peppermint"],
["E3F988", "Mindaro"],
["E47698", "Deep Blush"],
["E49B0F", "Gamboge"],
["E4C2D5", "Melanie"],
["E4CFDE", "Twilight"],
["E4D1C0", "Bone"],
["E4D422", "Sunflower"],
["E4D5B7", "Grain Brown"],
["E4D69B", "Zombie"],
["E4F6E7", "Frostee"],
["E4FFD1", "Snow Flurry"],
["E52B50", "Amaranth"],
["E5841B", "Zest"],
["E5CCC9", "Dust Storm"],
["E5D7BD", "Stark White"],
["E5D8AF", "Hampton"],
["E5E0E1", "Bon Jour"],
["E5E5E5", "Mercury"],
["E5F9F6", "Polar"],
["E64E03", "Trinidad"],
["E6BE8A", "Gold Sand"],
["E6BEA5", "Cashmere"],
["E6D7B9", "Double Spanish White"],
["E6E4D4", "Satin Linen"],
["E6F2EA", "Harp"],
["E6F8F3", "Off Green"],
["E6FFE9", "Hint of Green"],
["E6FFFF", "Tranquil"],
["E77200", "Mango Tango"],
["E7730A", "Christine"],
["E79F8C", "Tonys Pink"],
["E79FC4", "Kobi"],
["E7BCB4", "Rose Fog"],
["E7BF05", "Corn"],
["E7CD8C", "Putty"],
["E7ECE6", "Gray Nurse"],
["E7F8FF", "Lily White"],
["E7FEFF", "Bubbles"],
["E89928", "Fire Bush"],
["E8B9B3", "Shilo"],
["E8E0D5", "Pearl Bush"],
["E8EBE0", "Green White"],
["E8F1D4", "Chrome White"],
["E8F2EB", "Gin"],
["E8F5F2", "Aqua Squeeze"],
["E96E00", "Clementine"],
["E97451", "Burnt Sienna"],
["E97C07", "Tahiti Gold"],
["E9CECD", "Oyster Pink"],
["E9D75A", "Confetti"],
["E9E3E3", "Ebb"],
["E9F8ED", "Ottoman"],
["E9FFFD", "Clear Day"],
["EA88A8", "Carissma"],
["EAAE69", "Porsche"],
["EAB33B", "Tulip Tree"],
["EAC674", "Rob Roy"],
["EADAB8", "Raffia"],
["EAE8D4", "White Rock"],
["EAF6EE", "Panache"],
["EAF6FF", "Solitude"],
["EAF9F5", "Aqua Spring"],
["EAFFFE", "Dew"],
["EB9373", "Apricot"],
["EBC2AF", "Zinnwaldite"],
["ECA927", "Fuel Yellow"],
["ECC54E", "Ronchi"],
["ECC7EE", "French Lilac"],
["ECCDB9", "Just Right"],
["ECE090", "Wild Rice"],
["ECEBBD", "Fall Green"],
["ECEBCE", "Aths Special"],
["ECF245", "Starship"],
["ED0A3F", "Red Ribbon"],
["ED7A1C", "Tango"],
["ED9121", "Carrot Orange"],
["ED989E", "Sea Pink"],
["EDB381", "Tacao"],
["EDC9AF", "Desert Sand"],
["EDCDAB", "Pancho"],
["EDDCB1", "Chamois"],
["EDEA99", "Primrose"],
["EDF5DD", "Frost"],
["EDF5F5", "Aqua Haze"],
["EDF6FF", "Zumthor"],
["EDF9F1", "Narvik"],
["EDFC84", "Honeysuckle"],
["EE82EE", "Lavender Magenta"],
["EEC1BE", "Beauty Bush"],
["EED794", "Chalky"],
["EED9C4", "Almond"],
["EEDC82", "Flax"],
["EEDEDA", "Bizarre"],
["EEE3AD", "Double Colonial White"],
["EEEEE8", "Cararra"],
["EEEF78", "Manz"],
["EEF0C8", "Tahuna Sands"],
["EEF0F3", "Athens Gray"],
["EEF3C3", "Tusk"],
["EEF4DE", "Loafer"],
["EEF6F7", "Catskill White"],
["EEFDFF", "Twilight Blue"],
["EEFF9A", "Jonquil"],
["EEFFE2", "Rice Flower"],
["EF863F", "Jaffa"],
["EFEFEF", "Gallery"],
["EFF2F3", "Porcelain"],
["F091A9", "Mauvelous"],
["F0D52D", "Golden Dream"],
["F0DB7D", "Golden Sand"],
["F0DC82", "Buff"],
["F0E2EC", "Prim"],
["F0E68C", "Khaki"],
["F0EEFD", "Selago"],
["F0EEFF", "Titan White"],
["F0F8FF", "Alice Blue"],
["F0FCEA", "Feta"],
["F18200", "Gold Drop"],
["F19BAB", "Wewak"],
["F1E788", "Sahara Sand"],
["F1E9D2", "Parchment"],
["F1E9FF", "Blue Chalk"],
["F1EEC1", "Mint Julep"],
["F1F1F1", "Seashell"],
["F1F7F2", "Saltpan"],
["F1FFAD", "Tidal"],
["F1FFC8", "Chiffon"],
["F2552A", "Flamingo"],
["F28500", "Tangerine"],
["F2C3B2", "Mandys Pink"],
["F2F2F2", "Concrete"],
["F2FAFA", "Black Squeeze"],
["F34723", "Pomegranate"],
["F3AD16", "Buttercup"],
["F3D69D", "New Orleans"],
["F3D9DF", "Vanilla Ice"],
["F3E7BB", "Sidecar"],
["F3E9E5", "Dawn Pink"],
["F3EDCF", "Wheatfield"],
["F3FB62", "Canary"],
["F3FBD4", "Orinoco"],
["F3FFD8", "Carla"],
["F400A1", "Hollywood Cerise"],
["F4A460", "Sandy brown"],
["F4C430", "Saffron"],
["F4D81C", "Ripe Lemon"],
["F4EBD3", "Janna"],
["F4F2EE", "Pampas"],
["F4F4F4", "Wild Sand"],
["F4F8FF", "Zircon"],
["F57584", "Froly"],
["F5C85C", "Cream Can"],
["F5C999", "Manhattan"],
["F5D5A0", "Maize"],
["F5DEB3", "Wheat"],
["F5E7A2", "Sandwisp"],
["F5E7E2", "Pot Pourri"],
["F5E9D3", "Albescent White"],
["F5EDEF", "Soft Peach"],
["F5F3E5", "Ecru White"],
["F5F5DC", "Beige"],
["F5FB3D", "Golden Fizz"],
["F5FFBE", "Australian Mint"],
["F64A8A", "French Rose"],
["F653A6", "Brilliant Rose"],
["F6A4C9", "Illusion"],
["F6F0E6", "Merino"],
["F6F7F7", "Black Haze"],
["F6FFDC", "Spring Sun"],
["F7468A", "Violet Red"],
["F77703", "Chilean Fire"],
["F77FBE", "Persian Pink"],
["F7B668", "Rajah"],
["F7C8DA", "Azalea"],
["F7DBE6", "We Peep"],
["F7F2E1", "Quarter Spanish White"],
["F7F5FA", "Whisper"],
["F7FAF7", "Snow Drift"],
["F8B853", "Casablanca"],
["F8C3DF", "Chantilly"],
["F8D9E9", "Cherub"],
["F8DB9D", "Marzipan"],
["F8DD5C", "Energy Yellow"],
["F8E4BF", "Givry"],
["F8F0E8", "White Linen"],
["F8F4FF", "Magnolia"],
["F8F6F1", "Spring Wood"],
["F8F7DC", "Coconut Cream"],
["F8F7FC", "White Lilac"],
["F8F8F7", "Desert Storm"],
["F8F99C", "Texas"],
["F8FACD", "Corn Field"],
["F8FDD3", "Mimosa"],
["F95A61", "Carnation"],
["F9BF58", "Saffron Mango"],
["F9E0ED", "Carousel Pink"],
["F9E4BC", "Dairy Cream"],
["F9E663", "Portica"],
["F9E6F4", "Underage Pink"],
["F9EAF3", "Amour"],
["F9F8E4", "Rum Swizzle"],
["F9FF8B", "Dolly"],
["F9FFF6", "Sugar Cane"],
["FA7814", "Ecstasy"],
["FA9D5A", "Tan Hide"],
["FAD3A2", "Corvette"],
["FADFAD", "Peach Yellow"],
["FAE600", "Turbo"],
["FAEAB9", "Astra"],
["FAECCC", "Champagne"],
["FAF0E6", "Linen"],
["FAF3F0", "Fantasy"],
["FAF7D6", "Citrine White"],
["FAFAFA", "Alabaster"],
["FAFDE4", "Hint of Yellow"],
["FAFFA4", "Milan"],
["FB607F", "Brink Pink"],
["FB8989", "Geraldine"],
["FBA0E3", "Lavender Rose"],
["FBA129", "Sea Buckthorn"],
["FBAC13", "Sun"],
["FBAED2", "Lavender Pink"],
["FBB2A3", "Rose Bud"],
["FBBEDA", "Cupid"],
["FBCCE7", "Classic Rose"],
["FBCEB1", "Apricot Peach"],
["FBE7B2", "Banana Mania"],
["FBE870", "Marigold Yellow"],
["FBE96C", "Festival"],
["FBEA8C", "Sweet Corn"],
["FBEC5D", "Candy Corn"],
["FBF9F9", "Hint of Red"],
["FBFFBA", "Shalimar"],
["FC0FC0", "Shocking Pink"],
["FC80A5", "Tickle Me Pink"],
["FC9C1D", "Tree Poppy"],
["FCC01E", "Lightning Yellow"],
["FCD667", "Goldenrod"],
["FCD917", "Candlelight"],
["FCDA98", "Cherokee"],
["FCF4D0", "Double Pearl Lusta"],
["FCF4DC", "Pearl Lusta"],
["FCF8F7", "Vista White"],
["FCFBF3", "Bianca"],
["FCFEDA", "Moon Glow"],
["FCFFE7", "China Ivory"],
["FCFFF9", "Ceramic"],
["FD0E35", "Torch Red"],
["FD5B78", "Wild Watermelon"],
["FD7B33", "Crusta"],
["FD7C07", "Sorbus"],
["FD9FA2", "Sweet Pink"],
["FDD5B1", "Light Apricot"],
["FDD7E4", "Pig Pink"],
["FDE1DC", "Cinderella"],
["FDE295", "Golden Glow"],
["FDE910", "Lemon"],
["FDF5E6", "Old Lace"],
["FDF6D3", "Half Colonial White"],
["FDF7AD", "Drover"],
["FDFEB8", "Pale Prim"],
["FDFFD5", "Cumulus"],
["FE28A2", "Persian Rose"],
["FE4C40", "Sunset Orange"],
["FE6F5E", "Bittersweet"],
["FE9D04", "California"],
["FEA904", "Yellow Sea"],
["FEBAAD", "Melon"],
["FED33C", "Bright Sun"],
["FED85D", "Dandelion"],
["FEDB8D", "Salomie"],
["FEE5AC", "Cape Honey"],
["FEEBF3", "Remy"],
["FEEFCE", "Oasis"],
["FEF0EC", "Bridesmaid"],
["FEF2C7", "Beeswax"],
["FEF3D8", "Bleach White"],
["FEF4CC", "Pipi"],
["FEF4DB", "Half Spanish White"],
["FEF4F8", "Wisp Pink"],
["FEF5F1", "Provincial Pink"],
["FEF7DE", "Half Dutch White"],
["FEF8E2", "Solitaire"],
["FEF8FF", "White Pointer"],
["FEF9E3", "Off Yellow"],
["FEFCED", "Orange White"],
["FF0000", "Red"],
["FF007F", "Rose"],
["FF00CC", "Purple Pizzazz"],
["FF00FF", "Magenta / Fuchsia"],
["FF2400", "Scarlet"],
["FF3399", "Wild Strawberry"],
["FF33CC", "Razzle Dazzle Rose"],
["FF355E", "Radical Red"],
["FF3F34", "Red Orange"],
["FF4040", "Coral Red"],
["FF4D00", "Vermilion"],
["FF4F00", "International Orange"],
["FF6037", "Outrageous Orange"],
["FF6600", "Blaze Orange"],
["FF66FF", "Pink Flamingo"],
["FF681F", "Orange"],
["FF69B4", "Hot Pink"],
["FF6B53", "Persimmon"],
["FF6FFF", "Blush Pink"],
["FF7034", "Burning Orange"],
["FF7518", "Pumpkin"],
["FF7D07", "Flamenco"],
["FF7F00", "Flush Orange"],
["FF7F50", "Coral"],
["FF8C69", "Salmon"],
["FF9000", "Pizazz"],
["FF910F", "West Side"],
["FF91A4", "Pink Salmon"],
["FF9933", "Neon Carrot"],
["FF9966", "Atomic Tangerine"],
["FF9980", "Vivid Tangerine"],
["FF9E2C", "Sunshade"],
["FFA000", "Orange Peel"],
["FFA194", "Mona Lisa"],
["FFA500", "Web Orange"],
["FFA6C9", "Carnation Pink"],
["FFAB81", "Hit Pink"],
["FFAE42", "Yellow Orange"],
["FFB0AC", "Cornflower Lilac"],
["FFB1B3", "Sundown"],
["FFB31F", "My Sin"],
["FFB555", "Texas Rose"],
["FFB7D5", "Cotton Candy"],
["FFB97B", "Macaroni and Cheese"],
["FFBA00", "Selective Yellow"],
["FFBD5F", "Koromiko"],
["FFBF00", "Amber"],
["FFC0A8", "Wax Flower"],
["FFC0CB", "Pink"],
["FFC3C0", "Your Pink"],
["FFC901", "Supernova"],
["FFCBA4", "Flesh"],
["FFCC33", "Sunglow"],
["FFCC5C", "Golden Tainoi"],
["FFCC99", "Peach Orange"],
["FFCD8C", "Chardonnay"],
["FFD1DC", "Pastel Pink"],
["FFD2B7", "Romantic"],
["FFD38C", "Grandis"],
["FFD700", "Gold"],
["FFD800", "School bus Yellow"],
["FFD8D9", "Cosmos"],
["FFDB58", "Mustard"],
["FFDCD6", "Peach Schnapps"],
["FFDDAF", "Caramel"],
["FFDDCD", "Tuft Bush"],
["FFDDCF", "Watusi"],
["FFDDF4", "Pink Lace"],
["FFDEAD", "Navajo White"],
["FFDEB3", "Frangipani"],
["FFE1DF", "Pippin"],
["FFE1F2", "Pale Rose"],
["FFE2C5", "Negroni"],
["FFE5A0", "Cream Brulee"],
["FFE5B4", "Peach"],
["FFE6C7", "Tequila"],
["FFE772", "Kournikova"],
["FFEAC8", "Sandy Beach"],
["FFEAD4", "Karry"],
["FFEC13", "Broom"],
["FFEDBC", "Colonial White"],
["FFEED8", "Derby"],
["FFEFA1", "Vis Vis"],
["FFEFC1", "Egg White"],
["FFEFD5", "Papaya Whip"],
["FFEFEC", "Fair Pink"],
["FFF0DB", "Peach Cream"],
["FFF0F5", "Lavender blush"],
["FFF14F", "Gorse"],
["FFF1B5", "Buttermilk"],
["FFF1D8", "Pink Lady"],
["FFF1EE", "Forget Me Not"],
["FFF1F9", "Tutu"],
["FFF39D", "Picasso"],
["FFF3F1", "Chardon"],
["FFF46E", "Paris Daisy"],
["FFF4CE", "Barley White"],
["FFF4DD", "Egg Sour"],
["FFF4E0", "Sazerac"],
["FFF4E8", "Serenade"],
["FFF4F3", "Chablis"],
["FFF5EE", "Seashell Peach"],
["FFF5F3", "Sauvignon"],
["FFF6D4", "Milk Punch"],
["FFF6DF", "Varden"],
["FFF6F5", "Rose White"],
["FFF8D1", "Baja White"],
["FFF9E2", "Gin Fizz"],
["FFF9E6", "Early Dawn"],
["FFFACD", "Lemon Chiffon"],
["FFFAF4", "Bridal Heath"],
["FFFBDC", "Scotch Mist"],
["FFFBF9", "Soapstone"],
["FFFC99", "Witch Haze"],
["FFFCEA", "Buttery White"],
["FFFCEE", "Island Spice"],
["FFFDD0", "Cream"],
["FFFDE6", "Chilean Heath"],
["FFFDE8", "Travertine"],
["FFFDF3", "Orchid White"],
["FFFDF4", "Quarter Pearl Lusta"],
["FFFEE1", "Half and Half"],
["FFFEEC", "Apricot White"],
["FFFEF0", "Rice Cake"],
["FFFEF6", "Black White"],
["FFFEFD", "Romance"],
["FFFF00", "Yellow"],
["FFFF66", "Laser Lemon"],
["FFFF99", "Pale Canary"],
["FFFFB4", "Portafino"],
["FFFFF0", "Ivory"],
["FFFFFF", "White"]
]
}
ntc.init();
module.exports = ntc;
/***/ }),
/***/ "./node_modules/numeric/numeric-1.2.6.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
var numeric = ( false)?(function numeric() {}):(exports);
if(typeof global !== "undefined") { global.numeric = numeric; }
numeric.version = "1.2.6";
// 1. Utility functions
numeric.bench = function bench (f,interval) {
var t1,t2,n,i;
if(typeof interval === "undefined") { interval = 15; }
n = 0.5;
t1 = new Date();
while(1) {
n*=2;
for(i=n;i>3;i-=4) { f(); f(); f(); f(); }
while(i>0) { f(); i--; }
t2 = new Date();
if(t2-t1 > interval) break;
}
for(i=n;i>3;i-=4) { f(); f(); f(); f(); }
while(i>0) { f(); i--; }
t2 = new Date();
return 1000*(3*n-1)/(t2-t1);
}
numeric._myIndexOf = (function _myIndexOf(w) {
var n = this.length,k;
for(k=0;k numeric.largeArray) { ret.push('...Large Array...'); return true; }
var flag = false;
ret.push('[');
for(k=0;k0) { ret.push(','); if(flag) ret.push('\n '); } flag = foo(x[k]); }
ret.push(']');
return true;
}
ret.push('{');
var flag = false;
for(k in x) { if(x.hasOwnProperty(k)) { if(flag) ret.push(',\n'); flag = true; ret.push(k); ret.push(': \n'); foo(x[k]); } }
ret.push('}');
return true;
}
foo(x);
return ret.join('');
}
numeric.parseDate = function parseDate(d) {
function foo(d) {
if(typeof d === 'string') { return Date.parse(d.replace(/-/g,'/')); }
if(!(d instanceof Array)) { throw new Error("parseDate: parameter must be arrays of strings"); }
var ret = [],k;
for(k=0;k0) {
ret[count] = [];
for(j=0;j> 2;
q = ((x & 3) << 4) + (y >> 4);
r = ((y & 15) << 2) + (z >> 6);
s = z & 63;
if(i+1>=n) { r = s = 64; }
else if(i+2>=n) { s = 64; }
ret += key.charAt(p) + key.charAt(q) + key.charAt(r) + key.charAt(s);
}
return ret;
}
function crc32Array (a,from,to) {
if(typeof from === "undefined") { from = 0; }
if(typeof to === "undefined") { to = a.length; }
var table = [0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D];
var crc = -1, y = 0, n = a.length,i;
for (i = from; i < to; i++) {
y = (crc ^ a[i]) & 0xFF;
crc = (crc >>> 8) ^ table[y];
}
return crc ^ (-1);
}
var h = img[0].length, w = img[0][0].length, s1, s2, next,k,length,a,b,i,j,adler32,crc32;
var stream = [
137, 80, 78, 71, 13, 10, 26, 10, // 0: PNG signature
0,0,0,13, // 8: IHDR Chunk length
73, 72, 68, 82, // 12: "IHDR"
(w >> 24) & 255, (w >> 16) & 255, (w >> 8) & 255, w&255, // 16: Width
(h >> 24) & 255, (h >> 16) & 255, (h >> 8) & 255, h&255, // 20: Height
8, // 24: bit depth
2, // 25: RGB
0, // 26: deflate
0, // 27: no filter
0, // 28: no interlace
-1,-2,-3,-4, // 29: CRC
-5,-6,-7,-8, // 33: IDAT Chunk length
73, 68, 65, 84, // 37: "IDAT"
// RFC 1950 header starts here
8, // 41: RFC1950 CMF
29 // 42: RFC1950 FLG
];
crc32 = crc32Array(stream,12,29);
stream[29] = (crc32>>24)&255;
stream[30] = (crc32>>16)&255;
stream[31] = (crc32>>8)&255;
stream[32] = (crc32)&255;
s1 = 1;
s2 = 0;
for(i=0;i>8)&255;
stream.push(a); stream.push(b);
stream.push((~a)&255); stream.push((~b)&255);
if(i===0) stream.push(0);
for(j=0;j255) a = 255;
else if(a<0) a=0;
else a = Math.round(a);
s1 = (s1 + a )%65521;
s2 = (s2 + s1)%65521;
stream.push(a);
}
}
stream.push(0);
}
adler32 = (s2<<16)+s1;
stream.push((adler32>>24)&255);
stream.push((adler32>>16)&255);
stream.push((adler32>>8)&255);
stream.push((adler32)&255);
length = stream.length - 41;
stream[33] = (length>>24)&255;
stream[34] = (length>>16)&255;
stream[35] = (length>>8)&255;
stream[36] = (length)&255;
crc32 = crc32Array(stream,37);
stream.push((crc32>>24)&255);
stream.push((crc32>>16)&255);
stream.push((crc32>>8)&255);
stream.push((crc32)&255);
stream.push(0);
stream.push(0);
stream.push(0);
stream.push(0);
// a = stream.length;
stream.push(73); // I
stream.push(69); // E
stream.push(78); // N
stream.push(68); // D
stream.push(174); // CRC1
stream.push(66); // CRC2
stream.push(96); // CRC3
stream.push(130); // CRC4
return 'data:image/png;base64,'+base64(stream);
}
// 2. Linear algebra with Arrays.
numeric._dim = function _dim(x) {
var ret = [];
while(typeof x === "object") { ret.push(x.length); x = x[0]; }
return ret;
}
numeric.dim = function dim(x) {
var y,z;
if(typeof x === "object") {
y = x[0];
if(typeof y === "object") {
z = y[0];
if(typeof z === "object") {
return numeric._dim(x);
}
return [x.length,y.length];
}
return [x.length];
}
return [];
}
numeric.mapreduce = function mapreduce(body,init) {
return Function('x','accum','_s','_k',
'if(typeof accum === "undefined") accum = '+init+';\n'+
'if(typeof x === "number") { var xi = x; '+body+'; return accum; }\n'+
'if(typeof _s === "undefined") _s = numeric.dim(x);\n'+
'if(typeof _k === "undefined") _k = 0;\n'+
'var _n = _s[_k];\n'+
'var i,xi;\n'+
'if(_k < _s.length-1) {\n'+
' for(i=_n-1;i>=0;i--) {\n'+
' accum = arguments.callee(x[i],accum,_s,_k+1);\n'+
' }'+
' return accum;\n'+
'}\n'+
'for(i=_n-1;i>=1;i-=2) { \n'+
' xi = x[i];\n'+
' '+body+';\n'+
' xi = x[i-1];\n'+
' '+body+';\n'+
'}\n'+
'if(i === 0) {\n'+
' xi = x[i];\n'+
' '+body+'\n'+
'}\n'+
'return accum;'
);
}
numeric.mapreduce2 = function mapreduce2(body,setup) {
return Function('x',
'var n = x.length;\n'+
'var i,xi;\n'+setup+';\n'+
'for(i=n-1;i!==-1;--i) { \n'+
' xi = x[i];\n'+
' '+body+';\n'+
'}\n'+
'return accum;'
);
}
numeric.same = function same(x,y) {
var i,n;
if(!(x instanceof Array) || !(y instanceof Array)) { return false; }
n = x.length;
if(n !== y.length) { return false; }
for(i=0;i=0;i-=2) { ret[i+1] = v; ret[i] = v; }
if(i===-1) { ret[0] = v; }
return ret;
}
for(i=n-1;i>=0;i--) { ret[i] = numeric.rep(s,v,k+1); }
return ret;
}
numeric.dotMMsmall = function dotMMsmall(x,y) {
var i,j,k,p,q,r,ret,foo,bar,woo,i0,k0,p0,r0;
p = x.length; q = y.length; r = y[0].length;
ret = Array(p);
for(i=p-1;i>=0;i--) {
foo = Array(r);
bar = x[i];
for(k=r-1;k>=0;k--) {
woo = bar[q-1]*y[q-1][k];
for(j=q-2;j>=1;j-=2) {
i0 = j-1;
woo += bar[j]*y[j][k] + bar[i0]*y[i0][k];
}
if(j===0) { woo += bar[0]*y[0][k]; }
foo[k] = woo;
}
ret[i] = foo;
}
return ret;
}
numeric._getCol = function _getCol(A,j,x) {
var n = A.length, i;
for(i=n-1;i>0;--i) {
x[i] = A[i][j];
--i;
x[i] = A[i][j];
}
if(i===0) x[0] = A[0][j];
}
numeric.dotMMbig = function dotMMbig(x,y){
var gc = numeric._getCol, p = y.length, v = Array(p);
var m = x.length, n = y[0].length, A = new Array(m), xj;
var VV = numeric.dotVV;
var i,j,k,z;
--p;
--m;
for(i=m;i!==-1;--i) A[i] = Array(n);
--n;
for(i=n;i!==-1;--i) {
gc(y,i,v);
for(j=m;j!==-1;--j) {
z=0;
xj = x[j];
A[j][i] = VV(xj,v);
}
}
return A;
}
numeric.dotMV = function dotMV(x,y) {
var p = x.length, q = y.length,i;
var ret = Array(p), dotVV = numeric.dotVV;
for(i=p-1;i>=0;i--) { ret[i] = dotVV(x[i],y); }
return ret;
}
numeric.dotVM = function dotVM(x,y) {
var i,j,k,p,q,r,ret,foo,bar,woo,i0,k0,p0,r0,s1,s2,s3,baz,accum;
p = x.length; q = y[0].length;
ret = Array(q);
for(k=q-1;k>=0;k--) {
woo = x[p-1]*y[p-1][k];
for(j=p-2;j>=1;j-=2) {
i0 = j-1;
woo += x[j]*y[j][k] + x[i0]*y[i0][k];
}
if(j===0) { woo += x[0]*y[0][k]; }
ret[k] = woo;
}
return ret;
}
numeric.dotVV = function dotVV(x,y) {
var i,n=x.length,i1,ret = x[n-1]*y[n-1];
for(i=n-2;i>=1;i-=2) {
i1 = i-1;
ret += x[i]*y[i] + x[i1]*y[i1];
}
if(i===0) { ret += x[0]*y[0]; }
return ret;
}
numeric.dot = function dot(x,y) {
var d = numeric.dim;
switch(d(x).length*1000+d(y).length) {
case 2002:
if(y.length < 10) return numeric.dotMMsmall(x,y);
else return numeric.dotMMbig(x,y);
case 2001: return numeric.dotMV(x,y);
case 1002: return numeric.dotVM(x,y);
case 1001: return numeric.dotVV(x,y);
case 1000: return numeric.mulVS(x,y);
case 1: return numeric.mulSV(x,y);
case 0: return x*y;
default: throw new Error('numeric.dot only works on vectors and matrices');
}
}
numeric.diag = function diag(d) {
var i,i1,j,n = d.length, A = Array(n), Ai;
for(i=n-1;i>=0;i--) {
Ai = Array(n);
i1 = i+2;
for(j=n-1;j>=i1;j-=2) {
Ai[j] = 0;
Ai[j-1] = 0;
}
if(j>i) { Ai[j] = 0; }
Ai[i] = d[i];
for(j=i-1;j>=1;j-=2) {
Ai[j] = 0;
Ai[j-1] = 0;
}
if(j===0) { Ai[0] = 0; }
A[i] = Ai;
}
return A;
}
numeric.getDiag = function(A) {
var n = Math.min(A.length,A[0].length),i,ret = Array(n);
for(i=n-1;i>=1;--i) {
ret[i] = A[i][i];
--i;
ret[i] = A[i][i];
}
if(i===0) {
ret[0] = A[0][0];
}
return ret;
}
numeric.identity = function identity(n) { return numeric.diag(numeric.rep([n],1)); }
numeric.pointwise = function pointwise(params,body,setup) {
if(typeof setup === "undefined") { setup = ""; }
var fun = [];
var k;
var avec = /\[i\]$/,p,thevec = '';
var haveret = false;
for(k=0;k=0;i--) ret[i] = arguments.callee('+params.join(',')+',_s,_k+1);\n'+
' return ret;\n'+
'}\n'+
setup+'\n'+
'for(i=_n-1;i!==-1;--i) {\n'+
' '+body+'\n'+
'}\n'+
'return ret;'
);
return Function.apply(null,fun);
}
numeric.pointwise2 = function pointwise2(params,body,setup) {
if(typeof setup === "undefined") { setup = ""; }
var fun = [];
var k;
var avec = /\[i\]$/,p,thevec = '';
var haveret = false;
for(k=0;k=0;i--) { _biforeach(typeof x==="object"?x[i]:x,typeof y==="object"?y[i]:y,s,k+1,f); }
});
numeric._biforeach2 = (function _biforeach2(x,y,s,k,f) {
if(k === s.length-1) { return f(x,y); }
var i,n=s[k],ret = Array(n);
for(i=n-1;i>=0;--i) { ret[i] = _biforeach2(typeof x==="object"?x[i]:x,typeof y==="object"?y[i]:y,s,k+1,f); }
return ret;
});
numeric._foreach = (function _foreach(x,s,k,f) {
if(k === s.length-1) { f(x); return; }
var i,n=s[k];
for(i=n-1;i>=0;i--) { _foreach(x[i],s,k+1,f); }
});
numeric._foreach2 = (function _foreach2(x,s,k,f) {
if(k === s.length-1) { return f(x); }
var i,n=s[k], ret = Array(n);
for(i=n-1;i>=0;i--) { ret[i] = _foreach2(x[i],s,k+1,f); }
return ret;
});
/*numeric.anyV = numeric.mapreduce('if(xi) return true;','false');
numeric.allV = numeric.mapreduce('if(!xi) return false;','true');
numeric.any = function(x) { if(typeof x.length === "undefined") return x; return numeric.anyV(x); }
numeric.all = function(x) { if(typeof x.length === "undefined") return x; return numeric.allV(x); }*/
numeric.ops2 = {
add: '+',
sub: '-',
mul: '*',
div: '/',
mod: '%',
and: '&&',
or: '||',
eq: '===',
neq: '!==',
lt: '<',
gt: '>',
leq: '<=',
geq: '>=',
band: '&',
bor: '|',
bxor: '^',
lshift: '<<',
rshift: '>>',
rrshift: '>>>'
};
numeric.opseq = {
addeq: '+=',
subeq: '-=',
muleq: '*=',
diveq: '/=',
modeq: '%=',
lshifteq: '<<=',
rshifteq: '>>=',
rrshifteq: '>>>=',
bandeq: '&=',
boreq: '|=',
bxoreq: '^='
};
numeric.mathfuns = ['abs','acos','asin','atan','ceil','cos',
'exp','floor','log','round','sin','sqrt','tan',
'isNaN','isFinite'];
numeric.mathfuns2 = ['atan2','pow','max','min'];
numeric.ops1 = {
neg: '-',
not: '!',
bnot: '~',
clone: ''
};
numeric.mapreducers = {
any: ['if(xi) return true;','var accum = false;'],
all: ['if(!xi) return false;','var accum = true;'],
sum: ['accum += xi;','var accum = 0;'],
prod: ['accum *= xi;','var accum = 1;'],
norm2Squared: ['accum += xi*xi;','var accum = 0;'],
norminf: ['accum = max(accum,abs(xi));','var accum = 0, max = Math.max, abs = Math.abs;'],
norm1: ['accum += abs(xi)','var accum = 0, abs = Math.abs;'],
sup: ['accum = max(accum,xi);','var accum = -Infinity, max = Math.max;'],
inf: ['accum = min(accum,xi);','var accum = Infinity, min = Math.min;']
};
(function () {
var i,o;
for(i=0;iv0) { i0 = i; v0 = k; } }
Aj = A[i0]; A[i0] = A[j]; A[j] = Aj;
Ij = I[i0]; I[i0] = I[j]; I[j] = Ij;
x = Aj[j];
for(k=j;k!==n;++k) Aj[k] /= x;
for(k=n-1;k!==-1;--k) Ij[k] /= x;
for(i=m-1;i!==-1;--i) {
if(i!==j) {
Ai = A[i];
Ii = I[i];
x = Ai[j];
for(k=j+1;k!==n;++k) Ai[k] -= Aj[k]*x;
for(k=n-1;k>0;--k) { Ii[k] -= Ij[k]*x; --k; Ii[k] -= Ij[k]*x; }
if(k===0) Ii[0] -= Ij[0]*x;
}
}
}
return I;
}
numeric.det = function det(x) {
var s = numeric.dim(x);
if(s.length !== 2 || s[0] !== s[1]) { throw new Error('numeric: det() only works on square matrices'); }
var n = s[0], ret = 1,i,j,k,A = numeric.clone(x),Aj,Ai,alpha,temp,k1,k2,k3;
for(j=0;j Math.abs(A[k][j])) { k = i; } }
if(k !== j) {
temp = A[k]; A[k] = A[j]; A[j] = temp;
ret *= -1;
}
Aj = A[j];
for(i=j+1;i=1;i-=2) {
A1 = x[i];
A0 = x[i-1];
for(j=n-1;j>=1;--j) {
Bj = ret[j]; Bj[i] = A1[j]; Bj[i-1] = A0[j];
--j;
Bj = ret[j]; Bj[i] = A1[j]; Bj[i-1] = A0[j];
}
if(j===0) {
Bj = ret[0]; Bj[i] = A1[0]; Bj[i-1] = A0[0];
}
}
if(i===0) {
A0 = x[0];
for(j=n-1;j>=1;--j) {
ret[j][0] = A0[j];
--j;
ret[j][0] = A0[j];
}
if(j===0) { ret[0][0] = A0[0]; }
}
return ret;
}
numeric.negtranspose = function negtranspose(x) {
var i,j,m = x.length,n = x[0].length, ret=Array(n),A0,A1,Bj;
for(j=0;j=1;i-=2) {
A1 = x[i];
A0 = x[i-1];
for(j=n-1;j>=1;--j) {
Bj = ret[j]; Bj[i] = -A1[j]; Bj[i-1] = -A0[j];
--j;
Bj = ret[j]; Bj[i] = -A1[j]; Bj[i-1] = -A0[j];
}
if(j===0) {
Bj = ret[0]; Bj[i] = -A1[0]; Bj[i-1] = -A0[0];
}
}
if(i===0) {
A0 = x[0];
for(j=n-1;j>=1;--j) {
ret[j][0] = -A0[j];
--j;
ret[j][0] = -A0[j];
}
if(j===0) { ret[0][0] = -A0[0]; }
}
return ret;
}
numeric._random = function _random(s,k) {
var i,n=s[k],ret=Array(n), rnd;
if(k === s.length-1) {
rnd = Math.random;
for(i=n-1;i>=1;i-=2) {
ret[i] = rnd();
ret[i-1] = rnd();
}
if(i===0) { ret[0] = rnd(); }
return ret;
}
for(i=n-1;i>=0;i--) ret[i] = _random(s,k+1);
return ret;
}
numeric.random = function random(s) { return numeric._random(s,0); }
numeric.norm2 = function norm2(x) { return Math.sqrt(numeric.norm2Squared(x)); }
numeric.linspace = function linspace(a,b,n) {
if(typeof n === "undefined") n = Math.max(Math.round(b-a)+1,1);
if(n<2) { return n===1?[a]:[]; }
var i,ret = Array(n);
n--;
for(i=n;i>=0;i--) { ret[i] = (i*b+(n-i)*a)/n; }
return ret;
}
numeric.getBlock = function getBlock(x,from,to) {
var s = numeric.dim(x);
function foo(x,k) {
var i,a = from[k], n = to[k]-a, ret = Array(n);
if(k === s.length-1) {
for(i=n;i>=0;i--) { ret[i] = x[i+a]; }
return ret;
}
for(i=n;i>=0;i--) { ret[i] = foo(x[i+a],k+1); }
return ret;
}
return foo(x,0);
}
numeric.setBlock = function setBlock(x,from,to,B) {
var s = numeric.dim(x);
function foo(x,y,k) {
var i,a = from[k], n = to[k]-a;
if(k === s.length-1) { for(i=n;i>=0;i--) { x[i+a] = y[i]; } }
for(i=n;i>=0;i--) { foo(x[i+a],y[i],k+1); }
}
foo(x,B,0);
return x;
}
numeric.getRange = function getRange(A,I,J) {
var m = I.length, n = J.length;
var i,j;
var B = Array(m), Bi, AI;
for(i=m-1;i!==-1;--i) {
B[i] = Array(n);
Bi = B[i];
AI = A[I[i]];
for(j=n-1;j!==-1;--j) Bi[j] = AI[J[j]];
}
return B;
}
numeric.blockMatrix = function blockMatrix(X) {
var s = numeric.dim(X);
if(s.length<4) return numeric.blockMatrix([X]);
var m=s[0],n=s[1],M,N,i,j,Xij;
M = 0; N = 0;
for(i=0;i=0;i--) {
Ai = Array(n);
xi = x[i];
for(j=n-1;j>=3;--j) {
Ai[j] = xi * y[j];
--j;
Ai[j] = xi * y[j];
--j;
Ai[j] = xi * y[j];
--j;
Ai[j] = xi * y[j];
}
while(j>=0) { Ai[j] = xi * y[j]; --j; }
A[i] = Ai;
}
return A;
}
// 3. The Tensor type T
numeric.T = function T(x,y) { this.x = x; this.y = y; }
numeric.t = function t(x,y) { return new numeric.T(x,y); }
numeric.Tbinop = function Tbinop(rr,rc,cr,cc,setup) {
var io = numeric.indexOf;
if(typeof setup !== "string") {
var k;
setup = '';
for(k in numeric) {
if(numeric.hasOwnProperty(k) && (rr.indexOf(k)>=0 || rc.indexOf(k)>=0 || cr.indexOf(k)>=0 || cc.indexOf(k)>=0) && k.length>1) {
setup += 'var '+k+' = numeric.'+k+';\n';
}
}
}
return Function(['y'],
'var x = this;\n'+
'if(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n'+
setup+'\n'+
'if(x.y) {'+
' if(y.y) {'+
' return new numeric.T('+cc+');\n'+
' }\n'+
' return new numeric.T('+cr+');\n'+
'}\n'+
'if(y.y) {\n'+
' return new numeric.T('+rc+');\n'+
'}\n'+
'return new numeric.T('+rr+');\n'
);
}
numeric.T.prototype.add = numeric.Tbinop(
'add(x.x,y.x)',
'add(x.x,y.x),y.y',
'add(x.x,y.x),x.y',
'add(x.x,y.x),add(x.y,y.y)');
numeric.T.prototype.sub = numeric.Tbinop(
'sub(x.x,y.x)',
'sub(x.x,y.x),neg(y.y)',
'sub(x.x,y.x),x.y',
'sub(x.x,y.x),sub(x.y,y.y)');
numeric.T.prototype.mul = numeric.Tbinop(
'mul(x.x,y.x)',
'mul(x.x,y.x),mul(x.x,y.y)',
'mul(x.x,y.x),mul(x.y,y.x)',
'sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))');
numeric.T.prototype.reciprocal = function reciprocal() {
var mul = numeric.mul, div = numeric.div;
if(this.y) {
var d = numeric.add(mul(this.x,this.x),mul(this.y,this.y));
return new numeric.T(div(this.x,d),div(numeric.neg(this.y),d));
}
return new T(div(1,this.x));
}
numeric.T.prototype.div = function div(y) {
if(!(y instanceof numeric.T)) y = new numeric.T(y);
if(y.y) { return this.mul(y.reciprocal()); }
var div = numeric.div;
if(this.y) { return new numeric.T(div(this.x,y.x),div(this.y,y.x)); }
return new numeric.T(div(this.x,y.x));
}
numeric.T.prototype.dot = numeric.Tbinop(
'dot(x.x,y.x)',
'dot(x.x,y.x),dot(x.x,y.y)',
'dot(x.x,y.x),dot(x.y,y.x)',
'sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))'
);
numeric.T.prototype.transpose = function transpose() {
var t = numeric.transpose, x = this.x, y = this.y;
if(y) { return new numeric.T(t(x),t(y)); }
return new numeric.T(t(x));
}
numeric.T.prototype.transjugate = function transjugate() {
var t = numeric.transpose, x = this.x, y = this.y;
if(y) { return new numeric.T(t(x),numeric.negtranspose(y)); }
return new numeric.T(t(x));
}
numeric.Tunop = function Tunop(r,c,s) {
if(typeof s !== "string") { s = ''; }
return Function(
'var x = this;\n'+
s+'\n'+
'if(x.y) {'+
' '+c+';\n'+
'}\n'+
r+';\n'
);
}
numeric.T.prototype.exp = numeric.Tunop(
'return new numeric.T(ex)',
'return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))',
'var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;');
numeric.T.prototype.conj = numeric.Tunop(
'return new numeric.T(x.x);',
'return new numeric.T(x.x,numeric.neg(x.y));');
numeric.T.prototype.neg = numeric.Tunop(
'return new numeric.T(neg(x.x));',
'return new numeric.T(neg(x.x),neg(x.y));',
'var neg = numeric.neg;');
numeric.T.prototype.sin = numeric.Tunop(
'return new numeric.T(numeric.sin(x.x))',
'return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));');
numeric.T.prototype.cos = numeric.Tunop(
'return new numeric.T(numeric.cos(x.x))',
'return x.exp().add(x.neg().exp()).div(2);');
numeric.T.prototype.abs = numeric.Tunop(
'return new numeric.T(numeric.abs(x.x));',
'return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));',
'var mul = numeric.mul;');
numeric.T.prototype.log = numeric.Tunop(
'return new numeric.T(numeric.log(x.x));',
'var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\n'+
'return new numeric.T(numeric.log(r.x),theta.x);');
numeric.T.prototype.norm2 = numeric.Tunop(
'return numeric.norm2(x.x);',
'var f = numeric.norm2Squared;\n'+
'return Math.sqrt(f(x.x)+f(x.y));');
numeric.T.prototype.inv = function inv() {
var A = this;
if(typeof A.y === "undefined") { return new numeric.T(numeric.inv(A.x)); }
var n = A.x.length, i, j, k;
var Rx = numeric.identity(n),Ry = numeric.rep([n,n],0);
var Ax = numeric.clone(A.x), Ay = numeric.clone(A.y);
var Aix, Aiy, Ajx, Ajy, Rix, Riy, Rjx, Rjy;
var i,j,k,d,d1,ax,ay,bx,by,temp;
for(i=0;i d) { k=j; d = d1; }
}
if(k!==i) {
temp = Ax[i]; Ax[i] = Ax[k]; Ax[k] = temp;
temp = Ay[i]; Ay[i] = Ay[k]; Ay[k] = temp;
temp = Rx[i]; Rx[i] = Rx[k]; Rx[k] = temp;
temp = Ry[i]; Ry[i] = Ry[k]; Ry[k] = temp;
}
Aix = Ax[i]; Aiy = Ay[i];
Rix = Rx[i]; Riy = Ry[i];
ax = Aix[i]; ay = Aiy[i];
for(j=i+1;j0;i--) {
Rix = Rx[i]; Riy = Ry[i];
for(j=i-1;j>=0;j--) {
Rjx = Rx[j]; Rjy = Ry[j];
ax = Ax[j][i]; ay = Ay[j][i];
for(k=n-1;k>=0;k--) {
bx = Rix[k]; by = Riy[k];
Rjx[k] -= ax*bx - ay*by;
Rjy[k] -= ax*by + ay*bx;
}
}
}
return new numeric.T(Rx,Ry);
}
numeric.T.prototype.get = function get(i) {
var x = this.x, y = this.y, k = 0, ik, n = i.length;
if(y) {
while(k= 0 ? 1 : -1;
var alpha = s*numeric.norm2(x);
v[0] += alpha;
var foo = numeric.norm2(v);
if(foo === 0) { /* this should not happen */ throw new Error('eig: internal error'); }
return numeric.div(v,foo);
}
numeric.toUpperHessenberg = function toUpperHessenberg(me) {
var s = numeric.dim(me);
if(s.length !== 2 || s[0] !== s[1]) { throw new Error('numeric: toUpperHessenberg() only works on square matrices'); }
var m = s[0], i,j,k,x,v,A = numeric.clone(me),B,C,Ai,Ci,Q = numeric.identity(m),Qi;
for(j=0;j0) {
v = numeric.house(x);
B = numeric.getBlock(A,[j+1,j],[m-1,m-1]);
C = numeric.tensor(v,numeric.dot(v,B));
for(i=j+1;i=4*det) {
var s1,s2;
s1 = 0.5*(tr+Math.sqrt(tr*tr-4*det));
s2 = 0.5*(tr-Math.sqrt(tr*tr-4*det));
Hloc = numeric.add(numeric.sub(numeric.dot(Hloc,Hloc),
numeric.mul(Hloc,s1+s2)),
numeric.diag(numeric.rep([3],s1*s2)));
} else {
Hloc = numeric.add(numeric.sub(numeric.dot(Hloc,Hloc),
numeric.mul(Hloc,tr)),
numeric.diag(numeric.rep([3],det)));
}
x = [Hloc[0][0],Hloc[1][0],Hloc[2][0]];
v = numeric.house(x);
B = [H[0],H[1],H[2]];
C = numeric.tensor(v,numeric.dot(v,B));
for(i=0;i<3;i++) { Hi = H[i]; Ci = C[i]; for(k=0;k=0) {
if(p1<0) x = -0.5*(p1-sqrt(disc));
else x = -0.5*(p1+sqrt(disc));
n1 = (a-x)*(a-x)+b*b;
n2 = c*c+(d-x)*(d-x);
if(n1>n2) {
n1 = sqrt(n1);
p = (a-x)/n1;
q = b/n1;
} else {
n2 = sqrt(n2);
p = c/n2;
q = (d-x)/n2;
}
Q0 = new T([[q,-p],[p,q]]);
Q.setRows(i,j,Q0.dot(Q.getRows(i,j)));
} else {
x = -0.5*p1;
y = 0.5*sqrt(-disc);
n1 = (a-x)*(a-x)+b*b;
n2 = c*c+(d-x)*(d-x);
if(n1>n2) {
n1 = sqrt(n1+y*y);
p = (a-x)/n1;
q = b/n1;
x = 0;
y /= n1;
} else {
n2 = sqrt(n2+y*y);
p = c/n2;
q = (d-x)/n2;
x = y/n2;
y = 0;
}
Q0 = new T([[q,-p],[p,q]],[[x,y],[y,-x]]);
Q.setRows(i,j,Q0.dot(Q.getRows(i,j)));
}
}
}
var R = Q.dot(A).dot(Q.transjugate()), n = A.length, E = numeric.T.identity(n);
for(j=0;j0) {
for(k=j-1;k>=0;k--) {
var Rk = R.get([k,k]), Rj = R.get([j,j]);
if(numeric.neq(Rk.x,Rj.x) || numeric.neq(Rk.y,Rj.y)) {
x = R.getRow(k).getBlock([k],[j-1]);
y = E.getRow(j).getBlock([k],[j-1]);
E.set([j,k],(R.get([k,j]).neg().sub(x.dot(y))).div(Rk.sub(Rj)));
} else {
E.setRow(j,E.getRow(k));
continue;
}
}
}
}
for(j=0;j=counts.length) counts[counts.length] = 0;
if(foo[j]!==0) counts[j]++;
}
}
var n = counts.length;
var Ai = Array(n+1);
Ai[0] = 0;
for(i=0;i= k11) {
xj[n] = j[m];
if(m===0) return;
++n;
--m;
km = k[m];
k11 = k1[m];
} else {
foo = Pinv[Aj[km]];
if(x[foo] === 0) {
x[foo] = 1;
k[m] = km;
++m;
j[m] = foo;
km = Ai[foo];
k1[m] = k11 = Ai[foo+1];
} else ++km;
}
}
}
numeric.ccsLPSolve = function ccsLPSolve(A,B,x,xj,I,Pinv,dfs) {
var Ai = A[0], Aj = A[1], Av = A[2],m = Ai.length-1, n=0;
var Bi = B[0], Bj = B[1], Bv = B[2];
var i,i0,i1,j,J,j0,j1,k,l,l0,l1,a;
i0 = Bi[I];
i1 = Bi[I+1];
xj.length = 0;
for(i=i0;i a) { e = k; a = c; }
}
if(abs(x[i])= k11) {
xj[n] = Pinv[j[m]];
if(m===0) return;
++n;
--m;
km = k[m];
k11 = k1[m];
} else {
foo = Aj[km];
if(x[foo] === 0) {
x[foo] = 1;
k[m] = km;
++m;
j[m] = foo;
foo = Pinv[foo];
km = Ai[foo];
k1[m] = k11 = Ai[foo+1];
} else ++km;
}
}
}
numeric.ccsLPSolve0 = function ccsLPSolve0(A,B,y,xj,I,Pinv,P,dfs) {
var Ai = A[0], Aj = A[1], Av = A[2],m = Ai.length-1, n=0;
var Bi = B[0], Bj = B[1], Bv = B[2];
var i,i0,i1,j,J,j0,j1,k,l,l0,l1,a;
i0 = Bi[I];
i1 = Bi[I+1];
xj.length = 0;
for(i=i0;i a) { e = k; a = c; }
}
if(abs(y[P[i]]) ret[k]) ret[k] = A.length;
var i;
for(i in A) {
if(A.hasOwnProperty(i)) dim(A[i],ret,k+1);
}
return ret;
};
numeric.sclone = function clone(A,k,n) {
if(typeof k === "undefined") { k=0; }
if(typeof n === "undefined") { n = numeric.sdim(A).length; }
var i,ret = Array(A.length);
if(k === n-1) {
for(i in A) { if(A.hasOwnProperty(i)) ret[i] = A[i]; }
return ret;
}
for(i in A) {
if(A.hasOwnProperty(i)) ret[i] = clone(A[i],k+1,n);
}
return ret;
}
numeric.sdiag = function diag(d) {
var n = d.length,i,ret = Array(n),i1,i2,i3;
for(i=n-1;i>=1;i-=2) {
i1 = i-1;
ret[i] = []; ret[i][i] = d[i];
ret[i1] = []; ret[i1][i1] = d[i1];
}
if(i===0) { ret[0] = []; ret[0][0] = d[i]; }
return ret;
}
numeric.sidentity = function identity(n) { return numeric.sdiag(numeric.rep([n],1)); }
numeric.stranspose = function transpose(A) {
var ret = [], n = A.length, i,j,Ai;
for(i in A) {
if(!(A.hasOwnProperty(i))) continue;
Ai = A[i];
for(j in Ai) {
if(!(Ai.hasOwnProperty(j))) continue;
if(typeof ret[j] !== "object") { ret[j] = []; }
ret[j][i] = Ai[j];
}
}
return ret;
}
numeric.sLUP = function LUP(A,tol) {
throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.");
};
numeric.sdotMM = function dotMM(A,B) {
var p = A.length, q = B.length, BT = numeric.stranspose(B), r = BT.length, Ai, BTk;
var i,j,k,accum;
var ret = Array(p),reti;
for(i=p-1;i>=0;i--) {
reti = [];
Ai = A[i];
for(k=r-1;k>=0;k--) {
accum = 0;
BTk = BT[k];
for(j in Ai) {
if(!(Ai.hasOwnProperty(j))) continue;
if(j in BTk) { accum += Ai[j]*BTk[j]; }
}
if(accum) reti[k] = accum;
}
ret[i] = reti;
}
return ret;
}
numeric.sdotMV = function dotMV(A,x) {
var p = A.length, Ai, i,j;
var ret = Array(p), accum;
for(i=p-1;i>=0;i--) {
Ai = A[i];
accum = 0;
for(j in Ai) {
if(!(Ai.hasOwnProperty(j))) continue;
if(x[j]) accum += Ai[j]*x[j];
}
if(accum) ret[i] = accum;
}
return ret;
}
numeric.sdotVM = function dotMV(x,A) {
var i,j,Ai,alpha;
var ret = [], accum;
for(i in x) {
if(!x.hasOwnProperty(i)) continue;
Ai = A[i];
alpha = x[i];
for(j in Ai) {
if(!Ai.hasOwnProperty(j)) continue;
if(!ret[j]) { ret[j] = 0; }
ret[j] += alpha*Ai[j];
}
}
return ret;
}
numeric.sdotVV = function dotVV(x,y) {
var i,ret=0;
for(i in x) { if(x[i] && y[i]) ret+= x[i]*y[i]; }
return ret;
}
numeric.sdot = function dot(A,B) {
var m = numeric.sdim(A).length, n = numeric.sdim(B).length;
var k = m*1000+n;
switch(k) {
case 0: return A*B;
case 1001: return numeric.sdotVV(A,B);
case 2001: return numeric.sdotMV(A,B);
case 1002: return numeric.sdotVM(A,B);
case 2002: return numeric.sdotMM(A,B);
default: throw new Error('numeric.sdot not implemented for tensors of order '+m+' and '+n);
}
}
numeric.sscatter = function scatter(V) {
var n = V[0].length, Vij, i, j, m = V.length, A = [], Aj;
for(i=n-1;i>=0;--i) {
if(!V[m-1][i]) continue;
Aj = A;
for(j=0;j=0;--i) ret[i] = [];
}
for(i=n;i>=0;--i) ret[i].push(k[i]);
ret[n+1].push(Ai);
}
} else gather(Ai,ret,k);
}
}
if(k.length>n) k.pop();
return ret;
}
// 6. Coordinate matrices
numeric.cLU = function LU(A) {
var I = A[0], J = A[1], V = A[2];
var p = I.length, m=0, i,j,k,a,b,c;
for(i=0;i
m) m=I[i];
m++;
var L = Array(m), U = Array(m), left = numeric.rep([m],Infinity), right = numeric.rep([m],-Infinity);
var Ui, Uj,alpha;
for(k=0;k
right[i]) right[i] = j;
}
for(i=0;i right[i+1]) right[i+1] = right[i]; }
for(i=m-1;i>=1;i--) { if(left[i]=0;i--) {
while(Uj[k] > i) {
ret[i] -= Uv[k]*ret[Uj[k]];
k--;
}
ret[i] /= Uv[k];
k--;
}
return ret;
};
numeric.cgrid = function grid(n,shape) {
if(typeof n === "number") n = [n,n];
var ret = numeric.rep(n,-1);
var i,j,count;
if(typeof shape !== "function") {
switch(shape) {
case 'L':
shape = function(i,j) { return (i>=n[0]/2 || jN) N = Ai[k]; }
N++;
ret = numeric.rep([N],0);
for(k=0;k
Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second.
* var numbers = Rx.Observable.of(10, 20, 30);
* var letters = Rx.Observable.of('a', 'b', 'c');
* var interval = Rx.Observable.interval(1000);
* var result = numbers.concat(letters).concat(interval);
* result.subscribe(x => console.log(x));
*
* @see {@link create}
* @see {@link empty}
* @see {@link never}
* @see {@link throw}
*
* @param {...T} values Arguments that represent `next` values to be emitted.
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emissions of the `next` notifications.
* @return {Observable} An Observable that emits each given input value.
* @static true
* @name of
* @owner Observable
*/
ArrayObservable.of = function () {
var array = [];
for (var _i = 0; _i < arguments.length; _i++) {
array[_i - 0] = arguments[_i];
}
var scheduler = array[array.length - 1];
if (isScheduler_1.isScheduler(scheduler)) {
array.pop();
}
else {
scheduler = null;
}
var len = array.length;
if (len > 1) {
return new ArrayObservable(array, scheduler);
}
else if (len === 1) {
return new ScalarObservable_1.ScalarObservable(array[0], scheduler);
}
else {
return new EmptyObservable_1.EmptyObservable(scheduler);
}
};
ArrayObservable.dispatch = function (state) {
var array = state.array, index = state.index, count = state.count, subscriber = state.subscriber;
if (index >= count) {
subscriber.complete();
return;
}
subscriber.next(array[index]);
if (subscriber.closed) {
return;
}
state.index = index + 1;
this.schedule(state);
};
ArrayObservable.prototype._subscribe = function (subscriber) {
var index = 0;
var array = this.array;
var count = array.length;
var scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(ArrayObservable.dispatch, 0, {
array: array, index: index, count: count, subscriber: subscriber
});
}
else {
for (var i = 0; i < count && !subscriber.closed; i++) {
subscriber.next(array[i]);
}
subscriber.complete();
}
};
return ArrayObservable;
}(Observable_1.Observable));
exports.ArrayObservable = ArrayObservable;
//# sourceMappingURL=ArrayObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/ConnectableObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subject_1 = __webpack_require__("./node_modules/rxjs/Subject.js");
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
var Subscription_1 = __webpack_require__("./node_modules/rxjs/Subscription.js");
/**
* @class ConnectableObservable
*/
var ConnectableObservable = (function (_super) {
__extends(ConnectableObservable, _super);
function ConnectableObservable(source, subjectFactory) {
_super.call(this);
this.source = source;
this.subjectFactory = subjectFactory;
this._refCount = 0;
this._isComplete = false;
}
ConnectableObservable.prototype._subscribe = function (subscriber) {
return this.getSubject().subscribe(subscriber);
};
ConnectableObservable.prototype.getSubject = function () {
var subject = this._subject;
if (!subject || subject.isStopped) {
this._subject = this.subjectFactory();
}
return this._subject;
};
ConnectableObservable.prototype.connect = function () {
var connection = this._connection;
if (!connection) {
this._isComplete = false;
connection = this._connection = new Subscription_1.Subscription();
connection.add(this.source
.subscribe(new ConnectableSubscriber(this.getSubject(), this)));
if (connection.closed) {
this._connection = null;
connection = Subscription_1.Subscription.EMPTY;
}
else {
this._connection = connection;
}
}
return connection;
};
ConnectableObservable.prototype.refCount = function () {
return this.lift(new RefCountOperator(this));
};
return ConnectableObservable;
}(Observable_1.Observable));
exports.ConnectableObservable = ConnectableObservable;
var connectableProto = ConnectableObservable.prototype;
exports.connectableObservableDescriptor = {
operator: { value: null },
_refCount: { value: 0, writable: true },
_subject: { value: null, writable: true },
_connection: { value: null, writable: true },
_subscribe: { value: connectableProto._subscribe },
_isComplete: { value: connectableProto._isComplete, writable: true },
getSubject: { value: connectableProto.getSubject },
connect: { value: connectableProto.connect },
refCount: { value: connectableProto.refCount }
};
var ConnectableSubscriber = (function (_super) {
__extends(ConnectableSubscriber, _super);
function ConnectableSubscriber(destination, connectable) {
_super.call(this, destination);
this.connectable = connectable;
}
ConnectableSubscriber.prototype._error = function (err) {
this._unsubscribe();
_super.prototype._error.call(this, err);
};
ConnectableSubscriber.prototype._complete = function () {
this.connectable._isComplete = true;
this._unsubscribe();
_super.prototype._complete.call(this);
};
ConnectableSubscriber.prototype._unsubscribe = function () {
var connectable = this.connectable;
if (connectable) {
this.connectable = null;
var connection = connectable._connection;
connectable._refCount = 0;
connectable._subject = null;
connectable._connection = null;
if (connection) {
connection.unsubscribe();
}
}
};
return ConnectableSubscriber;
}(Subject_1.SubjectSubscriber));
var RefCountOperator = (function () {
function RefCountOperator(connectable) {
this.connectable = connectable;
}
RefCountOperator.prototype.call = function (subscriber, source) {
var connectable = this.connectable;
connectable._refCount++;
var refCounter = new RefCountSubscriber(subscriber, connectable);
var subscription = source.subscribe(refCounter);
if (!refCounter.closed) {
refCounter.connection = connectable.connect();
}
return subscription;
};
return RefCountOperator;
}());
var RefCountSubscriber = (function (_super) {
__extends(RefCountSubscriber, _super);
function RefCountSubscriber(destination, connectable) {
_super.call(this, destination);
this.connectable = connectable;
}
RefCountSubscriber.prototype._unsubscribe = function () {
var connectable = this.connectable;
if (!connectable) {
this.connection = null;
return;
}
this.connectable = null;
var refCount = connectable._refCount;
if (refCount <= 0) {
this.connection = null;
return;
}
connectable._refCount = refCount - 1;
if (refCount > 1) {
this.connection = null;
return;
}
///
// Compare the local RefCountSubscriber's connection Subscription to the
// connection Subscription on the shared ConnectableObservable. In cases
// where the ConnectableObservable source synchronously emits values, and
// the RefCountSubscriber's downstream Observers synchronously unsubscribe,
// execution continues to here before the RefCountOperator has a chance to
// supply the RefCountSubscriber with the shared connection Subscription.
// For example:
// ```
// Observable.range(0, 10)
// .publish()
// .refCount()
// .take(5)
// .subscribe();
// ```
// In order to account for this case, RefCountSubscriber should only dispose
// the ConnectableObservable's shared connection Subscription if the
// connection Subscription exists, *and* either:
// a. RefCountSubscriber doesn't have a reference to the shared connection
// Subscription yet, or,
// b. RefCountSubscriber's connection Subscription reference is identical
// to the shared connection Subscription
///
var connection = this.connection;
var sharedConnection = connectable._connection;
this.connection = null;
if (sharedConnection && (!connection || sharedConnection === connection)) {
sharedConnection.unsubscribe();
}
};
return RefCountSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=ConnectableObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/EmptyObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var EmptyObservable = (function (_super) {
__extends(EmptyObservable, _super);
function EmptyObservable(scheduler) {
_super.call(this);
this.scheduler = scheduler;
}
/**
* Creates an Observable that emits no items to the Observer and immediately
* emits a complete notification.
*
* Just emits 'complete', and nothing else.
*
*
*
*
* This static operator is useful for creating a simple Observable that only
* emits the complete notification. It can be used for composing with other
* Observables, such as in a {@link mergeMap}.
*
* @example
Emit the number 7, then complete.
* var result = Rx.Observable.empty().startWith(7);
* result.subscribe(x => console.log(x));
*
* @example
Map and flatten only odd numbers to the sequence 'a', 'b', 'c'
* var interval = Rx.Observable.interval(1000);
* var result = interval.mergeMap(x =>
* x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
* );
* result.subscribe(x => console.log(x));
*
* // Results in the following to the console:
* // x is equal to the count on the interval eg(0,1,2,3,...)
* // x will occur every 1000ms
* // if x % 2 is equal to 1 print abc
* // if x % 2 is not equal to 1 nothing will be output
*
* @see {@link create}
* @see {@link never}
* @see {@link of}
* @see {@link throw}
*
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emission of the complete notification.
* @return {Observable} An "empty" Observable: emits only the complete
* notification.
* @static true
* @name empty
* @owner Observable
*/
EmptyObservable.create = function (scheduler) {
return new EmptyObservable(scheduler);
};
EmptyObservable.dispatch = function (arg) {
var subscriber = arg.subscriber;
subscriber.complete();
};
EmptyObservable.prototype._subscribe = function (subscriber) {
var scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber });
}
else {
subscriber.complete();
}
};
return EmptyObservable;
}(Observable_1.Observable));
exports.EmptyObservable = EmptyObservable;
//# sourceMappingURL=EmptyObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/ErrorObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var ErrorObservable = (function (_super) {
__extends(ErrorObservable, _super);
function ErrorObservable(error, scheduler) {
_super.call(this);
this.error = error;
this.scheduler = scheduler;
}
/**
* Creates an Observable that emits no items to the Observer and immediately
* emits an error notification.
*
* Just emits 'error', and nothing else.
*
*
*
*
* This static operator is useful for creating a simple Observable that only
* emits the error notification. It can be used for composing with other
* Observables, such as in a {@link mergeMap}.
*
* @example
Emit the number 7, then emit an error.
* var result = Rx.Observable.throw(new Error('oops!')).startWith(7);
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @example
Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for 13
* var interval = Rx.Observable.interval(1000);
* var result = interval.mergeMap(x =>
* x === 13 ?
* Rx.Observable.throw('Thirteens are bad') :
* Rx.Observable.of('a', 'b', 'c')
* );
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @see {@link create}
* @see {@link empty}
* @see {@link never}
* @see {@link of}
*
* @param {any} error The particular Error to pass to the error notification.
* @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
* the emission of the error notification.
* @return {Observable} An error Observable: emits only the error notification
* using the given error argument.
* @static true
* @name throw
* @owner Observable
*/
ErrorObservable.create = function (error, scheduler) {
return new ErrorObservable(error, scheduler);
};
ErrorObservable.dispatch = function (arg) {
var error = arg.error, subscriber = arg.subscriber;
subscriber.error(error);
};
ErrorObservable.prototype._subscribe = function (subscriber) {
var error = this.error;
var scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(ErrorObservable.dispatch, 0, {
error: error, subscriber: subscriber
});
}
else {
subscriber.error(error);
}
};
return ErrorObservable;
}(Observable_1.Observable));
exports.ErrorObservable = ErrorObservable;
//# sourceMappingURL=ErrorObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/ForkJoinObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
var EmptyObservable_1 = __webpack_require__("./node_modules/rxjs/observable/EmptyObservable.js");
var isArray_1 = __webpack_require__("./node_modules/rxjs/util/isArray.js");
var subscribeToResult_1 = __webpack_require__("./node_modules/rxjs/util/subscribeToResult.js");
var OuterSubscriber_1 = __webpack_require__("./node_modules/rxjs/OuterSubscriber.js");
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var ForkJoinObservable = (function (_super) {
__extends(ForkJoinObservable, _super);
function ForkJoinObservable(sources, resultSelector) {
_super.call(this);
this.sources = sources;
this.resultSelector = resultSelector;
}
/* tslint:enable:max-line-length */
/**
* @param sources
* @return {any}
* @static true
* @name forkJoin
* @owner Observable
*/
ForkJoinObservable.create = function () {
var sources = [];
for (var _i = 0; _i < arguments.length; _i++) {
sources[_i - 0] = arguments[_i];
}
if (sources === null || arguments.length === 0) {
return new EmptyObservable_1.EmptyObservable();
}
var resultSelector = null;
if (typeof sources[sources.length - 1] === 'function') {
resultSelector = sources.pop();
}
// if the first and only other argument besides the resultSelector is an array
// assume it's been called with `forkJoin([obs1, obs2, obs3], resultSelector)`
if (sources.length === 1 && isArray_1.isArray(sources[0])) {
sources = sources[0];
}
if (sources.length === 0) {
return new EmptyObservable_1.EmptyObservable();
}
return new ForkJoinObservable(sources, resultSelector);
};
ForkJoinObservable.prototype._subscribe = function (subscriber) {
return new ForkJoinSubscriber(subscriber, this.sources, this.resultSelector);
};
return ForkJoinObservable;
}(Observable_1.Observable));
exports.ForkJoinObservable = ForkJoinObservable;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var ForkJoinSubscriber = (function (_super) {
__extends(ForkJoinSubscriber, _super);
function ForkJoinSubscriber(destination, sources, resultSelector) {
_super.call(this, destination);
this.sources = sources;
this.resultSelector = resultSelector;
this.completed = 0;
this.haveValues = 0;
var len = sources.length;
this.total = len;
this.values = new Array(len);
for (var i = 0; i < len; i++) {
var source = sources[i];
var innerSubscription = subscribeToResult_1.subscribeToResult(this, source, null, i);
if (innerSubscription) {
innerSubscription.outerIndex = i;
this.add(innerSubscription);
}
}
}
ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
this.values[outerIndex] = innerValue;
if (!innerSub._hasValue) {
innerSub._hasValue = true;
this.haveValues++;
}
};
ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) {
var destination = this.destination;
var _a = this, haveValues = _a.haveValues, resultSelector = _a.resultSelector, values = _a.values;
var len = values.length;
if (!innerSub._hasValue) {
destination.complete();
return;
}
this.completed++;
if (this.completed !== len) {
return;
}
if (haveValues === len) {
var value = resultSelector ? resultSelector.apply(this, values) : values;
destination.next(value);
}
destination.complete();
};
return ForkJoinSubscriber;
}(OuterSubscriber_1.OuterSubscriber));
//# sourceMappingURL=ForkJoinObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/FromObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var isArray_1 = __webpack_require__("./node_modules/rxjs/util/isArray.js");
var isArrayLike_1 = __webpack_require__("./node_modules/rxjs/util/isArrayLike.js");
var isPromise_1 = __webpack_require__("./node_modules/rxjs/util/isPromise.js");
var PromiseObservable_1 = __webpack_require__("./node_modules/rxjs/observable/PromiseObservable.js");
var IteratorObservable_1 = __webpack_require__("./node_modules/rxjs/observable/IteratorObservable.js");
var ArrayObservable_1 = __webpack_require__("./node_modules/rxjs/observable/ArrayObservable.js");
var ArrayLikeObservable_1 = __webpack_require__("./node_modules/rxjs/observable/ArrayLikeObservable.js");
var iterator_1 = __webpack_require__("./node_modules/rxjs/symbol/iterator.js");
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
var observeOn_1 = __webpack_require__("./node_modules/rxjs/operator/observeOn.js");
var observable_1 = __webpack_require__("./node_modules/rxjs/symbol/observable.js");
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var FromObservable = (function (_super) {
__extends(FromObservable, _super);
function FromObservable(ish, scheduler) {
_super.call(this, null);
this.ish = ish;
this.scheduler = scheduler;
}
/**
* Creates an Observable from an Array, an array-like object, a Promise, an
* iterable object, or an Observable-like object.
*
* Converts almost anything to an Observable.
*
*
*
* Convert various other objects and data types into Observables. `from`
* converts a Promise or an array-like or an
* [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)
* object into an Observable that emits the items in that promise or array or
* iterable. A String, in this context, is treated as an array of characters.
* Observable-like objects (contains a function named with the ES2015 Symbol
* for Observable) can also be converted through this operator.
*
* @example
Converts an array to an Observable
* var array = [10, 20, 30];
* var result = Rx.Observable.from(array);
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // 10 20 30
*
* @example
Convert an infinite iterable (from a generator) to an Observable
* function* generateDoubles(seed) {
* var i = seed;
* while (true) {
* yield i;
* i = 2 * i; // double it
* }
* }
*
* var iterator = generateDoubles(3);
* var result = Rx.Observable.from(iterator).take(10);
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // 3 6 12 24 48 96 192 384 768 1536
*
* @see {@link create}
* @see {@link fromEvent}
* @see {@link fromEventPattern}
* @see {@link fromPromise}
*
* @param {ObservableInput} ish A subscribable object, a Promise, an
* Observable-like, an Array, an iterable or an array-like object to be
* converted.
* @param {Scheduler} [scheduler] The scheduler on which to schedule the
* emissions of values.
* @return {Observable} The Observable whose values are originally from the
* input object that was converted.
* @static true
* @name from
* @owner Observable
*/
FromObservable.create = function (ish, scheduler) {
if (ish != null) {
if (typeof ish[observable_1.observable] === 'function') {
if (ish instanceof Observable_1.Observable && !scheduler) {
return ish;
}
return new FromObservable(ish, scheduler);
}
else if (isArray_1.isArray(ish)) {
return new ArrayObservable_1.ArrayObservable(ish, scheduler);
}
else if (isPromise_1.isPromise(ish)) {
return new PromiseObservable_1.PromiseObservable(ish, scheduler);
}
else if (typeof ish[iterator_1.iterator] === 'function' || typeof ish === 'string') {
return new IteratorObservable_1.IteratorObservable(ish, scheduler);
}
else if (isArrayLike_1.isArrayLike(ish)) {
return new ArrayLikeObservable_1.ArrayLikeObservable(ish, scheduler);
}
}
throw new TypeError((ish !== null && typeof ish || ish) + ' is not observable');
};
FromObservable.prototype._subscribe = function (subscriber) {
var ish = this.ish;
var scheduler = this.scheduler;
if (scheduler == null) {
return ish[observable_1.observable]().subscribe(subscriber);
}
else {
return ish[observable_1.observable]().subscribe(new observeOn_1.ObserveOnSubscriber(subscriber, scheduler, 0));
}
};
return FromObservable;
}(Observable_1.Observable));
exports.FromObservable = FromObservable;
//# sourceMappingURL=FromObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/IteratorObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var root_1 = __webpack_require__("./node_modules/rxjs/util/root.js");
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
var iterator_1 = __webpack_require__("./node_modules/rxjs/symbol/iterator.js");
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var IteratorObservable = (function (_super) {
__extends(IteratorObservable, _super);
function IteratorObservable(iterator, scheduler) {
_super.call(this);
this.scheduler = scheduler;
if (iterator == null) {
throw new Error('iterator cannot be null.');
}
this.iterator = getIterator(iterator);
}
IteratorObservable.create = function (iterator, scheduler) {
return new IteratorObservable(iterator, scheduler);
};
IteratorObservable.dispatch = function (state) {
var index = state.index, hasError = state.hasError, iterator = state.iterator, subscriber = state.subscriber;
if (hasError) {
subscriber.error(state.error);
return;
}
var result = iterator.next();
if (result.done) {
subscriber.complete();
return;
}
subscriber.next(result.value);
state.index = index + 1;
if (subscriber.closed) {
if (typeof iterator.return === 'function') {
iterator.return();
}
return;
}
this.schedule(state);
};
IteratorObservable.prototype._subscribe = function (subscriber) {
var index = 0;
var _a = this, iterator = _a.iterator, scheduler = _a.scheduler;
if (scheduler) {
return scheduler.schedule(IteratorObservable.dispatch, 0, {
index: index, iterator: iterator, subscriber: subscriber
});
}
else {
do {
var result = iterator.next();
if (result.done) {
subscriber.complete();
break;
}
else {
subscriber.next(result.value);
}
if (subscriber.closed) {
if (typeof iterator.return === 'function') {
iterator.return();
}
break;
}
} while (true);
}
};
return IteratorObservable;
}(Observable_1.Observable));
exports.IteratorObservable = IteratorObservable;
var StringIterator = (function () {
function StringIterator(str, idx, len) {
if (idx === void 0) { idx = 0; }
if (len === void 0) { len = str.length; }
this.str = str;
this.idx = idx;
this.len = len;
}
StringIterator.prototype[iterator_1.iterator] = function () { return (this); };
StringIterator.prototype.next = function () {
return this.idx < this.len ? {
done: false,
value: this.str.charAt(this.idx++)
} : {
done: true,
value: undefined
};
};
return StringIterator;
}());
var ArrayIterator = (function () {
function ArrayIterator(arr, idx, len) {
if (idx === void 0) { idx = 0; }
if (len === void 0) { len = toLength(arr); }
this.arr = arr;
this.idx = idx;
this.len = len;
}
ArrayIterator.prototype[iterator_1.iterator] = function () { return this; };
ArrayIterator.prototype.next = function () {
return this.idx < this.len ? {
done: false,
value: this.arr[this.idx++]
} : {
done: true,
value: undefined
};
};
return ArrayIterator;
}());
function getIterator(obj) {
var i = obj[iterator_1.iterator];
if (!i && typeof obj === 'string') {
return new StringIterator(obj);
}
if (!i && obj.length !== undefined) {
return new ArrayIterator(obj);
}
if (!i) {
throw new TypeError('object is not iterable');
}
return obj[iterator_1.iterator]();
}
var maxSafeInteger = Math.pow(2, 53) - 1;
function toLength(o) {
var len = +o.length;
if (isNaN(len)) {
return 0;
}
if (len === 0 || !numberIsFinite(len)) {
return len;
}
len = sign(len) * Math.floor(Math.abs(len));
if (len <= 0) {
return 0;
}
if (len > maxSafeInteger) {
return maxSafeInteger;
}
return len;
}
function numberIsFinite(value) {
return typeof value === 'number' && root_1.root.isFinite(value);
}
function sign(value) {
var valueAsNumber = +value;
if (valueAsNumber === 0) {
return valueAsNumber;
}
if (isNaN(valueAsNumber)) {
return valueAsNumber;
}
return valueAsNumber < 0 ? -1 : 1;
}
//# sourceMappingURL=IteratorObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/PromiseObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var root_1 = __webpack_require__("./node_modules/rxjs/util/root.js");
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var PromiseObservable = (function (_super) {
__extends(PromiseObservable, _super);
function PromiseObservable(promise, scheduler) {
_super.call(this);
this.promise = promise;
this.scheduler = scheduler;
}
/**
* Converts a Promise to an Observable.
*
* Returns an Observable that just emits the Promise's
* resolved value, then completes.
*
* Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an
* Observable. If the Promise resolves with a value, the output Observable
* emits that resolved value as a `next`, and then completes. If the Promise
* is rejected, then the output Observable emits the corresponding Error.
*
* @example
Convert the Promise returned by Fetch to an Observable
* var result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
* result.subscribe(x => console.log(x), e => console.error(e));
*
* @see {@link bindCallback}
* @see {@link from}
*
* @param {PromiseLike} promise The promise to be converted.
* @param {Scheduler} [scheduler] An optional IScheduler to use for scheduling
* the delivery of the resolved value (or the rejection).
* @return {Observable} An Observable which wraps the Promise.
* @static true
* @name fromPromise
* @owner Observable
*/
PromiseObservable.create = function (promise, scheduler) {
return new PromiseObservable(promise, scheduler);
};
PromiseObservable.prototype._subscribe = function (subscriber) {
var _this = this;
var promise = this.promise;
var scheduler = this.scheduler;
if (scheduler == null) {
if (this._isScalar) {
if (!subscriber.closed) {
subscriber.next(this.value);
subscriber.complete();
}
}
else {
promise.then(function (value) {
_this.value = value;
_this._isScalar = true;
if (!subscriber.closed) {
subscriber.next(value);
subscriber.complete();
}
}, function (err) {
if (!subscriber.closed) {
subscriber.error(err);
}
})
.then(null, function (err) {
// escape the promise trap, throw unhandled errors
root_1.root.setTimeout(function () { throw err; });
});
}
}
else {
if (this._isScalar) {
if (!subscriber.closed) {
return scheduler.schedule(dispatchNext, 0, { value: this.value, subscriber: subscriber });
}
}
else {
promise.then(function (value) {
_this.value = value;
_this._isScalar = true;
if (!subscriber.closed) {
subscriber.add(scheduler.schedule(dispatchNext, 0, { value: value, subscriber: subscriber }));
}
}, function (err) {
if (!subscriber.closed) {
subscriber.add(scheduler.schedule(dispatchError, 0, { err: err, subscriber: subscriber }));
}
})
.then(null, function (err) {
// escape the promise trap, throw unhandled errors
root_1.root.setTimeout(function () { throw err; });
});
}
}
};
return PromiseObservable;
}(Observable_1.Observable));
exports.PromiseObservable = PromiseObservable;
function dispatchNext(arg) {
var value = arg.value, subscriber = arg.subscriber;
if (!subscriber.closed) {
subscriber.next(value);
subscriber.complete();
}
}
function dispatchError(arg) {
var err = arg.err, subscriber = arg.subscriber;
if (!subscriber.closed) {
subscriber.error(err);
}
}
//# sourceMappingURL=PromiseObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/ScalarObservable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
/**
* We need this JSDoc comment for affecting ESDoc.
* @extends {Ignored}
* @hide true
*/
var ScalarObservable = (function (_super) {
__extends(ScalarObservable, _super);
function ScalarObservable(value, scheduler) {
_super.call(this);
this.value = value;
this.scheduler = scheduler;
this._isScalar = true;
if (scheduler) {
this._isScalar = false;
}
}
ScalarObservable.create = function (value, scheduler) {
return new ScalarObservable(value, scheduler);
};
ScalarObservable.dispatch = function (state) {
var done = state.done, value = state.value, subscriber = state.subscriber;
if (done) {
subscriber.complete();
return;
}
subscriber.next(value);
if (subscriber.closed) {
return;
}
state.done = true;
this.schedule(state);
};
ScalarObservable.prototype._subscribe = function (subscriber) {
var value = this.value;
var scheduler = this.scheduler;
if (scheduler) {
return scheduler.schedule(ScalarObservable.dispatch, 0, {
done: false, value: value, subscriber: subscriber
});
}
else {
subscriber.next(value);
if (!subscriber.closed) {
subscriber.complete();
}
}
};
return ScalarObservable;
}(Observable_1.Observable));
exports.ScalarObservable = ScalarObservable;
//# sourceMappingURL=ScalarObservable.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/forkJoin.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var ForkJoinObservable_1 = __webpack_require__("./node_modules/rxjs/observable/ForkJoinObservable.js");
exports.forkJoin = ForkJoinObservable_1.ForkJoinObservable.create;
//# sourceMappingURL=forkJoin.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/from.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var FromObservable_1 = __webpack_require__("./node_modules/rxjs/observable/FromObservable.js");
exports.from = FromObservable_1.FromObservable.create;
//# sourceMappingURL=from.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/fromPromise.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var PromiseObservable_1 = __webpack_require__("./node_modules/rxjs/observable/PromiseObservable.js");
exports.fromPromise = PromiseObservable_1.PromiseObservable.create;
//# sourceMappingURL=fromPromise.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/merge.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var merge_1 = __webpack_require__("./node_modules/rxjs/operator/merge.js");
exports.merge = merge_1.mergeStatic;
//# sourceMappingURL=merge.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/of.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var ArrayObservable_1 = __webpack_require__("./node_modules/rxjs/observable/ArrayObservable.js");
exports.of = ArrayObservable_1.ArrayObservable.of;
//# sourceMappingURL=of.js.map
/***/ }),
/***/ "./node_modules/rxjs/observable/throw.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var ErrorObservable_1 = __webpack_require__("./node_modules/rxjs/observable/ErrorObservable.js");
exports._throw = ErrorObservable_1.ErrorObservable.create;
//# sourceMappingURL=throw.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/catch.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var OuterSubscriber_1 = __webpack_require__("./node_modules/rxjs/OuterSubscriber.js");
var subscribeToResult_1 = __webpack_require__("./node_modules/rxjs/util/subscribeToResult.js");
/**
* Catches errors on the observable to be handled by returning a new observable or throwing an error.
*
*
*
* @example
Continues with a different Observable when there's an error
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n == 4) {
* throw 'four!';
* }
* return n;
* })
* .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
* .subscribe(x => console.log(x));
* // 1, 2, 3, I, II, III, IV, V
*
* @example
Retries the caught source Observable again in case of error, similar to retry() operator
Throws a new error when the source Observable throws an error
*
* Observable.of(1, 2, 3, 4, 5)
* .map(n => {
* if (n == 4) {
* throw 'four!';
* }
* return n;
* })
* .catch(err => {
* throw 'error in source. Details: ' + err;
* })
* .subscribe(
* x => console.log(x),
* err => console.log(err)
* );
* // 1, 2, 3, error in source. Details: four!
*
* @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
* is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
* is returned by the `selector` will be used to continue the observable chain.
* @return {Observable} An observable that originates from either the source or the observable returned by the
* catch `selector` function.
* @method catch
* @name catch
* @owner Observable
*/
function _catch(selector) {
var operator = new CatchOperator(selector);
var caught = this.lift(operator);
return (operator.caught = caught);
}
exports._catch = _catch;
var CatchOperator = (function () {
function CatchOperator(selector) {
this.selector = selector;
}
CatchOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
};
return CatchOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var CatchSubscriber = (function (_super) {
__extends(CatchSubscriber, _super);
function CatchSubscriber(destination, selector, caught) {
_super.call(this, destination);
this.selector = selector;
this.caught = caught;
}
// NOTE: overriding `error` instead of `_error` because we don't want
// to have this flag this subscriber as `isStopped`. We can mimic the
// behavior of the RetrySubscriber (from the `retry` operator), where
// we unsubscribe from our source chain, reset our Subscriber flags,
// then subscribe to the selector result.
CatchSubscriber.prototype.error = function (err) {
if (!this.isStopped) {
var result = void 0;
try {
result = this.selector(err, this.caught);
}
catch (err2) {
_super.prototype.error.call(this, err2);
return;
}
this._unsubscribeAndRecycle();
this.add(subscribeToResult_1.subscribeToResult(this, result));
}
};
return CatchSubscriber;
}(OuterSubscriber_1.OuterSubscriber));
//# sourceMappingURL=catch.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/concatAll.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var mergeAll_1 = __webpack_require__("./node_modules/rxjs/operator/mergeAll.js");
/* tslint:enable:max-line-length */
/**
* Converts a higher-order Observable into a first-order Observable by
* concatenating the inner Observables in order.
*
* Flattens an Observable-of-Observables by putting one
* inner Observable after the other.
*
*
*
* Joins every Observable emitted by the source (a higher-order Observable), in
* a serial fashion. It subscribes to each inner Observable only after the
* previous inner Observable has completed, and merges all of their values into
* the returned observable.
*
* __Warning:__ If the source Observable emits Observables quickly and
* endlessly, and the inner Observables it emits generally complete slower than
* the source emits, you can run into memory issues as the incoming Observables
* collect in an unbounded buffer.
*
* Note: `concatAll` is equivalent to `mergeAll` with concurrency parameter set
* to `1`.
*
* @example
For each click event, tick every second from 0 to 3, with no concurrency
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var higherOrder = clicks.map(ev => Rx.Observable.interval(1000).take(4));
* var firstOrder = higherOrder.concatAll();
* firstOrder.subscribe(x => console.log(x));
*
* // Results in the following:
* // (results are not concurrent)
* // For every click on the "document" it will emit values 0 to 3 spaced
* // on a 1000ms interval
* // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3
*
* @see {@link combineAll}
* @see {@link concat}
* @see {@link concatMap}
* @see {@link concatMapTo}
* @see {@link exhaust}
* @see {@link mergeAll}
* @see {@link switch}
* @see {@link zipAll}
*
* @return {Observable} An Observable emitting values from all the inner
* Observables concatenated.
* @method concatAll
* @owner Observable
*/
function concatAll() {
return this.lift(new mergeAll_1.MergeAllOperator(1));
}
exports.concatAll = concatAll;
//# sourceMappingURL=concatAll.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/concatMap.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var mergeMap_1 = __webpack_require__("./node_modules/rxjs/operator/mergeMap.js");
/* tslint:enable:max-line-length */
/**
* Projects each source value to an Observable which is merged in the output
* Observable, in a serialized fashion waiting for each one to complete before
* merging the next.
*
* Maps each value to an Observable, then flattens all of
* these inner Observables using {@link concatAll}.
*
*
*
* Returns an Observable that emits items based on applying a function that you
* supply to each item emitted by the source Observable, where that function
* returns an (so-called "inner") Observable. Each new inner Observable is
* concatenated with the previous inner Observable.
*
* __Warning:__ if source values arrive endlessly and faster than their
* corresponding inner Observables can complete, it will result in memory issues
* as inner Observables amass in an unbounded buffer waiting for their turn to
* be subscribed to.
*
* Note: `concatMap` is equivalent to `mergeMap` with concurrency parameter set
* to `1`.
*
* @example
For each click event, tick every second from 0 to 3, with no concurrency
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.concatMap(ev => Rx.Observable.interval(1000).take(4));
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // (results are not concurrent)
* // For every click on the "document" it will emit values 0 to 3 spaced
* // on a 1000ms interval
* // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3
*
* @see {@link concat}
* @see {@link concatAll}
* @see {@link concatMapTo}
* @see {@link exhaustMap}
* @see {@link mergeMap}
* @see {@link switchMap}
*
* @param {function(value: T, ?index: number): ObservableInput} project A function
* that, when applied to an item emitted by the source Observable, returns an
* Observable.
* @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
* A function to produce the value on the output Observable based on the values
* and the indices of the source (outer) emission and the inner Observable
* emission. The arguments passed to this function are:
* - `outerValue`: the value that came from the source
* - `innerValue`: the value that came from the projected Observable
* - `outerIndex`: the "index" of the value that came from the source
* - `innerIndex`: the "index" of the value from the projected Observable
* @return {Observable} An observable of values merged from the projected
* Observables as they were subscribed to, one at a time. Optionally, these
* values may have been projected from a passed `projectResult` argument.
* @return {Observable} An Observable that emits the result of applying the
* projection function (and the optional `resultSelector`) to each item emitted
* by the source Observable and taking values from each projected inner
* Observable sequentially.
* @method concatMap
* @owner Observable
*/
function concatMap(project, resultSelector) {
return this.lift(new mergeMap_1.MergeMapOperator(project, resultSelector, 1));
}
exports.concatMap = concatMap;
//# sourceMappingURL=concatMap.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/every.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
/**
* Returns an Observable that emits whether or not every item of the source satisfies the condition specified.
*
* @example
A simple example emitting true if all elements are less than 5, false otherwise
* Observable.of(1, 2, 3, 4, 5, 6)
* .every(x => x < 5)
* .subscribe(x => console.log(x)); // -> false
*
* @param {function} predicate A function for determining if an item meets a specified condition.
* @param {any} [thisArg] Optional object to use for `this` in the callback.
* @return {Observable} An Observable of booleans that determines if all items of the source Observable meet the condition specified.
* @method every
* @owner Observable
*/
function every(predicate, thisArg) {
return this.lift(new EveryOperator(predicate, thisArg, this));
}
exports.every = every;
var EveryOperator = (function () {
function EveryOperator(predicate, thisArg, source) {
this.predicate = predicate;
this.thisArg = thisArg;
this.source = source;
}
EveryOperator.prototype.call = function (observer, source) {
return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
};
return EveryOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var EverySubscriber = (function (_super) {
__extends(EverySubscriber, _super);
function EverySubscriber(destination, predicate, thisArg, source) {
_super.call(this, destination);
this.predicate = predicate;
this.thisArg = thisArg;
this.source = source;
this.index = 0;
this.thisArg = thisArg || this;
}
EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
this.destination.next(everyValueMatch);
this.destination.complete();
};
EverySubscriber.prototype._next = function (value) {
var result = false;
try {
result = this.predicate.call(this.thisArg, value, this.index++, this.source);
}
catch (err) {
this.destination.error(err);
return;
}
if (!result) {
this.notifyComplete(false);
}
};
EverySubscriber.prototype._complete = function () {
this.notifyComplete(true);
};
return EverySubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=every.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/filter.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
/* tslint:enable:max-line-length */
/**
* Filter items emitted by the source Observable by only emitting those that
* satisfy a specified predicate.
*
* Like
* [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
* it only emits a value from the source if it passes a criterion function.
*
*
*
* Similar to the well-known `Array.prototype.filter` method, this operator
* takes values from the source Observable, passes them through a `predicate`
* function and only emits those values that yielded `true`.
*
* @example
Emit only click events whose target was a DIV element
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var clicksOnDivs = clicks.filter(ev => ev.target.tagName === 'DIV');
* clicksOnDivs.subscribe(x => console.log(x));
*
* @see {@link distinct}
* @see {@link distinctUntilChanged}
* @see {@link distinctUntilKeyChanged}
* @see {@link ignoreElements}
* @see {@link partition}
* @see {@link skip}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates each value emitted by the source Observable. If it returns `true`,
* the value is emitted, if `false` the value is not passed to the output
* Observable. The `index` parameter is the number `i` for the i-th source
* emission that has happened since the subscription, starting from the number
* `0`.
* @param {any} [thisArg] An optional argument to determine the value of `this`
* in the `predicate` function.
* @return {Observable} An Observable of values from the source that were
* allowed by the `predicate` function.
* @method filter
* @owner Observable
*/
function filter(predicate, thisArg) {
return this.lift(new FilterOperator(predicate, thisArg));
}
exports.filter = filter;
var FilterOperator = (function () {
function FilterOperator(predicate, thisArg) {
this.predicate = predicate;
this.thisArg = thisArg;
}
FilterOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
};
return FilterOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var FilterSubscriber = (function (_super) {
__extends(FilterSubscriber, _super);
function FilterSubscriber(destination, predicate, thisArg) {
_super.call(this, destination);
this.predicate = predicate;
this.thisArg = thisArg;
this.count = 0;
this.predicate = predicate;
}
// the try catch block below is left specifically for
// optimization and perf reasons. a tryCatcher is not necessary here.
FilterSubscriber.prototype._next = function (value) {
var result;
try {
result = this.predicate.call(this.thisArg, value, this.count++);
}
catch (err) {
this.destination.error(err);
return;
}
if (result) {
this.destination.next(value);
}
};
return FilterSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=filter.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/first.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
var EmptyError_1 = __webpack_require__("./node_modules/rxjs/util/EmptyError.js");
/**
* Emits only the first value (or the first value that meets some condition)
* emitted by the source Observable.
*
* Emits only the first value. Or emits only the first
* value that passes some test.
*
*
*
* If called with no arguments, `first` emits the first value of the source
* Observable, then completes. If called with a `predicate` function, `first`
* emits the first value of the source that matches the specified condition. It
* may also take a `resultSelector` function to produce the output value from
* the input value, and a `defaultValue` to emit in case the source completes
* before it is able to emit a valid value. Throws an error if `defaultValue`
* was not provided and a matching element is not found.
*
* @example
Emit only the first click that happens on the DOM
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.first();
* result.subscribe(x => console.log(x));
*
* @example
Emits the first click that happens on a DIV
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.first(ev => ev.target.tagName === 'DIV');
* result.subscribe(x => console.log(x));
*
* @see {@link filter}
* @see {@link find}
* @see {@link take}
*
* @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
* callback if the Observable completes before any `next` notification was sent.
*
* @param {function(value: T, index: number, source: Observable): boolean} [predicate]
* An optional function called with each item to test for condition matching.
* @param {function(value: T, index: number): R} [resultSelector] A function to
* produce the value on the output Observable based on the values
* and the indices of the source Observable. The arguments passed to this
* function are:
* - `value`: the value that was emitted on the source.
* - `index`: the "index" of the value from the source.
* @param {R} [defaultValue] The default value emitted in case no valid value
* was found on the source.
* @return {Observable} An Observable of the first item that matches the
* condition.
* @method first
* @owner Observable
*/
function first(predicate, resultSelector, defaultValue) {
return this.lift(new FirstOperator(predicate, resultSelector, defaultValue, this));
}
exports.first = first;
var FirstOperator = (function () {
function FirstOperator(predicate, resultSelector, defaultValue, source) {
this.predicate = predicate;
this.resultSelector = resultSelector;
this.defaultValue = defaultValue;
this.source = source;
}
FirstOperator.prototype.call = function (observer, source) {
return source.subscribe(new FirstSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source));
};
return FirstOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var FirstSubscriber = (function (_super) {
__extends(FirstSubscriber, _super);
function FirstSubscriber(destination, predicate, resultSelector, defaultValue, source) {
_super.call(this, destination);
this.predicate = predicate;
this.resultSelector = resultSelector;
this.defaultValue = defaultValue;
this.source = source;
this.index = 0;
this.hasCompleted = false;
this._emitted = false;
}
FirstSubscriber.prototype._next = function (value) {
var index = this.index++;
if (this.predicate) {
this._tryPredicate(value, index);
}
else {
this._emit(value, index);
}
};
FirstSubscriber.prototype._tryPredicate = function (value, index) {
var result;
try {
result = this.predicate(value, index, this.source);
}
catch (err) {
this.destination.error(err);
return;
}
if (result) {
this._emit(value, index);
}
};
FirstSubscriber.prototype._emit = function (value, index) {
if (this.resultSelector) {
this._tryResultSelector(value, index);
return;
}
this._emitFinal(value);
};
FirstSubscriber.prototype._tryResultSelector = function (value, index) {
var result;
try {
result = this.resultSelector(value, index);
}
catch (err) {
this.destination.error(err);
return;
}
this._emitFinal(result);
};
FirstSubscriber.prototype._emitFinal = function (value) {
var destination = this.destination;
if (!this._emitted) {
this._emitted = true;
destination.next(value);
destination.complete();
this.hasCompleted = true;
}
};
FirstSubscriber.prototype._complete = function () {
var destination = this.destination;
if (!this.hasCompleted && typeof this.defaultValue !== 'undefined') {
destination.next(this.defaultValue);
destination.complete();
}
else if (!this.hasCompleted) {
destination.error(new EmptyError_1.EmptyError);
}
};
return FirstSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=first.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/last.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
var EmptyError_1 = __webpack_require__("./node_modules/rxjs/util/EmptyError.js");
/* tslint:enable:max-line-length */
/**
* Returns an Observable that emits only the last item emitted by the source Observable.
* It optionally takes a predicate function as a parameter, in which case, rather than emitting
* the last item from the source Observable, the resulting Observable will emit the last item
* from the source Observable that satisfies the predicate.
*
*
*
* @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
* callback if the Observable completes before any `next` notification was sent.
* @param {function} predicate - The condition any source emitted item has to satisfy.
* @return {Observable} An Observable that emits only the last item satisfying the given condition
* from the source, or an NoSuchElementException if no such items are emitted.
* @throws - Throws if no items that match the predicate are emitted by the source Observable.
* @method last
* @owner Observable
*/
function last(predicate, resultSelector, defaultValue) {
return this.lift(new LastOperator(predicate, resultSelector, defaultValue, this));
}
exports.last = last;
var LastOperator = (function () {
function LastOperator(predicate, resultSelector, defaultValue, source) {
this.predicate = predicate;
this.resultSelector = resultSelector;
this.defaultValue = defaultValue;
this.source = source;
}
LastOperator.prototype.call = function (observer, source) {
return source.subscribe(new LastSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source));
};
return LastOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var LastSubscriber = (function (_super) {
__extends(LastSubscriber, _super);
function LastSubscriber(destination, predicate, resultSelector, defaultValue, source) {
_super.call(this, destination);
this.predicate = predicate;
this.resultSelector = resultSelector;
this.defaultValue = defaultValue;
this.source = source;
this.hasValue = false;
this.index = 0;
if (typeof defaultValue !== 'undefined') {
this.lastValue = defaultValue;
this.hasValue = true;
}
}
LastSubscriber.prototype._next = function (value) {
var index = this.index++;
if (this.predicate) {
this._tryPredicate(value, index);
}
else {
if (this.resultSelector) {
this._tryResultSelector(value, index);
return;
}
this.lastValue = value;
this.hasValue = true;
}
};
LastSubscriber.prototype._tryPredicate = function (value, index) {
var result;
try {
result = this.predicate(value, index, this.source);
}
catch (err) {
this.destination.error(err);
return;
}
if (result) {
if (this.resultSelector) {
this._tryResultSelector(value, index);
return;
}
this.lastValue = value;
this.hasValue = true;
}
};
LastSubscriber.prototype._tryResultSelector = function (value, index) {
var result;
try {
result = this.resultSelector(value, index);
}
catch (err) {
this.destination.error(err);
return;
}
this.lastValue = result;
this.hasValue = true;
};
LastSubscriber.prototype._complete = function () {
var destination = this.destination;
if (this.hasValue) {
destination.next(this.lastValue);
destination.complete();
}
else {
destination.error(new EmptyError_1.EmptyError);
}
};
return LastSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=last.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/map.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
/**
* Applies a given `project` function to each value emitted by the source
* Observable, and emits the resulting values as an Observable.
*
* Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
* it passes each source value through a transformation function to get
* corresponding output values.
*
*
*
* Similar to the well known `Array.prototype.map` function, this operator
* applies a projection to each value and emits that projection in the output
* Observable.
*
* @example
Map every click to the clientX position of that click
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var positions = clicks.map(ev => ev.clientX);
* positions.subscribe(x => console.log(x));
*
* @see {@link mapTo}
* @see {@link pluck}
*
* @param {function(value: T, index: number): R} project The function to apply
* to each `value` emitted by the source Observable. The `index` parameter is
* the number `i` for the i-th emission that has happened since the
* subscription, starting from the number `0`.
* @param {any} [thisArg] An optional argument to define what `this` is in the
* `project` function.
* @return {Observable} An Observable that emits the values from the source
* Observable transformed by the given `project` function.
* @method map
* @owner Observable
*/
function map(project, thisArg) {
if (typeof project !== 'function') {
throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
}
return this.lift(new MapOperator(project, thisArg));
}
exports.map = map;
var MapOperator = (function () {
function MapOperator(project, thisArg) {
this.project = project;
this.thisArg = thisArg;
}
MapOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
};
return MapOperator;
}());
exports.MapOperator = MapOperator;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var MapSubscriber = (function (_super) {
__extends(MapSubscriber, _super);
function MapSubscriber(destination, project, thisArg) {
_super.call(this, destination);
this.project = project;
this.count = 0;
this.thisArg = thisArg || this;
}
// NOTE: This looks unoptimized, but it's actually purposefully NOT
// using try/catch optimizations.
MapSubscriber.prototype._next = function (value) {
var result;
try {
result = this.project.call(this.thisArg, value, this.count++);
}
catch (err) {
this.destination.error(err);
return;
}
this.destination.next(result);
};
return MapSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=map.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/merge.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
var ArrayObservable_1 = __webpack_require__("./node_modules/rxjs/observable/ArrayObservable.js");
var mergeAll_1 = __webpack_require__("./node_modules/rxjs/operator/mergeAll.js");
var isScheduler_1 = __webpack_require__("./node_modules/rxjs/util/isScheduler.js");
/* tslint:enable:max-line-length */
/**
* Creates an output Observable which concurrently emits all values from every
* given input Observable.
*
* Flattens multiple Observables together by blending
* their values into one Observable.
*
*
*
* `merge` subscribes to each given input Observable (either the source or an
* Observable given as argument), and simply forwards (without doing any
* transformation) all the values from all the input Observables to the output
* Observable. The output Observable only completes once all input Observables
* have completed. Any error delivered by an input Observable will be immediately
* emitted on the output Observable.
*
* @example
Merge together two Observables: 1s interval and clicks
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var timer = Rx.Observable.interval(1000);
* var clicksOrTimer = clicks.merge(timer);
* clicksOrTimer.subscribe(x => console.log(x));
*
* @example
Merge together 3 Observables, but only 2 run concurrently
* var timer1 = Rx.Observable.interval(1000).take(10);
* var timer2 = Rx.Observable.interval(2000).take(6);
* var timer3 = Rx.Observable.interval(500).take(10);
* var concurrent = 2; // the argument
* var merged = timer1.merge(timer2, timer3, concurrent);
* merged.subscribe(x => console.log(x));
*
* @see {@link mergeAll}
* @see {@link mergeMap}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
*
* @param {ObservableInput} other An input Observable to merge with the source
* Observable. More than one input Observables may be given as argument.
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @param {Scheduler} [scheduler=null] The IScheduler to use for managing
* concurrency of input Observables.
* @return {Observable} An Observable that emits items that are the result of
* every input Observable.
* @method merge
* @owner Observable
*/
function merge() {
var observables = [];
for (var _i = 0; _i < arguments.length; _i++) {
observables[_i - 0] = arguments[_i];
}
return this.lift.call(mergeStatic.apply(void 0, [this].concat(observables)));
}
exports.merge = merge;
/* tslint:enable:max-line-length */
/**
* Creates an output Observable which concurrently emits all values from every
* given input Observable.
*
* Flattens multiple Observables together by blending
* their values into one Observable.
*
*
*
* `merge` subscribes to each given input Observable (as arguments), and simply
* forwards (without doing any transformation) all the values from all the input
* Observables to the output Observable. The output Observable only completes
* once all input Observables have completed. Any error delivered by an input
* Observable will be immediately emitted on the output Observable.
*
* @example
Merge together two Observables: 1s interval and clicks
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var timer = Rx.Observable.interval(1000);
* var clicksOrTimer = Rx.Observable.merge(clicks, timer);
* clicksOrTimer.subscribe(x => console.log(x));
*
* // Results in the following:
* // timer will emit ascending values, one every second(1000ms) to console
* // clicks logs MouseEvents to console everytime the "document" is clicked
* // Since the two streams are merged you see these happening
* // as they occur.
*
* @example
Merge together 3 Observables, but only 2 run concurrently
* var timer1 = Rx.Observable.interval(1000).take(10);
* var timer2 = Rx.Observable.interval(2000).take(6);
* var timer3 = Rx.Observable.interval(500).take(10);
* var concurrent = 2; // the argument
* var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent);
* merged.subscribe(x => console.log(x));
*
* // Results in the following:
* // - First timer1 and timer2 will run concurrently
* // - timer1 will emit a value every 1000ms for 10 iterations
* // - timer2 will emit a value every 2000ms for 6 iterations
* // - after timer1 hits it's max iteration, timer2 will
* // continue, and timer3 will start to run concurrently with timer2
* // - when timer2 hits it's max iteration it terminates, and
* // timer3 will continue to emit a value every 500ms until it is complete
*
* @see {@link mergeAll}
* @see {@link mergeMap}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
*
* @param {...ObservableInput} observables Input Observables to merge together.
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @param {Scheduler} [scheduler=null] The IScheduler to use for managing
* concurrency of input Observables.
* @return {Observable} an Observable that emits items that are the result of
* every input Observable.
* @static true
* @name merge
* @owner Observable
*/
function mergeStatic() {
var observables = [];
for (var _i = 0; _i < arguments.length; _i++) {
observables[_i - 0] = arguments[_i];
}
var concurrent = Number.POSITIVE_INFINITY;
var scheduler = null;
var last = observables[observables.length - 1];
if (isScheduler_1.isScheduler(last)) {
scheduler = observables.pop();
if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
concurrent = observables.pop();
}
}
else if (typeof last === 'number') {
concurrent = observables.pop();
}
if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
return observables[0];
}
return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(concurrent));
}
exports.mergeStatic = mergeStatic;
//# sourceMappingURL=merge.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/mergeAll.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var OuterSubscriber_1 = __webpack_require__("./node_modules/rxjs/OuterSubscriber.js");
var subscribeToResult_1 = __webpack_require__("./node_modules/rxjs/util/subscribeToResult.js");
/**
* Converts a higher-order Observable into a first-order Observable which
* concurrently delivers all values that are emitted on the inner Observables.
*
* Flattens an Observable-of-Observables.
*
*
*
* `mergeAll` subscribes to an Observable that emits Observables, also known as
* a higher-order Observable. Each time it observes one of these emitted inner
* Observables, it subscribes to that and delivers all the values from the
* inner Observable on the output Observable. The output Observable only
* completes once all inner Observables have completed. Any error delivered by
* a inner Observable will be immediately emitted on the output Observable.
*
* @example
Spawn a new interval Observable for each click event, and blend their outputs as one Observable
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
* var firstOrder = higherOrder.mergeAll();
* firstOrder.subscribe(x => console.log(x));
*
* @example
Count from 0 to 9 every second for each click, but only allow 2 concurrent timers
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10));
* var firstOrder = higherOrder.mergeAll(2);
* firstOrder.subscribe(x => console.log(x));
*
* @see {@link combineAll}
* @see {@link concatAll}
* @see {@link exhaust}
* @see {@link merge}
* @see {@link mergeMap}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
* @see {@link switch}
* @see {@link zipAll}
*
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
* Observables being subscribed to concurrently.
* @return {Observable} An Observable that emits values coming from all the
* inner Observables emitted by the source Observable.
* @method mergeAll
* @owner Observable
*/
function mergeAll(concurrent) {
if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
return this.lift(new MergeAllOperator(concurrent));
}
exports.mergeAll = mergeAll;
var MergeAllOperator = (function () {
function MergeAllOperator(concurrent) {
this.concurrent = concurrent;
}
MergeAllOperator.prototype.call = function (observer, source) {
return source.subscribe(new MergeAllSubscriber(observer, this.concurrent));
};
return MergeAllOperator;
}());
exports.MergeAllOperator = MergeAllOperator;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var MergeAllSubscriber = (function (_super) {
__extends(MergeAllSubscriber, _super);
function MergeAllSubscriber(destination, concurrent) {
_super.call(this, destination);
this.concurrent = concurrent;
this.hasCompleted = false;
this.buffer = [];
this.active = 0;
}
MergeAllSubscriber.prototype._next = function (observable) {
if (this.active < this.concurrent) {
this.active++;
this.add(subscribeToResult_1.subscribeToResult(this, observable));
}
else {
this.buffer.push(observable);
}
};
MergeAllSubscriber.prototype._complete = function () {
this.hasCompleted = true;
if (this.active === 0 && this.buffer.length === 0) {
this.destination.complete();
}
};
MergeAllSubscriber.prototype.notifyComplete = function (innerSub) {
var buffer = this.buffer;
this.remove(innerSub);
this.active--;
if (buffer.length > 0) {
this._next(buffer.shift());
}
else if (this.active === 0 && this.hasCompleted) {
this.destination.complete();
}
};
return MergeAllSubscriber;
}(OuterSubscriber_1.OuterSubscriber));
exports.MergeAllSubscriber = MergeAllSubscriber;
//# sourceMappingURL=mergeAll.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/mergeMap.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var subscribeToResult_1 = __webpack_require__("./node_modules/rxjs/util/subscribeToResult.js");
var OuterSubscriber_1 = __webpack_require__("./node_modules/rxjs/OuterSubscriber.js");
/* tslint:enable:max-line-length */
/**
* Projects each source value to an Observable which is merged in the output
* Observable.
*
* Maps each value to an Observable, then flattens all of
* these inner Observables using {@link mergeAll}.
*
*
*
* Returns an Observable that emits items based on applying a function that you
* supply to each item emitted by the source Observable, where that function
* returns an Observable, and then merging those resulting Observables and
* emitting the results of this merger.
*
* @example
Map and flatten each letter to an Observable ticking every 1 second
* var letters = Rx.Observable.of('a', 'b', 'c');
* var result = letters.mergeMap(x =>
* Rx.Observable.interval(1000).map(i => x+i)
* );
* result.subscribe(x => console.log(x));
*
* // Results in the following:
* // a0
* // b0
* // c0
* // a1
* // b1
* // c1
* // continues to list a,b,c with respective ascending integers
*
* @see {@link concatMap}
* @see {@link exhaustMap}
* @see {@link merge}
* @see {@link mergeAll}
* @see {@link mergeMapTo}
* @see {@link mergeScan}
* @see {@link switchMap}
*
* @param {function(value: T, ?index: number): ObservableInput} project A function
* that, when applied to an item emitted by the source Observable, returns an
* Observable.
* @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
* A function to produce the value on the output Observable based on the values
* and the indices of the source (outer) emission and the inner Observable
* emission. The arguments passed to this function are:
* - `outerValue`: the value that came from the source
* - `innerValue`: the value that came from the projected Observable
* - `outerIndex`: the "index" of the value that came from the source
* - `innerIndex`: the "index" of the value from the projected Observable
* @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
* Observables being subscribed to concurrently.
* @return {Observable} An Observable that emits the result of applying the
* projection function (and the optional `resultSelector`) to each item emitted
* by the source Observable and merging the results of the Observables obtained
* from this transformation.
* @method mergeMap
* @owner Observable
*/
function mergeMap(project, resultSelector, concurrent) {
if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
if (typeof resultSelector === 'number') {
concurrent = resultSelector;
resultSelector = null;
}
return this.lift(new MergeMapOperator(project, resultSelector, concurrent));
}
exports.mergeMap = mergeMap;
var MergeMapOperator = (function () {
function MergeMapOperator(project, resultSelector, concurrent) {
if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
this.project = project;
this.resultSelector = resultSelector;
this.concurrent = concurrent;
}
MergeMapOperator.prototype.call = function (observer, source) {
return source.subscribe(new MergeMapSubscriber(observer, this.project, this.resultSelector, this.concurrent));
};
return MergeMapOperator;
}());
exports.MergeMapOperator = MergeMapOperator;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var MergeMapSubscriber = (function (_super) {
__extends(MergeMapSubscriber, _super);
function MergeMapSubscriber(destination, project, resultSelector, concurrent) {
if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
_super.call(this, destination);
this.project = project;
this.resultSelector = resultSelector;
this.concurrent = concurrent;
this.hasCompleted = false;
this.buffer = [];
this.active = 0;
this.index = 0;
}
MergeMapSubscriber.prototype._next = function (value) {
if (this.active < this.concurrent) {
this._tryNext(value);
}
else {
this.buffer.push(value);
}
};
MergeMapSubscriber.prototype._tryNext = function (value) {
var result;
var index = this.index++;
try {
result = this.project(value, index);
}
catch (err) {
this.destination.error(err);
return;
}
this.active++;
this._innerSub(result, value, index);
};
MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index));
};
MergeMapSubscriber.prototype._complete = function () {
this.hasCompleted = true;
if (this.active === 0 && this.buffer.length === 0) {
this.destination.complete();
}
};
MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
if (this.resultSelector) {
this._notifyResultSelector(outerValue, innerValue, outerIndex, innerIndex);
}
else {
this.destination.next(innerValue);
}
};
MergeMapSubscriber.prototype._notifyResultSelector = function (outerValue, innerValue, outerIndex, innerIndex) {
var result;
try {
result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex);
}
catch (err) {
this.destination.error(err);
return;
}
this.destination.next(result);
};
MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
var buffer = this.buffer;
this.remove(innerSub);
this.active--;
if (buffer.length > 0) {
this._next(buffer.shift());
}
else if (this.active === 0 && this.hasCompleted) {
this.destination.complete();
}
};
return MergeMapSubscriber;
}(OuterSubscriber_1.OuterSubscriber));
exports.MergeMapSubscriber = MergeMapSubscriber;
//# sourceMappingURL=mergeMap.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/multicast.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var ConnectableObservable_1 = __webpack_require__("./node_modules/rxjs/observable/ConnectableObservable.js");
/* tslint:enable:max-line-length */
/**
* Returns an Observable that emits the results of invoking a specified selector on items
* emitted by a ConnectableObservable that shares a single subscription to the underlying stream.
*
*
*
* @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through
* which the source sequence's elements will be multicast to the selector function
* or Subject to push source elements into.
* @param {Function} [selector] - Optional selector function that can use the multicasted source stream
* as many times as needed, without causing multiple subscriptions to the source stream.
* Subscribers to the given source will receive all notifications of the source from the
* time of the subscription forward.
* @return {Observable} An Observable that emits the results of invoking the selector
* on the items emitted by a `ConnectableObservable` that shares a single subscription to
* the underlying stream.
* @method multicast
* @owner Observable
*/
function multicast(subjectOrSubjectFactory, selector) {
var subjectFactory;
if (typeof subjectOrSubjectFactory === 'function') {
subjectFactory = subjectOrSubjectFactory;
}
else {
subjectFactory = function subjectFactory() {
return subjectOrSubjectFactory;
};
}
if (typeof selector === 'function') {
return this.lift(new MulticastOperator(subjectFactory, selector));
}
var connectable = Object.create(this, ConnectableObservable_1.connectableObservableDescriptor);
connectable.source = this;
connectable.subjectFactory = subjectFactory;
return connectable;
}
exports.multicast = multicast;
var MulticastOperator = (function () {
function MulticastOperator(subjectFactory, selector) {
this.subjectFactory = subjectFactory;
this.selector = selector;
}
MulticastOperator.prototype.call = function (subscriber, source) {
var selector = this.selector;
var subject = this.subjectFactory();
var subscription = selector(subject).subscribe(subscriber);
subscription.add(source.subscribe(subject));
return subscription;
};
return MulticastOperator;
}());
exports.MulticastOperator = MulticastOperator;
//# sourceMappingURL=multicast.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/observeOn.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
var Notification_1 = __webpack_require__("./node_modules/rxjs/Notification.js");
/**
*
* Re-emits all notifications from source Observable with specified scheduler.
*
* Ensure a specific scheduler is used, from outside of an Observable.
*
* `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule
* notifications emitted by the source Observable. It might be useful, if you do not have control over
* internal scheduler of a given Observable, but want to control when its values are emitted nevertheless.
*
* Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable,
* but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal
* scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits
* notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`.
* An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split
* that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source
* Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a
* little bit more, to ensure that they are emitted at expected moments.
*
* As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications
* will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn`
* will delay all notifications - including error notifications - while `delay` will pass through error
* from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator
* for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used
* for notification emissions in general.
*
* @example
Ensure values in subscribe are called just before browser repaint.
* const intervals = Rx.Observable.interval(10); // Intervals are scheduled
* // with async scheduler by default...
*
* intervals
* .observeOn(Rx.Scheduler.animationFrame) // ...but we will observe on animationFrame
* .subscribe(val => { // scheduler to ensure smooth animation.
* someDiv.style.height = val + 'px';
* });
*
* @see {@link delay}
*
* @param {IScheduler} scheduler Scheduler that will be used to reschedule notifications from source Observable.
* @param {number} [delay] Number of milliseconds that states with what delay every notification should be rescheduled.
* @return {Observable} Observable that emits the same notifications as the source Observable,
* but with provided scheduler.
*
* @method observeOn
* @owner Observable
*/
function observeOn(scheduler, delay) {
if (delay === void 0) { delay = 0; }
return this.lift(new ObserveOnOperator(scheduler, delay));
}
exports.observeOn = observeOn;
var ObserveOnOperator = (function () {
function ObserveOnOperator(scheduler, delay) {
if (delay === void 0) { delay = 0; }
this.scheduler = scheduler;
this.delay = delay;
}
ObserveOnOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
};
return ObserveOnOperator;
}());
exports.ObserveOnOperator = ObserveOnOperator;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var ObserveOnSubscriber = (function (_super) {
__extends(ObserveOnSubscriber, _super);
function ObserveOnSubscriber(destination, scheduler, delay) {
if (delay === void 0) { delay = 0; }
_super.call(this, destination);
this.scheduler = scheduler;
this.delay = delay;
}
ObserveOnSubscriber.dispatch = function (arg) {
var notification = arg.notification, destination = arg.destination;
notification.observe(destination);
this.unsubscribe();
};
ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
this.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
};
ObserveOnSubscriber.prototype._next = function (value) {
this.scheduleMessage(Notification_1.Notification.createNext(value));
};
ObserveOnSubscriber.prototype._error = function (err) {
this.scheduleMessage(Notification_1.Notification.createError(err));
};
ObserveOnSubscriber.prototype._complete = function () {
this.scheduleMessage(Notification_1.Notification.createComplete());
};
return ObserveOnSubscriber;
}(Subscriber_1.Subscriber));
exports.ObserveOnSubscriber = ObserveOnSubscriber;
var ObserveOnMessage = (function () {
function ObserveOnMessage(notification, destination) {
this.notification = notification;
this.destination = destination;
}
return ObserveOnMessage;
}());
exports.ObserveOnMessage = ObserveOnMessage;
//# sourceMappingURL=observeOn.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/reduce.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
/* tslint:enable:max-line-length */
/**
* Applies an accumulator function over the source Observable, and returns the
* accumulated result when the source completes, given an optional seed value.
*
* Combines together all values emitted on the source,
* using an accumulator function that knows how to join a new source value into
* the accumulation from the past.
*
*
*
* Like
* [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce),
* `reduce` applies an `accumulator` function against an accumulation and each
* value of the source Observable (from the past) to reduce it to a single
* value, emitted on the output Observable. Note that `reduce` will only emit
* one value, only when the source Observable completes. It is equivalent to
* applying operator {@link scan} followed by operator {@link last}.
*
* Returns an Observable that applies a specified `accumulator` function to each
* item emitted by the source Observable. If a `seed` value is specified, then
* that value will be used as the initial value for the accumulator. If no seed
* value is specified, the first item of the source is used as the seed.
*
* @example
Count the number of click events that happened in 5 seconds
* var clicksInFiveSeconds = Rx.Observable.fromEvent(document, 'click')
* .takeUntil(Rx.Observable.interval(5000));
* var ones = clicksInFiveSeconds.mapTo(1);
* var seed = 0;
* var count = ones.reduce((acc, one) => acc + one, seed);
* count.subscribe(x => console.log(x));
*
* @see {@link count}
* @see {@link expand}
* @see {@link mergeScan}
* @see {@link scan}
*
* @param {function(acc: R, value: T, index: number): R} accumulator The accumulator function
* called on each source value.
* @param {R} [seed] The initial accumulation value.
* @return {Observable} An Observable that emits a single value that is the
* result of accumulating the values emitted by the source Observable.
* @method reduce
* @owner Observable
*/
function reduce(accumulator, seed) {
var hasSeed = false;
// providing a seed of `undefined` *should* be valid and trigger
// hasSeed! so don't use `seed !== undefined` checks!
// For this reason, we have to check it here at the original call site
// otherwise inside Operator/Subscriber we won't know if `undefined`
// means they didn't provide anything or if they literally provided `undefined`
if (arguments.length >= 2) {
hasSeed = true;
}
return this.lift(new ReduceOperator(accumulator, seed, hasSeed));
}
exports.reduce = reduce;
var ReduceOperator = (function () {
function ReduceOperator(accumulator, seed, hasSeed) {
if (hasSeed === void 0) { hasSeed = false; }
this.accumulator = accumulator;
this.seed = seed;
this.hasSeed = hasSeed;
}
ReduceOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new ReduceSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
};
return ReduceOperator;
}());
exports.ReduceOperator = ReduceOperator;
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var ReduceSubscriber = (function (_super) {
__extends(ReduceSubscriber, _super);
function ReduceSubscriber(destination, accumulator, seed, hasSeed) {
_super.call(this, destination);
this.accumulator = accumulator;
this.hasSeed = hasSeed;
this.index = 0;
this.hasValue = false;
this.acc = seed;
if (!this.hasSeed) {
this.index++;
}
}
ReduceSubscriber.prototype._next = function (value) {
if (this.hasValue || (this.hasValue = this.hasSeed)) {
this._tryReduce(value);
}
else {
this.acc = value;
this.hasValue = true;
}
};
ReduceSubscriber.prototype._tryReduce = function (value) {
var result;
try {
result = this.accumulator(this.acc, value, this.index++);
}
catch (err) {
this.destination.error(err);
return;
}
this.acc = result;
};
ReduceSubscriber.prototype._complete = function () {
if (this.hasValue || this.hasSeed) {
this.destination.next(this.acc);
}
this.destination.complete();
};
return ReduceSubscriber;
}(Subscriber_1.Subscriber));
exports.ReduceSubscriber = ReduceSubscriber;
//# sourceMappingURL=reduce.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/share.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var multicast_1 = __webpack_require__("./node_modules/rxjs/operator/multicast.js");
var Subject_1 = __webpack_require__("./node_modules/rxjs/Subject.js");
function shareSubjectFactory() {
return new Subject_1.Subject();
}
/**
* Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
* Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
* unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
* This is an alias for .publish().refCount().
*
*
*
* @return {Observable} An Observable that upon connection causes the source Observable to emit items to its Observers.
* @method share
* @owner Observable
*/
function share() {
return multicast_1.multicast.call(this, shareSubjectFactory).refCount();
}
exports.share = share;
;
//# sourceMappingURL=share.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/take.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
var ArgumentOutOfRangeError_1 = __webpack_require__("./node_modules/rxjs/util/ArgumentOutOfRangeError.js");
var EmptyObservable_1 = __webpack_require__("./node_modules/rxjs/observable/EmptyObservable.js");
/**
* Emits only the first `count` values emitted by the source Observable.
*
* Takes the first `count` values from the source, then
* completes.
*
*
*
* `take` returns an Observable that emits only the first `count` values emitted
* by the source Observable. If the source emits fewer than `count` values then
* all of its values are emitted. After that, it completes, regardless if the
* source completes.
*
* @example
Take the first 5 seconds of an infinite 1-second interval Observable
* var interval = Rx.Observable.interval(1000);
* var five = interval.take(5);
* five.subscribe(x => console.log(x));
*
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link takeWhile}
* @see {@link skip}
*
* @throws {ArgumentOutOfRangeError} When using `take(i)`, it delivers an
* ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
*
* @param {number} count The maximum number of `next` values to emit.
* @return {Observable} An Observable that emits only the first `count`
* values emitted by the source Observable, or all of the values from the source
* if the source emits fewer than `count` values.
* @method take
* @owner Observable
*/
function take(count) {
if (count === 0) {
return new EmptyObservable_1.EmptyObservable();
}
else {
return this.lift(new TakeOperator(count));
}
}
exports.take = take;
var TakeOperator = (function () {
function TakeOperator(total) {
this.total = total;
if (this.total < 0) {
throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
}
}
TakeOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new TakeSubscriber(subscriber, this.total));
};
return TakeOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var TakeSubscriber = (function (_super) {
__extends(TakeSubscriber, _super);
function TakeSubscriber(destination, total) {
_super.call(this, destination);
this.total = total;
this.count = 0;
}
TakeSubscriber.prototype._next = function (value) {
var total = this.total;
var count = ++this.count;
if (count <= total) {
this.destination.next(value);
if (count === total) {
this.destination.complete();
this.unsubscribe();
}
}
};
return TakeSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=take.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/takeUntil.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var OuterSubscriber_1 = __webpack_require__("./node_modules/rxjs/OuterSubscriber.js");
var subscribeToResult_1 = __webpack_require__("./node_modules/rxjs/util/subscribeToResult.js");
/**
* Emits the values emitted by the source Observable until a `notifier`
* Observable emits a value.
*
* Lets values pass until a second Observable,
* `notifier`, emits something. Then, it completes.
*
*
*
* `takeUntil` subscribes and begins mirroring the source Observable. It also
* monitors a second Observable, `notifier` that you provide. If the `notifier`
* emits a value or a complete notification, the output Observable stops
* mirroring the source Observable and completes.
*
* @example
Tick every second until the first click happens
* var interval = Rx.Observable.interval(1000);
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = interval.takeUntil(clicks);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeWhile}
* @see {@link skip}
*
* @param {Observable} notifier The Observable whose first emitted value will
* cause the output Observable of `takeUntil` to stop emitting values from the
* source Observable.
* @return {Observable} An Observable that emits the values from the source
* Observable until such time as `notifier` emits its first value.
* @method takeUntil
* @owner Observable
*/
function takeUntil(notifier) {
return this.lift(new TakeUntilOperator(notifier));
}
exports.takeUntil = takeUntil;
var TakeUntilOperator = (function () {
function TakeUntilOperator(notifier) {
this.notifier = notifier;
}
TakeUntilOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new TakeUntilSubscriber(subscriber, this.notifier));
};
return TakeUntilOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var TakeUntilSubscriber = (function (_super) {
__extends(TakeUntilSubscriber, _super);
function TakeUntilSubscriber(destination, notifier) {
_super.call(this, destination);
this.notifier = notifier;
this.add(subscribeToResult_1.subscribeToResult(this, notifier));
}
TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
this.complete();
};
TakeUntilSubscriber.prototype.notifyComplete = function () {
// noop
};
return TakeUntilSubscriber;
}(OuterSubscriber_1.OuterSubscriber));
//# sourceMappingURL=takeUntil.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/takeWhile.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
/**
* Emits values emitted by the source Observable so long as each value satisfies
* the given `predicate`, and then completes as soon as this `predicate` is not
* satisfied.
*
* Takes values from the source only while they pass the
* condition given. When the first value does not satisfy, it completes.
*
*
*
* `takeWhile` subscribes and begins mirroring the source Observable. Each value
* emitted on the source is given to the `predicate` function which returns a
* boolean, representing a condition to be satisfied by the source values. The
* output Observable emits the source values until such time as the `predicate`
* returns false, at which point `takeWhile` stops mirroring the source
* Observable and completes the output Observable.
*
* @example
Emit click events only while the clientX property is greater than 200
* var clicks = Rx.Observable.fromEvent(document, 'click');
* var result = clicks.takeWhile(ev => ev.clientX > 200);
* result.subscribe(x => console.log(x));
*
* @see {@link take}
* @see {@link takeLast}
* @see {@link takeUntil}
* @see {@link skip}
*
* @param {function(value: T, index: number): boolean} predicate A function that
* evaluates a value emitted by the source Observable and returns a boolean.
* Also takes the (zero-based) index as the second argument.
* @return {Observable} An Observable that emits the values from the source
* Observable so long as each value satisfies the condition defined by the
* `predicate`, then completes.
* @method takeWhile
* @owner Observable
*/
function takeWhile(predicate) {
return this.lift(new TakeWhileOperator(predicate));
}
exports.takeWhile = takeWhile;
var TakeWhileOperator = (function () {
function TakeWhileOperator(predicate) {
this.predicate = predicate;
}
TakeWhileOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate));
};
return TakeWhileOperator;
}());
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var TakeWhileSubscriber = (function (_super) {
__extends(TakeWhileSubscriber, _super);
function TakeWhileSubscriber(destination, predicate) {
_super.call(this, destination);
this.predicate = predicate;
this.index = 0;
}
TakeWhileSubscriber.prototype._next = function (value) {
var destination = this.destination;
var result;
try {
result = this.predicate(value, this.index++);
}
catch (err) {
destination.error(err);
return;
}
this.nextOrComplete(value, result);
};
TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
var destination = this.destination;
if (Boolean(predicateResult)) {
destination.next(value);
}
else {
destination.complete();
}
};
return TakeWhileSubscriber;
}(Subscriber_1.Subscriber));
//# sourceMappingURL=takeWhile.js.map
/***/ }),
/***/ "./node_modules/rxjs/operator/toPromise.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var root_1 = __webpack_require__("./node_modules/rxjs/util/root.js");
/* tslint:enable:max-line-length */
/**
* Converts an Observable sequence to a ES2015 compliant promise.
*
* @example
* // Using normal ES2015
* let source = Rx.Observable
* .of(42)
* .toPromise();
*
* source.then((value) => console.log('Value: %s', value));
* // => Value: 42
*
* // Rejected Promise
* // Using normal ES2015
* let source = Rx.Observable
* .throw(new Error('woops'))
* .toPromise();
*
* source
* .then((value) => console.log('Value: %s', value))
* .catch((err) => console.log('Error: %s', err));
* // => Error: Error: woops
*
* // Setting via the config
* Rx.config.Promise = RSVP.Promise;
*
* let source = Rx.Observable
* .of(42)
* .toPromise();
*
* source.then((value) => console.log('Value: %s', value));
* // => Value: 42
*
* // Setting via the method
* let source = Rx.Observable
* .of(42)
* .toPromise(RSVP.Promise);
*
* source.then((value) => console.log('Value: %s', value));
* // => Value: 42
*
* @param PromiseCtor promise The constructor of the promise. If not provided,
* it will look for a constructor first in Rx.config.Promise then fall back to
* the native Promise constructor if available.
* @return {Promise} An ES2015 compatible promise with the last value from
* the observable sequence.
* @method toPromise
* @owner Observable
*/
function toPromise(PromiseCtor) {
var _this = this;
if (!PromiseCtor) {
if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
PromiseCtor = root_1.root.Rx.config.Promise;
}
else if (root_1.root.Promise) {
PromiseCtor = root_1.root.Promise;
}
}
if (!PromiseCtor) {
throw new Error('no Promise impl found');
}
return new PromiseCtor(function (resolve, reject) {
var value;
_this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
});
}
exports.toPromise = toPromise;
//# sourceMappingURL=toPromise.js.map
/***/ }),
/***/ "./node_modules/rxjs/symbol/iterator.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var root_1 = __webpack_require__("./node_modules/rxjs/util/root.js");
function symbolIteratorPonyfill(root) {
var Symbol = root.Symbol;
if (typeof Symbol === 'function') {
if (!Symbol.iterator) {
Symbol.iterator = Symbol('iterator polyfill');
}
return Symbol.iterator;
}
else {
// [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC)
var Set_1 = root.Set;
if (Set_1 && typeof new Set_1()['@@iterator'] === 'function') {
return '@@iterator';
}
var Map_1 = root.Map;
// required for compatability with es6-shim
if (Map_1) {
var keys = Object.getOwnPropertyNames(Map_1.prototype);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
// according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal.
if (key !== 'entries' && key !== 'size' && Map_1.prototype[key] === Map_1.prototype['entries']) {
return key;
}
}
}
return '@@iterator';
}
}
exports.symbolIteratorPonyfill = symbolIteratorPonyfill;
exports.iterator = symbolIteratorPonyfill(root_1.root);
/**
* @deprecated use iterator instead
*/
exports.$$iterator = exports.iterator;
//# sourceMappingURL=iterator.js.map
/***/ }),
/***/ "./node_modules/rxjs/symbol/observable.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var root_1 = __webpack_require__("./node_modules/rxjs/util/root.js");
function getSymbolObservable(context) {
var $$observable;
var Symbol = context.Symbol;
if (typeof Symbol === 'function') {
if (Symbol.observable) {
$$observable = Symbol.observable;
}
else {
$$observable = Symbol('observable');
Symbol.observable = $$observable;
}
}
else {
$$observable = '@@observable';
}
return $$observable;
}
exports.getSymbolObservable = getSymbolObservable;
exports.observable = getSymbolObservable(root_1.root);
/**
* @deprecated use observable instead
*/
exports.$$observable = exports.observable;
//# sourceMappingURL=observable.js.map
/***/ }),
/***/ "./node_modules/rxjs/symbol/rxSubscriber.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var root_1 = __webpack_require__("./node_modules/rxjs/util/root.js");
var Symbol = root_1.root.Symbol;
exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
Symbol.for('rxSubscriber') : '@@rxSubscriber';
/**
* @deprecated use rxSubscriber instead
*/
exports.$$rxSubscriber = exports.rxSubscriber;
//# sourceMappingURL=rxSubscriber.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/ArgumentOutOfRangeError.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* An error thrown when an element was queried at a certain index of an
* Observable, but no such index or position exists in that sequence.
*
* @see {@link elementAt}
* @see {@link take}
* @see {@link takeLast}
*
* @class ArgumentOutOfRangeError
*/
var ArgumentOutOfRangeError = (function (_super) {
__extends(ArgumentOutOfRangeError, _super);
function ArgumentOutOfRangeError() {
var err = _super.call(this, 'argument out of range');
this.name = err.name = 'ArgumentOutOfRangeError';
this.stack = err.stack;
this.message = err.message;
}
return ArgumentOutOfRangeError;
}(Error));
exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
//# sourceMappingURL=ArgumentOutOfRangeError.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/EmptyError.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* An error thrown when an Observable or a sequence was queried but has no
* elements.
*
* @see {@link first}
* @see {@link last}
* @see {@link single}
*
* @class EmptyError
*/
var EmptyError = (function (_super) {
__extends(EmptyError, _super);
function EmptyError() {
var err = _super.call(this, 'no elements in sequence');
this.name = err.name = 'EmptyError';
this.stack = err.stack;
this.message = err.message;
}
return EmptyError;
}(Error));
exports.EmptyError = EmptyError;
//# sourceMappingURL=EmptyError.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/ObjectUnsubscribedError.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* An error thrown when an action is invalid because the object has been
* unsubscribed.
*
* @see {@link Subject}
* @see {@link BehaviorSubject}
*
* @class ObjectUnsubscribedError
*/
var ObjectUnsubscribedError = (function (_super) {
__extends(ObjectUnsubscribedError, _super);
function ObjectUnsubscribedError() {
var err = _super.call(this, 'object unsubscribed');
this.name = err.name = 'ObjectUnsubscribedError';
this.stack = err.stack;
this.message = err.message;
}
return ObjectUnsubscribedError;
}(Error));
exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
//# sourceMappingURL=ObjectUnsubscribedError.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/UnsubscriptionError.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}.
*/
var UnsubscriptionError = (function (_super) {
__extends(UnsubscriptionError, _super);
function UnsubscriptionError(errors) {
_super.call(this);
this.errors = errors;
var err = Error.call(this, errors ?
errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) { return ((i + 1) + ") " + err.toString()); }).join('\n ') : '');
this.name = err.name = 'UnsubscriptionError';
this.stack = err.stack;
this.message = err.message;
}
return UnsubscriptionError;
}(Error));
exports.UnsubscriptionError = UnsubscriptionError;
//# sourceMappingURL=UnsubscriptionError.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/errorObject.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// typeof any so that it we don't have to cast when comparing a result to the error object
exports.errorObject = { e: {} };
//# sourceMappingURL=errorObject.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/isArray.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
//# sourceMappingURL=isArray.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/isArrayLike.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.isArrayLike = (function (x) { return x && typeof x.length === 'number'; });
//# sourceMappingURL=isArrayLike.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/isFunction.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function isFunction(x) {
return typeof x === 'function';
}
exports.isFunction = isFunction;
//# sourceMappingURL=isFunction.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/isObject.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function isObject(x) {
return x != null && typeof x === 'object';
}
exports.isObject = isObject;
//# sourceMappingURL=isObject.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/isPromise.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function isPromise(value) {
return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
}
exports.isPromise = isPromise;
//# sourceMappingURL=isPromise.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/isScheduler.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
function isScheduler(value) {
return value && typeof value.schedule === 'function';
}
exports.isScheduler = isScheduler;
//# sourceMappingURL=isScheduler.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/root.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
// CommonJS / Node have global context exposed as "global" variable.
// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
// the global "global" var for now.
var __window = typeof window !== 'undefined' && window;
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
self instanceof WorkerGlobalScope && self;
var __global = typeof global !== 'undefined' && global;
var _root = __window || __global || __self;
exports.root = _root;
// Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
// This is needed when used with angular/tsickle which inserts a goog.module statement.
// Wrap in IIFE
(function () {
if (!_root) {
throw new Error('RxJS could not find any global context (window, self, global)');
}
})();
//# sourceMappingURL=root.js.map
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/global.js")))
/***/ }),
/***/ "./node_modules/rxjs/util/subscribeToResult.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var root_1 = __webpack_require__("./node_modules/rxjs/util/root.js");
var isArrayLike_1 = __webpack_require__("./node_modules/rxjs/util/isArrayLike.js");
var isPromise_1 = __webpack_require__("./node_modules/rxjs/util/isPromise.js");
var isObject_1 = __webpack_require__("./node_modules/rxjs/util/isObject.js");
var Observable_1 = __webpack_require__("./node_modules/rxjs/Observable.js");
var iterator_1 = __webpack_require__("./node_modules/rxjs/symbol/iterator.js");
var InnerSubscriber_1 = __webpack_require__("./node_modules/rxjs/InnerSubscriber.js");
var observable_1 = __webpack_require__("./node_modules/rxjs/symbol/observable.js");
function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) {
var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex);
if (destination.closed) {
return null;
}
if (result instanceof Observable_1.Observable) {
if (result._isScalar) {
destination.next(result.value);
destination.complete();
return null;
}
else {
return result.subscribe(destination);
}
}
else if (isArrayLike_1.isArrayLike(result)) {
for (var i = 0, len = result.length; i < len && !destination.closed; i++) {
destination.next(result[i]);
}
if (!destination.closed) {
destination.complete();
}
}
else if (isPromise_1.isPromise(result)) {
result.then(function (value) {
if (!destination.closed) {
destination.next(value);
destination.complete();
}
}, function (err) { return destination.error(err); })
.then(null, function (err) {
// Escaping the Promise trap: globally throw unhandled errors
root_1.root.setTimeout(function () { throw err; });
});
return destination;
}
else if (result && typeof result[iterator_1.iterator] === 'function') {
var iterator = result[iterator_1.iterator]();
do {
var item = iterator.next();
if (item.done) {
destination.complete();
break;
}
destination.next(item.value);
if (destination.closed) {
break;
}
} while (true);
}
else if (result && typeof result[observable_1.observable] === 'function') {
var obs = result[observable_1.observable]();
if (typeof obs.subscribe !== 'function') {
destination.error(new TypeError('Provided object does not correctly implement Symbol.observable'));
}
else {
return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex));
}
}
else {
var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
var msg = ("You provided " + value + " where a stream was expected.")
+ ' You can provide an Observable, Promise, Array, or Iterable.';
destination.error(new TypeError(msg));
}
return null;
}
exports.subscribeToResult = subscribeToResult;
//# sourceMappingURL=subscribeToResult.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/toSubscriber.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var Subscriber_1 = __webpack_require__("./node_modules/rxjs/Subscriber.js");
var rxSubscriber_1 = __webpack_require__("./node_modules/rxjs/symbol/rxSubscriber.js");
var Observer_1 = __webpack_require__("./node_modules/rxjs/Observer.js");
function toSubscriber(nextOrObserver, error, complete) {
if (nextOrObserver) {
if (nextOrObserver instanceof Subscriber_1.Subscriber) {
return nextOrObserver;
}
if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
return nextOrObserver[rxSubscriber_1.rxSubscriber]();
}
}
if (!nextOrObserver && !error && !complete) {
return new Subscriber_1.Subscriber(Observer_1.empty);
}
return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
}
exports.toSubscriber = toSubscriber;
//# sourceMappingURL=toSubscriber.js.map
/***/ }),
/***/ "./node_modules/rxjs/util/tryCatch.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var errorObject_1 = __webpack_require__("./node_modules/rxjs/util/errorObject.js");
var tryCatchTarget;
function tryCatcher() {
try {
return tryCatchTarget.apply(this, arguments);
}
catch (e) {
errorObject_1.errorObject.e = e;
return errorObject_1.errorObject;
}
}
function tryCatch(fn) {
tryCatchTarget = fn;
return tryCatcher;
}
exports.tryCatch = tryCatch;
;
//# sourceMappingURL=tryCatch.js.map
/***/ }),
/***/ "./node_modules/safe-json-parse/tuple.js":
/***/ (function(module, exports) {
module.exports = SafeParseTuple
function SafeParseTuple(obj, reviver) {
var json
var error = null
try {
json = JSON.parse(obj, reviver)
} catch (err) {
error = err
}
return [error, json]
}
/***/ }),
/***/ "./node_modules/sprintf/lib/sprintf.js":
/***/ (function(module, exports) {
/**
sprintf() for JavaScript 0.7-beta1
http://www.diveintojavascript.com/projects/javascript-sprintf
Copyright (c) Alexandru Marasteanu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of sprintf() for JavaScript nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Changelog:
2010.11.07 - 0.7-beta1-node
- converted it to a node.js compatible module
2010.09.06 - 0.7-beta1
- features: vsprintf, support for named placeholders
- enhancements: format cache, reduced global namespace pollution
2010.05.22 - 0.6:
- reverted to 0.4 and fixed the bug regarding the sign of the number 0
Note:
Thanks to Raphael Pigulla (http://www.n3rd.org/)
who warned me about a bug in 0.5, I discovered that the last update was
a regress. I appologize for that.
2010.05.09 - 0.5:
- bug fix: 0 is now preceeded with a + sign
- bug fix: the sign was not at the right position on padded results (Kamal Abdali)
- switched from GPL to BSD license
2007.10.21 - 0.4:
- unit test and patch (David Baird)
2007.09.17 - 0.3:
- bug fix: no longer throws exception on empty paramenters (Hans Pufal)
2007.09.11 - 0.2:
- feature: added argument swapping
2007.04.03 - 0.1:
- initial release
**/
var sprintf = (function() {
function get_type(variable) {
return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
}
function str_repeat(input, multiplier) {
for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
return output.join('');
}
var str_format = function() {
if (!str_format.cache.hasOwnProperty(arguments[0])) {
str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
}
return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
};
// convert object to simple one line string without indentation or
// newlines. Note that this implementation does not print array
// values to their actual place for sparse arrays.
//
// For example sparse array like this
// l = []
// l[4] = 1
// Would be printed as "[1]" instead of "[, , , , 1]"
//
// If argument 'seen' is not null and array the function will check for
// circular object references from argument.
str_format.object_stringify = function(obj, depth, maxdepth, seen) {
var str = '';
if (obj != null) {
switch( typeof(obj) ) {
case 'function':
return '[Function' + (obj.name ? ': '+obj.name : '') + ']';
break;
case 'object':
if ( obj instanceof Error) { return '[' + obj.toString() + ']' };
if (depth >= maxdepth) return '[Object]'
if (seen) {
// add object to seen list
seen = seen.slice(0)
seen.push(obj);
}
if (obj.length != null) { //array
str += '[';
var arr = []
for (var i in obj) {
if (seen && seen.indexOf(obj[i]) >= 0) arr.push('[Circular]');
else arr.push(str_format.object_stringify(obj[i], depth+1, maxdepth, seen));
}
str += arr.join(', ') + ']';
} else if ('getMonth' in obj) { // date
return 'Date(' + obj + ')';
} else { // object
str += '{';
var arr = []
for (var k in obj) {
if(obj.hasOwnProperty(k)) {
if (seen && seen.indexOf(obj[k]) >= 0) arr.push(k + ': [Circular]');
else arr.push(k +': ' +str_format.object_stringify(obj[k], depth+1, maxdepth, seen));
}
}
str += arr.join(', ') + '}';
}
return str;
break;
case 'string':
return '"' + obj + '"';
break
}
}
return '' + obj;
}
str_format.format = function(parse_tree, argv) {
var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
for (i = 0; i < tree_length; i++) {
node_type = get_type(parse_tree[i]);
if (node_type === 'string') {
output.push(parse_tree[i]);
}
else if (node_type === 'array') {
match = parse_tree[i]; // convenience purposes only
if (match[2]) { // keyword argument
arg = argv[cursor];
for (k = 0; k < match[2].length; k++) {
if (!arg.hasOwnProperty(match[2][k])) {
throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
}
arg = arg[match[2][k]];
}
}
else if (match[1]) { // positional argument (explicit)
arg = argv[match[1]];
}
else { // positional argument (implicit)
arg = argv[cursor++];
}
if (/[^sO]/.test(match[8]) && (get_type(arg) != 'number')) {
throw new Error(sprintf('[sprintf] expecting number but found %s "' + arg + '"', get_type(arg)));
}
switch (match[8]) {
case 'b': arg = arg.toString(2); break;
case 'c': arg = String.fromCharCode(arg); break;
case 'd': arg = parseInt(arg, 10); break;
case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
case 'O': arg = str_format.object_stringify(arg, 0, parseInt(match[7]) || 5); break;
case 'o': arg = arg.toString(8); break;
case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
case 'u': arg = Math.abs(arg); break;
case 'x': arg = arg.toString(16); break;
case 'X': arg = arg.toString(16).toUpperCase(); break;
}
arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
pad_length = match[6] - String(arg).length;
pad = match[6] ? str_repeat(pad_character, pad_length) : '';
output.push(match[5] ? arg + pad : pad + arg);
}
}
return output.join('');
};
str_format.cache = {};
str_format.parse = function(fmt) {
var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
while (_fmt) {
if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
parse_tree.push(match[0]);
}
else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
parse_tree.push('%');
}
else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(_fmt)) !== null) {
if (match[2]) {
arg_names |= 1;
var field_list = [], replacement_field = match[2], field_match = [];
if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
}
else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
}
else {
throw new Error('[sprintf] ' + replacement_field);
}
}
}
else {
throw new Error('[sprintf] ' + replacement_field);
}
match[2] = field_list;
}
else {
arg_names |= 2;
}
if (arg_names === 3) {
throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported');
}
parse_tree.push(match);
}
else {
throw new Error('[sprintf] ' + _fmt);
}
_fmt = _fmt.substring(match[0].length);
}
return parse_tree;
};
return str_format;
})();
var vsprintf = function(fmt, argv) {
var argvClone = argv.slice();
argvClone.unshift(fmt);
return sprintf.apply(null, argvClone);
};
module.exports = sprintf;
sprintf.sprintf = sprintf;
sprintf.vsprintf = vsprintf;
/***/ }),
/***/ "./node_modules/timers-ext/max-timeout.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = 2147483647;
/***/ }),
/***/ "./node_modules/timers-ext/valid-timeout.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var toPosInt = __webpack_require__("./node_modules/es5-ext/number/to-pos-integer.js")
, maxTimeout = __webpack_require__("./node_modules/timers-ext/max-timeout.js");
module.exports = function (value) {
value = toPosInt(value);
if (value > maxTimeout) throw new TypeError(value + " exceeds maximum possible timeout");
return value;
};
/***/ }),
/***/ "./node_modules/tiny-inflate/index.js":
/***/ (function(module, exports) {
var TINF_OK = 0;
var TINF_DATA_ERROR = -3;
function Tree() {
this.table = new Uint16Array(16); /* table of code length counts */
this.trans = new Uint16Array(288); /* code -> symbol translation table */
}
function Data(source, dest) {
this.source = source;
this.sourceIndex = 0;
this.tag = 0;
this.bitcount = 0;
this.dest = dest;
this.destLen = 0;
this.ltree = new Tree(); /* dynamic length/symbol tree */
this.dtree = new Tree(); /* dynamic distance tree */
}
/* --------------------------------------------------- *
* -- uninitialized global data (static structures) -- *
* --------------------------------------------------- */
var sltree = new Tree();
var sdtree = new Tree();
/* extra bits and base tables for length codes */
var length_bits = new Uint8Array(30);
var length_base = new Uint16Array(30);
/* extra bits and base tables for distance codes */
var dist_bits = new Uint8Array(30);
var dist_base = new Uint16Array(30);
/* special ordering of code length codes */
var clcidx = new Uint8Array([
16, 17, 18, 0, 8, 7, 9, 6,
10, 5, 11, 4, 12, 3, 13, 2,
14, 1, 15
]);
/* used by tinf_decode_trees, avoids allocations every call */
var code_tree = new Tree();
var lengths = new Uint8Array(288 + 32);
/* ----------------------- *
* -- utility functions -- *
* ----------------------- */
/* build extra bits and base tables */
function tinf_build_bits_base(bits, base, delta, first) {
var i, sum;
/* build bits table */
for (i = 0; i < delta; ++i) bits[i] = 0;
for (i = 0; i < 30 - delta; ++i) bits[i + delta] = i / delta | 0;
/* build base table */
for (sum = first, i = 0; i < 30; ++i) {
base[i] = sum;
sum += 1 << bits[i];
}
}
/* build the fixed huffman trees */
function tinf_build_fixed_trees(lt, dt) {
var i;
/* build fixed length tree */
for (i = 0; i < 7; ++i) lt.table[i] = 0;
lt.table[7] = 24;
lt.table[8] = 152;
lt.table[9] = 112;
for (i = 0; i < 24; ++i) lt.trans[i] = 256 + i;
for (i = 0; i < 144; ++i) lt.trans[24 + i] = i;
for (i = 0; i < 8; ++i) lt.trans[24 + 144 + i] = 280 + i;
for (i = 0; i < 112; ++i) lt.trans[24 + 144 + 8 + i] = 144 + i;
/* build fixed distance tree */
for (i = 0; i < 5; ++i) dt.table[i] = 0;
dt.table[5] = 32;
for (i = 0; i < 32; ++i) dt.trans[i] = i;
}
/* given an array of code lengths, build a tree */
var offs = new Uint16Array(16);
function tinf_build_tree(t, lengths, off, num) {
var i, sum;
/* clear code length count table */
for (i = 0; i < 16; ++i) t.table[i] = 0;
/* scan symbol lengths, and sum code length counts */
for (i = 0; i < num; ++i) t.table[lengths[off + i]]++;
t.table[0] = 0;
/* compute offset table for distribution sort */
for (sum = 0, i = 0; i < 16; ++i) {
offs[i] = sum;
sum += t.table[i];
}
/* create code->symbol translation table (symbols sorted by code) */
for (i = 0; i < num; ++i) {
if (lengths[off + i]) t.trans[offs[lengths[off + i]]++] = i;
}
}
/* ---------------------- *
* -- decode functions -- *
* ---------------------- */
/* get one bit from source stream */
function tinf_getbit(d) {
/* check if tag is empty */
if (!d.bitcount--) {
/* load next tag */
d.tag = d.source[d.sourceIndex++];
d.bitcount = 7;
}
/* shift bit out of tag */
var bit = d.tag & 1;
d.tag >>>= 1;
return bit;
}
/* read a num bit value from a stream and add base */
function tinf_read_bits(d, num, base) {
if (!num)
return base;
while (d.bitcount < 24) {
d.tag |= d.source[d.sourceIndex++] << d.bitcount;
d.bitcount += 8;
}
var val = d.tag & (0xffff >>> (16 - num));
d.tag >>>= num;
d.bitcount -= num;
return val + base;
}
/* given a data stream and a tree, decode a symbol */
function tinf_decode_symbol(d, t) {
while (d.bitcount < 24) {
d.tag |= d.source[d.sourceIndex++] << d.bitcount;
d.bitcount += 8;
}
var sum = 0, cur = 0, len = 0;
var tag = d.tag;
/* get more bits while code value is above sum */
do {
cur = 2 * cur + (tag & 1);
tag >>>= 1;
++len;
sum += t.table[len];
cur -= t.table[len];
} while (cur >= 0);
d.tag = tag;
d.bitcount -= len;
return t.trans[sum + cur];
}
/* given a data stream, decode dynamic trees from it */
function tinf_decode_trees(d, lt, dt) {
var hlit, hdist, hclen;
var i, num, length;
/* get 5 bits HLIT (257-286) */
hlit = tinf_read_bits(d, 5, 257);
/* get 5 bits HDIST (1-32) */
hdist = tinf_read_bits(d, 5, 1);
/* get 4 bits HCLEN (4-19) */
hclen = tinf_read_bits(d, 4, 4);
for (i = 0; i < 19; ++i) lengths[i] = 0;
/* read code lengths for code length alphabet */
for (i = 0; i < hclen; ++i) {
/* get 3 bits code length (0-7) */
var clen = tinf_read_bits(d, 3, 0);
lengths[clcidx[i]] = clen;
}
/* build code length tree */
tinf_build_tree(code_tree, lengths, 0, 19);
/* decode code lengths for the dynamic trees */
for (num = 0; num < hlit + hdist;) {
var sym = tinf_decode_symbol(d, code_tree);
switch (sym) {
case 16:
/* copy previous code length 3-6 times (read 2 bits) */
var prev = lengths[num - 1];
for (length = tinf_read_bits(d, 2, 3); length; --length) {
lengths[num++] = prev;
}
break;
case 17:
/* repeat code length 0 for 3-10 times (read 3 bits) */
for (length = tinf_read_bits(d, 3, 3); length; --length) {
lengths[num++] = 0;
}
break;
case 18:
/* repeat code length 0 for 11-138 times (read 7 bits) */
for (length = tinf_read_bits(d, 7, 11); length; --length) {
lengths[num++] = 0;
}
break;
default:
/* values 0-15 represent the actual code lengths */
lengths[num++] = sym;
break;
}
}
/* build dynamic trees */
tinf_build_tree(lt, lengths, 0, hlit);
tinf_build_tree(dt, lengths, hlit, hdist);
}
/* ----------------------------- *
* -- block inflate functions -- *
* ----------------------------- */
/* given a stream and two trees, inflate a block of data */
function tinf_inflate_block_data(d, lt, dt) {
while (1) {
var sym = tinf_decode_symbol(d, lt);
/* check for end of block */
if (sym === 256) {
return TINF_OK;
}
if (sym < 256) {
d.dest[d.destLen++] = sym;
} else {
var length, dist, offs;
var i;
sym -= 257;
/* possibly get more bits from length code */
length = tinf_read_bits(d, length_bits[sym], length_base[sym]);
dist = tinf_decode_symbol(d, dt);
/* possibly get more bits from distance code */
offs = d.destLen - tinf_read_bits(d, dist_bits[dist], dist_base[dist]);
/* copy match */
for (i = offs; i < offs + length; ++i) {
d.dest[d.destLen++] = d.dest[i];
}
}
}
}
/* inflate an uncompressed block of data */
function tinf_inflate_uncompressed_block(d) {
var length, invlength;
var i;
/* unread from bitbuffer */
while (d.bitcount > 8) {
d.sourceIndex--;
d.bitcount -= 8;
}
/* get length */
length = d.source[d.sourceIndex + 1];
length = 256 * length + d.source[d.sourceIndex];
/* get one's complement of length */
invlength = d.source[d.sourceIndex + 3];
invlength = 256 * invlength + d.source[d.sourceIndex + 2];
/* check length */
if (length !== (~invlength & 0x0000ffff))
return TINF_DATA_ERROR;
d.sourceIndex += 4;
/* copy block */
for (i = length; i; --i)
d.dest[d.destLen++] = d.source[d.sourceIndex++];
/* make sure we start next block on a byte boundary */
d.bitcount = 0;
return TINF_OK;
}
/* inflate stream from source to dest */
function tinf_uncompress(source, dest) {
var d = new Data(source, dest);
var bfinal, btype, res;
do {
/* read final block flag */
bfinal = tinf_getbit(d);
/* read block type (2 bits) */
btype = tinf_read_bits(d, 2, 0);
/* decompress block */
switch (btype) {
case 0:
/* decompress uncompressed block */
res = tinf_inflate_uncompressed_block(d);
break;
case 1:
/* decompress block with fixed huffman trees */
res = tinf_inflate_block_data(d, sltree, sdtree);
break;
case 2:
/* decompress block with dynamic huffman trees */
tinf_decode_trees(d, d.ltree, d.dtree);
res = tinf_inflate_block_data(d, d.ltree, d.dtree);
break;
default:
res = TINF_DATA_ERROR;
}
if (res !== TINF_OK)
throw new Error('Data error');
} while (!bfinal);
if (d.destLen < d.dest.length) {
if (typeof d.dest.slice === 'function')
return d.dest.slice(0, d.destLen);
else
return d.dest.subarray(0, d.destLen);
}
return d.dest;
}
/* -------------------- *
* -- initialization -- *
* -------------------- */
/* build fixed huffman trees */
tinf_build_fixed_trees(sltree, sdtree);
/* build extra bits and base tables */
tinf_build_bits_base(length_bits, length_base, 4, 3);
tinf_build_bits_base(dist_bits, dist_base, 2, 1);
/* fix a special case */
length_bits[28] = 0;
length_base[28] = 258;
module.exports = tinf_uncompress;
/***/ }),
/***/ "./node_modules/trim/index.js":
/***/ (function(module, exports) {
exports = module.exports = trim;
function trim(str){
return str.replace(/^\s*|\s*$/g, '');
}
exports.left = function(str){
return str.replace(/^\s*/, '');
};
exports.right = function(str){
return str.replace(/\s*$/, '');
};
/***/ }),
/***/ "./node_modules/tsml/tsml.js":
/***/ (function(module, exports) {
function clean (s) {
return s.replace(/\n\r?\s*/g, '')
}
module.exports = function tsml (sa) {
var s = ''
, i = 0
for (; i < arguments.length; i++)
s += clean(sa[i]) + (arguments[i + 1] || '')
return s
}
/***/ }),
/***/ "./node_modules/util/node_modules/inherits/inherits_browser.js":
/***/ (function(module, exports) {
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
/***/ }),
/***/ "./node_modules/util/support/isBufferBrowser.js":
/***/ (function(module, exports) {
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}
/***/ }),
/***/ "./node_modules/util/util.js":
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var formatRegExp = /%[sdj%]/g;
exports.format = function(f) {
if (!isString(f)) {
var objects = [];
for (var i = 0; i < arguments.length; i++) {
objects.push(inspect(arguments[i]));
}
return objects.join(' ');
}
var i = 1;
var args = arguments;
var len = args.length;
var str = String(f).replace(formatRegExp, function(x) {
if (x === '%%') return '%';
if (i >= len) return x;
switch (x) {
case '%s': return String(args[i++]);
case '%d': return Number(args[i++]);
case '%j':
try {
return JSON.stringify(args[i++]);
} catch (_) {
return '[Circular]';
}
default:
return x;
}
});
for (var x = args[i]; i < len; x = args[++i]) {
if (isNull(x) || !isObject(x)) {
str += ' ' + x;
} else {
str += ' ' + inspect(x);
}
}
return str;
};
// Mark that a method should not be used.
// Returns a modified function which warns once by default.
// If --no-deprecation is set, then it is a no-op.
exports.deprecate = function(fn, msg) {
// Allow for deprecating things in the process of starting up.
if (isUndefined(global.process)) {
return function() {
return exports.deprecate(fn, msg).apply(this, arguments);
};
}
if (process.noDeprecation === true) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (process.throwDeprecation) {
throw new Error(msg);
} else if (process.traceDeprecation) {
console.trace(msg);
} else {
console.error(msg);
}
warned = true;
}
return fn.apply(this, arguments);
}
return deprecated;
};
var debugs = {};
var debugEnviron;
exports.debuglog = function(set) {
if (isUndefined(debugEnviron))
debugEnviron = process.env.NODE_DEBUG || '';
set = set.toUpperCase();
if (!debugs[set]) {
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
var pid = process.pid;
debugs[set] = function() {
var msg = exports.format.apply(exports, arguments);
console.error('%s %d: %s', set, pid, msg);
};
} else {
debugs[set] = function() {};
}
}
return debugs[set];
};
/**
* Echos the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} obj The object to print out.
* @param {Object} opts Optional options object that alters the output.
*/
/* legacy: obj, showHidden, depth, colors*/
function inspect(obj, opts) {
// default options
var ctx = {
seen: [],
stylize: stylizeNoColor
};
// legacy...
if (arguments.length >= 3) ctx.depth = arguments[2];
if (arguments.length >= 4) ctx.colors = arguments[3];
if (isBoolean(opts)) {
// legacy...
ctx.showHidden = opts;
} else if (opts) {
// got an "options" object
exports._extend(ctx, opts);
}
// set default options
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
if (isUndefined(ctx.depth)) ctx.depth = 2;
if (isUndefined(ctx.colors)) ctx.colors = false;
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
if (ctx.colors) ctx.stylize = stylizeWithColor;
return formatValue(ctx, obj, ctx.depth);
}
exports.inspect = inspect;
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
inspect.colors = {
'bold' : [1, 22],
'italic' : [3, 23],
'underline' : [4, 24],
'inverse' : [7, 27],
'white' : [37, 39],
'grey' : [90, 39],
'black' : [30, 39],
'blue' : [34, 39],
'cyan' : [36, 39],
'green' : [32, 39],
'magenta' : [35, 39],
'red' : [31, 39],
'yellow' : [33, 39]
};
// Don't use 'blue' not visible on cmd.exe
inspect.styles = {
'special': 'cyan',
'number': 'yellow',
'boolean': 'yellow',
'undefined': 'grey',
'null': 'bold',
'string': 'green',
'date': 'magenta',
// "name": intentionally not styling
'regexp': 'red'
};
function stylizeWithColor(str, styleType) {
var style = inspect.styles[styleType];
if (style) {
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
'\u001b[' + inspect.colors[style][1] + 'm';
} else {
return str;
}
}
function stylizeNoColor(str, styleType) {
return str;
}
function arrayToHash(array) {
var hash = {};
array.forEach(function(val, idx) {
hash[val] = true;
});
return hash;
}
function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (ctx.customInspect &&
value &&
isFunction(value.inspect) &&
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
var ret = value.inspect(recurseTimes, ctx);
if (!isString(ret)) {
ret = formatValue(ctx, ret, recurseTimes);
}
return ret;
}
// Primitive types cannot have properties
var primitive = formatPrimitive(ctx, value);
if (primitive) {
return primitive;
}
// Look up the keys of the object.
var keys = Object.keys(value);
var visibleKeys = arrayToHash(keys);
if (ctx.showHidden) {
keys = Object.getOwnPropertyNames(value);
}
// IE doesn't make error fields non-enumerable
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
if (isError(value)
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
return formatError(value);
}
// Some type of object without properties can be shortcutted.
if (keys.length === 0) {
if (isFunction(value)) {
var name = value.name ? ': ' + value.name : '';
return ctx.stylize('[Function' + name + ']', 'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
}
if (isDate(value)) {
return ctx.stylize(Date.prototype.toString.call(value), 'date');
}
if (isError(value)) {
return formatError(value);
}
}
var base = '', array = false, braces = ['{', '}'];
// Make Array say that they are Array
if (isArray(value)) {
array = true;
braces = ['[', ']'];
}
// Make functions say that they are functions
if (isFunction(value)) {
var n = value.name ? ': ' + value.name : '';
base = ' [Function' + n + ']';
}
// Make RegExps say that they are RegExps
if (isRegExp(value)) {
base = ' ' + RegExp.prototype.toString.call(value);
}
// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + Date.prototype.toUTCString.call(value);
}
// Make error with message first say the error
if (isError(value)) {
base = ' ' + formatError(value);
}
if (keys.length === 0 && (!array || value.length == 0)) {
return braces[0] + base + braces[1];
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
} else {
return ctx.stylize('[Object]', 'special');
}
}
ctx.seen.push(value);
var output;
if (array) {
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
} else {
output = keys.map(function(key) {
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
});
}
ctx.seen.pop();
return reduceToSingleString(output, base, braces);
}
function formatPrimitive(ctx, value) {
if (isUndefined(value))
return ctx.stylize('undefined', 'undefined');
if (isString(value)) {
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
.replace(/\\"/g, '"') + '\'';
return ctx.stylize(simple, 'string');
}
if (isNumber(value))
return ctx.stylize('' + value, 'number');
if (isBoolean(value))
return ctx.stylize('' + value, 'boolean');
// For some reason typeof null is "object", so special case here.
if (isNull(value))
return ctx.stylize('null', 'null');
}
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
}
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
}
}
keys.forEach(function(key) {
if (!key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
}
});
return output;
}
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str, desc;
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
if (desc.get) {
if (desc.set) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]', 'special');
}
} else {
if (desc.set) {
str = ctx.stylize('[Setter]', 'special');
}
}
if (!hasOwnProperty(visibleKeys, key)) {
name = '[' + key + ']';
}
if (!str) {
if (ctx.seen.indexOf(desc.value) < 0) {
if (isNull(recurseTimes)) {
str = formatValue(ctx, desc.value, null);
} else {
str = formatValue(ctx, desc.value, recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = ctx.stylize('[Circular]', 'special');
}
}
if (isUndefined(name)) {
if (array && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
name = ctx.stylize(name, 'name');
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = ctx.stylize(name, 'string');
}
}
return name + ': ' + str;
}
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
}, 0);
if (length > 60) {
return braces[0] +
(base === '' ? '' : base + '\n ') +
' ' +
output.join(',\n ') +
' ' +
braces[1];
}
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
// NOTE: These type checking functions intentionally don't use `instanceof`
// because it is fragile and can be easily faked with `Object.create()`.
function isArray(ar) {
return Array.isArray(ar);
}
exports.isArray = isArray;
function isBoolean(arg) {
return typeof arg === 'boolean';
}
exports.isBoolean = isBoolean;
function isNull(arg) {
return arg === null;
}
exports.isNull = isNull;
function isNullOrUndefined(arg) {
return arg == null;
}
exports.isNullOrUndefined = isNullOrUndefined;
function isNumber(arg) {
return typeof arg === 'number';
}
exports.isNumber = isNumber;
function isString(arg) {
return typeof arg === 'string';
}
exports.isString = isString;
function isSymbol(arg) {
return typeof arg === 'symbol';
}
exports.isSymbol = isSymbol;
function isUndefined(arg) {
return arg === void 0;
}
exports.isUndefined = isUndefined;
function isRegExp(re) {
return isObject(re) && objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
exports.isObject = isObject;
function isDate(d) {
return isObject(d) && objectToString(d) === '[object Date]';
}
exports.isDate = isDate;
function isError(e) {
return isObject(e) &&
(objectToString(e) === '[object Error]' || e instanceof Error);
}
exports.isError = isError;
function isFunction(arg) {
return typeof arg === 'function';
}
exports.isFunction = isFunction;
function isPrimitive(arg) {
return arg === null ||
typeof arg === 'boolean' ||
typeof arg === 'number' ||
typeof arg === 'string' ||
typeof arg === 'symbol' || // ES6 symbol
typeof arg === 'undefined';
}
exports.isPrimitive = isPrimitive;
exports.isBuffer = __webpack_require__("./node_modules/util/support/isBufferBrowser.js");
function objectToString(o) {
return Object.prototype.toString.call(o);
}
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'];
// 26 Feb 16:19:34
function timestamp() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], time].join(' ');
}
// log is just a thin wrapper to console.log that prepends a timestamp
exports.log = function() {
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
};
/**
* Inherit the prototype methods from one constructor into another.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be rewritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype.
* @param {function} superCtor Constructor function to inherit prototype from.
*/
exports.inherits = __webpack_require__("./node_modules/util/node_modules/inherits/inherits_browser.js");
exports._extend = function(origin, add) {
// Don't do anything if add isn't an object
if (!add || !isObject(add)) return origin;
var keys = Object.keys(add);
var i = keys.length;
while (i--) {
origin[keys[i]] = add[keys[i]];
}
return origin;
};
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__("./node_modules/webpack/buildin/global.js"), __webpack_require__("./node_modules/process/browser.js")))
/***/ }),
/***/ "./node_modules/video.js/es5/big-play-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _button = __webpack_require__("./node_modules/video.js/es5/button.js");
var _button2 = _interopRequireDefault(_button);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file big-play-button.js
*/
/**
* The initial play button that shows before the video has played. The hiding of the
* `BigPlayButton` get done via CSS and `Player` states.
*
* @extends Button
*/
var BigPlayButton = function (_Button) {
_inherits(BigPlayButton, _Button);
function BigPlayButton() {
_classCallCheck(this, BigPlayButton);
return _possibleConstructorReturn(this, _Button.apply(this, arguments));
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object. Always returns 'vjs-big-play-button'.
*/
BigPlayButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-big-play-button';
};
/**
* This gets called when a `BigPlayButton` "clicked". See {@link ClickableComponent}
* for more detailed information on what a click can be.
*
* @param {EventTarget~Event} event
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
BigPlayButton.prototype.handleClick = function handleClick(event) {
this.player_.play();
var cb = this.player_.getChild('controlBar');
var playToggle = cb && cb.getChild('playToggle');
if (!playToggle) {
this.player_.focus();
return;
}
this.setTimeout(function () {
playToggle.focus();
}, 1);
};
return BigPlayButton;
}(_button2['default']);
/**
* The text that should display over the `BigPlayButton`s controls. Added to for localization.
*
* @type {string}
* @private
*/
BigPlayButton.prototype.controlText_ = 'Play Video';
_component2['default'].registerComponent('BigPlayButton', BigPlayButton);
exports['default'] = BigPlayButton;
/***/ }),
/***/ "./node_modules/video.js/es5/button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _clickableComponent = __webpack_require__("./node_modules/video.js/es5/clickable-component.js");
var _clickableComponent2 = _interopRequireDefault(_clickableComponent);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file button.js
*/
/**
* Base class for all buttons.
*
* @extends ClickableComponent
*/
var Button = function (_ClickableComponent) {
_inherits(Button, _ClickableComponent);
function Button() {
_classCallCheck(this, Button);
return _possibleConstructorReturn(this, _ClickableComponent.apply(this, arguments));
}
/**
* Create the `Button`s DOM element.
*
* @param {string} [tag=button]
* Element's node type. e.g. 'button'
*
* @param {Object} [props={}]
* An object of properties that should be set on the element.
*
* @param {Object} [attributes={}]
* An object of attributes that should be set on the element.
*
* @return {Element}
* The element that gets created.
*/
Button.prototype.createEl = function createEl() {
var tag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'button';
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
props = (0, _obj.assign)({
className: this.buildCSSClass()
}, props);
if (tag !== 'button') {
_log2['default'].warn('Creating a Button with an HTML element of ' + tag + ' is deprecated; use ClickableComponent instead.');
// Add properties for clickable element which is not a native HTML button
props = (0, _obj.assign)({
tabIndex: 0
}, props);
// Add ARIA attributes for clickable element which is not a native HTML button
attributes = (0, _obj.assign)({
role: 'button'
}, attributes);
}
// Add attributes for button element
attributes = (0, _obj.assign)({
// Necessary since the default button type is "submit"
'type': 'button',
// let the screen reader user know that the text of the button may change
'aria-live': 'polite'
}, attributes);
var el = _component2['default'].prototype.createEl.call(this, tag, props, attributes);
this.createControlTextEl(el);
return el;
};
/**
* Add a child `Component` inside of this `Button`.
*
* @param {string|Component} child
* The name or instance of a child to add.
*
* @param {Object} [options={}]
* The key/value store of options that will get passed to children of
* the child.
*
* @return {Component}
* The `Component` that gets added as a child. When using a string the
* `Component` will get created by this process.
*
* @deprecated since version 5
*/
Button.prototype.addChild = function addChild(child) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var className = this.constructor.name;
_log2['default'].warn('Adding an actionable (user controllable) child to a Button (' + className + ') is not supported; use a ClickableComponent instead.');
// Avoid the error message generated by ClickableComponent's addChild method
return _component2['default'].prototype.addChild.call(this, child, options);
};
/**
* Enable the `Button` element so that it can be activated or clicked. Use this with
* {@link Button#disable}.
*/
Button.prototype.enable = function enable() {
_ClickableComponent.prototype.enable.call(this);
this.el_.removeAttribute('disabled');
};
/**
* Enable the `Button` element so that it cannot be activated or clicked. Use this with
* {@link Button#enable}.
*/
Button.prototype.disable = function disable() {
_ClickableComponent.prototype.disable.call(this);
this.el_.setAttribute('disabled', 'disabled');
};
/**
* This gets called when a `Button` has focus and `keydown` is triggered via a key
* press.
*
* @param {EventTarget~Event} event
* The event that caused this function to get called.
*
* @listens keydown
*/
Button.prototype.handleKeyPress = function handleKeyPress(event) {
// Ignore Space (32) or Enter (13) key operation, which is handled by the browser for a button.
if (event.which === 32 || event.which === 13) {
return;
}
// Pass keypress handling up for unsupported keys
_ClickableComponent.prototype.handleKeyPress.call(this, event);
};
return Button;
}(_clickableComponent2['default']);
_component2['default'].registerComponent('Button', Button);
exports['default'] = Button;
/***/ }),
/***/ "./node_modules/video.js/es5/clickable-component.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _events = __webpack_require__("./node_modules/video.js/es5/utils/events.js");
var Events = _interopRequireWildcard(_events);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file button.js
*/
/**
* Clickable Component which is clickable or keyboard actionable,
* but is not a native HTML button.
*
* @extends Component
*/
var ClickableComponent = function (_Component) {
_inherits(ClickableComponent, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function ClickableComponent(player, options) {
_classCallCheck(this, ClickableComponent);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.emitTapEvents();
_this.enable();
return _this;
}
/**
* Create the `Component`s DOM element.
*
* @param {string} [tag=div]
* The element's node type.
*
* @param {Object} [props={}]
* An object of properties that should be set on the element.
*
* @param {Object} [attributes={}]
* An object of attributes that should be set on the element.
*
* @return {Element}
* The element that gets created.
*/
ClickableComponent.prototype.createEl = function createEl() {
var tag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'div';
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
props = (0, _obj.assign)({
className: this.buildCSSClass(),
tabIndex: 0
}, props);
if (tag === 'button') {
_log2['default'].error('Creating a ClickableComponent with an HTML element of ' + tag + ' is not supported; use a Button instead.');
}
// Add ARIA attributes for clickable element which is not a native HTML button
attributes = (0, _obj.assign)({
'role': 'button',
// let the screen reader user know that the text of the element may change
'aria-live': 'polite'
}, attributes);
this.tabIndex_ = props.tabIndex;
var el = _Component.prototype.createEl.call(this, tag, props, attributes);
this.createControlTextEl(el);
return el;
};
/**
* Create a control text element on this `Component`
*
* @param {Element} [el]
* Parent element for the control text.
*
* @return {Element}
* The control text element that gets created.
*/
ClickableComponent.prototype.createControlTextEl = function createControlTextEl(el) {
this.controlTextEl_ = Dom.createEl('span', {
className: 'vjs-control-text'
});
if (el) {
el.appendChild(this.controlTextEl_);
}
this.controlText(this.controlText_, el);
return this.controlTextEl_;
};
/**
* Get or set the localize text to use for the controls on the `Component`.
*
* @param {string} [text]
* Control text for element.
*
* @param {Element} [el=this.el()]
* Element to set the title on.
*
* @return {string|ClickableComponent}
* - The control text when getting
* - Returns itself when setting; method can be chained.
*/
ClickableComponent.prototype.controlText = function controlText(text) {
var el = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.el();
if (!text) {
return this.controlText_ || 'Need Text';
}
var localizedText = this.localize(text);
this.controlText_ = text;
this.controlTextEl_.innerHTML = localizedText;
if (!this.nonIconControl) {
// Set title attribute if only an icon is shown
el.setAttribute('title', localizedText);
}
return this;
};
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
ClickableComponent.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-control vjs-button ' + _Component.prototype.buildCSSClass.call(this);
};
/**
* Enable this `Component`s element.
*
* @return {ClickableComponent}
* Returns itself; method can be chained.
*/
ClickableComponent.prototype.enable = function enable() {
this.removeClass('vjs-disabled');
this.el_.setAttribute('aria-disabled', 'false');
if (typeof this.tabIndex_ !== 'undefined') {
this.el_.setAttribute('tabIndex', this.tabIndex_);
}
this.on('tap', this.handleClick);
this.on('click', this.handleClick);
this.on('focus', this.handleFocus);
this.on('blur', this.handleBlur);
return this;
};
/**
* Disable this `Component`s element.
*
* @return {ClickableComponent}
* Returns itself; method can be chained.
*/
ClickableComponent.prototype.disable = function disable() {
this.addClass('vjs-disabled');
this.el_.setAttribute('aria-disabled', 'true');
if (typeof this.tabIndex_ !== 'undefined') {
this.el_.removeAttribute('tabIndex');
}
this.off('tap', this.handleClick);
this.off('click', this.handleClick);
this.off('focus', this.handleFocus);
this.off('blur', this.handleBlur);
return this;
};
/**
* This gets called when a `ClickableComponent` gets:
* - Clicked (via the `click` event, listening starts in the constructor)
* - Tapped (via the `tap` event, listening starts in the constructor)
* - The following things happen in order:
* 1. {@link ClickableComponent#handleFocus} is called via a `focus` event on the
* `ClickableComponent`.
* 2. {@link ClickableComponent#handleFocus} adds a listener for `keydown` on using
* {@link ClickableComponent#handleKeyPress}.
* 3. `ClickableComponent` has not had a `blur` event (`blur` means that focus was lost). The user presses
* the space or enter key.
* 4. {@link ClickableComponent#handleKeyPress} calls this function with the `keydown`
* event as a parameter.
*
* @param {EventTarget~Event} event
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
* @abstract
*/
ClickableComponent.prototype.handleClick = function handleClick(event) {};
/**
* This gets called when a `ClickableComponent` gains focus via a `focus` event.
* Turns on listening for `keydown` events. When they happen it
* calls `this.handleKeyPress`.
*
* @param {EventTarget~Event} event
* The `focus` event that caused this function to be called.
*
* @listens focus
*/
ClickableComponent.prototype.handleFocus = function handleFocus(event) {
Events.on(_document2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
};
/**
* Called when this ClickableComponent has focus and a key gets pressed down. By
* default it will call `this.handleClick` when the key is space or enter.
*
* @param {EventTarget~Event} event
* The `keydown` event that caused this function to be called.
*
* @listens keydown
*/
ClickableComponent.prototype.handleKeyPress = function handleKeyPress(event) {
// Support Space (32) or Enter (13) key operation to fire a click event
if (event.which === 32 || event.which === 13) {
event.preventDefault();
this.handleClick(event);
} else if (_Component.prototype.handleKeyPress) {
// Pass keypress handling up for unsupported keys
_Component.prototype.handleKeyPress.call(this, event);
}
};
/**
* Called when a `ClickableComponent` loses focus. Turns off the listener for
* `keydown` events. Which Stops `this.handleKeyPress` from getting called.
*
* @param {EventTarget~Event} event
* The `blur` event that caused this function to be called.
*
* @listens blur
*/
ClickableComponent.prototype.handleBlur = function handleBlur(event) {
Events.off(_document2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
};
return ClickableComponent;
}(_component2['default']);
_component2['default'].registerComponent('ClickableComponent', ClickableComponent);
exports['default'] = ClickableComponent;
/***/ }),
/***/ "./node_modules/video.js/es5/close-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _button = __webpack_require__("./node_modules/video.js/es5/button.js");
var _button2 = _interopRequireDefault(_button);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file close-button.js
*/
/**
* The `CloseButton` is a `{@link Button}` that fires a `close` event when
* it gets clicked.
*
* @extends Button
*/
var CloseButton = function (_Button) {
_inherits(CloseButton, _Button);
/**
* Creates an instance of the this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function CloseButton(player, options) {
_classCallCheck(this, CloseButton);
var _this = _possibleConstructorReturn(this, _Button.call(this, player, options));
_this.controlText(options && options.controlText || _this.localize('Close'));
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
CloseButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-close-button ' + _Button.prototype.buildCSSClass.call(this);
};
/**
* This gets called when a `CloseButton` gets clicked. See
* {@link ClickableComponent#handleClick} for more information on when this will be
* triggered
*
* @param {EventTarget~Event} event
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
* @fires CloseButton#close
*/
CloseButton.prototype.handleClick = function handleClick(event) {
/**
* Triggered when the a `CloseButton` is clicked.
*
* @event CloseButton#close
* @type {EventTarget~Event}
*
* @property {boolean} [bubbles=false]
* set to false so that the close event does not
* bubble up to parents if there is no listener
*/
this.trigger({ type: 'close', bubbles: false });
};
return CloseButton;
}(_button2['default']);
_component2['default'].registerComponent('CloseButton', CloseButton);
exports['default'] = CloseButton;
/***/ }),
/***/ "./node_modules/video.js/es5/component.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _guid = __webpack_require__("./node_modules/video.js/es5/utils/guid.js");
var Guid = _interopRequireWildcard(_guid);
var _events = __webpack_require__("./node_modules/video.js/es5/utils/events.js");
var Events = _interopRequireWildcard(_events);
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
var _toTitleCase = __webpack_require__("./node_modules/video.js/es5/utils/to-title-case.js");
var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
var _mergeOptions = __webpack_require__("./node_modules/video.js/es5/utils/merge-options.js");
var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } } /**
* Player Component - Base class for all UI objects
*
* @file component.js
*/
/**
* Base class for all UI Components.
* Components are UI objects which represent both a javascript object and an element
* in the DOM. They can be children of other components, and can have
* children themselves.
*
* Components can also use methods from {@link EventTarget}
*/
var Component = function () {
/**
* A callback that is called when a component is ready. Does not have any
* paramters and any callback value will be ignored.
*
* @callback Component~ReadyCallback
* @this Component
*/
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
#
* @param {Object[]} [options.children]
* An array of children objects to intialize this component with. Children objects have
* a name property that will be used if more than one component of the same type needs to be
* added.
*
* @param {Component~ReadyCallback} [ready]
* Function that gets called when the `Component` is ready.
*/
function Component(player, options, ready) {
_classCallCheck(this, Component);
// The component might be the player itself and we can't pass `this` to super
if (!player && this.play) {
this.player_ = player = this; // eslint-disable-line
} else {
this.player_ = player;
}
// Make a copy of prototype.options_ to protect against overriding defaults
this.options_ = (0, _mergeOptions2['default'])({}, this.options_);
// Updated options with supplied options
options = this.options_ = (0, _mergeOptions2['default'])(this.options_, options);
// Get ID from options or options element if one is supplied
this.id_ = options.id || options.el && options.el.id;
// If there was no ID from the options, generate one
if (!this.id_) {
// Don't require the player ID function in the case of mock players
var id = player && player.id && player.id() || 'no_player';
this.id_ = id + '_component_' + Guid.newGUID();
}
this.name_ = options.name || null;
// Create element if one wasn't provided in options
if (options.el) {
this.el_ = options.el;
} else if (options.createEl !== false) {
this.el_ = this.createEl();
}
this.children_ = [];
this.childIndex_ = {};
this.childNameIndex_ = {};
// Add any child components in options
if (options.initChildren !== false) {
this.initChildren();
}
this.ready(ready);
// Don't want to trigger ready here or it will before init is actually
// finished for all children that run this constructor
if (options.reportTouchActivity !== false) {
this.enableTouchActivity();
}
}
/**
* Dispose of the `Component` and all child components.
*
* @fires Component#dispose
*/
Component.prototype.dispose = function dispose() {
/**
* Triggered when a `Component` is disposed.
*
* @event Component#dispose
* @type {EventTarget~Event}
*
* @property {boolean} [bubbles=false]
* set to false so that the close event does not
* bubble up
*/
this.trigger({ type: 'dispose', bubbles: false });
// Dispose all children.
if (this.children_) {
for (var i = this.children_.length - 1; i >= 0; i--) {
if (this.children_[i].dispose) {
this.children_[i].dispose();
}
}
}
// Delete child references
this.children_ = null;
this.childIndex_ = null;
this.childNameIndex_ = null;
// Remove all event listeners.
this.off();
// Remove element from DOM
if (this.el_.parentNode) {
this.el_.parentNode.removeChild(this.el_);
}
Dom.removeElData(this.el_);
this.el_ = null;
};
/**
* Return the {@link Player} that the `Component` has attached to.
*
* @return {Player}
* The player that this `Component` has attached to.
*/
Component.prototype.player = function player() {
return this.player_;
};
/**
* Deep merge of options objects with new options.
* > Note: When both `obj` and `options` contain properties whose values are objects.
* The two properties get merged using {@link module:mergeOptions}
*
* @param {Object} obj
* The object that contains new options.
*
* @return {Object}
* A new object of `this.options_` and `obj` merged together.
*
* @deprecated since version 5
*/
Component.prototype.options = function options(obj) {
_log2['default'].warn('this.options() has been deprecated and will be moved to the constructor in 6.0');
if (!obj) {
return this.options_;
}
this.options_ = (0, _mergeOptions2['default'])(this.options_, obj);
return this.options_;
};
/**
* Get the `Component`s DOM element
*
* @return {Element}
* The DOM element for this `Component`.
*/
Component.prototype.el = function el() {
return this.el_;
};
/**
* Create the `Component`s DOM element.
*
* @param {string} [tagName]
* Element's DOM node type. e.g. 'div'
*
* @param {Object} [properties]
* An object of properties that should be set.
*
* @param {Object} [attributes]
* An object of attributes that should be set.
*
* @return {Element}
* The element that gets created.
*/
Component.prototype.createEl = function createEl(tagName, properties, attributes) {
return Dom.createEl(tagName, properties, attributes);
};
/**
* Localize a string given the string in english.
*
* @param {string} string
* The string to localize.
*
* @return {string}
* The localized string or if no localization exists the english string.
*/
Component.prototype.localize = function localize(string) {
var code = this.player_.language && this.player_.language();
var languages = this.player_.languages && this.player_.languages();
if (!code || !languages) {
return string;
}
var language = languages[code];
if (language && language[string]) {
return language[string];
}
var primaryCode = code.split('-')[0];
var primaryLang = languages[primaryCode];
if (primaryLang && primaryLang[string]) {
return primaryLang[string];
}
return string;
};
/**
* Return the `Component`s DOM element. This is where children get inserted.
* This will usually be the the same as the element returned in {@link Component#el}.
*
* @return {Element}
* The content element for this `Component`.
*/
Component.prototype.contentEl = function contentEl() {
return this.contentEl_ || this.el_;
};
/**
* Get this `Component`s ID
*
* @return {string}
* The id of this `Component`
*/
Component.prototype.id = function id() {
return this.id_;
};
/**
* Get the `Component`s name. The name gets used to reference the `Component`
* and is set during registration.
*
* @return {string}
* The name of this `Component`.
*/
Component.prototype.name = function name() {
return this.name_;
};
/**
* Get an array of all child components
*
* @return {Array}
* The children
*/
Component.prototype.children = function children() {
return this.children_;
};
/**
* Returns the child `Component` with the given `id`.
*
* @param {string} id
* The id of the child `Component` to get.
*
* @return {Component|undefined}
* The child `Component` with the given `id` or undefined.
*/
Component.prototype.getChildById = function getChildById(id) {
return this.childIndex_[id];
};
/**
* Returns the child `Component` with the given `name`.
*
* @param {string} name
* The name of the child `Component` to get.
*
* @return {Component|undefined}
* The child `Component` with the given `name` or undefined.
*/
Component.prototype.getChild = function getChild(name) {
if (!name) {
return;
}
name = (0, _toTitleCase2['default'])(name);
return this.childNameIndex_[name];
};
/**
* Add a child `Component` inside the current `Component`.
*
*
* @param {string|Component} child
* The name or instance of a child to add.
*
* @param {Object} [options={}]
* The key/value store of options that will get passed to children of
* the child.
*
* @param {number} [index=this.children_.length]
* The index to attempt to add a child into.
*
* @return {Component}
* The `Component` that gets added as a child. When using a string the
* `Component` will get created by this process.
*/
Component.prototype.addChild = function addChild(child) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.children_.length;
var component = void 0;
var componentName = void 0;
// If child is a string, create component with options
if (typeof child === 'string') {
componentName = (0, _toTitleCase2['default'])(child);
// Options can also be specified as a boolean,
// so convert to an empty object if false.
if (!options) {
options = {};
}
// Same as above, but true is deprecated so show a warning.
if (options === true) {
_log2['default'].warn('Initializing a child component with `true` is deprecated.' + 'Children should be defined in an array when possible, ' + 'but if necessary use an object instead of `true`.');
options = {};
}
var componentClassName = options.componentClass || componentName;
// Set name through options
options.name = componentName;
// Create a new object & element for this controls set
// If there's no .player_, this is a player
var ComponentClass = Component.getComponent(componentClassName);
if (!ComponentClass) {
throw new Error('Component ' + componentClassName + ' does not exist');
}
// data stored directly on the videojs object may be
// misidentified as a component to retain
// backwards-compatibility with 4.x. check to make sure the
// component class can be instantiated.
if (typeof ComponentClass !== 'function') {
return null;
}
component = new ComponentClass(this.player_ || this, options);
// child is a component instance
} else {
component = child;
}
this.children_.splice(index, 0, component);
if (typeof component.id === 'function') {
this.childIndex_[component.id()] = component;
}
// If a name wasn't used to create the component, check if we can use the
// name function of the component
componentName = componentName || component.name && (0, _toTitleCase2['default'])(component.name());
if (componentName) {
this.childNameIndex_[componentName] = component;
}
// Add the UI object's element to the container div (box)
// Having an element is not required
if (typeof component.el === 'function' && component.el()) {
var childNodes = this.contentEl().children;
var refNode = childNodes[index] || null;
this.contentEl().insertBefore(component.el(), refNode);
}
// Return so it can stored on parent object if desired.
return component;
};
/**
* Remove a child `Component` from this `Component`s list of children. Also removes
* the child `Component`s element from this `Component`s element.
*
* @param {Component} component
* The child `Component` to remove.
*/
Component.prototype.removeChild = function removeChild(component) {
if (typeof component === 'string') {
component = this.getChild(component);
}
if (!component || !this.children_) {
return;
}
var childFound = false;
for (var i = this.children_.length - 1; i >= 0; i--) {
if (this.children_[i] === component) {
childFound = true;
this.children_.splice(i, 1);
break;
}
}
if (!childFound) {
return;
}
this.childIndex_[component.id()] = null;
this.childNameIndex_[component.name()] = null;
var compEl = component.el();
if (compEl && compEl.parentNode === this.contentEl()) {
this.contentEl().removeChild(component.el());
}
};
/**
* Add and initialize default child `Component`s based upon options.
*/
Component.prototype.initChildren = function initChildren() {
var _this = this;
var children = this.options_.children;
if (children) {
// `this` is `parent`
var parentOptions = this.options_;
var handleAdd = function handleAdd(child) {
var name = child.name;
var opts = child.opts;
// Allow options for children to be set at the parent options
// e.g. videojs(id, { controlBar: false });
// instead of videojs(id, { children: { controlBar: false });
if (parentOptions[name] !== undefined) {
opts = parentOptions[name];
}
// Allow for disabling default components
// e.g. options['children']['posterImage'] = false
if (opts === false) {
return;
}
// Allow options to be passed as a simple boolean if no configuration
// is necessary.
if (opts === true) {
opts = {};
}
// We also want to pass the original player options
// to each component as well so they don't need to
// reach back into the player for options later.
opts.playerOptions = _this.options_.playerOptions;
// Create and add the child component.
// Add a direct reference to the child by name on the parent instance.
// If two of the same component are used, different names should be supplied
// for each
var newChild = _this.addChild(name, opts);
if (newChild) {
_this[name] = newChild;
}
};
// Allow for an array of children details to passed in the options
var workingChildren = void 0;
var Tech = Component.getComponent('Tech');
if (Array.isArray(children)) {
workingChildren = children;
} else {
workingChildren = Object.keys(children);
}
workingChildren
// children that are in this.options_ but also in workingChildren would
// give us extra children we do not want. So, we want to filter them out.
.concat(Object.keys(this.options_).filter(function (child) {
return !workingChildren.some(function (wchild) {
if (typeof wchild === 'string') {
return child === wchild;
}
return child === wchild.name;
});
})).map(function (child) {
var name = void 0;
var opts = void 0;
if (typeof child === 'string') {
name = child;
opts = children[name] || _this.options_[name] || {};
} else {
name = child.name;
opts = child;
}
return { name: name, opts: opts };
}).filter(function (child) {
// we have to make sure that child.name isn't in the techOrder since
// techs are registerd as Components but can't aren't compatible
// See https://github.com/videojs/video.js/issues/2772
var c = Component.getComponent(child.opts.componentClass || (0, _toTitleCase2['default'])(child.name));
return c && !Tech.isTech(c);
}).forEach(handleAdd);
}
};
/**
* Builds the default DOM class name. Should be overriden by sub-components.
*
* @return {string}
* The DOM class name for this object.
*
* @abstract
*/
Component.prototype.buildCSSClass = function buildCSSClass() {
// Child classes can include a function that does:
// return 'CLASS NAME' + this._super();
return '';
};
/**
* Add an `event listener` to this `Component`s element.
*
* The benefit of using this over the following:
* - `VjsEvents.on(otherElement, 'eventName', myFunc)`
* - `otherComponent.on('eventName', myFunc)`
*
* 1. Is that the listeners will get cleaned up when either component gets disposed.
* 1. It will also bind `myComponent` as the context of `myFunc`.
* > NOTE: If you remove the element from the DOM that has used `on` you need to
* clean up references using: `myComponent.trigger(el, 'dispose')`
* This will also allow the browser to garbage collect it. In special
* cases such as with `window` and `document`, which are both permanent,
* this is not necessary.
*
* @param {string|Component|string[]} [first]
* The event name, and array of event names, or another `Component`.
*
* @param {EventTarget~EventListener|string|string[]} [second]
* The listener function, an event name, or an Array of events names.
*
* @param {EventTarget~EventListener} [third]
* The event handler if `first` is a `Component` and `second` is an event name
* or an Array of event names.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @listens Component#dispose
*/
Component.prototype.on = function on(first, second, third) {
var _this2 = this;
if (typeof first === 'string' || Array.isArray(first)) {
Events.on(this.el_, first, Fn.bind(this, second));
// Targeting another component or element
} else {
var target = first;
var type = second;
var fn = Fn.bind(this, third);
// When this component is disposed, remove the listener from the other component
var removeOnDispose = function removeOnDispose() {
return _this2.off(target, type, fn);
};
// Use the same function ID so we can remove it later it using the ID
// of the original listener
removeOnDispose.guid = fn.guid;
this.on('dispose', removeOnDispose);
// If the other component is disposed first we need to clean the reference
// to the other component in this component's removeOnDispose listener
// Otherwise we create a memory leak.
var cleanRemover = function cleanRemover() {
return _this2.off('dispose', removeOnDispose);
};
// Add the same function ID so we can easily remove it later
cleanRemover.guid = fn.guid;
// Check if this is a DOM node
if (first.nodeName) {
// Add the listener to the other element
Events.on(target, type, fn);
Events.on(target, 'dispose', cleanRemover);
// Should be a component
// Not using `instanceof Component` because it makes mock players difficult
} else if (typeof first.on === 'function') {
// Add the listener to the other component
target.on(type, fn);
target.on('dispose', cleanRemover);
}
}
return this;
};
/**
* Remove an event listener from this `Component`s element. If the second argument is
* exluded all listeners for the type passed in as the first argument will be removed.
*
* @param {string|Component|string[]} [first]
* The event name, and array of event names, or another `Component`.
*
* @param {EventTarget~EventListener|string|string[]} [second]
* The listener function, an event name, or an Array of events names.
*
* @param {EventTarget~EventListener} [third]
* The event handler if `first` is a `Component` and `second` is an event name
* or an Array of event names.
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.off = function off(first, second, third) {
if (!first || typeof first === 'string' || Array.isArray(first)) {
Events.off(this.el_, first, second);
} else {
var target = first;
var type = second;
// Ensure there's at least a guid, even if the function hasn't been used
var fn = Fn.bind(this, third);
// Remove the dispose listener on this component,
// which was given the same guid as the event listener
this.off('dispose', fn);
if (first.nodeName) {
// Remove the listener
Events.off(target, type, fn);
// Remove the listener for cleaning the dispose listener
Events.off(target, 'dispose', fn);
} else {
target.off(type, fn);
target.off('dispose', fn);
}
}
return this;
};
/**
* Add an event listener that gets triggered only once and then gets removed.
*
* @param {string|Component|string[]} [first]
* The event name, and array of event names, or another `Component`.
*
* @param {EventTarget~EventListener|string|string[]} [second]
* The listener function, an event name, or an Array of events names.
*
* @param {EventTarget~EventListener} [third]
* The event handler if `first` is a `Component` and `second` is an event name
* or an Array of event names.
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.one = function one(first, second, third) {
var _this3 = this,
_arguments = arguments;
if (typeof first === 'string' || Array.isArray(first)) {
Events.one(this.el_, first, Fn.bind(this, second));
} else {
var target = first;
var type = second;
var fn = Fn.bind(this, third);
var newFunc = function newFunc() {
_this3.off(target, type, newFunc);
fn.apply(null, _arguments);
};
// Keep the same function ID so we can remove it later
newFunc.guid = fn.guid;
this.on(target, type, newFunc);
}
return this;
};
/**
* Trigger an event on an element.
*
* @param {EventTarget~Event|Object|string} event
* The event name, and Event, or an event-like object with a type attribute
* set to the event name.
*
* @param {Object} [hash]
* Data hash to pass along with the event
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.trigger = function trigger(event, hash) {
Events.trigger(this.el_, event, hash);
return this;
};
/**
* Bind a listener to the component's ready state. If the ready event has already
* happened it will trigger the function immediately.
*
* @param {Component~ReadyCallback} fn
* A function to call when ready is triggered.
*
* @param {boolean} [sync=false]
* Execute the listener synchronously if `Component` is ready.
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.ready = function ready(fn) {
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (fn) {
if (this.isReady_) {
if (sync) {
fn.call(this);
} else {
// Call the function asynchronously by default for consistency
this.setTimeout(fn, 1);
}
} else {
this.readyQueue_ = this.readyQueue_ || [];
this.readyQueue_.push(fn);
}
}
return this;
};
/**
* Trigger all the ready listeners for this `Component`.
*
* @fires Component#ready
*/
Component.prototype.triggerReady = function triggerReady() {
this.isReady_ = true;
// Ensure ready is triggerd asynchronously
this.setTimeout(function () {
var readyQueue = this.readyQueue_;
// Reset Ready Queue
this.readyQueue_ = [];
if (readyQueue && readyQueue.length > 0) {
readyQueue.forEach(function (fn) {
fn.call(this);
}, this);
}
// Allow for using event listeners also
/**
* Triggered when a `Component` is ready.
*
* @event Component#ready
* @type {EventTarget~Event}
*/
this.trigger('ready');
}, 1);
};
/**
* Find a single DOM element matching a `selector`. This can be within the `Component`s
* `contentEl()` or another custom context.
*
* @param {string} selector
* A valid CSS selector, which will be passed to `querySelector`.
*
* @param {Element|string} [context=this.contentEl()]
* A DOM element within which to query. Can also be a selector string in
* which case the first matching element will get used as context. If
* missing `this.contentEl()` gets used. If `this.contentEl()` returns
* nothing it falls back to `document`.
*
* @return {Element|null}
* the dom element that was found, or null
*
* @see [Information on CSS Selectors](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_Started/Selectors)
*/
Component.prototype.$ = function $(selector, context) {
return Dom.$(selector, context || this.contentEl());
};
/**
* Finds all DOM element matching a `selector`. This can be within the `Component`s
* `contentEl()` or another custom context.
*
* @param {string} selector
* A valid CSS selector, which will be passed to `querySelectorAll`.
*
* @param {Element|string} [context=this.contentEl()]
* A DOM element within which to query. Can also be a selector string in
* which case the first matching element will get used as context. If
* missing `this.contentEl()` gets used. If `this.contentEl()` returns
* nothing it falls back to `document`.
*
* @return {NodeList}
* a list of dom elements that were found
*
* @see [Information on CSS Selectors](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_Started/Selectors)
*/
Component.prototype.$$ = function $$(selector, context) {
return Dom.$$(selector, context || this.contentEl());
};
/**
* Check if a component's element has a CSS class name.
*
* @param {string} classToCheck
* CSS class name to check.
*
* @return {boolean}
* - True if the `Component` has the class.
* - False if the `Component` does not have the class`
*/
Component.prototype.hasClass = function hasClass(classToCheck) {
return Dom.hasElClass(this.el_, classToCheck);
};
/**
* Add a CSS class name to the `Component`s element.
*
* @param {string} classToAdd
* CSS class name to add
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.addClass = function addClass(classToAdd) {
Dom.addElClass(this.el_, classToAdd);
return this;
};
/**
* Remove a CSS class name from the `Component`s element.
*
* @param {string} classToRemove
* CSS class name to remove
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.removeClass = function removeClass(classToRemove) {
Dom.removeElClass(this.el_, classToRemove);
return this;
};
/**
* Add or remove a CSS class name from the component's element.
* - `classToToggle` gets added when {@link Component#hasClass} would return false.
* - `classToToggle` gets removed when {@link Component#hasClass} would return true.
*
* @param {string} classToToggle
* The class to add or remove based on (@link Component#hasClass}
*
* @param {boolean|Dom~predicate} [predicate]
* An {@link Dom~predicate} function or a boolean
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.toggleClass = function toggleClass(classToToggle, predicate) {
Dom.toggleElClass(this.el_, classToToggle, predicate);
return this;
};
/**
* Show the `Component`s element if it is hidden by removing the
* 'vjs-hidden' class name from it.
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.show = function show() {
this.removeClass('vjs-hidden');
return this;
};
/**
* Hide the `Component`s element if it is currently showing by adding the
* 'vjs-hidden` class name to it.
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.hide = function hide() {
this.addClass('vjs-hidden');
return this;
};
/**
* Lock a `Component`s element in its visible state by adding the 'vjs-lock-showing'
* class name to it. Used during fadeIn/fadeOut.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @private
*/
Component.prototype.lockShowing = function lockShowing() {
this.addClass('vjs-lock-showing');
return this;
};
/**
* Unlock a `Component`s element from its visible state by removing the 'vjs-lock-showing'
* class name from it. Used during fadeIn/fadeOut.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @private
*/
Component.prototype.unlockShowing = function unlockShowing() {
this.removeClass('vjs-lock-showing');
return this;
};
/**
* Get the value of an attribute on the `Component`s element.
*
* @param {string} attribute
* Name of the attribute to get the value from.
*
* @return {string|null}
* - The value of the attribute that was asked for.
* - Can be an empty string on some browsers if the attribute does not exist
* or has no value
* - Most browsers will return null if the attibute does not exist or has
* no value.
*
* @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute}
*/
Component.prototype.getAttribute = function getAttribute(attribute) {
return Dom.getAttribute(this.el_, attribute);
};
/**
* Set the value of an attribute on the `Component`'s element
*
* @param {string} attribute
* Name of the attribute to set.
*
* @param {string} value
* Value to set the attribute to.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute}
*/
Component.prototype.setAttribute = function setAttribute(attribute, value) {
Dom.setAttribute(this.el_, attribute, value);
return this;
};
/**
* Remove an attribute from the `Component`s element.
*
* @param {string} attribute
* Name of the attribute to remove.
*
* @return {Component}
* Returns itself; method can be chained.
*
* @see [DOM API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute}
*/
Component.prototype.removeAttribute = function removeAttribute(attribute) {
Dom.removeAttribute(this.el_, attribute);
return this;
};
/**
* Get or set the width of the component based upon the CSS styles.
* See {@link Component#dimension} for more detailed information.
*
* @param {number|string} [num]
* The width that you want to set postfixed with '%', 'px' or nothing.
*
* @param {boolean} [skipListeners]
* Skip the resize event trigger
*
* @return {Component|number|string}
* - The width when getting, zero if there is no width. Can be a string
* postpixed with '%' or 'px'.
* - Returns itself when setting; method can be chained.
*/
Component.prototype.width = function width(num, skipListeners) {
return this.dimension('width', num, skipListeners);
};
/**
* Get or set the height of the component based upon the CSS styles.
* See {@link Component#dimension} for more detailed information.
*
* @param {number|string} [num]
* The height that you want to set postfixed with '%', 'px' or nothing.
*
* @param {boolean} [skipListeners]
* Skip the resize event trigger
*
* @return {Component|number|string}
* - The width when getting, zero if there is no width. Can be a string
* postpixed with '%' or 'px'.
* - Returns itself when setting; method can be chained.
*/
Component.prototype.height = function height(num, skipListeners) {
return this.dimension('height', num, skipListeners);
};
/**
* Set both the width and height of the `Component` element at the same time.
*
* @param {number|string} width
* Width to set the `Component`s element to.
*
* @param {number|string} height
* Height to set the `Component`s element to.
*
* @return {Component}
* Returns itself; method can be chained.
*/
Component.prototype.dimensions = function dimensions(width, height) {
// Skip resize listeners on width for optimization
return this.width(width, true).height(height);
};
/**
* Get or set width or height of the `Component` element. This is the shared code
* for the {@link Component#width} and {@link Component#height}.
*
* Things to know:
* - If the width or height in an number this will return the number postfixed with 'px'.
* - If the width/height is a percent this will return the percent postfixed with '%'
* - Hidden elements have a width of 0 with `window.getComputedStyle`. This function
* defaults to the `Component`s `style.width` and falls back to `window.getComputedStyle`.
* See [this]{@link http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/}
* for more information
* - If you want the computed style of the component, use {@link Component#currentWidth}
* and {@link {Component#currentHeight}
*
* @fires Component#resize
*
* @param {string} widthOrHeight
8 'width' or 'height'
*
* @param {number|string} [num]
8 New dimension
*
* @param {boolean} [skipListeners]
* Skip resize event trigger
*
* @return {Component}
* - the dimension when getting or 0 if unset
* - Returns itself when setting; method can be chained.
*/
Component.prototype.dimension = function dimension(widthOrHeight, num, skipListeners) {
if (num !== undefined) {
// Set to zero if null or literally NaN (NaN !== NaN)
if (num === null || num !== num) {
num = 0;
}
// Check if using css width/height (% or px) and adjust
if (('' + num).indexOf('%') !== -1 || ('' + num).indexOf('px') !== -1) {
this.el_.style[widthOrHeight] = num;
} else if (num === 'auto') {
this.el_.style[widthOrHeight] = '';
} else {
this.el_.style[widthOrHeight] = num + 'px';
}
// skipListeners allows us to avoid triggering the resize event when setting both width and height
if (!skipListeners) {
/**
* Triggered when a component is resized.
*
* @event Component#resize
* @type {EventTarget~Event}
*/
this.trigger('resize');
}
// Return component
return this;
}
// Not setting a value, so getting it
// Make sure element exists
if (!this.el_) {
return 0;
}
// Get dimension value from style
var val = this.el_.style[widthOrHeight];
var pxIndex = val.indexOf('px');
if (pxIndex !== -1) {
// Return the pixel value with no 'px'
return parseInt(val.slice(0, pxIndex), 10);
}
// No px so using % or no style was set, so falling back to offsetWidth/height
// If component has display:none, offset will return 0
// TODO: handle display:none and no dimension style using px
return parseInt(this.el_['offset' + (0, _toTitleCase2['default'])(widthOrHeight)], 10);
};
/**
* Get the width or the height of the `Component` elements computed style. Uses
* `window.getComputedStyle`.
*
* @param {string} widthOrHeight
* A string containing 'width' or 'height'. Whichever one you want to get.
*
* @return {number}
* The dimension that gets asked for or 0 if nothing was set
* for that dimension.
*/
Component.prototype.currentDimension = function currentDimension(widthOrHeight) {
var computedWidthOrHeight = 0;
if (widthOrHeight !== 'width' && widthOrHeight !== 'height') {
throw new Error('currentDimension only accepts width or height value');
}
if (typeof _window2['default'].getComputedStyle === 'function') {
var computedStyle = _window2['default'].getComputedStyle(this.el_);
computedWidthOrHeight = computedStyle.getPropertyValue(widthOrHeight) || computedStyle[widthOrHeight];
}
// remove 'px' from variable and parse as integer
computedWidthOrHeight = parseFloat(computedWidthOrHeight);
// if the computed value is still 0, it's possible that the browser is lying
// and we want to check the offset values.
// This code also runs on IE8 and wherever getComputedStyle doesn't exist.
if (computedWidthOrHeight === 0) {
var rule = 'offset' + (0, _toTitleCase2['default'])(widthOrHeight);
computedWidthOrHeight = this.el_[rule];
}
return computedWidthOrHeight;
};
/**
* An object that contains width and height values of the `Component`s
* computed style. Uses `window.getComputedStyle`.
*
* @typedef {Object} Component~DimensionObject
*
* @property {number} width
* The width of the `Component`s computed style.
*
* @property {number} height
* The height of the `Component`s computed style.
*/
/**
* Get an object that contains width and height values of the `Component`s
* computed style.
*
* @return {Component~DimensionObject}
* The dimensions of the components element
*/
Component.prototype.currentDimensions = function currentDimensions() {
return {
width: this.currentDimension('width'),
height: this.currentDimension('height')
};
};
/**
* Get the width of the `Component`s computed style. Uses `window.getComputedStyle`.
*
* @return {number} width
* The width of the `Component`s computed style.
*/
Component.prototype.currentWidth = function currentWidth() {
return this.currentDimension('width');
};
/**
* Get the height of the `Component`s computed style. Uses `window.getComputedStyle`.
*
* @return {number} height
* The height of the `Component`s computed style.
*/
Component.prototype.currentHeight = function currentHeight() {
return this.currentDimension('height');
};
/**
* Set the focus to this component
*/
Component.prototype.focus = function focus() {
this.el_.focus();
};
/**
* Remove the focus from this component
*/
Component.prototype.blur = function blur() {
this.el_.blur();
};
/**
* Emit a 'tap' events when touch event support gets detected. This gets used to
* support toggling the controls through a tap on the video. They get enabled
* because every sub-component would have extra overhead otherwise.
*
* @private
* @fires Component#tap
* @listens Component#touchstart
* @listens Component#touchmove
* @listens Component#touchleave
* @listens Component#touchcancel
* @listens Component#touchend
*/
Component.prototype.emitTapEvents = function emitTapEvents() {
// Track the start time so we can determine how long the touch lasted
var touchStart = 0;
var firstTouch = null;
// Maximum movement allowed during a touch event to still be considered a tap
// Other popular libs use anywhere from 2 (hammer.js) to 15,
// so 10 seems like a nice, round number.
var tapMovementThreshold = 10;
// The maximum length a touch can be while still being considered a tap
var touchTimeThreshold = 200;
var couldBeTap = void 0;
this.on('touchstart', function (event) {
// If more than one finger, don't consider treating this as a click
if (event.touches.length === 1) {
// Copy pageX/pageY from the object
firstTouch = {
pageX: event.touches[0].pageX,
pageY: event.touches[0].pageY
};
// Record start time so we can detect a tap vs. "touch and hold"
touchStart = new Date().getTime();
// Reset couldBeTap tracking
couldBeTap = true;
}
});
this.on('touchmove', function (event) {
// If more than one finger, don't consider treating this as a click
if (event.touches.length > 1) {
couldBeTap = false;
} else if (firstTouch) {
// Some devices will throw touchmoves for all but the slightest of taps.
// So, if we moved only a small distance, this could still be a tap
var xdiff = event.touches[0].pageX - firstTouch.pageX;
var ydiff = event.touches[0].pageY - firstTouch.pageY;
var touchDistance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);
if (touchDistance > tapMovementThreshold) {
couldBeTap = false;
}
}
});
var noTap = function noTap() {
couldBeTap = false;
};
// TODO: Listen to the original target. http://youtu.be/DujfpXOKUp8?t=13m8s
this.on('touchleave', noTap);
this.on('touchcancel', noTap);
// When the touch ends, measure how long it took and trigger the appropriate
// event
this.on('touchend', function (event) {
firstTouch = null;
// Proceed only if the touchmove/leave/cancel event didn't happen
if (couldBeTap === true) {
// Measure how long the touch lasted
var touchTime = new Date().getTime() - touchStart;
// Make sure the touch was less than the threshold to be considered a tap
if (touchTime < touchTimeThreshold) {
// Don't let browser turn this into a click
event.preventDefault();
/**
* Triggered when a `Component` is tapped.
*
* @event Component#tap
* @type {EventTarget~Event}
*/
this.trigger('tap');
// It may be good to copy the touchend event object and change the
// type to tap, if the other event properties aren't exact after
// Events.fixEvent runs (e.g. event.target)
}
}
});
};
/**
* This function reports user activity whenever touch events happen. This can get
* turned off by any sub-components that wants touch events to act another way.
*
* Report user touch activity when touch events occur. User activity gets used to
* determine when controls should show/hide. It is simple when it comes to mouse
* events, because any mouse event should show the controls. So we capture mouse
* events that bubble up to the player and report activity when that happens.
* With touch events it isn't as easy as `touchstart` and `touchend` toggle player
* controls. So touch events can't help us at the player level either.
*
* User activity gets checked asynchronously. So what could happen is a tap event
* on the video turns the controls off. Then the `touchend` event bubbles up to
* the player. Which, if it reported user activity, would turn the controls right
* back on. We also don't want to completely block touch events from bubbling up.
* Furthermore a `touchmove` event and anything other than a tap, should not turn
* controls back on.
*
* @listens Component#touchstart
* @listens Component#touchmove
* @listens Component#touchend
* @listens Component#touchcancel
*/
Component.prototype.enableTouchActivity = function enableTouchActivity() {
// Don't continue if the root player doesn't support reporting user activity
if (!this.player() || !this.player().reportUserActivity) {
return;
}
// listener for reporting that the user is active
var report = Fn.bind(this.player(), this.player().reportUserActivity);
var touchHolding = void 0;
this.on('touchstart', function () {
report();
// For as long as the they are touching the device or have their mouse down,
// we consider them active even if they're not moving their finger or mouse.
// So we want to continue to update that they are active
this.clearInterval(touchHolding);
// report at the same interval as activityCheck
touchHolding = this.setInterval(report, 250);
});
var touchEnd = function touchEnd(event) {
report();
// stop the interval that maintains activity if the touch is holding
this.clearInterval(touchHolding);
};
this.on('touchmove', report);
this.on('touchend', touchEnd);
this.on('touchcancel', touchEnd);
};
/**
* A callback that has no parameters and is bound into `Component`s context.
*
* @callback Component~GenericCallback
* @this Component
*/
/**
* Creates a function that runs after an `x` millisecond timeout. This function is a
* wrapper around `window.setTimeout`. There are a few reasons to use this one
* instead though:
* 1. It gets cleared via {@link Component#clearTimeout} when
* {@link Component#dispose} gets called.
* 2. The function callback will gets turned into a {@link Component~GenericCallback}
*
* > Note: You can use `window.clearTimeout` on the id returned by this function. This
* will cause its dispose listener not to get cleaned up! Please use
* {@link Component#clearTimeout} or {@link Component#dispose}.
*
* @param {Component~GenericCallback} fn
* The function that will be run after `timeout`.
*
* @param {number} timeout
* Timeout in milliseconds to delay before executing the specified function.
*
* @return {number}
* Returns a timeout ID that gets used to identify the timeout. It can also
* get used in {@link Component#clearTimeout} to clear the timeout that
* was set.
*
* @listens Component#dispose
* @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout}
*/
Component.prototype.setTimeout = function setTimeout(fn, timeout) {
fn = Fn.bind(this, fn);
var timeoutId = _window2['default'].setTimeout(fn, timeout);
var disposeFn = function disposeFn() {
this.clearTimeout(timeoutId);
};
disposeFn.guid = 'vjs-timeout-' + timeoutId;
this.on('dispose', disposeFn);
return timeoutId;
};
/**
* Clears a timeout that gets created via `window.setTimeout` or
* {@link Component#setTimeout}. If you set a timeout via {@link Component#setTimeout}
* use this function instead of `window.clearTimout`. If you don't your dispose
* listener will not get cleaned up until {@link Component#dispose}!
*
* @param {number} timeoutId
* The id of the timeout to clear. The return value of
* {@link Component#setTimeout} or `window.setTimeout`.
*
* @return {number}
* Returns the timeout id that was cleared.
*
* @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/clearTimeout}
*/
Component.prototype.clearTimeout = function clearTimeout(timeoutId) {
_window2['default'].clearTimeout(timeoutId);
var disposeFn = function disposeFn() {};
disposeFn.guid = 'vjs-timeout-' + timeoutId;
this.off('dispose', disposeFn);
return timeoutId;
};
/**
* Creates a function that gets run every `x` milliseconds. This function is a wrapper
* around `window.setInterval`. There are a few reasons to use this one instead though.
* 1. It gets cleared via {@link Component#clearInterval} when
* {@link Component#dispose} gets called.
* 2. The function callback will be a {@link Component~GenericCallback}
*
* @param {Component~GenericCallback} fn
* The function to run every `x` seconds.
*
* @param {number} interval
* Execute the specified function every `x` milliseconds.
*
* @return {number}
* Returns an id that can be used to identify the interval. It can also be be used in
* {@link Component#clearInterval} to clear the interval.
*
* @listens Component#dispose
* @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval}
*/
Component.prototype.setInterval = function setInterval(fn, interval) {
fn = Fn.bind(this, fn);
var intervalId = _window2['default'].setInterval(fn, interval);
var disposeFn = function disposeFn() {
this.clearInterval(intervalId);
};
disposeFn.guid = 'vjs-interval-' + intervalId;
this.on('dispose', disposeFn);
return intervalId;
};
/**
* Clears an interval that gets created via `window.setInterval` or
* {@link Component#setInterval}. If you set an inteval via {@link Component#setInterval}
* use this function instead of `window.clearInterval`. If you don't your dispose
* listener will not get cleaned up until {@link Component#dispose}!
*
* @param {number} intervalId
* The id of the interval to clear. The return value of
* {@link Component#setInterval} or `window.setInterval`.
*
* @return {number}
* Returns the interval id that was cleared.
*
* @see [Similar to]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/clearInterval}
*/
Component.prototype.clearInterval = function clearInterval(intervalId) {
_window2['default'].clearInterval(intervalId);
var disposeFn = function disposeFn() {};
disposeFn.guid = 'vjs-interval-' + intervalId;
this.off('dispose', disposeFn);
return intervalId;
};
/**
* Register a `Component` with `videojs` given the name and the component.
*
* > NOTE: {@link Tech}s should not be registered as a `Component`. {@link Tech}s
* should be registered using {@link Tech.registerTech} or
* {@link videojs:videojs.registerTech}.
*
* > NOTE: This function can also be seen on videojs as
* {@link videojs:videojs.registerComponent}.
*
* @param {string} name
* The name of the `Component` to register.
*
* @param {Component} comp
* The `Component` class to register.
*
* @return {Component}
* The `Component` that was registered.
*/
Component.registerComponent = function registerComponent(name, comp) {
if (!name) {
return;
}
name = (0, _toTitleCase2['default'])(name);
if (!Component.components_) {
Component.components_ = {};
}
if (name === 'Player' && Component.components_[name]) {
var Player = Component.components_[name];
// If we have players that were disposed, then their name will still be
// in Players.players. So, we must loop through and verify that the value
// for each item is not null. This allows registration of the Player component
// after all players have been disposed or before any were created.
if (Player.players && Object.keys(Player.players).length > 0 && Object.keys(Player.players).map(function (playerName) {
return Player.players[playerName];
}).every(Boolean)) {
throw new Error('Can not register Player component after player has been created');
}
}
Component.components_[name] = comp;
return comp;
};
/**
* Get a `Component` based on the name it was registered with.
*
* @param {string} name
* The Name of the component to get.
*
* @return {Component}
* The `Component` that got registered under the given name.
*
* @deprecated In `videojs` 6 this will not return `Component`s that were not
* registered using {@link Component.registerComponent}. Currently we
* check the global `videojs` object for a `Component` name and
* return that if it exists.
*/
Component.getComponent = function getComponent(name) {
if (!name) {
return;
}
name = (0, _toTitleCase2['default'])(name);
if (Component.components_ && Component.components_[name]) {
return Component.components_[name];
}
if (_window2['default'] && _window2['default'].videojs && _window2['default'].videojs[name]) {
_log2['default'].warn('The ' + name + ' component was added to the videojs object when it should be registered using videojs.registerComponent(name, component)');
return _window2['default'].videojs[name];
}
};
/**
* Sets up the constructor using the supplied init method or uses the init of the
* parent object.
*
* @param {Object} [props={}]
* An object of properties.
*
* @return {Object}
* the extended object.
*
* @deprecated since version 5
*/
Component.extend = function extend(props) {
props = props || {};
_log2['default'].warn('Component.extend({}) has been deprecated, ' + ' use videojs.extend(Component, {}) instead');
// Set up the constructor using the supplied init method
// or using the init of the parent object
// Make sure to check the unobfuscated version for external libs
var init = props.init || props.init || this.prototype.init || this.prototype.init || function () {};
// In Resig's simple class inheritance (previously used) the constructor
// is a function that calls `this.init.apply(arguments)`
// However that would prevent us from using `ParentObject.call(this);`
// in a Child constructor because the `this` in `this.init`
// would still refer to the Child and cause an infinite loop.
// We would instead have to do
// `ParentObject.prototype.init.apply(this, arguments);`
// Bleh. We're not creating a _super() function, so it's good to keep
// the parent constructor reference simple.
var subObj = function subObj() {
init.apply(this, arguments);
};
// Inherit from this object's prototype
subObj.prototype = Object.create(this.prototype);
// Reset the constructor property for subObj otherwise
// instances of subObj would have the constructor of the parent Object
subObj.prototype.constructor = subObj;
// Make the class extendable
subObj.extend = Component.extend;
// Extend subObj's prototype with functions and other properties from props
for (var name in props) {
if (props.hasOwnProperty(name)) {
subObj.prototype[name] = props[name];
}
}
return subObj;
};
return Component;
}();
Component.registerComponent('Component', Component);
exports['default'] = Component;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/audio-track-controls/audio-track-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _trackButton = __webpack_require__("./node_modules/video.js/es5/control-bar/track-button.js");
var _trackButton2 = _interopRequireDefault(_trackButton);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _audioTrackMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/audio-track-controls/audio-track-menu-item.js");
var _audioTrackMenuItem2 = _interopRequireDefault(_audioTrackMenuItem);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file audio-track-button.js
*/
/**
* The base class for buttons that toggle specific {@link AudioTrack} types.
*
* @extends TrackButton
*/
var AudioTrackButton = function (_TrackButton) {
_inherits(AudioTrackButton, _TrackButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options={}]
* The key/value store of player options.
*/
function AudioTrackButton(player) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, AudioTrackButton);
options.tracks = player.audioTracks && player.audioTracks();
var _this = _possibleConstructorReturn(this, _TrackButton.call(this, player, options));
_this.el_.setAttribute('aria-label', 'Audio Menu');
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
AudioTrackButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-audio-button ' + _TrackButton.prototype.buildCSSClass.call(this);
};
/**
* Create a menu item for each audio track
*
* @param {AudioTrackMenuItem[]} [items=[]]
* An array of existing menu items to use.
*
* @return {AudioTrackMenuItem[]}
* An array of menu items
*/
AudioTrackButton.prototype.createItems = function createItems() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
// if there's only one audio track, there no point in showing it
this.hideThreshold_ = 1;
var tracks = this.player_.audioTracks && this.player_.audioTracks();
if (!tracks) {
return items;
}
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
items.push(new _audioTrackMenuItem2['default'](this.player_, {
track: track,
// MenuItem is selectable
selectable: true
}));
}
return items;
};
return AudioTrackButton;
}(_trackButton2['default']);
/**
* The text that should display over the `AudioTrackButton`s controls. Added for localization.
*
* @type {string}
* @private
*/
AudioTrackButton.prototype.controlText_ = 'Audio Track';
_component2['default'].registerComponent('AudioTrackButton', AudioTrackButton);
exports['default'] = AudioTrackButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/audio-track-controls/audio-track-menu-item.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _menuItem = __webpack_require__("./node_modules/video.js/es5/menu/menu-item.js");
var _menuItem2 = _interopRequireDefault(_menuItem);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file audio-track-menu-item.js
*/
/**
* An {@link AudioTrack} {@link MenuItem}
*
* @extends MenuItem
*/
var AudioTrackMenuItem = function (_MenuItem) {
_inherits(AudioTrackMenuItem, _MenuItem);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function AudioTrackMenuItem(player, options) {
_classCallCheck(this, AudioTrackMenuItem);
var track = options.track;
var tracks = player.audioTracks();
// Modify options for parent MenuItem class's init.
options.label = track.label || track.language || 'Unknown';
options.selected = track.enabled;
var _this = _possibleConstructorReturn(this, _MenuItem.call(this, player, options));
_this.track = track;
if (tracks) {
var changeHandler = Fn.bind(_this, _this.handleTracksChange);
tracks.addEventListener('change', changeHandler);
_this.on('dispose', function () {
tracks.removeEventListener('change', changeHandler);
});
}
return _this;
}
/**
* This gets called when an `AudioTrackMenuItem is "clicked". See {@link ClickableComponent}
* for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
AudioTrackMenuItem.prototype.handleClick = function handleClick(event) {
var tracks = this.player_.audioTracks();
_MenuItem.prototype.handleClick.call(this, event);
if (!tracks) {
return;
}
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
track.enabled = track === this.track;
}
};
/**
* Handle any {@link AudioTrack} change.
*
* @param {EventTarget~Event} [event]
* The {@link AudioTrackList#change} event that caused this to run.
*
* @listens AudioTrackList#change
*/
AudioTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
this.selected(this.track.enabled);
};
return AudioTrackMenuItem;
}(_menuItem2['default']);
_component2['default'].registerComponent('AudioTrackMenuItem', AudioTrackMenuItem);
exports['default'] = AudioTrackMenuItem;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/control-bar.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
__webpack_require__("./node_modules/video.js/es5/control-bar/play-toggle.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/time-controls/current-time-display.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/time-controls/duration-display.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/time-controls/time-divider.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/time-controls/remaining-time-display.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/live-display.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/progress-control/progress-control.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/fullscreen-toggle.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/volume-control/volume-control.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/volume-menu-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/mute-toggle.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/chapters-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/descriptions-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/subtitles-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/captions-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/audio-track-controls/audio-track-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/playback-rate-menu/playback-rate-menu-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/spacer-controls/custom-control-spacer.js");
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file control-bar.js
*/
// Required children
/**
* Container of main controls.
*
* @extends Component
*/
var ControlBar = function (_Component) {
_inherits(ControlBar, _Component);
function ControlBar() {
_classCallCheck(this, ControlBar);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
ControlBar.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-control-bar',
dir: 'ltr'
}, {
// The control bar is a group, so it can contain menuitems
role: 'group'
});
};
return ControlBar;
}(_component2['default']);
/**
* Default options for `ControlBar`
*
* @type {Object}
* @private
*/
ControlBar.prototype.options_ = {
children: ['playToggle', 'volumeMenuButton', 'currentTimeDisplay', 'timeDivider', 'durationDisplay', 'progressControl', 'liveDisplay', 'remainingTimeDisplay', 'customControlSpacer', 'playbackRateMenuButton', 'chaptersButton', 'descriptionsButton', 'subtitlesButton', 'captionsButton', 'audioTrackButton', 'fullscreenToggle']
};
_component2['default'].registerComponent('ControlBar', ControlBar);
exports['default'] = ControlBar;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/fullscreen-toggle.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _button = __webpack_require__("./node_modules/video.js/es5/button.js");
var _button2 = _interopRequireDefault(_button);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file fullscreen-toggle.js
*/
/**
* Toggle fullscreen video
*
* @extends Button
*/
var FullscreenToggle = function (_Button) {
_inherits(FullscreenToggle, _Button);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function FullscreenToggle(player, options) {
_classCallCheck(this, FullscreenToggle);
var _this = _possibleConstructorReturn(this, _Button.call(this, player, options));
_this.on(player, 'fullscreenchange', _this.handleFullscreenChange);
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
FullscreenToggle.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-fullscreen-control ' + _Button.prototype.buildCSSClass.call(this);
};
/**
* Handles fullscreenchange on the player and change control text accordingly.
*
* @param {EventTarget~Event} [event]
* The {@link Player#fullscreenchange} event that caused this function to be
* called.
*
* @listens Player#fullscreenchange
*/
FullscreenToggle.prototype.handleFullscreenChange = function handleFullscreenChange(event) {
if (this.player_.isFullscreen()) {
this.controlText('Non-Fullscreen');
} else {
this.controlText('Fullscreen');
}
};
/**
* This gets called when an `FullscreenToggle` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
FullscreenToggle.prototype.handleClick = function handleClick(event) {
if (!this.player_.isFullscreen()) {
this.player_.requestFullscreen();
} else {
this.player_.exitFullscreen();
}
};
return FullscreenToggle;
}(_button2['default']);
/**
* The text that should display over the `FullscreenToggle`s controls. Added for localization.
*
* @type {string}
* @private
*/
FullscreenToggle.prototype.controlText_ = 'Fullscreen';
_component2['default'].registerComponent('FullscreenToggle', FullscreenToggle);
exports['default'] = FullscreenToggle;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/live-display.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file live-display.js
*/
// TODO - Future make it click to snap to live
/**
* Displays the live indicator when duration is Infinity.
*
* @extends Component
*/
var LiveDisplay = function (_Component) {
_inherits(LiveDisplay, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function LiveDisplay(player, options) {
_classCallCheck(this, LiveDisplay);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.updateShowing();
_this.on(_this.player(), 'durationchange', _this.updateShowing);
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
LiveDisplay.prototype.createEl = function createEl() {
var el = _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-live-control vjs-control'
});
this.contentEl_ = Dom.createEl('div', {
className: 'vjs-live-display',
innerHTML: '' + this.localize('Stream Type') + '' + this.localize('LIVE')
}, {
'aria-live': 'off'
});
el.appendChild(this.contentEl_);
return el;
};
/**
* Check the duration to see if the LiveDisplay should be showing or not. Then show/hide
* it accordingly
*
* @param {EventTarget~Event} [event]
* The {@link Player#durationchange} event that caused this function to run.
*
* @listens Player#durationchange
*/
LiveDisplay.prototype.updateShowing = function updateShowing(event) {
if (this.player().duration() === Infinity) {
this.show();
} else {
this.hide();
}
};
return LiveDisplay;
}(_component2['default']);
_component2['default'].registerComponent('LiveDisplay', LiveDisplay);
exports['default'] = LiveDisplay;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/mute-toggle.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _button = __webpack_require__("./node_modules/video.js/es5/button.js");
var _button2 = _interopRequireDefault(_button);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file mute-toggle.js
*/
/**
* A button component for muting the audio.
*
* @extends Button
*/
var MuteToggle = function (_Button) {
_inherits(MuteToggle, _Button);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function MuteToggle(player, options) {
_classCallCheck(this, MuteToggle);
var _this = _possibleConstructorReturn(this, _Button.call(this, player, options));
_this.on(player, 'volumechange', _this.update);
// hide mute toggle if the current tech doesn't support volume control
if (player.tech_ && player.tech_.featuresVolumeControl === false) {
_this.addClass('vjs-hidden');
}
_this.on(player, 'loadstart', function () {
// We need to update the button to account for a default muted state.
this.update();
if (player.tech_.featuresVolumeControl === false) {
this.addClass('vjs-hidden');
} else {
this.removeClass('vjs-hidden');
}
});
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
MuteToggle.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-mute-control ' + _Button.prototype.buildCSSClass.call(this);
};
/**
* This gets called when an `MuteToggle` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
MuteToggle.prototype.handleClick = function handleClick(event) {
this.player_.muted(this.player_.muted() ? false : true);
};
/**
* Update the state of volume.
*
* @param {EventTarget~Event} [event]
* The {@link Player#loadstart} event if this function was called through an
* event.
*
* @listens Player#loadstart
*/
MuteToggle.prototype.update = function update(event) {
var vol = this.player_.volume();
var level = 3;
if (vol === 0 || this.player_.muted()) {
level = 0;
} else if (vol < 0.33) {
level = 1;
} else if (vol < 0.67) {
level = 2;
}
// Don't rewrite the button text if the actual text doesn't change.
// This causes unnecessary and confusing information for screen reader users.
// This check is needed because this function gets called every time the volume level is changed.
var toMute = this.player_.muted() ? 'Unmute' : 'Mute';
if (this.controlText() !== toMute) {
this.controlText(toMute);
}
// TODO improve muted icon classes
for (var i = 0; i < 4; i++) {
Dom.removeElClass(this.el_, 'vjs-vol-' + i);
}
Dom.addElClass(this.el_, 'vjs-vol-' + level);
};
return MuteToggle;
}(_button2['default']);
/**
* The text that should display over the `MuteToggle`s controls. Added for localization.
*
* @type {string}
* @private
*/
MuteToggle.prototype.controlText_ = 'Mute';
_component2['default'].registerComponent('MuteToggle', MuteToggle);
exports['default'] = MuteToggle;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/play-toggle.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _button = __webpack_require__("./node_modules/video.js/es5/button.js");
var _button2 = _interopRequireDefault(_button);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file play-toggle.js
*/
/**
* Button to toggle between play and pause.
*
* @extends Button
*/
var PlayToggle = function (_Button) {
_inherits(PlayToggle, _Button);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function PlayToggle(player, options) {
_classCallCheck(this, PlayToggle);
var _this = _possibleConstructorReturn(this, _Button.call(this, player, options));
_this.on(player, 'play', _this.handlePlay);
_this.on(player, 'pause', _this.handlePause);
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
PlayToggle.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-play-control ' + _Button.prototype.buildCSSClass.call(this);
};
/**
* This gets called when an `PlayToggle` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
PlayToggle.prototype.handleClick = function handleClick(event) {
if (this.player_.paused()) {
this.player_.play();
} else {
this.player_.pause();
}
};
/**
* Add the vjs-playing class to the element so it can change appearance.
*
* @param {EventTarget~Event} [event]
* The event that caused this function to run.
*
* @listens Player#play
*/
PlayToggle.prototype.handlePlay = function handlePlay(event) {
this.removeClass('vjs-paused');
this.addClass('vjs-playing');
// change the button text to "Pause"
this.controlText('Pause');
};
/**
* Add the vjs-paused class to the element so it can change appearance.
*
* @param {EventTarget~Event} [event]
* The event that caused this function to run.
*
* @listens Player#pause
*/
PlayToggle.prototype.handlePause = function handlePause(event) {
this.removeClass('vjs-playing');
this.addClass('vjs-paused');
// change the button text to "Play"
this.controlText('Play');
};
return PlayToggle;
}(_button2['default']);
/**
* The text that should display over the `PlayToggle`s controls. Added for localization.
*
* @type {string}
* @private
*/
PlayToggle.prototype.controlText_ = 'Play';
_component2['default'].registerComponent('PlayToggle', PlayToggle);
exports['default'] = PlayToggle;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/playback-rate-menu/playback-rate-menu-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _menuButton = __webpack_require__("./node_modules/video.js/es5/menu/menu-button.js");
var _menuButton2 = _interopRequireDefault(_menuButton);
var _menu = __webpack_require__("./node_modules/video.js/es5/menu/menu.js");
var _menu2 = _interopRequireDefault(_menu);
var _playbackRateMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/playback-rate-menu/playback-rate-menu-item.js");
var _playbackRateMenuItem2 = _interopRequireDefault(_playbackRateMenuItem);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file playback-rate-menu-button.js
*/
/**
* The component for controlling the playback rate.
*
* @extends MenuButton
*/
var PlaybackRateMenuButton = function (_MenuButton) {
_inherits(PlaybackRateMenuButton, _MenuButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function PlaybackRateMenuButton(player, options) {
_classCallCheck(this, PlaybackRateMenuButton);
var _this = _possibleConstructorReturn(this, _MenuButton.call(this, player, options));
_this.updateVisibility();
_this.updateLabel();
_this.on(player, 'loadstart', _this.updateVisibility);
_this.on(player, 'ratechange', _this.updateLabel);
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
PlaybackRateMenuButton.prototype.createEl = function createEl() {
var el = _MenuButton.prototype.createEl.call(this);
this.labelEl_ = Dom.createEl('div', {
className: 'vjs-playback-rate-value',
innerHTML: 1.0
});
el.appendChild(this.labelEl_);
return el;
};
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
PlaybackRateMenuButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-playback-rate ' + _MenuButton.prototype.buildCSSClass.call(this);
};
/**
* Create the playback rate menu
*
* @return {Menu}
* Menu object populated with {@link PlaybackRateMenuItem}s
*/
PlaybackRateMenuButton.prototype.createMenu = function createMenu() {
var menu = new _menu2['default'](this.player());
var rates = this.playbackRates();
if (rates) {
for (var i = rates.length - 1; i >= 0; i--) {
menu.addChild(new _playbackRateMenuItem2['default'](this.player(), { rate: rates[i] + 'x' }));
}
}
return menu;
};
/**
* Updates ARIA accessibility attributes
*/
PlaybackRateMenuButton.prototype.updateARIAAttributes = function updateARIAAttributes() {
// Current playback rate
this.el().setAttribute('aria-valuenow', this.player().playbackRate());
};
/**
* This gets called when an `PlaybackRateMenuButton` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
PlaybackRateMenuButton.prototype.handleClick = function handleClick(event) {
// select next rate option
var currentRate = this.player().playbackRate();
var rates = this.playbackRates();
// this will select first one if the last one currently selected
var newRate = rates[0];
for (var i = 0; i < rates.length; i++) {
if (rates[i] > currentRate) {
newRate = rates[i];
break;
}
}
this.player().playbackRate(newRate);
};
/**
* Get possible playback rates
*
* @return {Array}
* All possible playback rates
*/
PlaybackRateMenuButton.prototype.playbackRates = function playbackRates() {
return this.options_.playbackRates || this.options_.playerOptions && this.options_.playerOptions.playbackRates;
};
/**
* Get whether playback rates is supported by the tech
* and an array of playback rates exists
*
* @return {boolean}
* Whether changing playback rate is supported
*/
PlaybackRateMenuButton.prototype.playbackRateSupported = function playbackRateSupported() {
return this.player().tech_ && this.player().tech_.featuresPlaybackRate && this.playbackRates() && this.playbackRates().length > 0;
};
/**
* Hide playback rate controls when they're no playback rate options to select
*
* @param {EventTarget~Event} [event]
* The event that caused this function to run.
*
* @listens Player#loadstart
*/
PlaybackRateMenuButton.prototype.updateVisibility = function updateVisibility(event) {
if (this.playbackRateSupported()) {
this.removeClass('vjs-hidden');
} else {
this.addClass('vjs-hidden');
}
};
/**
* Update button label when rate changed
*
* @param {EventTarget~Event} [event]
* The event that caused this function to run.
*
* @listens Player#ratechange
*/
PlaybackRateMenuButton.prototype.updateLabel = function updateLabel(event) {
if (this.playbackRateSupported()) {
this.labelEl_.innerHTML = this.player().playbackRate() + 'x';
}
};
return PlaybackRateMenuButton;
}(_menuButton2['default']);
/**
* The text that should display over the `FullscreenToggle`s controls. Added for localization.
*
* @type {string}
* @private
*/
PlaybackRateMenuButton.prototype.controlText_ = 'Playback Rate';
_component2['default'].registerComponent('PlaybackRateMenuButton', PlaybackRateMenuButton);
exports['default'] = PlaybackRateMenuButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/playback-rate-menu/playback-rate-menu-item.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _menuItem = __webpack_require__("./node_modules/video.js/es5/menu/menu-item.js");
var _menuItem2 = _interopRequireDefault(_menuItem);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file playback-rate-menu-item.js
*/
/**
* The specific menu item type for selecting a playback rate.
*
* @extends MenuItem
*/
var PlaybackRateMenuItem = function (_MenuItem) {
_inherits(PlaybackRateMenuItem, _MenuItem);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function PlaybackRateMenuItem(player, options) {
_classCallCheck(this, PlaybackRateMenuItem);
var label = options.rate;
var rate = parseFloat(label, 10);
// Modify options for parent MenuItem class's init.
options.label = label;
options.selected = rate === 1;
options.selectable = true;
var _this = _possibleConstructorReturn(this, _MenuItem.call(this, player, options));
_this.label = label;
_this.rate = rate;
_this.on(player, 'ratechange', _this.update);
return _this;
}
/**
* This gets called when an `PlaybackRateMenuItem` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
PlaybackRateMenuItem.prototype.handleClick = function handleClick(event) {
_MenuItem.prototype.handleClick.call(this);
this.player().playbackRate(this.rate);
};
/**
* Update the PlaybackRateMenuItem when the playbackrate changes.
*
* @param {EventTarget~Event} [event]
* The `ratechange` event that caused this function to run.
*
* @listens Player#ratechange
*/
PlaybackRateMenuItem.prototype.update = function update(event) {
this.selected(this.player().playbackRate() === this.rate);
};
return PlaybackRateMenuItem;
}(_menuItem2['default']);
/**
* The text that should display over the `PlaybackRateMenuItem`s controls. Added for localization.
*
* @type {string}
* @private
*/
PlaybackRateMenuItem.prototype.contentElType = 'button';
_component2['default'].registerComponent('PlaybackRateMenuItem', PlaybackRateMenuItem);
exports['default'] = PlaybackRateMenuItem;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/progress-control/load-progress-bar.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file load-progress-bar.js
*/
/**
* Shows loading progress
*
* @extends Component
*/
var LoadProgressBar = function (_Component) {
_inherits(LoadProgressBar, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function LoadProgressBar(player, options) {
_classCallCheck(this, LoadProgressBar);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.partEls_ = [];
_this.on(player, 'progress', _this.update);
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
LoadProgressBar.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-load-progress',
innerHTML: '' + this.localize('Loaded') + ': 0%'
});
};
/**
* Update progress bar
*
* @param {EventTarget~Event} [event]
* The `progress` event that caused this function to run.
*
* @listens Player#progress
*/
LoadProgressBar.prototype.update = function update(event) {
var buffered = this.player_.buffered();
var duration = this.player_.duration();
var bufferedEnd = this.player_.bufferedEnd();
var children = this.partEls_;
// get the percent width of a time compared to the total end
var percentify = function percentify(time, end) {
// no NaN
var percent = time / end || 0;
return (percent >= 1 ? 1 : percent) * 100 + '%';
};
// update the width of the progress bar
this.el_.style.width = percentify(bufferedEnd, duration);
// add child elements to represent the individual buffered time ranges
for (var i = 0; i < buffered.length; i++) {
var start = buffered.start(i);
var end = buffered.end(i);
var part = children[i];
if (!part) {
part = this.el_.appendChild(Dom.createEl());
children[i] = part;
}
// set the percent based on the width of the progress bar (bufferedEnd)
part.style.left = percentify(start, bufferedEnd);
part.style.width = percentify(end - start, bufferedEnd);
}
// remove unused buffered range elements
for (var _i = children.length; _i > buffered.length; _i--) {
this.el_.removeChild(children[_i - 1]);
}
children.length = buffered.length;
};
return LoadProgressBar;
}(_component2['default']);
_component2['default'].registerComponent('LoadProgressBar', LoadProgressBar);
exports['default'] = LoadProgressBar;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/progress-control/mouse-time-display.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _formatTime = __webpack_require__("./node_modules/video.js/es5/utils/format-time.js");
var _formatTime2 = _interopRequireDefault(_formatTime);
var _computedStyle = __webpack_require__("./node_modules/video.js/es5/utils/computed-style.js");
var _computedStyle2 = _interopRequireDefault(_computedStyle);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file mouse-time-display.js
*/
/**
* The Mouse Time Display component shows the time you will seek to
* when hovering over the progress bar
*
* @extends Component
*/
var MouseTimeDisplay = function (_Component) {
_inherits(MouseTimeDisplay, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function MouseTimeDisplay(player, options) {
_classCallCheck(this, MouseTimeDisplay);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
_this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
}
if (_this.keepTooltipsInside) {
_this.tooltip = Dom.createEl('div', { className: 'vjs-time-tooltip' });
_this.el().appendChild(_this.tooltip);
_this.addClass('vjs-keep-tooltips-inside');
}
_this.update(0, 0);
player.on('ready', function () {
_this.on(player.controlBar.progressControl.el(), 'mousemove', Fn.throttle(Fn.bind(_this, _this.handleMouseMove), 25));
});
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
MouseTimeDisplay.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-mouse-display'
});
};
/**
* Handle the mouse move event on the `MouseTimeDisplay`.
*
* @param {EventTarget~Event} event
* The `mousemove` event that caused this to event to run.
*
* @listen mousemove
*/
MouseTimeDisplay.prototype.handleMouseMove = function handleMouseMove(event) {
var duration = this.player_.duration();
var newTime = this.calculateDistance(event) * duration;
var position = event.pageX - Dom.findElPosition(this.el().parentNode).left;
this.update(newTime, position);
};
/**
* Update the time and posistion of the `MouseTimeDisplay`.
*
* @param {number} newTime
* Time to change the `MouseTimeDisplay` to.
*
* @param {nubmer} position
* Postion from the left of the in pixels.
*/
MouseTimeDisplay.prototype.update = function update(newTime, position) {
var time = (0, _formatTime2['default'])(newTime, this.player_.duration());
this.el().style.left = position + 'px';
this.el().setAttribute('data-current-time', time);
if (this.keepTooltipsInside) {
var clampedPosition = this.clampPosition_(position);
var difference = position - clampedPosition + 1;
var tooltipWidth = parseFloat((0, _computedStyle2['default'])(this.tooltip, 'width'));
var tooltipWidthHalf = tooltipWidth / 2;
this.tooltip.innerHTML = time;
this.tooltip.style.right = '-' + (tooltipWidthHalf - difference) + 'px';
}
};
/**
* Get the mouse pointers x coordinate in pixels.
*
* @param {EventTarget~Event} [event]
* The `mousemove` event that was passed to this function by
* {@link MouseTimeDisplay#handleMouseMove}
*
* @return {number}
* THe x position in pixels of the mouse pointer.
*/
MouseTimeDisplay.prototype.calculateDistance = function calculateDistance(event) {
return Dom.getPointerPosition(this.el().parentNode, event).x;
};
/**
* This takes in a horizontal position for the bar and returns a clamped position.
* Clamped position means that it will keep the position greater than half the width
* of the tooltip and smaller than the player width minus half the width o the tooltip.
* It will only clamp the position if `keepTooltipsInside` option is set.
*
* @param {number} position
* The position the bar wants to be
*
* @return {number}
* The (potentially) new clamped position.
*
* @private
*/
MouseTimeDisplay.prototype.clampPosition_ = function clampPosition_(position) {
if (!this.keepTooltipsInside) {
return position;
}
var playerWidth = parseFloat((0, _computedStyle2['default'])(this.player().el(), 'width'));
var tooltipWidth = parseFloat((0, _computedStyle2['default'])(this.tooltip, 'width'));
var tooltipWidthHalf = tooltipWidth / 2;
var actualPosition = position;
if (position < tooltipWidthHalf) {
actualPosition = Math.ceil(tooltipWidthHalf);
} else if (position > playerWidth - tooltipWidthHalf) {
actualPosition = Math.floor(playerWidth - tooltipWidthHalf);
}
return actualPosition;
};
return MouseTimeDisplay;
}(_component2['default']);
_component2['default'].registerComponent('MouseTimeDisplay', MouseTimeDisplay);
exports['default'] = MouseTimeDisplay;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/progress-control/play-progress-bar.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _formatTime = __webpack_require__("./node_modules/video.js/es5/utils/format-time.js");
var _formatTime2 = _interopRequireDefault(_formatTime);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file play-progress-bar.js
*/
/**
* Shows play progress
*
* @extends Component
*/
var PlayProgressBar = function (_Component) {
_inherits(PlayProgressBar, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function PlayProgressBar(player, options) {
_classCallCheck(this, PlayProgressBar);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.updateDataAttr();
_this.on(player, 'timeupdate', _this.updateDataAttr);
player.ready(Fn.bind(_this, _this.updateDataAttr));
if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
_this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
}
if (_this.keepTooltipsInside) {
_this.addClass('vjs-keep-tooltips-inside');
}
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
PlayProgressBar.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-play-progress vjs-slider-bar',
innerHTML: '' + this.localize('Progress') + ': 0%'
});
};
/**
* Update the data-current-time attribute on the `PlayProgressBar`.
*
* @param {EventTarget~Event} [event]
* The `timeupdate` event that caused this to run.
*
* @listens Player#timeupdate
*/
PlayProgressBar.prototype.updateDataAttr = function updateDataAttr(event) {
var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
this.el_.setAttribute('data-current-time', (0, _formatTime2['default'])(time, this.player_.duration()));
};
return PlayProgressBar;
}(_component2['default']);
_component2['default'].registerComponent('PlayProgressBar', PlayProgressBar);
exports['default'] = PlayProgressBar;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/progress-control/progress-control.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
__webpack_require__("./node_modules/video.js/es5/control-bar/progress-control/seek-bar.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/progress-control/mouse-time-display.js");
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file progress-control.js
*/
/**
* The Progress Control component contains the seek bar, load progress,
* and play progress.
*
* @extends Component
*/
var ProgressControl = function (_Component) {
_inherits(ProgressControl, _Component);
function ProgressControl() {
_classCallCheck(this, ProgressControl);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
ProgressControl.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-progress-control vjs-control'
});
};
return ProgressControl;
}(_component2['default']);
/**
* Default options for `ProgressControl`
*
* @type {Object}
* @private
*/
ProgressControl.prototype.options_ = {
children: ['seekBar']
};
_component2['default'].registerComponent('ProgressControl', ProgressControl);
exports['default'] = ProgressControl;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/progress-control/seek-bar.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _slider = __webpack_require__("./node_modules/video.js/es5/slider/slider.js");
var _slider2 = _interopRequireDefault(_slider);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _formatTime = __webpack_require__("./node_modules/video.js/es5/utils/format-time.js");
var _formatTime2 = _interopRequireDefault(_formatTime);
var _computedStyle = __webpack_require__("./node_modules/video.js/es5/utils/computed-style.js");
var _computedStyle2 = _interopRequireDefault(_computedStyle);
__webpack_require__("./node_modules/video.js/es5/control-bar/progress-control/load-progress-bar.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/progress-control/play-progress-bar.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/progress-control/tooltip-progress-bar.js");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file seek-bar.js
*/
/**
* Seek Bar and holder for the progress bars
*
* @extends Slider
*/
var SeekBar = function (_Slider) {
_inherits(SeekBar, _Slider);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function SeekBar(player, options) {
_classCallCheck(this, SeekBar);
var _this = _possibleConstructorReturn(this, _Slider.call(this, player, options));
_this.on(player, 'timeupdate', _this.updateProgress);
_this.on(player, 'ended', _this.updateProgress);
player.ready(Fn.bind(_this, _this.updateProgress));
if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
_this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
}
if (_this.keepTooltipsInside) {
_this.tooltipProgressBar = _this.addChild('TooltipProgressBar');
}
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
SeekBar.prototype.createEl = function createEl() {
return _Slider.prototype.createEl.call(this, 'div', {
className: 'vjs-progress-holder'
}, {
'aria-label': 'progress bar'
});
};
/**
* Update the seek bars tooltip and width.
*
* @param {EventTarget~Event} [event]
* The `timeupdate` or `ended` event that caused this to run.
*
* @listens Player#timeupdate
* @listens Player#ended
*/
SeekBar.prototype.updateProgress = function updateProgress(event) {
this.updateAriaAttributes(this.el_);
if (this.keepTooltipsInside) {
this.updateAriaAttributes(this.tooltipProgressBar.el_);
this.tooltipProgressBar.el_.style.width = this.bar.el_.style.width;
var playerWidth = parseFloat((0, _computedStyle2['default'])(this.player().el(), 'width'));
var tooltipWidth = parseFloat((0, _computedStyle2['default'])(this.tooltipProgressBar.tooltip, 'width'));
var tooltipStyle = this.tooltipProgressBar.el().style;
tooltipStyle.maxWidth = Math.floor(playerWidth - tooltipWidth / 2) + 'px';
tooltipStyle.minWidth = Math.ceil(tooltipWidth / 2) + 'px';
tooltipStyle.right = '-' + tooltipWidth / 2 + 'px';
}
};
/**
* Update ARIA accessibility attributes
*
* @param {Element} el
* The element to update with aria accessibility attributes.
*/
SeekBar.prototype.updateAriaAttributes = function updateAriaAttributes(el) {
// Allows for smooth scrubbing, when player can't keep up.
var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
// machine readable value of progress bar (percentage complete)
el.setAttribute('aria-valuenow', (this.getPercent() * 100).toFixed(2));
// human readable value of progress bar (time complete)
el.setAttribute('aria-valuetext', (0, _formatTime2['default'])(time, this.player_.duration()));
};
/**
* Get percentage of video played
*
* @return {number}
* The percentage played
*/
SeekBar.prototype.getPercent = function getPercent() {
var percent = this.player_.currentTime() / this.player_.duration();
return percent >= 1 ? 1 : percent;
};
/**
* Handle mouse down on seek bar
*
* @param {EventTarget~Event} event
* The `mousedown` event that caused this to run.
*
* @listens mousedown
*/
SeekBar.prototype.handleMouseDown = function handleMouseDown(event) {
this.player_.scrubbing(true);
this.videoWasPlaying = !this.player_.paused();
this.player_.pause();
_Slider.prototype.handleMouseDown.call(this, event);
};
/**
* Handle mouse move on seek bar
*
* @param {EventTarget~Event} event
* The `mousemove` event that caused this to run.
*
* @listens mousemove
*/
SeekBar.prototype.handleMouseMove = function handleMouseMove(event) {
var newTime = this.calculateDistance(event) * this.player_.duration();
// Don't let video end while scrubbing.
if (newTime === this.player_.duration()) {
newTime = newTime - 0.1;
}
// Set new time (tell player to seek to new time)
this.player_.currentTime(newTime);
};
/**
* Handle mouse up on seek bar
*
* @param {EventTarget~Event} event
* The `mouseup` event that caused this to run.
*
* @listens mouseup
*/
SeekBar.prototype.handleMouseUp = function handleMouseUp(event) {
_Slider.prototype.handleMouseUp.call(this, event);
this.player_.scrubbing(false);
if (this.videoWasPlaying) {
this.player_.play();
}
};
/**
* Move more quickly fast forward for keyboard-only users
*/
SeekBar.prototype.stepForward = function stepForward() {
// more quickly fast forward for keyboard-only users
this.player_.currentTime(this.player_.currentTime() + 5);
};
/**
* Move more quickly rewind for keyboard-only users
*/
SeekBar.prototype.stepBack = function stepBack() {
// more quickly rewind for keyboard-only users
this.player_.currentTime(this.player_.currentTime() - 5);
};
return SeekBar;
}(_slider2['default']);
/**
* Default options for the `SeekBar`
*
* @type {Object}
* @private
*/
SeekBar.prototype.options_ = {
children: ['loadProgressBar', 'mouseTimeDisplay', 'playProgressBar'],
barName: 'playProgressBar'
};
/**
* Call the update event for this Slider when this event happens on the player.
*
* @type {string}
*/
SeekBar.prototype.playerEvent = 'timeupdate';
_component2['default'].registerComponent('SeekBar', SeekBar);
exports['default'] = SeekBar;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/progress-control/tooltip-progress-bar.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _formatTime = __webpack_require__("./node_modules/video.js/es5/utils/format-time.js");
var _formatTime2 = _interopRequireDefault(_formatTime);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file play-progress-bar.js
*/
/**
* Shows play progress
*
* @extends Component
*/
var TooltipProgressBar = function (_Component) {
_inherits(TooltipProgressBar, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function TooltipProgressBar(player, options) {
_classCallCheck(this, TooltipProgressBar);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.updateDataAttr();
_this.on(player, 'timeupdate', _this.updateDataAttr);
player.ready(Fn.bind(_this, _this.updateDataAttr));
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
TooltipProgressBar.prototype.createEl = function createEl() {
var el = _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-tooltip-progress-bar vjs-slider-bar',
innerHTML: '\n ' + this.localize('Progress') + ': 0%'
});
this.tooltip = el.querySelector('.vjs-time-tooltip');
return el;
};
/**
* Updatet the data-current-time attribute for TooltipProgressBar
*
* @param {EventTarget~Event} [event]
* The `timeupdate` event that caused this function to run.
*
* @listens Player#timeupdate
*/
TooltipProgressBar.prototype.updateDataAttr = function updateDataAttr(event) {
var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
var formattedTime = (0, _formatTime2['default'])(time, this.player_.duration());
this.el_.setAttribute('data-current-time', formattedTime);
this.tooltip.innerHTML = formattedTime;
};
return TooltipProgressBar;
}(_component2['default']);
_component2['default'].registerComponent('TooltipProgressBar', TooltipProgressBar);
exports['default'] = TooltipProgressBar;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/spacer-controls/custom-control-spacer.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _spacer = __webpack_require__("./node_modules/video.js/es5/control-bar/spacer-controls/spacer.js");
var _spacer2 = _interopRequireDefault(_spacer);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file custom-control-spacer.js
*/
/**
* Spacer specifically meant to be used as an insertion point for new plugins, etc.
*
* @extends Spacer
*/
var CustomControlSpacer = function (_Spacer) {
_inherits(CustomControlSpacer, _Spacer);
function CustomControlSpacer() {
_classCallCheck(this, CustomControlSpacer);
return _possibleConstructorReturn(this, _Spacer.apply(this, arguments));
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
CustomControlSpacer.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-custom-control-spacer ' + _Spacer.prototype.buildCSSClass.call(this);
};
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
CustomControlSpacer.prototype.createEl = function createEl() {
var el = _Spacer.prototype.createEl.call(this, {
className: this.buildCSSClass()
});
// No-flex/table-cell mode requires there be some content
// in the cell to fill the remaining space of the table.
el.innerHTML = ' ';
return el;
};
return CustomControlSpacer;
}(_spacer2['default']);
_component2['default'].registerComponent('CustomControlSpacer', CustomControlSpacer);
exports['default'] = CustomControlSpacer;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/spacer-controls/spacer.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file spacer.js
*/
/**
* Just an empty spacer element that can be used as an append point for plugins, etc.
* Also can be used to create space between elements when necessary.
*
* @extends Component
*/
var Spacer = function (_Component) {
_inherits(Spacer, _Component);
function Spacer() {
_classCallCheck(this, Spacer);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
Spacer.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-spacer ' + _Component.prototype.buildCSSClass.call(this);
};
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
Spacer.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: this.buildCSSClass()
});
};
return Spacer;
}(_component2['default']);
_component2['default'].registerComponent('Spacer', Spacer);
exports['default'] = Spacer;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/caption-settings-menu-item.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _textTrackMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/text-track-menu-item.js");
var _textTrackMenuItem2 = _interopRequireDefault(_textTrackMenuItem);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file caption-settings-menu-item.js
*/
/**
* The menu item for caption track settings menu
*
* @extends TextTrackMenuItem
*/
var CaptionSettingsMenuItem = function (_TextTrackMenuItem) {
_inherits(CaptionSettingsMenuItem, _TextTrackMenuItem);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function CaptionSettingsMenuItem(player, options) {
_classCallCheck(this, CaptionSettingsMenuItem);
options.track = {
player: player,
kind: options.kind,
label: options.kind + ' settings',
selectable: false,
'default': false,
mode: 'disabled'
};
// CaptionSettingsMenuItem has no concept of 'selected'
options.selectable = false;
var _this = _possibleConstructorReturn(this, _TextTrackMenuItem.call(this, player, options));
_this.addClass('vjs-texttrack-settings');
_this.controlText(', opens ' + options.kind + ' settings dialog');
return _this;
}
/**
* This gets called when an `CaptionSettingsMenuItem` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
CaptionSettingsMenuItem.prototype.handleClick = function handleClick(event) {
this.player().getChild('textTrackSettings').show();
this.player().getChild('textTrackSettings').el_.focus();
};
return CaptionSettingsMenuItem;
}(_textTrackMenuItem2['default']);
_component2['default'].registerComponent('CaptionSettingsMenuItem', CaptionSettingsMenuItem);
exports['default'] = CaptionSettingsMenuItem;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/captions-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _textTrackButton = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/text-track-button.js");
var _textTrackButton2 = _interopRequireDefault(_textTrackButton);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _captionSettingsMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/caption-settings-menu-item.js");
var _captionSettingsMenuItem2 = _interopRequireDefault(_captionSettingsMenuItem);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file captions-button.js
*/
/**
* The button component for toggling and selecting captions
*
* @extends TextTrackButton
*/
var CaptionsButton = function (_TextTrackButton) {
_inherits(CaptionsButton, _TextTrackButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} [ready]
* The function to call when this component is ready.
*/
function CaptionsButton(player, options, ready) {
_classCallCheck(this, CaptionsButton);
var _this = _possibleConstructorReturn(this, _TextTrackButton.call(this, player, options, ready));
_this.el_.setAttribute('aria-label', 'Captions Menu');
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
CaptionsButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-captions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
};
/**
* Create caption menu items
*
* @return {CaptionSettingsMenuItem[]}
* The array of current menu items.
*/
CaptionsButton.prototype.createItems = function createItems() {
var items = [];
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks)) {
items.push(new _captionSettingsMenuItem2['default'](this.player_, { kind: this.kind_ }));
this.hideThreshold_ += 1;
}
return _TextTrackButton.prototype.createItems.call(this, items);
};
return CaptionsButton;
}(_textTrackButton2['default']);
/**
* `kind` of TextTrack to look for to associate it with this menu.
*
* @type {string}
* @private
*/
CaptionsButton.prototype.kind_ = 'captions';
/**
* The text that should display over the `CaptionsButton`s controls. Added for localization.
*
* @type {string}
* @private
*/
CaptionsButton.prototype.controlText_ = 'Captions';
_component2['default'].registerComponent('CaptionsButton', CaptionsButton);
exports['default'] = CaptionsButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/chapters-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _textTrackButton = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/text-track-button.js");
var _textTrackButton2 = _interopRequireDefault(_textTrackButton);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _chaptersTrackMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/chapters-track-menu-item.js");
var _chaptersTrackMenuItem2 = _interopRequireDefault(_chaptersTrackMenuItem);
var _toTitleCase = __webpack_require__("./node_modules/video.js/es5/utils/to-title-case.js");
var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file chapters-button.js
*/
/**
* The button component for toggling and selecting chapters
* Chapters act much differently than other text tracks
* Cues are navigation vs. other tracks of alternative languages
*
* @extends TextTrackButton
*/
var ChaptersButton = function (_TextTrackButton) {
_inherits(ChaptersButton, _TextTrackButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} [ready]
* The function to call when this function is ready.
*/
function ChaptersButton(player, options, ready) {
_classCallCheck(this, ChaptersButton);
var _this = _possibleConstructorReturn(this, _TextTrackButton.call(this, player, options, ready));
_this.el_.setAttribute('aria-label', 'Chapters Menu');
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
ChaptersButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-chapters-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
};
/**
* Update the menu based on the current state of its items.
*
* @param {EventTarget~Event} [event]
* An event that triggered this function to run.
*
* @listens TextTrackList#addtrack
* @listens TextTrackList#removetrack
* @listens TextTrackList#change
*/
ChaptersButton.prototype.update = function update(event) {
if (!this.track_ || event && (event.type === 'addtrack' || event.type === 'removetrack')) {
this.setTrack(this.findChaptersTrack());
}
_TextTrackButton.prototype.update.call(this);
};
/**
* Set the currently selected track for the chapters button.
*
* @param {TextTrack} track
* The new track to select. Nothing will change if this is the currently selected
* track.
*/
ChaptersButton.prototype.setTrack = function setTrack(track) {
if (this.track_ === track) {
return;
}
if (!this.updateHandler_) {
this.updateHandler_ = this.update.bind(this);
}
// here this.track_ refers to the old track instance
if (this.track_) {
var remoteTextTrackEl = this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);
if (remoteTextTrackEl) {
remoteTextTrackEl.removeEventListener('load', this.updateHandler_);
}
this.track_ = null;
}
this.track_ = track;
// here this.track_ refers to the new track instance
if (this.track_) {
this.track_.mode = 'hidden';
var _remoteTextTrackEl = this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);
if (_remoteTextTrackEl) {
_remoteTextTrackEl.addEventListener('load', this.updateHandler_);
}
}
};
/**
* Find the track object that is currently in use by this ChaptersButton
*
* @return {TextTrack|undefined}
* The current track or undefined if none was found.
*/
ChaptersButton.prototype.findChaptersTrack = function findChaptersTrack() {
var tracks = this.player_.textTracks() || [];
for (var i = tracks.length - 1; i >= 0; i--) {
// We will always choose the last track as our chaptersTrack
var track = tracks[i];
if (track.kind === this.kind_) {
return track;
}
}
};
/**
* Get the caption for the ChaptersButton based on the track label. This will also
* use the current tracks localized kind as a fallback if a label does not exist.
*
* @return {string}
* The tracks current label or the localized track kind.
*/
ChaptersButton.prototype.getMenuCaption = function getMenuCaption() {
if (this.track_ && this.track_.label) {
return this.track_.label;
}
return this.localize((0, _toTitleCase2['default'])(this.kind_));
};
/**
* Create menu from chapter track
*
* @return {Menu}
* New menu for the chapter buttons
*/
ChaptersButton.prototype.createMenu = function createMenu() {
this.options_.title = this.getMenuCaption();
return _TextTrackButton.prototype.createMenu.call(this);
};
/**
* Create a menu item for each text track
*
* @return {TextTrackMenuItem[]}
* Array of menu items
*/
ChaptersButton.prototype.createItems = function createItems() {
var items = [];
if (!this.track_) {
return items;
}
var cues = this.track_.cues;
if (!cues) {
return items;
}
for (var i = 0, l = cues.length; i < l; i++) {
var cue = cues[i];
var mi = new _chaptersTrackMenuItem2['default'](this.player_, { track: this.track_, cue: cue });
items.push(mi);
}
return items;
};
return ChaptersButton;
}(_textTrackButton2['default']);
/**
* `kind` of TextTrack to look for to associate it with this menu.
*
* @type {string}
* @private
*/
ChaptersButton.prototype.kind_ = 'chapters';
/**
* The text that should display over the `ChaptersButton`s controls. Added for localization.
*
* @type {string}
* @private
*/
ChaptersButton.prototype.controlText_ = 'Chapters';
_component2['default'].registerComponent('ChaptersButton', ChaptersButton);
exports['default'] = ChaptersButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/chapters-track-menu-item.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _menuItem = __webpack_require__("./node_modules/video.js/es5/menu/menu-item.js");
var _menuItem2 = _interopRequireDefault(_menuItem);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file chapters-track-menu-item.js
*/
/**
* The chapter track menu item
*
* @extends MenuItem
*/
var ChaptersTrackMenuItem = function (_MenuItem) {
_inherits(ChaptersTrackMenuItem, _MenuItem);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function ChaptersTrackMenuItem(player, options) {
_classCallCheck(this, ChaptersTrackMenuItem);
var track = options.track;
var cue = options.cue;
var currentTime = player.currentTime();
// Modify options for parent MenuItem class's init.
options.selectable = true;
options.label = cue.text;
options.selected = cue.startTime <= currentTime && currentTime < cue.endTime;
var _this = _possibleConstructorReturn(this, _MenuItem.call(this, player, options));
_this.track = track;
_this.cue = cue;
track.addEventListener('cuechange', Fn.bind(_this, _this.update));
return _this;
}
/**
* This gets called when an `ChaptersTrackMenuItem` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
ChaptersTrackMenuItem.prototype.handleClick = function handleClick(event) {
_MenuItem.prototype.handleClick.call(this);
this.player_.currentTime(this.cue.startTime);
this.update(this.cue.startTime);
};
/**
* Update chapter menu item
*
* @param {EventTarget~Event} [event]
* The `cuechange` event that caused this function to run.
*
* @listens TextTrack#cuechange
*/
ChaptersTrackMenuItem.prototype.update = function update(event) {
var cue = this.cue;
var currentTime = this.player_.currentTime();
// vjs.log(currentTime, cue.startTime);
this.selected(cue.startTime <= currentTime && currentTime < cue.endTime);
};
return ChaptersTrackMenuItem;
}(_menuItem2['default']);
_component2['default'].registerComponent('ChaptersTrackMenuItem', ChaptersTrackMenuItem);
exports['default'] = ChaptersTrackMenuItem;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/descriptions-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _textTrackButton = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/text-track-button.js");
var _textTrackButton2 = _interopRequireDefault(_textTrackButton);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file descriptions-button.js
*/
/**
* The button component for toggling and selecting descriptions
*
* @extends TextTrackButton
*/
var DescriptionsButton = function (_TextTrackButton) {
_inherits(DescriptionsButton, _TextTrackButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} [ready]
* The function to call when this component is ready.
*/
function DescriptionsButton(player, options, ready) {
_classCallCheck(this, DescriptionsButton);
var _this = _possibleConstructorReturn(this, _TextTrackButton.call(this, player, options, ready));
_this.el_.setAttribute('aria-label', 'Descriptions Menu');
var tracks = player.textTracks();
if (tracks) {
var changeHandler = Fn.bind(_this, _this.handleTracksChange);
tracks.addEventListener('change', changeHandler);
_this.on('dispose', function () {
tracks.removeEventListener('change', changeHandler);
});
}
return _this;
}
/**
* Handle text track change
*
* @param {EventTarget~Event} event
* The event that caused this function to run
*
* @listens TextTrackList#change
*/
DescriptionsButton.prototype.handleTracksChange = function handleTracksChange(event) {
var tracks = this.player().textTracks();
var disabled = false;
// Check whether a track of a different kind is showing
for (var i = 0, l = tracks.length; i < l; i++) {
var track = tracks[i];
if (track.kind !== this.kind_ && track.mode === 'showing') {
disabled = true;
break;
}
}
// If another track is showing, disable this menu button
if (disabled) {
this.disable();
} else {
this.enable();
}
};
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
DescriptionsButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-descriptions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
};
return DescriptionsButton;
}(_textTrackButton2['default']);
/**
* `kind` of TextTrack to look for to associate it with this menu.
*
* @type {string}
* @private
*/
DescriptionsButton.prototype.kind_ = 'descriptions';
/**
* The text that should display over the `DescriptionsButton`s controls. Added for localization.
*
* @type {string}
* @private
*/
DescriptionsButton.prototype.controlText_ = 'Descriptions';
_component2['default'].registerComponent('DescriptionsButton', DescriptionsButton);
exports['default'] = DescriptionsButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/off-text-track-menu-item.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _textTrackMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/text-track-menu-item.js");
var _textTrackMenuItem2 = _interopRequireDefault(_textTrackMenuItem);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file off-text-track-menu-item.js
*/
/**
* A special menu item for turning of a specific type of text track
*
* @extends TextTrackMenuItem
*/
var OffTextTrackMenuItem = function (_TextTrackMenuItem) {
_inherits(OffTextTrackMenuItem, _TextTrackMenuItem);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function OffTextTrackMenuItem(player, options) {
_classCallCheck(this, OffTextTrackMenuItem);
// Create pseudo track info
// Requires options['kind']
options.track = {
player: player,
kind: options.kind,
label: options.kind + ' off',
'default': false,
mode: 'disabled'
};
// MenuItem is selectable
options.selectable = true;
var _this = _possibleConstructorReturn(this, _TextTrackMenuItem.call(this, player, options));
_this.selected(true);
return _this;
}
/**
* Handle text track change
*
* @param {EventTarget~Event} event
* The event that caused this function to run
*/
OffTextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
var tracks = this.player().textTracks();
var selected = true;
for (var i = 0, l = tracks.length; i < l; i++) {
var track = tracks[i];
if (track.kind === this.track.kind && track.mode === 'showing') {
selected = false;
break;
}
}
this.selected(selected);
};
return OffTextTrackMenuItem;
}(_textTrackMenuItem2['default']);
_component2['default'].registerComponent('OffTextTrackMenuItem', OffTextTrackMenuItem);
exports['default'] = OffTextTrackMenuItem;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/subtitles-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _textTrackButton = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/text-track-button.js");
var _textTrackButton2 = _interopRequireDefault(_textTrackButton);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file subtitles-button.js
*/
/**
* The button component for toggling and selecting subtitles
*
* @extends TextTrackButton
*/
var SubtitlesButton = function (_TextTrackButton) {
_inherits(SubtitlesButton, _TextTrackButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} [ready]
* The function to call when this component is ready.
*/
function SubtitlesButton(player, options, ready) {
_classCallCheck(this, SubtitlesButton);
var _this = _possibleConstructorReturn(this, _TextTrackButton.call(this, player, options, ready));
_this.el_.setAttribute('aria-label', 'Subtitles Menu');
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
SubtitlesButton.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-subtitles-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
};
return SubtitlesButton;
}(_textTrackButton2['default']);
/**
* `kind` of TextTrack to look for to associate it with this menu.
*
* @type {string}
* @private
*/
SubtitlesButton.prototype.kind_ = 'subtitles';
/**
* The text that should display over the `SubtitlesButton`s controls. Added for localization.
*
* @type {string}
* @private
*/
SubtitlesButton.prototype.controlText_ = 'Subtitles';
_component2['default'].registerComponent('SubtitlesButton', SubtitlesButton);
exports['default'] = SubtitlesButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/text-track-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _trackButton = __webpack_require__("./node_modules/video.js/es5/control-bar/track-button.js");
var _trackButton2 = _interopRequireDefault(_trackButton);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _textTrackMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/text-track-menu-item.js");
var _textTrackMenuItem2 = _interopRequireDefault(_textTrackMenuItem);
var _offTextTrackMenuItem = __webpack_require__("./node_modules/video.js/es5/control-bar/text-track-controls/off-text-track-menu-item.js");
var _offTextTrackMenuItem2 = _interopRequireDefault(_offTextTrackMenuItem);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file text-track-button.js
*/
/**
* The base class for buttons that toggle specific text track types (e.g. subtitles)
*
* @extends MenuButton
*/
var TextTrackButton = function (_TrackButton) {
_inherits(TextTrackButton, _TrackButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options={}]
* The key/value store of player options.
*/
function TextTrackButton(player) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, TextTrackButton);
options.tracks = player.textTracks();
return _possibleConstructorReturn(this, _TrackButton.call(this, player, options));
}
/**
* Create a menu item for each text track
*
* @param {TextTrackMenuItem[]} [items=[]]
* Existing array of items to use during creation
*
* @return {TextTrackMenuItem[]}
* Array of menu items that were created
*/
TextTrackButton.prototype.createItems = function createItems() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
// Add an OFF menu item to turn all tracks off
items.push(new _offTextTrackMenuItem2['default'](this.player_, { kind: this.kind_ }));
this.hideThreshold_ += 1;
var tracks = this.player_.textTracks();
if (!tracks) {
return items;
}
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
// only add tracks that are of the appropriate kind and have a label
if (track.kind === this.kind_) {
items.push(new _textTrackMenuItem2['default'](this.player_, {
track: track,
// MenuItem is selectable
selectable: true
}));
}
}
return items;
};
return TextTrackButton;
}(_trackButton2['default']);
_component2['default'].registerComponent('TextTrackButton', TextTrackButton);
exports['default'] = TextTrackButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/text-track-controls/text-track-menu-item.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _menuItem = __webpack_require__("./node_modules/video.js/es5/menu/menu-item.js");
var _menuItem2 = _interopRequireDefault(_menuItem);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file text-track-menu-item.js
*/
/**
* The specific menu item type for selecting a language within a text track kind
*
* @extends MenuItem
*/
var TextTrackMenuItem = function (_MenuItem) {
_inherits(TextTrackMenuItem, _MenuItem);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function TextTrackMenuItem(player, options) {
_classCallCheck(this, TextTrackMenuItem);
var track = options.track;
var tracks = player.textTracks();
// Modify options for parent MenuItem class's init.
options.label = track.label || track.language || 'Unknown';
options.selected = track['default'] || track.mode === 'showing';
var _this = _possibleConstructorReturn(this, _MenuItem.call(this, player, options));
_this.track = track;
if (tracks) {
var changeHandler = Fn.bind(_this, _this.handleTracksChange);
player.on(['loadstart', 'texttrackchange'], changeHandler);
tracks.addEventListener('change', changeHandler);
_this.on('dispose', function () {
tracks.removeEventListener('change', changeHandler);
});
}
// iOS7 doesn't dispatch change events to TextTrackLists when an
// associated track's mode changes. Without something like
// Object.observe() (also not present on iOS7), it's not
// possible to detect changes to the mode attribute and polyfill
// the change event. As a poor substitute, we manually dispatch
// change events whenever the controls modify the mode.
if (tracks && tracks.onchange === undefined) {
var event = void 0;
_this.on(['tap', 'click'], function () {
if (_typeof(_window2['default'].Event) !== 'object') {
// Android 2.3 throws an Illegal Constructor error for window.Event
try {
event = new _window2['default'].Event('change');
} catch (err) {
// continue regardless of error
}
}
if (!event) {
event = _document2['default'].createEvent('Event');
event.initEvent('change', true, true);
}
tracks.dispatchEvent(event);
});
}
return _this;
}
/**
* This gets called when an `TextTrackMenuItem` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} event
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
TextTrackMenuItem.prototype.handleClick = function handleClick(event) {
var kind = this.track.kind;
var tracks = this.player_.textTracks();
_MenuItem.prototype.handleClick.call(this, event);
if (!tracks) {
return;
}
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
if (track.kind !== kind) {
continue;
}
if (track === this.track) {
track.mode = 'showing';
} else {
track.mode = 'disabled';
}
}
};
/**
* Handle text track list change
*
* @param {EventTarget~Event} event
* The `change` event that caused this function to be called.
*
* @listens TextTrackList#change
*/
TextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
this.selected(this.track.mode === 'showing');
};
return TextTrackMenuItem;
}(_menuItem2['default']);
_component2['default'].registerComponent('TextTrackMenuItem', TextTrackMenuItem);
exports['default'] = TextTrackMenuItem;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/time-controls/current-time-display.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _formatTime = __webpack_require__("./node_modules/video.js/es5/utils/format-time.js");
var _formatTime2 = _interopRequireDefault(_formatTime);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file current-time-display.js
*/
/**
* Displays the current time
*
* @extends Component
*/
var CurrentTimeDisplay = function (_Component) {
_inherits(CurrentTimeDisplay, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function CurrentTimeDisplay(player, options) {
_classCallCheck(this, CurrentTimeDisplay);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.on(player, 'timeupdate', _this.updateContent);
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
CurrentTimeDisplay.prototype.createEl = function createEl() {
var el = _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-current-time vjs-time-control vjs-control'
});
this.contentEl_ = Dom.createEl('div', {
className: 'vjs-current-time-display',
// label the current time for screen reader users
innerHTML: 'Current Time ' + '0:00'
}, {
// tell screen readers not to automatically read the time as it changes
'aria-live': 'off'
});
el.appendChild(this.contentEl_);
return el;
};
/**
* Update current time display
*
* @param {EventTarget~Event} [event]
* The `timeupdate` event that caused this function to run.
*
* @listens Player#timeupdate
*/
CurrentTimeDisplay.prototype.updateContent = function updateContent(event) {
// Allows for smooth scrubbing, when player can't keep up.
var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
var localizedText = this.localize('Current Time');
var formattedTime = (0, _formatTime2['default'])(time, this.player_.duration());
if (formattedTime !== this.formattedTime_) {
this.formattedTime_ = formattedTime;
this.contentEl_.innerHTML = '' + localizedText + ' ' + formattedTime;
}
};
return CurrentTimeDisplay;
}(_component2['default']);
_component2['default'].registerComponent('CurrentTimeDisplay', CurrentTimeDisplay);
exports['default'] = CurrentTimeDisplay;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/time-controls/duration-display.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _formatTime = __webpack_require__("./node_modules/video.js/es5/utils/format-time.js");
var _formatTime2 = _interopRequireDefault(_formatTime);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file duration-display.js
*/
/**
* Displays the duration
*
* @extends Component
*/
var DurationDisplay = function (_Component) {
_inherits(DurationDisplay, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function DurationDisplay(player, options) {
_classCallCheck(this, DurationDisplay);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.on(player, 'durationchange', _this.updateContent);
// Also listen for timeupdate and loadedmetadata because removing those
// listeners could have broken dependent applications/libraries. These
// can likely be removed for 6.0.
_this.on(player, 'timeupdate', _this.updateContent);
_this.on(player, 'loadedmetadata', _this.updateContent);
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
DurationDisplay.prototype.createEl = function createEl() {
var el = _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-duration vjs-time-control vjs-control'
});
this.contentEl_ = Dom.createEl('div', {
className: 'vjs-duration-display',
// label the duration time for screen reader users
innerHTML: '' + this.localize('Duration Time') + ' 0:00'
}, {
// tell screen readers not to automatically read the time as it changes
'aria-live': 'off'
});
el.appendChild(this.contentEl_);
return el;
};
/**
* Update duration time display.
*
* @param {EventTarget~Event} [event]
* The `durationchange`, `timeupdate`, or `loadedmetadata` event that caused
* this function to be called.
*
* @listens Player#durationchange
* @listens Player#timeupdate
* @listens Player#loadedmetadata
*/
DurationDisplay.prototype.updateContent = function updateContent(event) {
var duration = this.player_.duration();
if (duration && this.duration_ !== duration) {
this.duration_ = duration;
var localizedText = this.localize('Duration Time');
var formattedTime = (0, _formatTime2['default'])(duration);
// label the duration time for screen reader users
this.contentEl_.innerHTML = '' + localizedText + ' ' + formattedTime;
}
};
return DurationDisplay;
}(_component2['default']);
_component2['default'].registerComponent('DurationDisplay', DurationDisplay);
exports['default'] = DurationDisplay;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/time-controls/remaining-time-display.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _formatTime = __webpack_require__("./node_modules/video.js/es5/utils/format-time.js");
var _formatTime2 = _interopRequireDefault(_formatTime);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file remaining-time-display.js
*/
/**
* Displays the time left in the video
*
* @extends Component
*/
var RemainingTimeDisplay = function (_Component) {
_inherits(RemainingTimeDisplay, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function RemainingTimeDisplay(player, options) {
_classCallCheck(this, RemainingTimeDisplay);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.on(player, 'timeupdate', _this.updateContent);
_this.on(player, 'durationchange', _this.updateContent);
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
RemainingTimeDisplay.prototype.createEl = function createEl() {
var el = _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-remaining-time vjs-time-control vjs-control'
});
this.contentEl_ = Dom.createEl('div', {
className: 'vjs-remaining-time-display',
// label the remaining time for screen reader users
innerHTML: '' + this.localize('Remaining Time') + ' -0:00'
}, {
// tell screen readers not to automatically read the time as it changes
'aria-live': 'off'
});
el.appendChild(this.contentEl_);
return el;
};
/**
* Update remaining time display.
*
* @param {EventTarget~Event} [event]
* The `timeupdate` or `durationchange` event that caused this to run.
*
* @listens Player#timeupdate
* @listens Player#durationchange
*/
RemainingTimeDisplay.prototype.updateContent = function updateContent(event) {
if (this.player_.duration()) {
var localizedText = this.localize('Remaining Time');
var formattedTime = (0, _formatTime2['default'])(this.player_.remainingTime());
if (formattedTime !== this.formattedTime_) {
this.formattedTime_ = formattedTime;
this.contentEl_.innerHTML = '' + localizedText + ' -' + formattedTime;
}
}
// Allows for smooth scrubbing, when player can't keep up.
// var time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
// this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
};
return RemainingTimeDisplay;
}(_component2['default']);
_component2['default'].registerComponent('RemainingTimeDisplay', RemainingTimeDisplay);
exports['default'] = RemainingTimeDisplay;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/time-controls/time-divider.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file time-divider.js
*/
/**
* The separator between the current time and duration.
* Can be hidden if it's not needed in the design.
*
* @extends Component
*/
var TimeDivider = function (_Component) {
_inherits(TimeDivider, _Component);
function TimeDivider() {
_classCallCheck(this, TimeDivider);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
/**
* Create the component's DOM element
*
* @return {Element}
* The element that was created.
*/
TimeDivider.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-time-control vjs-time-divider',
innerHTML: '
/
'
});
};
return TimeDivider;
}(_component2['default']);
_component2['default'].registerComponent('TimeDivider', TimeDivider);
exports['default'] = TimeDivider;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/track-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _menuButton = __webpack_require__("./node_modules/video.js/es5/menu/menu-button.js");
var _menuButton2 = _interopRequireDefault(_menuButton);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file track-button.js
*/
/**
* The base class for buttons that toggle specific track types (e.g. subtitles).
*
* @extends MenuButton
*/
var TrackButton = function (_MenuButton) {
_inherits(TrackButton, _MenuButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function TrackButton(player, options) {
_classCallCheck(this, TrackButton);
var tracks = options.tracks;
var _this = _possibleConstructorReturn(this, _MenuButton.call(this, player, options));
if (_this.items.length <= 1) {
_this.hide();
}
if (!tracks) {
return _possibleConstructorReturn(_this);
}
var updateHandler = Fn.bind(_this, _this.update);
tracks.addEventListener('removetrack', updateHandler);
tracks.addEventListener('addtrack', updateHandler);
_this.player_.on('dispose', function () {
tracks.removeEventListener('removetrack', updateHandler);
tracks.removeEventListener('addtrack', updateHandler);
});
return _this;
}
return TrackButton;
}(_menuButton2['default']);
_component2['default'].registerComponent('TrackButton', TrackButton);
exports['default'] = TrackButton;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/volume-control/volume-bar.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _slider = __webpack_require__("./node_modules/video.js/es5/slider/slider.js");
var _slider2 = _interopRequireDefault(_slider);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
__webpack_require__("./node_modules/video.js/es5/control-bar/volume-control/volume-level.js");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file volume-bar.js
*/
// Required children
/**
* The bar that contains the volume level and can be clicked on to adjust the level
*
* @extends Slider
*/
var VolumeBar = function (_Slider) {
_inherits(VolumeBar, _Slider);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function VolumeBar(player, options) {
_classCallCheck(this, VolumeBar);
var _this = _possibleConstructorReturn(this, _Slider.call(this, player, options));
_this.on(player, 'volumechange', _this.updateARIAAttributes);
player.ready(Fn.bind(_this, _this.updateARIAAttributes));
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
VolumeBar.prototype.createEl = function createEl() {
return _Slider.prototype.createEl.call(this, 'div', {
className: 'vjs-volume-bar vjs-slider-bar'
}, {
'aria-label': 'volume level'
});
};
/**
* Handle movement events on the {@link VolumeMenuButton}.
*
* @param {EventTarget~Event} event
* The event that caused this function to run.
*
* @listens mousemove
*/
VolumeBar.prototype.handleMouseMove = function handleMouseMove(event) {
this.checkMuted();
this.player_.volume(this.calculateDistance(event));
};
/**
* If the player is muted unmute it.
*/
VolumeBar.prototype.checkMuted = function checkMuted() {
if (this.player_.muted()) {
this.player_.muted(false);
}
};
/**
* Get percent of volume level
*
* @return {number}
* Volume level percent as a decimal number.
*/
VolumeBar.prototype.getPercent = function getPercent() {
if (this.player_.muted()) {
return 0;
}
return this.player_.volume();
};
/**
* Increase volume level for keyboard users
*/
VolumeBar.prototype.stepForward = function stepForward() {
this.checkMuted();
this.player_.volume(this.player_.volume() + 0.1);
};
/**
* Decrease volume level for keyboard users
*/
VolumeBar.prototype.stepBack = function stepBack() {
this.checkMuted();
this.player_.volume(this.player_.volume() - 0.1);
};
/**
* Update ARIA accessibility attributes
*
* @param {EventTarget~Event} [event]
* The `volumechange` event that caused this function to run.
*
* @listens Player#volumechange
*/
VolumeBar.prototype.updateARIAAttributes = function updateARIAAttributes(event) {
// Current value of volume bar as a percentage
var volume = (this.player_.volume() * 100).toFixed(2);
this.el_.setAttribute('aria-valuenow', volume);
this.el_.setAttribute('aria-valuetext', volume + '%');
};
return VolumeBar;
}(_slider2['default']);
/**
* Default options for the `VolumeBar`
*
* @type {Object}
* @private
*/
VolumeBar.prototype.options_ = {
children: ['volumeLevel'],
barName: 'volumeLevel'
};
/**
* Call the update event for this Slider when this event happens on the player.
*
* @type {string}
*/
VolumeBar.prototype.playerEvent = 'volumechange';
_component2['default'].registerComponent('VolumeBar', VolumeBar);
exports['default'] = VolumeBar;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/volume-control/volume-control.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
__webpack_require__("./node_modules/video.js/es5/control-bar/volume-control/volume-bar.js");
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file volume-control.js
*/
// Required children
/**
* The component for controlling the volume level
*
* @extends Component
*/
var VolumeControl = function (_Component) {
_inherits(VolumeControl, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options={}]
* The key/value store of player options.
*/
function VolumeControl(player, options) {
_classCallCheck(this, VolumeControl);
// hide volume controls when they're not supported by the current tech
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
if (player.tech_ && player.tech_.featuresVolumeControl === false) {
_this.addClass('vjs-hidden');
}
_this.on(player, 'loadstart', function () {
if (player.tech_.featuresVolumeControl === false) {
this.addClass('vjs-hidden');
} else {
this.removeClass('vjs-hidden');
}
});
return _this;
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
VolumeControl.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-volume-control vjs-control'
});
};
return VolumeControl;
}(_component2['default']);
/**
* Default options for the `VolumeControl`
*
* @type {Object}
* @private
*/
VolumeControl.prototype.options_ = {
children: ['volumeBar']
};
_component2['default'].registerComponent('VolumeControl', VolumeControl);
exports['default'] = VolumeControl;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/volume-control/volume-level.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file volume-level.js
*/
/**
* Shows volume level
*
* @extends Component
*/
var VolumeLevel = function (_Component) {
_inherits(VolumeLevel, _Component);
function VolumeLevel() {
_classCallCheck(this, VolumeLevel);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
/**
* Create the `Component`'s DOM element
*
* @return {Element}
* The element that was created.
*/
VolumeLevel.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-volume-level',
innerHTML: ''
});
};
return VolumeLevel;
}(_component2['default']);
_component2['default'].registerComponent('VolumeLevel', VolumeLevel);
exports['default'] = VolumeLevel;
/***/ }),
/***/ "./node_modules/video.js/es5/control-bar/volume-menu-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _popup = __webpack_require__("./node_modules/video.js/es5/popup/popup.js");
var _popup2 = _interopRequireDefault(_popup);
var _popupButton = __webpack_require__("./node_modules/video.js/es5/popup/popup-button.js");
var _popupButton2 = _interopRequireDefault(_popupButton);
var _muteToggle = __webpack_require__("./node_modules/video.js/es5/control-bar/mute-toggle.js");
var _muteToggle2 = _interopRequireDefault(_muteToggle);
var _volumeBar = __webpack_require__("./node_modules/video.js/es5/control-bar/volume-control/volume-bar.js");
var _volumeBar2 = _interopRequireDefault(_volumeBar);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file volume-menu-button.js
*/
/**
* Button for volume popup
*
* @extends PopupButton
*/
var VolumeMenuButton = function (_PopupButton) {
_inherits(VolumeMenuButton, _PopupButton);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options={}]
* The key/value store of player options.
*/
function VolumeMenuButton(player) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, VolumeMenuButton);
// Default to inline
if (options.inline === undefined) {
options.inline = true;
}
// If the vertical option isn't passed at all, default to true.
if (options.vertical === undefined) {
// If an inline volumeMenuButton is used, we should default to using
// a horizontal slider for obvious reasons.
if (options.inline) {
options.vertical = false;
} else {
options.vertical = true;
}
}
// The vertical option needs to be set on the volumeBar as well,
// since that will need to be passed along to the VolumeBar constructor
options.volumeBar = options.volumeBar || {};
options.volumeBar.vertical = !!options.vertical;
// Same listeners as MuteToggle
var _this = _possibleConstructorReturn(this, _PopupButton.call(this, player, options));
_this.on(player, 'volumechange', _this.volumeUpdate);
_this.on(player, 'loadstart', _this.volumeUpdate);
// hide mute toggle if the current tech doesn't support volume control
function updateVisibility() {
if (player.tech_ && player.tech_.featuresVolumeControl === false) {
this.addClass('vjs-hidden');
} else {
this.removeClass('vjs-hidden');
}
}
updateVisibility.call(_this);
_this.on(player, 'loadstart', updateVisibility);
_this.on(_this.volumeBar, ['slideractive', 'focus'], function () {
this.addClass('vjs-slider-active');
});
_this.on(_this.volumeBar, ['sliderinactive', 'blur'], function () {
this.removeClass('vjs-slider-active');
});
_this.on(_this.volumeBar, ['focus'], function () {
this.addClass('vjs-lock-showing');
});
_this.on(_this.volumeBar, ['blur'], function () {
this.removeClass('vjs-lock-showing');
});
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
VolumeMenuButton.prototype.buildCSSClass = function buildCSSClass() {
var orientationClass = '';
if (this.options_.vertical) {
orientationClass = 'vjs-volume-menu-button-vertical';
} else {
orientationClass = 'vjs-volume-menu-button-horizontal';
}
return 'vjs-volume-menu-button ' + _PopupButton.prototype.buildCSSClass.call(this) + ' ' + orientationClass;
};
/**
* Create the VolumeMenuButton popup
*
* @return {Popup}
* The popup that was created
*/
VolumeMenuButton.prototype.createPopup = function createPopup() {
var popup = new _popup2['default'](this.player_, {
contentElType: 'div'
});
var vb = new _volumeBar2['default'](this.player_, this.options_.volumeBar);
popup.addChild(vb);
this.menuContent = popup;
this.volumeBar = vb;
this.attachVolumeBarEvents();
return popup;
};
/**
* This gets called when an `VolumeMenuButton` is "clicked". See
* {@link ClickableComponent} for more detailed information on what a click can be.
*
* @param {EventTarget~Event} [event]
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
VolumeMenuButton.prototype.handleClick = function handleClick(event) {
_muteToggle2['default'].prototype.handleClick.call(this);
_PopupButton.prototype.handleClick.call(this);
};
/**
* Add events listeners to the created `VolumeBar`.
*/
VolumeMenuButton.prototype.attachVolumeBarEvents = function attachVolumeBarEvents() {
this.menuContent.on(['mousedown', 'touchdown'], Fn.bind(this, this.handleMouseDown));
};
/**
* Handle the `mousedown` and `touchdown` events on the `VolumeBar`
*
* @param {EventTarget~Event} [event]
* The `mousedown` or `touchdown` event that caused this to run.
*
* @listens mousedown
* @listens touchdown
*/
VolumeMenuButton.prototype.handleMouseDown = function handleMouseDown(event) {
this.on(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
this.on(this.el_.ownerDocument, ['mouseup', 'touchend'], this.handleMouseUp);
};
/**
* Handle the `mouseup` and `touchend` events on the `VolumeBar`
*
* @param {EventTarget~Event} [event]
* The `mouseup` or `touchend` event that caused this to run.
*
* @listens mouseup
* @listens touchend
*/
VolumeMenuButton.prototype.handleMouseUp = function handleMouseUp(event) {
this.off(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
};
return VolumeMenuButton;
}(_popupButton2['default']);
/**
* @borrows MuteToggle#update as VolumeMenuButton#volumeUpdate
*/
VolumeMenuButton.prototype.volumeUpdate = _muteToggle2['default'].prototype.update;
/**
* The text that should display over the `VolumeMenuButton`s controls. Added for localization.
*
* @type {string}
* @private
*/
VolumeMenuButton.prototype.controlText_ = 'Mute';
_component2['default'].registerComponent('VolumeMenuButton', VolumeMenuButton);
exports['default'] = VolumeMenuButton;
/***/ }),
/***/ "./node_modules/video.js/es5/error-display.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _modalDialog = __webpack_require__("./node_modules/video.js/es5/modal-dialog.js");
var _modalDialog2 = _interopRequireDefault(_modalDialog);
var _mergeOptions = __webpack_require__("./node_modules/video.js/es5/utils/merge-options.js");
var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file error-display.js
*/
/**
* A display that indicates an error has occurred. This means that the video
* is unplayable.
*
* @extends ModalDialog
*/
var ErrorDisplay = function (_ModalDialog) {
_inherits(ErrorDisplay, _ModalDialog);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function ErrorDisplay(player, options) {
_classCallCheck(this, ErrorDisplay);
var _this = _possibleConstructorReturn(this, _ModalDialog.call(this, player, options));
_this.on(player, 'error', _this.open);
return _this;
}
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*
* @deprecated Since version 5.
*/
ErrorDisplay.prototype.buildCSSClass = function buildCSSClass() {
return 'vjs-error-display ' + _ModalDialog.prototype.buildCSSClass.call(this);
};
/**
* Gets the localized error message based on the `Player`s error.
*
* @return {string}
* The `Player`s error message localized or an empty string.
*/
ErrorDisplay.prototype.content = function content() {
var error = this.player().error();
return error ? this.localize(error.message) : '';
};
return ErrorDisplay;
}(_modalDialog2['default']);
/**
* The default options for an `ErrorDisplay`.
*
* @private
*/
ErrorDisplay.prototype.options_ = (0, _mergeOptions2['default'])(_modalDialog2['default'].prototype.options_, {
pauseOnOpen: false,
fillAlways: true,
temporary: false,
uncloseable: true
});
_component2['default'].registerComponent('ErrorDisplay', ErrorDisplay);
exports['default'] = ErrorDisplay;
/***/ }),
/***/ "./node_modules/video.js/es5/event-target.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _events = __webpack_require__("./node_modules/video.js/es5/utils/events.js");
var Events = _interopRequireWildcard(_events);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
/**
* `EventTarget` is a class that can have the same API as the DOM `EventTarget`. It
* adds shorthand functions that wrap around lengthy functions. For example:
* the `on` function is a wrapper around `addEventListener`.
*
* @see [EventTarget Spec]{@link https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget}
* @class EventTarget
*/
var EventTarget = function EventTarget() {};
/**
* A Custom DOM event.
*
* @typedef {Object} EventTarget~Event
* @see [Properties]{@link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent}
*/
/**
* All event listeners should follow the following format.
*
* @callback EventTarget~EventListener
* @this {EventTarget}
*
* @param {EventTarget~Event} event
* the event that triggered this function
*
* @param {Object} [hash]
* hash of data sent during the event
*/
/**
* An object containing event names as keys and booleans as values.
*
* > NOTE: If an event name is set to a true value here {@link EventTarget#trigger}
* will have extra functionality. See that function for more information.
*
* @property EventTarget.prototype.allowedEvents_
* @private
*/
/**
* @file src/js/event-target.js
*/
EventTarget.prototype.allowedEvents_ = {};
/**
* Adds an `event listener` to an instance of an `EventTarget`. An `event listener` is a
* function that will get called when an event with a certain name gets triggered.
*
* @param {string|string[]} type
* An event name or an array of event names.
*
* @param {EventTarget~EventListener} fn
* The function to call with `EventTarget`s
*/
EventTarget.prototype.on = function (type, fn) {
// Remove the addEventListener alias before calling Events.on
// so we don't get into an infinite type loop
var ael = this.addEventListener;
this.addEventListener = function () {};
Events.on(this, type, fn);
this.addEventListener = ael;
};
/**
* An alias of {@link EventTarget#on}. Allows `EventTarget` to mimic
* the standard DOM API.
*
* @function
* @see {@link EventTarget#on}
*/
EventTarget.prototype.addEventListener = EventTarget.prototype.on;
/**
* Removes an `event listener` for a specific event from an instance of `EventTarget`.
* This makes it so that the `event listener` will no longer get called when the
* named event happens.
*
* @param {string|string[]} type
* An event name or an array of event names.
*
* @param {EventTarget~EventListener} fn
* The function to remove.
*/
EventTarget.prototype.off = function (type, fn) {
Events.off(this, type, fn);
};
/**
* An alias of {@link EventTarget#off}. Allows `EventTarget` to mimic
* the standard DOM API.
*
* @function
* @see {@link EventTarget#off}
*/
EventTarget.prototype.removeEventListener = EventTarget.prototype.off;
/**
* This function will add an `event listener` that gets triggered only once. After the
* first trigger it will get removed. This is like adding an `event listener`
* with {@link EventTarget#on} that calls {@link EventTarget#off} on itself.
*
* @param {string|string[]} type
* An event name or an array of event names.
*
* @param {EventTarget~EventListener} fn
* The function to be called once for each event name.
*/
EventTarget.prototype.one = function (type, fn) {
// Remove the addEventListener alialing Events.on
// so we don't get into an infinite type loop
var ael = this.addEventListener;
this.addEventListener = function () {};
Events.one(this, type, fn);
this.addEventListener = ael;
};
/**
* This function causes an event to happen. This will then cause any `event listeners`
* that are waiting for that event, to get called. If there are no `event listeners`
* for an event then nothing will happen.
*
* If the name of the `Event` that is being triggered is in `EventTarget.allowedEvents_`.
* Trigger will also call the `on` + `uppercaseEventName` function.
*
* Example:
* 'click' is in `EventTarget.allowedEvents_`, so, trigger will attempt to call
* `onClick` if it exists.
*
* @param {string|EventTarget~Event|Object} event
* The name of the event, an `Event`, or an object with a key of type set to
* an event name.
*/
EventTarget.prototype.trigger = function (event) {
var type = event.type || event;
if (typeof event === 'string') {
event = { type: type };
}
event = Events.fixEvent(event);
if (this.allowedEvents_[type] && this['on' + type]) {
this['on' + type](event);
}
Events.trigger(this, event);
};
/**
* An alias of {@link EventTarget#trigger}. Allows `EventTarget` to mimic
* the standard DOM API.
*
* @function
* @see {@link EventTarget#trigger}
*/
EventTarget.prototype.dispatchEvent = EventTarget.prototype.trigger;
exports['default'] = EventTarget;
/***/ }),
/***/ "./node_modules/video.js/es5/extend.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* @file extend.js
* @module extend
*/
/**
* A combination of node inherits and babel's inherits (after transpile).
* Both work the same but node adds `super_` to the subClass
* and Bable adds the superClass as __proto__. Both seem useful.
*
* @param {Object} subClass
* The class to inherit to
*
* @param {Object} superClass
* The class to inherit from
*
* @private
*/
var _inherits = function _inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError('Super expression must either be null or a function, not ' + (typeof superClass === 'undefined' ? 'undefined' : _typeof(superClass)));
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) {
// node
subClass.super_ = superClass;
}
};
/**
* Function for subclassing using the same inheritance that
* videojs uses internally
*
* @param {Object} superClass
* The class to inherit from
*
* @param {Object} [subClassMethods={}]
* The class to inherit to
*
* @return {Object}
* The new object with subClassMethods that inherited superClass.
*/
var extendFn = function extendFn(superClass) {
var subClassMethods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var subClass = function subClass() {
superClass.apply(this, arguments);
};
var methods = {};
if ((0, _obj.isObject)(subClassMethods)) {
if (typeof subClassMethods.init === 'function') {
_log2['default'].warn('Constructor logic via init() is deprecated; please use constructor() instead.');
subClassMethods.constructor = subClassMethods.init;
}
if (subClassMethods.constructor !== Object.prototype.constructor) {
subClass = subClassMethods.constructor;
}
methods = subClassMethods;
} else if (typeof subClassMethods === 'function') {
subClass = subClassMethods;
}
_inherits(subClass, superClass);
// Extend subObj's prototype with functions and other properties from props
for (var name in methods) {
if (methods.hasOwnProperty(name)) {
subClass.prototype[name] = methods[name];
}
}
return subClass;
};
exports['default'] = extendFn;
/***/ }),
/***/ "./node_modules/video.js/es5/fullscreen-api.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Store the browser-specific methods for the fullscreen API.
*
* @type {Object}
* @see [Specification]{@link https://fullscreen.spec.whatwg.org}
* @see [Map Approach From Screenfull.js]{@link https://github.com/sindresorhus/screenfull.js}
*/
var FullscreenApi = {};
// browser API methods
/**
* @file fullscreen-api.js
* @module fullscreen-api
* @private
*/
var apiMap = [['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
// WebKit
['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
// Old WebKit (Safari 5.1)
['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'],
// Mozilla
['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'],
// Microsoft
['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];
var specApi = apiMap[0];
var browserApi = void 0;
// determine the supported set of functions
for (var i = 0; i < apiMap.length; i++) {
// check for exitFullscreen function
if (apiMap[i][1] in _document2['default']) {
browserApi = apiMap[i];
break;
}
}
// map the browser API names to the spec API names
if (browserApi) {
for (var _i = 0; _i < browserApi.length; _i++) {
FullscreenApi[specApi[_i]] = browserApi[_i];
}
}
exports['default'] = FullscreenApi;
/***/ }),
/***/ "./node_modules/video.js/es5/loading-spinner.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file loading-spinner.js
*/
/**
* A loading spinner for use during waiting/loading events.
*
* @extends Component
*/
var LoadingSpinner = function (_Component) {
_inherits(LoadingSpinner, _Component);
function LoadingSpinner() {
_classCallCheck(this, LoadingSpinner);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
/**
* Create the `LoadingSpinner`s DOM element.
*
* @return {Element}
* The dom element that gets created.
*/
LoadingSpinner.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-loading-spinner',
dir: 'ltr'
});
};
return LoadingSpinner;
}(_component2['default']);
_component2['default'].registerComponent('LoadingSpinner', LoadingSpinner);
exports['default'] = LoadingSpinner;
/***/ }),
/***/ "./node_modules/video.js/es5/media-error.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
/**
* A Custom `MediaError` class which mimics the standard HTML5 `MediaError` class.
*
* @param {number|string|Object|MediaError} value
* This can be of multiple types:
* - number: should be a standard error code
* - string: an error message (the code will be 0)
* - Object: arbitrary properties
* - `MediaError` (native): used to populate a video.js `MediaError` object
* - `MediaError` (video.js): will return itself if it's already a
* video.js `MediaError` object.
*
* @see [MediaError Spec]{@link https://dev.w3.org/html5/spec-author-view/video.html#mediaerror}
* @see [Encrypted MediaError Spec]{@link https://www.w3.org/TR/2013/WD-encrypted-media-20130510/#error-codes}
*
* @class MediaError
*/
function MediaError(value) {
// Allow redundant calls to this constructor to avoid having `instanceof`
// checks peppered around the code.
if (value instanceof MediaError) {
return value;
}
if (typeof value === 'number') {
this.code = value;
} else if (typeof value === 'string') {
// default code is zero, so this is a custom error
this.message = value;
} else if ((0, _obj.isObject)(value)) {
// We assign the `code` property manually because native `MediaError` objects
// do not expose it as an own/enumerable property of the object.
if (typeof value.code === 'number') {
this.code = value.code;
}
(0, _obj.assign)(this, value);
}
if (!this.message) {
this.message = MediaError.defaultMessages[this.code] || '';
}
}
/**
* The error code that refers two one of the defined `MediaError` types
*
* @type {Number}
*/
/**
* @file media-error.js
*/
MediaError.prototype.code = 0;
/**
* An optional message that to show with the error. Message is not part of the HTML5
* video spec but allows for more informative custom errors.
*
* @type {String}
*/
MediaError.prototype.message = '';
/**
* An optional status code that can be set by plugins to allow even more detail about
* the error. For example a plugin might provide a specific HTTP status code and an
* error message for that code. Then when the plugin gets that error this class will
* know how to display an error message for it. This allows a custom message to show
* up on the `Player` error overlay.
*
* @type {Array}
*/
MediaError.prototype.status = null;
/**
* Errors indexed by the W3C standard. The order **CANNOT CHANGE**! See the
* specification listed under {@link MediaError} for more information.
*
* @enum {array}
* @readonly
* @property {string} 0 - MEDIA_ERR_CUSTOM
* @property {string} 1 - MEDIA_ERR_CUSTOM
* @property {string} 2 - MEDIA_ERR_ABORTED
* @property {string} 3 - MEDIA_ERR_NETWORK
* @property {string} 4 - MEDIA_ERR_SRC_NOT_SUPPORTED
* @property {string} 5 - MEDIA_ERR_ENCRYPTED
*/
MediaError.errorTypes = ['MEDIA_ERR_CUSTOM', 'MEDIA_ERR_ABORTED', 'MEDIA_ERR_NETWORK', 'MEDIA_ERR_DECODE', 'MEDIA_ERR_SRC_NOT_SUPPORTED', 'MEDIA_ERR_ENCRYPTED'];
/**
* The default `MediaError` messages based on the {@link MediaError.errorTypes}.
*
* @type {Array}
* @constant
*/
MediaError.defaultMessages = {
1: 'You aborted the media playback',
2: 'A network error caused the media download to fail part-way.',
3: 'The media playback was aborted due to a corruption problem or because the media used features your browser did not support.',
4: 'The media could not be loaded, either because the server or network failed or because the format is not supported.',
5: 'The media is encrypted and we do not have the keys to decrypt it.'
};
// Add types as properties on MediaError
// e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
for (var errNum = 0; errNum < MediaError.errorTypes.length; errNum++) {
MediaError[MediaError.errorTypes[errNum]] = errNum;
// values should be accessible on both the class and instance
MediaError.prototype[MediaError.errorTypes[errNum]] = errNum;
}
// jsdocs for instance/static members added above
// instance methods use `#` and static methods use `.`
/**
* W3C error code for any custom error.
*
* @member MediaError#MEDIA_ERR_CUSTOM
* @constant {number}
* @default 0
*/
/**
* W3C error code for any custom error.
*
* @member MediaError.MEDIA_ERR_CUSTOM
* @constant {number}
* @default 0
*/
/**
* W3C error code for media error aborted.
*
* @member MediaError#MEDIA_ERR_ABORTED
* @constant {number}
* @default 1
*/
/**
* W3C error code for media error aborted.
*
* @member MediaError.MEDIA_ERR_ABORTED
* @constant {number}
* @default 1
*/
/**
* W3C error code for any network error.
*
* @member MediaError#MEDIA_ERR_NETWORK
* @constant {number}
* @default 2
*/
/**
* W3C error code for any network error.
*
* @member MediaError.MEDIA_ERR_NETWORK
* @constant {number}
* @default 2
*/
/**
* W3C error code for any decoding error.
*
* @member MediaError#MEDIA_ERR_DECODE
* @constant {number}
* @default 3
*/
/**
* W3C error code for any decoding error.
*
* @member MediaError.MEDIA_ERR_DECODE
* @constant {number}
* @default 3
*/
/**
* W3C error code for any time that a source is not supported.
*
* @member MediaError#MEDIA_ERR_SRC_NOT_SUPPORTED
* @constant {number}
* @default 4
*/
/**
* W3C error code for any time that a source is not supported.
*
* @member MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED
* @constant {number}
* @default 4
*/
/**
* W3C error code for any time that a source is encrypted.
*
* @member MediaError#MEDIA_ERR_ENCRYPTED
* @constant {number}
* @default 5
*/
/**
* W3C error code for any time that a source is encrypted.
*
* @member MediaError.MEDIA_ERR_ENCRYPTED
* @constant {number}
* @default 5
*/
exports['default'] = MediaError;
/***/ }),
/***/ "./node_modules/video.js/es5/menu/menu-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _clickableComponent = __webpack_require__("./node_modules/video.js/es5/clickable-component.js");
var _clickableComponent2 = _interopRequireDefault(_clickableComponent);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _menu = __webpack_require__("./node_modules/video.js/es5/menu/menu.js");
var _menu2 = _interopRequireDefault(_menu);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _toTitleCase = __webpack_require__("./node_modules/video.js/es5/utils/to-title-case.js");
var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file menu-button.js
*/
/**
* A `MenuButton` class for any popup {@link Menu}.
*
* @extends ClickableComponent
*/
var MenuButton = function (_ClickableComponent) {
_inherits(MenuButton, _ClickableComponent);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options={}]
* The key/value store of player options.
*/
function MenuButton(player) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, MenuButton);
var _this = _possibleConstructorReturn(this, _ClickableComponent.call(this, player, options));
_this.update();
_this.enabled_ = true;
_this.el_.setAttribute('aria-haspopup', 'true');
_this.el_.setAttribute('role', 'menuitem');
_this.on('keydown', _this.handleSubmenuKeyPress);
return _this;
}
/**
* Update the menu based on the current state of its items.
*/
MenuButton.prototype.update = function update() {
var menu = this.createMenu();
if (this.menu) {
this.removeChild(this.menu);
}
this.menu = menu;
this.addChild(menu);
/**
* Track the state of the menu button
*
* @type {Boolean}
* @private
*/
this.buttonPressed_ = false;
this.el_.setAttribute('aria-expanded', 'false');
if (this.items && this.items.length <= this.hideThreshold_) {
this.hide();
} else {
this.show();
}
};
/**
* Create the menu and add all items to it.
*
* @return {Menu}
* The constructed menu
*/
MenuButton.prototype.createMenu = function createMenu() {
var menu = new _menu2['default'](this.player_);
/**
* Hide the menu if the number of items is less than or equal to this threshold. This defaults
* to 0 and whenever we add items which can be hidden to the menu we'll increment it. We list
* it here because every time we run `createMenu` we need to reset the value.
*
* @protected
* @type {Number}
*/
this.hideThreshold_ = 0;
// Add a title list item to the top
if (this.options_.title) {
var title = Dom.createEl('li', {
className: 'vjs-menu-title',
innerHTML: (0, _toTitleCase2['default'])(this.options_.title),
tabIndex: -1
});
this.hideThreshold_ += 1;
menu.children_.unshift(title);
Dom.insertElFirst(title, menu.contentEl());
}
this.items = this.createItems();
if (this.items) {
// Add menu items to the menu
for (var i = 0; i < this.items.length; i++) {
menu.addItem(this.items[i]);
}
}
return menu;
};
/**
* Create the list of menu items. Specific to each subclass.
*
* @abstract
*/
MenuButton.prototype.createItems = function createItems() {};
/**
* Create the `MenuButtons`s DOM element.
*
* @return {Element}
* The element that gets created.
*/
MenuButton.prototype.createEl = function createEl() {
return _ClickableComponent.prototype.createEl.call(this, 'div', {
className: this.buildCSSClass()
});
};
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
MenuButton.prototype.buildCSSClass = function buildCSSClass() {
var menuButtonClass = 'vjs-menu-button';
// If the inline option is passed, we want to use different styles altogether.
if (this.options_.inline === true) {
menuButtonClass += '-inline';
} else {
menuButtonClass += '-popup';
}
return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this);
};
/**
* Handle a click on a `MenuButton`.
* See {@link ClickableComponent#handleClick} for instances where this is called.
*
* @param {EventTarget~Event} event
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
MenuButton.prototype.handleClick = function handleClick(event) {
// When you click the button it adds focus, which will show the menu.
// So we'll remove focus when the mouse leaves the button. Focus is needed
// for tab navigation.
this.one(this.menu.contentEl(), 'mouseleave', Fn.bind(this, function (e) {
this.unpressButton();
this.el_.blur();
}));
if (this.buttonPressed_) {
this.unpressButton();
} else {
this.pressButton();
}
};
/**
* Handle tab, escape, down arrow, and up arrow keys for `MenuButton`. See
* {@link ClickableComponent#handleKeyPress} for instances where this is called.
*
* @param {EventTarget~Event} event
* The `keydown` event that caused this function to be called.
*
* @listens keydown
*/
MenuButton.prototype.handleKeyPress = function handleKeyPress(event) {
// Escape (27) key or Tab (9) key unpress the 'button'
if (event.which === 27 || event.which === 9) {
if (this.buttonPressed_) {
this.unpressButton();
}
// Don't preventDefault for Tab key - we still want to lose focus
if (event.which !== 9) {
event.preventDefault();
}
// Up (38) key or Down (40) key press the 'button'
} else if (event.which === 38 || event.which === 40) {
if (!this.buttonPressed_) {
this.pressButton();
event.preventDefault();
}
} else {
_ClickableComponent.prototype.handleKeyPress.call(this, event);
}
};
/**
* Handle a `keydown` event on a sub-menu. The listener for this is added in
* the constructor.
*
* @param {EventTarget~Event} event
* Key press event
*
* @listens keydown
*/
MenuButton.prototype.handleSubmenuKeyPress = function handleSubmenuKeyPress(event) {
// Escape (27) key or Tab (9) key unpress the 'button'
if (event.which === 27 || event.which === 9) {
if (this.buttonPressed_) {
this.unpressButton();
}
// Don't preventDefault for Tab key - we still want to lose focus
if (event.which !== 9) {
event.preventDefault();
}
}
};
/**
* Put the current `MenuButton` into a pressed state.
*/
MenuButton.prototype.pressButton = function pressButton() {
if (this.enabled_) {
this.buttonPressed_ = true;
this.menu.lockShowing();
this.el_.setAttribute('aria-expanded', 'true');
// set the focus into the submenu
this.menu.focus();
}
};
/**
* Take the current `MenuButton` out of a pressed state.
*/
MenuButton.prototype.unpressButton = function unpressButton() {
if (this.enabled_) {
this.buttonPressed_ = false;
this.menu.unlockShowing();
this.el_.setAttribute('aria-expanded', 'false');
// Set focus back to this menu button
this.el_.focus();
}
};
/**
* Disable the `MenuButton`. Don't allow it to be clicked.
*
* @return {MenuButton}
* Returns itself; method can be chained.
*/
MenuButton.prototype.disable = function disable() {
// Unpress, but don't force focus on this button
this.buttonPressed_ = false;
this.menu.unlockShowing();
this.el_.setAttribute('aria-expanded', 'false');
this.enabled_ = false;
return _ClickableComponent.prototype.disable.call(this);
};
/**
* Enable the `MenuButton`. Allow it to be clicked.
*
* @return {MenuButton}
* Returns itself; method can be chained.
*/
MenuButton.prototype.enable = function enable() {
this.enabled_ = true;
return _ClickableComponent.prototype.enable.call(this);
};
return MenuButton;
}(_clickableComponent2['default']);
_component2['default'].registerComponent('MenuButton', MenuButton);
exports['default'] = MenuButton;
/***/ }),
/***/ "./node_modules/video.js/es5/menu/menu-item.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _clickableComponent = __webpack_require__("./node_modules/video.js/es5/clickable-component.js");
var _clickableComponent2 = _interopRequireDefault(_clickableComponent);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file menu-item.js
*/
/**
* The component for a menu item. `
`
*
* @extends ClickableComponent
*/
var MenuItem = function (_ClickableComponent) {
_inherits(MenuItem, _ClickableComponent);
/**
* Creates an instance of the this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options={}]
* The key/value store of player options.
*
*/
function MenuItem(player, options) {
_classCallCheck(this, MenuItem);
var _this = _possibleConstructorReturn(this, _ClickableComponent.call(this, player, options));
_this.selectable = options.selectable;
_this.selected(options.selected);
if (_this.selectable) {
// TODO: May need to be either menuitemcheckbox or menuitemradio,
// and may need logical grouping of menu items.
_this.el_.setAttribute('role', 'menuitemcheckbox');
} else {
_this.el_.setAttribute('role', 'menuitem');
}
return _this;
}
/**
* Create the `MenuItem's DOM element
*
* @param {string} [type=li]
* Element's node type, not actually used, always set to `li`.
*
* @param {Object} [props={}]
* An object of properties that should be set on the element
*
* @param {Object} [attrs={}]
* An object of attributes that should be set on the element
*
* @return {Element}
* The element that gets created.
*/
MenuItem.prototype.createEl = function createEl(type, props, attrs) {
// The control is textual, not just an icon
this.nonIconControl = true;
return _ClickableComponent.prototype.createEl.call(this, 'li', (0, _obj.assign)({
className: 'vjs-menu-item',
innerHTML: this.localize(this.options_.label),
tabIndex: -1
}, props), attrs);
};
/**
* Any click on a `MenuItem` puts int into the selected state.
* See {@link ClickableComponent#handleClick} for instances where this is called.
*
* @param {EventTarget~Event} event
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
* @listens tap
* @listens click
*/
MenuItem.prototype.handleClick = function handleClick(event) {
this.selected(true);
};
/**
* Set the state for this menu item as selected or not.
*
* @param {boolean} selected
* if the menu item is selected or not
*/
MenuItem.prototype.selected = function selected(_selected) {
if (this.selectable) {
if (_selected) {
this.addClass('vjs-selected');
this.el_.setAttribute('aria-checked', 'true');
// aria-checked isn't fully supported by browsers/screen readers,
// so indicate selected state to screen reader in the control text.
this.controlText(', selected');
} else {
this.removeClass('vjs-selected');
this.el_.setAttribute('aria-checked', 'false');
// Indicate un-selected state to screen reader
// Note that a space clears out the selected state text
this.controlText(' ');
}
}
};
return MenuItem;
}(_clickableComponent2['default']);
_component2['default'].registerComponent('MenuItem', MenuItem);
exports['default'] = MenuItem;
/***/ }),
/***/ "./node_modules/video.js/es5/menu/menu.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _events = __webpack_require__("./node_modules/video.js/es5/utils/events.js");
var Events = _interopRequireWildcard(_events);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file menu.js
*/
/**
* The Menu component is used to build popup menus, including subtitle and
* captions selection menus.
*
* @extends Component
*/
var Menu = function (_Component) {
_inherits(Menu, _Component);
/**
* Create an instance of this class.
*
* @param {Player} player
* the player that this component should attach to
*
* @param {Object} [options]
* Object of option names and values
*
*/
function Menu(player, options) {
_classCallCheck(this, Menu);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.focusedChild_ = -1;
_this.on('keydown', _this.handleKeyPress);
return _this;
}
/**
* Add a {@link MenuItem} to the menu.
*
* @param {Object|string} component
* The name or instance of the `MenuItem` to add.
*
*/
Menu.prototype.addItem = function addItem(component) {
this.addChild(component);
component.on('click', Fn.bind(this, function (event) {
this.unlockShowing();
// TODO: Need to set keyboard focus back to the menuButton
}));
};
/**
* Create the `Menu`s DOM element.
*
* @return {Element}
* the element that was created
*/
Menu.prototype.createEl = function createEl() {
var contentElType = this.options_.contentElType || 'ul';
this.contentEl_ = Dom.createEl(contentElType, {
className: 'vjs-menu-content'
});
this.contentEl_.setAttribute('role', 'menu');
var el = _Component.prototype.createEl.call(this, 'div', {
append: this.contentEl_,
className: 'vjs-menu'
});
el.setAttribute('role', 'presentation');
el.appendChild(this.contentEl_);
// Prevent clicks from bubbling up. Needed for Menu Buttons,
// where a click on the parent is significant
Events.on(el, 'click', function (event) {
event.preventDefault();
event.stopImmediatePropagation();
});
return el;
};
/**
* Handle a `keydown` event on this menu. This listener is added in the constructor.
*
* @param {EventTarget~Event} event
* A `keydown` event that happened on the menu.
*
* @listens keydown
*/
Menu.prototype.handleKeyPress = function handleKeyPress(event) {
// Left and Down Arrows
if (event.which === 37 || event.which === 40) {
event.preventDefault();
this.stepForward();
// Up and Right Arrows
} else if (event.which === 38 || event.which === 39) {
event.preventDefault();
this.stepBack();
}
};
/**
* Move to next (lower) menu item for keyboard users.
*/
Menu.prototype.stepForward = function stepForward() {
var stepChild = 0;
if (this.focusedChild_ !== undefined) {
stepChild = this.focusedChild_ + 1;
}
this.focus(stepChild);
};
/**
* Move to previous (higher) menu item for keyboard users.
*/
Menu.prototype.stepBack = function stepBack() {
var stepChild = 0;
if (this.focusedChild_ !== undefined) {
stepChild = this.focusedChild_ - 1;
}
this.focus(stepChild);
};
/**
* Set focus on a {@link MenuItem} in the `Menu`.
*
* @param {Object|string} [item=0]
* Index of child item set focus on.
*/
Menu.prototype.focus = function focus() {
var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var children = this.children().slice();
var haveTitle = children.length && children[0].className && /vjs-menu-title/.test(children[0].className);
if (haveTitle) {
children.shift();
}
if (children.length > 0) {
if (item < 0) {
item = 0;
} else if (item >= children.length) {
item = children.length - 1;
}
this.focusedChild_ = item;
children[item].el_.focus();
}
};
return Menu;
}(_component2['default']);
_component2['default'].registerComponent('Menu', Menu);
exports['default'] = Menu;
/***/ }),
/***/ "./node_modules/video.js/es5/modal-dialog.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file modal-dialog.js
*/
var MODAL_CLASS_NAME = 'vjs-modal-dialog';
var ESC = 27;
/**
* The `ModalDialog` displays over the video and its controls, which blocks
* interaction with the player until it is closed.
*
* Modal dialogs include a "Close" button and will close when that button
* is activated - or when ESC is pressed anywhere.
*
* @extends Component
*/
var ModalDialog = function (_Component) {
_inherits(ModalDialog, _Component);
/**
* Create an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Mixed} [options.content=undefined]
* Provide customized content for this modal.
*
* @param {string} [options.description]
* A text description for the modal, primarily for accessibility.
*
* @param {boolean} [options.fillAlways=false]
* Normally, modals are automatically filled only the first time
* they open. This tells the modal to refresh its content
* every time it opens.
*
* @param {string} [options.label]
* A text label for the modal, primarily for accessibility.
*
* @param {boolean} [options.temporary=true]
* If `true`, the modal can only be opened once; it will be
* disposed as soon as it's closed.
*
* @param {boolean} [options.uncloseable=false]
* If `true`, the user will not be able to close the modal
* through the UI in the normal ways. Programmatic closing is
* still possible.
*/
function ModalDialog(player, options) {
_classCallCheck(this, ModalDialog);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.opened_ = _this.hasBeenOpened_ = _this.hasBeenFilled_ = false;
_this.closeable(!_this.options_.uncloseable);
_this.content(_this.options_.content);
// Make sure the contentEl is defined AFTER any children are initialized
// because we only want the contents of the modal in the contentEl
// (not the UI elements like the close button).
_this.contentEl_ = Dom.createEl('div', {
className: MODAL_CLASS_NAME + '-content'
}, {
role: 'document'
});
_this.descEl_ = Dom.createEl('p', {
className: MODAL_CLASS_NAME + '-description vjs-offscreen',
id: _this.el().getAttribute('aria-describedby')
});
Dom.textContent(_this.descEl_, _this.description());
_this.el_.appendChild(_this.descEl_);
_this.el_.appendChild(_this.contentEl_);
return _this;
}
/**
* Create the `ModalDialog`'s DOM element
*
* @return {Element}
* The DOM element that gets created.
*/
ModalDialog.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: this.buildCSSClass(),
tabIndex: -1
}, {
'aria-describedby': this.id() + '_description',
'aria-hidden': 'true',
'aria-label': this.label(),
'role': 'dialog'
});
};
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
ModalDialog.prototype.buildCSSClass = function buildCSSClass() {
return MODAL_CLASS_NAME + ' vjs-hidden ' + _Component.prototype.buildCSSClass.call(this);
};
/**
* Handles `keydown` events on the document, looking for ESC, which closes
* the modal.
*
* @param {EventTarget~Event} e
* The keypress that triggered this event.
*
* @listens keydown
*/
ModalDialog.prototype.handleKeyPress = function handleKeyPress(e) {
if (e.which === ESC && this.closeable()) {
this.close();
}
};
/**
* Returns the label string for this modal. Primarily used for accessibility.
*
* @return {string}
* the localized or raw label of this modal.
*/
ModalDialog.prototype.label = function label() {
return this.options_.label || this.localize('Modal Window');
};
/**
* Returns the description string for this modal. Primarily used for
* accessibility.
*
* @return {string}
* The localized or raw description of this modal.
*/
ModalDialog.prototype.description = function description() {
var desc = this.options_.description || this.localize('This is a modal window.');
// Append a universal closeability message if the modal is closeable.
if (this.closeable()) {
desc += ' ' + this.localize('This modal can be closed by pressing the Escape key or activating the close button.');
}
return desc;
};
/**
* Opens the modal.
*
* @fires ModalDialog#beforemodalopen
* @fires ModalDialog#modalopen
*
* @return {ModalDialog}
* Returns itself; method can be chained.
*/
ModalDialog.prototype.open = function open() {
if (!this.opened_) {
var player = this.player();
/**
* Fired just before a `ModalDialog` is opened.
*
* @event ModalDialog#beforemodalopen
* @type {EventTarget~Event}
*/
this.trigger('beforemodalopen');
this.opened_ = true;
// Fill content if the modal has never opened before and
// never been filled.
if (this.options_.fillAlways || !this.hasBeenOpened_ && !this.hasBeenFilled_) {
this.fill();
}
// If the player was playing, pause it and take note of its previously
// playing state.
this.wasPlaying_ = !player.paused();
if (this.options_.pauseOnOpen && this.wasPlaying_) {
player.pause();
}
if (this.closeable()) {
this.on(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
}
player.controls(false);
this.show();
this.el().setAttribute('aria-hidden', 'false');
/**
* Fired just after a `ModalDialog` is opened.
*
* @event ModalDialog#modalopen
* @type {EventTarget~Event}
*/
this.trigger('modalopen');
this.hasBeenOpened_ = true;
}
return this;
};
/**
* If the `ModalDialog` is currently open or closed.
*
* @param {boolean} [value]
* If given, it will open (`true`) or close (`false`) the modal.
*
* @return {boolean}
* the current open state of the modaldialog
*/
ModalDialog.prototype.opened = function opened(value) {
if (typeof value === 'boolean') {
this[value ? 'open' : 'close']();
}
return this.opened_;
};
/**
* Closes the modal, does nothing if the `ModalDialog` is
* not open.
*
* @fires ModalDialog#beforemodalclose
* @fires ModalDialog#modalclose
*
* @return {ModalDialog}
* Returns itself; method can be chained.
*/
ModalDialog.prototype.close = function close() {
if (this.opened_) {
var player = this.player();
/**
* Fired just before a `ModalDialog` is closed.
*
* @event ModalDialog#beforemodalclose
* @type {EventTarget~Event}
*/
this.trigger('beforemodalclose');
this.opened_ = false;
if (this.wasPlaying_ && this.options_.pauseOnOpen) {
player.play();
}
if (this.closeable()) {
this.off(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
}
player.controls(true);
this.hide();
this.el().setAttribute('aria-hidden', 'true');
/**
* Fired just after a `ModalDialog` is closed.
*
* @event ModalDialog#modalclose
* @type {EventTarget~Event}
*/
this.trigger('modalclose');
if (this.options_.temporary) {
this.dispose();
}
}
return this;
};
/**
* Check to see if the `ModalDialog` is closeable via the UI.
*
* @param {boolean} [value]
* If given as a boolean, it will set the `closeable` option.
*
* @return {boolean}
* Returns the final value of the closable option.
*/
ModalDialog.prototype.closeable = function closeable(value) {
if (typeof value === 'boolean') {
var closeable = this.closeable_ = !!value;
var close = this.getChild('closeButton');
// If this is being made closeable and has no close button, add one.
if (closeable && !close) {
// The close button should be a child of the modal - not its
// content element, so temporarily change the content element.
var temp = this.contentEl_;
this.contentEl_ = this.el_;
close = this.addChild('closeButton', { controlText: 'Close Modal Dialog' });
this.contentEl_ = temp;
this.on(close, 'close', this.close);
}
// If this is being made uncloseable and has a close button, remove it.
if (!closeable && close) {
this.off(close, 'close', this.close);
this.removeChild(close);
close.dispose();
}
}
return this.closeable_;
};
/**
* Fill the modal's content element with the modal's "content" option.
* The content element will be emptied before this change takes place.
*
* @return {ModalDialog}
* Returns itself; method can be chained.
*/
ModalDialog.prototype.fill = function fill() {
return this.fillWith(this.content());
};
/**
* Fill the modal's content element with arbitrary content.
* The content element will be emptied before this change takes place.
*
* @fires ModalDialog#beforemodalfill
* @fires ModalDialog#modalfill
*
* @param {Mixed} [content]
* The same rules apply to this as apply to the `content` option.
*
* @return {ModalDialog}
* Returns itself; method can be chained.
*/
ModalDialog.prototype.fillWith = function fillWith(content) {
var contentEl = this.contentEl();
var parentEl = contentEl.parentNode;
var nextSiblingEl = contentEl.nextSibling;
/**
* Fired just before a `ModalDialog` is filled with content.
*
* @event ModalDialog#beforemodalfill
* @type {EventTarget~Event}
*/
this.trigger('beforemodalfill');
this.hasBeenFilled_ = true;
// Detach the content element from the DOM before performing
// manipulation to avoid modifying the live DOM multiple times.
parentEl.removeChild(contentEl);
this.empty();
Dom.insertContent(contentEl, content);
/**
* Fired just after a `ModalDialog` is filled with content.
*
* @event ModalDialog#modalfill
* @type {EventTarget~Event}
*/
this.trigger('modalfill');
// Re-inject the re-filled content element.
if (nextSiblingEl) {
parentEl.insertBefore(contentEl, nextSiblingEl);
} else {
parentEl.appendChild(contentEl);
}
return this;
};
/**
* Empties the content element. This happens anytime the modal is filled.
*
* @fires ModalDialog#beforemodalempty
* @fires ModalDialog#modalempty
*
* @return {ModalDialog}
* Returns itself; method can be chained.
*/
ModalDialog.prototype.empty = function empty() {
/**
* Fired just before a `ModalDialog` is emptied.
*
* @event ModalDialog#beforemodalempty
* @type {EventTarget~Event}
*/
this.trigger('beforemodalempty');
Dom.emptyEl(this.contentEl());
/**
* Fired just after a `ModalDialog` is emptied.
*
* @event ModalDialog#modalempty
* @type {EventTarget~Event}
*/
this.trigger('modalempty');
return this;
};
/**
* Gets or sets the modal content, which gets normalized before being
* rendered into the DOM.
*
* This does not update the DOM or fill the modal, but it is called during
* that process.
*
* @param {Mixed} [value]
* If defined, sets the internal content value to be used on the
* next call(s) to `fill`. This value is normalized before being
* inserted. To "clear" the internal content value, pass `null`.
*
* @return {Mixed}
* The current content of the modal dialog
*/
ModalDialog.prototype.content = function content(value) {
if (typeof value !== 'undefined') {
this.content_ = value;
}
return this.content_;
};
return ModalDialog;
}(_component2['default']);
/**
* Default options for `ModalDialog` default options.
*
* @type {Object}
* @private
*/
ModalDialog.prototype.options_ = {
pauseOnOpen: true,
temporary: true
};
_component2['default'].registerComponent('ModalDialog', ModalDialog);
exports['default'] = ModalDialog;
/***/ }),
/***/ "./node_modules/video.js/es5/player.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
var _events = __webpack_require__("./node_modules/video.js/es5/utils/events.js");
var Events = _interopRequireWildcard(_events);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _guid = __webpack_require__("./node_modules/video.js/es5/utils/guid.js");
var Guid = _interopRequireWildcard(_guid);
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
var _toTitleCase = __webpack_require__("./node_modules/video.js/es5/utils/to-title-case.js");
var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
var _timeRanges = __webpack_require__("./node_modules/video.js/es5/utils/time-ranges.js");
var _buffer = __webpack_require__("./node_modules/video.js/es5/utils/buffer.js");
var _stylesheet = __webpack_require__("./node_modules/video.js/es5/utils/stylesheet.js");
var stylesheet = _interopRequireWildcard(_stylesheet);
var _fullscreenApi = __webpack_require__("./node_modules/video.js/es5/fullscreen-api.js");
var _fullscreenApi2 = _interopRequireDefault(_fullscreenApi);
var _mediaError = __webpack_require__("./node_modules/video.js/es5/media-error.js");
var _mediaError2 = _interopRequireDefault(_mediaError);
var _tuple = __webpack_require__("./node_modules/safe-json-parse/tuple.js");
var _tuple2 = _interopRequireDefault(_tuple);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
var _mergeOptions = __webpack_require__("./node_modules/video.js/es5/utils/merge-options.js");
var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
var _textTrackListConverter = __webpack_require__("./node_modules/video.js/es5/tracks/text-track-list-converter.js");
var _textTrackListConverter2 = _interopRequireDefault(_textTrackListConverter);
var _modalDialog = __webpack_require__("./node_modules/video.js/es5/modal-dialog.js");
var _modalDialog2 = _interopRequireDefault(_modalDialog);
var _tech = __webpack_require__("./node_modules/video.js/es5/tech/tech.js");
var _tech2 = _interopRequireDefault(_tech);
var _audioTrackList = __webpack_require__("./node_modules/video.js/es5/tracks/audio-track-list.js");
var _audioTrackList2 = _interopRequireDefault(_audioTrackList);
var _videoTrackList = __webpack_require__("./node_modules/video.js/es5/tracks/video-track-list.js");
var _videoTrackList2 = _interopRequireDefault(_videoTrackList);
__webpack_require__("./node_modules/video.js/es5/tech/loader.js");
__webpack_require__("./node_modules/video.js/es5/tech/flash.js");
__webpack_require__("./node_modules/video.js/es5/poster-image.js");
__webpack_require__("./node_modules/video.js/es5/tracks/text-track-display.js");
__webpack_require__("./node_modules/video.js/es5/loading-spinner.js");
__webpack_require__("./node_modules/video.js/es5/big-play-button.js");
__webpack_require__("./node_modules/video.js/es5/close-button.js");
__webpack_require__("./node_modules/video.js/es5/control-bar/control-bar.js");
__webpack_require__("./node_modules/video.js/es5/error-display.js");
__webpack_require__("./node_modules/video.js/es5/tracks/text-track-settings.js");
__webpack_require__("./node_modules/video.js/es5/tech/html5.js");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file player.js
*/
// Subclasses Component
// The following imports are used only to ensure that the corresponding modules
// are always included in the video.js package. Importing the modules will
// execute them and they will register themselves with video.js.
// Import Html5 tech, at least for disposing the original video tag.
// The following tech events are simply re-triggered
// on the player when they happen
var TECH_EVENTS_RETRIGGER = [
/**
* Fired while the user agent is downloading media data.
*
* @event Player#progress
* @type {EventTarget~Event}
*/
/**
* Retrigger the `progress` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechProgress_
* @fires Player#progress
* @listens Tech#progress
*/
'progress',
/**
* Fires when the loading of an audio/video is aborted.
*
* @event Player#abort
* @type {EventTarget~Event}
*/
/**
* Retrigger the `abort` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechAbort_
* @fires Player#abort
* @listens Tech#abort
*/
'abort',
/**
* Fires when the browser is intentionally not getting media data.
*
* @event Player#suspend
* @type {EventTarget~Event}
*/
/**
* Retrigger the `suspend` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechSuspend_
* @fires Player#suspend
* @listens Tech#suspend
*/
'suspend',
/**
* Fires when the current playlist is empty.
*
* @event Player#emptied
* @type {EventTarget~Event}
*/
/**
* Retrigger the `emptied` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechEmptied_
* @fires Player#emptied
* @listens Tech#emptied
*/
'emptied',
/**
* Fires when the browser is trying to get media data, but data is not available.
*
* @event Player#stalled
* @type {EventTarget~Event}
*/
/**
* Retrigger the `stalled` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechStalled_
* @fires Player#stalled
* @listens Tech#stalled
*/
'stalled',
/**
* Fires when the browser has loaded meta data for the audio/video.
*
* @event Player#loadedmetadata
* @type {EventTarget~Event}
*/
/**
* Retrigger the `stalled` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechLoadedmetadata_
* @fires Player#loadedmetadata
* @listens Tech#loadedmetadata
*/
'loadedmetadata',
/**
* Fires when the browser has loaded the current frame of the audio/video.
*
* @event player#loadeddata
* @type {event}
*/
/**
* Retrigger the `loadeddata` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechLoaddeddata_
* @fires Player#loadeddata
* @listens Tech#loadeddata
*/
'loadeddata',
/**
* Fires when the current playback position has changed.
*
* @event player#timeupdate
* @type {event}
*/
/**
* Retrigger the `timeupdate` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechTimeUpdate_
* @fires Player#timeupdate
* @listens Tech#timeupdate
*/
'timeupdate',
/**
* Fires when the playing speed of the audio/video is changed
*
* @event player#ratechange
* @type {event}
*/
/**
* Retrigger the `ratechange` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechRatechange_
* @fires Player#ratechange
* @listens Tech#ratechange
*/
'ratechange',
/**
* Fires when the volume has been changed
*
* @event player#volumechange
* @type {event}
*/
/**
* Retrigger the `volumechange` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechVolumechange_
* @fires Player#volumechange
* @listens Tech#volumechange
*/
'volumechange',
/**
* Fires when the text track has been changed
*
* @event player#texttrackchange
* @type {event}
*/
/**
* Retrigger the `texttrackchange` event that was triggered by the {@link Tech}.
*
* @private
* @method Player#handleTechTexttrackchange_
* @fires Player#texttrackchange
* @listens Tech#texttrackchange
*/
'texttrackchange'];
/**
* An instance of the `Player` class is created when any of the Video.js setup methods
* are used to initialize a video.
*
* After an instance has been created it can be accessed globally in two ways:
* 1. By calling `videojs('example_video_1');`
* 2. By using it directly via `videojs.players.example_video_1;`
*
* @extends Component
*/
var Player = function (_Component) {
_inherits(Player, _Component);
/**
* Create an instance of this class.
*
* @param {Element} tag
* The original video DOM element used for configuring options.
*
* @param {Object} [options]
* Object of option names and values.
*
* @param {Component~ReadyCallback} [ready]
* Ready callback function.
*/
function Player(tag, options, ready) {
_classCallCheck(this, Player);
// Make sure tag ID exists
tag.id = tag.id || 'vjs_video_' + Guid.newGUID();
// Set Options
// The options argument overrides options set in the video tag
// which overrides globally set options.
// This latter part coincides with the load order
// (tag must exist before Player)
options = (0, _obj.assign)(Player.getTagSettings(tag), options);
// Delay the initialization of children because we need to set up
// player properties first, and can't use `this` before `super()`
options.initChildren = false;
// Same with creating the element
options.createEl = false;
// we don't want the player to report touch activity on itself
// see enableTouchActivity in Component
options.reportTouchActivity = false;
// If language is not set, get the closest lang attribute
if (!options.language) {
if (typeof tag.closest === 'function') {
var closest = tag.closest('[lang]');
if (closest) {
options.language = closest.getAttribute('lang');
}
} else {
var element = tag;
while (element && element.nodeType === 1) {
if (Dom.getElAttributes(element).hasOwnProperty('lang')) {
options.language = element.getAttribute('lang');
break;
}
element = element.parentNode;
}
}
}
// Run base component initializing with new options
// if the global option object was accidentally blown away by
// someone, bail early with an informative error
var _this = _possibleConstructorReturn(this, _Component.call(this, null, options, ready));
if (!_this.options_ || !_this.options_.techOrder || !_this.options_.techOrder.length) {
throw new Error('No techOrder specified. Did you overwrite ' + 'videojs.options instead of just changing the ' + 'properties you want to override?');
}
// Store the original tag used to set options
_this.tag = tag;
// Store the tag attributes used to restore html5 element
_this.tagAttributes = tag && Dom.getElAttributes(tag);
// Update current language
_this.language(_this.options_.language);
// Update Supported Languages
if (options.languages) {
// Normalise player option languages to lowercase
var languagesToLower = {};
Object.getOwnPropertyNames(options.languages).forEach(function (name) {
languagesToLower[name.toLowerCase()] = options.languages[name];
});
_this.languages_ = languagesToLower;
} else {
_this.languages_ = Player.prototype.options_.languages;
}
// Cache for video property values.
_this.cache_ = {};
// Set poster
_this.poster_ = options.poster || '';
// Set controls
_this.controls_ = !!options.controls;
// Original tag settings stored in options
// now remove immediately so native controls don't flash.
// May be turned back on by HTML5 tech if nativeControlsForTouch is true
tag.controls = false;
/*
* Store the internal state of scrubbing
*
* @private
* @return {Boolean} True if the user is scrubbing
*/
_this.scrubbing_ = false;
_this.el_ = _this.createEl();
// We also want to pass the original player options to each component and plugin
// as well so they don't need to reach back into the player for options later.
// We also need to do another copy of this.options_ so we don't end up with
// an infinite loop.
var playerOptionsCopy = (0, _mergeOptions2['default'])(_this.options_);
// Load plugins
if (options.plugins) {
var plugins = options.plugins;
Object.getOwnPropertyNames(plugins).forEach(function (name) {
if (typeof this[name] === 'function') {
this[name](plugins[name]);
} else {
_log2['default'].error('Unable to find plugin:', name);
}
}, _this);
}
_this.options_.playerOptions = playerOptionsCopy;
_this.initChildren();
// Set isAudio based on whether or not an audio tag was used
_this.isAudio(tag.nodeName.toLowerCase() === 'audio');
// Update controls className. Can't do this when the controls are initially
// set because the element doesn't exist yet.
if (_this.controls()) {
_this.addClass('vjs-controls-enabled');
} else {
_this.addClass('vjs-controls-disabled');
}
// Set ARIA label and region role depending on player type
_this.el_.setAttribute('role', 'region');
if (_this.isAudio()) {
_this.el_.setAttribute('aria-label', 'audio player');
} else {
_this.el_.setAttribute('aria-label', 'video player');
}
if (_this.isAudio()) {
_this.addClass('vjs-audio');
}
if (_this.flexNotSupported_()) {
_this.addClass('vjs-no-flex');
}
// TODO: Make this smarter. Toggle user state between touching/mousing
// using events, since devices can have both touch and mouse events.
// if (browser.TOUCH_ENABLED) {
// this.addClass('vjs-touch-enabled');
// }
// iOS Safari has broken hover handling
if (!browser.IS_IOS) {
_this.addClass('vjs-workinghover');
}
// Make player easily findable by ID
Player.players[_this.id_] = _this;
// When the player is first initialized, trigger activity so components
// like the control bar show themselves if needed
_this.userActive(true);
_this.reportUserActivity();
_this.listenForUserActivity_();
_this.on('fullscreenchange', _this.handleFullscreenChange_);
_this.on('stageclick', _this.handleStageClick_);
return _this;
}
/**
* Destroys the video player and does any necessary cleanup.
*
* This is especially helpful if you are dynamically adding and removing videos
* to/from the DOM.
*
* @fires Player#dispose
*/
Player.prototype.dispose = function dispose() {
/**
* Called when the player is being disposed of.
*
* @event Player#dispose
* @type {EventTarget~Event}
*/
this.trigger('dispose');
// prevent dispose from being called twice
this.off('dispose');
if (this.styleEl_ && this.styleEl_.parentNode) {
this.styleEl_.parentNode.removeChild(this.styleEl_);
}
// Kill reference to this player
Player.players[this.id_] = null;
if (this.tag && this.tag.player) {
this.tag.player = null;
}
if (this.el_ && this.el_.player) {
this.el_.player = null;
}
if (this.tech_) {
this.tech_.dispose();
}
_Component.prototype.dispose.call(this);
};
/**
* Create the `Player`'s DOM element.
*
* @return {Element}
* The DOM element that gets created.
*/
Player.prototype.createEl = function createEl() {
var tag = this.tag;
var el = void 0;
var playerElIngest = this.playerElIngest_ = tag.parentNode && tag.parentNode.hasAttribute && tag.parentNode.hasAttribute('data-vjs-player');
if (playerElIngest) {
el = this.el_ = tag.parentNode;
} else {
el = this.el_ = _Component.prototype.createEl.call(this, 'div');
}
// set tabindex to -1 so we could focus on the player element
tag.setAttribute('tabindex', '-1');
// Remove width/height attrs from tag so CSS can make it 100% width/height
tag.removeAttribute('width');
tag.removeAttribute('height');
// Copy over all the attributes from the tag, including ID and class
// ID will now reference player box, not the video tag
var attrs = Dom.getElAttributes(tag);
Object.getOwnPropertyNames(attrs).forEach(function (attr) {
// workaround so we don't totally break IE7
// http://stackoverflow.com/questions/3653444/css-styles-not-applied-on-dynamic-elements-in-internet-explorer-7
if (attr === 'class') {
el.className += ' ' + attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
});
// Update tag id/class for use as HTML5 playback tech
// Might think we should do this after embedding in container so .vjs-tech class
// doesn't flash 100% width/height, but class only applies with .video-js parent
tag.playerId = tag.id;
tag.id += '_html5_api';
tag.className = 'vjs-tech';
// Make player findable on elements
tag.player = el.player = this;
// Default state of video is paused
this.addClass('vjs-paused');
// Add a style element in the player that we'll use to set the width/height
// of the player in a way that's still overrideable by CSS, just like the
// video element
if (_window2['default'].VIDEOJS_NO_DYNAMIC_STYLE !== true) {
this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions');
var defaultsStyleEl = Dom.$('.vjs-styles-defaults');
var head = Dom.$('head');
head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild);
}
// Pass in the width/height/aspectRatio options which will update the style el
this.width(this.options_.width);
this.height(this.options_.height);
this.fluid(this.options_.fluid);
this.aspectRatio(this.options_.aspectRatio);
// Hide any links within the video/audio tag, because IE doesn't hide them completely.
var links = tag.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
var linkEl = links.item(i);
Dom.addElClass(linkEl, 'vjs-hidden');
linkEl.setAttribute('hidden', 'hidden');
}
// insertElFirst seems to cause the networkState to flicker from 3 to 2, so
// keep track of the original for later so we can know if the source originally failed
tag.initNetworkState_ = tag.networkState;
// Wrap video tag in div (el/box) container
if (tag.parentNode && !playerElIngest) {
tag.parentNode.insertBefore(el, tag);
}
// insert the tag as the first child of the player element
// then manually add it to the children array so that this.addChild
// will work properly for other components
//
// Breaks iPhone, fixed in HTML5 setup.
Dom.insertElFirst(tag, el);
this.children_.unshift(tag);
this.el_ = el;
return el;
};
/**
* A getter/setter for the `Player`'s width.
*
* @param {number} [value]
* The value to set the `Player's width to.
*
* @return {number}
* The current width of the `Player`.
*/
Player.prototype.width = function width(value) {
return this.dimension('width', value);
};
/**
* A getter/setter for the `Player`'s height.
*
* @param {number} [value]
* The value to set the `Player's heigth to.
*
* @return {number}
* The current heigth of the `Player`.
*/
Player.prototype.height = function height(value) {
return this.dimension('height', value);
};
/**
* A getter/setter for the `Player`'s width & height.
*
* @param {string} dimension
* This string can be:
* - 'width'
* - 'height'
*
* @param {number} [value]
* Value for dimension specified in the first argument.
*
* @return {Player|number}
* - Returns itself when setting; method can be chained.
* - The dimension arguments value when getting (width/height).
*/
Player.prototype.dimension = function dimension(_dimension, value) {
var privDimension = _dimension + '_';
if (value === undefined) {
return this[privDimension] || 0;
}
if (value === '') {
// If an empty string is given, reset the dimension to be automatic
this[privDimension] = undefined;
} else {
var parsedVal = parseFloat(value);
if (isNaN(parsedVal)) {
_log2['default'].error('Improper value "' + value + '" supplied for for ' + _dimension);
return this;
}
this[privDimension] = parsedVal;
}
this.updateStyleEl_();
return this;
};
/**
* A getter/setter/toggler for the vjs-fluid `className` on the `Player`.
*
* @param {boolean} [bool]
* - A value of true adds the class.
* - A value of false removes the class.
* - No value will toggle the fluid class.
*
* @return {boolean|undefined}
* - The value of fluid when getting.
* - `undefined` when setting.
*/
Player.prototype.fluid = function fluid(bool) {
if (bool === undefined) {
return !!this.fluid_;
}
this.fluid_ = !!bool;
if (bool) {
this.addClass('vjs-fluid');
} else {
this.removeClass('vjs-fluid');
}
this.updateStyleEl_();
};
/**
* Get/Set the aspect ratio
*
* @param {string} [ratio]
* Aspect ratio for player
*
* @return {string|undefined}
* returns the current aspect ratio when getting
*/
/**
* A getter/setter for the `Player`'s aspect ratio.
*
* @param {string} [ratio]
* The value to set the `Player's aspect ratio to.
*
* @return {string|undefined}
* - The current aspect ratio of the `Player` when getting.
* - undefined when setting
*/
Player.prototype.aspectRatio = function aspectRatio(ratio) {
if (ratio === undefined) {
return this.aspectRatio_;
}
// Check for width:height format
if (!/^\d+\:\d+$/.test(ratio)) {
throw new Error('Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.');
}
this.aspectRatio_ = ratio;
// We're assuming if you set an aspect ratio you want fluid mode,
// because in fixed mode you could calculate width and height yourself.
this.fluid(true);
this.updateStyleEl_();
};
/**
* Update styles of the `Player` element (height, width and aspect ratio).
*
* @private
* @listens Tech#loadedmetadata
*/
Player.prototype.updateStyleEl_ = function updateStyleEl_() {
if (_window2['default'].VIDEOJS_NO_DYNAMIC_STYLE === true) {
var _width = typeof this.width_ === 'number' ? this.width_ : this.options_.width;
var _height = typeof this.height_ === 'number' ? this.height_ : this.options_.height;
var techEl = this.tech_ && this.tech_.el();
if (techEl) {
if (_width >= 0) {
techEl.width = _width;
}
if (_height >= 0) {
techEl.height = _height;
}
}
return;
}
var width = void 0;
var height = void 0;
var aspectRatio = void 0;
var idClass = void 0;
// The aspect ratio is either used directly or to calculate width and height.
if (this.aspectRatio_ !== undefined && this.aspectRatio_ !== 'auto') {
// Use any aspectRatio that's been specifically set
aspectRatio = this.aspectRatio_;
} else if (this.videoWidth() > 0) {
// Otherwise try to get the aspect ratio from the video metadata
aspectRatio = this.videoWidth() + ':' + this.videoHeight();
} else {
// Or use a default. The video element's is 2:1, but 16:9 is more common.
aspectRatio = '16:9';
}
// Get the ratio as a decimal we can use to calculate dimensions
var ratioParts = aspectRatio.split(':');
var ratioMultiplier = ratioParts[1] / ratioParts[0];
if (this.width_ !== undefined) {
// Use any width that's been specifically set
width = this.width_;
} else if (this.height_ !== undefined) {
// Or calulate the width from the aspect ratio if a height has been set
width = this.height_ / ratioMultiplier;
} else {
// Or use the video's metadata, or use the video el's default of 300
width = this.videoWidth() || 300;
}
if (this.height_ !== undefined) {
// Use any height that's been specifically set
height = this.height_;
} else {
// Otherwise calculate the height from the ratio and the width
height = width * ratioMultiplier;
}
// Ensure the CSS class is valid by starting with an alpha character
if (/^[^a-zA-Z]/.test(this.id())) {
idClass = 'dimensions-' + this.id();
} else {
idClass = this.id() + '-dimensions';
}
// Ensure the right class is still on the player for the style element
this.addClass(idClass);
stylesheet.setTextContent(this.styleEl_, '\n .' + idClass + ' {\n width: ' + width + 'px;\n height: ' + height + 'px;\n }\n\n .' + idClass + '.vjs-fluid {\n padding-top: ' + ratioMultiplier * 100 + '%;\n }\n ');
};
/**
* Load/Create an instance of playback {@link Tech} including element
* and API methods. Then append the `Tech` element in `Player` as a child.
*
* @param {string} techName
* name of the playback technology
*
* @param {string} source
* video source
*
* @private
*/
Player.prototype.loadTech_ = function loadTech_(techName, source) {
var _this2 = this;
// Pause and remove current playback technology
if (this.tech_) {
this.unloadTech_();
}
// get rid of the HTML5 video tag as soon as we are using another tech
if (techName !== 'Html5' && this.tag) {
_tech2['default'].getTech('Html5').disposeMediaElement(this.tag);
this.tag.player = null;
this.tag = null;
}
this.techName_ = techName;
// Turn off API access because we're loading a new tech that might load asynchronously
this.isReady_ = false;
// Grab tech-specific options from player options and add source and parent element to use.
var techOptions = (0, _obj.assign)({
source: source,
'nativeControlsForTouch': this.options_.nativeControlsForTouch,
'playerId': this.id(),
'techId': this.id() + '_' + techName + '_api',
'videoTracks': this.videoTracks_,
'textTracks': this.textTracks_,
'audioTracks': this.audioTracks_,
'autoplay': this.options_.autoplay,
'preload': this.options_.preload,
'loop': this.options_.loop,
'muted': this.options_.muted,
'poster': this.poster(),
'language': this.language(),
'playerElIngest': this.playerElIngest_ || false,
'vtt.js': this.options_['vtt.js']
}, this.options_[techName.toLowerCase()]);
if (this.tag) {
techOptions.tag = this.tag;
}
if (source) {
this.currentType_ = source.type;
if (source.src === this.cache_.src && this.cache_.currentTime > 0) {
techOptions.startTime = this.cache_.currentTime;
}
this.cache_.sources = null;
this.cache_.source = source;
this.cache_.src = source.src;
}
// Initialize tech instance
var TechComponent = _tech2['default'].getTech(techName);
// Support old behavior of techs being registered as components.
// Remove once that deprecated behavior is removed.
if (!TechComponent) {
TechComponent = _component2['default'].getComponent(techName);
}
this.tech_ = new TechComponent(techOptions);
// player.triggerReady is always async, so don't need this to be async
this.tech_.ready(Fn.bind(this, this.handleTechReady_), true);
_textTrackListConverter2['default'].jsonToTextTracks(this.textTracksJson_ || [], this.tech_);
// Listen to all HTML5-defined events and trigger them on the player
TECH_EVENTS_RETRIGGER.forEach(function (event) {
_this2.on(_this2.tech_, event, _this2['handleTech' + (0, _toTitleCase2['default'])(event) + '_']);
});
this.on(this.tech_, 'loadstart', this.handleTechLoadStart_);
this.on(this.tech_, 'waiting', this.handleTechWaiting_);
this.on(this.tech_, 'canplay', this.handleTechCanPlay_);
this.on(this.tech_, 'canplaythrough', this.handleTechCanPlayThrough_);
this.on(this.tech_, 'playing', this.handleTechPlaying_);
this.on(this.tech_, 'ended', this.handleTechEnded_);
this.on(this.tech_, 'seeking', this.handleTechSeeking_);
this.on(this.tech_, 'seeked', this.handleTechSeeked_);
this.on(this.tech_, 'play', this.handleTechPlay_);
this.on(this.tech_, 'firstplay', this.handleTechFirstPlay_);
this.on(this.tech_, 'pause', this.handleTechPause_);
this.on(this.tech_, 'durationchange', this.handleTechDurationChange_);
this.on(this.tech_, 'fullscreenchange', this.handleTechFullscreenChange_);
this.on(this.tech_, 'error', this.handleTechError_);
this.on(this.tech_, 'loadedmetadata', this.updateStyleEl_);
this.on(this.tech_, 'posterchange', this.handleTechPosterChange_);
this.on(this.tech_, 'textdata', this.handleTechTextData_);
this.usingNativeControls(this.techGet_('controls'));
if (this.controls() && !this.usingNativeControls()) {
this.addTechControlsListeners_();
}
// Add the tech element in the DOM if it was not already there
// Make sure to not insert the original video element if using Html5
if (this.tech_.el().parentNode !== this.el() && (techName !== 'Html5' || !this.tag)) {
Dom.insertElFirst(this.tech_.el(), this.el());
}
// Get rid of the original video tag reference after the first tech is loaded
if (this.tag) {
this.tag.player = null;
this.tag = null;
}
};
/**
* Unload and dispose of the current playback {@link Tech}.
*
* @private
*/
Player.prototype.unloadTech_ = function unloadTech_() {
// Save the current text tracks so that we can reuse the same text tracks with the next tech
this.videoTracks_ = this.videoTracks();
this.textTracks_ = this.textTracks();
this.audioTracks_ = this.audioTracks();
this.textTracksJson_ = _textTrackListConverter2['default'].textTracksToJson(this.tech_);
this.isReady_ = false;
this.tech_.dispose();
this.tech_ = false;
};
/**
* Return a reference to the current {@link Tech}, but only if given an object with the
* `IWillNotUseThisInPlugins` property having a true value. This is try and prevent misuse
* of techs by plugins.
*
* @param {Object} safety
* An object that must contain `{IWillNotUseThisInPlugins: true}`
*
* @param {boolean} safety.IWillNotUseThisInPlugins
* Must be set to true or else this function will throw an error.
*
* @return {Tech}
* The Tech
*/
Player.prototype.tech = function tech(safety) {
if (safety && safety.IWillNotUseThisInPlugins) {
return this.tech_;
}
var errorText = '\n Please make sure that you are not using this inside of a plugin.\n To disable this alert and error, please pass in an object with\n `IWillNotUseThisInPlugins` to the `tech` method. See\n https://github.com/videojs/video.js/issues/2617 for more info.\n ';
_window2['default'].alert(errorText);
throw new Error(errorText);
};
/**
* Set up click and touch listeners for the playback element
*
* - On desktops: a click on the video itself will toggle playback
* - On mobile devices: a click on the video toggles controls
* which is done by toggling the user state between active and
* inactive
* - A tap can signal that a user has become active or has become inactive
* e.g. a quick tap on an iPhone movie should reveal the controls. Another
* quick tap should hide them again (signaling the user is in an inactive
* viewing state)
* - In addition to this, we still want the user to be considered inactive after
* a few seconds of inactivity.
*
* > Note: the only part of iOS interaction we can't mimic with this setup
* is a touch and hold on the video element counting as activity in order to
* keep the controls showing, but that shouldn't be an issue. A touch and hold
* on any controls will still keep the user active
*
* @private
*/
Player.prototype.addTechControlsListeners_ = function addTechControlsListeners_() {
// Make sure to remove all the previous listeners in case we are called multiple times.
this.removeTechControlsListeners_();
// Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
// trigger mousedown/up.
// http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
// Any touch events are set to block the mousedown event from happening
this.on(this.tech_, 'mousedown', this.handleTechClick_);
// If the controls were hidden we don't want that to change without a tap event
// so we'll check if the controls were already showing before reporting user
// activity
this.on(this.tech_, 'touchstart', this.handleTechTouchStart_);
this.on(this.tech_, 'touchmove', this.handleTechTouchMove_);
this.on(this.tech_, 'touchend', this.handleTechTouchEnd_);
// The tap listener needs to come after the touchend listener because the tap
// listener cancels out any reportedUserActivity when setting userActive(false)
this.on(this.tech_, 'tap', this.handleTechTap_);
};
/**
* Remove the listeners used for click and tap controls. This is needed for
* toggling to controls disabled, where a tap/touch should do nothing.
*
* @private
*/
Player.prototype.removeTechControlsListeners_ = function removeTechControlsListeners_() {
// We don't want to just use `this.off()` because there might be other needed
// listeners added by techs that extend this.
this.off(this.tech_, 'tap', this.handleTechTap_);
this.off(this.tech_, 'touchstart', this.handleTechTouchStart_);
this.off(this.tech_, 'touchmove', this.handleTechTouchMove_);
this.off(this.tech_, 'touchend', this.handleTechTouchEnd_);
this.off(this.tech_, 'mousedown', this.handleTechClick_);
};
/**
* Player waits for the tech to be ready
*
* @private
*/
Player.prototype.handleTechReady_ = function handleTechReady_() {
this.triggerReady();
// Keep the same volume as before
if (this.cache_.volume) {
this.techCall_('setVolume', this.cache_.volume);
}
// Look if the tech found a higher resolution poster while loading
this.handleTechPosterChange_();
// Update the duration if available
this.handleTechDurationChange_();
// Chrome and Safari both have issues with autoplay.
// In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
// In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
// This fixes both issues. Need to wait for API, so it updates displays correctly
if ((this.src() || this.currentSrc()) && this.tag && this.options_.autoplay && this.paused()) {
try {
// Chrome Fix. Fixed in Chrome v16.
delete this.tag.poster;
} catch (e) {
(0, _log2['default'])('deleting tag.poster throws in some browsers', e);
}
this.play();
}
};
/**
* Retrigger the `loadstart` event that was triggered by the {@link Tech}. This
* function will also trigger {@link Player#firstplay} if it is the first loadstart
* for a video.
*
* @fires Player#loadstart
* @fires Player#firstplay
* @listens Tech#loadstart
* @private
*/
Player.prototype.handleTechLoadStart_ = function handleTechLoadStart_() {
// TODO: Update to use `emptied` event instead. See #1277.
this.removeClass('vjs-ended');
this.removeClass('vjs-seeking');
// reset the error state
this.error(null);
// If it's already playing we want to trigger a firstplay event now.
// The firstplay event relies on both the play and loadstart events
// which can happen in any order for a new source
if (!this.paused()) {
/**
* Fired when the user agent begins looking for media data
*
* @event Player#loadstart
* @type {EventTarget~Event}
*/
this.trigger('loadstart');
this.trigger('firstplay');
} else {
// reset the hasStarted state
this.hasStarted(false);
this.trigger('loadstart');
}
};
/**
* Add/remove the vjs-has-started class
*
* @fires Player#firstplay
*
* @param {boolean} hasStarted
* - true: adds the class
* - false: remove the class
*
* @return {boolean}
* the boolean value of hasStarted
*/
Player.prototype.hasStarted = function hasStarted(_hasStarted) {
if (_hasStarted !== undefined) {
// only update if this is a new value
if (this.hasStarted_ !== _hasStarted) {
this.hasStarted_ = _hasStarted;
if (_hasStarted) {
this.addClass('vjs-has-started');
// trigger the firstplay event if this newly has played
this.trigger('firstplay');
} else {
this.removeClass('vjs-has-started');
}
}
return this;
}
return !!this.hasStarted_;
};
/**
* Fired whenever the media begins or resumes playback
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play}
* @fires Player#play
* @listens Tech#play
* @private
*/
Player.prototype.handleTechPlay_ = function handleTechPlay_() {
this.removeClass('vjs-ended');
this.removeClass('vjs-paused');
this.addClass('vjs-playing');
// hide the poster when the user hits play
this.hasStarted(true);
/**
* Triggered whenever an {@link Tech#play} event happens. Indicates that
* playback has started or resumed.
*
* @event Player#play
* @type {EventTarget~Event}
*/
this.trigger('play');
};
/**
* Retrigger the `waiting` event that was triggered by the {@link Tech}.
*
* @fires Player#waiting
* @listens Tech#waiting
* @private
*/
Player.prototype.handleTechWaiting_ = function handleTechWaiting_() {
var _this3 = this;
this.addClass('vjs-waiting');
/**
* A readyState change on the DOM element has caused playback to stop.
*
* @event Player#waiting
* @type {EventTarget~Event}
*/
this.trigger('waiting');
this.one('timeupdate', function () {
return _this3.removeClass('vjs-waiting');
});
};
/**
* Retrigger the `canplay` event that was triggered by the {@link Tech}.
* > Note: This is not consistent between browsers. See #1351
*
* @fires Player#canplay
* @listens Tech#canplay
* @private
*/
Player.prototype.handleTechCanPlay_ = function handleTechCanPlay_() {
this.removeClass('vjs-waiting');
/**
* The media has a readyState of HAVE_FUTURE_DATA or greater.
*
* @event Player#canplay
* @type {EventTarget~Event}
*/
this.trigger('canplay');
};
/**
* Retrigger the `canplaythrough` event that was triggered by the {@link Tech}.
*
* @fires Player#canplaythrough
* @listens Tech#canplaythrough
* @private
*/
Player.prototype.handleTechCanPlayThrough_ = function handleTechCanPlayThrough_() {
this.removeClass('vjs-waiting');
/**
* The media has a readyState of HAVE_ENOUGH_DATA or greater. This means that the
* entire media file can be played without buffering.
*
* @event Player#canplaythrough
* @type {EventTarget~Event}
*/
this.trigger('canplaythrough');
};
/**
* Retrigger the `playing` event that was triggered by the {@link Tech}.
*
* @fires Player#playing
* @listens Tech#playing
* @private
*/
Player.prototype.handleTechPlaying_ = function handleTechPlaying_() {
this.removeClass('vjs-waiting');
/**
* The media is no longer blocked from playback, and has started playing.
*
* @event Player#playing
* @type {EventTarget~Event}
*/
this.trigger('playing');
};
/**
* Retrigger the `seeking` event that was triggered by the {@link Tech}.
*
* @fires Player#seeking
* @listens Tech#seeking
* @private
*/
Player.prototype.handleTechSeeking_ = function handleTechSeeking_() {
this.addClass('vjs-seeking');
/**
* Fired whenever the player is jumping to a new time
*
* @event Player#seeking
* @type {EventTarget~Event}
*/
this.trigger('seeking');
};
/**
* Retrigger the `seeked` event that was triggered by the {@link Tech}.
*
* @fires Player#seeked
* @listens Tech#seeked
* @private
*/
Player.prototype.handleTechSeeked_ = function handleTechSeeked_() {
this.removeClass('vjs-seeking');
/**
* Fired when the player has finished jumping to a new time
*
* @event Player#seeked
* @type {EventTarget~Event}
*/
this.trigger('seeked');
};
/**
* Retrigger the `firstplay` event that was triggered by the {@link Tech}.
*
* @fires Player#firstplay
* @listens Tech#firstplay
* @deprecated As of 6.0 passing the `starttime` option to the player will be deprecated
* @private
*/
Player.prototype.handleTechFirstPlay_ = function handleTechFirstPlay_() {
// If the first starttime attribute is specified
// then we will start at the given offset in seconds
if (this.options_.starttime) {
_log2['default'].warn('Passing the `starttime` option to the player will be deprecated in 6.0');
this.currentTime(this.options_.starttime);
}
this.addClass('vjs-has-started');
/**
* Fired the first time a video is played. Not part of the HLS spec, and this is
* probably not the best implementation yet, so use sparingly. If you don't have a
* reason to prevent playback, use `myPlayer.one('play');` instead.
*
* @event Player#firstplay
* @type {EventTarget~Event}
*/
this.trigger('firstplay');
};
/**
* Retrigger the `pause` event that was triggered by the {@link Tech}.
*
* @fires Player#pause
* @listens Tech#pause
* @private
*/
Player.prototype.handleTechPause_ = function handleTechPause_() {
this.removeClass('vjs-playing');
this.addClass('vjs-paused');
/**
* Fired whenever the media has been paused
*
* @event Player#pause
* @type {EventTarget~Event}
*/
this.trigger('pause');
};
/**
* Retrigger the `ended` event that was triggered by the {@link Tech}.
*
* @fires Player#ended
* @listens Tech#ended
* @private
*/
Player.prototype.handleTechEnded_ = function handleTechEnded_() {
this.addClass('vjs-ended');
if (this.options_.loop) {
this.currentTime(0);
this.play();
} else if (!this.paused()) {
this.pause();
}
/**
* Fired when the end of the media resource is reached (currentTime == duration)
*
* @event Player#ended
* @type {EventTarget~Event}
*/
this.trigger('ended');
};
/**
* Fired when the duration of the media resource is first known or changed
*
* @listens Tech#durationchange
* @private
*/
Player.prototype.handleTechDurationChange_ = function handleTechDurationChange_() {
this.duration(this.techGet_('duration'));
};
/**
* Handle a click on the media element to play/pause
*
* @param {EventTarget~Event} event
* the event that caused this function to trigger
*
* @listens Tech#mousedown
* @private
*/
Player.prototype.handleTechClick_ = function handleTechClick_(event) {
// We're using mousedown to detect clicks thanks to Flash, but mousedown
// will also be triggered with right-clicks, so we need to prevent that
if (event.button !== 0) {
return;
}
// When controls are disabled a click should not toggle playback because
// the click is considered a control
if (this.controls()) {
if (this.paused()) {
this.play();
} else {
this.pause();
}
}
};
/**
* Handle a tap on the media element. It will toggle the user
* activity state, which hides and shows the controls.
*
* @listens Tech#tap
* @private
*/
Player.prototype.handleTechTap_ = function handleTechTap_() {
this.userActive(!this.userActive());
};
/**
* Handle touch to start
*
* @listens Tech#touchstart
* @private
*/
Player.prototype.handleTechTouchStart_ = function handleTechTouchStart_() {
this.userWasActive = this.userActive();
};
/**
* Handle touch to move
*
* @listens Tech#touchmove
* @private
*/
Player.prototype.handleTechTouchMove_ = function handleTechTouchMove_() {
if (this.userWasActive) {
this.reportUserActivity();
}
};
/**
* Handle touch to end
*
* @param {EventTarget~Event} event
* the touchend event that triggered
* this function
*
* @listens Tech#touchend
* @private
*/
Player.prototype.handleTechTouchEnd_ = function handleTechTouchEnd_(event) {
// Stop the mouse events from also happening
event.preventDefault();
};
/**
* Fired when the player switches in or out of fullscreen mode
*
* @private
* @listens Player#fullscreenchange
*/
Player.prototype.handleFullscreenChange_ = function handleFullscreenChange_() {
if (this.isFullscreen()) {
this.addClass('vjs-fullscreen');
} else {
this.removeClass('vjs-fullscreen');
}
};
/**
* native click events on the SWF aren't triggered on IE11, Win8.1RT
* use stageclick events triggered from inside the SWF instead
*
* @private
* @listens stageclick
*/
Player.prototype.handleStageClick_ = function handleStageClick_() {
this.reportUserActivity();
};
/**
* Handle Tech Fullscreen Change
*
* @param {EventTarget~Event} event
* the fullscreenchange event that triggered this function
*
* @param {Object} data
* the data that was sent with the event
*
* @private
* @listens Tech#fullscreenchange
* @fires Player#fullscreenchange
*/
Player.prototype.handleTechFullscreenChange_ = function handleTechFullscreenChange_(event, data) {
if (data) {
this.isFullscreen(data.isFullscreen);
}
/**
* Fired when going in and out of fullscreen.
*
* @event Player#fullscreenchange
* @type {EventTarget~Event}
*/
this.trigger('fullscreenchange');
};
/**
* Fires when an error occurred during the loading of an audio/video.
*
* @private
* @listens Tech#error
*/
Player.prototype.handleTechError_ = function handleTechError_() {
var error = this.tech_.error();
this.error(error);
};
/**
* Retrigger the `textdata` event that was triggered by the {@link Tech}.
*
* @fires Player#textdata
* @listens Tech#textdata
* @private
*/
Player.prototype.handleTechTextData_ = function handleTechTextData_() {
var data = null;
if (arguments.length > 1) {
data = arguments[1];
}
/**
* Fires when we get a textdata event from tech
*
* @event Player#textdata
* @type {EventTarget~Event}
*/
this.trigger('textdata', data);
};
/**
* Get object for cached values.
*
* @return {Object}
* get the current object cache
*/
Player.prototype.getCache = function getCache() {
return this.cache_;
};
/**
* Pass values to the playback tech
*
* @param {string} [method]
* the method to call
*
* @param {Object} arg
* the argument to pass
*
* @private
*/
Player.prototype.techCall_ = function techCall_(method, arg) {
// If it's not ready yet, call method when it is
if (this.tech_ && !this.tech_.isReady_) {
this.tech_.ready(function () {
this[method](arg);
}, true);
// Otherwise call method now
} else {
try {
if (this.tech_) {
this.tech_[method](arg);
}
} catch (e) {
(0, _log2['default'])(e);
throw e;
}
}
};
/**
* Get calls can't wait for the tech, and sometimes don't need to.
*
* @param {string} method
* Tech method
*
* @return {Function|undefined}
* the method or undefined
*
* @private
*/
Player.prototype.techGet_ = function techGet_(method) {
if (this.tech_ && this.tech_.isReady_) {
// Flash likes to die and reload when you hide or reposition it.
// In these cases the object methods go away and we get errors.
// When that happens we'll catch the errors and inform tech that it's not ready any more.
try {
return this.tech_[method]();
} catch (e) {
// When building additional tech libs, an expected method may not be defined yet
if (this.tech_[method] === undefined) {
(0, _log2['default'])('Video.js: ' + method + ' method not defined for ' + this.techName_ + ' playback technology.', e);
// When a method isn't available on the object it throws a TypeError
} else if (e.name === 'TypeError') {
(0, _log2['default'])('Video.js: ' + method + ' unavailable on ' + this.techName_ + ' playback technology element.', e);
this.tech_.isReady_ = false;
} else {
(0, _log2['default'])(e);
}
throw e;
}
}
return;
};
/**
* start media playback
*
* @return {Player}
* A reference to the player object this function was called on
*/
Player.prototype.play = function play() {
// Only calls the tech's play if we already have a src loaded
if (this.src() || this.currentSrc()) {
this.techCall_('play');
} else {
this.tech_.one('loadstart', function () {
this.play();
});
}
return this;
};
/**
* Pause the video playback
*
* @return {Player}
* A reference to the player object this function was called on
*/
Player.prototype.pause = function pause() {
this.techCall_('pause');
return this;
};
/**
* Check if the player is paused or has yet to play
*
* @return {boolean}
* - false: if the media is currently playing
* - true: if media is not currently playing
*/
Player.prototype.paused = function paused() {
// The initial state of paused should be true (in Safari it's actually false)
return this.techGet_('paused') === false ? false : true;
};
/**
* Returns whether or not the user is "scrubbing". Scrubbing is
* when the user has clicked the progress bar handle and is
* dragging it along the progress bar.
*
* @param {boolean} [isScrubbing]
* wether the user is or is not scrubbing
*
* @return {boolean|Player}
* A instance of the player that called this function when setting,
* and the value of scrubbing when getting
*/
Player.prototype.scrubbing = function scrubbing(isScrubbing) {
if (isScrubbing !== undefined) {
this.scrubbing_ = !!isScrubbing;
if (isScrubbing) {
this.addClass('vjs-scrubbing');
} else {
this.removeClass('vjs-scrubbing');
}
return this;
}
return this.scrubbing_;
};
/**
* Get or set the current time (in seconds)
*
* @param {number|string} [seconds]
* The time to seek to in seconds
*
* @return {Player|number}
* - the current time in seconds when getting
* - a reference to the current player object when setting
*/
Player.prototype.currentTime = function currentTime(seconds) {
if (seconds !== undefined) {
this.techCall_('setCurrentTime', seconds);
return this;
}
// cache last currentTime and return. default to 0 seconds
//
// Caching the currentTime is meant to prevent a massive amount of reads on the tech's
// currentTime when scrubbing, but may not provide much performance benefit afterall.
// Should be tested. Also something has to read the actual current time or the cache will
// never get updated.
this.cache_.currentTime = this.techGet_('currentTime') || 0;
return this.cache_.currentTime;
};
/**
* Normally gets the length in time of the video in seconds;
* in all but the rarest use cases an argument will NOT be passed to the method
*
* > **NOTE**: The video must have started loading before the duration can be
* known, and in the case of Flash, may not be known until the video starts
* playing.
*
* @fires Player#durationchange
*
* @param {number} [seconds]
* The duration of the video to set in seconds
*
* @return {number|Player}
* - The duration of the video in seconds when getting
* - A reference to the player that called this function
* when setting
*/
Player.prototype.duration = function duration(seconds) {
if (seconds === undefined) {
return this.cache_.duration || 0;
}
seconds = parseFloat(seconds) || 0;
// Standardize on Inifity for signaling video is live
if (seconds < 0) {
seconds = Infinity;
}
if (seconds !== this.cache_.duration) {
// Cache the last set value for optimized scrubbing (esp. Flash)
this.cache_.duration = seconds;
if (seconds === Infinity) {
this.addClass('vjs-live');
} else {
this.removeClass('vjs-live');
}
/**
* @event Player#durationchange
* @type {EventTarget~Event}
*/
this.trigger('durationchange');
}
return this;
};
/**
* Calculates how much time is left in the video. Not part
* of the native video API.
*
* @return {number}
* The time remaining in seconds
*/
Player.prototype.remainingTime = function remainingTime() {
return this.duration() - this.currentTime();
};
//
// Kind of like an array of portions of the video that have been downloaded.
/**
* Get a TimeRange object with an array of the times of the video
* that have been downloaded. If you just want the percent of the
* video that's been downloaded, use bufferedPercent.
*
* @see [Buffered Spec]{@link http://dev.w3.org/html5/spec/video.html#dom-media-buffered}
*
* @return {TimeRange}
* A mock TimeRange object (following HTML spec)
*/
Player.prototype.buffered = function buffered() {
var buffered = this.techGet_('buffered');
if (!buffered || !buffered.length) {
buffered = (0, _timeRanges.createTimeRange)(0, 0);
}
return buffered;
};
/**
* Get the percent (as a decimal) of the video that's been downloaded.
* This method is not a part of the native HTML video API.
*
* @return {number}
* A decimal between 0 and 1 representing the percent
* that is bufferred 0 being 0% and 1 being 100%
*/
Player.prototype.bufferedPercent = function bufferedPercent() {
return (0, _buffer.bufferedPercent)(this.buffered(), this.duration());
};
/**
* Get the ending time of the last buffered time range
* This is used in the progress bar to encapsulate all time ranges.
*
* @return {number}
* The end of the last buffered time range
*/
Player.prototype.bufferedEnd = function bufferedEnd() {
var buffered = this.buffered();
var duration = this.duration();
var end = buffered.end(buffered.length - 1);
if (end > duration) {
end = duration;
}
return end;
};
/**
* Get or set the current volume of the media
*
* @param {number} [percentAsDecimal]
* The new volume as a decimal percent:
* - 0 is muted/0%/off
* - 1.0 is 100%/full
* - 0.5 is half volume or 50%
*
* @return {Player|number}
* a reference to the calling player when setting and the
* current volume as a percent when getting
*/
Player.prototype.volume = function volume(percentAsDecimal) {
var vol = void 0;
if (percentAsDecimal !== undefined) {
// Force value to between 0 and 1
vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal)));
this.cache_.volume = vol;
this.techCall_('setVolume', vol);
return this;
}
// Default to 1 when returning current volume.
vol = parseFloat(this.techGet_('volume'));
return isNaN(vol) ? 1 : vol;
};
/**
* Get the current muted state, or turn mute on or off
*
* @param {boolean} [muted]
* - true to mute
* - false to unmute
*
* @return {boolean|Player}
* - true if mute is on and getting
* - false if mute is off and getting
* - A reference to the current player when setting
*/
Player.prototype.muted = function muted(_muted) {
if (_muted !== undefined) {
this.techCall_('setMuted', _muted);
return this;
}
return this.techGet_('muted') || false;
};
/**
* Check if current tech can support native fullscreen
* (e.g. with built in controls like iOS, so not our flash swf)
*
* @return {boolean}
* if native fullscreen is supported
*/
Player.prototype.supportsFullScreen = function supportsFullScreen() {
return this.techGet_('supportsFullScreen') || false;
};
/**
* Check if the player is in fullscreen mode or tell the player that it
* is or is not in fullscreen mode.
*
* > NOTE: As of the latest HTML5 spec, isFullscreen is no longer an official
* property and instead document.fullscreenElement is used. But isFullscreen is
* still a valuable property for internal player workings.
*
* @param {boolean} [isFS]
* Set the players current fullscreen state
*
* @return {boolean|Player}
* - true if fullscreen is on and getting
* - false if fullscreen is off and getting
* - A reference to the current player when setting
*/
Player.prototype.isFullscreen = function isFullscreen(isFS) {
if (isFS !== undefined) {
this.isFullscreen_ = !!isFS;
return this;
}
return !!this.isFullscreen_;
};
/**
* Increase the size of the video to full screen
* In some browsers, full screen is not supported natively, so it enters
* "full window mode", where the video fills the browser window.
* In browsers and devices that support native full screen, sometimes the
* browser's default controls will be shown, and not the Video.js custom skin.
* This includes most mobile devices (iOS, Android) and older versions of
* Safari.
*
* @fires Player#fullscreenchange
* @return {Player}
* A reference to the current player
*/
Player.prototype.requestFullscreen = function requestFullscreen() {
var fsApi = _fullscreenApi2['default'];
this.isFullscreen(true);
if (fsApi.requestFullscreen) {
// the browser supports going fullscreen at the element level so we can
// take the controls fullscreen as well as the video
// Trigger fullscreenchange event after change
// We have to specifically add this each time, and remove
// when canceling fullscreen. Otherwise if there's multiple
// players on a page, they would all be reacting to the same fullscreen
// events
Events.on(_document2['default'], fsApi.fullscreenchange, Fn.bind(this, function documentFullscreenChange(e) {
this.isFullscreen(_document2['default'][fsApi.fullscreenElement]);
// If cancelling fullscreen, remove event listener.
if (this.isFullscreen() === false) {
Events.off(_document2['default'], fsApi.fullscreenchange, documentFullscreenChange);
}
/**
* @event Player#fullscreenchange
* @type {EventTarget~Event}
*/
this.trigger('fullscreenchange');
}));
this.el_[fsApi.requestFullscreen]();
} else if (this.tech_.supportsFullScreen()) {
// we can't take the video.js controls fullscreen but we can go fullscreen
// with native controls
this.techCall_('enterFullScreen');
} else {
// fullscreen isn't supported so we'll just stretch the video element to
// fill the viewport
this.enterFullWindow();
/**
* @event Player#fullscreenchange
* @type {EventTarget~Event}
*/
this.trigger('fullscreenchange');
}
return this;
};
/**
* Return the video to its normal size after having been in full screen mode
*
* @fires Player#fullscreenchange
*
* @return {Player}
* A reference to the current player
*/
Player.prototype.exitFullscreen = function exitFullscreen() {
var fsApi = _fullscreenApi2['default'];
this.isFullscreen(false);
// Check for browser element fullscreen support
if (fsApi.requestFullscreen) {
_document2['default'][fsApi.exitFullscreen]();
} else if (this.tech_.supportsFullScreen()) {
this.techCall_('exitFullScreen');
} else {
this.exitFullWindow();
/**
* @event Player#fullscreenchange
* @type {EventTarget~Event}
*/
this.trigger('fullscreenchange');
}
return this;
};
/**
* When fullscreen isn't supported we can stretch the
* video container to as wide as the browser will let us.
*
* @fires Player#enterFullWindow
*/
Player.prototype.enterFullWindow = function enterFullWindow() {
this.isFullWindow = true;
// Storing original doc overflow value to return to when fullscreen is off
this.docOrigOverflow = _document2['default'].documentElement.style.overflow;
// Add listener for esc key to exit fullscreen
Events.on(_document2['default'], 'keydown', Fn.bind(this, this.fullWindowOnEscKey));
// Hide any scroll bars
_document2['default'].documentElement.style.overflow = 'hidden';
// Apply fullscreen styles
Dom.addElClass(_document2['default'].body, 'vjs-full-window');
/**
* @event Player#enterFullWindow
* @type {EventTarget~Event}
*/
this.trigger('enterFullWindow');
};
/**
* Check for call to either exit full window or
* full screen on ESC key
*
* @param {string} event
* Event to check for key press
*/
Player.prototype.fullWindowOnEscKey = function fullWindowOnEscKey(event) {
if (event.keyCode === 27) {
if (this.isFullscreen() === true) {
this.exitFullscreen();
} else {
this.exitFullWindow();
}
}
};
/**
* Exit full window
*
* @fires Player#exitFullWindow
*/
Player.prototype.exitFullWindow = function exitFullWindow() {
this.isFullWindow = false;
Events.off(_document2['default'], 'keydown', this.fullWindowOnEscKey);
// Unhide scroll bars.
_document2['default'].documentElement.style.overflow = this.docOrigOverflow;
// Remove fullscreen styles
Dom.removeElClass(_document2['default'].body, 'vjs-full-window');
// Resize the box, controller, and poster to original sizes
// this.positionAll();
/**
* @event Player#exitFullWindow
* @type {EventTarget~Event}
*/
this.trigger('exitFullWindow');
};
/**
* Check whether the player can play a given mimetype
*
* @see https://www.w3.org/TR/2011/WD-html5-20110113/video.html#dom-navigator-canplaytype
*
* @param {string} type
* The mimetype to check
*
* @return {string}
* 'probably', 'maybe', or '' (empty string)
*/
Player.prototype.canPlayType = function canPlayType(type) {
var can = void 0;
// Loop through each playback technology in the options order
for (var i = 0, j = this.options_.techOrder; i < j.length; i++) {
var techName = (0, _toTitleCase2['default'])(j[i]);
var tech = _tech2['default'].getTech(techName);
// Support old behavior of techs being registered as components.
// Remove once that deprecated behavior is removed.
if (!tech) {
tech = _component2['default'].getComponent(techName);
}
// Check if the current tech is defined before continuing
if (!tech) {
_log2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
continue;
}
// Check if the browser supports this technology
if (tech.isSupported()) {
can = tech.canPlayType(type);
if (can) {
return can;
}
}
}
return '';
};
/**
* Select source based on tech-order or source-order
* Uses source-order selection if `options.sourceOrder` is truthy. Otherwise,
* defaults to tech-order selection
*
* @param {Array} sources
* The sources for a media asset
*
* @return {Object|boolean}
* Object of source and tech order or false
*/
Player.prototype.selectSource = function selectSource(sources) {
var _this4 = this;
// Get only the techs specified in `techOrder` that exist and are supported by the
// current platform
var techs = this.options_.techOrder.map(_toTitleCase2['default']).map(function (techName) {
// `Component.getComponent(...)` is for support of old behavior of techs
// being registered as components.
// Remove once that deprecated behavior is removed.
return [techName, _tech2['default'].getTech(techName) || _component2['default'].getComponent(techName)];
}).filter(function (_ref) {
var techName = _ref[0],
tech = _ref[1];
// Check if the current tech is defined before continuing
if (tech) {
// Check if the browser supports this technology
return tech.isSupported();
}
_log2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
return false;
});
// Iterate over each `innerArray` element once per `outerArray` element and execute
// `tester` with both. If `tester` returns a non-falsy value, exit early and return
// that value.
var findFirstPassingTechSourcePair = function findFirstPassingTechSourcePair(outerArray, innerArray, tester) {
var found = void 0;
outerArray.some(function (outerChoice) {
return innerArray.some(function (innerChoice) {
found = tester(outerChoice, innerChoice);
if (found) {
return true;
}
});
});
return found;
};
var foundSourceAndTech = void 0;
var flip = function flip(fn) {
return function (a, b) {
return fn(b, a);
};
};
var finder = function finder(_ref2, source) {
var techName = _ref2[0],
tech = _ref2[1];
if (tech.canPlaySource(source, _this4.options_[techName.toLowerCase()])) {
return { source: source, tech: techName };
}
};
// Depending on the truthiness of `options.sourceOrder`, we swap the order of techs and sources
// to select from them based on their priority.
if (this.options_.sourceOrder) {
// Source-first ordering
foundSourceAndTech = findFirstPassingTechSourcePair(sources, techs, flip(finder));
} else {
// Tech-first ordering
foundSourceAndTech = findFirstPassingTechSourcePair(techs, sources, finder);
}
return foundSourceAndTech || false;
};
/**
* The source function updates the video source
* There are three types of variables you can pass as the argument.
* **URL string**: A URL to the the video file. Use this method if you are sure
* the current playback technology (HTML5/Flash) can support the source you
* provide. Currently only MP4 files can be used in both HTML5 and Flash.
*
* @param {Tech~SourceObject|Tech~SourceObject[]} [source]
* One SourceObject or an array of SourceObjects
*
* @return {string|Player}
* - The current video source when getting
* - The player when setting
*/
Player.prototype.src = function src(source) {
if (source === undefined) {
return this.techGet_('src');
}
var currentTech = _tech2['default'].getTech(this.techName_);
// Support old behavior of techs being registered as components.
// Remove once that deprecated behavior is removed.
if (!currentTech) {
currentTech = _component2['default'].getComponent(this.techName_);
}
// case: Array of source objects to choose from and pick the best to play
if (Array.isArray(source)) {
this.sourceList_(source);
// case: URL String (http://myvideo...)
} else if (typeof source === 'string') {
// create a source object from the string
this.src({ src: source });
// case: Source object { src: '', type: '' ... }
} else if (source instanceof Object) {
// check if the source has a type and the loaded tech cannot play the source
// if there's no type we'll just try the current tech
if (source.type && !currentTech.canPlaySource(source, this.options_[this.techName_.toLowerCase()])) {
// create a source list with the current source and send through
// the tech loop to check for a compatible technology
this.sourceList_([source]);
} else {
this.cache_.sources = null;
this.cache_.source = source;
this.cache_.src = source.src;
this.currentType_ = source.type || '';
// wait until the tech is ready to set the source
this.ready(function () {
// The setSource tech method was added with source handlers
// so older techs won't support it
// We need to check the direct prototype for the case where subclasses
// of the tech do not support source handlers
if (currentTech.prototype.hasOwnProperty('setSource')) {
this.techCall_('setSource', source);
} else {
this.techCall_('src', source.src);
}
if (this.options_.preload === 'auto') {
this.load();
}
if (this.options_.autoplay) {
this.play();
}
// Set the source synchronously if possible (#2326)
}, true);
}
}
return this;
};
/**
* Handle an array of source objects
*
* @param {Tech~SourceObject[]} sources
* Array of source objects
*
* @private
*/
Player.prototype.sourceList_ = function sourceList_(sources) {
var sourceTech = this.selectSource(sources);
if (sourceTech) {
if (sourceTech.tech === this.techName_) {
// if this technology is already loaded, set the source
this.src(sourceTech.source);
} else {
// load this technology with the chosen source
this.loadTech_(sourceTech.tech, sourceTech.source);
}
this.cache_.sources = sources;
} else {
// We need to wrap this in a timeout to give folks a chance to add error event handlers
this.setTimeout(function () {
this.error({ code: 4, message: this.localize(this.options_.notSupportedMessage) });
}, 0);
// we could not find an appropriate tech, but let's still notify the delegate that this is it
// this needs a better comment about why this is needed
this.triggerReady();
}
};
/**
* Begin loading the src data.
*
* @return {Player}
* A reference to the player
*/
Player.prototype.load = function load() {
this.techCall_('load');
return this;
};
/**
* Reset the player. Loads the first tech in the techOrder,
* and calls `reset` on the tech`.
*
* @return {Player}
* A reference to the player
*/
Player.prototype.reset = function reset() {
this.loadTech_((0, _toTitleCase2['default'])(this.options_.techOrder[0]), null);
this.techCall_('reset');
return this;
};
/**
* Returns all of the current source objects.
*
* @return {Tech~SourceObject[]}
* The current source objects
*/
Player.prototype.currentSources = function currentSources() {
var source = this.currentSource();
var sources = [];
// assume `{}` or `{ src }`
if (Object.keys(source).length !== 0) {
sources.push(source);
}
return this.cache_.sources || sources;
};
/**
* Returns the current source object.
*
* @return {Tech~SourceObject}
* The current source object
*/
Player.prototype.currentSource = function currentSource() {
var source = {};
var src = this.currentSrc();
if (src) {
source.src = src;
}
return this.cache_.source || source;
};
/**
* Returns the fully qualified URL of the current source value e.g. http://mysite.com/video.mp4
* Can be used in conjuction with `currentType` to assist in rebuilding the current source object.
*
* @return {string}
* The current source
*/
Player.prototype.currentSrc = function currentSrc() {
return this.techGet_('currentSrc') || this.cache_.src || '';
};
/**
* Get the current source type e.g. video/mp4
* This can allow you rebuild the current source object so that you could load the same
* source and tech later
*
* @return {string}
* The source MIME type
*/
Player.prototype.currentType = function currentType() {
return this.currentType_ || '';
};
/**
* Get or set the preload attribute
*
* @param {boolean} [value]
* - true means that we should preload
* - false maens that we should not preload
*
* @return {string|Player}
* - the preload attribute value when getting
* - the player when setting
*/
Player.prototype.preload = function preload(value) {
if (value !== undefined) {
this.techCall_('setPreload', value);
this.options_.preload = value;
return this;
}
return this.techGet_('preload');
};
/**
* Get or set the autoplay attribute.
*
* @param {boolean} [value]
* - true means that we should autoplay
* - false maens that we should not autoplay
*
* @return {string|Player}
* - the current value of autoplay
* - the player when setting
*/
Player.prototype.autoplay = function autoplay(value) {
if (value !== undefined) {
this.techCall_('setAutoplay', value);
this.options_.autoplay = value;
return this;
}
return this.techGet_('autoplay', value);
};
/**
* Get or set the loop attribute on the video element.
*
* @param {boolean} [value]
* - true means that we should loop the video
* - false means that we should not loop the video
*
* @return {string|Player}
* - the current value of loop when getting
* - the player when setting
*/
Player.prototype.loop = function loop(value) {
if (value !== undefined) {
this.techCall_('setLoop', value);
this.options_.loop = value;
return this;
}
return this.techGet_('loop');
};
/**
* Get or set the poster image source url
*
* @fires Player#posterchange
*
* @param {string} [src]
* Poster image source URL
*
* @return {string|Player}
* - the current value of poster when getting
* - the player when setting
*/
Player.prototype.poster = function poster(src) {
if (src === undefined) {
return this.poster_;
}
// The correct way to remove a poster is to set as an empty string
// other falsey values will throw errors
if (!src) {
src = '';
}
// update the internal poster variable
this.poster_ = src;
// update the tech's poster
this.techCall_('setPoster', src);
// alert components that the poster has been set
/**
* This event fires when the poster image is changed on the player.
*
* @event Player#posterchange
* @type {EventTarget~Event}
*/
this.trigger('posterchange');
return this;
};
/**
* Some techs (e.g. YouTube) can provide a poster source in an
* asynchronous way. We want the poster component to use this
* poster source so that it covers up the tech's controls.
* (YouTube's play button). However we only want to use this
* soruce if the player user hasn't set a poster through
* the normal APIs.
*
* @fires Player#posterchange
* @listens Tech#posterchange
* @private
*/
Player.prototype.handleTechPosterChange_ = function handleTechPosterChange_() {
if (!this.poster_ && this.tech_ && this.tech_.poster) {
this.poster_ = this.tech_.poster() || '';
// Let components know the poster has changed
this.trigger('posterchange');
}
};
/**
* Get or set whether or not the controls are showing.
*
* @fires Player#controlsenabled
*
* @param {boolean} [bool]
* - true to turn controls on
* - false to turn controls off
*
* @return {boolean|Player}
* - the current value of controls when getting
* - the player when setting
*/
Player.prototype.controls = function controls(bool) {
if (bool !== undefined) {
bool = !!bool;
// Don't trigger a change event unless it actually changed
if (this.controls_ !== bool) {
this.controls_ = bool;
if (this.usingNativeControls()) {
this.techCall_('setControls', bool);
}
if (bool) {
this.removeClass('vjs-controls-disabled');
this.addClass('vjs-controls-enabled');
/**
* @event Player#controlsenabled
* @type {EventTarget~Event}
*/
this.trigger('controlsenabled');
if (!this.usingNativeControls()) {
this.addTechControlsListeners_();
}
} else {
this.removeClass('vjs-controls-enabled');
this.addClass('vjs-controls-disabled');
/**
* @event Player#controlsdisabled
* @type {EventTarget~Event}
*/
this.trigger('controlsdisabled');
if (!this.usingNativeControls()) {
this.removeTechControlsListeners_();
}
}
}
return this;
}
return !!this.controls_;
};
/**
* Toggle native controls on/off. Native controls are the controls built into
* devices (e.g. default iPhone controls), Flash, or other techs
* (e.g. Vimeo Controls)
* **This should only be set by the current tech, because only the tech knows
* if it can support native controls**
*
* @fires Player#usingnativecontrols
* @fires Player#usingcustomcontrols
*
* @param {boolean} [bool]
* - true to turn native controls on
* - false to turn native controls off
*
* @return {boolean|Player}
* - the current value of native controls when getting
* - the player when setting
*/
Player.prototype.usingNativeControls = function usingNativeControls(bool) {
if (bool !== undefined) {
bool = !!bool;
// Don't trigger a change event unless it actually changed
if (this.usingNativeControls_ !== bool) {
this.usingNativeControls_ = bool;
if (bool) {
this.addClass('vjs-using-native-controls');
/**
* player is using the native device controls
*
* @event Player#usingnativecontrols
* @type {EventTarget~Event}
*/
this.trigger('usingnativecontrols');
} else {
this.removeClass('vjs-using-native-controls');
/**
* player is using the custom HTML controls
*
* @event Player#usingcustomcontrols
* @type {EventTarget~Event}
*/
this.trigger('usingcustomcontrols');
}
}
return this;
}
return !!this.usingNativeControls_;
};
/**
* Set or get the current MediaError
*
* @fires Player#error
*
* @param {MediaError|string|number} [err]
* A MediaError or a string/number to be turned
* into a MediaError
*
* @return {MediaError|null|Player}
* - The current MediaError when getting (or null)
* - The player when setting
*/
Player.prototype.error = function error(err) {
if (err === undefined) {
return this.error_ || null;
}
// restoring to default
if (err === null) {
this.error_ = err;
this.removeClass('vjs-error');
if (this.errorDisplay) {
this.errorDisplay.close();
}
return this;
}
this.error_ = new _mediaError2['default'](err);
// add the vjs-error classname to the player
this.addClass('vjs-error');
// log the name of the error type and any message
// ie8 just logs "[object object]" if you just log the error object
_log2['default'].error('(CODE:' + this.error_.code + ' ' + _mediaError2['default'].errorTypes[this.error_.code] + ')', this.error_.message, this.error_);
/**
* @event Player#error
* @type {EventTarget~Event}
*/
this.trigger('error');
return this;
};
/**
* Report user activity
*
* @param {Object} event
* Event object
*/
Player.prototype.reportUserActivity = function reportUserActivity(event) {
this.userActivity_ = true;
};
/**
* Get/set if user is active
*
* @fires Player#useractive
* @fires Player#userinactive
*
* @param {boolean} [bool]
* - true if the user is active
* - false if the user is inactive
* @return {boolean|Player}
* - the current value of userActive when getting
* - the player when setting
*/
Player.prototype.userActive = function userActive(bool) {
if (bool !== undefined) {
bool = !!bool;
if (bool !== this.userActive_) {
this.userActive_ = bool;
if (bool) {
// If the user was inactive and is now active we want to reset the
// inactivity timer
this.userActivity_ = true;
this.removeClass('vjs-user-inactive');
this.addClass('vjs-user-active');
/**
* @event Player#useractive
* @type {EventTarget~Event}
*/
this.trigger('useractive');
} else {
// We're switching the state to inactive manually, so erase any other
// activity
this.userActivity_ = false;
// Chrome/Safari/IE have bugs where when you change the cursor it can
// trigger a mousemove event. This causes an issue when you're hiding
// the cursor when the user is inactive, and a mousemove signals user
// activity. Making it impossible to go into inactive mode. Specifically
// this happens in fullscreen when we really need to hide the cursor.
//
// When this gets resolved in ALL browsers it can be removed
// https://code.google.com/p/chromium/issues/detail?id=103041
if (this.tech_) {
this.tech_.one('mousemove', function (e) {
e.stopPropagation();
e.preventDefault();
});
}
this.removeClass('vjs-user-active');
this.addClass('vjs-user-inactive');
/**
* @event Player#userinactive
* @type {EventTarget~Event}
*/
this.trigger('userinactive');
}
}
return this;
}
return this.userActive_;
};
/**
* Listen for user activity based on timeout value
*
* @private
*/
Player.prototype.listenForUserActivity_ = function listenForUserActivity_() {
var mouseInProgress = void 0;
var lastMoveX = void 0;
var lastMoveY = void 0;
var handleActivity = Fn.bind(this, this.reportUserActivity);
var handleMouseMove = function handleMouseMove(e) {
// #1068 - Prevent mousemove spamming
// Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) {
lastMoveX = e.screenX;
lastMoveY = e.screenY;
handleActivity();
}
};
var handleMouseDown = function handleMouseDown() {
handleActivity();
// For as long as the they are touching the device or have their mouse down,
// we consider them active even if they're not moving their finger or mouse.
// So we want to continue to update that they are active
this.clearInterval(mouseInProgress);
// Setting userActivity=true now and setting the interval to the same time
// as the activityCheck interval (250) should ensure we never miss the
// next activityCheck
mouseInProgress = this.setInterval(handleActivity, 250);
};
var handleMouseUp = function handleMouseUp(event) {
handleActivity();
// Stop the interval that maintains activity if the mouse/touch is down
this.clearInterval(mouseInProgress);
};
// Any mouse movement will be considered user activity
this.on('mousedown', handleMouseDown);
this.on('mousemove', handleMouseMove);
this.on('mouseup', handleMouseUp);
// Listen for keyboard navigation
// Shouldn't need to use inProgress interval because of key repeat
this.on('keydown', handleActivity);
this.on('keyup', handleActivity);
// Run an interval every 250 milliseconds instead of stuffing everything into
// the mousemove/touchmove function itself, to prevent performance degradation.
// `this.reportUserActivity` simply sets this.userActivity_ to true, which
// then gets picked up by this loop
// http://ejohn.org/blog/learning-from-twitter/
var inactivityTimeout = void 0;
this.setInterval(function () {
// Check to see if mouse/touch activity has happened
if (this.userActivity_) {
// Reset the activity tracker
this.userActivity_ = false;
// If the user state was inactive, set the state to active
this.userActive(true);
// Clear any existing inactivity timeout to start the timer over
this.clearTimeout(inactivityTimeout);
var timeout = this.options_.inactivityTimeout;
if (timeout > 0) {
// In milliseconds, if no more activity has occurred the
// user will be considered inactive
inactivityTimeout = this.setTimeout(function () {
// Protect against the case where the inactivityTimeout can trigger just
// before the next user activity is picked up by the activity check loop
// causing a flicker
if (!this.userActivity_) {
this.userActive(false);
}
}, timeout);
}
}
}, 250);
};
/**
* Gets or sets the current playback rate. A playback rate of
* 1.0 represents normal speed and 0.5 would indicate half-speed
* playback, for instance.
*
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-playbackrate
*
* @param {number} [rate]
* New playback rate to set.
*
* @return {number|Player}
* - The current playback rate when getting or 1.0
* - the player when setting
*/
Player.prototype.playbackRate = function playbackRate(rate) {
if (rate !== undefined) {
this.techCall_('setPlaybackRate', rate);
return this;
}
if (this.tech_ && this.tech_.featuresPlaybackRate) {
return this.techGet_('playbackRate');
}
return 1.0;
};
/**
* Gets or sets the audio flag
*
* @param {boolean} bool
* - true signals that this is an audio player
* - false signals that this is not an audio player
*
* @return {Player|boolean}
* - the current value of isAudio when getting
* - the player if setting
*/
Player.prototype.isAudio = function isAudio(bool) {
if (bool !== undefined) {
this.isAudio_ = !!bool;
return this;
}
return !!this.isAudio_;
};
/**
* Get the {@link VideoTrackList}
*
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist
*
* @return {VideoTrackList}
* the current video track list
*/
Player.prototype.videoTracks = function videoTracks() {
// if we have not yet loadTech_, we create videoTracks_
// these will be passed to the tech during loading
if (!this.tech_) {
this.videoTracks_ = this.videoTracks_ || new _videoTrackList2['default']();
return this.videoTracks_;
}
return this.tech_.videoTracks();
};
/**
* Get the {@link AudioTrackList}
*
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist
*
* @return {AudioTrackList}
* the current audio track list
*/
Player.prototype.audioTracks = function audioTracks() {
// if we have not yet loadTech_, we create videoTracks_
// these will be passed to the tech during loading
if (!this.tech_) {
this.audioTracks_ = this.audioTracks_ || new _audioTrackList2['default']();
return this.audioTracks_;
}
return this.tech_.audioTracks();
};
/**
* Get the {@link TextTrackList}
*
* Text tracks are tracks of timed text events.
* - Captions: text displayed over the video
* for the hearing impaired
* - Subtitles: text displayed over the video for
* those who don't understand language in the video
* - Chapters: text displayed in a menu allowing the user to jump
* to particular points (chapters) in the video
* - Descriptions: (not yet implemented) audio descriptions that are read back to
* the user by a screen reading device
*
* @see http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-texttracks
*
* @return {TextTrackList|undefined}
* The current TextTrackList or undefined if
* or undefined if we don't have a tech
*/
Player.prototype.textTracks = function textTracks() {
// cannot use techGet_ directly because it checks to see whether the tech is ready.
// Flash is unlikely to be ready in time but textTracks should still work.
if (this.tech_) {
return this.tech_.textTracks();
}
};
/**
* Get the "remote" {@link TextTrackList}. Remote Text Tracks
* are tracks that were added to the HTML video element and can
* be removed, whereas normal texttracks cannot be removed.
*
*
* @return {TextTrackList|undefined}
* The current remote text track list or undefined
* if we don't have a tech
*/
Player.prototype.remoteTextTracks = function remoteTextTracks() {
if (this.tech_) {
return this.tech_.remoteTextTracks();
}
};
/**
* Get the "remote" {@link HTMLTrackElementList}.
* This gives the user all of the DOM elements that match up
* with the remote {@link TextTrackList}.
*
* @return {HTMLTrackElementList}
* The current remote text track list elements
* or undefined if we don't have a tech
*/
Player.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
if (this.tech_) {
return this.tech_.remoteTextTrackEls();
}
};
/**
* A helper method for adding a {@link TextTrack} to our
* {@link TextTrackList}.
*
* In addition to the W3C settings we allow adding additional info through options.
*
* @see http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-addtexttrack
*
* @param {string} [kind]
* the kind of TextTrack you are adding
*
* @param {string} [label]
* the label to give the TextTrack label
*
* @param {string} [language]
* the language to set on the TextTrack
*
* @return {TextTrack|undefined}
* the TextTrack that was added or undefined
* if there is no tech
*/
Player.prototype.addTextTrack = function addTextTrack(kind, label, language) {
if (this.tech_) {
return this.tech_.addTextTrack(kind, label, language);
}
};
/**
* Create a remote {@link TextTrack} and an {@link HTMLTrackElement}. It will
* automatically removed from the video element whenever the source changes, unless
* manualCleanup is set to false.
*
* @param {Object} options
* Options to pass to {@link HTMLTrackElement} during creation. See
* {@link HTMLTrackElement} for object properties that you should use.
*
* @param {boolean} [manualCleanup=true] if set to false, the TextTrack will be
*
* @return {HTMLTrackElement}
* the HTMLTrackElement that was created and added
* to the HTMLTrackElementList and the remote
* TextTrackList
*
* @deprecated The default value of the "manualCleanup" parameter will default
* to "false" in upcoming versions of Video.js
*/
Player.prototype.addRemoteTextTrack = function addRemoteTextTrack(options, manualCleanup) {
if (this.tech_) {
return this.tech_.addRemoteTextTrack(options, manualCleanup);
}
};
/**
* Remove a remote {@link TextTrack} from the respective
* {@link TextTrackList} and {@link HTMLTrackElementList}.
*
* @param {Object} track
* Remote {@link TextTrack} to remove
*
* @return {undefined}
* does not return anything
*/
Player.prototype.removeRemoteTextTrack = function removeRemoteTextTrack() {
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref3$track = _ref3.track,
track = _ref3$track === undefined ? arguments[0] : _ref3$track;
// destructure the input into an object with a track argument, defaulting to arguments[0]
// default the whole argument to an empty object if nothing was passed in
if (this.tech_) {
return this.tech_.removeRemoteTextTrack(track);
}
};
/**
* Get video width
*
* @return {number}
* current video width
*/
Player.prototype.videoWidth = function videoWidth() {
return this.tech_ && this.tech_.videoWidth && this.tech_.videoWidth() || 0;
};
/**
* Get video height
*
* @return {number}
* current video height
*/
Player.prototype.videoHeight = function videoHeight() {
return this.tech_ && this.tech_.videoHeight && this.tech_.videoHeight() || 0;
};
// Methods to add support for
// initialTime: function() { return this.techCall_('initialTime'); },
// startOffsetTime: function() { return this.techCall_('startOffsetTime'); },
// played: function() { return this.techCall_('played'); },
// defaultPlaybackRate: function() { return this.techCall_('defaultPlaybackRate'); },
// defaultMuted: function() { return this.techCall_('defaultMuted'); }
/**
* The player's language code
* NOTE: The language should be set in the player options if you want the
* the controls to be built with a specific language. Changing the lanugage
* later will not update controls text.
*
* @param {string} [code]
* the language code to set the player to
*
* @return {string|Player}
* - The current language code when getting
* - A reference to the player when setting
*/
Player.prototype.language = function language(code) {
if (code === undefined) {
return this.language_;
}
this.language_ = String(code).toLowerCase();
return this;
};
/**
* Get the player's language dictionary
* Merge every time, because a newly added plugin might call videojs.addLanguage() at any time
* Languages specified directly in the player options have precedence
*
* @return {Array}
* An array of of supported languages
*/
Player.prototype.languages = function languages() {
return (0, _mergeOptions2['default'])(Player.prototype.options_.languages, this.languages_);
};
/**
* returns a JavaScript object reperesenting the current track
* information. **DOES not return it as JSON**
*
* @return {Object}
* Object representing the current of track info
*/
Player.prototype.toJSON = function toJSON() {
var options = (0, _mergeOptions2['default'])(this.options_);
var tracks = options.tracks;
options.tracks = [];
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
// deep merge tracks and null out player so no circular references
track = (0, _mergeOptions2['default'])(track);
track.player = undefined;
options.tracks[i] = track;
}
return options;
};
/**
* Creates a simple modal dialog (an instance of the {@link ModalDialog}
* component) that immediately overlays the player with arbitrary
* content and removes itself when closed.
*
* @param {string|Function|Element|Array|null} content
* Same as {@link ModalDialog#content}'s param of the same name.
* The most straight-forward usage is to provide a string or DOM
* element.
*
* @param {Object} [options]
* Extra options which will be passed on to the {@link ModalDialog}.
*
* @return {ModalDialog}
* the {@link ModalDialog} that was created
*/
Player.prototype.createModal = function createModal(content, options) {
var _this5 = this;
options = options || {};
options.content = content || '';
var modal = new _modalDialog2['default'](this, options);
this.addChild(modal);
modal.on('dispose', function () {
_this5.removeChild(modal);
});
return modal.open();
};
/**
* Gets tag settings
*
* @param {Element} tag
* The player tag
*
* @return {Object}
* An object containing all of the settings
* for a player tag
*/
Player.getTagSettings = function getTagSettings(tag) {
var baseOptions = {
sources: [],
tracks: []
};
var tagOptions = Dom.getElAttributes(tag);
var dataSetup = tagOptions['data-setup'];
if (Dom.hasElClass(tag, 'vjs-fluid')) {
tagOptions.fluid = true;
}
// Check if data-setup attr exists.
if (dataSetup !== null) {
// Parse options JSON
// If empty string, make it a parsable json object.
var _safeParseTuple = (0, _tuple2['default'])(dataSetup || '{}'),
err = _safeParseTuple[0],
data = _safeParseTuple[1];
if (err) {
_log2['default'].error(err);
}
(0, _obj.assign)(tagOptions, data);
}
(0, _obj.assign)(baseOptions, tagOptions);
// Get tag children settings
if (tag.hasChildNodes()) {
var children = tag.childNodes;
for (var i = 0, j = children.length; i < j; i++) {
var child = children[i];
// Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
var childName = child.nodeName.toLowerCase();
if (childName === 'source') {
baseOptions.sources.push(Dom.getElAttributes(child));
} else if (childName === 'track') {
baseOptions.tracks.push(Dom.getElAttributes(child));
}
}
}
return baseOptions;
};
/**
* Determine wether or not flexbox is supported
*
* @return {boolean}
* - true if flexbox is supported
* - false if flexbox is not supported
*/
Player.prototype.flexNotSupported_ = function flexNotSupported_() {
var elem = _document2['default'].createElement('i');
// Note: We don't actually use flexBasis (or flexOrder), but it's one of the more
// common flex features that we can rely on when checking for flex support.
return !('flexBasis' in elem.style || 'webkitFlexBasis' in elem.style || 'mozFlexBasis' in elem.style || 'msFlexBasis' in elem.style ||
// IE10-specific (2012 flex spec)
'msFlexOrder' in elem.style);
};
return Player;
}(_component2['default']);
/**
* Global player list
*
* @type {Object}
*/
Player.players = {};
var navigator = _window2['default'].navigator;
/*
* Player instance options, surfaced using options
* options = Player.prototype.options_
* Make changes in options, not here.
*
* @type {Object}
* @private
*/
Player.prototype.options_ = {
// Default order of fallback technology
techOrder: ['html5', 'flash'],
// techOrder: ['flash','html5'],
html5: {},
flash: {},
// defaultVolume: 0.85,
defaultVolume: 0.00,
// default inactivity timeout
inactivityTimeout: 2000,
// default playback rates
playbackRates: [],
// Add playback rate selection by adding rates
// 'playbackRates': [0.5, 1, 1.5, 2],
// Included control sets
children: ['mediaLoader', 'posterImage', 'textTrackDisplay', 'loadingSpinner', 'bigPlayButton', 'controlBar', 'errorDisplay', 'textTrackSettings'],
language: navigator && (navigator.languages && navigator.languages[0] || navigator.userLanguage || navigator.language) || 'en',
// locales and their language translations
languages: {},
// Default message to show when a video cannot be played.
notSupportedMessage: 'No compatible source was found for this media.'
};
[
/**
* Returns whether or not the player is in the "ended" state.
*
* @return {Boolean} True if the player is in the ended state, false if not.
* @method Player#ended
*/
'ended',
/**
* Returns whether or not the player is in the "seeking" state.
*
* @return {Boolean} True if the player is in the seeking state, false if not.
* @method Player#seeking
*/
'seeking',
/**
* Returns the TimeRanges of the media that are currently available
* for seeking to.
*
* @return {TimeRanges} the seekable intervals of the media timeline
* @method Player#seekable
*/
'seekable',
/**
* Returns the current state of network activity for the element, from
* the codes in the list below.
* - NETWORK_EMPTY (numeric value 0)
* The element has not yet been initialised. All attributes are in
* their initial states.
* - NETWORK_IDLE (numeric value 1)
* The element's resource selection algorithm is active and has
* selected a resource, but it is not actually using the network at
* this time.
* - NETWORK_LOADING (numeric value 2)
* The user agent is actively trying to download data.
* - NETWORK_NO_SOURCE (numeric value 3)
* The element's resource selection algorithm is active, but it has
* not yet found a resource to use.
*
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#network-states
* @return {number} the current network activity state
* @method Player#networkState
*/
'networkState',
/**
* Returns a value that expresses the current state of the element
* with respect to rendering the current playback position, from the
* codes in the list below.
* - HAVE_NOTHING (numeric value 0)
* No information regarding the media resource is available.
* - HAVE_METADATA (numeric value 1)
* Enough of the resource has been obtained that the duration of the
* resource is available.
* - HAVE_CURRENT_DATA (numeric value 2)
* Data for the immediate current playback position is available.
* - HAVE_FUTURE_DATA (numeric value 3)
* Data for the immediate current playback position is available, as
* well as enough data for the user agent to advance the current
* playback position in the direction of playback.
* - HAVE_ENOUGH_DATA (numeric value 4)
* The user agent estimates that enough data is available for
* playback to proceed uninterrupted.
*
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-readystate
* @return {number} the current playback rendering state
* @method Player#readyState
*/
'readyState'].forEach(function (fn) {
Player.prototype[fn] = function () {
return this.techGet_(fn);
};
});
TECH_EVENTS_RETRIGGER.forEach(function (event) {
Player.prototype['handleTech' + (0, _toTitleCase2['default'])(event) + '_'] = function () {
return this.trigger(event);
};
});
/**
* Fired when the player has initial duration and dimension information
*
* @event Player#loadedmetadata
* @type {EventTarget~Event}
*/
/**
* Fired when the player has downloaded data at the current playback position
*
* @event Player#loadeddata
* @type {EventTarget~Event}
*/
/**
* Fired when the current playback position has changed *
* During playback this is fired every 15-250 milliseconds, depending on the
* playback technology in use.
*
* @event Player#timeupdate
* @type {EventTarget~Event}
*/
/**
* Fired when the volume changes
*
* @event Player#volumechange
* @type {EventTarget~Event}
*/
_component2['default'].registerComponent('Player', Player);
exports['default'] = Player;
/***/ }),
/***/ "./node_modules/video.js/es5/plugins.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _player = __webpack_require__("./node_modules/video.js/es5/player.js");
var _player2 = _interopRequireDefault(_player);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* The method for registering a video.js plugin. {@link videojs:videojs.registerPlugin].
*
* @param {string} name
* The name of the plugin that is being registered
*
* @param {plugins:PluginFn} init
* The function that gets run when a `Player` initializes.
*/
var plugin = function plugin(name, init) {
_player2['default'].prototype[name] = init;
}; /**
* @file plugins.js
* @module plugins
*/
exports['default'] = plugin;
/***/ }),
/***/ "./node_modules/video.js/es5/popup/popup-button.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _clickableComponent = __webpack_require__("./node_modules/video.js/es5/clickable-component.js");
var _clickableComponent2 = _interopRequireDefault(_clickableComponent);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file popup-button.js
*/
/**
* A button class for use with {@link Popup} controls
*
* @extends ClickableComponent
*/
var PopupButton = function (_ClickableComponent) {
_inherits(PopupButton, _ClickableComponent);
/**
* Create an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function PopupButton(player) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, PopupButton);
var _this = _possibleConstructorReturn(this, _ClickableComponent.call(this, player, options));
_this.update();
return _this;
}
/**
* Update the `Popup` that this button is attached to.
*/
PopupButton.prototype.update = function update() {
var popup = this.createPopup();
if (this.popup) {
this.removeChild(this.popup);
}
this.popup = popup;
this.addChild(popup);
if (this.items && this.items.length === 0) {
this.hide();
} else if (this.items && this.items.length > 1) {
this.show();
}
};
/**
* Create a `Popup`. - Override with specific functionality for component
*
* @abstract
*/
PopupButton.prototype.createPopup = function createPopup() {};
/**
* Create the `PopupButton`s DOM element.
*
* @return {Element}
* The element that gets created.
*/
PopupButton.prototype.createEl = function createEl() {
return _ClickableComponent.prototype.createEl.call(this, 'div', {
className: this.buildCSSClass()
});
};
/**
* Builds the default DOM `className`.
*
* @return {string}
* The DOM `className` for this object.
*/
PopupButton.prototype.buildCSSClass = function buildCSSClass() {
var menuButtonClass = 'vjs-menu-button';
// If the inline option is passed, we want to use different styles altogether.
if (this.options_.inline === true) {
menuButtonClass += '-inline';
} else {
menuButtonClass += '-popup';
}
return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this);
};
return PopupButton;
}(_clickableComponent2['default']);
_component2['default'].registerComponent('PopupButton', PopupButton);
exports['default'] = PopupButton;
/***/ }),
/***/ "./node_modules/video.js/es5/popup/popup.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _events = __webpack_require__("./node_modules/video.js/es5/utils/events.js");
var Events = _interopRequireWildcard(_events);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file popup.js
*/
/**
* The Popup component is used to build pop up controls.
*
* @extends Component
*/
var Popup = function (_Component) {
_inherits(Popup, _Component);
function Popup() {
_classCallCheck(this, Popup);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
/**
* Add a popup item to the popup
*
* @param {Object|string} component
* Component or component type to add
*
*/
Popup.prototype.addItem = function addItem(component) {
this.addChild(component);
component.on('click', Fn.bind(this, function () {
this.unlockShowing();
}));
};
/**
* Create the `PopupButton`s DOM element.
*
* @return {Element}
* The element that gets created.
*/
Popup.prototype.createEl = function createEl() {
var contentElType = this.options_.contentElType || 'ul';
this.contentEl_ = Dom.createEl(contentElType, {
className: 'vjs-menu-content'
});
var el = _Component.prototype.createEl.call(this, 'div', {
append: this.contentEl_,
className: 'vjs-menu'
});
el.appendChild(this.contentEl_);
// Prevent clicks from bubbling up. Needed for Popup Buttons,
// where a click on the parent is significant
Events.on(el, 'click', function (event) {
event.preventDefault();
event.stopImmediatePropagation();
});
return el;
};
return Popup;
}(_component2['default']);
_component2['default'].registerComponent('Popup', Popup);
exports['default'] = Popup;
/***/ }),
/***/ "./node_modules/video.js/es5/poster-image.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _clickableComponent = __webpack_require__("./node_modules/video.js/es5/clickable-component.js");
var _clickableComponent2 = _interopRequireDefault(_clickableComponent);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file poster-image.js
*/
/**
* A `ClickableComponent` that handles showing the poster image for the player.
*
* @extends ClickableComponent
*/
var PosterImage = function (_ClickableComponent) {
_inherits(PosterImage, _ClickableComponent);
/**
* Create an instance of this class.
*
* @param {Player} player
* The `Player` that this class should attach to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function PosterImage(player, options) {
_classCallCheck(this, PosterImage);
var _this = _possibleConstructorReturn(this, _ClickableComponent.call(this, player, options));
_this.update();
player.on('posterchange', Fn.bind(_this, _this.update));
return _this;
}
/**
* Clean up and dispose of the `PosterImage`.
*/
PosterImage.prototype.dispose = function dispose() {
this.player().off('posterchange', this.update);
_ClickableComponent.prototype.dispose.call(this);
};
/**
* Create the `PosterImage`s DOM element.
*
* @return {Element}
* The element that gets created.
*/
PosterImage.prototype.createEl = function createEl() {
var el = Dom.createEl('div', {
className: 'vjs-poster',
// Don't want poster to be tabbable.
tabIndex: -1
});
// To ensure the poster image resizes while maintaining its original aspect
// ratio, use a div with `background-size` when available. For browsers that
// do not support `background-size` (e.g. IE8), fall back on using a regular
// img element.
if (!browser.BACKGROUND_SIZE_SUPPORTED) {
this.fallbackImg_ = Dom.createEl('img');
el.appendChild(this.fallbackImg_);
}
return el;
};
/**
* An {@link EventTarget~EventListener} for {@link Player#posterchange} events.
*
* @listens Player#posterchange
*
* @param {EventTarget~Event} [event]
* The `Player#posterchange` event that triggered this function.
*/
PosterImage.prototype.update = function update(event) {
var url = this.player().poster();
this.setSrc(url);
// If there's no poster source we should display:none on this component
// so it's not still clickable or right-clickable
if (url) {
this.show();
} else {
this.hide();
}
};
/**
* Set the source of the `PosterImage` depending on the display method.
*
* @param {string} url
* The URL to the source for the `PosterImage`.
*/
PosterImage.prototype.setSrc = function setSrc(url) {
if (this.fallbackImg_) {
this.fallbackImg_.src = url;
} else {
var backgroundImage = '';
// Any falsey values should stay as an empty string, otherwise
// this will throw an extra error
if (url) {
backgroundImage = 'url("' + url + '")';
}
this.el_.style.backgroundImage = backgroundImage;
}
};
/**
* An {@link EventTarget~EventListener} for clicks on the `PosterImage`. See
* {@link ClickableComponent#handleClick} for instances where this will be triggered.
*
* @listens tap
* @listens click
* @listens keydown
*
* @param {EventTarget~Event} event
+ The `click`, `tap` or `keydown` event that caused this function to be called.
*/
PosterImage.prototype.handleClick = function handleClick(event) {
// We don't want a click to trigger playback when controls are disabled
if (!this.player_.controls()) {
return;
}
if (this.player_.paused()) {
this.player_.play();
} else {
this.player_.pause();
}
};
return PosterImage;
}(_clickableComponent2['default']);
_component2['default'].registerComponent('PosterImage', PosterImage);
exports['default'] = PosterImage;
/***/ }),
/***/ "./node_modules/video.js/es5/setup.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.hasLoaded = exports.autoSetupTimeout = exports.autoSetup = undefined;
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _events = __webpack_require__("./node_modules/video.js/es5/utils/events.js");
var Events = _interopRequireWildcard(_events);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
/**
* @file setup.js - Functions for setting up a player without
* user interaction based on the data-setup `attribute` of the video tag.
*
* @module setup
*/
var _windowLoaded = false;
var videojs = void 0;
/**
* Set up any tags that have a data-setup `attribute` when the player is started.
*/
var autoSetup = function autoSetup() {
// Protect against breakage in non-browser environments.
if (!Dom.isReal()) {
return;
}
// One day, when we stop supporting IE8, go back to this, but in the meantime...*hack hack hack*
// var vids = Array.prototype.slice.call(document.getElementsByTagName('video'));
// var audios = Array.prototype.slice.call(document.getElementsByTagName('audio'));
// var mediaEls = vids.concat(audios);
// Because IE8 doesn't support calling slice on a node list, we need to loop
// through each list of elements to build up a new, combined list of elements.
var vids = _document2['default'].getElementsByTagName('video');
var audios = _document2['default'].getElementsByTagName('audio');
var mediaEls = [];
if (vids && vids.length > 0) {
for (var i = 0, e = vids.length; i < e; i++) {
mediaEls.push(vids[i]);
}
}
if (audios && audios.length > 0) {
for (var _i = 0, _e = audios.length; _i < _e; _i++) {
mediaEls.push(audios[_i]);
}
}
// Check if any media elements exist
if (mediaEls && mediaEls.length > 0) {
for (var _i2 = 0, _e2 = mediaEls.length; _i2 < _e2; _i2++) {
var mediaEl = mediaEls[_i2];
// Check if element exists, has getAttribute func.
// IE seems to consider typeof el.getAttribute == 'object' instead of
// 'function' like expected, at least when loading the player immediately.
if (mediaEl && mediaEl.getAttribute) {
// Make sure this player hasn't already been set up.
if (mediaEl.player === undefined) {
var options = mediaEl.getAttribute('data-setup');
// Check if data-setup attr exists.
// We only auto-setup if they've added the data-setup attr.
if (options !== null) {
// Create new video.js instance.
videojs(mediaEl);
}
}
// If getAttribute isn't defined, we need to wait for the DOM.
} else {
autoSetupTimeout(1);
break;
}
}
// No videos were found, so keep looping unless page is finished loading.
} else if (!_windowLoaded) {
autoSetupTimeout(1);
}
};
/**
* Wait until the page is loaded before running autoSetup. This will be called in
* autoSetup if `hasLoaded` returns false.
*
* @param {number} wait
* How long to wait in ms
*
* @param {videojs} [vjs]
* The videojs library function
*/
function autoSetupTimeout(wait, vjs) {
if (vjs) {
videojs = vjs;
}
_window2['default'].setTimeout(autoSetup, wait);
}
if (Dom.isReal() && _document2['default'].readyState === 'complete') {
_windowLoaded = true;
} else {
/**
* Listen for the load event on window, and set _windowLoaded to true.
*
* @listens load
*/
Events.one(_window2['default'], 'load', function () {
_windowLoaded = true;
});
}
/**
* check if the document has been loaded
*/
var hasLoaded = function hasLoaded() {
return _windowLoaded;
};
exports.autoSetup = autoSetup;
exports.autoSetupTimeout = autoSetupTimeout;
exports.hasLoaded = hasLoaded;
/***/ }),
/***/ "./node_modules/video.js/es5/slider/slider.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file slider.js
*/
/**
* The base functionality for a slider. Can be vertical or horizontal.
* For instance the volume bar or the seek bar on a video is a slider.
*
* @extends Component
*/
var Slider = function (_Component) {
_inherits(Slider, _Component);
/**
* Create an instance of this class
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*/
function Slider(player, options) {
_classCallCheck(this, Slider);
// Set property names to bar to match with the child Slider class is looking for
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.bar = _this.getChild(_this.options_.barName);
// Set a horizontal or vertical class on the slider depending on the slider type
_this.vertical(!!_this.options_.vertical);
_this.on('mousedown', _this.handleMouseDown);
_this.on('touchstart', _this.handleMouseDown);
_this.on('focus', _this.handleFocus);
_this.on('blur', _this.handleBlur);
_this.on('click', _this.handleClick);
_this.on(player, 'controlsvisible', _this.update);
_this.on(player, _this.playerEvent, _this.update);
return _this;
}
/**
* Create the `Button`s DOM element.
*
* @param {string} type
* Type of element to create.
*
* @param {Object} [props={}]
* List of properties in Object form.
*
* @param {Object} [attributes={}]
* list of attributes in Object form.
*
* @return {Element}
* The element that gets created.
*/
Slider.prototype.createEl = function createEl(type) {
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
// Add the slider element class to all sub classes
props.className = props.className + ' vjs-slider';
props = (0, _obj.assign)({
tabIndex: 0
}, props);
attributes = (0, _obj.assign)({
'role': 'slider',
'aria-valuenow': 0,
'aria-valuemin': 0,
'aria-valuemax': 100,
'tabIndex': 0
}, attributes);
return _Component.prototype.createEl.call(this, type, props, attributes);
};
/**
* Handle `mousedown` or `touchstart` events on the `Slider`.
*
* @param {EventTarget~Event} event
* `mousedown` or `touchstart` event that triggered this function
*
* @listens mousedown
* @listens touchstart
* @fires Slider#slideractive
*/
Slider.prototype.handleMouseDown = function handleMouseDown(event) {
var doc = this.bar.el_.ownerDocument;
event.preventDefault();
Dom.blockTextSelection();
this.addClass('vjs-sliding');
/**
* Triggered when the slider is in an active state
*
* @event Slider#slideractive
* @type {EventTarget~Event}
*/
this.trigger('slideractive');
this.on(doc, 'mousemove', this.handleMouseMove);
this.on(doc, 'mouseup', this.handleMouseUp);
this.on(doc, 'touchmove', this.handleMouseMove);
this.on(doc, 'touchend', this.handleMouseUp);
this.handleMouseMove(event);
};
/**
* Handle the `mousemove`, `touchmove`, and `mousedown` events on this `Slider`.
* The `mousemove` and `touchmove` events will only only trigger this function during
* `mousedown` and `touchstart`. This is due to {@link Slider#handleMouseDown} and
* {@link Slider#handleMouseUp}.
*
* @param {EventTarget~Event} event
* `mousedown`, `mousemove`, `touchstart`, or `touchmove` event that triggered
* this function
*
* @listens mousemove
* @listens touchmove
*/
Slider.prototype.handleMouseMove = function handleMouseMove(event) {};
/**
* Handle `mouseup` or `touchend` events on the `Slider`.
*
* @param {EventTarget~Event} event
* `mouseup` or `touchend` event that triggered this function.
*
* @listens touchend
* @listens mouseup
* @fires Slider#sliderinactive
*/
Slider.prototype.handleMouseUp = function handleMouseUp() {
var doc = this.bar.el_.ownerDocument;
Dom.unblockTextSelection();
this.removeClass('vjs-sliding');
/**
* Triggered when the slider is no longer in an active state.
*
* @event Slider#sliderinactive
* @type {EventTarget~Event}
*/
this.trigger('sliderinactive');
this.off(doc, 'mousemove', this.handleMouseMove);
this.off(doc, 'mouseup', this.handleMouseUp);
this.off(doc, 'touchmove', this.handleMouseMove);
this.off(doc, 'touchend', this.handleMouseUp);
this.update();
};
/**
* Update the progress bar of the `Slider`.
*/
Slider.prototype.update = function update() {
// In VolumeBar init we have a setTimeout for update that pops and update to the end of the
// execution stack. The player is destroyed before then update will cause an error
if (!this.el_) {
return;
}
// If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
// On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
// var progress = (this.player_.scrubbing()) ? this.player_.getCache().currentTime / this.player_.duration() : this.player_.currentTime() / this.player_.duration();
var progress = this.getPercent();
var bar = this.bar;
// If there's no bar...
if (!bar) {
return;
}
// Protect against no duration and other division issues
if (typeof progress !== 'number' || progress !== progress || progress < 0 || progress === Infinity) {
progress = 0;
}
// Convert to a percentage for setting
var percentage = (progress * 100).toFixed(2) + '%';
// Set the new bar width or height
if (this.vertical()) {
bar.el().style.height = percentage;
} else {
bar.el().style.width = percentage;
}
};
/**
* Calculate distance for slider
*
* @param {EventTarget~Event} event
* The event that caused this function to run.
*
* @return {number}
* The current position of the Slider.
* - postition.x for vertical `Slider`s
* - postition.y for horizontal `Slider`s
*/
Slider.prototype.calculateDistance = function calculateDistance(event) {
var position = Dom.getPointerPosition(this.el_, event);
if (this.vertical()) {
return position.y;
}
return position.x;
};
/**
* Handle a `focus` event on this `Slider`.
*
* @param {EventTarget~Event} event
* The `focus` event that caused this function to run.
*
* @listens focus
*/
Slider.prototype.handleFocus = function handleFocus() {
this.on(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
};
/**
* Handle a `keydown` event on the `Slider`. Watches for left, rigth, up, and down
* arrow keys. This function will only be called when the slider has focus. See
* {@link Slider#handleFocus} and {@link Slider#handleBlur}.
*
* @param {EventTarget~Event} event
* the `keydown` event that caused this function to run.
*
* @listens keydown
*/
Slider.prototype.handleKeyPress = function handleKeyPress(event) {
// Left and Down Arrows
if (event.which === 37 || event.which === 40) {
event.preventDefault();
this.stepBack();
// Up and Right Arrows
} else if (event.which === 38 || event.which === 39) {
event.preventDefault();
this.stepForward();
}
};
/**
* Handle a `blur` event on this `Slider`.
*
* @param {EventTarget~Event} event
* The `blur` event that caused this function to run.
*
* @listens blur
*/
Slider.prototype.handleBlur = function handleBlur() {
this.off(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
};
/**
* Listener for click events on slider, used to prevent clicks
* from bubbling up to parent elements like button menus.
*
* @param {Object} event
* Event that caused this object to run
*/
Slider.prototype.handleClick = function handleClick(event) {
event.stopImmediatePropagation();
event.preventDefault();
};
/**
* Get/set if slider is horizontal for vertical
*
* @param {boolean} [bool]
* - true if slider is vertical,
* - false is horizontal
*
* @return {boolean|Slider}
* - true if slider is vertical, and getting
* - false is horizontal, and getting
* - a reference to this object when setting
*/
Slider.prototype.vertical = function vertical(bool) {
if (bool === undefined) {
return this.vertical_ || false;
}
this.vertical_ = !!bool;
if (this.vertical_) {
this.addClass('vjs-slider-vertical');
} else {
this.addClass('vjs-slider-horizontal');
}
return this;
};
return Slider;
}(_component2['default']);
_component2['default'].registerComponent('Slider', Slider);
exports['default'] = Slider;
/***/ }),
/***/ "./node_modules/video.js/es5/tech/flash-rtmp.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
/**
* @file flash-rtmp.js
* @module flash-rtmp
*/
/**
* Add RTMP properties to the {@link Flash} Tech.
*
* @param {Flash} Flash
* The flash tech class.
*
* @mixin FlashRtmpDecorator
*/
function FlashRtmpDecorator(Flash) {
Flash.streamingFormats = {
'rtmp/mp4': 'MP4',
'rtmp/flv': 'FLV'
};
/**
* Join connection and stream with an ampersand.
*
* @param {string} connection
* The connection string.
*
* @param {string} stream
* The stream string.
*/
Flash.streamFromParts = function (connection, stream) {
return connection + '&' + stream;
};
/**
* The flash parts object that contains connection and stream info.
*
* @typedef {Object} Flash~PartsObject
*
* @property {string} connection
* The connection string of a source, defaults to an empty string.
*
* @property {string} stream
* The stream string of the source, defaults to an empty string.
*/
/**
* Convert a source url into a stream and connection parts.
*
* @param {string} src
* the source url
*
* @return {Flash~PartsObject}
* The parts object that contains a connection and a stream
*/
Flash.streamToParts = function (src) {
var parts = {
connection: '',
stream: ''
};
if (!src) {
return parts;
}
// Look for the normal URL separator we expect, '&'.
// If found, we split the URL into two pieces around the
// first '&'.
var connEnd = src.search(/&(?!\w+=)/);
var streamBegin = void 0;
if (connEnd !== -1) {
streamBegin = connEnd + 1;
} else {
// If there's not a '&', we use the last '/' as the delimiter.
connEnd = streamBegin = src.lastIndexOf('/') + 1;
if (connEnd === 0) {
// really, there's not a '/'?
connEnd = streamBegin = src.length;
}
}
parts.connection = src.substring(0, connEnd);
parts.stream = src.substring(streamBegin, src.length);
return parts;
};
/**
* Check if the source type is a streaming type.
*
* @param {string} srcType
* The mime type to check.
*
* @return {boolean}
* - True if the source type is a streaming type.
* - False if the source type is not a streaming type.
*/
Flash.isStreamingType = function (srcType) {
return srcType in Flash.streamingFormats;
};
// RTMP has four variations, any string starting
// with one of these protocols should be valid
/**
* Regular expression used to check if the source is an rtmp source.
*
* @property {RegExp} Flash.RTMP_RE
*/
Flash.RTMP_RE = /^rtmp[set]?:\/\//i;
/**
* Check if the source itself is a streaming type.
*
* @param {string} src
* The url to the source.
*
* @return {boolean}
* - True if the source url indicates that the source is streaming.
* - False if the shource url indicates that the source url is not streaming.
*/
Flash.isStreamingSrc = function (src) {
return Flash.RTMP_RE.test(src);
};
/**
* A source handler for RTMP urls
* @type {Object}
*/
Flash.rtmpSourceHandler = {};
/**
* Check if Flash can play the given mime type.
*
* @param {string} type
* The mime type to check
*
* @return {string}
* 'maybe', or '' (empty string)
*/
Flash.rtmpSourceHandler.canPlayType = function (type) {
if (Flash.isStreamingType(type)) {
return 'maybe';
}
return '';
};
/**
* Check if Flash can handle the source natively
*
* @param {Object} source
* The source object
*
* @param {Object} [options]
* The options passed to the tech
*
* @return {string}
* 'maybe', or '' (empty string)
*/
Flash.rtmpSourceHandler.canHandleSource = function (source, options) {
var can = Flash.rtmpSourceHandler.canPlayType(source.type);
if (can) {
return can;
}
if (Flash.isStreamingSrc(source.src)) {
return 'maybe';
}
return '';
};
/**
* Pass the source to the flash object.
*
* @param {Object} source
* The source object
*
* @param {Flash} tech
* The instance of the Flash tech
*
* @param {Object} [options]
* The options to pass to the source
*/
Flash.rtmpSourceHandler.handleSource = function (source, tech, options) {
var srcParts = Flash.streamToParts(source.src);
tech.setRtmpConnection(srcParts.connection);
tech.setRtmpStream(srcParts.stream);
};
// Register the native source handler
Flash.registerSourceHandler(Flash.rtmpSourceHandler);
return Flash;
}
exports['default'] = FlashRtmpDecorator;
/***/ }),
/***/ "./node_modules/video.js/es5/tech/flash.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _tech = __webpack_require__("./node_modules/video.js/es5/tech/tech.js");
var _tech2 = _interopRequireDefault(_tech);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _url = __webpack_require__("./node_modules/video.js/es5/utils/url.js");
var Url = _interopRequireWildcard(_url);
var _timeRanges = __webpack_require__("./node_modules/video.js/es5/utils/time-ranges.js");
var _flashRtmp = __webpack_require__("./node_modules/video.js/es5/tech/flash-rtmp.js");
var _flashRtmp2 = _interopRequireDefault(_flashRtmp);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file flash.js
* VideoJS-SWF - Custom Flash Player with HTML5-ish API
* https://github.com/zencoder/video-js-swf
* Not using setupTriggers. Using global onEvent func to distribute events
*/
var navigator = _window2['default'].navigator;
/**
* Flash Media Controller - Wrapper for Flash Media API
*
* @mixes FlashRtmpDecorator
* @mixes Tech~SouceHandlerAdditions
* @extends Tech
*/
var Flash = function (_Tech) {
_inherits(Flash, _Tech);
/**
* Create an instance of this Tech.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} ready
* Callback function to call when the `Flash` Tech is ready.
*/
function Flash(options, ready) {
_classCallCheck(this, Flash);
// Set the source when ready
var _this = _possibleConstructorReturn(this, _Tech.call(this, options, ready));
if (options.source) {
_this.ready(function () {
this.setSource(options.source);
}, true);
}
// Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
// This allows resetting the playhead when we catch the reload
if (options.startTime) {
_this.ready(function () {
this.load();
this.play();
this.currentTime(options.startTime);
}, true);
}
// Add global window functions that the swf expects
// A 4.x workflow we weren't able to solve for in 5.0
// because of the need to hard code these functions
// into the swf for security reasons
_window2['default'].videojs = _window2['default'].videojs || {};
_window2['default'].videojs.Flash = _window2['default'].videojs.Flash || {};
_window2['default'].videojs.Flash.onReady = Flash.onReady;
_window2['default'].videojs.Flash.onEvent = Flash.onEvent;
_window2['default'].videojs.Flash.onError = Flash.onError;
_this.on('seeked', function () {
this.lastSeekTarget_ = undefined;
});
return _this;
}
/**
* Create the `Flash` Tech's DOM element.
*
* @return {Element}
* The element that gets created.
*/
Flash.prototype.createEl = function createEl() {
var options = this.options_;
// If video.js is hosted locally you should also set the location
// for the hosted swf, which should be relative to the page (not video.js)
// Otherwise this adds a CDN url.
// The CDN also auto-adds a swf URL for that specific version.
if (!options.swf) {
var ver = '5.3.0';
options.swf = '//vjs.zencdn.net/swf/' + ver + '/video-js.swf';
}
// Generate ID for swf object
var objId = options.techId;
// Merge default flashvars with ones passed in to init
var flashVars = (0, _obj.assign)({
// SWF Callback Functions
readyFunction: 'videojs.Flash.onReady',
eventProxyFunction: 'videojs.Flash.onEvent',
errorEventProxyFunction: 'videojs.Flash.onError',
// Player Settings
autoplay: options.autoplay,
preload: options.preload,
loop: options.loop,
muted: options.muted
}, options.flashVars);
// Merge default parames with ones passed in
var params = (0, _obj.assign)({
// Opaque is needed to overlay controls, but can affect playback performance
wmode: 'opaque',
// Using bgcolor prevents a white flash when the object is loading
bgcolor: '#000000'
}, options.params);
// Merge default attributes with ones passed in
var attributes = (0, _obj.assign)({
// Both ID and Name needed or swf to identify itself
id: objId,
name: objId,
'class': 'vjs-tech'
}, options.attributes);
this.el_ = Flash.embed(options.swf, flashVars, params, attributes);
this.el_.tech = this;
return this.el_;
};
/**
* Called by {@link Player#play} to play using the `Flash` `Tech`.
*/
Flash.prototype.play = function play() {
if (this.ended()) {
this.setCurrentTime(0);
}
this.el_.vjs_play();
};
/**
* Called by {@link Player#pause} to pause using the `Flash` `Tech`.
*/
Flash.prototype.pause = function pause() {
this.el_.vjs_pause();
};
/**
* A getter/setter for the `Flash` Tech's source object.
* > Note: Please use {@link Flash#setSource}
*
* @param {Tech~SourceObject} [src]
* The source object you want to set on the `Flash` techs.
*
* @return {Tech~SourceObject|undefined}
* - The current source object when a source is not passed in.
* - undefined when setting
*
* @deprecated Since version 5.
*/
Flash.prototype.src = function src(_src) {
if (_src === undefined) {
return this.currentSrc();
}
// Setting src through `src` not `setSrc` will be deprecated
return this.setSrc(_src);
};
/**
* A getter/setter for the `Flash` Tech's source object.
*
* @param {Tech~SourceObject} [src]
* The source object you want to set on the `Flash` techs.
*
* @return {Tech~SourceObject|undefined}
* - The current source object when a source is not passed in.
* - undefined when setting
*/
Flash.prototype.setSrc = function setSrc(src) {
var _this2 = this;
// Make sure source URL is absolute.
src = Url.getAbsoluteURL(src);
this.el_.vjs_src(src);
// Currently the SWF doesn't autoplay if you load a source later.
// e.g. Load player w/ no source, wait 2s, set src.
if (this.autoplay()) {
this.setTimeout(function () {
return _this2.play();
}, 0);
}
};
/**
* Indicates whether the media is currently seeking to a new position or not.
*
* @return {boolean}
* - True if seeking to a new position
* - False otherwise
*/
Flash.prototype.seeking = function seeking() {
return this.lastSeekTarget_ !== undefined;
};
/**
* Returns the current time in seconds that the media is at in playback.
*
* @param {number} time
* Current playtime of the media in seconds.
*/
Flash.prototype.setCurrentTime = function setCurrentTime(time) {
var seekable = this.seekable();
if (seekable.length) {
// clamp to the current seekable range
time = time > seekable.start(0) ? time : seekable.start(0);
time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1);
this.lastSeekTarget_ = time;
this.trigger('seeking');
this.el_.vjs_setProperty('currentTime', time);
_Tech.prototype.setCurrentTime.call(this);
}
};
/**
* Get the current playback time in seconds
*
* @return {number}
* The current time of playback in seconds.
*/
Flash.prototype.currentTime = function currentTime() {
// when seeking make the reported time keep up with the requested time
// by reading the time we're seeking to
if (this.seeking()) {
return this.lastSeekTarget_ || 0;
}
return this.el_.vjs_getProperty('currentTime');
};
/**
* Get the current source
*
* @method currentSrc
* @return {Tech~SourceObject}
* The current source
*/
Flash.prototype.currentSrc = function currentSrc() {
if (this.currentSource_) {
return this.currentSource_.src;
}
return this.el_.vjs_getProperty('currentSrc');
};
/**
* Get the total duration of the current media.
*
* @return {number}
8 The total duration of the current media.
*/
Flash.prototype.duration = function duration() {
if (this.readyState() === 0) {
return NaN;
}
var duration = this.el_.vjs_getProperty('duration');
return duration >= 0 ? duration : Infinity;
};
/**
* Load media into Tech.
*/
Flash.prototype.load = function load() {
this.el_.vjs_load();
};
/**
* Get the poster image that was set on the tech.
*/
Flash.prototype.poster = function poster() {
this.el_.vjs_getProperty('poster');
};
/**
* Poster images are not handled by the Flash tech so make this is a no-op.
*/
Flash.prototype.setPoster = function setPoster() {};
/**
* Determine the time ranges that can be seeked to in the media.
*
* @return {TimeRange}
* Returns the time ranges that can be seeked to.
*/
Flash.prototype.seekable = function seekable() {
var duration = this.duration();
if (duration === 0) {
return (0, _timeRanges.createTimeRange)();
}
return (0, _timeRanges.createTimeRange)(0, duration);
};
/**
* Get and create a `TimeRange` object for buffering.
*
* @return {TimeRange}
* The time range object that was created.
*/
Flash.prototype.buffered = function buffered() {
var ranges = this.el_.vjs_getProperty('buffered');
if (ranges.length === 0) {
return (0, _timeRanges.createTimeRange)();
}
return (0, _timeRanges.createTimeRange)(ranges[0][0], ranges[0][1]);
};
/**
* Get fullscreen support -
*
* Flash does not allow fullscreen through javascript
* so this always returns false.
*
* @return {boolean}
* The Flash tech does not support fullscreen, so it will always return false.
*/
Flash.prototype.supportsFullScreen = function supportsFullScreen() {
// Flash does not allow fullscreen through javascript
return false;
};
/**
* Flash does not allow fullscreen through javascript
* so this always returns false.
*
* @return {boolean}
* The Flash tech does not support fullscreen, so it will always return false.
*/
Flash.prototype.enterFullScreen = function enterFullScreen() {
return false;
};
return Flash;
}(_tech2['default']);
// Create setters and getters for attributes
var _api = Flash.prototype;
var _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
var _readOnly = 'networkState,readyState,initialTime,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(',');
function _createSetter(attr) {
var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
_api['set' + attrUpper] = function (val) {
return this.el_.vjs_setProperty(attr, val);
};
}
function _createGetter(attr) {
_api[attr] = function () {
return this.el_.vjs_getProperty(attr);
};
}
// Create getter and setters for all read/write attributes
for (var i = 0; i < _readWrite.length; i++) {
_createGetter(_readWrite[i]);
_createSetter(_readWrite[i]);
}
// Create getters for read-only attributes
for (var _i = 0; _i < _readOnly.length; _i++) {
_createGetter(_readOnly[_i]);
}
/** ------------------------------ Getters ------------------------------ **/
/**
* Get the value of `rtmpConnection` from the swf.
*
* @method Flash#rtmpConnection
* @return {string}
* The current value of `rtmpConnection` on the swf.
*/
/**
* Get the value of `rtmpStream` from the swf.
*
* @method Flash#rtmpStream
* @return {string}
* The current value of `rtmpStream` on the swf.
*/
/**
* Get the value of `preload` from the swf. `preload` indicates
* what should download before the media is interacted with. It can have the following
* values:
* - none: nothing should be downloaded
* - metadata: poster and the first few frames of the media may be downloaded to get
* media dimensions and other metadata
* - auto: allow the media and metadata for the media to be downloaded before
* interaction
*
* @method Flash#preload
* @return {string}
* The value of `preload` from the swf. Will be 'none', 'metadata',
* or 'auto'.
*/
/**
* Get the value of `defaultPlaybackRate` from the swf.
*
* @method Flash#defaultPlaybackRate
* @return {number}
* The current value of `defaultPlaybackRate` on the swf.
*/
/**
* Get the value of `playbackRate` from the swf. `playbackRate` indicates
* the rate at which the media is currently playing back. Examples:
* - if playbackRate is set to 2, media will play twice as fast.
* - if playbackRate is set to 0.5, media will play half as fast.
*
* @method Flash#playbackRate
* @return {number}
* The value of `playbackRate` from the swf. A number indicating
* the current playback speed of the media, where 1 is normal speed.
*/
/**
* Get the value of `autoplay` from the swf. `autoplay` indicates
* that the media should start to play as soon as the page is ready.
*
* @method Flash#autoplay
* @return {boolean}
* - The value of `autoplay` from the swf.
* - True indicates that the media ashould start as soon as the page loads.
* - False indicates that the media should not start as soon as the page loads.
*/
/**
* Get the value of `loop` from the swf. `loop` indicates
* that the media should return to the start of the media and continue playing once
* it reaches the end.
*
* @method Flash#loop
* @return {boolean}
* - The value of `loop` from the swf.
* - True indicates that playback should seek back to start once
* the end of a media is reached.
* - False indicates that playback should not loop back to the start when the
* end of the media is reached.
*/
/**
* Get the value of `mediaGroup` from the swf.
*
* @method Flash#mediaGroup
* @return {string}
* The current value of `mediaGroup` on the swf.
*/
/**
* Get the value of `controller` from the swf.
*
* @method Flash#controller
* @return {string}
* The current value of `controller` on the swf.
*/
/**
* Get the value of `controls` from the swf. `controls` indicates
* whether the native flash controls should be shown or hidden.
*
* @method Flash#controls
* @return {boolean}
* - The value of `controls` from the swf.
* - True indicates that native controls should be showing.
* - False indicates that native controls should be hidden.
*/
/**
* Get the value of the `volume` from the swf. `volume` indicates the current
* audio level as a percentage in decimal form. This means that 1 is 100%, 0.5 is 50%, and
* so on.
*
* @method Flash#volume
* @return {number}
* The volume percent as a decimal. Value will be between 0-1.
*/
/**
* Get the value of the `muted` from the swf. `muted` indicates the current
* audio level should be silent.
*
* @method Flash#muted
* @return {boolean}
* - True if the audio should be set to silent
* - False otherwise
*/
/**
* Get the value of `defaultMuted` from the swf. `defaultMuted` indicates
* whether the media should start muted or not. Only changes the default state of the
* media. `muted` and `defaultMuted` can have different values. `muted` indicates the
* current state.
*
* @method Flash#defaultMuted
* @return {boolean}
* - The value of `defaultMuted` from the swf.
* - True indicates that the media should start muted.
* - False indicates that the media should not start muted.
*/
/**
* Get the value of `networkState` from the swf. `networkState` indicates
* the current network state. It returns an enumeration from the following list:
* - 0: NETWORK_EMPTY
* - 1: NEWORK_IDLE
* - 2: NETWORK_LOADING
* - 3: NETWORK_NO_SOURCE
*
* @method Flash#networkState
* @return {number}
* The value of `networkState` from the swf. This will be a number
* from the list in the description.
*/
/**
* Get the value of `readyState` from the swf. `readyState` indicates
* the current state of the media element. It returns an enumeration from the
* following list:
* - 0: HAVE_NOTHING
* - 1: HAVE_METADATA
* - 2: HAVE_CURRENT_DATA
* - 3: HAVE_FUTURE_DATA
* - 4: HAVE_ENOUGH_DATA
*
* @method Flash#readyState
* @return {number}
* The value of `readyState` from the swf. This will be a number
* from the list in the description.
*/
/**
* Get the value of `readyState` from the swf. `readyState` indicates
* the current state of the media element. It returns an enumeration from the
* following list:
* - 0: HAVE_NOTHING
* - 1: HAVE_METADATA
* - 2: HAVE_CURRENT_DATA
* - 3: HAVE_FUTURE_DATA
* - 4: HAVE_ENOUGH_DATA
*
* @method Flash#readyState
* @return {number}
* The value of `readyState` from the swf. This will be a number
* from the list in the description.
*/
/**
* Get the value of `initialTime` from the swf.
*
* @method Flash#initialTime
* @return {number}
* The `initialTime` proprety on the swf.
*/
/**
* Get the value of `startOffsetTime` from the swf.
*
* @method Flash#startOffsetTime
* @return {number}
* The `startOffsetTime` proprety on the swf.
*/
/**
* Get the value of `paused` from the swf. `paused` indicates whether the swf
* is current paused or not.
*
* @method Flash#paused
* @return {boolean}
* The value of `paused` from the swf.
*/
/**
* Get the value of `ended` from the swf. `ended` indicates whether
* the media has reached the end or not.
*
* @method Flash#ended
* @return {boolean}
* - True indicates that the media has ended.
* - False indicates that the media has not ended.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-ended}
*/
/**
* Get the value of `videoWidth` from the swf. `videoWidth` indicates
* the current width of the media in css pixels.
*
* @method Flash#videoWidth
* @return {number}
* The value of `videoWidth` from the swf. This will be a number
* in css pixels.
*/
/**
* Get the value of `videoHeight` from the swf. `videoHeigth` indicates
* the current height of the media in css pixels.
*
* @method Flassh.prototype.videoHeight
* @return {number}
* The value of `videoHeight` from the swf. This will be a number
* in css pixels.
*/
/** ------------------------------ Setters ------------------------------ **/
/**
* Set the value of `rtmpConnection` on the swf.
*
* @method Flash#setRtmpConnection
* @param {string} rtmpConnection
* New value to set the `rtmpConnection` property to.
*/
/**
* Set the value of `rtmpStream` on the swf.
*
* @method Flash#setRtmpStream
* @param {string} rtmpStream
* New value to set the `rtmpStream` property to.
*/
/**
* Set the value of `preload` on the swf. `preload` indicates
* what should download before the media is interacted with. It can have the following
* values:
* - none: nothing should be downloaded
* - metadata: poster and the first few frames of the media may be downloaded to get
* media dimensions and other metadata
* - auto: allow the media and metadata for the media to be downloaded before
* interaction
*
* @method Flash#setPreload
* @param {string} preload
* The value of `preload` to set on the swf. Should be 'none', 'metadata',
* or 'auto'.
*/
/**
* Set the value of `defaultPlaybackRate` on the swf.
*
* @method Flash#setDefaultPlaybackRate
* @param {number} defaultPlaybackRate
* New value to set the `defaultPlaybackRate` property to.
*/
/**
* Set the value of `playbackRate` on the swf. `playbackRate` indicates
* the rate at which the media is currently playing back. Examples:
* - if playbackRate is set to 2, media will play twice as fast.
* - if playbackRate is set to 0.5, media will play half as fast.
*
* @method Flash#setPlaybackRate
* @param {number} playbackRate
* New value of `playbackRate` on the swf. A number indicating
* the current playback speed of the media, where 1 is normal speed.
*/
/**
* Set the value of `autoplay` on the swf. `autoplay` indicates
* that the media should start to play as soon as the page is ready.
*
* @method Flash#setAutoplay
* @param {boolean} autoplay
* - The value of `autoplay` from the swf.
* - True indicates that the media ashould start as soon as the page loads.
* - False indicates that the media should not start as soon as the page loads.
*/
/**
* Set the value of `loop` on the swf. `loop` indicates
* that the media should return to the start of the media and continue playing once
* it reaches the end.
*
* @method Flash#setLoop
* @param {boolean} loop
* - True indicates that playback should seek back to start once
* the end of a media is reached.
* - False indicates that playback should not loop back to the start when the
* end of the media is reached.
*/
/**
* Set the value of `mediaGroup` on the swf.
*
* @method Flash#setMediaGroup
* @param {string} mediaGroup
* New value of `mediaGroup` to set on the swf.
*/
/**
* Set the value of `controller` on the swf.
*
* @method Flash#setController
* @param {string} controller
* New value the current value of `controller` on the swf.
*/
/**
* Get the value of `controls` from the swf. `controls` indicates
* whether the native flash controls should be shown or hidden.
*
* @method Flash#controls
* @return {boolean}
* - The value of `controls` from the swf.
* - True indicates that native controls should be showing.
* - False indicates that native controls should be hidden.
*/
/**
* Set the value of the `volume` on the swf. `volume` indicates the current
* audio level as a percentage in decimal form. This means that 1 is 100%, 0.5 is 50%, and
* so on.
*
* @method Flash#setVolume
* @param {number} percentAsDecimal
* The volume percent as a decimal. Value will be between 0-1.
*/
/**
* Set the value of the `muted` on the swf. `muted` indicates that the current
* audio level should be silent.
*
* @method Flash#setMuted
* @param {boolean} muted
* - True if the audio should be set to silent
* - False otherwise
*/
/**
* Set the value of `defaultMuted` on the swf. `defaultMuted` indicates
* whether the media should start muted or not. Only changes the default state of the
* media. `muted` and `defaultMuted` can have different values. `muted` indicates the
* current state.
*
* @method Flash#setDefaultMuted
* @param {boolean} defaultMuted
* - True indicates that the media should start muted.
* - False indicates that the media should not start muted.
*/
/* Flash Support Testing -------------------------------------------------------- */
/**
* Check if the Flash tech is currently supported.
*
* @return {boolean}
* - True if the flash tech is supported.
* - False otherwise.
*/
Flash.isSupported = function () {
return Flash.version()[0] >= 10;
// return swfobject.hasFlashPlayerVersion('10');
};
// Add Source Handler pattern functions to this tech
_tech2['default'].withSourceHandlers(Flash);
/*
* Native source handler for flash, simply passes the source to the swf element.
*
* @property {Tech~SourceObject} source
* The source object
*
* @property {Flash} tech
* The instance of the Flash tech
*/
Flash.nativeSourceHandler = {};
/**
* Check if the Flash can play the given mime type.
*
* @param {string} type
* The mimetype to check
*
* @return {string}
* 'maybe', or '' (empty string)
*/
Flash.nativeSourceHandler.canPlayType = function (type) {
if (type in Flash.formats) {
return 'maybe';
}
return '';
};
/**
* Check if the media element can handle a source natively.
*
* @param {Tech~SourceObject} source
* The source object
*
* @param {Object} [options]
* Options to be passed to the tech.
*
* @return {string}
* 'maybe', or '' (empty string).
*/
Flash.nativeSourceHandler.canHandleSource = function (source, options) {
var type = void 0;
function guessMimeType(src) {
var ext = Url.getFileExtension(src);
if (ext) {
return 'video/' + ext;
}
return '';
}
if (!source.type) {
type = guessMimeType(source.src);
} else {
// Strip code information from the type because we don't get that specific
type = source.type.replace(/;.*/, '').toLowerCase();
}
return Flash.nativeSourceHandler.canPlayType(type);
};
/**
* Pass the source to the swf.
*
* @param {Tech~SourceObject} source
* The source object
*
* @param {Flash} tech
* The instance of the Flash tech
*
* @param {Object} [options]
* The options to pass to the source
*/
Flash.nativeSourceHandler.handleSource = function (source, tech, options) {
tech.setSrc(source.src);
};
/**
* noop for native source handler dispose, as cleanup will happen automatically.
*/
Flash.nativeSourceHandler.dispose = function () {};
// Register the native source handler
Flash.registerSourceHandler(Flash.nativeSourceHandler);
/**
* Flash supported mime types.
*
* @constant {Object}
*/
Flash.formats = {
'video/flv': 'FLV',
'video/x-flv': 'FLV',
'video/mp4': 'MP4',
'video/m4v': 'MP4'
};
/**
* Called when the the swf is "ready", and makes sure that the swf is really
* ready using {@link Flash#checkReady}
*/
Flash.onReady = function (currSwf) {
var el = Dom.getEl(currSwf);
var tech = el && el.tech;
// if there is no el then the tech has been disposed
// and the tech element was removed from the player div
if (tech && tech.el()) {
// check that the flash object is really ready
Flash.checkReady(tech);
}
};
/**
* The SWF isn't always ready when it says it is. Sometimes the API functions still
* need to be added to the object. If it's not ready, we set a timeout to check again
* shortly.
*
* @param {Flash} tech
* The instance of the flash tech to check.
*/
Flash.checkReady = function (tech) {
// stop worrying if the tech has been disposed
if (!tech.el()) {
return;
}
// check if API property exists
if (tech.el().vjs_getProperty) {
// tell tech it's ready
tech.triggerReady();
} else {
// wait longer
this.setTimeout(function () {
Flash.checkReady(tech);
}, 50);
}
};
/**
* Trigger events from the swf on the Flash Tech.
*
* @param {number} swfID
* The id of the swf that had the event
*
* @param {string} eventName
* The name of the event to trigger
*/
Flash.onEvent = function (swfID, eventName) {
var tech = Dom.getEl(swfID).tech;
var args = Array.prototype.slice.call(arguments, 2);
// dispatch Flash events asynchronously for two reasons:
// - Flash swallows any exceptions generated by javascript it
// invokes
// - Flash is suspended until the javascript returns which may cause
// playback performance issues
tech.setTimeout(function () {
tech.trigger(eventName, args);
}, 1);
};
/**
* Log errors from the swf on the Flash tech.
*
* @param {number} swfID
* The id of the swf that had an error.
*
* @param {string} The error string
* The error to set on the Flash Tech.
*
* @return {MediaError|undefined}
* - Returns a MediaError when err is 'srcnotfound'
* - Returns undefined otherwise.
*/
Flash.onError = function (swfID, err) {
var tech = Dom.getEl(swfID).tech;
// trigger MEDIA_ERR_SRC_NOT_SUPPORTED
if (err === 'srcnotfound') {
return tech.error(4);
}
// trigger a custom error
tech.error('FLASH: ' + err);
};
/**
* Get the current version of Flash that is in use on the page.
*
* @return {Array}
* an array of versions that are available.
*/
Flash.version = function () {
var version = '0,0,0';
// IE
try {
version = new _window2['default'].ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
// other browsers
} catch (e) {
try {
if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
version = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
}
} catch (err) {
// satisfy linter
}
}
return version.split(',');
};
/**
* Only use for non-iframe embeds.
*
* @param {Object} swf
* The videojs-swf object.
*
* @param {Object} flashVars
* Names and values to use as flash option variables.
*
* @param {Object} params
* Style parameters to set on the object.
*
* @param {Object} attributes
* Attributes to set on the element.
*
* @return {Element}
* The embeded Flash DOM element.
*/
Flash.embed = function (swf, flashVars, params, attributes) {
var code = Flash.getEmbedCode(swf, flashVars, params, attributes);
// Get element by embedding code and retrieving created element
var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0];
return obj;
};
/**
* Only use for non-iframe embeds.
*
* @param {Object} swf
* The videojs-swf object.
*
* @param {Object} flashVars
* Names and values to use as flash option variables.
*
* @param {Object} params
* Style parameters to set on the object.
*
* @param {Object} attributes
* Attributes to set on the element.
*
* @return {Element}
* The embeded Flash DOM element.
*/
Flash.getEmbedCode = function (swf, flashVars, params, attributes) {
var objTag = '';
});
attributes = (0, _obj.assign)({
// Add swf to attributes (need both for IE and Others to work)
data: swf,
// Default to 100% width/height
width: '100%',
height: '100%'
}, attributes);
// Create Attributes string
Object.getOwnPropertyNames(attributes).forEach(function (key) {
attrsString += key + '="' + attributes[key] + '" ';
});
return '' + objTag + attrsString + '>' + paramsString + '';
};
// Run Flash through the RTMP decorator
(0, _flashRtmp2['default'])(Flash);
_component2['default'].registerComponent('Flash', Flash);
_tech2['default'].registerTech('Flash', Flash);
exports['default'] = Flash;
/***/ }),
/***/ "./node_modules/video.js/es5/tech/html5.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _templateObject = _taggedTemplateLiteralLoose(['Text Tracks are being loaded from another origin but the crossorigin attribute isn\'t used.\n This may prevent text tracks from loading.'], ['Text Tracks are being loaded from another origin but the crossorigin attribute isn\'t used.\n This may prevent text tracks from loading.']);
var _tech = __webpack_require__("./node_modules/video.js/es5/tech/tech.js");
var _tech2 = _interopRequireDefault(_tech);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var Dom = _interopRequireWildcard(_dom);
var _url = __webpack_require__("./node_modules/video.js/es5/utils/url.js");
var Url = _interopRequireWildcard(_url);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
var _tsml = __webpack_require__("./node_modules/tsml/tsml.js");
var _tsml2 = _interopRequireDefault(_tsml);
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
var _mergeOptions = __webpack_require__("./node_modules/video.js/es5/utils/merge-options.js");
var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
var _toTitleCase = __webpack_require__("./node_modules/video.js/es5/utils/to-title-case.js");
var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file html5.js
*/
/**
* HTML5 Media Controller - Wrapper for HTML5 Media API
*
* @mixes Tech~SouceHandlerAdditions
* @extends Tech
*/
var Html5 = function (_Tech) {
_inherits(Html5, _Tech);
/**
* Create an instance of this Tech.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} ready
* Callback function to call when the `HTML5` Tech is ready.
*/
function Html5(options, ready) {
_classCallCheck(this, Html5);
var _this = _possibleConstructorReturn(this, _Tech.call(this, options, ready));
var source = options.source;
var crossoriginTracks = false;
// Set the source if one is provided
// 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted)
// 2) Check to see if the network state of the tag was failed at init, and if so, reset the source
// anyway so the error gets fired.
if (source && (_this.el_.currentSrc !== source.src || options.tag && options.tag.initNetworkState_ === 3)) {
_this.setSource(source);
} else {
_this.handleLateInit_(_this.el_);
}
if (_this.el_.hasChildNodes()) {
var nodes = _this.el_.childNodes;
var nodesLength = nodes.length;
var removeNodes = [];
while (nodesLength--) {
var node = nodes[nodesLength];
var nodeName = node.nodeName.toLowerCase();
if (nodeName === 'track') {
if (!_this.featuresNativeTextTracks) {
// Empty video tag tracks so the built-in player doesn't use them also.
// This may not be fast enough to stop HTML5 browsers from reading the tags
// so we'll need to turn off any default tracks if we're manually doing
// captions and subtitles. videoElement.textTracks
removeNodes.push(node);
} else {
// store HTMLTrackElement and TextTrack to remote list
_this.remoteTextTrackEls().addTrackElement_(node);
_this.remoteTextTracks().addTrack_(node.track);
if (!crossoriginTracks && !_this.el_.hasAttribute('crossorigin') && Url.isCrossOrigin(node.src)) {
crossoriginTracks = true;
}
}
}
}
for (var i = 0; i < removeNodes.length; i++) {
_this.el_.removeChild(removeNodes[i]);
}
}
// TODO: add text tracks into this list
var trackTypes = ['audio', 'video'];
// ProxyNative Video/Audio Track
trackTypes.forEach(function (type) {
var elTracks = _this.el()[type + 'Tracks'];
var techTracks = _this[type + 'Tracks']();
var capitalType = (0, _toTitleCase2['default'])(type);
if (!_this['featuresNative' + capitalType + 'Tracks'] || !elTracks || !elTracks.addEventListener) {
return;
}
_this['handle' + capitalType + 'TrackChange_'] = function (e) {
techTracks.trigger({
type: 'change',
target: techTracks,
currentTarget: techTracks,
srcElement: techTracks
});
};
_this['handle' + capitalType + 'TrackAdd_'] = function (e) {
return techTracks.addTrack(e.track);
};
_this['handle' + capitalType + 'TrackRemove_'] = function (e) {
return techTracks.removeTrack(e.track);
};
elTracks.addEventListener('change', _this['handle' + capitalType + 'TrackChange_']);
elTracks.addEventListener('addtrack', _this['handle' + capitalType + 'TrackAdd_']);
elTracks.addEventListener('removetrack', _this['handle' + capitalType + 'TrackRemove_']);
_this['removeOld' + capitalType + 'Tracks_'] = function (e) {
return _this.removeOldTracks_(techTracks, elTracks);
};
// Remove (native) tracks that are not used anymore
_this.on('loadstart', _this['removeOld' + capitalType + 'Tracks_']);
});
if (_this.featuresNativeTextTracks) {
if (crossoriginTracks) {
_log2['default'].warn((0, _tsml2['default'])(_templateObject));
}
_this.handleTextTrackChange_ = Fn.bind(_this, _this.handleTextTrackChange);
_this.handleTextTrackAdd_ = Fn.bind(_this, _this.handleTextTrackAdd);
_this.handleTextTrackRemove_ = Fn.bind(_this, _this.handleTextTrackRemove);
_this.proxyNativeTextTracks_();
}
// Determine if native controls should be used
// Our goal should be to get the custom controls on mobile solid everywhere
// so we can remove this all together. Right now this will block custom
// controls on touch enabled laptops like the Chrome Pixel
if ((browser.TOUCH_ENABLED || browser.IS_IPHONE || browser.IS_NATIVE_ANDROID) && options.nativeControlsForTouch === true) {
_this.setControls(true);
}
// on iOS, we want to proxy `webkitbeginfullscreen` and `webkitendfullscreen`
// into a `fullscreenchange` event
_this.proxyWebkitFullscreen_();
_this.triggerReady();
return _this;
}
/**
* Dispose of `HTML5` media element and remove all tracks.
*/
Html5.prototype.dispose = function dispose() {
var _this2 = this;
// Un-ProxyNativeTracks
['audio', 'video', 'text'].forEach(function (type) {
var capitalType = (0, _toTitleCase2['default'])(type);
var tl = _this2.el_[type + 'Tracks'];
if (tl && tl.removeEventListener) {
tl.removeEventListener('change', _this2['handle' + capitalType + 'TrackChange_']);
tl.removeEventListener('addtrack', _this2['handle' + capitalType + 'TrackAdd_']);
tl.removeEventListener('removetrack', _this2['handle' + capitalType + 'TrackRemove_']);
}
// Stop removing old text tracks
if (tl) {
_this2.off('loadstart', _this2['removeOld' + capitalType + 'Tracks_']);
}
});
Html5.disposeMediaElement(this.el_);
// tech will handle clearing of the emulated track list
_Tech.prototype.dispose.call(this);
};
/**
* Create the `Html5` Tech's DOM element.
*
* @return {Element}
* The element that gets created.
*/
Html5.prototype.createEl = function createEl() {
var el = this.options_.tag;
// Check if this browser supports moving the element into the box.
// On the iPhone video will break if you move the element,
// So we have to create a brand new element.
// If we ingested the player div, we do not need to move the media element.
if (!el || !(this.options_.playerElIngest || this.movingMediaElementInDOM)) {
// If the original tag is still there, clone and remove it.
if (el) {
var clone = el.cloneNode(true);
if (el.parentNode) {
el.parentNode.insertBefore(clone, el);
}
Html5.disposeMediaElement(el);
el = clone;
} else {
el = _document2['default'].createElement('video');
// determine if native controls should be used
var tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag);
var attributes = (0, _mergeOptions2['default'])({}, tagAttributes);
if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
delete attributes.controls;
}
Dom.setElAttributes(el, (0, _obj.assign)(attributes, {
id: this.options_.techId,
'class': 'vjs-tech'
}));
}
el.playerId = this.options_.playerId;
}
// Update specific tag settings, in case they were overridden
var settingsAttrs = ['autoplay', 'preload', 'loop', 'muted'];
for (var i = settingsAttrs.length - 1; i >= 0; i--) {
var attr = settingsAttrs[i];
var overwriteAttrs = {};
if (typeof this.options_[attr] !== 'undefined') {
overwriteAttrs[attr] = this.options_[attr];
}
Dom.setElAttributes(el, overwriteAttrs);
}
return el;
};
/**
* This will be triggered if the loadstart event has already fired, before videojs was
* ready. Two known examples of when this can happen are:
* 1. If we're loading the playback object after it has started loading
* 2. The media is already playing the (often with autoplay on) then
*
* This function will fire another loadstart so that videojs can catchup.
*
* @fires Tech#loadstart
*
* @return {undefined}
* returns nothing.
*/
Html5.prototype.handleLateInit_ = function handleLateInit_(el) {
if (el.networkState === 0 || el.networkState === 3) {
// The video element hasn't started loading the source yet
// or didn't find a source
return;
}
if (el.readyState === 0) {
// NetworkState is set synchronously BUT loadstart is fired at the
// end of the current stack, usually before setInterval(fn, 0).
// So at this point we know loadstart may have already fired or is
// about to fire, and either way the player hasn't seen it yet.
// We don't want to fire loadstart prematurely here and cause a
// double loadstart so we'll wait and see if it happens between now
// and the next loop, and fire it if not.
// HOWEVER, we also want to make sure it fires before loadedmetadata
// which could also happen between now and the next loop, so we'll
// watch for that also.
var loadstartFired = false;
var setLoadstartFired = function setLoadstartFired() {
loadstartFired = true;
};
this.on('loadstart', setLoadstartFired);
var triggerLoadstart = function triggerLoadstart() {
// We did miss the original loadstart. Make sure the player
// sees loadstart before loadedmetadata
if (!loadstartFired) {
this.trigger('loadstart');
}
};
this.on('loadedmetadata', triggerLoadstart);
this.ready(function () {
this.off('loadstart', setLoadstartFired);
this.off('loadedmetadata', triggerLoadstart);
if (!loadstartFired) {
// We did miss the original native loadstart. Fire it now.
this.trigger('loadstart');
}
});
return;
}
// From here on we know that loadstart already fired and we missed it.
// The other readyState events aren't as much of a problem if we double
// them, so not going to go to as much trouble as loadstart to prevent
// that unless we find reason to.
var eventsToTrigger = ['loadstart'];
// loadedmetadata: newly equal to HAVE_METADATA (1) or greater
eventsToTrigger.push('loadedmetadata');
// loadeddata: newly increased to HAVE_CURRENT_DATA (2) or greater
if (el.readyState >= 2) {
eventsToTrigger.push('loadeddata');
}
// canplay: newly increased to HAVE_FUTURE_DATA (3) or greater
if (el.readyState >= 3) {
eventsToTrigger.push('canplay');
}
// canplaythrough: newly equal to HAVE_ENOUGH_DATA (4)
if (el.readyState >= 4) {
eventsToTrigger.push('canplaythrough');
}
// We still need to give the player time to add event listeners
this.ready(function () {
eventsToTrigger.forEach(function (type) {
this.trigger(type);
}, this);
});
};
/**
* Add event listeners to native text track events. This adds the native text tracks
* to our emulated {@link TextTrackList}.
*/
Html5.prototype.proxyNativeTextTracks_ = function proxyNativeTextTracks_() {
var tt = this.el().textTracks;
if (tt) {
// Add tracks - if player is initialised after DOM loaded, textTracks
// will not trigger addtrack
for (var i = 0; i < tt.length; i++) {
this.textTracks().addTrack_(tt[i]);
}
if (tt.addEventListener) {
tt.addEventListener('change', this.handleTextTrackChange_);
tt.addEventListener('addtrack', this.handleTextTrackAdd_);
tt.addEventListener('removetrack', this.handleTextTrackRemove_);
}
// Remove (native) texttracks that are not used anymore
this.on('loadstart', this.removeOldTextTracks_);
}
};
/**
* Handle any {@link TextTrackList} `change` event.
*
* @param {EventTarget~Event} e
* The `change` event that caused this to run.
*
* @listens TextTrackList#change
*/
Html5.prototype.handleTextTrackChange = function handleTextTrackChange(e) {
var tt = this.textTracks();
this.textTracks().trigger({
type: 'change',
target: tt,
currentTarget: tt,
srcElement: tt
});
};
/**
* Handle any {@link TextTrackList} `addtrack` event.
*
* @param {EventTarget~Event} e
* The `addtrack` event that caused this to run.
*
* @listens TextTrackList#addtrack
*/
Html5.prototype.handleTextTrackAdd = function handleTextTrackAdd(e) {
this.textTracks().addTrack_(e.track);
};
/**
* Handle any {@link TextTrackList} `removetrack` event.
*
* @param {EventTarget~Event} e
* The `removetrack` event that caused this to run.
*
* @listens TextTrackList#removetrack
*/
Html5.prototype.handleTextTrackRemove = function handleTextTrackRemove(e) {
this.textTracks().removeTrack_(e.track);
};
/**
* This function removes any {@link AudioTrack}s, {@link VideoTrack}s, or
* {@link TextTrack}s that are not in the media elements TrackList.
*
* @param {TrackList} techTracks
* HTML5 Tech's TrackList to search through
*
* @param {TrackList} elTracks
* HTML5 media elements TrackList to search trough.
*
* @private
*/
Html5.prototype.removeOldTracks_ = function removeOldTracks_(techTracks, elTracks) {
// This will loop over the techTracks and check if they are still used by the HTML5 media element
// If not, they will be removed from the emulated list
var removeTracks = [];
if (!elTracks) {
return;
}
for (var i = 0; i < techTracks.length; i++) {
var techTrack = techTracks[i];
var found = false;
for (var j = 0; j < elTracks.length; j++) {
if (elTracks[j] === techTrack) {
found = true;
break;
}
}
if (!found) {
removeTracks.push(techTrack);
}
}
for (var _i = 0; _i < removeTracks.length; _i++) {
var track = removeTracks[_i];
techTracks.removeTrack_(track);
}
};
/**
* Remove {@link TextTrack}s that dont exist in the native track list from our
* emulated {@link TextTrackList}.
*
* @listens Tech#loadstart
*/
Html5.prototype.removeOldTextTracks_ = function removeOldTextTracks_(e) {
var techTracks = this.textTracks();
var elTracks = this.el().textTracks;
this.removeOldTracks_(techTracks, elTracks);
};
/**
* Called by {@link Player#play} to play using the `Html5` `Tech`.
*/
Html5.prototype.play = function play() {
var playPromise = this.el_.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
playPromise.then(null, function (e) {});
}
};
/**
* Set current time for the `HTML5` tech.
*
* @param {number} seconds
* Set the current time of the media to this.
*/
Html5.prototype.setCurrentTime = function setCurrentTime(seconds) {
try {
this.el_.currentTime = seconds;
} catch (e) {
(0, _log2['default'])(e, 'Video is not ready. (Video.js)');
// this.warning(VideoJS.warnings.videoNotReady);
}
};
/**
* Get the current duration of the HTML5 media element.
*
* @return {number}
* The duration of the media or 0 if there is no duration.
*/
Html5.prototype.duration = function duration() {
var _this3 = this;
// Android Chrome will report duration as Infinity for VOD HLS until after
// playback has started, which triggers the live display erroneously.
// Return NaN if playback has not started and trigger a durationupdate once
// the duration can be reliably known.
if (this.el_.duration === Infinity && browser.IS_ANDROID && browser.IS_CHROME) {
if (this.el_.currentTime === 0) {
// Wait for the first `timeupdate` with currentTime > 0 - there may be
// several with 0
var checkProgress = function checkProgress() {
if (_this3.el_.currentTime > 0) {
// Trigger durationchange for genuinely live video
if (_this3.el_.duration === Infinity) {
_this3.trigger('durationchange');
}
_this3.off('timeupdate', checkProgress);
}
};
this.on('timeupdate', checkProgress);
return NaN;
}
}
return this.el_.duration || NaN;
};
/**
* Get the current width of the HTML5 media element.
*
* @return {number}
* The width of the HTML5 media element.
*/
Html5.prototype.width = function width() {
return this.el_.offsetWidth;
};
/**
* Get the current height of the HTML5 media element.
*
* @return {number}
* The heigth of the HTML5 media element.
*/
Html5.prototype.height = function height() {
return this.el_.offsetHeight;
};
/**
* Proxy iOS `webkitbeginfullscreen` and `webkitendfullscreen` into
* `fullscreenchange` event.
*
* @private
* @fires fullscreenchange
* @listens webkitendfullscreen
* @listens webkitbeginfullscreen
* @listens webkitbeginfullscreen
*/
Html5.prototype.proxyWebkitFullscreen_ = function proxyWebkitFullscreen_() {
var _this4 = this;
if (!('webkitDisplayingFullscreen' in this.el_)) {
return;
}
var endFn = function endFn() {
this.trigger('fullscreenchange', { isFullscreen: false });
};
var beginFn = function beginFn() {
this.one('webkitendfullscreen', endFn);
this.trigger('fullscreenchange', { isFullscreen: true });
};
this.on('webkitbeginfullscreen', beginFn);
this.on('dispose', function () {
_this4.off('webkitbeginfullscreen', beginFn);
_this4.off('webkitendfullscreen', endFn);
});
};
/**
* Check if fullscreen is supported on the current playback device.
*
* @return {boolean}
* - True if fullscreen is supported.
* - False if fullscreen is not supported.
*/
Html5.prototype.supportsFullScreen = function supportsFullScreen() {
if (typeof this.el_.webkitEnterFullScreen === 'function') {
var userAgent = _window2['default'].navigator && _window2['default'].navigator.userAgent || '';
// Seems to be broken in Chromium/Chrome && Safari in Leopard
if (/Android/.test(userAgent) || !/Chrome|Mac OS X 10.5/.test(userAgent)) {
return true;
}
}
return false;
};
/**
* Request that the `HTML5` Tech enter fullscreen.
*/
Html5.prototype.enterFullScreen = function enterFullScreen() {
var video = this.el_;
if (video.paused && video.networkState <= video.HAVE_METADATA) {
// attempt to prime the video element for programmatic access
// this isn't necessary on the desktop but shouldn't hurt
this.el_.play();
// playing and pausing synchronously during the transition to fullscreen
// can get iOS ~6.1 devices into a play/pause loop
this.setTimeout(function () {
video.pause();
video.webkitEnterFullScreen();
}, 0);
} else {
video.webkitEnterFullScreen();
}
};
/**
* Request that the `HTML5` Tech exit fullscreen.
*/
Html5.prototype.exitFullScreen = function exitFullScreen() {
this.el_.webkitExitFullScreen();
};
/**
* A getter/setter for the `Html5` Tech's source object.
* > Note: Please use {@link Html5#setSource}
*
* @param {Tech~SourceObject} [src]
* The source object you want to set on the `HTML5` techs element.
*
* @return {Tech~SourceObject|undefined}
* - The current source object when a source is not passed in.
* - undefined when setting
*
* @deprecated Since version 5.
*/
Html5.prototype.src = function src(_src) {
if (_src === undefined) {
return this.el_.src;
}
// Setting src through `src` instead of `setSrc` will be deprecated
this.setSrc(_src);
};
/**
* Reset the tech by removing all sources and then calling
* {@link Html5.resetMediaElement}.
*/
Html5.prototype.reset = function reset() {
Html5.resetMediaElement(this.el_);
};
/**
* Get the current source on the `HTML5` Tech. Falls back to returning the source from
* the HTML5 media element.
*
* @return {Tech~SourceObject}
* The current source object from the HTML5 tech. With a fallback to the
* elements source.
*/
Html5.prototype.currentSrc = function currentSrc() {
if (this.currentSource_) {
return this.currentSource_.src;
}
return this.el_.currentSrc;
};
/**
* Set controls attribute for the HTML5 media Element.
*
* @param {string} val
* Value to set the controls attribute to
*/
Html5.prototype.setControls = function setControls(val) {
this.el_.controls = !!val;
};
/**
* Create and returns a remote {@link TextTrack} object.
*
* @param {string} kind
* `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata)
*
* @param {string} [label]
* Label to identify the text track
*
* @param {string} [language]
* Two letter language abbreviation
*
* @return {TextTrack}
* The TextTrack that gets created.
*/
Html5.prototype.addTextTrack = function addTextTrack(kind, label, language) {
if (!this.featuresNativeTextTracks) {
return _Tech.prototype.addTextTrack.call(this, kind, label, language);
}
return this.el_.addTextTrack(kind, label, language);
};
/**
* Creates either native TextTrack or an emulated TextTrack depending
* on the value of `featuresNativeTextTracks`
*
* @param {Object} options
* The object should contain the options to intialize the TextTrack with.
*
* @param {string} [options.kind]
* `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata).
*
* @param {string} [options.label].
* Label to identify the text track
*
* @param {string} [options.language]
* Two letter language abbreviation.
*
* @param {boolean} [options.default]
* Default this track to on.
*
* @param {string} [options.id]
* The internal id to assign this track.
*
* @param {string} [options.src]
* A source url for the track.
*
* @return {HTMLTrackElement}
* The track element that gets created.
*/
Html5.prototype.createRemoteTextTrack = function createRemoteTextTrack(options) {
if (!this.featuresNativeTextTracks) {
return _Tech.prototype.createRemoteTextTrack.call(this, options);
}
var htmlTrackElement = _document2['default'].createElement('track');
if (options.kind) {
htmlTrackElement.kind = options.kind;
}
if (options.label) {
htmlTrackElement.label = options.label;
}
if (options.language || options.srclang) {
htmlTrackElement.srclang = options.language || options.srclang;
}
if (options['default']) {
htmlTrackElement['default'] = options['default'];
}
if (options.id) {
htmlTrackElement.id = options.id;
}
if (options.src) {
htmlTrackElement.src = options.src;
}
return htmlTrackElement;
};
/**
* Creates a remote text track object and returns an html track element.
*
* @param {Object} options The object should contain values for
* kind, language, label, and src (location of the WebVTT file)
* @param {Boolean} [manualCleanup=true] if set to false, the TextTrack will be
* automatically removed from the video element whenever the source changes
* @return {HTMLTrackElement} An Html Track Element.
* This can be an emulated {@link HTMLTrackElement} or a native one.
* @deprecated The default value of the "manualCleanup" parameter will default
* to "false" in upcoming versions of Video.js
*/
Html5.prototype.addRemoteTextTrack = function addRemoteTextTrack(options, manualCleanup) {
var htmlTrackElement = _Tech.prototype.addRemoteTextTrack.call(this, options, manualCleanup);
if (this.featuresNativeTextTracks) {
this.el().appendChild(htmlTrackElement);
}
return htmlTrackElement;
};
/**
* Remove remote `TextTrack` from `TextTrackList` object
*
* @param {TextTrack} track
* `TextTrack` object to remove
*/
Html5.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
_Tech.prototype.removeRemoteTextTrack.call(this, track);
if (this.featuresNativeTextTracks) {
var tracks = this.$$('track');
var i = tracks.length;
while (i--) {
if (track === tracks[i] || track === tracks[i].track) {
this.el().removeChild(tracks[i]);
}
}
}
};
return Html5;
}(_tech2['default']);
/* HTML5 Support Testing ---------------------------------------------------- */
if (Dom.isReal()) {
/**
* Element for testing browser HTML5 media capabilities
*
* @type {Element}
* @constant
* @private
*/
Html5.TEST_VID = _document2['default'].createElement('video');
var track = _document2['default'].createElement('track');
track.kind = 'captions';
track.srclang = 'en';
track.label = 'English';
Html5.TEST_VID.appendChild(track);
}
/**
* Check if HTML5 media is supported by this browser/device.
*
* @return {boolean}
* - True if HTML5 media is supported.
* - False if HTML5 media is not supported.
*/
Html5.isSupported = function () {
// IE9 with no Media Player is a LIAR! (#984)
try {
Html5.TEST_VID.volume = 0.5;
} catch (e) {
return false;
}
return !!(Html5.TEST_VID && Html5.TEST_VID.canPlayType);
};
/**
* Check if the volume can be changed in this browser/device.
* Volume cannot be changed in a lot of mobile devices.
* Specifically, it can't be changed from 1 on iOS.
*
* @return {boolean}
* - True if volume can be controlled
* - False otherwise
*/
Html5.canControlVolume = function () {
// IE will error if Windows Media Player not installed #3315
try {
var volume = Html5.TEST_VID.volume;
Html5.TEST_VID.volume = volume / 2 + 0.1;
return volume !== Html5.TEST_VID.volume;
} catch (e) {
return false;
}
};
/**
* Check if the playback rate can be changed in this browser/device.
*
* @return {boolean}
* - True if playback rate can be controlled
* - False otherwise
*/
Html5.canControlPlaybackRate = function () {
// Playback rate API is implemented in Android Chrome, but doesn't do anything
// https://github.com/videojs/video.js/issues/3180
if (browser.IS_ANDROID && browser.IS_CHROME) {
return false;
}
// IE will error if Windows Media Player not installed #3315
try {
var playbackRate = Html5.TEST_VID.playbackRate;
Html5.TEST_VID.playbackRate = playbackRate / 2 + 0.1;
return playbackRate !== Html5.TEST_VID.playbackRate;
} catch (e) {
return false;
}
};
/**
* Check to see if native `TextTrack`s are supported by this browser/device.
*
* @return {boolean}
* - True if native `TextTrack`s are supported.
* - False otherwise
*/
Html5.supportsNativeTextTracks = function () {
return browser.IS_ANY_SAFARI;
};
/**
* Check to see if native `VideoTrack`s are supported by this browser/device
*
* @return {boolean}
* - True if native `VideoTrack`s are supported.
* - False otherwise
*/
Html5.supportsNativeVideoTracks = function () {
return !!(Html5.TEST_VID && Html5.TEST_VID.videoTracks);
};
/**
* Check to see if native `AudioTrack`s are supported by this browser/device
*
* @return {boolean}
* - True if native `AudioTrack`s are supported.
* - False otherwise
*/
Html5.supportsNativeAudioTracks = function () {
return !!(Html5.TEST_VID && Html5.TEST_VID.audioTracks);
};
/**
* An array of events available on the Html5 tech.
*
* @private
* @type {Array}
*/
Html5.Events = ['loadstart', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', 'playing', 'waiting', 'seeking', 'seeked', 'ended', 'durationchange', 'timeupdate', 'progress', 'play', 'pause', 'ratechange', 'volumechange'];
/**
* Boolean indicating whether the `Tech` supports volume control.
*
* @type {boolean}
* @default {@link Html5.canControlVolume}
*/
Html5.prototype.featuresVolumeControl = Html5.canControlVolume();
/**
* Boolean indicating whether the `Tech` supports changing the speed at which the media
* plays. Examples:
* - Set player to play 2x (twice) as fast
* - Set player to play 0.5x (half) as fast
*
* @type {boolean}
* @default {@link Html5.canControlPlaybackRate}
*/
Html5.prototype.featuresPlaybackRate = Html5.canControlPlaybackRate();
/**
* Boolean indicating whether the `HTML5` tech currently supports the media element
* moving in the DOM. iOS breaks if you move the media element, so this is set this to
* false there. Everywhere else this should be true.
*
* @type {boolean}
* @default
*/
Html5.prototype.movingMediaElementInDOM = !browser.IS_IOS;
// TODO: Previous comment: No longer appears to be used. Can probably be removed.
// Is this true?
/**
* Boolean indicating whether the `HTML5` tech currently supports automatic media resize
* when going into fullscreen.
*
* @type {boolean}
* @default
*/
Html5.prototype.featuresFullscreenResize = true;
/**
* Boolean indicating whether the `HTML5` tech currently supports the progress event.
* If this is false, manual `progress` events will be triggred instead.
*
* @type {boolean}
* @default
*/
Html5.prototype.featuresProgressEvents = true;
/**
* Boolean indicating whether the `HTML5` tech currently supports the timeupdate event.
* If this is false, manual `timeupdate` events will be triggred instead.
*
* @default
*/
Html5.prototype.featuresTimeupdateEvents = true;
/**
* Boolean indicating whether the `HTML5` tech currently supports native `TextTrack`s.
*
* @type {boolean}
* @default {@link Html5.supportsNativeTextTracks}
*/
Html5.prototype.featuresNativeTextTracks = Html5.supportsNativeTextTracks();
/**
* Boolean indicating whether the `HTML5` tech currently supports native `VideoTrack`s.
*
* @type {boolean}
* @default {@link Html5.supportsNativeVideoTracks}
*/
Html5.prototype.featuresNativeVideoTracks = Html5.supportsNativeVideoTracks();
/**
* Boolean indicating whether the `HTML5` tech currently supports native `AudioTrack`s.
*
* @type {boolean}
* @default {@link Html5.supportsNativeAudioTracks}
*/
Html5.prototype.featuresNativeAudioTracks = Html5.supportsNativeAudioTracks();
// HTML5 Feature detection and Device Fixes --------------------------------- //
var canPlayType = Html5.TEST_VID && Html5.TEST_VID.constructor.prototype.canPlayType;
var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i;
var mp4RE = /^video\/mp4/i;
Html5.patchCanPlayType = function () {
// Android 4.0 and above can play HLS to some extent but it reports being unable to do so
if (browser.ANDROID_VERSION >= 4.0 && !browser.IS_FIREFOX) {
Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
if (type && mpegurlRE.test(type)) {
return 'maybe';
}
return canPlayType.call(this, type);
};
// Override Android 2.2 and less canPlayType method which is broken
} else if (browser.IS_OLD_ANDROID) {
Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
if (type && mp4RE.test(type)) {
return 'maybe';
}
return canPlayType.call(this, type);
};
}
};
Html5.unpatchCanPlayType = function () {
var r = Html5.TEST_VID.constructor.prototype.canPlayType;
Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType;
return r;
};
// by default, patch the media element
Html5.patchCanPlayType();
Html5.disposeMediaElement = function (el) {
if (!el) {
return;
}
if (el.parentNode) {
el.parentNode.removeChild(el);
}
// remove any child track or source nodes to prevent their loading
while (el.hasChildNodes()) {
el.removeChild(el.firstChild);
}
// remove any src reference. not setting `src=''` because that causes a warning
// in firefox
el.removeAttribute('src');
// force the media element to update its loading state by calling load()
// however IE on Windows 7N has a bug that throws an error so need a try/catch (#793)
if (typeof el.load === 'function') {
// wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
(function () {
try {
el.load();
} catch (e) {
// not supported
}
})();
}
};
Html5.resetMediaElement = function (el) {
if (!el) {
return;
}
var sources = el.querySelectorAll('source');
var i = sources.length;
while (i--) {
el.removeChild(sources[i]);
}
// remove any src reference.
// not setting `src=''` because that throws an error
el.removeAttribute('src');
if (typeof el.load === 'function') {
// wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
(function () {
try {
el.load();
} catch (e) {
// satisfy linter
}
})();
}
};
/* Native HTML5 element property wrapping ----------------------------------- */
// Wrap native properties with a getter
[
/**
* Get the value of `paused` from the media element. `paused` indicates whether the media element
* is currently paused or not.
*
* @method Html5#paused
* @return {boolean}
* The value of `paused` from the media element.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-paused}
*/
'paused',
/**
* Get the value of `currentTime` from the media element. `currentTime` indicates
* the current second that the media is at in playback.
*
* @method Html5#currentTime
* @return {number}
* The value of `currentTime` from the media element.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-currenttime}
*/
'currentTime',
/**
* Get the value of `buffered` from the media element. `buffered` is a `TimeRange`
* object that represents the parts of the media that are already downloaded and
* available for playback.
*
* @method Html5#buffered
* @return {TimeRange}
* The value of `buffered` from the media element.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-buffered}
*/
'buffered',
/**
* Get the value of `volume` from the media element. `volume` indicates
* the current playback volume of audio for a media. `volume` will be a value from 0
* (silent) to 1 (loudest and default).
*
* @method Html5#volume
* @return {number}
* The value of `volume` from the media element. Value will be between 0-1.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-a-volume}
*/
'volume',
/**
* Get the value of `muted` from the media element. `muted` indicates
* that the volume for the media should be set to silent. This does not actually change
* the `volume` attribute.
*
* @method Html5#muted
* @return {boolean}
* - True if the value of `volume` should be ignored and the audio set to silent.
* - False if the value of `volume` should be used.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-muted}
*/
'muted',
/**
* Get the value of `poster` from the media element. `poster` indicates
* that the url of an image file that can/will be shown when no media data is available.
*
* @method Html5#poster
* @return {string}
* The value of `poster` from the media element. Value will be a url to an
* image.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-video-poster}
*/
'poster',
/**
* Get the value of `preload` from the media element. `preload` indicates
* what should download before the media is interacted with. It can have the following
* values:
* - none: nothing should be downloaded
* - metadata: poster and the first few frames of the media may be downloaded to get
* media dimensions and other metadata
* - auto: allow the media and metadata for the media to be downloaded before
* interaction
*
* @method Html5#preload
* @return {string}
* The value of `preload` from the media element. Will be 'none', 'metadata',
* or 'auto'.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-preload}
*/
'preload',
/**
* Get the value of `autoplay` from the media element. `autoplay` indicates
* that the media should start to play as soon as the page is ready.
*
* @method Html5#autoplay
* @return {boolean}
* - The value of `autoplay` from the media element.
* - True indicates that the media should start as soon as the page loads.
* - False indicates that the media should not start as soon as the page loads.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-autoplay}
*/
'autoplay',
/**
* Get the value of `controls` from the media element. `controls` indicates
* whether the native media controls should be shown or hidden.
*
* @method Html5#controls
* @return {boolean}
* - The value of `controls` from the media element.
* - True indicates that native controls should be showing.
* - False indicates that native controls should be hidden.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-controls}
*/
'controls',
/**
* Get the value of `loop` from the media element. `loop` indicates
* that the media should return to the start of the media and continue playing once
* it reaches the end.
*
* @method Html5#loop
* @return {boolean}
* - The value of `loop` from the media element.
* - True indicates that playback should seek back to start once
* the end of a media is reached.
* - False indicates that playback should not loop back to the start when the
* end of the media is reached.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-loop}
*/
'loop',
/**
* Get the value of the `error` from the media element. `error` indicates any
* MediaError that may have occured during playback. If error returns null there is no
* current error.
*
* @method Html5#error
* @return {MediaError|null}
* The value of `error` from the media element. Will be `MediaError` if there
* is a current error and null otherwise.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-error}
*/
'error',
/**
* Get the value of `seeking` from the media element. `seeking` indicates whether the
* media is currently seeking to a new position or not.
*
* @method Html5#seeking
* @return {boolean}
* - The value of `seeking` from the media element.
* - True indicates that the media is currently seeking to a new position.
* - Flase indicates that the media is not seeking to a new position at this time.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-seeking}
*/
'seeking',
/**
* Get the value of `seekable` from the media element. `seekable` returns a
* `TimeRange` object indicating ranges of time that can currently be `seeked` to.
*
* @method Html5#seekable
* @return {TimeRange}
* The value of `seekable` from the media element. A `TimeRange` object
* indicating the current ranges of time that can be seeked to.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-seekable}
*/
'seekable',
/**
* Get the value of `ended` from the media element. `ended` indicates whether
* the media has reached the end or not.
*
* @method Html5#ended
* @return {boolean}
* - The value of `ended` from the media element.
* - True indicates that the media has ended.
* - False indicates that the media has not ended.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-ended}
*/
'ended',
/**
* Get the value of `defaultMuted` from the media element. `defaultMuted` indicates
* whether the media should start muted or not. Only changes the default state of the
* media. `muted` and `defaultMuted` can have different values. `muted` indicates the
* current state.
*
* @method Html5#defaultMuted
* @return {boolean}
* - The value of `defaultMuted` from the media element.
* - True indicates that the media should start muted.
* - False indicates that the media should not start muted
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-defaultmuted}
*/
'defaultMuted',
/**
* Get the value of `playbackRate` from the media element. `playbackRate` indicates
* the rate at which the media is currently playing back. Examples:
* - if playbackRate is set to 2, media will play twice as fast.
* - if playbackRate is set to 0.5, media will play half as fast.
*
* @method Html5#playbackRate
* @return {number}
* The value of `playbackRate` from the media element. A number indicating
* the current playback speed of the media, where 1 is normal speed.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-playbackrate}
*/
'playbackRate',
/**
* Get the value of `played` from the media element. `played` returns a `TimeRange`
* object representing points in the media timeline that have been played.
*
* @method Html5#played
* @return {TimeRange}
* The value of `played` from the media element. A `TimeRange` object indicating
* the ranges of time that have been played.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-played}
*/
'played',
/**
* Get the value of `networkState` from the media element. `networkState` indicates
* the current network state. It returns an enumeration from the following list:
* - 0: NETWORK_EMPTY
* - 1: NEWORK_IDLE
* - 2: NETWORK_LOADING
* - 3: NETWORK_NO_SOURCE
*
* @method Html5#networkState
* @return {number}
* The value of `networkState` from the media element. This will be a number
* from the list in the description.
*
* @see [Spec] {@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-networkstate}
*/
'networkState',
/**
* Get the value of `readyState` from the media element. `readyState` indicates
* the current state of the media element. It returns an enumeration from the
* following list:
* - 0: HAVE_NOTHING
* - 1: HAVE_METADATA
* - 2: HAVE_CURRENT_DATA
* - 3: HAVE_FUTURE_DATA
* - 4: HAVE_ENOUGH_DATA
*
* @method Html5#readyState
* @return {number}
* The value of `readyState` from the media element. This will be a number
* from the list in the description.
*
* @see [Spec] {@link https://www.w3.org/TR/html5/embedded-content-0.html#ready-states}
*/
'readyState',
/**
* Get the value of `videoWidth` from the video element. `videoWidth` indicates
* the current width of the video in css pixels.
*
* @method Html5#videoWidth
* @return {number}
* The value of `videoWidth` from the video element. This will be a number
* in css pixels.
*
* @see [Spec] {@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-video-videowidth}
*/
'videoWidth',
/**
* Get the value of `videoHeight` from the video element. `videoHeigth` indicates
* the current height of the video in css pixels.
*
* @method Html5#videoHeight
* @return {number}
* The value of `videoHeight` from the video element. This will be a number
* in css pixels.
*
* @see [Spec] {@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-video-videowidth}
*/
'videoHeight'].forEach(function (prop) {
Html5.prototype[prop] = function () {
return this.el_[prop];
};
});
// Wrap native properties with a setter in this format:
// set + toTitleCase(name)
[
/**
* Set the value of `volume` on the media element. `volume` indicates the current
* audio level as a percentage in decimal form. This means that 1 is 100%, 0.5 is 50%, and
* so on.
*
* @method Html5#setVolume
* @param {number} percentAsDecimal
* The volume percent as a decimal. Valid range is from 0-1.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-a-volume}
*/
'volume',
/**
* Set the value of `muted` on the media element. `muted` indicates the current
* audio level should be silent.
*
* @method Html5#setMuted
* @param {boolean} muted
* - True if the audio should be set to silent
* - False otherwise
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-muted}
*/
'muted',
/**
* Set the value of `src` on the media element. `src` indicates the current
* {@link Tech~SourceObject} for the media.
*
* @method Html5#setSrc
* @param {Tech~SourceObject} src
* The source object to set as the current source.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-src}
*/
'src',
/**
* Set the value of `poster` on the media element. `poster` is the url to
* an image file that can/will be shown when no media data is available.
*
* @method Html5#setPoster
* @param {string} poster
* The url to an image that should be used as the `poster` for the media
* element.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-poster}
*/
'poster',
/**
* Set the value of `preload` on the media element. `preload` indicates
* what should download before the media is interacted with. It can have the following
* values:
* - none: nothing should be downloaded
* - metadata: poster and the first few frames of the media may be downloaded to get
* media dimensions and other metadata
* - auto: allow the media and metadata for the media to be downloaded before
* interaction
*
* @method Html5#setPreload
* @param {string} preload
* The value of `preload` to set on the media element. Must be 'none', 'metadata',
* or 'auto'.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-preload}
*/
'preload',
/**
* Set the value of `autoplay` on the media element. `autoplay` indicates
* that the media should start to play as soon as the page is ready.
*
* @method Html5#setAutoplay
* @param {boolean} autoplay
* - True indicates that the media should start as soon as the page loads.
* - False indicates that the media should not start as soon as the page loads.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-autoplay}
*/
'autoplay',
/**
* Set the value of `loop` on the media element. `loop` indicates
* that the media should return to the start of the media and continue playing once
* it reaches the end.
*
* @method Html5#setLoop
* @param {boolean} loop
* - True indicates that playback should seek back to start once
* the end of a media is reached.
* - False indicates that playback should not loop back to the start when the
* end of the media is reached.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#attr-media-loop}
*/
'loop',
/**
* Set the value of `playbackRate` on the media element. `playbackRate` indicates
* the rate at which the media should play back. Examples:
* - if playbackRate is set to 2, media will play twice as fast.
* - if playbackRate is set to 0.5, media will play half as fast.
*
* @method Html5#setPlaybackRate
* @return {number}
* The value of `playbackRate` from the media element. A number indicating
* the current playback speed of the media, where 1 is normal speed.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-playbackrate}
*/
'playbackRate'].forEach(function (prop) {
Html5.prototype['set' + (0, _toTitleCase2['default'])(prop)] = function (v) {
this.el_[prop] = v;
};
});
// wrap native functions with a function
[
/**
* A wrapper around the media elements `pause` function. This will call the `HTML5`
* media elements `pause` function.
*
* @method Html5#pause
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-pause}
*/
'pause',
/**
* A wrapper around the media elements `load` function. This will call the `HTML5`s
* media element `load` function.
*
* @method Html5#load
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-load}
*/
'load'].forEach(function (prop) {
Html5.prototype[prop] = function () {
return this.el_[prop]();
};
});
_tech2['default'].withSourceHandlers(Html5);
/**
* Native source handler for Html5, simply passes the source to the media element.
*
* @proprety {Tech~SourceObject} source
* The source object
*
* @proprety {Html5} tech
* The instance of the HTML5 tech.
*/
Html5.nativeSourceHandler = {};
/**
* Check if the media element can play the given mime type.
*
* @param {string} type
* The mimetype to check
*
* @return {string}
* 'probably', 'maybe', or '' (empty string)
*/
Html5.nativeSourceHandler.canPlayType = function (type) {
// IE9 on Windows 7 without MediaPlayer throws an error here
// https://github.com/videojs/video.js/issues/519
try {
return Html5.TEST_VID.canPlayType(type);
} catch (e) {
return '';
}
};
/**
* Check if the media element can handle a source natively.
*
* @param {Tech~SourceObject} source
* The source object
*
* @param {Object} [options]
* Options to be passed to the tech.
*
* @return {string}
* 'probably', 'maybe', or '' (empty string).
*/
Html5.nativeSourceHandler.canHandleSource = function (source, options) {
// If a type was provided we should rely on that
if (source.type) {
return Html5.nativeSourceHandler.canPlayType(source.type);
// If no type, fall back to checking 'video/[EXTENSION]'
} else if (source.src) {
var ext = Url.getFileExtension(source.src);
return Html5.nativeSourceHandler.canPlayType('video/' + ext);
}
return '';
};
/**
* Pass the source to the native media element.
*
* @param {Tech~SourceObject} source
* The source object
*
* @param {Html5} tech
* The instance of the Html5 tech
*
* @param {Object} [options]
* The options to pass to the source
*/
Html5.nativeSourceHandler.handleSource = function (source, tech, options) {
tech.setSrc(source.src);
};
/**
* A noop for the native dispose function, as cleanup is not needed.
*/
Html5.nativeSourceHandler.dispose = function () {};
// Register the native source handler
Html5.registerSourceHandler(Html5.nativeSourceHandler);
_component2['default'].registerComponent('Html5', Html5);
_tech2['default'].registerTech('Html5', Html5);
exports['default'] = Html5;
/***/ }),
/***/ "./node_modules/video.js/es5/tech/loader.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _tech = __webpack_require__("./node_modules/video.js/es5/tech/tech.js");
var _tech2 = _interopRequireDefault(_tech);
var _toTitleCase = __webpack_require__("./node_modules/video.js/es5/utils/to-title-case.js");
var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file loader.js
*/
/**
* The `MediaLoader` is the `Component` that decides which playback technology to load
* when a player is initialized.
*
* @extends Component
*/
var MediaLoader = function (_Component) {
_inherits(MediaLoader, _Component);
/**
* Create an instance of this class.
*
* @param {Player} player
* The `Player` that this class should attach to.
*
* @param {Object} [options]
* The key/value stroe of player options.
*
* @param {Component~ReadyCallback} [ready]
* The function that is run when this component is ready.
*/
function MediaLoader(player, options, ready) {
_classCallCheck(this, MediaLoader);
// If there are no sources when the player is initialized,
// load the first supported playback technology.
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options, ready));
if (!options.playerOptions.sources || options.playerOptions.sources.length === 0) {
for (var i = 0, j = options.playerOptions.techOrder; i < j.length; i++) {
var techName = (0, _toTitleCase2['default'])(j[i]);
var tech = _tech2['default'].getTech(techName);
// Support old behavior of techs being registered as components.
// Remove once that deprecated behavior is removed.
if (!techName) {
tech = _component2['default'].getComponent(techName);
}
// Check if the browser supports this technology
if (tech && tech.isSupported()) {
player.loadTech_(techName);
break;
}
}
} else {
// Loop through playback technologies (HTML5, Flash) and check for support.
// Then load the best source.
// A few assumptions here:
// All playback technologies respect preload false.
player.src(options.playerOptions.sources);
}
return _this;
}
return MediaLoader;
}(_component2['default']);
_component2['default'].registerComponent('MediaLoader', MediaLoader);
exports['default'] = MediaLoader;
/***/ }),
/***/ "./node_modules/video.js/es5/tech/tech.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _htmlTrackElement = __webpack_require__("./node_modules/video.js/es5/tracks/html-track-element.js");
var _htmlTrackElement2 = _interopRequireDefault(_htmlTrackElement);
var _htmlTrackElementList = __webpack_require__("./node_modules/video.js/es5/tracks/html-track-element-list.js");
var _htmlTrackElementList2 = _interopRequireDefault(_htmlTrackElementList);
var _mergeOptions = __webpack_require__("./node_modules/video.js/es5/utils/merge-options.js");
var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
var _textTrack = __webpack_require__("./node_modules/video.js/es5/tracks/text-track.js");
var _textTrack2 = _interopRequireDefault(_textTrack);
var _textTrackList = __webpack_require__("./node_modules/video.js/es5/tracks/text-track-list.js");
var _textTrackList2 = _interopRequireDefault(_textTrackList);
var _videoTrackList = __webpack_require__("./node_modules/video.js/es5/tracks/video-track-list.js");
var _videoTrackList2 = _interopRequireDefault(_videoTrackList);
var _audioTrackList = __webpack_require__("./node_modules/video.js/es5/tracks/audio-track-list.js");
var _audioTrackList2 = _interopRequireDefault(_audioTrackList);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
var _timeRanges = __webpack_require__("./node_modules/video.js/es5/utils/time-ranges.js");
var _buffer = __webpack_require__("./node_modules/video.js/es5/utils/buffer.js");
var _mediaError = __webpack_require__("./node_modules/video.js/es5/media-error.js");
var _mediaError2 = _interopRequireDefault(_mediaError);
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file tech.js
*/
/**
* An Object containing a structure like: `{src: 'url', type: 'mimetype'}` or string
* that just contains the src url alone.
* * `var SourceObject = {src: 'http://ex.com/video.mp4', type: 'video/mp4'};`
* `var SourceString = 'http://example.com/some-video.mp4';`
*
* @typedef {Object|string} Tech~SourceObject
*
* @property {string} src
* The url to the source
*
* @property {string} type
* The mime type of the source
*/
/**
* A function used by {@link Tech} to create a new {@link TextTrack}.
*
* @param {Tech} self
* An instance of the Tech class.
*
* @param {string} kind
* `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata)
*
* @param {string} [label]
* Label to identify the text track
*
* @param {string} [language]
* Two letter language abbreviation
*
* @param {Object} [options={}]
* An object with additional text track options
*
* @return {TextTrack}
* The text track that was created.
*/
function createTrackHelper(self, kind, label, language) {
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var tracks = self.textTracks();
options.kind = kind;
if (label) {
options.label = label;
}
if (language) {
options.language = language;
}
options.tech = self;
var track = new _textTrack2['default'](options);
tracks.addTrack_(track);
return track;
}
/**
* This is the base class for media playback technology controllers, such as
* {@link Flash} and {@link HTML5}
*
* @extends Component
*/
var Tech = function (_Component) {
_inherits(Tech, _Component);
/**
* Create an instance of this Tech.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} ready
* Callback function to call when the `HTML5` Tech is ready.
*/
function Tech() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var ready = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
_classCallCheck(this, Tech);
// we don't want the tech to report user activity automatically.
// This is done manually in addControlsListeners
options.reportTouchActivity = false;
// keep track of whether the current source has played at all to
// implement a very limited played()
var _this = _possibleConstructorReturn(this, _Component.call(this, null, options, ready));
_this.hasStarted_ = false;
_this.on('playing', function () {
this.hasStarted_ = true;
});
_this.on('loadstart', function () {
this.hasStarted_ = false;
});
_this.textTracks_ = options.textTracks;
_this.videoTracks_ = options.videoTracks;
_this.audioTracks_ = options.audioTracks;
// Manually track progress in cases where the browser/flash player doesn't report it.
if (!_this.featuresProgressEvents) {
_this.manualProgressOn();
}
// Manually track timeupdates in cases where the browser/flash player doesn't report it.
if (!_this.featuresTimeupdateEvents) {
_this.manualTimeUpdatesOn();
}
['Text', 'Audio', 'Video'].forEach(function (track) {
if (options['native' + track + 'Tracks'] === false) {
_this['featuresNative' + track + 'Tracks'] = false;
}
});
if (options.nativeCaptions === false) {
_this.featuresNativeTextTracks = false;
}
if (!_this.featuresNativeTextTracks) {
_this.emulateTextTracks();
}
_this.autoRemoteTextTracks_ = new _textTrackList2['default']();
_this.initTextTrackListeners();
_this.initTrackListeners();
// Turn on component tap events only if not using native controls
if (!options.nativeControlsForTouch) {
_this.emitTapEvents();
}
if (_this.constructor) {
_this.name_ = _this.constructor.name || 'Unknown Tech';
}
return _this;
}
/* Fallbacks for unsupported event types
================================================================================ */
/**
* Polyfill the `progress` event for browsers that don't support it natively.
*
* @see {@link Tech#trackProgress}
*/
Tech.prototype.manualProgressOn = function manualProgressOn() {
this.on('durationchange', this.onDurationChange);
this.manualProgress = true;
// Trigger progress watching when a source begins loading
this.one('ready', this.trackProgress);
};
/**
* Turn off the polyfill for `progress` events that was created in
* {@link Tech#manualProgressOn}
*/
Tech.prototype.manualProgressOff = function manualProgressOff() {
this.manualProgress = false;
this.stopTrackingProgress();
this.off('durationchange', this.onDurationChange);
};
/**
* This is used to trigger a `progress` event when the buffered percent changes. It
* sets an interval function that will be called every 500 milliseconds to check if the
* buffer end percent has changed.
*
* > This function is called by {@link Tech#manualProgressOn}
*
* @param {EventTarget~Event} event
* The `ready` event that caused this to run.
*
* @listens Tech#ready
* @fires Tech#progress
*/
Tech.prototype.trackProgress = function trackProgress(event) {
this.stopTrackingProgress();
this.progressInterval = this.setInterval(Fn.bind(this, function () {
// Don't trigger unless buffered amount is greater than last time
var numBufferedPercent = this.bufferedPercent();
if (this.bufferedPercent_ !== numBufferedPercent) {
/**
* See {@link Player#progress}
*
* @event Tech#progress
* @type {EventTarget~Event}
*/
this.trigger('progress');
}
this.bufferedPercent_ = numBufferedPercent;
if (numBufferedPercent === 1) {
this.stopTrackingProgress();
}
}), 500);
};
/**
* Update our internal duration on a `durationchange` event by calling
* {@link Tech#duration}.
*
* @param {EventTarget~Event} event
* The `durationchange` event that caused this to run.
*
* @listens Tech#durationchange
*/
Tech.prototype.onDurationChange = function onDurationChange(event) {
this.duration_ = this.duration();
};
/**
* Get and create a `TimeRange` object for buffering.
*
* @return {TimeRange}
* The time range object that was created.
*/
Tech.prototype.buffered = function buffered() {
return (0, _timeRanges.createTimeRange)(0, 0);
};
/**
* Get the percentage of the current video that is currently buffered.
*
* @return {number}
* A number from 0 to 1 that represents the decimal percentage of the
* video that is buffered.
*
*/
Tech.prototype.bufferedPercent = function bufferedPercent() {
return (0, _buffer.bufferedPercent)(this.buffered(), this.duration_);
};
/**
* Turn off the polyfill for `progress` events that was created in
* {@link Tech#manualProgressOn}
* Stop manually tracking progress events by clearing the interval that was set in
* {@link Tech#trackProgress}.
*/
Tech.prototype.stopTrackingProgress = function stopTrackingProgress() {
this.clearInterval(this.progressInterval);
};
/**
* Polyfill the `timeupdate` event for browsers that don't support it.
*
* @see {@link Tech#trackCurrentTime}
*/
Tech.prototype.manualTimeUpdatesOn = function manualTimeUpdatesOn() {
this.manualTimeUpdates = true;
this.on('play', this.trackCurrentTime);
this.on('pause', this.stopTrackingCurrentTime);
};
/**
* Turn off the polyfill for `timeupdate` events that was created in
* {@link Tech#manualTimeUpdatesOn}
*/
Tech.prototype.manualTimeUpdatesOff = function manualTimeUpdatesOff() {
this.manualTimeUpdates = false;
this.stopTrackingCurrentTime();
this.off('play', this.trackCurrentTime);
this.off('pause', this.stopTrackingCurrentTime);
};
/**
* Sets up an interval function to track current time and trigger `timeupdate` every
* 250 milliseconds.
*
* @listens Tech#play
* @triggers Tech#timeupdate
*/
Tech.prototype.trackCurrentTime = function trackCurrentTime() {
if (this.currentTimeInterval) {
this.stopTrackingCurrentTime();
}
this.currentTimeInterval = this.setInterval(function () {
/**
* Triggered at an interval of 250ms to indicated that time is passing in the video.
*
* @event Tech#timeupdate
* @type {EventTarget~Event}
*/
this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
// 42 = 24 fps // 250 is what Webkit uses // FF uses 15
}, 250);
};
/**
* Stop the interval function created in {@link Tech#trackCurrentTime} so that the
* `timeupdate` event is no longer triggered.
*
* @listens {Tech#pause}
*/
Tech.prototype.stopTrackingCurrentTime = function stopTrackingCurrentTime() {
this.clearInterval(this.currentTimeInterval);
// #1002 - if the video ends right before the next timeupdate would happen,
// the progress bar won't make it all the way to the end
this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
};
/**
* Turn off all event polyfills, clear the `Tech`s {@link AudioTrackList},
* {@link VideoTrackList}, and {@link TextTrackList}, and dispose of this Tech.
*
* @fires Component#dispose
*/
Tech.prototype.dispose = function dispose() {
// clear out all tracks because we can't reuse them between techs
this.clearTracks(['audio', 'video', 'text']);
// Turn off any manual progress or timeupdate tracking
if (this.manualProgress) {
this.manualProgressOff();
}
if (this.manualTimeUpdates) {
this.manualTimeUpdatesOff();
}
_Component.prototype.dispose.call(this);
};
/**
* Clear out a single `TrackList` or an array of `TrackLists` given their names.
*
* > Note: Techs without source handlers should call this between sources for `video`
* & `audio` tracks. You don't want to use them between tracks!
*
* @param {string[]|string} types
* TrackList names to clear, valid names are `video`, `audio`, and
* `text`.
*/
Tech.prototype.clearTracks = function clearTracks(types) {
var _this2 = this;
types = [].concat(types);
// clear out all tracks because we can't reuse them between techs
types.forEach(function (type) {
var list = _this2[type + 'Tracks']() || [];
var i = list.length;
while (i--) {
var track = list[i];
if (type === 'text') {
_this2.removeRemoteTextTrack(track);
}
list.removeTrack_(track);
}
});
};
/**
* Remove any TextTracks added via addRemoteTextTrack that are
* flagged for automatic garbage collection
*/
Tech.prototype.cleanupAutoTextTracks = function cleanupAutoTextTracks() {
var list = this.autoRemoteTextTracks_ || [];
var i = list.length;
while (i--) {
var track = list[i];
this.removeRemoteTextTrack(track);
}
};
/**
* Reset the tech, which will removes all sources and reset the internal readyState.
*
* @abstract
*/
Tech.prototype.reset = function reset() {};
/**
* Get or set an error on the Tech.
*
* @param {MediaError} [err]
* Error to set on the Tech
*
* @return {MediaError|null}
* The current error object on the tech, or null if there isn't one.
*/
Tech.prototype.error = function error(err) {
if (err !== undefined) {
this.error_ = new _mediaError2['default'](err);
this.trigger('error');
}
return this.error_;
};
/**
* Returns the `TimeRange`s that have been played through for the current source.
*
* > NOTE: This implementation is incomplete. It does not track the played `TimeRange`.
* It only checks wether the source has played at all or not.
*
* @return {TimeRange}
* - A single time range if this video has played
* - An empty set of ranges if not.
*/
Tech.prototype.played = function played() {
if (this.hasStarted_) {
return (0, _timeRanges.createTimeRange)(0, 0);
}
return (0, _timeRanges.createTimeRange)();
};
/**
* Causes a manual time update to occur if {@link Tech#manualTimeUpdatesOn} was
* previously called.
*
* @fires Tech#timeupdate
*/
Tech.prototype.setCurrentTime = function setCurrentTime() {
// improve the accuracy of manual timeupdates
if (this.manualTimeUpdates) {
/**
* A manual `timeupdate` event.
*
* @event Tech#timeupdate
* @type {EventTarget~Event}
*/
this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
}
};
/**
* Turn on listeners for {@link TextTrackList} events. This adds
* {@link EventTarget~EventListeners} for `texttrackchange`, `addtrack` and
* `removetrack`.
*
* @fires Tech#texttrackchange
*/
Tech.prototype.initTextTrackListeners = function initTextTrackListeners() {
var textTrackListChanges = Fn.bind(this, function () {
/**
* Triggered when tracks are added or removed on the Tech {@link TextTrackList}
*
* @event Tech#texttrackchange
* @type {EventTarget~Event}
*/
this.trigger('texttrackchange');
});
var tracks = this.textTracks();
if (!tracks) {
return;
}
tracks.addEventListener('removetrack', textTrackListChanges);
tracks.addEventListener('addtrack', textTrackListChanges);
this.on('dispose', Fn.bind(this, function () {
tracks.removeEventListener('removetrack', textTrackListChanges);
tracks.removeEventListener('addtrack', textTrackListChanges);
}));
};
/**
* Turn on listeners for {@link VideoTrackList} and {@link {AudioTrackList} events.
* This adds {@link EventTarget~EventListeners} for `addtrack`, and `removetrack`.
*
* @fires Tech#audiotrackchange
* @fires Tech#videotrackchange
*/
Tech.prototype.initTrackListeners = function initTrackListeners() {
var _this3 = this;
var trackTypes = ['video', 'audio'];
trackTypes.forEach(function (type) {
/**
* Triggered when tracks are added or removed on the Tech {@link AudioTrackList}
*
* @event Tech#audiotrackchange
* @type {EventTarget~Event}
*/
/**
* Triggered when tracks are added or removed on the Tech {@link VideoTrackList}
*
* @event Tech#videotrackchange
* @type {EventTarget~Event}
*/
var trackListChanges = function trackListChanges() {
_this3.trigger(type + 'trackchange');
};
var tracks = _this3[type + 'Tracks']();
tracks.addEventListener('removetrack', trackListChanges);
tracks.addEventListener('addtrack', trackListChanges);
_this3.on('dispose', function () {
tracks.removeEventListener('removetrack', trackListChanges);
tracks.removeEventListener('addtrack', trackListChanges);
});
});
};
/**
* Emulate TextTracks using vtt.js if necessary
*
* @fires Tech#vttjsloaded
* @fires Tech#vttjserror
*/
Tech.prototype.addWebVttScript_ = function addWebVttScript_() {
var _this4 = this;
if (_window2['default'].WebVTT) {
return;
}
// Initially, Tech.el_ is a child of a dummy-div wait until the Component system
// signals that the Tech is ready at which point Tech.el_ is part of the DOM
// before inserting the WebVTT script
if (_document2['default'].body.contains(this.el())) {
var vtt = __webpack_require__("./node_modules/videojs-vtt.js/lib/browser-index.js");
// load via require if available and vtt.js script location was not passed in
// as an option. novtt builds will turn the above require call into an empty object
// which will cause this if check to always fail.
if (!this.options_['vtt.js'] && (0, _obj.isPlain)(vtt) && Object.keys(vtt).length > 0) {
this.trigger('vttjsloaded');
return;
}
// load vtt.js via the script location option or the cdn of no location was
// passed in
var script = _document2['default'].createElement('script');
script.src = this.options_['vtt.js'] || 'https://vjs.zencdn.net/vttjs/0.12.3/vtt.min.js';
script.onload = function () {
/**
* Fired when vtt.js is loaded.
*
* @event Tech#vttjsloaded
* @type {EventTarget~Event}
*/
_this4.trigger('vttjsloaded');
};
script.onerror = function () {
/**
* Fired when vtt.js was not loaded due to an error
*
* @event Tech#vttjsloaded
* @type {EventTarget~Event}
*/
_this4.trigger('vttjserror');
};
this.on('dispose', function () {
script.onload = null;
script.onerror = null;
});
// but have not loaded yet and we set it to true before the inject so that
// we don't overwrite the injected window.WebVTT if it loads right away
_window2['default'].WebVTT = true;
this.el().parentNode.appendChild(script);
} else {
this.ready(this.addWebVttScript_);
}
};
/**
* Emulate texttracks
*
* @method emulateTextTracks
*/
Tech.prototype.emulateTextTracks = function emulateTextTracks() {
var _this5 = this;
var tracks = this.textTracks();
if (!tracks) {
return;
}
var remoteTracks = this.remoteTextTracks();
var handleAddTrack = function handleAddTrack(e) {
return tracks.addTrack_(e.track);
};
var handleRemoveTrack = function handleRemoveTrack(e) {
return tracks.removeTrack_(e.track);
};
remoteTracks.on('addtrack', handleAddTrack);
remoteTracks.on('removetrack', handleRemoveTrack);
this.addWebVttScript_();
var updateDisplay = function updateDisplay() {
return _this5.trigger('texttrackchange');
};
var textTracksChanges = function textTracksChanges() {
updateDisplay();
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
track.removeEventListener('cuechange', updateDisplay);
if (track.mode === 'showing') {
track.addEventListener('cuechange', updateDisplay);
}
}
};
textTracksChanges();
tracks.addEventListener('change', textTracksChanges);
tracks.addEventListener('addtrack', textTracksChanges);
tracks.addEventListener('removetrack', textTracksChanges);
this.on('dispose', function () {
remoteTracks.off('addtrack', handleAddTrack);
remoteTracks.off('removetrack', handleRemoveTrack);
tracks.removeEventListener('change', textTracksChanges);
tracks.removeEventListener('addtrack', textTracksChanges);
tracks.removeEventListener('removetrack', textTracksChanges);
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
track.removeEventListener('cuechange', updateDisplay);
}
});
};
/**
* Get the `Tech`s {@link VideoTrackList}.
*
* @return {VideoTrackList}
* The video track list that the Tech is currently using.
*/
Tech.prototype.videoTracks = function videoTracks() {
this.videoTracks_ = this.videoTracks_ || new _videoTrackList2['default']();
return this.videoTracks_;
};
/**
* Get the `Tech`s {@link AudioTrackList}.
*
* @return {AudioTrackList}
* The audio track list that the Tech is currently using.
*/
Tech.prototype.audioTracks = function audioTracks() {
this.audioTracks_ = this.audioTracks_ || new _audioTrackList2['default']();
return this.audioTracks_;
};
/**
* Get the `Tech`s {@link TextTrackList}.
*
* @return {TextTrackList}
* The text track list that the Tech is currently using.
*/
Tech.prototype.textTracks = function textTracks() {
this.textTracks_ = this.textTracks_ || new _textTrackList2['default']();
return this.textTracks_;
};
/**
* Get the `Tech`s remote {@link TextTrackList}, which is created from elements
* that were added to the DOM.
*
* @return {TextTrackList}
* The remote text track list that the Tech is currently using.
*/
Tech.prototype.remoteTextTracks = function remoteTextTracks() {
this.remoteTextTracks_ = this.remoteTextTracks_ || new _textTrackList2['default']();
return this.remoteTextTracks_;
};
/**
* Get The `Tech`s {HTMLTrackElementList}, which are the elements in the DOM that are
* being used as TextTracks.
*
* @return {HTMLTrackElementList}
* The current HTML track elements that exist for the tech.
*/
Tech.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
this.remoteTextTrackEls_ = this.remoteTextTrackEls_ || new _htmlTrackElementList2['default']();
return this.remoteTextTrackEls_;
};
/**
* Create and returns a remote {@link TextTrack} object.
*
* @param {string} kind
* `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata)
*
* @param {string} [label]
* Label to identify the text track
*
* @param {string} [language]
* Two letter language abbreviation
*
* @return {TextTrack}
* The TextTrack that gets created.
*/
Tech.prototype.addTextTrack = function addTextTrack(kind, label, language) {
if (!kind) {
throw new Error('TextTrack kind is required but was not provided');
}
return createTrackHelper(this, kind, label, language);
};
/**
* Create an emulated TextTrack for use by addRemoteTextTrack
*
* This is intended to be overridden by classes that inherit from
* Tech in order to create native or custom TextTracks.
*
* @param {Object} options
* The object should contain the options to initialize the TextTrack with.
*
* @param {string} [options.kind]
* `TextTrack` kind (subtitles, captions, descriptions, chapters, or metadata).
*
* @param {string} [options.label].
* Label to identify the text track
*
* @param {string} [options.language]
* Two letter language abbreviation.
*
* @return {HTMLTrackElement}
* The track element that gets created.
*/
Tech.prototype.createRemoteTextTrack = function createRemoteTextTrack(options) {
var track = (0, _mergeOptions2['default'])(options, {
tech: this
});
return new _htmlTrackElement2['default'](track);
};
/**
* Creates a remote text track object and returns an html track element.
*
* > Note: This can be an emulated {@link HTMLTrackElement} or a native one.
*
* @param {Object} options
* See {@link Tech#createRemoteTextTrack} for more detailed properties.
*
* @param {boolean} [manualCleanup=true]
* - When false: the TextTrack will be automatically removed from the video
* element whenever the source changes
* - When True: The TextTrack will have to be cleaned up manually
*
* @return {HTMLTrackElement}
* An Html Track Element.
*
* @deprecated The default functionality for this function will be equivalent
* to "manualCleanup=false" in the future. The manualCleanup parameter will
* also be removed.
*/
Tech.prototype.addRemoteTextTrack = function addRemoteTextTrack() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var manualCleanup = arguments[1];
var htmlTrackElement = this.createRemoteTextTrack(options);
if (manualCleanup !== true && manualCleanup !== false) {
// deprecation warning
_log2['default'].warn('Calling addRemoteTextTrack without explicitly setting the "manualCleanup" parameter to `true` is deprecated and default to `false` in future version of video.js');
manualCleanup = true;
}
// store HTMLTrackElement and TextTrack to remote list
this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
this.remoteTextTracks().addTrack_(htmlTrackElement.track);
if (manualCleanup !== true) {
// create the TextTrackList if it doesn't exist
this.autoRemoteTextTracks_.addTrack_(htmlTrackElement.track);
}
return htmlTrackElement;
};
/**
* Remove a remote text track from the remote `TextTrackList`.
*
* @param {TextTrack} track
* `TextTrack` to remove from the `TextTrackList`
*/
Tech.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
// remove HTMLTrackElement and TextTrack from remote list
this.remoteTextTrackEls().removeTrackElement_(trackElement);
this.remoteTextTracks().removeTrack_(track);
this.autoRemoteTextTracks_.removeTrack_(track);
};
/**
* A method to set a poster from a `Tech`.
*
* @abstract
*/
Tech.prototype.setPoster = function setPoster() {};
/*
* Check if the tech can support the given mime-type.
*
* The base tech does not support any type, but source handlers might
* overwrite this.
*
* @param {string} type
* The mimetype to check for support
*
* @return {string}
* 'probably', 'maybe', or empty string
*
* @see [Spec]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType}
*
* @abstract
*/
Tech.prototype.canPlayType = function canPlayType() {
return '';
};
/*
* Return whether the argument is a Tech or not.
* Can be passed either a Class like `Html5` or a instance like `player.tech_`
*
* @param {Object} component
* The item to check
*
* @return {boolean}
* Whether it is a tech or not
* - True if it is a tech
* - False if it is not
*/
Tech.isTech = function isTech(component) {
return component.prototype instanceof Tech || component instanceof Tech || component === Tech;
};
/**
* Registers a `Tech` into a shared list for videojs.
*
* @param {string} name
* Name of the `Tech` to register.
*
* @param {Object} tech
* The `Tech` class to register.
*/
Tech.registerTech = function registerTech(name, tech) {
if (!Tech.techs_) {
Tech.techs_ = {};
}
if (!Tech.isTech(tech)) {
throw new Error('Tech ' + name + ' must be a Tech');
}
Tech.techs_[name] = tech;
return tech;
};
/**
* Get a `Tech` from the shared list by name.
*
* @param {string} name
* Name of the component to get
*
* @return {Tech|undefined}
* The `Tech` or undefined if there was no tech with the name requsted.
*/
Tech.getTech = function getTech(name) {
if (Tech.techs_ && Tech.techs_[name]) {
return Tech.techs_[name];
}
if (_window2['default'] && _window2['default'].videojs && _window2['default'].videojs[name]) {
_log2['default'].warn('The ' + name + ' tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)');
return _window2['default'].videojs[name];
}
};
return Tech;
}(_component2['default']);
/**
* List of associated text tracks.
*
* @type {TextTrackList}
* @private
*/
Tech.prototype.textTracks_; // eslint-disable-line
/**
* List of associated audio tracks.
*
* @type {AudioTrackList}
* @private
*/
Tech.prototype.audioTracks_; // eslint-disable-line
/**
* List of associated video tracks.
*
* @type {VideoTrackList}
* @private
*/
Tech.prototype.videoTracks_; // eslint-disable-line
/**
* Boolean indicating wether the `Tech` supports volume control.
*
* @type {boolean}
* @default
*/
Tech.prototype.featuresVolumeControl = true;
/**
* Boolean indicating wether the `Tech` support fullscreen resize control.
* Resizing plugins using request fullscreen reloads the plugin
*
* @type {boolean}
* @default
*/
Tech.prototype.featuresFullscreenResize = false;
/**
* Boolean indicating wether the `Tech` supports changing the speed at which the video
* plays. Examples:
* - Set player to play 2x (twice) as fast
* - Set player to play 0.5x (half) as fast
*
* @type {boolean}
* @default
*/
Tech.prototype.featuresPlaybackRate = false;
/**
* Boolean indicating wether the `Tech` supports the `progress` event. This is currently
* not triggered by video-js-swf. This will be used to determine if
* {@link Tech#manualProgressOn} should be called.
*
* @type {boolean}
* @default
*/
Tech.prototype.featuresProgressEvents = false;
/**
* Boolean indicating wether the `Tech` supports the `timeupdate` event. This is currently
* not triggered by video-js-swf. This will be used to determine if
* {@link Tech#manualTimeUpdates} should be called.
*
* @type {boolean}
* @default
*/
Tech.prototype.featuresTimeupdateEvents = false;
/**
* Boolean indicating wether the `Tech` supports the native `TextTrack`s.
* This will help us integrate with native `TextTrack`s if the browser supports them.
*
* @type {boolean}
* @default
*/
Tech.prototype.featuresNativeTextTracks = false;
/**
* A functional mixin for techs that want to use the Source Handler pattern.
* Source handlers are scripts for handling specific formats.
* The source handler pattern is used for adaptive formats (HLS, DASH) that
* manually load video data and feed it into a Source Buffer (Media Source Extensions)
* Example: `Tech.withSourceHandlers.call(MyTech);`
*
* @param {Tech} _Tech
* The tech to add source handler functions to.
*
* @mixes Tech~SourceHandlerAdditions
*/
Tech.withSourceHandlers = function (_Tech) {
/**
* Register a source handler
*
* @param {Function} handler
* The source handler class
*
* @param {number} [index]
* Register it at the following index
*/
_Tech.registerSourceHandler = function (handler, index) {
var handlers = _Tech.sourceHandlers;
if (!handlers) {
handlers = _Tech.sourceHandlers = [];
}
if (index === undefined) {
// add to the end of the list
index = handlers.length;
}
handlers.splice(index, 0, handler);
};
/**
* Check if the tech can support the given type. Also checks the
* Techs sourceHandlers.
*
* @param {string} type
* The mimetype to check.
*
* @return {string}
* 'probably', 'maybe', or '' (empty string)
*/
_Tech.canPlayType = function (type) {
var handlers = _Tech.sourceHandlers || [];
var can = void 0;
for (var i = 0; i < handlers.length; i++) {
can = handlers[i].canPlayType(type);
if (can) {
return can;
}
}
return '';
};
/**
* Returns the first source handler that supports the source.
*
* TODO: Answer question: should 'probably' be prioritized over 'maybe'
*
* @param {Tech~SourceObject} source
* The source object
*
* @param {Object} options
* The options passed to the tech
*
* @return {SourceHandler|null}
* The first source handler that supports the source or null if
* no SourceHandler supports the source
*/
_Tech.selectSourceHandler = function (source, options) {
var handlers = _Tech.sourceHandlers || [];
var can = void 0;
for (var i = 0; i < handlers.length; i++) {
can = handlers[i].canHandleSource(source, options);
if (can) {
return handlers[i];
}
}
return null;
};
/**
* Check if the tech can support the given source.
*
* @param {Tech~SourceObject} srcObj
* The source object
*
* @param {Object} options
* The options passed to the tech
*
* @return {string}
* 'probably', 'maybe', or '' (empty string)
*/
_Tech.canPlaySource = function (srcObj, options) {
var sh = _Tech.selectSourceHandler(srcObj, options);
if (sh) {
return sh.canHandleSource(srcObj, options);
}
return '';
};
/**
* When using a source handler, prefer its implementation of
* any function normally provided by the tech.
*/
var deferrable = ['seekable', 'duration'];
/**
* A wrapper around {@link Tech#seekable} that will call a `SourceHandler`s seekable
* function if it exists, with a fallback to the Techs seekable function.
*
* @method _Tech.seekable
*/
/**
* A wrapper around {@link Tech#duration} that will call a `SourceHandler`s duration
* function if it exists, otherwise it will fallback to the techs duration function.
*
* @method _Tech.duration
*/
deferrable.forEach(function (fnName) {
var originalFn = this[fnName];
if (typeof originalFn !== 'function') {
return;
}
this[fnName] = function () {
if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments);
}
return originalFn.apply(this, arguments);
};
}, _Tech.prototype);
/**
* Create a function for setting the source using a source object
* and source handlers.
* Should never be called unless a source handler was found.
*
* @param {Tech~SourceObject} source
* A source object with src and type keys
*
* @return {Tech}
* Returns itself; this method is chainable
*/
_Tech.prototype.setSource = function (source) {
var sh = _Tech.selectSourceHandler(source, this.options_);
if (!sh) {
// Fall back to a native source hander when unsupported sources are
// deliberately set
if (_Tech.nativeSourceHandler) {
sh = _Tech.nativeSourceHandler;
} else {
_log2['default'].error('No source hander found for the current source.');
}
}
// Dispose any existing source handler
this.disposeSourceHandler();
this.off('dispose', this.disposeSourceHandler);
if (sh !== _Tech.nativeSourceHandler) {
this.currentSource_ = source;
// Catch if someone replaced the src without calling setSource.
// If they do, set currentSource_ to null and dispose our source handler.
this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
this.one(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
}
this.sourceHandler_ = sh.handleSource(source, this, this.options_);
this.on('dispose', this.disposeSourceHandler);
return this;
};
/**
* Called once for the first loadstart of a video.
*
* @listens Tech#loadstart
*/
_Tech.prototype.firstLoadStartListener_ = function () {
this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
};
// On successive loadstarts when setSource has not been called again
/**
* Called after the first loadstart for a video occurs.
*
* @listens Tech#loadstart
*/
_Tech.prototype.successiveLoadStartListener_ = function () {
this.disposeSourceHandler();
this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
};
/**
* Clean up any existing SourceHandlers and listeners when the Tech is disposed.
*
* @listens Tech#dispose
*/
_Tech.prototype.disposeSourceHandler = function () {
// if we have a source and get another one
// then we are loading something new
// than clear all of our current tracks
if (this.currentSource_) {
this.clearTracks(['audio', 'video']);
this.currentSource_ = null;
}
// always clean up auto-text tracks
this.cleanupAutoTextTracks();
if (this.sourceHandler_) {
this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
if (this.sourceHandler_.dispose) {
this.sourceHandler_.dispose();
}
this.sourceHandler_ = null;
}
};
};
_component2['default'].registerComponent('Tech', Tech);
// Old name for Tech
// @deprecated
_component2['default'].registerComponent('MediaTechController', Tech);
Tech.registerTech('Tech', Tech);
exports['default'] = Tech;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/audio-track-list.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _trackList = __webpack_require__("./node_modules/video.js/es5/tracks/track-list.js");
var _trackList2 = _interopRequireDefault(_trackList);
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file audio-track-list.js
*/
/**
* Anywhere we call this function we diverge from the spec
* as we only support one enabled audiotrack at a time
*
* @param {AudioTrackList} list
* list to work on
*
* @param {AudioTrack} track
* The track to skip
*
* @private
*/
var disableOthers = function disableOthers(list, track) {
for (var i = 0; i < list.length; i++) {
if (track.id === list[i].id) {
continue;
}
// another audio track is enabled, disable it
list[i].enabled = false;
}
};
/**
* The current list of {@link AudioTrack} for a media file.
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist}
* @extends TrackList
*/
var AudioTrackList = function (_TrackList) {
_inherits(AudioTrackList, _TrackList);
/**
* Create an instance of this class.
*
* @param {AudioTrack[]} [tracks=[]]
* A list of `AudioTrack` to instantiate the list with.
*/
function AudioTrackList() {
var _this, _ret;
var tracks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, AudioTrackList);
var list = void 0;
// make sure only 1 track is enabled
// sorted from last index to first index
for (var i = tracks.length - 1; i >= 0; i--) {
if (tracks[i].enabled) {
disableOthers(tracks, tracks[i]);
break;
}
}
// IE8 forces us to implement inheritance ourselves
// as it does not support Object.defineProperty properly
if (browser.IS_IE8) {
list = _document2['default'].createElement('custom');
for (var prop in _trackList2['default'].prototype) {
if (prop !== 'constructor') {
list[prop] = _trackList2['default'].prototype[prop];
}
}
for (var _prop in AudioTrackList.prototype) {
if (_prop !== 'constructor') {
list[_prop] = AudioTrackList.prototype[_prop];
}
}
}
list = (_this = _possibleConstructorReturn(this, _TrackList.call(this, tracks, list)), _this);
list.changing_ = false;
return _ret = list, _possibleConstructorReturn(_this, _ret);
}
/**
* Add an {@link AudioTrack} to the `AudioTrackList`.
*
* @param {AudioTrack} track
* The AudioTrack to add to the list
*
* @fires Track#addtrack
* @private
*/
AudioTrackList.prototype.addTrack_ = function addTrack_(track) {
var _this2 = this;
if (track.enabled) {
disableOthers(this, track);
}
_TrackList.prototype.addTrack_.call(this, track);
// native tracks don't have this
if (!track.addEventListener) {
return;
}
/**
* @listens AudioTrack#enabledchange
* @fires TrackList#change
*/
track.addEventListener('enabledchange', function () {
// when we are disabling other tracks (since we don't support
// more than one track at a time) we will set changing_
// to true so that we don't trigger additional change events
if (_this2.changing_) {
return;
}
_this2.changing_ = true;
disableOthers(_this2, track);
_this2.changing_ = false;
_this2.trigger('change');
});
};
/**
* Add an {@link AudioTrack} to the `AudioTrackList`.
*
* @param {AudioTrack} track
* The AudioTrack to add to the list
*
* @fires Track#addtrack
*/
AudioTrackList.prototype.addTrack = function addTrack(track) {
this.addTrack_(track);
};
/**
* Remove an {@link AudioTrack} from the `AudioTrackList`.
*
* @param {AudioTrack} track
* The AudioTrack to remove from the list
*
* @fires Track#removetrack
*/
AudioTrackList.prototype.removeTrack = function removeTrack(track) {
_TrackList.prototype.removeTrack_.call(this, track);
};
return AudioTrackList;
}(_trackList2['default']);
exports['default'] = AudioTrackList;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/audio-track.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _trackEnums = __webpack_require__("./node_modules/video.js/es5/tracks/track-enums.js");
var _track = __webpack_require__("./node_modules/video.js/es5/tracks/track.js");
var _track2 = _interopRequireDefault(_track);
var _mergeOptions = __webpack_require__("./node_modules/video.js/es5/utils/merge-options.js");
var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* A representation of a single `AudioTrack`. If it is part of an {@link AudioTrackList}
* only one `AudioTrack` in the list will be enabled at a time.
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack}
* @extends Track
*/
var AudioTrack = function (_Track) {
_inherits(AudioTrack, _Track);
/**
* Create an instance of this class.
*
* @param {Object} [options={}]
* Object of option names and values
*
* @param {AudioTrack~Kind} [options.kind='']
* A valid audio track kind
*
* @param {string} [options.id='vjs_track_' + Guid.newGUID()]
* A unique id for this AudioTrack.
*
* @param {string} [options.label='']
* The menu label for this track.
*
* @param {string} [options.language='']
* A valid two character language code.
*
* @param {boolean} [options.enabled]
* If this track is the one that is currently playing. If this track is part of
* an {@link AudioTrackList}, only one {@link AudioTrack} will be enabled.
*/
function AudioTrack() {
var _this, _ret;
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, AudioTrack);
var settings = (0, _mergeOptions2['default'])(options, {
kind: _trackEnums.AudioTrackKind[options.kind] || ''
});
// on IE8 this will be a document element
// for every other browser this will be a normal object
var track = (_this = _possibleConstructorReturn(this, _Track.call(this, settings)), _this);
var enabled = false;
if (browser.IS_IE8) {
for (var prop in AudioTrack.prototype) {
if (prop !== 'constructor') {
track[prop] = AudioTrack.prototype[prop];
}
}
}
/**
* @member {boolean} enabled
* If this `AudioTrack` is enabled or not. When setting this will
* fire {@link AudioTrack#enabledchange} if the state of enabled is changed.
*
* @fires VideoTrack#selectedchange
*/
Object.defineProperty(track, 'enabled', {
get: function get() {
return enabled;
},
set: function set(newEnabled) {
// an invalid or unchanged value
if (typeof newEnabled !== 'boolean' || newEnabled === enabled) {
return;
}
enabled = newEnabled;
/**
* An event that fires when enabled changes on this track. This allows
* the AudioTrackList that holds this track to act accordingly.
*
* > Note: This is not part of the spec! Native tracks will do
* this internally without an event.
*
* @event AudioTrack#enabledchange
* @type {EventTarget~Event}
*/
this.trigger('enabledchange');
}
});
// if the user sets this track to selected then
// set selected to that true value otherwise
// we keep it false
if (settings.enabled) {
track.enabled = settings.enabled;
}
track.loaded_ = true;
return _ret = track, _possibleConstructorReturn(_this, _ret);
}
return AudioTrack;
}(_track2['default']);
exports['default'] = AudioTrack;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/html-track-element-list.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
* @file html-track-element-list.js
*/
/**
* The current list of {@link HtmlTrackElement}s.
*/
var HtmlTrackElementList = function () {
/**
* Create an instance of this class.
*
* @param {HtmlTrackElement[]} [tracks=[]]
* A list of `HtmlTrackElement` to instantiate the list with.
*/
function HtmlTrackElementList() {
var trackElements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, HtmlTrackElementList);
var list = this; // eslint-disable-line
if (browser.IS_IE8) {
list = _document2['default'].createElement('custom');
for (var prop in HtmlTrackElementList.prototype) {
if (prop !== 'constructor') {
list[prop] = HtmlTrackElementList.prototype[prop];
}
}
}
list.trackElements_ = [];
/**
* @member {number} length
* The current number of `Track`s in the this Trackist.
*/
Object.defineProperty(list, 'length', {
get: function get() {
return this.trackElements_.length;
}
});
for (var i = 0, length = trackElements.length; i < length; i++) {
list.addTrackElement_(trackElements[i]);
}
if (browser.IS_IE8) {
return list;
}
}
/**
* Add an {@link HtmlTrackElement} to the `HtmlTrackElementList`
*
* @param {HtmlTrackElement} trackElement
* The track element to add to the list.
*
* @private
*/
HtmlTrackElementList.prototype.addTrackElement_ = function addTrackElement_(trackElement) {
var index = this.trackElements_.length;
if (!('' + index in this)) {
Object.defineProperty(this, index, {
get: function get() {
return this.trackElements_[index];
}
});
}
// Do not add duplicate elements
if (this.trackElements_.indexOf(trackElement) === -1) {
this.trackElements_.push(trackElement);
}
};
/**
* Get an {@link HtmlTrackElement} from the `HtmlTrackElementList` given an
* {@link TextTrack}.
*
* @param {TextTrack} track
* The track associated with a track element.
*
* @return {HtmlTrackElement|undefined}
* The track element that was found or undefined.
*
* @private
*/
HtmlTrackElementList.prototype.getTrackElementByTrack_ = function getTrackElementByTrack_(track) {
var trackElement_ = void 0;
for (var i = 0, length = this.trackElements_.length; i < length; i++) {
if (track === this.trackElements_[i].track) {
trackElement_ = this.trackElements_[i];
break;
}
}
return trackElement_;
};
/**
* Remove a {@link HtmlTrackElement} from the `HtmlTrackElementList`
*
* @param {HtmlTrackElement} trackElement
* The track element to remove from the list.
*
* @private
*/
HtmlTrackElementList.prototype.removeTrackElement_ = function removeTrackElement_(trackElement) {
for (var i = 0, length = this.trackElements_.length; i < length; i++) {
if (trackElement === this.trackElements_[i]) {
this.trackElements_.splice(i, 1);
break;
}
}
};
return HtmlTrackElementList;
}();
exports['default'] = HtmlTrackElementList;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/html-track-element.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
var _eventTarget = __webpack_require__("./node_modules/video.js/es5/event-target.js");
var _eventTarget2 = _interopRequireDefault(_eventTarget);
var _textTrack = __webpack_require__("./node_modules/video.js/es5/tracks/text-track.js");
var _textTrack2 = _interopRequireDefault(_textTrack);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file html-track-element.js
*/
/**
* @typedef {HTMLTrackElement~ReadyState}
* @enum {number}
*/
var NONE = 0;
var LOADING = 1;
var LOADED = 2;
var ERROR = 3;
/**
* A single track represented in the DOM.
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#htmltrackelement}
* @extends EventTarget
*/
var HTMLTrackElement = function (_EventTarget) {
_inherits(HTMLTrackElement, _EventTarget);
/**
* Create an instance of this class.
*
* @param {Object} options={}
* Object of option names and values
*
* @param {Tech} options.tech
* A reference to the tech that owns this HTMLTrackElement.
*
* @param {TextTrack~Kind} [options.kind='subtitles']
* A valid text track kind.
*
* @param {TextTrack~Mode} [options.mode='disabled']
* A valid text track mode.
*
* @param {string} [options.id='vjs_track_' + Guid.newGUID()]
* A unique id for this TextTrack.
*
* @param {string} [options.label='']
* The menu label for this track.
*
* @param {string} [options.language='']
* A valid two character language code.
*
* @param {string} [options.srclang='']
* A valid two character language code. An alternative, but deprioritized
* vesion of `options.language`
*
* @param {string} [options.src]
* A url to TextTrack cues.
*
* @param {boolean} [options.default]
* If this track should default to on or off.
*/
function HTMLTrackElement() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, HTMLTrackElement);
var _this = _possibleConstructorReturn(this, _EventTarget.call(this));
var readyState = void 0;
var trackElement = _this; // eslint-disable-line
if (browser.IS_IE8) {
trackElement = _document2['default'].createElement('custom');
for (var prop in HTMLTrackElement.prototype) {
if (prop !== 'constructor') {
trackElement[prop] = HTMLTrackElement.prototype[prop];
}
}
}
var track = new _textTrack2['default'](options);
trackElement.kind = track.kind;
trackElement.src = track.src;
trackElement.srclang = track.language;
trackElement.label = track.label;
trackElement['default'] = track['default'];
/**
* @member {HTMLTrackElement~ReadyState} readyState
* The current ready state of the track element.
*/
Object.defineProperty(trackElement, 'readyState', {
get: function get() {
return readyState;
}
});
/**
* @member {TextTrack} track
* The underlying TextTrack object.
*/
Object.defineProperty(trackElement, 'track', {
get: function get() {
return track;
}
});
readyState = NONE;
/**
* @listens TextTrack#loadeddata
* @fires HTMLTrackElement#load
*/
track.addEventListener('loadeddata', function () {
readyState = LOADED;
trackElement.trigger({
type: 'load',
target: trackElement
});
});
if (browser.IS_IE8) {
var _ret;
return _ret = trackElement, _possibleConstructorReturn(_this, _ret);
}
return _this;
}
return HTMLTrackElement;
}(_eventTarget2['default']);
HTMLTrackElement.prototype.allowedEvents_ = {
load: 'load'
};
HTMLTrackElement.NONE = NONE;
HTMLTrackElement.LOADING = LOADING;
HTMLTrackElement.LOADED = LOADED;
HTMLTrackElement.ERROR = ERROR;
exports['default'] = HTMLTrackElement;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/text-track-cue-list.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
* @file text-track-cue-list.js
*/
/**
* @typedef {Object} TextTrackCue
*
* @property {string} id
* The unique id for this text track cue
*
* @property {number} startTime
* The start time for this text track cue
*
* @property {number} endTime
* The end time for this text track cue
*
* @property {boolean} pauseOnExit
* Pause when the end time is reached if true.
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcue}
*/
/**
* A List of TextTrackCues.
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist}
*/
var TextTrackCueList = function () {
/**
* Create an instance of this class..
*
* @param {Array} cues
* A list of cues to be initialized with
*/
function TextTrackCueList(cues) {
_classCallCheck(this, TextTrackCueList);
var list = this; // eslint-disable-line
if (browser.IS_IE8) {
list = _document2['default'].createElement('custom');
for (var prop in TextTrackCueList.prototype) {
if (prop !== 'constructor') {
list[prop] = TextTrackCueList.prototype[prop];
}
}
}
TextTrackCueList.prototype.setCues_.call(list, cues);
/**
* @member {number} length
* The current number of `TextTrackCue`s in the TextTrackCueList.
*/
Object.defineProperty(list, 'length', {
get: function get() {
return this.length_;
}
});
if (browser.IS_IE8) {
return list;
}
}
/**
* A setter for cues in this list. Creates getters
* an an index for the cues.
*
* @param {Array} cues
* An array of cues to set
*
* @private
*/
TextTrackCueList.prototype.setCues_ = function setCues_(cues) {
var oldLength = this.length || 0;
var i = 0;
var l = cues.length;
this.cues_ = cues;
this.length_ = cues.length;
var defineProp = function defineProp(index) {
if (!('' + index in this)) {
Object.defineProperty(this, '' + index, {
get: function get() {
return this.cues_[index];
}
});
}
};
if (oldLength < l) {
i = oldLength;
for (; i < l; i++) {
defineProp.call(this, i);
}
}
};
/**
* Get a `TextTrackCue` that is currently in the `TextTrackCueList` by id.
*
* @param {string} id
* The id of the cue that should be searched for.
*
* @return {TextTrackCue|null}
* A single cue or null if none was found.
*/
TextTrackCueList.prototype.getCueById = function getCueById(id) {
var result = null;
for (var i = 0, l = this.length; i < l; i++) {
var cue = this[i];
if (cue.id === id) {
result = cue;
break;
}
}
return result;
};
return TextTrackCueList;
}();
exports['default'] = TextTrackCueList;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/text-track-display.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file text-track-display.js
*/
var darkGray = '#222';
var lightGray = '#ccc';
var fontMap = {
monospace: 'monospace',
sansSerif: 'sans-serif',
serif: 'serif',
monospaceSansSerif: '"Andale Mono", "Lucida Console", monospace',
monospaceSerif: '"Courier New", monospace',
proportionalSansSerif: 'sans-serif',
proportionalSerif: 'serif',
casual: '"Comic Sans MS", Impact, fantasy',
script: '"Monotype Corsiva", cursive',
smallcaps: '"Andale Mono", "Lucida Console", monospace, sans-serif'
};
/**
* Construct an rgba color from a given hex color code.
*
* @param {number} color
* Hex number for color, like #f0e.
*
* @param {number} opacity
* Value for opacity, 0.0 - 1.0.
*
* @return {string}
* The rgba color that was created, like 'rgba(255, 0, 0, 0.3)'.
*
* @private
*/
function constructColor(color, opacity) {
return 'rgba(' +
// color looks like "#f0e"
parseInt(color[1] + color[1], 16) + ',' + parseInt(color[2] + color[2], 16) + ',' + parseInt(color[3] + color[3], 16) + ',' + opacity + ')';
}
/**
* Try to update the style of a DOM element. Some style changes will throw an error,
* particularly in IE8. Those should be noops.
*
* @param {Element} el
* The DOM element to be styled.
*
* @param {string} style
* The CSS property on the element that should be styled.
*
* @param {string} rule
* The style rule that should be applied to the property.
*/
function tryUpdateStyle(el, style, rule) {
try {
el.style[style] = rule;
} catch (e) {
// Satisfies linter.
return;
}
}
/**
* The component for displaying text track cues.
*
* @extends Component
*/
var TextTrackDisplay = function (_Component) {
_inherits(TextTrackDisplay, _Component);
/**
* Creates an instance of this class.
*
* @param {Player} player
* The `Player` that this class should be attached to.
*
* @param {Object} [options]
* The key/value store of player options.
*
* @param {Component~ReadyCallback} [ready]
* The function to call when `TextTrackDisplay` is ready.
*/
function TextTrackDisplay(player, options, ready) {
_classCallCheck(this, TextTrackDisplay);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options, ready));
player.on('loadstart', Fn.bind(_this, _this.toggleDisplay));
player.on('texttrackchange', Fn.bind(_this, _this.updateDisplay));
// This used to be called during player init, but was causing an error
// if a track should show by default and the display hadn't loaded yet.
// Should probably be moved to an external track loader when we support
// tracks that don't need a display.
player.ready(Fn.bind(_this, function () {
if (player.tech_ && player.tech_.featuresNativeTextTracks) {
this.hide();
return;
}
player.on('fullscreenchange', Fn.bind(this, this.updateDisplay));
var tracks = this.options_.playerOptions.tracks || [];
for (var i = 0; i < tracks.length; i++) {
this.player_.addRemoteTextTrack(tracks[i], true);
}
var modes = { captions: 1, subtitles: 1 };
var trackList = this.player_.textTracks();
var firstDesc = void 0;
var firstCaptions = void 0;
if (trackList) {
for (var _i = 0; _i < trackList.length; _i++) {
var track = trackList[_i];
if (track['default']) {
if (track.kind === 'descriptions' && !firstDesc) {
firstDesc = track;
} else if (track.kind in modes && !firstCaptions) {
firstCaptions = track;
}
}
}
// We want to show the first default track but captions and subtitles
// take precedence over descriptions.
// So, display the first default captions or subtitles track
// and otherwise the first default descriptions track.
if (firstCaptions) {
firstCaptions.mode = 'showing';
} else if (firstDesc) {
firstDesc.mode = 'showing';
}
}
}));
return _this;
}
/**
* Turn display of {@link TextTrack}'s from the current state into the other state.
* There are only two states:
* - 'shown'
* - 'hidden'
*
* @listens Player#loadstart
*/
TextTrackDisplay.prototype.toggleDisplay = function toggleDisplay() {
if (this.player_.tech_ && this.player_.tech_.featuresNativeTextTracks) {
this.hide();
} else {
this.show();
}
};
/**
* Create the {@link Component}'s DOM element.
*
* @return {Element}
* The element that was created.
*/
TextTrackDisplay.prototype.createEl = function createEl() {
return _Component.prototype.createEl.call(this, 'div', {
className: 'vjs-text-track-display'
}, {
'aria-live': 'off',
'aria-atomic': 'true'
});
};
/**
* Clear all displayed {@link TextTrack}s.
*/
TextTrackDisplay.prototype.clearDisplay = function clearDisplay() {
if (typeof _window2['default'].WebVTT === 'function') {
_window2['default'].WebVTT.processCues(_window2['default'], [], this.el_);
}
};
/**
* Update the displayed TextTrack when a either a {@link Player#texttrackchange} or
* a {@link Player#fullscreenchange} is fired.
*
* @listens Player#texttrackchange
* @listens Player#fullscreenchange
*/
TextTrackDisplay.prototype.updateDisplay = function updateDisplay() {
var tracks = this.player_.textTracks();
this.clearDisplay();
if (!tracks) {
return;
}
// Track display prioritization model: if multiple tracks are 'showing',
// display the first 'subtitles' or 'captions' track which is 'showing',
// otherwise display the first 'descriptions' track which is 'showing'
var descriptionsTrack = null;
var captionsSubtitlesTrack = null;
var i = tracks.length;
while (i--) {
var track = tracks[i];
if (track.mode === 'showing') {
if (track.kind === 'descriptions') {
descriptionsTrack = track;
} else {
captionsSubtitlesTrack = track;
}
}
}
if (captionsSubtitlesTrack) {
if (this.getAttribute('aria-live') !== 'off') {
this.setAttribute('aria-live', 'off');
}
this.updateForTrack(captionsSubtitlesTrack);
} else if (descriptionsTrack) {
if (this.getAttribute('aria-live') !== 'assertive') {
this.setAttribute('aria-live', 'assertive');
}
this.updateForTrack(descriptionsTrack);
}
};
/**
* Add an {@link Texttrack} to to the {@link Tech}s {@link TextTrackList}.
*
* @param {TextTrack} track
* Text track object to be added to the list.
*/
TextTrackDisplay.prototype.updateForTrack = function updateForTrack(track) {
if (typeof _window2['default'].WebVTT !== 'function' || !track.activeCues) {
return;
}
var overrides = this.player_.textTrackSettings.getValues();
var cues = [];
for (var _i2 = 0; _i2 < track.activeCues.length; _i2++) {
cues.push(track.activeCues[_i2]);
}
_window2['default'].WebVTT.processCues(_window2['default'], cues, this.el_);
var i = cues.length;
while (i--) {
var cue = cues[i];
if (!cue) {
continue;
}
var cueDiv = cue.displayState;
if (overrides.color) {
cueDiv.firstChild.style.color = overrides.color;
}
if (overrides.textOpacity) {
tryUpdateStyle(cueDiv.firstChild, 'color', constructColor(overrides.color || '#fff', overrides.textOpacity));
}
if (overrides.backgroundColor) {
cueDiv.firstChild.style.backgroundColor = overrides.backgroundColor;
}
if (overrides.backgroundOpacity) {
tryUpdateStyle(cueDiv.firstChild, 'backgroundColor', constructColor(overrides.backgroundColor || '#000', overrides.backgroundOpacity));
}
if (overrides.windowColor) {
if (overrides.windowOpacity) {
tryUpdateStyle(cueDiv, 'backgroundColor', constructColor(overrides.windowColor, overrides.windowOpacity));
} else {
cueDiv.style.backgroundColor = overrides.windowColor;
}
}
if (overrides.edgeStyle) {
if (overrides.edgeStyle === 'dropshadow') {
cueDiv.firstChild.style.textShadow = '2px 2px 3px ' + darkGray + ', 2px 2px 4px ' + darkGray + ', 2px 2px 5px ' + darkGray;
} else if (overrides.edgeStyle === 'raised') {
cueDiv.firstChild.style.textShadow = '1px 1px ' + darkGray + ', 2px 2px ' + darkGray + ', 3px 3px ' + darkGray;
} else if (overrides.edgeStyle === 'depressed') {
cueDiv.firstChild.style.textShadow = '1px 1px ' + lightGray + ', 0 1px ' + lightGray + ', -1px -1px ' + darkGray + ', 0 -1px ' + darkGray;
} else if (overrides.edgeStyle === 'uniform') {
cueDiv.firstChild.style.textShadow = '0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray;
}
}
if (overrides.fontPercent && overrides.fontPercent !== 1) {
var fontSize = _window2['default'].parseFloat(cueDiv.style.fontSize);
cueDiv.style.fontSize = fontSize * overrides.fontPercent + 'px';
cueDiv.style.height = 'auto';
cueDiv.style.top = 'auto';
cueDiv.style.bottom = '2px';
}
if (overrides.fontFamily && overrides.fontFamily !== 'default') {
if (overrides.fontFamily === 'small-caps') {
cueDiv.firstChild.style.fontVariant = 'small-caps';
} else {
cueDiv.firstChild.style.fontFamily = fontMap[overrides.fontFamily];
}
}
}
};
return TextTrackDisplay;
}(_component2['default']);
_component2['default'].registerComponent('TextTrackDisplay', TextTrackDisplay);
exports['default'] = TextTrackDisplay;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/text-track-list-converter.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
/**
* @file text-track-list-converter.js Utilities for capturing text track state and
* re-creating tracks based on a capture.
*
* @module text-track-list-converter
*/
/**
* Examine a single {@link TextTrack} and return a JSON-compatible javascript object that
* represents the {@link TextTrack}'s state.
*
* @param {TextTrack} track
* The text track to query.
*
* @return {Object}
* A serializable javascript representation of the TextTrack.
* @private
*/
var trackToJson_ = function trackToJson_(track) {
var ret = ['kind', 'label', 'language', 'id', 'inBandMetadataTrackDispatchType', 'mode', 'src'].reduce(function (acc, prop, i) {
if (track[prop]) {
acc[prop] = track[prop];
}
return acc;
}, {
cues: track.cues && Array.prototype.map.call(track.cues, function (cue) {
return {
startTime: cue.startTime,
endTime: cue.endTime,
text: cue.text,
id: cue.id
};
})
});
return ret;
};
/**
* Examine a {@link Tech} and return a JSON-compatible javascript array that represents the
* state of all {@link TextTrack}s currently configured. The return array is compatible with
* {@link text-track-list-converter:jsonToTextTracks}.
*
* @param {Tech} tech
* The tech object to query
*
* @return {Array}
* A serializable javascript representation of the {@link Tech}s
* {@link TextTrackList}.
*/
var textTracksToJson = function textTracksToJson(tech) {
var trackEls = tech.$$('track');
var trackObjs = Array.prototype.map.call(trackEls, function (t) {
return t.track;
});
var tracks = Array.prototype.map.call(trackEls, function (trackEl) {
var json = trackToJson_(trackEl.track);
if (trackEl.src) {
json.src = trackEl.src;
}
return json;
});
return tracks.concat(Array.prototype.filter.call(tech.textTracks(), function (track) {
return trackObjs.indexOf(track) === -1;
}).map(trackToJson_));
};
/**
* Create a set of remote {@link TextTrack}s on a {@link Tech} based on an array of javascript
* object {@link TextTrack} representations.
*
* @param {Array} json
* An array of `TextTrack` representation objects, like those that would be
* produced by `textTracksToJson`.
*
* @param {Tech} tech
* The `Tech` to create the `TextTrack`s on.
*/
var jsonToTextTracks = function jsonToTextTracks(json, tech) {
json.forEach(function (track) {
var addedTrack = tech.addRemoteTextTrack(track).track;
if (!track.src && track.cues) {
track.cues.forEach(function (cue) {
return addedTrack.addCue(cue);
});
}
});
return tech.textTracks();
};
exports['default'] = { textTracksToJson: textTracksToJson, jsonToTextTracks: jsonToTextTracks, trackToJson_: trackToJson_ };
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/text-track-list.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _trackList = __webpack_require__("./node_modules/video.js/es5/tracks/track-list.js");
var _trackList2 = _interopRequireDefault(_trackList);
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _browser = __webpack_require__("./node_modules/video.js/es5/utils/browser.js");
var browser = _interopRequireWildcard(_browser);
var _document = __webpack_require__("./node_modules/video.js/node_modules/global/document.js");
var _document2 = _interopRequireDefault(_document);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file text-track-list.js
*/
/**
* The current list of {@link TextTrack} for a media file.
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttracklist}
* @extends TrackList
*/
var TextTrackList = function (_TrackList) {
_inherits(TextTrackList, _TrackList);
/**
* Create an instance of this class.
*
* @param {TextTrack[]} [tracks=[]]
* A list of `TextTrack` to instantiate the list with.
*/
function TextTrackList() {
var _this, _ret;
var tracks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, TextTrackList);
var list = void 0;
// IE8 forces us to implement inheritance ourselves
// as it does not support Object.defineProperty properly
if (browser.IS_IE8) {
list = _document2['default'].createElement('custom');
for (var prop in _trackList2['default'].prototype) {
if (prop !== 'constructor') {
list[prop] = _trackList2['default'].prototype[prop];
}
}
for (var _prop in TextTrackList.prototype) {
if (_prop !== 'constructor') {
list[_prop] = TextTrackList.prototype[_prop];
}
}
}
list = (_this = _possibleConstructorReturn(this, _TrackList.call(this, tracks, list)), _this);
return _ret = list, _possibleConstructorReturn(_this, _ret);
}
/**
* Add a {@link TextTrack} to the `TextTrackList`
*
* @param {TextTrack} track
* The text track to add to the list.
*
* @fires TrackList#addtrack
* @private
*/
TextTrackList.prototype.addTrack_ = function addTrack_(track) {
_TrackList.prototype.addTrack_.call(this, track);
/**
* @listens TextTrack#modechange
* @fires TrackList#change
*/
track.addEventListener('modechange', Fn.bind(this, function () {
this.trigger('change');
}));
};
return TextTrackList;
}(_trackList2['default']);
exports['default'] = TextTrackList;
/***/ }),
/***/ "./node_modules/video.js/es5/tracks/text-track-settings.js":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _window = __webpack_require__("./node_modules/video.js/node_modules/global/window.js");
var _window2 = _interopRequireDefault(_window);
var _component = __webpack_require__("./node_modules/video.js/es5/component.js");
var _component2 = _interopRequireDefault(_component);
var _dom = __webpack_require__("./node_modules/video.js/es5/utils/dom.js");
var _fn = __webpack_require__("./node_modules/video.js/es5/utils/fn.js");
var Fn = _interopRequireWildcard(_fn);
var _obj = __webpack_require__("./node_modules/video.js/es5/utils/obj.js");
var Obj = _interopRequireWildcard(_obj);
var _log = __webpack_require__("./node_modules/video.js/es5/utils/log.js");
var _log2 = _interopRequireDefault(_log);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
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"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* @file text-track-settings.js
*/
var LOCAL_STORAGE_KEY = 'vjs-text-track-settings';
var COLOR_BLACK = ['#000', 'Black'];
var COLOR_BLUE = ['#00F', 'Blue'];
var COLOR_CYAN = ['#0FF', 'Cyan'];
var COLOR_GREEN = ['#0F0', 'Green'];
var COLOR_MAGENTA = ['#F0F', 'Magenta'];
var COLOR_RED = ['#F00', 'Red'];
var COLOR_WHITE = ['#FFF', 'White'];
var COLOR_YELLOW = ['#FF0', 'Yellow'];
var OPACITY_OPAQUE = ['1', 'Opaque'];
var OPACITY_SEMI = ['0.5', 'Semi-Transparent'];
var OPACITY_TRANS = ['0', 'Transparent'];
// Configuration for the various