@marktiderman/genesis-native 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +470 -10
  2. package/dist/block-Onqx7NiK.d.ts +223 -0
  3. package/dist/blocks-C2RDpvaN.d.ts +1595 -0
  4. package/dist/chunk-65P7RU4V.js +49 -0
  5. package/dist/chunk-65P7RU4V.js.map +1 -0
  6. package/dist/chunk-6BT4PTGH.js +37 -0
  7. package/dist/chunk-6BT4PTGH.js.map +1 -0
  8. package/dist/chunk-75YP72G6.js +374 -0
  9. package/dist/chunk-75YP72G6.js.map +1 -0
  10. package/dist/chunk-NGYNYJPL.js +90 -0
  11. package/dist/chunk-NGYNYJPL.js.map +1 -0
  12. package/dist/chunk-ONAXQHNG.js +23 -0
  13. package/dist/chunk-ONAXQHNG.js.map +1 -0
  14. package/dist/chunk-VKTIHNAV.js +95 -0
  15. package/dist/chunk-VKTIHNAV.js.map +1 -0
  16. package/dist/{chunk-MMTPWUWI.js → chunk-VTJDIKFC.js} +9 -6
  17. package/dist/chunk-VTJDIKFC.js.map +1 -0
  18. package/dist/chunk-XE7LC7K6.js +29 -0
  19. package/dist/chunk-XE7LC7K6.js.map +1 -0
  20. package/dist/dev-warnings.d.ts +34 -0
  21. package/dist/dev-warnings.js +15 -0
  22. package/dist/dev-warnings.js.map +1 -0
  23. package/dist/devtools.d.ts +144 -0
  24. package/dist/devtools.js +390 -0
  25. package/dist/devtools.js.map +1 -0
  26. package/dist/index.d.ts +12 -368
  27. package/dist/index.js +88 -191
  28. package/dist/index.js.map +1 -1
  29. package/dist/observability.d.ts +170 -0
  30. package/dist/observability.js +123 -0
  31. package/dist/observability.js.map +1 -0
  32. package/dist/persist.d.ts +1 -1
  33. package/dist/persist.js +1 -1
  34. package/dist/push-payload.d.ts +43 -0
  35. package/dist/push-payload.js +3 -0
  36. package/dist/push-payload.js.map +1 -0
  37. package/dist/push.d.ts +187 -0
  38. package/dist/push.js +1069 -0
  39. package/dist/push.js.map +1 -0
  40. package/dist/{query-DhH3lLFa.d.ts → query-DUmVAfsF.d.ts} +11 -6
  41. package/dist/rich-push-plugin.d.ts +74 -0
  42. package/dist/rich-push-plugin.js +209 -0
  43. package/dist/rich-push-plugin.js.map +1 -0
  44. package/dist/updates.d.ts +8 -1
  45. package/dist/updates.js +44 -69
  46. package/dist/updates.js.map +1 -1
  47. package/ios/notification-service/NotificationService.swift +309 -0
  48. package/package.json +238 -5
  49. package/src/app.tsx +491 -0
  50. package/src/auth.tsx +176 -0
  51. package/src/blocks.tsx +144 -0
  52. package/src/boot.tsx +188 -0
  53. package/src/dev-warnings.ts +43 -0
  54. package/src/devtools/block.tsx +488 -0
  55. package/src/devtools/gestures.ts +107 -0
  56. package/src/devtools/index.ts +22 -0
  57. package/src/devtools/info.ts +45 -0
  58. package/src/devtools/slots.ts +21 -0
  59. package/src/errors.tsx +195 -0
  60. package/src/held-link.ts +90 -0
  61. package/src/hydration-gate.ts +88 -0
  62. package/src/index.ts +83 -0
  63. package/src/links.ts +140 -0
  64. package/src/nativewind.d.ts +41 -0
  65. package/src/observability/block.tsx +300 -0
  66. package/src/observability/events.ts +89 -0
  67. package/src/observability/index.ts +44 -0
  68. package/src/observability/scrub.ts +166 -0
  69. package/src/observability/sentry.ts +222 -0
  70. package/src/observability/sink.ts +147 -0
  71. package/src/persist.ts +83 -0
  72. package/src/plugin/rich-push.ts +312 -0
  73. package/src/push/backend.ts +137 -0
  74. package/src/push/block.tsx +604 -0
  75. package/src/push/index.ts +105 -0
  76. package/src/push/modules.ts +123 -0
  77. package/src/push/payload.ts +61 -0
  78. package/src/push/permission.ts +191 -0
  79. package/src/push/preferences.ts +136 -0
  80. package/src/push/quiet-hours.ts +71 -0
  81. package/src/push/registration.ts +225 -0
  82. package/src/push/routing.ts +57 -0
  83. package/src/push/screens.tsx +46 -0
  84. package/src/push/settings.tsx +378 -0
  85. package/src/query.ts +100 -0
  86. package/src/updates/block.tsx +442 -0
  87. package/src/updates/channels.ts +131 -0
  88. package/src/updates/checker.ts +190 -0
  89. package/src/updates/index.ts +87 -0
  90. package/src/updates/modules.ts +64 -0
  91. package/src/updates/policy.ts +314 -0
  92. package/src/updates/screens.tsx +159 -0
  93. package/src/updates/signature.ts +80 -0
  94. package/src/updates/store.ts +33 -0
  95. package/src/updates/version.ts +39 -0
  96. package/src/updates/whats-new.ts +122 -0
  97. package/dist/block-Dh5ny06W.d.ts +0 -535
  98. package/dist/chunk-MMTPWUWI.js.map +0 -1
@@ -0,0 +1,223 @@
1
+ import * as react from 'react';
2
+ import { ComponentType, ReactNode } from 'react';
3
+ import { N as NativeBlock, n as ErrorReport, x as NativeBlockRootProps } from './blocks-C2RDpvaN.js';
4
+
5
+ /**
6
+ * Typed analytics events: the app lists every event and the props each may
7
+ * carry once, and `track(name, props)` accepts nothing else. A prop is a
8
+ * closed list of strings, a number or a boolean, never free text, so an
9
+ * event can't carry a name, an email or a message someone typed.
10
+ *
11
+ * ```ts
12
+ * export const events = defineEvents({
13
+ * "auth.signed_in": { method: ["email", "apple"] },
14
+ * "settings.opened": {},
15
+ * "checkin.saved": { mood: "number", first: "boolean" },
16
+ * });
17
+ * ```
18
+ *
19
+ * At run time an unknown event, an unknown prop or a value outside its list
20
+ * is dropped and reported (a `console.warn` in development, `onInvalid`
21
+ * always), so a bad call is loud and still sends nothing.
22
+ */
23
+ /** A closed list of strings, `"number"` (finite) or `"boolean"`. */
24
+ type EventPropSpec = readonly string[] | "number" | "boolean";
25
+ /** Every event, by name, with the props it may carry. */
26
+ type EventSchema = Readonly<Record<string, Readonly<Record<string, EventPropSpec>>>>;
27
+ type PropValue<S> = S extends readonly (infer L)[] ? L : S extends "number" ? number : S extends "boolean" ? boolean : never;
28
+ /** The props of one event: every prop optional, each its spec's type. */
29
+ type EventProps<S extends Readonly<Record<string, EventPropSpec>>> = {
30
+ readonly [K in keyof S]?: PropValue<S[K]>;
31
+ };
32
+ /** What a sink receives: the checked props. */
33
+ type EventValues = Readonly<Record<string, string | number | boolean>>;
34
+ /**
35
+ * Declare the app's events. Checks names (lower-case, dot-separated), prop
36
+ * names, and that each list has at least one short value, and throws listing
37
+ * every problem, so a bad schema fails where it is written.
38
+ *
39
+ * @stability Beta
40
+ */
41
+ declare function defineEvents<const E extends EventSchema>(schema: E): E;
42
+ type EventCheck = {
43
+ ok: true;
44
+ props: EventValues;
45
+ } | {
46
+ ok: false;
47
+ problem: string;
48
+ };
49
+ /** Check one call against the schema: the props to send, or why nothing is sent. */
50
+ declare function checkEvent(schema: EventSchema, name: string, props: Readonly<Record<string, unknown>> | undefined): EventCheck;
51
+
52
+ /**
53
+ * The vendor-neutral seam: a sink is where errors, breadcrumbs, the user id,
54
+ * analytics events and timings go. `createObservability` fans every call out
55
+ * to its sinks, scrubbed first; a sink that throws is reported to
56
+ * `onSinkError` and never takes the others (or the app) down with it.
57
+ *
58
+ * Shipped sinks: `sentrySink` (Sentry), `observeSink` (EAS Observe) and
59
+ * `consoleSink` (development). A vendor adapter (PostHog, Datadog…) is one
60
+ * object with the methods it supports.
61
+ */
62
+
63
+ /** Where a caught error came from and whether the app could go on. */
64
+ interface ErrorContext {
65
+ /** True when the app could not go on (a render error, a failed boot, a fatal global error). */
66
+ fatal: boolean;
67
+ /** `boundary`, `global`, `boot`, `rejection` (the shell's), or the app's own (`updates:policy`, `sync`). */
68
+ source: string;
69
+ componentStack?: string;
70
+ /** The route pattern on screen (`/(app)/settings`), when known. */
71
+ route?: string | null;
72
+ }
73
+ type BreadcrumbLevel = "debug" | "info" | "warning" | "error";
74
+ /** One step that led up to an error: a navigation, a tap, a request. */
75
+ interface Breadcrumb {
76
+ /** `navigation`, `ui`, `http`, `event`, or the app's own. */
77
+ category: string;
78
+ message?: string;
79
+ level?: BreadcrumbLevel;
80
+ data?: Readonly<Record<string, unknown>>;
81
+ /** Milliseconds since the epoch. Default now. */
82
+ timestamp?: number;
83
+ }
84
+ /** Low-cardinality labels on a timing (`route`, `step`), never ids or text someone typed. */
85
+ type TimingTags = Readonly<Record<string, string>>;
86
+ /**
87
+ * One destination. Every method is optional: a sink takes what its vendor
88
+ * supports. Errors arrive as an `Error` whose message is already scrubbed,
89
+ * unless the sink sets `scrubsErrors` (it scrubs the whole event itself and
90
+ * needs the original object, as Sentry does to deduplicate).
91
+ *
92
+ * @stability Beta
93
+ */
94
+ interface ObservabilitySink {
95
+ readonly name: string;
96
+ /** The sink scrubs error events itself; give it the original `Error`. */
97
+ readonly scrubsErrors?: boolean;
98
+ captureError?(error: Error, context: ErrorContext): void;
99
+ breadcrumb?(crumb: Breadcrumb): void;
100
+ /** The signed-in login's id, or `null` when signed out. Never an email or a name. */
101
+ setUser?(id: string | null): void;
102
+ /** An analytics event, its props checked against the schema. */
103
+ event?(name: string, props: EventValues): void;
104
+ timing?(name: string, ms: number, tags?: TimingTags): void;
105
+ /** Wraps the root layout (Sentry's `wrap`, EAS Observe's `ObserveRoot.wrap`). */
106
+ wrap?<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;
107
+ }
108
+ /** A copy of `error` whose message and stack have been scrubbed (for sinks that don't scrub themselves). */
109
+ declare function scrubbedError(error: Error): Error;
110
+ interface ConsoleSinkOptions {
111
+ /** Default `console`. */
112
+ console?: Pick<Console, "log" | "warn" | "error">;
113
+ /** Also log breadcrumbs (noisy). Default false. */
114
+ breadcrumbs?: boolean;
115
+ }
116
+ /**
117
+ * Logs what would be sent, for development: fatal errors with `console.error`, others with `console.warn`,
118
+ * events and timings with `console.log`. Already scrubbed, so what you read
119
+ * is what a vendor sink would get.
120
+ *
121
+ * @stability Beta
122
+ */
123
+ declare function consoleSink(options?: ConsoleSinkOptions): ObservabilitySink;
124
+ /**
125
+ * `expo-observe`'s `Observe` (SDK 56+), or a stand-in: the calls `observeSink`
126
+ * uses. Pass `import { Observe } from "expo-observe"`.
127
+ */
128
+ interface ObserveLike {
129
+ logEvent(name: string, options?: {
130
+ severity?: "debug" | "info" | "warn" | "error";
131
+ body?: string;
132
+ attributes?: Record<string, unknown>;
133
+ }): void;
134
+ /** Error reporting, in preview on SDK 57+. */
135
+ reportError?(error: unknown): void;
136
+ }
137
+ interface ObserveSinkOptions {
138
+ /** Report caught errors with `Observe.reportError` (in preview). Default false: Sentry is the error tracker. */
139
+ errors?: boolean;
140
+ }
141
+ /**
142
+ * EAS Observe. It measures launch (cold, warm, bundle load, first render),
143
+ * time to interactive and, with its Expo Router integration, per-route
144
+ * render times on its own; it has no API for a custom timing metric, so
145
+ * `timing` is logged as an event (`timing.<name>` with `duration_ms`) and
146
+ * shows on the Events page, not as a metric. Analytics events go to
147
+ * `Observe.logEvent` as they are.
148
+ *
149
+ * @stability Beta
150
+ */
151
+ declare function observeSink(observe: ObserveLike, options?: ObserveSinkOptions): ObservabilitySink;
152
+ /** Breadcrumb data scrubbed and made plain (for sinks and the devtools overlay). */
153
+ declare function scrubBreadcrumb(crumb: Breadcrumb): Breadcrumb;
154
+
155
+ /** The FeatureId of the observability block. */
156
+ declare const OBSERVABILITY_BLOCK_ID = "observability";
157
+ /** A caught error as the devtools overlay shows it (scrubbed). */
158
+ interface RecentError {
159
+ at: number;
160
+ name: string;
161
+ message: string;
162
+ source: string;
163
+ fatal: boolean;
164
+ }
165
+ interface RecentActivity {
166
+ /** Oldest first. Navigation, events and the app's breadcrumbs. */
167
+ breadcrumbs: readonly Breadcrumb[];
168
+ /** Oldest first. */
169
+ errors: readonly RecentError[];
170
+ }
171
+ interface RecentStore {
172
+ getState(): RecentActivity;
173
+ subscribe(listener: () => void): () => void;
174
+ clear(): void;
175
+ }
176
+ interface ObservabilityOptions<E extends EventSchema = EventSchema> {
177
+ /** Where everything goes: `sentrySink(Sentry, …)`, `consoleSink()` in development, `observeSink(Observe)`. */
178
+ sinks: readonly (ObservabilitySink | null | undefined | false)[];
179
+ /** The app's analytics events (`defineEvents`). Without it, `track` accepts nothing. */
180
+ events?: E;
181
+ /** `useSegments` from expo-router: route breadcrumbs and `route.time_on_screen` timings. */
182
+ useSegments?: () => readonly string[];
183
+ /** How many breadcrumbs and errors `recent` keeps. Default 50 and 20. */
184
+ recent?: {
185
+ breadcrumbs?: number;
186
+ errors?: number;
187
+ };
188
+ /** A sink threw, or `track` was called with something the schema doesn't allow. Default `console.warn` in development. */
189
+ onProblem?: (problem: string, error?: unknown) => void;
190
+ now?: () => number;
191
+ }
192
+ interface ObservabilityBlock<E extends EventSchema = EventSchema> extends NativeBlock<typeof OBSERVABILITY_BLOCK_ID> {
193
+ readonly sinks: readonly ObservabilitySink[];
194
+ readonly events: E | undefined;
195
+ /** Report an error. The shell calls it for every error it catches. */
196
+ captureError(error: unknown, context?: Partial<ErrorContext>): void;
197
+ breadcrumb(crumb: Breadcrumb): void;
198
+ /** The login's id only. The block's root sets it from the session. */
199
+ setUser(id: string | null): void;
200
+ /** An analytics event from the schema. Anything else is dropped and reported. */
201
+ track<N extends keyof E & string>(name: N, props?: EventProps<E[N]>): void;
202
+ timing(name: string, ms: number, tags?: TimingTags): void;
203
+ /** The root layout wrapped by each sink that wraps (Sentry's `wrap`). Use once: `export default observability.wrap(RootLayout)`. */
204
+ wrap<P extends Record<string, unknown>>(root: ComponentType<P>): ComponentType<P>;
205
+ /** The last breadcrumbs and errors, scrubbed, for the devtools overlay. */
206
+ readonly recent: RecentStore;
207
+ /** For the shell: every error it catches. */
208
+ readonly onError: (error: Error, report: ErrorReport) => void;
209
+ readonly Root: ComponentType<NativeBlockRootProps>;
210
+ }
211
+ /** Build the block once, at module scope, before the root layout renders. @stability Beta */
212
+ declare function createObservability<const E extends EventSchema = EventSchema>(options: ObservabilityOptions<E>): ObservabilityBlock<E>;
213
+ /** Provides a block to the hooks without its root (rung 4). @stability Beta */
214
+ declare function ObservabilityProvider({ block, children }: {
215
+ block: ObservabilityBlock;
216
+ children?: ReactNode;
217
+ }): react.JSX.Element;
218
+ /** The block, or `null` when it is off (so a screen can call it whether or not the block is on). @stability Beta */
219
+ declare function useObservability(): ObservabilityBlock | null;
220
+ /** The last breadcrumbs and errors, scrubbed; empty when the block is off. @stability Beta */
221
+ declare function useRecentActivity(block?: ObservabilityBlock | null): RecentActivity;
222
+
223
+ export { type Breadcrumb as B, type ConsoleSinkOptions as C, type ErrorContext as E, type ObservabilityBlock as O, type RecentActivity as R, type TimingTags as T, type ObservabilitySink as a, type BreadcrumbLevel as b, type EventCheck as c, type EventPropSpec as d, type EventProps as e, type EventSchema as f, type EventValues as g, OBSERVABILITY_BLOCK_ID as h, type ObservabilityOptions as i, ObservabilityProvider as j, type ObserveLike as k, type ObserveSinkOptions as l, type RecentError as m, type RecentStore as n, checkEvent as o, consoleSink as p, createObservability as q, defineEvents as r, observeSink as s, scrubBreadcrumb as t, scrubbedError as u, useObservability as v, useRecentActivity as w };