@marktiderman/genesis-native 0.11.0 → 0.13.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 +13 -3
- package/dist/{block-Iga-mCeC.d.ts → block-BfJT3F6B.d.ts} +3 -3
- package/dist/{blocks-BQY_df3j.d.ts → blocks-DoY_Z-Lh.d.ts} +69 -7
- package/dist/{chunk-6BT4PTGH.js → chunk-6UVWYJPZ.js} +15 -5
- package/dist/chunk-6UVWYJPZ.js.map +1 -0
- package/dist/{chunk-EWHO5WQU.js → chunk-JWIBRHDE.js} +21 -9
- package/dist/chunk-JWIBRHDE.js.map +1 -0
- package/dist/{chunk-YIF4BFQH.js → chunk-JZHDEU4Q.js} +130 -13
- package/dist/chunk-JZHDEU4Q.js.map +1 -0
- package/dist/devtools.d.ts +101 -8
- package/dist/devtools.js +180 -104
- package/dist/devtools.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts +14 -8
- package/dist/observability.js +3 -3
- package/dist/persist.d.ts +1 -1
- package/dist/push.d.ts +4 -4
- package/dist/push.js +1 -1
- package/dist/push.js.map +1 -1
- package/dist/{query--ihYsJWC.d.ts → query-DJFrykK_.d.ts} +38 -2
- package/dist/{screen-boundary-B8DlsLwb.d.ts → screen-boundary-Da3qleNz.d.ts} +5 -1
- package/dist/updates.d.ts +3 -3
- package/dist/updates.js +6 -6
- package/dist/updates.js.map +1 -1
- package/package.json +50 -8
- package/src/app.tsx +2 -1
- package/src/blocks.tsx +20 -5
- package/src/devtools/block.tsx +281 -152
- package/src/devtools/index.ts +4 -3
- package/src/devtools/settings.ts +50 -0
- package/src/devtools/slots.ts +15 -0
- package/src/errors.tsx +144 -13
- package/src/index.ts +4 -0
- package/src/observability/block.tsx +1 -1
- package/src/observability/index.ts +1 -1
- package/src/observability/scrub.ts +22 -4
- package/src/push/block.tsx +1 -1
- package/src/screen-boundary.tsx +13 -2
- package/src/updates/block.tsx +7 -5
- package/src/updates/index.ts +1 -1
- package/src/updates/signature.ts +52 -3
- package/dist/chunk-65P7RU4V.js +0 -49
- package/dist/chunk-65P7RU4V.js.map +0 -1
- package/dist/chunk-6BT4PTGH.js.map +0 -1
- package/dist/chunk-EWHO5WQU.js.map +0 -1
- package/dist/chunk-YIF4BFQH.js.map +0 -1
package/src/errors.tsx
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* tree with fresh state.
|
|
7
7
|
*/
|
|
8
8
|
import { Component, type ComponentType, type ErrorInfo, type ReactNode } from "react";
|
|
9
|
-
import { Pressable, Text, View } from "react-native";
|
|
10
|
-
import { NativeButton, NativeEmptyState } from "@marktiderman/genesis-ui-native/components";
|
|
9
|
+
import { Linking, Pressable, Text, View } from "react-native";
|
|
10
|
+
import { Inline, NativeButton, NativeEmptyState } from "@marktiderman/genesis-ui-native/components";
|
|
11
11
|
import { classifyError, reportError } from "@marktiderman/genesis-core/errors";
|
|
12
12
|
import { toError } from "./boot";
|
|
13
|
+
import { useOptionalBlocks, type NativeBlock } from "./blocks";
|
|
13
14
|
|
|
14
15
|
declare const __DEV__: boolean | undefined;
|
|
15
16
|
|
|
@@ -45,8 +46,94 @@ export interface FatalScreenViewProps {
|
|
|
45
46
|
* could not start, or when the `fatal` slot threw.
|
|
46
47
|
*/
|
|
47
48
|
kind?: FatalScreenKind;
|
|
49
|
+
/**
|
|
50
|
+
* Where people can write when the app can't help (support's `contactEmail` / `contactUrl`
|
|
51
|
+
* settings: `support.contact()`): a "Contact support" button under "Try again". Left out, none.
|
|
52
|
+
*/
|
|
53
|
+
contact?: FatalScreenContact | null;
|
|
54
|
+
/**
|
|
55
|
+
* "Report this": opens the support block's feedback form with the error attached. Left out, the
|
|
56
|
+
* block's (when the support block is on and feedback with it); `null` for none.
|
|
57
|
+
*/
|
|
58
|
+
onReport?: ((error: Error, where: { kind: "app" | "screen" }) => void) | null;
|
|
59
|
+
/** The screen's words, in English by default. */
|
|
60
|
+
labels?: Partial<FatalScreenLabels>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The fatal and screen error screens' words. */
|
|
64
|
+
export interface FatalScreenLabels {
|
|
65
|
+
/** The app's fatal screen. */
|
|
66
|
+
title: string;
|
|
67
|
+
body: string;
|
|
68
|
+
/** One screen failed. */
|
|
69
|
+
screenTitle: string;
|
|
70
|
+
screenBody: string;
|
|
71
|
+
/** The plain screen's line when the error has nothing safe to say. */
|
|
72
|
+
plainBody: string;
|
|
73
|
+
retry: string;
|
|
74
|
+
contact: string;
|
|
75
|
+
report: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const DEFAULT_FATAL_SCREEN_LABELS: FatalScreenLabels = {
|
|
79
|
+
title: "Something went wrong",
|
|
80
|
+
body: "The app hit a problem. Try again, and if it keeps happening, close and reopen the app.",
|
|
81
|
+
screenTitle: "This screen hit a problem",
|
|
82
|
+
screenBody: "The rest of the app still works. Try again, or go back.",
|
|
83
|
+
plainBody: "Try again, and if it keeps happening, close and reopen the app.",
|
|
84
|
+
retry: "Try again",
|
|
85
|
+
contact: "Contact support",
|
|
86
|
+
report: "Report this",
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** A support contact for the fatal screens: an email address, a support page, or both. */
|
|
90
|
+
export interface FatalScreenContact {
|
|
91
|
+
email?: string | null;
|
|
92
|
+
url?: string | null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** An https page with a host (`https://acme.test/help`), else null. */
|
|
96
|
+
function httpsPage(text: string | null | undefined): string | null {
|
|
97
|
+
const t = text?.trim();
|
|
98
|
+
if (!t || t.length > 2048 || !/^https:\/\//i.test(t)) return null;
|
|
99
|
+
try {
|
|
100
|
+
const u = new URL(t);
|
|
101
|
+
return u.protocol === "https:" && u.hostname ? t : null;
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** One address, checked in one pass (no backtracking): one "@", no spaces or brackets, a dot in the domain, not at its ends. */
|
|
108
|
+
function looksLikeEmail(text: string): boolean {
|
|
109
|
+
if (text.length > 254) return false;
|
|
110
|
+
let at = -1;
|
|
111
|
+
for (let i = 0; i < text.length; i++) {
|
|
112
|
+
const c = text.charCodeAt(i);
|
|
113
|
+
if (c <= 0x20 || c === 0x3c || c === 0x3e || c === 0x7f) return false;
|
|
114
|
+
if (c === 0x40) {
|
|
115
|
+
if (at !== -1) return false;
|
|
116
|
+
at = i;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const dot = text.lastIndexOf(".");
|
|
120
|
+
return at > 0 && dot > at + 1 && dot < text.length - 1;
|
|
48
121
|
}
|
|
49
122
|
|
|
123
|
+
/** The link a contact opens: the support page, else a mailto. Null with neither (or one that isn't safe). */
|
|
124
|
+
export function contactHref(contact: FatalScreenContact | null | undefined): string | null {
|
|
125
|
+
const url = httpsPage(contact?.url);
|
|
126
|
+
if (url) return url;
|
|
127
|
+
const email = contact?.email?.trim();
|
|
128
|
+
// RFC 6068: "?", "#", "%", "&" and "/" in the mailbox are encoded, so they don't start a query.
|
|
129
|
+
if (email && looksLikeEmail(email)) return `mailto:${email.replace(/[%?#&/]/g, (c) => encodeURIComponent(c))}`;
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const openContact = (href: string) => () => {
|
|
134
|
+
void Linking.openURL(href).catch((e: unknown) => reportError(e, "native:contact"));
|
|
135
|
+
};
|
|
136
|
+
|
|
50
137
|
const runRetry = (retry: FatalScreenViewProps["retry"], source: string) => () => {
|
|
51
138
|
void Promise.resolve(retry()).catch((e: unknown) => reportError(e, source));
|
|
52
139
|
};
|
|
@@ -55,44 +142,88 @@ const runRetry = (retry: FatalScreenViewProps["retry"], source: string) => () =>
|
|
|
55
142
|
* The fatal screen: what went wrong and "Try again", for the whole app, one screen, or (with
|
|
56
143
|
* `kind="plain"`) the last resort that needs nothing above it.
|
|
57
144
|
*/
|
|
58
|
-
export function FatalScreen({ error, retry, kind = "app" }: FatalScreenViewProps) {
|
|
145
|
+
export function FatalScreen({ error, retry, kind = "app", contact, onReport, labels: given }: FatalScreenViewProps) {
|
|
146
|
+
const blocks = useOptionalBlocks();
|
|
147
|
+
const labels = { ...DEFAULT_FATAL_SCREEN_LABELS, ...given };
|
|
148
|
+
const href = contactHref(contact);
|
|
59
149
|
if (kind === "plain") {
|
|
60
150
|
return (
|
|
61
151
|
<View testID="genesis-fatal-plain" style={{ flex: 1, justifyContent: "center", alignItems: "center", padding: 24, gap: 12 }}>
|
|
62
152
|
<Text accessibilityRole="header" style={{ fontSize: 17, fontWeight: "600" }}>
|
|
63
|
-
|
|
153
|
+
{labels.title}
|
|
64
154
|
</Text>
|
|
65
|
-
<Text style={{ textAlign: "center" }}>{errorDetails(error) ??
|
|
155
|
+
<Text style={{ textAlign: "center" }}>{errorDetails(error) ?? labels.plainBody}</Text>
|
|
66
156
|
<Pressable accessibilityRole="button" onPress={() => void retry()} testID="genesis-fatal-plain-retry" style={{ padding: 12 }}>
|
|
67
|
-
<Text style={{ fontSize: 17 }}>
|
|
157
|
+
<Text style={{ fontSize: 17 }}>{labels.retry}</Text>
|
|
68
158
|
</Pressable>
|
|
159
|
+
{href ? (
|
|
160
|
+
<Pressable accessibilityRole="link" onPress={openContact(href)} testID="genesis-fatal-plain-contact" style={{ padding: 12 }}>
|
|
161
|
+
<Text style={{ fontSize: 15 }}>{labels.contact}</Text>
|
|
162
|
+
</Pressable>
|
|
163
|
+
) : null}
|
|
69
164
|
</View>
|
|
70
165
|
);
|
|
71
166
|
}
|
|
72
167
|
const screen = kind === "screen";
|
|
168
|
+
const report = onReport === undefined ? blockReporter(blocks?.blocks) : onReport;
|
|
169
|
+
const onReportPress = report
|
|
170
|
+
? () => {
|
|
171
|
+
// The app's screens are gone behind the fatal screen: bring them back, then open the form.
|
|
172
|
+
if (!screen) void Promise.resolve(retry()).catch((e: unknown) => reportError(e, "native:fatal-retry"));
|
|
173
|
+
try {
|
|
174
|
+
report(error, { kind: screen ? "screen" : "app" });
|
|
175
|
+
} catch (e) {
|
|
176
|
+
reportError(e, "native:report-problem");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
: null;
|
|
180
|
+
const secondary =
|
|
181
|
+
href || onReportPress ? (
|
|
182
|
+
<Inline gap="sm" wrap justify="center">
|
|
183
|
+
{onReportPress ? (
|
|
184
|
+
<NativeButton variant="outline" onPress={onReportPress} testID={screen ? "genesis-screen-error-report" : "genesis-fatal-report"}>
|
|
185
|
+
{labels.report}
|
|
186
|
+
</NativeButton>
|
|
187
|
+
) : null}
|
|
188
|
+
{href ? (
|
|
189
|
+
<NativeButton variant="outline" onPress={openContact(href)} testID={screen ? "genesis-screen-error-contact" : "genesis-fatal-contact"}>
|
|
190
|
+
{labels.contact}
|
|
191
|
+
</NativeButton>
|
|
192
|
+
) : null}
|
|
193
|
+
</Inline>
|
|
194
|
+
) : null;
|
|
73
195
|
return (
|
|
74
196
|
<NativeEmptyState
|
|
75
197
|
variant="error"
|
|
76
|
-
title={screen ?
|
|
77
|
-
body={
|
|
78
|
-
screen
|
|
79
|
-
? "The rest of the app still works. Try again, or go back."
|
|
80
|
-
: "The app hit a problem. Try again, and if it keeps happening, close and reopen the app."
|
|
81
|
-
}
|
|
198
|
+
title={screen ? labels.screenTitle : labels.title}
|
|
199
|
+
body={screen ? labels.screenBody : labels.body}
|
|
82
200
|
details={errorDetails(error)}
|
|
83
201
|
primaryAction={
|
|
84
202
|
<NativeButton
|
|
85
203
|
onPress={screen ? runRetry(retry, "native:screen-retry") : () => void retry()}
|
|
86
204
|
testID={screen ? "genesis-screen-error-retry" : "genesis-fatal-retry"}
|
|
87
205
|
>
|
|
88
|
-
|
|
206
|
+
{labels.retry}
|
|
89
207
|
</NativeButton>
|
|
90
208
|
}
|
|
209
|
+
{...(secondary ? { secondaryAction: secondary } : {})}
|
|
91
210
|
testID={screen ? "genesis-screen-error" : "genesis-fatal"}
|
|
92
211
|
/>
|
|
93
212
|
);
|
|
94
213
|
}
|
|
95
214
|
|
|
215
|
+
/**
|
|
216
|
+
* The first block that takes a problem report (the support block's "Report this"), read now: the
|
|
217
|
+
* function itself is kept, so a setting that changes before the press can't leave it undefined.
|
|
218
|
+
*/
|
|
219
|
+
function blockReporter(blocks: readonly NativeBlock[] | undefined): FatalScreenViewProps["onReport"] {
|
|
220
|
+
for (const block of blocks ?? []) {
|
|
221
|
+
const report = block.reportProblem;
|
|
222
|
+
if (report) return report;
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
96
227
|
/**
|
|
97
228
|
* The last-resort fatal screen.
|
|
98
229
|
*
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,10 @@ export {
|
|
|
34
34
|
FatalScreen,
|
|
35
35
|
type FatalScreenKind,
|
|
36
36
|
type FatalScreenViewProps,
|
|
37
|
+
type FatalScreenContact,
|
|
38
|
+
type FatalScreenLabels,
|
|
39
|
+
DEFAULT_FATAL_SCREEN_LABELS,
|
|
40
|
+
contactHref,
|
|
37
41
|
PlainFatalScreen,
|
|
38
42
|
GenesisErrorBoundary,
|
|
39
43
|
installGlobalErrorHandler,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* (`recent`).
|
|
28
28
|
*/
|
|
29
29
|
import { createContext, useContext, useEffect, useRef, useSyncExternalStore, type ComponentType, type ReactNode } from "react";
|
|
30
|
-
import { defineBlock } from "@marktiderman/genesis-
|
|
30
|
+
import { defineBlock } from "@marktiderman/genesis-config/blocks";
|
|
31
31
|
import { setErrorReporter } from "@marktiderman/genesis-core/errors";
|
|
32
32
|
import { useSession } from "../auth";
|
|
33
33
|
import { onBeforeReload } from "../reload";
|
|
@@ -43,4 +43,4 @@ export {
|
|
|
43
43
|
export { sentrySink, sentryRelease, signatureTags, type SentryLike, type SentrySinkOptions } from "./sentry";
|
|
44
44
|
export { defineEvents, checkEvent, type EventCheck, type EventPropSpec, type EventProps, type EventSchema, type EventValues } from "./events";
|
|
45
45
|
export { ScreenErrorScreen, createScreenErrorBoundary, type ScreenErrorProps } from "../screen-boundary";
|
|
46
|
-
export { FILTERED, isSecretKey, scrubEvent, scrubRecord, scrubString, scrubUrl, scrubValue, type ScrubbableEvent } from "./scrub";
|
|
46
|
+
export { FILTERED, isSecretKey, scrubEvent, scrubRecord, scrubString, scrubUrl, scrubValue, scrubValueStrict, type ScrubbableEvent } from "./scrub";
|
|
@@ -69,6 +69,15 @@ const PATTERNS: readonly [RegExp, string][] = [
|
|
|
69
69
|
// Phone numbers: international (`+1 555 555 0101`) and North American (`555-555-0101`).
|
|
70
70
|
[/\+\d[\d\s().-]{6,18}\d/g, "[phone]"],
|
|
71
71
|
[/\b\(?\d{3}\)?[-.\s]\d{3}[-.\s]\d{4}\b/g, "[phone]"],
|
|
72
|
+
// …national numbers in space-separated groups, which start with a trunk 0 (`020 7946 0958`), and
|
|
73
|
+
// international ones without the + (`44 20 7946 0958`: a country code, then two groups of 4).
|
|
74
|
+
// Plain counts, durations and dates (`120 340 560`, `2024 11 19`) don't have either shape.
|
|
75
|
+
[/\b0\d{2,4} \d{3,4} \d{3,4}\b/g, "[phone]"],
|
|
76
|
+
[/\b\d{2,3} \d{1,4} \d{4} \d{4}\b/g, "[phone]"],
|
|
77
|
+
// …and North American numbers with no separator (`5555550101`, `15555550101`): an area code and an
|
|
78
|
+
// exchange that start with 2-9. A whole word only, so a hex id, a longer number or an epoch
|
|
79
|
+
// time (which starts with 1) is left alone.
|
|
80
|
+
[/\b1?[2-9]\d{2}[2-9]\d{6}\b/g, "[phone]"],
|
|
72
81
|
// Long opaque hex runs: API keys, refresh tokens, DSN secrets. Linear: a run starts only after a non-hex character.
|
|
73
82
|
[/(^|[^A-Fa-f0-9])[A-Fa-f0-9]{32,}(?![A-Fa-f0-9])/g, "$1[hex]"],
|
|
74
83
|
];
|
|
@@ -96,10 +105,10 @@ const MAX_DEPTH = 8;
|
|
|
96
105
|
* `"[Truncated]"`. Errors become `{ name, message }`. Header lists
|
|
97
106
|
* (`[["authorization", "…"]]`) are treated like objects.
|
|
98
107
|
*/
|
|
99
|
-
export function scrubValue(value: unknown, key = "", depth = 0, seen: WeakSet<object> = new WeakSet()): unknown {
|
|
108
|
+
export function scrubValue(value: unknown, key = "", depth = 0, seen: WeakSet<object> = new WeakSet(), keepIds = true): unknown {
|
|
100
109
|
if (key && isSecretKey(key)) return value === undefined || value === null || value === "" ? value : FILTERED;
|
|
101
110
|
if (typeof value === "string") {
|
|
102
|
-
if (key && ID_KEY.test(key)) return value;
|
|
111
|
+
if (keepIds && key && ID_KEY.test(key)) return value;
|
|
103
112
|
return URL_KEY.test(key) ? scrubUrl(value) : scrubString(value);
|
|
104
113
|
}
|
|
105
114
|
if (value === null || typeof value !== "object") return value;
|
|
@@ -110,16 +119,25 @@ export function scrubValue(value: unknown, key = "", depth = 0, seen: WeakSet<ob
|
|
|
110
119
|
if (Array.isArray(value)) {
|
|
111
120
|
// A `[name, value]` pair (fetch's header lists): the name decides, as for an object key.
|
|
112
121
|
if (value.length === 2 && typeof value[0] === "string" && isSecretKey(value[0])) return [value[0], FILTERED];
|
|
113
|
-
return value.map((item) => scrubValue(item, "", depth + 1, seen));
|
|
122
|
+
return value.map((item) => scrubValue(item, "", depth + 1, seen, keepIds));
|
|
114
123
|
}
|
|
115
124
|
const out: Record<string, unknown> = {};
|
|
116
125
|
for (const [k, v] of Object.entries(value)) {
|
|
117
126
|
if (DROPPED_KEY.test(k)) continue;
|
|
118
|
-
out[k] = scrubValue(v, k, depth + 1, seen);
|
|
127
|
+
out[k] = scrubValue(v, k, depth + 1, seen, keepIds);
|
|
119
128
|
}
|
|
120
129
|
return out;
|
|
121
130
|
}
|
|
122
131
|
|
|
132
|
+
/**
|
|
133
|
+
* `scrubValue` without the pass for Sentry's own id fields (`release`, `environment`,
|
|
134
|
+
* `event_id`, …): for data that isn't a Sentry envelope (a support dump, an app's own
|
|
135
|
+
* object), where a key named like one can hold anything.
|
|
136
|
+
*/
|
|
137
|
+
export function scrubValueStrict(value: unknown): unknown {
|
|
138
|
+
return scrubValue(value, "", 0, new WeakSet(), false);
|
|
139
|
+
}
|
|
140
|
+
|
|
123
141
|
/** The fields of a Sentry-shaped event `scrubEvent` treats specially. Anything else is scrubbed by value. */
|
|
124
142
|
export interface ScrubbableEvent {
|
|
125
143
|
user?: { id?: unknown; [key: string]: unknown } | null;
|
package/src/push/block.tsx
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import { createContext, useContext, useEffect, useRef, useSyncExternalStore, type ComponentType, type ReactNode } from "react";
|
|
24
24
|
import { View } from "react-native";
|
|
25
25
|
import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
|
|
26
|
-
import { defineBlock } from "@marktiderman/genesis-
|
|
26
|
+
import { defineBlock } from "@marktiderman/genesis-config/blocks";
|
|
27
27
|
import { useSession } from "../auth";
|
|
28
28
|
import type { NativeBlock, NativeBlockRootProps } from "../blocks";
|
|
29
29
|
import type { BootStep } from "../boot";
|
package/src/screen-boundary.tsx
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { useEffect, useMemo, useRef, type ComponentType, type ReactNode } from "react";
|
|
21
21
|
import { reportError } from "@marktiderman/genesis-core/errors";
|
|
22
|
-
import { FatalScreen, GenesisErrorBoundary, type ErrorReport, type FatalScreenProps, type OnError } from "./errors";
|
|
22
|
+
import { FatalScreen, GenesisErrorBoundary, type ErrorReport, type FatalScreenContact, type FatalScreenLabels, type FatalScreenProps, type OnError } from "./errors";
|
|
23
23
|
|
|
24
24
|
/** What Expo Router gives a route's `ErrorBoundary`: the error, and `retry` to render the route again. */
|
|
25
25
|
export interface ScreenErrorProps {
|
|
@@ -48,6 +48,10 @@ export interface ScreenErrorBoundaryOptions {
|
|
|
48
48
|
onError?: OnError;
|
|
49
49
|
/** Wrappers around the route boundary, innermost first (Sentry's `wrapExpoRouterErrorBoundary`). */
|
|
50
50
|
wrap?: readonly ((boundary: ComponentType<ScreenErrorProps>) => ComponentType<ScreenErrorProps>)[];
|
|
51
|
+
/** "Contact support" on the default fallback (support's `support.contact()`), read when it shows. */
|
|
52
|
+
contact?: FatalScreenContact | (() => FatalScreenContact | null) | null;
|
|
53
|
+
/** The default fallback's words ("Contact support", "Report this"…), in English by default. */
|
|
54
|
+
labels?: Partial<FatalScreenLabels>;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
/**
|
|
@@ -57,7 +61,14 @@ export interface ScreenErrorBoundaryOptions {
|
|
|
57
61
|
* @stability Beta
|
|
58
62
|
*/
|
|
59
63
|
export function createScreenErrorBoundary(options: ScreenErrorBoundaryOptions = {}): ComponentType<ScreenErrorProps> {
|
|
60
|
-
const
|
|
64
|
+
const { contact, labels } = options;
|
|
65
|
+
const Fallback =
|
|
66
|
+
options.fallback ??
|
|
67
|
+
(contact || labels
|
|
68
|
+
? (props: ScreenErrorProps) => (
|
|
69
|
+
<FatalScreen {...props} kind="screen" contact={typeof contact === "function" ? contact() : (contact ?? null)} {...(labels ? { labels } : {})} />
|
|
70
|
+
)
|
|
71
|
+
: ScreenFallback);
|
|
61
72
|
const onError = options.onError ?? reportThroughCore;
|
|
62
73
|
function GenesisScreenErrorBoundary(props: ScreenErrorProps) {
|
|
63
74
|
const reported = useRef<Error | null>(null);
|
package/src/updates/block.tsx
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import { createContext, useContext, useEffect, useMemo, useState, useSyncExternalStore, type ComponentType, type ReactNode } from "react";
|
|
22
22
|
import { View } from "react-native";
|
|
23
23
|
import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
|
|
24
|
-
import { defineBlock } from "@marktiderman/genesis-
|
|
24
|
+
import { defineBlock } from "@marktiderman/genesis-config/blocks";
|
|
25
25
|
import type { NativeBlock } from "../blocks";
|
|
26
26
|
import { createUpdateChecker, createReloadGuard, type ReloadGuard, type UpdateChecker, type UpdateCheckState } from "./checker";
|
|
27
27
|
import { createChannelSwitcher, type ChannelSwitcher } from "./channels";
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
type UpdatePolicySource,
|
|
38
38
|
type UpdateVerdict,
|
|
39
39
|
} from "./policy";
|
|
40
|
-
import { versionSignature, type VersionSignature } from "./signature";
|
|
40
|
+
import { versionSignature, type BuildMetadata, type VersionSignature } from "./signature";
|
|
41
41
|
import { createWhatsNewStore, type WhatsNewState, type WhatsNewStore } from "./whats-new";
|
|
42
42
|
import {
|
|
43
43
|
ForceUpgradeScreen,
|
|
@@ -70,6 +70,8 @@ export interface UpdatesOptions {
|
|
|
70
70
|
application?: ApplicationLike;
|
|
71
71
|
/** `expo-updates`. Without it (or with updates off), no banner and no channel switching. */
|
|
72
72
|
updates?: UpdatesModuleLike;
|
|
73
|
+
/** The commit, OTA number and release the app stamped at publish time: shown in the signature. */
|
|
74
|
+
buildMetadata?: BuildMetadata | null;
|
|
73
75
|
/** Min versions, maintenance and notes. Without it, only `notes` and the banner. */
|
|
74
76
|
policy?: UpdatePolicySource;
|
|
75
77
|
/** AsyncStorage: the policy cache, the version whose notes were seen, the picked channel. */
|
|
@@ -176,7 +178,7 @@ export function createUpdates(options: UpdatesOptions): UpdatesBlock {
|
|
|
176
178
|
reloadScreenOptions,
|
|
177
179
|
onError,
|
|
178
180
|
});
|
|
179
|
-
const signature = versionSignature({ application, updates, platform });
|
|
181
|
+
const signature = versionSignature({ application, updates, platform, buildMetadata: options.buildMetadata ?? null });
|
|
180
182
|
|
|
181
183
|
const allNotes = (): ReleaseNote[] => [...(options.notes ?? []), ...(policy.getState().policy?.notes ?? [])];
|
|
182
184
|
const syncNotes = () => {
|
|
@@ -380,8 +382,8 @@ function useVersionSignatureOf(block: UpdatesBlock): VersionSignature {
|
|
|
380
382
|
}, [block]);
|
|
381
383
|
return useMemo(() => {
|
|
382
384
|
if (!requested) return block.signature;
|
|
383
|
-
const { application, updates, platform } = block.options;
|
|
384
|
-
return versionSignature({ application, updates, platform, requestedChannel: requested });
|
|
385
|
+
const { application, updates, platform, buildMetadata } = block.options;
|
|
386
|
+
return versionSignature({ application, updates, platform, requestedChannel: requested, buildMetadata: buildMetadata ?? null });
|
|
385
387
|
}, [block, requested]);
|
|
386
388
|
}
|
|
387
389
|
|
package/src/updates/index.ts
CHANGED
|
@@ -74,7 +74,7 @@ export {
|
|
|
74
74
|
type UpdateCheckStatus,
|
|
75
75
|
} from "./checker";
|
|
76
76
|
export { createWhatsNewStore, notesSince, type WhatsNewOptions, type WhatsNewState, type WhatsNewStore } from "./whats-new";
|
|
77
|
-
export { versionSignature, type VersionSignature, type VersionSignatureInput } from "./signature";
|
|
77
|
+
export { versionSignature, type BuildMetadata, type VersionSignature, type VersionSignatureInput } from "./signature";
|
|
78
78
|
export { createChannelSwitcher, type ChannelSwitcher, type ChannelSwitcherOptions, type ChannelSwitchResult } from "./channels";
|
|
79
79
|
export { compareVersions, isBelowMinimum, parseVersion } from "./version";
|
|
80
80
|
export type {
|
package/src/updates/signature.ts
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
* (an empty string counts as not given: expo-updates gives `""` for the
|
|
11
11
|
* runtime version in a development build); one that doesn't apply, with
|
|
12
12
|
* updates off, as `none`.
|
|
13
|
+
*
|
|
14
|
+
* With `buildMetadata` (a module the app writes at publish time: the commit,
|
|
15
|
+
* the OTA number, the release), the signature also carries `commit`,
|
|
16
|
+
* `otaNumber` and `release`, and the text names them. Without it they are
|
|
17
|
+
* null and the text is as before.
|
|
13
18
|
*/
|
|
14
19
|
import type { ApplicationLike, UpdatesModuleLike } from "./modules";
|
|
15
20
|
|
|
@@ -27,18 +32,51 @@ export interface VersionSignature {
|
|
|
27
32
|
launch: "update" | "embedded" | "off";
|
|
28
33
|
/** expo-updates fell back to the embedded code after a failed launch. */
|
|
29
34
|
emergency: boolean;
|
|
35
|
+
/** The commit the bundle was built from (`buildMetadata`), or null. Optional for signatures made by hand. */
|
|
36
|
+
commit?: string | null;
|
|
37
|
+
/** The OTA number (`buildMetadata`), or null. */
|
|
38
|
+
otaNumber?: string | null;
|
|
39
|
+
/** The release's name (`buildMetadata`), or null. */
|
|
40
|
+
release?: string | null;
|
|
41
|
+
/** When it was built (`buildMetadata`), ISO, or null. */
|
|
42
|
+
builtAt?: string | null;
|
|
30
43
|
/** One line, for an About row. */
|
|
31
44
|
short: string;
|
|
32
45
|
/** Several lines, for a support report. */
|
|
33
46
|
text: string;
|
|
34
47
|
}
|
|
35
48
|
|
|
49
|
+
/**
|
|
50
|
+
* What the app stamps into its bundle when it publishes (a generated `build-metadata.ts` or JSON):
|
|
51
|
+
* every field optional.
|
|
52
|
+
*/
|
|
53
|
+
export interface BuildMetadata {
|
|
54
|
+
/** The app's version at build time (`genesis build-stamp`). */
|
|
55
|
+
version?: string | null;
|
|
56
|
+
/** The channel it was built or published for. */
|
|
57
|
+
channel?: string | null;
|
|
58
|
+
/** When it was built, ISO. */
|
|
59
|
+
builtAt?: string | null;
|
|
60
|
+
/** The commit the bundle was built from, full or short. */
|
|
61
|
+
commit?: string | null;
|
|
62
|
+
commitMessage?: string | null;
|
|
63
|
+
branch?: string | null;
|
|
64
|
+
/** The over-the-air update's number on its channel. */
|
|
65
|
+
otaNumber?: string | number | null;
|
|
66
|
+
/** The release's name (a tag, a date, a version). */
|
|
67
|
+
release?: string | null;
|
|
68
|
+
/** When the release or update was published, ISO. */
|
|
69
|
+
publishedAt?: string | null;
|
|
70
|
+
}
|
|
71
|
+
|
|
36
72
|
export interface VersionSignatureInput {
|
|
37
73
|
application?: ApplicationLike;
|
|
38
74
|
updates?: UpdatesModuleLike;
|
|
39
75
|
/** `Platform.OS`. */
|
|
40
76
|
platform: string;
|
|
41
77
|
requestedChannel?: string | null;
|
|
78
|
+
/** The commit, OTA number and release the app stamped at publish time. */
|
|
79
|
+
buildMetadata?: BuildMetadata | null;
|
|
42
80
|
}
|
|
43
81
|
|
|
44
82
|
const UNKNOWN = "unknown";
|
|
@@ -46,8 +84,10 @@ const UNKNOWN = "unknown";
|
|
|
46
84
|
/** A module's value, or null when it gave none (undefined, null or an empty string). */
|
|
47
85
|
const given = (value: string | null | undefined): string | null => (typeof value === "string" && value.trim() !== "" ? value : null);
|
|
48
86
|
|
|
49
|
-
|
|
50
|
-
|
|
87
|
+
const metaText = (value: string | number | null | undefined): string | null => (typeof value === "number" && Number.isFinite(value) ? String(value) : given(typeof value === "string" ? value : null));
|
|
88
|
+
|
|
89
|
+
export function versionSignature({ application, updates, platform, requestedChannel = null, buildMetadata = null }: VersionSignatureInput): VersionSignature {
|
|
90
|
+
const version = given(application?.nativeApplicationVersion) ?? metaText(buildMetadata?.version);
|
|
51
91
|
const build = given(application?.nativeBuildVersion);
|
|
52
92
|
const on = Boolean(updates?.isEnabled);
|
|
53
93
|
const channel = on ? given(updates?.channel) : null;
|
|
@@ -76,5 +116,14 @@ export function versionSignature({ application, updates, platform, requestedChan
|
|
|
76
116
|
`Update ${launch === "off" ? "updates off" : launch === "embedded" ? "embedded" : (updateId ?? UNKNOWN)}`,
|
|
77
117
|
];
|
|
78
118
|
if (emergency) lines.push(`Emergency launch: ${updates?.emergencyLaunchReason ?? UNKNOWN}`);
|
|
79
|
-
|
|
119
|
+
const commit = metaText(buildMetadata?.commit);
|
|
120
|
+
const otaNumber = metaText(buildMetadata?.otaNumber);
|
|
121
|
+
const release = metaText(buildMetadata?.release);
|
|
122
|
+
if (commit) lines.push(`Commit ${commit}`);
|
|
123
|
+
if (otaNumber) lines.push(`OTA ${otaNumber}`);
|
|
124
|
+
if (release) lines.push(`Release ${release}`);
|
|
125
|
+
const builtAt = metaText(buildMetadata?.builtAt);
|
|
126
|
+
const builtFor = metaText(buildMetadata?.channel);
|
|
127
|
+
if (builtAt || builtFor) lines.push(`Built ${builtAt ?? UNKNOWN}${builtFor ? ` for ${builtFor}` : ""}`);
|
|
128
|
+
return { version, build, platform, channel, requestedChannel, runtimeVersion, updateId, launch, emergency, commit, otaNumber, release, builtAt, short, text: lines.join("\n") };
|
|
80
129
|
}
|
package/dist/chunk-65P7RU4V.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
// src/blocks.tsx
|
|
4
|
-
function reportToBlocks(blocks, error, report) {
|
|
5
|
-
for (const block of blocks) {
|
|
6
|
-
if (!block.onError) continue;
|
|
7
|
-
try {
|
|
8
|
-
block.onError(error, report);
|
|
9
|
-
} catch {
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
var BlocksContext = createContext(null);
|
|
14
|
-
var BlocksProvider = BlocksContext.Provider;
|
|
15
|
-
function useBlocks() {
|
|
16
|
-
const blocks = useContext(BlocksContext);
|
|
17
|
-
if (!blocks) throw new Error("useBlocks: no blocks. Render inside <GenesisNativeApp>.");
|
|
18
|
-
return blocks;
|
|
19
|
-
}
|
|
20
|
-
function useBlockSettings(sections, options = {}) {
|
|
21
|
-
const blocks = useContext(BlocksContext);
|
|
22
|
-
const rows = blocks?.settings ?? [];
|
|
23
|
-
const subtitles = rows.map((row) => row.useSubtitle?.());
|
|
24
|
-
return mergeBlockSettings(sections, rows, subtitles, options);
|
|
25
|
-
}
|
|
26
|
-
function mergeBlockSettings(sections, rows, subtitles = [], options = {}) {
|
|
27
|
-
const out = sections.map((s) => ({ ...s, rows: [...s.rows] }));
|
|
28
|
-
rows.forEach((row, i) => {
|
|
29
|
-
let section = out.find((s) => s.id === row.section);
|
|
30
|
-
if (!section) {
|
|
31
|
-
section = { id: row.section, title: options.sectionTitles?.[row.section] ?? row.section, rows: [] };
|
|
32
|
-
out.push(section);
|
|
33
|
-
}
|
|
34
|
-
const { navigate } = options;
|
|
35
|
-
const href = row.href;
|
|
36
|
-
section.rows.push({
|
|
37
|
-
id: row.id,
|
|
38
|
-
title: row.title,
|
|
39
|
-
subtitle: subtitles[i] ?? row.subtitle,
|
|
40
|
-
testID: row.testID,
|
|
41
|
-
...href && navigate ? { showChevron: true, onPress: () => navigate(href) } : {}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
return out;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { BlocksProvider, mergeBlockSettings, reportToBlocks, useBlockSettings, useBlocks };
|
|
48
|
-
//# sourceMappingURL=chunk-65P7RU4V.js.map
|
|
49
|
-
//# sourceMappingURL=chunk-65P7RU4V.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/blocks.tsx"],"names":[],"mappings":";;;AA0CO,SAAS,cAAA,CAAe,MAAA,EAAgC,KAAA,EAAc,MAAA,EAA2B;AACtG,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,IAAI,CAAC,MAAM,OAAA,EAAS;AACpB,IAAA,IAAI;AACF,MAAA,KAAA,CAAM,OAAA,CAAQ,OAAO,MAAM,CAAA;AAAA,IAC7B,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACF;AAEA,IAAM,aAAA,GAAgB,cAAkD,IAAI,CAAA;AAGrE,IAAM,iBAAiB,aAAA,CAAc;AAQrC,SAAS,SAAA,GAAyC;AACvD,EAAA,MAAM,MAAA,GAAS,WAAW,aAAa,CAAA;AACvC,EAAA,IAAI,CAAC,MAAA,EAAQ,MAAM,IAAI,MAAM,yDAAyD,CAAA;AACtF,EAAA,OAAO,MAAA;AACT;AAuCO,SAAS,gBAAA,CACd,QAAA,EACA,OAAA,GAAmC,EAAC,EACS;AAC7C,EAAA,MAAM,MAAA,GAAS,WAAW,aAAa,CAAA;AACvC,EAAA,MAAM,IAAA,GAAO,MAAA,EAAQ,QAAA,IAAY,EAAC;AAElC,EAAA,MAAM,YAAY,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,KAAQ,GAAA,CAAI,eAAe,CAAA;AACvD,EAAA,OAAO,kBAAA,CAAmB,QAAA,EAAU,IAAA,EAAM,SAAA,EAAW,OAAO,CAAA;AAC9D;AAGO,SAAS,kBAAA,CACd,UACA,IAAA,EACA,SAAA,GAAoD,EAAC,EACrD,OAAA,GAAmC,EAAC,EACS;AAC7C,EAAA,MAAM,GAAA,GAAmD,QAAA,CAAS,GAAA,CAAI,CAAC,OAAO,EAAE,GAAG,CAAA,EAAG,IAAA,EAAM,CAAC,GAAG,CAAA,CAAE,IAAI,GAAE,CAAE,CAAA;AAC1G,EAAA,IAAA,CAAK,OAAA,CAAQ,CAAC,GAAA,EAAK,CAAA,KAAM;AACvB,IAAA,IAAI,OAAA,GAAU,IAAI,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,EAAA,KAAO,IAAI,OAAO,CAAA;AAClD,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,OAAA,GAAU,EAAE,EAAA,EAAI,GAAA,CAAI,OAAA,EAAS,OAAO,OAAA,CAAQ,aAAA,GAAgB,GAAA,CAAI,OAAO,CAAA,IAAK,GAAA,CAAI,OAAA,EAAS,IAAA,EAAM,EAAC,EAAE;AAClG,MAAA,GAAA,CAAI,KAAK,OAAO,CAAA;AAAA,IAClB;AACA,IAAA,MAAM,EAAE,UAAS,GAAI,OAAA;AACrB,IAAA,MAAM,OAAO,GAAA,CAAI,IAAA;AACjB,IAAA,OAAA,CAAQ,KAAK,IAAA,CAAK;AAAA,MAChB,IAAI,GAAA,CAAI,EAAA;AAAA,MACR,OAAO,GAAA,CAAI,KAAA;AAAA,MACX,QAAA,EAAU,SAAA,CAAU,CAAC,CAAA,IAAK,GAAA,CAAI,QAAA;AAAA,MAC9B,QAAQ,GAAA,CAAI,MAAA;AAAA,MACZ,GAAI,IAAA,IAAQ,QAAA,GAAW,EAAE,WAAA,EAAa,IAAA,EAAM,OAAA,EAAS,MAAM,QAAA,CAAS,IAAI,CAAA,EAAE,GAAI;AAAC,KAChF,CAAA;AAAA,EACH,CAAC,CAAA;AACD,EAAA,OAAO,GAAA;AACT","file":"chunk-65P7RU4V.js","sourcesContent":["/**\n * Blocks on native: `defineBlock` declarations (from\n * `@marktiderman/genesis-features/blocks`) with the two things only a native\n * shell can run, boot steps behind the splash and a root around the screens.\n * `<GenesisNativeApp blocks={[…]}>` resolves them once, runs their steps,\n * mounts their roots, puts their slot fills under the app's own `slots`, and\n * hands their Settings rows to `useBlockSettings`.\n */\nimport { createContext, useContext, type ComponentType, type ReactNode } from \"react\";\nimport type { SlotPropsFor, Slots } from \"@marktiderman/genesis-core/slots\";\nimport type { BlockDef, BlockSettingsRow, Contributed, ResolvedBlocks } from \"@marktiderman/genesis-features/blocks\";\nimport type { BootStep } from \"./boot\";\nimport type { ErrorReport } from \"./errors\";\nimport type { NativeAppSlots } from \"./app\";\n\n/** What a block's `Root` is given: the app's slots, with every block's fills merged under them. @stability Beta */\nexport interface NativeBlockRootProps {\n slots?: Slots<NativeAppSlots>;\n slotProps?: SlotPropsFor<NativeAppSlots>;\n children?: ReactNode;\n}\n\n/**\n * A block a native shell can run. `contributes.slots` fills `GenesisNativeApp`\n * slots by name (the app's own `slots` win).\n *\n * @stability Beta\n */\nexport interface NativeBlock<Id extends string = string> extends BlockDef<Id, ComponentType<never>> {\n /** Run behind the splash after the app's own `steps`, before the session. A step that fails fails the boot, so keep them bounded. */\n readonly bootSteps?: readonly BootStep[];\n /** Mounted around the screens, inside the shell's error boundary. The first block's root is the outermost. */\n readonly Root?: ComponentType<NativeBlockRootProps>;\n /**\n * Every error the shell catches (render, global, boot, rejection), before\n * the app's own `onError`. The observability block reports them here. A\n * throw is ignored.\n */\n readonly onError?: (error: Error, report: ErrorReport) => void;\n}\n\n/** @internal Hand an error to each block's `onError`; one that throws never stops the rest. */\nexport function reportToBlocks(blocks: readonly NativeBlock[], error: Error, report: ErrorReport): void {\n for (const block of blocks) {\n if (!block.onError) continue;\n try {\n block.onError(error, report);\n } catch {\n // A failing reporter must not take the error path down with it.\n }\n }\n}\n\nconst BlocksContext = createContext<ResolvedBlocks<NativeBlock> | null>(null);\n\n/** @internal Provided by GenesisNativeApp. */\nexport const BlocksProvider = BlocksContext.Provider;\n\n/**\n * The resolved blocks: their ids, nav entries, Settings rows, routes and the\n * rest, each tagged with its FeatureId. Throws outside `GenesisNativeApp`.\n *\n * @stability Beta\n */\nexport function useBlocks(): ResolvedBlocks<NativeBlock> {\n const blocks = useContext(BlocksContext);\n if (!blocks) throw new Error(\"useBlocks: no blocks. Render inside <GenesisNativeApp>.\");\n return blocks;\n}\n\n/** A Settings section as `SettingsPage` from `@marktiderman/genesis-ui-native` takes it. @stability Beta */\nexport interface BlockSettingsSection<R extends { id: string; title: string } = SettingsRowLike> {\n id: string;\n title?: string;\n footnote?: string;\n rows: R[];\n}\n\n/** The row fields a block can fill. @stability Beta */\nexport interface SettingsRowLike {\n id: string;\n title: string;\n subtitle?: string;\n showChevron?: boolean;\n onPress?: () => void;\n testID?: string;\n}\n\n/** @stability Beta */\nexport interface UseBlockSettingsOptions {\n /** Open a row's `href` (expo-router's `router.push`). Without it, rows with an `href` aren't pressable. */\n navigate?: (href: string) => void;\n /** Titles for sections a block names that `sections` doesn't have. Default the section id. */\n sectionTitles?: Readonly<Record<string, string>>;\n}\n\n/**\n * The app's Settings sections with every block's rows added: each row goes\n * at the end of the section its `section` names (by `order`, then block\n * order), and a section no one has yet is added after the rest.\n *\n * Calls each row's `useSubtitle` hook, so call it unconditionally at the top\n * of the Settings screen. The blocks are fixed for the life of the app, so\n * the hooks run in the same order on every render.\n *\n * @stability Beta\n */\nexport function useBlockSettings<R extends SettingsRowLike>(\n sections: readonly BlockSettingsSection<R>[],\n options: UseBlockSettingsOptions = {},\n): BlockSettingsSection<R | SettingsRowLike>[] {\n const blocks = useContext(BlocksContext);\n const rows = blocks?.settings ?? [];\n // The same hooks in the same order every render: `rows` never changes once the shell has resolved it.\n const subtitles = rows.map((row) => row.useSubtitle?.());\n return mergeBlockSettings(sections, rows, subtitles, options);\n}\n\n/** The merge `useBlockSettings` does, without hooks (subtitles already read). @stability Beta */\nexport function mergeBlockSettings<R extends SettingsRowLike>(\n sections: readonly BlockSettingsSection<R>[],\n rows: readonly Contributed<BlockSettingsRow>[],\n subtitles: readonly (string | null | undefined)[] = [],\n options: UseBlockSettingsOptions = {},\n): BlockSettingsSection<R | SettingsRowLike>[] {\n const out: BlockSettingsSection<R | SettingsRowLike>[] = sections.map((s) => ({ ...s, rows: [...s.rows] }));\n rows.forEach((row, i) => {\n let section = out.find((s) => s.id === row.section);\n if (!section) {\n section = { id: row.section, title: options.sectionTitles?.[row.section] ?? row.section, rows: [] };\n out.push(section);\n }\n const { navigate } = options;\n const href = row.href;\n section.rows.push({\n id: row.id,\n title: row.title,\n subtitle: subtitles[i] ?? row.subtitle,\n testID: row.testID,\n ...(href && navigate ? { showChevron: true, onPress: () => navigate(href) } : {}),\n });\n });\n return out;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updates/signature.ts"],"names":[],"mappings":";AA2CA,IAAM,OAAA,GAAU,SAAA;AAGhB,IAAM,KAAA,GAAQ,CAAC,KAAA,KAAqD,OAAO,KAAA,KAAU,YAAY,KAAA,CAAM,IAAA,EAAK,KAAM,EAAA,GAAK,KAAA,GAAQ,IAAA;AAExH,SAAS,iBAAiB,EAAE,WAAA,EAAa,SAAS,QAAA,EAAU,gBAAA,GAAmB,MAAK,EAA4C;AACrI,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,WAAA,EAAa,wBAAwB,CAAA;AAC3D,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,WAAA,EAAa,kBAAkB,CAAA;AACnD,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,OAAA,EAAS,SAAS,CAAA;AACrC,EAAA,MAAM,OAAA,GAAU,EAAA,GAAK,KAAA,CAAM,OAAA,EAAS,OAAO,CAAA,GAAI,IAAA;AAC/C,EAAA,MAAM,QAAA,GAAW,EAAA,GAAK,KAAA,CAAM,OAAA,EAAS,QAAQ,CAAA,GAAI,IAAA;AACjD,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,OAAA,EAAS,cAAc,CAAA;AACpD,EAAA,MAAM,SAAqC,CAAC,EAAA,GAAK,KAAA,GAAQ,OAAA,EAAS,mBAAmB,UAAA,GAAa,QAAA;AAClG,EAAA,MAAM,SAAA,GAAY,EAAA,IAAM,OAAA,EAAS,iBAAA,KAAsB,IAAA;AACvD,EAAA,MAAM,eAAe,gBAAA,IAAoB,OAAA;AAEzC,EAAA,MAAM,OAAO,CAAA,EAAG,OAAA,IAAW,OAAO,CAAA,EAAA,EAAK,SAAS,OAAO,CAAA,CAAA,CAAA;AACvD,EAAA,MAAM,KAAA,GAAQ,CAAC,IAAI,CAAA;AACnB,EAAA,IAAI,WAAW,KAAA,EAAO;AACpB,IAAA,KAAA,CAAM,KAAK,aAAa,CAAA;AAAA,EAC1B,CAAA,MAAO;AACL,IAAA,KAAA,CAAM,IAAA,CAAK,gBAAgB,YAAY,CAAA;AACvC,IAAA,KAAA,CAAM,IAAA,CAAK,WAAW,UAAA,GAAa,UAAA,GAAc,UAAU,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,IAAK,OAAQ,CAAA;AAAA,EACpF;AACA,EAAA,IAAI,SAAA,EAAW,KAAA,CAAM,IAAA,CAAK,kBAAkB,CAAA;AAC5C,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,IAAA,CAAK,QAAK,CAAA;AAE9B,EAAA,MAAM,KAAA,GAAQ;AAAA,IACZ,WAAW,IAAI,CAAA,CAAA;AAAA,IACf,YAAY,QAAQ,CAAA,CAAA;AAAA,IACpB,CAAA,QAAA,EAAW,OAAA,KAAY,EAAA,GAAK,OAAA,GAAU,MAAA,CAAO,CAAA,EAAG,gBAAA,IAAoB,gBAAA,KAAqB,OAAA,GAAU,CAAA,cAAA,EAAiB,gBAAgB,CAAA,CAAA,CAAA,GAAM,EAAE,CAAA,CAAA;AAAA,IAC5I,CAAA,QAAA,EAAW,cAAA,KAAmB,EAAA,GAAK,OAAA,GAAU,MAAA,CAAO,CAAA,CAAA;AAAA,IACpD,CAAA,OAAA,EAAU,WAAW,KAAA,GAAQ,aAAA,GAAgB,WAAW,UAAA,GAAa,UAAA,GAAc,YAAY,OAAQ,CAAA;AAAA,GACzG;AACA,EAAA,IAAI,WAAW,KAAA,CAAM,IAAA,CAAK,qBAAqB,OAAA,EAAS,qBAAA,IAAyB,OAAO,CAAA,CAAE,CAAA;AAC1F,EAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,QAAA,EAAU,SAAS,gBAAA,EAAkB,cAAA,EAAgB,QAAA,EAAU,MAAA,EAAQ,WAAW,KAAA,EAAO,IAAA,EAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA,EAAE;AAC3I","file":"chunk-6BT4PTGH.js","sourcesContent":["/**\n * The version signature: which binary and which update this is, in one\n * line for Settings \"About\" and in a few lines for a support report.\n *\n * 1.4.0 (37) · preview · 3f2a9c1b\n * 1.4.0 (37) · production · embedded\n * 1.4.0 (37) · updates off\n *\n * A value the modules can't give is printed as `unknown`, never left out\n * (an empty string counts as not given: expo-updates gives `\"\"` for the\n * runtime version in a development build); one that doesn't apply, with\n * updates off, as `none`.\n */\nimport type { ApplicationLike, UpdatesModuleLike } from \"./modules\";\n\nexport interface VersionSignature {\n version: string | null;\n build: string | null;\n platform: string;\n /** The build's channel (expo-updates). */\n channel: string | null;\n /** A channel picked on this device (a test build switched channels); `null` when it follows the build. */\n requestedChannel: string | null;\n runtimeVersion: string | null;\n updateId: string | null;\n /** `update`: a downloaded update runs. `embedded`: the binary's own code. `off`: updates are off (development, Expo Go). */\n launch: \"update\" | \"embedded\" | \"off\";\n /** expo-updates fell back to the embedded code after a failed launch. */\n emergency: boolean;\n /** One line, for an About row. */\n short: string;\n /** Several lines, for a support report. */\n text: string;\n}\n\nexport interface VersionSignatureInput {\n application?: ApplicationLike;\n updates?: UpdatesModuleLike;\n /** `Platform.OS`. */\n platform: string;\n requestedChannel?: string | null;\n}\n\nconst UNKNOWN = \"unknown\";\n\n/** A module's value, or null when it gave none (undefined, null or an empty string). */\nconst given = (value: string | null | undefined): string | null => (typeof value === \"string\" && value.trim() !== \"\" ? value : null);\n\nexport function versionSignature({ application, updates, platform, requestedChannel = null }: VersionSignatureInput): VersionSignature {\n const version = given(application?.nativeApplicationVersion);\n const build = given(application?.nativeBuildVersion);\n const on = Boolean(updates?.isEnabled);\n const channel = on ? given(updates?.channel) : null;\n const updateId = on ? given(updates?.updateId) : null;\n const runtimeVersion = given(updates?.runtimeVersion);\n const launch: VersionSignature[\"launch\"] = !on ? \"off\" : updates?.isEmbeddedLaunch ? \"embedded\" : \"update\";\n const emergency = on && updates?.isEmergencyLaunch === true;\n const shownChannel = requestedChannel ?? channel;\n\n const head = `${version ?? UNKNOWN} (${build ?? UNKNOWN})`;\n const parts = [head];\n if (launch === \"off\") {\n parts.push(\"updates off\");\n } else {\n parts.push(shownChannel ?? \"no channel\");\n parts.push(launch === \"embedded\" ? \"embedded\" : (updateId?.slice(0, 8) ?? UNKNOWN));\n }\n if (emergency) parts.push(\"emergency launch\");\n const short = parts.join(\" · \");\n\n const lines = [\n `Version ${head}`,\n `Platform ${platform}`,\n `Channel ${channel ?? (on ? UNKNOWN : \"none\")}${requestedChannel && requestedChannel !== channel ? ` (switched to ${requestedChannel})` : \"\"}`,\n `Runtime ${runtimeVersion ?? (on ? UNKNOWN : \"none\")}`,\n `Update ${launch === \"off\" ? \"updates off\" : launch === \"embedded\" ? \"embedded\" : (updateId ?? UNKNOWN)}`,\n ];\n if (emergency) lines.push(`Emergency launch: ${updates?.emergencyLaunchReason ?? UNKNOWN}`);\n return { version, build, platform, channel, requestedChannel, runtimeVersion, updateId, launch, emergency, short, text: lines.join(\"\\n\") };\n}\n"]}
|