@react-motion-router/core 1.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.
@@ -0,0 +1,76 @@
1
+ import React from 'react';
2
+ import NavigationBase, { NavigateEvent, BackEvent } from './NavigationBase';
3
+ import { AnimationConfig, AnimationKeyframeEffectConfig, ReducedAnimationConfigSet, SwipeDirection, ScreenChild, PlainObject, RouterEventMap } from './common/types';
4
+ import RouterData, { RoutesData } from './RouterData';
5
+ import AnimationLayerData from './AnimationLayerData';
6
+ import { PageAnimationEndEvent } from './MotionEvents';
7
+ interface Config {
8
+ animation?: ReducedAnimationConfigSet | AnimationConfig | AnimationKeyframeEffectConfig;
9
+ defaultRoute?: string;
10
+ swipeAreaWidth?: number;
11
+ minFlingVelocity?: number;
12
+ hysteresis?: number;
13
+ basePathname?: string;
14
+ disableDiscovery?: boolean;
15
+ swipeDirection?: SwipeDirection;
16
+ disableBrowserRouting?: boolean;
17
+ paramsSerializer?(params: PlainObject): string;
18
+ paramsDeserializer?(queryString: string): PlainObject;
19
+ }
20
+ export interface RouterBaseProps {
21
+ id?: string;
22
+ config: Config;
23
+ children: ScreenChild | ScreenChild[];
24
+ }
25
+ export interface RouterBaseState {
26
+ currentPath: string;
27
+ backNavigating: boolean;
28
+ gestureNavigating: boolean;
29
+ routesData: RoutesData;
30
+ implicitBack: boolean;
31
+ defaultDocumentTitle: string;
32
+ }
33
+ export default abstract class RouterBase<P extends RouterBaseProps = RouterBaseProps, S extends RouterBaseState = RouterBaseState> extends React.Component<P, S> {
34
+ private readonly _id;
35
+ protected readonly animationLayerData: AnimationLayerData;
36
+ protected ref: HTMLElement | null;
37
+ protected abstract _routerData: RouterData;
38
+ protected config: Config;
39
+ protected dispatchEvent: ((event: Event) => Promise<boolean>) | null;
40
+ protected addEventListener: (<K extends keyof RouterEventMap>(type: K, listener: (this: HTMLElement, ev: RouterEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined) => void) | null;
41
+ protected removeEventListener: (<K extends keyof RouterEventMap>(type: K, listener: (this: HTMLElement, ev: RouterEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined) => void) | null;
42
+ static defaultProps: {
43
+ config: {
44
+ animation: {
45
+ in: {
46
+ type: string;
47
+ duration: number;
48
+ };
49
+ };
50
+ };
51
+ };
52
+ constructor(props: RouterBaseProps);
53
+ state: S;
54
+ componentDidMount(): void;
55
+ componentWillUnmount(): void;
56
+ /**
57
+ * Initialises current path and routes data from URL search params.
58
+ */
59
+ protected initialise(navigation: NavigationBase): void;
60
+ get id(): string;
61
+ protected get parentRouterData(): RouterData<NavigationBase> | null;
62
+ protected get baseURL(): URL;
63
+ protected abstract get navigation(): NavigationBase;
64
+ abstract onAnimationEnd: (e: PageAnimationEndEvent) => void;
65
+ abstract onGestureNavigationStart: () => void;
66
+ abstract onGestureNavigationEnd: () => void;
67
+ abstract onPopStateListener: (e: Event) => void;
68
+ abstract onBackListener: (e: BackEvent) => void;
69
+ abstract onNavigateListener: (e: NavigateEvent) => void;
70
+ onDocumentTitleChange: (title: string | null) => void;
71
+ addNavigationEventListeners(ref: HTMLElement): void;
72
+ removeNavigationEventListeners(ref: HTMLElement): void;
73
+ private setRef;
74
+ render(): JSX.Element;
75
+ }
76
+ export {};
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { ScreenBase } from '.';
3
+ import { AnimationConfigSet, PlainObject, RouterEventMap } from './common/types';
4
+ import GhostLayer from './GhostLayer';
5
+ import NavigationBase from './NavigationBase';
6
+ import RouterBase from './RouterBase';
7
+ import { ScrollRestorationData } from './ScrollRestorationData';
8
+ export type RoutesData = Map<string | undefined, PlainObject>;
9
+ export default class RouterData<N extends NavigationBase = NavigationBase> {
10
+ private routerInstance;
11
+ private _parentRouterData;
12
+ private _childRouterData;
13
+ private _dispatchEvent;
14
+ private _addEventListener;
15
+ private _removeEventListener;
16
+ private _currentPath;
17
+ private _routesData;
18
+ private static _scrollRestorationData;
19
+ private _navigation?;
20
+ private _backNavigating;
21
+ private _gestureNavigating;
22
+ private _paramsSerializer?;
23
+ private _paramsDeserializer?;
24
+ private _mountedScreen;
25
+ private _animation;
26
+ private _ghostLayer;
27
+ constructor(routerInstance: RouterBase, navigation?: N);
28
+ destructor(): void;
29
+ prefetchRoute(path: string): Promise<boolean>;
30
+ set parentRouterData(parentRouterData: RouterData<NavigationBase> | null);
31
+ set childRouterData(childRouterData: RouterData<NavigationBase> | null);
32
+ set dispatchEvent(_dispatchEvent: ((event: Event) => Promise<boolean>) | null);
33
+ set addEventListener(_addEventListener: (<K extends keyof RouterEventMap>(type: K, listener: (this: HTMLElement, ev: RouterEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined) => void) | null);
34
+ set removeEventListener(_removeEventListener: (<K extends keyof RouterEventMap>(type: K, listener: (this: HTMLElement, ev: RouterEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined) => void) | null);
35
+ set currentPath(_currentPath: string);
36
+ set routesData(_routesData: RoutesData);
37
+ set navigation(_navigation: N);
38
+ set animation(_animation: AnimationConfigSet);
39
+ set ghostLayer(_ghostLayer: GhostLayer | null);
40
+ set backNavigating(_backNavigating: boolean);
41
+ set gestureNavigating(_gestureNavigating: boolean);
42
+ set paramsSerializer(_paramsSerializer: ((params: PlainObject) => string) | undefined);
43
+ set paramsDeserializer(_paramsDeserializer: ((queryString: string) => PlainObject) | undefined);
44
+ set mountedScreen(_mountedScreen: ScreenBase | null);
45
+ get mountedScreen(): ScreenBase | null;
46
+ get routerId(): string;
47
+ get routes(): import(".").ScreenChild<import("./ScreenBase").ScreenBaseProps, typeof ScreenBase> | import(".").ScreenChild<import("./ScreenBase").ScreenBaseProps, typeof ScreenBase>[];
48
+ get parentRouterData(): RouterData<NavigationBase> | null;
49
+ get childRouterData(): RouterData<NavigationBase> | null;
50
+ get dispatchEvent(): ((event: Event) => Promise<boolean>) | null;
51
+ get addEventListener(): (<K extends keyof RouterEventMap>(type: K, listener: (this: HTMLElement, ev: RouterEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined) => void) | null;
52
+ get removeEventListener(): (<K extends keyof RouterEventMap>(type: K, listener: (this: HTMLElement, ev: RouterEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined) => void) | null;
53
+ get currentPath(): string;
54
+ get routesData(): RoutesData;
55
+ get scrollRestorationData(): ScrollRestorationData;
56
+ get navigation(): N;
57
+ get animation(): AnimationConfigSet;
58
+ get ghostLayer(): GhostLayer | null;
59
+ get backNavigating(): boolean;
60
+ get gestureNavigating(): boolean;
61
+ get paramsSerializer(): ((params: PlainObject) => string) | undefined;
62
+ get paramsDeserializer(): ((queryString: string) => PlainObject) | undefined;
63
+ }
64
+ export declare const RouterDataContext: React.Context<RouterData<NavigationBase> | null>;
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { AnimationConfig, AnimationConfigFactory, AnimationConfigSet, AnimationKeyframeEffectConfig, LazyExoticComponent, PlainObject, ReducedAnimationConfigSet, SwipeDirection } from "./common/types";
3
+ import { RouterDataContext } from "./RouterData";
4
+ export interface ScreenBaseProps {
5
+ out?: boolean;
6
+ in?: boolean;
7
+ component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
8
+ fallback?: React.ReactNode;
9
+ path?: string;
10
+ resolvedPathname?: string;
11
+ defaultParams?: PlainObject;
12
+ name?: string;
13
+ config?: {
14
+ animation?: ReducedAnimationConfigSet | AnimationConfig | AnimationKeyframeEffectConfig | AnimationConfigFactory;
15
+ pseudoElement?: {
16
+ selector: string;
17
+ animation?: ReducedAnimationConfigSet | AnimationConfig | AnimationKeyframeEffectConfig | AnimationConfigFactory;
18
+ };
19
+ keepAlive?: boolean;
20
+ swipeDirection?: SwipeDirection;
21
+ swipeAreaWidth?: number;
22
+ minFlingVelocity?: number;
23
+ hysteresis?: number;
24
+ disableDiscovery?: boolean;
25
+ };
26
+ }
27
+ export interface ScreenBaseState {
28
+ fallback?: React.ReactNode;
29
+ shouldKeepAlive: boolean;
30
+ }
31
+ export default abstract class ScreenBase<P extends ScreenBaseProps = ScreenBaseProps, S extends ScreenBaseState = ScreenBaseState> extends React.Component<P, S> {
32
+ private name;
33
+ private sharedElementScene;
34
+ private ref;
35
+ private contextParams;
36
+ private onRef;
37
+ private animation;
38
+ private pseudoElementAnimation;
39
+ static contextType: React.Context<import("./RouterData").default<import("./NavigationBase").default> | null>;
40
+ context: React.ContextType<typeof RouterDataContext>;
41
+ static defaultProps: {
42
+ route: {
43
+ params: {};
44
+ };
45
+ };
46
+ state: S;
47
+ componentDidMount(): void;
48
+ shouldComponentUpdate(nextProps: P): boolean;
49
+ componentDidUpdate(prevProps: P): void;
50
+ setupAnimation(animation?: ReducedAnimationConfigSet | AnimationConfig | AnimationKeyframeEffectConfig | AnimationConfigFactory): (() => AnimationConfigSet) | {
51
+ in: (AnimationConfig | AnimationKeyframeEffectConfig | undefined) & (AnimationConfig | AnimationKeyframeEffectConfig);
52
+ out: (AnimationConfig | AnimationKeyframeEffectConfig | undefined) & (AnimationConfig | AnimationKeyframeEffectConfig);
53
+ } | null;
54
+ animationFactory(animation?: AnimationKeyframeEffectConfig | AnimationConfig | ReducedAnimationConfigSet | AnimationConfigFactory): AnimationConfigSet;
55
+ onExit: () => void;
56
+ onEnter: () => void;
57
+ private setTransforms;
58
+ private setRef;
59
+ get resolvedPathname(): P["resolvedPathname"] | undefined;
60
+ render(): JSX.Element;
61
+ }
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ interface ScrollRestorationProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ id: string;
4
+ children: JSX.Element;
5
+ hashScrollConfig?: ScrollIntoViewOptions;
6
+ shouldRestore?: boolean;
7
+ }
8
+ export default class ScrollRestoration extends React.Component<ScrollRestorationProps> {
9
+ private ref;
10
+ private scrollPos;
11
+ private routerData;
12
+ private _mounted;
13
+ constructor(props: ScrollRestorationProps);
14
+ componentDidMount(): void;
15
+ componentWillUnmount(): void;
16
+ onPageAnimationEnd: () => void;
17
+ onHashChange: () => void;
18
+ setRef: (ref: HTMLElement | null) => void;
19
+ get scrollTop(): number;
20
+ get scrollLeft(): number;
21
+ get scrollWidth(): number;
22
+ get scrollHeight(): number;
23
+ render(): JSX.Element;
24
+ }
25
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Vec2 } from "./common/types";
2
+ export declare class ScrollRestorationData {
3
+ private _map;
4
+ set(key: string, scrollPos?: Vec2): void;
5
+ get(key: string): Vec2 | undefined;
6
+ }
@@ -0,0 +1,141 @@
1
+ import React from 'react';
2
+ import { EasingFunction, PlainObject, Vec2 } from './common/types';
3
+ declare enum TransformOriginKeywordEnum {
4
+ center = 0,
5
+ top = 1,
6
+ bottom = 2,
7
+ left = 3,
8
+ right = 4
9
+ }
10
+ declare enum TransformOriginLengthUnitEnum {
11
+ cap = 0,
12
+ ch = 1,
13
+ em = 2,
14
+ ex = 3,
15
+ ic = 4,
16
+ lh = 5,
17
+ rem = 6,
18
+ rlh = 7,
19
+ vh = 8,
20
+ vw = 9,
21
+ vi = 10,
22
+ vb = 11,
23
+ vmin = 12,
24
+ vmax = 13,
25
+ px = 14,
26
+ cm = 15,
27
+ mm = 16,
28
+ Q = 17,
29
+ in = 18,
30
+ pc = 19,
31
+ pt = 20,
32
+ '%' = 21
33
+ }
34
+ declare enum TransformOriginGlobalEnum {
35
+ inital = 0,
36
+ inherit = 1,
37
+ revert = 2,
38
+ unset = 3
39
+ }
40
+ declare enum TransitionAnimationEnum {
41
+ "morph" = 0,
42
+ "fade-through" = 1,
43
+ "fade" = 2,
44
+ "cross-fade" = 3
45
+ }
46
+ type TransitionAnimation = keyof typeof TransitionAnimationEnum;
47
+ type TransformOriginGlobal = keyof typeof TransformOriginGlobalEnum;
48
+ type TransformOriginLengthUnit = keyof typeof TransformOriginLengthUnitEnum;
49
+ type TransformOriginLength = `${number}${TransformOriginLengthUnit}` | 0;
50
+ type TransformOriginKeyword = keyof typeof TransformOriginKeywordEnum;
51
+ type OneValueTransformOrigin = TransformOriginKeyword | TransformOriginLength;
52
+ type TwoValueTransformOrigin = `${OneValueTransformOrigin} ${OneValueTransformOrigin}`;
53
+ type ThreeValueTransformOrigin = `${OneValueTransformOrigin} ${OneValueTransformOrigin} ${TransformOriginLength}`;
54
+ type TransformOrigin = TransformOriginGlobal | OneValueTransformOrigin | TwoValueTransformOrigin | ThreeValueTransformOrigin;
55
+ export interface SharedElementNode {
56
+ id: string;
57
+ instance: SharedElement;
58
+ }
59
+ export type SharedElementNodeMap = Map<string, SharedElementNode>;
60
+ export declare class SharedElementScene {
61
+ private _nodes;
62
+ private _name;
63
+ private _scrollPos;
64
+ private _x;
65
+ private _y;
66
+ private _xRatio;
67
+ private _yRatio;
68
+ private _keepAlive;
69
+ constructor(name: string);
70
+ addNode(node: SharedElementNode | null): void;
71
+ removeNode(_id: string): void;
72
+ get xRatio(): number;
73
+ get yRatio(): number;
74
+ get nodes(): SharedElementNodeMap;
75
+ get name(): string;
76
+ get scrollPos(): Vec2;
77
+ get x(): number;
78
+ get y(): number;
79
+ get keepAlive(): boolean;
80
+ set scrollPos(_scrollPos: Vec2);
81
+ set x(_x: number);
82
+ set y(_y: number);
83
+ set xRatio(_xRatio: number);
84
+ set yRatio(_yRatio: number);
85
+ set keepAlive(_keepAlive: boolean);
86
+ isEmpty(): boolean;
87
+ }
88
+ export declare const SharedElementSceneContext: React.Context<SharedElementScene | null>;
89
+ interface SharedElementConfig {
90
+ type?: TransitionAnimation;
91
+ transformOrigin?: TransformOrigin;
92
+ easingFunction?: EasingFunction;
93
+ duration?: number;
94
+ delay?: number;
95
+ x?: {
96
+ delay?: number;
97
+ duration?: number;
98
+ easingFunction?: EasingFunction;
99
+ };
100
+ y?: {
101
+ delay?: number;
102
+ duration?: number;
103
+ easingFunction?: EasingFunction;
104
+ };
105
+ }
106
+ interface SharedElementProps {
107
+ id: string | number;
108
+ children: React.ReactChild;
109
+ config?: SharedElementConfig;
110
+ }
111
+ interface SharedElementState {
112
+ hidden: boolean;
113
+ keepAlive: boolean;
114
+ }
115
+ export declare class SharedElement extends React.Component<SharedElementProps, SharedElementState> {
116
+ private _id;
117
+ private _ref;
118
+ private _scene;
119
+ private _mutationObserver;
120
+ private _callbackID;
121
+ private _computedStyle;
122
+ private _isMounted;
123
+ private onRef;
124
+ state: SharedElementState;
125
+ get scene(): SharedElementScene | null;
126
+ get node(): HTMLElement | null;
127
+ get clientRect(): DOMRect;
128
+ get CSSData(): [string, PlainObject<string>];
129
+ get CSSText(): string;
130
+ get id(): string;
131
+ get transitionType(): "fade" | "morph" | "fade-through" | "cross-fade" | undefined;
132
+ keepAlive(_keepAlive: boolean): Promise<void>;
133
+ hidden(_hidden: boolean): Promise<void>;
134
+ private setRef;
135
+ updateScene(): void;
136
+ componentDidMount(): void;
137
+ componentDidUpdate(): void;
138
+ componentWillUnmount(): void;
139
+ render(): JSX.Element;
140
+ }
141
+ export {};
@@ -0,0 +1,4 @@
1
+ import { NavigationBase } from "..";
2
+ export declare function useReducedMotion(): boolean;
3
+ export declare function useNavigation<T extends NavigationBase = NavigationBase>(): NavigationBase;
4
+ export declare function useMotion(): number;
@@ -0,0 +1,80 @@
1
+ /// <reference types="react" />
2
+ import NavigationBase from '../NavigationBase';
3
+ import ScreenBase, { ScreenBaseProps } from '../ScreenBase';
4
+ export type ScreenChild<P extends ScreenBaseProps = ScreenBaseProps, E extends typeof ScreenBase = typeof ScreenBase> = React.ReactElement<P, React.JSXElementConstructor<E>>;
5
+ declare enum AnimationDirectionEnum {
6
+ up = 0,
7
+ down = 1,
8
+ left = 2,
9
+ right = 3,
10
+ in = 4,
11
+ out = 5
12
+ }
13
+ declare enum AnimationTypeEnum {
14
+ slide = 0,
15
+ fade = 1,
16
+ zoom = 2,
17
+ none = 3
18
+ }
19
+ declare enum EasingFunctionKeywordEnum {
20
+ "ease" = 0,
21
+ "ease-in" = 1,
22
+ "ease-in-out" = 2,
23
+ "ease-out" = 3,
24
+ "linear" = 4
25
+ }
26
+ export type EasingFunctionKeyword = keyof typeof EasingFunctionKeywordEnum;
27
+ export type EasingFunction = EasingFunctionKeyword | `cubic-bezier(${number},${' ' | ''}${number},${' ' | ''}${number},${' ' | ''}${number})`;
28
+ export type ParamsSerializer = (params: PlainObject) => string;
29
+ export type ParamsDeserializer = (queryString: string) => PlainObject;
30
+ export type AnimationType = keyof typeof AnimationTypeEnum;
31
+ export type AnimationDirection = keyof typeof AnimationDirectionEnum;
32
+ export interface AnimationConfig {
33
+ type: AnimationType;
34
+ direction?: AnimationDirection;
35
+ duration: number;
36
+ easingFunction?: EasingFunction;
37
+ }
38
+ export interface AnimationKeyframeEffectConfig {
39
+ keyframes: Keyframe[] | PropertyIndexedKeyframes | null;
40
+ options?: number | KeyframeEffectOptions;
41
+ }
42
+ export interface AnimationConfigSet {
43
+ in: AnimationConfig | AnimationKeyframeEffectConfig;
44
+ out: AnimationConfig | AnimationKeyframeEffectConfig;
45
+ }
46
+ export type ReducedAnimationConfigSet = Partial<AnimationConfigSet> & Pick<AnimationConfigSet, 'in'>;
47
+ export type AnimationConfigFactory = (currentPath: string, nextPath: string, gestureNavigating: boolean) => AnimationConfig | AnimationKeyframeEffectConfig | ReducedAnimationConfigSet;
48
+ export interface Vec2 {
49
+ x: number;
50
+ y: number;
51
+ }
52
+ export type SwipeDirection = 'up' | 'down' | 'left' | 'right';
53
+ export type Without<T, U> = {
54
+ [P in Exclude<keyof T, keyof U>]?: never;
55
+ };
56
+ export type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
57
+ export type MetaTypeKey = 'http-equiv' | 'name' | 'itemprop' | 'property' | 'charset';
58
+ export type MetaType = [MetaTypeKey, string];
59
+ export type MetaKey = `${MetaTypeKey}=${string}`;
60
+ export type SearchParamsDeserializer = (queryString: string) => PlainObject;
61
+ export type SearchParamsSerializer = (params: PlainObject) => string;
62
+ export interface LazyExoticComponent<T extends React.ComponentType<any>> extends React.LazyExoticComponent<T> {
63
+ preload: () => Promise<{
64
+ default: T;
65
+ }>;
66
+ preloaded: T | undefined;
67
+ }
68
+ export interface ScreenComponentBaseProps<T extends PlainObject = {}, N extends NavigationBase = NavigationBase> {
69
+ route: {
70
+ params: T;
71
+ preloaded: boolean;
72
+ };
73
+ navigation: N;
74
+ orientation: ScreenOrientation;
75
+ }
76
+ export type PlainObject<T = any> = {
77
+ [key: string]: T;
78
+ };
79
+ export type RouterEventMap = Pick<HTMLElementEventMap, "navigate" | "go-back" | "motion-progress" | "motion-progress-start" | "motion-progress-end" | "page-animation-start" | "page-animation-end" | "page-animation-cancel">;
80
+ export {};
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import RouterData from "../RouterData";
3
+ import { LazyExoticComponent, PlainObject, SearchParamsDeserializer, SearchParamsSerializer } from "./types";
4
+ export declare function getCSSData(styles: CSSStyleDeclaration, object?: boolean): [string, PlainObject<string>];
5
+ export declare function getStyleObject(styles: CSSStyleDeclaration): PlainObject<string>;
6
+ export declare function clamp(num: number, min: number, max?: number): number;
7
+ export interface MatchedRoute {
8
+ matchedPathname?: string;
9
+ rest?: string;
10
+ exact: boolean;
11
+ }
12
+ export declare function matchRoute(routeTest: string | undefined, route: string | undefined, baseURL?: string): MatchedRoute | null;
13
+ export declare function includesRoute(routeString: string | undefined, routeTests: (string | undefined)[], baseURL?: string): boolean;
14
+ export declare function dispatchEvent<T>(event: CustomEvent<T> | Event, target?: HTMLElement | EventTarget): Promise<boolean>;
15
+ export declare function concatenateURL(path: string | URL, base: string | URL): URL;
16
+ export declare function defaultSearchParamsToObject(searchPart: string): PlainObject<string> | undefined;
17
+ export declare function searchParamsToObject(searchPart: string, paramsDeserializer: SearchParamsDeserializer | null): PlainObject<any>;
18
+ export declare function searchParamsFromObject(params: {
19
+ [key: string]: any;
20
+ }, paramsSerializer: SearchParamsSerializer | null): string;
21
+ export declare function lazy<T extends React.ComponentType<any>>(factory: () => Promise<{
22
+ default: T;
23
+ }>): LazyExoticComponent<T>;
24
+ /**
25
+ * Searches router data tree for matching screen. Once the screen is found
26
+ * its component is preloaded.
27
+ * @param path
28
+ * @param routerData
29
+ * @returns
30
+ */
31
+ export declare function prefetchRoute(path: string, routerData: RouterData): Promise<boolean>;
@@ -0,0 +1 @@
1
+ var e={689:e=>{e.exports=require("react")}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};(()=>{r.d(n,{Nu:()=>u,Po:()=>d,QN:()=>i,Vo:()=>h,cT:()=>o,e1:()=>c,fJ:()=>p,hR:()=>a,kI:()=>m,r2:()=>l,rL:()=>f,uZ:()=>s});var e=r(689),t=r.n(e);function a(e,t=!0){let r="";const n={};let a=0;for(let o in e){if(a<e.length){const t=e[o];let n=e.getPropertyValue(t);if("visibility"===t)n="visible";r+=`${t}:${n};`}else{if(!t)break;let r=o,a=e[r];if("string"==typeof a&&"cssText"!==r&&!r.includes("webkit")&&!r.includes("grid")){switch(r){case"offset":r="cssOffset";break;case"float":r="cssFloat";break;case"visibility":a="visible"}n[r]=a}}a++}return[r,n]}function o(e){const t={};for(const r in e)if(e[r]&&e[r].length&&"function"!=typeof e[r]){if(/^\d+$/.test(r))continue;if("offset"===r)continue;t[r]=e[r]}return t}function s(e,t,r){return e<t?t:r&&e>r?r:e}function i(e,t,r=window.location.origin){if(void 0===e||void 0===t)return e===t?{exact:!0,matchedPathname:t}:null;const n=new URLPattern(e,r),a=new URL(t,r),o=n.exec(a);let s="",i="";for(let r=0;r<e.length;r++){if(e[r]!==t[r]){i=t.substring(r);break}s+=e[r]}return o?{exact:e===t,matchedPathname:s,rest:i}:null}function c(e,t,r=window.location.origin){return t.some((t=>i(t,e,r)))}function u(e,t=window){return new Promise((r=>{queueMicrotask((()=>r(t.dispatchEvent(e))))}))}function l(e,t){return"string"==typeof t&&(t=new URL(t)),"string"!=typeof e&&(e=e.pathname),e=e.replace(/^\//,""),t.pathname.endsWith("/")||(t=new URL(t.href+"/")),new URL(e,t)}function f(e){const t=new URLSearchParams(decodeURI(e)).entries(),r={};for(const[e,n]of t){let t="";try{t=JSON.parse(n)}catch(e){console.warn("Non JSON serialisable value was passed as URL route param."),t=n}r[e]=t}return Object.keys(r).length?r:void 0}function p(e,t){return(t||f)(e)||{}}function d(e,t){try{return(t||function(e){return new URLSearchParams(e).toString()})(e)}catch(e){console.error(e),console.warn("Non JSON serialisable value was passed as route param to Anchor.")}return""}function h(e){const r=t().lazy(e);return r.preload=()=>{const t=e();return t.then((e=>r.preloaded=e.default)).catch(console.error),t},r}function m(e,r){let n=r;return new Promise(((a,o)=>{let s=!1;for(;n;){const c=n.routes;if(t().Children.forEach(c,(r=>{if(s)return;if(!t().isValidElement(r))return;i(r.props.path,e)&&(s=!0,queueMicrotask((async()=>{if("preload"in r.props.component)try{await r.props.component.preload(),a(s)}catch(e){o(e)}})))})),s)break;n=r.parentRouterData}s||a(!1)}))}})();var a=n.uZ,o=n.r2,s=n.rL,i=n.Nu,c=n.hR,u=n.cT,l=n.e1,f=n.Vo,p=n.QN,d=n.kI,h=n.Po,m=n.fJ;export{a as clamp,o as concatenateURL,s as defaultSearchParamsToObject,i as dispatchEvent,c as getCSSData,u as getStyleObject,l as includesRoute,f as lazy,p as matchRoute,d as prefetchRoute,h as searchParamsFromObject,m as searchParamsToObject};
@@ -0,0 +1,36 @@
1
+ import { ScreenChild, AnimationConfig, AnimationConfigFactory } from './common/types';
2
+ import RouterData from './RouterData';
3
+ import NavigationBase from './NavigationBase';
4
+ import type { BackEvent, BackEventDetail, NavigateEvent, NavigateEventDetail, NavigateOptions, NavigationOptions, GoBackOptions } from './NavigationBase';
5
+ import RouterBase, { RouterBaseProps, RouterBaseState } from './RouterBase';
6
+ import ScreenBase, { ScreenBaseProps, ScreenBaseState } from './ScreenBase';
7
+ import HistoryBase from './HistoryBase';
8
+ import Anchor from './Anchor';
9
+ import { Motion } from './AnimationLayer';
10
+ import type AnimationLayerData from './AnimationLayerData';
11
+ import GestureRegion from './GestureRegion';
12
+ import 'web-gesture-events';
13
+ import { MotionProgressEndEvent, MotionProgressEvent, MotionProgressStartEvent, PageAnimationCancelEvent, PageAnimationEndEvent, PageAnimationStartEvent } from './MotionEvents';
14
+ import ScrollRestoration from './ScrollRestoration';
15
+ import { SharedElement } from './SharedElement';
16
+ interface MotionEventsMap {
17
+ "page-animation-start": PageAnimationStartEvent;
18
+ "page-animation-cancel": PageAnimationCancelEvent;
19
+ "page-animation-end": PageAnimationEndEvent;
20
+ "motion-progress-start": MotionProgressStartEvent;
21
+ "motion-progress": MotionProgressEvent;
22
+ "motion-progress-end": MotionProgressEndEvent;
23
+ "go-back": BackEvent;
24
+ "navigate": NavigateEvent;
25
+ }
26
+ declare global {
27
+ interface GlobalEventHandlersEventMap extends MotionEventsMap {
28
+ }
29
+ }
30
+ export type { AnimationConfig, AnimationConfigFactory, ScreenChild, RouterBaseProps, RouterBaseState, ScreenBaseProps, ScreenBaseState };
31
+ export { SharedElement, Anchor, Motion, GestureRegion, ScrollRestoration };
32
+ export { NavigationBase, HistoryBase, RouterBase, RouterData, ScreenBase };
33
+ export type { MotionProgressEndEvent, MotionProgressEvent, MotionProgressStartEvent, BackEvent, BackEventDetail, NavigateEvent, NavigateEventDetail, NavigateOptions, NavigationOptions, GoBackOptions, AnimationLayerData };
34
+ export * from './common/hooks';
35
+ export * from './common/types';
36
+ export * from './common/utils';