@c1m-public/dash-site-kit 0.8.0 → 0.9.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.
@@ -0,0 +1,17 @@
1
+ import { NextResponse, type NextRequest } from "next/server";
2
+ import { type DashBootstrap } from "../models/bootstrap.js";
3
+ export interface DashSiteProxyOptions {
4
+ /** The site's cached bootstrap read (`data.loadDashBootstrap`). */
5
+ loadBootstrap: () => Promise<Pick<DashBootstrap, "gate">>;
6
+ /** Extra paths a page gate must never redirect. */
7
+ exempt?: readonly string[];
8
+ }
9
+ /**
10
+ * The site's proxy in one line. A live page gate answers a real 307 to the
11
+ * gate path before anything renders; every other request passes through with
12
+ * first-touch attribution recorded. The bootstrap read is the same cached
13
+ * `dash.init` the layout uses, so the gate costs no extra API call. If the
14
+ * bootstrap cannot be read the request passes through: the site's own error
15
+ * handling decides, not the gate.
16
+ */
17
+ export declare function createDashSiteProxy({ loadBootstrap, exempt }: DashSiteProxyOptions): (request: NextRequest) => Promise<NextResponse>;
@@ -0,0 +1,26 @@
1
+ import { NextResponse } from "next/server";
2
+ import { gateRedirect } from "../models/bootstrap.js";
3
+ import { recordFirstTouch } from "./first-touch.js";
4
+ /**
5
+ * The site's proxy in one line. A live page gate answers a real 307 to the
6
+ * gate path before anything renders; every other request passes through with
7
+ * first-touch attribution recorded. The bootstrap read is the same cached
8
+ * `dash.init` the layout uses, so the gate costs no extra API call. If the
9
+ * bootstrap cannot be read the request passes through: the site's own error
10
+ * handling decides, not the gate.
11
+ */
12
+ export function createDashSiteProxy({ loadBootstrap, exempt = [] }) {
13
+ return async function proxy(request) {
14
+ let target = null;
15
+ try {
16
+ target = gateRedirect(await loadBootstrap(), request.nextUrl.pathname, exempt);
17
+ }
18
+ catch {
19
+ target = null;
20
+ }
21
+ const response = target
22
+ ? NextResponse.redirect(new URL(target, request.nextUrl), 307)
23
+ : NextResponse.next();
24
+ return recordFirstTouch(request, response);
25
+ };
26
+ }
package/dist/next.d.ts CHANGED
@@ -24,6 +24,7 @@ export { resolveC1MAsset } from "./next/assets.js";
24
24
  export { createC1MBootstrapProvider } from "./next/providers/bootstrap.js";
25
25
  export { createC1MWaitlistProvider } from "./next/providers/waitlist.js";
26
26
  export { readFirstTouch, recordFirstTouch } from "./next/first-touch.js";
27
+ export { createDashSiteProxy, type DashSiteProxyOptions } from "./next/site-proxy.js";
27
28
  export { createC1MDirectoryProvider } from "./next/providers/directory.js";
28
29
  export { createC1MLeadPortalProvider } from "./next/providers/lead-portal.js";
29
30
  export { createC1MLeadsProvider } from "./next/providers/leads.js";
package/dist/next.js CHANGED
@@ -19,6 +19,7 @@ export { resolveC1MAsset } from "./next/assets.js";
19
19
  export { createC1MBootstrapProvider } from "./next/providers/bootstrap.js";
20
20
  export { createC1MWaitlistProvider } from "./next/providers/waitlist.js";
21
21
  export { readFirstTouch, recordFirstTouch } from "./next/first-touch.js";
22
+ export { createDashSiteProxy } from "./next/site-proxy.js";
22
23
  export { createC1MDirectoryProvider } from "./next/providers/directory.js";
23
24
  export { createC1MLeadPortalProvider } from "./next/providers/lead-portal.js";
24
25
  export { createC1MLeadsProvider } from "./next/providers/leads.js";
@@ -0,0 +1,23 @@
1
+ import type { DashWaitlistForm as DashWaitlistFormSettings, DashWaitlistReceipt, DashWaitlistSubmission } from "../models/waitlist.js";
2
+ /**
3
+ * The gate's page: a centred signup with the site's own name. Server
4
+ * component; `submit` is the site's Server Action.
5
+ */
6
+ export declare function DashWaitlistPage({ siteName, headline, description, form, submit, }: {
7
+ siteName: string;
8
+ headline?: string;
9
+ description?: string;
10
+ form: DashWaitlistFormSettings;
11
+ submit: (input: DashWaitlistSubmission) => Promise<DashWaitlistReceipt>;
12
+ }): import("react").JSX.Element;
13
+ /**
14
+ * An email-link page. It acts only on a click, so link scanners that prefetch
15
+ * the email cannot confirm or unsubscribe for the recipient. `action` is the
16
+ * site's Server Action; it redirects back with `result`.
17
+ */
18
+ export declare function DashWaitlistEmailLink({ kind, hasSecret, result, action, }: {
19
+ kind: "verify" | "leave";
20
+ hasSecret: boolean;
21
+ result?: "done" | "invalid";
22
+ action: () => Promise<void>;
23
+ }): import("react").JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Container, Eyebrow } from "./primitives.js";
3
+ import { DashWaitlistForm } from "./waitlist-form.js";
4
+ /**
5
+ * The gate's page: a centred signup with the site's own name. Server
6
+ * component; `submit` is the site's Server Action.
7
+ */
8
+ export function DashWaitlistPage({ siteName, headline = "Join the waitlist", description = "We are getting ready. Leave your email and we will let you know when we open.", form, submit, }) {
9
+ return (_jsx("main", { className: "flex min-h-screen items-center py-16", children: _jsxs(Container, { className: "max-w-md space-y-6", children: [_jsx(Eyebrow, { children: siteName }), _jsx("h1", { className: "text-3xl font-semibold tracking-tight text-ink", children: headline }), _jsx("p", { className: "text-base leading-7 text-muted", children: description }), _jsx(DashWaitlistForm, { acceptingEntries: form.acceptingEntries, collectMarketingConsent: form.collectMarketingConsent, placement: "page", submit: submit })] }) }));
10
+ }
11
+ const LINK_COPY = {
12
+ verify: {
13
+ prompt: "Confirm your email address to keep your place on the waitlist.",
14
+ button: "Confirm my email",
15
+ done: "Your email is confirmed. You are on the list.",
16
+ invalid: "This link has expired or was already used.",
17
+ },
18
+ leave: {
19
+ prompt: "Leave the waitlist and stop marketing emails?",
20
+ button: "Leave the list",
21
+ done: "You have left the list and will not receive marketing emails.",
22
+ invalid: "This link is no longer valid.",
23
+ },
24
+ };
25
+ /**
26
+ * An email-link page. It acts only on a click, so link scanners that prefetch
27
+ * the email cannot confirm or unsubscribe for the recipient. `action` is the
28
+ * site's Server Action; it redirects back with `result`.
29
+ */
30
+ export function DashWaitlistEmailLink({ kind, hasSecret, result, action, }) {
31
+ const copy = LINK_COPY[kind];
32
+ return (_jsx("main", { className: "flex min-h-screen items-center py-16", children: _jsx(Container, { className: "max-w-md space-y-6", children: result === "done" ? _jsx("p", { role: "status", className: "text-base text-ink", children: copy.done })
33
+ : result === "invalid" || !hasSecret ? _jsx("p", { role: "status", className: "text-base text-ink", children: copy.invalid })
34
+ : (_jsxs("form", { action: action, className: "space-y-4", children: [_jsx("p", { className: "text-base leading-7 text-muted", children: copy.prompt }), _jsx("button", { className: "min-h-11 rounded-full bg-accent px-5 py-2.5 text-sm font-semibold text-accent-foreground", type: "submit", children: copy.button })] })) }) }));
35
+ }
package/dist/ui.d.ts CHANGED
@@ -10,4 +10,5 @@
10
10
  export { ButtonLink, Container, Eyebrow, SectionHeading, StatusPanel, VerifiedBadge, } from "./ui/primitives.js";
11
11
  export { SiteImage } from "./ui/site-image.js";
12
12
  export { DashWaitlistForm } from "./ui/waitlist-form.js";
13
+ export { DashWaitlistEmailLink, DashWaitlistPage } from "./ui/waitlist-page.js";
13
14
  export { SiteErrorFallback } from "./ui/error-fallback.js";
package/dist/ui.js CHANGED
@@ -10,4 +10,5 @@
10
10
  export { ButtonLink, Container, Eyebrow, SectionHeading, StatusPanel, VerifiedBadge, } from "./ui/primitives.js";
11
11
  export { SiteImage } from "./ui/site-image.js";
12
12
  export { DashWaitlistForm } from "./ui/waitlist-form.js";
13
+ export { DashWaitlistEmailLink, DashWaitlistPage } from "./ui/waitlist-page.js";
13
14
  export { SiteErrorFallback } from "./ui/error-fallback.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/dash-site-kit",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Shared transport, domain and UI layer for MML dash-scoped public sites",
@@ -48,12 +48,14 @@
48
48
  "react": "^19"
49
49
  },
50
50
  "devDependencies": {
51
+ "@types/node": "^22",
51
52
  "@types/react": "^19.2.2",
53
+ "@types/react-dom": "^19.2.4",
52
54
  "next": "^16.3.1",
53
55
  "react": "^19.2.8",
56
+ "react-dom": "19.2.8",
54
57
  "typescript": "5.9.3",
55
58
  "vitest": "^4.1.4",
56
- "@types/node": "^22",
57
59
  "@c1m-public/channel-client": "0.28.0"
58
60
  },
59
61
  "peerDependenciesMeta": {