diff --git a/bower.json b/bower.json index a7b1d2d..d916273 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-history-browser", - "version": "1.3.2", + "version": "1.4.0", "description": "An implementation of the Aurelia history interface based on standard browser hash change and push state mechanisms.", "keywords": [ "aurelia", diff --git a/dist/amd/aurelia-history-browser.js b/dist/amd/aurelia-history-browser.js index 6e80f4b..238ced5 100644 --- a/dist/amd/aurelia-history-browser.js +++ b/dist/amd/aurelia-history-browser.js @@ -109,7 +109,7 @@ define(['exports', 'aurelia-history', 'aurelia-pal'], function (exports, aurelia function BrowserHistory(linkHandler) { var _this = _super.call(this) || this; _this._isActive = false; - _this._checkUrl = _this._checkUrl.bind(_this); + _this._checkUrlCallback = _this._checkUrl.bind(_this); _this.location = aureliaPal.PLATFORM.location; _this.history = aureliaPal.PLATFORM.history; _this.linkHandler = linkHandler; @@ -133,7 +133,7 @@ define(['exports', 'aurelia-history', 'aurelia-pal'], function (exports, aurelia else if (wantsHashChange) { eventName = 'hashchange'; } - aureliaPal.PLATFORM.addEventListener(eventName, this._checkUrl); + aureliaPal.PLATFORM.addEventListener(eventName, this._checkUrlCallback); if (wantsHashChange && wantsPushState) { var $location = this.location; var atRoot = $location.pathname.replace(/[^\/]$/, '$&/') === rootUrl; @@ -156,7 +156,7 @@ define(['exports', 'aurelia-history', 'aurelia-pal'], function (exports, aurelia } }; BrowserHistory.prototype.deactivate = function () { - var handler = this._checkUrl; + var handler = this._checkUrlCallback; aureliaPal.PLATFORM.removeEventListener('popstate', handler); aureliaPal.PLATFORM.removeEventListener('hashchange', handler); this._isActive = false; @@ -247,7 +247,7 @@ define(['exports', 'aurelia-history', 'aurelia-pal'], function (exports, aurelia fragment = this._getHash(); } } - return decodeURIComponent('/' + fragment.replace(routeStripper, '')); + return '/' + fragment.replace(routeStripper, ''); }; BrowserHistory.prototype._checkUrl = function () { var current = this._getFragment(''); diff --git a/dist/amd/aurelia-history-browser.js.map b/dist/amd/aurelia-history-browser.js.map index 00f6dd1..10a150e 100644 --- a/dist/amd/aurelia-history-browser.js.map +++ b/dist/amd/aurelia-history-browser.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrl = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrl);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrl;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n // caching fragment value to prevent triggering load same URL twice\n // as this could potentially trigger hashchange or pushstate\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n // without decoding the fragment\n // _loadUrl will be trigger twice if there are special character in the URL\n return decodeURIComponent('/' + fragment.replace(routeStripper, ''));\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n // a guard to prevent triggering load same URL twice\n // typically happens when calling navigate from router\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":["tslib_1.__extends","DOM","PLATFORM","History"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAOA;SAYC;QANC,8BAAQ,GAAR,UAAS,OAAuB,KAAc;QAK9C,gCAAU,GAAV,eAAyB;QAC3B,kBAAC;IAAD,CAAC,IAAA;;QAMuCA,sCAAW;QAUjD;YAAA,YACE,iBAAO,SAUR;YARC,KAAI,CAAC,OAAO,GAAG,UAAC,CAAC;gBACX,IAAA,uCAAgE,EAA9D,wCAAiB,EAAE,cAA2C,CAAC;gBAErE,IAAI,iBAAiB,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AS,CAACA,sBAAO,EAAE,cAAc,CAAC,CAAC;QAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IACrD,CAAC;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n _checkUrlCallback: any;\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrlCallback = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrlCallback);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrlCallback;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n return '/' + fragment.replace(routeStripper, '');\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":["tslib_1.__extends","DOM","PLATFORM","History"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAOA;SAYC;QANC,8BAAQ,GAAR,UAAS,OAAuB,KAAc;QAK9C,gCAAU,GAAV,eAAyB;QAC3B,kBAAC;IAAD,CAAC,IAAA;;QAMuCA,sCAAW;QAUjD;YAAA,YACE,iBAAO,SAUR;YARC,KAAI,CAAC,OAAO,GAAG,UAAC,CAAC;gBACX,IAAA,uCAAgE,EAA9D,wCAAiB,EAAE,cAA2C,CAAC;gBAErE,IAAI,iBAAiB,EAAE;oBACrB,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,KAAI,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WAAW,EAAE,kBAAkB,CAAC,CAAC;IACrD,CAAC;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/commonjs/aurelia-history-browser.js b/dist/commonjs/aurelia-history-browser.js index 0bae7de..7f8ef04 100644 --- a/dist/commonjs/aurelia-history-browser.js +++ b/dist/commonjs/aurelia-history-browser.js @@ -114,7 +114,7 @@ var BrowserHistory = (function (_super) { function BrowserHistory(linkHandler) { var _this = _super.call(this) || this; _this._isActive = false; - _this._checkUrl = _this._checkUrl.bind(_this); + _this._checkUrlCallback = _this._checkUrl.bind(_this); _this.location = aureliaPal.PLATFORM.location; _this.history = aureliaPal.PLATFORM.history; _this.linkHandler = linkHandler; @@ -138,7 +138,7 @@ var BrowserHistory = (function (_super) { else if (wantsHashChange) { eventName = 'hashchange'; } - aureliaPal.PLATFORM.addEventListener(eventName, this._checkUrl); + aureliaPal.PLATFORM.addEventListener(eventName, this._checkUrlCallback); if (wantsHashChange && wantsPushState) { var $location = this.location; var atRoot = $location.pathname.replace(/[^\/]$/, '$&/') === rootUrl; @@ -161,7 +161,7 @@ var BrowserHistory = (function (_super) { } }; BrowserHistory.prototype.deactivate = function () { - var handler = this._checkUrl; + var handler = this._checkUrlCallback; aureliaPal.PLATFORM.removeEventListener('popstate', handler); aureliaPal.PLATFORM.removeEventListener('hashchange', handler); this._isActive = false; @@ -252,7 +252,7 @@ var BrowserHistory = (function (_super) { fragment = this._getHash(); } } - return decodeURIComponent('/' + fragment.replace(routeStripper, '')); + return '/' + fragment.replace(routeStripper, ''); }; BrowserHistory.prototype._checkUrl = function () { var current = this._getFragment(''); diff --git a/dist/commonjs/aurelia-history-browser.js.map b/dist/commonjs/aurelia-history-browser.js.map index d3b5806..830cf0d 100644 --- a/dist/commonjs/aurelia-history-browser.js.map +++ b/dist/commonjs/aurelia-history-browser.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrl = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrl);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrl;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n // caching fragment value to prevent triggering load same URL twice\n // as this could potentially trigger hashchange or pushstate\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n // without decoding the fragment\n // _loadUrl will be trigger twice if there are special character in the URL\n return decodeURIComponent('/' + fragment.replace(routeStripper, ''));\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n // a guard to prevent triggering load same URL twice\n // typically happens when calling navigate from router\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":["tslib_1.__extends","DOM","PLATFORM","History"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOA;KAYC;IANC,8BAAQ,GAAR,UAAS,OAAuB,KAAc;IAK9C,gCAAU,GAAV,eAAyB;IAC3B,kBAAC;CAAA,IAAA;;IAMuCA,sCAAW;IAUjD;QAAA,YACE,iBAAO,SAUR;QARC,KAAI,CAAC,OAAO,GAAG,UAAC,CAAC;YACX,IAAA,uCAAgE,EAA9D,wCAAiB,EAAE,cAA2C,CAAC;YAErE,IAAI,iBAAiB,EAAE;gBACrB,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,KAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC7B;SACF,CAAC;;KACH;IAOD,qCAAQ,GAAR,UAAS,OAAuB;QAC9B,IAAI,OAAO,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AAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;QAEnE,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY;YAC9B,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC;YACnC,KAAK,CAAC;KACT;IArSM,qBAAM,GAAG,CAAC,WAAW,CAAC,CAAC;IAsShC,qBAAC;CAAA,CAxSmCE,sBAAO,GAwS1C;AAGD,IAAM,aAAa,GAAG,cAAc,CAAC;AAGrC,IAAM,YAAY,GAAG,YAAY,CAAC;AAGlC,IAAM,aAAa,GAAG,KAAK,CAAC;AAK5B,IAAM,WAAW,GAAG,8BAA8B,CAAC;AAInD,SAAS,UAAU,CAAC,SAAmB,EAAE,QAAgB,EAAE,OAAgB;IACzE,IAAI,OAAO,EAAE;QACX,IAAI,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QAC5D,SAAS,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC,CAAC;KAC1C;SAAM;QAEL,SAAS,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC;KACjC;CACF;AAED,SAAS,YAAY,CAAC,QAAgB,EAAE,QAAgB,EAAE,IAAY;IACpE,OAAU,QAAQ,UAAK,QAAQ,IAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,CAAE,CAAC;CAC5D;;SCrUe,SAAS,CAAC,MAAc;IAEtC,IAAM,OAAO,GAAG,MAAa,CAAC;IAC9B,OAAO,CAAC,SAAS,CAACA,sBAAO,EAAE,cAAc,CAAC,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;CACpD;;;;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n _checkUrlCallback: any;\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrlCallback = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrlCallback);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrlCallback;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n return '/' + fragment.replace(routeStripper, '');\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":["tslib_1.__extends","DOM","PLATFORM","History"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOA;KAYC;IANC,8BAAQ,GAAR,UAAS,OAAuB,KAAc;IAK9C,gCAAU,GAAV,eAAyB;IAC3B,kBAAC;CAAA,IAAA;;IAMuCA,sCAAW;IAUjD;QAAA,YACE,iBAAO,SAUR;QARC,KAAI,CAAC,OAAO,GAAG,UAAC,CAAC;YACX,IAAA,uCAAgE,EAA9D,wCAAiB,EAAE,cAA2C,CAAC;YAErE,IAAI,iBAAiB,EAAE;gBACrB,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,KAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC7B;SACF,CAAC;;KACH;IAOD,qCAAQ,GAAR,UAAS,OAAuB;QAC9B,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvBC,cAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SAC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IAjSM,qBAAM,GAAG,CAAC,WAAW,CAAC,CAAC;IAkShC,qBAAC;CAAA,CApSmCE,sBAAO,GAoS1C;AAGD,IAAM,aAAa,GAAG,cAAc,CAAC;AAGrC,IAAM,YAAY,GAAG,YAAY,CAAC;AAGlC,IAAM,aAAa,GAAG,KAAK,CAAC;AAK5B,IAAM,WAAW,GAAG,8BAA8B,CAAC;AAInD,SAAS,UAAU,CAAC,SAAmB,EAAE,QAAgB,EAAE,OAAgB;IACzE,IAAI,OAAO,EAAE;QACX,IAAI,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QAC5D,SAAS,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC,CAAC;KAC1C;SAAM;QAEL,SAAS,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC;KACjC;CACF;AAED,SAAS,YAAY,CAAC,QAAgB,EAAE,QAAgB,EAAE,IAAY;IACpE,OAAU,QAAQ,UAAK,QAAQ,IAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,CAAE,CAAC;CAC5D;;SCjUe,SAAS,CAAC,MAAc;IAEtC,IAAM,OAAO,GAAG,MAAa,CAAC;IAC9B,OAAO,CAAC,SAAS,CAACA,sBAAO,EAAE,cAAc,CAAC,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;CACpD;;;;;;;"} \ No newline at end of file diff --git a/dist/es2015/aurelia-history-browser.js b/dist/es2015/aurelia-history-browser.js index f436db8..f5b42f4 100644 --- a/dist/es2015/aurelia-history-browser.js +++ b/dist/es2015/aurelia-history-browser.js @@ -74,7 +74,7 @@ class BrowserHistory extends History { constructor(linkHandler) { super(); this._isActive = false; - this._checkUrl = this._checkUrl.bind(this); + this._checkUrlCallback = this._checkUrl.bind(this); this.location = PLATFORM.location; this.history = PLATFORM.history; this.linkHandler = linkHandler; @@ -97,7 +97,7 @@ class BrowserHistory extends History { else if (wantsHashChange) { eventName = 'hashchange'; } - PLATFORM.addEventListener(eventName, this._checkUrl); + PLATFORM.addEventListener(eventName, this._checkUrlCallback); if (wantsHashChange && wantsPushState) { let $location = this.location; let atRoot = $location.pathname.replace(/[^\/]$/, '$&/') === rootUrl; @@ -120,7 +120,7 @@ class BrowserHistory extends History { } } deactivate() { - const handler = this._checkUrl; + const handler = this._checkUrlCallback; PLATFORM.removeEventListener('popstate', handler); PLATFORM.removeEventListener('hashchange', handler); this._isActive = false; @@ -210,7 +210,7 @@ class BrowserHistory extends History { fragment = this._getHash(); } } - return decodeURIComponent('/' + fragment.replace(routeStripper, '')); + return '/' + fragment.replace(routeStripper, ''); } _checkUrl() { let current = this._getFragment(''); diff --git a/dist/es2015/aurelia-history-browser.js.map b/dist/es2015/aurelia-history-browser.js.map index e92f019..070e484 100644 --- a/dist/es2015/aurelia-history-browser.js.map +++ b/dist/es2015/aurelia-history-browser.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrl = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrl);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrl;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n // caching fragment value to prevent triggering load same URL twice\n // as this could potentially trigger hashchange or pushstate\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n // without decoding the fragment\n // _loadUrl will be trigger twice if there are special character in the URL\n return decodeURIComponent('/' + fragment.replace(routeStripper, ''));\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n // a guard to prevent triggering load same URL twice\n // typically happens when calling navigate from router\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":[],"mappings":";;;MAOa,WAAW;IAMtB,QAAQ,CAAC,OAAuB,KAAc;IAK9C,UAAU,MAAe;CAC1B;AAMD,MAAa,kBAAmB,SAAQ,WAAW;IAUjD;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACf,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAErE,IAAI,iBAAiB,EAAE;gBACrB,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC7B;SACF,CAAC;KACH;IAOD,QAAQ,CAAC,OAAuB;QAC9B,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACnD;KACF;IAKD,UAAU;QACR,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;KACtD;IAOD,OAAO,YAAY,CAAC,KAAY;QAC9B,IAAI,MAAM,GAAG,KAAmB,CAAC;QACjC,IAAI,IAAI,GAAG;YACT,iBAAiB,EAAE,KAAK;YACxB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAI;SACb,CAAC;QAEF,IAAI,MAAM,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAiB,CAAC,CAAC;QAC5E,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,k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B,EAAE,IAAY;IACpE,OAAO,GAAG,QAAQ,KAAK,QAAQ,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC;CAC5D;;SCrUe,SAAS,CAAC,MAAc;IAEtC,MAAM,OAAO,GAAG,MAAa,CAAC;IAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;CACpD;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n _checkUrlCallback: any;\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrlCallback = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrlCallback);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrlCallback;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n return '/' + fragment.replace(routeStripper, '');\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":[],"mappings":";;;MAOa,WAAW;IAMtB,QAAQ,CAAC,OAAuB,KAAc;IAK9C,UAAU,MAAe;CAC1B;AAMD,MAAa,kBAAmB,SAAQ,WAAW;IAUjD;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;YACf,IAAI,EAAE,iBAAiB,EAAE,IA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017/aurelia-history-browser.js +++ b/dist/es2017/aurelia-history-browser.js @@ -74,7 +74,7 @@ class BrowserHistory extends History { constructor(linkHandler) { super(); this._isActive = false; - this._checkUrl = this._checkUrl.bind(this); + this._checkUrlCallback = this._checkUrl.bind(this); this.location = PLATFORM.location; this.history = PLATFORM.history; this.linkHandler = linkHandler; @@ -97,7 +97,7 @@ class BrowserHistory extends History { else if (wantsHashChange) { eventName = 'hashchange'; } - PLATFORM.addEventListener(eventName, this._checkUrl); + PLATFORM.addEventListener(eventName, this._checkUrlCallback); if (wantsHashChange && wantsPushState) { let $location = this.location; let atRoot = $location.pathname.replace(/[^\/]$/, '$&/') === rootUrl; @@ -120,7 +120,7 @@ class BrowserHistory extends History { } } deactivate() { - const handler = this._checkUrl; + const handler = this._checkUrlCallback; PLATFORM.removeEventListener('popstate', handler); PLATFORM.removeEventListener('hashchange', handler); this._isActive = false; @@ -210,7 +210,7 @@ class BrowserHistory extends History { fragment = this._getHash(); } } - return decodeURIComponent('/' + fragment.replace(routeStripper, '')); + return '/' + fragment.replace(routeStripper, ''); } _checkUrl() { let current = this._getFragment(''); diff --git a/dist/native-modules/aurelia-history-browser.js b/dist/native-modules/aurelia-history-browser.js index 1cf4b5d..000aeb5 100644 --- a/dist/native-modules/aurelia-history-browser.js +++ b/dist/native-modules/aurelia-history-browser.js @@ -110,7 +110,7 @@ var BrowserHistory = (function (_super) { function BrowserHistory(linkHandler) { var _this = _super.call(this) || this; _this._isActive = false; - _this._checkUrl = _this._checkUrl.bind(_this); + _this._checkUrlCallback = _this._checkUrl.bind(_this); _this.location = PLATFORM.location; _this.history = PLATFORM.history; _this.linkHandler = linkHandler; @@ -134,7 +134,7 @@ var BrowserHistory = (function (_super) { else if (wantsHashChange) { eventName = 'hashchange'; } - PLATFORM.addEventListener(eventName, this._checkUrl); + PLATFORM.addEventListener(eventName, this._checkUrlCallback); if (wantsHashChange && wantsPushState) { var $location = this.location; var atRoot = $location.pathname.replace(/[^\/]$/, '$&/') === rootUrl; @@ -157,7 +157,7 @@ var BrowserHistory = (function (_super) { } }; BrowserHistory.prototype.deactivate = function () { - var handler = this._checkUrl; + var handler = this._checkUrlCallback; PLATFORM.removeEventListener('popstate', handler); PLATFORM.removeEventListener('hashchange', handler); this._isActive = false; @@ -248,7 +248,7 @@ var BrowserHistory = (function (_super) { fragment = this._getHash(); } } - return decodeURIComponent('/' + fragment.replace(routeStripper, '')); + return '/' + fragment.replace(routeStripper, ''); }; BrowserHistory.prototype._checkUrl = function () { var current = this._getFragment(''); diff --git a/dist/native-modules/aurelia-history-browser.js.map b/dist/native-modules/aurelia-history-browser.js.map index 5120ed3..323112a 100644 --- a/dist/native-modules/aurelia-history-browser.js.map +++ b/dist/native-modules/aurelia-history-browser.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrl = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrl);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrl;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n // caching fragment value to prevent triggering load same URL twice\n // as this could potentially trigger hashchange or pushstate\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n // without decoding the fragment\n // _loadUrl will be trigger twice if there are special character in the URL\n return decodeURIComponent('/' + fragment.replace(routeStripper, ''));\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n // a guard to prevent triggering load same URL twice\n // typically happens when calling navigate from router\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n Def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QAAQ,CAAC;KACjC;CACF;AAED,SAAS,YAAY,CAAC,QAAgB,EAAE,QAAgB,EAAE,IAAY;IACpE,OAAU,QAAQ,UAAK,QAAQ,IAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,CAAE,CAAC;CAC5D;;SCrUe,SAAS,CAAC,MAAc;IAEtC,IAAM,OAAO,GAAG,MAAa,CAAC;IAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;CACpD;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n _checkUrlCallback: any;\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrlCallback = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrlCallback);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrlCallback;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n return '/' + fragment.replace(routeStripper, '');\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":["tslib_1.__extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOA;KAYC;IANC,8BAAQ,GAAR,UAAS,OAAuB,KAAc;IAK9C,gCAAU,GAAV,eAAyB;IAC3B,kBAAC;CAAA,IAAA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IAAM,OAAO,GAAG,MAAa,CAAC;IAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;CACpD;;;;"} \ No newline at end of file diff --git a/dist/system/aurelia-history-browser.js b/dist/system/aurelia-history-browser.js index cb6c9ba..a870334 100644 --- a/dist/system/aurelia-history-browser.js +++ b/dist/system/aurelia-history-browser.js @@ -121,7 +121,7 @@ System.register(['aurelia-history', 'aurelia-pal'], function (exports, module) { function BrowserHistory(linkHandler) { var _this = _super.call(this) || this; _this._isActive = false; - _this._checkUrl = _this._checkUrl.bind(_this); + _this._checkUrlCallback = _this._checkUrl.bind(_this); _this.location = PLATFORM.location; _this.history = PLATFORM.history; _this.linkHandler = linkHandler; @@ -145,7 +145,7 @@ System.register(['aurelia-history', 'aurelia-pal'], function (exports, module) { else if (wantsHashChange) { eventName = 'hashchange'; } - PLATFORM.addEventListener(eventName, this._checkUrl); + PLATFORM.addEventListener(eventName, this._checkUrlCallback); if (wantsHashChange && wantsPushState) { var $location = this.location; var atRoot = $location.pathname.replace(/[^\/]$/, '$&/') === rootUrl; @@ -168,7 +168,7 @@ System.register(['aurelia-history', 'aurelia-pal'], function (exports, module) { } }; BrowserHistory.prototype.deactivate = function () { - var handler = this._checkUrl; + var handler = this._checkUrlCallback; PLATFORM.removeEventListener('popstate', handler); PLATFORM.removeEventListener('hashchange', handler); this._isActive = false; @@ -259,7 +259,7 @@ System.register(['aurelia-history', 'aurelia-pal'], function (exports, module) { fragment = this._getHash(); } } - return decodeURIComponent('/' + fragment.replace(routeStripper, '')); + return '/' + fragment.replace(routeStripper, ''); }; BrowserHistory.prototype._checkUrl = function () { var current = this._getFragment(''); diff --git a/dist/system/aurelia-history-browser.js.map b/dist/system/aurelia-history-browser.js.map index b3b9f88..e743647 100644 --- a/dist/system/aurelia-history-browser.js.map +++ b/dist/system/aurelia-history-browser.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrl = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrl);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrl;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n // caching fragment value to prevent triggering load same URL twice\n // as this could potentially trigger hashchange or pushstate\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n // without decoding the fragment\n // _loadUrl will be trigger twice if there are special character in the URL\n return decodeURIComponent('/' + fragment.replace(routeStripper, ''));\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n // a guard to prevent triggering load same URL twice\n // typically happens when calling navigate from router\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":["tslib_1.__extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAOA;iBAYC;gBANC,8BAAQ,GAAR,UAAS,OAAuB,KAAc;gBAK9C,gCAAU,GAAV,eAAyB;gBAC3B,kBAAC;YAAD,CAAC,KAAA;;gBAMuCA,sCAAW;gBAUjD;oBAAA,YACE,iBAAO,SAUR;oBARC,KAAI,CAAC,OAAO,GAAG,UAAC,CAAC;wBACX,IAAA,uCAAgE,EAA9D,wCAAiB,EAAE,cAA2C,CAAC;wBAErE,IAAI,iBAAiB,EAAE;4BACrB,CAAC,CAAC,cAAc,EAAE,CAAC;4BACnB,KAAI,CAAC,OAAO,CAAC,QAA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AC;;qBCrUe,SAAS,CAAC,MAAc;gBAEtC,IAAM,OAAO,GAAG,MAAa,CAAC;gBAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;gBAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;YACrD,CAAC;;;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-history-browser.js","sources":["../../src/link-handler.ts","../../src/browser-history.ts","../../src/aurelia-history-browser.ts"],"sourcesContent":["import { DOM, PLATFORM } from 'aurelia-pal';\nimport { BrowserHistory } from './browser-history';\nimport { AnchorEventInfo } from './interfaces';\n\n/**\n * Class responsible for handling interactions that should trigger browser history navigations.\n */\nexport class LinkHandler {\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {/**/}\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {/**/}\n}\n\n/**\n * The default LinkHandler implementation. Navigations are triggered by click events on\n * anchor elements with relative hrefs when the history instance is using pushstate.\n */\nexport class DefaultLinkHandler extends LinkHandler {\n\n /**@internal */\n handler: (e: Event) => void;\n\n /**@internal */\n history: BrowserHistory;\n /**\n * Creates an instance of DefaultLinkHandler.\n */\n constructor() {\n super();\n\n this.handler = (e) => {\n let { shouldHandleEvent, href } = DefaultLinkHandler.getEventInfo(e);\n\n if (shouldHandleEvent) {\n e.preventDefault();\n this.history.navigate(href);\n }\n };\n }\n\n /**\n * Activate the instance.\n *\n * @param history The BrowserHistory instance that navigations should be dispatched to.\n */\n activate(history: BrowserHistory): void {\n if (history._hasPushState) {\n this.history = history;\n DOM.addEventListener('click', this.handler, true);\n }\n }\n\n /**\n * Deactivate the instance. Event handlers and other resources should be cleaned up here.\n */\n deactivate(): void {\n DOM.removeEventListener('click', this.handler, true);\n }\n\n /**\n * Gets the href and a \"should handle\" recommendation, given an Event.\n *\n * @param event The Event to inspect for target anchor and href.\n */\n static getEventInfo(event: Event): AnchorEventInfo {\n let $event = event as MouseEvent;\n let info = {\n shouldHandleEvent: false,\n href: null,\n anchor: null\n };\n\n let target = DefaultLinkHandler.findClosestAnchor($event.target as Element);\n if (!target || !DefaultLinkHandler.targetIsThisWindow(target)) {\n return info;\n }\n\n if (hasAttribute(target, 'download')\n || hasAttribute(target, 'router-ignore')\n || hasAttribute(target, 'data-router-ignore')\n ) {\n return info;\n }\n\n if ($event.altKey || $event.ctrlKey || $event.metaKey || $event.shiftKey) {\n return info;\n }\n\n let href = target.getAttribute('href');\n info.anchor = target;\n info.href = href;\n\n let leftButtonClicked = $event.which === 1;\n let isRelative = href && !(href.charAt(0) === '#' || (/^[a-z]+:/i).test(href));\n\n info.shouldHandleEvent = leftButtonClicked && isRelative;\n return info;\n }\n\n /**\n * Finds the closest ancestor that's an anchor element.\n *\n * @param el The element to search upward from.\n * @returns The link element that is the closest ancestor.\n */\n static findClosestAnchor(el: Element): Element {\n while (el) {\n if (el.tagName === 'A') {\n return el;\n }\n\n el = el.parentNode as Element;\n }\n }\n\n /**\n * Gets a value indicating whether or not an anchor targets the current window.\n *\n * @param target The anchor element whose target should be inspected.\n * @returns True if the target of the link element is this window; false otherwise.\n */\n static targetIsThisWindow(target: Element): boolean {\n let targetWindow = target.getAttribute('target');\n let win = PLATFORM.global;\n\n return !targetWindow ||\n targetWindow === win.name ||\n targetWindow === '_self';\n }\n}\n\nconst hasAttribute = (el: Element, attr: string) => el.hasAttribute(attr);\n","import { DOM, PLATFORM } from 'aurelia-pal';\nimport { LinkHandler } from './link-handler';\nimport { History } from 'aurelia-history';\n\n/**\n * An implementation of the basic history API.\n */\nexport class BrowserHistory extends History {\n /**@internal */\n static inject = [LinkHandler];\n\n /**@internal */\n _isActive: boolean;\n\n /**@internal*/\n _checkUrlCallback: any;\n /**@internal*/\n location: Location;\n /**@internal*/\n history: typeof PLATFORM['history'];\n /**@internal*/\n linkHandler: LinkHandler;\n /**@internal*/\n options: any;\n /**@internal*/\n root: string;\n /**@internal*/\n _wantsHashChange: boolean;\n /**@internal*/\n _hasPushState: boolean;\n /**@internal*/\n fragment: string;\n\n /**\n * Creates an instance of BrowserHistory\n * @param linkHandler An instance of LinkHandler.\n */\n constructor(linkHandler: LinkHandler) {\n super();\n\n this._isActive = false;\n this._checkUrlCallback = this._checkUrl.bind(this);\n\n this.location = PLATFORM.location;\n this.history = PLATFORM.history;\n this.linkHandler = linkHandler;\n }\n\n /**\n * Activates the history object.\n * @param options The set of options to activate history with.\n * @returns Whether or not activation occurred.\n */\n activate(options?: Object): boolean {\n if (this._isActive) {\n throw new Error('History has already been activated.');\n }\n\n let $history = this.history;\n let wantsPushState = !!(options as any).pushState;\n\n this._isActive = true;\n let normalizedOptions = this.options = Object.assign({}, { root: '/' }, this.options, options);\n\n // Normalize root to always include a leading and trailing slash.\n let rootUrl = this.root = ('/' + normalizedOptions.root + '/').replace(rootStripper, '/');\n\n let wantsHashChange = this._wantsHashChange = normalizedOptions.hashChange !== false;\n let hasPushState = this._hasPushState = !!(normalizedOptions.pushState && $history && $history.pushState);\n\n // Determine how we check the URL state.\n let eventName: string;\n if (hasPushState) {\n eventName = 'popstate';\n } else if (wantsHashChange) {\n eventName = 'hashchange';\n }\n\n PLATFORM.addEventListener(eventName, this._checkUrlCallback);\n\n // Determine if we need to change the base url, for a pushState link\n // opened by a non-pushState browser.\n if (wantsHashChange && wantsPushState) {\n // Transition from hashChange to pushState or vice versa if both are requested.\n let $location = this.location;\n let atRoot = $location.pathname.replace(/[^\\/]$/, '$&/') === rootUrl;\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!hasPushState && !atRoot) {\n let fragment = this.fragment = this._getFragment(null, true);\n $location.replace(rootUrl + $location.search + '#' + fragment);\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (hasPushState && atRoot && $location.hash) {\n let fragment = this.fragment = this._getHash().replace(routeStripper, '');\n $history.replaceState({}, DOM.title, rootUrl + fragment + $location.search);\n }\n }\n\n if (!this.fragment) {\n this.fragment = this._getFragment('');\n }\n\n this.linkHandler.activate(this);\n\n if (!normalizedOptions.silent) {\n return this._loadUrl('');\n }\n }\n\n /**\n * Deactivates the history object.\n */\n deactivate(): void {\n const handler = this._checkUrlCallback;\n PLATFORM.removeEventListener('popstate', handler);\n PLATFORM.removeEventListener('hashchange', handler);\n this._isActive = false;\n this.linkHandler.deactivate();\n }\n\n /**\n * Returns the fully-qualified root of the current history object.\n * @returns The absolute root of the application.\n */\n getAbsoluteRoot(): string {\n let $location = this.location;\n let origin = createOrigin($location.protocol, $location.hostname, $location.port);\n return `${origin}${this.root}`;\n }\n\n /**\n * Causes a history navigation to occur.\n *\n * @param fragment The history fragment to navigate to.\n * @param options The set of options that specify how the navigation should occur.\n * @return Promise if triggering navigation, otherwise true/false indicating if navigation occurred.\n */\n navigate(fragment?: string, {trigger = true, replace = false} = {}): boolean {\n let location = this.location;\n if (fragment && absoluteUrl.test(fragment)) {\n location.href = fragment;\n return true;\n }\n\n if (!this._isActive) {\n return false;\n }\n\n fragment = this._getFragment(fragment || '');\n\n if (this.fragment === fragment && !replace) {\n return false;\n }\n\n this.fragment = fragment;\n\n let url = this.root + fragment;\n\n // Don't include a trailing slash on the root.\n if (fragment === '' && url !== '/') {\n url = url.slice(0, -1);\n }\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._hasPushState) {\n url = url.replace('//', '/');\n this.history[replace ? 'replaceState' : 'pushState']({}, DOM.title, url);\n } else if (this._wantsHashChange) {\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n updateHash(location, fragment, replace);\n } else {\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n location.assign(url);\n }\n\n if (trigger) {\n return this._loadUrl(fragment);\n }\n\n return true;\n }\n\n /**\n * Causes the history state to navigate back.\n */\n navigateBack(): void {\n this.history.back();\n }\n\n /**\n * Sets the document title.\n */\n setTitle(title: string): void {\n DOM.title = title;\n }\n\n /**\n * Sets a key in the history page state.\n * @param key The key for the value.\n * @param value The value to set.\n */\n setState(key: string, value: any): void {\n let $history = this.history;\n let state = Object.assign({}, $history.state);\n let { pathname, search, hash } = this.location;\n state[key] = value;\n $history.replaceState(state, null, `${pathname}${search}${hash}`);\n }\n\n /**\n * Gets a key in the history page state.\n * @param key The key for the value.\n * @return The value for the key.\n */\n getState(key: string): any {\n let state = Object.assign({}, this.history.state);\n return state[key];\n }\n\n /**\n * Returns the current index in the navigation history.\n * @returns The current index.\n */\n getHistoryIndex(): number {\n let historyIndex = this.getState('HistoryIndex');\n if (historyIndex === undefined) {\n historyIndex = this.history.length - 1;\n this.setState('HistoryIndex', historyIndex);\n }\n return historyIndex;\n }\n\n /**\n * Move to a specific position in the navigation history.\n * @param movement The amount of steps, positive or negative, to move.\n */\n go(movement: number): void {\n this.history.go(movement);\n }\n\n /**\n * @internal\n */\n _getHash(): string {\n return this.location.hash.substr(1);\n }\n\n /**\n * @internal\n */\n _getFragment(fragment: string, forcePushState?: boolean): string {\n let rootUrl: string;\n\n if (!fragment) {\n if (this._hasPushState || !this._wantsHashChange || forcePushState) {\n let location = this.location;\n fragment = location.pathname + location.search;\n rootUrl = this.root.replace(trailingSlash, '');\n if (!fragment.indexOf(rootUrl)) {\n fragment = fragment.substr(rootUrl.length);\n }\n } else {\n fragment = this._getHash();\n }\n }\n\n return '/' + fragment.replace(routeStripper, '');\n }\n\n /**\n * Url change handler.\n * Invoked when current fragment is different with previous fragment\n * @internal\n */\n _checkUrl(): void {\n let current = this._getFragment('');\n if (current !== this.fragment) {\n this._loadUrl('');\n }\n }\n\n /**\n * invoke routeHandler\n * @internal\n */\n _loadUrl(fragmentOverride: string): boolean {\n let fragment = this.fragment = this._getFragment(fragmentOverride);\n\n return this.options.routeHandler ?\n this.options.routeHandler(fragment) :\n false;\n }\n}\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nconst routeStripper = /^#?\\/*|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nconst rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for removing a trailing slash.\nconst trailingSlash = /\\/$/;\n\n// Cached regex for detecting if a URL is absolute,\n// i.e., starts with a scheme or is scheme-relative.\n// See http://www.ietf.org/rfc/rfc2396.txt section 3.1 for valid scheme format\nconst absoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n\n// Update the hash location, either replacing the current entry, or adding\n// a new one to the browser history.\nfunction updateHash($location: Location, fragment: string, replace: boolean) {\n if (replace) {\n let href = $location.href.replace(/(javascript:|#).*$/, '');\n $location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n $location.hash = '#' + fragment;\n }\n}\n\nfunction createOrigin(protocol: string, hostname: string, port: string) {\n return `${protocol}//${hostname}${port ? ':' + port : ''}`;\n}\n","import {History} from 'aurelia-history';\nimport {LinkHandler, DefaultLinkHandler} from './link-handler';\nimport { BrowserHistory } from './browser-history';\n\n/**\n * Configures the plugin by registering BrowserHistory as the implementation of History in the DI container.\n * @param config The FrameworkConfiguration object provided by Aurelia.\n */\nexport function configure(config: Object): void {\n // work around for converting to TS without breaking compat\n const $config = config as any;\n $config.singleton(History, BrowserHistory);\n $config.transient(LinkHandler, DefaultLinkHandler);\n}\n\nexport {\n LinkHandler,\n DefaultLinkHandler,\n BrowserHistory\n};\n"],"names":["tslib_1.__extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAOA;iBAYC;gBANC,8BAAQ,GAAR,UAAS,OAAuB,KAAc;gBAK9C,gCAAU,GAAV,eAAyB;gBAC3B,kBAAC;YAAD,CAAC,KAAA;;gBAMuCA,sCAAW;gBAUjD;oBAAA,YACE,iBAAO,SAUR;oBARC,KAAI,CAAC,OAAO,GAAG,UAAC,CAAC;wBACX,IAAA,uCAAgE,EAA9D,wCAAiB,EAAE,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,OAAU,QAAQ,UAAK,QAAQ,IAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,EAAE,CAAE,CAAC;YAC7D,CAAC;;qBCjUe,SAAS,CAAC,MAAc;gBAEtC,IAAM,OAAO,GAAG,MAAa,CAAC;gBAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;gBAC3C,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;YACrD,CAAC;;;;;;"} \ No newline at end of file diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 33dce05..bd2ed5e 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,16 +1,12 @@ -## [1.3.2](https://github.com/aurelia/history-browser/compare/1.3.1...1.3.2) (2019-04-22) - +# [1.4.0](https://github.com/aurelia/history-browser/compare/1.3.2...1.4.0) (2019-05-31) ### Bug Fixes * **browser-history:** decode fragment, add tests ([957532d](https://github.com/aurelia/history-browser/commit/957532d)) - ## [1.3.2](https://github.com/aurelia/history-browser/compare/1.3.1...1.3.2) (2019-04-20) - - <a name="1.3.2"></a> ## [1.3.2](https://github.com/aurelia/history-browser/compare/1.3.0...1.3.2) (2019-03-27) diff --git a/package-lock.json b/package-lock.json index 94d1883..3f1943f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "aurelia-history-browser", - "version": "1.3.1", + "version": "1.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f7a1e12..17c5053 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-history-browser", - "version": "1.3.2", + "version": "1.4.0", "description": "An implementation of the Aurelia history interface based on standard browser hash change and push state mechanisms.", "keywords": [ "aurelia",