@profullstack/waitlist 0.10.0 → 0.12.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 CHANGED
@@ -139,6 +139,7 @@ Every page showcases all plugins by default. Pick per site in `sites.json`:
139
139
  | `buyaday` | `<pf-buy-a-day>` from [@profullstack/marketing-widgets](https://github.com/profullstack/marketing-widgets): the next free doors on [holi.days](https://holi.days.pit.world/calendars) calendars (ones matching the site's keywords first), baked in and refreshed live, every sale credited to this site with `?ref=<host>`. Nothing shows when the feed is down. `buyadayKeywords` / `buyadayLimit` in `sites.json` override the keywords and count (default 3) |
140
140
  | `book` | The Profullstack pitch (four solution lines) and `<book-a-call>`, our booking widget: open times from the OutreachGraph public calendar in the reader's own time zone, booked inline as a PairUX call. A plain link to the booking page without script. `"booking": {"handle": "chovy"}` picks the calendar |
141
141
  | `promo` | "More from the network": sister properties from the live `@profullstack/cross-promo` catalog, tagged `utm_medium=waitlist`. `"promoAudience": "developers"` (or a list) overrides the audience picked from the hierarchy |
142
+ | `community` | A header bar with Search and a branded **Community** button to the name's own tsbb board (`https://bbs.<name>.pit.world`, sign in with pit.world / CoinPay OAuth 2.1, or `tsbb login <board> --with coinpay`). Linked only once the board answers over HTTPS, so new names gain it as their certificate lands. Writes `brand.json` (look, colours, light/dark, closest tsbb skin) that pit.world's board seed uses to match the site |
142
143
  | (search, resources) | Every search item and resource carries pit.world's result tools from `https://pit.world/widgets.js`: vote, Summarize, Listen and Share. They work without an account; on a pit.world host, "Sign in with CoinPay" (OAuth 2.1 + PKCE through pit.world) raises the limits. From a terminal the same account is `pit login` |
143
144
  | `affiliate` | Referrals (0.9). Every signup gets a personal link `https://<site>/?ref=<code>`, shown right after joining by `<pf-referral-share>` ("You are #X of Y, N people referred.", copy button, plain X/Bluesky/LinkedIn/email links) and in the confirmation email with a signed status page. A visitor who arrives with `?ref=` keeps a 30-day first-party, first-touch cookie `wl_ref`; their signup credits the referrer once they confirm. Each confirmed referral moves the referrer up `bumpPlaces`. A "Move up the list" section bakes `<pf-referral-leaderboard>` (handles or masked emails only). With `buyaday` on, a door sold to a referred visitor credits the referrer too (holi.days `ref=<code>.<site>`). See below |
144
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/waitlist",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Email waitlist for any launch page: a <waitlist-form> web component, a live signup chart, and a static-site builder on @profullstack/css + @profullstack/charts.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/build.js CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { mkdir, writeFile, copyFile, readFile, readdir } from 'node:fs/promises';
6
6
  import { pluginSet, keywordsFor, runPlugins, baseSlot, affiliateConfig } from './plugins.js';
7
+ import { boardLive, boardUrl, brandJson, navHtml } from './community.js';
7
8
  import {
8
9
  TABS, SORTS, tabPath, searchPageHtml, searchPageMeta, searchJson, searchLlms, manifestJson,
9
10
  openSearchXml, serviceWorker, maskableIconSvg,
@@ -39,7 +40,10 @@ export const DEFAULT_AB = { experiment: 'waitlist-look-v1', arms: ['themed', 'cl
39
40
  */
40
41
  export function abHeadScript(ab, themed) {
41
42
  const cfg = JSON.stringify({ e: ab.experiment, a: ab.arms, t: themed }).replace(/</g, '\\u003c');
42
- return `<script>(function(c){try{var L=localStorage,u=L.getItem("wl-unit");if(!u){u=Array.from(crypto.getRandomValues(new Uint8Array(12)),function(b){return(b%36).toString(36)}).join("");L.setItem("wl-unit",u)}
43
+ // The unit lives in localStorage and in a wl-unit cookie on this host, which bbs.<host> and
44
+ // social.<host> read too (tsbb 0.18+ board.lookAb): one visitor, one arm, across all three.
45
+ return `<script>(function(c){try{var L=localStorage,m=document.cookie.match(/(?:^|; )wl-unit=([a-z0-9]{6,32})/),u=(m&&m[1])||L.getItem("wl-unit");if(!u){u=Array.from(crypto.getRandomValues(new Uint8Array(12)),function(b){return(b%36).toString(36)}).join("")}L.setItem("wl-unit",u);
46
+ document.cookie="wl-unit="+u+"; Domain="+location.hostname.replace(/^www\\./,"")+"; Path=/; Max-Age=31536000; SameSite=Lax"+(location.protocol==="https:"?"; Secure":"");
43
47
  function h(s){var a=3735928559,b=1103547991;for(var i=0;i<s.length;i++){var k=s.charCodeAt(i);a=Math.imul(a^k,2654435761);b=Math.imul(b^k,1597334677)}a=Math.imul(a^a>>>16,2246822507);a^=Math.imul(b^b>>>13,3266489909);b=Math.imul(b^b>>>16,2246822507);b^=Math.imul(a^a>>>13,3266489909);return 4294967296*(2097151&b)+(a>>>0)}
44
48
  var w=L.getItem("wl-winner:"+c.e),arm=w&&c.a.indexOf(w)>=0?w:c.a[Math.floor(h(c.e+"\\0"+u)/Math.pow(2,53)*c.a.length)],d=document.documentElement;
45
49
  d.dataset.look=arm==="themed"?c.t:arm;d.dataset.abArm=arm;window.__wlab={experiment:c.e,unit:u,arm:arm,themed:c.t,winner:!!w}}catch(x){}})(${cfg});</script>`;
@@ -168,6 +172,7 @@ ${slot.head.join('\n')}
168
172
  </head>
169
173
  <body class="waitlist-page">
170
174
  <div data-look-marquee aria-hidden="true"><span>${esc(s.marquee)}</span></div>
175
+ ${navHtml(s, { community: s.community ?? null, esc })}
171
176
  <main class="container">
172
177
  ${main}
173
178
  <p class="waitlist-meta">${s.moshpit ? `Also at <a href="${esc(s.nativeUrl)}">${esc(s.nativeUrl.replace(/\/$/, ''))}</a> on the Moshpit. ` : ''}One email when it opens, nothing else. Hosted on <a href="https://c0mpute.com/hosting">c0mpute</a>.</p>
@@ -261,6 +266,11 @@ export async function buildSite(spec, out, { footers = true, images = true, fetc
261
266
  const foot = footers ? await renderFooters(s, { fetchImpl }) : '';
262
267
  const { slot, search } = await runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, searchOpts });
263
268
  s.searchLive = Boolean(search?.live?.length);
269
+ // community: the name's own board, linked once it answers over HTTPS; brand.json for its look.
270
+ if (s.plugins.has('community')) {
271
+ s.community = (await boardLive(boardUrl(s), { fetchImpl })) ? boardUrl(s) : null;
272
+ await writeFile(join(out, 'brand.json'), JSON.stringify(await brandJson(s), null, 2) + '\n');
273
+ }
264
274
  // Assets are cached by browsers and gateways (max-age 1 h), so a page must name the
265
275
  // exact build of every script and stylesheet it needs, or a new page runs old code.
266
276
  const ver = await versionAssets(out);
@@ -0,0 +1,85 @@
1
+ /**
2
+ * community: a branded "Community" link to the name's own board, and the site's brand for it.
3
+ *
4
+ * Every Moshpit name has a tsbb board at https://bbs.<name>.pit.world (pit.world makes it on the
5
+ * first visit; people sign in with their pit.world account, which is CoinPay OAuth 2.1, or with
6
+ * `tsbb login <board> --with coinpay` from a terminal). Its HTTPS certificate arrives with the
7
+ * name's, so the link is drawn only once the board answers over HTTPS: the daily rebuild adds it
8
+ * as certificates land, and a page never links to a broken board.
9
+ *
10
+ * brand.json tells the board how to look like this site: the look, its colours, light or dark,
11
+ * and the closest tsbb skin. pit.world's board seed reads it.
12
+ */
13
+ import { readFile } from 'node:fs/promises';
14
+ import { createRequire } from 'node:module';
15
+ import { dirname, join } from 'node:path';
16
+
17
+ const require = createRequire(import.meta.url);
18
+
19
+ /** The closest tsbb skin (modern, classic, terminal, paper) for each @profullstack/css look. */
20
+ const SKIN = {
21
+ terminal: 'terminal', matrix: 'terminal', amber: 'terminal', bbs: 'terminal', minitel: 'terminal', compuserve: 'terminal',
22
+ geocities: 'classic', aol: 'classic', prodigy: 'classic', brutalist: 'classic',
23
+ editorial: 'paper', swiss: 'paper',
24
+ };
25
+
26
+ let looksCss = null;
27
+ async function looks() {
28
+ looksCss ??= await readFile(join(dirname(require.resolve('@profullstack/css/css')), 'looks.css'), 'utf8');
29
+ return looksCss;
30
+ }
31
+
32
+ /** A look's palette from @profullstack/css: { scheme, primary, canvas, ink }. Missing values are null. */
33
+ export async function lookPalette(look) {
34
+ const css = await looks();
35
+ const at = css.indexOf(`:root[data-look="${look}"] {`);
36
+ if (at < 0) return { scheme: null, primary: null, canvas: null, ink: null };
37
+ const block = css.slice(at, css.indexOf('}', at));
38
+ const v = (name) => block.match(new RegExp(`--pf-color-${name}\\s*:\\s*(#[0-9a-fA-F]{3,8})`))?.[1] ?? null;
39
+ return { scheme: block.match(/color-scheme:\s*(light|dark)/)?.[1] ?? null, primary: v('primary'), canvas: v('canvas'), ink: v('ink') };
40
+ }
41
+
42
+ export function boardUrl(s) {
43
+ return s.moshpit ? `https://bbs.${s.name}.pit.world/` : null;
44
+ }
45
+
46
+ export async function brandJson(s) {
47
+ const p = await lookPalette(s.look);
48
+ return {
49
+ name: s.name,
50
+ title: s.title,
51
+ tagline: s.tagline,
52
+ url: s.url,
53
+ look: s.look,
54
+ scheme: p.scheme ?? (s.theme === 'light' ? 'light' : 'dark'),
55
+ primary: p.primary,
56
+ canvas: p.canvas,
57
+ ink: p.ink,
58
+ skin: SKIN[s.look] ?? 'modern',
59
+ icon: `${s.url}assets/icon-192.png`,
60
+ community: boardUrl(s),
61
+ // The look A/B test the site runs, for the board and social feed to share (same wl-unit cookie).
62
+ ab: s.ab ? { experiment: s.ab.experiment, arms: s.ab.arms } : null,
63
+ };
64
+ }
65
+
66
+ /** True when the board answers over HTTPS (any status below 500). Never throws. */
67
+ export async function boardLive(url, { fetchImpl = globalThis.fetch, timeoutMs = 10000 } = {}) {
68
+ if (!url) return false;
69
+ try {
70
+ const r = await fetchImpl(`${url}healthz`, { method: 'GET', redirect: 'manual', signal: AbortSignal.timeout(timeoutMs), headers: { 'user-agent': '@profullstack/waitlist (+https://github.com/profullstack/waitlist)' } });
71
+ return r.status < 500;
72
+ } catch {
73
+ return false;
74
+ }
75
+ }
76
+
77
+ /** The header bar: the site's name, its search, and the Community link when the board is live. */
78
+ export function navHtml(s, { community = null, esc }) {
79
+ const links = [
80
+ s.searchLive ? `<a href="search/">Search</a>` : '',
81
+ community ? `<a class="waitlist-community" href="${esc(community)}" rel="noopener">Community</a>` : '',
82
+ ].filter(Boolean);
83
+ if (!links.length) return '';
84
+ return `<nav class="waitlist-nav container" aria-label="${esc(s.title)}"><a class="waitlist-nav-home" href="./">${esc(s.title)}</a><span class="waitlist-nav-links">${links.join('')}</span></nav>`;
85
+ }
package/src/plugins.js CHANGED
@@ -24,7 +24,7 @@ import { fetchSearch, searchCardHtml } from './search.js';
24
24
 
25
25
  const require = createRequire(import.meta.url);
26
26
 
27
- export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'search', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo', 'affiliate'];
27
+ export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'search', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo', 'affiliate', 'community'];
28
28
 
29
29
  /** Resolve a site's `plugins` setting to a Set (default: all of them). */
30
30
  export function pluginSet(setting) {
package/src/waitlist.css CHANGED
@@ -46,3 +46,12 @@
46
46
  .wl-search .field-group { display: flex; gap: .4rem; }
47
47
  .wl-search input[type="search"] { flex: 1; min-width: 0; }
48
48
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
49
+
50
+ /* community: the header bar with the Community link (0.11.0) */
51
+ .waitlist-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .75rem; }
52
+ .waitlist-nav-home { font-weight: 700; text-decoration: none; color: inherit; }
53
+ .waitlist-nav-links { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
54
+ .waitlist-nav-links a { text-decoration: none; padding: .35rem .8rem; border-radius: 999px; border: 1px solid color-mix(in srgb, currentColor 25%, transparent); color: inherit; font-size: .9rem; }
55
+ .waitlist-nav-links a:hover { border-color: currentColor; }
56
+ .waitlist-nav-links a.waitlist-community { background: var(--pf-color-primary, currentColor); color: var(--pf-color-on-primary, #fff); border-color: transparent; font-weight: 700; }
57
+ .waitlist-nav-links a.waitlist-community:hover { filter: brightness(1.1); }