@rotki/ui-library 2.13.2 → 2.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,4 @@
1
1
  import { transformCase } from "../../utils/helpers.js";
2
- import { useFetch } from "@vueuse/core";
3
- import { get } from "@vueuse/shared";
4
2
  const ASSET_MAPPINGS_URL = "https://raw.githubusercontent.com/rotki/data";
5
3
  const sourcesCache = /* @__PURE__ */ new Map();
6
4
  function isExternalLinks(value) {
@@ -10,10 +8,13 @@ function isExternalLinks(value) {
10
8
  }
11
9
  async function fetchSourcesFromNetwork(branch) {
12
10
  try {
13
- const { data } = await useFetch(
11
+ const response = await fetch(
14
12
  `${ASSET_MAPPINGS_URL}/${branch}/constants/asset-mappings.json`
15
13
  );
16
- const links = transformCase(JSON.parse(get(data) ?? "null")?.logo, "camelCase");
14
+ if (!response.ok)
15
+ return void 0;
16
+ const json = await response.json();
17
+ const links = transformCase(json?.logo, "camelCase");
17
18
  if (isExternalLinks(links))
18
19
  return links;
19
20
  return void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"use-logo-sources.js","sources":["../../../src/components/logos/use-logo-sources.ts"],"sourcesContent":["import type { ExternalLinks } from '@/components/logos/RuiLogo.vue';\nimport { transformCase } from '@/utils/helpers';\n\nconst ASSET_MAPPINGS_URL = 'https://raw.githubusercontent.com/rotki/data';\n\n// Module-level cache: deduplicates asset-mappings fetches across all RuiLogo instances.\n// Keyed by branch so different branches don't share stale data.\nconst sourcesCache = new Map<string, Promise<ExternalLinks | undefined>>();\n\nfunction isExternalLinks(value: unknown): value is ExternalLinks {\n if (typeof value !== 'object' || value === null)\n return false;\n\n return Object.values(value).every(v => v === undefined || typeof v === 'string');\n}\n\nasync function fetchSourcesFromNetwork(branch: string): Promise<ExternalLinks | undefined> {\n try {\n const { data } = await useFetch<string>(\n `${ASSET_MAPPINGS_URL}/${branch}/constants/asset-mappings.json`,\n );\n\n const links = transformCase(JSON.parse(get(data) ?? 'null')?.logo, 'camelCase');\n if (isExternalLinks(links))\n return links;\n\n return undefined;\n }\n catch {\n return undefined;\n }\n}\n\n/**\n * Fetches external logo sources for a given branch, deduplicating concurrent requests.\n * Uses a module-level cache so all RuiLogo instances share a single fetch per branch.\n */\nexport function getLogoSources(branch: string): Promise<ExternalLinks | undefined> {\n const cached = sourcesCache.get(branch);\n if (cached)\n return cached;\n\n const promise = fetchSourcesFromNetwork(branch);\n sourcesCache.set(branch, promise);\n return promise;\n}\n\n/**\n * Clears the module-level cache. Exposed for testing only.\n */\nexport function clearLogoSourcesCache(): void {\n sourcesCache.clear();\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,qBAAqB;AAI3B,MAAM,mCAAmB,IAAA;AAEzB,SAAS,gBAAgB,OAAwC;AAC/D,MAAI,OAAO,UAAU,YAAY,UAAU;AACzC,WAAO;AAET,SAAO,OAAO,OAAO,KAAK,EAAE,MAAM,OAAK,MAAM,UAAa,OAAO,MAAM,QAAQ;AACjF;AAEA,eAAe,wBAAwB,QAAoD;AACzF,MAAI;AACF,UAAM,EAAE,KAAA,IAAS,MAAM;AAAA,MACrB,GAAG,kBAAkB,IAAI,MAAM;AAAA,IAAA;AAGjC,UAAM,QAAQ,cAAc,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,GAAG,MAAM,WAAW;AAC9E,QAAI,gBAAgB,KAAK;AACvB,aAAO;AAET,WAAO;AAAA,EACT,QACM;AACJ,WAAO;AAAA,EACT;AACF;AAMO,SAAS,eAAe,QAAoD;AACjF,QAAM,SAAS,aAAa,IAAI,MAAM;AACtC,MAAI;AACF,WAAO;AAET,QAAM,UAAU,wBAAwB,MAAM;AAC9C,eAAa,IAAI,QAAQ,OAAO;AAChC,SAAO;AACT;"}
1
+ {"version":3,"file":"use-logo-sources.js","sources":["../../../src/components/logos/use-logo-sources.ts"],"sourcesContent":["import type { ExternalLinks } from '@/components/logos/RuiLogo.vue';\nimport { transformCase } from '@/utils/helpers';\n\nconst ASSET_MAPPINGS_URL = 'https://raw.githubusercontent.com/rotki/data';\n\n// Module-level cache: deduplicates asset-mappings fetches across all RuiLogo instances.\n// Keyed by branch so different branches don't share stale data.\nconst sourcesCache = new Map<string, Promise<ExternalLinks | undefined>>();\n\nfunction isExternalLinks(value: unknown): value is ExternalLinks {\n if (typeof value !== 'object' || value === null)\n return false;\n\n return Object.values(value).every(v => v === undefined || typeof v === 'string');\n}\n\nasync function fetchSourcesFromNetwork(branch: string): Promise<ExternalLinks | undefined> {\n try {\n const response = await fetch(\n `${ASSET_MAPPINGS_URL}/${branch}/constants/asset-mappings.json`,\n );\n\n if (!response.ok)\n return undefined;\n\n const json = await response.json();\n const links = transformCase(json?.logo, 'camelCase');\n if (isExternalLinks(links))\n return links;\n\n return undefined;\n }\n catch {\n return undefined;\n }\n}\n\n/**\n * Fetches external logo sources for a given branch, deduplicating concurrent requests.\n * Uses a module-level cache so all RuiLogo instances share a single fetch per branch.\n */\nexport function getLogoSources(branch: string): Promise<ExternalLinks | undefined> {\n const cached = sourcesCache.get(branch);\n if (cached)\n return cached;\n\n const promise = fetchSourcesFromNetwork(branch);\n sourcesCache.set(branch, promise);\n return promise;\n}\n\n/**\n * Clears the module-level cache. Exposed for testing only.\n */\nexport function clearLogoSourcesCache(): void {\n sourcesCache.clear();\n}\n"],"names":[],"mappings":";AAGA,MAAM,qBAAqB;AAI3B,MAAM,mCAAmB,IAAA;AAEzB,SAAS,gBAAgB,OAAwC;AAC/D,MAAI,OAAO,UAAU,YAAY,UAAU;AACzC,WAAO;AAET,SAAO,OAAO,OAAO,KAAK,EAAE,MAAM,OAAK,MAAM,UAAa,OAAO,MAAM,QAAQ;AACjF;AAEA,eAAe,wBAAwB,QAAoD;AACzF,MAAI;AACF,UAAM,WAAW,MAAM;AAAA,MACrB,GAAG,kBAAkB,IAAI,MAAM;AAAA,IAAA;AAGjC,QAAI,CAAC,SAAS;AACZ,aAAO;AAET,UAAM,OAAO,MAAM,SAAS,KAAA;AAC5B,UAAM,QAAQ,cAAc,MAAM,MAAM,WAAW;AACnD,QAAI,gBAAgB,KAAK;AACvB,aAAO;AAET,WAAO;AAAA,EACT,QACM;AACJ,WAAO;AAAA,EACT;AACF;AAMO,SAAS,eAAe,QAAoD;AACjF,QAAM,SAAS,aAAa,IAAI,MAAM;AACtC,MAAI;AACF,WAAO;AAET,QAAM,UAAU,wBAAwB,MAAM;AAC9C,eAAa,IAAI,QAAQ,OAAO;AAChC,SAAO;AACT;"}
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json.schemastore.org/web-types",
3
3
  "framework": "vue",
4
4
  "name": "@rotki/ui-library",
5
- "version": "2.13.2",
5
+ "version": "2.13.3",
6
6
  "js-types-syntax": "typescript",
7
7
  "description-markup": "markdown",
8
8
  "contributions": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rotki/ui-library",
3
- "version": "2.13.2",
3
+ "version": "2.13.3",
4
4
  "description": "A vue design system and component library for rotki",
5
5
  "type": "module",
6
6
  "keywords": [