UNPKG

10.7 kBJavaScriptView Raw
1/**
2 * @license Angular v10.0.4
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("rxjs")):"function"==typeof define&&define.amd?define("@angular/common/testing",["exports","@angular/core","@angular/common","rxjs"],e):e(((t=t||self).ng=t.ng||{},t.ng.common=t.ng.common||{},t.ng.common.testing={}),t.ng.core,t.ng.common,t.rxjs)}(this,(function(t,e,n,r){"use strict";
7/**
8 * @license
9 * Copyright Google LLC All Rights Reserved.
10 *
11 * Use of this source code is governed by an MIT-style license that can be
12 * found in the LICENSE file at https://angular.io/license
13 */var s=function(){function t(){this.urlChanges=[],this._history=[new o("","",null)],this._historyIndex=0,this._subject=new e.EventEmitter,this._baseHref="",this._platformStrategy=null,this._platformLocation=null,this._urlChangeListeners=[]}return t.prototype.setInitialPath=function(t){this._history[this._historyIndex].path=t},t.prototype.setBaseHref=function(t){this._baseHref=t},t.prototype.path=function(){return this._history[this._historyIndex].path},t.prototype.getState=function(){return this._history[this._historyIndex].state},t.prototype.isCurrentPathEqualTo=function(t,e){void 0===e&&(e="");var n=t.endsWith("/")?t.substring(0,t.length-1):t;return(this.path().endsWith("/")?this.path().substring(0,this.path().length-1):this.path())==n+(e.length>0?"?"+e:"")},t.prototype.simulateUrlPop=function(t){this._subject.emit({url:t,pop:!0,type:"popstate"})},t.prototype.simulateHashChange=function(t){this.setInitialPath(t),this.urlChanges.push("hash: "+t),this._subject.emit({url:t,pop:!0,type:"hashchange"})},t.prototype.prepareExternalUrl=function(t){return t.length>0&&!t.startsWith("/")&&(t="/"+t),this._baseHref+t},t.prototype.go=function(t,e,n){void 0===e&&(e=""),void 0===n&&(n=null),t=this.prepareExternalUrl(t),this._historyIndex>0&&this._history.splice(this._historyIndex+1),this._history.push(new o(t,e,n)),this._historyIndex=this._history.length-1;var r=this._history[this._historyIndex-1];if(r.path!=t||r.query!=e){var s=t+(e.length>0?"?"+e:"");this.urlChanges.push(s),this._subject.emit({url:s,pop:!1})}},t.prototype.replaceState=function(t,e,n){void 0===e&&(e=""),void 0===n&&(n=null),t=this.prepareExternalUrl(t);var r=this._history[this._historyIndex];r.path==t&&r.query==e||(r.path=t,r.query=e,r.state=n,this.urlChanges.push("replace: "+t+(e.length>0?"?"+e:"")))},t.prototype.forward=function(){this._historyIndex<this._history.length-1&&(this._historyIndex++,this._subject.emit({url:this.path(),state:this.getState(),pop:!0}))},t.prototype.back=function(){this._historyIndex>0&&(this._historyIndex--,this._subject.emit({url:this.path(),state:this.getState(),pop:!0}))},t.prototype.onUrlChange=function(t){var e=this;this._urlChangeListeners.push(t),this._urlChangeSubscription||(this._urlChangeSubscription=this.subscribe((function(t){e._notifyUrlChangeListeners(t.url,t.state)})))},t.prototype._notifyUrlChangeListeners=function(t,e){void 0===t&&(t=""),this._urlChangeListeners.forEach((function(n){return n(t,e)}))},t.prototype.subscribe=function(t,e,n){return this._subject.subscribe({next:t,error:e,complete:n})},t.prototype.normalize=function(t){return null},t}();s.decorators=[{type:e.Injectable}];var o=function o(t,e,n){this.path=t,this.query=e,this.state=n},h=function(t,e){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},i=function(t){function n(){var n=t.call(this)||this;return n.internalBaseHref="/",n.internalPath="/",n.internalTitle="",n.urlChanges=[],n._subject=new e.EventEmitter,n.stateChanges=[],n}return function r(t,e){function n(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,t),n.prototype.simulatePopState=function(t){this.internalPath=t,this._subject.emit(new a(this.path()))},n.prototype.path=function(t){return void 0===t&&(t=!1),this.internalPath},n.prototype.prepareExternalUrl=function(t){return t.startsWith("/")&&this.internalBaseHref.endsWith("/")?this.internalBaseHref+t.substring(1):this.internalBaseHref+t},n.prototype.pushState=function(t,e,n,r){this.stateChanges.push(t),this.internalTitle=e;var s=n+(r.length>0?"?"+r:"");this.internalPath=s;var o=this.prepareExternalUrl(s);this.urlChanges.push(o)},n.prototype.replaceState=function(t,e,n,r){this.stateChanges[(this.stateChanges.length||1)-1]=t,this.internalTitle=e;var s=n+(r.length>0?"?"+r:"");this.internalPath=s;var o=this.prepareExternalUrl(s);this.urlChanges.push("replace: "+o)},n.prototype.onPopState=function(t){this._subject.subscribe({next:t})},n.prototype.getBaseHref=function(){return this.internalBaseHref},n.prototype.back=function(){this.urlChanges.length>0&&(this.urlChanges.pop(),this.stateChanges.pop(),this.simulatePopState(this.urlChanges.length>0?this.urlChanges[this.urlChanges.length-1]:""))},n.prototype.forward=function(){throw"not implemented"},n.prototype.getState=function(){return this.stateChanges[(this.stateChanges.length||1)-1]},n}(n.LocationStrategy);
14/*! *****************************************************************************
15 Copyright (c) Microsoft Corporation.
16
17 Permission to use, copy, modify, and/or distribute this software for any
18 purpose with or without fee is hereby granted.
19
20 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26 PERFORMANCE OF THIS SOFTWARE.
27 ***************************************************************************** */i.decorators=[{type:e.Injectable}],i.ctorParameters=function(){return[]};var a=function a(t){this.newUrl=t,this.pop=!0,this.type="popstate"},p=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,u=new e.InjectionToken("MOCK_PLATFORM_LOCATION_CONFIG"),c=function(){function t(t){if(this.baseHref="",this.hashUpdate=new r.Subject,this.urlChanges=[{hostname:"",protocol:"",port:"",pathname:"/",search:"",hash:"",state:null}],t){this.baseHref=t.appBaseHref||"";var e=this.parseChanges(null,t.startUrl||"http://<empty>/",this.baseHref);this.urlChanges[0]=Object.assign({},e)}}return Object.defineProperty(t.prototype,"hostname",{get:function(){return this.urlChanges[0].hostname},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"protocol",{get:function(){return this.urlChanges[0].protocol},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"port",{get:function(){return this.urlChanges[0].port},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pathname",{get:function(){return this.urlChanges[0].pathname},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"search",{get:function(){return this.urlChanges[0].search},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hash",{get:function(){return this.urlChanges[0].hash},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this.urlChanges[0].state},enumerable:!1,configurable:!0}),t.prototype.getBaseHrefFromDOM=function(){return this.baseHref},t.prototype.onPopState=function(t){},t.prototype.onHashChange=function(t){this.hashUpdate.subscribe(t)},Object.defineProperty(t.prototype,"href",{get:function(){return this.protocol+"//"+this.hostname+(this.port?":"+this.port:"")+("/"===this.pathname?"":this.pathname)+this.search+this.hash},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return""+this.pathname+this.search+this.hash},enumerable:!1,configurable:!0}),t.prototype.parseChanges=function(t,e,n){return void 0===n&&(n=""),t=JSON.parse(JSON.stringify(t)),Object.assign(Object.assign({},function r(t,e){var n,r;/^((http[s]?|ftp):\/\/)/.test(t)||(n="http://empty.com/");try{r=new URL(t,n)}catch(h){var s=p.exec(n||""+t);if(!s)throw new Error("Invalid URL: "+t+" with base: "+e);var o=s[4].split(":");r={protocol:s[1],hostname:o[0],port:o[1]||"",pathname:s[5],search:s[6],hash:s[8]}}return r.pathname&&0===r.pathname.indexOf(e)&&(r.pathname=r.pathname.substring(e.length)),{hostname:!n&&r.hostname||"",protocol:!n&&r.protocol||"",port:!n&&r.port||"",pathname:r.pathname||"/",search:r.search||"",hash:r.hash||""}}(e,n)),{state:t})},t.prototype.replaceState=function(t,e,n){var r=this.parseChanges(t,n),s=r.pathname,o=r.search,h=r.state,i=r.hash;this.urlChanges[0]=Object.assign(Object.assign({},this.urlChanges[0]),{pathname:s,search:o,hash:i,state:h})},t.prototype.pushState=function(t,e,n){var r=this.parseChanges(t,n),s=r.pathname,o=r.search,h=r.state,i=r.hash;this.urlChanges.unshift(Object.assign(Object.assign({},this.urlChanges[0]),{pathname:s,search:o,hash:i,state:h}))},t.prototype.forward=function(){throw new Error("Not implemented")},t.prototype.back=function(){var t=this,e=this.url,n=this.hash;this.urlChanges.shift(),n!==this.hash&&function r(t){Promise.resolve(null).then(t)}
28/**
29 * @license
30 * Copyright Google LLC All Rights Reserved.
31 *
32 * Use of this source code is governed by an MIT-style license that can be
33 * found in the LICENSE file at https://angular.io/license
34 */
35/**
36 * @license
37 * Copyright Google LLC All Rights Reserved.
38 *
39 * Use of this source code is governed by an MIT-style license that can be
40 * found in the LICENSE file at https://angular.io/license
41 */
42/**
43 * @license
44 * Copyright Google LLC All Rights Reserved.
45 *
46 * Use of this source code is governed by an MIT-style license that can be
47 * found in the LICENSE file at https://angular.io/license
48 */((function(){return t.hashUpdate.next({type:"hashchange",state:null,oldUrl:e,newUrl:t.url})}))},t.prototype.getState=function(){return this.state},t}();
49/**
50 * @license
51 * Copyright Google LLC All Rights Reserved.
52 *
53 * Use of this source code is governed by an MIT-style license that can be
54 * found in the LICENSE file at https://angular.io/license
55 */c.decorators=[{type:e.Injectable}],c.ctorParameters=function(){return[{type:void 0,decorators:[{type:e.Inject,args:[u]},{type:e.Optional}]}]},t.MOCK_PLATFORM_LOCATION_CONFIG=u,t.MockLocationStrategy=i,t.MockPlatformLocation=c,t.SpyLocation=s,Object.defineProperty(t,"__esModule",{value:!0})}));
\No newline at end of file