@c1m-public/dash-site-kit 0.7.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.
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/models/attribution.d.ts +22 -0
- package/dist/models/attribution.js +61 -0
- package/dist/models/bootstrap.d.ts +18 -7
- package/dist/models/bootstrap.js +25 -3
- package/dist/models/waitlist.d.ts +6 -0
- package/dist/next/data-layer.d.ts +2 -0
- package/dist/next/data-layer.js +2 -0
- package/dist/next/first-touch.d.ts +10 -0
- package/dist/next/first-touch.js +28 -0
- package/dist/next/normalize.js +7 -5
- package/dist/next/providers/waitlist.d.ts +2 -1
- package/dist/next/providers/waitlist.js +11 -3
- package/dist/next/site-proxy.d.ts +17 -0
- package/dist/next/site-proxy.js +26 -0
- package/dist/next.d.ts +2 -0
- package/dist/next.js +2 -0
- package/dist/ports/waitlist.d.ts +4 -0
- package/dist/ui/waitlist-form.d.ts +3 -1
- package/dist/ui/waitlist-form.js +3 -2
- package/dist/ui/waitlist-page.d.ts +23 -0
- package/dist/ui/waitlist-page.js +35 -0
- package/dist/ui.d.ts +1 -0
- package/dist/ui.js +1 -0
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export type * from "./models/bootstrap.js";
|
|
12
12
|
export type * from "./models/waitlist.js";
|
|
13
|
-
export {
|
|
13
|
+
export { GATE_EXEMPT_PATHS, gateRedirect } from "./models/bootstrap.js";
|
|
14
|
+
export type * from "./models/attribution.js";
|
|
15
|
+
export { FIRST_TOUCH_COOKIE, FIRST_TOUCH_MAX_AGE_SECONDS, decodeFirstTouch, encodeFirstTouch, firstTouchFrom } from "./models/attribution.js";
|
|
14
16
|
export type * from "./models/directory.js";
|
|
15
17
|
export type * from "./models/leads.js";
|
|
16
18
|
export type * from "./models/lead-portal.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { GATE_EXEMPT_PATHS, gateRedirect } from "./models/bootstrap.js";
|
|
2
|
+
export { FIRST_TOUCH_COOKIE, FIRST_TOUCH_MAX_AGE_SECONDS, decodeFirstTouch, encodeFirstTouch, firstTouchFrom } from "./models/attribution.js";
|
|
2
3
|
export { selectDirectoryRegion, validateDirectoryKey, validateRegionFilter, } from "./validation/directory.js";
|
|
3
4
|
export { LEAD_LIMITS, validateLeadForm } from "./validation/leads.js";
|
|
4
5
|
export { formatMoney } from "./format.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-touch attribution: where a visitor first came from, captured once and
|
|
3
|
+
* carried in a first-party cookie until they sign up. Framework-neutral.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FIRST_TOUCH_COOKIE = "c1m_ft";
|
|
6
|
+
export declare const FIRST_TOUCH_MAX_AGE_SECONDS: number;
|
|
7
|
+
export interface FirstTouch {
|
|
8
|
+
utm_source?: string;
|
|
9
|
+
utm_medium?: string;
|
|
10
|
+
utm_campaign?: string;
|
|
11
|
+
utm_term?: string;
|
|
12
|
+
utm_content?: string;
|
|
13
|
+
referrer_host?: string;
|
|
14
|
+
landing_path?: string;
|
|
15
|
+
country?: string;
|
|
16
|
+
locale?: string;
|
|
17
|
+
}
|
|
18
|
+
/** The first touch for a landing request. The referrer counts only when external. */
|
|
19
|
+
export declare function firstTouchFrom(url: URL, referrer: string | null | undefined): FirstTouch;
|
|
20
|
+
export declare function encodeFirstTouch(touch: FirstTouch): string;
|
|
21
|
+
/** Parses a cookie value, keeping only known, bounded string fields. */
|
|
22
|
+
export declare function decodeFirstTouch(value: string | null | undefined): FirstTouch;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-touch attribution: where a visitor first came from, captured once and
|
|
3
|
+
* carried in a first-party cookie until they sign up. Framework-neutral.
|
|
4
|
+
*/
|
|
5
|
+
export const FIRST_TOUCH_COOKIE = "c1m_ft";
|
|
6
|
+
export const FIRST_TOUCH_MAX_AGE_SECONDS = 60 * 60 * 24 * 30;
|
|
7
|
+
const UTM_KEYS = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
|
|
8
|
+
function bounded(value, max) {
|
|
9
|
+
const trimmed = value?.trim();
|
|
10
|
+
return trimmed && trimmed.length <= max && !/[\u0000-\u001f\u007f]/.test(trimmed) ? trimmed : undefined;
|
|
11
|
+
}
|
|
12
|
+
/** The first touch for a landing request. The referrer counts only when external. */
|
|
13
|
+
export function firstTouchFrom(url, referrer) {
|
|
14
|
+
const touch = { landing_path: bounded(url.pathname + url.search, 512) };
|
|
15
|
+
for (const key of UTM_KEYS) {
|
|
16
|
+
const value = bounded(url.searchParams.get(key), 128);
|
|
17
|
+
if (value)
|
|
18
|
+
touch[key] = value;
|
|
19
|
+
}
|
|
20
|
+
if (referrer) {
|
|
21
|
+
try {
|
|
22
|
+
const host = new URL(referrer).hostname.toLowerCase();
|
|
23
|
+
if (host && host !== url.hostname.toLowerCase())
|
|
24
|
+
touch.referrer_host = bounded(host, 253);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// An unparsable referrer is simply not recorded.
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return touch;
|
|
31
|
+
}
|
|
32
|
+
export function encodeFirstTouch(touch) {
|
|
33
|
+
return encodeURIComponent(JSON.stringify(touch));
|
|
34
|
+
}
|
|
35
|
+
/** Parses a cookie value, keeping only known, bounded string fields. */
|
|
36
|
+
export function decodeFirstTouch(value) {
|
|
37
|
+
if (!value || value.length > 4096)
|
|
38
|
+
return {};
|
|
39
|
+
let parsed;
|
|
40
|
+
try {
|
|
41
|
+
parsed = JSON.parse(decodeURIComponent(value));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
if (!parsed || typeof parsed !== "object")
|
|
47
|
+
return {};
|
|
48
|
+
const source = parsed;
|
|
49
|
+
const out = {};
|
|
50
|
+
const limits = {
|
|
51
|
+
utm_source: 128, utm_medium: 128, utm_campaign: 128, utm_term: 128, utm_content: 128,
|
|
52
|
+
referrer_host: 253, landing_path: 512, country: 2, locale: 35,
|
|
53
|
+
};
|
|
54
|
+
for (const key of Object.keys(limits)) {
|
|
55
|
+
const raw = source[key];
|
|
56
|
+
const value = typeof raw === "string" ? bounded(raw, limits[key]) : undefined;
|
|
57
|
+
if (value)
|
|
58
|
+
out[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
@@ -30,11 +30,22 @@ export interface DashBootstrap {
|
|
|
30
30
|
title: string;
|
|
31
31
|
description?: string;
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
/** The server-decided public gate; null means the normal site. */
|
|
34
|
+
gate: DashGate | null;
|
|
35
|
+
}
|
|
36
|
+
export interface DashGate {
|
|
37
|
+
kind: "waitlist";
|
|
38
|
+
placement: "page" | "block";
|
|
39
|
+
path: string;
|
|
38
40
|
}
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Paths a page gate never redirects: the gate itself, framework and API
|
|
43
|
+
* routes, crawler files and legal pages (consent must stay readable).
|
|
44
|
+
*/
|
|
45
|
+
export declare const GATE_EXEMPT_PATHS: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* Where a request must go instead, or null to serve it. Only page placement
|
|
48
|
+
* redirects; the server already decided whether the gate applies, so this
|
|
49
|
+
* never recomputes availability.
|
|
50
|
+
*/
|
|
51
|
+
export declare function gateRedirect(bootstrap: Pick<DashBootstrap, "gate">, pathname: string, exempt?: readonly string[]): string | null;
|
package/dist/models/bootstrap.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Paths a page gate never redirects: the gate itself, framework and API
|
|
3
|
+
* routes, crawler files and legal pages (consent must stay readable).
|
|
4
|
+
*/
|
|
5
|
+
export const GATE_EXEMPT_PATHS = [
|
|
6
|
+
"/api", "/_next", "/.well-known", "/robots.txt", "/sitemap.xml", "/favicon.ico",
|
|
7
|
+
"/privacy", "/terms", "/cookies", "/legal",
|
|
8
|
+
];
|
|
9
|
+
function underPath(pathname, prefix) {
|
|
10
|
+
return pathname === prefix || pathname.startsWith(prefix.endsWith("/") ? prefix : `${prefix}/`);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Where a request must go instead, or null to serve it. Only page placement
|
|
14
|
+
* redirects; the server already decided whether the gate applies, so this
|
|
15
|
+
* never recomputes availability.
|
|
16
|
+
*/
|
|
17
|
+
export function gateRedirect(bootstrap, pathname, exempt = []) {
|
|
18
|
+
const gate = bootstrap.gate;
|
|
19
|
+
if (!gate || gate.placement !== "page")
|
|
20
|
+
return null;
|
|
21
|
+
for (const prefix of [gate.path, ...GATE_EXEMPT_PATHS, ...exempt]) {
|
|
22
|
+
if (underPath(pathname, prefix))
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return gate.path;
|
|
4
26
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { FirstTouch } from "./attribution.js";
|
|
1
2
|
export interface DashWaitlistForm {
|
|
3
|
+
/** True while the server-decided gate is live. */
|
|
2
4
|
acceptingEntries: boolean;
|
|
3
5
|
collectMarketingConsent: boolean;
|
|
4
6
|
}
|
|
@@ -6,6 +8,10 @@ export interface DashWaitlistSubmission {
|
|
|
6
8
|
email: string;
|
|
7
9
|
name?: string;
|
|
8
10
|
marketingOptIn?: boolean;
|
|
11
|
+
/** Which placement captured the signup. */
|
|
12
|
+
source?: "waitlist_page" | "waitlist_block";
|
|
13
|
+
/** First-touch context; the server bounds and may drop any field. */
|
|
14
|
+
attribution?: FirstTouch;
|
|
9
15
|
}
|
|
10
16
|
export interface DashWaitlistReceipt {
|
|
11
17
|
accepted: true;
|
|
@@ -35,6 +35,8 @@ export interface DashDataLayer {
|
|
|
35
35
|
viewPortal(token: string): Promise<ViewOutcome>;
|
|
36
36
|
loadDashWaitlistForm(): Promise<DashWaitlistForm>;
|
|
37
37
|
submitDashWaitlist(input: DashWaitlistSubmission, attemptId: string): Promise<DashWaitlistReceipt>;
|
|
38
|
+
verifyWaitlistEmail(token: string): Promise<boolean>;
|
|
39
|
+
leaveWaitlist(key: string): Promise<boolean>;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Builds the whole logic layer for a dash site in one call.
|
package/dist/next/data-layer.js
CHANGED
|
@@ -53,5 +53,7 @@ export function createDashDataLayer(options) {
|
|
|
53
53
|
viewPortal: (token) => leadPortalProvider.view(token),
|
|
54
54
|
loadDashWaitlistForm: cache(() => waitlistProvider.loadForm()),
|
|
55
55
|
submitDashWaitlist: (input, attemptId) => waitlistProvider.submit(input, attemptId),
|
|
56
|
+
verifyWaitlistEmail: (token) => waitlistProvider.verify(token),
|
|
57
|
+
leaveWaitlist: (key) => waitlistProvider.leave(key),
|
|
56
58
|
};
|
|
57
59
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { NextRequest, NextResponse } from "next/server";
|
|
3
|
+
import { type FirstTouch } from "../models/attribution.js";
|
|
4
|
+
/**
|
|
5
|
+
* Call from the site's proxy/middleware on page requests. It records the
|
|
6
|
+
* first touch once; later visits never overwrite it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function recordFirstTouch(request: NextRequest, response: NextResponse): NextResponse;
|
|
9
|
+
/** The visitor's first touch plus request-time country and locale hints. */
|
|
10
|
+
export declare function readFirstTouch(): Promise<FirstTouch>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { cookies, headers } from "next/headers";
|
|
3
|
+
import { FIRST_TOUCH_COOKIE, FIRST_TOUCH_MAX_AGE_SECONDS, decodeFirstTouch, encodeFirstTouch, firstTouchFrom, } from "../models/attribution.js";
|
|
4
|
+
/**
|
|
5
|
+
* Call from the site's proxy/middleware on page requests. It records the
|
|
6
|
+
* first touch once; later visits never overwrite it.
|
|
7
|
+
*/
|
|
8
|
+
export function recordFirstTouch(request, response) {
|
|
9
|
+
if (request.cookies.has(FIRST_TOUCH_COOKIE))
|
|
10
|
+
return response;
|
|
11
|
+
const touch = firstTouchFrom(request.nextUrl, request.headers.get("referer"));
|
|
12
|
+
response.cookies.set(FIRST_TOUCH_COOKIE, encodeFirstTouch(touch), {
|
|
13
|
+
httpOnly: true, sameSite: "lax", secure: request.nextUrl.protocol === "https:", path: "/", maxAge: FIRST_TOUCH_MAX_AGE_SECONDS,
|
|
14
|
+
});
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
17
|
+
/** The visitor's first touch plus request-time country and locale hints. */
|
|
18
|
+
export async function readFirstTouch() {
|
|
19
|
+
const [jar, requestHeaders] = await Promise.all([cookies(), headers()]);
|
|
20
|
+
const touch = decodeFirstTouch(jar.get(FIRST_TOUCH_COOKIE)?.value);
|
|
21
|
+
const country = requestHeaders.get("x-vercel-ip-country")?.toUpperCase();
|
|
22
|
+
if (country && /^[A-Z]{2}$/.test(country))
|
|
23
|
+
touch.country = country;
|
|
24
|
+
const locale = requestHeaders.get("accept-language")?.split(",")[0]?.split(";")[0]?.trim();
|
|
25
|
+
if (locale && /^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$/.test(locale))
|
|
26
|
+
touch.locale = locale;
|
|
27
|
+
return touch;
|
|
28
|
+
}
|
package/dist/next/normalize.js
CHANGED
|
@@ -29,11 +29,7 @@ export function normalizeDashBootstrap(init) {
|
|
|
29
29
|
title: text(init.seo?.title) ?? name,
|
|
30
30
|
description: text(init.seo?.description) ?? text(init.public_profile.headline) ?? text(init.public_profile.short_description),
|
|
31
31
|
},
|
|
32
|
-
|
|
33
|
-
enabled: init.waitlist?.enabled === true,
|
|
34
|
-
acceptingEntries: init.waitlist?.accepting_entries === true,
|
|
35
|
-
display: init.waitlist?.display === "page" ? "page" : "block",
|
|
36
|
-
},
|
|
32
|
+
gate: normalizeGate(init.gate),
|
|
37
33
|
};
|
|
38
34
|
}
|
|
39
35
|
// --- profile --------------------------------------------------------------
|
|
@@ -145,3 +141,9 @@ export function normalizePlanCatalog(response) {
|
|
|
145
141
|
defaultRegion: response.default_region,
|
|
146
142
|
};
|
|
147
143
|
}
|
|
144
|
+
function normalizeGate(gate) {
|
|
145
|
+
if (gate?.kind !== "waitlist" || (gate.placement !== "page" && gate.placement !== "block"))
|
|
146
|
+
return null;
|
|
147
|
+
const path = typeof gate.path === "string" && gate.path.startsWith("/") && !gate.path.startsWith("//") ? gate.path : "/waitlist";
|
|
148
|
+
return { kind: "waitlist", placement: gate.placement, path };
|
|
149
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import type { WaitlistProvider } from "../../ports/waitlist.js";
|
|
3
3
|
import { getDashChannelClient } from "../client.js";
|
|
4
|
+
import { readFirstTouch } from "../first-touch.js";
|
|
4
5
|
type ChannelClient = Awaited<ReturnType<typeof getDashChannelClient>>;
|
|
5
6
|
type ChannelClientResolver = () => ChannelClient | Promise<ChannelClient>;
|
|
6
|
-
export declare function createC1MWaitlistProvider(resolveClient?: ChannelClientResolver): WaitlistProvider;
|
|
7
|
+
export declare function createC1MWaitlistProvider(resolveClient?: ChannelClientResolver, attribution?: typeof readFirstTouch): WaitlistProvider;
|
|
7
8
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { getDashChannelClient } from "../client.js";
|
|
3
|
-
|
|
3
|
+
import { readFirstTouch } from "../first-touch.js";
|
|
4
|
+
export function createC1MWaitlistProvider(resolveClient = getDashChannelClient, attribution = readFirstTouch) {
|
|
4
5
|
return {
|
|
5
6
|
async loadForm() {
|
|
6
7
|
const response = await (await resolveClient()).dash.waitlist.form();
|
|
7
8
|
return {
|
|
8
|
-
acceptingEntries: response.
|
|
9
|
+
acceptingEntries: response.gate !== undefined,
|
|
9
10
|
collectMarketingConsent: response.collect_marketing_consent === true,
|
|
10
11
|
};
|
|
11
12
|
},
|
|
@@ -14,11 +15,18 @@ export function createC1MWaitlistProvider(resolveClient = getDashChannelClient)
|
|
|
14
15
|
email: input.email,
|
|
15
16
|
name: input.name,
|
|
16
17
|
marketing_opt_in: input.marketingOptIn === true,
|
|
17
|
-
source: "waitlist_page",
|
|
18
|
+
source: input.source ?? "waitlist_page",
|
|
19
|
+
attribution: input.attribution ?? (await attribution()),
|
|
18
20
|
}, { idempotencyKey: attemptId });
|
|
19
21
|
if (response.accepted !== true)
|
|
20
22
|
throw new Error("waitlist submission was not accepted");
|
|
21
23
|
return { accepted: true };
|
|
22
24
|
},
|
|
25
|
+
async verify(token) {
|
|
26
|
+
return (await (await resolveClient()).audience.verify(token)).verified === true;
|
|
27
|
+
},
|
|
28
|
+
async leave(key) {
|
|
29
|
+
return (await (await resolveClient()).audience.unsubscribe(key)).unsubscribed === true;
|
|
30
|
+
},
|
|
23
31
|
};
|
|
24
32
|
}
|
|
@@ -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
|
@@ -23,6 +23,8 @@ export type { ChannelSiteSentryEnvironment, ChannelSiteSentryOptions, } from "./
|
|
|
23
23
|
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
|
+
export { readFirstTouch, recordFirstTouch } from "./next/first-touch.js";
|
|
27
|
+
export { createDashSiteProxy, type DashSiteProxyOptions } from "./next/site-proxy.js";
|
|
26
28
|
export { createC1MDirectoryProvider } from "./next/providers/directory.js";
|
|
27
29
|
export { createC1MLeadPortalProvider } from "./next/providers/lead-portal.js";
|
|
28
30
|
export { createC1MLeadsProvider } from "./next/providers/leads.js";
|
package/dist/next.js
CHANGED
|
@@ -18,6 +18,8 @@ export { ChannelSiteSentryConfigurationError, createChannelSiteRequestErrorHandl
|
|
|
18
18
|
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
|
+
export { readFirstTouch, recordFirstTouch } from "./next/first-touch.js";
|
|
22
|
+
export { createDashSiteProxy } from "./next/site-proxy.js";
|
|
21
23
|
export { createC1MDirectoryProvider } from "./next/providers/directory.js";
|
|
22
24
|
export { createC1MLeadPortalProvider } from "./next/providers/lead-portal.js";
|
|
23
25
|
export { createC1MLeadsProvider } from "./next/providers/leads.js";
|
package/dist/ports/waitlist.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ import type { DashWaitlistForm, DashWaitlistReceipt, DashWaitlistSubmission } fr
|
|
|
2
2
|
export interface WaitlistProvider {
|
|
3
3
|
loadForm(): Promise<DashWaitlistForm>;
|
|
4
4
|
submit(input: DashWaitlistSubmission, attemptId: string): Promise<DashWaitlistReceipt>;
|
|
5
|
+
/** Confirms an email from the confirmation link; false for unknown or used tokens. */
|
|
6
|
+
verify(token: string): Promise<boolean>;
|
|
7
|
+
/** Revokes consent and leaves every list from an email's unsubscribe link. */
|
|
8
|
+
leave(key: string): Promise<boolean>;
|
|
5
9
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { DashWaitlistReceipt, DashWaitlistSubmission } from "../models/waitlist.js";
|
|
2
|
-
export declare function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, submit, }: {
|
|
2
|
+
export declare function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, placement, submit, }: {
|
|
3
3
|
acceptingEntries: boolean;
|
|
4
4
|
collectMarketingConsent: boolean;
|
|
5
|
+
/** Recorded as the signup's source. */
|
|
6
|
+
placement?: "page" | "block";
|
|
5
7
|
submit: (input: DashWaitlistSubmission) => Promise<DashWaitlistReceipt>;
|
|
6
8
|
}): import("react").JSX.Element;
|
package/dist/ui/waitlist-form.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useState } from "react";
|
|
4
|
-
export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, submit, }) {
|
|
4
|
+
export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, placement = "page", submit, }) {
|
|
5
5
|
const id = useId();
|
|
6
6
|
const [ready, setReady] = useState(false);
|
|
7
7
|
const [pending, setPending] = useState(false);
|
|
@@ -20,6 +20,7 @@ export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, su
|
|
|
20
20
|
email: String(values.get("email") ?? "").trim(),
|
|
21
21
|
name: String(values.get("name") ?? "").trim(),
|
|
22
22
|
marketingOptIn: collectMarketingConsent && values.get("marketing_opt_in") === "on",
|
|
23
|
+
source: placement === "block" ? "waitlist_block" : "waitlist_page",
|
|
23
24
|
});
|
|
24
25
|
if (receipt.accepted !== true)
|
|
25
26
|
throw new Error("waitlist submission was not accepted");
|
|
@@ -33,7 +34,7 @@ export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, su
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
if (accepted)
|
|
36
|
-
return _jsx("p", { role: "status", children: "Thanks.
|
|
37
|
+
return _jsx("p", { role: "status", children: "Thanks. Check your inbox to confirm your place." });
|
|
37
38
|
if (!acceptingEntries)
|
|
38
39
|
return _jsx("p", { role: "status", children: "The waitlist is currently closed." });
|
|
39
40
|
return (_jsxs("form", { className: "space-y-4", onSubmit: onSubmit, children: [_jsxs("label", { className: "block space-y-1.5", htmlFor: `${id}-name`, children: [_jsx("span", { className: "text-sm font-medium text-ink", children: "Name (optional)" }), _jsx("input", { className: "min-h-11 w-full rounded-xl border border-border bg-white px-3 py-2 text-ink", disabled: !ready || pending, id: `${id}-name`, maxLength: 255, name: "name", autoComplete: "name" })] }), _jsxs("label", { className: "block space-y-1.5", htmlFor: `${id}-email`, children: [_jsx("span", { className: "text-sm font-medium text-ink", children: "Email" }), _jsx("input", { className: "min-h-11 w-full rounded-xl border border-border bg-white px-3 py-2 text-ink", disabled: !ready || pending, id: `${id}-email`, maxLength: 254, name: "email", type: "email", autoComplete: "email", required: true })] }), collectMarketingConsent ? (_jsxs("label", { className: "flex items-start gap-2 text-sm leading-6 text-muted", children: [_jsx("input", { className: "mt-1", disabled: !ready || pending, name: "marketing_opt_in", type: "checkbox" }), _jsx("span", { children: "I would also like to receive marketing emails. I can unsubscribe later." })] })) : null, error ? _jsx("p", { className: "text-sm text-red-700", role: "alert", children: error }) : null, _jsx("button", { className: "min-h-11 rounded-full bg-accent px-5 py-2.5 text-sm font-semibold text-accent-foreground disabled:opacity-60", disabled: !ready || pending, type: "submit", children: pending ? "Joining…" : "Join the waitlist" })] }));
|
|
@@ -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.
|
|
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",
|
|
@@ -43,18 +43,20 @@
|
|
|
43
43
|
"server-only": "0.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@c1m-public/channel-client": ">=0.
|
|
46
|
+
"@c1m-public/channel-client": ">=0.28.0 <1",
|
|
47
47
|
"next": "^16",
|
|
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
|
-
"@
|
|
57
|
-
"@c1m-public/channel-client": "0.27.0"
|
|
59
|
+
"@c1m-public/channel-client": "0.28.0"
|
|
58
60
|
},
|
|
59
61
|
"peerDependenciesMeta": {
|
|
60
62
|
"next": {
|