what-react 0.6.2 → 0.6.5

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/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # what-react
2
2
 
3
- React compatibility layer for [What Framework](https://whatfw.com). Use React ecosystem libraries with What's signal-based engine under the hood -- zero code changes required.
3
+ React compatibility layer for [What Framework](https://whatfw.com). Use many public-API React ecosystem libraries with What's signal-based engine under the hood; internals-heavy libraries still need verification.
4
4
 
5
- **90+ React libraries confirmed working**, including zustand, @tanstack/react-query, react-hook-form, framer-motion, @radix-ui, react-select, react-router, and many more.
5
+ **88 React libraries confirmed working**, with 1 partial and 5 expected entries in the current matrix, including zustand, @tanstack/react-query, react-hook-form, framer-motion, @radix-ui, react-select, react-router, and many more.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install what-react what-core
10
+ npm install what-react@backport what-core@backport
11
11
  ```
12
12
 
13
13
  ## Setup
@@ -32,7 +32,7 @@ The plugin handles everything automatically:
32
32
 
33
33
  ## Usage
34
34
 
35
- Install any React library and use it normally. No code changes needed.
35
+ Install a verified public-API React library and use it normally. Many work without app-code changes; libraries that depend on React internals should be tested against the matrix first.
36
36
 
37
37
  ```jsx
38
38
  // zustand -- just works
package/dom.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import type { ReactNode } from './index.js';
2
+
3
+ export interface Root {
4
+ render(element: ReactNode): void;
5
+ unmount(): void;
6
+ }
7
+
8
+ export function createRoot(container: Element | DocumentFragment): Root;
9
+ export function hydrateRoot(container: Element | DocumentFragment, initialChildren: ReactNode): Root;
10
+ export function render(element: ReactNode, container: Element | DocumentFragment, callback?: () => void): Root;
11
+ export function unmountComponentAtNode(container: Element | DocumentFragment): boolean;
12
+ export function createPortal(children: ReactNode, container: Element | DocumentFragment, key?: string | number | null): any;
13
+ export function flushSync<T = void>(fn?: () => T): T | void;
14
+ export function findDOMNode(component: any): Element | Text | null;
15
+ export function unstable_batchedUpdates<T = void>(fn: () => T): T | void;
16
+ export const version: string;
17
+
18
+ declare const ReactDOM: {
19
+ createRoot: typeof createRoot;
20
+ hydrateRoot: typeof hydrateRoot;
21
+ render: typeof render;
22
+ unmountComponentAtNode: typeof unmountComponentAtNode;
23
+ createPortal: typeof createPortal;
24
+ flushSync: typeof flushSync;
25
+ findDOMNode: typeof findDOMNode;
26
+ unstable_batchedUpdates: typeof unstable_batchedUpdates;
27
+ version: typeof version;
28
+ };
29
+
30
+ export default ReactDOM;
package/index.d.ts ADDED
@@ -0,0 +1,127 @@
1
+ import type { Component as WhatComponent, Context as WhatContext, VNode, VNodeChild } from 'what-core';
2
+
3
+ export type ReactNode = any;
4
+ export interface ReactElement<P = any, T = any> { type?: T; tag?: any; props: P; children?: ReactNode[]; key?: string | number | null; _vnode?: true; }
5
+ export type FC<P = {}> = FunctionComponent<P>;
6
+ export type FunctionComponent<P = {}> = (props: P & { children?: ReactNode }) => ReactNode;
7
+ export type ComponentType<P = {}> = FunctionComponent<P> | ComponentClass<P>;
8
+ export type ElementType<P = any> = string | ComponentType<P>;
9
+ export type RefObject<T> = { current: T | null };
10
+ export type MutableRefObject<T> = { current: T };
11
+ export type RefCallback<T> = (instance: T | null) => void;
12
+ export type Ref<T> = RefCallback<T> | RefObject<T> | null;
13
+ export type ForwardedRef<T> = Ref<T>;
14
+ export type DependencyList = readonly unknown[];
15
+ export type Dispatch<A> = (value: A) => void;
16
+ export type SetStateAction<S> = S | ((prevState: S) => S);
17
+ export type Reducer<S, A> = (prevState: S, action: A) => S;
18
+ export type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
19
+ export type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
20
+ export type Context<T> = WhatContext<T>;
21
+
22
+ export const Fragment: typeof import('what-core').Fragment;
23
+ export const Suspense: typeof import('what-core').Suspense;
24
+ export const memo: typeof import('what-core').memo;
25
+ export const lazy: typeof import('what-core').lazy;
26
+
27
+ export function createElement<P = any>(type: ElementType<P>, props?: (P & { children?: ReactNode; key?: string | number; ref?: any }) | null, ...children: ReactNode[]): ReactElement<P>;
28
+ export function cloneElement<P = any>(element: ReactElement<P>, props?: Partial<P> | null, ...children: ReactNode[]): ReactElement<P>;
29
+ export function createFactory<P = any>(type: ElementType<P>): ((props?: P | null, ...children: ReactNode[]) => ReactElement<P>) & { type: ElementType<P> };
30
+ export function isValidElement(object: unknown): object is ReactElement;
31
+ export function createRef<T = any>(): RefObject<T>;
32
+ export function forwardRef<T, P = {}>(render: (props: P, ref: ForwardedRef<T>) => ReactNode): FunctionComponent<P & { ref?: Ref<T> }> & { displayName?: string };
33
+
34
+ export const Children: {
35
+ map<T = ReactNode, R = any>(children: ReactNode, fn: (child: T, index: number) => R): R[];
36
+ forEach<T = ReactNode>(children: ReactNode, fn: (child: T, index: number) => void): void;
37
+ count(children: ReactNode): number;
38
+ toArray(children: ReactNode): ReactNode[];
39
+ only<T = ReactNode>(children: T): T;
40
+ };
41
+
42
+ export function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
43
+ export function useEffect(effect: () => void | (() => void), deps?: DependencyList): void;
44
+ export function useMemo<T>(factory: () => T, deps?: DependencyList): T;
45
+ export function useCallback<T extends (...args: any[]) => any>(callback: T, deps?: DependencyList): T;
46
+ export function useRef<T>(initialValue: T): MutableRefObject<T>;
47
+ export function useRef<T = undefined>(): MutableRefObject<T | undefined>;
48
+ export function useContext<T>(context: Context<T>): T;
49
+ export function useReducer<R extends Reducer<any, any>>(reducer: R, initialState: ReducerState<R>, init?: (initial: ReducerState<R>) => ReducerState<R>): [ReducerState<R>, Dispatch<ReducerAction<R>>];
50
+ export function createContext<T>(defaultValue: T): Context<T>;
51
+ export function useLayoutEffect(effect: () => void | (() => void), deps?: DependencyList): void;
52
+ export function useInsertionEffect(effect: () => void | (() => void), deps?: DependencyList): void;
53
+ export function useImperativeHandle<T, R extends T>(ref: Ref<T> | undefined, createHandle: () => R, deps?: DependencyList): void;
54
+ export function useId(): string;
55
+ export function useDebugValue<T>(value?: T, format?: (value: T) => any): void;
56
+ export function useSyncExternalStore<T>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T;
57
+ export function useTransition(): [boolean, (callback: () => void) => void];
58
+ export function useDeferredValue<T>(value: T): T;
59
+ export function startTransition(callback: () => void): void;
60
+
61
+ export function StrictMode(props: { children?: ReactNode }): ReactNode;
62
+
63
+ export interface ComponentClass<P = {}, S = any> {
64
+ new (props: P): Component<P, S>;
65
+ displayName?: string;
66
+ defaultProps?: Partial<P>;
67
+ contextType?: Context<any>;
68
+ getDerivedStateFromProps?: (props: P, state: S) => Partial<S> | null;
69
+ }
70
+
71
+ export class Component<P = {}, S = {}> {
72
+ constructor(props: P);
73
+ props: P;
74
+ state: S;
75
+ context?: any;
76
+ setState(update: Partial<S> | ((state: S, props: P) => Partial<S>), callback?: () => void): void;
77
+ forceUpdate(callback?: () => void): void;
78
+ render(): ReactNode;
79
+ componentDidMount?(): void;
80
+ componentWillUnmount?(): void;
81
+ componentDidUpdate?(prevProps: P, prevState: S, snapshot?: any): void;
82
+ getSnapshotBeforeUpdate?(prevProps: P, prevState: S): any;
83
+ static displayName?: string;
84
+ static defaultProps?: Record<string, any>;
85
+ static contextType?: Context<any>;
86
+ static getDerivedStateFromProps?: (props: any, state: any) => any;
87
+ }
88
+
89
+ export class PureComponent<P = {}, S = {}> extends Component<P, S> {}
90
+
91
+ export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: Record<string, any>;
92
+
93
+ declare const React: {
94
+ createElement: typeof createElement;
95
+ cloneElement: typeof cloneElement;
96
+ createFactory: typeof createFactory;
97
+ isValidElement: typeof isValidElement;
98
+ createRef: typeof createRef;
99
+ forwardRef: typeof forwardRef;
100
+ Children: typeof Children;
101
+ Fragment: typeof Fragment;
102
+ Suspense: typeof Suspense;
103
+ StrictMode: typeof StrictMode;
104
+ Component: typeof Component;
105
+ PureComponent: typeof PureComponent;
106
+ memo: typeof memo;
107
+ lazy: typeof lazy;
108
+ useState: typeof useState;
109
+ useEffect: typeof useEffect;
110
+ useMemo: typeof useMemo;
111
+ useCallback: typeof useCallback;
112
+ useRef: typeof useRef;
113
+ useContext: typeof useContext;
114
+ useReducer: typeof useReducer;
115
+ createContext: typeof createContext;
116
+ useLayoutEffect: typeof useLayoutEffect;
117
+ useInsertionEffect: typeof useInsertionEffect;
118
+ useImperativeHandle: typeof useImperativeHandle;
119
+ useId: typeof useId;
120
+ useDebugValue: typeof useDebugValue;
121
+ useSyncExternalStore: typeof useSyncExternalStore;
122
+ useTransition: typeof useTransition;
123
+ useDeferredValue: typeof useDeferredValue;
124
+ startTransition: typeof startTransition;
125
+ };
126
+
127
+ export default React;
@@ -0,0 +1,2 @@
1
+ export { jsx, jsxs, jsxDEV, Fragment } from './jsx-runtime.js';
2
+ export type { JSX } from './jsx-runtime.js';
@@ -0,0 +1,13 @@
1
+ import type { ReactElement, ReactNode } from './index.js';
2
+ export { Fragment } from './index.js';
3
+
4
+ export function jsx(type: any, props: any, key?: string | number): ReactElement;
5
+ export function jsxs(type: any, props: any, key?: string | number): ReactElement;
6
+ export function jsxDEV(type: any, props: any, key?: string | number, isStaticChildren?: boolean, source?: any, self?: any): ReactElement;
7
+
8
+ export namespace JSX {
9
+ type Element = ReactElement;
10
+ interface ElementChildrenAttribute { children: {}; }
11
+ interface IntrinsicElements { [elemName: string]: any; }
12
+ interface IntrinsicAttributes { key?: string | number; children?: ReactNode; ref?: any; }
13
+ }
package/package.json CHANGED
@@ -1,18 +1,43 @@
1
1
  {
2
2
  "name": "what-react",
3
- "version": "0.6.2",
4
- "description": "React compatibility layer for What Framework use React packages with signals under the hood",
3
+ "version": "0.6.5",
4
+ "description": "React compatibility layer for What Framework \u2014 use React packages with signals under the hood",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
- ".": "./src/index.js",
9
- "./dom": "./src/dom.js",
10
- "./jsx-runtime": "./src/jsx-runtime.js",
11
- "./jsx-dev-runtime": "./src/jsx-dev-runtime.js",
12
- "./vite": "./src/vite-plugin.js"
8
+ ".": {
9
+ "types": "./index.d.ts",
10
+ "import": "./src/index.js"
11
+ },
12
+ "./dom": {
13
+ "types": "./dom.d.ts",
14
+ "import": "./src/dom.js"
15
+ },
16
+ "./jsx-runtime": {
17
+ "types": "./jsx-runtime.d.ts",
18
+ "import": "./src/jsx-runtime.js"
19
+ },
20
+ "./jsx-dev-runtime": {
21
+ "types": "./jsx-dev-runtime.d.ts",
22
+ "import": "./src/jsx-dev-runtime.js"
23
+ },
24
+ "./vite": {
25
+ "types": "./vite.d.ts",
26
+ "import": "./src/vite-plugin.js"
27
+ },
28
+ "./use-sync-external-store-with-selector": {
29
+ "types": "./use-sync-external-store-with-selector.d.ts",
30
+ "import": "./src/use-sync-external-store-with-selector.js"
31
+ }
13
32
  },
14
33
  "files": [
15
- "src"
34
+ "src",
35
+ "index.d.ts",
36
+ "dom.d.ts",
37
+ "jsx-runtime.d.ts",
38
+ "jsx-dev-runtime.d.ts",
39
+ "vite.d.ts",
40
+ "use-sync-external-store-with-selector.d.ts"
16
41
  ],
17
42
  "keywords": [
18
43
  "react",
@@ -23,7 +48,7 @@
23
48
  "compatibility"
24
49
  ],
25
50
  "peerDependencies": {
26
- "what-core": "^0.6.2"
51
+ "what-core": "^0.6.5"
27
52
  },
28
53
  "author": "ZVN DEV (https://zvndev.com)",
29
54
  "license": "MIT",
@@ -34,5 +59,6 @@
34
59
  "bugs": {
35
60
  "url": "https://github.com/CelsianJs/what-framework/issues"
36
61
  },
37
- "homepage": "https://react.whatfw.com"
62
+ "homepage": "https://react.whatfw.com",
63
+ "types": "index.d.ts"
38
64
  }
@@ -0,0 +1,7 @@
1
+ export function useSyncExternalStoreWithSelector<Snapshot, Selection>(
2
+ subscribe: (onStoreChange: () => void) => () => void,
3
+ getSnapshot: () => Snapshot,
4
+ getServerSnapshot: (() => Snapshot) | undefined,
5
+ selector: (snapshot: Snapshot) => Selection,
6
+ isEqual?: (a: Selection, b: Selection) => boolean,
7
+ ): Selection;
package/vite.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export type Plugin = any;
2
+
3
+ export interface ReactCompatOptions {
4
+ exclude?: string[];
5
+ autoDetect?: boolean;
6
+ }
7
+
8
+ export function reactCompat(options?: ReactCompatOptions): Plugin;