@wwchen/stack 0.6.2 → 0.6.4

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 (78) hide show
  1. package/blocks/env.example +1 -2
  2. package/dist/auth/better-auth/index.d.ts +6 -17
  3. package/dist/auth/better-auth/index.js +11 -33
  4. package/dist/auth/better-auth/tables.js +5 -14
  5. package/dist/auth/better-auth/users.d.ts +2 -7
  6. package/dist/auth/better-auth/users.js +3 -9
  7. package/dist/auth/index.d.ts +6 -17
  8. package/dist/auth/index.js +5 -19
  9. package/dist/auth/proxy.d.ts +1 -3
  10. package/dist/auth/proxy.js +6 -19
  11. package/dist/auth/safe-next.d.ts +2 -8
  12. package/dist/auth/safe-next.js +2 -8
  13. package/dist/auth/types.d.ts +1 -2
  14. package/dist/auth/types.js +1 -2
  15. package/dist/cli/context.d.ts +1 -3
  16. package/dist/cli/index.js +1 -2
  17. package/dist/cli/neon.d.ts +11 -44
  18. package/dist/cli/neon.js +15 -56
  19. package/dist/cli/sync-blocks.d.ts +1 -3
  20. package/dist/cli/sync-blocks.js +2 -6
  21. package/dist/cli/vercel-build.js +5 -16
  22. package/dist/configs/vitest.js +3 -7
  23. package/dist/connections/index.d.ts +2 -8
  24. package/dist/connections/index.js +2 -8
  25. package/dist/connections/providers.d.ts +1 -3
  26. package/dist/connections/table.d.ts +1 -2
  27. package/dist/connections/table.js +1 -2
  28. package/dist/db/explaining-pool.d.ts +1 -6
  29. package/dist/db/explaining-pool.js +3 -10
  30. package/dist/db/index.d.ts +1 -3
  31. package/dist/db/index.js +5 -13
  32. package/dist/db/migration-status.d.ts +1 -4
  33. package/dist/db/migration-status.js +1 -4
  34. package/dist/db/ssl.d.ts +1 -5
  35. package/dist/db/ssl.js +1 -5
  36. package/dist/db/target.d.ts +2 -9
  37. package/dist/db/target.js +2 -9
  38. package/dist/db/testing/index.d.ts +3 -7
  39. package/dist/db/testing/index.js +3 -7
  40. package/dist/db/testing/isolate.js +1 -2
  41. package/dist/db/testing/pglite.d.ts +2 -6
  42. package/dist/db/testing/pglite.js +2 -6
  43. package/dist/env/define-env.d.ts +3 -9
  44. package/dist/env/define-env.js +6 -16
  45. package/dist/env/load-env-file.d.ts +4 -9
  46. package/dist/env/load-env-file.js +5 -11
  47. package/dist/env/stack-env.d.ts +1 -3
  48. package/dist/env/stack-env.js +3 -7
  49. package/dist/env/testing.d.ts +1 -3
  50. package/dist/env/testing.js +2 -5
  51. package/dist/http/client-ip.d.ts +2 -8
  52. package/dist/http/client-ip.js +3 -10
  53. package/dist/http/guards.d.ts +3 -10
  54. package/dist/http/guards.js +4 -12
  55. package/dist/http/rate-limit.d.ts +4 -10
  56. package/dist/http/rate-limit.js +7 -19
  57. package/dist/jobs/index.d.ts +2 -9
  58. package/dist/jobs/index.js +2 -9
  59. package/dist/mail/index.d.ts +2 -9
  60. package/dist/mail/index.js +2 -7
  61. package/dist/next/api.d.ts +6 -17
  62. package/dist/next/api.js +6 -15
  63. package/dist/next/config.js +10 -32
  64. package/dist/next/cron.d.ts +2 -6
  65. package/dist/next/cron.js +3 -8
  66. package/dist/next/health.d.ts +3 -8
  67. package/dist/next/health.js +3 -8
  68. package/dist/testing/next.d.ts +1 -4
  69. package/dist/testing/next.js +2 -7
  70. package/dist/ui/app.css +5 -16
  71. package/dist/ui/globals.css +6 -20
  72. package/dist/ui/icons.d.ts +1 -3
  73. package/dist/ui/icons.js +3 -10
  74. package/dist/ui/index.d.ts +4 -12
  75. package/dist/ui/index.js +4 -12
  76. package/dist/ui/theme.d.ts +3 -9
  77. package/dist/ui/theme.js +3 -9
  78. package/package.json +3 -3
package/dist/next/api.js CHANGED
@@ -1,16 +1,11 @@
1
1
  import { z } from "zod";
2
2
  import { hasNoBody, isJsonRequest, isMutation, isSameOrigin } from "../http/guards.js";
3
3
  /**
4
- * The shell every API route runs in: session, admin check, the request guards, the handler, and
5
- * the envelope for whatever it throws. Written once so route files cannot drift on it.
4
+ * The shell every API route runs in: session, admin check, the request guards, the handler, and the envelope for whatever it throws. Written once so route files cannot drift on it.
6
5
  *
7
- * Every failure answers `{ error: { code, message } }`. An `ApiError` is answered as it says; that
8
- * is how `readJson` reports the request body (400 `invalid_json`, 422 `invalid_input`). Anything
9
- * else is a bug, even a SyntaxError or a ZodError from the route's own code, and becomes a 500 with
10
- * a fixed message: what was thrown is logged for the operator and never sent to the caller.
6
+ * Every failure answers `{ error: { code, message } }`. An `ApiError` is answered as it says; that is how `readJson` reports the request body (400 `invalid_json`, 422 `invalid_input`). Anything else is a bug, even a SyntaxError or a ZodError from the route's own code, and becomes a 500 with a fixed message: what was thrown is logged for the operator and never sent to the caller.
11
7
  *
12
- * `CRON_SECRET` and `HEALTH_TOKEN` are never read here. This wrapper accepts a session and nothing
13
- * else, so neither secret opens an API route.
8
+ * `CRON_SECRET` and `HEALTH_TOKEN` are never read here. This wrapper accepts a session and nothing else, so neither secret opens an API route.
14
9
  */
15
10
  /** An error a route throws on purpose: its message is written for the caller and is sent as is. */
16
11
  export class ApiError extends Error {
@@ -35,8 +30,7 @@ export class NotFoundError extends ApiError {
35
30
  }
36
31
  }
37
32
  /**
38
- * A path id that is not a uuid: the same 404 a missing row gets, but told apart from one so a
39
- * route that surfaces its own not-found message never surfaces this one.
33
+ * A path id that is not a uuid: the same 404 a missing row gets, but told apart from one so a route that surfaces its own not-found message never surfaces this one.
40
34
  */
41
35
  export class PathIdError extends NotFoundError {
42
36
  constructor() {
@@ -45,9 +39,7 @@ export class PathIdError extends NotFoundError {
45
39
  }
46
40
  }
47
41
  /**
48
- * A path id, or a `PathIdError` for the wrapper to answer. Anything that is not a uuid cannot name
49
- * a row, so it is the same 404 a missing row gets, answered before the query: Postgres would
50
- * otherwise reject the cast and turn a typo'd URL into a 500.
42
+ * A path id, or a `PathIdError` for the wrapper to answer. Anything that is not a uuid cannot name a row, so it is the same 404 a missing row gets, answered before the query: Postgres would otherwise reject the cast and turn a typo'd URL into a 500.
51
43
  */
52
44
  export function requirePathId(value) {
53
45
  if (!z.uuid().safeParse(value).success)
@@ -99,8 +91,7 @@ export function apiHandler(opts, fn) {
99
91
  return apiError(404, "not_found", "Not found.");
100
92
  }
101
93
  if (isMutation(req)) {
102
- // JSON only, so a cross-site form post can't reach a handler; a request with no body at
103
- // all (a plain `DELETE`) has nothing to be JSON, and a form always sends a Content-Type.
94
+ // JSON only, so a cross-site form post can't reach a handler; a request with no body at all (a plain `DELETE`) has nothing to be JSON, and a form always sends a Content-Type.
104
95
  if (!isJsonRequest(req) && !hasNoBody(req)) {
105
96
  return apiError(415, "unsupported_media_type", "Send application/json.");
106
97
  }
@@ -2,8 +2,7 @@ import { isProductionEnv } from "../env/index.js";
2
2
  /**
3
3
  * `next.config.ts`: `export default withStack({ ...the app's own config })`.
4
4
  *
5
- * Sentry (or any monitor) is initialised at runtime from `instrumentation.ts`, not through a
6
- * build-time config wrapper, so there is nothing to compose here.
5
+ * Sentry (or any monitor) is initialised at runtime from `instrumentation.ts`, not through a build-time config wrapper, so there is nothing to compose here.
7
6
  */
8
7
  const securityHeaders = [
9
8
  { key: "X-Content-Type-Options", value: "nosniff" },
@@ -15,51 +14,31 @@ const securityHeaders = [
15
14
  /**
16
15
  * **The Content-Security-Policy, production only.**
17
16
  *
18
- * Turbopack's dev server needs `'unsafe-eval'` and a websocket for HMR that a production policy
19
- * must not carry, and a half-right CSP breaks the dev loop. So the header is added to production
20
- * builds only, and a claim about it can only be checked against a production build
21
- * (`pnpm build && pnpm start`): an e2e suite running against `pnpm dev` never sees it.
17
+ * Turbopack's dev server needs `'unsafe-eval'` and a websocket for HMR that a production policy must not carry, and a half-right CSP breaks the dev loop. So the header is added to production builds only, and a claim about it can only be checked against a production build (`pnpm build && pnpm start`): an e2e suite running against `pnpm dev` never sees it.
22
18
  *
23
- * `process.env.NODE_ENV` is read through `isProductionEnv` rather than an app's validated env
24
- * because this file is Next's own config: the framework evaluates it before any application module
25
- * loads, and importing validated config would make a build depend on a boot.
19
+ * `process.env.NODE_ENV` is read through `isProductionEnv` rather than an app's validated env because this file is Next's own config: the framework evaluates it before any application module loads, and importing validated config would make a build depend on a boot.
26
20
  */
27
21
  function contentSecurityPolicy(connectSrc) {
28
22
  return [
29
23
  // Nothing loads from anywhere but this origin unless a directive below says so.
30
24
  "default-src 'self'",
31
25
  /**
32
- * `'unsafe-inline'`, and the reason is structural rather than lazy: Next's App Router ships the
33
- * flight payload and its hydration bootstrap as INLINE `<script>` tags, and a policy living in
34
- * `next.config.ts` is a static header: it cannot carry the per-request nonce those tags would
35
- * need. With `script-src 'self'` alone the page server-renders and the console fills with
36
- * "Executing inline script violates...", which means no hydration and dead client components.
26
+ * `'unsafe-inline'`, and the reason is structural rather than lazy: Next's App Router ships the flight payload and its hydration bootstrap as INLINE `<script>` tags, and a policy living in `next.config.ts` is a static header: it cannot carry the per-request nonce those tags would need. With `script-src 'self'` alone the page server-renders and the console fills with "Executing inline script violates...", which means no hydration and dead client components.
37
27
  *
38
- * A nonce-based policy is strictly better: generate one per request in `src/proxy.ts`, pass it
39
- * on the request headers, and Next stamps its own scripts with it. That moves the CSP out of
40
- * this file and puts per-request work in the one file that guards every page, so it is a
41
- * decision for the app rather than a default here.
28
+ * A nonce-based policy is strictly better: generate one per request in `src/proxy.ts`, pass it on the request headers, and Next stamps its own scripts with it. That moves the CSP out of this file and puts per-request work in the one file that guards every page, so it is a decision for the app rather than a default here.
42
29
  *
43
- * What this still buys: no script from another origin can load, `eval` is refused (no
44
- * `'unsafe-eval'`), and the directives below close framing, base-tag and form-action
45
- * redirection. Strictly better than no CSP.
30
+ * What this still buys: no script from another origin can load, `eval` is refused (no `'unsafe-eval'`), and the directives below close framing, base-tag and form-action redirection. Strictly better than no CSP.
46
31
  */
47
32
  "script-src 'self' 'unsafe-inline'",
48
33
  /**
49
- * `'unsafe-inline'` here is a correctness requirement, not a convenience. Under `style-src
50
- * 'self'` a browser keeps a `style="..."` attribute and refuses to apply it, so any component
51
- * that sets a width or transform inline renders as if the style were absent (a meter drawn at
52
- * full width is a worse failure than a missing header).
34
+ * `'unsafe-inline'` here is a correctness requirement, not a convenience. Under `style-src 'self'` a browser keeps a `style="..."` attribute and refuses to apply it, so any component that sets a width or transform inline renders as if the style were absent (a meter drawn at full width is a worse failure than a missing header).
53
35
  *
54
- * `style-src-attr 'unsafe-inline'` with a strict `style-src` would be tighter, and is
55
- * deliberately not used: where a browser does not support `style-src-attr` it falls back to
56
- * `style-src`, and the failure mode of guessing wrong is the one above.
36
+ * `style-src-attr 'unsafe-inline'` with a strict `style-src` would be tighter, and is deliberately not used: where a browser does not support `style-src-attr` it falls back to `style-src`, and the failure mode of guessing wrong is the one above.
57
37
  */
58
38
  "style-src 'self' 'unsafe-inline'",
59
39
  // `data:` is for the favicon and inline icons; remote images are an app decision.
60
40
  "img-src 'self' data:",
61
- // `next/font` downloads fonts AT BUILD TIME and serves them from /_next/static, so the running
62
- // app never reaches a font CDN and this stays 'self'.
41
+ // `next/font` downloads fonts AT BUILD TIME and serves them from /_next/static, so the running app never reaches a font CDN and this stays 'self'.
63
42
  "font-src 'self'",
64
43
  // Same-origin fetches only, plus whatever origins the app lists in `cspConnectSrc`.
65
44
  ["connect-src 'self'", ...connectSrc].join(" "),
@@ -87,8 +66,7 @@ export function withStack(appConfig = {}, opts = {}) {
87
66
  reactStrictMode: true,
88
67
  ...appConfig,
89
68
  poweredByHeader: false,
90
- // The health route checks the migrations folder at runtime. Vercel bundles only traced files,
91
- // so without this the read fails and migrations always report "unknown".
69
+ // The health route checks the migrations folder at runtime. Vercel bundles only traced files, so without this the read fails and migrations always report "unknown".
92
70
  outputFileTracingIncludes: {
93
71
  ...appConfig.outputFileTracingIncludes,
94
72
  "/api/health": ["./drizzle/**"],
@@ -1,11 +1,7 @@
1
1
  /**
2
- * A scheduled job's route, called by Vercel Cron with `Authorization: Bearer $CRON_SECRET`.
3
- * `CRON_SECRET` triggers scheduled jobs and nothing else: with none configured every request is
4
- * refused (an empty bearer is not accepted), and the response is whatever `fn` returned, which
5
- * must be counts. No row data, no ids, no messages.
2
+ * A scheduled job's route, called by Vercel Cron with `Authorization: Bearer $CRON_SECRET`. `CRON_SECRET` triggers scheduled jobs and nothing else: with none configured every request is refused (an empty bearer is not accepted), and the response is whatever `fn` returned, which must be counts. No row data, no ids, no messages.
6
3
  *
7
- * A job that returns `alerting: true` answers 500 with the same counts, so an uptime monitor calling
8
- * it alerts: a multi-person job sets it while someone's failure is new (`@wwchen/stack/jobs`).
4
+ * A job that returns `alerting: true` answers 500 with the same counts, so an uptime monitor calling it alerts: a multi-person job sets it while someone's failure is new (`@wwchen/stack/jobs`).
9
5
  *
10
6
  * `export const GET = cronRoute(tick, { secret: env.CRON_SECRET })`.
11
7
  */
package/dist/next/cron.js CHANGED
@@ -1,21 +1,16 @@
1
1
  import { bearerMatches } from "../http/guards.js";
2
2
  import { apiError } from "./api.js";
3
3
  /**
4
- * A scheduled job's route, called by Vercel Cron with `Authorization: Bearer $CRON_SECRET`.
5
- * `CRON_SECRET` triggers scheduled jobs and nothing else: with none configured every request is
6
- * refused (an empty bearer is not accepted), and the response is whatever `fn` returned, which
7
- * must be counts. No row data, no ids, no messages.
4
+ * A scheduled job's route, called by Vercel Cron with `Authorization: Bearer $CRON_SECRET`. `CRON_SECRET` triggers scheduled jobs and nothing else: with none configured every request is refused (an empty bearer is not accepted), and the response is whatever `fn` returned, which must be counts. No row data, no ids, no messages.
8
5
  *
9
- * A job that returns `alerting: true` answers 500 with the same counts, so an uptime monitor calling
10
- * it alerts: a multi-person job sets it while someone's failure is new (`@wwchen/stack/jobs`).
6
+ * A job that returns `alerting: true` answers 500 with the same counts, so an uptime monitor calling it alerts: a multi-person job sets it while someone's failure is new (`@wwchen/stack/jobs`).
11
7
  *
12
8
  * `export const GET = cronRoute(tick, { secret: env.CRON_SECRET })`.
13
9
  */
14
10
  export function cronRoute(fn, opts) {
15
11
  return async (req) => {
16
12
  if (!bearerMatches(req, opts.secret)) {
17
- // A refused call writes nothing anywhere, so without this line a missing or wrong secret
18
- // looks exactly like a cron that never fired. Never logs what was presented.
13
+ // A refused call writes nothing anywhere, so without this line a missing or wrong secret looks exactly like a cron that never fired. Never logs what was presented.
19
14
  console.warn(JSON.stringify({
20
15
  level: "warn",
21
16
  msg: "cron refused",
@@ -1,15 +1,10 @@
1
1
  import type { NodePgDatabase } from "drizzle-orm/node-postgres";
2
2
  /**
3
- * Liveness, deliberately not readiness. The status is ALWAYS 200 while the process can answer: a
4
- * database blip must not make an uptime check report a healthy web process as down.
3
+ * Liveness, deliberately not readiness. The status is ALWAYS 200 while the process can answer: a database blip must not make an uptime check report a healthy web process as down.
5
4
  *
6
- * Without the token the answer is `{ ok: true }` and the database is never touched, so an
7
- * anonymous caller cannot make the app query it. With `Authorization: Bearer $HEALTH_TOKEN` it
8
- * also reports `db` and `migrations`. `HEALTH_TOKEN` is its own secret, never `CRON_SECRET`.
5
+ * Without the token the answer is `{ ok: true }` and the database is never touched, so an anonymous caller cannot make the app query it. With `Authorization: Bearer $HEALTH_TOKEN` it also reports `db` and `migrations`. `HEALTH_TOKEN` is its own secret, never `CRON_SECRET`.
9
6
  *
10
- * `export const GET = healthRoute({ db, token: env.HEALTH_TOKEN })`, with `dynamic =
11
- * "force-dynamic"`. `withStack` traces `./drizzle/**` into this route so the migrations folder
12
- * exists in a deployment.
7
+ * `export const GET = healthRoute({ db, token: env.HEALTH_TOKEN })`, with `dynamic = "force-dynamic"`. `withStack` traces `./drizzle/**` into this route so the migrations folder exists in a deployment.
13
8
  */
14
9
  export declare function healthRoute(opts: {
15
10
  db?: NodePgDatabase<any>;
@@ -3,16 +3,11 @@ import { sql } from "drizzle-orm";
3
3
  import { migrationStatus } from "../db/migration-status.js";
4
4
  import { bearerMatches } from "../http/guards.js";
5
5
  /**
6
- * Liveness, deliberately not readiness. The status is ALWAYS 200 while the process can answer: a
7
- * database blip must not make an uptime check report a healthy web process as down.
6
+ * Liveness, deliberately not readiness. The status is ALWAYS 200 while the process can answer: a database blip must not make an uptime check report a healthy web process as down.
8
7
  *
9
- * Without the token the answer is `{ ok: true }` and the database is never touched, so an
10
- * anonymous caller cannot make the app query it. With `Authorization: Bearer $HEALTH_TOKEN` it
11
- * also reports `db` and `migrations`. `HEALTH_TOKEN` is its own secret, never `CRON_SECRET`.
8
+ * Without the token the answer is `{ ok: true }` and the database is never touched, so an anonymous caller cannot make the app query it. With `Authorization: Bearer $HEALTH_TOKEN` it also reports `db` and `migrations`. `HEALTH_TOKEN` is its own secret, never `CRON_SECRET`.
12
9
  *
13
- * `export const GET = healthRoute({ db, token: env.HEALTH_TOKEN })`, with `dynamic =
14
- * "force-dynamic"`. `withStack` traces `./drizzle/**` into this route so the migrations folder
15
- * exists in a deployment.
10
+ * `export const GET = healthRoute({ db, token: env.HEALTH_TOKEN })`, with `dynamic = "force-dynamic"`. `withStack` traces `./drizzle/**` into this route so the migrations folder exists in a deployment.
16
11
  */
17
12
  export function healthRoute(opts) {
18
13
  const migrationsFolder = opts.migrationsFolder ?? path.join(process.cwd(), "drizzle");
@@ -1,8 +1,5 @@
1
1
  /**
2
- * Runs `fn` inside a real Next request scope in its server-action phase — what Next sets up around
3
- * a `"use server"` function — so `headers()` reads `headers` and `cookies().set()` works. Returns
4
- * the `Set-Cookie` lines the scope would send, which is how a test sees what Better Auth's
5
- * `nextCookies()` wrote. Built from Next's own internals (next is pinned exactly).
2
+ * Runs `fn` inside a real Next request scope in its server-action phase — what Next sets up around a `"use server"` function — so `headers()` reads `headers` and `cookies().set()` works. Returns the `Set-Cookie` lines the scope would send, which is how a test sees what Better Auth's `nextCookies()` wrote. Built from Next's own internals (next is pinned exactly).
6
3
  *
7
4
  * `redirect()` and `notFound()` throw as they do in Next; `thrownBy` reads where they pointed.
8
5
  */
@@ -1,14 +1,9 @@
1
- // `@wwchen/stack/testing/next`: test helpers, for a stack app's tests and the package's own. Not
2
- // for app code. Built on Next's internals, which move with the exact `next` the stack pins, so they
3
- // ship here and an app takes a fix with the stack rather than keeping a copy.
1
+ // `@wwchen/stack/testing/next`: test helpers, for a stack app's tests and the package's own. Not for app code. Built on Next's internals, which move with the exact `next` the stack pins, so they ship here and an app takes a fix with the stack rather than keeping a copy.
4
2
  import { workAsyncStorage } from "next/dist/server/app-render/work-async-storage.external.js";
5
3
  import { workUnitAsyncStorage } from "next/dist/server/app-render/work-unit-async-storage.external.js";
6
4
  import { createRequestStoreForAPI } from "next/dist/server/async-storage/request-store.js";
7
5
  /**
8
- * Runs `fn` inside a real Next request scope in its server-action phase — what Next sets up around
9
- * a `"use server"` function — so `headers()` reads `headers` and `cookies().set()` works. Returns
10
- * the `Set-Cookie` lines the scope would send, which is how a test sees what Better Auth's
11
- * `nextCookies()` wrote. Built from Next's own internals (next is pinned exactly).
6
+ * Runs `fn` inside a real Next request scope in its server-action phase — what Next sets up around a `"use server"` function — so `headers()` reads `headers` and `cookies().set()` works. Returns the `Set-Cookie` lines the scope would send, which is how a test sees what Better Auth's `nextCookies()` wrote. Built from Next's own internals (next is pinned exactly).
12
7
  *
13
8
  * `redirect()` and `notFound()` throw as they do in Next; `thrownBy` reads where they pointed.
14
9
  */
package/dist/ui/app.css CHANGED
@@ -1,13 +1,9 @@
1
1
  /*
2
- * The bridge onto LDS (`@lew-ds/lds`, imported in globals.css): the only place the package adjusts
3
- * it. Each rule says which gap it fills.
2
+ * The bridge onto LDS (`@lew-ds/lds`, imported in globals.css): the only place the package adjusts it. Each rule says which gap it fills.
4
3
  */
5
4
 
6
5
  /*
7
- * Fonts. The product theme names 'Inter', which LDS does not ship as a file. An app that loads
8
- * Inter through `next/font` exposes it as `--font-inter` under a generated family name, so the
9
- * theme's font roles point there; without it they fall back to the system font.
10
- * `--th-mono` stays the theme's ui-monospace.
6
+ * Fonts. The product theme names 'Inter', which LDS does not ship as a file. An app that loads Inter through `next/font` exposes it as `--font-inter` under a generated family name, so the theme's font roles point there; without it they fall back to the system font. `--th-mono` stays the theme's ui-monospace.
11
7
  */
12
8
  .theme-product {
13
9
  --th-display: var(--font-inter, Inter), system-ui, sans-serif;
@@ -16,9 +12,7 @@
16
12
  }
17
13
 
18
14
  /*
19
- * Two roles LDS spells only inside a component, given a name so a layout utility can use them: the
20
- * soft tint (`.emph-soft`'s fill and ink, for a selected nav item) and the error ink (an
21
- * `lds-field__error`'s colour on the red ramp).
15
+ * Two roles LDS spells only inside a component, given a name so a layout utility can use them: the soft tint (`.emph-soft`'s fill and ink, for a selected nav item) and the error ink (an `lds-field__error`'s colour on the red ramp).
22
16
  */
23
17
  :root {
24
18
  --app-tint: var(--c-100);
@@ -33,19 +27,14 @@
33
27
  }
34
28
 
35
29
  /*
36
- * Tooltip line breaks. LDS's bubble collapses whitespace, so a label listing several items, one to
37
- * a line, would run together. `pre-line` keeps the label's newlines and still wraps long lines; a
38
- * label without one reads as before.
30
+ * Tooltip line breaks. LDS's bubble collapses whitespace, so a label listing several items, one to a line, would run together. `pre-line` keeps the label's newlines and still wraps long lines; a label without one reads as before.
39
31
  */
40
32
  .lds-tooltip__bubble {
41
33
  white-space: pre-line;
42
34
  }
43
35
 
44
36
  /*
45
- * No zoom on focus. iOS Safari zooms the page into any field whose text is under 16px and leaves
46
- * it zoomed after; LDS's fields take the 13px body. On a touch screen they take 16px, so focusing a
47
- * field leaves the page where it was. Pinch zoom stays: the viewport is never locked
48
- * (`maximum-scale` would break the 200% zoom rule). A desktop keeps LDS's size.
37
+ * No zoom on focus. iOS Safari zooms the page into any field whose text is under 16px and leaves it zoomed after; LDS's fields take the 13px body. On a touch screen they take 16px, so focusing a field leaves the page where it was. Pinch zoom stays: the viewport is never locked (`maximum-scale` would break the 200% zoom rule). A desktop keeps LDS's size.
49
38
  */
50
39
  @media (pointer: coarse) {
51
40
  .lds-field input,
@@ -1,19 +1,12 @@
1
1
  /*
2
- * The design system is LDS (Lew Design System), product theme: the `@lew-ds/lds` package.
3
- * LDS paints components through its own class names (`lds-btn`, `lds-tag`, `lds-table`, …), which
4
- * `@lew-ds/lds-react`'s components emit. Tailwind is kept for LAYOUT, and every colour, radius
5
- * and shadow utility below resolves to an LDS role, so there is one palette, not two.
2
+ * The design system is LDS (Lew Design System), product theme: the `@lew-ds/lds` package. LDS paints components through its own class names (`lds-btn`, `lds-tag`, `lds-table`, …), which `@lew-ds/lds-react`'s components emit. Tailwind is kept for LAYOUT, and every colour, radius and shadow utility below resolves to an LDS role, so there is one palette, not two.
6
3
  *
7
4
  * Import this file FIRST in the app's stylesheet, then Tailwind:
8
5
  *
9
6
  * @import "@wwchen/stack/ui/globals.css";
10
7
  * @import "tailwindcss";
11
8
  *
12
- * The layer order below must be the first `@layer` statement Tailwind's own sees: LDS sits after
13
- * Tailwind's preflight (so it styles bare buttons and links) and before `components` and
14
- * `utilities` (so a layout utility on an LDS element still wins). LDS's root tokens therefore also
15
- * win over any Tailwind default that shares their name (`--radius-lg`, `--shadow-sm`,
16
- * `--leading-tight`): LDS is the system.
9
+ * The layer order below must be the first `@layer` statement Tailwind's own sees: LDS sits after Tailwind's preflight (so it styles bare buttons and links) and before `components` and `utilities` (so a layout utility on an LDS element still wins). LDS's root tokens therefore also win over any Tailwind default that shares their name (`--radius-lg`, `--shadow-sm`, `--leading-tight`): LDS is the system.
17
10
  */
18
11
  @layer theme, base, lds, components, utilities;
19
12
 
@@ -23,15 +16,12 @@
23
16
  @import "./app.css" layer(lds);
24
17
 
25
18
  /*
26
- * Dark mode is LDS's `mode-dark` class, which the SERVER writes onto <html> from the theme cookie
27
- * beside `theme-product` (see `htmlClassName`): never a media query and never a client-side flip,
28
- * so the first response is already correct.
19
+ * Dark mode is LDS's `mode-dark` class, which the SERVER writes onto <html> from the theme cookie beside `theme-product` (see `htmlClassName`): never a media query and never a client-side flip, so the first response is already correct.
29
20
  */
30
21
  @custom-variant dark (&:where(.mode-dark, .mode-dark *));
31
22
 
32
23
  /*
33
- * `inline`: each utility emits the LDS variable itself (`color: var(--text)`), so it re-resolves
34
- * wherever an LDS emphasis or mode class re-points the role, the way LDS's own components do.
24
+ * `inline`: each utility emits the LDS variable itself (`color: var(--text)`), so it re-resolves wherever an LDS emphasis or mode class re-points the role, the way LDS's own components do.
35
25
  */
36
26
  @theme inline {
37
27
  /* ---- surfaces, borders and text: LDS's object-colour roles ---- */
@@ -108,9 +98,7 @@
108
98
 
109
99
  @layer base {
110
100
  /*
111
- * The root stays 14px (LDS's size-3): every rem-based utility (the container widths) is measured
112
- * from it, and LDS's own sizes are px. Text takes LDS's 13px body from the `text-copy` on <body>,
113
- * not from here.
101
+ * The root stays 14px (LDS's size-3): every rem-based utility (the container widths) is measured from it, and LDS's own sizes are px. Text takes LDS's 13px body from the `text-copy` on <body>, not from here.
114
102
  */
115
103
  html {
116
104
  font-size: var(--size-3);
@@ -135,9 +123,7 @@
135
123
  }
136
124
 
137
125
  /*
138
- * Reduced motion, deliberately OUTSIDE every layer: unlayered CSS wins over `@layer utilities`
139
- * whatever the specificity, so this needs no `!important` to switch off a `duration-*` utility. It
140
- * covers LDS's own hover, focus and press transitions too.
126
+ * Reduced motion, deliberately OUTSIDE every layer: unlayered CSS wins over `@layer utilities` whatever the specificity, so this needs no `!important` to switch off a `duration-*` utility. It covers LDS's own hover, focus and press transitions too.
141
127
  */
142
128
  @media (prefers-reduced-motion: reduce) {
143
129
  [class*="duration-"],
@@ -1,7 +1,5 @@
1
1
  /**
2
- * The page's icon sprite holds the app's icons plus what LDS's components draw on their own. A
3
- * glyph a component names but the sprite lacks renders as nothing, with no error anywhere, so this
4
- * reads every glyph name the app's source hands an LDS component and checks it is in the sprite.
2
+ * The page's icon sprite holds the app's icons plus what LDS's components draw on their own. A glyph a component names but the sprite lacks renders as nothing, with no error anywhere, so this reads every glyph name the app's source hands an LDS component and checks it is in the sprite.
5
3
  */
6
4
  export interface IconReport {
7
5
  /** Named in source, in neither the app's icons nor LDS's component icons. */
package/dist/ui/icons.js CHANGED
@@ -14,9 +14,7 @@ const IMPORTS_LDS = /from "(?:@wwchen\/stack\/ui|@lew-ds\/lds-react)"/;
14
14
  /** An icon named as data: `icon: "home"` (or `iconStart`/`iconEnd`) in an object literal. */
15
15
  const ICON_DATA = /\b(?:icon|iconStart|iconEnd):\s*"([^"]+)"/g;
16
16
  /**
17
- * Whether the file renders an LDS component, however it imports it: an app's own re-export
18
- * (`@/components/ui/lds`) is as much LDS as `@wwchen/stack/ui`. A file that does is where a glyph
19
- * listed as data (`{ href: "/", icon: "home" }`, handed on as `<Icon name={view.icon} />`) is drawn.
17
+ * Whether the file renders an LDS component, however it imports it: an app's own re-export (`@/components/ui/lds`) is as much LDS as `@wwchen/stack/ui`. A file that does is where a glyph listed as data (`{ href: "/", icon: "home" }`, handed on as `<Icon name={view.icon} />`) is drawn.
20
18
  */
21
19
  function rendersLds(text) {
22
20
  for (const tag of text.matchAll(/<([A-Z]\w*)/g)) {
@@ -37,8 +35,7 @@ function braced(text, open) {
37
35
  return text.slice(open + 1);
38
36
  }
39
37
  /**
40
- * Whether the tag opened at `from` is still open at `to`: no `>` outside braces and quotes between
41
- * them. A `=>` or `>` inside a `{…}` value or a string does not close it.
38
+ * Whether the tag opened at `from` is still open at `to`: no `>` outside braces and quotes between them. A `=>` or `>` inside a `{…}` value or a string does not close it.
42
39
  */
43
40
  function tagOpenAt(text, from, to) {
44
41
  let depth = 0;
@@ -70,11 +67,7 @@ function enclosingTag(text, at) {
70
67
  return undefined;
71
68
  }
72
69
  /**
73
- * Every glyph name a JSX source hands an LDS component: a literal (`iconStart="edit"`) or any
74
- * string in an expression (`iconStart={open ? "chevron-up" : "chevron-down"}`), except an
75
- * attribute value nested inside it (`type="button"` on an element passed as the icon). Also an
76
- * `icon: "…"` in an object literal (a SegmentedControl option, a nav's list of views), in a file
77
- * that imports LDS or renders an LDS component.
70
+ * Every glyph name a JSX source hands an LDS component: a literal (`iconStart="edit"`) or any string in an expression (`iconStart={open ? "chevron-up" : "chevron-down"}`), except an attribute value nested inside it (`type="button"` on an element passed as the icon). Also an `icon: "…"` in an object literal (a SegmentedControl option, a nav's list of views), in a file that imports LDS or renders an LDS component.
78
71
  */
79
72
  function glyphNamesIn(text) {
80
73
  const found = [];
@@ -1,14 +1,9 @@
1
1
  import { type ButtonProps, type IconButtonProps, type LinkProps, type RowProps } from "@lew-ds/lds-react";
2
2
  import type { ReactNode } from "react";
3
3
  /**
4
- * The design system, as an app imports it: `@lew-ds/lds-react` (server components, but for the
5
- * five stateful ones, which carry their own `"use client"`), with one thing bound. Every component
6
- * that can take an `href` (Button, IconButton, Link, Row) renders it through `next/link`, so moving
7
- * between pages is a client navigation rather than a full reload. LDS takes the router's link as
8
- * `as`; a call site can still pass its own.
4
+ * The design system, as an app imports it: `@lew-ds/lds-react` (server components, but for the five stateful ones, which carry their own `"use client"`), with one thing bound. Every component that can take an `href` (Button, IconButton, Link, Row) renders it through `next/link`, so moving between pages is a client navigation rather than a full reload. LDS takes the router's link as `as`; a call site can still pass its own.
9
5
  *
10
- * Import every LDS component from here, never from the package directly, so no link forgets `as`.
11
- * This module has no `"use client"`: a server component can import it, and so can a client one.
6
+ * Import every LDS component from here, never from the package directly, so no link forgets `as`. This module has no `"use client"`: a server component can import it, and so can a client one.
12
7
  */
13
8
  export * from "@lew-ds/lds-react";
14
9
  export type { Theme } from "./theme.ts";
@@ -17,15 +12,12 @@ export declare function Button(props: ButtonProps): import("react").JSX.Element;
17
12
  /** IconButton renders the package's own Button inside its Tooltip, so it needs the binding too. */
18
13
  export declare function IconButton(props: IconButtonProps): import("react").JSX.Element;
19
14
  /**
20
- * LDS's Link renders an anchor even with no `href` (a placeholder link), which `next/link` refuses:
21
- * the router's link only stands in when there is somewhere to go.
15
+ * LDS's Link renders an anchor even with no `href` (a placeholder link), which `next/link` refuses: the router's link only stands in when there is somewhere to go.
22
16
  */
23
17
  export declare function Link(props: LinkProps): import("react").JSX.Element;
24
18
  export declare function Row(props: RowProps): import("react").JSX.Element;
25
19
  /**
26
- * The root of an app's `<body>`: the inline icon sprite, then the page. Masked glyphs draw blank
27
- * from an external sprite in Chromium, so the sprite is in the document. `icons` is the app's own
28
- * glyphs (see `checkIcons`); LDS adds the ones its components draw.
20
+ * The root of an app's `<body>`: the inline icon sprite, then the page. Masked glyphs draw blank from an external sprite in Chromium, so the sprite is in the document. `icons` is the app's own glyphs (see `checkIcons`); LDS adds the ones its components draw.
29
21
  */
30
22
  export declare function StackRoot({ icons, children }: {
31
23
  icons: readonly string[];
package/dist/ui/index.js CHANGED
@@ -3,14 +3,9 @@ import { Button as LdsButton, IconButton as LdsIconButton, Link as LdsLink, Row
3
3
  import { IconSprite } from "@lew-ds/lds-react/icon-sprite";
4
4
  import NextLink from "next/link.js";
5
5
  /**
6
- * The design system, as an app imports it: `@lew-ds/lds-react` (server components, but for the
7
- * five stateful ones, which carry their own `"use client"`), with one thing bound. Every component
8
- * that can take an `href` (Button, IconButton, Link, Row) renders it through `next/link`, so moving
9
- * between pages is a client navigation rather than a full reload. LDS takes the router's link as
10
- * `as`; a call site can still pass its own.
6
+ * The design system, as an app imports it: `@lew-ds/lds-react` (server components, but for the five stateful ones, which carry their own `"use client"`), with one thing bound. Every component that can take an `href` (Button, IconButton, Link, Row) renders it through `next/link`, so moving between pages is a client navigation rather than a full reload. LDS takes the router's link as `as`; a call site can still pass its own.
11
7
  *
12
- * Import every LDS component from here, never from the package directly, so no link forgets `as`.
13
- * This module has no `"use client"`: a server component can import it, and so can a client one.
8
+ * Import every LDS component from here, never from the package directly, so no link forgets `as`. This module has no `"use client"`: a server component can import it, and so can a client one.
14
9
  */
15
10
  export * from "@lew-ds/lds-react";
16
11
  export { htmlClassName, resolveTheme, THEME_COOKIE } from "./theme.js";
@@ -22,8 +17,7 @@ export function IconButton(props) {
22
17
  return _jsx(LdsIconButton, { as: NextLink, ...props });
23
18
  }
24
19
  /**
25
- * LDS's Link renders an anchor even with no `href` (a placeholder link), which `next/link` refuses:
26
- * the router's link only stands in when there is somewhere to go.
20
+ * LDS's Link renders an anchor even with no `href` (a placeholder link), which `next/link` refuses: the router's link only stands in when there is somewhere to go.
27
21
  */
28
22
  export function Link(props) {
29
23
  return _jsx(LdsLink, { as: props.href === undefined ? undefined : NextLink, ...props });
@@ -32,9 +26,7 @@ export function Row(props) {
32
26
  return _jsx(LdsRow, { as: NextLink, ...props });
33
27
  }
34
28
  /**
35
- * The root of an app's `<body>`: the inline icon sprite, then the page. Masked glyphs draw blank
36
- * from an external sprite in Chromium, so the sprite is in the document. `icons` is the app's own
37
- * glyphs (see `checkIcons`); LDS adds the ones its components draw.
29
+ * The root of an app's `<body>`: the inline icon sprite, then the page. Masked glyphs draw blank from an external sprite in Chromium, so the sprite is in the document. `icons` is the app's own glyphs (see `checkIcons`); LDS adds the ones its components draw.
38
30
  */
39
31
  export function StackRoot({ icons, children }) {
40
32
  return (_jsxs(_Fragment, { children: [_jsx(IconSprite, { icons: icons }), children] }));
@@ -1,18 +1,12 @@
1
1
  export type Theme = "light" | "dark";
2
2
  export declare const THEME_COOKIE = "theme";
3
3
  /**
4
- * The classes LDS needs on `<html>`: the product theme (its ramps, type, radii and shadows) and the
5
- * mode its dark rules key on (`.mode-dark .lds-tag`). Pure, so a root layout and Storybook write
6
- * the same thing. `extra` is appended (an app's `next/font` class).
4
+ * The classes LDS needs on `<html>`: the product theme (its ramps, type, radii and shadows) and the mode its dark rules key on (`.mode-dark .lds-tag`). Pure, so a root layout and Storybook write the same thing. `extra` is appended (an app's `next/font` class).
7
5
  */
8
6
  export declare function htmlClassName(theme: Theme, extra?: string): string;
9
7
  /**
10
- * The server-side theme read: the `theme` cookie, `light` unless it says `dark`. Dark mode is
11
- * correct in the FIRST server response, before any client script runs, because the root layout
12
- * calls this during render and writes the class onto `<html>`.
8
+ * The server-side theme read: the `theme` cookie, `light` unless it says `dark`. Dark mode is correct in the FIRST server response, before any client script runs, because the root layout calls this during render and writes the class onto `<html>`.
13
9
  *
14
- * `next/headers.js` is imported on call, not at the top: `@wwchen/stack/ui` also re-exports the
15
- * design system's components, and a client component importing a Button from it must not pull
16
- * `next/headers` into the client bundle.
10
+ * `next/headers.js` is imported on call, not at the top: `@wwchen/stack/ui` also re-exports the design system's components, and a client component importing a Button from it must not pull `next/headers` into the client bundle.
17
11
  */
18
12
  export declare function resolveTheme(): Promise<Theme>;
package/dist/ui/theme.js CHANGED
@@ -1,21 +1,15 @@
1
1
  export const THEME_COOKIE = "theme";
2
2
  /**
3
- * The classes LDS needs on `<html>`: the product theme (its ramps, type, radii and shadows) and the
4
- * mode its dark rules key on (`.mode-dark .lds-tag`). Pure, so a root layout and Storybook write
5
- * the same thing. `extra` is appended (an app's `next/font` class).
3
+ * The classes LDS needs on `<html>`: the product theme (its ramps, type, radii and shadows) and the mode its dark rules key on (`.mode-dark .lds-tag`). Pure, so a root layout and Storybook write the same thing. `extra` is appended (an app's `next/font` class).
6
4
  */
7
5
  export function htmlClassName(theme, extra) {
8
6
  const base = `theme-product mode-${theme}`;
9
7
  return extra ? `${base} ${extra}` : base;
10
8
  }
11
9
  /**
12
- * The server-side theme read: the `theme` cookie, `light` unless it says `dark`. Dark mode is
13
- * correct in the FIRST server response, before any client script runs, because the root layout
14
- * calls this during render and writes the class onto `<html>`.
10
+ * The server-side theme read: the `theme` cookie, `light` unless it says `dark`. Dark mode is correct in the FIRST server response, before any client script runs, because the root layout calls this during render and writes the class onto `<html>`.
15
11
  *
16
- * `next/headers.js` is imported on call, not at the top: `@wwchen/stack/ui` also re-exports the
17
- * design system's components, and a client component importing a Button from it must not pull
18
- * `next/headers` into the client bundle.
12
+ * `next/headers.js` is imported on call, not at the top: `@wwchen/stack/ui` also re-exports the design system's components, and a client component importing a Button from it must not pull `next/headers` into the client bundle.
19
13
  */
20
14
  export async function resolveTheme() {
21
15
  const { cookies } = await import("next/headers.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwchen/stack",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Shared Next.js, Neon, Better Auth, Resend and lew-ds building blocks.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -109,8 +109,8 @@
109
109
  "peerDependencies": {
110
110
  "@electric-sql/pglite": "0.5.10",
111
111
  "@electric-sql/pglite-socket": "0.2.13",
112
- "@lew-ds/lds": "1.2.0",
113
- "@lew-ds/lds-react": "2.0.0",
112
+ "@lew-ds/lds": "1.3.0",
113
+ "@lew-ds/lds-react": "2.1.0",
114
114
  "@lew-ds/open-icons": "1.1.0",
115
115
  "@storybook/nextjs-vite": "10.6.2",
116
116
  "drizzle-orm": "0.45.4",