@ringozz/react-godot 1.0.0-2 → 1.0.0-4
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 +280 -94
- package/package.json +2 -2
- package/src/index.ts +58 -58
- package/src/react-fiber.ts +307 -307
- package/src/react-hooks.ts +22 -22
- package/src/react-jsx.ts +41 -41
- package/src/react-types.ts +36 -36
package/src/react-jsx.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
/**********************************************************************
|
|
2
|
-
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
|
-
***********************************************************************/
|
|
4
|
-
|
|
5
|
-
import { jsxDEV as reactJsxDEV } from 'react/jsx-dev-runtime';
|
|
6
|
-
import type * as ReactJSX from 'react/jsx-runtime';
|
|
7
|
-
import { Fragment, jsx as reactJsx, jsxs as reactJsxs } from 'react/jsx-runtime';
|
|
8
|
-
import type { ComponentProps, Instance } from './react-types.ts';
|
|
9
|
-
import { GodotVar } from '@ringozz/godot/runtime';
|
|
10
|
-
|
|
11
|
-
export function jsx(type: any, props?: any, key?: any) {
|
|
12
|
-
return reactJsx(GodotVar.isPrototypeOf(type) ? type.name : type, props, key);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function jsxs(type: any, props?: any, key?: any) {
|
|
16
|
-
return reactJsxs(GodotVar.isPrototypeOf(type) ? type.name : type, props, key);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function jsxDEV(type: any, props?: any, key?: any, isStatic?: any, source?: any, self?: any) {
|
|
20
|
-
return reactJsxDEV(GodotVar.isPrototypeOf(type) ? type.name : type, props, key, isStatic, source, self);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { Fragment };
|
|
24
|
-
|
|
25
|
-
declare module '@ringozz/react-godot/jsx-runtime' {
|
|
26
|
-
export namespace JSX {
|
|
27
|
-
interface IntrinsicElements extends ReactJSX.JSX.IntrinsicElements { }
|
|
28
|
-
interface Element extends ReactJSX.JSX.Element { }
|
|
29
|
-
|
|
30
|
-
type GodotConstructor = { new(...args: any[]): Instance } & Function;
|
|
31
|
-
|
|
32
|
-
type ElementType =
|
|
33
|
-
| ReactJSX.JSX.ElementType
|
|
34
|
-
| GodotConstructor;
|
|
35
|
-
|
|
36
|
-
type LibraryManagedAttributes<C, P> =
|
|
37
|
-
C extends GodotConstructor
|
|
38
|
-
? ComponentProps<C>
|
|
39
|
-
: ReactJSX.JSX.LibraryManagedAttributes<C, P>;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
|
+
***********************************************************************/
|
|
4
|
+
|
|
5
|
+
import { jsxDEV as reactJsxDEV } from 'react/jsx-dev-runtime';
|
|
6
|
+
import type * as ReactJSX from 'react/jsx-runtime';
|
|
7
|
+
import { Fragment, jsx as reactJsx, jsxs as reactJsxs } from 'react/jsx-runtime';
|
|
8
|
+
import type { ComponentProps, Instance } from './react-types.ts';
|
|
9
|
+
import { GodotVar } from '@ringozz/godot/runtime';
|
|
10
|
+
|
|
11
|
+
export function jsx(type: any, props?: any, key?: any) {
|
|
12
|
+
return reactJsx(GodotVar.isPrototypeOf(type) ? type.name : type, props, key);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function jsxs(type: any, props?: any, key?: any) {
|
|
16
|
+
return reactJsxs(GodotVar.isPrototypeOf(type) ? type.name : type, props, key);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function jsxDEV(type: any, props?: any, key?: any, isStatic?: any, source?: any, self?: any) {
|
|
20
|
+
return reactJsxDEV(GodotVar.isPrototypeOf(type) ? type.name : type, props, key, isStatic, source, self);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { Fragment };
|
|
24
|
+
|
|
25
|
+
declare module '@ringozz/react-godot/jsx-runtime' {
|
|
26
|
+
export namespace JSX {
|
|
27
|
+
interface IntrinsicElements extends ReactJSX.JSX.IntrinsicElements { }
|
|
28
|
+
interface Element extends ReactJSX.JSX.Element { }
|
|
29
|
+
|
|
30
|
+
type GodotConstructor = { new(...args: any[]): Instance } & Function;
|
|
31
|
+
|
|
32
|
+
type ElementType =
|
|
33
|
+
| ReactJSX.JSX.ElementType
|
|
34
|
+
| GodotConstructor;
|
|
35
|
+
|
|
36
|
+
type LibraryManagedAttributes<C, P> =
|
|
37
|
+
C extends GodotConstructor
|
|
38
|
+
? ComponentProps<C>
|
|
39
|
+
: ReactJSX.JSX.LibraryManagedAttributes<C, P>;
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/react-types.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**********************************************************************
|
|
2
|
-
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
|
-
***********************************************************************/
|
|
4
|
-
|
|
5
|
-
import type React from 'react';
|
|
6
|
-
import type { Object } from '@ringozz/godot/Object';
|
|
7
|
-
import type { ValueTypes } from '@ringozz/godot';
|
|
8
|
-
|
|
9
|
-
type FunctionKeys<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
|
|
10
|
-
type Properties<T> = Omit<T, FunctionKeys<T>>;
|
|
11
|
-
type Overwrite<P, O> = Properties<P> & O;
|
|
12
|
-
type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> };
|
|
13
|
-
type ConstructorRepresentation<T = any> = new (...args: any[]) => T;
|
|
14
|
-
|
|
15
|
-
export type Instance = Object;
|
|
16
|
-
|
|
17
|
-
export type InstanceProps<T extends Instance = Instance> = {
|
|
18
|
-
/** An existing instance to render instead of creating a new one. */
|
|
19
|
-
object?: T;
|
|
20
|
-
/** Attaches the element to a named property of the parent instead of adding it as a child. */
|
|
21
|
-
attach?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type ReactProps<P> = React.PropsWithChildren<React.RefAttributes<P>>;
|
|
25
|
-
|
|
26
|
-
type WidenVT<T> = {
|
|
27
|
-
[K in keyof T]: T[K] extends ValueTypes ? T[K] | number[] : T[K];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
|
|
31
|
-
Overwrite<WidenVT<P>, ReactProps<P>>
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
export type ComponentProps<T extends ConstructorRepresentation> = Mutable<
|
|
35
|
-
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>>, 'object'>>
|
|
36
|
-
>;
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
|
+
***********************************************************************/
|
|
4
|
+
|
|
5
|
+
import type React from 'react';
|
|
6
|
+
import type { Object } from '@ringozz/godot/Object';
|
|
7
|
+
import type { ValueTypes } from '@ringozz/godot';
|
|
8
|
+
|
|
9
|
+
type FunctionKeys<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
|
|
10
|
+
type Properties<T> = Omit<T, FunctionKeys<T>>;
|
|
11
|
+
type Overwrite<P, O> = Properties<P> & O;
|
|
12
|
+
type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> };
|
|
13
|
+
type ConstructorRepresentation<T = any> = new (...args: any[]) => T;
|
|
14
|
+
|
|
15
|
+
export type Instance = Object;
|
|
16
|
+
|
|
17
|
+
export type InstanceProps<T extends Instance = Instance> = {
|
|
18
|
+
/** An existing instance to render instead of creating a new one. */
|
|
19
|
+
object?: T;
|
|
20
|
+
/** Attaches the element to a named property of the parent instead of adding it as a child. */
|
|
21
|
+
attach?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type ReactProps<P> = React.PropsWithChildren<React.RefAttributes<P>>;
|
|
25
|
+
|
|
26
|
+
type WidenVT<T> = {
|
|
27
|
+
[K in keyof T]: T[K] extends ValueTypes ? T[K] | number[] : T[K];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
|
|
31
|
+
Overwrite<WidenVT<P>, ReactProps<P>>
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export type ComponentProps<T extends ConstructorRepresentation> = Mutable<
|
|
35
|
+
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>>, 'object'>>
|
|
36
|
+
>;
|