@alignable/bifrost 0.0.21 → 0.0.23
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.
- package/dist/{chunk-ZZ5EBVFO.js → chunk-UQXLIJWA.js} +1 -1
- package/dist/chunk-UQXLIJWA.js.map +1 -0
- package/dist/controller-16e58bbd.d.ts +7 -0
- package/dist/index.d.ts +3 -2
- package/dist/{internal-5ba13db0.d.ts → internal-45a068f0.d.ts} +14 -6
- package/dist/proxy/pages/+config.js.map +1 -1
- package/dist/proxy/pages/onBeforeRender.d.ts +16 -3
- package/dist/proxy/pages/onBeforeRender.js +22 -2
- package/dist/proxy/pages/onBeforeRender.js.map +1 -1
- package/dist/proxy/pages/onRenderClient.d.ts +2 -1
- package/dist/proxy/pages/onRenderClient.js +1 -1
- package/dist/proxy/pages/onRenderHtml.d.ts +2 -1
- package/dist/proxy/pages/restorationVisit/+config.d.ts +5 -2
- package/dist/proxy/pages/restorationVisit/+config.js +6 -5
- package/dist/proxy/pages/restorationVisit/+config.js.map +1 -1
- package/dist/proxy/pages/restorationVisit/onBeforeRender.d.ts +3 -0
- package/dist/proxy/pages/restorationVisit/onBeforeRender.js +7 -0
- package/dist/proxy/pages/restorationVisit/onBeforeRender.js.map +1 -0
- package/dist/proxy/pages/restorationVisit/onRenderClient.d.ts +2 -1
- package/dist/proxy/pages/restorationVisit/onRenderClient.js +3 -2
- package/dist/proxy/pages/restorationVisit/onRenderClient.js.map +1 -1
- package/dist/renderer/+config.js.map +1 -1
- package/dist/renderer/getConfigOrPageContext.d.ts +2 -1
- package/dist/renderer/onBeforeRoute.d.ts +6 -1
- package/dist/renderer/onBeforeRoute.js +1 -3
- package/dist/renderer/onBeforeRoute.js.map +1 -1
- package/dist/renderer/onRenderClient.d.ts +2 -1
- package/dist/renderer/onRenderClient.js +1 -1
- package/dist/renderer/onRenderHtml.d.ts +2 -1
- package/dist/renderer/usePageContext.d.ts +2 -1
- package/dist/renderer/utils/buildHead.d.ts +2 -1
- package/package.json +7 -3
- package/dist/chunk-ZZ5EBVFO.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/renderReact.ts","../lib/turbolinks/util.ts","../lib/turbolinks/mergeHead.ts","../lib/turbolinks/lruCache.ts","../lib/turbolinks/progress_bar.ts","../lib/turbolinks/browser_adapter.ts","../lib/turbolinks/location.ts","../lib/turbolinks/types.ts","../lib/turbolinks/visit.ts","../lib/turbolinks/controller.ts","../lib/turbolinks/index.ts"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { Root, createRoot, hydrateRoot } from \"react-dom/client\";\n\nlet root: Root;\n\nexport function renderReact(page: ReactNode, isHydration: boolean) {\n const container = document.getElementById(\"page-view\")!;\n if (isHydration) {\n root = hydrateRoot(container, page);\n } else {\n if (!root) {\n root = createRoot(container);\n }\n root.render(page);\n }\n}\n","export function array<T>(values: ArrayLike<T>): T[] {\n return Array.prototype.slice.call(values);\n}\n\nexport const closest = (() => {\n const html = document.documentElement;\n\n type MatchesSelector = (this: Element, selector: string) => boolean;\n const match: MatchesSelector =\n html.matches ||\n (html as any).webkitMatchesSelector ||\n (html as any).msMatchesSelector ||\n (html as any).mozMatchesSelector;\n\n type Closest = (this: Element, selector: string) => Element | null;\n const closest: Closest =\n html.closest ||\n function (selector: string) {\n let element: Element | null = this;\n while (element) {\n if (match.call(element, selector)) {\n return element;\n } else {\n element = element.parentElement;\n }\n }\n };\n\n return function (element: Element, selector: string) {\n return closest.call(element, selector);\n };\n})();\n\nexport function defer(callback: () => any) {\n setTimeout(callback, 1);\n}\n\nexport type DispatchOptions = {\n target: EventTarget;\n cancelable: boolean;\n data: any;\n};\n\nexport function dispatch(\n eventName: string,\n { target, cancelable, data }: Partial<DispatchOptions> = {}\n) {\n const event = document.createEvent(\"Events\") as Event & { data: any };\n event.initEvent(eventName, true, cancelable == true);\n event.data = data || {};\n\n // Fix setting `defaultPrevented` when `preventDefault()` is called\n // http://stackoverflow.com/questions/23349191/event-preventdefault-is-not-working-in-ie-11-for-custom-events\n if (event.cancelable && !preventDefaultSupported) {\n const { preventDefault } = event;\n event.preventDefault = function () {\n if (!this.defaultPrevented) {\n Object.defineProperty(this, \"defaultPrevented\", { get: () => true });\n }\n preventDefault.call(this);\n };\n }\n\n (target || document).dispatchEvent(event);\n return event;\n}\n\nconst preventDefaultSupported = (() => {\n const event = document.createEvent(\"Events\");\n event.initEvent(\"test\", true, true);\n event.preventDefault();\n return event.defaultPrevented;\n})();\n\nexport function unindent(\n strings: TemplateStringsArray,\n ...values: any[]\n): string {\n const lines = trimLeft(interpolate(strings, values)).split(\"\\n\");\n const match = lines[0].match(/^\\s+/);\n const indent = match ? match[0].length : 0;\n return lines.map((line) => line.slice(indent)).join(\"\\n\");\n}\n\nfunction trimLeft(string: string) {\n return string.replace(/^\\n/, \"\");\n}\n\nfunction interpolate(strings: TemplateStringsArray, values: any[]) {\n return strings.reduce((result, string, i) => {\n const value = values[i] == undefined ? \"\" : values[i];\n return result + string + value;\n }, \"\");\n}\n\nexport function uuid() {\n return Array.apply(null, { length: 36 } as any)\n .map((_, i) => {\n if (i == 8 || i == 13 || i == 18 || i == 23) {\n return \"-\";\n } else if (i == 14) {\n return \"4\";\n } else if (i == 19) {\n return (Math.floor(Math.random() * 4) + 8).toString(16);\n } else {\n return Math.floor(Math.random() * 15).toString(16);\n }\n })\n .join(\"\");\n}\n\nexport function createScriptElement(element: Element, cb?: () => void) {\n if (element.getAttribute(\"data-turbolinks-eval\") == \"false\") {\n return element;\n } else {\n const createdScriptElement = document.createElement(\"script\");\n createdScriptElement.textContent = element.textContent;\n // async false makes scripts run in-order. it wont block js execution (thankfully)\n // https://github.com/turbolinks/turbolinks/issues/282#issuecomment-355731712\n createdScriptElement.async = false;\n copyElementAttributes(createdScriptElement, element);\n if (cb) {\n createdScriptElement.addEventListener(\"load\", cb);\n }\n return createdScriptElement;\n }\n}\n\nexport function copyElementAttributes(\n destinationElement: Element,\n sourceElement: Element\n) {\n for (const { name, value } of array(sourceElement.attributes)) {\n destinationElement.setAttribute(name, value);\n }\n}\n\nfunction replaceElementWithElement(fromElement: Element, toElement: Element) {\n const parentElement = fromElement.parentElement;\n if (parentElement) {\n return parentElement.replaceChild(toElement, fromElement);\n }\n}\nexport function activateNewBodyScriptElements(\n newScriptElements: HTMLScriptElement[]\n) {\n for (const inertScriptElement of newScriptElements) {\n const activatedScriptElement = createScriptElement(inertScriptElement);\n replaceElementWithElement(inertScriptElement, activatedScriptElement);\n }\n}\n\nexport function focusFirstAutofocusableElement() {\n const element = document.body.querySelector(\"[autofocus]\");\n if (element && \"focus\" in element && typeof element.focus === \"function\") {\n element.focus();\n }\n}\n","import { createScriptElement } from \"./util\";\n\ninterface ElementDetails {\n tracked: boolean;\n}\nconst allHeadScriptsEverRun: { [outerHTML: string]: ElementDetails } = {};\nlet firstLoad = true;\nlet lastTrackedScriptSignature: string;\n\nexport async function mergeHead(\n head: HTMLHeadElement,\n trackScripts: boolean,\n reload: () => void\n) {\n const newHead = categorizeHead(head);\n const oldHead = categorizeHead(document.head);\n\n if (\n head\n .querySelector('meta[name=\"turbolinks-visit-control\"]')\n ?.getAttribute(\"content\") === \"reload\"\n ) {\n reload();\n }\n if (trackScripts) {\n lastTrackedScriptSignature =\n lastTrackedScriptSignature ||\n trackedElementSignature([...oldHead.scripts, ...oldHead.stylesheets]);\n if (\n lastTrackedScriptSignature !==\n trackedElementSignature([...newHead.scripts, ...newHead.stylesheets])\n ) {\n reload();\n }\n }\n\n if (firstLoad) {\n // TODO: messy code\n for (const element of oldHead.scripts) {\n allHeadScriptsEverRun[element.outerHTML] = {\n tracked: elementIsTracked(element),\n };\n }\n firstLoad = false;\n }\n\n copyNewHeadStylesheetElements(newHead.stylesheets, oldHead.stylesheets);\n removeCurrentHeadProvisionalElements(oldHead.provisional);\n copyNewHeadProvisionalElements(newHead.provisional);\n\n return new Promise<void>((resolve) => {\n copyNewHeadScriptElements(newHead.scripts, resolve);\n });\n}\n\nfunction trackedElementSignature(scripts: Element[]) {\n return scripts\n .filter(elementIsTracked)\n .map((s) => s.outerHTML)\n .join();\n}\n\nfunction copyNewHeadStylesheetElements(next: Element[], prev: Element[]) {\n const existing = prev.map((s) => s.outerHTML);\n for (const element of next) {\n if (!existing.includes(element.outerHTML)) {\n document.head.appendChild(element);\n }\n }\n}\n\nfunction copyNewHeadScriptElements(\n next: Element[],\n onScriptsLoaded: () => void\n) {\n let blockingLoaded: boolean[] = [];\n function dispatch() {\n onScriptsLoaded();\n }\n for (const element of next as HTMLScriptElement[]) {\n const runBefore = element.outerHTML in allHeadScriptsEverRun;\n if (!runBefore) {\n let cb;\n if (!element.defer && element.src) {\n const idx = blockingLoaded.length;\n cb = () => {\n blockingLoaded[idx] = true;\n if (blockingLoaded.every((v) => v)) {\n dispatch();\n }\n };\n blockingLoaded.push(false);\n }\n document.head.appendChild(createScriptElement(element, cb));\n allHeadScriptsEverRun[element.outerHTML] = {\n tracked: elementIsTracked(element),\n };\n }\n }\n if (blockingLoaded.length === 0) {\n // raf waits for react to finish\n requestAnimationFrame(dispatch);\n }\n}\n\nfunction removeCurrentHeadProvisionalElements(prev: Element[]) {\n for (const element of prev) {\n document.head.removeChild(element);\n }\n}\n\nfunction copyNewHeadProvisionalElements(next: Element[]) {\n for (const element of next) {\n document.head.appendChild(element);\n }\n}\n\nfunction elementIsTracked(element: Element) {\n return element.getAttribute(\"data-turbolinks-track\") == \"reload\";\n}\n\nfunction elementIsScript(element: Element) {\n const tagName = element.tagName.toLowerCase();\n return tagName == \"script\";\n}\n\nfunction elementIsStylesheet(element: Element) {\n const tagName = element.tagName.toLowerCase();\n return (\n tagName == \"style\" ||\n (tagName == \"link\" && element.getAttribute(\"rel\") == \"stylesheet\")\n );\n}\n\nfunction elementIsFavicon(element: Element) {\n const tagName = element.tagName.toLowerCase();\n\n return tagName == \"link\" && element.getAttribute(\"rel\") == \"icon\";\n}\n\nfunction categorizeHead(head: ParentNode) {\n const scripts = [];\n const stylesheets = [];\n const provisional = [];\n for (const element of head.children) {\n // we want to keep the same favicon on page transitions\n if (elementIsFavicon(element)) {\n continue;\n }\n\n if (elementIsScript(element)) {\n scripts.push(element);\n } else if (elementIsStylesheet(element)) {\n stylesheets.push(element);\n } else {\n provisional.push(element);\n }\n }\n return { scripts, stylesheets, provisional };\n}\n","export class LruCache<T> {\n private values: Map<string, T> = new Map<string, T>();\n private maxEntries;\n\n constructor(maxEntries: number) {\n this.maxEntries = maxEntries;\n }\n\n public get(key: string): T | undefined {\n const hasKey = this.values.has(key);\n let entry: T | undefined;\n if (hasKey) {\n // peek the entry, re-insert for LRU strategy\n entry = this.values.get(key)!;\n this.values.delete(key);\n this.values.set(key, entry);\n }\n\n return entry;\n }\n\n public put(key: string, value: T) {\n if (this.values.size >= this.maxEntries) {\n // least-recently used cache eviction strategy\n const keyToDelete = this.values.keys().next().value;\n\n this.values.delete(keyToDelete);\n }\n\n this.values.set(key, value);\n }\n}\n","import { unindent } from \"./util\";\n\nexport class ProgressBar {\n static animationDuration = 300; /*ms*/\n\n static get defaultCSS() {\n return unindent`\n .turbolinks-progress-bar {\n position: fixed;\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n background: #0076ff;\n z-index: 9999;\n transition:\n width ${ProgressBar.animationDuration}ms ease-out,\n opacity ${ProgressBar.animationDuration / 2}ms ${\n ProgressBar.animationDuration / 2\n }ms ease-in;\n transform: translate3d(0, 0, 0);\n }\n `;\n }\n\n readonly stylesheetElement = this.createStylesheetElement();\n readonly progressElement = this.createProgressElement();\n\n hiding = false;\n trickleInterval?: number;\n value = 0;\n visible = false;\n\n show() {\n if (!this.visible) {\n this.visible = true;\n this.installStylesheetElement();\n this.installProgressElement();\n this.startTrickling();\n }\n }\n\n hide() {\n if (this.visible && !this.hiding) {\n this.hiding = true;\n this.fadeProgressElement(() => {\n this.uninstallProgressElement();\n this.stopTrickling();\n this.visible = false;\n this.hiding = false;\n });\n }\n }\n\n setValue(value: number) {\n this.value = value;\n this.refresh();\n }\n\n // Private\n\n installStylesheetElement() {\n document.head.insertBefore(\n this.stylesheetElement,\n document.head.firstChild\n );\n }\n\n installProgressElement() {\n this.progressElement.style.width = \"0\";\n this.progressElement.style.opacity = \"1\";\n document.documentElement.insertBefore(this.progressElement, document.body);\n this.refresh();\n }\n\n fadeProgressElement(callback: () => void) {\n this.progressElement.style.opacity = \"0\";\n setTimeout(callback, ProgressBar.animationDuration * 1.5);\n }\n\n uninstallProgressElement() {\n if (this.progressElement.parentNode) {\n document.documentElement.removeChild(this.progressElement);\n }\n }\n\n startTrickling() {\n if (!this.trickleInterval) {\n this.trickleInterval = window.setInterval(\n this.trickle,\n ProgressBar.animationDuration\n );\n }\n }\n\n stopTrickling() {\n window.clearInterval(this.trickleInterval);\n delete this.trickleInterval;\n }\n\n trickle = () => {\n this.setValue(this.value + Math.random() / 100);\n };\n\n refresh() {\n requestAnimationFrame(() => {\n this.progressElement.style.width = `${10 + this.value * 90}%`;\n });\n }\n\n createStylesheetElement() {\n const element = document.createElement(\"style\");\n element.type = \"text/css\";\n element.textContent = ProgressBar.defaultCSS;\n return element;\n }\n\n createProgressElement() {\n const element = document.createElement(\"div\");\n element.className = \"turbolinks-progress-bar\";\n return element;\n }\n}\n","import { Adapter } from \"./adapter\";\nimport { Controller } from \"./controller\";\nimport { Locatable } from \"./location\";\nimport { ProgressBar } from \"./progress_bar\";\nimport { Action } from \"./types\";\nimport { Visit } from \"./visit\";\n\nexport class BrowserAdapter implements Adapter {\n readonly controller: Controller;\n readonly progressBar = new ProgressBar();\n\n progressBarTimeout?: number;\n\n constructor(controller: Controller) {\n this.controller = controller;\n }\n\n visitProposedToLocationWithAction(location: Locatable, action: Action) {\n this.controller.startVisitToLocationWithAction(\n location,\n action,\n );\n }\n\n visitStarted(visit: Visit) {\n visit.issueRequest();\n visit.changeHistory();\n visit.loadCachedSnapshot();\n }\n\n visitRequestStarted(visit: Visit) {\n this.progressBar.setValue(0);\n if (visit.hasCachedSnapshot() || visit.action != \"restore\") {\n this.showProgressBarAfterDelay();\n } else {\n this.showProgressBar();\n }\n }\n\n visitRequestProgressed(visit: Visit) {\n this.progressBar.setValue(visit.progress);\n }\n\n visitRequestCompleted(visit: Visit) {\n visit.loadResponse();\n }\n\n visitRequestFailedWithStatusCode(visit: Visit, statusCode: number) {\n switch (statusCode) {\n // TODO\n // case SystemStatusCode.networkFailure:\n // case SystemStatusCode.timeoutFailure:\n // case SystemStatusCode.contentTypeMismatch:\n // return this.reload()\n default:\n return visit.loadResponse();\n }\n }\n\n visitRequestFinished(visit: Visit) {\n this.hideProgressBar();\n }\n\n visitCompleted(visit: Visit) {\n }\n\n pageInvalidated() {\n this.reload();\n }\n\n visitFailed(visit: Visit) {}\n\n visitRendered(visit: Visit) {}\n\n // Private\n\n showProgressBarAfterDelay() {\n this.progressBarTimeout = window.setTimeout(\n this.showProgressBar,\n this.controller.progressBarDelay\n );\n }\n\n showProgressBar = () => {\n this.progressBar.show();\n };\n\n hideProgressBar() {\n this.progressBar.hide();\n if (this.progressBarTimeout != null) {\n window.clearTimeout(this.progressBarTimeout);\n delete this.progressBarTimeout;\n }\n }\n\n reload() {\n window.location.reload();\n }\n}\n","export type Locatable = Location | string;\n\nexport class Location {\n static get currentLocation() {\n return this.wrap(window.location.toString());\n }\n\n static wrap(locatable: Locatable): Location;\n static wrap(locatable?: Locatable | null): Location | undefined;\n static wrap(locatable: Locatable) {\n if (typeof locatable == \"string\") {\n return new this(locatable);\n } else if (locatable != null) {\n return locatable;\n }\n }\n\n readonly absoluteURL: string;\n readonly requestURL: string;\n readonly anchor?: string;\n\n constructor(url: string) {\n const linkWithAnchor = document.createElement(\"a\");\n linkWithAnchor.href = url;\n\n this.absoluteURL = linkWithAnchor.href;\n\n const anchorLength = linkWithAnchor.hash.length;\n if (anchorLength < 2) {\n this.requestURL = this.absoluteURL;\n } else {\n this.requestURL = this.absoluteURL.slice(0, -anchorLength);\n this.anchor = linkWithAnchor.hash.slice(1);\n }\n }\n\n getOrigin() {\n return this.absoluteURL.split(\"/\", 3).join(\"/\");\n }\n\n getPath() {\n return (this.requestURL.match(/\\/\\/[^/]*(\\/[^?;]*)/) || [])[1] || \"/\";\n }\n\n getPathComponents() {\n return this.getPath().split(\"/\").slice(1);\n }\n\n getLastPathComponent() {\n return this.getPathComponents().slice(-1)[0];\n }\n\n getExtension() {\n return (this.getLastPathComponent().match(/\\.[^.]*$/) || [])[0] || \"\";\n }\n\n isHTML() {\n return this.getExtension().match(/^(?:|\\.(?:htm|html|xhtml))$/);\n }\n\n isPrefixedBy(location: Location): boolean {\n const prefixURL = getPrefixURL(location);\n return (\n this.isEqualTo(location) || stringStartsWith(this.absoluteURL, prefixURL)\n );\n }\n\n isEqualTo(location?: Location) {\n return location && this.absoluteURL === location.absoluteURL;\n }\n\n toCacheKey() {\n return this.requestURL;\n }\n\n toJSON() {\n return this.absoluteURL;\n }\n\n toString() {\n return this.absoluteURL;\n }\n\n valueOf() {\n return this.absoluteURL;\n }\n}\n\nfunction getPrefixURL(location: Location) {\n return addTrailingSlash(location.getOrigin() + location.getPath());\n}\n\nfunction addTrailingSlash(url: string) {\n return stringEndsWith(url, \"/\") ? url : url + \"/\";\n}\n\nfunction stringStartsWith(string: string, prefix: string) {\n return string.slice(0, prefix.length) === prefix;\n}\n\nfunction stringEndsWith(string: string, suffix: string) {\n return string.slice(-suffix.length) === suffix;\n}\n","export type Action = \"advance\" | \"replace\" | \"restore\";\n\nexport function isAction(action: any): action is Action {\n return action == \"advance\" || action == \"replace\" || action == \"restore\";\n}\n\nexport type Position = { x: number; y: number };\n","import { navigate } from \"vite-plugin-ssr/client/router\";\nimport { Adapter } from \"./adapter\";\nimport { Controller } from \"./controller.js\";\nimport { Location } from \"./location\";\nimport { Action } from \"./types\";\nimport { uuid } from \"./util\";\n\nexport enum TimingMetric {\n visitStart = \"visitStart\",\n requestStart = \"requestStart\",\n requestEnd = \"requestEnd\",\n visitEnd = \"visitEnd\",\n}\n\nexport type TimingMetrics = Partial<{ [metric in TimingMetric]: any }>;\n\nexport enum VisitState {\n initialized = \"initialized\",\n started = \"started\",\n canceled = \"canceled\",\n failed = \"failed\",\n completed = \"completed\",\n}\n\nexport class Visit {\n readonly controller: Controller;\n readonly action: Action;\n readonly adapter: Adapter;\n readonly identifier = uuid();\n readonly restorationIdentifier: string;\n readonly timingMetrics: TimingMetrics = {};\n\n frame?: number;\n location: Location;\n progress = 0;\n referrer?: Location;\n redirectedToLocation?: Location;\n snapshotCached = false;\n state = VisitState.initialized;\n\n requestInFlight = false;\n renderFn?: () => Promise<void>;\n\n constructor(\n controller: Controller,\n location: Location,\n action: Action,\n restorationIdentifier: string = uuid()\n ) {\n this.controller = controller;\n this.location = location;\n this.action = action;\n this.adapter = controller.adapter;\n this.restorationIdentifier = restorationIdentifier;\n }\n\n start() {\n if (this.state == VisitState.initialized) {\n this.recordTimingMetric(TimingMetric.visitStart);\n this.state = VisitState.started;\n this.adapter.visitStarted(this);\n }\n }\n\n cancel() {\n if (this.state == VisitState.started) {\n this.requestInFlight = false;\n this.cancelRender();\n this.state = VisitState.canceled;\n }\n }\n\n complete() {\n if (this.state == VisitState.started) {\n this.recordTimingMetric(TimingMetric.visitEnd);\n this.state = VisitState.completed;\n this.adapter.visitCompleted(this);\n this.controller.visitCompleted(this);\n }\n }\n\n fail() {\n if (this.state == VisitState.started) {\n this.state = VisitState.failed;\n this.adapter.visitFailed(this);\n }\n }\n\n changeHistory() {\n // no-op since issueRequest calls navigate which handles all of this already\n return;\n }\n\n issueRequest() {\n if (!this.requestInFlight) {\n if (this.shouldIssueRequest()) {\n const url = new URL(\n this.location.toString(),\n this.location.getOrigin()\n );\n navigate(url.pathname + url.hash + url.search, {\n overwriteLastHistoryEntry: this.action === \"replace\",\n }).catch(console.error);\n this.progress = 0;\n this.requestInFlight = true;\n }\n }\n }\n\n getCachedSnapshot() {\n const snapshot = this.controller.getCachedSnapshotForLocation(\n this.location\n );\n if (snapshot) {\n if (this.action == \"restore\") {\n return snapshot;\n }\n }\n }\n\n hasCachedSnapshot() {\n return this.getCachedSnapshot() != null;\n }\n\n loadCachedSnapshot() {\n // no-op since issueRequest calls navigate which handles all of this already\n return;\n }\n\n loadResponse() {\n this.render(async () => {\n if (!this.renderFn)\n throw new Error(\"Render details not set before rendering\");\n this.cacheSnapshot();\n await this.renderFn();\n this.complete();\n });\n }\n\n // HTTP request delegate\n\n /*\n requestStarted() {\n this.recordTimingMetric(TimingMetric.requestStart);\n this.adapter.visitRequestStarted(this);\n }\n\n requestProgressed(progress: number) {\n this.progress = progress;\n if (this.adapter.visitRequestProgressed) {\n this.adapter.visitRequestProgressed(this);\n }\n }\n\n requestCompletedWithResponse(\n response: string,\n redirectedToLocation?: Location\n ) {\n this.response = response;\n this.redirectedToLocation = redirectedToLocation;\n this.adapter.visitRequestCompleted(this);\n }\n\n requestFailedWithStatusCode(statusCode: number, response?: string) {\n this.response = response;\n this.adapter.visitRequestFailedWithStatusCode(this, statusCode);\n }\n\n requestFinished() {\n this.recordTimingMetric(TimingMetric.requestEnd);\n this.adapter.visitRequestFinished(this);\n }\n */\n\n // Instrumentation\n\n recordTimingMetric(metric: TimingMetric) {\n this.timingMetrics[metric] = new Date().getTime();\n }\n\n getTimingMetrics(): TimingMetrics {\n return { ...this.timingMetrics };\n }\n\n // Private\n\n shouldIssueRequest() {\n return this.action == \"restore\" ? !this.hasCachedSnapshot() : true;\n }\n\n cacheSnapshot() {\n if (!this.snapshotCached) {\n this.controller.cacheSnapshot();\n this.snapshotCached = true;\n }\n }\n\n render(callback: () => Promise<void>) {\n this.cancelRender();\n this.frame = requestAnimationFrame(() => {\n delete this.frame;\n callback.call(this);\n });\n }\n\n cancelRender() {\n if (this.frame) {\n cancelAnimationFrame(this.frame);\n delete this.frame;\n }\n }\n}\n","import { LruCache } from \"./lruCache\";\nimport { Adapter } from \"./adapter\";\nimport { BrowserAdapter } from \"./browser_adapter\";\nimport { Location, Locatable } from \"./location\";\nimport { Action, isAction } from \"./types\";\nimport { closest, defer, dispatch, uuid } from \"./util\";\nimport { Visit } from \"./visit\";\n\nexport type TimingData = {};\nexport type VisitOptions = { action: Action };\n\nexport interface Snapshot {\n bodyEl: Element;\n headEl: HTMLHeadElement;\n pageContext: any;\n}\n\nexport class Controller {\n adapter: Adapter = new BrowserAdapter(this);\n\n cache = new LruCache<Snapshot>(10);\n currentVisit?: Visit;\n enabled = true;\n lastRenderedLocation?: Location;\n location!: Location;\n progressBarDelay = 500;\n restorationIdentifier!: string; // This only exists for compatibility with iOS\n started = false;\n pageContext: any;\n\n start() {\n if (!this.started) {\n // TODO: delete document.body in this file. We are doing this to pre-empt VPS interceptor.\n // https://github.com/brillout/vite-plugin-ssr/issues/918 fixes this.\n document.body.addEventListener(\"click\", this.clickCaptured, true);\n this.location = Location.currentLocation;\n this.restorationIdentifier = uuid();\n this.lastRenderedLocation = this.location;\n this.started = true;\n this.enabled = true;\n }\n }\n\n disable() {\n this.enabled = false;\n }\n\n stop() {\n if (this.started) {\n document.body.removeEventListener(\"click\", this.clickCaptured, true);\n this.started = false;\n }\n }\n\n clearCache() {\n this.cache = new LruCache(10);\n }\n\n visit(location: Locatable, options: Partial<VisitOptions> = {}) {\n location = Location.wrap(location);\n if (this.applicationAllowsVisitingLocation(location)) {\n if (this.locationIsVisitable(location)) {\n const action = options.action || \"advance\";\n this.adapter.visitProposedToLocationWithAction(location, action);\n } else {\n window.location.href = location.toString();\n }\n }\n }\n\n startVisitToLocationWithAction(\n location: Locatable,\n action: Action,\n restorationIdentifier?: string\n ) {\n this.startVisit(Location.wrap(location), action);\n }\n\n setProgressBarDelay(delay: number) {\n this.progressBarDelay = delay;\n }\n\n // History delegate\n\n historyPoppedToLocationWithRestorationIdentifier(\n location: Locatable,\n restorationIdentifier: string\n ) {\n if (this.enabled) {\n this.location = Location.wrap(location);\n this.restorationIdentifier = restorationIdentifier;\n this.startVisit(this.location, \"restore\");\n } else {\n this.adapter.pageInvalidated();\n }\n }\n\n // Snapshot cache\n\n getCachedSnapshotForLocation(location: Locatable) {\n return this.cache.get(Location.wrap(location).toCacheKey());\n }\n\n shouldCacheSnapshot() {\n return (\n document.body.querySelector(\"#proxied-body\") &&\n document.head\n .querySelector(\"meta[name='turbolinks-no-cache']\")\n ?.getAttribute(\"content\") != \"no-cache\"\n );\n }\n\n cacheSnapshot() {\n if (this.shouldCacheSnapshot()) {\n this.notifyApplicationBeforeCachingSnapshot();\n const snapshot = {\n bodyEl: document.body.cloneNode(true),\n headEl: document.head.cloneNode(true),\n pageContext: this.pageContext,\n };\n const location = this.lastRenderedLocation || Location.currentLocation;\n defer(() => this.cache.put(location.toCacheKey(), snapshot));\n }\n }\n\n // View\n viewInvalidated() {\n this.adapter.pageInvalidated();\n }\n\n viewWillRender() {\n this.notifyApplicationBeforeRender();\n }\n\n viewRendered() {\n this.lastRenderedLocation = this.currentVisit!.location;\n this.notifyApplicationAfterRender();\n }\n\n // Event handlers\n\n clickCaptured = () => {\n document.body.removeEventListener(\"click\", this.clickBubbled, false);\n document.body.addEventListener(\"click\", this.clickBubbled, false);\n };\n\n clickBubbled = (event: MouseEvent) => {\n if (this.enabled && this.clickEventIsSignificant(event)) {\n const link = this.getVisitableLinkForTarget(event.target);\n if (link) {\n const location = this.getVisitableLocationForLink(link);\n if (\n location &&\n this.applicationAllowsFollowingLinkToLocation(link, location)\n ) {\n event.preventDefault();\n event.stopPropagation();\n const action = this.getActionForLink(link);\n this.visit(location, { action });\n }\n }\n }\n };\n\n // Application events\n\n applicationAllowsFollowingLinkToLocation(link: Element, location: Location) {\n const event = this.notifyApplicationAfterClickingLinkToLocation(\n link,\n location\n );\n return !event.defaultPrevented;\n }\n\n applicationAllowsVisitingLocation(location: Location) {\n const event = this.notifyApplicationBeforeVisitingLocation(location);\n return !event.defaultPrevented;\n }\n\n notifyApplicationAfterClickingLinkToLocation(\n link: Element,\n location: Location\n ) {\n return dispatch(\"turbolinks:click\", {\n target: link,\n data: { url: location.absoluteURL },\n cancelable: true,\n });\n }\n\n notifyApplicationBeforeVisitingLocation(location: Location) {\n return dispatch(\"turbolinks:before-visit\", {\n data: { url: location.absoluteURL },\n cancelable: true,\n });\n }\n\n notifyApplicationAfterVisitingLocation(location: Location) {\n return dispatch(\"turbolinks:visit\", {\n data: { url: location.absoluteURL },\n });\n }\n\n notifyApplicationBeforeCachingSnapshot() {\n return dispatch(\"turbolinks:before-cache\");\n }\n\n notifyApplicationBeforeRender() {\n return dispatch(\"turbolinks:before-render\");\n }\n\n notifyApplicationAfterRender() {\n return dispatch(\"turbolinks:render\");\n }\n\n notifyApplicationAfterPageLoad(timing: TimingData = {}) {\n return dispatch(\"turbolinks:load\", {\n data: { url: this.location.absoluteURL, timing },\n });\n }\n\n // Private\n\n startVisit(location: Location, action: Action) {\n if (this.currentVisit) {\n this.currentVisit.cancel();\n }\n this.currentVisit = this.createVisit(location, action);\n this.currentVisit.start();\n this.notifyApplicationAfterVisitingLocation(location);\n }\n\n createVisit(location: Location, action: Action): Visit {\n const visit = new Visit(this, location, action);\n visit.referrer = this.location;\n if (action === \"restore\") {\n // dont issue navigate() because VPS already did.\n visit.requestInFlight = true;\n }\n return visit;\n }\n\n visitCompleted(visit: Visit) {\n this.notifyApplicationAfterPageLoad(visit.getTimingMetrics());\n }\n\n clickEventIsSignificant(event: MouseEvent) {\n return !(\n (event.target && (event.target as any).isContentEditable) ||\n event.defaultPrevented ||\n event.which > 1 ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.shiftKey\n );\n }\n\n getVisitableLinkForTarget(target: EventTarget | null) {\n if (target instanceof Element && this.elementIsVisitable(target)) {\n return closest(target, \"a[href]:not([target]):not([download])\");\n }\n }\n\n getVisitableLocationForLink(link: Element) {\n const location = new Location(link.getAttribute(\"href\") || \"\");\n if (this.locationIsVisitable(location)) {\n return location;\n }\n }\n\n getActionForLink(link: Element): Action {\n const action = link.getAttribute(\"data-turbolinks-action\");\n return isAction(action) ? action : \"advance\";\n }\n\n elementIsVisitable(element: Element) {\n const container = closest(element, \"[data-turbolinks]\");\n if (container) {\n return container.getAttribute(\"data-turbolinks\") != \"false\";\n } else {\n return true;\n }\n }\n\n locationIsVisitable(location: Location) {\n return location.isPrefixedBy(new Location(\"/\")) && location.isHTML();\n }\n}\n","import { mergeHead } from \"./mergeHead\";\nimport { Controller, VisitOptions } from \"./controller\";\nimport { Locatable } from \"./location\";\nimport { activateNewBodyScriptElements, focusFirstAutofocusableElement } from \"./util\";\n\nconst controller = new Controller();\n\nexport const Turbolinks = {\n get supported() {\n return true;\n },\n\n controller,\n\n visit(location: Locatable, options?: Partial<VisitOptions>) {\n controller.visit(location, options);\n },\n\n clearCache() {\n controller.clearCache();\n },\n\n setProgressBarDelay(delay: number) {\n controller.setProgressBarDelay(delay);\n },\n\n start() {\n // because this runs after ios hooks, we have to recover. See onRenderHtml\n if (\n window.Turbolinks !== Turbolinks &&\n window.Turbolinks.controller.adapter\n ) {\n (window.Turbolinks.controller.adapter as any).controller = controller;\n controller.adapter = window.Turbolinks.controller.adapter;\n }\n // Tells vite-plugin-ssr not to do link interception\n (window as any)._disableAutomaticLinkInterception = true\n window.Turbolinks = Turbolinks;\n controller.start();\n },\n\n _vpsCachePageContext(pageContext: any) {\n controller.pageContext = pageContext;\n },\n\n _vpsOnRenderClient(\n newHead: HTMLHeadElement,\n trackScripts: boolean,\n executeBodyScripts: boolean,\n renderBody: () => void\n ) {\n if (controller.currentVisit) {\n const { currentVisit } = controller;\n // TODO: move to controller?\n currentVisit.renderFn = async () => {\n const scriptsLoaded = mergeHead(newHead, trackScripts, () =>\n controller.viewInvalidated()\n );\n\n controller.viewWillRender();\n renderBody();\n await scriptsLoaded;\n \n if (executeBodyScripts) {\n activateNewBodyScriptElements(\n Array.from(document.body.querySelectorAll(\"script\"))\n );\n }\n focusFirstAutofocusableElement();\n\n controller.viewRendered();\n controller.adapter.visitRendered(currentVisit);\n };\n\n controller.adapter.visitRequestCompleted(controller.currentVisit);\n controller.adapter.visitRequestFinished(controller.currentVisit);\n } else {\n console.error(\n \"controller.curr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,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["closest","dispatch","controller","controller"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { PageContextBuiltIn } from 'vite-plugin-ssr/types';
|
|
2
|
-
import { A as AugmentMe, P as PageContextNoProxy } from './internal-
|
|
3
|
-
export { N as BifrostConfig, a as BifrostProxyConfig, D as DocumentProps, b as LayoutComponent, L as LayoutMap, c as PageContext } from './internal-
|
|
2
|
+
import { A as AugmentMe, P as PageContextNoProxy } from './internal-45a068f0.js';
|
|
3
|
+
export { N as BifrostConfig, a as BifrostProxyConfig, D as DocumentProps, b as LayoutComponent, L as LayoutMap, c as PageContext } from './internal-45a068f0.js';
|
|
4
4
|
export { usePageContext } from './renderer/usePageContext.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
import './proxy/pages/_config.js';
|
|
7
7
|
import './renderer/_config.js';
|
|
8
|
+
import './controller-16e58bbd.js';
|
|
8
9
|
|
|
9
10
|
type OptionalPromise<T> = Promise<T> | T;
|
|
10
11
|
type OnBeforeRender = (pageContext: PageContextBuiltIn & AugmentMe.PageContextInit) => OptionalPromise<{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Config, PageContextBuiltIn, PageContextBuiltInClientWithClientRouting } from 'vite-plugin-ssr/types';
|
|
3
3
|
import _default from './proxy/pages/_config.js';
|
|
4
4
|
import _default$1 from './renderer/_config.js';
|
|
5
|
+
import { S as Snapshot } from './controller-16e58bbd.js';
|
|
5
6
|
|
|
6
7
|
declare namespace AugmentMe {
|
|
7
8
|
interface PageContextInit {
|
|
@@ -9,10 +10,10 @@ declare namespace AugmentMe {
|
|
|
9
10
|
interface LayoutProps {
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
type ConfigConstructor<LibConfig extends
|
|
13
|
+
type ConfigConstructor<LibConfig extends Config, T extends {
|
|
13
14
|
[K in keyof LibConfig["meta"]]: any;
|
|
14
15
|
}> = Omit<Config, "extends"> & {
|
|
15
|
-
extends?:
|
|
16
|
+
extends?: Config;
|
|
16
17
|
} & Partial<T>;
|
|
17
18
|
interface DocumentProps {
|
|
18
19
|
title?: string;
|
|
@@ -46,14 +47,21 @@ type PageContextProxyClientNav = {
|
|
|
46
47
|
redirectTo?: string;
|
|
47
48
|
proxySendClient?: string;
|
|
48
49
|
};
|
|
50
|
+
type FromProxy = {
|
|
51
|
+
layout: string;
|
|
52
|
+
layoutProps: AugmentMe.LayoutProps;
|
|
53
|
+
html: string;
|
|
54
|
+
};
|
|
55
|
+
type PageContextProxyInit = PageContextBuiltIn<Page> & {
|
|
56
|
+
fromProxy: FromProxy;
|
|
57
|
+
};
|
|
49
58
|
type PageContextProxyServer = PageContextBuiltIn<Page> & PageContextProxyCommon & {
|
|
50
59
|
proxy: string;
|
|
51
60
|
};
|
|
52
61
|
type PageContextProxyClient = PageContextBuiltInClientWithClientRouting<Page> & PageContextProxyCommon & (PageContextProxyClientHydration | PageContextProxyClientNav);
|
|
53
62
|
type PageContextProxy = PageContextProxyServer | PageContextProxyClient;
|
|
54
63
|
type PageContextProxyRestorationVisit = PageContextBuiltInClientWithClientRouting<Page> & {
|
|
55
|
-
|
|
56
|
-
headEl: HTMLHeadElement;
|
|
64
|
+
snapshot: Snapshot;
|
|
57
65
|
} & PageContextProxyCommon;
|
|
58
66
|
type NoProxyConfig = ConfigConstructor<typeof _default$1, {
|
|
59
67
|
Layout: LayoutComponent;
|
|
@@ -76,4 +84,4 @@ type PageContextNoProxyClient = PageContextBuiltInClientWithClientRouting<Page>
|
|
|
76
84
|
type PageContextNoProxy = PageContextNoProxyServer | PageContextNoProxyClient;
|
|
77
85
|
type PageContext = PageContextNoProxy | PageContextProxy | PageContextProxyRestorationVisit;
|
|
78
86
|
|
|
79
|
-
export { AugmentMe as A, DocumentProps as D, LayoutMap as L, NoProxyConfig as N, PageContextNoProxy as P, ProxyConfig as a, LayoutComponent as b, PageContext as c, PageContextNoProxyClient as d, PageContextNoProxyServer as e,
|
|
87
|
+
export { AugmentMe as A, DocumentProps as D, LayoutMap as L, NoProxyConfig as N, PageContextNoProxy as P, ProxyConfig as a, LayoutComponent as b, PageContext as c, PageContextNoProxyClient as d, PageContextNoProxyServer as e, PageContextProxyInit as f, PageContextProxyClient as g, PageContextProxyServer as h, PageContextProxyRestorationVisit as i };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../proxy/pages/+config.ts"],"sourcesContent":["import { type
|
|
1
|
+
{"version":3,"sources":["../../../proxy/pages/+config.ts"],"sourcesContent":["import { type Config } from \"vite-plugin-ssr/types\";\n\nexport default {\n route: \"/*\",\n onBeforeRender: \"import:@alignable/bifrost/proxy/pages/onBeforeRender\",\n onRenderClient: \"import:@alignable/bifrost/proxy/pages/onRenderClient\",\n onRenderHtml: \"import:@alignable/bifrost/proxy/pages/onRenderHtml\",\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n passToClient: [\"proxySendClient\", \"layout\", \"layoutProps\", \"redirectTo\"],\n clientRouting: true,\n hydrationCanBeAborted: true,\n meta: {\n layoutMap: { env: \"server-and-client\" },\n },\n} satisfies Config;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,cAAc,CAAC,mBAAmB,UAAU,eAAe,YAAY;AAAA,EACvE,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,IACJ,WAAW,EAAE,KAAK,oBAAoB;AAAA,EACxC;AACF;","names":[]}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import { f as
|
|
1
|
+
import { f as PageContextProxyInit, A as AugmentMe } from '../../internal-45a068f0.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vite-plugin-ssr/types';
|
|
4
4
|
import './_config.js';
|
|
5
5
|
import '../../renderer/_config.js';
|
|
6
|
+
import '../../controller-16e58bbd.js';
|
|
6
7
|
|
|
7
|
-
declare function onBeforeRender(pageContext:
|
|
8
|
-
pageContext: {
|
|
8
|
+
declare function onBeforeRender(pageContext: PageContextProxyInit): Promise<{
|
|
9
|
+
pageContext: {
|
|
10
|
+
layout: string;
|
|
11
|
+
layoutProps: AugmentMe.LayoutProps;
|
|
12
|
+
proxySendClient: string;
|
|
13
|
+
proxy?: undefined;
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
pageContext: {
|
|
17
|
+
layout: string;
|
|
18
|
+
layoutProps: AugmentMe.LayoutProps;
|
|
19
|
+
proxy: string;
|
|
20
|
+
proxySendClient?: undefined;
|
|
21
|
+
};
|
|
9
22
|
} | undefined>;
|
|
10
23
|
|
|
11
24
|
export { onBeforeRender as default };
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
// proxy/pages/onBeforeRender.tsx
|
|
2
2
|
async function onBeforeRender(pageContext) {
|
|
3
|
-
if (pageContext.
|
|
4
|
-
|
|
3
|
+
if (pageContext.fromProxy) {
|
|
4
|
+
const { fromProxy } = pageContext;
|
|
5
|
+
if (pageContext.isClientSideNavigation) {
|
|
6
|
+
return {
|
|
7
|
+
pageContext: {
|
|
8
|
+
layout: fromProxy.layout,
|
|
9
|
+
layoutProps: fromProxy.layoutProps,
|
|
10
|
+
// proxySendClient is serialized and sent to client on subsequent navigation.
|
|
11
|
+
// Important that we dont send it on ssr
|
|
12
|
+
proxySendClient: fromProxy.html
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
} else {
|
|
16
|
+
return {
|
|
17
|
+
pageContext: {
|
|
18
|
+
layout: fromProxy.layout,
|
|
19
|
+
layoutProps: fromProxy.layoutProps,
|
|
20
|
+
// proxy is ONLY included server-side to avoid doubling page size
|
|
21
|
+
proxy: fromProxy.html
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
5
25
|
}
|
|
6
26
|
}
|
|
7
27
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../proxy/pages/onBeforeRender.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../proxy/pages/onBeforeRender.tsx"],"sourcesContent":["import { PageContextProxyInit } from \"../../types/internal\";\n\nexport default async function onBeforeRender(\n pageContext: PageContextProxyInit\n) {\n if (pageContext.fromProxy) {\n const { fromProxy } = pageContext;\n if (pageContext.isClientSideNavigation) {\n return {\n pageContext: {\n layout: fromProxy.layout,\n layoutProps: fromProxy.layoutProps,\n // proxySendClient is serialized and sent to client on subsequent navigation.\n // Important that we dont send it on ssr\n proxySendClient: fromProxy.html,\n },\n };\n } else {\n return {\n pageContext: {\n layout: fromProxy.layout,\n layoutProps: fromProxy.layoutProps,\n // proxy is ONLY included server-side to avoid doubling page size\n proxy: fromProxy.html,\n },\n };\n }\n }\n}\n"],"mappings":";AAEA,eAAO,eACL,aACA;AACA,MAAI,YAAY,WAAW;AACzB,UAAM,EAAE,UAAU,IAAI;AACtB,QAAI,YAAY,wBAAwB;AACtC,aAAO;AAAA,QACL,aAAa;AAAA,UACX,QAAQ,UAAU;AAAA,UAClB,aAAa,UAAU;AAAA;AAAA;AAAA,UAGvB,iBAAiB,UAAU;AAAA,QAC7B;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO;AAAA,QACL,aAAa;AAAA,UACX,QAAQ,UAAU;AAAA,UAClB,aAAa,UAAU;AAAA;AAAA,UAEvB,OAAO,UAAU;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { g as PageContextProxyClient } from '../../internal-
|
|
1
|
+
import { g as PageContextProxyClient } from '../../internal-45a068f0.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vite-plugin-ssr/types';
|
|
4
4
|
import './_config.js';
|
|
5
5
|
import '../../renderer/_config.js';
|
|
6
|
+
import '../../controller-16e58bbd.js';
|
|
6
7
|
|
|
7
8
|
declare function onRenderClient(pageContext: PageContextProxyClient): Promise<void>;
|
|
8
9
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as vite_plugin_ssr_dist_types_node_runtime_html_renderHtml_js from 'vite-plugin-ssr/dist/types/node/runtime/html/renderHtml.js';
|
|
2
|
-
import {
|
|
2
|
+
import { h as PageContextProxyServer } from '../../internal-45a068f0.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'vite-plugin-ssr/types';
|
|
5
5
|
import './_config.js';
|
|
6
6
|
import '../../renderer/_config.js';
|
|
7
|
+
import '../../controller-16e58bbd.js';
|
|
7
8
|
|
|
8
9
|
declare function onRenderHtml(pageContext: PageContextProxyServer): Promise<{
|
|
9
10
|
documentHtml: vite_plugin_ssr_dist_types_node_runtime_html_renderHtml_js.TemplateWrapped;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
route: string;
|
|
3
3
|
Page: string;
|
|
4
|
+
onBeforeRender: "import:@alignable/bifrost/proxy/pages/restorationVisit/onBeforeRender";
|
|
4
5
|
onRenderClient: "import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient";
|
|
5
|
-
passToClient:
|
|
6
|
+
passToClient: never[];
|
|
7
|
+
clientRouting: true;
|
|
8
|
+
hydrationCanBeAborted: true;
|
|
6
9
|
meta: {
|
|
7
10
|
onBeforeRender: {
|
|
8
|
-
env: "
|
|
11
|
+
env: "client-only";
|
|
9
12
|
};
|
|
10
13
|
};
|
|
11
14
|
};
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
var config_default = {
|
|
3
3
|
route: "import:@alignable/bifrost/proxy/pages/restorationVisit/route",
|
|
4
4
|
Page: "import:@alignable/bifrost/proxy/pages/Page",
|
|
5
|
+
onBeforeRender: "import:@alignable/bifrost/proxy/pages/restorationVisit/onBeforeRender",
|
|
5
6
|
onRenderClient: "import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient",
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
passToClient: [],
|
|
8
|
+
clientRouting: true,
|
|
9
|
+
hydrationCanBeAborted: true,
|
|
8
10
|
meta: {
|
|
9
11
|
onBeforeRender: {
|
|
10
|
-
// We tell vite-plugin-ssr to load and execute onBeforeRender()
|
|
11
|
-
// not only on the server-side but also on the client-side.
|
|
12
|
+
// We tell vite-plugin-ssr to load and execute onBeforeRender() on the client-side.
|
|
12
13
|
// Moving onBeforeRender to client tells VPS it does not need to make network request on navigation
|
|
13
|
-
env: "
|
|
14
|
+
env: "client-only"
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/+config.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/+config.ts"],"sourcesContent":["import { Config } from \"vite-plugin-ssr/types\";\n\nexport default {\n route: \"import:@alignable/bifrost/proxy/pages/restorationVisit/route\",\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n onBeforeRender:\n \"import:@alignable/bifrost/proxy/pages/restorationVisit/onBeforeRender\",\n onRenderClient:\n \"import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient\",\n passToClient: [],\n clientRouting: true,\n hydrationCanBeAborted: true,\n meta: {\n onBeforeRender: {\n // We tell vite-plugin-ssr to load and execute onBeforeRender() on the client-side.\n // Moving onBeforeRender to client tells VPS it does not need to make network request on navigation\n env: \"client-only\",\n },\n },\n} satisfies Config;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AAAA,EACN,gBACE;AAAA,EACF,gBACE;AAAA,EACF,cAAc,CAAC;AAAA,EACf,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,IACJ,gBAAgB;AAAA;AAAA;AAAA,MAGd,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/onBeforeRender.tsx"],"sourcesContent":["import { PageContextProxyServer } from \"../../../types/internal.js\";\n\n// In restoration visit, this happens on client.\n// Do nothing. onBeforeRoute handles it all for us.\nexport default async function onBeforeRender() {}\n"],"mappings":";AAIA,eAAO,iBAAwC;AAAC;","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as PageContextProxyRestorationVisit } from '../../../internal-45a068f0.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vite-plugin-ssr/types';
|
|
4
4
|
import '../_config.js';
|
|
5
5
|
import '../../../renderer/_config.js';
|
|
6
|
+
import '../../../controller-16e58bbd.js';
|
|
6
7
|
|
|
7
8
|
declare function onRenderClient(pageContext: PageContextProxyRestorationVisit): Promise<void>;
|
|
8
9
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
Turbolinks,
|
|
6
6
|
copyElementAttributes,
|
|
7
7
|
renderReact
|
|
8
|
-
} from "../../../chunk-
|
|
8
|
+
} from "../../../chunk-UQXLIJWA.js";
|
|
9
9
|
import {
|
|
10
10
|
PageShell
|
|
11
11
|
} from "../../../chunk-4DL7N7Y5.js";
|
|
@@ -18,7 +18,8 @@ async function onRenderClient(pageContext) {
|
|
|
18
18
|
if (pageContext.isHydration) {
|
|
19
19
|
throw new Error("restoration visit should never happen on initial render");
|
|
20
20
|
}
|
|
21
|
-
const { layoutProps, layout
|
|
21
|
+
const { layoutProps, layout } = pageContext.snapshot.pageContext;
|
|
22
|
+
const { bodyEl, headEl } = pageContext.snapshot;
|
|
22
23
|
const { layoutMap } = pageContext.config;
|
|
23
24
|
if (!layoutMap) {
|
|
24
25
|
throw new Error("layoutMap needs to be defined in config");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/onRenderClient.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageContextProxyRestorationVisit } from \"../../../types/internal.js\";\nimport { PageShell } from \"../../../lib/PageShell.js\";\nimport { renderReact } from \"../../../lib/renderReact.js\";\nimport { Turbolinks } from \"../../../lib/turbolinks/index.js\";\nimport { getElementAttributes } from \"../../../lib/getElementAttributes.js\";\nimport { copyElementAttributes } from \"../../../lib/turbolinks/util.js\";\n\nexport default async function onRenderClient(\n pageContext: PageContextProxyRestorationVisit\n) {\n if (pageContext.isHydration) {\n throw new Error(\"restoration visit should never happen on initial render\");\n }\n\n const { layoutProps, layout
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/onRenderClient.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageContextProxyRestorationVisit } from \"../../../types/internal.js\";\nimport { PageShell } from \"../../../lib/PageShell.js\";\nimport { renderReact } from \"../../../lib/renderReact.js\";\nimport { Turbolinks } from \"../../../lib/turbolinks/index.js\";\nimport { getElementAttributes } from \"../../../lib/getElementAttributes.js\";\nimport { copyElementAttributes } from \"../../../lib/turbolinks/util.js\";\n\nexport default async function onRenderClient(\n pageContext: PageContextProxyRestorationVisit\n) {\n if (pageContext.isHydration) {\n throw new Error(\"restoration visit should never happen on initial render\");\n }\n\n const { layoutProps, layout } = pageContext.snapshot.pageContext;\n const { bodyEl, headEl } = pageContext.snapshot;\n const { layoutMap } = pageContext.config;\n if (!layoutMap) {\n throw new Error(\"layoutMap needs to be defined in config\");\n }\n const Layout = layoutMap[layout];\n\n function render(body: string) {\n renderReact(\n <PageShell key={pageContext.urlOriginal} pageContext={pageContext}>\n <Layout {...layoutProps}>\n <div id=\"proxied-body\" dangerouslySetInnerHTML={{ __html: body }} />\n </Layout>\n </PageShell>,\n pageContext.isHydration\n );\n }\n const proxyBodyEl = bodyEl.querySelector(\"#proxied-body\");\n if (!proxyBodyEl) {\n throw new Error(\"proxied body not found in cached snapshot\");\n }\n\n Turbolinks._vpsOnRenderClient(headEl, true, true, () => {\n // merge body attributes\n document.body\n .getAttributeNames()\n .forEach((n) => document.body.removeAttribute(n));\n copyElementAttributes(document.body, bodyEl);\n // render body with react\n render(proxyBodyEl.innerHTML);\n });\n // cache page context will save it and return it to us during restoration visits\n Turbolinks._vpsCachePageContext({\n layoutProps,\n layout,\n bodyAttrs: getElementAttributes(bodyEl),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAQlB,eAAO,eACL,aACA;AACA,MAAI,YAAY,aAAa;AAC3B,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,EAAE,aAAa,OAAO,IAAI,YAAY,SAAS;AACrD,QAAM,EAAE,QAAQ,OAAO,IAAI,YAAY;AACvC,QAAM,EAAE,UAAU,IAAI,YAAY;AAClC,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AACA,QAAM,SAAS,UAAU,MAAM;AAE/B,WAAS,OAAO,MAAc;AAC5B;AAAA,MACE,oCAAC,aAAU,KAAK,YAAY,aAAa,eACvC,oCAAC,UAAQ,GAAG,eACV,oCAAC,SAAI,IAAG,gBAAe,yBAAyB,EAAE,QAAQ,KAAK,GAAG,CACpE,CACF;AAAA,MACA,YAAY;AAAA,IACd;AAAA,EACF;AACA,QAAM,cAAc,OAAO,cAAc,eAAe;AACxD,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,2CAA2C;AAAA,EAC7D;AAEA,aAAW,mBAAmB,QAAQ,MAAM,MAAM,MAAM;AAEtD,aAAS,KACN,kBAAkB,EAClB,QAAQ,CAAC,MAAM,SAAS,KAAK,gBAAgB,CAAC,CAAC;AAClD,0BAAsB,SAAS,MAAM,MAAM;AAE3C,WAAO,YAAY,SAAS;AAAA,EAC9B,CAAC;AAED,aAAW,qBAAqB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA,WAAW,qBAAqB,MAAM;AAAA,EACxC,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../renderer/+config.ts"],"sourcesContent":["import { type
|
|
1
|
+
{"version":3,"sources":["../../renderer/+config.ts"],"sourcesContent":["import { type Config } from \"vite-plugin-ssr/types\";\n\nconst passToClient = [\n \"layoutProps\",\n \"pageProps\",\n \"redirectTo\",\n \"documentProps\",\n \"scripts\",\n];\nexport default {\n passToClient,\n onRenderClient: \"import:@alignable/bifrost/renderer/onRenderClient\",\n onRenderHtml: \"import:@alignable/bifrost/renderer/onRenderHtml\",\n onBeforeRoute: \"import:@alignable/bifrost/renderer/onBeforeRoute\",\n clientRouting: true,\n hydrationCanBeAborted: true,\n meta: {\n Layout: { env: \"server-and-client\" },\n layoutProps: { env: \"server-and-client\" },\n documentProps: { env: \"server-and-client\" },\n scripts: { env: \"server-and-client\" },\n favicon: { env: \"server-only\" },\n },\n} satisfies Config;\n"],"mappings":";AAEA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAO,iBAAQ;AAAA,EACb;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,IACJ,QAAQ,EAAE,KAAK,oBAAoB;AAAA,IACnC,aAAa,EAAE,KAAK,oBAAoB;AAAA,IACxC,eAAe,EAAE,KAAK,oBAAoB;AAAA,IAC1C,SAAS,EAAE,KAAK,oBAAoB;AAAA,IACpC,SAAS,EAAE,KAAK,cAAc;AAAA,EAChC;AACF;","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { P as PageContextNoProxy } from '../internal-
|
|
1
|
+
import { P as PageContextNoProxy } from '../internal-45a068f0.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vite-plugin-ssr/types';
|
|
4
4
|
import '../proxy/pages/_config.js';
|
|
5
5
|
import './_config.js';
|
|
6
|
+
import '../controller-16e58bbd.js';
|
|
6
7
|
|
|
7
8
|
type ConfigOrContext = PageContextNoProxy | PageContextNoProxy["config"];
|
|
8
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../renderer/onBeforeRoute.ts"],"sourcesContent":["// do NOT import turbolinks in this file. It is used on server side.\n\nexport default function onBeforeRoute(_pageContext: any) {\n if (typeof window === \"undefined\") return undefined;\n const Turbolinks = window.Turbolinks;\n\n const currentVisit = Turbolinks.controller.currentVisit;\n if (!currentVisit || currentVisit.state === \"completed\") {\n // old/nonexistent currentVisit means VPS is doing history navigation. Ideally we might turn off VPS' onpopstate listener.\n const snapshot = Turbolinks.controller.getCachedSnapshotForLocation(\n window.location.href\n );\n Turbolinks.controller.historyPoppedToLocationWithRestorationIdentifier(\n window.location.href,\n \"\"\n );\n\n if (!!snapshot) {\n return {\n pageContext: {\n
|
|
1
|
+
{"version":3,"sources":["../../renderer/onBeforeRoute.ts"],"sourcesContent":["// do NOT import turbolinks in this file. It is used on server side.\n\nexport default function onBeforeRoute(_pageContext: any) {\n if (typeof window === \"undefined\") return undefined;\n const Turbolinks = window.Turbolinks;\n\n const currentVisit = Turbolinks.controller.currentVisit;\n if (!currentVisit || currentVisit.state === \"completed\") {\n // old/nonexistent currentVisit means VPS is doing history navigation. Ideally we might turn off VPS' onpopstate listener.\n const snapshot = Turbolinks.controller.getCachedSnapshotForLocation(\n window.location.href\n );\n Turbolinks.controller.historyPoppedToLocationWithRestorationIdentifier(\n window.location.href,\n \"\"\n );\n\n if (!!snapshot) {\n return {\n pageContext: {\n snapshot,\n _pageId: \"/proxy/pages/restorationVisit\",\n },\n };\n }\n }\n return undefined;\n}\n"],"mappings":";AAEe,SAAR,cAA+B,cAAmB;AACvD,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,QAAM,aAAa,OAAO;AAE1B,QAAM,eAAe,WAAW,WAAW;AAC3C,MAAI,CAAC,gBAAgB,aAAa,UAAU,aAAa;AAEvD,UAAM,WAAW,WAAW,WAAW;AAAA,MACrC,OAAO,SAAS;AAAA,IAClB;AACA,eAAW,WAAW;AAAA,MACpB,OAAO,SAAS;AAAA,MAChB;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,UAAU;AACd,aAAO;AAAA,QACL,aAAa;AAAA,UACX;AAAA,UACA,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { d as PageContextNoProxyClient } from '../internal-
|
|
1
|
+
import { d as PageContextNoProxyClient } from '../internal-45a068f0.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vite-plugin-ssr/types';
|
|
4
4
|
import '../proxy/pages/_config.js';
|
|
5
5
|
import './_config.js';
|
|
6
|
+
import '../controller-16e58bbd.js';
|
|
6
7
|
|
|
7
8
|
declare function onRenderClient(pageContext: PageContextNoProxyClient): Promise<void>;
|
|
8
9
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as vite_plugin_ssr_dist_types_node_runtime_html_renderHtml_js from 'vite-plugin-ssr/dist/types/node/runtime/html/renderHtml.js';
|
|
2
|
-
import { e as PageContextNoProxyServer } from '../internal-
|
|
2
|
+
import { e as PageContextNoProxyServer } from '../internal-45a068f0.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'vite-plugin-ssr/types';
|
|
5
5
|
import '../proxy/pages/_config.js';
|
|
6
6
|
import './_config.js';
|
|
7
|
+
import '../controller-16e58bbd.js';
|
|
7
8
|
|
|
8
9
|
declare function onRenderHtml(pageContext: PageContextNoProxyServer): Promise<{
|
|
9
10
|
pageContext: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { c as PageContext } from '../internal-
|
|
2
|
+
import { c as PageContext } from '../internal-45a068f0.js';
|
|
3
3
|
import 'vite-plugin-ssr/types';
|
|
4
4
|
import '../proxy/pages/_config.js';
|
|
5
5
|
import './_config.js';
|
|
6
|
+
import '../controller-16e58bbd.js';
|
|
6
7
|
|
|
7
8
|
declare function PageContextProvider({ pageContext, children }: {
|
|
8
9
|
pageContext: PageContext;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { D as DocumentProps } from '../../internal-
|
|
2
|
+
import { D as DocumentProps } from '../../internal-45a068f0.js';
|
|
3
3
|
import 'vite-plugin-ssr/types';
|
|
4
4
|
import '../../proxy/pages/_config.js';
|
|
5
5
|
import '../_config.js';
|
|
6
|
+
import '../../controller-16e58bbd.js';
|
|
6
7
|
|
|
7
8
|
declare function documentPropsToReact({ title, description, viewport, metaTags, }: DocumentProps): React.ReactElement;
|
|
8
9
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alignable/bifrost",
|
|
3
3
|
"repository": "https://github.com/Alignable/bifrost.git",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.23",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
"types": "./dist/proxy/pages/restorationVisit/onRenderClient.d.ts",
|
|
54
54
|
"default": "./dist/proxy/pages/restorationVisit/onRenderClient.js"
|
|
55
55
|
},
|
|
56
|
+
"./proxy/pages/restorationVisit/onBeforeRender": {
|
|
57
|
+
"types": "./dist/proxy/pages/restorationVisit/onBeforeRender.d.ts",
|
|
58
|
+
"default": "./dist/proxy/pages/restorationVisit/onBeforeRender.js"
|
|
59
|
+
},
|
|
56
60
|
".": {
|
|
57
61
|
"types": "./dist/index.d.ts",
|
|
58
62
|
"default": "./dist/index.js"
|
|
@@ -83,14 +87,14 @@
|
|
|
83
87
|
"react-dom": "^18.x.x",
|
|
84
88
|
"tough-cookie": "^4.1.2",
|
|
85
89
|
"uuid": "^9.0.0",
|
|
86
|
-
"vite-plugin-ssr": "0.4.
|
|
90
|
+
"vite-plugin-ssr": "0.4.135"
|
|
87
91
|
},
|
|
88
92
|
"peerDependencies": {
|
|
89
93
|
"jsdom": "^22.1.0",
|
|
90
94
|
"react": "^18.x.x",
|
|
91
95
|
"react-dom": "^18.x.x",
|
|
92
96
|
"typescript": ">=4.7",
|
|
93
|
-
"vite-plugin-ssr": "0.4.
|
|
97
|
+
"vite-plugin-ssr": "0.4.135"
|
|
94
98
|
},
|
|
95
99
|
"devDependencies": {
|
|
96
100
|
"@types/node": "^18.11.9",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/renderReact.ts","../lib/turbolinks/util.ts","../lib/turbolinks/mergeHead.ts","../lib/turbolinks/lruCache.ts","../lib/turbolinks/progress_bar.ts","../lib/turbolinks/browser_adapter.ts","../lib/turbolinks/location.ts","../lib/turbolinks/types.ts","../lib/turbolinks/visit.ts","../lib/turbolinks/controller.ts","../lib/turbolinks/index.ts"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { Root, createRoot, hydrateRoot } from \"react-dom/client\";\n\nlet root: Root;\n\nexport function renderReact(page: ReactNode, isHydration: boolean) {\n const container = document.getElementById(\"page-view\")!;\n if (isHydration) {\n root = hydrateRoot(container, page);\n } else {\n if (!root) {\n root = createRoot(container);\n }\n root.render(page);\n }\n}\n","export function array<T>(values: ArrayLike<T>): T[] {\n return Array.prototype.slice.call(values);\n}\n\nexport const closest = (() => {\n const html = document.documentElement;\n\n type MatchesSelector = (this: Element, selector: string) => boolean;\n const match: MatchesSelector =\n html.matches ||\n (html as any).webkitMatchesSelector ||\n (html as any).msMatchesSelector ||\n (html as any).mozMatchesSelector;\n\n type Closest = (this: Element, selector: string) => Element | null;\n const closest: Closest =\n html.closest ||\n function (selector: string) {\n let element: Element | null = this;\n while (element) {\n if (match.call(element, selector)) {\n return element;\n } else {\n element = element.parentElement;\n }\n }\n };\n\n return function (element: Element, selector: string) {\n return closest.call(element, selector);\n };\n})();\n\nexport function defer(callback: () => any) {\n setTimeout(callback, 1);\n}\n\nexport type DispatchOptions = {\n target: EventTarget;\n cancelable: boolean;\n data: any;\n};\n\nexport function dispatch(\n eventName: string,\n { target, cancelable, data }: Partial<DispatchOptions> = {}\n) {\n const event = document.createEvent(\"Events\") as Event & { data: any };\n event.initEvent(eventName, true, cancelable == true);\n event.data = data || {};\n\n // Fix setting `defaultPrevented` when `preventDefault()` is called\n // http://stackoverflow.com/questions/23349191/event-preventdefault-is-not-working-in-ie-11-for-custom-events\n if (event.cancelable && !preventDefaultSupported) {\n const { preventDefault } = event;\n event.preventDefault = function () {\n if (!this.defaultPrevented) {\n Object.defineProperty(this, \"defaultPrevented\", { get: () => true });\n }\n preventDefault.call(this);\n };\n }\n\n (target || document).dispatchEvent(event);\n return event;\n}\n\nconst preventDefaultSupported = (() => {\n const event = document.createEvent(\"Events\");\n event.initEvent(\"test\", true, true);\n event.preventDefault();\n return event.defaultPrevented;\n})();\n\nexport function unindent(\n strings: TemplateStringsArray,\n ...values: any[]\n): string {\n const lines = trimLeft(interpolate(strings, values)).split(\"\\n\");\n const match = lines[0].match(/^\\s+/);\n const indent = match ? match[0].length : 0;\n return lines.map((line) => line.slice(indent)).join(\"\\n\");\n}\n\nfunction trimLeft(string: string) {\n return string.replace(/^\\n/, \"\");\n}\n\nfunction interpolate(strings: TemplateStringsArray, values: any[]) {\n return strings.reduce((result, string, i) => {\n const value = values[i] == undefined ? \"\" : values[i];\n return result + string + value;\n }, \"\");\n}\n\nexport function uuid() {\n return Array.apply(null, { length: 36 } as any)\n .map((_, i) => {\n if (i == 8 || i == 13 || i == 18 || i == 23) {\n return \"-\";\n } else if (i == 14) {\n return \"4\";\n } else if (i == 19) {\n return (Math.floor(Math.random() * 4) + 8).toString(16);\n } else {\n return Math.floor(Math.random() * 15).toString(16);\n }\n })\n .join(\"\");\n}\n\nexport function createScriptElement(element: Element, cb?: () => void) {\n if (element.getAttribute(\"data-turbolinks-eval\") == \"false\") {\n return element;\n } else {\n const createdScriptElement = document.createElement(\"script\");\n createdScriptElement.textContent = element.textContent;\n // async false makes scripts run in-order. it wont block js execution (thankfully)\n // https://github.com/turbolinks/turbolinks/issues/282#issuecomment-355731712\n createdScriptElement.async = false;\n copyElementAttributes(createdScriptElement, element);\n if (cb) {\n createdScriptElement.addEventListener(\"load\", cb);\n }\n return createdScriptElement;\n }\n}\n\nexport function copyElementAttributes(\n destinationElement: Element,\n sourceElement: Element\n) {\n for (const { name, value } of array(sourceElement.attributes)) {\n destinationElement.setAttribute(name, value);\n }\n}\n\nfunction replaceElementWithElement(fromElement: Element, toElement: Element) {\n const parentElement = fromElement.parentElement;\n if (parentElement) {\n return parentElement.replaceChild(toElement, fromElement);\n }\n}\nexport function activateNewBodyScriptElements(\n newScriptElements: HTMLScriptElement[]\n) {\n for (const inertScriptElement of newScriptElements) {\n const activatedScriptElement = createScriptElement(inertScriptElement);\n replaceElementWithElement(inertScriptElement, activatedScriptElement);\n }\n}\n\nexport function focusFirstAutofocusableElement() {\n const element = document.body.querySelector(\"[autofocus]\");\n if (element && \"focus\" in element && typeof element.focus === \"function\") {\n element.focus();\n }\n}\n","import { createScriptElement } from \"./util\";\n\ninterface ElementDetails {\n tracked: boolean;\n}\nconst allHeadScriptsEverRun: { [outerHTML: string]: ElementDetails } = {};\nlet firstLoad = true;\nlet lastTrackedScriptSignature: string;\n\nexport async function mergeHead(\n head: HTMLHeadElement,\n trackScripts: boolean,\n reload: () => void\n) {\n const newHead = categorizeHead(head);\n const oldHead = categorizeHead(document.head);\n\n if (\n head\n .querySelector('meta[name=\"turbolinks-visit-control\"]')\n ?.getAttribute(\"content\") === \"reload\"\n ) {\n reload();\n }\n if (trackScripts) {\n lastTrackedScriptSignature =\n lastTrackedScriptSignature ||\n trackedElementSignature([...oldHead.scripts, ...oldHead.stylesheets]);\n if (\n lastTrackedScriptSignature !==\n trackedElementSignature([...newHead.scripts, ...newHead.stylesheets])\n ) {\n reload();\n }\n }\n\n if (firstLoad) {\n // TODO: messy code\n for (const element of oldHead.scripts) {\n allHeadScriptsEverRun[element.outerHTML] = {\n tracked: elementIsTracked(element),\n };\n }\n firstLoad = false;\n }\n\n copyNewHeadStylesheetElements(newHead.stylesheets, oldHead.stylesheets);\n removeCurrentHeadProvisionalElements(oldHead.provisional);\n copyNewHeadProvisionalElements(newHead.provisional);\n\n return new Promise<void>((resolve) => {\n copyNewHeadScriptElements(newHead.scripts, resolve);\n });\n}\n\nfunction trackedElementSignature(scripts: Element[]) {\n return scripts\n .filter(elementIsTracked)\n .map((s) => s.outerHTML)\n .join();\n}\n\nfunction copyNewHeadStylesheetElements(next: Element[], prev: Element[]) {\n const existing = prev.map((s) => s.outerHTML);\n for (const element of next) {\n if (!existing.includes(element.outerHTML)) {\n document.head.appendChild(element);\n }\n }\n}\n\nfunction copyNewHeadScriptElements(\n next: Element[],\n onScriptsLoaded: () => void\n) {\n let blockingLoaded: boolean[] = [];\n function dispatch() {\n onScriptsLoaded();\n }\n for (const element of next as HTMLScriptElement[]) {\n const runBefore = element.outerHTML in allHeadScriptsEverRun;\n if (!runBefore) {\n let cb;\n if (!element.defer && element.src) {\n const idx = blockingLoaded.length;\n cb = () => {\n blockingLoaded[idx] = true;\n if (blockingLoaded.every((v) => v)) {\n dispatch();\n }\n };\n blockingLoaded.push(false);\n }\n document.head.appendChild(createScriptElement(element, cb));\n allHeadScriptsEverRun[element.outerHTML] = {\n tracked: elementIsTracked(element),\n };\n }\n }\n if (blockingLoaded.length === 0) {\n // raf waits for react to finish\n requestAnimationFrame(dispatch);\n }\n}\n\nfunction removeCurrentHeadProvisionalElements(prev: Element[]) {\n for (const element of prev) {\n document.head.removeChild(element);\n }\n}\n\nfunction copyNewHeadProvisionalElements(next: Element[]) {\n for (const element of next) {\n document.head.appendChild(element);\n }\n}\n\nfunction elementIsTracked(element: Element) {\n return element.getAttribute(\"data-turbolinks-track\") == \"reload\";\n}\n\nfunction elementIsScript(element: Element) {\n const tagName = element.tagName.toLowerCase();\n return tagName == \"script\";\n}\n\nfunction elementIsStylesheet(element: Element) {\n const tagName = element.tagName.toLowerCase();\n return (\n tagName == \"style\" ||\n (tagName == \"link\" && element.getAttribute(\"rel\") == \"stylesheet\")\n );\n}\n\nfunction elementIsFavicon(element: Element) {\n const tagName = element.tagName.toLowerCase();\n\n return tagName == \"link\" && element.getAttribute(\"rel\") == \"icon\";\n}\n\nfunction categorizeHead(head: ParentNode) {\n const scripts = [];\n const stylesheets = [];\n const provisional = [];\n for (const element of head.children) {\n // we want to keep the same favicon on page transitions\n if (elementIsFavicon(element)) {\n continue;\n }\n\n if (elementIsScript(element)) {\n scripts.push(element);\n } else if (elementIsStylesheet(element)) {\n stylesheets.push(element);\n } else {\n provisional.push(element);\n }\n }\n return { scripts, stylesheets, provisional };\n}\n","export class LruCache<T> {\n private values: Map<string, T> = new Map<string, T>();\n private maxEntries;\n\n constructor(maxEntries: number) {\n this.maxEntries = maxEntries;\n }\n\n public get(key: string): T | undefined {\n const hasKey = this.values.has(key);\n let entry: T | undefined;\n if (hasKey) {\n // peek the entry, re-insert for LRU strategy\n entry = this.values.get(key)!;\n this.values.delete(key);\n this.values.set(key, entry);\n }\n\n return entry;\n }\n\n public put(key: string, value: T) {\n if (this.values.size >= this.maxEntries) {\n // least-recently used cache eviction strategy\n const keyToDelete = this.values.keys().next().value;\n\n this.values.delete(keyToDelete);\n }\n\n this.values.set(key, value);\n }\n}\n","import { unindent } from \"./util\";\n\nexport class ProgressBar {\n static animationDuration = 300; /*ms*/\n\n static get defaultCSS() {\n return unindent`\n .turbolinks-progress-bar {\n position: fixed;\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n background: #0076ff;\n z-index: 9999;\n transition:\n width ${ProgressBar.animationDuration}ms ease-out,\n opacity ${ProgressBar.animationDuration / 2}ms ${\n ProgressBar.animationDuration / 2\n }ms ease-in;\n transform: translate3d(0, 0, 0);\n }\n `;\n }\n\n readonly stylesheetElement = this.createStylesheetElement();\n readonly progressElement = this.createProgressElement();\n\n hiding = false;\n trickleInterval?: number;\n value = 0;\n visible = false;\n\n show() {\n if (!this.visible) {\n this.visible = true;\n this.installStylesheetElement();\n this.installProgressElement();\n this.startTrickling();\n }\n }\n\n hide() {\n if (this.visible && !this.hiding) {\n this.hiding = true;\n this.fadeProgressElement(() => {\n this.uninstallProgressElement();\n this.stopTrickling();\n this.visible = false;\n this.hiding = false;\n });\n }\n }\n\n setValue(value: number) {\n this.value = value;\n this.refresh();\n }\n\n // Private\n\n installStylesheetElement() {\n document.head.insertBefore(\n this.stylesheetElement,\n document.head.firstChild\n );\n }\n\n installProgressElement() {\n this.progressElement.style.width = \"0\";\n this.progressElement.style.opacity = \"1\";\n document.documentElement.insertBefore(this.progressElement, document.body);\n this.refresh();\n }\n\n fadeProgressElement(callback: () => void) {\n this.progressElement.style.opacity = \"0\";\n setTimeout(callback, ProgressBar.animationDuration * 1.5);\n }\n\n uninstallProgressElement() {\n if (this.progressElement.parentNode) {\n document.documentElement.removeChild(this.progressElement);\n }\n }\n\n startTrickling() {\n if (!this.trickleInterval) {\n this.trickleInterval = window.setInterval(\n this.trickle,\n ProgressBar.animationDuration\n );\n }\n }\n\n stopTrickling() {\n window.clearInterval(this.trickleInterval);\n delete this.trickleInterval;\n }\n\n trickle = () => {\n this.setValue(this.value + Math.random() / 100);\n };\n\n refresh() {\n requestAnimationFrame(() => {\n this.progressElement.style.width = `${10 + this.value * 90}%`;\n });\n }\n\n createStylesheetElement() {\n const element = document.createElement(\"style\");\n element.type = \"text/css\";\n element.textContent = ProgressBar.defaultCSS;\n return element;\n }\n\n createProgressElement() {\n const element = document.createElement(\"div\");\n element.className = \"turbolinks-progress-bar\";\n return element;\n }\n}\n","import { Adapter } from \"./adapter\";\nimport { Controller } from \"./controller\";\nimport { Locatable } from \"./location\";\nimport { ProgressBar } from \"./progress_bar\";\nimport { Action } from \"./types\";\nimport { Visit } from \"./visit\";\n\nexport class BrowserAdapter implements Adapter {\n readonly controller: Controller;\n readonly progressBar = new ProgressBar();\n\n progressBarTimeout?: number;\n\n constructor(controller: Controller) {\n this.controller = controller;\n }\n\n visitProposedToLocationWithAction(location: Locatable, action: Action) {\n this.controller.startVisitToLocationWithAction(\n location,\n action,\n );\n }\n\n visitStarted(visit: Visit) {\n visit.issueRequest();\n visit.changeHistory();\n visit.loadCachedSnapshot();\n }\n\n visitRequestStarted(visit: Visit) {\n this.progressBar.setValue(0);\n if (visit.hasCachedSnapshot() || visit.action != \"restore\") {\n this.showProgressBarAfterDelay();\n } else {\n this.showProgressBar();\n }\n }\n\n visitRequestProgressed(visit: Visit) {\n this.progressBar.setValue(visit.progress);\n }\n\n visitRequestCompleted(visit: Visit) {\n visit.loadResponse();\n }\n\n visitRequestFailedWithStatusCode(visit: Visit, statusCode: number) {\n switch (statusCode) {\n // TODO\n // case SystemStatusCode.networkFailure:\n // case SystemStatusCode.timeoutFailure:\n // case SystemStatusCode.contentTypeMismatch:\n // return this.reload()\n default:\n return visit.loadResponse();\n }\n }\n\n visitRequestFinished(visit: Visit) {\n this.hideProgressBar();\n }\n\n visitCompleted(visit: Visit) {\n }\n\n pageInvalidated() {\n this.reload();\n }\n\n visitFailed(visit: Visit) {}\n\n visitRendered(visit: Visit) {}\n\n // Private\n\n showProgressBarAfterDelay() {\n this.progressBarTimeout = window.setTimeout(\n this.showProgressBar,\n this.controller.progressBarDelay\n );\n }\n\n showProgressBar = () => {\n this.progressBar.show();\n };\n\n hideProgressBar() {\n this.progressBar.hide();\n if (this.progressBarTimeout != null) {\n window.clearTimeout(this.progressBarTimeout);\n delete this.progressBarTimeout;\n }\n }\n\n reload() {\n window.location.reload();\n }\n}\n","export type Locatable = Location | string;\n\nexport class Location {\n static get currentLocation() {\n return this.wrap(window.location.toString());\n }\n\n static wrap(locatable: Locatable): Location;\n static wrap(locatable?: Locatable | null): Location | undefined;\n static wrap(locatable: Locatable) {\n if (typeof locatable == \"string\") {\n return new this(locatable);\n } else if (locatable != null) {\n return locatable;\n }\n }\n\n readonly absoluteURL: string;\n readonly requestURL: string;\n readonly anchor?: string;\n\n constructor(url: string) {\n const linkWithAnchor = document.createElement(\"a\");\n linkWithAnchor.href = url;\n\n this.absoluteURL = linkWithAnchor.href;\n\n const anchorLength = linkWithAnchor.hash.length;\n if (anchorLength < 2) {\n this.requestURL = this.absoluteURL;\n } else {\n this.requestURL = this.absoluteURL.slice(0, -anchorLength);\n this.anchor = linkWithAnchor.hash.slice(1);\n }\n }\n\n getOrigin() {\n return this.absoluteURL.split(\"/\", 3).join(\"/\");\n }\n\n getPath() {\n return (this.requestURL.match(/\\/\\/[^/]*(\\/[^?;]*)/) || [])[1] || \"/\";\n }\n\n getPathComponents() {\n return this.getPath().split(\"/\").slice(1);\n }\n\n getLastPathComponent() {\n return this.getPathComponents().slice(-1)[0];\n }\n\n getExtension() {\n return (this.getLastPathComponent().match(/\\.[^.]*$/) || [])[0] || \"\";\n }\n\n isHTML() {\n return this.getExtension().match(/^(?:|\\.(?:htm|html|xhtml))$/);\n }\n\n isPrefixedBy(location: Location): boolean {\n const prefixURL = getPrefixURL(location);\n return (\n this.isEqualTo(location) || stringStartsWith(this.absoluteURL, prefixURL)\n );\n }\n\n isEqualTo(location?: Location) {\n return location && this.absoluteURL === location.absoluteURL;\n }\n\n toCacheKey() {\n return this.requestURL;\n }\n\n toJSON() {\n return this.absoluteURL;\n }\n\n toString() {\n return this.absoluteURL;\n }\n\n valueOf() {\n return this.absoluteURL;\n }\n}\n\nfunction getPrefixURL(location: Location) {\n return addTrailingSlash(location.getOrigin() + location.getPath());\n}\n\nfunction addTrailingSlash(url: string) {\n return stringEndsWith(url, \"/\") ? url : url + \"/\";\n}\n\nfunction stringStartsWith(string: string, prefix: string) {\n return string.slice(0, prefix.length) === prefix;\n}\n\nfunction stringEndsWith(string: string, suffix: string) {\n return string.slice(-suffix.length) === suffix;\n}\n","export type Action = \"advance\" | \"replace\" | \"restore\";\n\nexport function isAction(action: any): action is Action {\n return action == \"advance\" || action == \"replace\" || action == \"restore\";\n}\n\nexport type Position = { x: number; y: number };\n","import { navigate } from \"vite-plugin-ssr/client/router\";\nimport { Adapter } from \"./adapter\";\nimport { Controller } from \"./controller.js\";\nimport { Location } from \"./location\";\nimport { Action } from \"./types\";\nimport { uuid } from \"./util\";\n\nexport enum TimingMetric {\n visitStart = \"visitStart\",\n requestStart = \"requestStart\",\n requestEnd = \"requestEnd\",\n visitEnd = \"visitEnd\",\n}\n\nexport type TimingMetrics = Partial<{ [metric in TimingMetric]: any }>;\n\nexport enum VisitState {\n initialized = \"initialized\",\n started = \"started\",\n canceled = \"canceled\",\n failed = \"failed\",\n completed = \"completed\",\n}\n\nexport class Visit {\n readonly controller: Controller;\n readonly action: Action;\n readonly adapter: Adapter;\n readonly identifier = uuid();\n readonly restorationIdentifier: string;\n readonly timingMetrics: TimingMetrics = {};\n\n frame?: number;\n location: Location;\n progress = 0;\n referrer?: Location;\n redirectedToLocation?: Location;\n snapshotCached = false;\n state = VisitState.initialized;\n\n requestInFlight = false;\n renderFn?: () => Promise<void>;\n\n constructor(\n controller: Controller,\n location: Location,\n action: Action,\n restorationIdentifier: string = uuid()\n ) {\n this.controller = controller;\n this.location = location;\n this.action = action;\n this.adapter = controller.adapter;\n this.restorationIdentifier = restorationIdentifier;\n }\n\n start() {\n if (this.state == VisitState.initialized) {\n this.recordTimingMetric(TimingMetric.visitStart);\n this.state = VisitState.started;\n this.adapter.visitStarted(this);\n }\n }\n\n cancel() {\n if (this.state == VisitState.started) {\n this.requestInFlight = false;\n this.cancelRender();\n this.state = VisitState.canceled;\n }\n }\n\n complete() {\n if (this.state == VisitState.started) {\n this.recordTimingMetric(TimingMetric.visitEnd);\n this.state = VisitState.completed;\n this.adapter.visitCompleted(this);\n this.controller.visitCompleted(this);\n }\n }\n\n fail() {\n if (this.state == VisitState.started) {\n this.state = VisitState.failed;\n this.adapter.visitFailed(this);\n }\n }\n\n changeHistory() {\n // no-op since issueRequest calls navigate which handles all of this already\n return;\n }\n\n issueRequest() {\n if (!this.requestInFlight) {\n if (this.shouldIssueRequest()) {\n const url = new URL(\n this.location.toString(),\n this.location.getOrigin()\n );\n navigate(url.pathname + url.hash + url.search, {\n overwriteLastHistoryEntry: this.action === \"replace\",\n }).catch(console.error);\n this.progress = 0;\n this.requestInFlight = true;\n }\n }\n }\n\n getCachedSnapshot() {\n const snapshot = this.controller.getCachedSnapshotForLocation(\n this.location\n );\n if (snapshot) {\n if (this.action == \"restore\") {\n return snapshot;\n }\n }\n }\n\n hasCachedSnapshot() {\n return this.getCachedSnapshot() != null;\n }\n\n loadCachedSnapshot() {\n // no-op since issueRequest calls navigate which handles all of this already\n return;\n }\n\n loadResponse() {\n this.render(async () => {\n if (!this.renderFn)\n throw new Error(\"Render details not set before rendering\");\n this.cacheSnapshot();\n await this.renderFn();\n this.complete();\n });\n }\n\n // HTTP request delegate\n\n /*\n requestStarted() {\n this.recordTimingMetric(TimingMetric.requestStart);\n this.adapter.visitRequestStarted(this);\n }\n\n requestProgressed(progress: number) {\n this.progress = progress;\n if (this.adapter.visitRequestProgressed) {\n this.adapter.visitRequestProgressed(this);\n }\n }\n\n requestCompletedWithResponse(\n response: string,\n redirectedToLocation?: Location\n ) {\n this.response = response;\n this.redirectedToLocation = redirectedToLocation;\n this.adapter.visitRequestCompleted(this);\n }\n\n requestFailedWithStatusCode(statusCode: number, response?: string) {\n this.response = response;\n this.adapter.visitRequestFailedWithStatusCode(this, statusCode);\n }\n\n requestFinished() {\n this.recordTimingMetric(TimingMetric.requestEnd);\n this.adapter.visitRequestFinished(this);\n }\n */\n\n // Instrumentation\n\n recordTimingMetric(metric: TimingMetric) {\n this.timingMetrics[metric] = new Date().getTime();\n }\n\n getTimingMetrics(): TimingMetrics {\n return { ...this.timingMetrics };\n }\n\n // Private\n\n shouldIssueRequest() {\n return this.action == \"restore\" ? !this.hasCachedSnapshot() : true;\n }\n\n cacheSnapshot() {\n if (!this.snapshotCached) {\n this.controller.cacheSnapshot();\n this.snapshotCached = true;\n }\n }\n\n render(callback: () => Promise<void>) {\n this.cancelRender();\n this.frame = requestAnimationFrame(() => {\n delete this.frame;\n callback.call(this);\n });\n }\n\n cancelRender() {\n if (this.frame) {\n cancelAnimationFrame(this.frame);\n delete this.frame;\n }\n }\n}\n","import { LruCache } from \"./lruCache\";\nimport { Adapter } from \"./adapter\";\nimport { BrowserAdapter } from \"./browser_adapter\";\nimport { Location, Locatable } from \"./location\";\nimport { Action, isAction } from \"./types\";\nimport { closest, defer, dispatch, uuid } from \"./util\";\nimport { Visit } from \"./visit\";\n\nexport type TimingData = {};\nexport type VisitOptions = { action: Action };\n\nexport interface Snapshot {\n bodyEl: Element;\n headEl: Element;\n pageContext: any;\n}\n\nexport class Controller {\n adapter: Adapter = new BrowserAdapter(this);\n\n cache = new LruCache<Snapshot>(10);\n currentVisit?: Visit;\n enabled = true;\n lastRenderedLocation?: Location;\n location!: Location;\n progressBarDelay = 500;\n restorationIdentifier!: string; // This only exists for compatibility with iOS\n started = false;\n pageContext: any;\n\n start() {\n if (!this.started) {\n // TODO: delete document.body in this file. We are doing this to pre-empt VPS interceptor.\n // https://github.com/brillout/vite-plugin-ssr/issues/918 fixes this.\n document.body.addEventListener(\"click\", this.clickCaptured, true);\n this.location = Location.currentLocation;\n this.restorationIdentifier = uuid();\n this.lastRenderedLocation = this.location;\n this.started = true;\n this.enabled = true;\n }\n }\n\n disable() {\n this.enabled = false;\n }\n\n stop() {\n if (this.started) {\n document.body.removeEventListener(\"click\", this.clickCaptured, true);\n this.started = false;\n }\n }\n\n clearCache() {\n this.cache = new LruCache(10);\n }\n\n visit(location: Locatable, options: Partial<VisitOptions> = {}) {\n location = Location.wrap(location);\n if (this.applicationAllowsVisitingLocation(location)) {\n if (this.locationIsVisitable(location)) {\n const action = options.action || \"advance\";\n this.adapter.visitProposedToLocationWithAction(location, action);\n } else {\n window.location.href = location.toString();\n }\n }\n }\n\n startVisitToLocationWithAction(\n location: Locatable,\n action: Action,\n restorationIdentifier?: string\n ) {\n this.startVisit(Location.wrap(location), action);\n }\n\n setProgressBarDelay(delay: number) {\n this.progressBarDelay = delay;\n }\n\n // History delegate\n\n historyPoppedToLocationWithRestorationIdentifier(\n location: Locatable,\n restorationIdentifier: string\n ) {\n if (this.enabled) {\n this.location = Location.wrap(location);\n this.restorationIdentifier = restorationIdentifier;\n this.startVisit(this.location, \"restore\");\n } else {\n this.adapter.pageInvalidated();\n }\n }\n\n // Snapshot cache\n\n getCachedSnapshotForLocation(location: Locatable) {\n return this.cache.get(Location.wrap(location).toCacheKey());\n }\n\n shouldCacheSnapshot() {\n return (\n document.body.querySelector(\"#proxied-body\") &&\n document.head\n .querySelector(\"meta[name='turbolinks-no-cache']\")\n ?.getAttribute(\"content\") != \"no-cache\"\n );\n }\n\n cacheSnapshot() {\n if (this.shouldCacheSnapshot()) {\n this.notifyApplicationBeforeCachingSnapshot();\n const snapshot = {\n bodyEl: document.body.cloneNode(true),\n headEl: document.head.cloneNode(true),\n pageContext: this.pageContext,\n };\n const location = this.lastRenderedLocation || Location.currentLocation;\n defer(() => this.cache.put(location.toCacheKey(), snapshot));\n }\n }\n\n // View\n viewInvalidated() {\n this.adapter.pageInvalidated();\n }\n\n viewWillRender() {\n this.notifyApplicationBeforeRender();\n }\n\n viewRendered() {\n this.lastRenderedLocation = this.currentVisit!.location;\n this.notifyApplicationAfterRender();\n }\n\n // Event handlers\n\n clickCaptured = () => {\n document.body.removeEventListener(\"click\", this.clickBubbled, false);\n document.body.addEventListener(\"click\", this.clickBubbled, false);\n };\n\n clickBubbled = (event: MouseEvent) => {\n if (this.enabled && this.clickEventIsSignificant(event)) {\n const link = this.getVisitableLinkForTarget(event.target);\n if (link) {\n const location = this.getVisitableLocationForLink(link);\n if (\n location &&\n this.applicationAllowsFollowingLinkToLocation(link, location)\n ) {\n event.preventDefault();\n event.stopPropagation();\n const action = this.getActionForLink(link);\n this.visit(location, { action });\n }\n }\n }\n };\n\n // Application events\n\n applicationAllowsFollowingLinkToLocation(link: Element, location: Location) {\n const event = this.notifyApplicationAfterClickingLinkToLocation(\n link,\n location\n );\n return !event.defaultPrevented;\n }\n\n applicationAllowsVisitingLocation(location: Location) {\n const event = this.notifyApplicationBeforeVisitingLocation(location);\n return !event.defaultPrevented;\n }\n\n notifyApplicationAfterClickingLinkToLocation(\n link: Element,\n location: Location\n ) {\n return dispatch(\"turbolinks:click\", {\n target: link,\n data: { url: location.absoluteURL },\n cancelable: true,\n });\n }\n\n notifyApplicationBeforeVisitingLocation(location: Location) {\n return dispatch(\"turbolinks:before-visit\", {\n data: { url: location.absoluteURL },\n cancelable: true,\n });\n }\n\n notifyApplicationAfterVisitingLocation(location: Location) {\n return dispatch(\"turbolinks:visit\", {\n data: { url: location.absoluteURL },\n });\n }\n\n notifyApplicationBeforeCachingSnapshot() {\n return dispatch(\"turbolinks:before-cache\");\n }\n\n notifyApplicationBeforeRender() {\n return dispatch(\"turbolinks:before-render\");\n }\n\n notifyApplicationAfterRender() {\n return dispatch(\"turbolinks:render\");\n }\n\n notifyApplicationAfterPageLoad(timing: TimingData = {}) {\n return dispatch(\"turbolinks:load\", {\n data: { url: this.location.absoluteURL, timing },\n });\n }\n\n // Private\n\n startVisit(location: Location, action: Action) {\n if (this.currentVisit) {\n this.currentVisit.cancel();\n }\n this.currentVisit = this.createVisit(location, action);\n this.currentVisit.start();\n this.notifyApplicationAfterVisitingLocation(location);\n }\n\n createVisit(location: Location, action: Action): Visit {\n const visit = new Visit(this, location, action);\n visit.referrer = this.location;\n if (action === \"restore\") {\n // dont issue navigate() because VPS already did.\n visit.requestInFlight = true;\n }\n return visit;\n }\n\n visitCompleted(visit: Visit) {\n this.notifyApplicationAfterPageLoad(visit.getTimingMetrics());\n }\n\n clickEventIsSignificant(event: MouseEvent) {\n return !(\n (event.target && (event.target as any).isContentEditable) ||\n event.defaultPrevented ||\n event.which > 1 ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.shiftKey\n );\n }\n\n getVisitableLinkForTarget(target: EventTarget | null) {\n if (target instanceof Element && this.elementIsVisitable(target)) {\n return closest(target, \"a[href]:not([target]):not([download])\");\n }\n }\n\n getVisitableLocationForLink(link: Element) {\n const location = new Location(link.getAttribute(\"href\") || \"\");\n if (this.locationIsVisitable(location)) {\n return location;\n }\n }\n\n getActionForLink(link: Element): Action {\n const action = link.getAttribute(\"data-turbolinks-action\");\n return isAction(action) ? action : \"advance\";\n }\n\n elementIsVisitable(element: Element) {\n const container = closest(element, \"[data-turbolinks]\");\n if (container) {\n return container.getAttribute(\"data-turbolinks\") != \"false\";\n } else {\n return true;\n }\n }\n\n locationIsVisitable(location: Location) {\n return location.isPrefixedBy(new Location(\"/\")) && location.isHTML();\n }\n}\n","import { mergeHead } from \"./mergeHead\";\nimport { Controller, VisitOptions } from \"./controller\";\nimport { Locatable } from \"./location\";\nimport { activateNewBodyScriptElements, focusFirstAutofocusableElement } from \"./util\";\n\nconst controller = new Controller();\n\nexport const Turbolinks = {\n get supported() {\n return true;\n },\n\n controller,\n\n visit(location: Locatable, options?: Partial<VisitOptions>) {\n controller.visit(location, options);\n },\n\n clearCache() {\n controller.clearCache();\n },\n\n setProgressBarDelay(delay: number) {\n controller.setProgressBarDelay(delay);\n },\n\n start() {\n // because this runs after ios hooks, we have to recover. See onRenderHtml\n if (\n window.Turbolinks !== Turbolinks &&\n window.Turbolinks.controller.adapter\n ) {\n (window.Turbolinks.controller.adapter as any).controller = controller;\n controller.adapter = window.Turbolinks.controller.adapter;\n }\n // Tells vite-plugin-ssr not to do link interception\n (window as any)._disableAutomaticLinkInterception = true\n window.Turbolinks = Turbolinks;\n controller.start();\n },\n\n _vpsCachePageContext(pageContext: any) {\n controller.pageContext = pageContext;\n },\n\n _vpsOnRenderClient(\n newHead: HTMLHeadElement,\n trackScripts: boolean,\n executeBodyScripts: boolean,\n renderBody: () => void\n ) {\n if (controller.currentVisit) {\n const { currentVisit } = controller;\n // TODO: move to controller?\n currentVisit.renderFn = async () => {\n const scriptsLoaded = mergeHead(newHead, trackScripts, () =>\n controller.viewInvalidated()\n );\n\n controller.viewWillRender();\n renderBody();\n await scriptsLoaded;\n \n if (executeBodyScripts) {\n activateNewBodyScriptElements(\n Array.from(document.body.querySelectorAll(\"script\"))\n );\n }\n focusFirstAutofocusableElement();\n\n controller.viewRendered();\n controller.adapter.visitRendered(currentVisit);\n };\n\n controller.adapter.visitRequestCompleted(controller.currentVisit);\n controller.adapter.visitRequestFinished(controller.currentVisit);\n } else {\n console.error(\n \"controller.currentVisit should exist when onRenderClient fires\"\n );\n }\n },\n};\n\nexport type Turbolinks = typeof Turbolinks;\n"],"mappings":";AACA,SAAe,YAAY,mBAAmB;AAE9C,IAAI;AAEG,SAAS,YAAY,MAAiB,aAAsB;AACjE,QAAM,YAAY,SAAS,eAAe,WAAW;AACrD,MAAI,aAAa;AACf,WAAO,YAAY,WAAW,IAAI;AAAA,EACpC,OAAO;AACL,QAAI,CAAC,MAAM;AACT,aAAO,WAAW,SAAS;AAAA,IAC7B;AACA,SAAK,OAAO,IAAI;AAAA,EAClB;AACF;;;ACfO,SAAS,MAAS,QAA2B;AAClD,SAAO,MAAM,UAAU,MAAM,KAAK,MAAM;AAC1C;AAEO,IAAM,WAAW,MAAM;AAC5B,QAAM,OAAO,SAAS;AAGtB,QAAM,QACJ,KAAK,WACJ,KAAa,yBACb,KAAa,qBACb,KAAa;AAGhB,QAAMA,WACJ,KAAK,WACL,SAAU,UAAkB;AAC1B,QAAI,UAA0B;AAC9B,WAAO,SAAS;AACd,UAAI,MAAM,KAAK,SAAS,QAAQ,GAAG;AACjC,eAAO;AAAA,MACT,OAAO;AACL,kBAAU,QAAQ;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEF,SAAO,SAAU,SAAkB,UAAkB;AACnD,WAAOA,SAAQ,KAAK,SAAS,QAAQ;AAAA,EACvC;AACF,GAAG;AAEI,SAAS,MAAM,UAAqB;AACzC,aAAW,UAAU,CAAC;AACxB;AAQO,SAAS,SACd,WACA,EAAE,QAAQ,YAAY,KAAK,IAA8B,CAAC,GAC1D;AACA,QAA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