An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Display local compatibility for downloaded marketplace packages https://github.com/siyuan-note/siyuan/issues/18601
Danielb45c1ccb2c05
diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.tsindex e28799ff7c..9b812f2382 100644--- a/app/src/config/bazaar.ts+++ b/app/src/config/bazaar.ts@@ -21,6 +21,7 @@ import {switchSettingPanelSubTab} from "./setting/mount";import {isThemeFrontendSupported} from "../util/themeCompatibility";import {getBazaarBackendSystemLabels,+ getBazaarCompatibilityData,getBazaarCompatibilityFieldVisibility,getBazaarFundingItems,getBazaarKernelSystemLabels,@@ -763,7 +764,7 @@ type="checkbox">const available = detail?.available || updatedDetail?.available ||(from === "downloaded" ? bazaar._getUpdatedItem(bazaarType, data.name)?.available : data);const displayData = from === "downloaded" ? installed || data : available || data;- const compatibilityData = available || installed || data;+ const compatibilityData = getBazaarCompatibilityData(from, installed, available, data);const resourceData = available || displayData;bazaar._setPackageDetail(bazaarType, data.name, {installed, available});const urls = resourceData.repoURL.split("/");diff --git a/app/src/util/bazaarPackage.test.ts b/app/src/util/bazaarPackage.test.tsindex e7ffea623e..3fad71c63a 100644--- a/app/src/util/bazaarPackage.test.ts+++ b/app/src/util/bazaarPackage.test.ts@@ -2,6 +2,7 @@ import {describe, it} from "node:test";import * as assert from "node:assert/strict";import {getBazaarBackendSystemLabels,+ getBazaarCompatibilityData,getBazaarCompatibilityFieldVisibility,getBazaarFundingItems,getBazaarKernelSystemLabels,@@ -9,6 +10,27 @@ import {isValidBazaarPackageName,} from "./bazaarPackage";+describe("getBazaarCompatibilityData", () => {+ const installed = {source: "installed"};+ const available = {source: "available"};+ const fallback = {source: "fallback"};++ it("uses installed metadata for downloaded packages", () => {+ assert.equal(getBazaarCompatibilityData("downloaded", installed, available, fallback), installed);+ });++ it("uses available metadata for update and marketplace packages", () => {+ assert.equal(getBazaarCompatibilityData("updated", installed, available, fallback), available);+ assert.equal(getBazaarCompatibilityData("bazaar", installed, available, fallback), available);+ });++ it("falls back without changing the selected source semantics", () => {+ assert.equal(getBazaarCompatibilityData("downloaded", undefined, available, fallback), fallback);+ assert.equal(getBazaarCompatibilityData("updated", installed, undefined, fallback), installed);+ assert.equal(getBazaarCompatibilityData("bazaar", undefined, undefined, fallback), fallback);+ });+});+describe("getBazaarCompatibilityFieldVisibility", () => {it("shows shared and dedicated compatibility fields for each package type", () => {assert.deepEqual(getBazaarCompatibilityFieldVisibility("plugins"), {diff --git a/app/src/util/bazaarPackage.ts b/app/src/util/bazaarPackage.tsindex 8071580875..2f8a3e5bc9 100644--- a/app/src/util/bazaarPackage.ts+++ b/app/src/util/bazaarPackage.ts@@ -4,6 +4,13 @@ const reservedWindowsDeviceNames = new Set(["LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9",]);+export const getBazaarCompatibilityData = <T extends object>(+ source: "downloaded" | "updated" | "bazaar",+ installed: T | undefined,+ available: T | undefined,+ fallback: T,+) => source === "downloaded" ? installed ?? fallback : available ?? installed ?? fallback;+export const getBazaarCompatibilityFieldVisibility = (packageType: string) => {const isPlugin = packageType === "plugins";const isTheme = packageType === "themes";