swup 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Swup.umd.js","sources":["../src/helpers/classify.ts","../src/helpers/getCurrentUrl.ts","../src/helpers/updateHistoryRecord.ts","../node_modules/delegate-it/index.js","../src/helpers/delegateEvent.ts","../src/utils/index.ts","../src/helpers/Location.ts","../src/helpers/markSwupElements.ts","../src/helpers/cleanupAnimationClasses.ts","../src/modules/Cache.ts","../src/modules/enterPage.ts","../src/modules/getAnchorElement.ts","../src/modules/getAnimationPromises.ts","../src/modules/getPageData.ts","../src/helpers/getDataFromHtml.ts","../src/modules/fetchPage.ts","../src/helpers/fetch.ts","../src/modules/leavePage.ts","../src/modules/loadPage.ts","../src/helpers/createHistoryRecord.ts","../src/modules/replaceContent.ts","../src/modules/events.ts","../src/modules/plugins.ts","../src/modules/renderPage.ts","../src/modules/transitions.ts","../src/Swup.ts"],"sourcesContent":["export const classify = (text: string, fallback?: string): string => {\n\tconst output = String(text)\n\t\t.toLowerCase()\n\t\t// .normalize('NFD') // split an accented letter in the base letter and the acent\n\t\t// .replace(/[\\u0300-\\u036f]/g, '') // remove all previously split accents\n\t\t.replace(/[\\s/_.]+/g, '-') // replace spaces and _./ with '-'\n\t\t.replace(/[^\\w-]+/g, '') // remove all non-word chars\n\t\t.replace(/--+/g, '-') // replace repeating '-' with single '-'\n\t\t.replace(/^-+|-+$/g, ''); // trim '-' from edges\n\treturn output || fallback || '';\n};\n","export const getCurrentUrl = ({ hash }: { hash?: boolean } = {}): string => {\n\treturn location.pathname + location.search + (hash ? location.hash : '');\n};\n","import { getCurrentUrl } from './getCurrentUrl';\n\nexport const updateHistoryRecord = (\n\turl: string | null = null,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\t...history.state,\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.replaceState(data, '', url);\n};\n","/** Keeps track of raw listeners added to the base elements to avoid duplication */\nconst ledger = new WeakMap();\nfunction editLedger(wanted, baseElement, callback, setup) {\n var _a, _b;\n if (!wanted && !ledger.has(baseElement)) {\n return false;\n }\n const elementMap = (_a = ledger.get(baseElement)) !== null && _a !== void 0 ? _a : new WeakMap();\n ledger.set(baseElement, elementMap);\n if (!wanted && !ledger.has(baseElement)) {\n return false;\n }\n const setups = (_b = elementMap.get(callback)) !== null && _b !== void 0 ? _b : new Set();\n elementMap.set(callback, setups);\n const existed = setups.has(setup);\n if (wanted) {\n setups.add(setup);\n }\n else {\n setups.delete(setup);\n }\n return existed && wanted;\n}\nfunction isEventTarget(elements) {\n return typeof elements.addEventListener === 'function';\n}\nfunction safeClosest(event, selector) {\n let target = event.target;\n if (target instanceof Text) {\n target = target.parentElement;\n }\n if (target instanceof Element && event.currentTarget instanceof Element) {\n // `.closest()` may match ancestors of `currentTarget` but we only need its children\n const closest = target.closest(selector);\n if (closest && event.currentTarget.contains(closest)) {\n return closest;\n }\n }\n}\n// This type isn't exported as a declaration, so it needs to be duplicated above\nfunction delegate(base, selector, type, callback, options) {\n // Handle Selector-based usage\n if (typeof base === 'string') {\n base = document.querySelectorAll(base);\n }\n // Handle Array-like based usage\n if (!isEventTarget(base)) {\n const subscriptions = Array.prototype.map.call(base, (element) => delegate(element, selector, type, callback, options));\n return {\n destroy() {\n for (const subscription of subscriptions) {\n subscription.destroy();\n }\n },\n };\n }\n // `document` should never be the base, it's just an easy way to define \"global event listeners\"\n const baseElement = base instanceof Document ? base.documentElement : base;\n // Handle the regular Element usage\n const capture = Boolean(typeof options === 'object' ? options.capture : options);\n const listenerFn = (event) => {\n const delegateTarget = safeClosest(event, selector);\n if (delegateTarget) {\n event.delegateTarget = delegateTarget;\n callback.call(baseElement, event);\n }\n };\n // Drop unsupported `once` option https://github.com/fregante/delegate-it/pull/28#discussion_r863467939\n if (typeof options === 'object') {\n delete options.once;\n }\n const setup = JSON.stringify({ selector, type, capture });\n const isAlreadyListening = editLedger(true, baseElement, callback, setup);\n const delegateSubscription = {\n destroy() {\n baseElement.removeEventListener(type, listenerFn, options);\n editLedger(false, baseElement, callback, setup);\n },\n };\n if (!isAlreadyListening) {\n baseElement.addEventListener(type, listenerFn, options);\n }\n return delegateSubscription;\n}\nexport default delegate;\n","import delegate, { EventType } from 'delegate-it';\nimport { ParseSelector } from 'typed-query-selector/parser';\n\nexport type Unsubscribe = {\n\tdestroy: () => void;\n};\nexport const delegateEvent = <Selector extends string, TEvent extends EventType>(\n\tselector: Selector,\n\ttype: TEvent,\n\tcallback: delegate.EventHandler<GlobalEventHandlersEventMap[TEvent]>,\n\t{ base = document, ...eventOptions } = {}\n): Unsubscribe => {\n\tconst delegation = delegate<string, ParseSelector<Selector, HTMLElement>, TEvent>(\n\t\tbase,\n\t\tselector,\n\t\ttype,\n\t\tcallback,\n\t\teventOptions\n\t);\n\treturn { destroy: () => delegation.destroy() };\n};\n","export const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector<HTMLElement>(selector);\n};\n\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\nexport const nextTick = (callback: () => void) => {\n\trequestAnimationFrame(() => {\n\t\trequestAnimationFrame(() => {\n\t\t\tcallback();\n\t\t});\n\t});\n};\n\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t} else {\n\t\treturn ident;\n\t}\n};\n\n// Fix for Chrome below v61 formatting CSS floats with comma in some locales\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n","/**\n * A helper for creating a Location from either an element\n * or a URL object/string\n *\n */\n\nexport class Location extends URL {\n\tconstructor(url: string, base: string = document.baseURI) {\n\t\tsuper(url.toString(), base);\n\t}\n\n\tget url() {\n\t\treturn this.pathname + this.search;\n\t}\n\n\t/**\n\t * Instantiate a Location from an element's href attribute\n\t * @param {Element} el\n\t * @return new Location instance\n\t */\n\tstatic fromElement(el: HTMLAnchorElement): Location {\n\t\tconst href = el.getAttribute('href') || el.getAttribute('xlink:href');\n\t\treturn new Location(href!);\n\t}\n\n\t/**\n\t * Instantiate a Location from a URL object or string\n\t * @param {URL|string} url\n\t * @return new Location instance\n\t */\n\tstatic fromUrl(url: string): Location {\n\t\treturn new Location(url);\n\t}\n}\n","import { query, queryAll } from '../utils';\n\nexport const markSwupElements = (element: Element, containers: string[]): void => {\n\tlet blocks = 0;\n\n\tcontainers.forEach((selector) => {\n\t\tif (query(selector, element) == null) {\n\t\t\tconsole.warn(`[swup] Container ${selector} not found on page.`);\n\t\t} else {\n\t\t\tqueryAll(selector).forEach((item: Element, index: number) => {\n\t\t\t\tqueryAll(selector, element)[index].setAttribute('data-swup', String(blocks));\n\t\t\t\tblocks++;\n\t\t\t});\n\t\t}\n\t});\n};\n","export const isSwupClass = (className: string): boolean =>\n\t/^to-/.test(className) || ['is-changing', 'is-rendering', 'is-popstate'].includes(className);\n\nexport const cleanupAnimationClasses = (): void => {\n\tconst htmlClasses = document.documentElement.className.split(' ');\n\tconst removeClasses = htmlClasses.filter(isSwupClass);\n\tdocument.documentElement.classList.remove(...removeClasses);\n};\n","import { getCurrentUrl, Location } from '../helpers';\nimport Swup from '../Swup';\nimport { PageData } from './getPageData';\n\nexport interface PageRecord extends PageData {\n\turl: string;\n\tresponseURL: string;\n}\nexport class Cache {\n\tpages: Record<string, PageRecord> = {};\n\tlast: PageRecord | null = null;\n\tswup: Swup;\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\tgetCacheUrl(url: string): string {\n\t\treturn this.swup.resolveUrl(Location.fromUrl(url).url);\n\t}\n\n\tcacheUrl(page: PageRecord) {\n\t\tpage.url = this.getCacheUrl(page.url);\n\t\tif (page.url in this.pages === false) {\n\t\t\tthis.pages[page.url] = page;\n\t\t}\n\t\tpage.responseURL = this.getCacheUrl(page.responseURL);\n\t\tthis.last = this.pages[page.url];\n\t\tthis.swup.log(`Cache (${Object.keys(this.pages).length})`, this.pages);\n\t}\n\n\tgetPage(url: string): PageRecord {\n\t\turl = this.getCacheUrl(url);\n\t\treturn this.pages[url];\n\t}\n\n\tgetCurrentPage(): PageRecord {\n\t\treturn this.getPage(getCurrentUrl());\n\t}\n\n\texists(url: string): boolean {\n\t\turl = this.getCacheUrl(url);\n\t\treturn url in this.pages;\n\t}\n\n\tempty(): void {\n\t\tthis.pages = {};\n\t\tthis.last = null;\n\t\tthis.swup.log('Cache cleared');\n\t}\n\n\tremove(url: string): void {\n\t\tdelete this.pages[this.getCacheUrl(url)];\n\t}\n}\n","import { nextTick } from '../utils';\nimport Swup from '../Swup';\nimport { PageRenderOptions } from './renderPage';\n\nexport const enterPage = function (this: Swup, { event, skipTransition }: PageRenderOptions = {}) {\n\tif (skipTransition) {\n\t\tthis.triggerEvent('transitionEnd', event);\n\t\tthis.cleanupAnimationClasses();\n\t\treturn [Promise.resolve()];\n\t}\n\n\tnextTick(() => {\n\t\tthis.triggerEvent('animationInStart');\n\t\tdocument.documentElement.classList.remove('is-animating');\n\t});\n\n\tconst animationPromises = this.getAnimationPromises('in');\n\tPromise.all(animationPromises).then(() => {\n\t\tthis.triggerEvent('animationInDone');\n\t\tthis.triggerEvent('transitionEnd', event);\n\t\tthis.cleanupAnimationClasses();\n\t});\n\treturn animationPromises;\n};\n","import { escapeCssIdentifier, query } from '../utils';\n\nexport const getAnchorElement = (hash: string): Element | null => {\n\tif (!hash) {\n\t\treturn null;\n\t}\n\n\tif (hash.charAt(0) === '#') {\n\t\thash = hash.substring(1);\n\t}\n\n\thash = decodeURIComponent(hash);\n\thash = escapeCssIdentifier(hash);\n\n\t// https://html.spec.whatwg.org/#find-a-potential-indicated-element\n\treturn query(`#${hash}`) || query(`a[name='${hash}']`);\n};\n","import { queryAll, toMs } from '../utils';\nimport Swup from '../Swup';\n\n// Transition property/event sniffing\nlet transitionProp = 'transition';\nlet transitionEndEvent = 'transitionend';\nlet animationProp = 'animation';\nlet animationEndEvent = 'animationend';\n\nif (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {\n\ttransitionProp = 'WebkitTransition';\n\ttransitionEndEvent = 'webkitTransitionEnd';\n}\n\nif (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {\n\tanimationProp = 'WebkitAnimation';\n\tanimationEndEvent = 'webkitAnimationEnd';\n}\n\nexport function getAnimationPromises(\n\tthis: Swup,\n\t// we don't use this argument, but JS plugin depends on it with\n\t// its own version of getAnimationPromises, so it must be specified when\n\t// getAnimationPromises is being used\n\tanimationType: 'in' | 'out'\n): Promise<void>[] {\n\tconst selector = this.options.animationSelector;\n\n\t// Allow usage of swup without animations\n\tif (selector === false) {\n\t\t// Use array of a single resolved promise instead of an empty array to allow\n\t\t// possible future use with Promise.race() which requires an actual value\n\t\treturn [Promise.resolve()];\n\t}\n\n\tconst animatedElements = queryAll(selector, document.body);\n\n\t// Warn if no animated containers found on page, but keep things going\n\tif (!animatedElements.length) {\n\t\tconsole.warn(`[swup] No animated elements found by selector ${selector}`);\n\t\treturn [Promise.resolve()];\n\t}\n\n\treturn animatedElements.map((element) => getAnimationPromiseForElement(element, selector));\n}\n\nconst isTransitionOrAnimationEvent = (event: any): event is TransitionEvent | AnimationEvent =>\n\t!!event.elapsedTime;\n\nfunction getAnimationPromiseForElement(\n\telement: Element,\n\tselector: string,\n\texpectedType: 'animation' | 'transition' | null = null\n): Promise<void> {\n\tconst { type, timeout, propCount } = getTransitionInfo(element, expectedType);\n\n\t// Resolve immediately if no transition defined\n\tif (!type || !timeout) {\n\t\tconsole.warn(\n\t\t\t`[swup] No CSS transition duration defined for element of selector ${selector}`\n\t\t);\n\t\treturn Promise.resolve();\n\t}\n\n\treturn new Promise((resolve) => {\n\t\tconst endEvent = type === 'transition' ? transitionEndEvent : animationEndEvent;\n\t\tconst startTime = performance.now();\n\t\tlet propsTransitioned = 0;\n\n\t\tconst end = () => {\n\t\t\telement.removeEventListener(endEvent, onEnd);\n\t\t\tresolve();\n\t\t};\n\n\t\tconst onEnd: EventListener = (event) => {\n\t\t\t// Skip transitions on child elements\n\t\t\tif (event.target !== element) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isTransitionOrAnimationEvent(event)) {\n\t\t\t\tthrow new Error('Not a transition or animation event.');\n\t\t\t}\n\n\t\t\t// Skip transitions that happened before we started listening\n\t\t\tconst elapsedTime = (performance.now() - startTime) / 1000;\n\t\t\tif (elapsedTime < event.elapsedTime) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// End if all properties have transitioned\n\t\t\tif (++propsTransitioned >= propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t};\n\n\t\tsetTimeout(() => {\n\t\t\tif (propsTransitioned < propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t}, timeout + 1);\n\n\t\telement.addEventListener(endEvent, onEnd);\n\t});\n}\n\nexport function getTransitionInfo(\n\telement: Element,\n\texpectedType: 'animation' | 'transition' | null = null\n) {\n\tconst styles = window.getComputedStyle(element);\n\n\t// not sure what to do about the below mess other than casting, but it's a mess\n\tconst transitionDelay = `${transitionProp}Delay` as keyof CSSStyleDeclaration;\n\tconst transitionDuration = `${transitionProp}Duration` as keyof CSSStyleDeclaration;\n\tconst animationDelay = `${animationProp}Delay` as keyof CSSStyleDeclaration;\n\tconst animationDuration = `${animationProp}Duration` as keyof CSSStyleDeclaration;\n\n\tconst transitionDelays = (\n\t\tstyles[transitionDelay] as CSSStyleDeclaration['transitionDelay']\n\t).split(', ');\n\tconst transitionDurations = (\n\t\t(styles[transitionDuration] || '') as CSSStyleDeclaration['transitionDuration']\n\t).split(', ');\n\tconst transitionTimeout = calculateTimeout(transitionDelays, transitionDurations);\n\n\tconst animationDelays = (\n\t\t(styles[animationDelay] || '') as CSSStyleDeclaration['animationDelay']\n\t).split(', ');\n\tconst animationDurations = (\n\t\t(styles[animationDuration] || '') as CSSStyleDeclaration['animationDuration']\n\t).split(', ');\n\tconst animationTimeout = calculateTimeout(animationDelays, animationDurations);\n\n\tlet type: string | null = '';\n\tlet timeout = 0;\n\tlet propCount = 0;\n\n\tif (expectedType === 'transition') {\n\t\tif (transitionTimeout > 0) {\n\t\t\ttype = 'transition';\n\t\t\ttimeout = transitionTimeout;\n\t\t\tpropCount = transitionDurations.length;\n\t\t}\n\t} else if (expectedType === 'animation') {\n\t\tif (animationTimeout > 0) {\n\t\t\ttype = 'animation';\n\t\t\ttimeout = animationTimeout;\n\t\t\tpropCount = animationDurations.length;\n\t\t}\n\t} else {\n\t\ttimeout = Math.max(transitionTimeout, animationTimeout);\n\t\ttype =\n\t\t\ttimeout > 0\n\t\t\t\t? transitionTimeout > animationTimeout\n\t\t\t\t\t? 'transition'\n\t\t\t\t\t: 'animation'\n\t\t\t\t: null;\n\t\tpropCount = type\n\t\t\t? type === 'transition'\n\t\t\t\t? transitionDurations.length\n\t\t\t\t: animationDurations.length\n\t\t\t: 0;\n\t}\n\n\treturn {\n\t\ttype,\n\t\ttimeout,\n\t\tpropCount\n\t};\n}\n\nfunction calculateTimeout(delays: string[], durations: string[]) {\n\twhile (delays.length < durations.length) {\n\t\tdelays = delays.concat(delays);\n\t}\n\n\treturn Math.max(...durations.map((duration, i) => toMs(duration) + toMs(delays[i])));\n}\n","import { getDataFromHtml } from '../helpers';\nimport Swup from '../Swup';\nimport { PageHtmlData } from '../helpers/getDataFromHtml';\n\nexport type PageData = PageHtmlData & {\n\tresponseURL: string;\n};\nexport const getPageData = function (this: Swup, request: XMLHttpRequest): PageData | null {\n\t// this method can be replaced in case other content than html is expected to be received from server\n\t// this function should always return { title, pageClass, originalContent, blocks, responseURL }\n\t// in case page has invalid structure - return null\n\tconst html = request.responseText;\n\tconst pageHtmlData = getDataFromHtml(html, this.options.containers);\n\n\tif (!pageHtmlData) {\n\t\tconsole.warn('[swup] Received page is invalid.');\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...pageHtmlData,\n\t\tresponseURL: request.responseURL || window.location.href\n\t};\n};\n","import { query, queryAll } from '../utils';\n\nexport type PageHtmlData = {\n\ttitle: string;\n\toriginalContent: string;\n\tblocks: string[];\n\tpageClass?: string;\n};\n\nexport const getDataFromHtml = (html: string, containers: string[]): PageHtmlData => {\n\tlet fakeDom = document.createElement('html');\n\tfakeDom.innerHTML = html;\n\tlet blocks: string[] = [];\n\n\tcontainers.forEach((selector) => {\n\t\tif (query(selector, fakeDom) == null) {\n\t\t\tconsole.warn(`[swup] Container ${selector} not found on page.`);\n\t\t\treturn null;\n\t\t} else {\n\t\t\tif (queryAll(selector).length !== queryAll(selector, fakeDom).length) {\n\t\t\t\tconsole.warn(`[swup] Mismatched number of containers found on new page.`);\n\t\t\t}\n\t\t\tqueryAll(selector).forEach((item, index) => {\n\t\t\t\tqueryAll(selector, fakeDom)[index].setAttribute('data-swup', String(blocks.length));\n\t\t\t\tblocks.push(queryAll(selector, fakeDom)[index].outerHTML);\n\t\t\t});\n\t\t}\n\t});\n\n\tconst title = query('title', fakeDom)?.innerText || '';\n\tconst pageClass = query('body', fakeDom)?.className;\n\n\t// to prevent memory leaks\n\tfakeDom.innerHTML = '';\n\t// @ts-ignore don't want to type it as possible null, since it's created at the top of the function always\n\tfakeDom = null;\n\n\treturn { title, pageClass, blocks, originalContent: html };\n};\n","import Swup from '../Swup';\nimport { fetch } from '../helpers';\nimport { TransitionOptions } from './loadPage';\nimport { PageRecord } from './Cache';\n\nexport function fetchPage(this: Swup, data: TransitionOptions): Promise<PageRecord> {\n\tconst headers = this.options.requestHeaders;\n\tconst { url } = data;\n\n\tif (this.cache.exists(url)) {\n\t\tthis.triggerEvent('pageRetrievedFromCache');\n\t\treturn Promise.resolve(this.cache.getPage(url));\n\t}\n\n\treturn new Promise((resolve, reject) => {\n\t\tfetch({ ...data, headers }, (response) => {\n\t\t\tif (response.status === 500) {\n\t\t\t\tthis.triggerEvent('serverError');\n\t\t\t\treject(url);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// get json data\n\t\t\tconst page = this.getPageData(response);\n\t\t\tif (!page || !page.blocks.length) {\n\t\t\t\treject(url);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// render page\n\t\t\tconst cacheablePageData = { ...page, url };\n\t\t\tthis.cache.cacheUrl(cacheablePageData);\n\t\t\tthis.triggerEvent('pageLoaded');\n\t\t\tresolve(cacheablePageData);\n\t\t});\n\t});\n}\n","import { TransitionOptions } from '../modules/loadPage';\nimport { Options } from '../Swup';\n\nexport const fetch = (\n\toptions: TransitionOptions & { headers: Options['requestHeaders'] },\n\tcallback: (request: XMLHttpRequest) => void\n): XMLHttpRequest => {\n\tconst defaults = {\n\t\turl: window.location.pathname + window.location.search,\n\t\tmethod: 'GET',\n\t\tdata: null,\n\t\theaders: {}\n\t};\n\n\tconst { url, method, headers, data } = { ...defaults, ...options };\n\n\tconst request = new XMLHttpRequest();\n\n\trequest.onreadystatechange = function () {\n\t\tif (request.readyState === 4) {\n\t\t\t// if (request.status === 500) {} else {}\n\t\t\tcallback(request);\n\t\t}\n\t};\n\n\trequest.open(method, url, true);\n\tObject.entries(headers).forEach(([key, header]) => {\n\t\trequest.setRequestHeader(key, header);\n\t});\n\trequest.send(data);\n\n\treturn request;\n};\n","import Swup from '../Swup';\nimport { PageRenderOptions } from './renderPage';\n\nexport const leavePage = function (this: Swup, { event, skipTransition }: PageRenderOptions = {}) {\n\tconst isHistoryVisit = event instanceof PopStateEvent;\n\n\tif (skipTransition) {\n\t\tthis.triggerEvent('animationSkipped');\n\t\treturn [Promise.resolve()];\n\t}\n\n\tthis.triggerEvent('animationOutStart');\n\n\t// handle classes\n\tdocument.documentElement.classList.add('is-changing', 'is-leaving', 'is-animating');\n\tif (isHistoryVisit) {\n\t\tdocument.documentElement.classList.add('is-popstate');\n\t}\n\n\t// animation promise stuff\n\tconst animationPromises: Promise<void>[] = this.getAnimationPromises('out');\n\tPromise.all(animationPromises).then(() => {\n\t\tthis.triggerEvent('animationOutDone');\n\t});\n\n\treturn animationPromises;\n};\n","import { classify, createHistoryRecord, getCurrentUrl } from '../helpers';\nimport Swup from '../Swup';\nimport { PageRecord } from './Cache';\n\nexport type TransitionOptions = {\n\turl: string;\n\tcustomTransition?: string;\n};\n\nexport type PageLoadOptions = {\n\turl: string;\n\tevent?: Event;\n\tcustomTransition?: string;\n};\n\nexport function loadPage(this: Swup, data: TransitionOptions) {\n\tconst { url } = data;\n\n\t// Check if the visit should be ignored\n\tif (this.shouldIgnoreVisit(url)) {\n\t\twindow.location.href = url;\n\t} else {\n\t\tthis.performPageLoad(data);\n\t}\n}\n\nexport function performPageLoad(this: Swup, data: PageLoadOptions) {\n\tconst { url, event, customTransition } = data ?? {};\n\n\tconst isHistoryVisit = event instanceof PopStateEvent;\n\tconst skipTransition = this.shouldSkipTransition({ url, event });\n\n\tthis.triggerEvent('transitionStart', event);\n\n\t// set transition object\n\tthis.updateTransition(getCurrentUrl(), url, customTransition);\n\tif (customTransition != null) {\n\t\tdocument.documentElement.classList.add(`to-${classify(customTransition)}`);\n\t}\n\n\t// start/skip animation\n\tconst animationPromises = this.leavePage({ event, skipTransition });\n\n\t// create history record if this is not a popstate call (with or without anchor)\n\tif (!isHistoryVisit) {\n\t\tcreateHistoryRecord(url + (this.scrollToElement || ''));\n\t}\n\n\tthis.currentPageUrl = getCurrentUrl();\n\n\t// Load page data\n\tconst fetchPromise = this.fetchPage(data);\n\n\t// when everything is ready, render the page\n\tPromise.all<PageRecord | void>([fetchPromise, ...animationPromises])\n\t\t.then(([pageData]) => {\n\t\t\tthis.renderPage(pageData as PageRecord, { event, skipTransition });\n\t\t})\n\t\t.catch((errorUrl) => {\n\t\t\t// Return early if errorUrl is not defined (probably aborted preload request)\n\t\t\tif (errorUrl === undefined) return;\n\n\t\t\t// Rewrite `skipPopStateHandling` to redirect manually when `history.go` is processed\n\t\t\tthis.options.skipPopStateHandling = () => {\n\t\t\t\twindow.location = errorUrl;\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t// Go back to the actual page we're still at\n\t\t\thistory.go(-1);\n\t\t});\n}\n","import { getCurrentUrl } from './getCurrentUrl';\n\nexport const createHistoryRecord = (\n\turl: string,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.pushState(data, '', url);\n};\n","/**\n * Perform the replacement of content after loading a page.\n *\n * This method can be replaced or augmented by plugins to allow pausing.\n *\n * It takes an object with the page data as return from `getPageData` and has to\n * return a Promise that resolves once all content has been replaced and the\n * site is ready to start animating in the new page.\n *\n * @param {object} page The page object\n * @returns Promise\n */\nexport const replaceContent = function ({ blocks, title }: { blocks: string[]; title: string }) {\n\t// Replace content blocks\n\tblocks.forEach((html, i) => {\n\t\t// we know the block exists at this point\n\t\tconst block = document.body.querySelector(`[data-swup=\"${i}\"]`)!;\n\t\tblock.outerHTML = html;\n\t});\n\n\t// Update browser title\n\tdocument.title = title;\n\n\t// Return a Promise to allow plugins to defer\n\treturn Promise.resolve();\n};\n","import Swup from '../Swup';\n\nexport type EventType =\n\t| 'animationInDone'\n\t| 'animationInStart'\n\t| 'animationOutDone'\n\t| 'animationOutStart'\n\t| 'animationSkipped'\n\t| 'clickLink'\n\t| 'contentReplaced'\n\t| 'disabled'\n\t| 'enabled'\n\t| 'openPageInNewTab'\n\t| 'pageLoaded'\n\t| 'pageRetrievedFromCache'\n\t| 'pageView'\n\t| 'popState'\n\t| 'samePage'\n\t| 'samePageWithHash'\n\t| 'serverError'\n\t| 'transitionStart'\n\t| 'transitionEnd'\n\t| 'willReplaceContent';\nexport type Handler = (event?: Event) => void;\nexport type Handlers = Record<EventType, Handler[]>;\n\nexport function on(this: Swup, event: EventType, handler: Handler) {\n\tif (this._handlers[event]) {\n\t\tthis._handlers[event].push(handler);\n\t} else {\n\t\tconsole.warn(`Unsupported event ${event}.`);\n\t}\n}\n\nexport function off(this: Swup, event?: EventType, handler?: Handler) {\n\tif (event && handler) {\n\t\t// Remove specific handler\n\t\tif (this._handlers[event].includes(handler)) {\n\t\t\tthis._handlers[event] = this._handlers[event].filter((h) => h !== handler);\n\t\t} else {\n\t\t\tconsole.warn(`Handler for event '${event}' not found.`);\n\t\t}\n\t} else if (event) {\n\t\t// Remove all handlers for specific event\n\t\tthis._handlers[event] = [];\n\t} else {\n\t\t// Remove all handlers for all events\n\t\tObject.keys(this._handlers).forEach((event) => {\n\t\t\tthis._handlers[event as EventType] = [];\n\t\t});\n\t}\n}\n\nexport function triggerEvent(this: Swup, eventName: EventType, originalEvent?: Event): void {\n\t// call saved handlers with \"on\" method and pass originalEvent object if available\n\tthis._handlers[eventName].forEach((handler) => {\n\t\ttry {\n\t\t\thandler(originalEvent);\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t});\n\n\t// trigger event on document with prefix \"swup:\"\n\tconst event = new CustomEvent(`swup:${eventName}`, { detail: eventName });\n\tdocument.dispatchEvent(event);\n}\n","import Swup from '../Swup';\n\nexport type Plugin = {\n\tname: string;\n\tisSwupPlugin: true;\n\tmount: () => void;\n\tunmount: () => void;\n\n\t// the instance is assigned later on after passing to swup\n\tswup?: Swup;\n\n\t// these are possibly undefined for backward compatibility\n\tversion?: string;\n\trequires?: Record<string, string>;\n\t_beforeMount?: () => void;\n\t_afterUnmount?: () => void;\n\t_checkRequirements?: () => boolean;\n};\n\nconst isSwupPlugin = (maybeInvalidPlugin: unknown): maybeInvalidPlugin is Plugin => {\n\t// @ts-ignore\n\treturn maybeInvalidPlugin?.isSwupPlugin;\n};\n\nexport const use = function (this: Swup, plugin: unknown) {\n\tif (!isSwupPlugin(plugin)) {\n\t\tconsole.error('Not a swup plugin instance', plugin);\n\t\treturn;\n\t}\n\n\tplugin.swup = this;\n\tif (plugin._checkRequirements) {\n\t\tif (!plugin._checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif (plugin._beforeMount) {\n\t\tplugin._beforeMount();\n\t}\n\tplugin.mount();\n\n\tthis.plugins.push(plugin);\n\n\treturn this.plugins;\n};\n\nexport function unuse(this: Swup, pluginOrName: Plugin | string) {\n\tconst plugin = this.findPlugin(pluginOrName);\n\tif (!plugin) {\n\t\tconsole.error('No such plugin', plugin);\n\t\treturn;\n\t}\n\n\tplugin.unmount();\n\tif (plugin._afterUnmount) {\n\t\tplugin._afterUnmount();\n\t}\n\n\tthis.plugins = this.plugins.filter((p) => p !== plugin);\n\n\treturn this.plugins;\n}\n\nexport function findPlugin(this: Swup, pluginOrName: Plugin | string) {\n\treturn this.plugins.find((plugin) => plugin === pluginOrName || plugin.name === pluginOrName);\n}\n","import { Location, updateHistoryRecord, getCurrentUrl } from '../helpers';\nimport Swup from '../Swup';\nimport { PageRecord } from './Cache';\n\nexport type PageRenderOptions = {\n\tevent?: Event;\n\tskipTransition?: boolean;\n};\n\nexport const renderPage = function (\n\tthis: Swup,\n\tpage: PageRecord,\n\t{ event, skipTransition }: PageRenderOptions = {}\n) {\n\tdocument.documentElement.classList.remove('is-leaving');\n\n\t// do nothing if another page was requested in the meantime\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), page.url)) {\n\t\treturn;\n\t}\n\n\tconst { url } = Location.fromUrl(page.responseURL);\n\n\t// update cache and state if the url was redirected\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), url)) {\n\t\tthis.cache.cacheUrl({ ...page, url });\n\t\tthis.currentPageUrl = getCurrentUrl();\n\t\tupdateHistoryRecord(url);\n\t}\n\n\t// only add for page loads with transitions\n\tif (!skipTransition) {\n\t\tdocument.documentElement.classList.add('is-rendering');\n\t}\n\n\tthis.triggerEvent('willReplaceContent', event);\n\n\tthis.replaceContent(page).then(() => {\n\t\tthis.triggerEvent('contentReplaced', event);\n\t\tthis.triggerEvent('pageView', event);\n\n\t\t// empty cache if it's disabled (in case preload plugin filled it)\n\t\tif (!this.options.cache) {\n\t\t\tthis.cache.empty();\n\t\t}\n\n\t\t// Perform in transition\n\t\tthis.enterPage({ event, skipTransition });\n\n\t\t// reset scroll-to element\n\t\tthis.scrollToElement = null;\n\t});\n};\n","import Swup from '../Swup';\n\nexport function updateTransition(this: Swup, from: string, to: string, custom?: string): void {\n\tthis.transition = { from, to, custom };\n}\n\nexport function shouldSkipTransition(this: Swup, { event }: { url?: string; event?: Event }) {\n\tconst isHistoryVisit = event instanceof PopStateEvent;\n\treturn !!(isHistoryVisit && !this.options.animateHistoryBrowsing);\n}\n","import delegate from 'delegate-it';\n\nimport version from './config/version';\n\nimport {\n\tcleanupAnimationClasses,\n\tdelegateEvent,\n\tgetCurrentUrl,\n\tLocation,\n\tmarkSwupElements,\n\tupdateHistoryRecord\n} from './helpers';\nimport { Unsubscribe } from './helpers/delegateEvent';\n\nimport { Cache } from './modules/Cache';\nimport { enterPage } from './modules/enterPage';\nimport { getAnchorElement } from './modules/getAnchorElement';\nimport { getAnimationPromises } from './modules/getAnimationPromises';\nimport { getPageData } from './modules/getPageData';\nimport { fetchPage } from './modules/fetchPage';\nimport { leavePage } from './modules/leavePage';\nimport { loadPage, performPageLoad } from './modules/loadPage';\nimport { replaceContent } from './modules/replaceContent';\nimport { on, off, triggerEvent, Handlers } from './modules/events';\nimport { use, unuse, findPlugin, Plugin } from './modules/plugins';\nimport { renderPage } from './modules/renderPage';\nimport { updateTransition, shouldSkipTransition } from './modules/transitions';\n\nimport { queryAll } from './utils';\n\nexport type Transition = {\n\tfrom?: string;\n\tto?: string;\n\tcustom?: string;\n};\n\ntype DelegatedListeners = {\n\tclick?: Unsubscribe;\n};\n\nexport type Options = {\n\tanimateHistoryBrowsing: boolean;\n\tanimationSelector: string | false;\n\tlinkSelector: string;\n\tcache: boolean;\n\tcontainers: string[];\n\trequestHeaders: Record<string, string>;\n\tplugins: Plugin[];\n\tskipPopStateHandling: (event: any) => boolean;\n\tignoreVisit: (url: string, { el }: { el?: Element }) => boolean;\n\tresolveUrl: (url: string) => string;\n};\n\nexport default class Swup {\n\tversion = version;\n\n\t_handlers: Handlers = {\n\t\tanimationInDone: [],\n\t\tanimationInStart: [],\n\t\tanimationOutDone: [],\n\t\tanimationOutStart: [],\n\t\tanimationSkipped: [],\n\t\tclickLink: [],\n\t\tcontentReplaced: [],\n\t\tdisabled: [],\n\t\tenabled: [],\n\t\topenPageInNewTab: [],\n\t\tpageLoaded: [],\n\t\tpageRetrievedFromCache: [],\n\t\tpageView: [],\n\t\tpopState: [],\n\t\tsamePage: [],\n\t\tsamePageWithHash: [],\n\t\tserverError: [],\n\t\ttransitionStart: [],\n\t\ttransitionEnd: [],\n\t\twillReplaceContent: []\n\t};\n\n\t// variable for anchor to scroll to after render\n\tscrollToElement: string | null = null;\n\t// variable for save options\n\toptions: Options;\n\t// running plugin instances\n\tplugins: Plugin[] = [];\n\t// variable for current transition info object\n\ttransition: Transition = {};\n\t// cache instance\n\tcache: Cache;\n\t// allows us to compare the current and new path inside popStateHandler\n\tcurrentPageUrl = getCurrentUrl();\n\t// variable for keeping event listeners from \"delegate\"\n\tdelegatedListeners: DelegatedListeners = {};\n\t// so we are able to remove the listener\n\tboundPopStateHandler: (event: PopStateEvent) => void;\n\n\tloadPage = loadPage;\n\tperformPageLoad = performPageLoad;\n\tleavePage = leavePage;\n\trenderPage = renderPage;\n\treplaceContent = replaceContent;\n\tenterPage = enterPage;\n\ttriggerEvent = triggerEvent;\n\tdelegateEvent = delegateEvent;\n\ton = on;\n\toff = off;\n\tupdateTransition = updateTransition;\n\tshouldSkipTransition = shouldSkipTransition;\n\tgetAnimationPromises = getAnimationPromises;\n\tgetPageData = getPageData;\n\tfetchPage = fetchPage;\n\tgetAnchorElement = getAnchorElement;\n\tlog: (message: string, context?: any) => void = () => {}; // here so it can be used by plugins\n\tuse = use;\n\tunuse = unuse;\n\tfindPlugin = findPlugin;\n\tgetCurrentUrl = getCurrentUrl;\n\tcleanupAnimationClasses = cleanupAnimationClasses;\n\n\tdefaults: Options = {\n\t\tanimateHistoryBrowsing: false,\n\t\tanimationSelector: '[class*=\"transition-\"]',\n\t\tcache: true,\n\t\tcontainers: ['#swup'],\n\t\tignoreVisit: (url, { el } = {}) => !!el?.closest('[data-no-swup]'),\n\t\tlinkSelector: 'a[href]',\n\t\tplugins: [],\n\t\tresolveUrl: (url) => url,\n\t\trequestHeaders: {\n\t\t\t'X-Requested-With': 'swup',\n\t\t\tAccept: 'text/html, application/xhtml+xml'\n\t\t},\n\t\tskipPopStateHandling: (event) => event.state?.source !== 'swup'\n\t};\n\n\tconstructor(options: Partial<Options> = {}) {\n\t\t// Merge defaults and options\n\t\tthis.options = { ...this.defaults, ...options };\n\n\t\tthis.boundPopStateHandler = this.popStateHandler.bind(this);\n\n\t\tthis.cache = new Cache(this);\n\n\t\tthis.enable();\n\t}\n\n\tenable() {\n\t\t// Check for Promise support\n\t\tif (typeof Promise === 'undefined') {\n\t\t\tconsole.warn('Promise is not supported');\n\t\t\treturn;\n\t\t}\n\n\t\t// Add event listeners\n\t\tthis.delegatedListeners.click = delegateEvent(\n\t\t\tthis.options.linkSelector,\n\t\t\t'click',\n\t\t\tthis.linkClickHandler.bind(this)\n\t\t);\n\n\t\twindow.addEventListener('popstate', this.boundPopStateHandler);\n\n\t\t// Initial save to cache\n\t\tif (this.options.cache) {\n\t\t\t// Disabled to avoid caching modified dom state: logic moved to preload plugin\n\t\t\t// https://github.com/swup/swup/issues/475\n\t\t}\n\n\t\t// Mark swup blocks in html\n\t\tmarkSwupElements(document.documentElement, this.options.containers);\n\n\t\t// Mount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.use(plugin));\n\n\t\t// Modify initial history record\n\t\tupdateHistoryRecord();\n\n\t\t// Trigger enabled event\n\t\tthis.triggerEvent('enabled');\n\n\t\t// Add swup-enabled class to html tag\n\t\tdocument.documentElement.classList.add('swup-enabled');\n\n\t\t// Trigger page view event\n\t\tthis.triggerEvent('pageView');\n\t}\n\n\tdestroy() {\n\t\t// remove delegated listeners\n\t\tthis.delegatedListeners.click!.destroy();\n\n\t\t// remove popstate listener\n\t\twindow.removeEventListener('popstate', this.boundPopStateHandler);\n\n\t\t// empty cache\n\t\tthis.cache.empty();\n\n\t\t// unmount plugins\n\t\tthis.options.plugins.forEach((plugin) => {\n\t\t\tthis.unuse(plugin);\n\t\t});\n\n\t\t// remove swup data atributes from blocks\n\t\tqueryAll('[data-swup]').forEach((element) => {\n\t\t\telement.removeAttribute('data-swup');\n\t\t});\n\n\t\t// remove handlers\n\t\tthis.off();\n\n\t\t// trigger disable event\n\t\tthis.triggerEvent('disabled');\n\n\t\t// remove swup-enabled class from html tag\n\t\tdocument.documentElement.classList.remove('swup-enabled');\n\t}\n\n\tshouldIgnoreVisit(href: string, { el }: { el?: Element } = {}) {\n\t\tconst { origin, url, hash } = Location.fromUrl(href);\n\n\t\t// Ignore if the new origin doesn't match the current one\n\t\tif (origin !== window.location.origin) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the link/form would open a new window (or none at all)\n\t\tif (el && this.triggerWillOpenNewWindow(el)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the visit should be ignored as per user options\n\t\tif (this.options.ignoreVisit(url + hash, { el })) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Finally, allow the visit\n\t\treturn false;\n\t}\n\n\tlinkClickHandler(event: delegate.Event<MouseEvent>) {\n\t\tconst linkEl = event.delegateTarget;\n\t\tconst { href, url, hash } = Location.fromElement(linkEl as HTMLAnchorElement);\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href, { el: linkEl })) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if control key pressed\n\t\tif (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n\t\t\tthis.triggerEvent('openPageInNewTab', event);\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if other than left mouse button\n\t\tif (event.button !== 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.triggerEvent('clickLink', event);\n\t\tevent.preventDefault();\n\n\t\t// Handle links to the same page and exit early, where applicable\n\t\tif (!url || url === getCurrentUrl()) {\n\t\t\tthis.handleLinkToSamePage(url, hash, event);\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the resolved path hasn't changed\n\t\tif (this.isSameResolvedUrl(url, getCurrentUrl())) return;\n\n\t\t// Store the element that should be scrolled to after loading the next page\n\t\tthis.scrollToElement = hash || null;\n\n\t\t// Get the custom transition name, if present\n\t\tconst customTransition = linkEl.getAttribute('data-swup-transition') || undefined;\n\n\t\t// Finally, proceed with loading the page\n\t\tthis.performPageLoad({ url, customTransition });\n\t}\n\n\thandleLinkToSamePage(url: string, hash: string, event: MouseEvent) {\n\t\t// Emit event and exit early if the url points to the same page without hash\n\t\tif (!hash) {\n\t\t\tthis.triggerEvent('samePage', event);\n\t\t\treturn;\n\t\t}\n\n\t\t// link to the same URL with hash\n\t\tthis.triggerEvent('samePageWithHash', event);\n\n\t\tconst element = getAnchorElement(hash);\n\n\t\t// Warn and exit early if no matching element was found for the hash\n\t\tif (!element) {\n\t\t\treturn console.warn(`Element for offset not found (#${hash})`);\n\t\t}\n\n\t\tupdateHistoryRecord(url + hash);\n\t}\n\n\ttriggerWillOpenNewWindow(triggerEl: Element) {\n\t\tif (triggerEl.matches('[download], [target=\"_blank\"]')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpopStateHandler(event: PopStateEvent) {\n\t\t// Exit early if this event should be ignored\n\t\tif (this.options.skipPopStateHandling(event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the resolved path hasn't changed\n\t\tif (this.isSameResolvedUrl(getCurrentUrl(), this.currentPageUrl)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst href = event.state?.url ?? location.href;\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { url, hash } = Location.fromUrl(href);\n\n\t\tif (hash) {\n\t\t\tthis.scrollToElement = hash;\n\t\t} else {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tthis.triggerEvent('popState', event);\n\n\t\tif (!this.options.animateHistoryBrowsing) {\n\t\t\tdocument.documentElement.classList.remove('is-animating');\n\t\t\tcleanupAnimationClasses();\n\t\t}\n\n\t\tthis.performPageLoad({ url, event });\n\t}\n\n\t/**\n\t * Utility function to validate and run the global option 'resolveUrl'\n\t * @param {string} url\n\t * @returns {string} the resolved url\n\t */\n\tresolveUrl(url: string) {\n\t\tif (typeof this.options.resolveUrl !== 'function') {\n\t\t\tconsole.warn(`[swup] options.resolveUrl expects a callback function.`);\n\t\t\treturn url;\n\t\t}\n\t\tconst result = this.options.resolveUrl(url);\n\t\tif (!result || typeof result !== 'string') {\n\t\t\tconsole.warn(`[swup] options.resolveUrl needs to return a url`);\n\t\t\treturn url;\n\t\t}\n\t\tif (result.startsWith('//') || result.startsWith('http')) {\n\t\t\tconsole.warn(`[swup] options.resolveUrl needs to return a relative url`);\n\t\t\treturn url;\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Compares the resolved version of two paths and returns true if they are the same\n\t * @param {string} url1\n\t * @param {string} url2\n\t * @returns {boolean}\n\t */\n\tisSameResolvedUrl(url1: string, url2: string) {\n\t\treturn this.resolveUrl(url1) === this.resolveUrl(url2);\n\t}\n}\n"],"names":["getCurrentUrl","_temp","hash","location","pathname","search","updateHistoryRecord","url","customData","data","history","state","random","Math","source","replaceState","ledger","WeakMap","editLedger","wanted","baseElement","callback","setup","_a","_b","has","elementMap","get","set","setups","Set","existed","add","delete","delegate","base","selector","type","options","document","querySelectorAll","addEventListener","subscriptions","Array","prototype","map","call","element","destroy","subscription","Document","documentElement","capture","Boolean","listenerFn","event","delegateTarget","target","Text","parentElement","Element","currentTarget","closest","contains","safeClosest","once","JSON","stringify","delegateSubscription","removeEventListener","delegateEvent","eventOptions","delegation","query","context","querySelector","queryAll","from","toMs","s","Number","slice","replace","Location","constructor","baseURI","super","toString","this","static","el","getAttribute","href","markSwupElements","isSwupClass","className","test","includes","cleanupAnimationClasses","removeClasses","split","filter","classList","remove","Cache","swup","pages","last","getCacheUrl","resolveUrl","fromUrl","cacheUrl","page","responseURL","log","Object","keys","length","getPage","getCurrentPage","exists","empty","enterPage","skipTransition","triggerEvent","Promise","resolve","requestAnimationFrame","animationPromises","getAnimationPromises","all","then","getAnchorElement","charAt","substring","ident","decodeURIComponent","window","CSS","escape","transitionProp","transitionEndEvent","animationProp","animationEndEvent","animationType","animationSelector","animatedElements","body","expectedType","timeout","propCount","styles","getComputedStyle","transitionDuration","animationDelay","animationDuration","transitionDelays","transitionDurations","transitionTimeout","calculateTimeout","animationDelays","animationDurations","animationTimeout","max","getTransitionInfo","endEvent","startTime","performance","now","propsTransitioned","end","onEnd","elapsedTime","isTransitionOrAnimationEvent","Error","setTimeout","console","warn","getAnimationPromiseForElement","delays","durations","concat","duration","i","undefined","ontransitionend","onwebkittransitionend","onanimationend","onwebkitanimationend","getPageData","request","pageHtmlData","html","containers","_query","_query2","fakeDom","createElement","innerHTML","blocks","forEach","item","index","setAttribute","String","push","outerHTML","title","innerText","pageClass","originalContent","getDataFromHtml","responseText","fetchPage","headers","requestHeaders","cache","reject","defaults","method","onreadystatechange","readyState","open","entries","_ref","key","header","setRequestHeader","send","fetch","response","status","cacheablePageData","leavePage","isHistoryVisit","loadPage","shouldIgnoreVisit","performPageLoad","customTransition","PopStateEvent","shouldSkipTransition","updateTransition","classify","toLowerCase","pushState","createHistoryRecord","scrollToElement","currentPageUrl","fetchPromise","pageData","renderPage","catch","errorUrl","skipPopStateHandling","go","replaceContent","handler","_handlers","off","h","eventName","originalEvent","error","CustomEvent","detail","dispatchEvent","use","plugin","maybeInvalidPlugin","isSwupPlugin","_checkRequirements","_beforeMount","mount","plugins","unuse","pluginOrName","findPlugin","unmount","_afterUnmount","p","find","name","isSameResolvedUrl","to","custom","transition","animateHistoryBrowsing","Swup","version","animationInDone","animationInStart","animationOutDone","animationOutStart","animationSkipped","clickLink","contentReplaced","disabled","enabled","openPageInNewTab","pageLoaded","pageRetrievedFromCache","pageView","popState","samePage","samePageWithHash","serverError","transitionStart","transitionEnd","willReplaceContent","delegatedListeners","boundPopStateHandler","on","ignoreVisit","linkSelector","Accept","_event$state","popStateHandler","bind","enable","click","linkClickHandler","removeAttribute","_temp2","origin","triggerWillOpenNewWindow","linkEl","fromElement","metaKey","ctrlKey","shiftKey","altKey","button","preventDefault","handleLinkToSamePage","triggerEl","matches","_event$state$url","_event$state2","result","startsWith","url1","url2"],"mappings":"uNAAO,MCAMA,EAAgB,SAAAC,GAAC,IAAAC,KAAEA,QAA6B,IAAAD,EAAA,CAAE,EAAAA,EAC9D,OAAOE,SAASC,SAAWD,SAASE,QAAUH,EAAOC,SAASD,KAAO,GACtE,ECAgCI,EAAG,SAClCC,EACAC,YADAD,IAAAA,EAAqB,WACrBC,IAAAA,IAAAA,EAAsC,CAAE,GAExCD,EAAMA,GAAOP,EAAc,CAAEE,MAAM,IACnC,MAAUO,EAAG,IACTC,QAAQC,MACXJ,MACAK,OAAQC,KAAKD,SACbE,OAAQ,UACLN,GAEJE,QAAQK,aAAaN,EAAM,GAAIF,EAChC,ECdMS,EAAS,IAAIC,QACnB,SAASC,EAAWC,EAAQC,EAAaC,EAAUC,GAC/C,IAAIC,EAAIC,EACR,IAAKL,IAAWH,EAAOS,IAAIL,GACvB,OAAO,EAEX,MAAMM,EAAgD,QAAlCH,EAAKP,EAAOW,IAAIP,UAAiC,IAAPG,EAAgBA,EAAK,IAAIN,QAEvF,GADAD,EAAOY,IAAIR,EAAaM,IACnBP,IAAWH,EAAOS,IAAIL,GACvB,OAAO,EAEX,MAAMS,EAA6C,QAAnCL,EAAKE,EAAWC,IAAIN,UAA8B,IAAPG,EAAgBA,EAAK,IAAIM,IACpFJ,EAAWE,IAAIP,EAAUQ,GACzB,MAAME,EAAUF,EAAOJ,IAAIH,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GACxB,QAAIA,EAAUC,QAAQ,gCAIvB,CAEAnB,gBAAgBrQ,GAEf,IAAAyR,EAAAC,EAAA,GAAIzP,KAAKlD,QAAQuN,qBAAqBtM,GACrC,OAID,GAAIiC,KAAKkM,kBAAkB1R,IAAiBwF,KAAK+J,gBAChD,OAGD,MAAM3J,EAAuB,SAAL,SAAXrC,EAAM5C,YAAK,EAAXsU,EAAa1U,KAAGyU,EAAI7U,SAASyF,KAG1C,GAAIJ,KAAKoJ,kBAAkBhJ,GAC1B,OAGD,MAAMrF,IAAEA,EAAGL,KAAEA,GAASiF,EAAS2B,QAAQlB,GAEnC1F,EACHsF,KAAK8J,gBAAkBpP,EAEvBqD,EAAMqR,iBAGPpP,KAAKoC,aAAa,WAAYrE,GAEzBiC,KAAKlD,QAAQwP,yBACjBvP,SAASY,gBAAgBmD,UAAUC,OAAO,gBAC1CL,KAGDV,KAAKqJ,gBAAgB,CAAEtO,MAAKgD,SAC7B,CAOAsD,WAAWtG,GACV,GAAuC,mBAAxBiF,KAAClD,QAAQuE,WAEvB,OADAmE,QAAQC,+DAER1K,EACD,MAAY2U,EAAG1P,KAAKlD,QAAQuE,WAAWtG,GACvC,OAAK2U,GAA4B,iBAALA,EAIxBA,EAAOC,WAAW,OAASD,EAAOC,WAAW,SAChDnK,QAAQC,KAAI,+DAIdiK,GARElK,QAAQC,KAAI,qDAQd,CAQAyG,kBAAkB0D,EAAcC,GAC/B,OAAW7P,KAACqB,WAAWuO,KAAU5P,KAAKqB,WAAWwO,EAClD"}
1
+ {"version":3,"file":"Swup.umd.js","sources":["../src/helpers/classify.ts","../src/helpers/getCurrentUrl.ts","../src/helpers/updateHistoryRecord.ts","../node_modules/delegate-it/index.js","../src/helpers/delegateEvent.ts","../src/utils/index.ts","../src/helpers/Location.ts","../src/helpers/markSwupElements.ts","../src/helpers/cleanupAnimationClasses.ts","../src/modules/Cache.ts","../src/modules/enterPage.ts","../src/modules/getAnchorElement.ts","../src/modules/getAnimationPromises.ts","../src/modules/getPageData.ts","../src/helpers/getDataFromHtml.ts","../src/modules/fetchPage.ts","../src/helpers/fetch.ts","../src/modules/leavePage.ts","../src/modules/loadPage.ts","../src/helpers/createHistoryRecord.ts","../src/modules/replaceContent.ts","../src/modules/events.ts","../src/modules/plugins.ts","../src/modules/renderPage.ts","../src/modules/transitions.ts","../src/Swup.ts"],"sourcesContent":["export const classify = (text: string, fallback?: string): string => {\n\tconst output = String(text)\n\t\t.toLowerCase()\n\t\t// .normalize('NFD') // split an accented letter in the base letter and the acent\n\t\t// .replace(/[\\u0300-\\u036f]/g, '') // remove all previously split accents\n\t\t.replace(/[\\s/_.]+/g, '-') // replace spaces and _./ with '-'\n\t\t.replace(/[^\\w-]+/g, '') // remove all non-word chars\n\t\t.replace(/--+/g, '-') // replace repeating '-' with single '-'\n\t\t.replace(/^-+|-+$/g, ''); // trim '-' from edges\n\treturn output || fallback || '';\n};\n","export const getCurrentUrl = ({ hash }: { hash?: boolean } = {}): string => {\n\treturn location.pathname + location.search + (hash ? location.hash : '');\n};\n","import { getCurrentUrl } from './getCurrentUrl';\n\nexport const updateHistoryRecord = (\n\turl: string | null = null,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\t...history.state,\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.replaceState(data, '', url);\n};\n","/** Keeps track of raw listeners added to the base elements to avoid duplication */\nconst ledger = new WeakMap();\nfunction editLedger(wanted, baseElement, callback, setup) {\n var _a, _b;\n if (!wanted && !ledger.has(baseElement)) {\n return false;\n }\n const elementMap = (_a = ledger.get(baseElement)) !== null && _a !== void 0 ? _a : new WeakMap();\n ledger.set(baseElement, elementMap);\n if (!wanted && !ledger.has(baseElement)) {\n return false;\n }\n const setups = (_b = elementMap.get(callback)) !== null && _b !== void 0 ? _b : new Set();\n elementMap.set(callback, setups);\n const existed = setups.has(setup);\n if (wanted) {\n setups.add(setup);\n }\n else {\n setups.delete(setup);\n }\n return existed && wanted;\n}\nfunction isEventTarget(elements) {\n return typeof elements.addEventListener === 'function';\n}\nfunction safeClosest(event, selector) {\n let target = event.target;\n if (target instanceof Text) {\n target = target.parentElement;\n }\n if (target instanceof Element && event.currentTarget instanceof Element) {\n // `.closest()` may match ancestors of `currentTarget` but we only need its children\n const closest = target.closest(selector);\n if (closest && event.currentTarget.contains(closest)) {\n return closest;\n }\n }\n}\n// This type isn't exported as a declaration, so it needs to be duplicated above\nfunction delegate(base, selector, type, callback, options) {\n // Handle Selector-based usage\n if (typeof base === 'string') {\n base = document.querySelectorAll(base);\n }\n // Handle Array-like based usage\n if (!isEventTarget(base)) {\n const subscriptions = Array.prototype.map.call(base, (element) => delegate(element, selector, type, callback, options));\n return {\n destroy() {\n for (const subscription of subscriptions) {\n subscription.destroy();\n }\n },\n };\n }\n // `document` should never be the base, it's just an easy way to define \"global event listeners\"\n const baseElement = base instanceof Document ? base.documentElement : base;\n // Handle the regular Element usage\n const capture = Boolean(typeof options === 'object' ? options.capture : options);\n const listenerFn = (event) => {\n const delegateTarget = safeClosest(event, selector);\n if (delegateTarget) {\n event.delegateTarget = delegateTarget;\n callback.call(baseElement, event);\n }\n };\n // Drop unsupported `once` option https://github.com/fregante/delegate-it/pull/28#discussion_r863467939\n if (typeof options === 'object') {\n delete options.once;\n }\n const setup = JSON.stringify({ selector, type, capture });\n const isAlreadyListening = editLedger(true, baseElement, callback, setup);\n const delegateSubscription = {\n destroy() {\n baseElement.removeEventListener(type, listenerFn, options);\n editLedger(false, baseElement, callback, setup);\n },\n };\n if (!isAlreadyListening) {\n baseElement.addEventListener(type, listenerFn, options);\n }\n return delegateSubscription;\n}\nexport default delegate;\n","import delegate, { EventType } from 'delegate-it';\nimport { ParseSelector } from 'typed-query-selector/parser';\n\nexport type Unsubscribe = {\n\tdestroy: () => void;\n};\nexport const delegateEvent = <Selector extends string, TEvent extends EventType>(\n\tselector: Selector,\n\ttype: TEvent,\n\tcallback: delegate.EventHandler<GlobalEventHandlersEventMap[TEvent]>,\n\t{ base = document, ...eventOptions } = {}\n): Unsubscribe => {\n\tconst delegation = delegate<string, ParseSelector<Selector, HTMLElement>, TEvent>(\n\t\tbase,\n\t\tselector,\n\t\ttype,\n\t\tcallback,\n\t\teventOptions\n\t);\n\treturn { destroy: () => delegation.destroy() };\n};\n","export const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector<HTMLElement>(selector);\n};\n\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\nexport const nextTick = (callback: () => void) => {\n\trequestAnimationFrame(() => {\n\t\trequestAnimationFrame(() => {\n\t\t\tcallback();\n\t\t});\n\t});\n};\n\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t} else {\n\t\treturn ident;\n\t}\n};\n\n// Fix for Chrome below v61 formatting CSS floats with comma in some locales\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n","/**\n * A helper for creating a Location from either an element\n * or a URL object/string\n *\n */\n\nexport class Location extends URL {\n\tconstructor(url: string, base: string = document.baseURI) {\n\t\tsuper(url.toString(), base);\n\t}\n\n\tget url() {\n\t\treturn this.pathname + this.search;\n\t}\n\n\t/**\n\t * Instantiate a Location from an element's href attribute\n\t * @param {Element} el\n\t * @return new Location instance\n\t */\n\tstatic fromElement(el: HTMLAnchorElement): Location {\n\t\tconst href = el.getAttribute('href') || el.getAttribute('xlink:href');\n\t\treturn new Location(href!);\n\t}\n\n\t/**\n\t * Instantiate a Location from a URL object or string\n\t * @param {URL|string} url\n\t * @return new Location instance\n\t */\n\tstatic fromUrl(url: string): Location {\n\t\treturn new Location(url);\n\t}\n}\n","import { query, queryAll } from '../utils';\n\nexport const markSwupElements = (element: Element, containers: string[]): void => {\n\tlet blocks = 0;\n\n\tcontainers.forEach((selector) => {\n\t\tif (query(selector, element) == null) {\n\t\t\tconsole.warn(`[swup] Container ${selector} not found on page.`);\n\t\t} else {\n\t\t\tqueryAll(selector).forEach((item: Element, index: number) => {\n\t\t\t\tqueryAll(selector, element)[index].setAttribute('data-swup', String(blocks));\n\t\t\t\tblocks++;\n\t\t\t});\n\t\t}\n\t});\n};\n","export const isSwupClass = (className: string): boolean =>\n\t/^to-/.test(className) || ['is-changing', 'is-rendering', 'is-popstate'].includes(className);\n\nexport const cleanupAnimationClasses = (): void => {\n\tconst htmlClasses = document.documentElement.className.split(' ');\n\tconst removeClasses = htmlClasses.filter(isSwupClass);\n\tdocument.documentElement.classList.remove(...removeClasses);\n};\n","import { getCurrentUrl, Location } from '../helpers';\nimport Swup from '../Swup';\nimport { PageData } from './getPageData';\n\nexport interface PageRecord extends PageData {\n\turl: string;\n\tresponseURL: string;\n}\nexport class Cache {\n\tpages: Record<string, PageRecord> = {};\n\tlast: PageRecord | null = null;\n\tswup: Swup;\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\tgetCacheUrl(url: string): string {\n\t\treturn this.swup.resolveUrl(Location.fromUrl(url).url);\n\t}\n\n\tcacheUrl(page: PageRecord) {\n\t\tpage.url = this.getCacheUrl(page.url);\n\t\tif (page.url in this.pages === false) {\n\t\t\tthis.pages[page.url] = page;\n\t\t}\n\t\tpage.responseURL = this.getCacheUrl(page.responseURL);\n\t\tthis.last = this.pages[page.url];\n\t\tthis.swup.log(`Cache (${Object.keys(this.pages).length})`, this.pages);\n\t}\n\n\tgetPage(url: string): PageRecord {\n\t\turl = this.getCacheUrl(url);\n\t\treturn this.pages[url];\n\t}\n\n\tgetCurrentPage(): PageRecord {\n\t\treturn this.getPage(getCurrentUrl());\n\t}\n\n\texists(url: string): boolean {\n\t\turl = this.getCacheUrl(url);\n\t\treturn url in this.pages;\n\t}\n\n\tempty(): void {\n\t\tthis.pages = {};\n\t\tthis.last = null;\n\t\tthis.swup.log('Cache cleared');\n\t}\n\n\tremove(url: string): void {\n\t\tdelete this.pages[this.getCacheUrl(url)];\n\t}\n}\n","import { nextTick } from '../utils';\nimport Swup from '../Swup';\nimport { PageRenderOptions } from './renderPage';\n\nexport const enterPage = function (this: Swup, { event, skipTransition }: PageRenderOptions = {}) {\n\tif (skipTransition) {\n\t\tthis.triggerEvent('transitionEnd', event);\n\t\tthis.cleanupAnimationClasses();\n\t\treturn [Promise.resolve()];\n\t}\n\n\tnextTick(() => {\n\t\tthis.triggerEvent('animationInStart');\n\t\tdocument.documentElement.classList.remove('is-animating');\n\t});\n\n\tconst animationPromises = this.getAnimationPromises('in');\n\tPromise.all(animationPromises).then(() => {\n\t\tthis.triggerEvent('animationInDone');\n\t\tthis.triggerEvent('transitionEnd', event);\n\t\tthis.cleanupAnimationClasses();\n\t});\n\treturn animationPromises;\n};\n","import { escapeCssIdentifier, query } from '../utils';\n\nexport const getAnchorElement = (hash: string): Element | null => {\n\tif (!hash) {\n\t\treturn null;\n\t}\n\n\tif (hash.charAt(0) === '#') {\n\t\thash = hash.substring(1);\n\t}\n\n\thash = decodeURIComponent(hash);\n\thash = escapeCssIdentifier(hash);\n\n\t// https://html.spec.whatwg.org/#find-a-potential-indicated-element\n\treturn query(`#${hash}`) || query(`a[name='${hash}']`);\n};\n","import { queryAll, toMs } from '../utils';\nimport Swup from '../Swup';\n\n// Transition property/event sniffing\nlet transitionProp = 'transition';\nlet transitionEndEvent = 'transitionend';\nlet animationProp = 'animation';\nlet animationEndEvent = 'animationend';\n\nif (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {\n\ttransitionProp = 'WebkitTransition';\n\ttransitionEndEvent = 'webkitTransitionEnd';\n}\n\nif (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {\n\tanimationProp = 'WebkitAnimation';\n\tanimationEndEvent = 'webkitAnimationEnd';\n}\n\nexport function getAnimationPromises(\n\tthis: Swup,\n\t// we don't use this argument, but JS plugin depends on it with\n\t// its own version of getAnimationPromises, so it must be specified when\n\t// getAnimationPromises is being used\n\tanimationType: 'in' | 'out'\n): Promise<void>[] {\n\tconst selector = this.options.animationSelector;\n\n\t// Allow usage of swup without animations\n\tif (selector === false) {\n\t\t// Use array of a single resolved promise instead of an empty array to allow\n\t\t// possible future use with Promise.race() which requires an actual value\n\t\treturn [Promise.resolve()];\n\t}\n\n\tconst animatedElements = queryAll(selector, document.body);\n\n\t// Warn if no animated containers found on page, but keep things going\n\tif (!animatedElements.length) {\n\t\tconsole.warn(`[swup] No animated elements found by selector ${selector}`);\n\t\treturn [Promise.resolve()];\n\t}\n\n\treturn animatedElements.map((element) => getAnimationPromiseForElement(element, selector));\n}\n\nconst isTransitionOrAnimationEvent = (event: any): event is TransitionEvent | AnimationEvent =>\n\t!!event.elapsedTime;\n\nfunction getAnimationPromiseForElement(\n\telement: Element,\n\tselector: string,\n\texpectedType: 'animation' | 'transition' | null = null\n): Promise<void> {\n\tconst { type, timeout, propCount } = getTransitionInfo(element, expectedType);\n\n\t// Resolve immediately if no transition defined\n\tif (!type || !timeout) {\n\t\tconsole.warn(\n\t\t\t`[swup] No CSS transition duration defined for element of selector ${selector}`\n\t\t);\n\t\treturn Promise.resolve();\n\t}\n\n\treturn new Promise((resolve) => {\n\t\tconst endEvent = type === 'transition' ? transitionEndEvent : animationEndEvent;\n\t\tconst startTime = performance.now();\n\t\tlet propsTransitioned = 0;\n\n\t\tconst end = () => {\n\t\t\telement.removeEventListener(endEvent, onEnd);\n\t\t\tresolve();\n\t\t};\n\n\t\tconst onEnd: EventListener = (event) => {\n\t\t\t// Skip transitions on child elements\n\t\t\tif (event.target !== element) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isTransitionOrAnimationEvent(event)) {\n\t\t\t\tthrow new Error('Not a transition or animation event.');\n\t\t\t}\n\n\t\t\t// Skip transitions that happened before we started listening\n\t\t\tconst elapsedTime = (performance.now() - startTime) / 1000;\n\t\t\tif (elapsedTime < event.elapsedTime) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// End if all properties have transitioned\n\t\t\tif (++propsTransitioned >= propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t};\n\n\t\tsetTimeout(() => {\n\t\t\tif (propsTransitioned < propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t}, timeout + 1);\n\n\t\telement.addEventListener(endEvent, onEnd);\n\t});\n}\n\nexport function getTransitionInfo(\n\telement: Element,\n\texpectedType: 'animation' | 'transition' | null = null\n) {\n\tconst styles = window.getComputedStyle(element);\n\n\t// not sure what to do about the below mess other than casting, but it's a mess\n\tconst transitionDelay = `${transitionProp}Delay` as keyof CSSStyleDeclaration;\n\tconst transitionDuration = `${transitionProp}Duration` as keyof CSSStyleDeclaration;\n\tconst animationDelay = `${animationProp}Delay` as keyof CSSStyleDeclaration;\n\tconst animationDuration = `${animationProp}Duration` as keyof CSSStyleDeclaration;\n\n\tconst transitionDelays = (\n\t\tstyles[transitionDelay] as CSSStyleDeclaration['transitionDelay']\n\t).split(', ');\n\tconst transitionDurations = (\n\t\t(styles[transitionDuration] || '') as CSSStyleDeclaration['transitionDuration']\n\t).split(', ');\n\tconst transitionTimeout = calculateTimeout(transitionDelays, transitionDurations);\n\n\tconst animationDelays = (\n\t\t(styles[animationDelay] || '') as CSSStyleDeclaration['animationDelay']\n\t).split(', ');\n\tconst animationDurations = (\n\t\t(styles[animationDuration] || '') as CSSStyleDeclaration['animationDuration']\n\t).split(', ');\n\tconst animationTimeout = calculateTimeout(animationDelays, animationDurations);\n\n\tlet type: string | null = '';\n\tlet timeout = 0;\n\tlet propCount = 0;\n\n\tif (expectedType === 'transition') {\n\t\tif (transitionTimeout > 0) {\n\t\t\ttype = 'transition';\n\t\t\ttimeout = transitionTimeout;\n\t\t\tpropCount = transitionDurations.length;\n\t\t}\n\t} else if (expectedType === 'animation') {\n\t\tif (animationTimeout > 0) {\n\t\t\ttype = 'animation';\n\t\t\ttimeout = animationTimeout;\n\t\t\tpropCount = animationDurations.length;\n\t\t}\n\t} else {\n\t\ttimeout = Math.max(transitionTimeout, animationTimeout);\n\t\ttype =\n\t\t\ttimeout > 0\n\t\t\t\t? transitionTimeout > animationTimeout\n\t\t\t\t\t? 'transition'\n\t\t\t\t\t: 'animation'\n\t\t\t\t: null;\n\t\tpropCount = type\n\t\t\t? type === 'transition'\n\t\t\t\t? transitionDurations.length\n\t\t\t\t: animationDurations.length\n\t\t\t: 0;\n\t}\n\n\treturn {\n\t\ttype,\n\t\ttimeout,\n\t\tpropCount\n\t};\n}\n\nfunction calculateTimeout(delays: string[], durations: string[]) {\n\twhile (delays.length < durations.length) {\n\t\tdelays = delays.concat(delays);\n\t}\n\n\treturn Math.max(...durations.map((duration, i) => toMs(duration) + toMs(delays[i])));\n}\n","import { getDataFromHtml } from '../helpers';\nimport Swup from '../Swup';\nimport { PageHtmlData } from '../helpers/getDataFromHtml';\n\nexport type PageData = PageHtmlData & {\n\tresponseURL: string;\n};\nexport const getPageData = function (this: Swup, request: XMLHttpRequest): PageData | null {\n\t// this method can be replaced in case other content than html is expected to be received from server\n\t// this function should always return { title, pageClass, originalContent, blocks, responseURL }\n\t// in case page has invalid structure - return null\n\tconst html = request.responseText;\n\tconst pageHtmlData = getDataFromHtml(html, this.options.containers);\n\n\tif (!pageHtmlData) {\n\t\tconsole.warn('[swup] Received page is invalid.');\n\t\treturn null;\n\t}\n\n\treturn {\n\t\t...pageHtmlData,\n\t\tresponseURL: request.responseURL || window.location.href\n\t};\n};\n","import { query, queryAll } from '../utils';\n\nexport type PageHtmlData = {\n\ttitle: string;\n\toriginalContent: string;\n\tblocks: string[];\n\tpageClass?: string;\n};\n\nexport const getDataFromHtml = (html: string, containers: string[]): PageHtmlData => {\n\tlet fakeDom = document.createElement('html');\n\tfakeDom.innerHTML = html;\n\tlet blocks: string[] = [];\n\n\tcontainers.forEach((selector) => {\n\t\tif (query(selector, fakeDom) == null) {\n\t\t\tconsole.warn(`[swup] Container ${selector} not found on page.`);\n\t\t\treturn null;\n\t\t} else {\n\t\t\tif (queryAll(selector).length !== queryAll(selector, fakeDom).length) {\n\t\t\t\tconsole.warn(`[swup] Mismatched number of containers found on new page.`);\n\t\t\t}\n\t\t\tqueryAll(selector).forEach((item, index) => {\n\t\t\t\tqueryAll(selector, fakeDom)[index].setAttribute('data-swup', String(blocks.length));\n\t\t\t\tblocks.push(queryAll(selector, fakeDom)[index].outerHTML);\n\t\t\t});\n\t\t}\n\t});\n\n\tconst title = query('title', fakeDom)?.innerText || '';\n\tconst pageClass = query('body', fakeDom)?.className;\n\n\t// to prevent memory leaks\n\tfakeDom.innerHTML = '';\n\t// @ts-ignore don't want to type it as possible null, since it's created at the top of the function always\n\tfakeDom = null;\n\n\treturn { title, pageClass, blocks, originalContent: html };\n};\n","import Swup from '../Swup';\nimport { fetch } from '../helpers';\nimport { TransitionOptions } from './loadPage';\nimport { PageRecord } from './Cache';\n\nexport function fetchPage(this: Swup, data: TransitionOptions): Promise<PageRecord> {\n\tconst headers = this.options.requestHeaders;\n\tconst { url } = data;\n\n\tif (this.cache.exists(url)) {\n\t\tthis.triggerEvent('pageRetrievedFromCache');\n\t\treturn Promise.resolve(this.cache.getPage(url));\n\t}\n\n\treturn new Promise((resolve, reject) => {\n\t\tfetch({ ...data, headers }, (response) => {\n\t\t\tif (response.status === 500) {\n\t\t\t\tthis.triggerEvent('serverError');\n\t\t\t\treject(url);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// get json data\n\t\t\tconst page = this.getPageData(response);\n\t\t\tif (!page || !page.blocks.length) {\n\t\t\t\treject(url);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// render page\n\t\t\tconst cacheablePageData = { ...page, url };\n\t\t\tthis.cache.cacheUrl(cacheablePageData);\n\t\t\tthis.triggerEvent('pageLoaded');\n\t\t\tresolve(cacheablePageData);\n\t\t});\n\t});\n}\n","import { TransitionOptions } from '../modules/loadPage';\nimport { Options } from '../Swup';\n\nexport const fetch = (\n\toptions: TransitionOptions & { headers: Options['requestHeaders'] },\n\tcallback: (request: XMLHttpRequest) => void\n): XMLHttpRequest => {\n\tconst defaults = {\n\t\turl: window.location.pathname + window.location.search,\n\t\tmethod: 'GET',\n\t\tdata: null,\n\t\theaders: {}\n\t};\n\n\tconst { url, method, headers, data } = { ...defaults, ...options };\n\n\tconst request = new XMLHttpRequest();\n\n\trequest.onreadystatechange = function () {\n\t\tif (request.readyState === 4) {\n\t\t\t// if (request.status === 500) {} else {}\n\t\t\tcallback(request);\n\t\t}\n\t};\n\n\trequest.open(method, url, true);\n\tObject.entries(headers).forEach(([key, header]) => {\n\t\trequest.setRequestHeader(key, header);\n\t});\n\trequest.send(data);\n\n\treturn request;\n};\n","import Swup from '../Swup';\nimport { PageRenderOptions } from './renderPage';\n\nexport const leavePage = function (this: Swup, { event, skipTransition }: PageRenderOptions = {}) {\n\tconst isHistoryVisit = event instanceof PopStateEvent;\n\n\tif (skipTransition) {\n\t\tthis.triggerEvent('animationSkipped');\n\t\treturn [Promise.resolve()];\n\t}\n\n\tthis.triggerEvent('animationOutStart');\n\n\t// handle classes\n\tdocument.documentElement.classList.add('is-changing', 'is-leaving', 'is-animating');\n\tif (isHistoryVisit) {\n\t\tdocument.documentElement.classList.add('is-popstate');\n\t}\n\n\t// animation promise stuff\n\tconst animationPromises: Promise<void>[] = this.getAnimationPromises('out');\n\tPromise.all(animationPromises).then(() => {\n\t\tthis.triggerEvent('animationOutDone');\n\t});\n\n\treturn animationPromises;\n};\n","import { classify, createHistoryRecord, getCurrentUrl } from '../helpers';\nimport Swup from '../Swup';\nimport { PageRecord } from './Cache';\n\nexport type TransitionOptions = {\n\turl: string;\n\tcustomTransition?: string;\n};\n\nexport type PageLoadOptions = {\n\turl: string;\n\tevent?: Event;\n\tcustomTransition?: string;\n};\n\nexport function loadPage(this: Swup, data: TransitionOptions) {\n\tconst { url } = data;\n\n\t// Check if the visit should be ignored\n\tif (this.shouldIgnoreVisit(url)) {\n\t\twindow.location.href = url;\n\t} else {\n\t\tthis.performPageLoad(data);\n\t}\n}\n\nexport function performPageLoad(this: Swup, data: PageLoadOptions) {\n\tconst { url, event, customTransition } = data ?? {};\n\n\tconst isHistoryVisit = event instanceof PopStateEvent;\n\tconst skipTransition = this.shouldSkipTransition({ url, event });\n\n\tthis.triggerEvent('transitionStart', event);\n\n\t// set transition object\n\tthis.updateTransition(getCurrentUrl(), url, customTransition);\n\tif (customTransition != null) {\n\t\tdocument.documentElement.classList.add(`to-${classify(customTransition)}`);\n\t}\n\n\t// start/skip animation\n\tconst animationPromises = this.leavePage({ event, skipTransition });\n\n\t// create history record if this is not a popstate call (with or without anchor)\n\tif (!isHistoryVisit) {\n\t\tcreateHistoryRecord(url + (this.scrollToElement || ''));\n\t}\n\n\tthis.currentPageUrl = getCurrentUrl();\n\n\t// Load page data\n\tconst fetchPromise = this.fetchPage(data);\n\n\t// when everything is ready, render the page\n\tPromise.all<PageRecord | void>([fetchPromise, ...animationPromises])\n\t\t.then(([pageData]) => {\n\t\t\tthis.renderPage(pageData as PageRecord, { event, skipTransition });\n\t\t})\n\t\t.catch((errorUrl) => {\n\t\t\t// Return early if errorUrl is not defined (probably aborted preload request)\n\t\t\tif (errorUrl === undefined) return;\n\n\t\t\t// Rewrite `skipPopStateHandling` to redirect manually when `history.go` is processed\n\t\t\tthis.options.skipPopStateHandling = () => {\n\t\t\t\twindow.location = errorUrl;\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t// Go back to the actual page we're still at\n\t\t\thistory.go(-1);\n\t\t});\n}\n","import { getCurrentUrl } from './getCurrentUrl';\n\nexport const createHistoryRecord = (\n\turl: string,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.pushState(data, '', url);\n};\n","/**\n * Perform the replacement of content after loading a page.\n *\n * This method can be replaced or augmented by plugins to allow pausing.\n *\n * It takes an object with the page data as return from `getPageData` and has to\n * return a Promise that resolves once all content has been replaced and the\n * site is ready to start animating in the new page.\n *\n * @param {object} page The page object\n * @returns Promise\n */\nexport const replaceContent = function ({ blocks, title }: { blocks: string[]; title: string }) {\n\t// Replace content blocks\n\tblocks.forEach((html, i) => {\n\t\t// we know the block exists at this point\n\t\tconst block = document.body.querySelector(`[data-swup=\"${i}\"]`)!;\n\t\tblock.outerHTML = html;\n\t});\n\n\t// Update browser title\n\tdocument.title = title;\n\n\t// Return a Promise to allow plugins to defer\n\treturn Promise.resolve();\n};\n","import Swup from '../Swup';\n\nexport type EventType =\n\t| 'animationInDone'\n\t| 'animationInStart'\n\t| 'animationOutDone'\n\t| 'animationOutStart'\n\t| 'animationSkipped'\n\t| 'clickLink'\n\t| 'contentReplaced'\n\t| 'disabled'\n\t| 'enabled'\n\t| 'openPageInNewTab'\n\t| 'pageLoaded'\n\t| 'pageRetrievedFromCache'\n\t| 'pageView'\n\t| 'popState'\n\t| 'samePage'\n\t| 'samePageWithHash'\n\t| 'serverError'\n\t| 'transitionStart'\n\t| 'transitionEnd'\n\t| 'willReplaceContent';\nexport type Handler = (event?: Event) => void;\nexport type Handlers = Record<EventType, Handler[]>;\n\nexport function on(this: Swup, event: EventType, handler: Handler) {\n\tif (this._handlers[event]) {\n\t\tthis._handlers[event].push(handler);\n\t} else {\n\t\tconsole.warn(`Unsupported event ${event}.`);\n\t}\n}\n\nexport function off(this: Swup, event?: EventType, handler?: Handler) {\n\tif (event && handler) {\n\t\t// Remove specific handler\n\t\tif (this._handlers[event].includes(handler)) {\n\t\t\tthis._handlers[event] = this._handlers[event].filter((h) => h !== handler);\n\t\t} else {\n\t\t\tconsole.warn(`Handler for event '${event}' not found.`);\n\t\t}\n\t} else if (event) {\n\t\t// Remove all handlers for specific event\n\t\tthis._handlers[event] = [];\n\t} else {\n\t\t// Remove all handlers for all events\n\t\tObject.keys(this._handlers).forEach((event) => {\n\t\t\tthis._handlers[event as EventType] = [];\n\t\t});\n\t}\n}\n\nexport function triggerEvent(this: Swup, eventName: EventType, originalEvent?: Event): void {\n\t// call saved handlers with \"on\" method and pass originalEvent object if available\n\tthis._handlers[eventName].forEach((handler) => {\n\t\ttry {\n\t\t\thandler(originalEvent);\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t}\n\t});\n\n\t// trigger event on document with prefix \"swup:\"\n\tconst event = new CustomEvent(`swup:${eventName}`, { detail: eventName });\n\tdocument.dispatchEvent(event);\n}\n","import Swup from '../Swup';\n\nexport type Plugin = {\n\tname: string;\n\tisSwupPlugin: true;\n\tmount: () => void;\n\tunmount: () => void;\n\n\t// the instance is assigned later on after passing to swup\n\tswup?: Swup;\n\n\t// these are possibly undefined for backward compatibility\n\tversion?: string;\n\trequires?: Record<string, string>;\n\t_beforeMount?: () => void;\n\t_afterUnmount?: () => void;\n\t_checkRequirements?: () => boolean;\n};\n\nconst isSwupPlugin = (maybeInvalidPlugin: unknown): maybeInvalidPlugin is Plugin => {\n\t// @ts-ignore\n\treturn maybeInvalidPlugin?.isSwupPlugin;\n};\n\nexport const use = function (this: Swup, plugin: unknown) {\n\tif (!isSwupPlugin(plugin)) {\n\t\tconsole.error('Not a swup plugin instance', plugin);\n\t\treturn;\n\t}\n\n\tplugin.swup = this;\n\tif (plugin._checkRequirements) {\n\t\tif (!plugin._checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif (plugin._beforeMount) {\n\t\tplugin._beforeMount();\n\t}\n\tplugin.mount();\n\n\tthis.plugins.push(plugin);\n\n\treturn this.plugins;\n};\n\nexport function unuse(this: Swup, pluginOrName: Plugin | string) {\n\tconst plugin = this.findPlugin(pluginOrName);\n\tif (!plugin) {\n\t\tconsole.error('No such plugin', plugin);\n\t\treturn;\n\t}\n\n\tplugin.unmount();\n\tif (plugin._afterUnmount) {\n\t\tplugin._afterUnmount();\n\t}\n\n\tthis.plugins = this.plugins.filter((p) => p !== plugin);\n\n\treturn this.plugins;\n}\n\nexport function findPlugin(this: Swup, pluginOrName: Plugin | string) {\n\treturn this.plugins.find((plugin) => plugin === pluginOrName || plugin.name === pluginOrName);\n}\n","import { Location, updateHistoryRecord, getCurrentUrl } from '../helpers';\nimport Swup from '../Swup';\nimport { PageRecord } from './Cache';\n\nexport type PageRenderOptions = {\n\tevent?: Event;\n\tskipTransition?: boolean;\n};\n\nexport const renderPage = function (\n\tthis: Swup,\n\tpage: PageRecord,\n\t{ event, skipTransition }: PageRenderOptions = {}\n) {\n\tdocument.documentElement.classList.remove('is-leaving');\n\n\t// do nothing if another page was requested in the meantime\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), page.url)) {\n\t\treturn;\n\t}\n\n\tconst { url } = Location.fromUrl(page.responseURL);\n\n\t// update cache and state if the url was redirected\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), url)) {\n\t\tthis.cache.cacheUrl({ ...page, url });\n\t\tthis.currentPageUrl = getCurrentUrl();\n\t\tupdateHistoryRecord(url);\n\t}\n\n\t// only add for page loads with transitions\n\tif (!skipTransition) {\n\t\tdocument.documentElement.classList.add('is-rendering');\n\t}\n\n\tthis.triggerEvent('willReplaceContent', event);\n\n\tthis.replaceContent(page).then(() => {\n\t\tthis.triggerEvent('contentReplaced', event);\n\t\tthis.triggerEvent('pageView', event);\n\n\t\t// empty cache if it's disabled (in case preload plugin filled it)\n\t\tif (!this.options.cache) {\n\t\t\tthis.cache.empty();\n\t\t}\n\n\t\t// Perform in transition\n\t\tthis.enterPage({ event, skipTransition });\n\n\t\t// reset scroll-to element\n\t\tthis.scrollToElement = null;\n\t});\n};\n","import Swup from '../Swup';\n\nexport function updateTransition(this: Swup, from: string, to: string, custom?: string): void {\n\tthis.transition = { from, to, custom };\n}\n\nexport function shouldSkipTransition(this: Swup, { event }: { url?: string; event?: Event }) {\n\tconst isHistoryVisit = event instanceof PopStateEvent;\n\treturn !!(isHistoryVisit && !this.options.animateHistoryBrowsing);\n}\n","import delegate from 'delegate-it';\n\nimport version from './config/version';\n\nimport {\n\tcleanupAnimationClasses,\n\tdelegateEvent,\n\tgetCurrentUrl,\n\tLocation,\n\tmarkSwupElements,\n\tupdateHistoryRecord\n} from './helpers';\nimport { Unsubscribe } from './helpers/delegateEvent';\n\nimport { Cache } from './modules/Cache';\nimport { enterPage } from './modules/enterPage';\nimport { getAnchorElement } from './modules/getAnchorElement';\nimport { getAnimationPromises } from './modules/getAnimationPromises';\nimport { getPageData } from './modules/getPageData';\nimport { fetchPage } from './modules/fetchPage';\nimport { leavePage } from './modules/leavePage';\nimport { loadPage, performPageLoad } from './modules/loadPage';\nimport { replaceContent } from './modules/replaceContent';\nimport { on, off, triggerEvent, Handlers } from './modules/events';\nimport { use, unuse, findPlugin, Plugin } from './modules/plugins';\nimport { renderPage } from './modules/renderPage';\nimport { updateTransition, shouldSkipTransition } from './modules/transitions';\n\nimport { queryAll } from './utils';\n\nexport type Transition = {\n\tfrom?: string;\n\tto?: string;\n\tcustom?: string;\n};\n\ntype DelegatedListeners = {\n\tclick?: Unsubscribe;\n};\n\nexport type Options = {\n\tanimateHistoryBrowsing: boolean;\n\tanimationSelector: string | false;\n\tlinkSelector: string;\n\tcache: boolean;\n\tcontainers: string[];\n\trequestHeaders: Record<string, string>;\n\tplugins: Plugin[];\n\tskipPopStateHandling: (event: any) => boolean;\n\tignoreVisit: (url: string, { el }: { el?: Element }) => boolean;\n\tresolveUrl: (url: string) => string;\n};\n\nexport default class Swup {\n\tversion = version;\n\n\t_handlers: Handlers = {\n\t\tanimationInDone: [],\n\t\tanimationInStart: [],\n\t\tanimationOutDone: [],\n\t\tanimationOutStart: [],\n\t\tanimationSkipped: [],\n\t\tclickLink: [],\n\t\tcontentReplaced: [],\n\t\tdisabled: [],\n\t\tenabled: [],\n\t\topenPageInNewTab: [],\n\t\tpageLoaded: [],\n\t\tpageRetrievedFromCache: [],\n\t\tpageView: [],\n\t\tpopState: [],\n\t\tsamePage: [],\n\t\tsamePageWithHash: [],\n\t\tserverError: [],\n\t\ttransitionStart: [],\n\t\ttransitionEnd: [],\n\t\twillReplaceContent: []\n\t};\n\n\t// variable for anchor to scroll to after render\n\tscrollToElement: string | null = null;\n\t// variable for save options\n\toptions: Options;\n\t// running plugin instances\n\tplugins: Plugin[] = [];\n\t// variable for current transition info object\n\ttransition: Transition = {};\n\t// cache instance\n\tcache: Cache;\n\t// allows us to compare the current and new path inside popStateHandler\n\tcurrentPageUrl = getCurrentUrl();\n\t// variable for keeping event listeners from \"delegate\"\n\tdelegatedListeners: DelegatedListeners = {};\n\t// so we are able to remove the listener\n\tboundPopStateHandler: (event: PopStateEvent) => void;\n\n\tloadPage = loadPage;\n\tperformPageLoad = performPageLoad;\n\tleavePage = leavePage;\n\trenderPage = renderPage;\n\treplaceContent = replaceContent;\n\tenterPage = enterPage;\n\ttriggerEvent = triggerEvent;\n\tdelegateEvent = delegateEvent;\n\ton = on;\n\toff = off;\n\tupdateTransition = updateTransition;\n\tshouldSkipTransition = shouldSkipTransition;\n\tgetAnimationPromises = getAnimationPromises;\n\tgetPageData = getPageData;\n\tfetchPage = fetchPage;\n\tgetAnchorElement = getAnchorElement;\n\tlog: (message: string, context?: any) => void = () => {}; // here so it can be used by plugins\n\tuse = use;\n\tunuse = unuse;\n\tfindPlugin = findPlugin;\n\tgetCurrentUrl = getCurrentUrl;\n\tcleanupAnimationClasses = cleanupAnimationClasses;\n\n\tdefaults: Options = {\n\t\tanimateHistoryBrowsing: false,\n\t\tanimationSelector: '[class*=\"transition-\"]',\n\t\tcache: true,\n\t\tcontainers: ['#swup'],\n\t\tignoreVisit: (url, { el } = {}) => !!el?.closest('[data-no-swup]'),\n\t\tlinkSelector: 'a[href]',\n\t\tplugins: [],\n\t\tresolveUrl: (url) => url,\n\t\trequestHeaders: {\n\t\t\t'X-Requested-With': 'swup',\n\t\t\tAccept: 'text/html, application/xhtml+xml'\n\t\t},\n\t\tskipPopStateHandling: (event) => event.state?.source !== 'swup'\n\t};\n\n\tconstructor(options: Partial<Options> = {}) {\n\t\t// Merge defaults and options\n\t\tthis.options = { ...this.defaults, ...options };\n\n\t\tthis.boundPopStateHandler = this.popStateHandler.bind(this);\n\n\t\tthis.cache = new Cache(this);\n\n\t\tthis.enable();\n\t}\n\n\tenable() {\n\t\t// Check for Promise support\n\t\tif (typeof Promise === 'undefined') {\n\t\t\tconsole.warn('Promise is not supported');\n\t\t\treturn;\n\t\t}\n\n\t\t// Add event listeners\n\t\tthis.delegatedListeners.click = delegateEvent(\n\t\t\tthis.options.linkSelector,\n\t\t\t'click',\n\t\t\tthis.linkClickHandler.bind(this)\n\t\t);\n\n\t\twindow.addEventListener('popstate', this.boundPopStateHandler);\n\n\t\t// Initial save to cache\n\t\tif (this.options.cache) {\n\t\t\t// Disabled to avoid caching modified dom state: logic moved to preload plugin\n\t\t\t// https://github.com/swup/swup/issues/475\n\t\t}\n\n\t\t// Mark swup blocks in html\n\t\tmarkSwupElements(document.documentElement, this.options.containers);\n\n\t\t// Mount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.use(plugin));\n\n\t\t// Modify initial history record\n\t\tupdateHistoryRecord();\n\n\t\t// Trigger enabled event\n\t\tthis.triggerEvent('enabled');\n\n\t\t// Add swup-enabled class to html tag\n\t\tdocument.documentElement.classList.add('swup-enabled');\n\n\t\t// Trigger page view event\n\t\tthis.triggerEvent('pageView');\n\t}\n\n\tdestroy() {\n\t\t// remove delegated listeners\n\t\tthis.delegatedListeners.click!.destroy();\n\n\t\t// remove popstate listener\n\t\twindow.removeEventListener('popstate', this.boundPopStateHandler);\n\n\t\t// empty cache\n\t\tthis.cache.empty();\n\n\t\t// unmount plugins\n\t\tthis.options.plugins.forEach((plugin) => {\n\t\t\tthis.unuse(plugin);\n\t\t});\n\n\t\t// remove swup data atributes from blocks\n\t\tqueryAll('[data-swup]').forEach((element) => {\n\t\t\telement.removeAttribute('data-swup');\n\t\t});\n\n\t\t// remove handlers\n\t\tthis.off();\n\n\t\t// trigger disable event\n\t\tthis.triggerEvent('disabled');\n\n\t\t// remove swup-enabled class from html tag\n\t\tdocument.documentElement.classList.remove('swup-enabled');\n\t}\n\n\tshouldIgnoreVisit(href: string, { el }: { el?: Element } = {}) {\n\t\tconst { origin, url, hash } = Location.fromUrl(href);\n\n\t\t// Ignore if the new origin doesn't match the current one\n\t\tif (origin !== window.location.origin) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the link/form would open a new window (or none at all)\n\t\tif (el && this.triggerWillOpenNewWindow(el)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the visit should be ignored as per user options\n\t\tif (this.options.ignoreVisit(url + hash, { el })) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Finally, allow the visit\n\t\treturn false;\n\t}\n\n\tlinkClickHandler(event: delegate.Event<MouseEvent>) {\n\t\tconst linkEl = event.delegateTarget;\n\t\tconst { href, url, hash } = Location.fromElement(linkEl as HTMLAnchorElement);\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href, { el: linkEl })) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if control key pressed\n\t\tif (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n\t\t\tthis.triggerEvent('openPageInNewTab', event);\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if other than left mouse button\n\t\tif (event.button !== 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.triggerEvent('clickLink', event);\n\t\tevent.preventDefault();\n\n\t\t// Handle links to the same page and exit early, where applicable\n\t\tif (!url || url === getCurrentUrl()) {\n\t\t\tthis.handleLinkToSamePage(url, hash, event);\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the resolved path hasn't changed\n\t\tif (this.isSameResolvedUrl(url, getCurrentUrl())) return;\n\n\t\t// Store the element that should be scrolled to after loading the next page\n\t\tthis.scrollToElement = hash || null;\n\n\t\t// Get the custom transition name, if present\n\t\tconst customTransition = linkEl.getAttribute('data-swup-transition') || undefined;\n\n\t\t// Finally, proceed with loading the page\n\t\tthis.performPageLoad({ url, customTransition });\n\t}\n\n\thandleLinkToSamePage(url: string, hash: string, event: MouseEvent) {\n\t\t// Emit event and exit early if the url points to the same page without hash\n\t\tif (!hash) {\n\t\t\tthis.triggerEvent('samePage', event);\n\t\t\treturn;\n\t\t}\n\n\t\t// link to the same URL with hash\n\t\tthis.triggerEvent('samePageWithHash', event);\n\n\t\tconst element = getAnchorElement(hash);\n\n\t\t// Warn and exit early if no matching element was found for the hash\n\t\tif (!element) {\n\t\t\treturn console.warn(`Element for offset not found (#${hash})`);\n\t\t}\n\n\t\tupdateHistoryRecord(url + hash);\n\t}\n\n\ttriggerWillOpenNewWindow(triggerEl: Element) {\n\t\tif (triggerEl.matches('[download], [target=\"_blank\"]')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpopStateHandler(event: PopStateEvent) {\n\t\t// Exit early if this event should be ignored\n\t\tif (this.options.skipPopStateHandling(event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the resolved path hasn't changed\n\t\tif (this.isSameResolvedUrl(getCurrentUrl(), this.currentPageUrl)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst href = event.state?.url ?? location.href;\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { url, hash } = Location.fromUrl(href);\n\n\t\tif (hash) {\n\t\t\tthis.scrollToElement = hash;\n\t\t} else {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\tthis.triggerEvent('popState', event);\n\n\t\tif (!this.options.animateHistoryBrowsing) {\n\t\t\tdocument.documentElement.classList.remove('is-animating');\n\t\t\tcleanupAnimationClasses();\n\t\t}\n\n\t\tthis.performPageLoad({ url, event });\n\t}\n\n\t/**\n\t * Utility function to validate and run the global option 'resolveUrl'\n\t * @param {string} url\n\t * @returns {string} the resolved url\n\t */\n\tresolveUrl(url: string) {\n\t\tif (typeof this.options.resolveUrl !== 'function') {\n\t\t\tconsole.warn(`[swup] options.resolveUrl expects a callback function.`);\n\t\t\treturn url;\n\t\t}\n\t\tconst result = this.options.resolveUrl(url);\n\t\tif (!result || typeof result !== 'string') {\n\t\t\tconsole.warn(`[swup] options.resolveUrl needs to return a url`);\n\t\t\treturn url;\n\t\t}\n\t\tif (result.startsWith('//') || result.startsWith('http')) {\n\t\t\tconsole.warn(`[swup] options.resolveUrl needs to return a relative url`);\n\t\t\treturn url;\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Compares the resolved version of two paths and returns true if they are the same\n\t * @param {string} url1\n\t * @param {string} url2\n\t * @returns {boolean}\n\t */\n\tisSameResolvedUrl(url1: string, url2: string) {\n\t\treturn this.resolveUrl(url1) === this.resolveUrl(url2);\n\t}\n}\n"],"names":["getCurrentUrl","_temp","hash","location","pathname","search","updateHistoryRecord","url","customData","data","history","state","random","Math","source","replaceState","ledger","WeakMap","editLedger","wanted","baseElement","callback","setup","_a","_b","has","elementMap","get","set","setups","Set","existed","add","delete","delegate","base","selector","type","options","document","querySelectorAll","addEventListener","subscriptions","Array","prototype","map","call","element","destroy","subscription","Document","documentElement","capture","Boolean","listenerFn","event","delegateTarget","target","Text","parentElement","Element","currentTarget","closest","contains","safeClosest","once","JSON","stringify","delegateSubscription","removeEventListener","delegateEvent","eventOptions","delegation","query","context","querySelector","queryAll","from","toMs","s","Number","slice","replace","Location","constructor","baseURI","super","toString","this","static","el","getAttribute","href","markSwupElements","isSwupClass","className","test","includes","cleanupAnimationClasses","removeClasses","split","filter","classList","remove","Cache","swup","pages","last","getCacheUrl","resolveUrl","fromUrl","cacheUrl","page","responseURL","log","Object","keys","length","getPage","getCurrentPage","exists","empty","enterPage","skipTransition","triggerEvent","Promise","resolve","requestAnimationFrame","animationPromises","getAnimationPromises","all","then","getAnchorElement","charAt","substring","ident","decodeURIComponent","window","CSS","escape","transitionProp","transitionEndEvent","animationProp","animationEndEvent","animationType","animationSelector","body","animatedElements","expectedType","timeout","propCount","styles","getComputedStyle","animationDelay","transitionDelays","transitionDurations","transitionDuration","transitionTimeout","calculateTimeout","animationDelays","animationDurations","animationDuration","animationTimeout","max","getTransitionInfo","performance","now","end","endEvent","onEnd","elapsedTime","isTransitionOrAnimationEvent","Error","startTime","propsTransitioned","setTimeout","console","warn","getAnimationPromiseForElement","delays","durations","concat","duration","i","undefined","ontransitionend","onwebkittransitionend","onanimationend","onwebkitanimationend","getPageData","request","pageHtmlData","html","containers","fakeDom","createElement","innerHTML","blocks","forEach","item","index","setAttribute","String","push","outerHTML","title","innerText","pageClass","originalContent","getDataFromHtml","responseText","fetchPage","headers","requestHeaders","cache","reject","defaults","method","onreadystatechange","readyState","open","entries","_ref","key","header","setRequestHeader","send","fetch","response","status","cacheablePageData","leavePage","isHistoryVisit","loadPage","shouldIgnoreVisit","performPageLoad","customTransition","PopStateEvent","shouldSkipTransition","text","updateTransition","toLowerCase","pushState","createHistoryRecord","scrollToElement","currentPageUrl","fetchPromise","pageData","renderPage","catch","errorUrl","skipPopStateHandling","go","replaceContent","handler","_handlers","off","h","eventName","originalEvent","error","CustomEvent","detail","dispatchEvent","plugin","isSwupPlugin","_checkRequirements","_beforeMount","mount","plugins","pluginOrName","findPlugin","unmount","_afterUnmount","p","find","name","isSameResolvedUrl","to","custom","transition","animateHistoryBrowsing","version","animationInDone","animationInStart","animationOutDone","animationOutStart","animationSkipped","clickLink","contentReplaced","disabled","enabled","openPageInNewTab","pageLoaded","pageRetrievedFromCache","pageView","popState","samePage","samePageWithHash","serverError","transitionStart","transitionEnd","willReplaceContent","delegatedListeners","boundPopStateHandler","on","use","unuse","ignoreVisit","linkSelector","Accept","popStateHandler","bind","enable","click","linkClickHandler","removeAttribute","_temp2","origin","triggerWillOpenNewWindow","linkEl","fromElement","metaKey","ctrlKey","shiftKey","altKey","button","preventDefault","handleLinkToSamePage","triggerEl","matches","result","startsWith","url1","url2"],"mappings":"uNAAO,MCAMA,EAAgB,SAAAC,GAAC,IAAAC,KAAEA,QAA6B,IAAA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nP,KAAKlD,QAAQuE,WAAWtG,GACvC,OAAKoU,GAA4B,mBAI7BA,EAAOC,WAAW,OAASD,EAAOC,WAAW,SAChD5J,QAAQC,KAAK,+DAIf0J,GARE3J,QAAQC,KAAK,mDAEb1K,EAMF,CAQA8Q,kBAAkBwD,EAAcC,GAC/B,OAAWtP,KAACqB,WAAWgO,KAAUrP,KAAKqB,WAAWiO,EAClD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "swup",
3
3
  "amdName": "Swup",
4
- "version": "3.0.2",
4
+ "version": "3.0.3",
5
5
  "description": "Complete, flexible, extensible, and easy-to-use page transition library for your server-side rendered website.",
6
6
  "type": "module",
7
7
  "source": "src/Swup.ts",
@@ -16,9 +16,9 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "build": "npm run build:module && npm run build:bundle",
19
- "build:module": "microbundle src/index.ts -f modern,esm,cjs",
20
- "build:bundle": "microbundle src/Swup.ts -f umd --external none",
21
- "dev": "microbundle src/*.ts -w",
19
+ "build:module": "BROWSERSLIST_ENV=modern microbundle src/index.ts -f modern,esm,cjs",
20
+ "build:bundle": "BROWSERSLIST_ENV=production microbundle src/Swup.ts -f umd --external none",
21
+ "dev": "BROWSERSLIST_ENV=development microbundle src/*.ts -w",
22
22
  "lint": "npm run lint:ts && npm run lint:prettier -- --check",
23
23
  "format": "npm run lint:ts && npm run lint:prettier -- --write",
24
24
  "lint:ts": "tsc --noEmit --skipLibCheck",
@@ -58,6 +58,7 @@
58
58
  "devDependencies": {
59
59
  "@babel/preset-typescript": "^7.18.6",
60
60
  "@cypress/code-coverage": "^3.10.0",
61
+ "@swup/browserslist-config": "^1.0.0",
61
62
  "@swup/prettier-config": "^1.0.0",
62
63
  "@types/jest": "^29.2.5",
63
64
  "cypress": "^12.3.0",
@@ -76,5 +77,8 @@
76
77
  "type": "opencollective",
77
78
  "url": "https://opencollective.com/swup"
78
79
  },
80
+ "browserslist": [
81
+ "extends @swup/browserslist-config"
82
+ ],
79
83
  "prettier": "@swup/prettier-config"
80
84
  }
@@ -7,8 +7,19 @@ console.error = jest.fn();
7
7
 
8
8
  const baseUrl = window.location.origin;
9
9
 
10
- describe('exports', () => {
11
- it('exports Swup, and Options/Plugin types', () => {
10
+ function createPlugin(plugin = {}) {
11
+ return {
12
+ name: 'TestPlugin',
13
+ isSwupPlugin: true as const,
14
+ mount: jest.fn(() => {}),
15
+ unmount: jest.fn(() => {}),
16
+ _checkRequirements: jest.fn(() => true),
17
+ ...plugin
18
+ };
19
+ }
20
+
21
+ describe('Exports', () => {
22
+ it('should export Swup and Options/Plugin types', () => {
12
23
  class SwupPlugin implements Plugin {
13
24
  name = 'SwupPlugin';
14
25
  isSwupPlugin = true as const;
@@ -36,13 +47,15 @@ describe('exports', () => {
36
47
  expect(swup).toBeInstanceOf(Swup);
37
48
  });
38
49
 
39
- it('defines a version', () => {
50
+ it('should define a version', () => {
40
51
  const swup = new Swup();
41
52
  expect(swup.version).not.toBeUndefined();
42
53
  expect(swup.version).toEqual(pckg.version);
43
54
  });
55
+ });
44
56
 
45
- it('calls and passes relative URL to ignoreVisit', () => {
57
+ describe('ignoreVisit', () => {
58
+ it('should be called with relative URL', () => {
46
59
  const ignoreVisit = jest.fn(() => true);
47
60
  const swup = new Swup({ ignoreVisit });
48
61
 
@@ -53,7 +66,7 @@ describe('exports', () => {
53
66
  expect((ignoreVisit.mock.lastCall as any)[0]).toEqual('/path/?query#hash');
54
67
  });
55
68
 
56
- it('calls ignoreVisit from loadPage method', () => {
69
+ it('should be called from loadPage method', () => {
57
70
  const ignoreVisit = jest.fn(() => true);
58
71
  const swup = new Swup({ ignoreVisit });
59
72
 
@@ -62,3 +75,61 @@ describe('exports', () => {
62
75
  expect(ignoreVisit.mock.calls).toHaveLength(1);
63
76
  });
64
77
  });
78
+
79
+ describe('Plugin module', () => {
80
+ it('should mount and unmount plugins', function () {
81
+ const plugin = createPlugin();
82
+ const swup = new Swup();
83
+ swup.use(plugin);
84
+ swup.unuse(plugin);
85
+
86
+ expect(plugin.mount.mock.calls).toHaveLength(1);
87
+ expect(plugin.unmount.mock.calls).toHaveLength(1);
88
+ });
89
+
90
+ it('should mount plugins from options', function () {
91
+ const plugin = createPlugin();
92
+ const swup = new Swup({ plugins: [plugin] });
93
+ expect(plugin.mount.mock.calls).toHaveLength(1);
94
+ });
95
+
96
+ it('should find a plugin instance by reference', function () {
97
+ const plugin = createPlugin({ name: 'ExamplePlugin' });
98
+ const swup = new Swup({ plugins: [plugin] });
99
+ const instance = swup.findPlugin(plugin);
100
+
101
+ expect(instance).toEqual(expect.objectContaining({ name: 'ExamplePlugin' }));
102
+ });
103
+
104
+ it('should find a plugin instance by name', function () {
105
+ const plugin = createPlugin({ name: 'ExamplePlugin' });
106
+ const swup = new Swup({ plugins: [plugin] });
107
+ const instance = swup.findPlugin('ExamplePlugin');
108
+
109
+ expect(instance).toEqual(expect.objectContaining({ name: 'ExamplePlugin' }));
110
+ });
111
+
112
+ it('should check plugin requirements', function () {
113
+ const plugin = createPlugin();
114
+ const swup = new Swup({ plugins: [plugin] });
115
+ expect(plugin._checkRequirements.mock.calls).toHaveLength(1);
116
+ });
117
+
118
+ it('should reject plugins with unmet requirements', function () {
119
+ const allowedPlugin = createPlugin({
120
+ name: 'AllowedPlugin',
121
+ _checkRequirements: () => true
122
+ });
123
+ const unallowedPlugin = createPlugin({
124
+ name: 'UnallowedPlugin',
125
+ _checkRequirements: () => false
126
+ });
127
+ const swup = new Swup({ plugins: [allowedPlugin, unallowedPlugin] });
128
+
129
+ const allowedInstance = swup.findPlugin(allowedPlugin);
130
+ expect(allowedInstance).toEqual(expect.objectContaining({ name: 'AllowedPlugin' }));
131
+
132
+ const unallowedInstance = swup.findPlugin(unallowedPlugin);
133
+ expect(unallowedInstance).toBeUndefined();
134
+ });
135
+ });