From fcaf21d1c52f1f4aa94bd3ea88320661f70216b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Vila=C3=A7a=20de=20Jesus?= Date: Sun, 25 Oct 2026 16:27:51 -0300 Subject: [PATCH 1/2] chore: start #625 From 240c83909a333bbf0e91b7124393d681b5f5f7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Vila=C3=A7a=20de=20Jesus?= Date: Sun, 25 Oct 2026 18:28:32 -0300 Subject: [PATCH 2/2] refactor: split packages/ui/scripts/build-manifest.ts into focused modules (#625) --- packages/ui/scripts/build-manifest.ts | 1640 +------------------- packages/ui/scripts/manifest/ast.ts | 25 + packages/ui/scripts/manifest/components.ts | 487 ++++++ packages/ui/scripts/manifest/demos.ts | 365 +++++ packages/ui/scripts/manifest/exports.ts | 227 +++ packages/ui/scripts/manifest/guides.ts | 60 + packages/ui/scripts/manifest/paths.ts | 35 + packages/ui/scripts/manifest/styling.ts | 124 ++ packages/ui/scripts/manifest/tokens.ts | 175 +++ packages/ui/scripts/manifest/writers.ts | 153 ++ 10 files changed, 1679 insertions(+), 1612 deletions(-) create mode 100644 packages/ui/scripts/manifest/ast.ts create mode 100644 packages/ui/scripts/manifest/components.ts create mode 100644 packages/ui/scripts/manifest/demos.ts create mode 100644 packages/ui/scripts/manifest/exports.ts create mode 100644 packages/ui/scripts/manifest/guides.ts create mode 100644 packages/ui/scripts/manifest/paths.ts create mode 100644 packages/ui/scripts/manifest/styling.ts create mode 100644 packages/ui/scripts/manifest/tokens.ts create mode 100644 packages/ui/scripts/manifest/writers.ts diff --git a/packages/ui/scripts/build-manifest.ts b/packages/ui/scripts/build-manifest.ts index 7139b614..1cd0073e 100644 --- a/packages/ui/scripts/build-manifest.ts +++ b/packages/ui/scripts/build-manifest.ts @@ -22,1629 +22,45 @@ * exports (stores, functions, types, Vite/Astro/Kit helpers) is resolved with a TypeScript * `Program` over the entry files and reported with its signature and JSDoc summary. */ -import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; -import { createRequire } from "node:module"; -import { dirname, join, relative, resolve } from "node:path"; -import { fileURLToPath } from "node:url"; -import ts from "typescript"; +import { existsSync, mkdirSync, writeFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; import { loadMigrations, migrationMarkdown } from "../src/cli/migrations.ts"; -import { STYLES, type SurfaceStyle } from "../src/lib/theme/define.ts"; -import { DESIGN_STYLES } from "../src/lib/theme/styles.ts"; -import { ENTRY_PAGES, parseRecipes, type Recipe } from "./ai-entry.ts"; import { buildAtlasFile } from "./atlas-markdown.ts"; import { buildReleaseFile } from "./changelog-markdown.ts"; import { buildIndexFiles } from "./index-build.ts"; -import { checkIdRange, checkIndexFacets, ID_PATTERN, type IndexFacets } from "./index-schema.ts"; -import { demoSources, mdxToMarkdown } from "./mdx-to-markdown.ts"; +import { buildManifest } from "./manifest/components.ts"; +import { buildDemos, checkCatalog } from "./manifest/demos.ts"; +import { buildGuides, buildRecipes } from "./manifest/guides.ts"; +import { DEMOS_DIR, ROOT } from "./manifest/paths.ts"; +import { buildSurfaces, buildTokens } from "./manifest/tokens.ts"; +import { buildParts, demosMarkdown, skillMarkdown } from "./manifest/writers.ts"; import { buildStyleFile } from "./styles-markdown.ts"; -// CJS require keeps svelte2tsx out of Vite's transform pipeline (its sourceMappingURL points at a file it does not ship). -const { svelte2tsx }: typeof import("svelte2tsx") = createRequire(import.meta.url)("svelte2tsx"); -const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); -const LIB = join(ROOT, "src/lib"); -const PKG = "@codeatlasdev/ui"; - -/** Public entry points: import specifier → entry file under src/lib. */ -const ENTRIES: Record = { - [PKG]: "index.ts", - [`${PKG}/charts`]: "charts/index.ts", - [`${PKG}/map`]: "map/index.ts", - [`${PKG}/sound`]: "sound/index.ts", - [`${PKG}/table`]: "components/DataTable/index.ts", - [`${PKG}/code`]: "components/CodeSnippet/index.ts", - [`${PKG}/forms`]: "forms/index.ts", -}; - -/** Entries whose non-component exports are documented: specifier → source file (mirrors package.json#exports). */ -const API_ENTRIES: Record = { - ...ENTRIES, - [`${PKG}/kit`]: "kit/index.ts", - [`${PKG}/vite`]: "vite-plugin.ts", - [`${PKG}/astro`]: "astro.ts", - [`${PKG}/actions`]: "actions/index.ts", - [`${PKG}/seo`]: "seo/index.ts", - [`${PKG}/tokens`]: "tokens/index.ts", - [`${PKG}/utils/palette-generator`]: "utils/palette-generator.ts", - [`${PKG}/utils/color`]: "utils/color.ts", -}; - -export type ExportKind = "function" | "store" | "const" | "class" | "type"; - -export interface ManifestExport { - name: string; - /** Import specifier, e.g. `@codeatlasdev/ui/kit`. */ - import: string; - kind: ExportKind; - /** One-line declaration: `function f(a: A): R`, `interface X { ... }`, `type T = ...`, `const x: T`. */ - signature: string; - /** First paragraph of the JSDoc of the declaration (or of the comment right above it). */ - description?: string; - /** Fields of an exported interface (or object type alias): name, type, optionality, JSDoc. */ - members?: ManifestExportMember[]; - /** Source file relative to `src/lib`. */ - source: string; -} - -export interface ManifestExportMember { - name: string; - type: string; - optional: boolean; - description?: string; -} - -export interface ManifestProp { - name: string; - type: string; - optional: boolean; - default?: string; - /** `$bindable` prop (use `bind:name`). */ - bindable?: boolean; - description?: string; -} - -export interface ManifestComponent { - name: string; - /** Import specifier, e.g. `@codeatlasdev/ui` or `@codeatlasdev/ui/charts`. */ - import: string; - /** Source file relative to `src/lib`. */ - source: string; - /** First JSDoc/comment paragraph of the component, when present. */ - description?: string; - /** Replacement text of a component-level `@deprecated` ("Use ``: ..."). Absent on current components. */ - deprecated?: string; - /** Own props. Inherited attributes (e.g. `HTMLAttributes`) are listed in `extends`. */ - props: ManifestProp[]; - /** Props typed as `Snippet`/`Snippet<[...]>`: the holes a caller fills. */ - snippets: ManifestProp[]; - /** Text of the interface `extends` clause: native attributes that also pass through. */ - extends?: string; - /** Stable `ca-*` class names defined in the component `