Radish alpha
r
Radicle desktop app
Radicle
Git (anonymous pull)
Log in to clone via SSH
Bump zod 3 -> 4
Rūdolfs Ošiņš committed 7 days ago
commit 8c2c6703d38a4984b5d463c36ad1a24ce0bc4bc0
parent a0836d40cc6f70b9034f5678cdca087272273a05
4 files changed +17 -39
modified package-lock.json
@@ -21,7 +21,7 @@
        "overlayscrollbars": "^2.16.0",
        "overlayscrollbars-svelte": "^0.5.5",
        "semver": "^7.8.0",
-
        "zod": "^3.25.76"
+
        "zod": "^4.4.3"
      },
      "devDependencies": {
        "@eslint/js": "^10.0.1",
@@ -5236,22 +5236,6 @@
        }
      }
    },
-
    "node_modules/yaml": {
-
      "version": "2.9.0",
-
      "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz",
-
      "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==",
-
      "extraneous": true,
-
      "license": "ISC",
-
      "bin": {
-
        "yaml": "bin.mjs"
-
      },
-
      "engines": {
-
        "node": ">= 14.6"
-
      },
-
      "funding": {
-
        "url": "https://github.com/sponsors/eemeli"
-
      }
-
    },
    "node_modules/yocto-queue": {
      "version": "0.1.0",
      "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
@@ -5285,9 +5269,9 @@
      "license": "MIT"
    },
    "node_modules/zod": {
-
      "version": "3.25.76",
-
      "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
-
      "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
+
      "version": "4.4.3",
+
      "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
+
      "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/colinhacks"
modified package.json
@@ -37,7 +37,7 @@
    "overlayscrollbars": "^2.16.0",
    "overlayscrollbars-svelte": "^0.5.5",
    "semver": "^7.8.0",
-
    "zod": "^3.25.76"
+
    "zod": "^4.4.3"
  },
  "devDependencies": {
    "@eslint/js": "^10.0.1",
modified src/components/SidebarRepoList.svelte
@@ -102,7 +102,7 @@
    !window.localStorage,
  );

-
  const pinnedRepoIds = useLocalStorage<string[]>(
+
  const pinnedRepoIds = useLocalStorage(
    "sidebarPinnedRepos",
    array(string()),
    [],
modified src/lib/useLocalStorage.svelte.ts
@@ -1,37 +1,31 @@
-
import { type SafeParseReturnType, z } from "zod";
+
import { z } from "zod";

-
export default function useLocalStorage<
-
  S extends z.infer<T>,
-
  T extends z.ZodType = z.ZodType<S>,
-
>(
+
export default function useLocalStorage<T extends z.ZodType>(
  key: string,
  schema: T,
-
  initialValue: z.infer<typeof schema>,
+
  initialValue: z.infer<T>,
  disableLocalStorage = false,
) {
  const stored = !disableLocalStorage ? localStorage.getItem(key) : null;

-
  const parseFromJson = (
-
    content: string,
-
  ): SafeParseReturnType<string, T["_output"]> => {
-
    return z
+
  const parseFromJson = (content: string) =>
+
    z
      .string()
      .transform((_, ctx) => {
        try {
          return JSON.parse(content);
        } catch {
          ctx.addIssue({
-
            code: z.ZodIssueCode.custom,
+
            code: "custom",
            message: "invalid json",
          });
-
          return z.never;
+
          return z.NEVER;
        }
      })
      .pipe(schema)
      .safeParse(content);
-
  };

-
  let value = $state<S>(initialValue);
+
  let value = $state<z.infer<T>>(initialValue);

  if (stored) {
    try {
@@ -46,7 +40,7 @@ export default function useLocalStorage<
    }
  }

-
  function set(v: S) {
+
  function set(v: z.infer<T>) {
    value = v;
    if (!disableLocalStorage) localStorage.setItem(key, JSON.stringify(value));
  }
@@ -55,10 +49,10 @@ export default function useLocalStorage<
    get value() {
      return value;
    },
-
    set value(v: S) {
+
    set value(v: z.infer<T>) {
      set(v);
    },
-
    update(fn: (v: S) => S) {
+
    update(fn: (v: z.infer<T>) => z.infer<T>) {
      set(fn(value));
    },
    clear() {