what-core 0.6.6 → 0.6.7

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.
Files changed (2) hide show
  1. package/hooks.d.ts +25 -0
  2. package/package.json +3 -1
package/hooks.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ // What Framework - Hooks Type Definitions
2
+
3
+ import { Signal } from './index.js';
4
+
5
+ export function useState<T>(initial: T | (() => T)): [Signal<T>, (value: T | ((prev: T) => T)) => void];
6
+ export function useSignal<T>(initial: T): Signal<T>;
7
+ export function useComputed<T>(fn: () => T): Signal<T>;
8
+ export function useEffect(fn: () => void | (() => void), deps?: any[]): void;
9
+ export function useMemo<T>(fn: () => T, deps?: any[]): T;
10
+ export function useCallback<T extends (...args: any[]) => any>(fn: T, deps?: any[]): T;
11
+ export function useRef<T>(initial?: T): { current: T };
12
+ export function useContext<T>(context: { _defaultValue: T }): T;
13
+ export function createContext<T>(defaultValue?: T): { _defaultValue: T; Provider: (props: { value: T; children: any }) => any };
14
+ export function useReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S, init?: (s: S) => S): [Signal<S>, (action: A) => void];
15
+ export function onMount(fn: () => void | (() => void)): void;
16
+ export function onCleanup(fn: () => void): void;
17
+
18
+ export interface Resource<T> {
19
+ (): T | undefined;
20
+ loading: Signal<boolean>;
21
+ error: Signal<Error | null>;
22
+ refetch: () => void;
23
+ mutate: (value: T) => void;
24
+ }
25
+ export function createResource<T>(fetcher: () => Promise<T>, options?: { initialValue?: T }): Resource<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "what-core",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "What Framework - The closest framework to vanilla JS",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -33,6 +33,7 @@
33
33
  "import": "./src/testing.js"
34
34
  },
35
35
  "./hooks": {
36
+ "types": "./hooks.d.ts",
36
37
  "import": "./src/hooks.js"
37
38
  },
38
39
  "./compiler": {
@@ -53,6 +54,7 @@
53
54
  "jsx-runtime.d.ts",
54
55
  "render.d.ts",
55
56
  "testing.d.ts",
57
+ "hooks.d.ts",
56
58
  "compiler.d.ts",
57
59
  "devtools.d.ts"
58
60
  ],