sordo 0.5.0 → 1.0.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +6 -126
  2. package/README.md +8 -178
  3. package/bin/sordo.ts +1 -4
  4. package/package.json +17 -41
  5. package/src/agents-md.ts +1 -0
  6. package/src/ai.ts +1 -0
  7. package/src/build.ts +1 -0
  8. package/src/client.ts +1 -0
  9. package/src/config.ts +1 -0
  10. package/src/dev.ts +1 -0
  11. package/src/index.ts +1 -55
  12. package/src/middleware.ts +1 -0
  13. package/src/plugin.ts +1 -0
  14. package/src/render.ts +1 -0
  15. package/src/router.ts +1 -0
  16. package/src/server.ts +1 -0
  17. package/CLAUDE.md +0 -124
  18. package/src/adapters/bun.ts +0 -59
  19. package/src/adapters/edge.ts +0 -75
  20. package/src/adapters/types.ts +0 -43
  21. package/src/agents-md/collect.ts +0 -113
  22. package/src/agents-md/generate.ts +0 -44
  23. package/src/agents-md/index.ts +0 -9
  24. package/src/agents-md/render.ts +0 -151
  25. package/src/agents-md/subprocess-entry.ts +0 -92
  26. package/src/agents-md/subprocess-runner.ts +0 -111
  27. package/src/agents-md/write.ts +0 -38
  28. package/src/agents-md/zod-to-json-schema.ts +0 -18
  29. package/src/ai/context.ts +0 -72
  30. package/src/ai/define.ts +0 -15
  31. package/src/ai/errors.ts +0 -51
  32. package/src/ai/index.ts +0 -36
  33. package/src/ai/middleware.ts +0 -21
  34. package/src/ai/registry.ts +0 -96
  35. package/src/ai/run.ts +0 -185
  36. package/src/ai/scan.ts +0 -42
  37. package/src/ai/stream.ts +0 -71
  38. package/src/ai/triggers.ts +0 -124
  39. package/src/ai/types.ts +0 -67
  40. package/src/ai/validate.ts +0 -82
  41. package/src/build/assets.ts +0 -48
  42. package/src/build/client-entry.ts +0 -43
  43. package/src/build/css.ts +0 -128
  44. package/src/build/embedded.ts +0 -66
  45. package/src/build/hash.ts +0 -21
  46. package/src/build/index.ts +0 -505
  47. package/src/build/macros/agents-hash.macro.ts +0 -9
  48. package/src/build/macros/agents.macro.ts +0 -21
  49. package/src/build/macros/env.macro.ts +0 -25
  50. package/src/build/macros/inline-assets.macro.ts +0 -34
  51. package/src/build/macros/manifest.macro.ts +0 -8
  52. package/src/build/macros/routes.macro.ts +0 -10
  53. package/src/build/page-entry.ts +0 -136
  54. package/src/build/scan-islands.ts +0 -39
  55. package/src/build/server-entry.ts +0 -256
  56. package/src/cli/ansi.ts +0 -41
  57. package/src/cli/build.ts +0 -195
  58. package/src/cli/commands/add/apply.ts +0 -31
  59. package/src/cli/commands/add/component-diff.ts +0 -116
  60. package/src/cli/commands/add/diff.ts +0 -153
  61. package/src/cli/commands/add/internal.ts +0 -41
  62. package/src/cli/commands/add/load-catalog.ts +0 -22
  63. package/src/cli/commands/add/peer-deps.ts +0 -115
  64. package/src/cli/commands/add/registry-fetch.ts +0 -122
  65. package/src/cli/commands/add/shadcn.ts +0 -285
  66. package/src/cli/commands/add/source.ts +0 -273
  67. package/src/cli/commands/add/stamper.ts +0 -73
  68. package/src/cli/commands/add/tokens.ts +0 -81
  69. package/src/cli/commands/add/ui-paths.ts +0 -113
  70. package/src/cli/commands/add.ts +0 -427
  71. package/src/cli/commands/deploy.ts +0 -143
  72. package/src/cli/commands/migrate.ts +0 -149
  73. package/src/cli/commands/secret.ts +0 -316
  74. package/src/cli/commands/ui/build.ts +0 -111
  75. package/src/cli/commands/ui/init.ts +0 -135
  76. package/src/cli/commands/ui/migrate/git-guard.ts +0 -19
  77. package/src/cli/commands/ui/migrate/radix.ts +0 -67
  78. package/src/cli/commands/ui/migrate/rtl.ts +0 -148
  79. package/src/cli/commands/ui/shadcn.ts +0 -82
  80. package/src/cli/commands/ui/view.ts +0 -63
  81. package/src/cli/commands/ui.ts +0 -86
  82. package/src/cli/commands/update.ts +0 -134
  83. package/src/cli/commands/upgrade.ts +0 -53
  84. package/src/cli/commands/view.ts +0 -34
  85. package/src/cli/dev.ts +0 -393
  86. package/src/cli/doctor/config-checks.ts +0 -63
  87. package/src/cli/doctor/deps.ts +0 -295
  88. package/src/cli/doctor/hydrate.ts +0 -65
  89. package/src/cli/doctor/monorepo.ts +0 -158
  90. package/src/cli/doctor/probes.ts +0 -16
  91. package/src/cli/doctor/report.ts +0 -72
  92. package/src/cli/doctor/toolchain.ts +0 -95
  93. package/src/cli/doctor/types.ts +0 -36
  94. package/src/cli/doctor.ts +0 -127
  95. package/src/cli/index.ts +0 -168
  96. package/src/cli/log.ts +0 -135
  97. package/src/cli/run/affected.ts +0 -79
  98. package/src/cli/run/cache-key.ts +0 -177
  99. package/src/cli/run/cache-store.ts +0 -0
  100. package/src/cli/run/files.ts +0 -96
  101. package/src/cli/run/git.ts +0 -13
  102. package/src/cli/run/runner.ts +0 -189
  103. package/src/cli/run/workspace.ts +0 -216
  104. package/src/cli/run.ts +0 -184
  105. package/src/cli/start.ts +0 -99
  106. package/src/cli/update-check.ts +0 -157
  107. package/src/client/index.ts +0 -65
  108. package/src/client/link.tsx +0 -61
  109. package/src/client/page.ts +0 -250
  110. package/src/config/define.ts +0 -5
  111. package/src/config/env.ts +0 -36
  112. package/src/config/load.ts +0 -152
  113. package/src/config/schema.ts +0 -135
  114. package/src/config/secrets.ts +0 -108
  115. package/src/dev/client.ts +0 -112
  116. package/src/dev/hot.ts +0 -24
  117. package/src/dev/index.ts +0 -4
  118. package/src/dev/tree.ts +0 -95
  119. package/src/dev/watcher.ts +0 -95
  120. package/src/internal/hmr-client.ts +0 -52
  121. package/src/internal/open-in-editor.ts +0 -23
  122. package/src/internal/runtime.ts +0 -30
  123. package/src/middleware/cookie-jar.ts +0 -135
  124. package/src/middleware/cookies.ts +0 -60
  125. package/src/middleware/index.ts +0 -135
  126. package/src/middleware/request-id.ts +0 -22
  127. package/src/middleware/response-helpers.ts +0 -25
  128. package/src/plugin/index.ts +0 -109
  129. package/src/render/bootstrap.ts +0 -44
  130. package/src/render/dev-error.tsx +0 -73
  131. package/src/render/index.tsx +0 -261
  132. package/src/render/island.tsx +0 -33
  133. package/src/render/meta.tsx +0 -48
  134. package/src/render/shell.tsx +0 -41
  135. package/src/router/conflict.ts +0 -20
  136. package/src/router/filesystem.ts +0 -37
  137. package/src/router/index.ts +0 -269
  138. package/src/router/match.ts +0 -91
  139. package/src/router/pattern.ts +0 -104
  140. package/src/server/index.ts +0 -250
  141. package/src/server/inline-assets.ts +0 -57
  142. package/src/types.ts +0 -53
  143. package/src/ui/schema.ts +0 -68
  144. package/src/ui/types.ts +0 -10
  145. package/templates/_internal/cn.ts +0 -6
  146. package/templates/_internal/slot.ts +0 -50
  147. package/templates/_internal/variants.ts +0 -1
  148. package/templates/themes/neutral/tokens.css +0 -46
  149. package/templates/themes/slate/tokens.css +0 -46
  150. package/templates/themes/stone/tokens.css +0 -46
  151. package/templates/themes/zinc/tokens.css +0 -46
  152. package/templates/tokens.css +0 -46
@@ -1,250 +0,0 @@
1
- import { networkInterfaces } from "node:os";
2
- import { hotState } from "../dev/hot.ts";
3
- import type { DevServer } from "../dev/watcher.ts";
4
- import { handleOpenInEditor } from "../internal/open-in-editor.ts";
5
- import { compilePatterns, dispatch } from "../router/match.ts";
6
- import type { BunRoutes } from "../types.ts";
7
-
8
- export interface ServerOptions {
9
- port?: number;
10
- hostname?: string;
11
- unix?: string;
12
- reusePort?: boolean;
13
- routes: BunRoutes;
14
- fallback: (req: Request) => Response | Promise<Response>;
15
- dev?: boolean;
16
- devServer?: DevServer;
17
- staticRoutes?: Record<string, Response>;
18
- /** Suppress the bound-URL log line; the caller will print its own banner. */
19
- quiet?: boolean;
20
- }
21
-
22
- export interface ServerHandle {
23
- fetch: (req: Request) => Promise<Response>;
24
- port: number;
25
- }
26
-
27
- // Build the routes table Bun.serve will receive (including dev-only internals).
28
- function buildRoutes(opts: ServerOptions): BunRoutes {
29
- const routes: BunRoutes = { ...(opts.staticRoutes ?? {}), ...opts.routes };
30
- if (opts.dev) {
31
- routes["/__sordo_open"] = ((req: Request) =>
32
- handleOpenInEditor(req)) as unknown as (typeof routes)[string];
33
- if (opts.devServer) {
34
- // Real upgrade path: attempt WS upgrade, otherwise fall back to the dev
35
- // server's `fetch` (a 426 message).
36
- const dev = opts.devServer;
37
- routes["/__sordo_hmr"] = ((req: Request, server: unknown) => {
38
- const s = server as { upgrade?: (r: Request) => boolean } | undefined;
39
- if (s && typeof s.upgrade === "function" && s.upgrade(req))
40
- return undefined;
41
- return dev.fetch(req);
42
- }) as unknown as (typeof routes)[string];
43
- } else {
44
- routes["/__sordo_hmr"] = (() =>
45
- new Response("HMR upgrade requires a real Bun.serve instance", {
46
- status: 426,
47
- })) as unknown as (typeof routes)[string];
48
- }
49
- }
50
- return routes;
51
- }
52
-
53
- function validate(opts: ServerOptions): void {
54
- if (!opts.routes) throw new Error("createServer: `routes` is required");
55
- if (opts.unix && (opts.port !== undefined || opts.hostname !== undefined)) {
56
- throw new Error(
57
- "createServer: `unix` is mutually exclusive with `port`/`hostname`",
58
- );
59
- }
60
- }
61
-
62
- // Lightweight in-process fetch: matches a request against the routes table
63
- // using simple path matching (`:param` and `*` catch-all). Used in tests and
64
- // when callers want a `fetch(req)` they can drive without binding a port.
65
- // In production `startServer()` should be used so Bun's native matcher handles
66
- // dispatch.
67
- export function createServer(opts: ServerOptions): ServerHandle {
68
- validate(opts);
69
- const routes = buildRoutes(opts);
70
- const compiled = compilePatterns(routes);
71
- const port = opts.port ?? 3000;
72
-
73
- const fetch = async (req: Request): Promise<Response> => {
74
- const hit = await dispatch(routes, req, {}, compiled);
75
- if (hit) return hit;
76
- return Promise.resolve(opts.fallback(req));
77
- };
78
-
79
- return { fetch, port };
80
- }
81
-
82
- export function startServer(opts: ServerOptions) {
83
- validate(opts);
84
- let routes = buildRoutes(opts);
85
- if (opts.dev) {
86
- routes = wrapRoutesForDevLogging(routes);
87
- }
88
-
89
- const userFallback = opts.fallback;
90
- const fallback = opts.dev
91
- ? async (req: Request): Promise<Response> => {
92
- const t0 = performance.now();
93
- const res = await userFallback(req);
94
- logDevRequest(req, res.status, performance.now() - t0);
95
- return res;
96
- }
97
- : (req: Request) => Promise.resolve(userFallback(req));
98
-
99
- const serverOptions: Record<string, unknown> = {
100
- routes,
101
- fetch: fallback,
102
- reusePort: opts.reusePort,
103
- };
104
- if (opts.devServer) {
105
- serverOptions.websocket = opts.devServer.websocket;
106
- }
107
- if (opts.unix) {
108
- serverOptions.unix = opts.unix;
109
- } else {
110
- serverOptions.port = opts.port ?? 3000;
111
- serverOptions.hostname = opts.hostname ?? "0.0.0.0";
112
- }
113
-
114
- // Bun.serve's union of overload types is hard to satisfy generically; cast to any.
115
- const server = Bun.serve(
116
- serverOptions as unknown as Parameters<typeof Bun.serve>[0],
117
- );
118
- if (opts.devServer) {
119
- opts.devServer.attachServer(
120
- server as unknown as { publish: (t: string, d: string) => number },
121
- );
122
- }
123
- // A `bun --hot` reload re-runs the app's `start`; the URL hasn't changed.
124
- if (!opts.quiet && !(opts.dev && hotState().generation > 1)) {
125
- printBoundBanner(
126
- opts,
127
- server as unknown as { hostname: string; port: number },
128
- );
129
- }
130
- return server;
131
- }
132
-
133
- // ──────────────────────────────────────────────────────────────────────────
134
- // Dev-mode logging helpers.
135
- //
136
- // In dev we wrap every route handler with a small middleware that prints
137
- // `HH:MM:SS METHOD path STATUS Xms`. Internal `/__sordo_*` endpoints are
138
- // suppressed (they're noisy WS pings + editor-open beacons). Static `Response`
139
- // route values are passed through unwrapped — they can't be cleanly observed
140
- // without consuming/cloning the body, and the cost isn't worth it.
141
-
142
- const DEV_SKIP = /^\/__sordo_/;
143
-
144
- function logDevRequest(req: Request, status: number, ms: number): void {
145
- const path = new URL(req.url).pathname;
146
- if (DEV_SKIP.test(path)) return;
147
- const time = new Date().toTimeString().slice(0, 8);
148
- const stream = process.stdout as NodeJS.WriteStream;
149
- const tty = Boolean(stream.isTTY) && !process.env.NO_COLOR;
150
- const dim = (s: string) => (tty ? `\x1b[2m${s}\x1b[0m` : s);
151
- const color =
152
- status >= 500
153
- ? (s: string) => (tty ? `\x1b[31m${s}\x1b[0m` : s)
154
- : status >= 400
155
- ? (s: string) => (tty ? `\x1b[33m${s}\x1b[0m` : s)
156
- : (s: string) => (tty ? `\x1b[32m${s}\x1b[0m` : s);
157
- stream.write(
158
- `${dim(time)} ${req.method} ${path} ${color(String(status))} ${dim(`${ms.toFixed(1)}ms`)}\n`,
159
- );
160
- }
161
-
162
- // Route handlers can return undefined (e.g. WS upgrade path) — accept that.
163
- type AnyHandler = (
164
- req: Request & { params: Record<string, string> },
165
- server: unknown,
166
- ) => Response | undefined | Promise<Response | undefined>;
167
-
168
- function wrapHandler(fn: AnyHandler): AnyHandler {
169
- return async (req, server) => {
170
- const t0 = performance.now();
171
- const out = await fn(req, server);
172
- if (out instanceof Response) {
173
- logDevRequest(req, out.status, performance.now() - t0);
174
- }
175
- return out;
176
- };
177
- }
178
-
179
- function wrapRoutesForDevLogging(routes: BunRoutes): BunRoutes {
180
- const out: BunRoutes = {};
181
- for (const [path, value] of Object.entries(routes)) {
182
- if (typeof value === "function") {
183
- out[path] = wrapHandler(
184
- value as AnyHandler,
185
- ) as unknown as BunRoutes[string];
186
- } else if (
187
- value &&
188
- typeof value === "object" &&
189
- !(value instanceof Response)
190
- ) {
191
- const wrapped: Record<string, AnyHandler> = {};
192
- for (const [method, h] of Object.entries(value)) {
193
- if (typeof h === "function") {
194
- wrapped[method] = wrapHandler(h as AnyHandler);
195
- }
196
- }
197
- out[path] = wrapped as unknown as BunRoutes[string];
198
- } else {
199
- out[path] = value;
200
- }
201
- }
202
- return out;
203
- }
204
-
205
- function printBoundBanner(
206
- opts: ServerOptions,
207
- server: { hostname: string; port: number },
208
- ): void {
209
- if (opts.unix) {
210
- console.log(`[sordo] listening on unix://${opts.unix}`);
211
- return;
212
- }
213
- const port = server.port;
214
- const stream = process.stdout as NodeJS.WriteStream;
215
- const tty = Boolean(stream.isTTY) && !process.env.NO_COLOR;
216
- const dim = (s: string) => (tty ? `\x1b[2m${s}\x1b[0m` : s);
217
- const cyan = (s: string) => (tty ? `\x1b[36m${s}\x1b[0m` : s);
218
- const isAllInterfaces =
219
- server.hostname === "0.0.0.0" || server.hostname === "::";
220
- stream.write(` ${dim("➜")} Local: ${cyan(`http://localhost:${port}`)}\n`);
221
- if (isAllInterfaces) {
222
- const lan = findLanIp();
223
- if (lan) {
224
- stream.write(
225
- ` ${dim("➜")} Network: ${cyan(`http://${lan}:${port}`)}\n`,
226
- );
227
- } else {
228
- stream.write(` ${dim("➜")} Network: ${dim("(no LAN interface)")}\n`);
229
- }
230
- } else if (
231
- server.hostname !== "localhost" &&
232
- server.hostname !== "127.0.0.1"
233
- ) {
234
- stream.write(
235
- ` ${dim("➜")} Network: ${cyan(`http://${server.hostname}:${port}`)}\n`,
236
- );
237
- }
238
- }
239
-
240
- function findLanIp(): string | null {
241
- try {
242
- const nets = networkInterfaces();
243
- for (const list of Object.values(nets)) {
244
- for (const ni of list ?? []) {
245
- if (ni.family === "IPv4" && !ni.internal) return ni.address;
246
- }
247
- }
248
- } catch {}
249
- return null;
250
- }
@@ -1,57 +0,0 @@
1
- // Build-time-inlined client outputs: hashed island/page chunks, the CSS sheet
2
- // and its url() assets.
3
- // Kept free of Bun APIs: the edge worker imports this too.
4
- export interface InlineAsset {
5
- type: string;
6
- body: string;
7
- base64: boolean;
8
- // public/ files keep their names, so they must not be cached as immutable.
9
- mutable?: boolean;
10
- // Content hash; lets revalidating clients get a 304 instead of the body.
11
- etag?: string;
12
- }
13
-
14
- // URLs carry a content hash, so a cached copy never goes stale.
15
- const IMMUTABLE = "public, max-age=31536000, immutable";
16
- const REVALIDATE = "public, max-age=0, must-revalidate";
17
-
18
- export function inlineAssetResponse(
19
- asset: InlineAsset,
20
- req?: Request,
21
- ): Response {
22
- const headers: Record<string, string> = {
23
- "content-type": asset.type,
24
- "cache-control": asset.mutable ? REVALIDATE : IMMUTABLE,
25
- };
26
- if (asset.etag) {
27
- const etag = `"${asset.etag}"`;
28
- headers.etag = etag;
29
- const inm = req?.headers.get("if-none-match");
30
- if (inm?.split(",").some((t) => t.trim().replace(/^W\//, "") === etag)) {
31
- return new Response(null, { status: 304, headers });
32
- }
33
- }
34
- const body = asset.base64
35
- ? Uint8Array.from(atob(asset.body), (c) => c.charCodeAt(0))
36
- : asset.body;
37
- return new Response(body, { headers });
38
- }
39
-
40
- export function inlineAssetRoutes(
41
- assets: Record<string, InlineAsset>,
42
- ): Record<string, Response> {
43
- const out: Record<string, Response> = {};
44
- for (const [url, asset] of Object.entries(assets)) {
45
- out[url] = inlineAssetResponse(asset);
46
- }
47
- return out;
48
- }
49
-
50
- export function matchInlineAsset(
51
- assets: Record<string, InlineAsset>,
52
- req: Request,
53
- ): Response | null {
54
- if (req.method !== "GET" && req.method !== "HEAD") return null;
55
- const asset = assets[new URL(req.url).pathname];
56
- return asset ? inlineAssetResponse(asset, req) : null;
57
- }
package/src/types.ts DELETED
@@ -1,53 +0,0 @@
1
- import type { Handler, Middleware, SordoContext } from "./middleware/index.ts";
2
-
3
- export type { Handler, Middleware, SordoContext };
4
-
5
- export type HTTPMethod =
6
- | "GET"
7
- | "POST"
8
- | "PUT"
9
- | "DELETE"
10
- | "PATCH"
11
- | "OPTIONS"
12
- | "HEAD";
13
-
14
- export const HTTP_METHODS: HTTPMethod[] = [
15
- "GET",
16
- "POST",
17
- "PUT",
18
- "DELETE",
19
- "PATCH",
20
- "OPTIONS",
21
- "HEAD",
22
- ];
23
-
24
- export interface Segment {
25
- raw: string;
26
- kind: "static" | "param" | "catchall";
27
- name?: string;
28
- }
29
-
30
- export interface RouteEntry {
31
- filePath: string;
32
- bunPattern: string;
33
- kind: "page" | "api" | "notFound";
34
- segments: Segment[];
35
- }
36
-
37
- // Bun.serve({ routes }) accepts handlers, method-keyed objects, or Response.
38
- // We use plain functions; Bun adapts them as Request -> Response handlers.
39
- export type BunRouteValue =
40
- | Response
41
- | ((
42
- req: Request & { params: Record<string, string> },
43
- ) => Response | Promise<Response>)
44
- | Partial<
45
- Record<
46
- HTTPMethod,
47
- (
48
- req: Request & { params: Record<string, string> },
49
- ) => Response | Promise<Response>
50
- >
51
- >;
52
-
53
- export type BunRoutes = Record<string, BunRouteValue>;
package/src/ui/schema.ts DELETED
@@ -1,68 +0,0 @@
1
- import { z } from "zod";
2
-
3
- // Runtime validator for catalog entries. `types.ts` re-derives its exported
4
- // types from these schemas, so the schema is the single source of truth — the
5
- // CLI uses it to validate fetched/built third-party registries (cli/15).
6
-
7
- export const IslandSchema = z.enum(["no", "yes", "subtree", "yes-downgrade"]);
8
- export const KindSchema = z.enum(["primitive", "recipe", "provider"]);
9
- export const StatusSchema = z.enum(["draft", "completed"]);
10
- export const PhaseSchema = z.union([
11
- z.literal(0),
12
- z.literal(1),
13
- z.literal(2),
14
- z.literal(3),
15
- z.literal(4),
16
- ]);
17
- export const InternalHelperSchema = z.enum(["cn", "slot", "variants"]);
18
-
19
- // `from`/`to` here and registry `templates` keys are joined against temp dirs
20
- // and the project's components/internal dirs when stamping fetched or
21
- // third-party registries. Reject anything that could escape the destination:
22
- // absolute paths, drive letters, backslashes, `..` segments, or null bytes.
23
- // Exported so the registry payload schema can reuse it for `templates` keys.
24
- export const SafeRelPath = z
25
- .string()
26
- .refine(
27
- (p) =>
28
- p.length > 0 &&
29
- !p.includes("\0") &&
30
- !p.includes("\\") &&
31
- !p.startsWith("/") &&
32
- !/^[a-zA-Z]:/.test(p) &&
33
- !p.split("/").some((seg) => seg === ".."),
34
- {
35
- message:
36
- "unsafe path: must be relative, without '..' segments, backslashes, drive letters, or null bytes",
37
- },
38
- );
39
-
40
- // Where `to` is anchored. Absent ⇒ "components" (the catalog default). "app"
41
- // is the app dir the `@/` import alias points at, used by adapted registries
42
- // (e.g. shadcn `registry:hook` → `app/hooks/`). The stamper confines "app"
43
- // files to `components/`, `hooks/` and `lib/` — registry payloads are
44
- // untrusted, so they never get to place routes, config, or dotfiles.
45
- export const FileRootSchema = z.enum(["components", "app"]);
46
-
47
- export const ComponentFileSchema = z
48
- .object({
49
- from: SafeRelPath,
50
- to: SafeRelPath,
51
- root: FileRootSchema.optional(),
52
- })
53
- .strict();
54
-
55
- export const ComponentEntrySchema = z
56
- .object({
57
- name: z.string(),
58
- spec: z.string(),
59
- phase: PhaseSchema,
60
- kind: KindSchema,
61
- island: IslandSchema,
62
- status: StatusSchema,
63
- files: z.array(ComponentFileSchema),
64
- peerDeps: z.record(z.string(), z.string()),
65
- internalHelpers: z.array(InternalHelperSchema),
66
- tokens: z.array(z.string()).optional(),
67
- })
68
- .strict();
package/src/ui/types.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { z } from "zod";
2
- import type {
3
- ComponentEntrySchema,
4
- ComponentFileSchema,
5
- InternalHelperSchema,
6
- } from "./schema.ts";
7
-
8
- export type InternalHelper = z.infer<typeof InternalHelperSchema>;
9
- export type ComponentFile = z.infer<typeof ComponentFileSchema>;
10
- export type ComponentEntry = z.infer<typeof ComponentEntrySchema>;
@@ -1,6 +0,0 @@
1
- import { type ClassValue, clsx } from "clsx";
2
- import { twMerge } from "tailwind-merge";
3
-
4
- export function cn(...inputs: ClassValue[]): string {
5
- return twMerge(clsx(inputs));
6
- }
@@ -1,50 +0,0 @@
1
- import {
2
- Children,
3
- cloneElement,
4
- isValidElement,
5
- type ReactElement,
6
- type ReactNode,
7
- } from "react";
8
-
9
- interface SlotProps {
10
- children?: ReactNode;
11
- [key: string]: unknown;
12
- }
13
-
14
- export function Slot({
15
- children,
16
- ...slotProps
17
- }: SlotProps): ReactElement | null {
18
- const child = Children.only(children);
19
- if (!isValidElement(child)) return null;
20
- const childEl = child as ReactElement<Record<string, unknown>>;
21
- return cloneElement(childEl, mergeProps(slotProps, childEl.props));
22
- }
23
-
24
- function mergeProps(
25
- parent: Record<string, unknown>,
26
- child: Record<string, unknown>,
27
- ): Record<string, unknown> {
28
- const merged: Record<string, unknown> = { ...parent };
29
- for (const key of Object.keys(child)) {
30
- const parentVal = parent[key];
31
- const childVal = child[key];
32
- if (
33
- key.startsWith("on") &&
34
- typeof parentVal === "function" &&
35
- typeof childVal === "function"
36
- ) {
37
- merged[key] = (...args: unknown[]) => {
38
- (childVal as (...a: unknown[]) => unknown)(...args);
39
- (parentVal as (...a: unknown[]) => unknown)(...args);
40
- };
41
- } else if (key === "className") {
42
- merged[key] = [parentVal, childVal].filter(Boolean).join(" ");
43
- } else if (key === "style") {
44
- merged[key] = { ...(parentVal as object), ...(childVal as object) };
45
- } else {
46
- merged[key] = childVal;
47
- }
48
- }
49
- return merged;
50
- }
@@ -1 +0,0 @@
1
- export { cva, type VariantProps } from "class-variance-authority";
@@ -1,46 +0,0 @@
1
- /* @sordo:tokens base */
2
- :root {
3
- --background: oklch(1 0 0);
4
- --foreground: oklch(0.145 0 0);
5
- --card: oklch(1 0 0);
6
- --card-foreground: oklch(0.145 0 0);
7
- --popover: oklch(1 0 0);
8
- --popover-foreground: oklch(0.145 0 0);
9
- --primary: oklch(0.205 0 0);
10
- --primary-foreground: oklch(0.985 0 0);
11
- --secondary: oklch(0.97 0 0);
12
- --secondary-foreground: oklch(0.205 0 0);
13
- --muted: oklch(0.97 0 0);
14
- --muted-foreground: oklch(0.556 0 0);
15
- --accent: oklch(0.97 0 0);
16
- --accent-foreground: oklch(0.205 0 0);
17
- --destructive: oklch(0.577 0.245 27.325);
18
- --destructive-foreground: oklch(0.985 0 0);
19
- --border: oklch(0.922 0 0);
20
- --input: oklch(0.922 0 0);
21
- --ring: oklch(0.708 0 0);
22
- --radius: 0.625rem;
23
- }
24
-
25
- .dark {
26
- --background: oklch(0.145 0 0);
27
- --foreground: oklch(0.985 0 0);
28
- --card: oklch(0.205 0 0);
29
- --card-foreground: oklch(0.985 0 0);
30
- --popover: oklch(0.205 0 0);
31
- --popover-foreground: oklch(0.985 0 0);
32
- --primary: oklch(0.985 0 0);
33
- --primary-foreground: oklch(0.205 0 0);
34
- --secondary: oklch(0.269 0 0);
35
- --secondary-foreground: oklch(0.985 0 0);
36
- --muted: oklch(0.269 0 0);
37
- --muted-foreground: oklch(0.708 0 0);
38
- --accent: oklch(0.269 0 0);
39
- --accent-foreground: oklch(0.985 0 0);
40
- --destructive: oklch(0.704 0.191 22.216);
41
- --destructive-foreground: oklch(0.985 0 0);
42
- --border: oklch(0.269 0 0);
43
- --input: oklch(0.269 0 0);
44
- --ring: oklch(0.556 0 0);
45
- }
46
- /* @sordo:end base */
@@ -1,46 +0,0 @@
1
- /* @sordo:tokens base */
2
- :root {
3
- --background: oklch(1 0 0);
4
- --foreground: oklch(0.129 0.042 264.695);
5
- --card: oklch(1 0 0);
6
- --card-foreground: oklch(0.129 0.042 264.695);
7
- --popover: oklch(1 0 0);
8
- --popover-foreground: oklch(0.129 0.042 264.695);
9
- --primary: oklch(0.208 0.042 265.755);
10
- --primary-foreground: oklch(0.984 0.003 247.858);
11
- --secondary: oklch(0.968 0.007 247.896);
12
- --secondary-foreground: oklch(0.208 0.042 265.755);
13
- --muted: oklch(0.968 0.007 247.896);
14
- --muted-foreground: oklch(0.554 0.046 257.417);
15
- --accent: oklch(0.968 0.007 247.896);
16
- --accent-foreground: oklch(0.208 0.042 265.755);
17
- --destructive: oklch(0.577 0.245 27.325);
18
- --destructive-foreground: oklch(0.984 0.003 247.858);
19
- --border: oklch(0.929 0.013 255.508);
20
- --input: oklch(0.929 0.013 255.508);
21
- --ring: oklch(0.704 0.04 256.788);
22
- --radius: 0.625rem;
23
- }
24
-
25
- .dark {
26
- --background: oklch(0.129 0.042 264.695);
27
- --foreground: oklch(0.984 0.003 247.858);
28
- --card: oklch(0.208 0.042 265.755);
29
- --card-foreground: oklch(0.984 0.003 247.858);
30
- --popover: oklch(0.208 0.042 265.755);
31
- --popover-foreground: oklch(0.984 0.003 247.858);
32
- --primary: oklch(0.929 0.013 255.508);
33
- --primary-foreground: oklch(0.208 0.042 265.755);
34
- --secondary: oklch(0.279 0.041 260.031);
35
- --secondary-foreground: oklch(0.984 0.003 247.858);
36
- --muted: oklch(0.279 0.041 260.031);
37
- --muted-foreground: oklch(0.704 0.04 256.788);
38
- --accent: oklch(0.279 0.041 260.031);
39
- --accent-foreground: oklch(0.984 0.003 247.858);
40
- --destructive: oklch(0.704 0.191 22.216);
41
- --destructive-foreground: oklch(0.984 0.003 247.858);
42
- --border: oklch(0.279 0.041 260.031);
43
- --input: oklch(0.279 0.041 260.031);
44
- --ring: oklch(0.551 0.027 264.364);
45
- }
46
- /* @sordo:end base */
@@ -1,46 +0,0 @@
1
- /* @sordo:tokens base */
2
- :root {
3
- --background: oklch(1 0 0);
4
- --foreground: oklch(0.147 0.004 49.25);
5
- --card: oklch(1 0 0);
6
- --card-foreground: oklch(0.147 0.004 49.25);
7
- --popover: oklch(1 0 0);
8
- --popover-foreground: oklch(0.147 0.004 49.25);
9
- --primary: oklch(0.216 0.006 56.043);
10
- --primary-foreground: oklch(0.985 0.001 106.423);
11
- --secondary: oklch(0.97 0.001 106.424);
12
- --secondary-foreground: oklch(0.216 0.006 56.043);
13
- --muted: oklch(0.97 0.001 106.424);
14
- --muted-foreground: oklch(0.553 0.013 58.071);
15
- --accent: oklch(0.97 0.001 106.424);
16
- --accent-foreground: oklch(0.216 0.006 56.043);
17
- --destructive: oklch(0.577 0.245 27.325);
18
- --destructive-foreground: oklch(0.985 0.001 106.423);
19
- --border: oklch(0.923 0.003 48.717);
20
- --input: oklch(0.923 0.003 48.717);
21
- --ring: oklch(0.709 0.01 56.259);
22
- --radius: 0.625rem;
23
- }
24
-
25
- .dark {
26
- --background: oklch(0.147 0.004 49.25);
27
- --foreground: oklch(0.985 0.001 106.423);
28
- --card: oklch(0.216 0.006 56.043);
29
- --card-foreground: oklch(0.985 0.001 106.423);
30
- --popover: oklch(0.216 0.006 56.043);
31
- --popover-foreground: oklch(0.985 0.001 106.423);
32
- --primary: oklch(0.923 0.003 48.717);
33
- --primary-foreground: oklch(0.216 0.006 56.043);
34
- --secondary: oklch(0.268 0.007 34.298);
35
- --secondary-foreground: oklch(0.985 0.001 106.423);
36
- --muted: oklch(0.268 0.007 34.298);
37
- --muted-foreground: oklch(0.709 0.01 56.259);
38
- --accent: oklch(0.268 0.007 34.298);
39
- --accent-foreground: oklch(0.985 0.001 106.423);
40
- --destructive: oklch(0.704 0.191 22.216);
41
- --destructive-foreground: oklch(0.985 0.001 106.423);
42
- --border: oklch(0.268 0.007 34.298);
43
- --input: oklch(0.268 0.007 34.298);
44
- --ring: oklch(0.553 0.013 58.071);
45
- }
46
- /* @sordo:end base */
@@ -1,46 +0,0 @@
1
- /* @sordo:tokens base */
2
- :root {
3
- --background: oklch(1 0 0);
4
- --foreground: oklch(0.141 0.005 285.823);
5
- --card: oklch(1 0 0);
6
- --card-foreground: oklch(0.141 0.005 285.823);
7
- --popover: oklch(1 0 0);
8
- --popover-foreground: oklch(0.141 0.005 285.823);
9
- --primary: oklch(0.21 0.006 285.885);
10
- --primary-foreground: oklch(0.985 0 0);
11
- --secondary: oklch(0.967 0.001 286.375);
12
- --secondary-foreground: oklch(0.21 0.006 285.885);
13
- --muted: oklch(0.967 0.001 286.375);
14
- --muted-foreground: oklch(0.552 0.016 285.938);
15
- --accent: oklch(0.967 0.001 286.375);
16
- --accent-foreground: oklch(0.21 0.006 285.885);
17
- --destructive: oklch(0.577 0.245 27.325);
18
- --destructive-foreground: oklch(0.985 0 0);
19
- --border: oklch(0.92 0.004 286.32);
20
- --input: oklch(0.92 0.004 286.32);
21
- --ring: oklch(0.705 0.015 286.067);
22
- --radius: 0.625rem;
23
- }
24
-
25
- .dark {
26
- --background: oklch(0.141 0.005 285.823);
27
- --foreground: oklch(0.985 0 0);
28
- --card: oklch(0.21 0.006 285.885);
29
- --card-foreground: oklch(0.985 0 0);
30
- --popover: oklch(0.21 0.006 285.885);
31
- --popover-foreground: oklch(0.985 0 0);
32
- --primary: oklch(0.92 0.004 286.32);
33
- --primary-foreground: oklch(0.21 0.006 285.885);
34
- --secondary: oklch(0.274 0.006 286.033);
35
- --secondary-foreground: oklch(0.985 0 0);
36
- --muted: oklch(0.274 0.006 286.033);
37
- --muted-foreground: oklch(0.705 0.015 286.067);
38
- --accent: oklch(0.274 0.006 286.033);
39
- --accent-foreground: oklch(0.985 0 0);
40
- --destructive: oklch(0.704 0.191 22.216);
41
- --destructive-foreground: oklch(0.985 0 0);
42
- --border: oklch(0.274 0.006 286.033);
43
- --input: oklch(0.274 0.006 286.033);
44
- --ring: oklch(0.552 0.016 285.938);
45
- }
46
- /* @sordo:end base */