first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
"use strict";
import { useTheme } from '@react-navigation/core';
import * as React from 'react';
import { Platform, Text } from 'react-native';
import { useLinkProps } from "./useLinkProps.js";
/**
* Component to render link to another screen using a path.
* Uses an anchor tag on the web.
*
* @param props.screen Name of the screen to navigate to (e.g. `'Feeds'`).
* @param props.params Params to pass to the screen to navigate to (e.g. `{ sort: 'hot' }`).
* @param props.href Optional absolute path to use for the href (e.g. `/feeds/hot`).
* @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
* @param props.children Child elements to render the content.
*/
export function Link({
screen,
params,
action,
href,
style,
...rest
}) {
const {
colors,
fonts
} = useTheme();
// @ts-expect-error: This is already type-checked by the prop types
const props = useLinkProps({
screen,
params,
action,
href
});
const onPress = e => {
if ('onPress' in rest) {
rest.onPress?.(e);
}
// Let user prevent default behavior
if (!e.defaultPrevented) {
props.onPress(e);
}
};
return /*#__PURE__*/React.createElement(Text, {
...props,
...rest,
...Platform.select({
web: {
onClick: onPress
},
default: {
onPress
}
}),
style: [{
color: colors.primary
}, fonts.regular, style]
});
}
//# sourceMappingURL=Link.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useTheme","React","Platform","Text","useLinkProps","Link","screen","params","action","href","style","rest","colors","fonts","props","onPress","e","defaultPrevented","createElement","select","web","onClick","default","color","primary","regular"],"sourceRoot":"../../src","sources":["Link.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,wBAAwB;AACjD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAEEC,QAAQ,EACRC,IAAI,QAEC,cAAc;AAErB,SAAyBC,YAAY,QAAQ,mBAAgB;AAe7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,IAAIA,CAAkD;EACpEC,MAAM;EACNC,MAAM;EACNC,MAAM;EACNC,IAAI;EACJC,KAAK;EACL,GAAGC;AACa,CAAC,EAAE;EACnB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGb,QAAQ,CAAC,CAAC;EACpC;EACA,MAAMc,KAAK,GAAGV,YAAY,CAAY;IAAEE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAK,CAAC,CAAC;EAEvE,MAAMM,OAAO,GACXC,CAA0E,IACvE;IACH,IAAI,SAAS,IAAIL,IAAI,EAAE;MACrBA,IAAI,CAACI,OAAO,GAAGC,CAAC,CAAC;IACnB;;IAEA;IACA,IAAI,CAACA,CAAC,CAACC,gBAAgB,EAAE;MACvBH,KAAK,CAACC,OAAO,CAACC,CAAC,CAAC;IAClB;EACF,CAAC;EAED,oBAAOf,KAAK,CAACiB,aAAa,CAACf,IAAI,EAAE;IAC/B,GAAGW,KAAK;IACR,GAAGH,IAAI;IACP,GAAGT,QAAQ,CAACiB,MAAM,CAAC;MACjBC,GAAG,EAAE;QAAEC,OAAO,EAAEN;MAAQ,CAAQ;MAChCO,OAAO,EAAE;QAAEP;MAAQ;IACrB,CAAC,CAAC;IACFL,KAAK,EAAE,CAAC;MAAEa,KAAK,EAAEX,MAAM,CAACY;IAAQ,CAAC,EAAEX,KAAK,CAACY,OAAO,EAAEf,KAAK;EACzD,CAAC,CAAC;AACJ","ignoreList":[]}

View File

@@ -0,0 +1,11 @@
"use strict";
import * as React from 'react';
const MISSING_CONTEXT_ERROR = "Couldn't find a LinkingContext context.";
export const LinkingContext = /*#__PURE__*/React.createContext({
get options() {
throw new Error(MISSING_CONTEXT_ERROR);
}
});
LinkingContext.displayName = 'LinkingContext';
//# sourceMappingURL=LinkingContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","MISSING_CONTEXT_ERROR","LinkingContext","createContext","options","Error","displayName"],"sourceRoot":"../../src","sources":["LinkingContext.tsx"],"mappings":";;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAI9B,MAAMC,qBAAqB,GAAG,yCAAyC;AAEvE,OAAO,MAAMC,cAAc,gBAAGF,KAAK,CAACG,aAAa,CAE9C;EACD,IAAIC,OAAOA,CAAA,EAAQ;IACjB,MAAM,IAAIC,KAAK,CAACJ,qBAAqB,CAAC;EACxC;AACF,CAAC,CAAC;AAEFC,cAAc,CAACI,WAAW,GAAG,gBAAgB","ignoreList":[]}

View File

@@ -0,0 +1,6 @@
"use strict";
import * as React from 'react';
export const LocaleDirContext = /*#__PURE__*/React.createContext('ltr');
LocaleDirContext.displayName = 'LocaleDirContext';
//# sourceMappingURL=LocaleDirContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","LocaleDirContext","createContext","displayName"],"sourceRoot":"../../src","sources":["LocaleDirContext.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAI9B,OAAO,MAAMC,gBAAgB,gBAAGD,KAAK,CAACE,aAAa,CAAkB,KAAK,CAAC;AAE3ED,gBAAgB,CAACE,WAAW,GAAG,kBAAkB","ignoreList":[]}

View File

@@ -0,0 +1,128 @@
"use strict";
import { BaseNavigationContainer, getActionFromState, getPathFromState, getStateFromPath, ThemeProvider, validatePathConfig } from '@react-navigation/core';
import * as React from 'react';
import { I18nManager } from 'react-native';
import useLatestCallback from 'use-latest-callback';
import { LinkingContext } from "./LinkingContext.js";
import { LocaleDirContext } from "./LocaleDirContext.js";
import { DefaultTheme } from "./theming/DefaultTheme.js";
import { UnhandledLinkingContext } from "./UnhandledLinkingContext.js";
import { useBackButton } from './useBackButton';
import { useDocumentTitle } from './useDocumentTitle';
import { useLinking } from './useLinking';
import { useThenable } from "./useThenable.js";
import { jsx as _jsx } from "react/jsx-runtime";
globalThis.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
function NavigationContainerInner({
direction = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr',
theme = DefaultTheme,
linking,
fallback = null,
documentTitle,
onReady,
onStateChange,
...rest
}, ref) {
const isLinkingEnabled = linking ? linking.enabled !== false : false;
if (linking?.config) {
validatePathConfig(linking.config);
}
const refContainer = React.useRef(null);
useBackButton(refContainer);
useDocumentTitle(refContainer, documentTitle);
const [lastUnhandledLink, setLastUnhandledLink] = React.useState();
const {
getInitialState
} = useLinking(refContainer, {
enabled: isLinkingEnabled,
prefixes: [],
...linking
}, setLastUnhandledLink);
const linkingContext = React.useMemo(() => ({
options: linking
}), [linking]);
const unhandledLinkingContext = React.useMemo(() => ({
lastUnhandledLink,
setLastUnhandledLink
}), [lastUnhandledLink, setLastUnhandledLink]);
const onReadyForLinkingHandling = useLatestCallback(() => {
// If the screen path matches lastUnhandledLink, we do not track it
const path = refContainer.current?.getCurrentRoute()?.path;
setLastUnhandledLink(previousLastUnhandledLink => {
if (previousLastUnhandledLink === path) {
return undefined;
}
return previousLastUnhandledLink;
});
onReady?.();
});
const onStateChangeForLinkingHandling = useLatestCallback(state => {
// If the screen path matches lastUnhandledLink, we do not track it
const path = refContainer.current?.getCurrentRoute()?.path;
setLastUnhandledLink(previousLastUnhandledLink => {
if (previousLastUnhandledLink === path) {
return undefined;
}
return previousLastUnhandledLink;
});
onStateChange?.(state);
});
// Add additional linking related info to the ref
// This will be used by the devtools
React.useEffect(() => {
if (refContainer.current) {
REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {
get linking() {
return {
...linking,
enabled: isLinkingEnabled,
prefixes: linking?.prefixes ?? [],
getStateFromPath: linking?.getStateFromPath ?? getStateFromPath,
getPathFromState: linking?.getPathFromState ?? getPathFromState,
getActionFromState: linking?.getActionFromState ?? getActionFromState
};
}
});
}
});
const [isResolved, initialState] = useThenable(getInitialState);
// FIXME
// @ts-expect-error not sure why this is not working
React.useImperativeHandle(ref, () => refContainer.current);
const isLinkingReady = rest.initialState != null || !isLinkingEnabled || isResolved;
if (!isLinkingReady) {
return /*#__PURE__*/_jsx(LocaleDirContext.Provider, {
value: direction,
children: /*#__PURE__*/_jsx(ThemeProvider, {
value: theme,
children: fallback
})
});
}
return /*#__PURE__*/_jsx(LocaleDirContext.Provider, {
value: direction,
children: /*#__PURE__*/_jsx(UnhandledLinkingContext.Provider, {
value: unhandledLinkingContext,
children: /*#__PURE__*/_jsx(LinkingContext.Provider, {
value: linkingContext,
children: /*#__PURE__*/_jsx(BaseNavigationContainer, {
...rest,
theme: theme,
onReady: onReadyForLinkingHandling,
onStateChange: onStateChangeForLinkingHandling,
initialState: rest.initialState == null ? initialState : rest.initialState,
ref: refContainer
})
})
})
});
}
/**
* Container component that manages the navigation state.
* This should be rendered at the root wrapping the whole app.
*/
export const NavigationContainer = /*#__PURE__*/React.forwardRef(NavigationContainerInner);
//# sourceMappingURL=NavigationContainer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["BaseNavigationContainer","getActionFromState","getPathFromState","getStateFromPath","ThemeProvider","validatePathConfig","React","I18nManager","useLatestCallback","LinkingContext","LocaleDirContext","DefaultTheme","UnhandledLinkingContext","useBackButton","useDocumentTitle","useLinking","useThenable","jsx","_jsx","globalThis","REACT_NAVIGATION_DEVTOOLS","WeakMap","NavigationContainerInner","direction","getConstants","isRTL","theme","linking","fallback","documentTitle","onReady","onStateChange","rest","ref","isLinkingEnabled","enabled","config","refContainer","useRef","lastUnhandledLink","setLastUnhandledLink","useState","getInitialState","prefixes","linkingContext","useMemo","options","unhandledLinkingContext","onReadyForLinkingHandling","path","current","getCurrentRoute","previousLastUnhandledLink","undefined","onStateChangeForLinkingHandling","state","useEffect","set","isResolved","initialState","useImperativeHandle","isLinkingReady","Provider","value","children","NavigationContainer","forwardRef"],"sourceRoot":"../../src","sources":["NavigationContainer.tsx"],"mappings":";;AAAA,SACEA,uBAAuB,EACvBC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAKhBC,aAAa,EACbC,kBAAkB,QACb,wBAAwB;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,WAAW,QAAQ,cAAc;AAC1C,OAAOC,iBAAiB,MAAM,qBAAqB;AAEnD,SAASC,cAAc,QAAQ,qBA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EI;QAAa,CACnB;MAAC,CACqB;IAAC,CACM;EAAC,CACV,CAAC;AAEhC;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAM4B,mBAAmB,gBAAG3D,KAAK,CAAC4D,UAAU,CACjD5C,wBACF,CAIuB","ignoreList":[]}

View File

@@ -0,0 +1,55 @@
"use strict";
import { CurrentRenderContext } from '@react-navigation/core';
import * as React from 'react';
import { ServerContext } from "./ServerContext.js";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Container component for server rendering.
*
* @param props.location Location object to base the initial URL for SSR.
* @param props.children Child elements to render the content.
* @param props.ref Ref object which contains helper methods.
*/
export const ServerContainer = /*#__PURE__*/React.forwardRef(function ServerContainer({
children,
location
}, ref) {
React.useEffect(() => {
console.error("'ServerContainer' should only be used on the server with 'react-dom/server' for SSR.");
}, []);
// eslint-disable-next-line @eslint-react/no-unstable-context-value
const current = {};
if (ref) {
const value = {
getCurrentOptions() {
return current.options;
}
};
// We write to the `ref` during render instead of `React.useImperativeHandle`
// This is because `useImperativeHandle` will update the ref after 'commit',
// and there's no 'commit' phase during SSR.
// Mutating ref during render is unsafe in concurrent mode, but we don't care about it for SSR.
if (typeof ref === 'function') {
ref(value);
} else {
ref.current = value;
}
}
return (
/*#__PURE__*/
// eslint-disable-next-line @eslint-react/no-unstable-context-value
_jsx(ServerContext.Provider, {
value: {
location
},
children: /*#__PURE__*/_jsx(CurrentRenderContext.Provider, {
value: current,
children: children
})
})
);
});
//# sourceMappingURL=ServerContainer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["CurrentRenderContext","React","ServerContext","jsx","_jsx","ServerContainer","forwardRef","children","location","ref","useEffect","console","error","current","value","getCurrentOptions","options","Provider"],"sourceRoot":"../../src","sources":["ServerContainer.tsx"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,wBAAwB;AAC7D,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,aAAa,QAAgC,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,gBAAGJ,KAAK,CAACK,UAAU,CAAC,SAASD,eAAeA,CACtE;EAAEE,QAAQ;EAAEC;AAAgB,CAAC,EAC7BC,GAAkC,EAClC;EACAR,KAAK,CAACS,SAAS,CAAC,MAAM;IACpBC,OAAO,CAACC,KAAK,CACX,sFACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA,MAAMC,OAA6B,GAAG,CAAC,CAAC;EAExC,IAAIJ,GAAG,EAAE;IACP,MAAMK,KAAK,GAAG;MACZC,iBAAiBA,CAAA,EAAG;QAClB,OAAOF,OAAO,CAACG,OAAO;MACxB;IACF,CAAC;;IAED;IACA;IACA;IACA;IACA,IAAI,OAAOP,GAAG,KAAK,UAAU,EAAE;MAC7BA,GAAG,CAACK,KAAK,CAAC;IACZ,CAAC,MAAM;MACLL,GAAG,CAACI,OAAO,GAAGC,KAAK;IACrB;EACF;EAEA;IAAA;IACE;IACAV,IAAA,CAACF,aAAa,CAACe,QAAQ;MAACH,KAAK,EAAE;QAAEN;MAAS,CAAE;MAAAD,QAAA,eAC1CH,IAAA,CAACJ,oBAAoB,CAACiB,QAAQ;QAACH,KAAK,EAAED,OAAQ;QAAAN,QAAA,EAC3CA;MAAQ,CACoB;IAAC,CACV;EAAC;AAE7B,CAAC,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,5 @@
"use strict";
import * as React from 'react';
export const ServerContext = /*#__PURE__*/React.createContext(undefined);
//# sourceMappingURL=ServerContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","ServerContext","createContext","undefined"],"sourceRoot":"../../src","sources":["ServerContext.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAS9B,OAAO,MAAMC,aAAa,gBAAGD,KAAK,CAACE,aAAa,CAC9CC,SACF,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,14 @@
"use strict";
import * as React from 'react';
const MISSING_CONTEXT_ERROR = "Couldn't find an UnhandledLinkingContext context.";
export const UnhandledLinkingContext = /*#__PURE__*/React.createContext({
get lastUnhandledLink() {
throw new Error(MISSING_CONTEXT_ERROR);
},
get setLastUnhandledLink() {
throw new Error(MISSING_CONTEXT_ERROR);
}
});
UnhandledLinkingContext.displayName = 'UnhandledLinkingContext';
//# sourceMappingURL=UnhandledLinkingContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","MISSING_CONTEXT_ERROR","UnhandledLinkingContext","createContext","lastUnhandledLink","Error","setLastUnhandledLink","displayName"],"sourceRoot":"../../src","sources":["UnhandledLinkingContext.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,MAAMC,qBAAqB,GACzB,mDAAmD;AAErD,OAAO,MAAMC,uBAAuB,gBAAGF,KAAK,CAACG,aAAa,CAGvD;EACD,IAAIC,iBAAiBA,CAAA,EAAQ;IAC3B,MAAM,IAAIC,KAAK,CAACJ,qBAAqB,CAAC;EACxC,CAAC;EACD,IAAIK,oBAAoBA,CAAA,EAAQ;IAC9B,MAAM,IAAID,KAAK,CAACJ,qBAAqB,CAAC;EACxC;AACF,CAAC,CAAC;AAEFC,uBAAuB,CAACK,WAAW,GAAG,yBAAyB","ignoreList":[]}

View File

@@ -0,0 +1,18 @@
"use strict";
import { createNavigatorFactory, StackRouter, useNavigationBuilder } from '@react-navigation/core';
import { jsx as _jsx } from "react/jsx-runtime";
const StackNavigator = props => {
const {
state,
descriptors,
NavigationContent
} = useNavigationBuilder(StackRouter, props);
return /*#__PURE__*/_jsx(NavigationContent, {
children: descriptors[state.routes[state.index].key].render()
});
};
export function createStackNavigator() {
return createNavigatorFactory(StackNavigator)();
}
//# sourceMappingURL=createStackNavigator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createNavigatorFactory","StackRouter","useNavigationBuilder","jsx","_jsx","StackNavigator","props","state","descriptors","NavigationContent","children","routes","index","key","render","createStackNavigator"],"sourceRoot":"../../../src","sources":["__stubs__/createStackNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EAKtBC,WAAW,EAEXC,oBAAoB,QACf,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEhC,MAAMC,cAAc,GAClBC,KAOC,IACE;EACH,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC;EAAkB,CAAC,GAAGP,oBAAoB,CACpED,WAAW,EACXK,KACF,CAAC;EAED,oBACEF,IAAA,CAACK,iBAAiB;IAAAC,QAAA,EACfF,WAAW,CAACD,KAAK,CAACI,MAAM,CAACJ,KAAK,CAACK,KAAK,CAAC,CAACC,GAAG,CAAC,CAACC,MAAM,CAAC;EAAC,CACnC,CAAC;AAExB,CAAC;AAED,OAAO,SAASC,oBAAoBA,CAAA,EAUjC;EACD,OAAOf,sBAAsB,CAACK,cAAc,CAAC,CAAC,CAAC;AACjD","ignoreList":[]}

View File

@@ -0,0 +1,75 @@
"use strict";
let location = new URL('', 'http://example.com');
let listeners = [];
let entries = [{
state: null,
href: location.href
}];
let index = 0;
let currentState = null;
const history = {
get state() {
return currentState;
},
pushState(state, _, path) {
location = new URL(path, location.origin);
currentState = state;
entries = entries.slice(0, index + 1);
entries.push({
state,
href: location.href
});
index = entries.length - 1;
},
replaceState(state, _, path) {
location = new URL(path, location.origin);
currentState = state;
entries[index] = {
state,
href: location.href
};
},
go(n) {
setTimeout(() => {
if (n > 0 && n < entries.length - index || n < 0 && Math.abs(n) <= index) {
index += n;
const entry = entries[index];
location = new URL(entry.href);
currentState = entry.state;
listeners.forEach(cb => cb());
}
}, 0);
},
back() {
this.go(-1);
},
forward() {
this.go(1);
}
};
const addEventListener = (type, listener) => {
if (type === 'popstate') {
listeners.push(listener);
}
};
const removeEventListener = (type, listener) => {
if (type === 'popstate') {
listeners = listeners.filter(cb => cb !== listener);
}
};
export const window = {
document: {
title: ''
},
get location() {
return location;
},
history,
addEventListener,
removeEventListener,
get window() {
return window;
}
};
//# sourceMappingURL=window.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["location","URL","listeners","entries","state","href","index","currentState","history","pushState","_","path","origin","slice","push","length","replaceState","go","n","setTimeout","Math","abs","entry","forEach","cb","back","forward","addEventListener","type","listener","removeEventListener","filter","window","document","title"],"sourceRoot":"../../../src","sources":["__stubs__/window.tsx"],"mappings":";;AAAA,IAAIA,QAAQ,GAAG,IAAIC,GAAG,CAAC,EAAE,EAAE,oBAAoB,CAAC;AAEhD,IAAIC,SAAyB,GAAG,EAAE;AAClC,IAAIC,OAAO,GAAG,CAAC;EAAEC,KAAK,EAAE,IAAI;EAAEC,IAAI,EAAEL,QAAQ,CAACK;AAAK,CAAC,CAAC;AACpD,IAAIC,KAAK,GAAG,CAAC;AAEb,IAAIC,YAAiB,GAAG,IAAI;AAE5B,MAAMC,OAAO,GAAG;EACd,IAAIJ,KAAKA,CAAA,EAAG;IACV,OAAOG,YAAY;EACrB,CAAC;EAEDE,SAASA,CAACL,KAAU,EAAEM,CAAS,EAAEC,IAAY,EAAE;IAC7CX,QAAQ,GAAG,IAAIC,GAAG,CAACU,IAAI,EAAEX,QAAQ,CAACY,MAAM,CAAC;IAEzCL,YAAY,GAAGH,KAAK;IACpBD,OAAO,GAAGA,OAAO,CAACU,KAAK,CAAC,CAAC,EAAEP,KAAK,GAAG,CAAC,CAAC;IACrCH,OAAO,CAACW,IAAI,CAAC;MAAEV,KAAK;MAAEC,IAAI,EAAEL,QAAQ,CAACK;IAAK,CAAC,CAAC;IAC5CC,KAAK,GAAGH,OAAO,CAACY,MAAM,GAAG,CAAC;EAC5B,CAAC;EAEDC,YAAYA,CAACZ,KAAU,EAAEM,CAAS,EAAEC,IAAY,EAAE;IAChDX,QAAQ,GAAG,IAAIC,GAAG,CAACU,IAAI,EAAEX,QAAQ,CAACY,MAAM,CAAC;IAEzCL,YAAY,GAAGH,KAAK;IACpBD,OAAO,CAACG,KAAK,CAAC,GAAG;MAAEF,KAAK;MAAEC,IAAI,EAAEL,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;EACjB,CAAC;EACDQ,OAAO;EACPmB,gBAAgB;EAChBG,mBAAmB;EACnB,IAAIE,MAAMA,CAAA,EAAG;IACX,OAAOA,MAAM;EACf;AACF,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,216 @@
"use strict";
import { nanoid } from 'nanoid/non-secure';
export function createMemoryHistory() {
let index = 0;
let items = [];
// Pending callbacks for `history.go(n)`
// We might modify the callback stored if it was interrupted, so we have a ref to identify it
const pending = [];
const interrupt = () => {
// If another history operation was performed we need to interrupt existing ones
// This makes sure that calls such as `history.replace` after `history.go` don't happen
// Since otherwise it won't be correct if something else has changed
pending.forEach(it => {
const cb = it.cb;
it.cb = () => cb(true);
});
};
const history = {
get index() {
// We store an id in the state instead of an index
// Index could get out of sync with in-memory values if page reloads
const id = window.history.state?.id;
if (id) {
const index = items.findIndex(item => item.id === id);
return index > -1 ? index : 0;
}
return 0;
},
get(index) {
return items[index];
},
backIndex({
path
}) {
// We need to find the index from the element before current to get closest path to go back to
for (let i = index - 1; i >= 0; i--) {
const item = items[i];
if (item.path === path) {
return i;
}
}
return -1;
},
push({
path,
state
}) {
interrupt();
const id = nanoid();
// When a new entry is pushed, all the existing entries after index will be inaccessible
// So we remove any existing entries after the current index to clean them up
items = items.slice(0, index + 1);
items.push({
path,
state,
id
});
index = items.length - 1;
// We pass empty string for title because it's ignored in all browsers except safari
// We don't store state object in history.state because:
// - browsers have limits on how big it can be, and we don't control the size
// - while not recommended, there could be non-serializable data in state
window.history.pushState({
id
}, '', path);
},
replace({
path,
state
}) {
interrupt();
const id = window.history.state?.id ?? nanoid();
// Need to keep the hash part of the path if there was no previous history entry
// or the previous history entry had the same path
let pathWithHash = path;
const hash = pathWithHash.includes('#') ? '' : location.hash;
if (!items.length || items.findIndex(item => item.id === id) < 0) {
// There are two scenarios for creating an array with only one history record:
// - When loaded id not found in the items array, this function by default will replace
// the first item. We need to keep only the new updated object, otherwise it will break
// the page when navigating forward in history.
// - This is the first time any state modifications are done
// So we need to push the entry as there's nothing to replace
pathWithHash = pathWithHash + hash;
items = [{
path: pathWithHash,
state,
id
}];
index = 0;
} else {
if (items[index].path === path) {
pathWithHash = pathWithHash + hash;
}
items[index] = {
path,
state,
id
};
}
window.history.replaceState({
id
}, '', pathWithHash);
},
// `history.go(n)` is asynchronous, there are couple of things to keep in mind:
// - it won't do anything if we can't go `n` steps, the `popstate` event won't fire.
// - each `history.go(n)` call will trigger a separate `popstate` event with correct location.
// - the `popstate` event fires before the next frame after calling `history.go(n)`.
// This method differs from `history.go(n)` in the sense that it'll go back as many steps it can.
go(n) {
interrupt();
// To guard against unexpected navigation out of the app we will assume that browser history is only as deep as the length of our memory
// history. If we don't have an item to navigate to then update our index and navigate as far as we can without taking the user out of the app.
const nextIndex = index + n;
const lastItemIndex = items.length - 1;
if (n < 0 && !items[nextIndex]) {
// Attempted to navigate beyond the first index. Negating the current index will align the browser history with the first item.
n = -index;
index = 0;
} else if (n > 0 && nextIndex > lastItemIndex) {
// Attempted to navigate past the last index. Calculate how many indices away from the last index and go there.
n = lastItemIndex - index;
index = lastItemIndex;
} else {
index = nextIndex;
}
if (n === 0) {
return;
}
// When we call `history.go`, `popstate` will fire when there's history to go back to
// So we need to somehow handle following cases:
// - There's history to go back, `history.go` is called, and `popstate` fires
// - `history.go` is called multiple times, we need to resolve on respective `popstate`
// - No history to go back, but `history.go` was called, browser has no API to detect it
return new Promise((resolve, reject) => {
const done = interrupted => {
clearTimeout(timer);
if (interrupted) {
reject(new Error('History was changed during navigation.'));
return;
}
// There seems to be a bug in Chrome regarding updating the title
// If we set a title just before calling `history.go`, the title gets lost
// However the value of `document.title` is still what we set it to
// It's just not displayed in the tab bar
// To update the tab bar, we need to reset the title to something else first (e.g. '')
// And set the title to what it was before so it gets applied
// It won't work without setting it to empty string coz otherwise title isn't changing
// Which means that the browser won't do anything after setting the title
const {
title
} = window.document;
window.document.title = '';
window.document.title = title;
resolve();
};
pending.push({
ref: done,
cb: done
});
// If navigation didn't happen within 100ms, assume that it won't happen
// This may not be accurate, but hopefully it won't take so much time
// In Chrome, navigation seems to happen instantly in next microtask
// But on Firefox, it seems to take much longer, around 50ms from our testing
// We're using a hacky timeout since there doesn't seem to be way to know for sure
const timer = setTimeout(() => {
const foundIndex = pending.findIndex(it => it.ref === done);
if (foundIndex > -1) {
pending[foundIndex].cb();
pending.splice(foundIndex, 1);
}
index = this.index;
}, 100);
const onPopState = () => {
// Fix createMemoryHistory.index variable's value
// as it may go out of sync when navigating in the browser.
index = this.index;
const last = pending.pop();
window.removeEventListener('popstate', onPopState);
last?.cb();
};
window.addEventListener('popstate', onPopState);
window.history.go(n);
});
},
// The `popstate` event is triggered when history changes, except `pushState` and `replaceState`
// If we call `history.go(n)` ourselves, we don't want it to trigger the listener
// Here we normalize it so that only external changes (e.g. user pressing back/forward) trigger the listener
listen(listener) {
const onPopState = () => {
// Fix createMemoryHistory.index variable's value
// as it may go out of sync when navigating in the browser.
index = this.index;
if (pending.length) {
// This was triggered by `history.go(n)`, we shouldn't call the listener
return;
}
listener();
};
window.addEventListener('popstate', onPopState);
return () => window.removeEventListener('popstate', onPopState);
}
};
return history;
}
//# sourceMappingURL=createMemoryHistory.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,54 @@
"use strict";
import { createComponentForStaticNavigation, createPathConfigForStaticNavigation } from '@react-navigation/core';
import * as React from 'react';
import { NavigationContainer } from "./NavigationContainer.js";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Create a navigation component from a static navigation config.
* The returned component is a wrapper around `NavigationContainer`.
*
* @param tree Static navigation config.
* @returns Navigation component to use in your app.
*/
export function createStaticNavigation(tree) {
const Component = createComponentForStaticNavigation(tree, 'RootNavigator');
function Navigation({
linking,
...rest
}, ref) {
const linkingConfig = React.useMemo(() => {
const screens = createPathConfigForStaticNavigation(tree, {
initialRouteName: linking?.config?.initialRouteName
}, linking?.enabled === 'auto');
if (!screens) return;
return {
path: linking?.config?.path,
initialRouteName: linking?.config?.initialRouteName,
screens
};
}, [linking?.enabled, linking?.config?.path, linking?.config?.initialRouteName]);
const memoizedLinking = React.useMemo(() => {
if (!linking) {
return undefined;
}
const enabled = typeof linking.enabled === 'boolean' ? linking.enabled : linkingConfig?.screens != null;
return {
...linking,
enabled,
config: linkingConfig
};
}, [linking, linkingConfig]);
if (linking?.enabled === true && linkingConfig?.screens == null) {
throw new Error('Linking is enabled but no linking configuration was found for the screens.\n\n' + 'To solve this:\n' + "- Specify a 'linking' property for the screens you want to link to.\n" + "- Or set 'linking.enabled' to 'auto' to generate paths automatically.\n\n" + 'See usage guide: https://reactnavigation.org/docs/static-configuration#linking');
}
return /*#__PURE__*/_jsx(NavigationContainer, {
...rest,
ref: ref,
linking: memoizedLinking,
children: /*#__PURE__*/_jsx(Component, {})
});
}
return /*#__PURE__*/React.forwardRef(Navigation);
}
//# sourceMappingURL=createStaticNavigation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createComponentForStaticNavigation","createPathConfigForStaticNavigation","React","NavigationContainer","jsx","_jsx","createStaticNavigation","tree","Component","Navigation","linking","rest","ref","linkingConfig","useMemo","screens","initialRouteName","config","enabled","path","memoizedLinking","undefined","Error","children","forwardRef"],"sourceRoot":"../../src","sources":["createStaticNavigation.tsx"],"mappings":";;AAAA,SACEA,kCAAkC,EAClCC,mCAAmC,QAI9B,wBAAwB;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,mBAAmB,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA8B5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAACC,IAAqC,EAAE;EAC5E,MAAMC,SAAS,GAAGR,kCAAkC,CAACO,IAAI,EAAE,eAAe,CAAC;EAE3E,SAASE,UAAUA,CACjB;IAAEC,OAAO;IAAE,GAAGC;EAAY,CAAC,EAC3BC,GAAqD,EACrD;IACA,MAAMC,aAAa,GAAGX,KAAK,CAACY,OAAO,CAAC,MAAM;MACxC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B,UAAU,CAACf,UAAU,CAAC;AACrC","ignoreList":[]}

View File

@@ -0,0 +1,19 @@
"use strict";
import escapeStringRegexp from 'escape-string-regexp';
export function extractPathFromURL(prefixes, url) {
for (const prefix of prefixes) {
const protocol = prefix.match(/^[^:]+:/)?.[0] ?? '';
const host = prefix.replace(new RegExp(`^${escapeStringRegexp(protocol)}`), '').replace(/\/+/g, '/') // Replace multiple slash (//) with single ones
.replace(/^\//, ''); // Remove extra leading slash
const prefixRegex = new RegExp(`^${escapeStringRegexp(protocol)}(/)*${host.split('.').map(it => it === '*' ? '[^/]+' : escapeStringRegexp(it)).join('\\.')}`);
const [originAndPath, ...searchParams] = url.split('?');
const normalizedURL = originAndPath.replace(/\/+/g, '/').concat(searchParams.length ? `?${searchParams.join('?')}` : '');
if (prefixRegex.test(normalizedURL)) {
return normalizedURL.replace(prefixRegex, '');
}
}
return undefined;
}
//# sourceMappingURL=extractPathFromURL.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["escapeStringRegexp","extractPathFromURL","prefixes","url","prefix","protocol","match","host","replace","RegExp","prefixRegex","split","map","it","join","originAndPath","searchParams","normalizedURL","concat","length","test","undefined"],"sourceRoot":"../../src","sources":["extractPathFromURL.tsx"],"mappings":";;AAAA,OAAOA,kBAAkB,MAAM,sBAAsB;AAErD,OAAO,SAASC,kBAAkBA,CAACC,QAAkB,EAAEC,GAAW,EAAE;EAClE,KAAK,MAAMC,MAAM,IAAIF,QAAQ,EAAE;IAC7B,MAAMG,QAAQ,GAAGD,MAAM,CAACE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;IACnD,MAAMC,IAAI,GAAGH,MAAM,CAChBI,OAAO,CAAC,IAAIC,MAAM,CAAC,IAAIT,kBAAkB,CAACK,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC3DG,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAA,CACrBA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;;IAEvB,MAAME,WAAW,GAAG,IAAID,MAAM,CAC5B,IAAIT,kBAAkB,CAACK,QAAQ,CAAC,OAAOE,IAAI,CACxCI,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,EAAE,IAAMA,EAAE,KAAK,GAAG,GAAG,OAAO,GAAGb,kBAAkB,CAACa,EAAE,CAAE,CAAC,CAC5DC,IAAI,CAAC,KAAK,CAAC,EAChB,CAAC;IAED,MAAM,CAACC,aAAa,EAAE,GAAGC,YAAY,CAAC,GAAGb,GAAG,CAACQ,KAAK,CAAC,GAAG,CAAC;IACvD,MAAMM,aAAa,GAAGF,aAAa,CAChCP,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CACpBU,MAAM,CAACF,YAAY,CAACG,MAAM,GAAG,IAAIH,YAAY,CAACF,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;IAElE,IAAIJ,WAAW,CAACU,IAAI,CAACH,aAAa,CAAC,EAAE;MACnC,OAAOA,aAAa,CAACT,OAAO,CAACE,WAAW,EAAE,EAAE,CAAC;IAC/C;EACF;EAEA,OAAOW,SAAS;AAClB","ignoreList":[]}

View File

@@ -0,0 +1,20 @@
"use strict";
export { createStaticNavigation } from "./createStaticNavigation.js";
export { Link } from "./Link.js";
export { LinkingContext } from "./LinkingContext.js";
export { LocaleDirContext } from "./LocaleDirContext.js";
export { NavigationContainer } from "./NavigationContainer.js";
export { ServerContainer } from "./ServerContainer.js";
export { DarkTheme } from "./theming/DarkTheme.js";
export { DefaultTheme } from "./theming/DefaultTheme.js";
export * from "./types.js";
export { UnhandledLinkingContext as UNSTABLE_UnhandledLinkingContext } from "./UnhandledLinkingContext.js";
export { useLinkBuilder } from "./useLinkBuilder.js";
export { useLinkProps } from "./useLinkProps.js";
export { useLinkTo } from "./useLinkTo.js";
export { useLocale } from "./useLocale.js";
export { useRoutePath } from "./useRoutePath.js";
export { useScrollToTop } from "./useScrollToTop.js";
export * from '@react-navigation/core';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createStaticNavigation","Link","LinkingContext","LocaleDirContext","NavigationContainer","ServerContainer","DarkTheme","DefaultTheme","UnhandledLinkingContext","UNSTABLE_UnhandledLinkingContext","useLinkBuilder","useLinkProps","useLinkTo","useLocale","useRoutePath","useScrollToTop"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,sBAAsB,QAAQ,6BAA0B;AACjE,SAASC,IAAI,QAAQ,WAAQ;AAC7B,SAASC,cAAc,QAAQ,qBAAkB;AACjD,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,mBAAmB,QAAQ,0BAAuB;AAC3D,SAASC,eAAe,QAAQ,sBAAmB;AACnD,SAASC,SAAS,QAAQ,wBAAqB;AAC/C,SAASC,YAAY,QAAQ,2BAAwB;AACrD,cAAc,YAAS;AACvB,SAASC,uBAAuB,IAAIC,gCAAgC,QAAQ,8BAA2B;AACvG,SAASC,cAAc,QAAQ,qBAAkB;AACjD,SAAyBC,YAAY,QAAQ,mBAAgB;AAC7D,SAASC,SAAS,QAAQ,gBAAa;AACvC,SAASC,SAAS,QAAQ,gBAAa;AACvC,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,cAAc,QAAQ,qBAAkB;AACjD,cAAc,wBAAwB","ignoreList":[]}

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,16 @@
"use strict";
import { fonts } from "./fonts.js";
export const DarkTheme = {
dark: true,
colors: {
primary: 'rgb(10, 132, 255)',
background: 'rgb(1, 1, 1)',
card: 'rgb(18, 18, 18)',
text: 'rgb(229, 229, 231)',
border: 'rgb(39, 39, 41)',
notification: 'rgb(255, 69, 58)'
},
fonts
};
//# sourceMappingURL=DarkTheme.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["fonts","DarkTheme","dark","colors","primary","background","card","text","border","notification"],"sourceRoot":"../../../src","sources":["theming/DarkTheme.tsx"],"mappings":";;AACA,SAASA,KAAK,QAAQ,YAAS;AAE/B,OAAO,MAAMC,SAAgB,GAAG;EAC9BC,IAAI,EAAE,IAAI;EACVC,MAAM,EAAE;IACNC,OAAO,EAAE,mBAAmB;IAC5BC,UAAU,EAAE,cAAc;IAC1BC,IAAI,EAAE,iBAAiB;IACvBC,IAAI,EAAE,oBAAoB;IAC1BC,MAAM,EAAE,iBAAiB;IACzBC,YAAY,EAAE;EAChB,CAAC;EACDT;AACF,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,16 @@
"use strict";
import { fonts } from "./fonts.js";
export const DefaultTheme = {
dark: false,
colors: {
primary: 'rgb(0, 122, 255)',
background: 'rgb(242, 242, 242)',
card: 'rgb(255, 255, 255)',
text: 'rgb(28, 28, 30)',
border: 'rgb(216, 216, 216)',
notification: 'rgb(255, 59, 48)'
},
fonts
};
//# sourceMappingURL=DefaultTheme.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["fonts","DefaultTheme","dark","colors","primary","background","card","text","border","notification"],"sourceRoot":"../../../src","sources":["theming/DefaultTheme.tsx"],"mappings":";;AACA,SAASA,KAAK,QAAQ,YAAS;AAE/B,OAAO,MAAMC,YAAmB,GAAG;EACjCC,IAAI,EAAE,KAAK;EACXC,MAAM,EAAE;IACNC,OAAO,EAAE,kBAAkB;IAC3BC,UAAU,EAAE,oBAAoB;IAChCC,IAAI,EAAE,oBAAoB;IAC1BC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE,oBAAoB;IAC5BC,YAAY,EAAE;EAChB,CAAC;EACDT;AACF,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,61 @@
"use strict";
import { Platform } from 'react-native';
const WEB_FONT_STACK = 'system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';
export const fonts = Platform.select({
web: {
regular: {
fontFamily: WEB_FONT_STACK,
fontWeight: '400'
},
medium: {
fontFamily: WEB_FONT_STACK,
fontWeight: '500'
},
bold: {
fontFamily: WEB_FONT_STACK,
fontWeight: '600'
},
heavy: {
fontFamily: WEB_FONT_STACK,
fontWeight: '700'
}
},
ios: {
regular: {
fontFamily: 'System',
fontWeight: '400'
},
medium: {
fontFamily: 'System',
fontWeight: '500'
},
bold: {
fontFamily: 'System',
fontWeight: '600'
},
heavy: {
fontFamily: 'System',
fontWeight: '700'
}
},
default: {
regular: {
fontFamily: 'sans-serif',
fontWeight: 'normal'
},
medium: {
fontFamily: 'sans-serif-medium',
fontWeight: 'normal'
},
bold: {
fontFamily: 'sans-serif',
fontWeight: '600'
},
heavy: {
fontFamily: 'sans-serif',
fontWeight: '700'
}
}
});
//# sourceMappingURL=fonts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Platform","WEB_FONT_STACK","fonts","select","web","regular","fontFamily","fontWeight","medium","bold","heavy","ios","default"],"sourceRoot":"../../../src","sources":["theming/fonts.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAIvC,MAAMC,cAAc,GAClB,uHAAuH;AAEzH,OAAO,MAAMC,KAAK,GAAGF,QAAQ,CAACG,MAAM,CAAC;EACnCC,GAAG,EAAE;IACHC,OAAO,EAAE;MACPC,UAAU,EAAEL,cAAc;MAC1BM,UAAU,EAAE;IACd,CAAC;IACDC,MAAM,EAAE;MACNF,UAAU,EAAEL,cAAc;MAC1BM,UAAU,EAAE;IACd,CAAC;IACDE,IAAI,EAAE;MACJH,UAAU,EAAEL,cAAc;MAC1BM,UAAU,EAAE;IACd,CAAC;IACDG,KAAK,EAAE;MACLJ,UAAU,EAAEL,cAAc;MAC1BM,UAAU,EAAE;IACd;EACF,CAAC;EACDI,GAAG,EAAE;IACHN,OAAO,EAAE;MACPC,UAAU,EAAE,QAAQ;MACpBC,UAAU,EAAE;IACd,CAAC;IACDC,MAAM,EAAE;MACNF,UAAU,EAAE,QAAQ;MACpBC,UAAU,EAAE;IACd,CAAC;IACDE,IAAI,EAAE;MACJH,UAAU,EAAE,QAAQ;MACpBC,UAAU,EAAE;IACd,CAAC;IACDG,KAAK,EAAE;MACLJ,UAAU,EAAE,QAAQ;MACpBC,UAAU,EAAE;IACd;EACF,CAAC;EACDK,OAAO,EAAE;IACPP,OAAO,EAAE;MACPC,UAAU,EAAE,YAAY;MACxBC,UAAU,EAAE;IACd,CAAC;IACDC,MAAM,EAAE;MACNF,UAAU,EAAE,mBAAmB;MAC/BC,UAAU,EAAE;IACd,CAAC;IACDE,IAAI,EAAE;MACJH,UAAU,EAAE,YAAY;MACxBC,UAAU,EAAE;IACd,CAAC;IACDG,KAAK,EAAE;MACLJ,UAAU,EAAE,YAAY;MACxBC,UAAU,EAAE;IACd;EACF;AACF,CAAmD,CAAC","ignoreList":[]}

View File

@@ -0,0 +1,4 @@
"use strict";
export {};
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.tsx"],"mappings":"","ignoreList":[]}

View File

@@ -0,0 +1,7 @@
"use strict";
export function useBackButton(_) {
// No-op
// BackHandler is not available on web
}
//# sourceMappingURL=useBackButton.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useBackButton","_"],"sourceRoot":"../../src","sources":["useBackButton.tsx"],"mappings":";;AAKA,OAAO,SAASA,aAAaA,CAC3BC,CAAgE,EAChE;EACA;EACA;AAAA","ignoreList":[]}

View File

@@ -0,0 +1,21 @@
"use strict";
import * as React from 'react';
import { BackHandler } from 'react-native';
export function useBackButton(ref) {
React.useEffect(() => {
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
const navigation = ref.current;
if (navigation == null) {
return false;
}
if (navigation.canGoBack()) {
navigation.goBack();
return true;
}
return false;
});
return () => subscription.remove();
}, [ref]);
}
//# sourceMappingURL=useBackButton.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","BackHandler","useBackButton","ref","useEffect","subscription","addEventListener","navigation","current","canGoBack","goBack","remove"],"sourceRoot":"../../src","sources":["useBackButton.native.tsx"],"mappings":";;AAIA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,WAAW,QAAQ,cAAc;AAE1C,OAAO,SAASC,aAAaA,CAC3BC,GAAkE,EAClE;EACAH,KAAK,CAACI,SAAS,CAAC,MAAM;IACpB,MAAMC,YAAY,GAAGJ,WAAW,CAACK,gBAAgB,CAC/C,mBAAmB,EACnB,MAAM;MACJ,MAAMC,UAAU,GAAGJ,GAAG,CAACK,OAAO;MAE9B,IAAID,UAAU,IAAI,IAAI,EAAE;QACtB,OAAO,KAAK;MACd;MAEA,IAAIA,UAAU,CAACE,SAAS,CAAC,CAAC,EAAE;QAC1BF,UAAU,CAACG,MAAM,CAAC,CAAC;QAEnB,OAAO,IAAI;MACb;MAEA,OAAO,KAAK;IACd,CACF,CAAC;IAED,OAAO,MAAML,YAAY,CAACM,MAAM,CAAC,CAAC;EACpC,CAAC,EAAE,CAACR,GAAG,CAAC,CAAC;AACX","ignoreList":[]}

View File

@@ -0,0 +1,26 @@
"use strict";
import * as React from 'react';
/**
* Set the document title for the active screen
*/
export function useDocumentTitle(ref, {
enabled = true,
formatter = (options, route) => options?.title ?? route?.name
} = {}) {
React.useEffect(() => {
if (!enabled) {
return;
}
const navigation = ref.current;
if (navigation) {
const title = formatter(navigation.getCurrentOptions(), navigation.getCurrentRoute());
document.title = title;
}
return navigation?.addListener('options', e => {
const title = formatter(e.data.options, navigation?.getCurrentRoute());
document.title = title;
});
});
}
//# sourceMappingURL=useDocumentTitle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","useDocumentTitle","ref","enabled","formatter","options","route","title","name","useEffect","navigation","current","getCurrentOptions","getCurrentRoute","document","addListener","e","data"],"sourceRoot":"../../src","sources":["useDocumentTitle.tsx"],"mappings":";;AAIA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAI9B;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,GAAkE,EAClE;EACEC,OAAO,GAAG,IAAI;EACdC,SAAS,GAAGA,CAACC,OAAO,EAAEC,KAAK,KAAKD,OAAO,EAAEE,KAAK,IAAID,KAAK,EAAEE;AACrC,CAAC,GAAG,CAAC,CAAC,EAC5B;EACAR,KAAK,CAACS,SAAS,CAAC,MAAM;IACpB,IAAI,CAACN,OAAO,EAAE;MACZ;IACF;IAEA,MAAMO,UAAU,GAAGR,GAAG,CAACS,OAAO;IAE9B,IAAID,UAAU,EAAE;MACd,MAAMH,KAAK,GAAGH,SAAS,CACrBM,UAAU,CAACE,iBAAiB,CAAC,CAAC,EAC9BF,UAAU,CAACG,eAAe,CAAC,CAC7B,CAAC;MAEDC,QAAQ,CAACP,KAAK,GAAGA,KAAK;IACxB;IAEA,OAAOG,UAAU,EAAEK,WAAW,CAAC,SAAS,EAAGC,CAAC,IAAK;MAC/C,MAAMT,KAAK,GAAGH,SAAS,CAACY,CAAC,CAACC,IAAI,CAACZ,OAAO,EAAEK,UAAU,EAAEG,eAAe,CAAC,CAAC,CAAC;MAEtEC,QAAQ,CAACP,KAAK,GAAGA,KAAK;IACxB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}

View File

@@ -0,0 +1,6 @@
"use strict";
export function useDocumentTitle() {
// Noop for native platforms
}
//# sourceMappingURL=useDocumentTitle.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useDocumentTitle"],"sourceRoot":"../../src","sources":["useDocumentTitle.native.tsx"],"mappings":";;AAAA,OAAO,SAASA,gBAAgBA,CAAA,EAAG;EACjC;AAAA","ignoreList":[]}

View File

@@ -0,0 +1,104 @@
"use strict";
import { CommonActions, findFocusedRoute, getActionFromState, getPathFromState, getStateFromPath, NavigationHelpersContext, NavigationRouteContext, useStateForPath } from '@react-navigation/core';
import * as React from 'react';
import { LinkingContext } from "./LinkingContext.js";
/**
* Helper to build a href for a screen based on the linking options.
*/
export function useBuildHref() {
const navigation = React.useContext(NavigationHelpersContext);
const route = React.useContext(NavigationRouteContext);
const {
options
} = React.useContext(LinkingContext);
const focusedRouteState = useStateForPath();
const getPathFromStateHelper = options?.getPathFromState ?? getPathFromState;
const buildHref = React.useCallback((name, params) => {
if (options?.enabled === false) {
return undefined;
}
// Check that we're inside:
// - navigator's context
// - route context of the navigator (could be a screen, tab, etc.)
// - route matches the state for path (from the screen's context)
// This ensures that we're inside a screen
const isScreen = navigation && route?.key && focusedRouteState ? route.key === findFocusedRoute(focusedRouteState)?.key && navigation.getState().routes.some(r => r.key === route.key) : false;
const stateForRoute = {
routes: [{
name,
params
}]
};
const constructState = state => {
if (state) {
const route = state.routes[0];
// If we're inside a screen and at the innermost route
// We need to replace the state with the provided one
// This assumes that we're navigating to a sibling route
if (isScreen && !route.state) {
return stateForRoute;
}
// Otherwise, dive into the nested state of the route
return {
routes: [{
...route,
state: constructState(route.state)
}]
};
}
// Once there is no more nested state, we're at the innermost route
// We can add a state based on provided parameters
// This assumes that we're navigating to a child of this route
// In this case, the helper is used in a navigator for its routes
return stateForRoute;
};
const state = constructState(focusedRouteState);
const path = getPathFromStateHelper(state, options?.config);
return path;
}, [options?.enabled, options?.config, route?.key, navigation, focusedRouteState, getPathFromStateHelper]);
return buildHref;
}
/**
* Helper to build a navigation action from a href based on the linking options.
*/
export const useBuildAction = () => {
const {
options
} = React.useContext(LinkingContext);
const getStateFromPathHelper = options?.getStateFromPath ?? getStateFromPath;
const getActionFromStateHelper = options?.getActionFromState ?? getActionFromState;
const buildAction = React.useCallback(href => {
if (!href.startsWith('/')) {
throw new Error(`The href must start with '/' (${href}).`);
}
const state = getStateFromPathHelper(href, options?.config);
if (state) {
const action = getActionFromStateHelper(state, options?.config);
return action ?? CommonActions.reset(state);
} else {
throw new Error('Failed to parse the href to a navigation state.');
}
}, [options?.config, getStateFromPathHelper, getActionFromStateHelper]);
return buildAction;
};
/**
* Helpers to build href or action based on the linking options.
*
* @returns `buildHref` to build an `href` for screen and `buildAction` to build an action from an `href`.
*/
export function useLinkBuilder() {
const buildHref = useBuildHref();
const buildAction = useBuildAction();
return {
buildHref,
buildAction
};
}
//# sourceMappingURL=useLinkBuilder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["CommonActions","findFocusedRoute","getActionFromState","getPathFromState","getStateFromPath","NavigationHelpersContext","NavigationRouteContext","useStateForPath","React","LinkingContext","useBuildHref","navigation","useContext","route","options","focusedRouteState","getPathFromStateHelper","buildHref","useCallback","name","params","enabled","undefined","isScreen","key","getState","routes","some","r","stateForRoute","constructState","state","path","config","useBuildAction","getStateFromPathHelper","getActionFromStateHelper","buildAction","href","startsWith","Error","action","reset","useLinkBuilder"],"sourceRoot":"../../src","sources":["useLinkBuilder.tsx"],"mappings":";;AAAA,SACEA,aAAa,EACbC,gBAAgB,EAChBC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAChBC,wBAAwB,EACxBC,sBAAsB,EACtBC,eAAe,QACV,wBAAwB;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,cAAc,QAAQ,qBAAkB;AAMjD;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAG;EAC7B,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAACP,wBAAwB,CAAC;EAC7D,MAAMQ,KAAK,GAAGL,KAAK,CAACI,UAAU,CAACN,sBAAsB,CAAC;EAEtD,MAAM;IAAEQ;EAAQ,CAAC,GAAGN,KAAK,CAACI,UAAU,CAACH,cAAc,CAAC;EAEpD,MAAMM,iBAAiB,GAAGR,eAAe,CAAC,CAAC;EAE3C,MAAMS,sBAAsB,GAAGF,OAAO,EAAEX,gBAAgB,IAAIA,gBAAgB;EAE5E,MAAMc,SAAS,GAAGT,KAAK,CAACU,WAAW,CACjC,CAACC,IAAY,EAAEC,MAAe,KAAK;IACjC,IAAIN,OAAO,EAAEO,OAAO,KAAK,KAAK,EAAE;MAC9B,OAAOC,SAAS;IAClB;;IAEA;IACA;IACA;IACA;IACA;IACA,MAAMC,QAAQ,GACZZ,UAAU,IAAIE,KAAK,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AC;EAEpD,MAAM0B,sBAAsB,GAAGrB,OAAO,EAAEV,gBAAgB,IAAIA,gBAAgB;EAC5E,MAAMgC,wBAAwB,GAC5BtB,OAAO,EAAEZ,kBAAkB,IAAIA,kBAAkB;EAEnD,MAAMmC,WAAW,GAAG7B,KAAK,CAACU,WAAW,CAClCoB,IAAY,IAAK;IAChB,IAAI,CAACA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC,EAAE;MACzB,MAAM,IAAIC,KAAK,CAAC,iCAAiCF,IAAI,IAAI,CAAC;IAC5D;IAEA,MAAMP,KAAK,GAAGI,sBAAsB,CAACG,IAAI,EAAExB,OAAO,EAAEmB,MAAM,CAAC;IAE3D,IAAIF,KAAK,EAAE;MACT,MAAMU,MAAM,GAAGL,wBAAwB,CAACL,KAAK,EAAEjB,OAAO,EAAEmB,MAAM,CAAC;MAE/D,OAAOQ,MAAM,IAAIzC,aAAa,CAAC0C,KAAK,CAACX,KAAK,CAAC;IAC7C,CAAC,MAAM;MACL,MAAM,IAAIS,KAAK,CAAC,iDAAiD,CAAC;IACpE;EACF,CAAC,EACD,CAAC1B,OAAO,EAAEmB,MAAM,EAAEE,sBAAsB,EAAEC,wBAAwB,CACpE,CAAC;EAED,OAAOC,WAAW;AACpB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,cAAcA,CAAA,EAAG;EAC/B,MAAM1B,SAAS,GAAGP,YAAY,CAAC,CAAC;EAChC,MAAM2B,WAAW,GAAGH,cAAc,CAAC,CAAC;EAEpC,OAAO;IACLjB,SAAS;IACToB;EACF,CAAC;AACH","ignoreList":[]}

View File

@@ -0,0 +1,93 @@
"use strict";
import { getPathFromState, NavigationContainerRefContext, NavigationHelpersContext } from '@react-navigation/core';
import * as React from 'react';
import { Platform } from 'react-native';
import { LinkingContext } from "./LinkingContext.js";
const getStateFromParams = params => {
if (params?.state) {
return params.state;
}
if (params?.screen) {
return {
routes: [{
name: params.screen,
params: params.params,
// @ts-expect-error this is fine 🔥
state: params.screen ? getStateFromParams(params.params) : undefined
}]
};
}
return undefined;
};
/**
* Hook to get props for an anchor tag so it can work with in page navigation.
*
* @param props.screen Name of the screen to navigate to (e.g. `'Feeds'`).
* @param props.params Params to pass to the screen to navigate to (e.g. `{ sort: 'hot' }`).
* @param props.href Optional absolute path to use for the href (e.g. `/feeds/hot`).
* @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
*/
export function useLinkProps({
screen,
params,
href,
action
}) {
const root = React.useContext(NavigationContainerRefContext);
const navigation = React.useContext(NavigationHelpersContext);
const {
options
} = React.useContext(LinkingContext);
const onPress = e => {
let shouldHandle = false;
if (Platform.OS !== 'web' || !e) {
e?.preventDefault?.();
shouldHandle = true;
} else {
// ignore clicks with modifier keys
const hasModifierKey = 'metaKey' in e && e.metaKey || 'altKey' in e && e.altKey || 'ctrlKey' in e && e.ctrlKey || 'shiftKey' in e && e.shiftKey;
// only handle left clicks
const isLeftClick = 'button' in e ? e.button == null || e.button === 0 : true;
// let browser handle "target=_blank" etc.
const isSelfTarget = e.currentTarget && 'target' in e.currentTarget ? [undefined, null, '', 'self'].includes(e.currentTarget.target) : true;
if (!hasModifierKey && isLeftClick && isSelfTarget) {
e.preventDefault?.();
shouldHandle = true;
}
}
if (shouldHandle) {
if (action) {
if (navigation) {
navigation.dispatch(action);
} else if (root) {
root.dispatch(action);
} else {
throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
}
} else {
// @ts-expect-error This is already type-checked by the prop types
navigation?.navigate(screen, params);
}
}
};
const getPathFromStateHelper = options?.getPathFromState ?? getPathFromState;
return {
href: href ?? (Platform.OS === 'web' && screen != null ? getPathFromStateHelper({
routes: [{
// @ts-expect-error this is fine 🔥
name: screen,
// @ts-expect-error this is fine 🔥
params: params,
// @ts-expect-error this is fine 🔥
state: getStateFromParams(params)
}]
}, options?.config) : undefined),
role: 'link',
onPress
};
}
//# sourceMappingURL=useLinkProps.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getPathFromState","NavigationContainerRefContext","NavigationHelpersContext","React","Platform","LinkingContext","getStateFromParams","params","state","screen","routes","name","undefined","useLinkProps","href","action","root","useContext","navigation","options","onPress","e","shouldHandle","OS","preventDefault","hasModifierKey","metaKey","altKey","ctrlKey","shiftKey","isLeftClick","button","isSelfTarget","currentTarget","includes","target","dispatch","Error","navigate","getPathFromStateHelper","config","role"],"sourceRoot":"../../src","sources":["useLinkProps.tsx"],"mappings":";;AAAA,SACEA,gBAAgB,EAEhBC,6BAA6B,EAC7BC,wBAAwB,QAGnB,wBAAwB;AAE/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAAqCC,QAAQ,QAAQ,cAAc;AAEnE,SAASC,cAAc,QAAQ,qBAAkB;AAqBjD,MAAMC,kBAAkB,GACtBC,MAAwD,IACQ;EAChE,IAAIA,MAAM,EAAEC,KAAK,EAAE;IACjB,OAAOD,MAAM,CAACC,KAAK;EACrB;EAEA,IAAID,MAAM,EAAEE,MAAM,EAAE;IAClB,OAAO;MACLC,MAAM,EAAE,CACN;QACEC,IAAI,EAAEJ,MAAM,CAACE,MAAM;QACnBF,MAAM,EAAEA,MAAM,CAACA,MAAM;QACrB;QACAC,KAAK,EAAED,MAAM,CAACE,MAAM,GAChBH,kBAAkB,CAChBC,MAAM,CAACA,MAGT,CAAC,GACDK;MACN,CAAC;IAEL,CAAC;EACH;EAEA,OAAOA,SAAS;AAClB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAkD;EAC5EJ,MAAM;EACNF,MAAM;EACNO,IAAI;EACJC;AACoB,CAAC,EAAE;EACvB,MAAMC,IAAI,GAAGb,KAAK,CAACc,UAAU,CAAChB,6BAA6B,CAAC;EAC5D,MAAMiB,UAAU,GAAGf,KAAK,CAACc,UAAU,CAACf,wBAAwB,CAAC;EAC7D,MAAM;IAAEiB;EAAQ,CAAC,GAAGhB,KAAK,CAACc,UAAU,CAACZ,cAAc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AAC,MAAM;QACL;QACAnB,UAAU,EAAEoB,QAAQ,CAAC7B,MAAM,EAAEF,MAAM,CAAC;MACtC;IACF;EACF,CAAC;EAED,MAAMgC,sBAAsB,GAAGpB,OAAO,EAAEnB,gBAAgB,IAAIA,gBAAgB;EAE5E,OAAO;IACLc,IAAI,EACFA,IAAI,KACHV,QAAQ,CAACmB,EAAE,KAAK,KAAK,IAAId,MAAM,IAAI,IAAI,GACpC8B,sBAAsB,CACpB;MACE7B,MAAM,EAAE,CACN;QACE;QACAC,IAAI,EAAEF,MAAM;QACZ;QACAF,MAAM,EAAEA,MAAM;QACd;QACAC,KAAK,EAAEF,kBAAkB,CAACC,MAAM;MAClC,CAAC;IAEL,CAAC,EACDY,OAAO,EAAEqB,MACX,CAAC,GACD5B,SAAS,CAAC;IAChB6B,IAAI,EAAE,MAAe;IACrBrB;EACF,CAAC;AACH","ignoreList":[]}

View File

@@ -0,0 +1,24 @@
"use strict";
import { NavigationContainerRefContext } from '@react-navigation/core';
import * as React from 'react';
import { useBuildAction } from "./useLinkBuilder.js";
/**
* Helper to navigate to a screen using a href based on the linking options.
*
* @returns function that receives the href to navigate to.
*/
export function useLinkTo() {
const navigation = React.useContext(NavigationContainerRefContext);
const buildAction = useBuildAction();
const linkTo = React.useCallback(href => {
if (navigation === undefined) {
throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
}
const action = buildAction(href);
navigation.dispatch(action);
}, [buildAction, navigation]);
return linkTo;
}
//# sourceMappingURL=useLinkTo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationContainerRefContext","React","useBuildAction","useLinkTo","navigation","useContext","buildAction","linkTo","useCallback","href","undefined","Error","action","dispatch"],"sourceRoot":"../../src","sources":["useLinkTo.tsx"],"mappings":";;AAAA,SAASA,6BAA6B,QAAQ,wBAAwB;AACtE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,cAAc,QAAQ,qBAAkB;;AAEjD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAA,EAAG;EAC1B,MAAMC,UAAU,GAAGH,KAAK,CAACI,UAAU,CAACL,6BAA6B,CAAC;EAClE,MAAMM,WAAW,GAAGJ,cAAc,CAAC,CAAC;EAEpC,MAAMK,MAAM,GAAGN,KAAK,CAACO,WAAW,CAC7BC,IAAY,IAAK;IAChB,IAAIL,UAAU,KAAKM,SAAS,EAAE;MAC5B,MAAM,IAAIC,KAAK,CACb,kFACF,CAAC;IACH;IAEA,MAAMC,MAAM,GAAGN,WAAW,CAACG,IAAI,CAAC;IAEhCL,UAAU,CAACS,QAAQ,CAACD,MAAM,CAAC;EAC7B,CAAC,EACD,CAACN,WAAW,EAAEF,UAAU,CAC1B,CAAC;EAED,OAAOG,MAAM;AACf","ignoreList":[]}

View File

@@ -0,0 +1,320 @@
"use strict";
import { findFocusedRoute, getActionFromState as getActionFromStateDefault, getPathFromState as getPathFromStateDefault, getStateFromPath as getStateFromPathDefault, useNavigationIndependentTree } from '@react-navigation/core';
import isEqual from 'fast-deep-equal';
import * as React from 'react';
import { createMemoryHistory } from "./createMemoryHistory.js";
import { ServerContext } from "./ServerContext.js";
/**
* Find the matching navigation state that changed between 2 navigation states
* e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state
*/
const findMatchingState = (a, b) => {
if (a === undefined || b === undefined || a.key !== b.key) {
return [undefined, undefined];
}
// Tab and drawer will have `history` property, but stack will have history in `routes`
const aHistoryLength = a.history ? a.history.length : a.routes.length;
const bHistoryLength = b.history ? b.history.length : b.routes.length;
const aRoute = a.routes[a.index];
const bRoute = b.routes[b.index];
const aChildState = aRoute.state;
const bChildState = bRoute.state;
// Stop here if this is the state object that changed:
// - history length is different
// - focused routes are different
// - one of them doesn't have child state
// - child state keys are different
if (aHistoryLength !== bHistoryLength || aRoute.key !== bRoute.key || aChildState === undefined || bChildState === undefined || aChildState.key !== bChildState.key) {
return [a, b];
}
return findMatchingState(aChildState, bChildState);
};
/**
* Run async function in series as it's called.
*/
export const series = cb => {
let queue = Promise.resolve();
const callback = () => {
// eslint-disable-next-line promise/no-callback-in-promise
queue = queue.then(cb);
};
return callback;
};
const linkingHandlers = [];
export function useLinking(ref, {
enabled = true,
config,
getStateFromPath = getStateFromPathDefault,
getPathFromState = getPathFromStateDefault,
getActionFromState = getActionFromStateDefault
}, onUnhandledLinking) {
const independent = useNavigationIndependentTree();
React.useEffect(() => {
if (process.env.NODE_ENV === 'production') {
return undefined;
}
if (independent) {
return undefined;
}
if (enabled !== false && linkingHandlers.length) {
console.error(['Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered'].join('\n').trim());
}
const handler = Symbol();
if (enabled !== false) {
linkingHandlers.push(handler);
}
return () => {
const index = linkingHandlers.indexOf(handler);
if (index > -1) {
linkingHandlers.splice(index, 1);
}
};
}, [enabled, independent]);
const [history] = React.useState(createMemoryHistory);
// We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
// This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
const enabledRef = React.useRef(enabled);
const configRef = React.useRef(config);
const getStateFromPathRef = React.useRef(getStateFromPath);
const getPathFromStateRef = React.useRef(getPathFromState);
const getActionFromStateRef = React.useRef(getActionFromState);
React.useEffect(() => {
enabledRef.current = enabled;
configRef.current = config;
getStateFromPathRef.current = getStateFromPath;
getPathFromStateRef.current = getPathFromState;
getActionFromStateRef.current = getActionFromState;
});
const validateRoutesNotExistInRootState = React.useCallback(state => {
const navigation = ref.current;
const rootState = navigation?.getRootState();
// Make sure that the routes in the state exist in the root navigator
// Otherwise there's an error in the linking configuration
return state?.routes.some(r => !rootState?.routeNames.includes(r.name));
}, [ref]);
const server = React.useContext(ServerContext);
const getInitialState = React.useCallback(() => {
let value;
if (enabledRef.current) {
const location = server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);
const path = location ? location.pathname + location.search : undefined;
if (path) {
value = getStateFromPathRef.current(path, configRef.current);
}
// If the link were handled, it gets cleared in NavigationContainer
onUnhandledLinking(path);
}
const thenable = {
then(onfulfilled) {
return Promise.resolve(onfulfilled ? onfulfilled(value) : value);
},
catch() {
return thenable;
}
};
return thenable;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const previousIndexRef = React.useRef(undefined);
const previousStateRef = React.useRef(undefined);
const pendingPopStatePathRef = React.useRef(undefined);
React.useEffect(() => {
previousIndexRef.current = history.index;
return history.listen(() => {
const navigation = ref.current;
if (!navigation || !enabled) {
return;
}
const {
location
} = window;
const path = location.pathname + location.search;
const index = history.index;
const previousIndex = previousIndexRef.current ?? 0;
previousIndexRef.current = index;
pendingPopStatePathRef.current = path;
// When browser back/forward is clicked, we first need to check if state object for this index exists
// If it does we'll reset to that state object
// Otherwise, we'll handle it like a regular deep link
const record = history.get(index);
if (record?.path === path && record?.state) {
navigation.resetRoot(record.state);
return;
}
const state = getStateFromPathRef.current(path, configRef.current);
// We should only dispatch an action when going forward
// Otherwise the action will likely add items to history, which would mess things up
if (state) {
// If the link were handled, it gets cleared in NavigationContainer
onUnhandledLinking(path);
// Make sure that the routes in the state exist in the root navigator
// Otherwise there's an error in the linking configuration
if (validateRoutesNotExistInRootState(state)) {
return;
}
if (index > previousIndex) {
const action = getActionFromStateRef.current(state, configRef.current);
if (action !== undefined) {
try {
navigation.dispatch(action);
} catch (e) {
// Ignore any errors from deep linking.
// This could happen in case of malformed links, navigation object not being initialized etc.
console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? e.message : e}`);
}
} else {
navigation.resetRoot(state);
}
} else {
navigation.resetRoot(state);
}
} else {
// if current path didn't return any state, we should revert to initial state
navigation.resetRoot(state);
}
});
}, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);
React.useEffect(() => {
if (!enabled) {
return;
}
const getPathForRoute = (route, state) => {
let path;
// If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match
// This makes sure that we preserve the original URL for wildcard routes
if (route?.path) {
const stateForPath = getStateFromPathRef.current(route.path, configRef.current);
if (stateForPath) {
const focusedRoute = findFocusedRoute(stateForPath);
if (focusedRoute && focusedRoute.name === route.name && isEqual(focusedRoute.params, route.params)) {
path = route.path;
}
}
}
if (path == null) {
path = getPathFromStateRef.current(state, configRef.current);
}
const previousRoute = previousStateRef.current ? findFocusedRoute(previousStateRef.current) : undefined;
// Preserve the hash if the route didn't change
if (previousRoute && route && 'key' in previousRoute && 'key' in route && previousRoute.key === route.key) {
path = path + location.hash;
}
return path;
};
if (ref.current) {
// We need to record the current metadata on the first render if they aren't set
// This will allow the initial state to be in the history entry
const state = ref.current.getRootState();
if (state) {
const route = findFocusedRoute(state);
const path = getPathForRoute(route, state);
if (previousStateRef.current === undefined) {
previousStateRef.current = state;
}
history.replace({
path,
state
});
}
}
const onStateChange = async () => {
const navigation = ref.current;
if (!navigation || !enabled) {
return;
}
const previousState = previousStateRef.current;
const state = navigation.getRootState();
// root state may not available, for example when root navigators switch inside the container
if (!state) {
return;
}
const pendingPath = pendingPopStatePathRef.current;
const route = findFocusedRoute(state);
const path = getPathForRoute(route, state);
previousStateRef.current = state;
pendingPopStatePathRef.current = undefined;
// To detect the kind of state change, we need to:
// - Find the common focused navigation state in previous and current state
// - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace
// - If no common focused navigation state found, it's a replace
const [previousFocusedState, focusedState] = findMatchingState(previousState, state);
if (previousFocusedState && focusedState &&
// We should only handle push/pop if path changed from what was in last `popstate`
// Otherwise it's likely a change triggered by `popstate`
path !== pendingPath) {
const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
if (historyDelta > 0) {
// If history length is increased, we should pushState
// Note that path might not actually change here, for example, drawer open should pushState
history.push({
path,
state
});
} else if (historyDelta < 0) {
// If history length is decreased, i.e. entries were removed, we want to go back
const nextIndex = history.backIndex({
path
});
const currentIndex = history.index;
try {
if (nextIndex !== -1 && nextIndex < currentIndex &&
// We should only go back if the entry exists and it's less than current index
history.get(nextIndex)) {
// An existing entry for this path exists and it's less than current index, go back to that
await history.go(nextIndex - currentIndex);
} else {
// We couldn't find an existing entry to go back to, so we'll go back by the delta
// This won't be correct if multiple routes were pushed in one go before
// Usually this shouldn't happen and this is a fallback for that
await history.go(historyDelta);
}
// Store the updated state as well as fix the path if incorrect
history.replace({
path,
state
});
} catch (e) {
// The navigation was interrupted
}
} else {
// If history length is unchanged, we want to replaceState
history.replace({
path,
state
});
}
} else {
// If no common navigation state was found, assume it's a replace
// This would happen if the user did a reset/conditionally changed navigators
history.replace({
path,
state
});
}
};
// We debounce onStateChange coz we don't want multiple state changes to be handled at one time
// This could happen since `history.go(n)` is asynchronous
// If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up
return ref.current?.addListener('state', series(onStateChange));
}, [enabled, history, ref]);
return {
getInitialState
};
}
//# sourceMappingURL=useLinking.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,148 @@
"use strict";
import { getActionFromState as getActionFromStateDefault, getStateFromPath as getStateFromPathDefault, useNavigationIndependentTree } from '@react-navigation/core';
import * as React from 'react';
import { Linking, Platform } from 'react-native';
import { extractPathFromURL } from "./extractPathFromURL.js";
const linkingHandlers = [];
export function useLinking(ref, {
enabled = true,
prefixes,
filter,
config,
getInitialURL = () => Promise.race([Linking.getInitialURL(), new Promise(resolve => {
// Timeout in 150ms if `getInitialState` doesn't resolve
// Workaround for https://github.com/facebook/react-native/issues/25675
setTimeout(resolve, 150);
})]),
subscribe = listener => {
const callback = ({
url
}) => listener(url);
const subscription = Linking.addEventListener('url', callback);
// Storing this in a local variable stops Jest from complaining about import after teardown
// @ts-expect-error: removeEventListener is not present in newer RN versions
const removeEventListener = Linking.removeEventListener?.bind(Linking);
return () => {
// https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7
if (subscription?.remove) {
subscription.remove();
} else {
removeEventListener?.('url', callback);
}
};
},
getStateFromPath = getStateFromPathDefault,
getActionFromState = getActionFromStateDefault
}, onUnhandledLinking) {
const independent = useNavigationIndependentTree();
React.useEffect(() => {
if (process.env.NODE_ENV === 'production') {
return undefined;
}
if (independent) {
return undefined;
}
if (enabled !== false && linkingHandlers.length) {
console.error(['Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered', Platform.OS === 'android' ? "- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances" : ''].join('\n').trim());
}
const handler = Symbol();
if (enabled !== false) {
linkingHandlers.push(handler);
}
return () => {
const index = linkingHandlers.indexOf(handler);
if (index > -1) {
linkingHandlers.splice(index, 1);
}
};
}, [enabled, independent]);
// We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
// This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
const enabledRef = React.useRef(enabled);
const prefixesRef = React.useRef(prefixes);
const filterRef = React.useRef(filter);
const configRef = React.useRef(config);
const getInitialURLRef = React.useRef(getInitialURL);
const getStateFromPathRef = React.useRef(getStateFromPath);
const getActionFromStateRef = React.useRef(getActionFromState);
React.useEffect(() => {
enabledRef.current = enabled;
prefixesRef.current = prefixes;
filterRef.current = filter;
configRef.current = config;
getInitialURLRef.current = getInitialURL;
getStateFromPathRef.current = getStateFromPath;
getActionFromStateRef.current = getActionFromState;
});
const getStateFromURL = React.useCallback(url => {
if (!url || filterRef.current && !filterRef.current(url)) {
return undefined;
}
const path = extractPathFromURL(prefixesRef.current, url);
return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;
}, []);
const getInitialState = React.useCallback(() => {
let state;
if (enabledRef.current) {
const url = getInitialURLRef.current();
if (url != null) {
if (typeof url !== 'string') {
return url.then(url => {
const state = getStateFromURL(url);
if (typeof url === 'string') {
// If the link were handled, it gets cleared in NavigationContainer
onUnhandledLinking(extractPathFromURL(prefixes, url));
}
return state;
});
} else {
onUnhandledLinking(extractPathFromURL(prefixes, url));
}
}
state = getStateFromURL(url);
}
const thenable = {
then(onfulfilled) {
return Promise.resolve(onfulfilled ? onfulfilled(state) : state);
},
catch() {
return thenable;
}
};
return thenable;
}, [getStateFromURL, onUnhandledLinking, prefixes]);
React.useEffect(() => {
const listener = url => {
if (!enabled) {
return;
}
const navigation = ref.current;
const state = navigation ? getStateFromURL(url) : undefined;
if (navigation && state) {
// If the link were handled, it gets cleared in NavigationContainer
onUnhandledLinking(extractPathFromURL(prefixes, url));
const action = getActionFromStateRef.current(state, configRef.current);
if (action !== undefined) {
try {
navigation.dispatch(action);
} catch (e) {
// Ignore any errors from deep linking.
// This could happen in case of malformed links, navigation object not being initialized etc.
console.warn(`An error occurred when trying to handle the link '${url}': ${typeof e === 'object' && e != null && 'message' in e ? e.message : e}`);
}
} else {
navigation.resetRoot(state);
}
}
};
return subscribe(listener);
}, [enabled, getStateFromURL, onUnhandledLinking, prefixes, ref, subscribe]);
return {
getInitialState
};
}
//# sourceMappingURL=useLinking.native.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
"use strict";
import * as React from 'react';
import { LocaleDirContext } from "./LocaleDirContext.js";
/**
* Hook to access the text direction specified in the `NavigationContainer`.
*/
export function useLocale() {
const direction = React.useContext(LocaleDirContext);
if (direction === undefined) {
throw new Error("Couldn't determine the text direction. Is your component inside NavigationContainer?");
}
return {
direction
};
}
//# sourceMappingURL=useLocale.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","LocaleDirContext","useLocale","direction","useContext","undefined","Error"],"sourceRoot":"../../src","sources":["useLocale.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,gBAAgB,QAAQ,uBAAoB;;AAErD;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAA,EAAG;EAC1B,MAAMC,SAAS,GAAGH,KAAK,CAACI,UAAU,CAACH,gBAAgB,CAAC;EAEpD,IAAIE,SAAS,KAAKE,SAAS,EAAE;IAC3B,MAAM,IAAIC,KAAK,CACb,sFACF,CAAC;EACH;EAEA,OAAO;IAAEH;EAAU,CAAC;AACtB","ignoreList":[]}

View File

@@ -0,0 +1,30 @@
"use strict";
import { getPathFromState, useStateForPath } from '@react-navigation/core';
import * as React from 'react';
import { LinkingContext } from "./LinkingContext.js";
/**
* Hook to get the path for the current route based on linking options.
*
* @returns Path for the current route.
*/
export function useRoutePath() {
const {
options
} = React.useContext(LinkingContext);
const state = useStateForPath();
if (state === undefined) {
throw new Error("Couldn't find a state for the route object. Is your component inside a screen in a navigator?");
}
const getPathFromStateHelper = options?.getPathFromState ?? getPathFromState;
const path = React.useMemo(() => {
if (options?.enabled === false) {
return undefined;
}
const path = getPathFromStateHelper(state, options?.config);
return path;
}, [options?.enabled, options?.config, state, getPathFromStateHelper]);
return path;
}
//# sourceMappingURL=useRoutePath.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getPathFromState","useStateForPath","React","LinkingContext","useRoutePath","options","useContext","state","undefined","Error","getPathFromStateHelper","path","useMemo","enabled","config"],"sourceRoot":"../../src","sources":["useRoutePath.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,EAAEC,eAAe,QAAQ,wBAAwB;AAC1E,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,cAAc,QAAQ,qBAAkB;;AAEjD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAG;EAC7B,MAAM;IAAEC;EAAQ,CAAC,GAAGH,KAAK,CAACI,UAAU,CAACH,cAAc,CAAC;EACpD,MAAMI,KAAK,GAAGN,eAAe,CAAC,CAAC;EAE/B,IAAIM,KAAK,KAAKC,SAAS,EAAE;IACvB,MAAM,IAAIC,KAAK,CACb,+FACF,CAAC;EACH;EAEA,MAAMC,sBAAsB,GAAGL,OAAO,EAAEL,gBAAgB,IAAIA,gBAAgB;EAE5E,MAAMW,IAAI,GAAGT,KAAK,CAACU,OAAO,CAAC,MAAM;IAC/B,IAAIP,OAAO,EAAEQ,OAAO,KAAK,KAAK,EAAE;MAC9B,OAAOL,SAAS;IAClB;IAEA,MAAMG,IAAI,GAAGD,sBAAsB,CAACH,KAAK,EAAEF,OAAO,EAAES,MAAM,CAAC;IAE3D,OAAOH,IAAI;EACb,CAAC,EAAE,CAACN,OAAO,EAAEQ,OAAO,EAAER,OAAO,EAAES,MAAM,EAAEP,KAAK,EAAEG,sBAAsB,CAAC,CAAC;EAEtE,OAAOC,IAAI;AACb","ignoreList":[]}

View File

@@ -0,0 +1,91 @@
"use strict";
import { NavigationContext, useRoute } from '@react-navigation/core';
import * as React from 'react';
function getScrollableNode(ref) {
if (ref.current == null) {
return null;
}
if ('scrollToTop' in ref.current || 'scrollTo' in ref.current || 'scrollToOffset' in ref.current || 'scrollResponderScrollTo' in ref.current) {
// This is already a scrollable node.
return ref.current;
} else if ('getScrollResponder' in ref.current) {
// If the view is a wrapper like FlatList, SectionList etc.
// We need to use `getScrollResponder` to get access to the scroll responder
return ref.current.getScrollResponder();
} else if ('getNode' in ref.current) {
// When a `ScrollView` is wrapped in `Animated.createAnimatedComponent`
// we need to use `getNode` to get the ref to the actual scrollview.
// Note that `getNode` is deprecated in newer versions of react-native
// this is why we check if we already have a scrollable node above.
return ref.current.getNode();
} else {
return ref.current;
}
}
export function useScrollToTop(ref) {
const navigation = React.useContext(NavigationContext);
const route = useRoute();
if (navigation === undefined) {
throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
}
React.useEffect(() => {
const tabNavigations = [];
let currentNavigation = navigation;
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
// So we need to find all the parent tab navigators and add the listeners there
while (currentNavigation) {
if (currentNavigation.getState().type === 'tab') {
tabNavigations.push(currentNavigation);
}
currentNavigation = currentNavigation.getParent();
}
if (tabNavigations.length === 0) {
return;
}
const unsubscribers = tabNavigations.map(tab => {
return tab.addListener(
// We don't wanna import tab types here to avoid extra deps
// in addition, there are multiple tab implementations
// @ts-expect-error the `tabPress` event is only available when navigation type is tab
'tabPress', e => {
// We should scroll to top only when the screen is focused
const isFocused = navigation.isFocused();
// In a nested stack navigator, tab press resets the stack to first screen
// So we should scroll to top only when we are on first screen
const isFirst = tabNavigations.includes(navigation) || navigation.getState().routes[0].key === route.key;
// Run the operation in the next frame so we're sure all listeners have been run
// This is necessary to know if preventDefault() has been called
requestAnimationFrame(() => {
const scrollable = getScrollableNode(ref);
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
if ('scrollToTop' in scrollable) {
scrollable.scrollToTop();
} else if ('scrollTo' in scrollable) {
scrollable.scrollTo({
y: 0,
animated: true
});
} else if ('scrollToOffset' in scrollable) {
scrollable.scrollToOffset({
offset: 0,
animated: true
});
} else if ('scrollResponderScrollTo' in scrollable) {
scrollable.scrollResponderScrollTo({
y: 0,
animated: true
});
}
}
});
});
});
return () => {
unsubscribers.forEach(unsubscribe => unsubscribe());
};
}, [navigation, ref, route.key]);
}
//# sourceMappingURL=useScrollToTop.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationContext","useRoute","React","getScrollableNode","ref","current","getScrollResponder","getNode","useScrollToTop","navigation","useContext","route","undefined","Error","useEffect","tabNavigations","currentNavigation","getState","type","push","getParent","length","unsubscribers","map","tab","addListener","e","isFocused","isFirst","includes","routes","key","requestAnimationFrame","scrollable","defaultPrevented","scrollToTop","scrollTo","y","animated","scrollToOffset","offset","scrollResponderScrollTo","forEach","unsubscribe"],"sourceRoot":"../../src","sources":["useScrollToTop.tsx"],"mappings":";;AAAA,SAEEA,iBAAiB,EAGjBC,QAAQ,QACH,wBAAwB;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAiB9B,SAASC,iBAAiBA,CAACC,GAAu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,WAAW,IAAKA,WAAW,CAAC,CAAC,CAAC;IACvD,CAAC;EACH,CAAC,EAAE,CAAClC,UAAU,EAAEL,GAAG,EAAEO,KAAK,CAACoB,GAAG,CAAC,CAAC;AAClC","ignoreList":[]}

View File

@@ -0,0 +1,36 @@
"use strict";
import * as React from 'react';
export function useThenable(create) {
const [promise] = React.useState(create);
let initialState = [false, undefined];
// Check if our thenable is synchronous
// eslint-disable-next-line promise/catch-or-return, promise/always-return
promise.then(result => {
initialState = [true, result];
});
const [state, setState] = React.useState(initialState);
const [resolved] = state;
React.useEffect(() => {
let cancelled = false;
const resolve = async () => {
let result;
try {
result = await promise;
} finally {
if (!cancelled) {
setState([true, result]);
}
}
};
if (!resolved) {
resolve();
}
return () => {
cancelled = true;
};
}, [promise, resolved]);
return state;
}
//# sourceMappingURL=useThenable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","useThenable","create","promise","useState","initialState","undefined","then","result","state","setState","resolved","useEffect","cancelled","resolve"],"sourceRoot":"../../src","sources":["useThenable.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,OAAO,SAASC,WAAWA,CAAIC,MAA4B,EAAE;EAC3D,MAAM,CAACC,OAAO,CAAC,GAAGH,KAAK,CAACI,QAAQ,CAACF,MAAM,CAAC;EAExC,IAAIG,YAAsC,GAAG,CAAC,KAAK,EAAEC,SAAS,CAAC;;EAE/D;EACA;EACAH,OAAO,CAACI,IAAI,CAAEC,MAAM,IAAK;IACvBH,YAAY,GAAG,CAAC,IAAI,EAAEG,MAAM,CAAC;EAC/B,CAAC,CAAC;EAEF,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGV,KAAK,CAACI,QAAQ,CAACC,YAAY,CAAC;EACtD,MAAM,CAACM,QAAQ,CAAC,GAAGF,KAAK;EAExBT,KAAK,CAACY,SAAS,CAAC,MAAM;IACpB,IAAIC,SAAS,GAAG,KAAK;IAErB,MAAMC,OAAO,GAAG,MAAAA,CAAA,KAAY;MAC1B,IAAIN,MAAM;MAEV,IAAI;QACFA,MAAM,GAAG,MAAML,OAAO;MACxB,CAAC,SAAS;QACR,IAAI,CAACU,SAAS,EAAE;UACdH,QAAQ,CAAC,CAAC,IAAI,EAAEF,MAAM,CAAC,CAAC;QAC1B;MACF;IACF,CAAC;IAED,IAAI,CAACG,QAAQ,EAAE;MACbG,OAAO,CAAC,CAAC;IACX;IAEA,OAAO,MAAM;MACXD,SAAS,GAAG,IAAI;IAClB,CAAC;EACH,CAAC,EAAE,CAACV,OAAO,EAAEQ,QAAQ,CAAC,CAAC;EAEvB,OAAOF,KAAK;AACd","ignoreList":[]}