@atelic-action/ui 8.0.0 → 8.2.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 (64) hide show
  1. package/README.md +187 -22
  2. package/bin/atelic-check-sentry.ts +5 -0
  3. package/dist/gate/middleware.js +15 -1
  4. package/dist/monitoring/server.d.ts +122 -0
  5. package/dist/monitoring/server.js +302 -0
  6. package/dist/vite/index.d.ts +1 -1
  7. package/dist/vite/index.js +1 -1
  8. package/dist/vite/marketing-config.d.ts +28 -1
  9. package/dist/vite/marketing-config.js +62 -0
  10. package/package.json +10 -2
  11. package/src/app/layout/DesktopRail.tsx +6 -4
  12. package/src/app/layout/MobileMenu.tsx +10 -5
  13. package/src/app/layout/MobileTabBar.tsx +3 -2
  14. package/src/app/layout/PageError.tsx +2 -2
  15. package/src/app/layout/SectionCards.tsx +7 -2
  16. package/src/app/layout/UserMenu.tsx +1 -1
  17. package/src/app/ui/alert.tsx +1 -1
  18. package/src/app/ui/form.tsx +2 -2
  19. package/src/artifact/AppErrorBoundary.tsx +12 -7
  20. package/src/chrome/BrandLockup.tsx +46 -7
  21. package/src/chrome/ContactDock.tsx +59 -13
  22. package/src/chrome/Footer.tsx +97 -28
  23. package/src/chrome/NavMegaPanel.tsx +11 -6
  24. package/src/chrome/SiteHeader.tsx +68 -18
  25. package/src/chrome/SiteMenu.tsx +207 -72
  26. package/src/chrome/SiteShell.tsx +25 -3
  27. package/src/chrome/StickyCTABar.tsx +24 -8
  28. package/src/chrome/index.ts +2 -0
  29. package/src/components/NotFound.tsx +3 -2
  30. package/src/gate/middleware.ts +15 -1
  31. package/src/lib/emailText.tsx +26 -0
  32. package/src/lib/phoneText.tsx +49 -0
  33. package/src/monitoring/ErrorCatcherScript.tsx +26 -0
  34. package/src/monitoring/catcher.ts +118 -0
  35. package/src/monitoring/index.ts +25 -0
  36. package/src/monitoring/sdk.ts +112 -0
  37. package/src/monitoring/server.ts +368 -0
  38. package/src/monitoring/start.ts +118 -0
  39. package/src/primitives/Button.tsx +3 -1
  40. package/src/primitives/Eyebrow.tsx +6 -2
  41. package/src/routing/index.ts +11 -32
  42. package/src/routing/miss.ts +32 -0
  43. package/src/routing/routerErrors.tsx +57 -0
  44. package/src/routing/staticNotFound.tsx +64 -0
  45. package/src/scripts/check-sentry.ts +98 -0
  46. package/src/sections/CalloutPanel.tsx +4 -1
  47. package/src/sections/ContactInfoCard.tsx +1 -1
  48. package/src/sections/FullBleedVideo.tsx +13 -4
  49. package/src/sections/Hero.tsx +10 -3
  50. package/src/sections/LinkColumns.tsx +30 -14
  51. package/src/sections/Locations.tsx +1 -1
  52. package/src/sections/LogoMarquee.tsx +1 -1
  53. package/src/sections/PricingBand.tsx +1 -1
  54. package/src/sections/ProcessSteps.tsx +1 -1
  55. package/src/sections/siteConfig.ts +67 -5
  56. package/src/styles/app.css +9 -0
  57. package/src/styles/base.css +34 -2
  58. package/src/styles/chrome.css +449 -41
  59. package/src/styles/defaults.css +61 -2
  60. package/src/styles/primitives.css +20 -7
  61. package/src/styles/sections.css +52 -9
  62. package/src/types.ts +40 -2
  63. package/src/vite/index.ts +4 -0
  64. package/src/vite/marketing-config.ts +81 -1
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Error reporting on the server: a dependency free Sentry reporter for a
3
+ * Vercel function or middleware. Built to dist/ with the gate (CLAUDE.md,
4
+ * the built corner), since Vercel runs a function's package imports as
5
+ * shipped, so this file imports nothing and touches only what a function and
6
+ * the middleware runtime both have (fetch, `AbortController`, `crypto`).
7
+ *
8
+ * import { reportServerError, reportServerErrorLater, withErrorReporting } from "@atelic-action/ui/monitoring/server";
9
+ *
10
+ * Privacy: a report carries the request's method and path, and its user
11
+ * agent, never its body, its query string, or any other header. A contact
12
+ * form's request holds a person's name, address, and message.
13
+ */
14
+
15
+ /** The parts of a DSN a report is sent with. */
16
+ export interface ParsedDSN {
17
+ /** The public key, sent as `sentry_key`. */
18
+ key: string;
19
+ projectId: string;
20
+ /** Where the envelope is posted. */
21
+ envelopeURL: string;
22
+ }
23
+
24
+ export interface ServerReportOptions {
25
+ /** Defaults to `SENTRY_DSN`, then `VITE_SENTRY_DSN`, from the environment. */
26
+ dsn?: string;
27
+ /** The request being handled; only its method, path, and user agent are read. */
28
+ request?: Request;
29
+ /** Tags beside the runtime's, e.g. `{ route: "contact" }`. */
30
+ tags?: Record<string, string>;
31
+ /** Defaults to `VERCEL_GIT_COMMIT_SHA`. */
32
+ release?: string;
33
+ /** Defaults to `VERCEL_ENV`. */
34
+ environment?: string;
35
+ /** How long the send may take, in milliseconds. Defaults to 2000. */
36
+ timeoutMs?: number;
37
+ }
38
+
39
+ /** One stack frame in Sentry's exception format. */
40
+ export interface SentryFrame {
41
+ function?: string;
42
+ filename?: string;
43
+ lineno?: number;
44
+ colno?: number;
45
+ in_app: boolean;
46
+ }
47
+
48
+ const SDK = { name: "atelic.server", version: "1" };
49
+
50
+ function environmentValue(name: string): string | undefined {
51
+ const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process
52
+ ?.env;
53
+ const value = env?.[name];
54
+ return value === "" ? undefined : value;
55
+ }
56
+
57
+ /**
58
+ * Reads a DSN (`https://<key>@<host>[/<path>]/<project>`) into the URL its
59
+ * envelopes are posted to. Undefined for anything that is not one.
60
+ */
61
+ export function parseDSN(dsn: string | undefined): ParsedDSN | undefined {
62
+ if (!dsn) return undefined;
63
+ let url: URL;
64
+ try {
65
+ url = new URL(dsn);
66
+ } catch {
67
+ return undefined;
68
+ }
69
+ const key = url.username;
70
+ const parts = url.pathname.split("/").filter(Boolean);
71
+ const projectId = parts.pop();
72
+ if (!key || !projectId || !/^\d+$/.test(projectId)) return undefined;
73
+ const prefix = parts.length ? `/${parts.join("/")}` : "";
74
+ const envelopeURL = `${url.protocol}//${url.host}${prefix}/api/${projectId}/envelope/?sentry_key=${encodeURIComponent(key)}&sentry_version=7`;
75
+ return { key, projectId, envelopeURL };
76
+ }
77
+
78
+ /**
79
+ * The frames of a V8 stack (`at fn (file:line:col)`, `at file:line:col`),
80
+ * oldest call first, as Sentry lists them. A frame inside `node_modules` is
81
+ * not the site's own code.
82
+ */
83
+ export function parseStack(stack: string | undefined): SentryFrame[] {
84
+ if (!stack) return [];
85
+ const frames: SentryFrame[] = [];
86
+ for (const line of stack.split("\n")) {
87
+ const match = line.match(/^\s*at (?:(.+?) \()?(.+?):(\d+):(\d+)\)?\s*$/);
88
+ if (!match) continue;
89
+ const [, fn, filename, lineno, colno] = match;
90
+ frames.push({
91
+ ...(fn ? { function: fn } : {}),
92
+ filename,
93
+ lineno: Number(lineno),
94
+ colno: Number(colno),
95
+ in_app: !filename.includes("node_modules"),
96
+ });
97
+ }
98
+ return frames.reverse();
99
+ }
100
+
101
+ /** The runtime a report came from: Vercel's edge, Node, or neither. */
102
+ function runtime(): string {
103
+ if (typeof (globalThis as { EdgeRuntime?: unknown }).EdgeRuntime !== "undefined") return "edge";
104
+ const node = (globalThis as { process?: { versions?: { node?: string } } }).process?.versions
105
+ ?.node;
106
+ return node ? "node" : "unknown";
107
+ }
108
+
109
+ function eventID(): string {
110
+ const random = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto?.randomUUID;
111
+ if (random) return random.call(globalThis.crypto).replaceAll("-", "");
112
+ let id = "";
113
+ for (let i = 0; i < 32; i++) id += Math.floor(Math.random() * 16).toString(16);
114
+ return id;
115
+ }
116
+
117
+ /** The thrown value as Sentry's exception: its type, message, and frames. */
118
+ function exceptionOf(error: unknown) {
119
+ if (error instanceof Error) {
120
+ const frames = parseStack(error.stack);
121
+ return {
122
+ type: error.name || "Error",
123
+ value: error.message,
124
+ ...(frames.length ? { stacktrace: { frames } } : {}),
125
+ };
126
+ }
127
+ let value: string;
128
+ try {
129
+ value = typeof error === "string" ? error : JSON.stringify(error);
130
+ } catch {
131
+ value = String(error);
132
+ }
133
+ return { type: "Error", value: value ?? String(error) };
134
+ }
135
+
136
+ /**
137
+ * The request as a report may carry it: the method, the URL with no query
138
+ * string or fragment, and the user agent. Never the body, never another
139
+ * header.
140
+ */
141
+ function requestOf(request: Request | undefined) {
142
+ if (!request) return undefined;
143
+ let url: string | undefined;
144
+ try {
145
+ const parsed = new URL(request.url);
146
+ url = `${parsed.origin}${parsed.pathname}`;
147
+ } catch {
148
+ url = undefined;
149
+ }
150
+ const agent = request.headers?.get?.("user-agent");
151
+ return {
152
+ method: request.method,
153
+ ...(url ? { url } : {}),
154
+ ...(agent ? { headers: { "User-Agent": agent } } : {}),
155
+ };
156
+ }
157
+
158
+ /**
159
+ * The envelope a report is sent as: the envelope header, the item header,
160
+ * and the event, one JSON document to a line. Exported for the tests.
161
+ */
162
+ export function buildEnvelope(
163
+ error: unknown,
164
+ dsn: string,
165
+ options: Omit<ServerReportOptions, "dsn" | "timeoutMs"> = {},
166
+ now: Date = new Date(),
167
+ ): string {
168
+ const id = eventID();
169
+ const release = options.release ?? environmentValue("VERCEL_GIT_COMMIT_SHA");
170
+ const environment = options.environment ?? environmentValue("VERCEL_ENV");
171
+ const request = requestOf(options.request);
172
+ const event = {
173
+ event_id: id,
174
+ timestamp: now.getTime() / 1000,
175
+ platform: "javascript",
176
+ level: "error",
177
+ sdk: SDK,
178
+ ...(release ? { release } : {}),
179
+ ...(environment ? { environment } : {}),
180
+ tags: { runtime: runtime(), ...options.tags },
181
+ ...(request ? { request } : {}),
182
+ exception: { values: [exceptionOf(error)] },
183
+ };
184
+ const header = { event_id: id, sent_at: now.toISOString(), dsn, sdk: SDK };
185
+ return [JSON.stringify(header), JSON.stringify({ type: "event" }), JSON.stringify(event)].join(
186
+ "\n",
187
+ );
188
+ }
189
+
190
+ /**
191
+ * Reports an error to Sentry from a function or the middleware. Resolves
192
+ * true when Sentry took it and false otherwise (no DSN, a bad DSN, a failed
193
+ * or slow send), and never throws, so a report can never become a second
194
+ * failure. With no DSN it sends nothing.
195
+ */
196
+ export async function reportServerError(
197
+ error: unknown,
198
+ options: ServerReportOptions = {},
199
+ ): Promise<boolean> {
200
+ try {
201
+ const dsn =
202
+ options.dsn ?? environmentValue("SENTRY_DSN") ?? environmentValue("VITE_SENTRY_DSN");
203
+ const parsed = parseDSN(dsn);
204
+ if (!dsn || !parsed) return false;
205
+ const body = buildEnvelope(error, dsn, options);
206
+ const controller = new AbortController();
207
+ const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? 2000);
208
+ try {
209
+ const response = await fetch(parsed.envelopeURL, {
210
+ method: "POST",
211
+ headers: { "Content-Type": "application/x-sentry-envelope" },
212
+ body,
213
+ signal: controller.signal,
214
+ });
215
+ // The answer's body is never read, so it is let go at once rather
216
+ // than held open until the runtime collects it.
217
+ await response.body?.cancel().catch(() => {});
218
+ return response.ok;
219
+ } finally {
220
+ clearTimeout(timer);
221
+ }
222
+ } catch {
223
+ return false;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * What a handler's context offers to keep work running after the answer has
229
+ * gone: the second argument of an edge middleware or a Vercel function
230
+ * (`context.waitUntil`), or any object holding a `waitUntil` like it.
231
+ */
232
+ export interface WaitUntilContext {
233
+ waitUntil(promise: Promise<unknown>): void;
234
+ }
235
+
236
+ /**
237
+ * The platform's own `waitUntil`, read the way `@vercel/functions` reads it,
238
+ * from the request context Vercel keeps on a global symbol, so this file
239
+ * needs no dependency for it. Undefined anywhere else.
240
+ */
241
+ function platformWaitUntil(): ((promise: Promise<unknown>) => void) | undefined {
242
+ try {
243
+ const store = (globalThis as Record<symbol, unknown>)[Symbol.for("@vercel/request-context")] as
244
+ | { get?: () => { waitUntil?: (promise: Promise<unknown>) => void } | undefined }
245
+ | undefined;
246
+ const context = store?.get?.();
247
+ const waitUntil = context?.waitUntil;
248
+ return typeof waitUntil === "function" ? waitUntil.bind(context) : undefined;
249
+ } catch {
250
+ return undefined;
251
+ }
252
+ }
253
+
254
+ /**
255
+ * Reports an error without making the caller wait for it. The send starts
256
+ * at once and is handed to the platform's `waitUntil` (the `context` given,
257
+ * else Vercel's request context), which keeps the function alive until it
258
+ * finishes after the answer has gone. With neither, the send still runs,
259
+ * never blocking the answer, and may be cut short if the runtime freezes
260
+ * once the answer is out. Never throws, and returns nothing to wait on.
261
+ *
262
+ * Use `reportServerError`, awaited, where the report must land before the
263
+ * handler goes on (before a throw, in a handler that already waits); use
264
+ * this one where the answer should leave at once (a refusal the person is
265
+ * waiting to read).
266
+ */
267
+ export function reportServerErrorLater(
268
+ error: unknown,
269
+ options: ServerReportOptions & { context?: WaitUntilContext } = {},
270
+ ): void {
271
+ const { context, ...report } = options;
272
+ const sending = reportServerError(error, report);
273
+ // The context's own waitUntil first, then the platform's; a context with
274
+ // none that can be called, or one that throws, falls through to the
275
+ // next, and with neither the send runs on its own, never blocking.
276
+ const own = (context as { waitUntil?: unknown } | undefined)?.waitUntil;
277
+ const fromContext =
278
+ typeof own === "function"
279
+ ? (promise: Promise<unknown>) => own.call(context, promise)
280
+ : undefined;
281
+ for (const find of [() => fromContext, platformWaitUntil]) {
282
+ try {
283
+ const hold = find();
284
+ if (!hold) continue;
285
+ hold(sending);
286
+ return;
287
+ } catch {
288
+ // This one could not hold the send; the next is tried.
289
+ }
290
+ }
291
+ }
292
+
293
+ /** Anything shaped like an email address, which a refusal may quote (the recipient, the sender). */
294
+ const ADDRESS = /[^\s@<>()[\]"',;:]+@[^\s@<>()[\]"',;:]+\.[^\s@<>()[\]"',;:]+/g;
295
+
296
+ /** The longest a refusal's field is kept, so a report never carries a page of text. */
297
+ const REFUSAL_FIELD_MAX = 300;
298
+
299
+ /**
300
+ * A refused upstream answer as an error a report may carry: the service's
301
+ * name, the status, and the error body's `name` and `message` fields alone,
302
+ * each with anything shaped like an email address replaced by `[address]`
303
+ * and cut to 300 characters. Nothing else of the body is read, and a body
304
+ * that is not JSON leaves the status alone. Never throws.
305
+ *
306
+ * await refusalError(response, "Resend") // Error("Resend answered 422: validation_error: ...")
307
+ */
308
+ export async function refusalError(
309
+ response: Response,
310
+ service = "The upstream service",
311
+ ): Promise<Error> {
312
+ let body: { name?: unknown; message?: unknown } = {};
313
+ try {
314
+ const parsed: unknown = await response.json();
315
+ if (parsed && typeof parsed === "object") body = parsed as typeof body;
316
+ } catch {
317
+ // Not JSON, or already read: the status says what there is to say.
318
+ }
319
+ const parts = [body.name, body.message]
320
+ .filter((part): part is string => typeof part === "string" && part.trim() !== "")
321
+ .map((part) => part.replace(ADDRESS, "[address]").slice(0, REFUSAL_FIELD_MAX));
322
+ return new Error(
323
+ `${service} answered ${response.status}${parts.length ? `: ${parts.join(": ")}` : ""}`,
324
+ );
325
+ }
326
+
327
+ /**
328
+ * Reports a refused upstream answer (a send the mail service would not
329
+ * take) without holding the caller's own answer: the error is built by
330
+ * `refusalError`, so no address in the refusal survives, and sent by
331
+ * `reportServerErrorLater`. Resolves once the refusal's body is read, never
332
+ * waiting on the send, and never throws.
333
+ *
334
+ * if (!response.ok) {
335
+ * await reportRefusedResponse(response, { service: "Resend", request, tags: { route: "contact" } });
336
+ * return json(502, { ok: false, error: "Sending failed. Please try again in a moment." });
337
+ * }
338
+ */
339
+ export async function reportRefusedResponse(
340
+ response: Response,
341
+ options: ServerReportOptions & { service?: string; context?: WaitUntilContext } = {},
342
+ ): Promise<void> {
343
+ const { service, ...report } = options;
344
+ try {
345
+ reportServerErrorLater(await refusalError(response, service), report);
346
+ } catch {
347
+ // A report never becomes a second failure.
348
+ }
349
+ }
350
+
351
+ /**
352
+ * Wraps a function's handler so a throw is reported, then thrown again: the
353
+ * platform still answers the request as it would have, and Sentry hears of
354
+ * it first. `export const POST = withErrorReporting(async (request) => ...)`.
355
+ */
356
+ export function withErrorReporting<Args extends [Request, ...unknown[]], Result>(
357
+ handler: (...args: Args) => Result | Promise<Result>,
358
+ options: Omit<ServerReportOptions, "request"> = {},
359
+ ): (...args: Args) => Promise<Result> {
360
+ return async (...args: Args) => {
361
+ try {
362
+ return await handler(...args);
363
+ } catch (error) {
364
+ await reportServerError(error, { ...options, request: args[0] });
365
+ throw error;
366
+ }
367
+ };
368
+ }
@@ -0,0 +1,118 @@
1
+ /// <reference types="vite/client" />
2
+ import { installCatcher } from "./catcher";
3
+
4
+ export interface ErrorReportingOptions {
5
+ /** The project's DSN, `VITE_SENTRY_DSN`. With none, nothing is installed or loaded. */
6
+ dsn?: string;
7
+ /** The release the errors are filed under: the build's commit (`import.meta.env.VITE_RELEASE`). */
8
+ release?: string;
9
+ /**
10
+ * The environment the errors are filed under. Defaults to the build's
11
+ * `import.meta.env.VITE_ENVIRONMENT`, which `marketingConfig` sets from
12
+ * `VERCEL_ENV` (production, preview, development), falling back to the
13
+ * build's mode.
14
+ */
15
+ environment?: string;
16
+ }
17
+
18
+ /** The message the launch check's error carries, so it is plain in Sentry what it is. */
19
+ export const LAUNCH_CHECK_MESSAGE =
20
+ "Atelic error reporting launch check: thrown on purpose from @atelic-action/ui";
21
+
22
+ /** The environment the site's build names, when it names one. */
23
+ function buildEnvironment(): string | undefined {
24
+ try {
25
+ return import.meta.env?.VITE_ENVIRONMENT || undefined;
26
+ } catch {
27
+ return undefined;
28
+ }
29
+ }
30
+
31
+ /** Throws the launch check's error on the next turn, uncaught, from this module. */
32
+ export function throwLaunchCheck(): void {
33
+ setTimeout(() => {
34
+ throw new Error(LAUNCH_CHECK_MESSAGE);
35
+ }, 0);
36
+ }
37
+
38
+ /** The longest the SDK waits for first paint before it loads anyway. */
39
+ export const LOAD_CAP_MS = 10_000;
40
+
41
+ /**
42
+ * Runs `task` once, after the first contentful paint, falling back to the
43
+ * load event where the browser cannot report paints (no
44
+ * `PerformanceObserver`, or one without the `paint` entry type), and after
45
+ * ten seconds whatever happens, so a page that never paints still reports.
46
+ * The SDK waits for paint because loaded any earlier it competes with the
47
+ * page's own first paint, which is what a speed test measures.
48
+ */
49
+ export function afterFirstPaint(task: () => void, win: Window = window): void {
50
+ let ran = false;
51
+ const once = () => {
52
+ if (ran) return;
53
+ ran = true;
54
+ task();
55
+ };
56
+ const Observer = (win as Window & { PerformanceObserver?: typeof PerformanceObserver })
57
+ .PerformanceObserver;
58
+ let watching = false;
59
+ if (Observer && (Observer.supportedEntryTypes ?? []).includes("paint")) {
60
+ try {
61
+ const observer = new Observer((entries) => {
62
+ if (entries.getEntriesByName("first-contentful-paint").length) {
63
+ observer.disconnect();
64
+ win.setTimeout(once, 0);
65
+ }
66
+ });
67
+ observer.observe({ type: "paint", buffered: true });
68
+ watching = true;
69
+ } catch {
70
+ watching = false;
71
+ }
72
+ }
73
+ if (!watching) {
74
+ if (win.document.readyState === "complete") win.setTimeout(once, 0);
75
+ else win.addEventListener("load", once, { once: true });
76
+ }
77
+ win.setTimeout(once, LOAD_CAP_MS);
78
+ }
79
+
80
+ /**
81
+ * Starts error reporting in the browser: errors only, never tracing.
82
+ *
83
+ * At once it makes sure the early catcher is listening (the inline script
84
+ * from the root route, or one installed here), so nothing thrown before the
85
+ * SDK arrives is lost. After first paint it loads the SDK, set up for errors
86
+ * alone, replays what the catcher held (each tagged `early`), hands the
87
+ * catcher's later errors to the SDK, and takes the catcher's own listeners
88
+ * off, since the SDK's global handlers listen from then on and an error
89
+ * must never be reported twice.
90
+ *
91
+ * With no `dsn` it does nothing and loads nothing. Call it once, in the
92
+ * browser (a site's router module, guarded by `typeof window`).
93
+ */
94
+ export function startErrorReporting({
95
+ dsn,
96
+ release,
97
+ environment = buildEnvironment(),
98
+ }: ErrorReportingOptions): void {
99
+ if (!dsn || typeof window === "undefined") return;
100
+ const win = window;
101
+ const catcher = installCatcher(win);
102
+ catcher.test = throwLaunchCheck;
103
+ afterFirstPaint(() => {
104
+ import("./sdk")
105
+ .then(({ initSentry }) => {
106
+ const capture = initSentry({ dsn, release, environment });
107
+ win.removeEventListener("error", catcher.onError);
108
+ win.removeEventListener("unhandledrejection", catcher.onRejection);
109
+ catcher.report = (error, kind) => capture(error, kind);
110
+ const held = catcher.q.splice(0, catcher.q.length);
111
+ for (const item of held) capture(item.error, item.kind, true, catcher.dropped);
112
+ })
113
+ .catch(() => {
114
+ // The SDK failed to load (offline, blocked by a content blocker):
115
+ // the catcher keeps holding, and the page is none the worse.
116
+ });
117
+ }, win);
118
+ }
@@ -1,5 +1,6 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
2
  import { newTabProps } from "../lib/newTabProps";
3
+ import { telText } from "../lib/phoneText";
3
4
  import { useWithBase } from "../routing/BasePathProvider";
4
5
 
5
6
  export interface ButtonProps {
@@ -52,9 +53,10 @@ export function Button({
52
53
  .filter(Boolean)
53
54
  .join(" ");
54
55
 
56
+ // A call button with words beside its number holds the number whole.
55
57
  const content = (
56
58
  <>
57
- {children}
59
+ {telText(href, children)}
58
60
  {arrow && (
59
61
  <span className="arrow" aria-hidden="true">
60
62
  →
@@ -11,6 +11,8 @@ export interface EyebrowProps {
11
11
  * Accepted so existing call sites keep compiling.
12
12
  */
13
13
  run?: boolean;
14
+ /** Draws the trailing rule. Defaults to true; false sets the kicker alone. */
15
+ rule?: boolean;
14
16
  children: ReactNode;
15
17
  }
16
18
 
@@ -19,7 +21,9 @@ export interface EyebrowProps {
19
21
  * that fades out to the right (the practice wordmark's signature), rendered
20
22
  * from the primary token so it carries each site's brand color.
21
23
  */
22
- export function Eyebrow({ onDark = false, center = false, children }: EyebrowProps) {
23
- const classes = ["eyebrow", onDark && "on-dark", center && "center"].filter(Boolean).join(" ");
24
+ export function Eyebrow({ onDark = false, center = false, rule = true, children }: EyebrowProps) {
25
+ const classes = ["eyebrow", onDark && "on-dark", center && "center", !rule && "no-rule"]
26
+ .filter(Boolean)
27
+ .join(" ");
24
28
  return <p className={classes}>{children}</p>;
25
29
  }
@@ -1,35 +1,3 @@
1
- /**
2
- * The router options that keep a not found page alive on a statically
3
- * prerendered TanStack Start site. Spread them into createRouter:
4
- *
5
- * createRouter({ routeTree, ...staticNotFoundRouting(NotFoundPage) })
6
- *
7
- * The static host serves the /404 prerender for every unknown path, and it
8
- * takes a catch all route (src/routes/$.tsx rendering the same page) plus
9
- * these two options to survive hydration:
10
- *
11
- * - The splat gives the client a match below the root. With a dedicated
12
- * /404 route instead, an unknown path matches only the root, hydrate takes
13
- * its SPA branch, throws, and the page goes blank.
14
- * - The splat's match id still carries the path, so it differs from the
15
- * dehydrated /404 match and hydrate renders the pending state first.
16
- * Pending as the page itself keeps that first render identical to the
17
- * server HTML; the default null is a hydration mismatch.
18
- *
19
- * Static sites only. On a live app the pending state is a real loading
20
- * moment, and this would flash the not found page through every slow load;
21
- * an app sets defaultNotFoundComponent alone.
22
- *
23
- * Generic over the page so the router checks it against its own component
24
- * type; the package stays free of any router import.
25
- */
26
- export function staticNotFoundRouting<Page>(page: Page) {
27
- return {
28
- defaultNotFoundComponent: page,
29
- defaultPendingComponent: page,
30
- };
31
- }
32
-
33
1
  export {
34
2
  BasePathProvider,
35
3
  type BasePathProviderProps,
@@ -37,3 +5,14 @@ export {
37
5
  useWithBase,
38
6
  } from "./BasePathProvider";
39
7
  export { hasBase, joinBase, normalizeBasePath, stripBase } from "./basePath";
8
+ export { CATCH_ALL_ROUTE_ID, isMiss, type MissMatch } from "./miss";
9
+ export {
10
+ RouteErrorFallback,
11
+ type RouteErrorProps,
12
+ reportRouteError,
13
+ routerErrorOptions,
14
+ } from "./routerErrors";
15
+ export {
16
+ type StaticNotFoundOptions,
17
+ staticNotFoundRouting,
18
+ } from "./staticNotFound";
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Whether the router's matches are a miss: the catch all route took the
3
+ * path (an unknown page), or a route with params says its params name a page
4
+ * it does not have (a blog slug nobody wrote) through `staticData.missing`.
5
+ * Router free: it reads the plain fields every TanStack match carries, so a
6
+ * site's root route asks it from `head` and from `useMatches`.
7
+ *
8
+ * Under `staticNotFoundRouting` a miss is still pending while the page
9
+ * hydrates, and a route's `notFound()` lands as late, so the question is
10
+ * answered from the matches alone, before anything has loaded. A site's root
11
+ * uses it twice: to emit the 404's head tags from the root (tags on the
12
+ * pending catch all route would be emitted twice), and to draw a miss inside
13
+ * the site's shell from the root layout, so the shell stays mounted while
14
+ * the not found body swaps from its pending render to its own.
15
+ */
16
+ export interface MissMatch {
17
+ routeId: string;
18
+ params: Record<string, string>;
19
+ staticData?: { missing?: (params: Record<string, string>) => boolean };
20
+ }
21
+
22
+ /** The catch all route's id in a TanStack file route tree. */
23
+ export const CATCH_ALL_ROUTE_ID = "/$";
24
+
25
+ export function isMiss(
26
+ matches: ReadonlyArray<MissMatch>,
27
+ catchAllId: string = CATCH_ALL_ROUTE_ID,
28
+ ): boolean {
29
+ return matches.some(
30
+ (match) => match.routeId === catchAllId || match.staticData?.missing?.(match.params) === true,
31
+ );
32
+ }
@@ -0,0 +1,57 @@
1
+ import { ErrorFallback } from "../artifact/ErrorFallback";
2
+ import { reportError } from "../monitoring/catcher";
3
+
4
+ /** What a router hands its error component: the error and a way to try again. */
5
+ export interface RouteErrorProps {
6
+ error: unknown;
7
+ reset: () => void;
8
+ /** Reloads the page; defaults to the window's own. For a test. */
9
+ reload?: () => void;
10
+ }
11
+
12
+ /**
13
+ * The package's `ErrorFallback` as a router's error component: the same
14
+ * dependency free page `AppErrorBoundary` draws. Try Again reloads the page.
15
+ * A loader or beforeLoad error stays on the router's match, so the boundary's
16
+ * own reset throws it again (and reports it a second time), and recovering in
17
+ * place takes the router's invalidate, which this entry cannot import. The
18
+ * `reload` prop is there for a test; a router never passes it.
19
+ */
20
+ export function RouteErrorFallback({ error, reload }: RouteErrorProps) {
21
+ const retry = reload ?? (() => window.location.reload());
22
+ return <ErrorFallback error={error} resetError={retry} />;
23
+ }
24
+
25
+ /**
26
+ * Hands a crash a router's own boundary caught to error reporting, exactly
27
+ * as `AppErrorBoundary` does (`reportError(error, "boundary")`).
28
+ */
29
+ export function reportRouteError(error: unknown): void {
30
+ reportError(error, "boundary");
31
+ }
32
+
33
+ /**
34
+ * The router options that make a route's render crash reach error reporting
35
+ * whichever boundary catches it. TanStack Router (1.170) gives a route its
36
+ * own catch boundary only when an `errorComponent` applies to it; with none,
37
+ * a crash rises to the site's `AppErrorBoundary`, which reports it. A route
38
+ * or a site that sets its own `errorComponent` with no `onCatch` puts a
39
+ * boundary in the way that catches the crash and reports it to nobody, since
40
+ * React keeps a caught crash from the window's handlers. With these spread
41
+ * into `createRouter`, every route has the boundary, `defaultOnCatch` reports
42
+ * what it catches once, and `defaultErrorComponent` draws the package's error
43
+ * page in its place, so the report no longer depends on which boundary is
44
+ * nearest:
45
+ *
46
+ * createRouter({ routeTree, ...routerErrorOptions() })
47
+ *
48
+ * A route's own `onCatch` or `errorComponent` wins over these; a not found
49
+ * is never caught here, since the router rethrows it to its not found
50
+ * handling first. Like the rest of this entry, it imports no router.
51
+ */
52
+ export function routerErrorOptions() {
53
+ return {
54
+ defaultOnCatch: reportRouteError,
55
+ defaultErrorComponent: RouteErrorFallback,
56
+ };
57
+ }