@ankhorage/contracts 10.1.0 → 11.1.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -1
  3. package/dist/appManifest/navigator.d.ts +3 -0
  4. package/dist/appManifest/navigator.d.ts.map +1 -0
  5. package/dist/appManifest/navigator.js +142 -0
  6. package/dist/appManifest/navigator.js.map +1 -0
  7. package/dist/appManifest/navigatorOptions.d.ts +13 -0
  8. package/dist/appManifest/navigatorOptions.d.ts.map +1 -0
  9. package/dist/appManifest/navigatorOptions.js +226 -0
  10. package/dist/appManifest/navigatorOptions.js.map +1 -0
  11. package/dist/appManifest/screens.d.ts +1 -2
  12. package/dist/appManifest/screens.d.ts.map +1 -1
  13. package/dist/appManifest/screens.js +2 -116
  14. package/dist/appManifest/screens.js.map +1 -1
  15. package/dist/navigator/extensions.d.ts +23 -0
  16. package/dist/navigator/extensions.d.ts.map +1 -0
  17. package/dist/navigator/extensions.js +2 -0
  18. package/dist/navigator/extensions.js.map +1 -0
  19. package/dist/navigator/generation.d.ts +26 -0
  20. package/dist/navigator/generation.d.ts.map +1 -0
  21. package/dist/navigator/generation.js +2 -0
  22. package/dist/navigator/generation.js.map +1 -0
  23. package/dist/navigator/planning.d.ts +105 -0
  24. package/dist/navigator/planning.d.ts.map +1 -0
  25. package/dist/navigator/planning.js +2 -0
  26. package/dist/navigator/planning.js.map +1 -0
  27. package/dist/navigator.d.ts +104 -15
  28. package/dist/navigator.d.ts.map +1 -1
  29. package/dist/navigator.js +23 -1
  30. package/dist/navigator.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/appManifest/navigator.ts +179 -0
  33. package/src/appManifest/navigatorOptions.ts +292 -0
  34. package/src/appManifest/screens.ts +3 -170
  35. package/src/contracts.test.ts +1 -1
  36. package/src/navigator/extensions.ts +26 -0
  37. package/src/navigator/generation.ts +28 -0
  38. package/src/navigator/planning.ts +146 -0
  39. package/src/navigator-runtime-contracts.test.ts +53 -0
  40. package/src/navigator-validation.test.ts +153 -0
  41. package/src/navigator.test.ts +153 -10
  42. package/src/navigator.ts +180 -13
@@ -1,30 +1,13 @@
1
1
  import { COLOR_HARMONIES } from '@ankhorage/color-theory';
2
2
 
3
- import {
4
- CUSTOM_TABS_PRESENTATIONS,
5
- FIXED_CUSTOM_TABS_PRESENTATIONS,
6
- JAVASCRIPT_TABS_PRESENTATIONS,
7
- NAVIGATOR_PRESETS,
8
- NAVIGATOR_TYPES,
9
- } from '../navigator';
10
3
  import { APP_CATEGORIES } from '../types';
11
4
  import { isBindingValueSource, isScreenDataLoaderDefinition } from './bindings';
12
- import { isIconSpec } from './icon';
13
- import {
14
- isOptionalBoolean,
15
- isOptionalNumber,
16
- isOptionalString,
17
- isRecord,
18
- isStringArray,
19
- } from './shared';
5
+ import { isOptionalNumber, isOptionalString, isRecord } from './shared';
6
+
7
+ export { isAppNavigatorManifest } from './navigator';
20
8
 
21
9
  const APP_CATEGORY_SET = new Set<string>(APP_CATEGORIES);
22
10
  const COLOR_HARMONY_SET = new Set<string>(COLOR_HARMONIES);
23
- const CUSTOM_TABS_PRESENTATION_SET = new Set<string>(CUSTOM_TABS_PRESENTATIONS);
24
- const FIXED_CUSTOM_TABS_PRESENTATION_SET = new Set<string>(FIXED_CUSTOM_TABS_PRESENTATIONS);
25
- const JAVASCRIPT_TABS_PRESENTATION_SET = new Set<string>(JAVASCRIPT_TABS_PRESENTATIONS);
26
- const NAVIGATOR_PRESET_SET = new Set<string>(NAVIGATOR_PRESETS);
27
- const NAVIGATOR_TYPE_SET = new Set<string>(NAVIGATOR_TYPES);
28
11
  const SPLASH_SCREEN_RESIZE_MODE_SET = new Set<string>(['contain', 'cover', 'native']);
29
12
 
30
13
  export function isManifestMetadata(value: unknown): boolean {
@@ -51,19 +34,6 @@ export function isThemeConfig(value: unknown): boolean {
51
34
  );
52
35
  }
53
36
 
54
- /*** Validate the complete serialized `AppManifest.navigator` slice. */
55
- export function isAppNavigatorManifest(value: unknown): boolean {
56
- return (
57
- isRecord(value) &&
58
- isNavigatorNode(value) &&
59
- (value.preset === undefined ||
60
- (typeof value.preset === 'string' && NAVIGATOR_PRESET_SET.has(value.preset))) &&
61
- (value.flows === undefined || isNavigatorFlows(value.flows)) &&
62
- (value.defaults === undefined || isNavigatorDefaults(value.defaults)) &&
63
- (value.platforms === undefined || isNavigatorPlatforms(value.platforms))
64
- );
65
- }
66
-
67
37
  export function isScreenRegistry(value: unknown): boolean {
68
38
  return (
69
39
  isRecord(value) &&
@@ -130,143 +100,6 @@ function isScreenSpec(value: unknown): boolean {
130
100
  );
131
101
  }
132
102
 
133
- /*** Validate one nested navigator node independently from app-level authoring metadata. */
134
- function isNavigatorNode(value: unknown): boolean {
135
- return (
136
- isRecord(value) &&
137
- typeof value.type === 'string' &&
138
- NAVIGATOR_TYPE_SET.has(value.type) &&
139
- isOptionalString(value.initialRouteName) &&
140
- Array.isArray(value.routes) &&
141
- value.routes.every(isRouteDefinition) &&
142
- (value.options === undefined || isRecord(value.options)) &&
143
- (value.type !== 'tabs' || isTabsImplementationConfig(value))
144
- );
145
- }
146
-
147
- function isRouteDefinition(value: unknown): boolean {
148
- return (
149
- isRecord(value) &&
150
- typeof value.name === 'string' &&
151
- isOptionalString(value.path) &&
152
- isOptionalString(value.label) &&
153
- (value.icon === undefined || isIconSpec(value.icon)) &&
154
- isOptionalBoolean(value.showInPrimaryNavigation) &&
155
- (value.guards === undefined || isStringArray(value.guards)) &&
156
- isOptionalString(value.screenId) &&
157
- (value.navigator === undefined || isNavigatorNode(value.navigator))
158
- );
159
- }
160
-
161
- /*** Validate tabs implementation desired state, with omitted implementation meaning adaptive. */
162
- function isTabsImplementationConfig(value: Record<string, unknown>): boolean {
163
- if (value.implementation === undefined || value.implementation === 'adaptive') {
164
- return (
165
- (value.native === undefined || isNativeTabsConfig(value.native)) &&
166
- (value.web === undefined || isCustomTabsWebConfig(value.web))
167
- );
168
- }
169
-
170
- if (value.implementation === 'native') return true;
171
-
172
- if (value.implementation === 'javascript') {
173
- return (
174
- value.presentation === undefined ||
175
- (typeof value.presentation === 'string' &&
176
- JAVASCRIPT_TABS_PRESENTATION_SET.has(value.presentation))
177
- );
178
- }
179
-
180
- return value.implementation === 'custom' && isCustomTabsConfig(value);
181
- }
182
-
183
- /*** Validate the native branch used by adaptive tabs. */
184
- function isNativeTabsConfig(value: unknown): boolean {
185
- return isRecord(value) && value.implementation === 'native';
186
- }
187
-
188
- /*** Validate a full custom-tabs implementation config. */
189
- function isCustomTabsConfig(value: Record<string, unknown>): boolean {
190
- return value.implementation === 'custom' && isCustomTabsPresentationConfig(value);
191
- }
192
-
193
- /*** Validate the implementation-free custom-tabs Web branch inside adaptive tabs. */
194
- function isCustomTabsWebConfig(value: unknown): boolean {
195
- return (
196
- isRecord(value) && value.implementation === undefined && isCustomTabsPresentationConfig(value)
197
- );
198
- }
199
-
200
- /*** Validate custom-tab presentation and its conditional serializable configuration. */
201
- function isCustomTabsPresentationConfig(value: Record<string, unknown>): boolean {
202
- if (
203
- typeof value.presentation !== 'string' ||
204
- !CUSTOM_TABS_PRESENTATION_SET.has(value.presentation)
205
- ) {
206
- return false;
207
- }
208
-
209
- if (value.responsive !== undefined && !isResponsiveTabsPresentation(value.responsive)) {
210
- return false;
211
- }
212
-
213
- if (!isOptionalString(value.customPresentationId)) return false;
214
- if (value.presentation === 'responsive' && value.responsive === undefined) return false;
215
-
216
- return (
217
- value.presentation !== 'custom' ||
218
- (typeof value.customPresentationId === 'string' && value.customPresentationId.length > 0)
219
- );
220
- }
221
-
222
- /*** Validate semantic compact/medium/expanded custom-tab presentation mapping. */
223
- function isResponsiveTabsPresentation(value: unknown): boolean {
224
- return (
225
- isRecord(value) &&
226
- typeof value.compact === 'string' &&
227
- FIXED_CUSTOM_TABS_PRESENTATION_SET.has(value.compact) &&
228
- (value.medium === undefined ||
229
- (typeof value.medium === 'string' && FIXED_CUSTOM_TABS_PRESENTATION_SET.has(value.medium))) &&
230
- typeof value.expanded === 'string' &&
231
- FIXED_CUSTOM_TABS_PRESENTATION_SET.has(value.expanded)
232
- );
233
- }
234
-
235
- /*** Validate optional app-level navigator flow intent. */
236
- function isNavigatorFlows(value: unknown): boolean {
237
- return (
238
- isRecord(value) &&
239
- isOptionalBoolean(value.onboarding) &&
240
- isOptionalBoolean(value.authentication)
241
- );
242
- }
243
-
244
- /*** Validate package-owned navigator defaults without requiring a navigator node type. */
245
- function isNavigatorDefaults(value: unknown): boolean {
246
- return (
247
- isRecord(value) &&
248
- (value.tabs === undefined || (isRecord(value.tabs) && isTabsImplementationConfig(value.tabs)))
249
- );
250
- }
251
-
252
- /*** Validate per-platform navigator implementation overrides. */
253
- function isNavigatorPlatforms(value: unknown): boolean {
254
- return (
255
- isRecord(value) &&
256
- (value.android === undefined || isNavigatorPlatformConfig(value.android)) &&
257
- (value.ios === undefined || isNavigatorPlatformConfig(value.ios)) &&
258
- (value.web === undefined || isNavigatorPlatformConfig(value.web))
259
- );
260
- }
261
-
262
- /*** Validate one platform-specific navigator override slice. */
263
- function isNavigatorPlatformConfig(value: unknown): boolean {
264
- return (
265
- isRecord(value) &&
266
- (value.tabs === undefined || (isRecord(value.tabs) && isTabsImplementationConfig(value.tabs)))
267
- );
268
- }
269
-
270
103
  function isSplashScreenModeSpec(value: unknown): boolean {
271
104
  return (
272
105
  isRecord(value) &&
@@ -80,7 +80,7 @@ describe('contracts', () => {
80
80
  });
81
81
 
82
82
  it('exports stable platform constants', () => {
83
- expect(NAVIGATOR_TYPES).toEqual(['stack', 'tabs', 'drawer']);
83
+ expect(NAVIGATOR_TYPES).toEqual(['slot', 'stack', 'tabs', 'drawer', 'split-view', 'custom']);
84
84
  expect(APP_CATEGORIES).toEqual([
85
85
  'books_reading',
86
86
  'business_productivity',
@@ -0,0 +1,26 @@
1
+ import type { CustomNavigatorNode } from '../navigator';
2
+ import type { NavigatorApiStability, NavigatorRuntimePlatform } from './planning';
3
+ export interface CustomNavigatorConfigIssue {
4
+ code: string;
5
+ message: string;
6
+ path?: string;
7
+ }
8
+
9
+ export interface CustomNavigatorRegistration {
10
+ readonly id: string;
11
+ readonly platforms: readonly NavigatorRuntimePlatform[];
12
+ readonly stability: NavigatorApiStability;
13
+ readonly integration: 'expo-router-standard';
14
+ readonly router: 'stack' | 'tab';
15
+ readonly module: string;
16
+ readonly exportName: string;
17
+ readonly validateConfig: (
18
+ config: CustomNavigatorNode['config'],
19
+ ) => readonly CustomNavigatorConfigIssue[];
20
+ }
21
+
22
+ export type CustomNavigatorRegistry = Readonly<Record<string, CustomNavigatorRegistration>> & {
23
+ readonly [CUSTOM_NAVIGATOR_REGISTRY]: true;
24
+ };
25
+
26
+ declare const CUSTOM_NAVIGATOR_REGISTRY: unique symbol;
@@ -0,0 +1,28 @@
1
+ export interface NavigatorGeneratedFile {
2
+ path: string;
3
+ contents: string;
4
+ }
5
+
6
+ export interface NavigatorGenerationBindings {
7
+ screens: Readonly<Record<string, NavigatorScreenModule>>;
8
+ guards: Readonly<Record<string, NavigatorScreenModule>>;
9
+ iconSourceResolver?: NavigatorScreenModule;
10
+ flows?: {
11
+ onboardingRoute?: string;
12
+ authenticationRoute?: string;
13
+ };
14
+ tabPresentations?: Readonly<Record<string, NavigatorScreenModule>>;
15
+ }
16
+
17
+ /** Options for placing Navigator-owned files inside a consumer-owned Expo Router app shell. */
18
+ export interface NavigatorGenerationOptions {
19
+ /** Directory that receives the root navigator layout. Must be `src/app` or one of its safe descendants. */
20
+ rootDirectory?: string;
21
+ /** Emit routed screen re-export modules in addition to layouts. Defaults to true. */
22
+ includeScreenFiles?: boolean;
23
+ }
24
+
25
+ export interface NavigatorScreenModule {
26
+ module: string;
27
+ exportName: string;
28
+ }
@@ -0,0 +1,146 @@
1
+ import type {
2
+ CustomNavigatorNode,
3
+ DrawerNavigatorOptions,
4
+ NavigatorType,
5
+ RouteDefinition,
6
+ StackImplementation,
7
+ StackScreenOptions,
8
+ } from '../navigator';
9
+ import type { CustomNavigatorRegistry } from './extensions';
10
+
11
+ export interface ResolvedCustomTabsPresentation {
12
+ presentation: ResolvedTabsPresentation;
13
+ customPresentationId?: string;
14
+ }
15
+
16
+ export type ResolvedTabsImplementation = 'custom' | 'javascript' | 'native';
17
+
18
+ export type ResolvedTabsPresentation = 'bottom' | 'top' | 'rail' | 'sidebar' | 'custom';
19
+
20
+ /**
21
+ * Disposable adapter plan for a `tabs` topology.
22
+ *
23
+ * The implementation selects the Router runtime. Presentation only selects its visual chrome and
24
+ * never creates another route topology.
25
+ */
26
+ export interface TabsNavigatorPlan {
27
+ implementation: ResolvedTabsImplementation;
28
+ module: ExpoRouterNavigatorModule;
29
+ exportName: string;
30
+ stability: NavigatorApiStability;
31
+ presentation?: ResolvedTabsPresentation;
32
+ presentations?: Readonly<Record<NavigatorResponsiveSize, ResolvedTabsPresentation>>;
33
+ customPresentationId?: string;
34
+ minimizeBehavior?: 'automatic' | 'never' | 'onScrollDown' | 'onScrollUp';
35
+ bottomAccessoryScreenId?: string;
36
+ }
37
+
38
+ export interface CreateNavigatorPlanOptions {
39
+ platform: NavigatorRuntimePlatform;
40
+ expoRouterVersion: string;
41
+ responsiveSize?: NavigatorResponsiveSize;
42
+ customNavigators?: CustomNavigatorRegistry;
43
+ }
44
+
45
+ export type ExpoRouterNavigatorModule =
46
+ | 'expo-router'
47
+ | 'expo-router/drawer'
48
+ | 'expo-router/js-stack'
49
+ | 'expo-router/js-tabs'
50
+ | 'expo-router/js-top-tabs'
51
+ | 'expo-router/ui'
52
+ | 'expo-router/unstable-split-view'
53
+ | 'expo-router/unstable-native-tabs';
54
+
55
+ export type NavigatorAdapterId =
56
+ | 'slot'
57
+ | 'stack.native'
58
+ | 'stack.javascript'
59
+ | 'stack.experimental'
60
+ | 'drawer'
61
+ | 'tabs.native'
62
+ | 'tabs.javascript'
63
+ | 'tabs.custom'
64
+ | 'split-view'
65
+ | 'custom';
66
+
67
+ export interface NavigatorAdapterPlan {
68
+ id: NavigatorAdapterId;
69
+ /** Built-in Expo Router entry point or an explicitly registered custom module. */
70
+ module?: string;
71
+ exportName?: string;
72
+ support: NavigatorSupportStatus;
73
+ stability: NavigatorApiStability;
74
+ limitations: readonly string[];
75
+ }
76
+
77
+ export type NavigatorApiStability = 'stable' | 'alpha';
78
+
79
+ export interface NavigatorDiagnostic {
80
+ code: string;
81
+ severity: 'error' | 'warning';
82
+ path: string;
83
+ message: string;
84
+ }
85
+
86
+ export interface NavigatorNodePlan {
87
+ type: NavigatorType;
88
+ pointer: string;
89
+ adapter: NavigatorAdapterPlan;
90
+ initialRouteName?: string;
91
+ routes: readonly NavigatorRoutePlan[];
92
+ stack?: {
93
+ implementation: StackImplementation;
94
+ options?: StackScreenOptions;
95
+ };
96
+ drawer?: {
97
+ options?: DrawerNavigatorOptions;
98
+ };
99
+ tabs?: TabsNavigatorPlan;
100
+ splitView?: {
101
+ columns: {
102
+ primary: string;
103
+ supplementary?: string;
104
+ };
105
+ inspector?: string;
106
+ topColumnForCollapsing?: 'primary' | 'secondary' | 'supplementary';
107
+ };
108
+ custom?: {
109
+ navigatorId: string;
110
+ config?: CustomNavigatorNode['config'];
111
+ };
112
+ }
113
+
114
+ export interface NavigatorPlan {
115
+ context: NavigatorValidationContext;
116
+ root: NavigatorNodePlan;
117
+ diagnostics: readonly NavigatorDiagnostic[];
118
+ supported: boolean;
119
+ flows: {
120
+ onboarding: boolean;
121
+ authentication: boolean;
122
+ };
123
+ }
124
+
125
+ export type NavigatorResponsiveSize = 'compact' | 'medium' | 'expanded';
126
+
127
+ export interface NavigatorRoutePlan {
128
+ name: string;
129
+ path?: string;
130
+ label?: string;
131
+ icon?: RouteDefinition['icon'];
132
+ showInPrimaryNavigation?: boolean;
133
+ guards: readonly string[];
134
+ screenId?: string;
135
+ stackOptions?: StackScreenOptions;
136
+ navigator?: NavigatorNodePlan;
137
+ }
138
+
139
+ export type NavigatorRuntimePlatform = 'android' | 'ios' | 'web';
140
+
141
+ export type NavigatorSupportStatus = 'supported' | 'unavailable';
142
+
143
+ export interface NavigatorValidationContext {
144
+ platform: NavigatorRuntimePlatform;
145
+ expoRouterVersion: string;
146
+ }
@@ -0,0 +1,53 @@
1
+ import { expect, test } from 'bun:test';
2
+
3
+ import type {
4
+ CustomNavigatorRegistration,
5
+ NavigatorGeneratedFile,
6
+ NavigatorGenerationBindings,
7
+ NavigatorPlan,
8
+ } from './navigator';
9
+
10
+ test('keeps generation bindings and plan output portable across package boundaries', () => {
11
+ const bindings: NavigatorGenerationBindings = {
12
+ screens: { home: { module: '@/screens/Home', exportName: 'Home' } },
13
+ guards: {},
14
+ };
15
+ const file: NavigatorGeneratedFile = {
16
+ path: 'src/app/index.tsx',
17
+ contents: 'export default Home;',
18
+ };
19
+ const plan: NavigatorPlan = {
20
+ context: { platform: 'web', expoRouterVersion: '57.0.18' },
21
+ root: {
22
+ type: 'slot',
23
+ pointer: '',
24
+ adapter: {
25
+ id: 'slot',
26
+ module: 'expo-router',
27
+ exportName: 'Slot',
28
+ support: 'supported',
29
+ stability: 'stable',
30
+ limitations: [],
31
+ },
32
+ routes: [],
33
+ },
34
+ diagnostics: [],
35
+ supported: true,
36
+ flows: { onboarding: false, authentication: false },
37
+ };
38
+ expect(JSON.parse(JSON.stringify({ bindings, file, plan }))).toEqual({ bindings, file, plan });
39
+ });
40
+
41
+ test('describes a custom extension without importing Navigator or a UI runtime', () => {
42
+ const registration: CustomNavigatorRegistration = {
43
+ id: 'example',
44
+ platforms: ['web'],
45
+ stability: 'stable',
46
+ integration: 'expo-router-standard',
47
+ router: 'stack',
48
+ module: '@example/navigation',
49
+ exportName: 'ExampleNavigator',
50
+ validateConfig: () => [],
51
+ };
52
+ expect(registration.validateConfig({ mode: 'compact' })).toEqual([]);
53
+ });
@@ -0,0 +1,153 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+
4
+ import { describe, expect, it } from 'bun:test';
5
+
6
+ import { isAppNavigatorManifest } from './appManifest/screens';
7
+ import type {
8
+ CustomNavigatorNode,
9
+ CustomTabsConfig,
10
+ NavigatorNode,
11
+ StackImplementationConfig,
12
+ } from './navigator';
13
+
14
+ describe('app navigator manifest type discrimination', () => {
15
+ it('prevents incompatible options and non-serializable configuration at compile time', () => {
16
+ // @ts-expect-error Slot does not own an arbitrary options bag.
17
+ const slot: NavigatorNode = { type: 'slot', options: { arbitrary: true }, routes: [] };
18
+ // @ts-expect-error Experimental Stack has no presentation options.
19
+ const experimental: StackImplementationConfig = {
20
+ implementation: 'experimental',
21
+ options: { presentation: 'modal' },
22
+ };
23
+ // @ts-expect-error Fixed custom tabs do not accept a registered custom presentation id.
24
+ const tabs: CustomTabsConfig = {
25
+ implementation: 'custom',
26
+ presentation: 'sidebar',
27
+ customPresentationId: 'workspace-tabs',
28
+ };
29
+ // @ts-expect-error Custom navigator configuration must be serializable manifest values.
30
+ const custom: CustomNavigatorNode = {
31
+ type: 'custom',
32
+ navigatorId: 'workspace',
33
+ config: { callback: () => undefined },
34
+ routes: [],
35
+ };
36
+
37
+ expect([slot, experimental, tabs, custom]).toHaveLength(4);
38
+ });
39
+ });
40
+
41
+ describe('app navigator manifest stack validation', () => {
42
+ it('rejects the removed untyped options bag and unsupported stack branch fields', () => {
43
+ expect(isAppNavigatorManifest({ type: 'slot', options: { arbitrary: true }, routes: [] })).toBe(
44
+ false,
45
+ );
46
+ expect(
47
+ isAppNavigatorManifest({
48
+ type: 'stack',
49
+ implementation: 'experimental',
50
+ options: { presentation: 'modal' },
51
+ routes: [],
52
+ }),
53
+ ).toBe(false);
54
+ expect(
55
+ isAppNavigatorManifest({
56
+ type: 'stack',
57
+ implementation: 'javascript',
58
+ options: { presentation: 'formSheet' },
59
+ routes: [],
60
+ }),
61
+ ).toBe(false);
62
+ expect(
63
+ isAppNavigatorManifest({
64
+ type: 'stack',
65
+ implementation: 'native',
66
+ minimizeBehavior: 'never',
67
+ routes: [],
68
+ }),
69
+ ).toBe(false);
70
+ });
71
+ });
72
+
73
+ describe('app navigator manifest sheet validation', () => {
74
+ it('validates native form-sheet detents and their presentation discriminant', () => {
75
+ for (const sheetAllowedDetents of [[], [0.8, 0.4], [0.4, 0.4], [0], [1.1], [Number.NaN]]) {
76
+ expect(
77
+ isAppNavigatorManifest({
78
+ type: 'stack',
79
+ options: { presentation: 'formSheet', sheetAllowedDetents },
80
+ routes: [],
81
+ }),
82
+ ).toBe(false);
83
+ }
84
+ expect(
85
+ isAppNavigatorManifest({
86
+ type: 'stack',
87
+ options: { presentation: 'modal', sheetGrabberVisible: true },
88
+ routes: [],
89
+ }),
90
+ ).toBe(false);
91
+ expect(
92
+ isAppNavigatorManifest({
93
+ type: 'stack',
94
+ routes: [
95
+ {
96
+ name: 'compose',
97
+ stackOptions: {
98
+ presentation: 'formSheet',
99
+ sheetAllowedDetents: 'fitToContents',
100
+ },
101
+ },
102
+ ],
103
+ }),
104
+ ).toBe(true);
105
+ });
106
+ });
107
+
108
+ describe('app navigator manifest custom validation', () => {
109
+ it('rejects non-JSON and cyclic custom navigator configuration', () => {
110
+ const cyclicConfig: Record<string, unknown> = {};
111
+ cyclicConfig.self = cyclicConfig;
112
+
113
+ for (const invalidConfig of [
114
+ { callback: () => undefined },
115
+ { token: Symbol('token') },
116
+ { count: Number.NaN },
117
+ { count: Number.POSITIVE_INFINITY },
118
+ cyclicConfig,
119
+ ]) {
120
+ expect(
121
+ isAppNavigatorManifest({
122
+ type: 'custom',
123
+ navigatorId: 'workspace',
124
+ config: invalidConfig,
125
+ routes: [],
126
+ }),
127
+ ).toBe(false);
128
+ }
129
+ });
130
+
131
+ it('rejects incomplete Split View bindings', () => {
132
+ expect(
133
+ isAppNavigatorManifest({
134
+ type: 'split-view',
135
+ columns: {},
136
+ routes: [],
137
+ }),
138
+ ).toBe(false);
139
+ });
140
+ });
141
+
142
+ describe('app navigator manifest package boundary', () => {
143
+ it('publishes the focused navigator contract subpath', async () => {
144
+ const packageJson = JSON.parse(await readFile(join(process.cwd(), 'package.json'), 'utf8')) as {
145
+ exports?: Record<string, { default?: string; types?: string }>;
146
+ };
147
+
148
+ expect(packageJson.exports?.['./navigator']).toEqual({
149
+ types: './dist/navigator.d.ts',
150
+ default: './dist/navigator.js',
151
+ });
152
+ });
153
+ });