@granite-js/react-native 0.0.1
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 +66 -0
- package/LICENSE +202 -0
- package/README.md +24 -0
- package/bin/cli.js +3 -0
- package/cli.d.ts +1 -0
- package/cli.js +4 -0
- package/config.d.ts +2 -0
- package/config.js +5 -0
- package/dist/app/App/index.android.d.ts +2 -0
- package/dist/app/App/index.ios.d.ts +6 -0
- package/dist/app/Granite.d.ts +60 -0
- package/dist/app/index.d.ts +2 -0
- package/dist/app/registerPage.d.ts +20 -0
- package/dist/async-bridges.d.ts +2 -0
- package/dist/constant-bridges.d.ts +1 -0
- package/dist/dev-entrypoint/index.d.ts +2 -0
- package/dist/event/abstract.d.ts +42 -0
- package/dist/event/index.d.ts +2 -0
- package/dist/event/useGraniteEvent.d.ts +14 -0
- package/dist/impression-area/ImpressionArea.d.ts +231 -0
- package/dist/impression-area/index.d.ts +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/initial-props/InitialProps.d.ts +127 -0
- package/dist/initial-props/index.d.ts +1 -0
- package/dist/intersection-observer/IOContext.d.ts +10 -0
- package/dist/intersection-observer/IOFlatList.d.ts +55 -0
- package/dist/intersection-observer/IOManager.d.ts +24 -0
- package/dist/intersection-observer/IOScrollView.d.ts +59 -0
- package/dist/intersection-observer/InView.d.ts +107 -0
- package/dist/intersection-observer/IntersectionObserver.d.ts +67 -0
- package/dist/intersection-observer/index.d.ts +8 -0
- package/dist/intersection-observer/withIO.d.ts +20 -0
- package/dist/jest/index.d.ts +1 -0
- package/dist/jest/index.js +32 -0
- package/dist/keyboard/KeyboardAboveView.d.ts +40 -0
- package/dist/keyboard/index.d.ts +1 -0
- package/dist/keyboard/useKeyboardAnimatedHeight.d.ts +20 -0
- package/dist/native-event-emitter/eventEmitters/index.d.ts +2 -0
- package/dist/native-event-emitter/eventEmitters/types.d.ts +4 -0
- package/dist/native-event-emitter/eventEmitters/visibilityChanged.d.ts +10 -0
- package/dist/native-event-emitter/index.d.ts +1 -0
- package/dist/native-event-emitter/nativeEventEmitter.d.ts +15 -0
- package/dist/native-modules/core/GraniteCoreModule.d.ts +8 -0
- package/dist/native-modules/index.d.ts +3 -0
- package/dist/native-modules/natives/GraniteModule.d.ts +7 -0
- package/dist/native-modules/natives/closeView.d.ts +21 -0
- package/dist/native-modules/natives/getSchemeUri.d.ts +23 -0
- package/dist/native-modules/natives/index.d.ts +3 -0
- package/dist/native-modules/natives/openURL.d.ts +36 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/useWaitForReturnNavigator.d.ts +39 -0
- package/dist/rn-polyfills/index.d.ts +1 -0
- package/dist/rn-polyfills/symbol-asynciterator/index.d.ts +9 -0
- package/dist/rn-polyfills/url/index.d.ts +1 -0
- package/dist/router/Router.d.ts +59 -0
- package/dist/router/components/BackButton.d.ts +7 -0
- package/dist/router/components/CanGoBackGuard.d.ts +6 -0
- package/dist/router/components/RouterBackButton.d.ts +9 -0
- package/dist/router/components/StackNavigator.d.ts +54 -0
- package/dist/router/constants.d.ts +2 -0
- package/dist/router/createRoute.d.ts +39 -0
- package/dist/router/createRoute.test-d.d.ts +9 -0
- package/dist/router/hooks/useInitialRouteName.d.ts +1 -0
- package/dist/router/hooks/useIsInitialScreen.d.ts +1 -0
- package/dist/router/hooks/useRouterControls.d.ts +11 -0
- package/dist/router/index.d.ts +3 -0
- package/dist/router/types/RequireContext.d.ts +7 -0
- package/dist/router/types/RouteScreen.d.ts +16 -0
- package/dist/router/types/Screen.d.ts +23 -0
- package/dist/router/types/index.d.ts +3 -0
- package/dist/router/types/screen-option.d.ts +4 -0
- package/dist/router/utils/createParentRouteScreenMap.d.ts +8 -0
- package/dist/router/utils/defaultParserParams.d.ts +9 -0
- package/dist/router/utils/index.d.ts +2 -0
- package/dist/router/utils/matchers.d.ts +2 -0
- package/dist/router/utils/mergeParentLayoutScreen.d.ts +18 -0
- package/dist/router/utils/path.d.ts +53 -0
- package/dist/router/utils/screen.d.ts +53 -0
- package/dist/scroll-view-inertial-background/ScrollViewInertialBackground.d.ts +49 -0
- package/dist/scroll-view-inertial-background/index.d.ts +1 -0
- package/dist/types/global.d.ts +18 -0
- package/dist/use-back-event/index.d.ts +1 -0
- package/dist/use-back-event/useBackEvent.d.ts +135 -0
- package/dist/utils/noop.d.ts +1 -0
- package/dist/utils/usePreservedCallback.d.ts +1 -0
- package/dist/visibility/VisibilityProvider.d.ts +27 -0
- package/dist/visibility/index.d.ts +6 -0
- package/dist/visibility/react-navigation/index.d.ts +2 -0
- package/dist/visibility/react-navigation/useIsFocusedSafely.d.ts +20 -0
- package/dist/visibility/react-navigation/useNavigationSafely.d.ts +19 -0
- package/dist/visibility/useIsAppForeground.d.ts +39 -0
- package/dist/visibility/useVisibility.d.ts +35 -0
- package/dist/visibility/useVisibilityChange.d.ts +51 -0
- package/dist/visibility/useVisibilityChanged.d.ts +41 -0
- package/dist/visibility/utils/usePrevious.d.ts +15 -0
- package/jest.d.ts +1 -0
- package/package.json +92 -0
- package/presets.d.ts +1 -0
- package/src/app/App/index.android.tsx +6 -0
- package/src/app/App/index.d.ts +6 -0
- package/src/app/App/index.ios.tsx +13 -0
- package/src/app/Granite.tsx +130 -0
- package/src/app/index.ts +2 -0
- package/src/app/registerPage.ts +29 -0
- package/src/async-bridges.ts +2 -0
- package/src/constant-bridges.ts +1 -0
- package/src/dev-entrypoint/index.tsx +21 -0
- package/src/event/abstract.ts +130 -0
- package/src/event/index.ts +2 -0
- package/src/event/useGraniteEvent.ts +34 -0
- package/src/impression-area/ImpressionArea.tsx +341 -0
- package/src/impression-area/index.ts +1 -0
- package/src/index.ts +19 -0
- package/src/initial-props/InitialProps.ts +144 -0
- package/src/initial-props/index.ts +1 -0
- package/src/intersection-observer/IOContext.ts +16 -0
- package/src/intersection-observer/IOFlatList.ts +72 -0
- package/src/intersection-observer/IOManager.ts +73 -0
- package/src/intersection-observer/IOScrollView.ts +69 -0
- package/src/intersection-observer/InView.tsx +205 -0
- package/src/intersection-observer/IntersectionObserver.ts +212 -0
- package/src/intersection-observer/index.ts +24 -0
- package/src/intersection-observer/withIO.tsx +151 -0
- package/src/jest/index.ts +1 -0
- package/src/keyboard/KeyboardAboveView.tsx +62 -0
- package/src/keyboard/index.ts +1 -0
- package/src/keyboard/useKeyboardAnimatedHeight.tsx +81 -0
- package/src/native-event-emitter/eventEmitters/index.ts +3 -0
- package/src/native-event-emitter/eventEmitters/types.ts +4 -0
- package/src/native-event-emitter/eventEmitters/visibilityChanged.ts +11 -0
- package/src/native-event-emitter/index.ts +1 -0
- package/src/native-event-emitter/nativeEventEmitter.ts +18 -0
- package/src/native-modules/core/GraniteCoreModule.ts +9 -0
- package/src/native-modules/index.ts +3 -0
- package/src/native-modules/natives/GraniteModule.ts +8 -0
- package/src/native-modules/natives/closeView.ts +25 -0
- package/src/native-modules/natives/getSchemeUri.ts +27 -0
- package/src/native-modules/natives/index.ts +3 -0
- package/src/native-modules/natives/openURL.ts +40 -0
- package/src/react/index.ts +1 -0
- package/src/react/useWaitForReturnNavigator.ts +75 -0
- package/src/rn-polyfills/index.ts +7 -0
- package/src/rn-polyfills/symbol-asynciterator/index.ts +15 -0
- package/src/rn-polyfills/url/index.ts +1 -0
- package/src/router/Router.tsx +164 -0
- package/src/router/components/BackButton.tsx +58 -0
- package/src/router/components/CanGoBackGuard.tsx +31 -0
- package/src/router/components/RouterBackButton.tsx +32 -0
- package/src/router/components/StackNavigator.tsx +12 -0
- package/src/router/constants.ts +3 -0
- package/src/router/createRoute.test-d.ts +52 -0
- package/src/router/createRoute.ts +161 -0
- package/src/router/hooks/useInitialRouteName.tsx +22 -0
- package/src/router/hooks/useIsInitialScreen.ts +7 -0
- package/src/router/hooks/useRouterControls.tsx +72 -0
- package/src/router/index.ts +3 -0
- package/src/router/types/RequireContext.ts +7 -0
- package/src/router/types/RouteScreen.ts +17 -0
- package/src/router/types/Screen.tsx +24 -0
- package/src/router/types/index.ts +3 -0
- package/src/router/types/screen-option.ts +23 -0
- package/src/router/utils/createParentRouteScreenMap.spec.ts +166 -0
- package/src/router/utils/createParentRouteScreenMap.ts +136 -0
- package/src/router/utils/defaultParserParams.spec.ts +46 -0
- package/src/router/utils/defaultParserParams.ts +19 -0
- package/src/router/utils/index.ts +2 -0
- package/src/router/utils/matchers.ts +5 -0
- package/src/router/utils/mergeParentLayoutScreen.spec.tsx +112 -0
- package/src/router/utils/mergeParentLayoutScreen.tsx +43 -0
- package/src/router/utils/path.spec.ts +135 -0
- package/src/router/utils/path.ts +105 -0
- package/src/router/utils/screen.tsx +111 -0
- package/src/scroll-view-inertial-background/ScrollViewInertialBackground.tsx +99 -0
- package/src/scroll-view-inertial-background/index.ts +1 -0
- package/src/types/global.ts +31 -0
- package/src/use-back-event/index.ts +1 -0
- package/src/use-back-event/useBackEvent.tsx +260 -0
- package/src/utils/noop.ts +1 -0
- package/src/utils/usePreservedCallback.ts +16 -0
- package/src/visibility/VisibilityProvider.tsx +36 -0
- package/src/visibility/index.ts +6 -0
- package/src/visibility/react-navigation/index.ts +2 -0
- package/src/visibility/react-navigation/useIsFocusedSafely.tsx +58 -0
- package/src/visibility/react-navigation/useNavigationSafely.tsx +30 -0
- package/src/visibility/useIsAppForeground.tsx +73 -0
- package/src/visibility/useVisibility.tsx +54 -0
- package/src/visibility/useVisibilityChange.ts +69 -0
- package/src/visibility/useVisibilityChanged.tsx +69 -0
- package/src/visibility/utils/usePrevious.tsx +24 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { LayoutRectangle, NativeScrollEvent } from 'react-native';
|
|
2
|
+
export interface Root {
|
|
3
|
+
/**
|
|
4
|
+
* NodeHandle of the target component
|
|
5
|
+
*/
|
|
6
|
+
node: any;
|
|
7
|
+
/**
|
|
8
|
+
* Whether horizontal scroll is enabled
|
|
9
|
+
*/
|
|
10
|
+
horizontal: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Scroll event of the target component
|
|
13
|
+
*/
|
|
14
|
+
current: NativeScrollEvent;
|
|
15
|
+
onLayout?: () => void;
|
|
16
|
+
onScroll?: (event: NativeScrollEvent) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface Element {
|
|
19
|
+
inView: boolean;
|
|
20
|
+
intersectionRatio: number;
|
|
21
|
+
layout: LayoutRectangle;
|
|
22
|
+
measureLayout: (node: any, callback: (x: number, y: number, width: number, height: number) => void) => void;
|
|
23
|
+
onLayout?: () => void;
|
|
24
|
+
}
|
|
25
|
+
export interface IntersectionObserverEntry {
|
|
26
|
+
target: Element;
|
|
27
|
+
isIntersecting: boolean;
|
|
28
|
+
intersectionRatio: number;
|
|
29
|
+
}
|
|
30
|
+
export interface RootMargin {
|
|
31
|
+
left?: number;
|
|
32
|
+
right?: number;
|
|
33
|
+
top?: number;
|
|
34
|
+
bottom?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface IntersectionObserverOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Information about the component that wraps the element
|
|
39
|
+
*/
|
|
40
|
+
root: Root;
|
|
41
|
+
rootMargin?: RootMargin;
|
|
42
|
+
threshold?: number | number[];
|
|
43
|
+
}
|
|
44
|
+
export type IntersectionObserverCallback = (entries: IntersectionObserverEntry[]) => void;
|
|
45
|
+
export declare const defaultRootMargin: RootMargin;
|
|
46
|
+
export declare const defaultThreshold = 0;
|
|
47
|
+
/**
|
|
48
|
+
* @kind class
|
|
49
|
+
* @name IntersectionObserver
|
|
50
|
+
* @description
|
|
51
|
+
* IntersectionObserver implemented for React Native environment.
|
|
52
|
+
*
|
|
53
|
+
* @param {IntersectionObserverCallback} callback - Callback function that is called when the visibility state of the target element changes.
|
|
54
|
+
* @param {IntersectionObserverOptions} options - Options object that controls the behavior of IntersectionObserver.
|
|
55
|
+
*/
|
|
56
|
+
declare class IntersectionObserver {
|
|
57
|
+
protected callback: IntersectionObserverCallback;
|
|
58
|
+
protected options: IntersectionObserverOptions;
|
|
59
|
+
protected targets: Element[];
|
|
60
|
+
constructor(callback: IntersectionObserverCallback, options: IntersectionObserverOptions);
|
|
61
|
+
protected measureTarget: (target: Element) => void;
|
|
62
|
+
protected handleLayout: () => void;
|
|
63
|
+
protected handleScroll: () => void;
|
|
64
|
+
observe(target: Element): void;
|
|
65
|
+
unobserve(target: Element): void;
|
|
66
|
+
}
|
|
67
|
+
export default IntersectionObserver;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import IOContext from './IOContext';
|
|
2
|
+
import IOFlatList, { type IOFlatListController, type IOFlatListProps } from './IOFlatList';
|
|
3
|
+
import IOScrollView, { type IOScrollViewController, type IOScrollViewProps } from './IOScrollView';
|
|
4
|
+
import InView, { type InViewProps } from './InView';
|
|
5
|
+
import { type IntersectionObserverEntry, type IntersectionObserverOptions, type RootMargin } from './IntersectionObserver';
|
|
6
|
+
import type { IOComponentProps } from './withIO';
|
|
7
|
+
export type { IntersectionObserverEntry, IntersectionObserverOptions, RootMargin, InViewProps, IOComponentProps, IOFlatListController, IOFlatListProps, IOScrollViewController, IOScrollViewProps, };
|
|
8
|
+
export { InView, IOContext, IOFlatList, IOScrollView };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import { ScrollView } from 'react-native';
|
|
3
|
+
import { RootMargin } from './IntersectionObserver';
|
|
4
|
+
export interface IOComponentProps {
|
|
5
|
+
rootMargin?: RootMargin;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @category Functions
|
|
9
|
+
* @kind function
|
|
10
|
+
* @name withIO
|
|
11
|
+
* @description
|
|
12
|
+
* A Higher-Order Component (HoC) that wraps a component with `IOContext` to enable Intersection Observer functionality.
|
|
13
|
+
*
|
|
14
|
+
* @argument
|
|
15
|
+
* @param {React.ComponentType} [BaseComponent] - Callback function that is called when the component is mounted.
|
|
16
|
+
* @param {string[]} [methods] - List of event handler names from BaseComponent to be bound.
|
|
17
|
+
* @returns {React.ComponentType} - Returns a wrapped component that can use Intersection Observer functionality.
|
|
18
|
+
*/
|
|
19
|
+
declare function withIO<CompProps extends Pick<ComponentProps<typeof ScrollView>, 'horizontal' | 'scrollEventThrottle' | 'onContentSizeChange' | 'onLayout' | 'onScroll'>>(BaseComponent: React.ComponentType<CompProps>, methods: string[]): typeof BaseComponent;
|
|
20
|
+
export default withIO;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setup, config } from '@granite-js/jest';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/jest/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
config: () => import_jest.config,
|
|
24
|
+
setup: () => import_jest.setup
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_jest = require("@granite-js/jest");
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
config,
|
|
31
|
+
setup
|
|
32
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @category UI
|
|
6
|
+
* @name KeyboardAboveView
|
|
7
|
+
* @kind function
|
|
8
|
+
* @description
|
|
9
|
+
* A component that automatically lifts child components above the keyboard when it appears on the screen.
|
|
10
|
+
* It's useful when you want to keep elements like a "Send" button fixed above the keyboard during text input.
|
|
11
|
+
*
|
|
12
|
+
* @param {StyleProp<ViewStyle>} [props.style] - Additional styles can be applied. For example, you can set background color or size.
|
|
13
|
+
* @param {ReactNode} [props.children] - Components to be displayed above the keyboard when it appears. For example, you can include buttons, text input fields, etc.
|
|
14
|
+
* @returns {ReactElement} - Returns an [`Animated.View`](https://reactnative.dev/docs/animated#createanimatedcomponent) that is adjusted above the keyboard when it appears.
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ### Lifting elements above the keyboard
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { ScrollView, TextInput, View, Text } from 'react-native';
|
|
21
|
+
* import { KeyboardAboveView } from '@granite-js/react-native';
|
|
22
|
+
*
|
|
23
|
+
* export function KeyboardAboveViewExample() {
|
|
24
|
+
* return (
|
|
25
|
+
* <>
|
|
26
|
+
* <ScrollView>
|
|
27
|
+
* <TextInput placeholder="placeholder" />
|
|
28
|
+
* </ScrollView>
|
|
29
|
+
*
|
|
30
|
+
* <KeyboardAboveView>
|
|
31
|
+
* <View style={{ width: '100%', height: 50, backgroundColor: 'yellow' }}>
|
|
32
|
+
* <Text>Above the keyboard</Text>
|
|
33
|
+
* </View>
|
|
34
|
+
* </KeyboardAboveView>
|
|
35
|
+
* </>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function KeyboardAboveView({ style, children, ...props }: ComponentProps<typeof View>): ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KeyboardAboveView } from './KeyboardAboveView';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* @category Hooks
|
|
4
|
+
* @name useKeyboardAnimatedHeight
|
|
5
|
+
* @description
|
|
6
|
+
* A Hook that returns an animatable value (`Animated.Value`) representing the keyboard height changes when the keyboard appears or disappears. You can smoothly animate UI elements according to the keyboard height as it rises or falls.
|
|
7
|
+
*
|
|
8
|
+
* This Hook is primarily used on iOS. On Android, it does not detect keyboard height changes and always returns an `Animated.Value` with an initial value of `0`. In other words, animations are not applied in the Android environment.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Animated.Value} - An animation value representing the keyboard height.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const keyboardHeight = useKeyboardAnimatedHeight();
|
|
14
|
+
*
|
|
15
|
+
* <Animated.View style={{ marginBottom: keyboardHeight }}>
|
|
16
|
+
* {children}
|
|
17
|
+
* </Animated.View>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function useKeyboardAnimatedHeight(): Animated.Value;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EventEmitterSchema } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @name VisibilityChangedEventEmitter
|
|
4
|
+
* @kind typedef
|
|
5
|
+
* @platform iOS
|
|
6
|
+
* @description
|
|
7
|
+
* Emits an event when the visibility state of the app changes.
|
|
8
|
+
* Only available on iOS.
|
|
9
|
+
*/
|
|
10
|
+
export type VisibilityChangedEventEmitter = EventEmitterSchema<'visibilityChanged', [boolean]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './nativeEventEmitter';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import { EventEmitters } from './eventEmitters';
|
|
3
|
+
import { EventEmitterSchema } from './eventEmitters/types';
|
|
4
|
+
type MapOf<T> = T extends EventEmitterSchema<infer K, any> ? {
|
|
5
|
+
[key in K]: T;
|
|
6
|
+
} : never;
|
|
7
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
8
|
+
type EventEmittersMap = UnionToIntersection<MapOf<EventEmitters>>;
|
|
9
|
+
type EventKeys = keyof EventEmittersMap;
|
|
10
|
+
type ParamOf<K extends EventKeys> = EventEmittersMap[K]['params'];
|
|
11
|
+
interface EventEmitter {
|
|
12
|
+
addListener<Event extends EventKeys>(event: Event, callback: (...params: ParamOf<Event>) => void): EmitterSubscription;
|
|
13
|
+
}
|
|
14
|
+
export declare const nativeEventEmitter: EventEmitter;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TurboModule } from 'react-native';
|
|
2
|
+
interface GraniteCoreModule extends TurboModule {
|
|
3
|
+
addListener: (eventType: string) => void;
|
|
4
|
+
removeListeners: (count: number) => void;
|
|
5
|
+
importLazy: () => Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare const GraniteCoreModule: GraniteCoreModule;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @category Screen Control
|
|
4
|
+
* @kind function
|
|
5
|
+
* @name closeView
|
|
6
|
+
* @description Function that closes the current screen. It can be used when you want to exit a service by pressing a "Close" button.
|
|
7
|
+
* @returns {Promise<void>}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ### Close screen with close button
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { Button } from 'react-native';
|
|
14
|
+
* import { closeView } from '@granite-js/react-native';
|
|
15
|
+
*
|
|
16
|
+
* function CloseButton() {
|
|
17
|
+
* return <Button title="Close" onPress={closeView} />;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function closeView(): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @name getSchemeUri
|
|
4
|
+
* @category Environment Check
|
|
5
|
+
* @kind function
|
|
6
|
+
* @description Returns the scheme value when first entering the screen. URI changes due to page navigation are not reflected.
|
|
7
|
+
* @returns {string} Returns the scheme value when first entering the screen.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ### Get initial scheme value
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { getSchemeUri } from '@granite-js/react-native';
|
|
14
|
+
* import { Text } from 'react-native';
|
|
15
|
+
*
|
|
16
|
+
* function MyPage() {
|
|
17
|
+
* const schemeUri = getSchemeUri();
|
|
18
|
+
*
|
|
19
|
+
* return <Text>Initial scheme value: {schemeUri}</Text>
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function getSchemeUri(): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @kind function
|
|
4
|
+
* @category Screen Navigation
|
|
5
|
+
*
|
|
6
|
+
* @name openURL
|
|
7
|
+
* @signature
|
|
8
|
+
* ```typescript
|
|
9
|
+
* function openURL(url: string): Promise<any>;
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Opens the specified URL in the device's default browser or related app.
|
|
14
|
+
* This function uses the [`Linking.openURL`](https://reactnative.dev/docs/0.72/linking#openurl) method from `react-native` to open the URL.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} url URL address to open
|
|
17
|
+
* @returns {Promise<any>} Promise that resolves when the URL is successfully opened
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* ### Open external URL
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { openURL } from '@granite-js/react-native';
|
|
25
|
+
* import { Button } from 'react-native';
|
|
26
|
+
*
|
|
27
|
+
* function Page() {
|
|
28
|
+
* const handlePress = () => {
|
|
29
|
+
* openURL('https://google.com');
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* return <Button title="Open Google Website" onPress={handlePress} />;
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function openURL(url: string): Promise<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useWaitForReturnNavigator } from './useWaitForReturnNavigator';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* @category Screen Control
|
|
4
|
+
* @name useWaitForReturnNavigator
|
|
5
|
+
* @description
|
|
6
|
+
* A Hook that helps execute the next code synchronously when returning from a screen transition.
|
|
7
|
+
* Screen navigation uses [@react-navigation/native `useNavigation`'s `navigate`](https://reactnavigation.org/docs/6.x/navigation-prop#navigate).
|
|
8
|
+
*
|
|
9
|
+
* For example, it can be used when you want to log that a user has navigated to another screen and returned.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ### Example of code execution when returning from screen navigation
|
|
13
|
+
*
|
|
14
|
+
* When the **"Navigate"** button is pressed, it navigates to another screen, and logs are created when returning.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { Button } from 'react-native';
|
|
18
|
+
* import { useWaitForReturnNavigator } from '@granite-js/react-native';
|
|
19
|
+
*
|
|
20
|
+
* export function UseWaitForReturnNavigator() {
|
|
21
|
+
* const navigate = useWaitForReturnNavigator();
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <>
|
|
25
|
+
* <Button
|
|
26
|
+
* title="Navigate"
|
|
27
|
+
* onPress={async () => {
|
|
28
|
+
* console.log(1);
|
|
29
|
+
* await navigate('/examples/use-visibility');
|
|
30
|
+
* // This code executes when returning to the screen
|
|
31
|
+
* console.log(2);
|
|
32
|
+
* }}
|
|
33
|
+
* />
|
|
34
|
+
* </>
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function useWaitForReturnNavigator<T extends Record<string, object | undefined>>(): <RouteName extends keyof T>(route: RouteName, params?: T[RouteName]) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setup(): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polyfill for @swc/helpers build compatibility
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/swc-project/swc/blob/v1.4.15/packages/helpers/esm/_async_iterator.js#L3
|
|
5
|
+
*
|
|
6
|
+
* - babel: No runtime issues after build as there is a fallback for `Symbol.asyncIterator`
|
|
7
|
+
* - swc: No fallback for `Symbol.asyncIterator`, so it needs to be defined in advance
|
|
8
|
+
*/
|
|
9
|
+
export declare function setup(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setupURLPolyfill as setup } from 'react-native-url-polyfill';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { NavigationContainer, NavigationContainerRefWithCurrent, ParamListBase, RouteProp } from '@granite-js/native/@react-navigation/native';
|
|
2
|
+
import { NativeStackNavigationOptions } from '@granite-js/native/@react-navigation/native-stack';
|
|
3
|
+
import { ComponentProps, ComponentType, PropsWithChildren, ReactElement } from 'react';
|
|
4
|
+
export type RouterProps = StackNavigatorProps & NavigationContainerProps;
|
|
5
|
+
interface StackNavigatorProps {
|
|
6
|
+
/**
|
|
7
|
+
* @name navigationContainerRef
|
|
8
|
+
* @description
|
|
9
|
+
* You can create and pass a NavigationContainerRef from @react-navigation/native externally. This allows external control of the router.
|
|
10
|
+
*/
|
|
11
|
+
navigationContainerRef?: NavigationContainerRefWithCurrent<any>;
|
|
12
|
+
/**
|
|
13
|
+
* @name defaultScreenOption
|
|
14
|
+
* @description
|
|
15
|
+
* Default options for screens. You can set options to be applied commonly to screens, such as title or headerStyle.
|
|
16
|
+
*/
|
|
17
|
+
defaultScreenOption?: NativeStackNavigationOptions | ((props: {
|
|
18
|
+
route: RouteProp<ParamListBase>;
|
|
19
|
+
navigation: any;
|
|
20
|
+
}) => NativeStackNavigationOptions);
|
|
21
|
+
/**
|
|
22
|
+
* @name screenContainer
|
|
23
|
+
* @description
|
|
24
|
+
* Container component that wraps each Screen component.
|
|
25
|
+
*/
|
|
26
|
+
screenContainer?: ComponentType<PropsWithChildren<any>>;
|
|
27
|
+
}
|
|
28
|
+
type NavigationContainerProps = Pick<ComponentProps<typeof NavigationContainer>, 'ref' | 'documentTitle' | 'fallback' | 'onReady' | 'onUnhandledAction' | 'onStateChange'>;
|
|
29
|
+
/**
|
|
30
|
+
* @category Components
|
|
31
|
+
* @kind function
|
|
32
|
+
* @name Router
|
|
33
|
+
* @description
|
|
34
|
+
* Router component for page navigation in React Native environment.
|
|
35
|
+
* Automatically assigns appropriate paths to screens based on file naming rules in pages/*.
|
|
36
|
+
* Using this component, you can manage screens in a way similar to Next.js's file-based routing.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} prefix Prefix to use when the scheme is executed. For example, to enter 'scheme://my-service/intro', you need to set 'scheme://my-service' as the prefix.
|
|
39
|
+
* @param {RequireContext} context Object containing information about screens for file-based routing.
|
|
40
|
+
* @param {NavigationContainerRefWithCurrent<any>} [navigationContainerRef] You can create and pass a NavigationContainerRef from @react-navigation/native externally. This allows external control of the router.
|
|
41
|
+
* @param {NativeStackNavigationOptions | ((props: { route: RouteProp<ParamListBase>; navigation: any }) => NativeStackNavigationOptions)} [defaultScreenOption] Default options for screens. You can set options to be applied commonly to screens, such as title or headerStyle.
|
|
42
|
+
* @param {boolean} [canGoBack=true] Whether navigation back is possible. Default is true, and when set to true, you can use the back gesture or back button from @react-navigation/native.
|
|
43
|
+
* @param {() => void} [onBack] Callback function called when the user presses the back button or uses the back gesture. For example, you can set it to log when the user presses the back button.
|
|
44
|
+
* @param {ComponentType<{ children: ReactNode }>} [container=Fragment] Container component that wraps the Navigator from @react-navigation/native.
|
|
45
|
+
* @param {NavigationContainerProps} [navigationContainerProps] - You can set props to be passed to NavigationContainer from @react-navigation/native.
|
|
46
|
+
*
|
|
47
|
+
* @returns {ReactElement} - Returns the router component.
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* import { Router } from '@granite-js/react-native';
|
|
51
|
+
* import { context } from '../require.context';
|
|
52
|
+
*
|
|
53
|
+
* function App() {
|
|
54
|
+
* return <Router context={context} prefix={'scheme://testbench'} />;
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function Router({ prefix, context, canGoBack, onBack, container: Container, initialProps, navigationContainerRef, defaultScreenOption, screenContainer, ...navigationContainerProps }: InternalRouterProps & RouterProps): ReactElement;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TouchableOpacityProps } from 'react-native';
|
|
2
|
+
interface BackButtonProps extends TouchableOpacityProps {
|
|
3
|
+
tintColor?: string;
|
|
4
|
+
onPress?: () => void;
|
|
5
|
+
}
|
|
6
|
+
declare function BackButton({ tintColor, onPress }: BackButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { BackButton };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NavigationContainerRefWithCurrent } from '@granite-js/native/@react-navigation/native';
|
|
2
|
+
export type RouterBackButtonProps = {
|
|
3
|
+
onPress?: () => void;
|
|
4
|
+
tintColor?: string;
|
|
5
|
+
canGoBack?: boolean;
|
|
6
|
+
onBack?: () => void;
|
|
7
|
+
navigationContainerRef: NavigationContainerRefWithCurrent<any>;
|
|
8
|
+
};
|
|
9
|
+
export declare function RouterBackButton({ tintColor, canGoBack, onBack, navigationContainerRef }: RouterBackButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const StackNavigator: {
|
|
2
|
+
Navigator: import("react").ComponentType<Omit<import("@react-navigation/routers").DefaultRouterOptions<string> & {
|
|
3
|
+
id?: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
screenListeners?: Partial<{
|
|
6
|
+
transitionStart: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionStart">;
|
|
7
|
+
transitionEnd: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionEnd">;
|
|
8
|
+
focus: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "focus">;
|
|
9
|
+
blur: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "blur">;
|
|
10
|
+
state: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "state">;
|
|
11
|
+
beforeRemove: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "beforeRemove">;
|
|
12
|
+
}> | ((props: {
|
|
13
|
+
route: import("@react-navigation/core").RouteProp<import("@react-navigation/routers").ParamListBase, string>;
|
|
14
|
+
navigation: any;
|
|
15
|
+
}) => Partial<{
|
|
16
|
+
transitionStart: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionStart">;
|
|
17
|
+
transitionEnd: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionEnd">;
|
|
18
|
+
focus: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "focus">;
|
|
19
|
+
blur: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "blur">;
|
|
20
|
+
state: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "state">;
|
|
21
|
+
beforeRemove: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "beforeRemove">;
|
|
22
|
+
}>) | undefined;
|
|
23
|
+
screenOptions?: import("@react-navigation/native-stack").NativeStackNavigationOptions | ((props: {
|
|
24
|
+
route: import("@react-navigation/core").RouteProp<import("@react-navigation/routers").ParamListBase, string>;
|
|
25
|
+
navigation: any;
|
|
26
|
+
}) => import("@react-navigation/native-stack").NativeStackNavigationOptions) | undefined;
|
|
27
|
+
} & import("@react-navigation/routers").StackRouterOptions, "children" | "id" | "initialRouteName" | "screenListeners" | "screenOptions"> & import("@react-navigation/routers").DefaultRouterOptions<string> & {
|
|
28
|
+
id?: string;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
screenListeners?: Partial<{
|
|
31
|
+
transitionStart: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionStart">;
|
|
32
|
+
transitionEnd: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionEnd">;
|
|
33
|
+
focus: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "focus">;
|
|
34
|
+
blur: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "blur">;
|
|
35
|
+
state: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "state">;
|
|
36
|
+
beforeRemove: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "beforeRemove">;
|
|
37
|
+
}> | ((props: {
|
|
38
|
+
route: import("@react-navigation/core").RouteProp<import("@react-navigation/routers").ParamListBase, string>;
|
|
39
|
+
navigation: any;
|
|
40
|
+
}) => Partial<{
|
|
41
|
+
transitionStart: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionStart">;
|
|
42
|
+
transitionEnd: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "transitionEnd">;
|
|
43
|
+
focus: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "focus">;
|
|
44
|
+
blur: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "blur">;
|
|
45
|
+
state: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "state">;
|
|
46
|
+
beforeRemove: import("@react-navigation/core").EventListenerCallback<import("@react-navigation/native-stack").NativeStackNavigationEventMap & import("@react-navigation/core").EventMapCore<import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>>, "beforeRemove">;
|
|
47
|
+
}>) | undefined;
|
|
48
|
+
screenOptions?: import("@react-navigation/native-stack").NativeStackNavigationOptions | ((props: {
|
|
49
|
+
route: import("@react-navigation/core").RouteProp<import("@react-navigation/routers").ParamListBase, string>;
|
|
50
|
+
navigation: any;
|
|
51
|
+
}) => import("@react-navigation/native-stack").NativeStackNavigationOptions) | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
Screen: <RouteName extends string>(_: import("@react-navigation/core").RouteConfig<import("@react-navigation/routers").ParamListBase, RouteName, import("@react-navigation/routers").StackNavigationState<import("@react-navigation/routers").ParamListBase>, import("@react-navigation/native-stack").NativeStackNavigationOptions, import("@react-navigation/native-stack").NativeStackNavigationEventMap>) => null;
|
|
54
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ParamListBase } from '@granite-js/native/@react-navigation/native';
|
|
2
|
+
import { NativeStackNavigationProp } from '@granite-js/native/@react-navigation/native-stack';
|
|
3
|
+
import { defaultParserParams } from './utils/defaultParserParams';
|
|
4
|
+
export interface RouteOptions<T extends Readonly<object | undefined>> {
|
|
5
|
+
parserParams?: (params: Record<string, unknown>) => Record<string, unknown>;
|
|
6
|
+
validateParams?: (params: Readonly<object | undefined>) => T;
|
|
7
|
+
component: React.FC<any>;
|
|
8
|
+
}
|
|
9
|
+
export type NavigationProps = NativeStackNavigationProp<keyof RegisterScreen extends never ? ParamListBase : RegisterScreen>;
|
|
10
|
+
export interface RegisterScreen {
|
|
11
|
+
}
|
|
12
|
+
export declare function useNavigation(): NavigationProps;
|
|
13
|
+
export type RouteHooksOptions<TScreen extends keyof RegisterScreen> = {
|
|
14
|
+
from: TScreen;
|
|
15
|
+
strict?: true;
|
|
16
|
+
} | {
|
|
17
|
+
strict: false;
|
|
18
|
+
from?: never;
|
|
19
|
+
};
|
|
20
|
+
export declare const routeMap: Map<"/test", {
|
|
21
|
+
options: Omit<RouteOptions<any>, "component">;
|
|
22
|
+
component: React.FC<any>;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function useMatchOptions<TScreen extends keyof RegisterScreen>(options: RouteHooksOptions<TScreen>): {
|
|
25
|
+
parserParams: ((params: Record<string, unknown>) => Record<string, unknown>) | typeof defaultParserParams;
|
|
26
|
+
validateParams?: ((params: Readonly<object | undefined>) => any) | undefined;
|
|
27
|
+
} | null;
|
|
28
|
+
export declare function useParams<TScreen extends keyof RegisterScreen>(options: {
|
|
29
|
+
from: TScreen;
|
|
30
|
+
strict?: true;
|
|
31
|
+
}): RegisterScreen[TScreen];
|
|
32
|
+
export declare function useParams(options: {
|
|
33
|
+
strict: false;
|
|
34
|
+
}): Readonly<object | undefined>;
|
|
35
|
+
export declare const createRoute: <T extends Readonly<object | undefined>>(path: keyof RegisterScreen, options: RouteOptions<T>) => {
|
|
36
|
+
_path: "/test";
|
|
37
|
+
useNavigation: typeof useNavigation;
|
|
38
|
+
useParams: () => T;
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useInitialRouteName(prefix: string): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsInitialScreen(): boolean;
|