anhedral 0.15.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.
- package/README.md +82 -34
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/UPSTREAM.json +0 -11
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -66
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +39 -322
- package/dist/dependencies.d.ts +29 -9
- package/dist/dependencies.js +57 -64
- package/dist/index.d.ts +1 -42
- package/dist/index.js +1 -27
- package/dist/platforms/web.d.ts +1 -1
- package/dist/platforms/web.js +27 -75
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -82
- package/dist/registry/options.js +1 -5
- package/dist/registry/resolve.d.ts +1 -1
- package/dist/registry/resolve.js +4 -10
- package/dist/registry/usage.js +3 -9
- package/dist/scaffold/backend.js +0 -3
- package/dist/scaffold/database.js +2 -1
- package/dist/scaffold/documentation.js +56 -25
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/workspace.js +21 -22
- package/dist/stack-registry.d.ts +2 -10
- package/dist/stack-registry.js +12 -98
- package/dist/standard.js +1 -11
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +12 -23
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +47 -0
- package/docs/software-factory.md +35 -50
- package/docs/stack-standard.md +19 -70
- package/docs/ui.md +33 -0
- package/docs/verification.md +6 -876
- package/package.json +21 -16
- package/assets/ui/native/button.tsx +0 -85
- package/assets/ui/native/card.tsx +0 -33
- package/assets/ui/native/dialog.tsx +0 -75
- package/assets/ui/native/input.tsx +0 -27
- package/assets/ui/native/label.tsx +0 -4
- package/assets/ui/native/layout.tsx +0 -26
- package/assets/ui/native/text.tsx +0 -20
- package/assets/ui/native/theme-switcher.tsx +0 -22
- package/assets/ui/theme-storage.ts +0 -25
- package/assets/ui/theme.tsx +0 -66
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -129
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -112
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -157
- package/dist/delivery.d.ts +0 -82
- package/dist/delivery.js +0 -489
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -12
- package/dist/integration-service-readers.js +0 -92
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -370
- package/dist/platforms/mobile.d.ts +0 -2
- package/dist/platforms/mobile.js +0 -156
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -671
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -47
- package/dist/project-state.js +0 -480
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -180
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -85
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -103
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -136
- package/dist/providers/definitions.d.ts +0 -115
- package/dist/providers/definitions.js +0 -42
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -56
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -52
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -234
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -283
- package/dist/provision.d.ts +0 -47
- package/dist/provision.js +0 -208
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -117
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -210
- package/dist/registry/bootstrap.d.ts +0 -3
- package/dist/registry/bootstrap.js +0 -5
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -83
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -2
- package/dist/scaffold/auth.js +0 -76
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -208
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -203
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -257
- package/dist/scaffold/expo-runtime.d.ts +0 -3
- package/dist/scaffold/expo-runtime.js +0 -43
- package/dist/scaffold/integrations.d.ts +0 -2
- package/dist/scaffold/integrations.js +0 -11
- package/dist/scaffold/managed-email.d.ts +0 -3
- package/dist/scaffold/managed-email.js +0 -47
- package/dist/scaffold/native-ui.d.ts +0 -2
- package/dist/scaffold/native-ui.js +0 -69
- package/dist/scaffold/password-reset.d.ts +0 -1
- package/dist/scaffold/password-reset.js +0 -99
- package/dist/scaffold/private-files.d.ts +0 -2
- package/dist/scaffold/private-files.js +0 -78
- package/dist/scaffold/web-billing.d.ts +0 -2
- package/dist/scaffold/web-billing.js +0 -48
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -71
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -48
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -216
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -96
- package/dist/ship.d.ts +0 -35
- package/dist/ship.js +0 -107
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anhedral",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.17.0",
|
|
4
|
+
"description": "Start with Next.js and Anhedral UI, then progressively add APIs, data, clients, payments, realtime and AI as editable source.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -29,7 +29,16 @@
|
|
|
29
29
|
"docs/anhedral-stack.md",
|
|
30
30
|
"docs/assets/anhedral-stack.png",
|
|
31
31
|
"docs/assets/anhedral-stack-light.png",
|
|
32
|
-
"
|
|
32
|
+
"docs/native-ui.md",
|
|
33
|
+
"docs/ui.md",
|
|
34
|
+
"assets/stack",
|
|
35
|
+
"docs/capabilities.md",
|
|
36
|
+
"assets/ui/web",
|
|
37
|
+
"assets/ui/catalog.json",
|
|
38
|
+
"assets/ui/extensions",
|
|
39
|
+
"assets/ui/LICENSE.shadcn",
|
|
40
|
+
"assets/ui/LICENSE.react-native-reusables",
|
|
41
|
+
"assets/ui/UPSTREAM.json"
|
|
33
42
|
],
|
|
34
43
|
"homepage": "https://github.com/anhedral/anhedral-cli#readme",
|
|
35
44
|
"repository": {
|
|
@@ -73,16 +82,14 @@
|
|
|
73
82
|
"release:artifact:verify": "node scripts/verify-release-artifact.mjs .artifacts/release/metadata.json && node scripts/check-release-secrets.mjs .artifacts/release/metadata.json",
|
|
74
83
|
"release:artifact:smoke": "node tests/test-packed-cli.js .artifacts/release/metadata.json",
|
|
75
84
|
"test:standard": "pnpm build && node --test tests/test-standard.test.mjs",
|
|
76
|
-
"test:unit": "node
|
|
85
|
+
"test:unit": "node --test --test-concurrency=4 --test-reporter=spec tests/*.test.mjs",
|
|
77
86
|
"test:integration": "pnpm build && node tests/test-generated-apps.mjs",
|
|
78
|
-
"
|
|
79
|
-
"format": "prettier --
|
|
80
|
-
"
|
|
81
|
-
"plugin:
|
|
82
|
-
"plugin:check": "pnpm --dir plugins/codex/inspector check",
|
|
83
|
-
"plugin:preview": "pnpm --dir plugins/codex/inspector start",
|
|
87
|
+
"format": "prettier --write src scripts tests \"assets/patches/*.mjs\" assets/ui && node scripts/stack-template-format.mjs --write",
|
|
88
|
+
"format:check": "prettier --check src scripts tests \"assets/patches/*.mjs\" assets/ui && node scripts/stack-template-format.mjs",
|
|
89
|
+
"plugin:build": "node scripts/check-plugin.mjs",
|
|
90
|
+
"plugin:check": "node scripts/check-plugin.mjs",
|
|
84
91
|
"test:patch": "node tests/test-braces-install.mjs && node tests/test-forge-install.mjs",
|
|
85
|
-
"test:
|
|
92
|
+
"test:next-runtime": "pnpm build && node scripts/next-runtime-smoke.mjs"
|
|
86
93
|
},
|
|
87
94
|
"keywords": [
|
|
88
95
|
"cli",
|
|
@@ -94,8 +101,6 @@
|
|
|
94
101
|
"d1",
|
|
95
102
|
"r2",
|
|
96
103
|
"drizzle",
|
|
97
|
-
"stripe",
|
|
98
|
-
"revenuecat",
|
|
99
104
|
"turborepo",
|
|
100
105
|
"nextjs",
|
|
101
106
|
"opennext"
|
|
@@ -106,11 +111,11 @@
|
|
|
106
111
|
"@types/node": "20.19.43",
|
|
107
112
|
"hono": "4.13.13",
|
|
108
113
|
"prettier": "3.9.10",
|
|
109
|
-
"typescript": "5.9.3"
|
|
114
|
+
"typescript": "5.9.3",
|
|
115
|
+
"zod": "4.6.6"
|
|
110
116
|
},
|
|
111
117
|
"dependencies": {
|
|
112
118
|
"jsonc-parser": "3.3.1",
|
|
113
|
-
"yaml": "2.9.1"
|
|
114
|
-
"zod": "4.6.6"
|
|
119
|
+
"yaml": "2.9.1"
|
|
115
120
|
}
|
|
116
121
|
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { Pressable, Text, StyleSheet, type View, type PressableProps } from 'react-native';
|
|
2
|
-
import { Children, type ReactNode, type Ref } from 'react';
|
|
3
|
-
import { useTheme } from '../theme';
|
|
4
|
-
export type ButtonProps = Omit<PressableProps, 'children'> & {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
ref?: Ref<View>;
|
|
7
|
-
variant?: 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link';
|
|
8
|
-
size?: 'default' | 'sm' | 'lg' | 'icon';
|
|
9
|
-
};
|
|
10
|
-
const sizes = {
|
|
11
|
-
default: { minHeight: 44 },
|
|
12
|
-
sm: { minHeight: 44 },
|
|
13
|
-
lg: { minHeight: 48 },
|
|
14
|
-
icon: { minHeight: 44, minWidth: 44 },
|
|
15
|
-
};
|
|
16
|
-
export function Button({
|
|
17
|
-
children,
|
|
18
|
-
variant = 'default',
|
|
19
|
-
size = 'default',
|
|
20
|
-
style,
|
|
21
|
-
disabled,
|
|
22
|
-
accessibilityState,
|
|
23
|
-
...props
|
|
24
|
-
}: ButtonProps) {
|
|
25
|
-
const { colors } = useTheme();
|
|
26
|
-
const backgrounds = {
|
|
27
|
-
default: colors.primary,
|
|
28
|
-
secondary: colors.secondary,
|
|
29
|
-
outline: colors.background,
|
|
30
|
-
ghost: 'transparent',
|
|
31
|
-
destructive: 'transparent',
|
|
32
|
-
link: 'transparent',
|
|
33
|
-
};
|
|
34
|
-
const foregrounds = {
|
|
35
|
-
default: colors['primary-foreground'],
|
|
36
|
-
secondary: colors.foreground,
|
|
37
|
-
outline: colors.foreground,
|
|
38
|
-
ghost: colors.foreground,
|
|
39
|
-
destructive: colors.destructive,
|
|
40
|
-
link: colors.primary,
|
|
41
|
-
};
|
|
42
|
-
const surface = {
|
|
43
|
-
backgroundColor: backgrounds[variant],
|
|
44
|
-
borderColor: variant === 'outline' ? colors.border : 'transparent',
|
|
45
|
-
};
|
|
46
|
-
return (
|
|
47
|
-
<Pressable
|
|
48
|
-
{...props}
|
|
49
|
-
accessibilityRole="button"
|
|
50
|
-
accessibilityState={{ ...accessibilityState, disabled: !!disabled }}
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
style={(state) => [
|
|
53
|
-
styles.button,
|
|
54
|
-
sizes[size],
|
|
55
|
-
surface,
|
|
56
|
-
disabled && styles.disabled,
|
|
57
|
-
state.pressed && styles.pressed,
|
|
58
|
-
typeof style === 'function' ? style(state) : style,
|
|
59
|
-
]}
|
|
60
|
-
>
|
|
61
|
-
{Children.map(children, (child) =>
|
|
62
|
-
typeof child === 'string' || typeof child === 'number' ? (
|
|
63
|
-
<Text style={[styles.label, { color: foregrounds[variant] }]}>{child}</Text>
|
|
64
|
-
) : (
|
|
65
|
-
child
|
|
66
|
-
),
|
|
67
|
-
)}
|
|
68
|
-
</Pressable>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
const styles = StyleSheet.create({
|
|
72
|
-
button: {
|
|
73
|
-
borderRadius: 8,
|
|
74
|
-
borderWidth: 1,
|
|
75
|
-
paddingHorizontal: 12,
|
|
76
|
-
paddingVertical: 10,
|
|
77
|
-
flexDirection: 'row',
|
|
78
|
-
gap: 6,
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
justifyContent: 'center',
|
|
81
|
-
},
|
|
82
|
-
label: { fontSize: 14, fontWeight: '500' },
|
|
83
|
-
disabled: { opacity: 0.5 },
|
|
84
|
-
pressed: { opacity: 0.75 },
|
|
85
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { View, type ViewProps } from 'react-native';
|
|
2
|
-
import { Text, type TextProps } from './text';
|
|
3
|
-
import { useTheme } from '../theme';
|
|
4
|
-
export function Card({ style, ...props }: ViewProps) {
|
|
5
|
-
const { colors } = useTheme();
|
|
6
|
-
return (
|
|
7
|
-
<View
|
|
8
|
-
{...props}
|
|
9
|
-
style={[
|
|
10
|
-
{
|
|
11
|
-
backgroundColor: colors.card,
|
|
12
|
-
borderWidth: 1,
|
|
13
|
-
borderColor: colors.border,
|
|
14
|
-
borderRadius: 12,
|
|
15
|
-
paddingVertical: 16,
|
|
16
|
-
gap: 16,
|
|
17
|
-
},
|
|
18
|
-
style,
|
|
19
|
-
]}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
export function CardContent({ style, ...props }: ViewProps) {
|
|
24
|
-
return <View {...props} style={[{ paddingHorizontal: 16, gap: 12 }, style]} />;
|
|
25
|
-
}
|
|
26
|
-
export const CardHeader = CardContent;
|
|
27
|
-
export const CardFooter = CardContent;
|
|
28
|
-
export function CardTitle(props: TextProps) {
|
|
29
|
-
return <Text variant="title" {...props} />;
|
|
30
|
-
}
|
|
31
|
-
export function CardDescription(props: TextProps) {
|
|
32
|
-
return <Text variant="muted" {...props} />;
|
|
33
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Modal, View, Pressable, AccessibilityInfo, findNodeHandle, Platform } from 'react-native';
|
|
2
|
-
import { useEffect, useRef, type ReactNode } from 'react';
|
|
3
|
-
import { Button } from './button';
|
|
4
|
-
import { Text } from './text';
|
|
5
|
-
import { useTheme } from '../theme';
|
|
6
|
-
export function Dialog({
|
|
7
|
-
open,
|
|
8
|
-
onOpenChange,
|
|
9
|
-
title,
|
|
10
|
-
description,
|
|
11
|
-
children,
|
|
12
|
-
triggerLabel,
|
|
13
|
-
}: {
|
|
14
|
-
open: boolean;
|
|
15
|
-
onOpenChange: (open: boolean) => void;
|
|
16
|
-
title: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
children?: ReactNode;
|
|
19
|
-
triggerLabel: string;
|
|
20
|
-
}) {
|
|
21
|
-
const { colors } = useTheme();
|
|
22
|
-
const trigger = useRef<View>(null);
|
|
23
|
-
const heading = useRef<View>(null);
|
|
24
|
-
function focus(ref: typeof heading) {
|
|
25
|
-
const node = findNodeHandle(ref.current);
|
|
26
|
-
if (node) AccessibilityInfo.setAccessibilityFocus(node);
|
|
27
|
-
}
|
|
28
|
-
const previousOpen = useRef(open);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const closed = previousOpen.current && !open;
|
|
31
|
-
previousOpen.current = open;
|
|
32
|
-
// RN Modal.onDismiss is iOS-only. Android removes the Modal in this commit.
|
|
33
|
-
if (!closed || Platform.OS === 'ios') return;
|
|
34
|
-
const frame = requestAnimationFrame(() => focus(trigger));
|
|
35
|
-
return () => cancelAnimationFrame(frame);
|
|
36
|
-
}, [open]);
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
<Button ref={trigger} onPress={() => onOpenChange(true)}>
|
|
40
|
-
{triggerLabel}
|
|
41
|
-
</Button>
|
|
42
|
-
<Modal
|
|
43
|
-
visible={open}
|
|
44
|
-
transparent
|
|
45
|
-
animationType="fade"
|
|
46
|
-
onShow={() => focus(heading)}
|
|
47
|
-
onDismiss={() => focus(trigger)}
|
|
48
|
-
onRequestClose={() => onOpenChange(false)}
|
|
49
|
-
>
|
|
50
|
-
<View
|
|
51
|
-
style={{ flex: 1, justifyContent: 'center', padding: 24, backgroundColor: '#00000066' }}
|
|
52
|
-
>
|
|
53
|
-
<Pressable
|
|
54
|
-
accessibilityLabel="Close dialog"
|
|
55
|
-
onPress={() => onOpenChange(false)}
|
|
56
|
-
style={{ position: 'absolute', inset: 0 }}
|
|
57
|
-
/>
|
|
58
|
-
<View
|
|
59
|
-
accessibilityViewIsModal
|
|
60
|
-
style={{ backgroundColor: colors.popover, padding: 20, borderRadius: 12, gap: 16 }}
|
|
61
|
-
>
|
|
62
|
-
<View ref={heading} accessible accessibilityRole="header" accessibilityLabel={title}>
|
|
63
|
-
<Text variant="title">{title}</Text>
|
|
64
|
-
</View>
|
|
65
|
-
{description && <Text variant="muted">{description}</Text>}
|
|
66
|
-
{children}
|
|
67
|
-
<Button variant="outline" onPress={() => onOpenChange(false)}>
|
|
68
|
-
Close
|
|
69
|
-
</Button>
|
|
70
|
-
</View>
|
|
71
|
-
</View>
|
|
72
|
-
</Modal>
|
|
73
|
-
</>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { TextInput, type TextInputProps } from 'react-native';
|
|
2
|
-
import { useTheme } from '../theme';
|
|
3
|
-
export type InputProps = TextInputProps & { invalid?: boolean };
|
|
4
|
-
export function Input({ style, invalid, ...props }: InputProps) {
|
|
5
|
-
const { colors } = useTheme();
|
|
6
|
-
return (
|
|
7
|
-
<TextInput
|
|
8
|
-
{...props}
|
|
9
|
-
placeholderTextColor={colors['muted-foreground']}
|
|
10
|
-
selectionColor={colors.primary}
|
|
11
|
-
style={[
|
|
12
|
-
{
|
|
13
|
-
minHeight: 44,
|
|
14
|
-
borderWidth: 1,
|
|
15
|
-
borderColor: invalid ? colors.destructive : colors.input,
|
|
16
|
-
backgroundColor: colors.background,
|
|
17
|
-
color: colors.foreground,
|
|
18
|
-
borderRadius: 8,
|
|
19
|
-
paddingHorizontal: 12,
|
|
20
|
-
paddingVertical: 10,
|
|
21
|
-
fontSize: 16,
|
|
22
|
-
},
|
|
23
|
-
style,
|
|
24
|
-
]}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ScrollView, View, type ViewProps } from 'react-native';
|
|
2
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
import { useTheme } from '../theme';
|
|
5
|
-
export function Stack({ style, ...props }: ViewProps) {
|
|
6
|
-
return <View {...props} style={[{ gap: 12 }, style]} />;
|
|
7
|
-
}
|
|
8
|
-
export function Screen({ children }: { children: ReactNode }) {
|
|
9
|
-
const insets = useSafeAreaInsets();
|
|
10
|
-
const { colors } = useTheme();
|
|
11
|
-
return (
|
|
12
|
-
<ScrollView
|
|
13
|
-
style={{ flex: 1, backgroundColor: colors.background }}
|
|
14
|
-
contentContainerStyle={{
|
|
15
|
-
paddingTop: insets.top + 24,
|
|
16
|
-
paddingBottom: insets.bottom + 24,
|
|
17
|
-
paddingHorizontal: 20,
|
|
18
|
-
flexGrow: 1,
|
|
19
|
-
}}
|
|
20
|
-
keyboardShouldPersistTaps="handled"
|
|
21
|
-
automaticallyAdjustKeyboardInsets
|
|
22
|
-
>
|
|
23
|
-
<View style={{ width: '100%', maxWidth: 640, alignSelf: 'center', gap: 24 }}>{children}</View>
|
|
24
|
-
</ScrollView>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -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,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,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
|
-
}
|
package/assets/ui/theme.tsx
DELETED
|
@@ -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
|
-
}
|
package/dist/access.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ApplicationProject } from './project-state.js';
|
|
2
|
-
import { type CloudflareRequest } from './cloudflare.js';
|
|
3
|
-
export interface AccessReceipt {
|
|
4
|
-
target: string;
|
|
5
|
-
workerId: string;
|
|
6
|
-
applicationId: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function validatePrivateAudience(project: ApplicationProject, root: string): void;
|
|
9
|
-
/** Protect the entire Worker, including every route and preview, before product code is deployed. */
|
|
10
|
-
export declare function reconcileAccess(root: string, project: ApplicationProject, request: CloudflareRequest, create: boolean): Promise<AccessReceipt[]>;
|
package/dist/access.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { atomicJson, readConfig, targetDirectory, } from './project-state.js';
|
|
3
|
-
import { listCloudflare } from './cloudflare.js';
|
|
4
|
-
export function validatePrivateAudience(project, root) {
|
|
5
|
-
if (!project.access?.emails.length ||
|
|
6
|
-
project.access.emails.some((email) => !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)))
|
|
7
|
-
throw new Error('Private delivery requires explicit allowed email addresses.');
|
|
8
|
-
for (const target of project.targets) {
|
|
9
|
-
const config = readConfig(targetDirectory(root, target));
|
|
10
|
-
if (target.id === 'realtime' ||
|
|
11
|
-
config.durable_objects?.bindings?.some((item) => item.class_name === 'Rooms'))
|
|
12
|
-
throw new Error('Worker-level Access does not support WebSockets. Use a reviewed hostname Access workflow or application identity for realtime products.');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function policiesMatch(policies, emails) {
|
|
16
|
-
if (policies.length !== 1 || policies[0].decision !== 'allow')
|
|
17
|
-
return false;
|
|
18
|
-
const policy = policies[0];
|
|
19
|
-
if (!Array.isArray(policy.include) ||
|
|
20
|
-
!policy.include.length ||
|
|
21
|
-
policy.exclude?.length ||
|
|
22
|
-
policy.require?.length)
|
|
23
|
-
return false;
|
|
24
|
-
const actual = [];
|
|
25
|
-
for (const rule of policy.include) {
|
|
26
|
-
if (!rule || Object.keys(rule).length !== 1 || typeof rule.email?.email !== 'string')
|
|
27
|
-
return false;
|
|
28
|
-
actual.push(rule.email.email.toLowerCase());
|
|
29
|
-
}
|
|
30
|
-
return (JSON.stringify([...new Set(actual)].sort()) === JSON.stringify([...new Set(emails)].sort()));
|
|
31
|
-
}
|
|
32
|
-
/** Protect the entire Worker, including every route and preview, before product code is deployed. */
|
|
33
|
-
export async function reconcileAccess(root, project, request, create) {
|
|
34
|
-
validatePrivateAudience(project, root);
|
|
35
|
-
const receipts = [];
|
|
36
|
-
const workers = await listCloudflare(request, '/workers/workers');
|
|
37
|
-
const apps = await listCloudflare(request, '/access/apps');
|
|
38
|
-
for (const target of project.targets) {
|
|
39
|
-
const matches = workers.filter((item) => item.name === target.workerName);
|
|
40
|
-
if (matches.length > 1)
|
|
41
|
-
throw new Error('Ambiguous Worker identity.');
|
|
42
|
-
let worker = matches[0];
|
|
43
|
-
if (!worker && create)
|
|
44
|
-
worker = (await request('POST', '/workers/workers', { name: target.workerName }))
|
|
45
|
-
.result;
|
|
46
|
-
if (!worker || typeof worker.id !== 'string' || !/^[a-f0-9]{32}$/i.test(worker.id))
|
|
47
|
-
throw new Error('Provider did not return an immutable Worker ID.');
|
|
48
|
-
const destinations = [{ type: 'worker', worker_id: worker.id }];
|
|
49
|
-
const candidates = apps.filter((app) => Array.isArray(app.destinations) &&
|
|
50
|
-
app.destinations.some((destination) => destination.worker_id === worker.id));
|
|
51
|
-
if (candidates.length > 1)
|
|
52
|
-
throw new Error('Multiple Access applications target this Worker; reconcile policies explicitly.');
|
|
53
|
-
let app = candidates[0];
|
|
54
|
-
if (!app && create) {
|
|
55
|
-
app = (await request('POST', '/access/apps', {
|
|
56
|
-
name: `Anhedral ${project.id} ${target.id}`,
|
|
57
|
-
type: 'self_hosted',
|
|
58
|
-
session_duration: '24h',
|
|
59
|
-
destinations,
|
|
60
|
-
policies: [
|
|
61
|
-
{
|
|
62
|
-
name: 'Application members',
|
|
63
|
-
decision: 'allow',
|
|
64
|
-
include: project.access.emails.map((email) => ({ email: { email } })),
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
})).result;
|
|
68
|
-
apps.push(app);
|
|
69
|
-
}
|
|
70
|
-
if (!app ||
|
|
71
|
-
typeof app.id !== 'string' ||
|
|
72
|
-
!/^[a-f0-9-]{36}$/i.test(app.id) ||
|
|
73
|
-
app.type !== 'self_hosted' ||
|
|
74
|
-
!Array.isArray(app.destinations) ||
|
|
75
|
-
app.destinations.length !== 1 ||
|
|
76
|
-
app.destinations[0].type !== 'worker' ||
|
|
77
|
-
app.destinations[0].worker_id !== worker.id)
|
|
78
|
-
throw new Error('Whole-Worker private Access protection is missing or differs from the requested policy.');
|
|
79
|
-
const policies = await listCloudflare(request, `/access/apps/${app.id}/policies`);
|
|
80
|
-
if (!policiesMatch(policies, project.access.emails))
|
|
81
|
-
throw new Error('Access policies differ from the explicit application members; no unrelated policy was overwritten.');
|
|
82
|
-
receipts.push({ target: target.id, workerId: worker.id, applicationId: app.id });
|
|
83
|
-
if (create)
|
|
84
|
-
atomicJson(path.join(root, '.anhedral/access.json'), {
|
|
85
|
-
schemaVersion: 1,
|
|
86
|
-
projectId: project.id,
|
|
87
|
-
accountId: project.accountId,
|
|
88
|
-
checkedAt: new Date().toISOString(),
|
|
89
|
-
receipts,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return receipts;
|
|
93
|
-
}
|