From 6dd772bf00459fe5165140e4e756e2b3096686e8 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Mon, 21 Apr 2025 23:55:38 -0700 Subject: [PATCH 1/5] fix(popover): properly clear popover on racing fetch --- quartz/components/scripts/popover.inline.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/quartz/components/scripts/popover.inline.ts b/quartz/components/scripts/popover.inline.ts index d8f1e1a64..989af7ee8 100644 --- a/quartz/components/scripts/popover.inline.ts +++ b/quartz/components/scripts/popover.inline.ts @@ -3,12 +3,13 @@ import { normalizeRelativeURLs } from "../../util/path" import { fetchCanonical } from "./util" const p = new DOMParser() +let activeAnchor: HTMLAnchorElement | null = null async function mouseEnterHandler( this: HTMLAnchorElement, { clientX, clientY }: { clientX: number; clientY: number }, ) { - const link = this + const link = (activeAnchor = this) if (link.dataset.noPopover === "true") { return } @@ -44,10 +45,9 @@ async function mouseEnterHandler( targetUrl.search = "" const popoverId = `popover-${link.pathname}` const prevPopoverElement = document.getElementById(popoverId) - const hasAlreadyBeenFetched = () => !!document.getElementById(popoverId) // dont refetch if there's already a popover - if (hasAlreadyBeenFetched()) { + if (!!document.getElementById(popoverId)) { showPopover(prevPopoverElement as HTMLElement) return } @@ -56,11 +56,6 @@ async function mouseEnterHandler( console.error(err) }) - // bailout if another popover exists - if (hasAlreadyBeenFetched()) { - return - } - if (!response) return const [contentType] = response.headers.get("Content-Type")!.split(";") const [contentTypeCategory, typeInfo] = contentType.split("/") @@ -107,11 +102,20 @@ async function mouseEnterHandler( elts.forEach((elt) => popoverInner.appendChild(elt)) } + if (!!document.getElementById(popoverId)) { + return + } + document.body.appendChild(popoverElement) + if (activeAnchor !== this) { + return + } + showPopover(popoverElement) } function clearActivePopover() { + activeAnchor = null const allPopoverElements = document.querySelectorAll(".popover") allPopoverElements.forEach((popoverElement) => popoverElement.classList.remove("active-popover")) } From 771c05ff1866a32e05fd5926317372405202d640 Mon Sep 17 00:00:00 2001 From: ARYAN TECHIE <76107940+Aryan-Techie@users.noreply.github.com> Date: Tue, 22 Apr 2025 22:52:43 +0530 Subject: [PATCH 2/5] fix: dynamically detect current branch for quartz sync push (#1930) --- quartz/cli/handlers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quartz/cli/handlers.js b/quartz/cli/handlers.js index c41bafc31..0cb371bd9 100644 --- a/quartz/cli/handlers.js +++ b/quartz/cli/handlers.js @@ -589,7 +589,8 @@ export async function handleSync(argv) { await popContentFolder(contentFolder) if (argv.push) { console.log("Pushing your changes") - const res = spawnSync("git", ["push", "-uf", ORIGIN_NAME, QUARTZ_SOURCE_BRANCH], { + const currentBranch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim() + const res = spawnSync("git", ["push", "-uf", ORIGIN_NAME, currentBranch], { stdio: "inherit", }) if (res.status !== 0) { From 2a9290b3dfedb718dbd5fc7da09775eb803f9764 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Tue, 22 Apr 2025 11:18:50 -0700 Subject: [PATCH 3/5] fix(transclude): blockref detection --- quartz/components/renderPage.tsx | 2 +- quartz/plugins/transformers/ofm.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quartz/components/renderPage.tsx b/quartz/components/renderPage.tsx index 19324f51e..e43189dc7 100644 --- a/quartz/components/renderPage.tsx +++ b/quartz/components/renderPage.tsx @@ -75,7 +75,7 @@ function renderTranscludes( const classNames = (node.properties?.className ?? []) as string[] if (classNames.includes("transclude")) { const inner = node.children[0] as Element - const transcludeTarget = inner.properties["data-slug"] as FullSlug + const transcludeTarget = (inner.properties["data-slug"] ?? slug) as FullSlug const page = componentData.allFiles.find((f) => f.slug === transcludeTarget) if (!page) { return diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 5c2f4b25c..dada7d4d1 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -191,7 +191,8 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin> const [rawFp, rawHeader, rawAlias]: (string | undefined)[] = capture const [fp, anchor] = splitAnchor(`${rawFp ?? ""}${rawHeader ?? ""}`) - const displayAnchor = anchor ? `#${anchor.trim().replace(/^#+/, "")}` : "" + const blockRef = Boolean(rawHeader?.startsWith("#^")) ? "^" : "" + const displayAnchor = anchor ? `#${blockRef}${anchor.trim().replace(/^#+/, "")}` : "" const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? "" const embedDisplay = value.startsWith("!") ? "!" : "" @@ -221,7 +222,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin> let [rawFp, rawHeader, rawAlias] = capture const fp = rawFp?.trim() ?? "" const anchor = rawHeader?.trim() ?? "" - const alias = rawAlias?.slice(1).trim() + const alias = rawAlias?.slice(1).trim() ?? "" // embed cases if (value.startsWith("!")) { From cdebd05dc92135229306ebf261fb62437581c7e9 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Wed, 23 Apr 2025 09:30:25 -0700 Subject: [PATCH 4/5] fix(wikilinks): dont default empty alias --- quartz/plugins/transformers/ofm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index dada7d4d1..983fd7327 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -222,7 +222,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin> let [rawFp, rawHeader, rawAlias] = capture const fp = rawFp?.trim() ?? "" const anchor = rawHeader?.trim() ?? "" - const alias = rawAlias?.slice(1).trim() ?? "" + const alias: string | undefined = rawAlias?.slice(1).trim() // embed cases if (value.startsWith("!")) { From 7d49dff0747f69e96ab83a98b97ece96d4268b36 Mon Sep 17 00:00:00 2001 From: anthops <32993852+anthops@users.noreply.github.com> Date: Thu, 24 Apr 2025 02:02:52 +0930 Subject: [PATCH 5/5] fix: prefer webgl for devices with webgpu and no float32-blendable feature flag #1899 (#1933) Co-authored-by: Tony <32993852+0xREDACTED@users.noreply.github.com> --- package-lock.json | 7 ++++--- package.json | 1 + quartz/components/scripts/graph.inline.ts | 12 +++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e18594967..227e756da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@myriaddreamin/rehype-typst": "^0.5.4", "@napi-rs/simple-git": "0.1.19", "@tweenjs/tween.js": "^25.0.0", + "@webgpu/types": "^0.1.60", "ansi-truncate": "^1.2.0", "async-mutex": "^0.5.0", "chalk": "^5.4.1", @@ -2001,9 +2002,9 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" }, "node_modules/@webgpu/types": { - "version": "0.1.44", - "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.44.tgz", - "integrity": "sha512-JDpYJN5E/asw84LTYhKyvPpxGnD+bAKPtpW9Ilurf7cZpxaTbxkQcGwOd7jgB9BPBrTYQ+32ufo4HiuomTjHNQ==", + "version": "0.1.60", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.60.tgz", + "integrity": "sha512-8B/tdfRFKdrnejqmvq95ogp8tf52oZ51p3f4QD5m5Paey/qlX4Rhhy5Y8tgFMi7Ms70HzcMMw3EQjH/jdhTwlA==", "license": "BSD-3-Clause" }, "node_modules/@xmldom/xmldom": { diff --git a/package.json b/package.json index 0378c5322..ddcb5f2a0 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "@myriaddreamin/rehype-typst": "^0.5.4", "@napi-rs/simple-git": "0.1.19", "@tweenjs/tween.js": "^25.0.0", + "@webgpu/types": "^0.1.60", "ansi-truncate": "^1.2.0", "async-mutex": "^0.5.0", "chalk": "^5.4.1", diff --git a/quartz/components/scripts/graph.inline.ts b/quartz/components/scripts/graph.inline.ts index a669b0547..87e2958d6 100644 --- a/quartz/components/scripts/graph.inline.ts +++ b/quartz/components/scripts/graph.inline.ts @@ -68,6 +68,15 @@ type TweenNode = { stop: () => void } +async function determineGraphicsAPI(): Promise<"webgpu" | "webgl"> { + const adapter = await navigator.gpu?.requestAdapter().catch(() => null) + if (!adapter) { + return "webgl" + } + // Devices with WebGPU but no float32-blendable feature fail to render the graph + return adapter.features.has("float32-blendable") ? "webgpu" : "webgl" +} + async function renderGraph(graph: HTMLElement, fullSlug: FullSlug) { const slug = simplifySlug(fullSlug) const visited = getVisited() @@ -349,6 +358,7 @@ async function renderGraph(graph: HTMLElement, fullSlug: FullSlug) { tweens.forEach((tween) => tween.stop()) tweens.clear() + const pixiPreference = await determineGraphicsAPI() const app = new Application() await app.init({ width, @@ -357,7 +367,7 @@ async function renderGraph(graph: HTMLElement, fullSlug: FullSlug) { autoStart: false, autoDensity: true, backgroundAlpha: 0, - preference: "webgpu", + preference: pixiPreference, resolution: window.devicePixelRatio, eventMode: "static", })