Files
vercel__workflow/tarballs/src/styles.css
Pranay Prakash b883ea0de8 tarballs: redesign preview tarballs index page (#1911)
* tarballs: redesign preview tarballs index page

Rebuild the static index page produced by `tarballs/scripts/pack.ts`:

- Featured `workflow` package up top with prominent install command,
  copy button, and direct tarball download
- Top-of-page metadata chips: short SHA (linked to commit), branch,
  PR number, build timestamp, package count + total size
- Collapsible "What is this?" explainer
- Package-manager tab toggle (pnpm / npm / yarn / bun) that swaps the
  install command for every row in place
- Live filter input over the rest of the package list (with `/` shortcut)
- Per-row install command, copy button, and direct download
- Modern dark/light theme with system preference, Geist-inspired styling

Also captures tarball size during pack and renders human-readable byte counts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tarballs: fix client-side interactivity broken by HTML-encoded JSON

`escapeHtml(JSON.stringify(catalog))` was HTML-encoding every quote in
the embedded catalog JSON to `&quot;`, so `JSON.parse(textContent)` threw
on the first character and the IIFE bailed before attaching any event
listeners — package-manager toggle, search filter, copy buttons, and the
`/` shortcut were all dead UI on the deployed page.

`<script type="application/json">` content is treated as text by the HTML
parser; the only sequence that can break out is `</script>` (or `</`
in legacy parsers). Replace `<` with the JSON `<` escape, which is
legal per the JSON spec and prevents the breakout without needing entity
encoding.

Also switch `formatBytes` from `KB`/`MB` to `KiB`/`MiB` since the
divisor is 1024.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tarballs: rewrite as Vite + Preact SPA with file breakdown, fix bundling

Address TooTallNate's review feedback by replacing the hand-rolled HTML-
in-template-literal approach with a small Vite + Preact SPA. The old
~600 lines of inlined HTML/CSS/JS in `pack.ts` is now `~80 lines of TSX`,
fully type-checked.

Layout:
- `tarballs/index.html`, `vite.config.ts`, `tsconfig.json` at the root
- `src/main.tsx` mounts the Preact app and fetches `/catalog.json`
- `src/app.tsx` is the page (Header, FeaturedCard, PackageRow, etc.)
- `src/catalog.ts` is the shared types + helpers (`buildInstallCommand`,
  `formatBytes`)
- `src/icons.tsx`, `src/styles.css`
- `scripts/pack.ts` is now data-only — it scans packages, packs
  tarballs, and writes `public/catalog.json`

The eliminates several smells the reviewer called out:
- The interactive script is now TypeScript with strict mode and JSX
  type checking instead of an inline `<script>` block
- The `escapeHtml`-around-JSON-blob hack that broke client-side JS in
  the prior commit is gone; the SPA fetches `catalog.json` and parses
  it natively
- Pack-time logic and presentation logic no longer share a file

# Fix bundling: tarballs now actually contain compiled code

While verifying real tarball sizes I noticed `workflow-serde.tgz` was
only 828 bytes — it had `package.json`, `LICENSE.md`, `README.md` and
*nothing* else, because each package's `files: ["dist"]` excludes
sources but `dist/` hadn't been built. The Vercel build was running
`pnpm --filter tarballs build`, which only builds the `tarballs`
package itself — its workspace dependencies were never built.

Switch `vercel.json#buildCommand` to `pnpm turbo run build
--filter=tarballs`, which transitively builds dependencies first via
the `dependsOn: ["^build"]` rule already in the root `turbo.json`. With
the fix:

  workflow:        241 KiB  →  252 KiB tarball, 916 KiB unpacked, 205 files
  @workflow/core:   59 KiB  →  493 KiB tarball, 1.70 MiB unpacked, 236 files
  @workflow/serde: 828 B    →  1.4 KiB tarball, 4.6 KiB unpacked, 7 files

Add a smoke check that the `workflow` package has at least 5 files in
its tarball — catches the regression directly.

# Per-package contents view (packagephobia-style)

`pack.ts` now also runs `tar -tvzf` on each tarball and records the
file list with sizes. The SPA renders this as an expandable
"What's inside?" disclosure per package, grouped by top-level
directory (e.g. `dist/`, `docs/`) with proportional bars showing
each group's share of the unpacked size, and the largest files
listed below.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tarballs: replace tar shell-out with in-process tar reader

The smoke check broke in CI: `'workflow' tarball only has 0 files`.
Root cause is that `tar -tvzf` emits a different verbose layout on GNU
tar (Linux, what CI runs) vs BSD tar (macOS, where I tested locally) —
the parser only matched the BSD column ordering, so on Linux every line
was rejected and `fileCount` came out as 0.

Replace the shell-out with a small in-process tar reader using
`zlib.gunzipSync` + manual 512-byte block walk. ustar headers are
trivially structured (name at offset 0, octal size at 124, typeflag at
156, ustar prefix at 345). We emit regular files only (`typeflag` `0`
or NUL) and consume but skip pax extended headers (`x`/`g`) and GNU
long-name entries (`L`). Result is identical on every platform.

Verified locally: 206 files / 998413 bytes for `workflow.tgz` matches
`tar -tvzf` exactly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tarballs: redesign per-package details with packagephobia-style stats

The previous "What's inside?" view crammed nested directory groups,
proportional bars, and per-group file lists into a `<details>` inside
an already-narrow row. It was hard to read and harder to compare.

Replace it with the layout packagephobia uses on its result page:

- Two large headline metric tiles (Publish size / Unpacked size)
  with a big bold value, smaller unit, and small uppercase label.
  Modeled directly on packagephobia's `Stats` component but using
  our existing CSS variables so it tracks light/dark theme.
- A single sortable file table beneath. Default is size-descending so
  the contributors to package size are immediately visible. Click a
  header to flip direction or switch sort key. Sticky header keeps
  the columns visible inside the scrollable region.

Drop the `groupByTopLevel`, `ContentsGroup`, and bar-chart styles —
they were the source of the "hard to use" feedback and don't add
information that the flat sortable table doesn't already convey.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* tarballs: address Copilot review feedback (a11y, dev script, caching)

- main.tsx: drop `cache: 'no-store'` from the catalog fetch. Each
  tarballs deployment is immutable per commit, so HTTP caching is
  appropriate; forcing no-store made every visit re-download the full
  catalog (which now includes per-package file lists).
- app.tsx (search input): add `aria-label="Filter packages"`. The
  visible label only contained an icon and placeholder, so screen
  readers had no name for the control.
- app.tsx (PmTabs): replace `role="tablist"` / `role="tab"` /
  `aria-selected` with plain buttons that use `aria-pressed`. The
  ARIA tab pattern requires arrow-key roving focus we never wired
  up; toggle buttons are the honest representation. Each button
  also gets an explicit `aria-label`.
- app.tsx (row buttons): include the package name in the accessible
  label of every per-row copy/download button (and on the featured
  card too), so the screen reader buttons/links list distinguishes
  them. Added an `accessibleName` prop to `CopyButton`.
- app.tsx (CopyButton): only flip to the "Copied" state when the
  write actually succeeded. Both the modern `navigator.clipboard`
  path and the `execCommand` fallback can fail; the new
  `writeToClipboard` helper returns success and the button shows a
  short "Failed" state if both paths fail.

# Make `pnpm dev` work from a clean checkout

The previous `dev: vite` couldn't actually serve the page because
`/catalog.json` 404s and the SPA boots into the error fallback.

Restructure the build layout to vite's conventional shape:
- `public/` is now a true vite public dir — pack writes tarballs and
  catalog.json there. In dev, vite serves these at the root.
- `dist/` is the production build output (vite copies public/ into it
  and adds index.html + assets/).
- `vercel.json#outputDirectory` switches from `public` → `dist`.
- `turbo.json` outputs updated to match.
- `dev` chains pack before vite so the catalog exists when the dev
  server starts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 15:16:08 -07:00

795 lines
14 KiB
CSS

:root {
color-scheme: light dark;
--bg: #ffffff;
--bg-elevated: #fafafa;
--bg-hover: #f5f5f5;
--fg: #0a0a0a;
--fg-muted: #666666;
--fg-subtle: #999999;
--border: #eaeaea;
--border-strong: #d4d4d4;
--accent: #0070f3;
--accent-fg: #ffffff;
--accent-soft: rgba(0, 112, 243, 0.12);
--code-bg: #f5f5f5;
--success: #16a34a;
--shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0a0a0a;
--bg-elevated: #111111;
--bg-hover: #1a1a1a;
--fg: #ededed;
--fg-muted: #a1a1a1;
--fg-subtle: #666666;
--border: #1f1f1f;
--border-strong: #2a2a2a;
--accent: #3291ff;
--accent-soft: rgba(50, 145, 255, 0.18);
--code-bg: #161616;
--success: #4ade80;
--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
}
body {
font-family:
'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--bg);
color: var(--fg);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code,
pre,
.mono {
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.container {
max-width: 1040px;
margin: 0 auto;
padding: 2.5rem 1.5rem 5rem;
}
header.page {
margin-bottom: 2.5rem;
}
h1 {
font-size: 2rem;
font-weight: 600;
letter-spacing: -0.02em;
margin: 0 0 0.5rem;
}
.lede {
color: var(--fg-muted);
font-size: 1rem;
margin: 0 0 1.25rem;
max-width: 60ch;
}
.meta-chips {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
}
.chip {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.3rem 0.65rem;
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: 999px;
font-size: 0.8rem;
color: var(--fg-muted);
text-decoration: none;
transition:
background 0.15s,
border-color 0.15s,
color 0.15s;
}
a.chip:hover {
background: var(--bg-hover);
border-color: var(--border-strong);
color: var(--fg);
}
.chip code {
background: transparent;
padding: 0;
font-size: 0.8rem;
}
details.about {
margin: 1.5rem 0 0;
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: 10px;
padding: 0.75rem 1rem;
}
details.about summary {
cursor: pointer;
font-weight: 500;
font-size: 0.9rem;
list-style: none;
display: flex;
align-items: center;
gap: 0.5rem;
color: var(--fg);
}
details.about summary::-webkit-details-marker {
display: none;
}
details.about summary::before {
content: '▸';
font-size: 0.7rem;
color: var(--fg-muted);
transition: transform 0.15s;
}
details.about[open] summary::before {
transform: rotate(90deg);
}
details.about p {
margin: 0.75rem 0 0;
color: var(--fg-muted);
font-size: 0.9rem;
}
details.about p + p {
margin-top: 0.5rem;
}
details.about code {
background: var(--code-bg);
padding: 0.1rem 0.35rem;
border-radius: 4px;
font-size: 0.85rem;
}
.controls {
display: flex;
gap: 1rem;
align-items: center;
margin: 0.5rem 0 1rem;
flex-wrap: wrap;
}
.pm-tabs {
display: inline-flex;
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: 8px;
padding: 3px;
gap: 2px;
}
.pm-tab {
appearance: none;
background: transparent;
border: 0;
padding: 0.4rem 0.85rem;
font-family: inherit;
font-size: 0.85rem;
font-weight: 500;
color: var(--fg-muted);
border-radius: 6px;
cursor: pointer;
transition:
background 0.15s,
color 0.15s;
}
.pm-tab:hover {
color: var(--fg);
}
.pm-tab[aria-pressed='true'] {
background: var(--bg);
color: var(--fg);
box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) {
.pm-tab[aria-pressed='true'] {
background: var(--bg-hover);
}
}
.search {
flex: 1;
min-width: 200px;
position: relative;
}
.search input {
width: 100%;
padding: 0.55rem 0.85rem 0.55rem 2.25rem;
font-family: inherit;
font-size: 0.9rem;
background: var(--bg-elevated);
border: 1px solid var(--border);
color: var(--fg);
border-radius: 8px;
outline: none;
transition:
border-color 0.15s,
background 0.15s;
}
.search input:focus {
border-color: var(--accent);
background: var(--bg);
}
.search svg {
position: absolute;
left: 0.75rem;
top: 50%;
transform: translateY(-50%);
color: var(--fg-subtle);
pointer-events: none;
}
/* Featured card */
.featured {
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 2.5rem;
position: relative;
overflow: hidden;
}
.featured::before {
content: '';
position: absolute;
inset: 0;
background: radial-gradient(
circle at top right,
var(--accent-soft),
transparent 60%
);
pointer-events: none;
}
.featured > * {
position: relative;
}
.featured-header {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 0.75rem;
margin-bottom: 0.5rem;
}
.featured-badge {
display: inline-flex;
align-items: center;
gap: 0.35rem;
padding: 0.2rem 0.55rem;
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
background: var(--accent);
color: var(--accent-fg);
border-radius: 4px;
}
.featured-name {
font-size: 1.5rem;
font-weight: 600;
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: -0.01em;
}
.featured-version,
.featured-size {
color: var(--fg-muted);
font-size: 0.85rem;
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
.featured-desc {
color: var(--fg-muted);
font-size: 0.95rem;
margin: 0 0 1.25rem;
}
.install-block {
display: flex;
gap: 0.5rem;
align-items: stretch;
}
.install-cmd {
flex: 1;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 0.75rem 1rem;
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.9rem;
overflow-x: auto;
white-space: nowrap;
color: var(--fg);
}
.install-cmd::-webkit-scrollbar {
height: 4px;
}
.install-cmd::-webkit-scrollbar-thumb {
background: var(--border-strong);
border-radius: 2px;
}
.copy-btn,
.download-btn {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0 1rem;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
font-family: inherit;
font-size: 0.85rem;
font-weight: 500;
color: var(--fg);
cursor: pointer;
text-decoration: none;
transition:
background 0.15s,
border-color 0.15s;
}
.copy-btn:hover,
.download-btn:hover {
background: var(--bg-hover);
border-color: var(--border-strong);
}
.copy-btn[data-copied='true'] {
color: var(--success);
border-color: var(--success);
}
.copy-btn[data-failed='true'],
.icon-btn[data-failed='true'] {
color: #dc2626;
border-color: #dc2626;
}
@media (prefers-color-scheme: dark) {
.copy-btn[data-failed='true'],
.icon-btn[data-failed='true'] {
color: #f87171;
border-color: #f87171;
}
}
/* Other packages section */
.section-title {
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--fg-muted);
margin: 0 0 0.75rem;
}
.pkg-list {
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
background: var(--bg-elevated);
}
.pkg-row {
display: grid;
grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) auto;
align-items: center;
gap: 1rem;
padding: 0.85rem 1.25rem;
border-bottom: 1px solid var(--border);
transition: background 0.1s;
}
.pkg-row:last-child {
border-bottom: 0;
}
.pkg-row:hover {
background: var(--bg-hover);
}
.pkg-info {
min-width: 0;
}
.pkg-name {
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.9rem;
font-weight: 500;
color: var(--fg);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.pkg-meta {
font-size: 0.75rem;
color: var(--fg-subtle);
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
margin-top: 0.15rem;
}
.pkg-cmd {
background: var(--bg);
border: 1px solid var(--border);
border-radius: 6px;
padding: 0.45rem 0.7rem;
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.8rem;
overflow-x: auto;
white-space: nowrap;
color: var(--fg);
min-width: 0;
}
.pkg-actions {
display: flex;
gap: 0.4rem;
}
.icon-btn {
appearance: none;
background: transparent;
border: 1px solid var(--border);
border-radius: 6px;
width: 32px;
height: 32px;
display: inline-flex;
align-items: center;
justify-content: center;
color: var(--fg-muted);
cursor: pointer;
transition:
background 0.15s,
color 0.15s,
border-color 0.15s;
text-decoration: none;
}
.icon-btn:hover {
background: var(--bg-hover);
color: var(--fg);
border-color: var(--border-strong);
}
.icon-btn[data-copied='true'] {
color: var(--success);
border-color: var(--success);
}
.empty {
padding: 2rem 1.25rem;
text-align: center;
color: var(--fg-muted);
font-size: 0.9rem;
}
footer.page {
margin-top: 3rem;
padding-top: 1.5rem;
border-top: 1px solid var(--border);
font-size: 0.8rem;
color: var(--fg-subtle);
}
footer.page a {
color: var(--fg-muted);
text-decoration: none;
}
footer.page a:hover {
color: var(--fg);
}
/* Package contents (file breakdown) */
details.contents {
margin-top: 1rem;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--bg);
overflow: hidden;
}
details.contents-row {
grid-column: 1 / -1;
margin-top: 0.5rem;
background: transparent;
}
details.contents > summary {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.6rem 0.85rem;
cursor: pointer;
list-style: none;
font-size: 0.8rem;
font-weight: 500;
color: var(--fg-muted);
user-select: none;
}
details.contents > summary::-webkit-details-marker {
display: none;
}
details.contents > summary svg {
transition: transform 0.15s;
}
details.contents[open] > summary svg {
transform: rotate(180deg);
}
details.contents > summary:hover {
color: var(--fg);
}
.contents-summary-meta {
margin-left: auto;
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.75rem;
color: var(--fg-subtle);
}
.contents-body {
padding: 0;
border-top: 1px solid var(--border);
}
/* Stats — packagephobia-style headline metrics */
.size-stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0;
border-bottom: 1px solid var(--border);
background: var(--bg-elevated);
}
.size-stat {
padding: 1.5rem 1.25rem;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.size-stat + .size-stat {
border-left: 1px solid var(--border);
}
.size-stat-row {
display: flex;
align-items: baseline;
gap: 0.35rem;
line-height: 1;
}
.size-stat-value {
font-size: 2.5rem;
font-weight: 700;
letter-spacing: -0.02em;
color: var(--fg);
font-variant-numeric: tabular-nums;
}
.size-stat-unit {
font-size: 1.4rem;
font-weight: 600;
color: var(--fg-muted);
}
.size-stat-label {
margin-top: 0.5rem;
font-size: 0.7rem;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.12em;
color: var(--fg-muted);
}
@media (max-width: 480px) {
.size-stat-value {
font-size: 1.8rem;
}
.size-stat-unit {
font-size: 1.1rem;
}
}
/* Sortable file table */
.file-table-wrap {
max-height: 360px;
overflow-y: auto;
}
.file-table {
width: 100%;
border-collapse: collapse;
font-family:
'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.78rem;
}
.file-table thead {
position: sticky;
top: 0;
background: var(--bg-elevated);
z-index: 1;
}
.file-table th {
text-align: left;
padding: 0;
border-bottom: 1px solid var(--border);
}
.file-table th.file-table-size {
text-align: right;
width: 110px;
}
.sort-btn {
appearance: none;
background: transparent;
border: 0;
width: 100%;
padding: 0.55rem 0.85rem;
font-family: inherit;
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--fg-muted);
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 0.4rem;
text-align: inherit;
}
.file-table th.file-table-size .sort-btn {
justify-content: flex-end;
}
.sort-btn:hover {
color: var(--fg);
}
.sort-indicator {
display: inline-block;
width: 10px;
text-align: center;
color: var(--fg-subtle);
font-size: 0.85em;
}
.sort-indicator-active {
color: var(--accent);
}
.file-table tbody tr {
border-bottom: 1px solid var(--border);
}
.file-table tbody tr:last-child {
border-bottom: 0;
}
.file-table tbody tr:hover {
background: var(--bg-hover);
}
.file-table td {
padding: 0.4rem 0.85rem;
vertical-align: top;
}
.file-path {
color: var(--fg);
word-break: break-all;
}
.file-size {
color: var(--fg-muted);
text-align: right;
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.error {
max-width: 600px;
margin: 4rem auto;
padding: 1.5rem;
border: 1px solid var(--border);
border-radius: 8px;
}
.error pre {
white-space: pre-wrap;
word-break: break-word;
background: var(--code-bg);
padding: 1rem;
border-radius: 6px;
font-size: 0.85rem;
}
@media (max-width: 720px) {
.container {
padding: 1.5rem 1rem 3rem;
}
h1 {
font-size: 1.5rem;
}
.featured-name {
font-size: 1.2rem;
}
.install-block {
flex-direction: column;
}
.copy-btn,
.download-btn {
padding: 0.55rem 1rem;
justify-content: center;
}
.pkg-row {
grid-template-columns: 1fr;
gap: 0.5rem;
}
.pkg-actions {
justify-content: flex-end;
}
}