1 line
25 KiB
Plaintext
1 line
25 KiB
Plaintext
{"version":3,"sources":["StackRouter.tsx"],"names":["StackActions","replace","name","params","type","payload","push","pop","count","popToTop","StackRouter","options","router","BaseRouter","getInitialState","routeNames","routeParamList","initialRouteName","undefined","includes","stale","key","index","routes","getRehydratedState","partialState","state","filter","route","map","length","getStateForRouteNamesChange","Math","min","getStateForRouteFocus","findIndex","r","slice","getStateForAction","action","target","source","i","getId","routeGetIdList","id","find","max","concat","merge","actionCreators"],"mappings":";;;;;;;;AAAA;;AACA;;;;AAkFO,MAAMA,YAAY,GAAG;AAC1BC,EAAAA,OAAO,CAACC,IAAD,EAAeC,MAAf,EAAiD;AACtD,WAAO;AAAEC,MAAAA,IAAI,EAAE,SAAR;AAAmBC,MAAAA,OAAO,EAAE;AAAEH,QAAAA,IAAF;AAAQC,QAAAA;AAAR;AAA5B,KAAP;AACD,GAHyB;;AAI1BG,EAAAA,IAAI,CAACJ,IAAD,EAAeC,MAAf,EAAiD;AACnD,WAAO;AAAEC,MAAAA,IAAI,EAAE,MAAR;AAAgBC,MAAAA,OAAO,EAAE;AAAEH,QAAAA,IAAF;AAAQC,QAAAA;AAAR;AAAzB,KAAP;AACD,GANyB;;AAO1BI,EAAAA,GAAG,CAACC,KAAa,GAAG,CAAjB,EAAqC;AACtC,WAAO;AAAEJ,MAAAA,IAAI,EAAE,KAAR;AAAeC,MAAAA,OAAO,EAAE;AAAEG,QAAAA;AAAF;AAAxB,KAAP;AACD,GATyB;;AAU1BC,EAAAA,QAAQ,GAAoB;AAC1B,WAAO;AAAEL,MAAAA,IAAI,EAAE;AAAR,KAAP;AACD;;AAZyB,CAArB;;;AAeQ,SAASM,WAAT,CAAqBC,OAArB,EAAkD;AAC/D,QAAMC,MAGL,GAAG,EACF,GAAGC,mBADD;AAGFT,IAAAA,IAAI,EAAE,OAHJ;;AAKFU,IAAAA,eAAe,CAAC;AAAEC,MAAAA,UAAF;AAAcC,MAAAA;AAAd,KAAD,EAAiC;AAC9C,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AACH,MAAN,CAAaD,KAAb,CAJE;AAHH,aAAP;AAUD;;AAED,iBAAO,IAAP;;AAEF,aAAK,SAAL;AACE,cAAII,KAAK,CAACJ,KAAN,GAAc,CAAlB,EAAqB;AACnB,mBAAOV,MAAM,CAAC0B,iBAAP,CACLZ,KADK,EAEL;AACEtB,cAAAA,IAAI,EAAE,KADR;AAEEC,cAAAA,OAAO,EAAE;AAAEG,gBAAAA,KAAK,EAAE;AAAT,eAFX;AAGEgC,cAAAA,MAAM,EAAED,MAAM,CAACC,MAHjB;AAIEC,cAAAA,MAAM,EAAEF,MAAM,CAACE;AAJjB,aAFK,EAQL9B,OARK,CAAP;AAUD;;AAED,iBAAO,IAAP;;AAEF;AACE,iBAAOE,oBAAWyB,iBAAX,CAA6BZ,KAA7B,EAAoCa,MAApC,CAAP;AAnQJ;AAqQD,KA5XC;;AA8XFW,IAAAA,cAAc,EAAElD;AA9Xd,GAHJ;AAoYA,SAAOY,MAAP;AACD","sourcesContent":["import { nanoid } from 'nanoid/non-secure';\nimport BaseRouter from './BaseRouter';\nimport type {\n NavigationState,\n CommonNavigationAction,\n Router,\n DefaultRouterOptions,\n Route,\n ParamListBase,\n} from './types';\n\nexport type StackActionType =\n | {\n type: 'REPLACE';\n payload: { name: string; key?: string | undefined; params?: object };\n source?: string;\n target?: string;\n }\n | {\n type: 'PUSH';\n payload: { name: string; key?: string | undefined; params?: object };\n source?: string;\n target?: string;\n }\n | {\n type: 'POP';\n payload: { count: number };\n source?: string;\n target?: string;\n }\n | {\n type: 'POP_TO_TOP';\n source?: string;\n target?: string;\n };\n\nexport type StackRouterOptions = DefaultRouterOptions;\n\nexport type StackNavigationState<\n ParamList extends ParamListBase\n> = NavigationState<ParamList> & {\n /**\n * Type of the router, in this case, it's stack.\n */\n type: 'stack';\n};\n\nexport type StackActionHelpers<ParamList extends ParamListBase> = {\n /**\n * Replace the current route with a new one.\n *\n * @param name Route name of the new route.\n * @param [params] Params object for the new route.\n */\n replace<RouteName extends keyof ParamList>(\n ...args: undefined extends ParamList[RouteName]\n ? [RouteName] | [RouteName, ParamList[RouteName]]\n : [RouteName, ParamList[RouteName]]\n ): void;\n\n /**\n * Push a new screen onto the stack.\n *\n * @param name Name of the route for the tab.\n * @param [params] Params object for the route.\n */\n push<RouteName extends keyof ParamList>(\n ...args: undefined extends ParamList[RouteName]\n ? [RouteName] | [RouteName, ParamList[RouteName]]\n : [RouteName, ParamList[RouteName]]\n ): void;\n\n /**\n * Pop a screen from the stack.\n */\n pop(count?: number): void;\n\n /**\n * Pop to the first route in the stack, dismissing all other screens.\n */\n popToTop(): void;\n};\n\nexport const StackActions = {\n replace(name: string, params?: object): StackActionType {\n return { type: 'REPLACE', payload: { name, params } };\n },\n push(name: string, params?: object): StackActionType {\n return { type: 'PUSH', payload: { name, params } };\n },\n pop(count: number = 1): StackActionType {\n return { type: 'POP', payload: { count } };\n },\n popToTop(): StackActionType {\n return { type: 'POP_TO_TOP' };\n },\n};\n\nexport default function StackRouter(options: StackRouterOptions) {\n const router: Router<\n StackNavigationState<ParamListBase>,\n CommonNavigationAction | StackActionType\n > = {\n ...BaseRouter,\n\n type: 'stack',\n\n getInitialState({ routeNames, routeParamList }) {\n const initialRouteName =\n options.initialRouteName !== undefined &&\n routeNames.includes(options.initialRouteName)\n ? options.initialRouteName\n : routeNames[0];\n\n return {\n stale: false,\n type: 'stack',\n key: `stack-${nanoid()}`,\n index: 0,\n routeNames,\n routes: [\n {\n key: `${initialRouteName}-${nanoid()}`,\n name: initialRouteName,\n params: routeParamList[initialRouteName],\n },\n ],\n };\n },\n\n getRehydratedState(partialState, { routeNames, routeParamList }) {\n let state = partialState;\n\n if (state.stale === false) {\n return state;\n }\n\n const routes = state.routes\n .filter((route) => routeNames.includes(route.name))\n .map(\n (route) =>\n ({\n ...route,\n key: route.key || `${route.name}-${nanoid()}`,\n params:\n routeParamList[route.name] !== undefined\n ? {\n ...routeParamList[route.name],\n ...route.params,\n }\n : route.params,\n } as Route<string>)\n );\n\n if (routes.length === 0) {\n const initialRouteName =\n options.initialRouteName !== undefined\n ? options.initialRouteName\n : routeNames[0];\n\n routes.push({\n key: `${initialRouteName}-${nanoid()}`,\n name: initialRouteName,\n params: routeParamList[initialRouteName],\n });\n }\n\n return {\n stale: false,\n type: 'stack',\n key: `stack-${nanoid()}`,\n index: routes.length - 1,\n routeNames,\n routes,\n };\n },\n\n getStateForRouteNamesChange(state, { routeNames, routeParamList }) {\n const routes = state.routes.filter((route) =>\n routeNames.includes(route.name)\n );\n\n if (routes.length === 0) {\n const initialRouteName =\n options.initialRouteName !== undefined &&\n routeNames.includes(options.initialRouteName)\n ? options.initialRouteName\n : routeNames[0];\n\n routes.push({\n key: `${initialRouteName}-${nanoid()}`,\n name: initialRouteName,\n params: routeParamList[initialRouteName],\n });\n }\n\n return {\n ...state,\n routeNames,\n routes,\n index: Math.min(state.index, routes.length - 1),\n };\n },\n\n getStateForRouteFocus(state, key) {\n const index = state.routes.findIndex((r) => r.key === key);\n\n if (index === -1 || index === state.index) {\n return state;\n }\n\n return {\n ...state,\n index,\n routes: state.routes.slice(0, index + 1),\n };\n },\n\n getStateForAction(state, action, options) {\n const { routeParamList } = options;\n\n switch (action.type) {\n case 'REPLACE': {\n const index =\n action.target === state.key && action.source\n ? state.routes.findIndex((r) => r.key === action.source)\n : state.index;\n\n if (index === -1) {\n return null;\n }\n\n const { name, key, params } = action.payload;\n\n if (!state.routeNames.includes(name)) {\n return null;\n }\n\n return {\n ...state,\n routes: state.routes.map((route, i) =>\n i === index\n ? {\n key: key !== undefined ? key : `${name}-${nanoid()}`,\n name,\n params:\n routeParamList[name] !== undefined\n ? {\n ...routeParamList[name],\n ...params,\n }\n : params,\n }\n : route\n ),\n };\n }\n\n case 'PUSH':\n if (state.routeNames.includes(action.payload.name)) {\n const getId = options.routeGetIdList[action.payload.name];\n const id = getId?.({ params: action.payload.params });\n\n const route =\n action.payload.name && action.payload.key\n ? state.routes.find(\n (route) =>\n route.name === action.payload.name &&\n route.key === action.payload.key\n )\n : id\n ? state.routes.find(\n (route) =>\n route.name === action.payload.name &&\n id === getId?.({ params: route.params })\n )\n : undefined;\n\n let routes: Route<string>[];\n\n if (route) {\n routes = state.routes.filter((r) => r.key !== route.key);\n routes.push({\n ...route,\n params:\n action.payload.params !== undefined\n ? {\n ...route.params,\n ...action.payload.params,\n }\n : route.params,\n });\n } else {\n routes = [\n ...state.routes,\n {\n key:\n action.payload.key ?? `${action.payload.name}-${nanoid()}`,\n name: action.payload.name,\n params:\n routeParamList[action.payload.name] !== undefined\n ? {\n ...routeParamList[action.payload.name],\n ...action.payload.params,\n }\n : action.payload.params,\n },\n ];\n }\n\n return {\n ...state,\n index: routes.length - 1,\n routes,\n };\n }\n\n return null;\n\n case 'POP': {\n const index =\n action.target === state.key && action.source\n ? state.routes.findIndex((r) => r.key === action.source)\n : state.index;\n\n if (index > 0) {\n const count = Math.max(index - action.payload.count + 1, 1);\n const routes = state.routes\n .slice(0, count)\n .concat(state.routes.slice(index + 1));\n\n return {\n ...state,\n index: routes.length - 1,\n routes,\n };\n }\n\n return null;\n }\n\n case 'POP_TO_TOP':\n return router.getStateForAction(\n state,\n {\n type: 'POP',\n payload: { count: state.routes.length - 1 },\n },\n options\n );\n\n case 'NAVIGATE':\n if (\n action.payload.name !== undefined &&\n !state.routeNames.includes(action.payload.name)\n ) {\n return null;\n }\n\n if (action.payload.key || action.payload.name) {\n // If the route already exists, navigate to that\n let index = -1;\n\n const getId =\n // `getId` and `key` can't be used together\n action.payload.key === undefined &&\n action.payload.name !== undefined\n ? options.routeGetIdList[action.payload.name]\n : undefined;\n const id = getId?.({ params: action.payload.params });\n\n if (id) {\n index = state.routes.findIndex(\n (route) =>\n route.name === action.payload.name &&\n id === getId?.({ params: route.params })\n );\n } else if (\n (state.routes[state.index].name === action.payload.name &&\n action.payload.key === undefined) ||\n state.routes[state.index].key === action.payload.key\n ) {\n index = state.index;\n } else {\n for (let i = state.routes.length - 1; i >= 0; i--) {\n if (\n (state.routes[i].name === action.payload.name &&\n action.payload.key === undefined) ||\n state.routes[i].key === action.payload.key\n ) {\n index = i;\n break;\n }\n }\n }\n\n if (\n index === -1 &&\n action.payload.key &&\n action.payload.name === undefined\n ) {\n return null;\n }\n\n if (index === -1 && action.payload.name !== undefined) {\n const routes = [\n ...state.routes,\n {\n key:\n action.payload.key ?? `${action.payload.name}-${nanoid()}`,\n name: action.payload.name,\n params:\n routeParamList[action.payload.name] !== undefined\n ? {\n ...routeParamList[action.payload.name],\n ...action.payload.params,\n }\n : action.payload.params,\n },\n ];\n\n return {\n ...state,\n routes,\n index: routes.length - 1,\n };\n }\n\n const route = state.routes[index];\n\n let params;\n\n if (action.payload.merge === false) {\n params =\n routeParamList[route.name] !== undefined\n ? {\n ...routeParamList[route.name],\n ...action.payload.params,\n }\n : action.payload.params;\n } else {\n params = action.payload.params\n ? {\n ...route.params,\n ...action.payload.params,\n }\n : route.params;\n }\n\n return {\n ...state,\n index,\n routes: [\n ...state.routes.slice(0, index),\n params !== route.params\n ? { ...route, params }\n : state.routes[index],\n ],\n };\n }\n\n return null;\n\n case 'GO_BACK':\n if (state.index > 0) {\n return router.getStateForAction(\n state,\n {\n type: 'POP',\n payload: { count: 1 },\n target: action.target,\n source: action.source,\n },\n options\n );\n }\n\n return null;\n\n default:\n return BaseRouter.getStateForAction(state, action);\n }\n },\n\n actionCreators: StackActions,\n };\n\n return router;\n}\n"]} |