{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "simplex-noise-changelog",
  "title": "Simplex Noise Changelog",
  "description": "A changelog timeline where every release gets its own cover, generated from the version number.",
  "dependencies": [
    "@paper-design/shaders-react"
  ],
  "files": [
    {
      "path": "registry/shaders/simplex-noise-changelog/simplex-noise-changelog.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { SimplexNoise } from \"@paper-design/shaders-react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype ChangeType = \"new\" | \"improved\" | \"fixed\"\n\ntype Release = {\n  version: string\n  /** ISO date, like \"2026-09-30\". */\n  date: string\n  title: string\n  description?: string\n  changes?: { type: ChangeType; text: string }[]\n  /** A cover image. Leave it out to get one generated from the version. */\n  image?: string\n  href?: string\n}\n\nconst DEFAULT_RELEASES: Release[] = [\n  {\n    version: \"3.2\",\n    date: \"2026-09-30\",\n    title: \"Shared workspaces\",\n    description:\n      \"Invite your whole team to a workspace, with roles, shared templates and one bill.\",\n    changes: [\n      { type: \"new\", text: \"Workspaces with owner, editor and viewer roles\" },\n      { type: \"new\", text: \"Templates shared across a workspace\" },\n      { type: \"improved\", text: \"Search is up to 4× faster on large projects\" },\n      { type: \"fixed\", text: \"Exports no longer drop the last page\" },\n    ],\n  },\n  {\n    version: \"3.1\",\n    date: \"2026-08-12\",\n    title: \"Offline mode\",\n    description:\n      \"Keep working on the train. Changes sync the moment you're back online.\",\n    changes: [\n      { type: \"new\", text: \"Full offline editing on desktop and mobile\" },\n      { type: \"improved\", text: \"Conflicts are merged line by line\" },\n      { type: \"fixed\", text: \"Dark mode flashing on first load\" },\n    ],\n  },\n  {\n    version: \"3.0\",\n    date: \"2026-06-24\",\n    title: \"A faster, calmer editor\",\n    description:\n      \"Rebuilt from the ground up. Opens instantly, even with thousands of pages.\",\n    changes: [\n      { type: \"new\", text: \"A brand new editor engine\" },\n      { type: \"new\", text: \"Command menu for everything\" },\n      { type: \"improved\", text: \"Startup time down from 2.1s to 300ms\" },\n    ],\n  },\n]\n\nconst CHANGE_LABELS: Record<ChangeType, string> = {\n  new: \"New\",\n  improved: \"Improved\",\n  fixed: \"Fixed\",\n}\n\n// Dates are formatted in UTC with a fixed locale, so the server and the\n// browser always agree.\nconst dateFormat = new Intl.DateTimeFormat(\"en-US\", {\n  dateStyle: \"medium\",\n  timeZone: \"UTC\",\n})\n\ntype SimplexNoiseChangelogProps = React.ComponentProps<\"section\"> & {\n  title?: string\n  description?: string\n  releases?: Release[]\n  /**\n   * Colors of the generated covers. Every cover uses the same colors, in a\n   * different order and shape picked from its version.\n   */\n  colors?: string[]\n}\n\nfunction SimplexNoiseChangelog({\n  title = \"Changelog\",\n  description = \"New features, improvements and fixes, shipped every few weeks.\",\n  releases = DEFAULT_RELEASES,\n  colors = [\"#1e1b4b\", \"#4f46e5\", \"#22d3ee\", \"#f472b6\", \"#fde68a\"],\n  className,\n  ...props\n}: SimplexNoiseChangelogProps) {\n  return (\n    <section\n      data-slot=\"simplex-noise-changelog\"\n      className={cn(\n        \"flex w-full flex-col gap-16 bg-background px-6 py-20 text-foreground md:px-12 lg:px-16\",\n        className\n      )}\n      {...props}\n    >\n      <div className=\"flex max-w-2xl flex-col gap-4\">\n        <h2 className=\"font-heading text-4xl leading-tight tracking-tight sm:text-6xl\">\n          {title}\n        </h2>\n        <p className=\"max-w-md text-base text-pretty text-muted-foreground\">\n          {description}\n        </p>\n      </div>\n      <ol className=\"flex flex-col\">\n        {releases.map((release) => (\n          <li\n            key={release.version}\n            className=\"grid gap-4 border-t py-12 md:grid-cols-[12rem_1fr] md:gap-10\"\n          >\n            <div className=\"flex items-center gap-3 md:sticky md:top-8 md:flex-col md:items-start md:self-start\">\n              <time\n                dateTime={release.date}\n                className=\"text-sm text-muted-foreground\"\n              >\n                {dateFormat.format(new Date(release.date))}\n              </time>\n              <span className=\"border px-2 py-0.5 font-mono text-xs\">\n                v{release.version}\n              </span>\n            </div>\n            <article className=\"flex max-w-2xl flex-col gap-5\">\n              <div className=\"relative aspect-2/1 w-full overflow-hidden border\">\n                {release.image ? (\n                  // eslint-disable-next-line @next/next/no-img-element\n                  <img\n                    src={release.image}\n                    alt=\"\"\n                    className=\"size-full object-cover\"\n                  />\n                ) : (\n                  <GeneratedCover version={release.version} colors={colors} />\n                )}\n              </div>\n              <h3 className=\"font-heading text-2xl tracking-tight\">\n                {release.href ? (\n                  <a\n                    href={release.href}\n                    className=\"underline-offset-4 hover:underline\"\n                  >\n                    {release.title}\n                  </a>\n                ) : (\n                  release.title\n                )}\n              </h3>\n              {release.description && (\n                <p className=\"text-pretty text-muted-foreground\">\n                  {release.description}\n                </p>\n              )}\n              {release.changes && (\n                <ul className=\"flex flex-col gap-2.5 text-sm\">\n                  {release.changes.map((change) => (\n                    <li key={change.text} className=\"flex items-start gap-3\">\n                      <span\n                        className={cn(\n                          \"mt-px w-18 shrink-0 border px-1.5 py-0.5 text-center font-mono text-[10px] tracking-wider uppercase\",\n                          change.type === \"new\" &&\n                            \"border-foreground bg-foreground text-background\"\n                        )}\n                      >\n                        {CHANGE_LABELS[change.type]}\n                      </span>\n                      {change.text}\n                    </li>\n                  ))}\n                </ul>\n              )}\n            </article>\n          </li>\n        ))}\n      </ol>\n    </section>\n  )\n}\n\n/**\n * A cover drawn from the version number, so every release gets its own art\n * and the same version always gets the same cover.\n */\nfunction GeneratedCover({\n  version,\n  colors,\n}: {\n  version: string\n  colors: string[]\n}) {\n  const params = getCover(version, colors)\n  // Compared by value, so inline color arrays don't trigger a new render.\n  const key = JSON.stringify(params)\n  const [snapshot, setSnapshot] = React.useState<{ key: string; url: string }>()\n  const src = snapshot?.key === key ? snapshot.url : undefined\n\n  React.useEffect(() => {\n    if (!snapshot) return\n    return () => URL.revokeObjectURL(snapshot.url)\n  }, [snapshot])\n\n  return (\n    <div\n      className=\"absolute inset-0 bg-cover\"\n      style={{\n        // A plain CSS gradient in the same colors shows until the shader is\n        // ready, and is what the server renders.\n        backgroundImage: src\n          ? `url(${src})`\n          : `linear-gradient(135deg, ${params.colors.join(\", \")})`,\n      }}\n    >\n      {!src && (\n        <Snapshot\n          key={key}\n          params={params}\n          onRender={(url) => setSnapshot({ key, url })}\n        />\n      )}\n      <span className=\"absolute bottom-4 left-5 font-heading text-6xl leading-none tracking-tight text-white [text-shadow:0_2px_24px_rgb(0_0_0/0.35)] sm:text-8xl\">\n        {version}\n      </span>\n    </div>\n  )\n}\n\n// Browsers cap live WebGL contexts per page (around 16), so a long changelog\n// can't keep a canvas per cover. Instead each cover renders once, is saved as\n// an image, and frees its context. Only a few render at the same time.\nconst MAX_RENDERING = 4\n\nconst queue: Array<() => void> = []\nlet rendering = 0\n\nfunction acquireSlot() {\n  if (rendering < MAX_RENDERING) {\n    rendering++\n    return Promise.resolve()\n  }\n  return new Promise<void>((resolve) => queue.push(resolve))\n}\n\nfunction releaseSlot() {\n  const next = queue.shift()\n  if (next) next()\n  else rendering--\n}\n\nfunction Snapshot({\n  params,\n  onRender,\n}: {\n  params: ReturnType<typeof getCover>\n  onRender: (url: string) => void\n}) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const [ready, setReady] = React.useState(false)\n  const handleRender = React.useEffectEvent(onRender)\n\n  // Wait for a free slot before mounting the shader.\n  React.useEffect(() => {\n    const element = ref.current\n    let acquired = false\n    let cancelled = false\n\n    acquireSlot().then(() => {\n      if (cancelled) return releaseSlot()\n      acquired = true\n      setReady(true)\n    })\n\n    return () => {\n      cancelled = true\n      if (!acquired) return\n      // Unmounting doesn't free the context until it's garbage collected, so\n      // drop it explicitly before handing the slot to the next cover.\n      element\n        ?.querySelector(\"canvas\")\n        ?.getContext(\"webgl2\")\n        ?.getExtension(\"WEBGL_lose_context\")\n        ?.loseContext()\n      releaseSlot()\n    }\n  }, [])\n\n  // The shader mounts asynchronously, so poll until it exists. It draws when\n  // its resize observer first fires, and observers run in the order they were\n  // created, so one added now fires right after that first draw. Then save the\n  // canvas as an image.\n  React.useEffect(() => {\n    if (!ready) return\n\n    let cancelled = false\n    let observer: ResizeObserver | undefined\n    let frame = requestAnimationFrame(function check() {\n      const shader = ref.current?.querySelector(\"[data-paper-shader]\")\n      const canvas = shader?.querySelector(\"canvas\")\n      if (!shader || !canvas) {\n        frame = requestAnimationFrame(check)\n        return\n      }\n      observer = new ResizeObserver(() => {\n        observer?.disconnect()\n        canvas.toBlob(\n          (blob) => {\n            if (blob && !cancelled) handleRender(URL.createObjectURL(blob))\n          },\n          \"image/jpeg\",\n          0.92\n        )\n      })\n      observer.observe(shader)\n    })\n\n    return () => {\n      cancelled = true\n      cancelAnimationFrame(frame)\n      observer?.disconnect()\n    }\n  }, [ready])\n\n  return (\n    // Rendered in place at the cover's size, then hidden behind the gradient.\n    <div\n      ref={ref}\n      aria-hidden\n      className=\"pointer-events-none absolute inset-0 opacity-0\"\n    >\n      {ready && (\n        <SimplexNoise\n          className=\"size-full\"\n          // Keeps the pixels around after drawing so they can be read back.\n          webGlContextAttributes={{ preserveDrawingBuffer: true }}\n          {...params}\n        />\n      )}\n    </div>\n  )\n}\n\n/** Picks the color order and shape from the version, so it always matches. */\nfunction getCover(version: string, colors: string[]) {\n  const random = mulberry32(hash(version))\n  const shuffled = [...colors]\n  for (let i = shuffled.length - 1; i > 0; i--) {\n    const j = Math.floor(random() * (i + 1))\n    ;[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]\n  }\n\n  return {\n    colors: shuffled,\n    // A paused moment of the animation. Each one is a different shape.\n    frame: Math.floor(random() * 1_000_000),\n    speed: 0,\n    stepsPerColor: 2,\n    softness: 0,\n    scale: 0.4 + random() * 0.4,\n    rotation: Math.floor(random() * 360),\n  }\n}\n\n// FNV-1a: turns the version into a 32-bit number.\nfunction hash(value: string) {\n  let h = 0x811c9dc5\n  for (let i = 0; i < value.length; i++) {\n    h ^= value.charCodeAt(i)\n    h = Math.imul(h, 0x01000193)\n  }\n  return h >>> 0\n}\n\n// A tiny seeded random number generator.\nfunction mulberry32(seed: number) {\n  return () => {\n    seed = (seed + 0x6d2b79f5) | 0\n    let t = Math.imul(seed ^ (seed >>> 15), 1 | seed)\n    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n  }\n}\n\nexport { SimplexNoiseChangelog, type Release }\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "sections",
    "changelog"
  ],
  "type": "registry:block"
}