anhedral 0.16.0 → 0.18.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 (195) hide show
  1. package/README.md +42 -20
  2. package/assets/contracts/LICENSE +201 -0
  3. package/assets/contracts/LICENSE.environment +201 -0
  4. package/assets/contracts/LICENSE.operations +201 -0
  5. package/assets/contracts/deployment-provenance.json +15 -0
  6. package/assets/contracts/environment-provenance.json +11 -0
  7. package/assets/contracts/operations-provenance.json +11 -0
  8. package/assets/launch/application.server.ts.txt +13 -0
  9. package/assets/launch/auth-client.ts.txt +4 -0
  10. package/assets/launch/home.tsx.txt +20 -0
  11. package/assets/launch/minimal-application.server.ts.txt +5 -0
  12. package/assets/launch/minimal-server.ts.txt +7 -0
  13. package/assets/launch/request-context.ts.txt +3 -0
  14. package/assets/launch/root.tsx.txt +27 -0
  15. package/assets/launch/router.tsx.txt +21 -0
  16. package/assets/launch/server.ts.txt +13 -0
  17. package/assets/launch/sign-in.tsx.txt +53 -0
  18. package/assets/launch/styles.css.txt +19 -0
  19. package/assets/security/credential-patterns.d.mts +3 -0
  20. package/assets/security/credential-patterns.mjs +59 -0
  21. package/assets/stack/api-index.ts.txt +6 -1
  22. package/assets/stack/event-retention.sql.txt +10 -0
  23. package/assets/stack/stripe.ts.txt +30 -13
  24. package/assets/ui/UPSTREAM.json +1 -18
  25. package/dist/bin.js +55 -36
  26. package/dist/capabilities.d.ts +1 -1
  27. package/dist/capability-catalog.d.ts +44 -11
  28. package/dist/capability-catalog.js +96 -11
  29. package/dist/capability-command.d.ts +2 -2
  30. package/dist/capability-command.js +178 -27
  31. package/dist/capability-editor.js +6 -5
  32. package/dist/capability-recipes.js +54 -6
  33. package/dist/cli-arguments.d.ts +2 -0
  34. package/dist/cli-arguments.js +101 -50
  35. package/dist/cli-commands.d.ts +1 -1
  36. package/dist/cli-commands.js +30 -6
  37. package/dist/cli-errors.d.ts +18 -0
  38. package/dist/cli-errors.js +63 -0
  39. package/dist/cli-output.d.ts +22 -0
  40. package/dist/cli-output.js +42 -7
  41. package/dist/command-runner.d.ts +1 -0
  42. package/dist/command-runner.js +88 -0
  43. package/dist/command-schema.d.ts +16 -0
  44. package/dist/command-schema.js +390 -21
  45. package/dist/completion.d.ts +2 -0
  46. package/dist/completion.js +201 -0
  47. package/dist/composition.d.ts +35 -0
  48. package/dist/composition.js +28 -0
  49. package/dist/contracts/cli-transport.d.ts +217 -0
  50. package/dist/contracts/cli-transport.js +167 -0
  51. package/dist/contracts/deployment.d.ts +282 -0
  52. package/dist/contracts/deployment.js +234 -0
  53. package/dist/contracts/environment-file.d.ts +7 -0
  54. package/dist/contracts/environment-file.js +112 -0
  55. package/dist/contracts/environment-transport.d.ts +79 -0
  56. package/dist/contracts/environment-transport.js +110 -0
  57. package/dist/contracts/runtime-logs-transport.d.ts +127 -0
  58. package/dist/contracts/runtime-logs-transport.js +50 -0
  59. package/dist/contracts/source-bundle.d.ts +11 -0
  60. package/dist/contracts/source-bundle.js +197 -0
  61. package/dist/contracts/source-profile.d.ts +4 -0
  62. package/dist/contracts/source-profile.js +5 -0
  63. package/dist/contracts/staging-transport.d.ts +79 -0
  64. package/dist/contracts/staging-transport.js +43 -0
  65. package/dist/dependencies.d.ts +10 -4
  66. package/dist/dependencies.js +17 -54
  67. package/dist/index.d.ts +6 -0
  68. package/dist/index.js +4 -0
  69. package/dist/launch.d.ts +21 -0
  70. package/dist/launch.js +250 -0
  71. package/dist/platform-command.d.ts +9 -0
  72. package/dist/platform-command.js +584 -0
  73. package/dist/platform-environment.d.ts +18 -0
  74. package/dist/platform-environment.js +257 -0
  75. package/dist/platform-operations.d.ts +26 -0
  76. package/dist/platform-operations.js +155 -0
  77. package/dist/platform-source.d.ts +8 -0
  78. package/dist/platform-source.js +111 -0
  79. package/dist/platform-state.d.ts +13 -0
  80. package/dist/platform-state.js +207 -0
  81. package/dist/platforms/tanstack.d.ts +8 -0
  82. package/dist/platforms/tanstack.js +155 -0
  83. package/dist/registry/options.js +34 -31
  84. package/dist/registry/resolve.js +2 -0
  85. package/dist/registry/usage.d.ts +4 -1
  86. package/dist/registry/usage.js +58 -4
  87. package/dist/scaffold/documentation.js +17 -48
  88. package/dist/scaffold/styling.d.ts +1 -1
  89. package/dist/scaffold/workspace.js +11 -7
  90. package/dist/stack-registry.d.ts +2 -4
  91. package/dist/stack-registry.js +1 -11
  92. package/dist/standard.js +21 -6
  93. package/dist/transaction.js +28 -3
  94. package/dist/ui-command.d.ts +4 -2
  95. package/dist/ui-command.js +79 -38
  96. package/dist/ui-project.d.ts +2 -0
  97. package/dist/ui-project.js +38 -8
  98. package/dist/util.js +40 -61
  99. package/dist/version.d.ts +1 -1
  100. package/dist/version.js +1 -1
  101. package/docs/capabilities.md +22 -88
  102. package/docs/software-factory.md +189 -16
  103. package/docs/stack-standard.md +6 -18
  104. package/docs/ui.md +9 -22
  105. package/docs/verification.md +6 -1067
  106. package/package.json +33 -22
  107. package/assets/ui/native/_controls.tsx +0 -521
  108. package/assets/ui/native/_core.tsx +0 -118
  109. package/assets/ui/native/_data.tsx +0 -200
  110. package/assets/ui/native/_display.tsx +0 -453
  111. package/assets/ui/native/_feedback.tsx +0 -242
  112. package/assets/ui/native/_legacy-dialog.tsx +0 -38
  113. package/assets/ui/native/_motion.tsx +0 -520
  114. package/assets/ui/native/_overlay.tsx +0 -402
  115. package/assets/ui/native/_selection.tsx +0 -366
  116. package/assets/ui/native/accordion.tsx +0 -1
  117. package/assets/ui/native/alert-dialog.tsx +0 -11
  118. package/assets/ui/native/alert.tsx +0 -1
  119. package/assets/ui/native/aspect-ratio.tsx +0 -1
  120. package/assets/ui/native/attachment.tsx +0 -8
  121. package/assets/ui/native/avatar.tsx +0 -8
  122. package/assets/ui/native/badge.tsx +0 -1
  123. package/assets/ui/native/breadcrumb.tsx +0 -9
  124. package/assets/ui/native/bubble.tsx +0 -1
  125. package/assets/ui/native/button-group.tsx +0 -1
  126. package/assets/ui/native/button.tsx +0 -86
  127. package/assets/ui/native/calendar.tsx +0 -170
  128. package/assets/ui/native/card.tsx +0 -44
  129. package/assets/ui/native/carousel.tsx +0 -1
  130. package/assets/ui/native/chart.tsx +0 -193
  131. package/assets/ui/native/checkbox.tsx +0 -1
  132. package/assets/ui/native/code-block.tsx +0 -137
  133. package/assets/ui/native/collapsible.tsx +0 -1
  134. package/assets/ui/native/combobox.tsx +0 -1
  135. package/assets/ui/native/command.tsx +0 -11
  136. package/assets/ui/native/context-menu.tsx +0 -16
  137. package/assets/ui/native/data-table.tsx +0 -1
  138. package/assets/ui/native/date-picker.tsx +0 -43
  139. package/assets/ui/native/dialog.tsx +0 -15
  140. package/assets/ui/native/direction.tsx +0 -1
  141. package/assets/ui/native/drawer.tsx +0 -10
  142. package/assets/ui/native/dropdown-menu.tsx +0 -16
  143. package/assets/ui/native/empty.tsx +0 -8
  144. package/assets/ui/native/field.tsx +0 -13
  145. package/assets/ui/native/hover-card.tsx +0 -1
  146. package/assets/ui/native/input-group.tsx +0 -8
  147. package/assets/ui/native/input-otp.tsx +0 -1
  148. package/assets/ui/native/input.tsx +0 -28
  149. package/assets/ui/native/item.tsx +0 -12
  150. package/assets/ui/native/kbd.tsx +0 -1
  151. package/assets/ui/native/label.tsx +0 -4
  152. package/assets/ui/native/layout.tsx +0 -26
  153. package/assets/ui/native/marker.tsx +0 -1
  154. package/assets/ui/native/menubar.tsx +0 -17
  155. package/assets/ui/native/message-scroller.tsx +0 -6
  156. package/assets/ui/native/message.tsx +0 -10
  157. package/assets/ui/native/native-select.tsx +0 -1
  158. package/assets/ui/native/navigation-menu.tsx +0 -10
  159. package/assets/ui/native/pagination.tsx +0 -9
  160. package/assets/ui/native/popover.tsx +0 -1
  161. package/assets/ui/native/progress.tsx +0 -1
  162. package/assets/ui/native/questionnaire.tsx +0 -130
  163. package/assets/ui/native/radio-group.tsx +0 -1
  164. package/assets/ui/native/registry.json +0 -1103
  165. package/assets/ui/native/resizable.tsx +0 -1
  166. package/assets/ui/native/scroll-area.tsx +0 -1
  167. package/assets/ui/native/select.tsx +0 -11
  168. package/assets/ui/native/separator.tsx +0 -1
  169. package/assets/ui/native/sheet.tsx +0 -10
  170. package/assets/ui/native/sidebar.tsx +0 -22
  171. package/assets/ui/native/skeleton.tsx +0 -1
  172. package/assets/ui/native/slider.tsx +0 -1
  173. package/assets/ui/native/spinner.tsx +0 -1
  174. package/assets/ui/native/switch.tsx +0 -1
  175. package/assets/ui/native/table.tsx +0 -10
  176. package/assets/ui/native/tabs.tsx +0 -1
  177. package/assets/ui/native/text.tsx +0 -20
  178. package/assets/ui/native/textarea.tsx +0 -1
  179. package/assets/ui/native/theme-switcher.tsx +0 -22
  180. package/assets/ui/native/toast.tsx +0 -11
  181. package/assets/ui/native/toggle-group.tsx +0 -1
  182. package/assets/ui/native/toggle.tsx +0 -1
  183. package/assets/ui/native/tooltip.tsx +0 -1
  184. package/assets/ui/native/trace.tsx +0 -20
  185. package/assets/ui/native/typography.tsx +0 -15
  186. package/assets/ui/theme-storage.ts +0 -25
  187. package/assets/ui/theme.tsx +0 -66
  188. package/dist/platforms/mobile.d.ts +0 -2
  189. package/dist/platforms/mobile.js +0 -137
  190. package/dist/scaffold/expo-runtime.d.ts +0 -3
  191. package/dist/scaffold/expo-runtime.js +0 -42
  192. package/dist/scaffold/native-ui.d.ts +0 -2
  193. package/dist/scaffold/native-ui.js +0 -74
  194. package/docs/anhedral-stack.md +0 -7
  195. package/docs/native-ui.md +0 -102
@@ -1,118 +0,0 @@
1
- import {
2
- Children,
3
- isValidElement,
4
- createContext,
5
- useContext,
6
- useRef,
7
- useState,
8
- type ReactNode,
9
- } from 'react';
10
- import {
11
- View,
12
- I18nManager,
13
- Platform,
14
- Text as NativeText,
15
- type ViewProps,
16
- type TextProps,
17
- type StyleProp,
18
- type ViewStyle,
19
- } from 'react-native';
20
- import { useTheme } from '../theme';
21
-
22
- export function useControllable<T>(value: T | undefined, initial: T, change?: (value: T) => void) {
23
- const [internal, setInternal] = useState(initial);
24
- const current = value === undefined ? internal : value;
25
- const latest = useRef(current);
26
- latest.current = current;
27
- const set = (next: T | ((previous: T) => T)) => {
28
- const resolved =
29
- typeof next === 'function' ? (next as (previous: T) => T)(latest.current) : next;
30
- if (Object.is(resolved, latest.current)) return;
31
- if (value === undefined) {
32
- latest.current = resolved;
33
- setInternal(resolved);
34
- }
35
- change?.(resolved);
36
- };
37
- return [current, set] as const;
38
- }
39
- export const monospace = Platform.OS === 'ios' ? 'Menlo' : 'monospace';
40
- export function plainText(node: ReactNode): string {
41
- return Children.toArray(node)
42
- .map((child) =>
43
- typeof child === 'string' || typeof child === 'number' || typeof child === 'bigint'
44
- ? String(child)
45
- : isValidElement<{ children?: ReactNode }>(child)
46
- ? plainText(child.props.children)
47
- : '',
48
- )
49
- .join('');
50
- }
51
- export function content(children: ReactNode) {
52
- return Children.map(children, (child) =>
53
- typeof child === 'string' || typeof child === 'number' || typeof child === 'bigint' ? (
54
- <LabelText>{String(child)}</LabelText>
55
- ) : (
56
- child
57
- ),
58
- );
59
- }
60
- export function Box({ children, style, ...props }: ViewProps) {
61
- return (
62
- <View {...props} style={[{ gap: 8 }, style]}>
63
- {content(children)}
64
- </View>
65
- );
66
- }
67
- export function LabelText({ style, ...props }: TextProps) {
68
- const { colors } = useTheme();
69
- return (
70
- <NativeText
71
- {...props}
72
- style={[{ color: colors.foreground, fontSize: 14, lineHeight: 21 }, style]}
73
- />
74
- );
75
- }
76
- export function Muted({ style, ...props }: TextProps) {
77
- const { colors } = useTheme();
78
- return <LabelText {...props} style={[{ color: colors['muted-foreground'] }, style]} />;
79
- }
80
- export function Surface({ style, ...props }: ViewProps) {
81
- const { colors } = useTheme();
82
- return (
83
- <Box
84
- {...props}
85
- style={[
86
- {
87
- backgroundColor: colors.card,
88
- borderColor: colors.border,
89
- borderWidth: 1,
90
- borderRadius: 10,
91
- padding: 12,
92
- },
93
- style,
94
- ]}
95
- />
96
- );
97
- }
98
- export function row(style?: StyleProp<ViewStyle>): StyleProp<ViewStyle> {
99
- return [{ flexDirection: 'row', alignItems: 'center', gap: 8, flexWrap: 'wrap' }, style];
100
- }
101
- export function clamp(value: number, min: number, max: number) {
102
- return Math.min(max, Math.max(min, Number.isFinite(value) ? value : min));
103
- }
104
- const DirectionContext = createContext<'ltr' | 'rtl'>(I18nManager.isRTL ? 'rtl' : 'ltr');
105
- export function DirectionProvider({
106
- dir = 'ltr',
107
- children,
108
- }: {
109
- dir?: 'ltr' | 'rtl';
110
- children: ReactNode;
111
- }) {
112
- return (
113
- <DirectionContext.Provider value={dir}>
114
- <View style={{ direction: dir }}>{children}</View>
115
- </DirectionContext.Provider>
116
- );
117
- }
118
- export const useDirection = () => useContext(DirectionContext);
@@ -1,200 +0,0 @@
1
- import { useMemo, useState, type ReactNode } from 'react';
2
- import { ScrollView, type ViewProps } from 'react-native';
3
- import { Box, LabelText, Muted, row, useControllable } from './_core';
4
- import { Button, type ButtonProps } from './button';
5
- import { Input } from './input';
6
- import { Checkbox } from './_controls';
7
- export const ScrollArea = ({ children, ...props }: React.ComponentProps<typeof ScrollView>) => (
8
- <ScrollView {...props}>{children}</ScrollView>
9
- );
10
- export const ScrollBar = () => null; // Native ScrollView owns the platform scrollbar.
11
- export const Table = ({ children, ...props }: React.ComponentProps<typeof ScrollView>) => (
12
- <ScrollView horizontal accessibilityLabel="Table" {...props}>
13
- <Box>{children}</Box>
14
- </ScrollView>
15
- );
16
- export const TableHeader = Box;
17
- export const TableBody = Box;
18
- export const TableFooter = Box;
19
- export const TableRow = ({ style, ...props }: ViewProps) => (
20
- <Box {...props} style={row([{ flexWrap: 'nowrap' }, style])} />
21
- );
22
- export const TableHead = ({ style, ...props }: React.ComponentProps<typeof LabelText>) => (
23
- <LabelText
24
- accessibilityRole="header"
25
- {...props}
26
- style={[{ fontWeight: '600', minWidth: 120, padding: 8 }, style]}
27
- />
28
- );
29
- export const TableCell = ({ style, ...props }: ViewProps) => (
30
- <Box {...props} style={[{ minWidth: 120, padding: 8, flex: 1 }, style]} />
31
- );
32
- export const TableCaption = Muted;
33
- export const Pagination = ({ style, ...props }: ViewProps) => (
34
- <Box accessibilityLabel="Pagination" {...props} style={row(style)} />
35
- );
36
- export const PaginationContent = ({ style, ...props }: ViewProps) => (
37
- <Box {...props} style={row(style)} />
38
- );
39
- export const PaginationItem = Box;
40
- export const PaginationLink = ({ isActive, ...props }: ButtonProps & { isActive?: boolean }) => (
41
- <Button
42
- variant={isActive ? 'outline' : 'ghost'}
43
- {...props}
44
- accessibilityState={{ selected: !!isActive, disabled: !!props.disabled }}
45
- />
46
- );
47
- export const PaginationPrevious = ({
48
- children = 'Previous',
49
- ...props
50
- }: Omit<ButtonProps, 'children'> & { children?: ReactNode }) => (
51
- <Button {...props} accessibilityLabel={props.accessibilityLabel ?? 'Previous page'}>
52
- {children}
53
- </Button>
54
- );
55
- export const PaginationNext = ({
56
- children = 'Next',
57
- ...props
58
- }: Omit<ButtonProps, 'children'> & { children?: ReactNode }) => (
59
- <Button {...props} accessibilityLabel={props.accessibilityLabel ?? 'Next page'}>
60
- {children}
61
- </Button>
62
- );
63
- export const PaginationEllipsis = () => <Muted accessibilityLabel="More pages">…</Muted>;
64
- export type DataColumn<T> = {
65
- id: string;
66
- header: string;
67
- accessor: (row: T) => string | number | boolean | null;
68
- cell?: (row: T) => ReactNode;
69
- sortable?: boolean;
70
- };
71
- export function DataTable<T>({
72
- data,
73
- columns,
74
- getRowId,
75
- pageSize = 10,
76
- selectedRowIds,
77
- defaultSelectedRowIds = [],
78
- onSelectionChange,
79
- searchable = true,
80
- emptyText = 'No results',
81
- }: {
82
- data: readonly T[];
83
- columns: readonly DataColumn<T>[];
84
- getRowId: (row: T) => string;
85
- pageSize?: number;
86
- selectedRowIds?: string[];
87
- defaultSelectedRowIds?: string[];
88
- onSelectionChange?: (ids: string[]) => void;
89
- searchable?: boolean;
90
- emptyText?: string;
91
- }) {
92
- const [query, setQuery] = useState('');
93
- const [sort, setSort] = useState<{ id: string; descending: boolean } | null>(null);
94
- const [page, setPage] = useState(0);
95
- const [selection, setSelection] = useControllable(
96
- selectedRowIds,
97
- defaultSelectedRowIds,
98
- onSelectionChange,
99
- );
100
- const size = Math.max(1, Math.floor(pageSize) || 10);
101
- const filtered = useMemo(() => {
102
- const rows = data.filter((item) =>
103
- columns.some((column) =>
104
- String(column.accessor(item) ?? '')
105
- .toLocaleLowerCase()
106
- .includes(query.toLocaleLowerCase()),
107
- ),
108
- );
109
- const column = sort && columns.find((item) => item.id === sort.id);
110
- return column
111
- ? [...rows].sort((a, b) => {
112
- const first = column.accessor(a);
113
- const second = column.accessor(b);
114
- return (
115
- (typeof first === 'number' && typeof second === 'number'
116
- ? first - second
117
- : String(first ?? '').localeCompare(String(second ?? ''))) *
118
- (sort?.descending ? -1 : 1)
119
- );
120
- })
121
- : rows;
122
- }, [data, columns, query, sort]);
123
- const pages = Math.max(1, Math.ceil(filtered.length / size));
124
- const current = Math.min(page, pages - 1);
125
- const visible = filtered.slice(current * size, (current + 1) * size);
126
- return (
127
- <Box>
128
- {searchable && (
129
- <Input
130
- accessibilityLabel="Filter rows"
131
- value={query}
132
- onChangeText={(next) => {
133
- setQuery(next);
134
- setPage(0);
135
- }}
136
- />
137
- )}
138
- <Table>
139
- <TableHeader>
140
- <TableRow>
141
- {onSelectionChange && <TableHead>Selected</TableHead>}
142
- {columns.map((column) => (
143
- <Button
144
- key={column.id}
145
- variant="ghost"
146
- disabled={column.sortable === false}
147
- accessibilityLabel={`${column.header}${sort?.id === column.id ? (sort.descending ? ', descending' : ', ascending') : ', unsorted'}`}
148
- onPress={() => {
149
- setSort({
150
- id: column.id,
151
- descending: sort?.id === column.id && !sort.descending,
152
- });
153
- setPage(0);
154
- }}
155
- >
156
- {column.header}
157
- </Button>
158
- ))}
159
- </TableRow>
160
- </TableHeader>
161
- <TableBody>
162
- {visible.map((item) => {
163
- const id = getRowId(item);
164
- return (
165
- <TableRow key={id}>
166
- {onSelectionChange && (
167
- <Checkbox
168
- accessibilityLabel={`Select row ${id}`}
169
- checked={selection.includes(id)}
170
- onCheckedChange={(checked) =>
171
- setSelection(
172
- checked ? [...selection, id] : selection.filter((key) => key !== id),
173
- )
174
- }
175
- />
176
- )}
177
- {columns.map((column) => (
178
- <TableCell
179
- key={column.id}
180
- accessibilityLabel={`${column.header}: ${String(column.accessor(item) ?? '')}`}
181
- >
182
- {column.cell?.(item) ?? String(column.accessor(item) ?? '')}
183
- </TableCell>
184
- ))}
185
- </TableRow>
186
- );
187
- })}
188
- {!visible.length && <Muted accessibilityLiveRegion="polite">{emptyText}</Muted>}
189
- </TableBody>
190
- </Table>
191
- <Pagination>
192
- <PaginationPrevious disabled={current === 0} onPress={() => setPage(current - 1)} />
193
- <LabelText accessibilityLiveRegion="polite">
194
- {current + 1} / {pages}
195
- </LabelText>
196
- <PaginationNext disabled={current === pages - 1} onPress={() => setPage(current + 1)} />
197
- </Pagination>
198
- </Box>
199
- );
200
- }