anhedral 0.13.0 → 0.15.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 +35 -232
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +33 -0
- package/assets/ui/native/button.tsx +85 -0
- package/assets/ui/native/card.tsx +33 -0
- package/assets/ui/native/dialog.tsx +75 -0
- package/assets/ui/native/input.tsx +27 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/capabilities.d.ts +5 -5
- package/dist/capabilities.js +3 -21
- package/dist/capability-contract.d.ts +3 -3
- package/dist/capability-contract.js +11 -50
- package/dist/cli-delivery.d.ts +1 -1
- package/dist/cli-delivery.js +5 -65
- package/dist/cli-output.js +3 -3
- package/dist/command-schema.js +35 -86
- package/dist/delivery-evidence.d.ts +1 -1
- package/dist/delivery-evidence.js +7 -36
- package/dist/delivery.d.ts +2 -8
- package/dist/delivery.js +20 -101
- package/dist/dependencies.d.ts +6 -57
- package/dist/dependencies.js +54 -188
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/inspector-model.d.ts +2 -2
- package/dist/integration-service-readers.d.ts +1 -2
- package/dist/integration-service-readers.js +3 -84
- package/dist/lifecycle-model.d.ts +1 -1
- package/dist/lifecycle-model.js +1 -1
- package/dist/mobile-delivery.d.ts +1 -1
- package/dist/mobile-delivery.js +4 -0
- package/dist/platforms/mobile.js +30 -121
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +299 -0
- package/dist/project-config.d.ts +1 -1
- package/dist/project-config.js +0 -1
- package/dist/project-inspector.js +5 -36
- package/dist/project-state.d.ts +1 -3
- package/dist/project-state.js +2 -85
- package/dist/provider-auth.js +3 -38
- package/dist/provider-readiness.d.ts +1 -1
- package/dist/provider-readiness.js +5 -24
- package/dist/providers/adapters.js +0 -175
- package/dist/providers/api.d.ts +1 -1
- package/dist/providers/api.js +3 -3
- package/dist/providers/config.js +2 -48
- package/dist/providers/definitions.d.ts +1 -204
- package/dist/providers/definitions.js +0 -85
- package/dist/providers/provision.d.ts +1 -1
- package/dist/providers/receipts.js +1 -11
- package/dist/providers/recovery-verification.js +1 -61
- package/dist/providers/runtime.js +4 -35
- package/dist/providers/state.js +1 -7
- package/dist/provision.d.ts +5 -13
- package/dist/provision.js +4 -80
- package/dist/readiness.d.ts +1 -1
- package/dist/readiness.js +3 -8
- package/dist/registry/add.js +10 -70
- package/dist/registry/bootstrap.d.ts +3 -2
- package/dist/registry/bootstrap.js +4 -13
- package/dist/registry/commands.js +8 -10
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +8 -38
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +26 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +2 -2
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/auth.d.ts +1 -2
- package/dist/scaffold/auth.js +55 -130
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -186
- package/dist/scaffold/billing-schema.d.ts +1 -1
- package/dist/scaffold/billing-schema.js +4 -4
- package/dist/scaffold/billing.js +11 -19
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +18 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +22 -86
- package/dist/scaffold/expo-auth.js +33 -22
- package/dist/scaffold/expo-billing.js +17 -52
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +6 -97
- package/dist/scaffold/integrations.d.ts +1 -3
- package/dist/scaffold/integrations.js +9 -10
- package/dist/scaffold/managed-email.d.ts +3 -0
- package/dist/scaffold/managed-email.js +47 -0
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +69 -0
- package/dist/scaffold/password-reset.d.ts +1 -0
- package/dist/scaffold/password-reset.js +99 -0
- package/dist/scaffold/private-files.d.ts +2 -0
- package/dist/scaffold/private-files.js +78 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/web-billing.d.ts +2 -0
- package/dist/scaffold/web-billing.js +48 -0
- package/dist/scaffold/workspace.js +53 -194
- package/dist/service-deletion.js +1 -1
- package/dist/service-descriptor.js +5 -12
- package/dist/service-model.d.ts +1 -1
- package/dist/service-operations.js +2 -32
- package/dist/service-readers.js +1 -32
- package/dist/services-command.d.ts +1 -1
- package/dist/services-command.js +3 -9
- package/dist/ship.d.ts +3 -316
- package/dist/ship.js +10 -142
- package/dist/stack-registry.d.ts +2 -52
- package/dist/stack-registry.js +55 -403
- package/dist/standard.js +7 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +23 -122
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/software-factory.md +24 -557
- package/docs/stack-standard.md +47 -294
- package/docs/verification.md +320 -0
- package/package.json +20 -22
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
|
@@ -27,12 +27,7 @@ export function scaffoldExpoAuth(root, scheme, linkHome = true) {
|
|
|
27
27
|
if (!plugins.some((plugin) => (Array.isArray(plugin) ? plugin[0] : plugin) === 'expo-secure-store'))
|
|
28
28
|
expo.plugins = [...plugins, 'expo-secure-store'];
|
|
29
29
|
json(root, `${directory}/app.json`, config);
|
|
30
|
-
put(root, `${directory}/lib/auth-client.ts`, `
|
|
31
|
-
|
|
32
|
-
let client: ReturnType<typeof createAuthClient> | undefined;
|
|
33
|
-
export function getAuthClient() { return client ??= createAuthClient(); }
|
|
34
|
-
export function authConfigurationError(): string | null { return null; }
|
|
35
|
-
`);
|
|
30
|
+
put(root, `${directory}/lib/auth-client.ts`, `export { getAuthClient, authConfigurationError } from './auth-client.native';\n`);
|
|
36
31
|
put(root, `${directory}/lib/auth-client.native.ts`, `import { createAuthClient } from 'better-auth/react';
|
|
37
32
|
import { expoClient } from '@better-auth/expo/client';
|
|
38
33
|
import * as SecureStore from 'expo-secure-store';
|
|
@@ -52,9 +47,7 @@ function createNativeClient() {
|
|
|
52
47
|
let client: ReturnType<typeof createNativeClient> | undefined;
|
|
53
48
|
export function getAuthClient() { return client ??= createNativeClient(); }
|
|
54
49
|
`);
|
|
55
|
-
put(root, `${directory}/lib/session-api.ts`, `
|
|
56
|
-
export const sessionApi = createApplicationApiClient();
|
|
57
|
-
`);
|
|
50
|
+
put(root, `${directory}/lib/session-api.ts`, `export { sessionApi } from './session-api.native';\n`);
|
|
58
51
|
put(root, `${directory}/lib/session-api.native.ts`, `import { createApplicationApiClient } from './api-client';
|
|
59
52
|
import { getAuthClient } from './auth-client.native';
|
|
60
53
|
|
|
@@ -65,18 +58,19 @@ export const sessionApi = createApplicationApiClient({ headers: async () => {
|
|
|
65
58
|
return headers;
|
|
66
59
|
} });
|
|
67
60
|
`);
|
|
68
|
-
put(root, `${directory}/components/auth-configuration.tsx`, `import { Text,
|
|
61
|
+
put(root, `${directory}/components/auth-configuration.tsx`, `import { Text, Screen } from '@workspace/native-ui';
|
|
69
62
|
import { authConfigurationError } from '@/lib/auth-client';
|
|
70
63
|
|
|
71
64
|
export function AuthConfiguration({ children }: { children: React.ReactNode }) {
|
|
72
65
|
const error = authConfigurationError();
|
|
73
|
-
if (error) return <
|
|
66
|
+
if (error) return <Screen><Text accessibilityRole="header">Configure the product API</Text><Text selectable>{error}</Text></Screen>;
|
|
74
67
|
return <>{children}</>;
|
|
75
68
|
}
|
|
76
69
|
`);
|
|
77
70
|
put(root, `${directory}/app/sign-in.tsx`, `import { useState } from 'react';
|
|
78
|
-
import { router } from 'expo-router';
|
|
79
|
-
import
|
|
71
|
+
import { Link, router } from 'expo-router';
|
|
72
|
+
import * as Linking from 'expo-linking';
|
|
73
|
+
import { Screen, Text, Input as TextInput } from '@workspace/native-ui';
|
|
80
74
|
import { Button } from '@/components/ui/button';
|
|
81
75
|
import { AuthConfiguration } from '@/components/auth-configuration';
|
|
82
76
|
import { getAuthClient } from '@/lib/auth-client';
|
|
@@ -84,6 +78,7 @@ import { sessionApi } from '@/lib/session-api';
|
|
|
84
78
|
|
|
85
79
|
export default function SignInRoute() { return <AuthConfiguration><SignIn /></AuthConfiguration>; }
|
|
86
80
|
|
|
81
|
+
function verificationPending(create: boolean, signedIn: boolean): boolean { return create && !signedIn; }
|
|
87
82
|
function modeLabel(create: boolean): string { return create ? 'Create account' : 'Sign in'; }
|
|
88
83
|
function submitLabel(pending: boolean, create: boolean): string { return pending ? 'Working…' : modeLabel(create); }
|
|
89
84
|
function switchLabel(create: boolean): string { return create ? 'Use an existing account' : 'Create an account'; }
|
|
@@ -92,11 +87,13 @@ function authenticationError(error: unknown): string {
|
|
|
92
87
|
}
|
|
93
88
|
async function authenticate(values: { create: boolean; name: string; email: string; password: string }) {
|
|
94
89
|
const auth = getAuthClient();
|
|
95
|
-
const result = values.create ? await auth.signUp.email(values) : await auth.signIn.email(values);
|
|
96
|
-
if (result.error) throw new Error(
|
|
90
|
+
const result = values.create ? await auth.signUp.email({ ...values, callbackURL: Linking.createURL('sign-in') }) : await auth.signIn.email(values);
|
|
91
|
+
if (result.error) throw new Error('Sign in failed. Verify your email or check your details.');
|
|
92
|
+
return Boolean(result.data?.token);
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
function SignIn() {
|
|
96
|
+
const { refetch } = getAuthClient().useSession();
|
|
100
97
|
const [create, setCreate] = useState(false);
|
|
101
98
|
const [name, setName] = useState('');
|
|
102
99
|
const [email, setEmail] = useState('');
|
|
@@ -104,29 +101,43 @@ function SignIn() {
|
|
|
104
101
|
const [pending, setPending] = useState(false);
|
|
105
102
|
const [message, setMessage] = useState('');
|
|
106
103
|
async function submit() {
|
|
104
|
+
if (pending) return;
|
|
107
105
|
setPending(true); setMessage('');
|
|
108
106
|
try {
|
|
109
|
-
await authenticate({ create, name, email, password });
|
|
107
|
+
const signedIn = await authenticate({ create, name, email, password });
|
|
108
|
+
if (verificationPending(create, signedIn)) { setPassword(''); setMessage('Check your email to verify your account, then sign in.'); setCreate(false); return; }
|
|
110
109
|
await sessionApi.session();
|
|
110
|
+
await refetch();
|
|
111
111
|
setPassword('');
|
|
112
112
|
router.replace('/account');
|
|
113
113
|
} catch (error) { setMessage(authenticationError(error)); }
|
|
114
114
|
finally { setPending(false); }
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
async function resend() {
|
|
117
|
+
if (pending) return; setPending(true); setMessage('');
|
|
118
|
+
try {
|
|
119
|
+
const result = await getAuthClient().sendVerificationEmail({ email, callbackURL: Linking.createURL('sign-in') });
|
|
120
|
+
if (result.error) throw Error('Verification unavailable');
|
|
121
|
+
setMessage('If verification is needed, check your email for the link.');
|
|
122
|
+
} catch { setMessage('Unable to request verification. Please retry.'); }
|
|
123
|
+
finally { setPending(false); }
|
|
124
|
+
}
|
|
125
|
+
return <Screen>
|
|
117
126
|
<Text accessibilityRole="header">{modeLabel(create)}</Text>
|
|
118
127
|
{create && <TextInput accessibilityLabel="Name" placeholder="Name" value={name} onChangeText={setName} autoComplete="name" />}
|
|
119
128
|
<TextInput accessibilityLabel="Email" placeholder="Email" value={email} onChangeText={setEmail} keyboardType="email-address" autoCapitalize="none" autoComplete="email" />
|
|
120
129
|
<TextInput accessibilityLabel="Password" placeholder="Password" value={password} onChangeText={setPassword} secureTextEntry autoComplete={create ? 'new-password' : 'current-password'} />
|
|
121
130
|
<Button disabled={pending} onPress={() => void submit()}>{submitLabel(pending, create)}</Button>
|
|
122
131
|
<Text accessibilityLiveRegion="polite">{message}</Text>
|
|
132
|
+
<Link href="/reset-password">Forgot your password?</Link>
|
|
133
|
+
<Button disabled={pending || !email} onPress={() => void resend()}>Resend verification email</Button>
|
|
123
134
|
<Button disabled={pending} onPress={() => { setCreate(!create); setMessage(''); }}>{switchLabel(create)}</Button>
|
|
124
|
-
</
|
|
135
|
+
</Screen>;
|
|
125
136
|
}
|
|
126
137
|
`);
|
|
127
138
|
put(root, `${directory}/app/account.tsx`, `import { useEffect, useState } from 'react';
|
|
128
139
|
import { Link, Redirect, router } from 'expo-router';
|
|
129
|
-
import { Text,
|
|
140
|
+
import { Text, Screen } from '@workspace/native-ui';
|
|
130
141
|
import type { Session } from '@workspace/contracts';
|
|
131
142
|
import { Button } from '@/components/ui/button';
|
|
132
143
|
import { AuthConfiguration } from '@/components/auth-configuration';
|
|
@@ -158,7 +169,7 @@ function Account() {
|
|
|
158
169
|
} catch { setMessage('Unable to sign out. Check the connection and retry.'); }
|
|
159
170
|
finally { setPending(false); }
|
|
160
171
|
}
|
|
161
|
-
if (isPending) return <
|
|
172
|
+
if (isPending) return <Screen><Text>Restoring session…</Text></Screen>;
|
|
162
173
|
if (!session) return <Redirect href="/sign-in" />;
|
|
163
174
|
return <AccountContent userId={session.user.id} verified={verified} message={message} pending={pending} signOut={signOut} />;
|
|
164
175
|
}
|
|
@@ -170,14 +181,14 @@ function accountMessage(userId: string, verified: Session['user'] | null, messag
|
|
|
170
181
|
function AccountContent({ userId, verified, message, pending, signOut }: {
|
|
171
182
|
userId: string; verified: Session['user'] | null; message: string; pending: boolean; signOut: () => Promise<void>;
|
|
172
183
|
}) {
|
|
173
|
-
return <
|
|
184
|
+
return <Screen>
|
|
174
185
|
<Text accessibilityRole="header">Account</Text>
|
|
175
186
|
<Text>{accountMessage(userId, verified, message)}</Text>
|
|
176
187
|
<Text accessibilityLiveRegion="polite">{message}</Text>
|
|
177
188
|
<Button disabled={pending} onPress={() => void signOut()}>{pending ? 'Signing out…' : 'Sign out'}</Button>
|
|
178
189
|
<Link href="/sign-in">Sign in again</Link>
|
|
179
190
|
<Link href="/">Home</Link>
|
|
180
|
-
</
|
|
191
|
+
</Screen>;
|
|
181
192
|
}
|
|
182
193
|
`);
|
|
183
194
|
// Additions expose /account and /sign-in without rewriting existing product screens.
|
|
@@ -5,13 +5,8 @@ import { STACK_DEPENDENCIES } from '../dependencies.js';
|
|
|
5
5
|
import { patchPackage, put } from './files.js';
|
|
6
6
|
/** Native store purchases and web Stripe checkout share only server-verified entitlements. */
|
|
7
7
|
export function scaffoldExpoBilling({ root, has }) {
|
|
8
|
-
if (!has('expo'))
|
|
9
|
-
return;
|
|
10
8
|
const directory = 'apps/mobile';
|
|
11
|
-
|
|
12
|
-
put(root, `${directory}/billing-integration.md`, '# Native billing integration\n\nThe selected Clerk identity needs its native session adapter before using the authenticated billing APIs. Supply verified session headers to createBillingClient from @workspace/contracts. Do not use a client-selected account ID to authorize access.\n');
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
9
|
+
put(root, `${directory}/lib/billing-types.ts`, 'export interface StoreOffer { id: string; label: string; price: string }\n');
|
|
15
10
|
if (has('revenuecat')) {
|
|
16
11
|
writeEnvironmentFile(root, `${directory}/.env.example`, {
|
|
17
12
|
EXPO_PUBLIC_REVENUECAT_IOS_API_KEY: '',
|
|
@@ -21,9 +16,7 @@ export function scaffoldExpoBilling({ root, has }) {
|
|
|
21
16
|
dependencies: { 'react-native-purchases': STACK_DEPENDENCIES['react-native-purchases'] },
|
|
22
17
|
});
|
|
23
18
|
}
|
|
24
|
-
put(root, `${directory}/lib/billing-api.ts`, `
|
|
25
|
-
export const billingApi = createBillingClient();
|
|
26
|
-
`);
|
|
19
|
+
put(root, `${directory}/lib/billing-api.ts`, `export { billingApi } from './billing-api.native';\n`);
|
|
27
20
|
put(root, `${directory}/lib/billing-api.native.ts`, `import { createBillingClient } from '@workspace/contracts';
|
|
28
21
|
import { nativeApiOrigin } from './api-client';
|
|
29
22
|
import { getAuthClient } from './auth-client.native';
|
|
@@ -43,35 +36,19 @@ export const billingApi = {
|
|
|
43
36
|
portal: () => client().portal(),
|
|
44
37
|
};
|
|
45
38
|
`);
|
|
46
|
-
put(root, `${directory}/lib/billing-platform.ts`, `export
|
|
47
|
-
export
|
|
48
|
-
export async function connectStore(_userId: string): Promise<void> {}
|
|
49
|
-
export async function disconnectStore(): Promise<void> {}
|
|
50
|
-
export async function storeOffers(): Promise<StoreOffer[]> { return []; }
|
|
51
|
-
export async function purchaseStoreOffer(_id: string): Promise<void> { throw new Error('Native store purchases require a device build.'); }
|
|
52
|
-
export async function restoreStorePurchases(): Promise<void> { throw new Error('Restore purchases in the native app.'); }
|
|
53
|
-
export async function manageStorePurchases(): Promise<void> { throw new Error('Native store management requires a device build.'); }
|
|
54
|
-
export function checkoutKey(): string { return crypto.randomUUID(); }
|
|
55
|
-
export async function openBillingURL(value: string): Promise<void> {
|
|
56
|
-
const url = new URL(value);
|
|
57
|
-
if (url.protocol !== 'https:') throw new Error('Billing navigation requires HTTPS.');
|
|
58
|
-
if (!['checkout.stripe.com', 'billing.stripe.com'].includes(url.hostname)) throw new Error('Unrecognized Stripe destination.');
|
|
59
|
-
globalThis.location.assign(url.href);
|
|
60
|
-
}
|
|
39
|
+
put(root, `${directory}/lib/billing-platform.ts`, `export type { StoreOffer } from './billing-types';
|
|
40
|
+
export * from './billing-platform.native';
|
|
61
41
|
`);
|
|
62
42
|
if (has('revenuecat'))
|
|
63
43
|
put(root, `${directory}/lib/billing-platform.native.ts`, nativeStoreSource());
|
|
64
44
|
else
|
|
65
|
-
put(root, `${directory}/lib/billing-platform.native.ts`, `export type { StoreOffer } from './billing-
|
|
66
|
-
export const billingPlatform = 'native';
|
|
45
|
+
put(root, `${directory}/lib/billing-platform.native.ts`, `export type { StoreOffer } from './billing-types';
|
|
67
46
|
export async function connectStore(_userId: string): Promise<void> {}
|
|
68
47
|
export async function disconnectStore(): Promise<void> {}
|
|
69
|
-
export async function storeOffers(): Promise<import('./billing-
|
|
48
|
+
export async function storeOffers(): Promise<import('./billing-types').StoreOffer[]> { return []; }
|
|
70
49
|
export async function purchaseStoreOffer(_id: string): Promise<void> { throw new Error('RevenueCat is not selected.'); }
|
|
71
50
|
export async function restoreStorePurchases(): Promise<void> { throw new Error('RevenueCat is not selected.'); }
|
|
72
51
|
export async function manageStorePurchases(): Promise<void> { throw new Error('RevenueCat is not selected.'); }
|
|
73
|
-
export function checkoutKey(): string { throw new Error('Stripe checkout is web-only.'); }
|
|
74
|
-
export async function openBillingURL(_url: string): Promise<void> { throw new Error('Stripe checkout is web-only.'); }
|
|
75
52
|
`);
|
|
76
53
|
put(root, `${directory}/app/billing.tsx`, billingScreenSource());
|
|
77
54
|
const account = `${directory}/app/account.tsx`;
|
|
@@ -87,8 +64,7 @@ export async function openBillingURL(_url: string): Promise<void> { throw new Er
|
|
|
87
64
|
function nativeStoreSource() {
|
|
88
65
|
return `import Purchases from 'react-native-purchases';
|
|
89
66
|
import { Linking, Platform } from 'react-native';
|
|
90
|
-
import type { StoreOffer } from './billing-
|
|
91
|
-
export const billingPlatform = 'native';
|
|
67
|
+
import type { StoreOffer } from './billing-types';
|
|
92
68
|
let generation = 0;
|
|
93
69
|
let account: string | null = null;
|
|
94
70
|
let queue: Promise<void> = Promise.resolve();
|
|
@@ -186,20 +162,19 @@ export async function manageStorePurchases(): Promise<void> {
|
|
|
186
162
|
await Linking.openURL(url.href);
|
|
187
163
|
});
|
|
188
164
|
}
|
|
189
|
-
export function checkoutKey(): string { throw new Error('Stripe checkout is web-only.'); }
|
|
190
|
-
export async function openBillingURL(_url: string): Promise<void> { throw new Error('Stripe checkout is web-only.'); }
|
|
191
165
|
`;
|
|
192
166
|
}
|
|
193
167
|
function billingScreenSource() {
|
|
194
168
|
return `import { useCallback, useEffect, useRef, useState } from 'react';
|
|
195
169
|
import { Redirect } from 'expo-router';
|
|
196
|
-
import {
|
|
170
|
+
import { View } from 'react-native';
|
|
171
|
+
import { Screen, Text } from '@workspace/native-ui';
|
|
197
172
|
import type { BillingIdentity, BillingEntitlements } from '@workspace/contracts';
|
|
198
173
|
import { AuthConfiguration } from '@/components/auth-configuration';
|
|
199
174
|
import { Button } from '@/components/ui/button';
|
|
200
175
|
import { getAuthClient } from '@/lib/auth-client';
|
|
201
176
|
import { billingApi } from '@/lib/billing-api';
|
|
202
|
-
import {
|
|
177
|
+
import { connectStore, disconnectStore, manageStorePurchases, purchaseStoreOffer, restoreStorePurchases, storeOffers, type StoreOffer } from '@/lib/billing-platform';
|
|
203
178
|
|
|
204
179
|
export default function BillingRoute() { return <AuthConfiguration><Billing /></AuthConfiguration>; }
|
|
205
180
|
type Data = { identity: BillingIdentity; state: BillingEntitlements; offers: StoreOffer[] };
|
|
@@ -231,7 +206,6 @@ function Billing() {
|
|
|
231
206
|
const [message, setMessage] = useState('');
|
|
232
207
|
const [pending, setPending] = useState(false);
|
|
233
208
|
const [reload, setReload] = useState(0);
|
|
234
|
-
const attempts = useRef<Record<string, string>>({});
|
|
235
209
|
const generation = useRef(0);
|
|
236
210
|
const invalidate = useCallback(() => { ++generation.current; void disconnectStore(); }, []);
|
|
237
211
|
useEffect(() => {
|
|
@@ -253,40 +227,31 @@ function Billing() {
|
|
|
253
227
|
} catch (error) { updateCurrent(token, () => setMessage(billingError(error))); }
|
|
254
228
|
finally { updateCurrent(token, () => setPending(false)); }
|
|
255
229
|
}
|
|
256
|
-
async function checkout(plan: string) {
|
|
257
|
-
const key = attempts.current[plan] ??= checkoutKey();
|
|
258
|
-
const result = await billingApi.checkout(plan, key);
|
|
259
|
-
await openBillingURL(result.url);
|
|
260
|
-
}
|
|
261
230
|
if (isPending) return <Text>Restoring session…</Text>;
|
|
262
231
|
if (!session) return <Redirect href="/sign-in" />;
|
|
263
|
-
return <SessionBilling userId={session.user.id} data={data} message={message} pending={pending} run={run}
|
|
232
|
+
return <SessionBilling userId={session.user.id} data={data} message={message} pending={pending} run={run} retry={() => setReload((value) => value + 1)} />;
|
|
264
233
|
}
|
|
265
|
-
function SessionBilling({ userId, data, message, pending, run,
|
|
234
|
+
function SessionBilling({ userId, data, message, pending, run, retry }: Actions & { userId: string; data: Data | null; message: string; retry: () => void }) {
|
|
266
235
|
if (data?.identity.appUserId !== userId) return <View style={{ padding: 24, gap: 12 }}><Text>{message || 'Loading subscriptions…'}</Text><Button onPress={retry}>Retry subscriptions</Button></View>;
|
|
267
|
-
return <BillingContent data={data} message={message} pending={pending} run={run}
|
|
236
|
+
return <BillingContent data={data} message={message} pending={pending} run={run} />;
|
|
268
237
|
}
|
|
269
238
|
function Entitlements({ state }: { state: BillingEntitlements }) {
|
|
270
239
|
return <View><Text accessibilityRole="header">Last server-verified access</Text>{state.entitlements.map((item) => <Text key={item.key}>{item.key}: {item.active ? 'Active' : 'Inactive'}</Text>)}<Text>Checked: {state.checkedAt}</Text></View>;
|
|
271
240
|
}
|
|
272
241
|
type Actions = { pending: boolean; run: (action: () => Promise<void>) => Promise<void> };
|
|
273
|
-
function WebPlans({ data, pending, run, checkout }: Actions & { data: Data; checkout: (plan: string) => Promise<void> }) {
|
|
274
|
-
if (!data.identity.providers.stripe) return <Text>Web checkout is not configured for this product.</Text>;
|
|
275
|
-
return <View style={{ gap: 12 }}>{data.identity.plans.map((plan) => <Button key={plan.id} disabled={pending} onPress={() => void run(() => checkout(plan.id))}>{plan.label}</Button>)}<Button disabled={pending} onPress={() => void run(async () => openBillingURL((await billingApi.portal()).url))}>Manage web subscription</Button></View>;
|
|
276
|
-
}
|
|
277
242
|
function NativePlans({ data, pending, run }: Actions & { data: Data }) {
|
|
278
243
|
if (!data.identity.providers.revenuecat) return <Text>Native store purchases are not selected.</Text>;
|
|
279
244
|
return <View style={{ gap: 12 }}>{data.offers.map((offer) => <Button key={offer.id} disabled={pending} onPress={() => void run(() => purchaseStoreOffer(offer.id))}>{offer.label + ' — ' + offer.price}</Button>)}<Button disabled={pending} onPress={() => void run(restoreStorePurchases)}>Restore purchases</Button><Button disabled={pending} onPress={() => void run(manageStorePurchases)}>Manage store subscription</Button></View>;
|
|
280
245
|
}
|
|
281
|
-
function BillingContent({ data, message, pending, run
|
|
282
|
-
return <
|
|
246
|
+
function BillingContent({ data, message, pending, run }: Actions & { data: Data; message: string }) {
|
|
247
|
+
return <Screen>
|
|
283
248
|
<Text accessibilityRole="header">Subscriptions</Text>
|
|
284
249
|
<Entitlements state={data.state} />
|
|
285
|
-
|
|
250
|
+
<NativePlans data={data} pending={pending} run={run} />
|
|
286
251
|
<Button disabled={pending} onPress={() => void run(async () => undefined)}>Refresh server access</Button>
|
|
287
252
|
<Text accessibilityLiveRegion="polite">{message}</Text>
|
|
288
253
|
<Text>Purchases grant access only after server verification. Store account transfers follow the configured provider policy.</Text>
|
|
289
|
-
</
|
|
254
|
+
</Screen>;
|
|
290
255
|
}
|
|
291
256
|
`;
|
|
292
257
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
-
/**
|
|
3
|
-
export declare function scaffoldExpoRuntime({ root
|
|
2
|
+
/** Native uses the public product origin; all browser transport belongs to Next. */
|
|
3
|
+
export declare function scaffoldExpoRuntime({ root }: RecipeContext): void;
|
|
@@ -1,102 +1,12 @@
|
|
|
1
1
|
import { writeEnvironmentFile } from './environment.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** Expo remains a static universal client. Its Worker owns only assets and API transport. */
|
|
6
|
-
export function scaffoldExpoRuntime({ root, options, has }) {
|
|
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 }) {
|
|
7
5
|
const directory = 'apps/mobile';
|
|
8
|
-
const api = has('hono');
|
|
9
|
-
const webPort = has('vinext') || has('next') ? 3001 : 3000;
|
|
10
|
-
json(root, `${directory}/wrangler.jsonc`, {
|
|
11
|
-
...workerConfig(resourceName(options.name, 'mobile')),
|
|
12
|
-
main: 'worker/index.ts',
|
|
13
|
-
assets: {
|
|
14
|
-
directory: './dist',
|
|
15
|
-
binding: 'ASSETS',
|
|
16
|
-
run_worker_first: ['/api', '/api/*'],
|
|
17
|
-
html_handling: 'auto-trailing-slash',
|
|
18
|
-
not_found_handling: '404-page',
|
|
19
|
-
},
|
|
20
|
-
...(api ? { services: [{ binding: 'API', service: resourceName(options.name, 'api') }] } : {}),
|
|
21
|
-
});
|
|
22
6
|
patchPackage(root, `${directory}/package.json`, {
|
|
23
|
-
|
|
24
|
-
dev: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
|
|
25
|
-
start: 'expo start -c',
|
|
26
|
-
web: 'pnpm dev',
|
|
27
|
-
build: 'pnpm typecheck && pnpm build:web && pnpm build:worker',
|
|
28
|
-
'build:worker': 'wrangler deploy --dry-run --outdir .output/worker',
|
|
29
|
-
preview: `pnpm build:web && wrangler dev --port ${webPort} --inspector-port 9230`,
|
|
30
|
-
deploy: 'pnpm build:web && wrangler deploy',
|
|
31
|
-
typecheck: 'tsc --noEmit && pnpm typecheck:worker',
|
|
32
|
-
'typecheck:worker': 'tsc --project tsconfig.worker.json --noEmit',
|
|
33
|
-
lint: 'eslint app components lib worker --max-warnings 0',
|
|
34
|
-
},
|
|
35
|
-
...(api ? { dependencies: { '@workspace/contracts': 'workspace:*' } } : {}),
|
|
36
|
-
devDependencies: { wrangler: STACK_DEPENDENCIES.wrangler },
|
|
37
|
-
});
|
|
38
|
-
json(root, `${directory}/tsconfig.worker.json`, {
|
|
39
|
-
compilerOptions: {
|
|
40
|
-
target: 'ES2022',
|
|
41
|
-
lib: ['ES2022', 'DOM', 'DOM.Iterable'],
|
|
42
|
-
module: 'ESNext',
|
|
43
|
-
moduleResolution: 'Bundler',
|
|
44
|
-
strict: true,
|
|
45
|
-
skipLibCheck: true,
|
|
46
|
-
noEmit: true,
|
|
47
|
-
types: [],
|
|
48
|
-
},
|
|
49
|
-
include: ['worker/**/*.ts'],
|
|
50
|
-
});
|
|
51
|
-
put(root, `${directory}/worker/index.ts`, `interface Binding { fetch(request: Request): Promise<Response> }
|
|
52
|
-
interface Env { ASSETS: Binding; ${api ? 'API: Binding;' : ''} }
|
|
53
|
-
|
|
54
|
-
${api
|
|
55
|
-
? `// Browser-supplied edge identity headers never cross the API boundary.
|
|
56
|
-
function forwardedHeaders(request: Request): Headers {
|
|
57
|
-
const headers = new Headers();
|
|
58
|
-
for (const name of ['accept', 'content-type', 'cookie', 'origin', 'authorization', 'sec-fetch-site', 'expo-origin', 'idempotency-key']) {
|
|
59
|
-
const value = request.headers.get(name);
|
|
60
|
-
if (value) headers.set(name, value);
|
|
61
|
-
}
|
|
62
|
-
return headers;
|
|
63
|
-
}
|
|
64
|
-
function privateResponse(response: Response): Response {
|
|
65
|
-
const headers = new Headers(response.headers);
|
|
66
|
-
for (const name of ['connection', 'transfer-encoding', 'access-control-allow-origin', 'access-control-allow-credentials']) headers.delete(name);
|
|
67
|
-
headers.set('cache-control', 'private, no-store');
|
|
68
|
-
return new Response(response.body, { status: response.status, headers });
|
|
69
|
-
}
|
|
70
|
-
async function proxyApi(request: Request, env: Env): Promise<Response> {
|
|
71
|
-
const url = new URL(request.url);
|
|
72
|
-
const target = new URL('https://api.internal');
|
|
73
|
-
target.pathname = url.pathname;
|
|
74
|
-
target.search = url.search;
|
|
75
|
-
try {
|
|
76
|
-
const upstream = new Request(new Request(target, request), {
|
|
77
|
-
headers: forwardedHeaders(request), redirect: 'manual',
|
|
78
|
-
signal: AbortSignal.any([request.signal, AbortSignal.timeout(15000)]),
|
|
7
|
+
dependencies: { '@workspace/contracts': 'workspace:*' },
|
|
79
8
|
});
|
|
80
|
-
|
|
81
|
-
} catch {
|
|
82
|
-
return Response.json({ error: 'API unavailable' }, { status: 503, headers: { 'cache-control': 'private, no-store' } });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
`
|
|
86
|
-
: ''}
|
|
87
|
-
export default {
|
|
88
|
-
async fetch(request: Request, env: Env): Promise<Response> {
|
|
89
|
-
const pathname = new URL(request.url).pathname;
|
|
90
|
-
const apiPath = pathname === '/api' || pathname.startsWith('/api/');
|
|
91
|
-
if (!apiPath) return env.ASSETS.fetch(request);
|
|
92
|
-
${api ? 'return proxyApi(request, env);' : "return Response.json({ error: 'API not configured' }, { status: 404, headers: { 'cache-control': 'private, no-store' } });"}
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
`);
|
|
96
|
-
if (!api)
|
|
97
|
-
return;
|
|
98
|
-
put(root, `${directory}/lib/api-client.ts`, `import { Platform } from 'react-native';
|
|
99
|
-
import { createApiClient } from '@workspace/contracts';
|
|
9
|
+
put(root, `${directory}/lib/api-client.ts`, `import { createApiClient } from '@workspace/contracts';
|
|
100
10
|
|
|
101
11
|
type Options = NonNullable<Parameters<typeof createApiClient>[1]>;
|
|
102
12
|
|
|
@@ -113,14 +23,13 @@ export function nativeApiOrigin(): string {
|
|
|
113
23
|
return origin.origin;
|
|
114
24
|
}
|
|
115
25
|
function apiBaseURL(): string {
|
|
116
|
-
if (Platform.OS === 'web') return '/api';
|
|
117
26
|
return nativeApiOrigin() + '/api';
|
|
118
27
|
}
|
|
119
28
|
|
|
120
29
|
// A native auth adapter can provide its own session headers. No server secret belongs here.
|
|
121
30
|
export function createApplicationApiClient(options: Options = {}) {
|
|
122
31
|
const client = () => createApiClient(apiBaseURL(), {
|
|
123
|
-
...options, credentials:
|
|
32
|
+
...options, credentials: 'omit',
|
|
124
33
|
});
|
|
125
34
|
return {
|
|
126
35
|
health: (init?: RequestInit) => client().health(init),
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import type { RecipeContext } from '../registry/types.js';
|
|
2
|
-
export declare function scaffoldPrivateFiles({ root
|
|
3
|
-
export declare function scaffoldStripe(context: RecipeContext): void;
|
|
4
|
-
export declare function scaffoldRevenueCat(context: RecipeContext): void;
|
|
2
|
+
export declare function scaffoldPrivateFiles({ root }: RecipeContext): void;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
1
3
|
import { put } from './files.js';
|
|
2
|
-
import {
|
|
3
|
-
export function scaffoldPrivateFiles({ root
|
|
4
|
-
put(root,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function scaffoldRevenueCat(context) {
|
|
10
|
-
scaffoldBilling(context);
|
|
11
|
-
put(context.root, 'packages/billing/revenuecat.md', '# RevenueCat + Stripe\n\nConfigure web/App Store/Play Store products and offerings in client-owned accounts. Add the platform SDK to each selected app. Verify signed provider webhooks, reconcile entitlement authority, and keep transactional idempotent credits/quotas separate from subscription status. No payment activation occurs during init.\n');
|
|
4
|
+
import { PRIVATE_FILES_SOURCE } from './private-files.js';
|
|
5
|
+
export function scaffoldPrivateFiles({ root }) {
|
|
6
|
+
put(root, 'apps/api/src/private-files.ts', PRIVATE_FILES_SOURCE);
|
|
7
|
+
const file = 'apps/api/src/index.ts';
|
|
8
|
+
const source = readFileSync(path.join(root, file), 'utf8');
|
|
9
|
+
put(root, file, "import { privateFileRoutes } from './private-files';\n" +
|
|
10
|
+
source.replace('export default app;', "app.route('/api/files', privateFileRoutes);\nexport default app;"));
|
|
12
11
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Generated apps receive a scoped capability, never the broker's provider credentials. */
|
|
2
|
+
export declare function scaffoldManagedEmail(root: string): void;
|
|
3
|
+
export declare const MANAGED_EMAIL_SOURCE = "export type EmailTemplate = 'verify-email' | 'reset-password';\nexport interface EmailEnvironment {\n ANHEDRAL_EMAIL?: { fetch(request: Request): Promise<Response> };\n ANHEDRAL_EMAIL_SCOPE?: string;\n ANHEDRAL_EMAIL_CAPABILITY?: string;\n}\nfunction validConfiguration(env: EmailEnvironment): boolean {\n return [typeof env.ANHEDRAL_EMAIL?.fetch === 'function', /^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(env.ANHEDRAL_EMAIL_SCOPE ?? ''), /^[a-f0-9]{72}$/.test(env.ANHEDRAL_EMAIL_CAPABILITY ?? '')].every(Boolean);\n}\nexport function createManagedEmail(env: EmailEnvironment) {\n const { ANHEDRAL_EMAIL: binding, ANHEDRAL_EMAIL_SCOPE: scope, ANHEDRAL_EMAIL_CAPABILITY: capability } = env;\n if (![binding, scope, capability].some(Boolean)) return undefined;\n if (!validConfiguration(env))\n throw new Error('Managed email configuration is incomplete.');\n return async (template: EmailTemplate, to: string, url: string) => {\n const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify([template, to, url])));\n const id = Array.from(new Uint8Array(digest), byte => byte.toString(16).padStart(2, '0')).join('');\n try {\n const response = await binding!.fetch(new Request('https://email.internal/scopes/' + encodeURIComponent(scope!) + '/send', {\n method: 'POST', redirect: 'error',\n headers: { authorization: 'Bearer ' + capability, 'content-type': 'application/json' },\n body: JSON.stringify({ id, template, to, url }), signal: AbortSignal.timeout(15000),\n }));\n if (!response.ok) throw new Error('Email rejected');\n } catch { throw new Error('Application email could not be accepted. Please try again.'); }\n };\n}\n";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { put, sharedPackage } from './files.js';
|
|
2
|
+
/** Generated apps receive a scoped capability, never the broker's provider credentials. */
|
|
3
|
+
export function scaffoldManagedEmail(root) {
|
|
4
|
+
sharedPackage(root, 'managed-email', MANAGED_EMAIL_SOURCE, {});
|
|
5
|
+
put(root, 'packages/managed-email/README.md', `# Managed authentication email
|
|
6
|
+
|
|
7
|
+
Anhedral provisions the ANHEDRAL_EMAIL service binding, ANHEDRAL_EMAIL_SCOPE and
|
|
8
|
+
ANHEDRAL_EMAIL_CAPABILITY in the API Worker only. No provider keys belong in clients.
|
|
9
|
+
The broker owns sender/provider configuration, scope/origin checks, quotas and receipts.
|
|
10
|
+
Configure the scope with this app's public Better Auth origin and exact native URL scheme.
|
|
11
|
+
|
|
12
|
+
With no binding or scope/capability, standalone email/password sessions keep their
|
|
13
|
+
existing behavior. Any partial configuration fails closed. A complete configuration
|
|
14
|
+
requires verified email and enables password reset with session revocation. Do not
|
|
15
|
+
remove configuration to bypass verification. Use a local mail sink in tests; never
|
|
16
|
+
log token URLs or use a production capability in fixtures. Request acceptance does
|
|
17
|
+
not establish inbox delivery. Initialization never provisions the broker or sends mail.
|
|
18
|
+
`);
|
|
19
|
+
}
|
|
20
|
+
export const MANAGED_EMAIL_SOURCE = `export type EmailTemplate = 'verify-email' | 'reset-password';
|
|
21
|
+
export interface EmailEnvironment {
|
|
22
|
+
ANHEDRAL_EMAIL?: { fetch(request: Request): Promise<Response> };
|
|
23
|
+
ANHEDRAL_EMAIL_SCOPE?: string;
|
|
24
|
+
ANHEDRAL_EMAIL_CAPABILITY?: string;
|
|
25
|
+
}
|
|
26
|
+
function validConfiguration(env: EmailEnvironment): boolean {
|
|
27
|
+
return [typeof env.ANHEDRAL_EMAIL?.fetch === 'function', /^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(env.ANHEDRAL_EMAIL_SCOPE ?? ''), /^[a-f0-9]{72}$/.test(env.ANHEDRAL_EMAIL_CAPABILITY ?? '')].every(Boolean);
|
|
28
|
+
}
|
|
29
|
+
export function createManagedEmail(env: EmailEnvironment) {
|
|
30
|
+
const { ANHEDRAL_EMAIL: binding, ANHEDRAL_EMAIL_SCOPE: scope, ANHEDRAL_EMAIL_CAPABILITY: capability } = env;
|
|
31
|
+
if (![binding, scope, capability].some(Boolean)) return undefined;
|
|
32
|
+
if (!validConfiguration(env))
|
|
33
|
+
throw new Error('Managed email configuration is incomplete.');
|
|
34
|
+
return async (template: EmailTemplate, to: string, url: string) => {
|
|
35
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify([template, to, url])));
|
|
36
|
+
const id = Array.from(new Uint8Array(digest), byte => byte.toString(16).padStart(2, '0')).join('');
|
|
37
|
+
try {
|
|
38
|
+
const response = await binding!.fetch(new Request('https://email.internal/scopes/' + encodeURIComponent(scope!) + '/send', {
|
|
39
|
+
method: 'POST', redirect: 'error',
|
|
40
|
+
headers: { authorization: 'Bearer ' + capability, 'content-type': 'application/json' },
|
|
41
|
+
body: JSON.stringify({ id, template, to, url }), signal: AbortSignal.timeout(15000),
|
|
42
|
+
}));
|
|
43
|
+
if (!response.ok) throw new Error('Email rejected');
|
|
44
|
+
} catch { throw new Error('Application email could not be accepted. Please try again.'); }
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
@@ -0,0 +1,69 @@
|
|
|
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 components = [
|
|
9
|
+
'button',
|
|
10
|
+
'card',
|
|
11
|
+
'dialog',
|
|
12
|
+
'input',
|
|
13
|
+
'label',
|
|
14
|
+
'layout',
|
|
15
|
+
'text',
|
|
16
|
+
'theme-switcher',
|
|
17
|
+
];
|
|
18
|
+
for (const file of [
|
|
19
|
+
'theme.tsx',
|
|
20
|
+
'theme-storage.ts',
|
|
21
|
+
'LICENSE.shadcn',
|
|
22
|
+
'UPSTREAM.json',
|
|
23
|
+
...components.map((name) => `native/${name}.tsx`),
|
|
24
|
+
]) {
|
|
25
|
+
const source = readFileSync(fileURLToPath(new URL(`../../assets/ui/${file}`, import.meta.url)), 'utf8');
|
|
26
|
+
put(root, `packages/native-ui/${file.endsWith('.tsx') || file.endsWith('.ts') ? 'src/' : ''}${file}`, source);
|
|
27
|
+
}
|
|
28
|
+
put(root, 'packages/native-ui/src/index.ts', `export * from './theme';\n` +
|
|
29
|
+
components.map((name) => `export * from './native/${name}';\n`).join(''));
|
|
30
|
+
json(root, 'packages/native-ui/package.json', {
|
|
31
|
+
name: '@workspace/native-ui',
|
|
32
|
+
private: true,
|
|
33
|
+
type: 'module',
|
|
34
|
+
exports: { '.': './src/index.ts' },
|
|
35
|
+
scripts: { typecheck: 'tsc --noEmit', lint: 'eslint . --max-warnings 0' },
|
|
36
|
+
dependencies: {
|
|
37
|
+
...NATIVE_UI_DEPENDENCIES.dependencies,
|
|
38
|
+
'react-native-safe-area-context': MOBILE_APP_DEPENDENCIES.dependencies['react-native-safe-area-context'],
|
|
39
|
+
'@workspace/styling': 'workspace:*',
|
|
40
|
+
},
|
|
41
|
+
peerDependencies: {
|
|
42
|
+
react: MOBILE_APP_DEPENDENCIES.dependencies.react,
|
|
43
|
+
'react-native': MOBILE_APP_DEPENDENCIES.dependencies['react-native'],
|
|
44
|
+
},
|
|
45
|
+
devDependencies: {
|
|
46
|
+
typescript: MOBILE_APP_DEPENDENCIES.devDependencies.typescript,
|
|
47
|
+
'@types/react': MOBILE_APP_DEPENDENCIES.devDependencies['@types/react'],
|
|
48
|
+
react: MOBILE_APP_DEPENDENCIES.dependencies.react,
|
|
49
|
+
'react-native': MOBILE_APP_DEPENDENCIES.dependencies['react-native'],
|
|
50
|
+
'@workspace/eslint-config': 'workspace:*',
|
|
51
|
+
eslint: NATIVE_ESLINT_VERSION,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
json(root, 'packages/native-ui/tsconfig.json', {
|
|
55
|
+
compilerOptions: {
|
|
56
|
+
target: 'ES2022',
|
|
57
|
+
lib: ['ES2022'],
|
|
58
|
+
module: 'ESNext',
|
|
59
|
+
moduleResolution: 'Bundler',
|
|
60
|
+
strict: true,
|
|
61
|
+
jsx: 'react-jsx',
|
|
62
|
+
noEmit: true,
|
|
63
|
+
skipLibCheck: true,
|
|
64
|
+
esModuleInterop: true,
|
|
65
|
+
},
|
|
66
|
+
include: ['src/**/*.ts', 'src/**/*.tsx'],
|
|
67
|
+
});
|
|
68
|
+
writeReactLintConfig(root + '/packages/native-ui');
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function scaffoldPasswordReset(root: string): void;
|