@ankhorage/navigator 1.6.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/{expo-router/resolveCustomNavigatorPlan.d.ts → features/custom/application/resolveCustomNavigatorAdapterPlan.d.ts} +2 -4
- package/dist/features/custom/application/resolveCustomNavigatorAdapterPlan.d.ts.map +1 -0
- package/dist/{expo-router/resolveCustomNavigatorPlan.js → features/custom/application/resolveCustomNavigatorAdapterPlan.js} +1 -1
- package/dist/features/custom/application/resolveCustomNavigatorAdapterPlan.js.map +1 -0
- package/dist/{validation/validateCustomNavigator.d.ts → features/custom/domain/addCustomNavigatorDiagnostics.d.ts} +2 -4
- package/dist/features/custom/domain/addCustomNavigatorDiagnostics.d.ts.map +1 -0
- package/dist/{validation/validateCustomNavigator.js → features/custom/domain/addCustomNavigatorDiagnostics.js} +50 -50
- package/dist/features/custom/domain/addCustomNavigatorDiagnostics.js.map +1 -0
- package/dist/features/custom/domain/defineCustomNavigatorRegistry.d.ts +4 -0
- package/dist/features/custom/domain/defineCustomNavigatorRegistry.d.ts.map +1 -0
- package/dist/{custom/CustomNavigatorRegistry.js → features/custom/domain/defineCustomNavigatorRegistry.js} +5 -5
- package/dist/features/custom/domain/defineCustomNavigatorRegistry.js.map +1 -0
- package/dist/features/drawer/adapters/outbound/resolveDrawerRouteOptions.d.ts +4 -0
- package/dist/features/drawer/adapters/outbound/resolveDrawerRouteOptions.d.ts.map +1 -0
- package/dist/features/drawer/adapters/outbound/resolveDrawerRouteOptions.js +8 -0
- package/dist/features/drawer/adapters/outbound/resolveDrawerRouteOptions.js.map +1 -0
- package/dist/features/drawer/application/createDrawerAdapter.d.ts +4 -0
- package/dist/features/drawer/application/createDrawerAdapter.d.ts.map +1 -0
- package/dist/features/drawer/application/createDrawerAdapter.js +12 -0
- package/dist/features/drawer/application/createDrawerAdapter.js.map +1 -0
- package/dist/features/slot/adapters/outbound/generateSlotLayoutFile.d.ts +4 -0
- package/dist/features/slot/adapters/outbound/generateSlotLayoutFile.d.ts.map +1 -0
- package/dist/features/slot/adapters/outbound/generateSlotLayoutFile.js +8 -0
- package/dist/features/slot/adapters/outbound/generateSlotLayoutFile.js.map +1 -0
- package/dist/features/slot/application/createSlotAdapter.d.ts +4 -0
- package/dist/features/slot/application/createSlotAdapter.d.ts.map +1 -0
- package/dist/features/slot/application/createSlotAdapter.js +12 -0
- package/dist/features/slot/application/createSlotAdapter.js.map +1 -0
- package/dist/features/slot/domain/addSlotDiagnostics.d.ts +4 -0
- package/dist/features/slot/domain/addSlotDiagnostics.d.ts.map +1 -0
- package/dist/features/slot/domain/addSlotDiagnostics.js +24 -0
- package/dist/features/slot/domain/addSlotDiagnostics.js.map +1 -0
- package/dist/{generation → features/split-view/adapters/outbound}/generateSplitViewLayoutFile.d.ts +1 -1
- package/dist/features/split-view/adapters/outbound/generateSplitViewLayoutFile.d.ts.map +1 -0
- package/dist/{generation → features/split-view/adapters/outbound}/generateSplitViewLayoutFile.js +37 -36
- package/dist/features/split-view/adapters/outbound/generateSplitViewLayoutFile.js.map +1 -0
- package/dist/{expo-router/resolveSplitViewNavigatorPlan.d.ts → features/split-view/application/resolveSplitViewAdapterPlan.d.ts} +2 -2
- package/dist/features/split-view/application/resolveSplitViewAdapterPlan.d.ts.map +1 -0
- package/dist/{expo-router/resolveSplitViewNavigatorPlan.js → features/split-view/application/resolveSplitViewAdapterPlan.js} +1 -1
- package/dist/features/split-view/application/resolveSplitViewAdapterPlan.js.map +1 -0
- package/dist/{validation/validateSplitView.d.ts → features/split-view/domain/addSplitViewDiagnostics.d.ts} +2 -3
- package/dist/features/split-view/domain/addSplitViewDiagnostics.d.ts.map +1 -0
- package/dist/{validation/validateSplitView.js → features/split-view/domain/addSplitViewDiagnostics.js} +76 -76
- package/dist/features/split-view/domain/addSplitViewDiagnostics.js.map +1 -0
- package/dist/features/stack/application/createStackAdapter.d.ts +4 -0
- package/dist/features/stack/application/createStackAdapter.d.ts.map +1 -0
- package/dist/features/stack/application/createStackAdapter.js +43 -0
- package/dist/features/stack/application/createStackAdapter.js.map +1 -0
- package/dist/{validation/validateExperimentalStack.d.ts → features/stack/domain/addExperimentalStackDiagnostics.d.ts} +2 -3
- package/dist/features/stack/domain/addExperimentalStackDiagnostics.d.ts.map +1 -0
- package/dist/{validation/validateExperimentalStack.js → features/stack/domain/addExperimentalStackDiagnostics.js} +49 -49
- package/dist/features/stack/domain/addExperimentalStackDiagnostics.js.map +1 -0
- package/dist/features/stack/domain/addStackAdapterDiagnostics.d.ts +4 -0
- package/dist/features/stack/domain/addStackAdapterDiagnostics.d.ts.map +1 -0
- package/dist/features/stack/domain/addStackAdapterDiagnostics.js +15 -0
- package/dist/features/stack/domain/addStackAdapterDiagnostics.js.map +1 -0
- package/dist/features/stack/domain/resolveEffectiveStackConfig.d.ts +4 -0
- package/dist/features/stack/domain/resolveEffectiveStackConfig.d.ts.map +1 -0
- package/dist/features/stack/domain/resolveEffectiveStackConfig.js +6 -0
- package/dist/features/stack/domain/resolveEffectiveStackConfig.js.map +1 -0
- package/dist/features/stack/domain/resolveEffectiveStackConfigSource.d.ts +9 -0
- package/dist/features/stack/domain/resolveEffectiveStackConfigSource.d.ts.map +1 -0
- package/dist/{expo-router/resolveNavigatorConfig.js → features/stack/domain/resolveEffectiveStackConfigSource.js} +20 -46
- package/dist/features/stack/domain/resolveEffectiveStackConfigSource.js.map +1 -0
- package/dist/features/stack/domain/validateStackRouteOptions.d.ts +4 -0
- package/dist/features/stack/domain/validateStackRouteOptions.d.ts.map +1 -0
- package/dist/features/stack/domain/validateStackRouteOptions.js +25 -0
- package/dist/features/stack/domain/validateStackRouteOptions.js.map +1 -0
- package/dist/{tabs → features/tabs/adapters/inbound}/CustomTabsLayout.d.ts +16 -17
- package/dist/features/tabs/adapters/inbound/CustomTabsLayout.d.ts.map +1 -0
- package/dist/{tabs → features/tabs/adapters/inbound}/CustomTabsLayout.js +62 -61
- package/dist/features/tabs/adapters/inbound/CustomTabsLayout.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome5Family.d.ts +4 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome5Family.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome5Family.js +9 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome5Family.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome6Family.d.ts +4 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome6Family.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome6Family.js +9 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesome6Family.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesomeFamily.d.ts +4 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesomeFamily.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesomeFamily.js +4 -0
- package/dist/features/tabs/adapters/inbound/NativeFontAwesomeFamily.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeIoniconsFamily.d.ts +4 -0
- package/dist/features/tabs/adapters/inbound/NativeIoniconsFamily.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeIoniconsFamily.js +4 -0
- package/dist/features/tabs/adapters/inbound/NativeIoniconsFamily.js.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeMaterialDesignIconsFamily.d.ts +4 -0
- package/dist/features/tabs/adapters/inbound/NativeMaterialDesignIconsFamily.d.ts.map +1 -0
- package/dist/features/tabs/adapters/inbound/NativeMaterialDesignIconsFamily.js +4 -0
- package/dist/features/tabs/adapters/inbound/NativeMaterialDesignIconsFamily.js.map +1 -0
- package/dist/{generation → features/tabs/adapters/outbound}/generateTabsLayoutFile.d.ts +1 -1
- package/dist/features/tabs/adapters/outbound/generateTabsLayoutFile.d.ts.map +1 -0
- package/dist/{generation → features/tabs/adapters/outbound}/generateTabsLayoutFile.js +95 -92
- package/dist/features/tabs/adapters/outbound/generateTabsLayoutFile.js.map +1 -0
- package/dist/features/tabs/application/createTabsAdapter.d.ts +4 -0
- package/dist/features/tabs/application/createTabsAdapter.d.ts.map +1 -0
- package/dist/features/tabs/application/createTabsAdapter.js +18 -0
- package/dist/features/tabs/application/createTabsAdapter.js.map +1 -0
- package/dist/{expo-router → features/tabs/application}/resolveTabsNavigatorPlan.d.ts +1 -2
- package/dist/features/tabs/application/resolveTabsNavigatorPlan.d.ts.map +1 -0
- package/dist/{expo-router → features/tabs/application}/resolveTabsNavigatorPlan.js +41 -41
- package/dist/features/tabs/application/resolveTabsNavigatorPlan.js.map +1 -0
- package/dist/features/tabs/application/resolveTabsPlan.d.ts +4 -0
- package/dist/features/tabs/application/resolveTabsPlan.d.ts.map +1 -0
- package/dist/features/tabs/application/resolveTabsPlan.js +14 -0
- package/dist/features/tabs/application/resolveTabsPlan.js.map +1 -0
- package/dist/{validation/validateTabsNavigator.d.ts → features/tabs/domain/addTabsAdapterDiagnostics.d.ts} +2 -3
- package/dist/features/tabs/domain/addTabsAdapterDiagnostics.d.ts.map +1 -0
- package/dist/{validation/validateTabsNavigator.js → features/tabs/domain/addTabsAdapterDiagnostics.js} +47 -47
- package/dist/features/tabs/domain/addTabsAdapterDiagnostics.js.map +1 -0
- package/dist/features/tabs/domain/resolveCustomTabsPresentation.d.ts +4 -0
- package/dist/features/tabs/domain/resolveCustomTabsPresentation.d.ts.map +1 -0
- package/dist/{presentation → features/tabs/domain}/resolveCustomTabsPresentation.js +16 -16
- package/dist/features/tabs/domain/resolveCustomTabsPresentation.js.map +1 -0
- package/dist/features/tabs/domain/resolveEffectiveTabsConfig.d.ts +4 -0
- package/dist/features/tabs/domain/resolveEffectiveTabsConfig.d.ts.map +1 -0
- package/dist/features/tabs/domain/resolveEffectiveTabsConfig.js +24 -0
- package/dist/features/tabs/domain/resolveEffectiveTabsConfig.js.map +1 -0
- package/dist/features/tabs/nativeIcons.d.ts +6 -0
- package/dist/features/tabs/nativeIcons.d.ts.map +1 -0
- package/dist/features/tabs/nativeIcons.js +6 -0
- package/dist/features/tabs/nativeIcons.js.map +1 -0
- package/dist/features/tabs/tabs.d.ts +2 -0
- package/dist/features/tabs/tabs.d.ts.map +1 -0
- package/dist/features/tabs/tabs.js +2 -0
- package/dist/features/tabs/tabs.js.map +1 -0
- package/dist/navigator.d.ts +8 -0
- package/dist/navigator.d.ts.map +1 -0
- package/dist/navigator.js +8 -0
- package/dist/navigator.js.map +1 -0
- package/dist/types/nativeIcons.d.ts +5 -0
- package/dist/types/nativeIcons.d.ts.map +1 -0
- package/dist/types/nativeIcons.js +2 -0
- package/dist/types/nativeIcons.js.map +1 -0
- package/dist/{metadata/index.d.ts → utils/NAVIGATOR_PACKAGE_METADATA.d.ts} +1 -1
- package/dist/utils/NAVIGATOR_PACKAGE_METADATA.d.ts.map +1 -0
- package/dist/{metadata/index.js → utils/NAVIGATOR_PACKAGE_METADATA.js} +1 -1
- package/dist/utils/NAVIGATOR_PACKAGE_METADATA.js.map +1 -0
- package/dist/utils/createNavigatorPlan.d.ts +4 -0
- package/dist/utils/createNavigatorPlan.d.ts.map +1 -0
- package/dist/{expo-router → utils}/createNavigatorPlan.js +67 -140
- package/dist/utils/createNavigatorPlan.js.map +1 -0
- package/dist/{generation → utils}/generateNavigatorFiles.d.ts +1 -1
- package/dist/utils/generateNavigatorFiles.d.ts.map +1 -0
- package/dist/{generation → utils}/generateNavigatorFiles.js +160 -154
- package/dist/utils/generateNavigatorFiles.js.map +1 -0
- package/dist/utils/parseExpoRouterMajor.d.ts +3 -0
- package/dist/utils/parseExpoRouterMajor.d.ts.map +1 -0
- package/dist/utils/parseExpoRouterMajor.js +6 -0
- package/dist/utils/parseExpoRouterMajor.js.map +1 -0
- package/dist/utils/resolveNavigatorPreset.d.ts.map +1 -0
- package/dist/utils/resolveNavigatorPreset.js.map +1 -0
- package/dist/utils/validateNavigatorManifest.d.ts +4 -0
- package/dist/utils/validateNavigatorManifest.d.ts.map +1 -0
- package/dist/{validation → utils}/validateNavigatorManifest.js +53 -92
- package/dist/utils/validateNavigatorManifest.js.map +1 -0
- package/dist/{validation → utils}/validatePresetTopology.d.ts +1 -2
- package/dist/utils/validatePresetTopology.d.ts.map +1 -0
- package/dist/{validation → utils}/validatePresetTopology.js +1 -1
- package/dist/utils/validatePresetTopology.js.map +1 -0
- package/package.json +16 -15
- package/dist/custom/CustomNavigatorRegistry.d.ts +0 -25
- package/dist/custom/CustomNavigatorRegistry.d.ts.map +0 -1
- package/dist/custom/CustomNavigatorRegistry.js.map +0 -1
- package/dist/definitions/NavigatorPlan.d.ts +0 -119
- package/dist/definitions/NavigatorPlan.d.ts.map +0 -1
- package/dist/definitions/NavigatorPlan.js +0 -2
- package/dist/definitions/NavigatorPlan.js.map +0 -1
- package/dist/expo-router/createNavigatorPlan.d.ts +0 -12
- package/dist/expo-router/createNavigatorPlan.d.ts.map +0 -1
- package/dist/expo-router/createNavigatorPlan.js.map +0 -1
- package/dist/expo-router/resolveCustomNavigatorPlan.d.ts.map +0 -1
- package/dist/expo-router/resolveCustomNavigatorPlan.js.map +0 -1
- package/dist/expo-router/resolveNavigatorConfig.d.ts +0 -13
- package/dist/expo-router/resolveNavigatorConfig.d.ts.map +0 -1
- package/dist/expo-router/resolveNavigatorConfig.js.map +0 -1
- package/dist/expo-router/resolveSplitViewNavigatorPlan.d.ts.map +0 -1
- package/dist/expo-router/resolveSplitViewNavigatorPlan.js.map +0 -1
- package/dist/expo-router/resolveTabsNavigatorPlan.d.ts.map +0 -1
- package/dist/expo-router/resolveTabsNavigatorPlan.js.map +0 -1
- package/dist/generation/generateNavigatorFiles.d.ts.map +0 -1
- package/dist/generation/generateNavigatorFiles.js.map +0 -1
- package/dist/generation/generateSplitViewLayoutFile.d.ts.map +0 -1
- package/dist/generation/generateSplitViewLayoutFile.js.map +0 -1
- package/dist/generation/generateTabsLayoutFile.d.ts.map +0 -1
- package/dist/generation/generateTabsLayoutFile.js.map +0 -1
- package/dist/generation/generationSafety.d.ts +0 -10
- package/dist/generation/generationSafety.d.ts.map +0 -1
- package/dist/generation/generationSafety.js +0 -54
- package/dist/generation/generationSafety.js.map +0 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/metadata/index.d.ts.map +0 -1
- package/dist/metadata/index.js.map +0 -1
- package/dist/presentation/resolveCustomTabsPresentation.d.ts +0 -9
- package/dist/presentation/resolveCustomTabsPresentation.d.ts.map +0 -1
- package/dist/presentation/resolveCustomTabsPresentation.js.map +0 -1
- package/dist/tabs/CustomTabsLayout.d.ts.map +0 -1
- package/dist/tabs/CustomTabsLayout.js.map +0 -1
- package/dist/tabs/index.d.ts +0 -3
- package/dist/tabs/index.d.ts.map +0 -1
- package/dist/tabs/index.js +0 -2
- package/dist/tabs/index.js.map +0 -1
- package/dist/tabs/nativeIconFamilies.d.ts +0 -16
- package/dist/tabs/nativeIconFamilies.d.ts.map +0 -1
- package/dist/tabs/nativeIconFamilies.js +0 -24
- package/dist/tabs/nativeIconFamilies.js.map +0 -1
- package/dist/topology/resolveNavigatorPreset.d.ts.map +0 -1
- package/dist/topology/resolveNavigatorPreset.js.map +0 -1
- package/dist/validation/validateCustomNavigator.d.ts.map +0 -1
- package/dist/validation/validateCustomNavigator.js.map +0 -1
- package/dist/validation/validateExperimentalStack.d.ts.map +0 -1
- package/dist/validation/validateExperimentalStack.js.map +0 -1
- package/dist/validation/validateNavigatorManifest.d.ts +0 -6
- package/dist/validation/validateNavigatorManifest.d.ts.map +0 -1
- package/dist/validation/validateNavigatorManifest.js.map +0 -1
- package/dist/validation/validatePresetTopology.d.ts.map +0 -1
- package/dist/validation/validatePresetTopology.js.map +0 -1
- package/dist/validation/validateSplitView.d.ts.map +0 -1
- package/dist/validation/validateSplitView.js.map +0 -1
- package/dist/validation/validateTabsNavigator.d.ts.map +0 -1
- package/dist/validation/validateTabsNavigator.js.map +0 -1
- /package/dist/{topology → utils}/resolveNavigatorPreset.d.ts +0 -0
- /package/dist/{topology → utils}/resolveNavigatorPreset.js +0 -0
|
@@ -1,88 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { resolveSplitViewAdapterPlan } from '
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
id: 'stack.experimental',
|
|
22
|
-
module: 'expo-router',
|
|
23
|
-
exportName: 'ExperimentalStack',
|
|
24
|
-
support: routerMajor !== undefined && routerMajor >= 56 ? 'supported' : 'unavailable',
|
|
25
|
-
stability: 'alpha',
|
|
26
|
-
limitations: platform === 'web'
|
|
27
|
-
? ['Testing-only API; Expo Router falls back to the standard Stack on web.']
|
|
28
|
-
: [
|
|
29
|
-
'Testing-only API; supports only title and header visibility options.',
|
|
30
|
-
...(platform === 'android'
|
|
31
|
-
? [
|
|
32
|
-
'Cannot coexist with the standard native Stack on Android.',
|
|
33
|
-
'Requires android.predictiveBackGestureEnabled in app config.',
|
|
34
|
-
]
|
|
35
|
-
: []),
|
|
36
|
-
],
|
|
37
|
-
};
|
|
38
|
-
}
|
|
1
|
+
import { resolveCustomNavigatorAdapterPlan } from '../features/custom/application/resolveCustomNavigatorAdapterPlan';
|
|
2
|
+
import { createDrawerAdapter } from '../features/drawer/application/createDrawerAdapter';
|
|
3
|
+
import { createSlotAdapter } from '../features/slot/application/createSlotAdapter';
|
|
4
|
+
import { resolveSplitViewAdapterPlan } from '../features/split-view/application/resolveSplitViewAdapterPlan';
|
|
5
|
+
import { createStackAdapter } from '../features/stack/application/createStackAdapter';
|
|
6
|
+
import { resolveEffectiveStackConfig } from '../features/stack/domain/resolveEffectiveStackConfig';
|
|
7
|
+
import { createTabsAdapter } from '../features/tabs/application/createTabsAdapter';
|
|
8
|
+
import { resolveTabsPlan } from '../features/tabs/application/resolveTabsPlan';
|
|
9
|
+
import { resolveEffectiveTabsConfig } from '../features/tabs/domain/resolveEffectiveTabsConfig';
|
|
10
|
+
import { parseExpoRouterMajor } from './parseExpoRouterMajor';
|
|
11
|
+
import { validateNavigatorManifest } from './validateNavigatorManifest';
|
|
12
|
+
/*** Create a disposable, provider-aware plan from only the navigator desired-state slice. */
|
|
13
|
+
export function createNavigatorPlan(manifest, options) {
|
|
14
|
+
const context = {
|
|
15
|
+
platform: options.platform,
|
|
16
|
+
expoRouterVersion: options.expoRouterVersion,
|
|
17
|
+
};
|
|
18
|
+
const diagnostics = validateNavigatorManifest(manifest, context, options.customNavigators);
|
|
19
|
+
const root = createNodePlan(manifest, manifest, '', options, options.responsiveSize ?? 'compact');
|
|
39
20
|
return {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
context,
|
|
22
|
+
root,
|
|
23
|
+
diagnostics,
|
|
24
|
+
supported: diagnostics.every((diagnostic) => diagnostic.severity !== 'error') &&
|
|
25
|
+
root.adapter.support === 'supported',
|
|
26
|
+
flows: {
|
|
27
|
+
onboarding: manifest.flows?.onboarding ?? false,
|
|
28
|
+
authentication: manifest.flows?.authentication ?? false,
|
|
29
|
+
},
|
|
46
30
|
};
|
|
47
31
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
/*** Resolve a node and its descendants using one platform and responsive-size context. */
|
|
33
|
+
function createNodePlan(manifest, node, pointer, options, responsiveSize) {
|
|
34
|
+
const stack = node.type === 'stack'
|
|
35
|
+
? resolveEffectiveStackConfig(manifest, node, options.platform)
|
|
36
|
+
: undefined;
|
|
37
|
+
const tabs = node.type === 'tabs'
|
|
38
|
+
? resolveTabsPlan(resolveEffectiveTabsConfig(manifest, node, options.platform), options.platform, responsiveSize)
|
|
39
|
+
: undefined;
|
|
40
|
+
const routes = node.routes.map((route, index) => createRoutePlan(manifest, route, `${pointer}/routes/${index}`, options, responsiveSize));
|
|
51
41
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
type: node.type,
|
|
43
|
+
pointer,
|
|
44
|
+
adapter: createAdapter(node, stack, tabs, options.platform, parseExpoRouterMajor(options.expoRouterVersion), options.customNavigators),
|
|
45
|
+
...(node.initialRouteName === undefined ? {} : { initialRouteName: node.initialRouteName }),
|
|
46
|
+
routes,
|
|
47
|
+
...createNodeDetails(node, stack, tabs),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/*** Preserve portable route metadata and recursively plan a nested navigator when present. */
|
|
51
|
+
function createRoutePlan(manifest, route, pointer, options, responsiveSize) {
|
|
52
|
+
return {
|
|
53
|
+
name: route.name,
|
|
54
|
+
...(route.path === undefined ? {} : { path: route.path }),
|
|
55
|
+
...(route.label === undefined ? {} : { label: route.label }),
|
|
56
|
+
...(route.icon === undefined ? {} : { icon: route.icon }),
|
|
57
|
+
...(route.showInPrimaryNavigation === undefined
|
|
58
|
+
? {}
|
|
59
|
+
: { showInPrimaryNavigation: route.showInPrimaryNavigation }),
|
|
60
|
+
guards: route.guards ?? [],
|
|
61
|
+
...(route.screenId === undefined ? {} : { screenId: route.screenId }),
|
|
62
|
+
...(route.stackOptions === undefined ? {} : { stackOptions: route.stackOptions }),
|
|
63
|
+
...(route.navigator === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: {
|
|
66
|
+
navigator: createNodePlan(manifest, route.navigator, `${pointer}/navigator`, options, responsiveSize),
|
|
67
|
+
}),
|
|
62
68
|
};
|
|
63
69
|
}
|
|
70
|
+
/*** Dispatch adapter planning to the feature that owns the authored navigator type. */
|
|
64
71
|
function createAdapter(node, stack, tabs, platform, routerMajor, customNavigators) {
|
|
65
72
|
switch (node.type) {
|
|
66
73
|
case 'slot':
|
|
67
|
-
return
|
|
68
|
-
id: 'slot',
|
|
69
|
-
module: 'expo-router',
|
|
70
|
-
exportName: 'Slot',
|
|
71
|
-
support: 'supported',
|
|
72
|
-
stability: 'stable',
|
|
73
|
-
limitations: [],
|
|
74
|
-
};
|
|
74
|
+
return createSlotAdapter();
|
|
75
75
|
case 'stack':
|
|
76
76
|
return createStackAdapter(stack, platform, routerMajor);
|
|
77
77
|
case 'drawer':
|
|
78
|
-
return
|
|
79
|
-
id: 'drawer',
|
|
80
|
-
module: 'expo-router/drawer',
|
|
81
|
-
exportName: 'Drawer',
|
|
82
|
-
support: 'supported',
|
|
83
|
-
stability: 'stable',
|
|
84
|
-
limitations: [],
|
|
85
|
-
};
|
|
78
|
+
return createDrawerAdapter();
|
|
86
79
|
case 'tabs':
|
|
87
80
|
if (tabs === undefined)
|
|
88
81
|
throw new Error('Tabs planning did not resolve an adapter.');
|
|
@@ -93,17 +86,7 @@ function createAdapter(node, stack, tabs, platform, routerMajor, customNavigator
|
|
|
93
86
|
return resolveCustomNavigatorAdapterPlan(node, platform, routerMajor, customNavigators);
|
|
94
87
|
}
|
|
95
88
|
}
|
|
96
|
-
|
|
97
|
-
if (config?.implementation === 'native' && platform === 'web') {
|
|
98
|
-
return {
|
|
99
|
-
implementation: 'native',
|
|
100
|
-
module: 'expo-router/unstable-native-tabs',
|
|
101
|
-
exportName: 'NativeTabs',
|
|
102
|
-
stability: 'alpha',
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return resolveTabsNavigatorPlan(config, platform, responsiveSize);
|
|
106
|
-
}
|
|
89
|
+
/*** Project each navigator's resolved configuration onto the shared recursive plan. */
|
|
107
90
|
function createNodeDetails(node, stack, tabs) {
|
|
108
91
|
switch (node.type) {
|
|
109
92
|
case 'stack':
|
|
@@ -143,60 +126,4 @@ function createNodeDetails(node, stack, tabs) {
|
|
|
143
126
|
return {};
|
|
144
127
|
}
|
|
145
128
|
}
|
|
146
|
-
function createRoutePlan(manifest, route, pointer, options, responsiveSize) {
|
|
147
|
-
return {
|
|
148
|
-
name: route.name,
|
|
149
|
-
...(route.path === undefined ? {} : { path: route.path }),
|
|
150
|
-
...(route.label === undefined ? {} : { label: route.label }),
|
|
151
|
-
...(route.icon === undefined ? {} : { icon: route.icon }),
|
|
152
|
-
...(route.showInPrimaryNavigation === undefined
|
|
153
|
-
? {}
|
|
154
|
-
: { showInPrimaryNavigation: route.showInPrimaryNavigation }),
|
|
155
|
-
guards: route.guards ?? [],
|
|
156
|
-
...(route.screenId === undefined ? {} : { screenId: route.screenId }),
|
|
157
|
-
...(route.stackOptions === undefined ? {} : { stackOptions: route.stackOptions }),
|
|
158
|
-
...(route.navigator === undefined
|
|
159
|
-
? {}
|
|
160
|
-
: {
|
|
161
|
-
navigator: createNodePlan(manifest, route.navigator, `${pointer}/navigator`, options, responsiveSize),
|
|
162
|
-
}),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function createNodePlan(manifest, node, pointer, options, responsiveSize) {
|
|
166
|
-
const stack = node.type === 'stack'
|
|
167
|
-
? resolveEffectiveStackConfig(manifest, node, options.platform)
|
|
168
|
-
: undefined;
|
|
169
|
-
const tabs = node.type === 'tabs'
|
|
170
|
-
? resolveTabsPlan(resolveEffectiveTabsConfig(manifest, node, options.platform), options.platform, responsiveSize)
|
|
171
|
-
: undefined;
|
|
172
|
-
const routes = node.routes.map((route, index) => createRoutePlan(manifest, route, `${pointer}/routes/${index}`, options, responsiveSize));
|
|
173
|
-
return {
|
|
174
|
-
type: node.type,
|
|
175
|
-
pointer,
|
|
176
|
-
adapter: createAdapter(node, stack, tabs, options.platform, parseExpoRouterMajor(options.expoRouterVersion), options.customNavigators),
|
|
177
|
-
...(node.initialRouteName === undefined ? {} : { initialRouteName: node.initialRouteName }),
|
|
178
|
-
routes,
|
|
179
|
-
...createNodeDetails(node, stack, tabs),
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
/*** Create a disposable, provider-aware plan from only the navigator desired-state slice. */
|
|
183
|
-
export function createNavigatorPlan(manifest, options) {
|
|
184
|
-
const context = {
|
|
185
|
-
platform: options.platform,
|
|
186
|
-
expoRouterVersion: options.expoRouterVersion,
|
|
187
|
-
};
|
|
188
|
-
const diagnostics = validateNavigatorManifest(manifest, context, options.customNavigators);
|
|
189
|
-
const root = createNodePlan(manifest, manifest, '', options, options.responsiveSize ?? 'compact');
|
|
190
|
-
return {
|
|
191
|
-
context,
|
|
192
|
-
root,
|
|
193
|
-
diagnostics,
|
|
194
|
-
supported: diagnostics.every((diagnostic) => diagnostic.severity !== 'error') &&
|
|
195
|
-
root.adapter.support === 'supported',
|
|
196
|
-
flows: {
|
|
197
|
-
onboarding: manifest.flows?.onboarding ?? false,
|
|
198
|
-
authentication: manifest.flows?.authentication ?? false,
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
129
|
//# sourceMappingURL=createNavigatorPlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNavigatorPlan.js","sourceRoot":"","sources":["../../src/utils/createNavigatorPlan.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,iCAAiC,EAAE,MAAM,kEAAkE,CAAC;AACrH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gEAAgE,CAAC;AAC7G,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAA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a,KAAK,SAAS;4BAC1C,CAAC,CAAC,EAAE;4BACJ,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;qBAC5D;oBACD,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;oBAC/E,GAAG,CAAC,IAAI,CAAC,sBAAsB,KAAK,SAAS;wBAC3C,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC,EAAE,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC;iBAC7D;aACF,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO;gBACL,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI,CAAC,WAAW;oBAC7B,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;iBAC9D;aACF,CAAC;QACJ,KAAK,MAAM;YACT,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NavigatorGeneratedFile, NavigatorGenerationBindings, NavigatorGenerationOptions, NavigatorPlan } from '
|
|
1
|
+
import type { NavigatorGeneratedFile, NavigatorGenerationBindings, NavigatorGenerationOptions, NavigatorPlan } from '@ankhorage/contracts/navigator';
|
|
2
2
|
/*** Generate deterministic Expo Router files from a validated disposable plan and narrow bindings. */
|
|
3
3
|
export declare function generateNavigatorFiles(plan: NavigatorPlan, bindings: NavigatorGenerationBindings, options?: NavigatorGenerationOptions): readonly NavigatorGeneratedFile[];
|
|
4
4
|
//# sourceMappingURL=generateNavigatorFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateNavigatorFiles.d.ts","sourceRoot":"","sources":["../../src/utils/generateNavigatorFiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,0BAA0B,EAE1B,aAAa,EAGd,MAAM,gCAAgC,CAAC;AASxC,sGAAsG;AACtG,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,2BAA2B,EACrC,OAAO,GAAE,0BAA+B,GACvC,SAAS,sBAAsB,EAAE,CAsBnC"}
|
|
@@ -1,9 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { quoteJavaScriptString, serializeJavaScriptLiteral } from '@ankhorage/utility/string';
|
|
2
|
+
import { assertStaticImportBinding } from '@ankhorage/utility/validation';
|
|
3
|
+
import { resolveDrawerRouteOptions } from '../features/drawer/adapters/outbound/resolveDrawerRouteOptions';
|
|
4
|
+
import { generateSlotLayoutFile } from '../features/slot/adapters/outbound/generateSlotLayoutFile';
|
|
5
|
+
import { generateSplitViewLayoutFile } from '../features/split-view/adapters/outbound/generateSplitViewLayoutFile';
|
|
6
|
+
import { generateTabsLayoutFile } from '../features/tabs/adapters/outbound/generateTabsLayoutFile';
|
|
7
|
+
/*** Generate deterministic Expo Router files from a validated disposable plan and narrow bindings. */
|
|
8
|
+
export function generateNavigatorFiles(plan, bindings, options = {}) {
|
|
9
|
+
const errors = plan.diagnostics.filter((diagnostic) => diagnostic.severity === 'error');
|
|
10
|
+
if (!plan.supported || errors.length > 0) {
|
|
11
|
+
throw new Error(`Cannot generate an unsupported navigator plan: ${errors.map((error) => error.code).join(', ') || 'adapter unavailable'}.`);
|
|
12
|
+
}
|
|
13
|
+
validateFlowBindings(plan, bindings);
|
|
14
|
+
const rootDirectory = resolveRootDirectory(options.rootDirectory);
|
|
15
|
+
const files = collectFiles(plan.root, rootDirectory, bindings, options.includeScreenFiles ?? true).sort((left, right) => left.path.localeCompare(right.path));
|
|
16
|
+
const paths = new Set();
|
|
17
|
+
for (const file of files) {
|
|
18
|
+
if (paths.has(file.path))
|
|
19
|
+
throw new Error(`Generated file path ${JSON.stringify(file.path)} is duplicated.`);
|
|
20
|
+
paths.add(file.path);
|
|
21
|
+
}
|
|
22
|
+
return files;
|
|
23
|
+
}
|
|
24
|
+
/*** Require enabled onboarding and authentication flows to reference an existing route. */
|
|
25
|
+
function validateFlowBindings(plan, bindings) {
|
|
26
|
+
const routeIds = new Set(collectRouteIds(plan.root));
|
|
27
|
+
for (const [enabled, routeId, name] of [
|
|
28
|
+
[plan.flows.onboarding, bindings.flows?.onboardingRoute, 'onboarding'],
|
|
29
|
+
[plan.flows.authentication, bindings.flows?.authenticationRoute, 'authentication'],
|
|
30
|
+
]) {
|
|
31
|
+
if (!enabled)
|
|
32
|
+
continue;
|
|
33
|
+
if (routeId === undefined)
|
|
34
|
+
throw new Error(`Missing ${name} flow-route binding.`);
|
|
35
|
+
if (!routeIds.has(routeId)) {
|
|
36
|
+
throw new Error(`${name[0]?.toUpperCase()}${name.slice(1)} flow route ${JSON.stringify(routeId)} does not exist.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/*** Collect nested route identifiers without changing their authored segment names. */
|
|
41
|
+
function collectRouteIds(node, parent = []) {
|
|
42
|
+
return node.routes.flatMap((route) => {
|
|
43
|
+
const segments = [...parent, route.name];
|
|
44
|
+
const routeId = segments.join('/');
|
|
45
|
+
return route.navigator === undefined
|
|
46
|
+
? [routeId]
|
|
47
|
+
: [routeId, ...collectRouteIds(route.navigator, segments)];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/*** Resolve a safe directory below the Expo Router app root without filesystem normalization. */
|
|
7
51
|
function resolveRootDirectory(rootDirectory) {
|
|
8
52
|
const directory = rootDirectory ?? APP_DIRECTORY;
|
|
9
53
|
const segments = directory.split('/');
|
|
@@ -16,80 +60,67 @@ function resolveRootDirectory(rootDirectory) {
|
|
|
16
60
|
}
|
|
17
61
|
return directory;
|
|
18
62
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
options.drawerLabel = route.label;
|
|
34
|
-
if (route.showInPrimaryNavigation === false) {
|
|
35
|
-
options.drawerItemStyle = { display: 'none' };
|
|
63
|
+
const APP_DIRECTORY = 'src/app';
|
|
64
|
+
const SAFE_ROUTE_NAME = /^[A-Za-z0-9_.()[\]-]+$/u;
|
|
65
|
+
/*** Traverse the plan to emit layouts and optional screen bindings in their route directories. */
|
|
66
|
+
function collectFiles(node, directory, bindings, includeScreenFiles) {
|
|
67
|
+
const files = [createLayoutFile(node, directory, bindings)];
|
|
68
|
+
for (const route of node.routes) {
|
|
69
|
+
assertRouteName(route.name);
|
|
70
|
+
if (includeScreenFiles) {
|
|
71
|
+
const screen = createScreenFile(route, directory, bindings);
|
|
72
|
+
if (screen !== undefined)
|
|
73
|
+
files.push(screen);
|
|
74
|
+
}
|
|
75
|
+
if (route.navigator !== undefined) {
|
|
76
|
+
files.push(...collectFiles(route.navigator, `${directory}/${route.name}`, bindings, includeScreenFiles));
|
|
36
77
|
}
|
|
37
78
|
}
|
|
38
|
-
|
|
39
|
-
node.tabs?.implementation === 'javascript' &&
|
|
40
|
-
route.showInPrimaryNavigation === false) {
|
|
41
|
-
if (node.tabs.presentation === 'top')
|
|
42
|
-
options.tabBarItemStyle = { display: 'none' };
|
|
43
|
-
else
|
|
44
|
-
options.href = null;
|
|
45
|
-
}
|
|
46
|
-
return Object.keys(options).length === 0 ? undefined : options;
|
|
79
|
+
return files;
|
|
47
80
|
}
|
|
48
|
-
/***
|
|
49
|
-
function
|
|
50
|
-
if (
|
|
51
|
-
|
|
81
|
+
/*** Dispatch specialized layout generation or render the shared Screen-registration contract. */
|
|
82
|
+
function createLayoutFile(node, directory, bindings) {
|
|
83
|
+
if (node.adapter.support !== 'supported' ||
|
|
84
|
+
node.adapter.module === undefined ||
|
|
85
|
+
node.adapter.exportName === undefined) {
|
|
86
|
+
throw new Error(`Cannot generate unavailable navigator adapter ${JSON.stringify(node.adapter.id)} at ${node.pointer || '/'}.`);
|
|
52
87
|
}
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
${
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return `${alias}()`;
|
|
75
|
-
})
|
|
76
|
-
.join(' && ');
|
|
77
|
-
return ` <${componentName}.Protected guard={${guardExpression}}>
|
|
78
|
-
${screen}
|
|
79
|
-
</${componentName}.Protected>`;
|
|
88
|
+
const tabsLayout = generateTabsLayoutFile(node, directory, bindings);
|
|
89
|
+
if (tabsLayout !== undefined)
|
|
90
|
+
return tabsLayout;
|
|
91
|
+
const splitViewLayout = generateSplitViewLayoutFile(node, directory, bindings);
|
|
92
|
+
if (splitViewLayout !== undefined)
|
|
93
|
+
return splitViewLayout;
|
|
94
|
+
const componentName = node.adapter.exportName;
|
|
95
|
+
assertStaticImportBinding(node.adapter.module, componentName, `Adapter ${JSON.stringify(node.adapter.id)}`);
|
|
96
|
+
const guardAliases = new Map();
|
|
97
|
+
const guardImports = createGuardImports(node, bindings, guardAliases);
|
|
98
|
+
const imports = [
|
|
99
|
+
`import { ${componentName} } from ${quoteJavaScriptString(node.adapter.module)};`,
|
|
100
|
+
...(guardImports.length > 0 ? ['', ...guardImports] : []),
|
|
101
|
+
].join('\n');
|
|
102
|
+
if (node.type === 'slot') {
|
|
103
|
+
return generateSlotLayoutFile(directory, componentName, imports);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
path: `${directory}/_layout.tsx`,
|
|
107
|
+
contents: createNavigatorContents(node, componentName, imports, guardAliases),
|
|
108
|
+
};
|
|
80
109
|
}
|
|
110
|
+
/*** Validate and alias every distinct guard binding used by a navigator's routes. */
|
|
81
111
|
function createGuardImports(node, bindings, guardAliases) {
|
|
82
112
|
const guards = [...new Set(node.routes.flatMap((route) => route.guards))].sort();
|
|
83
113
|
return guards.map((guard, index) => {
|
|
84
114
|
const binding = Reflect.get(bindings.guards, guard);
|
|
85
115
|
if (binding === undefined)
|
|
86
116
|
throw new Error(`Missing guard binding for ${JSON.stringify(guard)}.`);
|
|
87
|
-
|
|
117
|
+
assertStaticImportBinding(binding.module, binding.exportName, `Guard ${JSON.stringify(guard)}`);
|
|
88
118
|
const alias = `navigatorGuard${index}`;
|
|
89
119
|
guardAliases.set(guard, alias);
|
|
90
|
-
return `import { ${binding.exportName} as ${alias} } from ${
|
|
120
|
+
return `import { ${binding.exportName} as ${alias} } from ${quoteJavaScriptString(binding.module)};`;
|
|
91
121
|
});
|
|
92
122
|
}
|
|
123
|
+
/*** Render navigator options and registered screens using the resolved adapter component. */
|
|
93
124
|
function createNavigatorContents(node, componentName, imports, guardAliases) {
|
|
94
125
|
const navigatorOptions = node.type === 'stack'
|
|
95
126
|
? node.stack?.options
|
|
@@ -99,12 +130,12 @@ function createNavigatorContents(node, componentName, imports, guardAliases) {
|
|
|
99
130
|
const props = [
|
|
100
131
|
node.initialRouteName === undefined
|
|
101
132
|
? undefined
|
|
102
|
-
: `initialRouteName=${
|
|
133
|
+
: `initialRouteName=${JSON.stringify(node.initialRouteName)}`,
|
|
103
134
|
navigatorOptions === undefined
|
|
104
135
|
? undefined
|
|
105
|
-
: `screenOptions={${
|
|
136
|
+
: `screenOptions={${serializeJavaScriptLiteral(navigatorOptions)}}`,
|
|
106
137
|
node.type === 'custom' && node.custom?.config !== undefined
|
|
107
|
-
? `{...${
|
|
138
|
+
? `{...${serializeJavaScriptLiteral(node.custom.config)}}`
|
|
108
139
|
: undefined,
|
|
109
140
|
].filter((value) => value !== undefined);
|
|
110
141
|
const openingTag = `<${componentName}${props.length === 0 ? '' : ` ${props.join(' ')}`}>`;
|
|
@@ -113,37 +144,68 @@ function createNavigatorContents(node, componentName, imports, guardAliases) {
|
|
|
113
144
|
.join('\n');
|
|
114
145
|
return `${imports}\n\nexport default function NavigatorLayout() {\n return (\n ${openingTag}\n${screens}\n </${componentName}>\n );\n}\n`;
|
|
115
146
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
147
|
+
/*** Wrap a generated screen in the conjunction of its registered route guards. */
|
|
148
|
+
function renderScreen(componentName, node, route, guardAliases) {
|
|
149
|
+
const options = routeOptions(node, route);
|
|
150
|
+
const screen = renderScreenElement(componentName, route.name, options, route.guards.length === 0 ? ' ' : ' ');
|
|
151
|
+
if (route.guards.length === 0)
|
|
152
|
+
return screen;
|
|
153
|
+
const guardExpression = route.guards
|
|
154
|
+
.map((guard) => {
|
|
155
|
+
const alias = guardAliases.get(guard);
|
|
156
|
+
if (alias === undefined)
|
|
157
|
+
throw new Error(`Missing generated guard alias for ${JSON.stringify(guard)}.`);
|
|
158
|
+
return `${alias}()`;
|
|
159
|
+
})
|
|
160
|
+
.join(' && ');
|
|
161
|
+
return ` <${componentName}.Protected guard={${guardExpression}}>
|
|
162
|
+
${screen}
|
|
163
|
+
</${componentName}.Protected>`;
|
|
164
|
+
}
|
|
165
|
+
/*** Merge route labels with the owning adapter's screen-option mapping. */
|
|
166
|
+
function routeOptions(node, route) {
|
|
167
|
+
const options = {};
|
|
168
|
+
if (route.label !== undefined)
|
|
169
|
+
options.title = route.label;
|
|
170
|
+
if (node.type === 'stack' && route.stackOptions !== undefined) {
|
|
171
|
+
Object.assign(options, route.stackOptions);
|
|
121
172
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return tabsLayout;
|
|
125
|
-
const splitViewLayout = generateSplitViewLayoutFile(node, directory, bindings);
|
|
126
|
-
if (splitViewLayout !== undefined)
|
|
127
|
-
return splitViewLayout;
|
|
128
|
-
const componentName = node.adapter.exportName;
|
|
129
|
-
assertModuleBinding({ module: node.adapter.module, exportName: componentName }, `Adapter ${JSON.stringify(node.adapter.id)}`);
|
|
130
|
-
const guardAliases = new Map();
|
|
131
|
-
const guardImports = createGuardImports(node, bindings, guardAliases);
|
|
132
|
-
const imports = [
|
|
133
|
-
`import { ${componentName} } from ${quote(node.adapter.module)};`,
|
|
134
|
-
...(guardImports.length > 0 ? ['', ...guardImports] : []),
|
|
135
|
-
].join('\n');
|
|
136
|
-
if (node.type === 'slot') {
|
|
137
|
-
return {
|
|
138
|
-
path: `${directory}/_layout.tsx`,
|
|
139
|
-
contents: `${imports}\n\nexport default function NavigatorLayout() {\n return <${componentName} />;\n}\n`,
|
|
140
|
-
};
|
|
173
|
+
if (node.type === 'drawer') {
|
|
174
|
+
Object.assign(options, resolveDrawerRouteOptions(route));
|
|
141
175
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
176
|
+
if (node.type === 'tabs' &&
|
|
177
|
+
node.tabs?.implementation === 'javascript' &&
|
|
178
|
+
route.showInPrimaryNavigation === false) {
|
|
179
|
+
if (node.tabs.presentation === 'top')
|
|
180
|
+
options.tabBarItemStyle = { display: 'none' };
|
|
181
|
+
else
|
|
182
|
+
options.href = null;
|
|
183
|
+
}
|
|
184
|
+
return Object.keys(options).length === 0 ? undefined : options;
|
|
146
185
|
}
|
|
186
|
+
/*** Render one generated Screen with a stable multiline options object when route options exist. */
|
|
187
|
+
function renderScreenElement(componentName, routeName, options, indentation) {
|
|
188
|
+
if (options === undefined) {
|
|
189
|
+
return `${indentation}<${componentName}.Screen name=${JSON.stringify(routeName)} />`;
|
|
190
|
+
}
|
|
191
|
+
const optionLines = Object.entries(options)
|
|
192
|
+
.filter(([, value]) => value !== undefined)
|
|
193
|
+
.map(([key, value]) => `${indentation} ${key}: ${serializeJavaScriptLiteral(value)},`)
|
|
194
|
+
.join('\n');
|
|
195
|
+
return `${indentation}<${componentName}.Screen
|
|
196
|
+
${indentation} name=${JSON.stringify(routeName)}
|
|
197
|
+
${indentation} options={{
|
|
198
|
+
${optionLines}
|
|
199
|
+
${indentation} }}
|
|
200
|
+
${indentation}/>`;
|
|
201
|
+
}
|
|
202
|
+
/*** Reject route segments that could escape or invalidate the generated directory. */
|
|
203
|
+
function assertRouteName(name) {
|
|
204
|
+
if (!SAFE_ROUTE_NAME.test(name) || name === '.' || name === '..') {
|
|
205
|
+
throw new Error(`Route name ${JSON.stringify(name)} is not a safe generated file segment.`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/*** Emit a route module that re-exports its registered screen as the default component. */
|
|
147
209
|
function createScreenFile(route, directory, bindings) {
|
|
148
210
|
if (route.screenId === undefined)
|
|
149
211
|
return undefined;
|
|
@@ -151,66 +213,10 @@ function createScreenFile(route, directory, bindings) {
|
|
|
151
213
|
const binding = Reflect.get(bindings.screens, route.screenId);
|
|
152
214
|
if (binding === undefined)
|
|
153
215
|
throw new Error(`Missing screen binding for ${JSON.stringify(route.screenId)}.`);
|
|
154
|
-
|
|
216
|
+
assertStaticImportBinding(binding.module, binding.exportName, `Screen ${JSON.stringify(route.screenId)}`);
|
|
155
217
|
return {
|
|
156
218
|
path: `${directory}/${route.name}.tsx`,
|
|
157
|
-
contents: `export { ${binding.exportName} as default } from ${
|
|
219
|
+
contents: `export { ${binding.exportName} as default } from ${quoteJavaScriptString(binding.module)};\n`,
|
|
158
220
|
};
|
|
159
221
|
}
|
|
160
|
-
function collectFiles(node, directory, bindings, includeScreenFiles) {
|
|
161
|
-
const files = [createLayoutFile(node, directory, bindings)];
|
|
162
|
-
for (const route of node.routes) {
|
|
163
|
-
assertRouteName(route.name);
|
|
164
|
-
if (includeScreenFiles) {
|
|
165
|
-
const screen = createScreenFile(route, directory, bindings);
|
|
166
|
-
if (screen !== undefined)
|
|
167
|
-
files.push(screen);
|
|
168
|
-
}
|
|
169
|
-
if (route.navigator !== undefined) {
|
|
170
|
-
files.push(...collectFiles(route.navigator, `${directory}/${route.name}`, bindings, includeScreenFiles));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return files;
|
|
174
|
-
}
|
|
175
|
-
function collectRouteIds(node, parent = []) {
|
|
176
|
-
return node.routes.flatMap((route) => {
|
|
177
|
-
const segments = [...parent, route.name];
|
|
178
|
-
const routeId = segments.join('/');
|
|
179
|
-
return route.navigator === undefined
|
|
180
|
-
? [routeId]
|
|
181
|
-
: [routeId, ...collectRouteIds(route.navigator, segments)];
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function validateFlowBindings(plan, bindings) {
|
|
185
|
-
const routeIds = new Set(collectRouteIds(plan.root));
|
|
186
|
-
for (const [enabled, routeId, name] of [
|
|
187
|
-
[plan.flows.onboarding, bindings.flows?.onboardingRoute, 'onboarding'],
|
|
188
|
-
[plan.flows.authentication, bindings.flows?.authenticationRoute, 'authentication'],
|
|
189
|
-
]) {
|
|
190
|
-
if (!enabled)
|
|
191
|
-
continue;
|
|
192
|
-
if (routeId === undefined)
|
|
193
|
-
throw new Error(`Missing ${name} flow-route binding.`);
|
|
194
|
-
if (!routeIds.has(routeId)) {
|
|
195
|
-
throw new Error(`${name[0]?.toUpperCase()}${name.slice(1)} flow route ${JSON.stringify(routeId)} does not exist.`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/*** Generate deterministic Expo Router files from a validated disposable plan and narrow bindings. */
|
|
200
|
-
export function generateNavigatorFiles(plan, bindings, options = {}) {
|
|
201
|
-
const errors = plan.diagnostics.filter((diagnostic) => diagnostic.severity === 'error');
|
|
202
|
-
if (!plan.supported || errors.length > 0) {
|
|
203
|
-
throw new Error(`Cannot generate an unsupported navigator plan: ${errors.map((error) => error.code).join(', ') || 'adapter unavailable'}.`);
|
|
204
|
-
}
|
|
205
|
-
validateFlowBindings(plan, bindings);
|
|
206
|
-
const rootDirectory = resolveRootDirectory(options.rootDirectory);
|
|
207
|
-
const files = collectFiles(plan.root, rootDirectory, bindings, options.includeScreenFiles ?? true).sort((left, right) => left.path.localeCompare(right.path));
|
|
208
|
-
const paths = new Set();
|
|
209
|
-
for (const file of files) {
|
|
210
|
-
if (paths.has(file.path))
|
|
211
|
-
throw new Error(`Generated file path ${JSON.stringify(file.path)} is duplicated.`);
|
|
212
|
-
paths.add(file.path);
|
|
213
|
-
}
|
|
214
|
-
return files;
|
|
215
|
-
}
|
|
216
222
|
//# sourceMappingURL=generateNavigatorFiles.js.map
|