@marktiderman/genesis-cli 1.5.0 → 1.7.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 +224 -3
- package/dist/cli.js +4602 -1549
- package/dist/cli.js.map +1 -1
- package/dist/{config-Ci-_Ue-1.d.ts → config-CrZbM3jD.d.ts} +73 -4
- package/dist/doctor.d.ts +31 -4
- package/dist/doctor.js +976 -30
- package/dist/doctor.js.map +1 -1
- package/dist/expo.d.ts +91 -8
- package/dist/expo.js +207 -14
- package/dist/expo.js.map +1 -1
- package/dist/genesis-catalog.json +502 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +987 -38
- package/dist/index.js.map +1 -1
- package/dist/scaffolder.d.ts +1 -1
- package/dist/scaffolder.js +9 -6
- package/dist/scaffolder.js.map +1 -1
- package/dist/starter/.eas/scripts/rollout-health.mjs +85 -0
- package/dist/starter/.eas/workflows/deploy-production.yml +149 -0
- package/dist/starter/.eas/workflows/e2e.yml +77 -0
- package/dist/starter/.eas/workflows/pr-preview.yml +117 -0
- package/dist/starter/.eas/workflows/rollout.yml +120 -0
- package/dist/starter/.env.example +11 -0
- package/dist/starter/.fingerprintignore +7 -0
- package/dist/starter/.maestro/README.md +38 -0
- package/dist/starter/.maestro/config.yaml +5 -0
- package/dist/starter/.maestro/flows/deep-link.yaml +22 -0
- package/dist/starter/.maestro/flows/launch.yaml +17 -0
- package/dist/starter/.maestro/flows/settings-version.yaml +28 -0
- package/dist/starter/.maestro/flows/sign-in-screen.yaml +17 -0
- package/dist/starter/.maestro/subflows/sign-in.yaml +20 -0
- package/dist/starter/README.md +314 -0
- package/dist/starter/__tests__/app-config.test.ts +51 -0
- package/dist/starter/__tests__/check-in-photos.test.ts +57 -0
- package/dist/starter/__tests__/components/css-stub.js +2 -0
- package/dist/starter/__tests__/components/fake-supabase.ts +136 -0
- package/dist/starter/__tests__/components/links.test.ts +25 -0
- package/dist/starter/__tests__/components/render-app.ts +22 -0
- package/dist/starter/__tests__/components/reports.ts +10 -0
- package/dist/starter/__tests__/components/resolver.js +12 -0
- package/dist/starter/__tests__/components/root-layout.test.tsx +55 -0
- package/dist/starter/__tests__/components/session-storage.test.tsx +81 -0
- package/dist/starter/__tests__/components/settings.test.tsx +134 -0
- package/dist/starter/__tests__/components/setup.ts +69 -0
- package/dist/starter/__tests__/components/sign-in.test.tsx +90 -0
- package/dist/starter/__tests__/components/tabs-feature-off.test.tsx +19 -0
- package/dist/starter/__tests__/components/tabs.test.tsx +43 -0
- package/dist/starter/__tests__/components/tabs.ts +12 -0
- package/dist/starter/__tests__/entry.test.ts +28 -0
- package/dist/starter/__tests__/inline-copy.ts +59 -0
- package/dist/starter/__tests__/starter.test.ts +319 -0
- package/dist/starter/_gitignore +13 -0
- package/dist/starter/app.config.ts +44 -0
- package/dist/starter/babel.config.js +9 -0
- package/dist/starter/eas.json +47 -0
- package/dist/starter/eslint.config.js +5 -0
- package/dist/starter/genesis.config.json +12 -0
- package/dist/starter/global.css +3 -0
- package/dist/starter/index.ts +14 -0
- package/dist/starter/jest.config.js +36 -0
- package/dist/starter/metro.config.js +38 -0
- package/dist/starter/package.json +93 -0
- package/dist/starter/pnpm-workspace.yaml +73 -0
- package/dist/starter/src/app/(app)/(home)/_layout.tsx +6 -0
- package/dist/starter/src/app/(app)/(home)/check-in.tsx +41 -0
- package/dist/starter/src/app/(app)/(home)/index.tsx +34 -0
- package/dist/starter/src/app/(app)/_layout.tsx +27 -0
- package/dist/starter/src/app/(app)/notifications/_layout.tsx +6 -0
- package/dist/starter/src/app/(app)/notifications/index.tsx +36 -0
- package/dist/starter/src/app/(app)/settings/_layout.tsx +6 -0
- package/dist/starter/src/app/(app)/settings/index.tsx +96 -0
- package/dist/starter/src/app/(app)/settings/notifications.tsx +16 -0
- package/dist/starter/src/app/(app)/settings/support/[id].tsx +23 -0
- package/dist/starter/src/app/(app)/settings/support/ideas.tsx +20 -0
- package/dist/starter/src/app/(app)/settings/support/index.tsx +20 -0
- package/dist/starter/src/app/(app)/settings/support/new.tsx +35 -0
- package/dist/starter/src/app/(app)/settings/support/shipped.tsx +20 -0
- package/dist/starter/src/app/+native-intent.ts +11 -0
- package/dist/starter/src/app/_layout.tsx +20 -0
- package/dist/starter/src/app/sign-in.tsx +69 -0
- package/dist/starter/src/copy.ts +118 -0
- package/dist/starter/src/forms/check-in.json +121 -0
- package/dist/starter/src/lib/account.ts +42 -0
- package/dist/starter/src/lib/app.ts +52 -0
- package/dist/starter/src/lib/auth.ts +80 -0
- package/dist/starter/src/lib/check-in-photos.ts +66 -0
- package/dist/starter/src/lib/check-in.ts +85 -0
- package/dist/starter/src/lib/define-starter.ts +148 -0
- package/dist/starter/src/lib/devtools-overlay.ts +34 -0
- package/dist/starter/src/lib/devtools.ts +23 -0
- package/dist/starter/src/lib/env.ts +33 -0
- package/dist/starter/src/lib/google-signin.ts +23 -0
- package/dist/starter/src/lib/links.ts +40 -0
- package/dist/starter/src/lib/native-modules.ts +27 -0
- package/dist/starter/src/lib/notifications.ts +15 -0
- package/dist/starter/src/lib/observability.ts +45 -0
- package/dist/starter/src/lib/push.ts +49 -0
- package/dist/starter/src/lib/supabase.ts +65 -0
- package/dist/starter/src/lib/support.ts +44 -0
- package/dist/starter/src/lib/updates.ts +61 -0
- package/dist/starter/starter.config.ts +37 -0
- package/dist/starter/supabase/config.toml +26 -0
- package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +237 -0
- package/dist/starter/supabase/functions/genesis-apple-revoke/handler.ts +227 -0
- package/dist/starter/supabase/functions/genesis-apple-revoke/index.ts +55 -0
- package/dist/starter/supabase/functions/genesis-push-send/expo.ts +117 -0
- package/dist/starter/supabase/functions/genesis-push-send/handler.ts +462 -0
- package/dist/starter/supabase/functions/genesis-push-send/index.ts +54 -0
- package/dist/starter/supabase/migrations/20261024000000_genesis_account_deletion.sql +133 -0
- package/dist/starter/supabase/migrations/20261024000100_genesis_app_release_policy.sql +82 -0
- package/dist/starter/supabase/migrations/20261024000200_genesis_apple_token_revocation.sql +205 -0
- package/dist/starter/supabase/migrations/20261024000400_genesis_push.sql +524 -0
- package/dist/starter/supabase/migrations/20261024000600_genesis_support.sql +846 -0
- package/dist/starter/supabase/tests/database/genesis_account_deletion.test.sql +138 -0
- package/dist/starter/supabase/tests/database/genesis_app_release_policy.test.sql +148 -0
- package/dist/starter/supabase/tests/database/genesis_apple_token_revocation.test.sql +230 -0
- package/dist/starter/supabase/tests/database/genesis_push.test.sql +407 -0
- package/dist/starter/supabase/tests/database/genesis_support.test.sql +552 -0
- package/dist/starter/tailwind.config.mjs +15 -0
- package/dist/starter/tsconfig.json +14 -0
- package/dist/starter/vitest.config.mts +7 -0
- package/dist/templates/ci/app-ci.yml +17 -0
- package/dist/templates/ci/genesis-upgrade.yml +21 -0
- package/dist/templates/ci/supabase-ci.yml +20 -0
- package/dist/templates/eas/eas.json +47 -0
- package/dist/templates/eas/scripts/rollout-health.mjs +85 -0
- package/dist/templates/eas/workflows/deploy-production.yml +149 -0
- package/dist/templates/eas/workflows/e2e.yml +77 -0
- package/dist/templates/eas/workflows/pr-preview.yml +117 -0
- package/dist/templates/eas/workflows/rollout.yml +120 -0
- package/dist/templates/maestro/config.yaml +5 -0
- package/dist/templates/maestro/flows/deep-link.yaml +22 -0
- package/dist/templates/maestro/flows/launch.yaml +17 -0
- package/dist/templates/maestro/flows/settings-version.yaml +28 -0
- package/dist/templates/maestro/flows/sign-in-screen.yaml +17 -0
- package/dist/templates/maestro/subflows/sign-in.yaml +20 -0
- package/dist/vite.js +975 -29
- package/dist/vite.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything `<GenesisNativeApp>` is given, built from `starter.config.ts`,
|
|
3
|
+
* so the root layout stays a few lines. A feature that is off is left out.
|
|
4
|
+
*/
|
|
5
|
+
// First: Sentry starts here, before the rest of the app loads.
|
|
6
|
+
import { observability } from "./observability";
|
|
7
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
8
|
+
import NetInfo from "@react-native-community/netinfo";
|
|
9
|
+
import Constants from "expo-constants";
|
|
10
|
+
import { router, type Href } from "expo-router";
|
|
11
|
+
import { AppState } from "react-native";
|
|
12
|
+
import { KeyboardAwareScrollView, KeyboardProvider, KeyboardToolbar } from "react-native-keyboard-controller";
|
|
13
|
+
import { genesisBrand } from "@marktiderman/genesis-design-system";
|
|
14
|
+
import type { GenesisNativeAppProps } from "@marktiderman/genesis-native";
|
|
15
|
+
import { persistQueries } from "@marktiderman/genesis-native/persist";
|
|
16
|
+
import starter from "../../starter.config";
|
|
17
|
+
import { assertEnv } from "./env";
|
|
18
|
+
import { linkHold } from "./links";
|
|
19
|
+
import { nativeModules } from "./native-modules";
|
|
20
|
+
import { sessionReady, supabase } from "./supabase";
|
|
21
|
+
import { devtools } from "./devtools";
|
|
22
|
+
import { createStarterPush } from "./push";
|
|
23
|
+
import { support } from "./support";
|
|
24
|
+
import { updatesBlock } from "./updates";
|
|
25
|
+
|
|
26
|
+
const { features } = starter;
|
|
27
|
+
|
|
28
|
+
/** The query-key roots saved to the phone when `queryPersistence` is on. Add yours: `["me", "projects"]`. */
|
|
29
|
+
export const persistedQueryKeys = ["me"] as const;
|
|
30
|
+
|
|
31
|
+
export const shell: Omit<GenesisNativeAppProps, "children" | "splash"> = {
|
|
32
|
+
brand: genesisBrand,
|
|
33
|
+
supabase,
|
|
34
|
+
steps: [
|
|
35
|
+
{ id: "starter:env", run: assertEnv },
|
|
36
|
+
{ id: "starter:session-storage", run: sessionReady },
|
|
37
|
+
],
|
|
38
|
+
persist: features.queryPersistence
|
|
39
|
+
? persistQueries({ storage: AsyncStorage, keys: persistedQueryKeys, buster: Constants.expoConfig?.version ?? "0" })
|
|
40
|
+
: undefined,
|
|
41
|
+
lifecycle: features.queryLifecycle ? { appState: AppState, netInfo: NetInfo } : undefined,
|
|
42
|
+
keyboardProvider: features.keyboardScroll ? KeyboardProvider : undefined,
|
|
43
|
+
keyboardScroll: features.keyboardScroll ? KeyboardAwareScrollView : undefined,
|
|
44
|
+
keyboardToolbar: features.keyboardScroll ? KeyboardToolbar : undefined,
|
|
45
|
+
modules: nativeModules,
|
|
46
|
+
links: features.deepLinks ? { hold: linkHold, onRelease: (path) => router.replace(path as Href) } : undefined,
|
|
47
|
+
updates: updatesBlock,
|
|
48
|
+
// The first block's root is the outermost: observability sees everything below it.
|
|
49
|
+
blocks: [observability, features.push ? createStarterPush() : undefined, support, devtools].filter((block) => block !== undefined),
|
|
50
|
+
// Support needs a signed-in person: the account feature (sign-in in AuthScreen) is the app's own, not a block.
|
|
51
|
+
appFeatures: ["account"],
|
|
52
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sign-in actions for the sign-in screen. Errors come back as copy from the
|
|
3
|
+
* catalog, chosen by Supabase's error `code`, never the server's own text.
|
|
4
|
+
*/
|
|
5
|
+
import * as AppleAuthentication from "expo-apple-authentication";
|
|
6
|
+
import * as Crypto from "expo-crypto";
|
|
7
|
+
import Constants from "expo-constants";
|
|
8
|
+
import { storeAppleToken } from "@marktiderman/genesis-supabase";
|
|
9
|
+
import { signInWithApple, signInWithGoogle } from "@marktiderman/genesis-supabase/native";
|
|
10
|
+
import starter from "../../starter.config";
|
|
11
|
+
import { copy } from "@/copy";
|
|
12
|
+
import { googleModule } from "./google-signin";
|
|
13
|
+
import { supabase } from "./supabase";
|
|
14
|
+
|
|
15
|
+
// A switch that can't work fails where the sign-in screen loads, naming the fix.
|
|
16
|
+
if (starter.features.googleSignIn && !googleModule) {
|
|
17
|
+
throw new Error("[starter] features.googleSignIn is on, but src/lib/google-signin.ts exports no module. See the README, \"Google sign-in\".");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type ErrorCode = keyof typeof copy.signIn.errors;
|
|
21
|
+
|
|
22
|
+
/** The catalog's message for an auth error code, or the default one. */
|
|
23
|
+
export function authErrorMessage(code: string | undefined): string {
|
|
24
|
+
const errors = copy.signIn.errors;
|
|
25
|
+
return code && code in errors ? errors[code as ErrorCode] : errors.default;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type EmailResult = { ok: true; confirmEmail: boolean } | { ok: false; message: string };
|
|
29
|
+
|
|
30
|
+
/** Sign in, or create the account (`create`). `confirmEmail` is true when Supabase wants the email confirmed first. */
|
|
31
|
+
export async function emailSignIn(email: string, password: string, create: boolean): Promise<EmailResult> {
|
|
32
|
+
const { data, error } = create
|
|
33
|
+
? await supabase.auth.signUp({ email, password })
|
|
34
|
+
: await supabase.auth.signInWithPassword({ email, password });
|
|
35
|
+
if (error) return { ok: false, message: authErrorMessage(error.code) };
|
|
36
|
+
return { ok: true, confirmEmail: data.session === null };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const digest = (value: string) => Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, value);
|
|
40
|
+
|
|
41
|
+
// Apple shares the name on the first sign-in only; kept here if saving it failed, for the retry.
|
|
42
|
+
let pendingName: string | null = null;
|
|
43
|
+
|
|
44
|
+
/** Sign in with Apple. Returns an error message, or null (signed in, or they closed Apple's sheet). */
|
|
45
|
+
export async function appleSignIn(): Promise<string | null> {
|
|
46
|
+
// The nonce is the package default: 32 random bytes from crypto.getRandomValues, which
|
|
47
|
+
// createGenesisSupabase installed from expo-crypto when it made `supabase`.
|
|
48
|
+
const result = await signInWithApple(supabase, AppleAuthentication, { digest });
|
|
49
|
+
if (result.canceled) return null;
|
|
50
|
+
if (result.error) {
|
|
51
|
+
pendingName = result.fullName ?? pendingName;
|
|
52
|
+
return authErrorMessage(result.error.code);
|
|
53
|
+
}
|
|
54
|
+
const fullName = result.fullName ?? pendingName;
|
|
55
|
+
if (fullName) {
|
|
56
|
+
const { error } = await supabase.auth.updateUser({ data: { full_name: fullName } });
|
|
57
|
+
pendingName = error ? fullName : null;
|
|
58
|
+
}
|
|
59
|
+
// Hand Apple's single-use code to the genesis-apple-revoke function, so deleting the account
|
|
60
|
+
// can revoke the person's Apple tokens (App Review requires it). They're signed in either way.
|
|
61
|
+
if (result.authorizationCode) {
|
|
62
|
+
const stored = await storeAppleToken(supabase, { authorizationCode: result.authorizationCode, clientId: Constants.expoConfig?.ios?.bundleIdentifier });
|
|
63
|
+
if (!stored.ok) console.warn(`genesis-apple-revoke: couldn't keep the Apple token: ${stored.error.message}`);
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Sign in with Google (`features.googleSignIn`). Returns an error message, or null (signed in, or they closed Google's sheet). */
|
|
69
|
+
export async function googleSignIn(): Promise<string | null> {
|
|
70
|
+
if (!googleModule) return authErrorMessage(undefined);
|
|
71
|
+
const result = await signInWithGoogle(supabase, googleModule, { digest });
|
|
72
|
+
if (result.canceled) return null;
|
|
73
|
+
if (result.error) {
|
|
74
|
+
if (result.error.code === "google_nonce_missing") console.error(`[starter] ${result.error.message}`);
|
|
75
|
+
return authErrorMessage(result.error.code);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { AppleAuthentication };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The check-in's photo question: forms-native's `photos` seam (`PhotoHost`) over
|
|
3
|
+
* expo-image-picker. The picker is passed in, so this file loads in tests without the native
|
|
4
|
+
* module; `check-in.ts` hands it the real one.
|
|
5
|
+
*
|
|
6
|
+
* The upload `check-in.ts` passes is a stub, like the check-in's `send`: the photo stays on the
|
|
7
|
+
* phone and the answer keeps a reference to it. Point it at your storage (a Supabase Storage
|
|
8
|
+
* bucket under RLS, say) and resolve to the stored file's id; then declare "photos or videos" in
|
|
9
|
+
* the privacy manifest (genesis.config.json `privacy.collects`).
|
|
10
|
+
*/
|
|
11
|
+
import type { PhotoRef } from "@marktiderman/genesis-forms";
|
|
12
|
+
import type { NativePhotoFile, PhotoHost } from "@marktiderman/genesis-forms-native";
|
|
13
|
+
|
|
14
|
+
/** The parts of an expo-image-picker asset the host reads. */
|
|
15
|
+
export interface PickedAsset {
|
|
16
|
+
uri: string;
|
|
17
|
+
fileName?: string | null;
|
|
18
|
+
fileSize?: number;
|
|
19
|
+
mimeType?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PickResult = { canceled: true; assets: null } | { canceled: false; assets: PickedAsset[] };
|
|
23
|
+
|
|
24
|
+
/** `launchImageLibraryAsync` from expo-image-picker, or a stand-in. */
|
|
25
|
+
export type LaunchLibrary = (options: {
|
|
26
|
+
mediaTypes: ["images"];
|
|
27
|
+
allowsMultipleSelection: boolean;
|
|
28
|
+
selectionLimit: number;
|
|
29
|
+
quality: number;
|
|
30
|
+
}) => Promise<PickResult>;
|
|
31
|
+
|
|
32
|
+
const EXTENSION_TYPES: Readonly<Record<string, string>> = {
|
|
33
|
+
jpg: "image/jpeg",
|
|
34
|
+
jpeg: "image/jpeg",
|
|
35
|
+
png: "image/png",
|
|
36
|
+
heic: "image/heic",
|
|
37
|
+
webp: "image/webp",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** A picked asset as the form's file, with a name and a MIME type even when the picker gives none. */
|
|
41
|
+
export function photoFile(asset: PickedAsset, index: number): NativePhotoFile {
|
|
42
|
+
const fromUri = asset.uri.split(/[?#]/)[0]?.split("/").pop() ?? "";
|
|
43
|
+
const name = asset.fileName || fromUri || `photo-${index + 1}.jpg`;
|
|
44
|
+
const extension = name.includes(".") ? (name.split(".").pop() ?? "").toLowerCase() : "";
|
|
45
|
+
return { uri: asset.uri, name, type: asset.mimeType || EXTENSION_TYPES[extension] || "image/jpeg", size: asset.fileSize ?? 0 };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The photo host: the photo library (no camera, so no camera permission) and `upload`. */
|
|
49
|
+
export function createCheckInPhotos(launch: LaunchLibrary, upload: (file: NativePhotoFile) => Promise<PhotoRef>): PhotoHost {
|
|
50
|
+
return {
|
|
51
|
+
camera: false,
|
|
52
|
+
async pick(_field, { max }) {
|
|
53
|
+
if (max <= 0) return [];
|
|
54
|
+
// A quality below 1 re-encodes as JPEG, so a HEIC library photo arrives as a type the form takes.
|
|
55
|
+
const result = await launch({ mediaTypes: ["images"], allowsMultipleSelection: max > 1, selectionLimit: max, quality: 0.8 });
|
|
56
|
+
if (result.canceled) return [];
|
|
57
|
+
return result.assets.slice(0, max).map(photoFile);
|
|
58
|
+
},
|
|
59
|
+
upload: (file) => upload(file),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The stub upload: the photo stays on the phone and the answer keeps a reference to it. */
|
|
64
|
+
export function stubUpload(makeId: () => string): (file: NativePhotoFile) => Promise<PhotoRef> {
|
|
65
|
+
return async (file) => ({ id: `local-${makeId()}`, name: file.name, type: file.type, size: file.size });
|
|
66
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The check-in example (`features.checkIn`): a sample form in focus layout, with every check-in
|
|
3
|
+
* field type, an "Other" answer, a list filtered by an earlier answer, a searchable list, a
|
|
4
|
+
* question a link can fill in (`?gym=hilltop`) and content steps. Drafts and the submit outbox
|
|
5
|
+
* keep their data in AsyncStorage, so a check-in survives the app closing and waits offline.
|
|
6
|
+
*
|
|
7
|
+
* Submissions go to a stub `send` that answers like `submitResponse` would. Point it at your own
|
|
8
|
+
* endpoint (a Supabase Edge Function that runs `submitResponse`) to store them for real, and
|
|
9
|
+
* declare the answers in the iOS privacy manifest then: genesis.config.json `privacy.collects`
|
|
10
|
+
* ("other user content" for the free text, "phone number" for the phone field, and so on).
|
|
11
|
+
*/
|
|
12
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
13
|
+
import NetInfo from "@react-native-community/netinfo";
|
|
14
|
+
import * as Crypto from "expo-crypto";
|
|
15
|
+
import * as Haptics from "expo-haptics";
|
|
16
|
+
import * as ImagePicker from "expo-image-picker";
|
|
17
|
+
import {
|
|
18
|
+
createDraftStore,
|
|
19
|
+
createSubmitOutbox,
|
|
20
|
+
parseForm,
|
|
21
|
+
registerContentType,
|
|
22
|
+
type ChoiceOption,
|
|
23
|
+
type FormDefinition,
|
|
24
|
+
type SubmitResult,
|
|
25
|
+
} from "@marktiderman/genesis-forms";
|
|
26
|
+
import type { FormHaptics } from "@marktiderman/genesis-forms-native";
|
|
27
|
+
import sample from "../forms/check-in.json";
|
|
28
|
+
import { createCheckInPhotos, stubUpload, type LaunchLibrary } from "./check-in-photos";
|
|
29
|
+
|
|
30
|
+
// A callout is a content kind this app adds. Register it wherever the form is parsed (here, and
|
|
31
|
+
// on the server that checks submissions), so every side reads the same definition.
|
|
32
|
+
for (const kind of sample.contentTypes) {
|
|
33
|
+
try {
|
|
34
|
+
registerContentType(kind);
|
|
35
|
+
} catch {
|
|
36
|
+
// Already registered (a fast refresh re-ran this module).
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function load(raw: unknown): FormDefinition {
|
|
41
|
+
const parsed = parseForm(raw);
|
|
42
|
+
if (!parsed.ok) throw new Error(`[check-in] The sample form doesn't parse: ${parsed.issues.map((i) => `${i.path}: ${i.message}`).join("; ")}`);
|
|
43
|
+
return parsed.form;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The sample check-in, checked once when the app loads. */
|
|
47
|
+
export const checkInForm: FormDefinition = load(sample.definition);
|
|
48
|
+
|
|
49
|
+
/** The coaches the app supplies for the filtered question (`optionsFrom: { source: "host", key: "coaches" }`). */
|
|
50
|
+
export const checkInHostOptions: Readonly<Record<string, readonly ChoiceOption[]>> = { coaches: sample.coaches };
|
|
51
|
+
|
|
52
|
+
/** Where check-in drafts are kept, by form and respondent. */
|
|
53
|
+
export const checkInDrafts = createDraftStore(AsyncStorage);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The stub server: waits a moment and answers as `submitResponse` does when it stores a
|
|
57
|
+
* response. Replace with a `fetch` to your endpoint, returning its JSON body.
|
|
58
|
+
*/
|
|
59
|
+
async function send(item: { id: string }): Promise<SubmitResult> {
|
|
60
|
+
await new Promise((resolve) => setTimeout(resolve, 800));
|
|
61
|
+
return { ok: true, id: `stub-${item.id}`, receivedAt: new Date().toISOString() };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Idempotency keys: one per check-in, so a retry is stored once. */
|
|
65
|
+
export const checkInKey = (): string => Crypto.randomUUID();
|
|
66
|
+
|
|
67
|
+
/** One outbox for the whole app: submissions wait on the phone until the server has them. */
|
|
68
|
+
export const checkInOutbox = createSubmitOutbox({
|
|
69
|
+
storage: AsyncStorage,
|
|
70
|
+
prefix: "genesis-starter:check-in-outbox",
|
|
71
|
+
send,
|
|
72
|
+
createKey: checkInKey,
|
|
73
|
+
});
|
|
74
|
+
checkInOutbox.start();
|
|
75
|
+
NetInfo.addEventListener((state) => checkInOutbox.setOnline(state.isConnected !== false && state.isInternetReachable !== false));
|
|
76
|
+
|
|
77
|
+
/** The photo question's picker (the photo library) and storage (a stub; see `check-in-photos.ts`). */
|
|
78
|
+
export const checkInPhotos = createCheckInPhotos(ImagePicker.launchImageLibraryAsync as LaunchLibrary, stubUpload(Crypto.randomUUID));
|
|
79
|
+
|
|
80
|
+
/** A pick, a sent check-in and a refused step, felt. */
|
|
81
|
+
export const checkInHaptics: FormHaptics = {
|
|
82
|
+
selection: () => void Haptics.selectionAsync(),
|
|
83
|
+
success: () => void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success),
|
|
84
|
+
error: () => void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error),
|
|
85
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed shape of `starter.config.ts`. Kept free of React Native imports so
|
|
3
|
+
* `app.config.ts` (run by Node) and the tests can read it too.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Who the app is: the store name and the ids the variants are built from. */
|
|
7
|
+
export interface StarterApp {
|
|
8
|
+
/** The app's name on the home screen. Development and preview builds add " (Dev)" / " (Preview)". */
|
|
9
|
+
name: string;
|
|
10
|
+
/** The Expo slug, also the prefix of the Keychain key the session is stored under. */
|
|
11
|
+
slug: string;
|
|
12
|
+
/** The URL scheme, without `://`: `myapp://settings` opens Settings. */
|
|
13
|
+
scheme: string;
|
|
14
|
+
/** iOS bundle id and Android package. Development and preview builds add `.dev` / `.preview`. */
|
|
15
|
+
bundleId: string;
|
|
16
|
+
/**
|
|
17
|
+
* The EAS project id (a UUID, from `eas init`), or `""` before there is one. It sets the
|
|
18
|
+
* update URL (`https://u.expo.dev/<id>`) and `extra.eas.projectId`; empty, builds have no
|
|
19
|
+
* update URL, so expo-updates is off in them.
|
|
20
|
+
*/
|
|
21
|
+
easProjectId: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Every universal feature the Genesis packages ship. `true` is on; set one to `false` to turn it off. */
|
|
25
|
+
export interface StarterFeatures {
|
|
26
|
+
/** Email and password sign-in and sign-up on `AuthScreen` (Supabase Auth). With Google off, the only sign-in on Android: off, the app builds for iOS only. */
|
|
27
|
+
emailSignIn: boolean;
|
|
28
|
+
/** Sign in with Apple on iOS (`signInWithApple` + `appleProvider`). Needs the Apple provider in Supabase Auth. */
|
|
29
|
+
appleSignIn: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Native Google sign-in (`signInWithGoogle` + `googleProvider`), off by default: it needs Google
|
|
32
|
+
* client ids, the Google provider in Supabase Auth and the Universal sign-in module of
|
|
33
|
+
* `@react-native-google-signin/google-signin` in `src/lib/google-signin.ts` (README, "Google
|
|
34
|
+
* sign-in"). On iOS it needs `appleSignIn` too (App Store Review Guideline 4.8).
|
|
35
|
+
*/
|
|
36
|
+
googleSignIn: boolean;
|
|
37
|
+
/** "Delete account" in Settings (`deleteMyAccount` + the `delete_my_account` migration). */
|
|
38
|
+
accountDeletion: boolean;
|
|
39
|
+
/** The Notifications tab (`NotificationsPage`). */
|
|
40
|
+
notifications: boolean;
|
|
41
|
+
/** Save the listed queries to the phone for 24 hours, per user (`persistQueries`). */
|
|
42
|
+
queryPersistence: boolean;
|
|
43
|
+
/** Refetch when the app comes to the front and follow the network (`lifecycle`: AppState + NetInfo). */
|
|
44
|
+
queryLifecycle: boolean;
|
|
45
|
+
/** Keep the focused field above the keyboard on form screens (react-native-keyboard-controller). */
|
|
46
|
+
keyboardScroll: boolean;
|
|
47
|
+
/** Open universal links and `scheme://` links in the app, and follow one after sign-in (`normalizeLink`). */
|
|
48
|
+
deepLinks: boolean;
|
|
49
|
+
/** Start signed out after a reinstall (iOS keeps the Keychain across uninstalls). */
|
|
50
|
+
wipeSessionOnReinstall: boolean;
|
|
51
|
+
/** Refresh the session only while the app is in front, as Supabase recommends on React Native. */
|
|
52
|
+
refreshWhileActive: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The updates block (`createUpdates`): force upgrade and maintenance from the
|
|
55
|
+
* `app_release_policy` table, the update banner, what's new, and the version signature in
|
|
56
|
+
* Settings. JavaScript only: turning it off leaves the native build and its fingerprint alone.
|
|
57
|
+
*/
|
|
58
|
+
updates: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The push block (`createPush`): this device's push token on sign-in and off on sign-out, taps
|
|
61
|
+
* routed through the deep-link map, the badge, the soft prompt (offered on the Notifications tab,
|
|
62
|
+
* never at launch) and Settings → Notifications (categories, quiet hours, previews), on the
|
|
63
|
+
* `push_devices` and `notification_preferences` migration. JavaScript only: expo-notifications
|
|
64
|
+
* stays in the build either way. Needs an EAS project id for a push token.
|
|
65
|
+
*/
|
|
66
|
+
push: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The observability block (`createObservability`, `src/lib/observability.ts`): every error the
|
|
69
|
+
* shell catches, route breadcrumbs and timings, the user's id and typed analytics events, to
|
|
70
|
+
* Sentry when `EXPO_PUBLIC_SENTRY_DSN` is set (and the console in development), scrubbed of
|
|
71
|
+
* emails, tokens and query strings on the phone. JavaScript only.
|
|
72
|
+
*/
|
|
73
|
+
observability: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The devtools overlay (`createDevtools`, `src/lib/devtools.ts`) in development and preview
|
|
76
|
+
* builds: a three-finger hold, the dev menu or Settings > About open a sheet with the version
|
|
77
|
+
* signature, channel switch, user id, blocks, flags and recent errors. Left out of production
|
|
78
|
+
* bundles at build time. JavaScript only.
|
|
79
|
+
*/
|
|
80
|
+
devtools: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The support block (`createSupport` from @marktiderman/genesis-support): Send feedback and Help
|
|
83
|
+
* in Settings, a feedback screen with a screenshot (shake the phone to capture the screen you're
|
|
84
|
+
* on), the person's reports with staff replies, and the idea board with votes, on the
|
|
85
|
+
* `genesis_support` migration. JavaScript only: react-native-view-shot and expo-sensors stay in
|
|
86
|
+
* the build either way.
|
|
87
|
+
*/
|
|
88
|
+
support: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The check-in example on Home (`@marktiderman/genesis-forms-native`'s `FormFocus`): a sample
|
|
91
|
+
* form one question at a time, with a draft per user and the offline outbox. A demo: replace
|
|
92
|
+
* the form in `src/forms/check-in.json`, or turn it off. JavaScript only.
|
|
93
|
+
*/
|
|
94
|
+
checkIn: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface StarterConfig {
|
|
98
|
+
app: StarterApp;
|
|
99
|
+
features: StarterFeatures;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The platforms the app builds for. Sign in with Apple only shows on iOS, so
|
|
104
|
+
* with email and Google sign-in off an Android build would have no way to
|
|
105
|
+
* sign in: the app is iOS only then (`platforms` in app.config.ts).
|
|
106
|
+
*/
|
|
107
|
+
export function nativePlatforms(features: Pick<StarterFeatures, "emailSignIn"> & Partial<Pick<StarterFeatures, "googleSignIn">>): ("ios" | "android")[] {
|
|
108
|
+
return features.emailSignIn || features.googleSignIn ? ["ios", "android"] : ["ios"];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The Genesis blocks that send data off the phone, for the privacy manifest
|
|
113
|
+
* (`withGenesis({ privacy: { blocks } })` in app.config.ts): a switch turned
|
|
114
|
+
* off declares nothing. Sign-in is always on, so `account` always is.
|
|
115
|
+
*/
|
|
116
|
+
export function privacyBlocks(features: Pick<StarterFeatures, "observability" | "push" | "support">): string[] {
|
|
117
|
+
return ["account", ...(features.observability ? ["observability"] : []), ...(features.push ? ["push"] : []), ...(features.support ? ["support"] : [])];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Checks the config once, where it is written, so a combination that can't work fails at start-up. */
|
|
121
|
+
export function defineStarter<const C extends StarterConfig>(config: C): C {
|
|
122
|
+
const { features } = config;
|
|
123
|
+
if (!features.emailSignIn && !features.appleSignIn && !features.googleSignIn) {
|
|
124
|
+
throw new Error("[starter] emailSignIn, appleSignIn and googleSignIn are all off in starter.config.ts, so nobody can sign in. Turn one on.");
|
|
125
|
+
}
|
|
126
|
+
if (features.googleSignIn && !features.appleSignIn) {
|
|
127
|
+
throw new Error("[starter] googleSignIn is on without appleSignIn. App Store Review Guideline 4.8 wants Sign in with Apple beside Google on iOS: turn appleSignIn on.");
|
|
128
|
+
}
|
|
129
|
+
if (!/^[a-z][a-z0-9+.-]*$/.test(config.app.scheme)) {
|
|
130
|
+
throw new Error(`[starter] app.scheme "${config.app.scheme}" in starter.config.ts must be lower case letters, digits, "+", "." or "-", without "://".`);
|
|
131
|
+
}
|
|
132
|
+
if (config.app.easProjectId !== "" && !UUID.test(config.app.easProjectId)) {
|
|
133
|
+
throw new Error(`[starter] app.easProjectId "${config.app.easProjectId}" in starter.config.ts must be the UUID \`eas init\` prints, or "" for none.`);
|
|
134
|
+
}
|
|
135
|
+
return config;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The EAS part of the Expo config: the update URL and the project id. Before `eas init` there is
|
|
142
|
+
* no project, so expo-updates is turned off in the build rather than left without a URL. Kept here
|
|
143
|
+
* so app.config.ts and the tests read one rule.
|
|
144
|
+
*/
|
|
145
|
+
export function easConfig(app: Pick<StarterApp, "easProjectId">): { updates: { enabled: boolean; url?: string }; extra?: { eas: { projectId: string } } } {
|
|
146
|
+
if (!app.easProjectId) return { updates: { enabled: false } };
|
|
147
|
+
return { updates: { enabled: true, url: `https://u.expo.dev/${app.easProjectId}` }, extra: { eas: { projectId: app.easProjectId } } };
|
|
148
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The overlay itself. Only `devtools.ts` imports this file, behind a
|
|
3
|
+
* condition Metro folds, so production bundles never include it. Open it
|
|
4
|
+
* with a three-finger hold, "Open devtools" in the dev menu, or Settings >
|
|
5
|
+
* About > Developer tools.
|
|
6
|
+
*/
|
|
7
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
8
|
+
import * as Application from "expo-application";
|
|
9
|
+
import { DevSettings } from "react-native";
|
|
10
|
+
import { createDevtools } from "@marktiderman/genesis-native/devtools";
|
|
11
|
+
import starter from "../../starter.config";
|
|
12
|
+
import { env } from "./env";
|
|
13
|
+
import { observability } from "./observability";
|
|
14
|
+
import { supabase } from "./supabase";
|
|
15
|
+
import { updatesBlock } from "./updates";
|
|
16
|
+
|
|
17
|
+
/** The variants (withGenesis bundle id suffixes) that may open the overlay. */
|
|
18
|
+
const TEST_BUILD = /\.(dev|preview)$/;
|
|
19
|
+
|
|
20
|
+
/** The persisted query cache's key (`persistQueries`' default). */
|
|
21
|
+
const QUERY_CACHE_KEY = "genesis-query-cache";
|
|
22
|
+
|
|
23
|
+
export function createStarterDevtools() {
|
|
24
|
+
return createDevtools({
|
|
25
|
+
enabled: __DEV__ || TEST_BUILD.test(Application.applicationId ?? ""),
|
|
26
|
+
updates: updatesBlock,
|
|
27
|
+
observability,
|
|
28
|
+
baseUrl: env.supabaseUrl,
|
|
29
|
+
flags: starter.features,
|
|
30
|
+
devSettings: __DEV__ ? DevSettings : undefined,
|
|
31
|
+
clearCache: () => AsyncStorage.removeItem(QUERY_CACHE_KEY),
|
|
32
|
+
signOut: () => supabase.auth.signOut(),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The devtools overlay (`features.devtools`), in development, preview and
|
|
3
|
+
* internal builds only. Two locks:
|
|
4
|
+
*
|
|
5
|
+
* 1. At build time: the condition below is folded by Metro (`__DEV__` and
|
|
6
|
+
* `EXPO_PUBLIC_APP_VARIANT`, which eas.json and the EAS workflows set next
|
|
7
|
+
* to `APP_VARIANT`), so a production bundle, or one built without the
|
|
8
|
+
* variable, has no `require` of the overlay and none of its code. Keep the
|
|
9
|
+
* condition written out here: a variable or a helper would stop Metro
|
|
10
|
+
* folding it.
|
|
11
|
+
* 2. At run time: `enabled` is a fact of the binary, the `.dev` / `.preview`
|
|
12
|
+
* bundle id the variant gave it (see `devtools-overlay.ts`).
|
|
13
|
+
*/
|
|
14
|
+
import type { DevtoolsBlock } from "@marktiderman/genesis-native/devtools";
|
|
15
|
+
import starter from "../../starter.config";
|
|
16
|
+
|
|
17
|
+
export const devtools: DevtoolsBlock | undefined =
|
|
18
|
+
__DEV__ || process.env.EXPO_PUBLIC_APP_VARIANT === "development" || process.env.EXPO_PUBLIC_APP_VARIANT === "preview"
|
|
19
|
+
? starter.features.devtools
|
|
20
|
+
? // eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
21
|
+
(require("./devtools-overlay") as typeof import("./devtools-overlay")).createStarterDevtools()
|
|
22
|
+
: undefined
|
|
23
|
+
: undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's public settings, from `.env` (copy `.env.example`). Expo inlines
|
|
3
|
+
* `EXPO_PUBLIC_*` values at build time, so each one is read by its full name.
|
|
4
|
+
* Only publishable values go here: everything in the bundle can be read off
|
|
5
|
+
* the phone.
|
|
6
|
+
*
|
|
7
|
+
* A missing value doesn't throw here: this module loads before
|
|
8
|
+
* `GenesisNativeApp` exists, and a throw would close a release build with
|
|
9
|
+
* nothing on screen. The first boot step (`app.ts`) throws instead, so the
|
|
10
|
+
* fatal screen names the variable.
|
|
11
|
+
*/
|
|
12
|
+
const values = {
|
|
13
|
+
EXPO_PUBLIC_SUPABASE_URL: process.env.EXPO_PUBLIC_SUPABASE_URL,
|
|
14
|
+
EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY: process.env.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** The names of the settings that aren't set. */
|
|
18
|
+
export const missingEnv = Object.entries(values)
|
|
19
|
+
.filter(([, value]) => !value)
|
|
20
|
+
.map(([name]) => name);
|
|
21
|
+
|
|
22
|
+
/** Throws, naming what's missing, when a setting isn't set. The boot runs it first. */
|
|
23
|
+
export function assertEnv(): void {
|
|
24
|
+
if (missingEnv.length > 0) {
|
|
25
|
+
throw new Error(`[starter] ${missingEnv.join(" and ")} not set. Copy .env.example to .env, fill it in, and restart Metro.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const env = {
|
|
30
|
+
// A placeholder keeps the client constructible until the boot step reports the missing value.
|
|
31
|
+
supabaseUrl: values.EXPO_PUBLIC_SUPABASE_URL || "https://missing-supabase-url.invalid",
|
|
32
|
+
supabasePublishableKey: values.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY || "missing-publishable-key",
|
|
33
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Google sign-in module for `features.googleSignIn` (off by default).
|
|
3
|
+
*
|
|
4
|
+
* `signInWithGoogle` needs the Universal sign-in module (`GoogleOneTapSignIn`)
|
|
5
|
+
* of `@react-native-google-signin/google-signin`: only it puts the sign-in's
|
|
6
|
+
* nonce in Google's ID token, which Supabase checks. It ships in the library's
|
|
7
|
+
* paid build, so the starter doesn't install it. To turn Google on, follow the
|
|
8
|
+
* README ("Google sign-in"), then replace the `null` below with:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { GoogleOneTapSignIn } from "@react-native-google-signin/google-signin";
|
|
12
|
+
*
|
|
13
|
+
* GoogleOneTapSignIn.configure({
|
|
14
|
+
* webClientId: process.env.EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID!,
|
|
15
|
+
* iosClientId: process.env.EXPO_PUBLIC_GOOGLE_IOS_CLIENT_ID,
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* export const googleModule: GoogleSignInLike | null = GoogleOneTapSignIn;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import type { GoogleSignInLike } from "@marktiderman/genesis-supabase/native";
|
|
22
|
+
|
|
23
|
+
export const googleModule: GoogleSignInLike | null = null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep links. The hosts come from `genesis.config.json`'s `links` block, the
|
|
3
|
+
* same block the Expo config plugin turns into associated domains and app
|
|
4
|
+
* links, so the two can't disagree.
|
|
5
|
+
*/
|
|
6
|
+
import Constants from "expo-constants";
|
|
7
|
+
import { createLinkHold, type LinkOptions } from "@marktiderman/genesis-native";
|
|
8
|
+
import genesisConfig from "../../genesis.config.json";
|
|
9
|
+
import starter from "../../starter.config";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The schemes this build answers to. withGenesis gives each APP_VARIANT its own
|
|
13
|
+
* (`genesis-starter-dev://`, `genesis-starter-preview://`, production keeps `genesis-starter://`),
|
|
14
|
+
* so the OS hands a link to the build it names, and only that build. Every variant's is accepted
|
|
15
|
+
* here, plus the one in the served config: a `.dev` binary running against a plain `expo start`
|
|
16
|
+
* (no APP_VARIANT) gets the production config from Metro, but still receives `-dev` links.
|
|
17
|
+
* The suffixes are withGenesis's defaults; change both together.
|
|
18
|
+
*/
|
|
19
|
+
export const VARIANT_SCHEME_SUFFIXES = ["", "-dev", "-preview"] as const;
|
|
20
|
+
|
|
21
|
+
export function appSchemes(base: string, built: string | readonly string[] | undefined): string[] {
|
|
22
|
+
const served = built === undefined ? [] : typeof built === "string" ? [built] : built;
|
|
23
|
+
return [...new Set([...VARIANT_SCHEME_SUFFIXES.map((suffix) => base + suffix), ...served])];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Incoming link paths and the screens they open. `/` is always known; anything else opens `/`. */
|
|
27
|
+
export const links: LinkOptions = {
|
|
28
|
+
schemes: appSchemes(starter.app.scheme, Constants.expoConfig?.scheme),
|
|
29
|
+
hosts: genesisConfig.links.hosts,
|
|
30
|
+
map: {
|
|
31
|
+
...(starter.features.notifications ? { "/notifications": "/notifications" } : {}),
|
|
32
|
+
// The check-in example's link (`genesis-starter://check-in?gym=hilltop` fills in the gym; `genesis-starter-dev://` in a development build).
|
|
33
|
+
...(starter.features.checkIn ? { "/check-in": "/check-in" } : {}),
|
|
34
|
+
"/settings": "/settings",
|
|
35
|
+
...(starter.features.push ? { "/settings/notifications": "/settings/notifications" } : {}),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A link that arrives while signed out, followed once the person signs in. */
|
|
40
|
+
export const linkHold = createLinkHold();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The optional native modules Genesis components use when they're given:
|
|
3
|
+
* FlashList v2 for long lists, expo-image for avatars and pictures,
|
|
4
|
+
* Reanimated 4 for toasts, drawers and skeletons, Liquid Glass for floating
|
|
5
|
+
* surfaces on iOS 26, SF Symbols on iOS with lucide everywhere else, and the
|
|
6
|
+
* @expo/ui (SwiftUI / Jetpack Compose) date picker. To fall back to plain
|
|
7
|
+
* React Native for one, delete its line, its import below and its package.
|
|
8
|
+
*/
|
|
9
|
+
import DateTimePicker from "@expo/ui/community/datetime-picker";
|
|
10
|
+
import { FlashList } from "@shopify/flash-list";
|
|
11
|
+
import * as GlassEffect from "expo-glass-effect";
|
|
12
|
+
import { Image } from "expo-image";
|
|
13
|
+
import { SymbolView } from "expo-symbols";
|
|
14
|
+
import * as Reanimated from "react-native-reanimated";
|
|
15
|
+
import type { GenesisModules } from "@marktiderman/genesis-ui-native";
|
|
16
|
+
import { lucideIcons } from "@marktiderman/genesis-ui-native/icons/lucide";
|
|
17
|
+
|
|
18
|
+
// Genesis describes each module by the props it passes, so the packages' own (wider) types are cast once here.
|
|
19
|
+
export const nativeModules: GenesisModules = {
|
|
20
|
+
list: FlashList as unknown as GenesisModules["list"],
|
|
21
|
+
image: Image as unknown as GenesisModules["image"],
|
|
22
|
+
reanimated: Reanimated as unknown as GenesisModules["reanimated"],
|
|
23
|
+
glass: GlassEffect as unknown as GenesisModules["glass"],
|
|
24
|
+
symbol: SymbolView as unknown as GenesisModules["symbol"],
|
|
25
|
+
icons: lucideIcons,
|
|
26
|
+
datePicker: DateTimePicker as unknown as GenesisModules["datePicker"],
|
|
27
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the Notifications tab gets its items. The starter has no notifications
|
|
3
|
+
* source yet, so the list is empty and the tab shows its empty state. Point
|
|
4
|
+
* `queryFn` at yours (a Supabase table read with `must(...)`, say) and keep
|
|
5
|
+
* the query key: `["notifications"]`.
|
|
6
|
+
*/
|
|
7
|
+
import { useQuery } from "@tanstack/react-query";
|
|
8
|
+
import type { NotificationItem } from "@marktiderman/genesis-ui-native";
|
|
9
|
+
|
|
10
|
+
export function useNotifications() {
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: ["notifications"],
|
|
13
|
+
queryFn: async (): Promise<NotificationItem[]> => [],
|
|
14
|
+
});
|
|
15
|
+
}
|