what-framework 0.6.6 → 0.6.8

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 (3) hide show
  1. package/README.md +1 -1
  2. package/hooks.d.ts +15 -14
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -13,7 +13,7 @@ npm install what-framework
13
13
  Or scaffold a new project:
14
14
 
15
15
  ```bash
16
- npm create what@latest my-app
16
+ npm create what@backport my-app
17
17
  cd my-app
18
18
  npm install
19
19
  npm run dev
package/hooks.d.ts CHANGED
@@ -1,25 +1,26 @@
1
1
  // What Framework - Hooks Type Definitions
2
2
 
3
- import { Signal } from './index.js';
3
+ import { Signal, Computed, Updater, VNodeChild } from './index.js';
4
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>;
5
+ export function useState<T>(initial: T | (() => T)): [Signal<T>, (value: Updater<T>) => void];
6
+ export function useSignal<T>(initial: T | (() => T)): Signal<T>;
7
+ export function useComputed<T>(fn: () => T): Computed<T>;
8
8
  export function useEffect(fn: () => void | (() => void), deps?: any[]): void;
9
- export function useMemo<T>(fn: () => T, deps?: any[]): T;
9
+ export function useMemo<T>(fn: () => T, deps?: any[]): Computed<T>;
10
10
  export function useCallback<T extends (...args: any[]) => any>(fn: T, deps?: any[]): T;
11
- export function useRef<T>(initial?: T): { current: T };
11
+ export function useRef<T>(initial?: T): { current: T | undefined };
12
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 };
13
+ export function createContext<T>(defaultValue?: T): { _defaultValue: T; Provider: (props: { value: T; children?: VNodeChild }) => VNodeChild; Consumer: (props: { children: (value: T) => VNodeChild }) => VNodeChild };
14
14
  export function useReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S, init?: (s: S) => S): [Signal<S>, (action: A) => void];
15
15
  export function onMount(fn: () => void | (() => void)): void;
16
16
  export function onCleanup(fn: () => void): void;
17
17
 
18
- export interface Resource<T> {
19
- (): T | undefined;
18
+ export function createResource<T = any, S = any>(
19
+ fetcher: (source?: S, ctx?: { signal: AbortSignal }) => Promise<T> | T,
20
+ options?: { initialValue?: T; source?: S },
21
+ ): [Signal<T | null>, {
20
22
  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>;
23
+ error: Signal<any>;
24
+ refetch: (source?: S) => Promise<any>;
25
+ mutate: (value: Updater<T | null>) => void;
26
+ }];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "what-framework",
3
- "version": "0.6.6",
4
- "description": "The closest framework to vanilla JS \u2014 signals, components, islands, SSR",
3
+ "version": "0.6.8",
4
+ "description": "The closest framework to vanilla JS signals, components, islands, SSR",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "module": "src/index.js",
@@ -92,9 +92,9 @@
92
92
  },
93
93
  "homepage": "https://whatfw.com",
94
94
  "dependencies": {
95
- "what-core": "^0.6.7",
96
- "what-router": "^0.6.6",
97
- "what-server": "^0.6.6",
95
+ "what-core": "^0.6.8",
96
+ "what-router": "^0.6.7",
97
+ "what-server": "^0.6.7",
98
98
  "what-compiler": "^0.6.5"
99
99
  }
100
100
  }