expo-router 4.0.0-preview.10 → 4.0.0-preview.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/fast-refresh.d.ts.map +1 -1
- package/build/fast-refresh.js.map +1 -1
- package/build/getRoutesCore.d.ts +1 -0
- package/build/getRoutesCore.d.ts.map +1 -1
- package/build/getRoutesCore.js +3 -1
- package/build/getRoutesCore.js.map +1 -1
- package/build/head/url.d.ts +1 -0
- package/build/head/url.d.ts.map +1 -1
- package/build/head/url.js +21 -4
- package/build/head/url.js.map +1 -1
- package/build/hooks.d.ts +90 -38
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +46 -39
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.d.ts +58 -15
- package/build/imperative-api.d.ts.map +1 -1
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/withLayoutContext.d.ts +4 -1
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +4 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +48 -4
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +47 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/href.d.ts +1 -1
- package/build/link/href.d.ts.map +1 -1
- package/build/link/href.js.map +1 -1
- package/build/link/useLinkHooks.d.ts +122 -29
- package/build/link/useLinkHooks.d.ts.map +1 -1
- package/build/link/useLinkHooks.js.map +1 -1
- package/build/rsc/exports.d.ts +3 -1
- package/build/rsc/exports.d.ts.map +1 -1
- package/build/rsc/exports.js +3 -1
- package/build/rsc/exports.js.map +1 -1
- package/build/rsc/router/client.d.ts +2 -2
- package/build/rsc/router/client.d.ts.map +1 -1
- package/build/rsc/router/client.js.map +1 -1
- package/build/rsc/router/host.d.ts.map +1 -1
- package/build/rsc/router/host.js +20 -15
- package/build/rsc/router/host.js.map +1 -1
- package/build/rsc/rsc-renderer.d.ts +1 -1
- package/build/rsc/rsc-renderer.d.ts.map +1 -1
- package/build/rsc/rsc-renderer.js +1 -1
- package/build/rsc/rsc-renderer.js.map +1 -1
- package/build/testing-library/context-stubs.d.ts.map +1 -1
- package/build/testing-library/context-stubs.js +3 -1
- package/build/testing-library/context-stubs.js.map +1 -1
- package/build/testing-library/mocks.js +14 -13
- package/build/testing-library/mocks.js.map +1 -1
- package/build/typed-routes/generate.d.ts +5 -1
- package/build/typed-routes/generate.d.ts.map +1 -1
- package/build/typed-routes/generate.js +129 -64
- package/build/typed-routes/generate.js.map +1 -1
- package/build/typed-routes/index.d.ts +5 -0
- package/build/typed-routes/index.d.ts.map +1 -1
- package/build/typed-routes/index.js +8 -3
- package/build/typed-routes/index.js.map +1 -1
- package/build/typed-routes/testSetup.d.ts +1 -1
- package/build/typed-routes/testSetup.d.ts.map +1 -1
- package/build/typed-routes/testSetup.js +29 -17
- package/build/typed-routes/testSetup.js.map +1 -1
- package/build/typed-routes/types.d.ts +43 -145
- package/build/typed-routes/types.d.ts.map +1 -1
- package/build/typed-routes/types.js.map +1 -1
- package/build/types.d.ts +33 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/ui/TabContext.d.ts +157 -1
- package/build/ui/TabContext.d.ts.map +1 -1
- package/build/ui/TabContext.js +25 -1
- package/build/ui/TabContext.js.map +1 -1
- package/build/ui/TabList.d.ts +16 -0
- package/build/ui/TabList.d.ts.map +1 -1
- package/build/ui/TabList.js +16 -0
- package/build/ui/TabList.js.map +1 -1
- package/build/ui/TabSlot.d.ts +41 -5
- package/build/ui/TabSlot.d.ts.map +1 -1
- package/build/ui/TabSlot.js +36 -14
- package/build/ui/TabSlot.js.map +1 -1
- package/build/ui/TabTrigger.d.ts +50 -68
- package/build/ui/TabTrigger.d.ts.map +1 -1
- package/build/ui/TabTrigger.js +23 -1
- package/build/ui/TabTrigger.js.map +1 -1
- package/build/ui/Tabs.d.ts +96 -132
- package/build/ui/Tabs.d.ts.map +1 -1
- package/build/ui/Tabs.js +48 -8
- package/build/ui/Tabs.js.map +1 -1
- package/build/ui/common.d.ts +3 -3
- package/build/ui/common.d.ts.map +1 -1
- package/build/ui/common.js.map +1 -1
- package/build/useFocusEffect.d.ts +15 -6
- package/build/useFocusEffect.d.ts.map +1 -1
- package/build/useFocusEffect.js +15 -6
- package/build/useFocusEffect.js.map +1 -1
- package/build/useNavigation.d.ts +11 -5
- package/build/useNavigation.d.ts.map +1 -1
- package/build/useNavigation.js +11 -5
- package/build/useNavigation.js.map +1 -1
- package/build/views/Navigator.d.ts +6 -5
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Navigator.js +6 -5
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Try.d.ts +1 -1
- package/build/views/Try.d.ts.map +1 -1
- package/build/views/Try.js.map +1 -1
- package/entry-classic.js +0 -6
- package/package.json +4 -5
- package/plugin/build/index.d.ts +2 -0
- package/plugin/options.json +74 -73
- package/rsc/entry.js +0 -6
- package/build/rsc/runtime.d.ts +0 -9
- package/build/rsc/runtime.d.ts.map +0 -1
- package/build/rsc/runtime.js +0 -36
- package/build/rsc/runtime.js.map +0 -1
- package/virtual-client-boundaries.js +0 -1
package/build/ui/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/ui/common.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC,eAAO,MAAM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AC;gBACtB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;aAC1B;SACF;aAAM;YACL,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;gBAC/B,kBAAkB,GAAG,IAAI,CAAC;aAC3B;YACD,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACtE,IAAI,SAAS,EAAE;gBACb,KAAK,GAAG,SAAS,CAAC;aACnB;SACF;KACF;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,WAAW;KACrB,CAAC;AACJ,CAAC;AAvCD,sCAuCC","sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport { LinkingOptions, ParamListBase, PartialRoute, Route } from '@react-navigation/native';\nimport { ViewProps, View, SafeAreaView } from 'react-native';\n\nimport type { ExpoTabActionType } from './TabRouter';\nimport { UrlObject } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { sortRoutesWithInitial } from '../sortRoutes';\nimport { Href } from '../types';\nimport { routeToScreen } from '../useScreens';\n\n// Fix the TypeScript types for <Slot />. It complains about the ViewProps[\"style\"]\nexport const ViewSlot = Slot as React.ForwardRefExoticComponent<\n ViewProps & React.RefAttributes<View>\n>;\n\nexport const SafeAreaViewSlot = Slot as React.ForwardRefExoticComponent<\n ViewProps & React.RefAttributes<SafeAreaView>\n>;\n\nexport type ScreenTrigger<T extends string | object> =\n | {\n type: 'internal';\n href: Href<T>;\n name: string;\n }\n | {\n type: 'external';\n name: string;\n href: string;\n };\n\ntype JumpToNavigationAction = Extract<ExpoTabActionType, { type: 'JUMP_TO' }>;\ntype TriggerConfig =\n | {\n type: 'internal';\n name: string;\n href: string;\n routeNode: RouteNode;\n action: JumpToNavigationAction;\n }\n | { type: 'external'; name: string; href: string };\n\nexport type TriggerMap = Record<string, TriggerConfig & { index: number }>;\n\nexport function triggersToScreens(\n triggers: ScreenTrigger<any>[],\n layoutRouteNode: RouteNode,\n linking: LinkingOptions<ParamListBase>,\n initialRouteName: undefined | string,\n parentTriggerMap: TriggerMap,\n routeInfo: UrlObject,\n contextKey: string\n) {\n const configs: TriggerConfig[] = [];\n\n for (const trigger of triggers) {\n if (trigger.name in parentTriggerMap) {\n const parentTrigger = parentTriggerMap[trigger.name];\n throw new Error(\n `Trigger ${JSON.stringify({\n name: trigger.name,\n href: trigger.href,\n })} has the same name as parent trigger ${JSON.stringify({\n name: parentTrigger.name,\n href: parentTrigger.href,\n })}. Triggers must have unique names.`\n );\n }\n\n if (trigger.type === 'external') {\n configs.push(trigger);\n continue;\n }\n\n let resolvedHref = resolveHref(trigger.href);\n\n if (resolvedHref.startsWith('../')) {\n throw new Error('Trigger href cannot link to a parent directory');\n }\n\n const segmentsWithoutGroups = contextKey.split('/').filter((segment) => {\n return !(segment.startsWith('(') && segment.endsWith(')'));\n });\n\n resolvedHref = resolveHrefStringWithSegments(\n resolvedHref,\n {\n ...routeInfo,\n segments: segmentsWithoutGroups,\n },\n true\n );\n\n let state = linking.getStateFromPath?.(resolvedHref, linking.config)?.routes[0];\n\n if (!state) {\n // This shouldn't occur, as you should get the global +not-found\n console.warn(\n `Unable to find screen for trigger ${JSON.stringify(trigger)}. Does this point to a valid screen?`\n );\n continue;\n }\n\n let routeState = state;\n\n // The state object is the current state from the rootNavigator\n // We need to work out the state for just this trigger\n if (layoutRouteNode.route) {\n while (state?.state) {\n const previousState = state;\n if (previousState.name === layoutRouteNode.route) break;\n state = state.state.routes[state.state.index ?? state.state.routes.length - 1];\n }\n routeState = state.state?.routes[state.state.index ?? state.state.routes.length - 1] || state;\n }\n\n const routeNode = layoutRouteNode.children.find((child) => child.route === routeState?.name);\n if (!routeNode) {\n console.warn(\n `Unable to find routeNode for trigger ${JSON.stringify(trigger)}. This might be a bug with Expo Router`\n );\n continue;\n }\n\n if (routeNode.generated && routeNode.internal && routeNode.route.includes('+not-found')) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Tab trigger '${trigger.name}' has the href '${trigger.href}' which points to a +not-found route.`\n );\n }\n continue;\n }\n\n const duplicateTrigger =\n trigger.type === 'internal' &&\n configs.find((config): config is Extract<TriggerConfig, { type: 'internal' }> => {\n if (config.type === 'external') {\n return false;\n }\n\n return config.routeNode.route === routeNode.route;\n });\n\n if (duplicateTrigger) {\n const duplicateTriggerText = `${JSON.stringify({ name: duplicateTrigger.name, href: duplicateTrigger.href })} and ${JSON.stringify({ name: trigger.name, href: trigger.href })}`;\n\n throw new Error(\n `A navigator cannot contain multiple trigger components that map to the same sub-segment. Consider adding a shared group and assigning a group to each trigger. Conflicting triggers:\\n\\t${duplicateTriggerText}.\\nBoth triggers map to route ${routeNode.route}.`\n );\n }\n\n configs.push({\n ...trigger,\n href: resolvedHref,\n routeNode,\n action: stateToAction(state, layoutRouteNode.route),\n });\n }\n\n const sortFn = sortRoutesWithInitial(initialRouteName);\n\n const sortedConfigs = configs.sort((a, b) => {\n // External routes should be last. They will eventually be dropped\n if (a.type === 'external' && b.type === 'external') {\n return 0;\n } else if (a.type === 'external') {\n return 1;\n } else if (b.type === 'external') {\n return -1;\n }\n\n return sortFn(a.routeNode, b.routeNode);\n });\n\n const children: React.JSX.Element[] = [];\n const triggerMap: TriggerMap = { ...parentTriggerMap };\n\n for (const [index, config] of sortedConfigs.entries()) {\n triggerMap[config.name] = { ...config, index };\n\n if (config.type === 'internal') {\n children.push(routeToScreen(config.routeNode));\n }\n }\n return {\n children,\n triggerMap,\n };\n}\n\nexport function stateToAction(\n state: PartialRoute<Route<string, object | undefined>> | undefined,\n startAtRoute?: string\n): JumpToNavigationAction {\n const rootPayload: any = {};\n let payload = rootPayload;\n\n let foundStartingPoint = !startAtRoute || !state?.state;\n\n while (state) {\n if (foundStartingPoint) {\n if (payload === rootPayload) {\n payload.name = state.name;\n } else {\n payload.screen = state.name;\n }\n payload.params = state.params ? { ...state.params } : {};\n\n state = state.state?.routes[state.state?.routes.length - 1];\n\n if (state) {\n payload.params ??= {};\n payload = payload.params;\n }\n } else {\n if (state.name === startAtRoute) {\n foundStartingPoint = true;\n }\n const nextState = state.state?.routes[state.state?.routes.length - 1];\n if (nextState) {\n state = nextState;\n }\n }\n }\n\n return {\n type: 'JUMP_TO',\n payload: rootPayload,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/ui/common.tsx"],"names":[],"mappings":";;;AAAA,qDAA4C;AAO5C,uCAA0E;AAC1E,8CAAsD;AAEtD,8CAA8C;AAE9C,mFAAmF;AACtE,QAAA,QAAQ,GAAG,iBAEvB,CAAC;AAEW,QAAA,gBAAgB,GAAG,iBAE/B,CAAC;AA2BF,SAAgB,iBAAiB,CAC/B,QAAyB,EACzB,eAA0B,EAC1B,OAAsC,EACtC,gBAAoC,EACpC,gBAA4B,EAC5B,SAAoB,EACpB,UAAkB;IAElB,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,IAAI,OAAO,CAAC,IAAI,IAAI,gBAAgB,EAAE;YACpC,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACrD,MAAM,IAAI,KAAK,CACb,WAAW,IAAI,CAAC,SAAS,CAAC;gBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC,wCAAwC,IAAI,CAAC,SAAS,CAAC;gBACvD,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,IAAI,EAAE,aAAa,CAAC,IAAI;aACzB,CAAC,oCAAoC,CACvC,CAAC;SACH;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE;YAC/B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,SAAS;SACV;QAED,IAAI,YAAY,GAAG,IAAA,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aACnB;SACF;KACF;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,WAAW;KACrB,CAAC;AACJ,CAAC;AAvCD,sCAuCC","sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport { LinkingOptions, ParamListBase, PartialRoute, Route } from '@react-navigation/native';\nimport { ViewProps, View, SafeAreaView } from 'react-native';\n\nimport type { ExpoTabActionType } from './TabRouter';\nimport { UrlObject } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { sortRoutesWithInitial } from '../sortRoutes';\nimport { Href } from '../types';\nimport { routeToScreen } from '../useScreens';\n\n// Fix the TypeScript types for <Slot />. It complains about the ViewProps[\"style\"]\nexport const ViewSlot = Slot as React.ForwardRefExoticComponent<\n ViewProps & React.RefAttributes<View>\n>;\n\nexport const SafeAreaViewSlot = Slot as React.ForwardRefExoticComponent<\n ViewProps & React.RefAttributes<SafeAreaView>\n>;\n\nexport type ScreenTrigger =\n | {\n type: 'internal';\n href: Href;\n name: string;\n }\n | {\n type: 'external';\n name: string;\n href: string;\n };\n\ntype JumpToNavigationAction = Extract<ExpoTabActionType, { type: 'JUMP_TO' }>;\ntype TriggerConfig =\n | {\n type: 'internal';\n name: string;\n href: string;\n routeNode: RouteNode;\n action: JumpToNavigationAction;\n }\n | { type: 'external'; name: string; href: string };\n\nexport type TriggerMap = Record<string, TriggerConfig & { index: number }>;\n\nexport function triggersToScreens(\n triggers: ScreenTrigger[],\n layoutRouteNode: RouteNode,\n linking: LinkingOptions<ParamListBase>,\n initialRouteName: undefined | string,\n parentTriggerMap: TriggerMap,\n routeInfo: UrlObject,\n contextKey: string\n) {\n const configs: TriggerConfig[] = [];\n\n for (const trigger of triggers) {\n if (trigger.name in parentTriggerMap) {\n const parentTrigger = parentTriggerMap[trigger.name];\n throw new Error(\n `Trigger ${JSON.stringify({\n name: trigger.name,\n href: trigger.href,\n })} has the same name as parent trigger ${JSON.stringify({\n name: parentTrigger.name,\n href: parentTrigger.href,\n })}. Triggers must have unique names.`\n );\n }\n\n if (trigger.type === 'external') {\n configs.push(trigger);\n continue;\n }\n\n let resolvedHref = resolveHref(trigger.href);\n\n if (resolvedHref.startsWith('../')) {\n throw new Error('Trigger href cannot link to a parent directory');\n }\n\n const segmentsWithoutGroups = contextKey.split('/').filter((segment) => {\n return !(segment.startsWith('(') && segment.endsWith(')'));\n });\n\n resolvedHref = resolveHrefStringWithSegments(\n resolvedHref,\n {\n ...routeInfo,\n segments: segmentsWithoutGroups,\n },\n true\n );\n\n let state = linking.getStateFromPath?.(resolvedHref, linking.config)?.routes[0];\n\n if (!state) {\n // This shouldn't occur, as you should get the global +not-found\n console.warn(\n `Unable to find screen for trigger ${JSON.stringify(trigger)}. Does this point to a valid screen?`\n );\n continue;\n }\n\n let routeState = state;\n\n // The state object is the current state from the rootNavigator\n // We need to work out the state for just this trigger\n if (layoutRouteNode.route) {\n while (state?.state) {\n const previousState = state;\n if (previousState.name === layoutRouteNode.route) break;\n state = state.state.routes[state.state.index ?? state.state.routes.length - 1];\n }\n routeState = state.state?.routes[state.state.index ?? state.state.routes.length - 1] || state;\n }\n\n const routeNode = layoutRouteNode.children.find((child) => child.route === routeState?.name);\n if (!routeNode) {\n console.warn(\n `Unable to find routeNode for trigger ${JSON.stringify(trigger)}. This might be a bug with Expo Router`\n );\n continue;\n }\n\n if (routeNode.generated && routeNode.internal && routeNode.route.includes('+not-found')) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Tab trigger '${trigger.name}' has the href '${trigger.href}' which points to a +not-found route.`\n );\n }\n continue;\n }\n\n const duplicateTrigger =\n trigger.type === 'internal' &&\n configs.find((config): config is Extract<TriggerConfig, { type: 'internal' }> => {\n if (config.type === 'external') {\n return false;\n }\n\n return config.routeNode.route === routeNode.route;\n });\n\n if (duplicateTrigger) {\n const duplicateTriggerText = `${JSON.stringify({ name: duplicateTrigger.name, href: duplicateTrigger.href })} and ${JSON.stringify({ name: trigger.name, href: trigger.href })}`;\n\n throw new Error(\n `A navigator cannot contain multiple trigger components that map to the same sub-segment. Consider adding a shared group and assigning a group to each trigger. Conflicting triggers:\\n\\t${duplicateTriggerText}.\\nBoth triggers map to route ${routeNode.route}.`\n );\n }\n\n configs.push({\n ...trigger,\n href: resolvedHref,\n routeNode,\n action: stateToAction(state, layoutRouteNode.route),\n });\n }\n\n const sortFn = sortRoutesWithInitial(initialRouteName);\n\n const sortedConfigs = configs.sort((a, b) => {\n // External routes should be last. They will eventually be dropped\n if (a.type === 'external' && b.type === 'external') {\n return 0;\n } else if (a.type === 'external') {\n return 1;\n } else if (b.type === 'external') {\n return -1;\n }\n\n return sortFn(a.routeNode, b.routeNode);\n });\n\n const children: React.JSX.Element[] = [];\n const triggerMap: TriggerMap = { ...parentTriggerMap };\n\n for (const [index, config] of sortedConfigs.entries()) {\n triggerMap[config.name] = { ...config, index };\n\n if (config.type === 'internal') {\n children.push(routeToScreen(config.routeNode));\n }\n }\n return {\n children,\n triggerMap,\n };\n}\n\nexport function stateToAction(\n state: PartialRoute<Route<string, object | undefined>> | undefined,\n startAtRoute?: string\n): JumpToNavigationAction {\n const rootPayload: any = {};\n let payload = rootPayload;\n\n let foundStartingPoint = !startAtRoute || !state?.state;\n\n while (state) {\n if (foundStartingPoint) {\n if (payload === rootPayload) {\n payload.name = state.name;\n } else {\n payload.screen = state.name;\n }\n payload.params = state.params ? { ...state.params } : {};\n\n state = state.state?.routes[state.state?.routes.length - 1];\n\n if (state) {\n payload.params ??= {};\n payload = payload.params;\n }\n } else {\n if (state.name === startAtRoute) {\n foundStartingPoint = true;\n }\n const nextState = state.state?.routes[state.state?.routes.length - 1];\n if (nextState) {\n state = nextState;\n }\n }\n }\n\n return {\n type: 'JUMP_TO',\n payload: rootPayload,\n };\n}\n"]}
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type EffectCallback = () => undefined | void | (() => void);
|
|
5
5
|
/**
|
|
6
|
-
* Hook to run an effect whenever a route is
|
|
6
|
+
* Hook to run an effect whenever a route is **focused**. Similar to
|
|
7
|
+
* [`React.useEffect`](https://react.dev/reference/react/useEffect).
|
|
8
|
+
*
|
|
7
9
|
* This can be used to perform side-effects such as fetching data or subscribing to events.
|
|
8
|
-
* The passed callback should be wrapped in `React.useCallback`
|
|
10
|
+
* The passed callback should be wrapped in [`React.useCallback`](https://react.dev/reference/react/useCallback)
|
|
11
|
+
* to avoid running the effect too often.
|
|
9
12
|
*
|
|
10
13
|
* @example
|
|
11
14
|
* ```tsx
|
|
@@ -17,10 +20,16 @@ export type EffectCallback = () => undefined | void | (() => void);
|
|
|
17
20
|
* // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.
|
|
18
21
|
* useCallback(() => {
|
|
19
22
|
* // Invoked whenever the route is focused.
|
|
20
|
-
* console.log('Hello')
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
* console.log('Hello, I'm focused!');
|
|
24
|
+
*
|
|
25
|
+
* // Return function is invoked whenever the route gets out of focus.
|
|
26
|
+
* return () => {
|
|
27
|
+
* console.log('This route is now unfocused.');
|
|
28
|
+
* };
|
|
29
|
+
* }, []);
|
|
30
|
+
* );
|
|
31
|
+
*
|
|
32
|
+
* return </>;
|
|
24
33
|
* }
|
|
25
34
|
*```
|
|
26
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusEffect.d.ts","sourceRoot":"","sources":["../src/useFocusEffect.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEnE
|
|
1
|
+
{"version":3,"file":"useFocusEffect.d.ts","sourceRoot":"","sources":["../src/useFocusEffect.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,yBAAyB,CAAC,EAAE,KAAK,QAsGvF"}
|
package/build/useFocusEffect.js
CHANGED
|
@@ -30,9 +30,12 @@ exports.useFocusEffect = void 0;
|
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
31
|
const useLoadedNavigation_1 = require("./link/useLoadedNavigation");
|
|
32
32
|
/**
|
|
33
|
-
* Hook to run an effect whenever a route is
|
|
33
|
+
* Hook to run an effect whenever a route is **focused**. Similar to
|
|
34
|
+
* [`React.useEffect`](https://react.dev/reference/react/useEffect).
|
|
35
|
+
*
|
|
34
36
|
* This can be used to perform side-effects such as fetching data or subscribing to events.
|
|
35
|
-
* The passed callback should be wrapped in `React.useCallback`
|
|
37
|
+
* The passed callback should be wrapped in [`React.useCallback`](https://react.dev/reference/react/useCallback)
|
|
38
|
+
* to avoid running the effect too often.
|
|
36
39
|
*
|
|
37
40
|
* @example
|
|
38
41
|
* ```tsx
|
|
@@ -44,10 +47,16 @@ const useLoadedNavigation_1 = require("./link/useLoadedNavigation");
|
|
|
44
47
|
* // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.
|
|
45
48
|
* useCallback(() => {
|
|
46
49
|
* // Invoked whenever the route is focused.
|
|
47
|
-
* console.log('Hello')
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* console.log('Hello, I'm focused!');
|
|
51
|
+
*
|
|
52
|
+
* // Return function is invoked whenever the route gets out of focus.
|
|
53
|
+
* return () => {
|
|
54
|
+
* console.log('This route is now unfocused.');
|
|
55
|
+
* };
|
|
56
|
+
* }, []);
|
|
57
|
+
* );
|
|
58
|
+
*
|
|
59
|
+
* return </>;
|
|
51
60
|
* }
|
|
52
61
|
*```
|
|
53
62
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusEffect.js","sourceRoot":"","sources":["../src/useFocusEffect.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,gFAAgF;AAChF,sEAAsE;AACtE,6CAA+B;AAE/B,oEAAmE;AAOnE
|
|
1
|
+
{"version":3,"file":"useFocusEffect.js","sourceRoot":"","sources":["../src/useFocusEffect.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,gFAAgF;AAChF,sEAAsE;AACtE,6CAA+B;AAE/B,oEAAmE;AAOnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,cAAc,CAAC,MAAsB,EAAE,yBAAiC;IACtF,MAAM,UAAU,GAAG,IAAA,2CAAqB,GAAE,CAAC;IAE3C,IAAI,yBAAyB,KAAK,SAAS,EAAE;QAC3C,MAAM,OAAO,GACX,sFAAsF;YACtF,8EAA8E;YAC9E,mBAAmB;YACnB,+BAA+B;YAC/B,yBAAyB;YACzB,sBAAsB;YACtB,QAAQ;YACR,oEAAoE,CAAC;QAEvE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB;IAED,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,OAAwC,CAAC;QAE7C,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;YAEzB,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;gBAC1D,OAAO,OAAO,CAAC;aAChB;YAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;gBACzC,IAAI,OAAO,GACT,6FAA6F,CAAC;gBAEhG,IAAI,OAAO,KAAK,IAAI,EAAE;oBACpB,OAAO;wBACL,kGAAkG,C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,CAAC;YACnB,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAC3B,CAAC;AAtGD,wCAsGC","sourcesContent":["'use client';\n// A fork of `useFocusEffect` that waits for the navigation state to load before\n// running the effect. This is especially useful for native redirects.\nimport * as React from 'react';\n\nimport { useOptionalNavigation } from './link/useLoadedNavigation';\n\n/**\n * Memoized callback containing the effect, should optionally return a cleanup function.\n */\nexport type EffectCallback = () => undefined | void | (() => void);\n\n/**\n * Hook to run an effect whenever a route is **focused**. Similar to\n * [`React.useEffect`](https://react.dev/reference/react/useEffect).\n *\n * This can be used to perform side-effects such as fetching data or subscribing to events.\n * The passed callback should be wrapped in [`React.useCallback`](https://react.dev/reference/react/useCallback)\n * to avoid running the effect too often.\n *\n * @example\n * ```tsx\n * import { useFocusEffect } from 'expo-router';\n * import { useCallback } from 'react';\n *\n * export default function Route() {\n * useFocusEffect(\n * // Callback should be wrapped in `React.useCallback` to avoid running the effect too often.\n * useCallback(() => {\n * // Invoked whenever the route is focused.\n * console.log('Hello, I'm focused!');\n *\n * // Return function is invoked whenever the route gets out of focus.\n * return () => {\n * console.log('This route is now unfocused.');\n * };\n * }, []);\n * );\n *\n * return </>;\n * }\n *```\n *\n * @param effect Memoized callback containing the effect, should optionally return a cleanup function.\n * @param do_not_pass_a_second_prop\n */\nexport function useFocusEffect(effect: EffectCallback, do_not_pass_a_second_prop?: never) {\n const navigation = useOptionalNavigation();\n\n if (do_not_pass_a_second_prop !== undefined) {\n const message =\n \"You passed a second argument to 'useFocusEffect', but it only accepts one argument. \" +\n \"If you want to pass a dependency array, you can use 'React.useCallback':\\n\\n\" +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' // Your code here\\n' +\n ' }, [depA, depB])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n\n console.error(message);\n }\n\n React.useEffect(() => {\n if (!navigation) {\n return;\n }\n\n let isFocused = false;\n let cleanup: undefined | void | (() => void);\n\n const callback = () => {\n const destroy = effect();\n\n if (destroy === undefined || typeof destroy === 'function') {\n return destroy;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n let message =\n 'An effect function must not return anything besides a function, which is used for clean-up.';\n\n if (destroy === null) {\n message +=\n \" You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing).\";\n } else if (typeof (destroy as any).then === 'function') {\n message +=\n \"\\n\\nIt looks like you wrote 'useFocusEffect(async () => ...)' or returned a Promise. \" +\n 'Instead, write the async function inside your effect ' +\n 'and call it immediately:\\n\\n' +\n 'useFocusEffect(\\n' +\n ' React.useCallback(() => {\\n' +\n ' async function fetchData() {\\n' +\n ' // You can await here\\n' +\n ' const response = await MyAPI.getData(someId);\\n' +\n ' // ...\\n' +\n ' }\\n\\n' +\n ' fetchData();\\n' +\n ' }, [someId])\\n' +\n ');\\n\\n' +\n 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';\n } else {\n message += ` You returned '${JSON.stringify(destroy)}'.`;\n }\n\n console.error(message);\n }\n };\n\n // We need to run the effect on initial render/dep changes if the screen is focused\n if (navigation.isFocused()) {\n cleanup = callback();\n isFocused = true;\n }\n\n const unsubscribeFocus = navigation.addListener('focus', () => {\n // If callback was already called for focus, avoid calling it again\n // The focus event may also fire on initial render, so we guard against running the effect twice\n if (isFocused) {\n return;\n }\n\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = callback();\n isFocused = true;\n });\n\n const unsubscribeBlur = navigation.addListener('blur', () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n cleanup = undefined;\n isFocused = false;\n });\n\n return () => {\n if (cleanup !== undefined) {\n cleanup();\n }\n\n unsubscribeFocus();\n unsubscribeBlur();\n };\n }, [effect, navigation]);\n}\n"]}
|
package/build/useNavigation.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { NavigationProp } from '@react-navigation/native';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)
|
|
4
|
+
* to imperatively access layout-specific functionality like `navigation.openDrawer()` in a
|
|
5
|
+
* [Drawer](/router/advanced/drawer/) layout.
|
|
4
6
|
*
|
|
5
7
|
* @example
|
|
6
|
-
* ```tsx
|
|
8
|
+
* ```tsx app/index.tsx
|
|
7
9
|
* import { useNavigation } from 'expo-router';
|
|
8
10
|
*
|
|
9
11
|
* export default function Route() {
|
|
@@ -23,7 +25,8 @@ import { NavigationProp } from '@react-navigation/native';
|
|
|
23
25
|
* }
|
|
24
26
|
* ```
|
|
25
27
|
*
|
|
26
|
-
* When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.
|
|
28
|
+
* When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.
|
|
29
|
+
* For example, `/menu/_layout.tsx` is nested inside `/app/orders/`, you can use `useNavigation('/orders/menu/')`.
|
|
27
30
|
*
|
|
28
31
|
* @example
|
|
29
32
|
* ```tsx app/orders/menu/index.tsx
|
|
@@ -38,12 +41,15 @@ import { NavigationProp } from '@react-navigation/native';
|
|
|
38
41
|
* }
|
|
39
42
|
* ```
|
|
40
43
|
*
|
|
41
|
-
* If you attempt to access a layout that doesn't exist, an error such as
|
|
44
|
+
* If you attempt to access a layout that doesn't exist, an error such as
|
|
45
|
+
* `Could not find parent navigation with route "/non-existent"` is thrown.
|
|
42
46
|
*
|
|
43
|
-
* See React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions) for more information.
|
|
44
47
|
*
|
|
45
48
|
* @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.
|
|
46
49
|
* @returns The navigation object for the current route.
|
|
50
|
+
*
|
|
51
|
+
* @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)
|
|
52
|
+
* for more information.
|
|
47
53
|
*/
|
|
48
54
|
export declare function useNavigation<T = NavigationProp<ReactNavigation.RootParamList>>(parent?: string): T;
|
|
49
55
|
export declare function resolveParentId(contextKey: string, parentId?: string | null): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAA0C,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAMlG
|
|
1
|
+
{"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAA0C,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAMlG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,EAC7E,MAAM,CAAC,EAAE,MAAM,GACd,CAAC,CA8BH;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAS3F"}
|
package/build/useNavigation.js
CHANGED
|
@@ -10,10 +10,12 @@ const react_1 = __importDefault(require("react"));
|
|
|
10
10
|
const Route_1 = require("./Route");
|
|
11
11
|
const matchers_1 = require("./matchers");
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)
|
|
14
|
+
* to imperatively access layout-specific functionality like `navigation.openDrawer()` in a
|
|
15
|
+
* [Drawer](/router/advanced/drawer/) layout.
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
16
|
-
* ```tsx
|
|
18
|
+
* ```tsx app/index.tsx
|
|
17
19
|
* import { useNavigation } from 'expo-router';
|
|
18
20
|
*
|
|
19
21
|
* export default function Route() {
|
|
@@ -33,7 +35,8 @@ const matchers_1 = require("./matchers");
|
|
|
33
35
|
* }
|
|
34
36
|
* ```
|
|
35
37
|
*
|
|
36
|
-
* When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.
|
|
38
|
+
* When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.
|
|
39
|
+
* For example, `/menu/_layout.tsx` is nested inside `/app/orders/`, you can use `useNavigation('/orders/menu/')`.
|
|
37
40
|
*
|
|
38
41
|
* @example
|
|
39
42
|
* ```tsx app/orders/menu/index.tsx
|
|
@@ -48,12 +51,15 @@ const matchers_1 = require("./matchers");
|
|
|
48
51
|
* }
|
|
49
52
|
* ```
|
|
50
53
|
*
|
|
51
|
-
* If you attempt to access a layout that doesn't exist, an error such as
|
|
54
|
+
* If you attempt to access a layout that doesn't exist, an error such as
|
|
55
|
+
* `Could not find parent navigation with route "/non-existent"` is thrown.
|
|
52
56
|
*
|
|
53
|
-
* See React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions) for more information.
|
|
54
57
|
*
|
|
55
58
|
* @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.
|
|
56
59
|
* @returns The navigation object for the current route.
|
|
60
|
+
*
|
|
61
|
+
* @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)
|
|
62
|
+
* for more information.
|
|
57
63
|
*/
|
|
58
64
|
function useNavigation(parent) {
|
|
59
65
|
const navigation = (0, native_1.useNavigation)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AACb,qDAAkG;AAClG,kDAA0B;AAE1B,mCAAwC;AACxC,yCAAiD;AAEjD
|
|
1
|
+
{"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AACb,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AAA,8BAAmB,EAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;KACjE;IACD,OAAO,IAAA,8BAAmB,EAAC,QAAQ,CAAC,CAAC;AACvC,CAAC;AATD,0CASC;AAED,+DAA+D;AAC/D,SAAS,aAAa,CAAC,IAAY,EAAE,EAAU;IAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE9C,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;QAC1B,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,wBAAwB,EAAE,kBAAkB,IAAI,GAAG,CAAC,CAAC;aACtE;YACD,SAAS,CAAC,GAAG,EAAE,CAAC;SACjB;aAAM,IAAI,IAAI,KAAK,GAAG,EAAE;YACvB,SAAS;SACV;aAAM;YACL,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACtB;KACF;IAED,OAAO,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC","sourcesContent":["'use client';\nimport { useNavigation as useUpstreamNavigation, NavigationProp } from '@react-navigation/native';\nimport React from 'react';\n\nimport { useContextKey } from './Route';\nimport { getNameFromFilePath } from './matchers';\n\n/**\n * Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)\n * to imperatively access layout-specific functionality like `navigation.openDrawer()` in a\n * [Drawer](/router/advanced/drawer/) layout.\n *\n * @example\n * ```tsx app/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function Route() {\n * // Access the current navigation object for the current route.\n * const navigation = useNavigation();\n *\n * return (\n * <View>\n * <Text onPress={() => {\n * // Open the drawer view.\n * navigation.openDrawer();\n * }}>\n * Open Drawer\n * </Text>\n * </View>\n * );\n * }\n * ```\n *\n * When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.\n * For example, `/menu/_layout.tsx` is nested inside `/app/orders/`, you can use `useNavigation('/orders/menu/')`.\n *\n * @example\n * ```tsx app/orders/menu/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function MenuRoute() {\n * const rootLayout = useNavigation('/');\n * const ordersLayout = useNavigation('/orders');\n *\n * // Same as the default results of `useNavigation()` when invoked in this route.\n * const parentLayout = useNavigation('/orders/menu');\n * }\n * ```\n *\n * If you attempt to access a layout that doesn't exist, an error such as\n * `Could not find parent navigation with route \"/non-existent\"` is thrown.\n *\n *\n * @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.\n * @returns The navigation object for the current route.\n *\n * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)\n * for more information.\n */\nexport function useNavigation<T = NavigationProp<ReactNavigation.RootParamList>>(\n parent?: string\n): T {\n const navigation = useUpstreamNavigation<any>();\n\n const contextKey = useContextKey();\n const normalizedParent = React.useMemo(() => {\n if (!parent) {\n return null;\n }\n const normalized = getNameFromFilePath(parent);\n\n if (parent.startsWith('.')) {\n return relativePaths(contextKey, parent);\n }\n return normalized;\n }, [contextKey, parent]);\n\n if (normalizedParent != null) {\n const parentNavigation = navigation.getParent(normalizedParent);\n\n // TODO: Maybe print a list of parents...\n\n if (!parentNavigation) {\n throw new Error(\n `Could not find parent navigation with route \"${parent}\".` +\n (normalizedParent !== parent ? ` (normalized: ${normalizedParent})` : '')\n );\n }\n return parentNavigation;\n }\n return navigation;\n}\n\nexport function resolveParentId(contextKey: string, parentId?: string | null): string | null {\n if (!parentId) {\n return null;\n }\n\n if (parentId.startsWith('.')) {\n return getNameFromFilePath(relativePaths(contextKey, parentId));\n }\n return getNameFromFilePath(parentId);\n}\n\n// Resolve a path like `../` relative to a path like `/foo/bar`\nfunction relativePaths(from: string, to: string): string {\n const fromParts = from.split('/').filter(Boolean);\n const toParts = to.split('/').filter(Boolean);\n\n for (const part of toParts) {\n if (part === '..') {\n if (fromParts.length === 0) {\n throw new Error(`Cannot resolve path \"${to}\" relative to \"${from}\"`);\n }\n fromParts.pop();\n } else if (part === '.') {\n // Ignore\n } else {\n fromParts.push(part);\n }\n }\n\n return '/' + fromParts.join('/');\n}\n"]}
|
|
@@ -32,12 +32,13 @@ export declare function useNavigatorContext(): NavigatorContextValue;
|
|
|
32
32
|
/**
|
|
33
33
|
* Renders the currently selected content.
|
|
34
34
|
*
|
|
35
|
-
* There are actually two different implementations of Slot
|
|
36
|
-
* - Used inside a _layout as the Navigator
|
|
37
|
-
* - Used inside a Navigator as the content
|
|
35
|
+
* There are actually two different implementations of `<Slot/>`:
|
|
36
|
+
* - Used inside a `_layout` as the `Navigator`
|
|
37
|
+
* - Used inside a `Navigator` as the content
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* Since a custom `Navigator` will set the `NavigatorContext.contextKey` to
|
|
40
|
+
* the current `_layout`, you can use this to determine if you are inside
|
|
41
|
+
* a custom navigator or not.
|
|
41
42
|
*/
|
|
42
43
|
export declare function Slot(props: Omit<NavigatorProps<any>, 'children'>): React.JSX.Element;
|
|
43
44
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigator.d.ts","sourceRoot":"","sources":["../../src/views/Navigator.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,E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C,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,gBAAgB,6CAA0D,CAAC;AAMxF,KAAK,0BAA0B,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,KAAK,2BAA2B,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9E,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,0BAA0B,IAAI;IACjE,gBAAgB,CAAC,EAAE,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;IACnE,aAAa,CAAC,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC7D,QAAQ,CAAC,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAC;IACnD,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,aAAa,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,0BAA0B,GAAG,OAAO,WAAW,EAAE,EACnF,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,MAAM,EACN,aAAa,GACd,EAAE,cAAc,CAAC,CAAC,CAAC,4BAsCnB;yBA5Ce,SAAS;;;;;AA8CzB;;GAEG;AACH,wBAAgB,mBAAmB,0BAMlC;AAqBD;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,qBAchE;AAED;;GAEG;AACH,iBAAS,aAAa,gBAMrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,sBAM/B"}
|
package/build/views/Navigator.js
CHANGED
|
@@ -100,12 +100,13 @@ function SlotNavigator(props) {
|
|
|
100
100
|
/**
|
|
101
101
|
* Renders the currently selected content.
|
|
102
102
|
*
|
|
103
|
-
* There are actually two different implementations of Slot
|
|
104
|
-
* - Used inside a _layout as the Navigator
|
|
105
|
-
* - Used inside a Navigator as the content
|
|
103
|
+
* There are actually two different implementations of `<Slot/>`:
|
|
104
|
+
* - Used inside a `_layout` as the `Navigator`
|
|
105
|
+
* - Used inside a `Navigator` as the content
|
|
106
106
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
107
|
+
* Since a custom `Navigator` will set the `NavigatorContext.contextKey` to
|
|
108
|
+
* the current `_layout`, you can use this to determine if you are inside
|
|
109
|
+
* a custom navigator or not.
|
|
109
110
|
*/
|
|
110
111
|
function Slot(props) {
|
|
111
112
|
const contextKey = (0, Route_1.useContextKey)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigator.js","sourceRoot":"","sources":["../../src/views/Navigator.tsx"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,qDAA4F;AAC5F,6CAA+B;AAC/B,mFAA8D;AAE9D,qCAAkC;AAClC,oCAAyC;AACzC,oEAAuE;AACvE,8CAAiD;AAOpC,QAAA,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAA+B,IAAI,CAAC,CAAC;AAExF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;CACnD;AAaD;;;;GAIG;AACH,SAAgB,SAAS,CAA4D,EACnF,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,MAAM,EACN,aAAa,GACK;IAClB,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;IAEnC,+FAA+F;IAC/F,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,IAAA,2CAAuB,EAAC,QAAQ,EAAE;QACjF,iBAAiB,EAAE,IAAI;QACvB,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,a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M,CAAC","sourcesContent":["// Copyright © 2024 650 Industries.\n'use client';\n\nimport { RouterFactory, StackRouter, useNavigationBuilder } from '@react-navigation/native';\nimport * as React from 'react';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n\nimport { Screen } from './Screen';\nimport { useContextKey } from '../Route';\nimport { useFilterScreenChildren } from '../layouts/withLayoutContext';\nimport { useSortedScreens } from '../useScreens';\n\nexport type NavigatorContextValue = ReturnType<typeof useNavigationBuilder> & {\n contextKey: string;\n router: RouterFactory<any, any, any>;\n};\n\nexport const NavigatorContext = React.createContext<NavigatorContextValue | null>(null);\n\nif (process.env.NODE_ENV !== 'production') {\n NavigatorContext.displayName = 'NavigatorContext';\n}\n\ntype UseNavigationBuilderRouter = Parameters<typeof useNavigationBuilder>[0];\ntype UseNavigationBuilderOptions = Parameters<typeof useNavigationBuilder>[1];\n\nexport type NavigatorProps<T extends UseNavigationBuilderRouter> = {\n initialRouteName?: UseNavigationBuilderOptions['initialRouteName'];\n screenOptions?: UseNavigationBuilderOptions['screenOptions'];\n children?: UseNavigationBuilderOptions['children'];\n router?: T;\n routerOptions?: Omit<Parameters<T>[0], 'initialRouteName'>;\n};\n\n/**\n * An unstyled custom navigator. Good for basic web layouts.\n *\n * @hidden\n */\nexport function Navigator<T extends UseNavigationBuilderRouter = typeof StackRouter>({\n initialRouteName,\n screenOptions,\n children,\n router,\n routerOptions,\n}: NavigatorProps<T>) {\n const contextKey = useContextKey();\n\n // A custom navigator can have a mix of Screen and other components (like a Slot inside a View)\n const { screens, children: nonScreenChildren } = useFilterScreenChildren(children, {\n isCustomNavigator: true,\n contextKey,\n });\n\n const sortedScreens = useSortedScreens(screens ?? []);\n\n router ||= StackRouter as unknown as T;\n\n const navigation = useNavigationBuilder(router, {\n // Used for getting the parent with navigation.getParent('/normalized/path')\n ...routerOptions,\n id: contextKey,\n children: sortedScreens || [<Screen key=\"default\" />],\n screenOptions,\n initialRouteName,\n });\n\n // useNavigationBuilder requires at least one screen to be defined otherwise it will throw.\n if (!sortedScreens.length) {\n console.warn(`Navigator at \"${contextKey}\" has no children.`);\n return null;\n }\n\n return (\n <NavigatorContext.Provider\n value={{\n ...navigation,\n contextKey,\n router,\n }}>\n {nonScreenChildren}\n </NavigatorContext.Provider>\n );\n}\n\n/**\n * @hidden\n */\nexport function useNavigatorContext() {\n const context = React.useContext(NavigatorContext);\n if (!context) {\n throw new Error('useNavigatorContext must be used within a <Navigator />');\n }\n return context;\n}\n\nfunction SlotNavigator(props: NavigatorProps<any>) {\n const contextKey = useContextKey();\n\n // Allows adding Screen components as children to configure routes.\n const { screens } = useFilterScreenChildren([], {\n contextKey,\n });\n\n const { state, descriptors, NavigationContent } = useNavigationBuilder(StackRouter, {\n ...props,\n id: contextKey,\n children: useSortedScreens(screens ?? []),\n });\n\n return (\n <NavigationContent>{descriptors[state.routes[state.index].key].render()}</NavigationContent>\n );\n}\n\n/**\n * Renders the currently selected content.\n *\n * There are actually two different implementations of `<Slot/>`:\n * - Used inside a `_layout` as the `Navigator`\n * - Used inside a `Navigator` as the content\n *\n * Since a custom `Navigator` will set the `NavigatorContext.contextKey` to\n * the current `_layout`, you can use this to determine if you are inside\n * a custom navigator or not.\n */\nexport function Slot(props: Omit<NavigatorProps<any>, 'children'>) {\n const contextKey = useContextKey();\n const context = React.useContext(NavigatorContext);\n\n if (context?.contextKey !== contextKey) {\n // The _layout has changed since the last navigator\n return <SlotNavigator {...props} />;\n }\n\n /*\n * The user has defined a custom navigator\n * <Navigator><Slot /></Navigator>\n */\n return <NavigatorSlot />;\n}\n\n/**\n * Render the current navigator content.\n */\nfunction NavigatorSlot() {\n const context = useNavigatorContext();\n\n const { state, descriptors } = context;\n\n return descriptors[state.routes[state.index].key]?.render() ?? null;\n}\n\n/**\n * The default navigator for the app when no root _layout is provided.\n */\nexport function DefaultNavigator() {\n return (\n <SafeAreaView style={{ flex: 1 }}>\n <SlotNavigator />\n </SafeAreaView>\n );\n}\n\nNavigator.Slot = NavigatorSlot;\nNavigator.useContext = useNavigatorContext;\n\n/** Used to configure route settings. */\nNavigator.Screen = Screen;\n"]}
|
package/build/views/Try.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Component, type ComponentType, type PropsWithChildren } from 'react';
|
|
2
2
|
/** Props passed to a page's `ErrorBoundary` export. */
|
|
3
3
|
export type ErrorBoundaryProps = {
|
|
4
|
-
/**
|
|
4
|
+
/** A function that will re-render the route component by clearing the `error` state. */
|
|
5
5
|
retry: () => Promise<void>;
|
|
6
6
|
/** The error that was thrown. */
|
|
7
7
|
error: Error;
|
package/build/views/Try.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Try.d.ts","sourceRoot":"","sources":["../../src/views/Try.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAIrF,uDAAuD;AACvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,
|
|
1
|
+
{"version":3,"file":"Try.d.ts","sourceRoot":"","sources":["../../src/views/Try.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAIrF,uDAAuD;AACvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wFAAwF;IACxF,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,iCAAiC;IACjC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAGF,qBAAa,GAAI,SAAQ,SAAS,CAChC,iBAAiB,CAAC;IAChB,KAAK,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CAC1C,CAAC,EACF;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAClB;IACC,KAAK;;MAAwB;IAE7B,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;;IAY5C,KAAK,sBAMH;IAEF,MAAM;CAQP"}
|
package/build/views/Try.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Try.js","sourceRoot":"","sources":["../../src/views/Try.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,iEAAmD;AACnD,+CAAqF;AAErF,iDAAwD;AAUxD,gFAAgF;AAChF,MAAa,GAAI,SAAQ,iBAKxB;IACC,KAAK,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAE7B,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC1C,mDAAmD;QACnD,YAAY,CAAC,SAAS,EAAE,CAAC;QAEzB,IAAI,OAAO,IAAI,KAAK,YAAY,yBAAgB,EAAE;YAChD,0BAA0B;YAC1B,OAAO,IAAI,CAAC;SACb;QAED,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC;IAED,KAAK,GAAG,GAAG,EAAE;QACX,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE;gBACvC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM;QACJ,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7B,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACtD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,QAAQ,CAAC;SACjB;QACD,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAG,CAAC;IAC5D,CAAC;CACF;AApCD,kBAoCC","sourcesContent":["'use client';\n\nimport * as SplashScreen from 'expo-splash-screen';\nimport React, { Component, type ComponentType, type PropsWithChildren } from 'react';\n\nimport { MetroServerError } from '../rsc/router/errors';\n\n/** Props passed to a page's `ErrorBoundary` export. */\nexport type ErrorBoundaryProps = {\n /**
|
|
1
|
+
{"version":3,"file":"Try.js","sourceRoot":"","sources":["../../src/views/Try.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,iEAAmD;AACnD,+CAAqF;AAErF,iDAAwD;AAUxD,gFAAgF;AAChF,MAAa,GAAI,SAAQ,iBAKxB;IACC,KAAK,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAE7B,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC1C,mDAAmD;QACnD,YAAY,CAAC,SAAS,EAAE,CAAC;QAEzB,IAAI,OAAO,IAAI,KAAK,YAAY,yBAAgB,EAAE;YAChD,0BAA0B;YAC1B,OAAO,IAAI,CAAC;SACb;QAED,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC;IAED,KAAK,GAAG,GAAG,EAAE;QACX,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE;gBACvC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM;QACJ,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7B,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACtD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,QAAQ,CAAC;SACjB;QACD,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAG,CAAC;IAC5D,CAAC;CACF;AApCD,kBAoCC","sourcesContent":["'use client';\n\nimport * as SplashScreen from 'expo-splash-screen';\nimport React, { Component, type ComponentType, type PropsWithChildren } from 'react';\n\nimport { MetroServerError } from '../rsc/router/errors';\n\n/** Props passed to a page's `ErrorBoundary` export. */\nexport type ErrorBoundaryProps = {\n /** A function that will re-render the route component by clearing the `error` state. */\n retry: () => Promise<void>;\n /** The error that was thrown. */\n error: Error;\n};\n\n// No way to access `getDerivedStateFromError` from a function component afaict.\nexport class Try extends Component<\n PropsWithChildren<{\n catch: ComponentType<ErrorBoundaryProps>;\n }>,\n { error?: Error }\n> {\n state = { error: undefined };\n\n static getDerivedStateFromError(error: Error) {\n // Force hide the splash screen if an error occurs.\n SplashScreen.hideAsync();\n\n if (__DEV__ && error instanceof MetroServerError) {\n // Throw up to the LogBox.\n return null;\n }\n\n return { error };\n }\n\n retry = () => {\n return new Promise<void>((resolve) => {\n this.setState({ error: undefined }, () => {\n resolve();\n });\n });\n };\n\n render() {\n const { error } = this.state;\n const { catch: ErrorBoundary, children } = this.props;\n if (!error) {\n return children;\n }\n return <ErrorBoundary error={error} retry={this.retry} />;\n }\n}\n"]}
|
package/entry-classic.js
CHANGED
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
// on web.
|
|
3
3
|
import '@expo/metro-runtime';
|
|
4
4
|
|
|
5
|
-
// Hook for the virtual client modules.
|
|
6
|
-
// TODO: Remove this in favor of the webpack runtime one.
|
|
7
|
-
import 'expo-router/virtual-client-boundaries';
|
|
8
|
-
// Add server component support.
|
|
9
|
-
import 'expo-router/build/rsc/runtime';
|
|
10
|
-
|
|
11
5
|
import { App } from 'expo-router/build/qualified-entry';
|
|
12
6
|
import { renderRootComponent } from 'expo-router/build/renderRootComponent';
|
|
13
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "4.0.0-preview.
|
|
3
|
+
"version": "4.0.0-preview.12",
|
|
4
4
|
"description": "Expo Router is a file-based router for React Native and web applications.",
|
|
5
5
|
"author": "650 Industries, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"_ctx-shared.js",
|
|
27
27
|
"_error.js",
|
|
28
28
|
"app.plugin.js",
|
|
29
|
-
"virtual-client-boundaries.js",
|
|
30
29
|
"babel.js",
|
|
31
30
|
"drawer.js",
|
|
32
31
|
"drawer.d.ts",
|
|
@@ -103,18 +102,18 @@
|
|
|
103
102
|
"tsd": "^0.28.1"
|
|
104
103
|
},
|
|
105
104
|
"dependencies": {
|
|
106
|
-
"@expo/metro-runtime": "4.0.0-preview.
|
|
105
|
+
"@expo/metro-runtime": "4.0.0-preview.1",
|
|
107
106
|
"@expo/server": "^0.5.0-preview.0",
|
|
108
107
|
"@radix-ui/react-slot": "1.0.1",
|
|
109
108
|
"@react-navigation/bottom-tabs": "7.0.0-rc.36",
|
|
110
109
|
"@react-navigation/native": "7.0.0-rc.21",
|
|
111
110
|
"@react-navigation/native-stack": "7.0.0-rc.30",
|
|
112
111
|
"client-only": "^0.0.1",
|
|
113
|
-
"expo-splash-screen": "0.29.
|
|
112
|
+
"expo-splash-screen": "0.29.1",
|
|
114
113
|
"react-helmet-async": "^1.3.0",
|
|
115
114
|
"react-native-helmet-async": "2.0.4",
|
|
116
115
|
"schema-utils": "^4.0.1",
|
|
117
116
|
"server-only": "^0.0.1"
|
|
118
117
|
},
|
|
119
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "d97ae0839fa465cee14e13ca38f3c6c84c124d82"
|
|
120
119
|
}
|
package/plugin/build/index.d.ts
CHANGED