astro-vtbot
Advanced tools
Comparing version 1.7.18 to 1.7.19
@@ -51,3 +51,5 @@ // todos: | ||
const definedNames = new Set<string>(); | ||
const matches = style?.innerHTML.replace(/@supports[^{]*\{/gu,"").matchAll(new RegExp(`${property}:\\s*([^;}]*)`, 'gu')); | ||
const matches = style?.innerHTML | ||
.replace(/@supports[^{]*\{/gu, '') | ||
.matchAll(new RegExp(`${property}:\\s*([^;}]*)`, 'gu')); | ||
[...matches].forEach((match) => definedNames.add(decode(property, match[1]!))); | ||
@@ -54,0 +56,0 @@ try { |
@@ -13,3 +13,3 @@ /// <reference types="astro/client" /> | ||
export function loading(newShow: () => void, newHide: () => void, newInit: () => void = () => { }) { | ||
export function loading(newShow: () => void, newHide: () => void, newInit: () => void = () => {}) { | ||
show = newShow; | ||
@@ -53,4 +53,6 @@ hide = newHide; | ||
const icons = options.src ? [] : document.querySelectorAll<HTMLLinkElement>(`head link[rel*="icon"]`); | ||
const favicon = (options.src || (icons[icons.length - 1])?.href) ?? '/favicon.ico'; | ||
const icons = options.src | ||
? [] | ||
: document.querySelectorAll<HTMLLinkElement>(`head link[rel*="icon"]`); | ||
const favicon = (options.src || icons[icons.length - 1]?.href) ?? '/favicon.ico'; | ||
@@ -57,0 +59,0 @@ let src = ''; |
@@ -9,3 +9,3 @@ export const MAIN_FRAME = 'div.main-frame'; | ||
export const LANGUAGE_SELECTOR = 'starlight-lang-select'; | ||
export const MULTI_SIDEBAR = `${SIDEBAR_CONTENT} .__collapse` | ||
/* | ||
@@ -15,5 +15,5 @@ * Returns the the sidebar anchor that best fits the parameter URL. | ||
export function sidebarEntry(url: URL): HTMLAnchorElement | null { | ||
const normalized = normalize(url.href); | ||
const normalized = removeTrailingSlash(url.href); | ||
const target = normalized.split(''); | ||
const anchors = document.querySelectorAll<HTMLAnchorElement>(`${SIDEBAR_CONTENT} a`); | ||
const anchors = document.querySelectorAll<HTMLAnchorElement>(`${SIDEBAR_CONTENT} a[href^='/']`); | ||
if (anchors.length === 0) return null; | ||
@@ -23,3 +23,3 @@ | ||
const normalizedArray = anchorsArray.map((anchor) => | ||
normalize(new URL(anchor.href, location.href).href) | ||
removeTrailingSlash(new URL(anchor.href, location.href).href) | ||
); | ||
@@ -30,7 +30,11 @@ | ||
.map((href) => href.split('').findIndex((char, index) => char !== target[index])) | ||
.map((len, idx) => len !== -1 ? len | ||
: Math.min(normalized.length, normalizedArray[idx].length) + (normalized.length === normalizedArray[idx].length ? 1 : 0)) | ||
.map((len, idx) => | ||
len !== -1 | ||
? len | ||
: Math.min(normalized.length, normalizedArray[idx].length) + | ||
(normalized.length === normalizedArray[idx].length ? 1 : 0) | ||
) | ||
.reduce((best, current, idx, arr) => (current > arr[best] ? idx : best), 0) | ||
]; | ||
function normalize(url: string): string { | ||
function removeTrailingSlash(url: string): string { | ||
return url.replace(/\/#/, '#').replace(/\/$/, ''); | ||
@@ -62,3 +66,1 @@ } | ||
} | ||
@@ -46,6 +46,6 @@ /* | ||
[...document.head.children].forEach((e) => { | ||
if (e instanceof HTMLElement) { | ||
const id = e.getAttribute(PERSIST_ATTR); | ||
let other: Element | "" | null | undefined = id && doc.head.querySelector(`[${PERSIST_ATTR}="${id}"]`); | ||
let other: Element | '' | null | undefined = | ||
id && doc.head.querySelector(`[${PERSIST_ATTR}="${id}"]`); | ||
other ||= [...doc.head.children].find((o) => o.isEqualNode(e)); | ||
@@ -52,0 +52,0 @@ (other ?? e).remove(); |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.7.18", | ||
"version": "1.7.19", | ||
"description": "The 👜 Bag of Tricks ✨ for Astro's View Transitions", | ||
@@ -71,3 +71,3 @@ "homepage": "https://github.com/martrapp/astro-vtbot#readme", | ||
"format": "prettier -w components integration animations test", | ||
"test": "scripts/test.sh", | ||
"test": "npm run format; scripts/test.sh", | ||
"changeset": "changeset", | ||
@@ -74,0 +74,0 @@ "release": "changeset publish" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97275
57
1274