@peachy/hooks 0.0.11 → 0.0.12

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @peachy/hooks
2
2
 
3
+ ## 0.0.12
4
+
3
5
  ## 0.0.11
4
6
 
5
7
  ### Patch Changes
@@ -1,4 +1,3 @@
1
1
  import { useAccentColor } from "./use-accent-color.mjs";
2
2
  import { useDarkMode } from "./use-dark-mode.mjs";
3
-
4
- export { useAccentColor, useDarkMode };
3
+ export { useAccentColor, useDarkMode };
@@ -1,8 +1,8 @@
1
1
  //#region src/adw/use-accent-color.d.ts
2
2
  /**
3
- * Query the system's accent color if supported
4
- * @returns [accentColor] - accent color or null
5
- */
6
- declare function useAccentColor(): any[];
3
+ * Query the system's accent color if supported
4
+ * @returns [accentColor] - accent color or null
5
+ */
6
+ declare function useAccentColor(): [accentColor: number | null];
7
7
  //#endregion
8
8
  export { useAccentColor };
@@ -2,7 +2,6 @@ import { useBinding } from "../gobject/use-binding.mjs";
2
2
  import "../gobject/index.mjs";
3
3
  import { useRef } from "react";
4
4
  import Adw from "gi://Adw?version=1";
5
-
6
5
  //#region src/adw/use-accent-color.ts
7
6
  /**
8
7
  * Query the system's accent color if supported
@@ -14,6 +13,5 @@ function useAccentColor() {
14
13
  const [systemSupportsAccentColors] = useBinding(styleManager, "system-supports-accent-colors");
15
14
  return [systemSupportsAccentColors ? accentColor : null];
16
15
  }
17
-
18
16
  //#endregion
19
- export { useAccentColor };
17
+ export { useAccentColor };
@@ -1,4 +1,4 @@
1
1
  //#region src/adw/use-dark-mode.d.ts
2
- declare function useDarkMode(): any[];
2
+ declare function useDarkMode(): [isDark: boolean, setDarkMode: (value: boolean) => void];
3
3
  //#endregion
4
4
  export { useDarkMode };
@@ -2,7 +2,6 @@ import { useBinding } from "../gobject/use-binding.mjs";
2
2
  import "../gobject/index.mjs";
3
3
  import { useCallback, useRef } from "react";
4
4
  import Adw from "gi://Adw?version=1";
5
-
6
5
  //#region src/adw/use-dark-mode.ts
7
6
  function useDarkMode() {
8
7
  const styleManager = useRef(Adw.StyleManager.get_default());
@@ -11,6 +10,5 @@ function useDarkMode() {
11
10
  styleManager.current.set_color_scheme(value ? Adw.ColorScheme.PREFER_DARK : Adw.ColorScheme.PREFER_LIGHT);
12
11
  }, [styleManager])];
13
12
  }
14
-
15
13
  //#endregion
16
- export { useDarkMode };
14
+ export { useDarkMode };
@@ -1,3 +1,2 @@
1
1
  import { useReference } from "./use-reference.mjs";
2
-
3
- export { useReference };
2
+ export { useReference };
@@ -2,8 +2,8 @@ import { RefObject } from "react";
2
2
 
3
3
  //#region src/base/use-reference.d.ts
4
4
  /**
5
- * Returns the value inside a `ref`, correctly checking it after the initial render
6
- */
5
+ * Returns the value inside a `ref`, correctly checking it after the initial render
6
+ */
7
7
  declare function useReference<T>(value: T | RefObject<T>, defaultValue?: T): T | null;
8
8
  //#endregion
9
9
  export { useReference };
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useState } from "react";
2
-
3
2
  //#region src/base/use-reference.ts
4
3
  /**
5
4
  * Returns the value inside a `ref`, correctly checking it after the initial render
@@ -19,6 +18,5 @@ function getValue(object) {
19
18
  function isRef(object) {
20
19
  return typeof object === "object" && object !== null && "current" in object;
21
20
  }
22
-
23
21
  //#endregion
24
- export { useReference };
22
+ export { useReference };
@@ -1,4 +1,3 @@
1
1
  import { useNetworkMonitor } from "./use-network-monitor.mjs";
2
2
  import { useSetting } from "./use-setting.mjs";
3
-
4
- export { useNetworkMonitor, useSetting };
3
+ export { useNetworkMonitor, useSetting };
@@ -1,6 +1,5 @@
1
1
  import { useCallback, useEffect, useRef, useState } from "react";
2
2
  import Gio from "gi://Gio?version=2.0";
3
-
4
3
  //#region src/gio/use-network-monitor.ts
5
4
  function useNetworkMonitor() {
6
5
  const monitor = useRef(Gio.NetworkMonitor.get_default());
@@ -24,6 +23,5 @@ function useNetworkMonitor() {
24
23
  }, [calculateState]);
25
24
  return state;
26
25
  }
27
-
28
26
  //#endregion
29
- export { useNetworkMonitor };
27
+ export { useNetworkMonitor };
@@ -1,6 +1,5 @@
1
1
  import { useCallback, useEffect, useRef, useState } from "react";
2
2
  import Gio from "gi://Gio?version=2.0";
3
-
4
3
  //#region src/gio/use-setting.ts
5
4
  function useSetting(schema, key) {
6
5
  const settings = useRef(Gio.Settings.new(schema));
@@ -21,6 +20,5 @@ function useSetting(schema, key) {
21
20
  settings.current.set_value(key, newValue);
22
21
  }, [key])];
23
22
  }
24
-
25
23
  //#endregion
26
- export { useSetting };
24
+ export { useSetting };
@@ -1,3 +1,2 @@
1
1
  import { useBinding } from "./use-binding.mjs";
2
-
3
- export { useBinding };
2
+ export { useBinding };
@@ -1,7 +1,6 @@
1
1
  import { useReference } from "../base/use-reference.mjs";
2
2
  import "../base/index.mjs";
3
3
  import { useEffect, useState } from "react";
4
-
5
4
  //#region src/gobject/use-binding.ts
6
5
  function useBinding(object, property, defaultValue) {
7
6
  const value = useReference(object);
@@ -20,6 +19,5 @@ function useBinding(object, property, defaultValue) {
20
19
  }, [value, property]);
21
20
  return [result];
22
21
  }
23
-
24
22
  //#endregion
25
- export { useBinding };
23
+ export { useBinding };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { useAccentColor } from "./adw/use-accent-color.mjs";
2
2
  import { useDarkMode } from "./adw/use-dark-mode.mjs";
3
3
  import { useReference } from "./base/use-reference.mjs";
4
- import "./base/index.mjs";
5
4
  import { useBinding } from "./gobject/use-binding.mjs";
6
- import "./gobject/index.mjs";
7
5
  export { useAccentColor, useBinding, useDarkMode, useReference };
package/dist/index.mjs CHANGED
@@ -5,5 +5,4 @@ import "./gobject/index.mjs";
5
5
  import { useAccentColor } from "./adw/use-accent-color.mjs";
6
6
  import { useDarkMode } from "./adw/use-dark-mode.mjs";
7
7
  import "./adw/index.mjs";
8
-
9
- export { useAccentColor, useBinding, useDarkMode, useReference };
8
+ export { useAccentColor, useBinding, useDarkMode, useReference };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peachy/hooks",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -16,11 +16,11 @@
16
16
  }
17
17
  },
18
18
  "devDependencies": {
19
- "@types/react": "^19.2.13",
19
+ "@types/react": "^19.2.14",
20
20
  "react": "^19.2.4",
21
- "tsdown": "0.20.3",
21
+ "tsdown": "0.21.0",
22
22
  "typescript": "^5.9.3",
23
- "@peachy/react": "0.0.11"
23
+ "@peachy/react": "0.0.12"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^19.2.0"
@@ -8,7 +8,7 @@ import { useBinding } from "../gobject";
8
8
  * Query the system's accent color if supported
9
9
  * @returns [accentColor] - accent color or null
10
10
  */
11
- export function useAccentColor() {
11
+ export function useAccentColor(): [accentColor: number | null] {
12
12
  const styleManager = useRef(Adw.StyleManager.get_default());
13
13
 
14
14
  const [accentColor] = useBinding(styleManager, "accent-color");
@@ -4,12 +4,12 @@ import { useCallback, useRef } from "react";
4
4
 
5
5
  import { useBinding } from "../gobject";
6
6
 
7
- export function useDarkMode() {
7
+ export function useDarkMode(): [isDark: boolean, setDarkMode: (value: boolean) => void] {
8
8
  const styleManager = useRef(Adw.StyleManager.get_default());
9
9
 
10
10
  const [isDark] = useBinding(styleManager, "dark");
11
11
  const setDarkMode = useCallback(
12
- (value: boolean) => {
12
+ (value: boolean): void => {
13
13
  styleManager.current.set_color_scheme(
14
14
  value ? Adw.ColorScheme.PREFER_DARK : Adw.ColorScheme.PREFER_LIGHT,
15
15
  );
@@ -17,5 +17,5 @@ export function useDarkMode() {
17
17
  [styleManager],
18
18
  );
19
19
 
20
- return [isDark, setDarkMode];
20
+ return [isDark, setDarkMode] as const;
21
21
  }
package/tsdown.config.mjs CHANGED
@@ -3,7 +3,9 @@ import { defineConfig } from "tsdown";
3
3
  export default defineConfig({
4
4
  entry: ["./src/**/*.ts"],
5
5
  dts: true,
6
- external: [/^gi:\/\/*/],
6
+ deps: {
7
+ neverBundle: [/^gi:\/\/*/],
8
+ },
7
9
  outputOptions: {
8
10
  preserveModules: true,
9
11
  },