anhedral 0.16.0 → 0.17.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 (109) hide show
  1. package/README.md +75 -18
  2. package/assets/ui/UPSTREAM.json +1 -18
  3. package/dist/capabilities.d.ts +1 -1
  4. package/dist/dependencies.d.ts +0 -3
  5. package/dist/dependencies.js +0 -54
  6. package/dist/registry/resolve.js +2 -0
  7. package/dist/scaffold/documentation.js +17 -48
  8. package/dist/scaffold/workspace.js +0 -6
  9. package/dist/stack-registry.d.ts +2 -4
  10. package/dist/stack-registry.js +1 -11
  11. package/dist/version.d.ts +1 -1
  12. package/dist/version.js +1 -1
  13. package/docs/anhedral-stack.md +10 -5
  14. package/docs/assets/anhedral-stack-light.png +0 -0
  15. package/docs/assets/anhedral-stack.png +0 -0
  16. package/docs/capabilities.md +1 -1
  17. package/docs/native-ui.md +47 -102
  18. package/docs/software-factory.md +37 -24
  19. package/docs/stack-standard.md +19 -21
  20. package/docs/ui.md +1 -1
  21. package/docs/verification.md +6 -1067
  22. package/package.json +10 -6
  23. package/assets/ui/native/_controls.tsx +0 -521
  24. package/assets/ui/native/_core.tsx +0 -118
  25. package/assets/ui/native/_data.tsx +0 -200
  26. package/assets/ui/native/_display.tsx +0 -453
  27. package/assets/ui/native/_feedback.tsx +0 -242
  28. package/assets/ui/native/_legacy-dialog.tsx +0 -38
  29. package/assets/ui/native/_motion.tsx +0 -520
  30. package/assets/ui/native/_overlay.tsx +0 -402
  31. package/assets/ui/native/_selection.tsx +0 -366
  32. package/assets/ui/native/accordion.tsx +0 -1
  33. package/assets/ui/native/alert-dialog.tsx +0 -11
  34. package/assets/ui/native/alert.tsx +0 -1
  35. package/assets/ui/native/aspect-ratio.tsx +0 -1
  36. package/assets/ui/native/attachment.tsx +0 -8
  37. package/assets/ui/native/avatar.tsx +0 -8
  38. package/assets/ui/native/badge.tsx +0 -1
  39. package/assets/ui/native/breadcrumb.tsx +0 -9
  40. package/assets/ui/native/bubble.tsx +0 -1
  41. package/assets/ui/native/button-group.tsx +0 -1
  42. package/assets/ui/native/button.tsx +0 -86
  43. package/assets/ui/native/calendar.tsx +0 -170
  44. package/assets/ui/native/card.tsx +0 -44
  45. package/assets/ui/native/carousel.tsx +0 -1
  46. package/assets/ui/native/chart.tsx +0 -193
  47. package/assets/ui/native/checkbox.tsx +0 -1
  48. package/assets/ui/native/code-block.tsx +0 -137
  49. package/assets/ui/native/collapsible.tsx +0 -1
  50. package/assets/ui/native/combobox.tsx +0 -1
  51. package/assets/ui/native/command.tsx +0 -11
  52. package/assets/ui/native/context-menu.tsx +0 -16
  53. package/assets/ui/native/data-table.tsx +0 -1
  54. package/assets/ui/native/date-picker.tsx +0 -43
  55. package/assets/ui/native/dialog.tsx +0 -15
  56. package/assets/ui/native/direction.tsx +0 -1
  57. package/assets/ui/native/drawer.tsx +0 -10
  58. package/assets/ui/native/dropdown-menu.tsx +0 -16
  59. package/assets/ui/native/empty.tsx +0 -8
  60. package/assets/ui/native/field.tsx +0 -13
  61. package/assets/ui/native/hover-card.tsx +0 -1
  62. package/assets/ui/native/input-group.tsx +0 -8
  63. package/assets/ui/native/input-otp.tsx +0 -1
  64. package/assets/ui/native/input.tsx +0 -28
  65. package/assets/ui/native/item.tsx +0 -12
  66. package/assets/ui/native/kbd.tsx +0 -1
  67. package/assets/ui/native/label.tsx +0 -4
  68. package/assets/ui/native/layout.tsx +0 -26
  69. package/assets/ui/native/marker.tsx +0 -1
  70. package/assets/ui/native/menubar.tsx +0 -17
  71. package/assets/ui/native/message-scroller.tsx +0 -6
  72. package/assets/ui/native/message.tsx +0 -10
  73. package/assets/ui/native/native-select.tsx +0 -1
  74. package/assets/ui/native/navigation-menu.tsx +0 -10
  75. package/assets/ui/native/pagination.tsx +0 -9
  76. package/assets/ui/native/popover.tsx +0 -1
  77. package/assets/ui/native/progress.tsx +0 -1
  78. package/assets/ui/native/questionnaire.tsx +0 -130
  79. package/assets/ui/native/radio-group.tsx +0 -1
  80. package/assets/ui/native/registry.json +0 -1103
  81. package/assets/ui/native/resizable.tsx +0 -1
  82. package/assets/ui/native/scroll-area.tsx +0 -1
  83. package/assets/ui/native/select.tsx +0 -11
  84. package/assets/ui/native/separator.tsx +0 -1
  85. package/assets/ui/native/sheet.tsx +0 -10
  86. package/assets/ui/native/sidebar.tsx +0 -22
  87. package/assets/ui/native/skeleton.tsx +0 -1
  88. package/assets/ui/native/slider.tsx +0 -1
  89. package/assets/ui/native/spinner.tsx +0 -1
  90. package/assets/ui/native/switch.tsx +0 -1
  91. package/assets/ui/native/table.tsx +0 -10
  92. package/assets/ui/native/tabs.tsx +0 -1
  93. package/assets/ui/native/text.tsx +0 -20
  94. package/assets/ui/native/textarea.tsx +0 -1
  95. package/assets/ui/native/theme-switcher.tsx +0 -22
  96. package/assets/ui/native/toast.tsx +0 -11
  97. package/assets/ui/native/toggle-group.tsx +0 -1
  98. package/assets/ui/native/toggle.tsx +0 -1
  99. package/assets/ui/native/tooltip.tsx +0 -1
  100. package/assets/ui/native/trace.tsx +0 -20
  101. package/assets/ui/native/typography.tsx +0 -15
  102. package/assets/ui/theme-storage.ts +0 -25
  103. package/assets/ui/theme.tsx +0 -66
  104. package/dist/platforms/mobile.d.ts +0 -2
  105. package/dist/platforms/mobile.js +0 -137
  106. package/dist/scaffold/expo-runtime.d.ts +0 -3
  107. package/dist/scaffold/expo-runtime.js +0 -42
  108. package/dist/scaffold/native-ui.d.ts +0 -2
  109. package/dist/scaffold/native-ui.js +0 -74
@@ -1 +0,0 @@
1
- export { ResizablePanelGroup, ResizablePanel, ResizableHandle } from './_motion';
@@ -1 +0,0 @@
1
- export { ScrollArea, ScrollBar } from './_data';
@@ -1,11 +0,0 @@
1
- export {
2
- Select,
3
- SelectTrigger,
4
- SelectValue,
5
- SelectContent,
6
- SelectItem,
7
- SelectGroup,
8
- SelectLabel,
9
- SelectItemText,
10
- SelectSeparator,
11
- } from './_selection';
@@ -1 +0,0 @@
1
- export { Separator } from './_display';
@@ -1,10 +0,0 @@
1
- export {
2
- Sheet,
3
- SheetTrigger,
4
- SheetContent,
5
- SheetClose,
6
- SheetHeader,
7
- SheetFooter,
8
- SheetTitle,
9
- SheetDescription,
10
- } from './_overlay';
@@ -1,22 +0,0 @@
1
- export {
2
- SidebarProvider,
3
- useSidebar,
4
- Sidebar,
5
- SidebarTrigger,
6
- SidebarInset,
7
- SidebarHeader,
8
- SidebarFooter,
9
- SidebarContent,
10
- SidebarGroup,
11
- SidebarGroupContent,
12
- SidebarGroupLabel,
13
- SidebarMenu,
14
- SidebarMenuItem,
15
- SidebarMenuButton,
16
- SidebarMenuAction,
17
- SidebarMenuBadge,
18
- SidebarSeparator,
19
- SidebarMenuSub,
20
- SidebarMenuSubItem,
21
- SidebarMenuSubButton,
22
- } from './_feedback';
@@ -1 +0,0 @@
1
- export { Skeleton } from './_display';
@@ -1 +0,0 @@
1
- export { Slider } from './_motion';
@@ -1 +0,0 @@
1
- export { Spinner } from './_display';
@@ -1 +0,0 @@
1
- export { Switch } from './_controls';
@@ -1,10 +0,0 @@
1
- export {
2
- Table,
3
- TableHeader,
4
- TableBody,
5
- TableFooter,
6
- TableRow,
7
- TableHead,
8
- TableCell,
9
- TableCaption,
10
- } from './_data';
@@ -1 +0,0 @@
1
- export { Tabs, TabsList, TabsTrigger, TabsContent } from './_controls';
@@ -1,20 +0,0 @@
1
- import { Text as NativeText, StyleSheet, type TextProps as NativeTextProps } from 'react-native';
2
- import { useTheme } from '../theme';
3
- export type TextProps = NativeTextProps & {
4
- variant?: 'heading' | 'title' | 'body' | 'muted' | 'caption' | 'label';
5
- };
6
- const typography = StyleSheet.create({
7
- heading: { fontSize: 24, lineHeight: 32, fontWeight: '600' },
8
- title: { fontSize: 16, lineHeight: 22, fontWeight: '500' },
9
- body: { fontSize: 14, lineHeight: 20, fontWeight: '400' },
10
- muted: { fontSize: 14, lineHeight: 20, fontWeight: '400' },
11
- caption: { fontSize: 12, lineHeight: 20, fontWeight: '400' },
12
- label: { fontSize: 14, lineHeight: 20, fontWeight: '500' },
13
- });
14
- export function Text({ variant = 'body', style, ...props }: TextProps) {
15
- const { colors } = useTheme();
16
- const color = ['muted', 'caption'].includes(variant)
17
- ? colors['muted-foreground']
18
- : colors.foreground;
19
- return <NativeText {...props} style={[typography[variant], { color }, style]} />;
20
- }
@@ -1 +0,0 @@
1
- export { Textarea } from './_controls';
@@ -1,22 +0,0 @@
1
- import { Stack } from './layout';
2
- import { Button } from './button';
3
- import { Text } from './text';
4
- import { useTheme } from '../theme';
5
- export function ThemeSwitcher() {
6
- const { preference, setPreference } = useTheme();
7
- return (
8
- <Stack>
9
- <Text variant="label">Appearance</Text>
10
- {(['system', 'light', 'dark'] as const).map((value) => (
11
- <Button
12
- key={value}
13
- variant={preference === value ? 'secondary' : 'ghost'}
14
- accessibilityState={{ selected: preference === value }}
15
- onPress={() => setPreference(value)}
16
- >
17
- {value === 'system' ? 'System' : value === 'light' ? 'Light' : 'Dark'}
18
- </Button>
19
- ))}
20
- </Stack>
21
- );
22
- }
@@ -1,11 +0,0 @@
1
- export {
2
- ToastProvider,
3
- useToast,
4
- Toast,
5
- Toaster,
6
- ToastViewport,
7
- ToastTitle,
8
- ToastDescription,
9
- ToastAction,
10
- ToastClose,
11
- } from './_feedback';
@@ -1 +0,0 @@
1
- export { ToggleGroup, ToggleGroupItem } from './_controls';
@@ -1 +0,0 @@
1
- export { Toggle } from './_controls';
@@ -1 +0,0 @@
1
- export { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, TooltipClose } from './_overlay';
@@ -1,20 +0,0 @@
1
- import { Box, LabelText, Muted, row } from './_core';
2
- import { Collapsible, CollapsibleTrigger, CollapsibleContent } from './_controls';
3
- import { CodeBlock } from './code-block';
4
- import type { ViewProps } from 'react-native';
5
- export const Trace = Box;
6
- export const TraceItem = Collapsible;
7
- export const TraceTrigger = CollapsibleTrigger;
8
- export const TraceContent = CollapsibleContent;
9
- export const TraceTitle = LabelText;
10
- export const TraceDescription = Muted;
11
- export const TraceIcon = Box;
12
- export const TraceHeader = ({ style, ...props }: ViewProps) => (
13
- <Box {...props} style={row(style)} />
14
- );
15
- export const TraceCode = CodeBlock;
16
- export const TraceStatus = ({
17
- status,
18
- }: {
19
- status: 'pending' | 'running' | 'complete' | 'error';
20
- }) => <LabelText accessibilityLiveRegion="polite">{status}</LabelText>;
@@ -1,15 +0,0 @@
1
- export {
2
- Typography,
3
- TypographyH1,
4
- TypographyH2,
5
- TypographyH3,
6
- TypographyH4,
7
- TypographyP,
8
- TypographyMuted,
9
- TypographyLead,
10
- TypographyLarge,
11
- TypographySmall,
12
- TypographyBlockquote,
13
- TypographyInlineCode,
14
- TypographyList,
15
- } from './_display';
@@ -1,25 +0,0 @@
1
- import { Appearance } from 'react-native';
2
- import AsyncStorage from '@react-native-async-storage/async-storage';
3
- import * as SystemUI from 'expo-system-ui';
4
- const key = 'anhedral-theme';
5
- export async function readPreference() {
6
- try {
7
- return await AsyncStorage.getItem(key);
8
- } catch {
9
- return null;
10
- }
11
- }
12
- export async function savePreference(value: string) {
13
- try {
14
- await AsyncStorage.setItem(key, value);
15
- } catch {
16
- /* Preferences remain usable without storage. */
17
- }
18
- }
19
- export function applyTheme(mode: 'light' | 'dark', background: string, preference: string) {
20
- Appearance.setColorScheme(preference === 'system' ? 'unspecified' : mode);
21
- void SystemUI.setBackgroundColorAsync(background).catch(() => {});
22
- }
23
- export function subscribePreference(_listener: (value: unknown) => void) {
24
- return () => {};
25
- }
@@ -1,66 +0,0 @@
1
- import { createContext, useContext, useEffect, useRef, useState, type ReactNode } from 'react';
2
- import { useColorScheme } from 'react-native';
3
- import { styling } from '@workspace/styling';
4
- type ThemeColors = Record<string, string> & { background: string; foreground: string };
5
- const colors = (tokens: Record<string, string>) =>
6
- Object.fromEntries(
7
- Object.entries(tokens)
8
- .filter(([key]) => key !== '--radius')
9
- .map(([key, value]) => [key.slice(2), 'hsl(' + value.replaceAll(' ', ', ') + ')']),
10
- ) as ThemeColors;
11
- const themes = { light: colors(styling.themes.light), dark: colors(styling.themes.dark) };
12
- import { readPreference, savePreference, applyTheme, subscribePreference } from './theme-storage';
13
-
14
- export type ThemePreference = 'system' | 'light' | 'dark';
15
- export function isThemePreference(value: unknown): value is ThemePreference {
16
- return value === 'system' || value === 'light' || value === 'dark';
17
- }
18
- const ThemeContext = createContext<{
19
- preference: ThemePreference;
20
- mode: 'light' | 'dark';
21
- colors: typeof themes.light;
22
- setPreference: (value: ThemePreference) => void;
23
- } | null>(null);
24
- export function ThemeProvider({ children }: { children: ReactNode }) {
25
- const system = useColorScheme();
26
- const [preference, setPreferenceState] = useState<ThemePreference>('system');
27
- const [ready, setReady] = useState(false);
28
- const changed = useRef(false);
29
- const mode = preference === 'system' ? (system === 'dark' ? 'dark' : 'light') : preference;
30
- useEffect(() => {
31
- let active = true;
32
- void readPreference()
33
- .then((saved) => {
34
- if (active && !changed.current && isThemePreference(saved)) setPreferenceState(saved);
35
- })
36
- .finally(() => {
37
- if (active) setReady(true);
38
- });
39
- const unsubscribe = subscribePreference((saved) => {
40
- if (isThemePreference(saved)) setPreferenceState(saved);
41
- });
42
- return () => {
43
- active = false;
44
- unsubscribe();
45
- };
46
- }, []);
47
- useEffect(() => {
48
- if (ready) applyTheme(mode, themes[mode].background, preference);
49
- }, [mode, ready, preference]);
50
- function setPreference(value: ThemePreference) {
51
- if (!isThemePreference(value)) return;
52
- changed.current = true;
53
- setPreferenceState(value);
54
- void savePreference(value);
55
- }
56
- return (
57
- <ThemeContext.Provider value={{ preference, mode, colors: themes[mode], setPreference }}>
58
- {children}
59
- </ThemeContext.Provider>
60
- );
61
- }
62
- export function useTheme() {
63
- const value = useContext(ThemeContext);
64
- if (!value) throw new Error('Mount ThemeProvider at the application root.');
65
- return value;
66
- }
@@ -1,2 +0,0 @@
1
- import type { RecipeContext } from '../registry/types.js';
2
- export declare function scaffoldExpo(context: RecipeContext): Promise<void>;
@@ -1,137 +0,0 @@
1
- import { NATIVE_ESLINT_VERSION } from '../dependencies.js';
2
- import path from 'node:path';
3
- import { writeReactLintConfig } from './lint.js';
4
- import { appendGitignore, writeFile } from '../util.js';
5
- import { childPackageName, jsString } from '../render.js';
6
- import { MOBILE_APP_DEPENDENCIES } from '../dependencies.js';
7
- import { scaffoldNativeUI } from '../scaffold/native-ui.js';
8
- import { scaffoldExpoRuntime } from '../scaffold/expo-runtime.js';
9
- function expoScheme(projectName) {
10
- const unscoped = projectName.replace(/^@[^/]+\//, '');
11
- const safe = unscoped.toLowerCase().replace(/[^a-z0-9+.-]+/g, '-');
12
- let start = 0;
13
- let end = safe.length;
14
- while (start < end && '+.-'.includes(safe[start]))
15
- start++;
16
- while (end > start && '+.-'.includes(safe[end - 1]))
17
- end--;
18
- const normalized = safe.slice(start, end);
19
- const candidate = normalized || 'app';
20
- return /^[a-z]/.test(candidate) ? candidate : `app-${candidate}`;
21
- }
22
- export async function scaffoldExpo(context) {
23
- const { root, options } = context;
24
- const dir = path.join(root, 'apps/mobile');
25
- const projectName = options.name;
26
- const displayName = options.name;
27
- const nameLiteral = jsString(displayName);
28
- writeReactLintConfig(dir);
29
- writeFile(path.join(dir, 'babel.config.js'), "module.exports = function(api) { api.cache(true); return { presets: ['babel-preset-expo'] }; };\n");
30
- writeFile(path.join(dir, 'package.json'), JSON.stringify({
31
- name: childPackageName(projectName, 'mobile'),
32
- version: '0.1.0',
33
- private: true,
34
- main: 'expo-router/entry',
35
- scripts: {
36
- android: 'expo start -c --android',
37
- ios: 'expo start -c --ios',
38
- start: 'expo start -c',
39
- build: 'pnpm typecheck',
40
- typecheck: 'tsc --noEmit',
41
- lint: 'eslint . --max-warnings 0',
42
- },
43
- dependencies: {
44
- ...MOBILE_APP_DEPENDENCIES.dependencies,
45
- '@workspace/native-ui': 'workspace:*',
46
- '@workspace/styling': 'workspace:*',
47
- },
48
- devDependencies: {
49
- ...MOBILE_APP_DEPENDENCIES.devDependencies,
50
- '@workspace/eslint-config': 'workspace:*',
51
- eslint: NATIVE_ESLINT_VERSION,
52
- },
53
- }, null, 2) + '\n');
54
- writeFile(path.join(dir, 'app.json'), JSON.stringify({
55
- expo: {
56
- name: displayName,
57
- slug: projectName.replace(/^@[^/]+\//, ''),
58
- version: '1.0.0',
59
- orientation: 'portrait',
60
- userInterfaceStyle: 'automatic',
61
- scheme: expoScheme(projectName),
62
- platforms: ['ios', 'android'],
63
- plugins: ['expo-router', 'expo-status-bar'],
64
- experiments: { reactCompiler: true, typedRoutes: true },
65
- },
66
- }, null, 2) + '\n');
67
- writeFile(path.join(dir, 'tsconfig.json'), JSON.stringify({
68
- extends: 'expo/tsconfig.base',
69
- compilerOptions: {
70
- strict: true,
71
- noUncheckedIndexedAccess: true,
72
- paths: { '@/*': ['./*'] },
73
- },
74
- include: ['**/*.ts', '**/*.tsx', '.expo/types/**/*.ts', 'expo-env.d.ts'],
75
- exclude: ['node_modules', 'worker', '.output', 'worker-configuration.d.ts'],
76
- }, null, 2) + '\n');
77
- scaffoldNativeUI(root);
78
- writeFile(path.join(dir, 'components/ui/button.tsx'), "export { Button } from '@workspace/native-ui';\n");
79
- writeFile(path.join(dir, 'app/_layout.tsx'), `import '@/lib/development-client';
80
- import { ThemeProvider } from '@workspace/native-ui';
81
- import { SafeAreaProvider } from 'react-native-safe-area-context';
82
- import { Stack } from 'expo-router';
83
-
84
- export default function RootLayout() {
85
- return <SafeAreaProvider><ThemeProvider><Stack /></ThemeProvider></SafeAreaProvider>;
86
- }
87
- `);
88
- writeFile(path.join(dir, 'lib/development-client.ts'), 'export {};\n');
89
- writeFile(path.join(dir, 'lib/development-client.native.ts'), "import 'expo-dev-client';\n");
90
- writeFile(path.join(dir, 'app/index.tsx'), `import { useEffect, useState } from 'react';
91
- import { api } from '@/lib/api-client';
92
- import { StatusBar } from 'expo-status-bar';
93
- import { Linking } from 'react-native';
94
- import { Screen, Stack, Text } from '@workspace/native-ui';
95
- import { Button } from '@/components/ui/button';
96
-
97
- export default function HomeScreen() {
98
- const [connection, setConnection] = useState('Connecting to the API…');
99
- const [pending, setPending] = useState(true);
100
- useEffect(() => {
101
- let active = true;
102
- void api.health().then(
103
- () => { if (active) setConnection('API connected'); },
104
- () => { if (active) setConnection('Unable to reach the API. Check the server and device API origin.'); },
105
- ).finally(() => { if (active) setPending(false); });
106
- return () => { active = false; };
107
- }, []);
108
- async function checkConnection() {
109
- setPending(true);
110
- setConnection('Connecting to the API…');
111
- try { await api.health(); setConnection('API connected'); }
112
- catch { setConnection('Unable to reach the API. Check the server and device API origin.'); }
113
- finally { setPending(false); }
114
- }
115
-
116
- return <Screen><StatusBar style="auto" /><Stack>
117
- <Text variant="heading" accessibilityRole="header">{${nameLiteral}}</Text>
118
- <Text variant="muted">Native iOS and Android application generated by Anhedral.</Text>
119
- <Text accessibilityLiveRegion="polite">{connection}</Text>
120
- <Button disabled={pending} onPress={() => void checkConnection()}>{pending ? 'Connecting…' : 'Check API connection'}</Button>
121
- <Button onPress={() => void Linking.openURL('https://docs.expo.dev')}>Learn more</Button>
122
- </Stack></Screen>;
123
- }
124
- `);
125
- writeFile(path.join(dir, '.env.example'), '');
126
- scaffoldExpoRuntime(context);
127
- appendGitignore(dir, [
128
- '.env',
129
- '.env.*',
130
- '!.env.example',
131
- '.expo',
132
- '.wrangler',
133
- '.output',
134
- 'dist',
135
- 'node_modules',
136
- ]);
137
- }
@@ -1,3 +0,0 @@
1
- import type { RecipeContext } from '../registry/types.js';
2
- /** Native uses the public product origin; all browser transport belongs to Next. */
3
- export declare function scaffoldExpoRuntime({ root }: RecipeContext): void;
@@ -1,42 +0,0 @@
1
- import { writeEnvironmentFile } from './environment.js';
2
- import { patchPackage, put } from './files.js';
3
- /** Native uses the public product origin; all browser transport belongs to Next. */
4
- export function scaffoldExpoRuntime({ root }) {
5
- const directory = 'apps/mobile';
6
- patchPackage(root, `${directory}/package.json`, {
7
- dependencies: { '@workspace/contracts': 'workspace:*' },
8
- });
9
- put(root, `${directory}/lib/api-client.ts`, `import { createApiClient } from '@workspace/contracts';
10
-
11
- type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
12
-
13
- function validProtocol(url: URL): boolean {
14
- return url.protocol === 'https:' || (__DEV__ && url.protocol === 'http:');
15
- }
16
- function nativeApiOrigin(): string {
17
- const configured = process.env.EXPO_PUBLIC_API_URL;
18
- if (!configured) throw new Error('Configure EXPO_PUBLIC_API_URL with the product origin reachable from this device.');
19
- const origin = new URL(configured);
20
- if (!validProtocol(origin)) throw new Error('EXPO_PUBLIC_API_URL requires HTTPS outside development.');
21
- if ([origin.username, origin.password, origin.pathname !== '/', origin.search, origin.hash].some(Boolean))
22
- throw new Error('EXPO_PUBLIC_API_URL must be an origin without credentials, path, query or fragment.');
23
- return origin.origin;
24
- }
25
- function apiBaseURL(): string {
26
- return nativeApiOrigin() + '/api';
27
- }
28
-
29
- // Consumers can extend transport headers for their own application. No server secret belongs here.
30
- function createApplicationApiClient(options: Options = {}) {
31
- const client = () => createApiClient(apiBaseURL(), {
32
- ...options, credentials: 'omit',
33
- });
34
- return {
35
- health: (init?: RequestInit) => client().health(init),
36
- };
37
- }
38
-
39
- export const api = createApplicationApiClient();
40
- `);
41
- writeEnvironmentFile(root, `${directory}/.env.example`, { EXPO_PUBLIC_API_URL: '' });
42
- }
@@ -1,2 +0,0 @@
1
- /** Anhedral-maintained native shadcn port. Never imported by the DOM application. */
2
- export declare function scaffoldNativeUI(root: string): void;
@@ -1,74 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import { NATIVE_ESLINT_VERSION, NATIVE_UI_DEPENDENCIES, MOBILE_APP_DEPENDENCIES, } from '../dependencies.js';
4
- import { json, put } from './files.js';
5
- import { writeReactLintConfig } from '../platforms/lint.js';
6
- /** Anhedral-maintained native shadcn port. Never imported by the DOM application. */
7
- export function scaffoldNativeUI(root) {
8
- const assets = fileURLToPath(new URL('../../assets/ui/', import.meta.url));
9
- const registry = JSON.parse(readFileSync(assets + 'native/registry.json', 'utf8'));
10
- const components = [
11
- ...registry.components.map((item) => item.id),
12
- 'layout',
13
- 'text',
14
- 'theme-switcher',
15
- ];
16
- const nativeFiles = [...registry.components.map((item) => item.file), ...registry.supportFiles];
17
- for (const file of [
18
- 'theme.tsx',
19
- 'theme-storage.ts',
20
- 'LICENSE.shadcn',
21
- 'UPSTREAM.json',
22
- ...nativeFiles.map((name) => `native/${name}`),
23
- ]) {
24
- const source = readFileSync(fileURLToPath(new URL(`../../assets/ui/${file}`, import.meta.url)), 'utf8');
25
- put(root, `packages/native-ui/${file.endsWith('.tsx') || file.endsWith('.ts') ? 'src/' : ''}${file}`, source);
26
- }
27
- put(root, 'packages/native-ui/README.md', readFileSync(fileURLToPath(new URL('../../docs/native-ui.md', import.meta.url)), 'utf8'));
28
- put(root, 'packages/native-ui/NATIVE_COMPONENTS.json', readFileSync(assets + 'native/registry.json', 'utf8'));
29
- put(root, 'packages/native-ui/src/index.ts', `export * from './theme';\n` +
30
- components.map((name) => `export * from './native/${name}';\n`).join(''));
31
- json(root, 'packages/native-ui/package.json', {
32
- name: '@workspace/native-ui',
33
- private: true,
34
- type: 'module',
35
- exports: {
36
- '.': './src/index.ts',
37
- './components/*': './src/native/*.tsx',
38
- './theme': './src/theme.tsx',
39
- },
40
- scripts: { typecheck: 'tsc --noEmit', lint: 'eslint . --max-warnings 0' },
41
- dependencies: {
42
- ...NATIVE_UI_DEPENDENCIES.dependencies,
43
- 'react-native-safe-area-context': MOBILE_APP_DEPENDENCIES.dependencies['react-native-safe-area-context'],
44
- '@workspace/styling': 'workspace:*',
45
- },
46
- peerDependencies: {
47
- react: MOBILE_APP_DEPENDENCIES.dependencies.react,
48
- 'react-native': MOBILE_APP_DEPENDENCIES.dependencies['react-native'],
49
- },
50
- devDependencies: {
51
- typescript: MOBILE_APP_DEPENDENCIES.devDependencies.typescript,
52
- '@types/react': MOBILE_APP_DEPENDENCIES.devDependencies['@types/react'],
53
- react: MOBILE_APP_DEPENDENCIES.dependencies.react,
54
- 'react-native': MOBILE_APP_DEPENDENCIES.dependencies['react-native'],
55
- '@workspace/eslint-config': 'workspace:*',
56
- eslint: NATIVE_ESLINT_VERSION,
57
- },
58
- });
59
- json(root, 'packages/native-ui/tsconfig.json', {
60
- compilerOptions: {
61
- target: 'ES2022',
62
- lib: ['ES2022'],
63
- module: 'ESNext',
64
- moduleResolution: 'Bundler',
65
- strict: true,
66
- jsx: 'react-jsx',
67
- noEmit: true,
68
- skipLibCheck: true,
69
- esModuleInterop: true,
70
- },
71
- include: ['src/**/*.ts', 'src/**/*.tsx'],
72
- });
73
- writeReactLintConfig(root + '/packages/native-ui');
74
- }