@kbach/react 1.0.0-beta.6 → 1.0.0-beta.7

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.
package/README.md CHANGED
@@ -62,11 +62,14 @@ first render, same as before.
62
62
 
63
63
  ## React Router
64
64
 
65
- Nothing beyond the Quick Start above — React Router is a client-side
66
- routing library with no build-tool coupling of its own, so it layers on
67
- top of the exact same Vite + `kbach.css` setup with zero extra
68
- configuration, whether you're on the framework mode (`createBrowserRouter`)
69
- or the classic `<BrowserRouter>` component form:
65
+ React Router is a client-side routing library with no build-tool coupling
66
+ of its own, so it layers on top of the exact same Vite + `kbach.css` setup
67
+ either way — but which "either way" depends on which of React Router's two
68
+ genuinely different modes you're using.
69
+
70
+ **Library mode** (you call `createRoot` yourself — `createBrowserRouter` +
71
+ `<RouterProvider>`, or the classic `<BrowserRouter>` component): needs
72
+ nothing beyond the Quick Start above.
70
73
 
71
74
  ```tsx
72
75
  // main.tsx
@@ -84,10 +87,40 @@ const router = createBrowserRouter([
84
87
  createRoot(document.getElementById('root')!).render(<RouterProvider router={router} />);
85
88
  ```
86
89
 
87
- Every route's own components use `className` exactly like any other
88
- component — routing has no effect on how Kbach resolves classes, since
89
- resolution already happened at build time, before routing even enters the
90
- picture.
90
+ **Framework mode** (`npx create-react-router@latest` — file-based routing
91
+ under `app/`, its own Vite plugin, SSR by default): two things differ from
92
+ the Quick Start, both because this mode owns your project's structure and
93
+ render lifecycle, not you:
94
+
95
+ 1. Its convention is `app/`, not `src/` — pass `cssFile` so the plugin
96
+ writes to `app/kbach.css` instead of the (here, nonexistent) default:
97
+ ```ts
98
+ // vite.config.ts
99
+ import { reactRouter } from '@react-router/dev/vite';
100
+ import { kbach } from '@kbach/react/vite';
101
+ import { defineConfig } from 'vite';
102
+
103
+ export default defineConfig({
104
+ plugins: [kbach({ cssFile: 'app/kbach.css' }), reactRouter()],
105
+ });
106
+ ```
107
+ 2. **Don't call `createRoot` yourself in `app/root.tsx`** — the framework's
108
+ own generated client/server entry points already do this; `root.tsx`
109
+ only ever *exports* a `Layout`/default component. Adding your own
110
+ `createRoot(...).render(...)` at that file's top level runs during SSR
111
+ too, where `document` doesn't exist, and crashes the build immediately.
112
+ `app/root.tsx` needs only:
113
+ ```tsx
114
+ import './kbach.css';
115
+ export default function App() {
116
+ return <Outlet />;
117
+ }
118
+ ```
119
+
120
+ Either mode: every route's own components use `className` exactly like any
121
+ other component — routing has no effect on how Kbach resolves classes,
122
+ since resolution already happened at build time, before routing even
123
+ enters the picture.
91
124
 
92
125
  ## Next.js
93
126
 
@@ -1260,7 +1260,7 @@ function kbach(options = {}) {
1260
1260
  let theme = defaultTheme;
1261
1261
  let engine = createKbachStaticCssEngine({ root, theme, themeJson: JSON.stringify(theme), includeDirs, safelist });
1262
1262
  function mainCSSFile() {
1263
- return join4(root, "src", "kbach.css");
1263
+ return join4(root, options.cssFile ?? "src/kbach.css");
1264
1264
  }
1265
1265
  function classNameHintsFile() {
1266
1266
  return join4(root, ".kbach", "kbach-classnames.d.ts");
@@ -2,7 +2,7 @@ import {
2
2
  DEFAULT_SCAN_DIRS,
3
3
  createKbachStaticCssEngine,
4
4
  resolveEffectiveTheme
5
- } from "./chunk-GPLCUNFX.mjs";
5
+ } from "./chunk-P4CQSYIL.mjs";
6
6
  import "./chunk-NKR3PSWO.mjs";
7
7
  import "./chunk-N5HCQIBB.mjs";
8
8
 
@@ -27,6 +27,17 @@ interface KbachPluginOptions {
27
27
  * purpose as Tailwind's `safelist`.
28
28
  */
29
29
  safelist?: string[];
30
+ /**
31
+ * Path to the `kbach:start`/`kbach:end` marker file, relative to Vite's
32
+ * resolved root. Defaults to `"src/kbach.css"` — override this for any
33
+ * project whose source root isn't `src/`: React Router v7's framework
34
+ * mode (`app/kbach.css`), a Pages-Router-style Next.js app using this
35
+ * plugin directly (`styles/kbach.css`), or any other convention. Getting
36
+ * this wrong fails loudly at build start (`ENOENT` writing the file's
37
+ * parent directory) rather than silently generating nothing, but it's
38
+ * still worth setting explicitly if your project doesn't use `src/`.
39
+ */
40
+ cssFile?: string;
30
41
  }
31
42
  declare const DEFAULT_SCAN_DIRS: string[];
32
43
  declare const CSS_SYNC_DEBOUNCE_MS = 50;
@@ -62,10 +73,11 @@ declare function resolveEffectiveTheme(root: string, options: {
62
73
  * Build-time static CSS generation for Vite — scans source files for
63
74
  * Kbach class strings, resolves them through the same Rust engine the
64
75
  * runtime uses (via the Node-target WASM build, see wasmNode.ts), and
65
- * writes a real kbach.css. Simplified vs old-kbach's version: expects
66
- * `src/kbach.css` to exist at a fixed conventional path (create it with
67
- * `/* kbach:start *\/` / `/* kbach:end *\/` markers) rather than scanning
68
- * the whole project for a file named kbach.css.
76
+ * writes a real kbach.css. Simplified vs old-kbach's version: expects a
77
+ * marker file to already exist at a fixed conventional path — `src/
78
+ * kbach.css` by default, override via `cssFile` for any other source root
79
+ * (create it with `/* kbach:start *\/` / `/* kbach:end *\/` markers)
80
+ * rather than scanning the whole project for a file named kbach.css.
69
81
  *
70
82
  * The actual scanning/resolution/generation logic lives in
71
83
  * `staticCss/engine.ts`, shared with `postcss-plugin/index.ts` (Next.js/
@@ -27,6 +27,17 @@ interface KbachPluginOptions {
27
27
  * purpose as Tailwind's `safelist`.
28
28
  */
29
29
  safelist?: string[];
30
+ /**
31
+ * Path to the `kbach:start`/`kbach:end` marker file, relative to Vite's
32
+ * resolved root. Defaults to `"src/kbach.css"` — override this for any
33
+ * project whose source root isn't `src/`: React Router v7's framework
34
+ * mode (`app/kbach.css`), a Pages-Router-style Next.js app using this
35
+ * plugin directly (`styles/kbach.css`), or any other convention. Getting
36
+ * this wrong fails loudly at build start (`ENOENT` writing the file's
37
+ * parent directory) rather than silently generating nothing, but it's
38
+ * still worth setting explicitly if your project doesn't use `src/`.
39
+ */
40
+ cssFile?: string;
30
41
  }
31
42
  declare const DEFAULT_SCAN_DIRS: string[];
32
43
  declare const CSS_SYNC_DEBOUNCE_MS = 50;
@@ -62,10 +73,11 @@ declare function resolveEffectiveTheme(root: string, options: {
62
73
  * Build-time static CSS generation for Vite — scans source files for
63
74
  * Kbach class strings, resolves them through the same Rust engine the
64
75
  * runtime uses (via the Node-target WASM build, see wasmNode.ts), and
65
- * writes a real kbach.css. Simplified vs old-kbach's version: expects
66
- * `src/kbach.css` to exist at a fixed conventional path (create it with
67
- * `/* kbach:start *\/` / `/* kbach:end *\/` markers) rather than scanning
68
- * the whole project for a file named kbach.css.
76
+ * writes a real kbach.css. Simplified vs old-kbach's version: expects a
77
+ * marker file to already exist at a fixed conventional path — `src/
78
+ * kbach.css` by default, override via `cssFile` for any other source root
79
+ * (create it with `/* kbach:start *\/` / `/* kbach:end *\/` markers)
80
+ * rather than scanning the whole project for a file named kbach.css.
69
81
  *
70
82
  * The actual scanning/resolution/generation logic lives in
71
83
  * `staticCss/engine.ts`, shared with `postcss-plugin/index.ts` (Next.js/
@@ -1779,7 +1779,7 @@ function kbach(options = {}) {
1779
1779
  let theme = defaultTheme;
1780
1780
  let engine = createKbachStaticCssEngine({ root, theme, themeJson: JSON.stringify(theme), includeDirs, safelist });
1781
1781
  function mainCSSFile() {
1782
- return (0, import_path4.join)(root, "src", "kbach.css");
1782
+ return (0, import_path4.join)(root, options.cssFile ?? "src/kbach.css");
1783
1783
  }
1784
1784
  function classNameHintsFile() {
1785
1785
  return (0, import_path4.join)(root, ".kbach", "kbach-classnames.d.ts");
@@ -4,7 +4,7 @@ import {
4
4
  kbach,
5
5
  loadConfigFile,
6
6
  resolveEffectiveTheme
7
- } from "./chunk-GPLCUNFX.mjs";
7
+ } from "./chunk-P4CQSYIL.mjs";
8
8
  import "./chunk-NKR3PSWO.mjs";
9
9
  import "./chunk-N5HCQIBB.mjs";
10
10
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.7",
4
4
  "description": "A utility-first styling engine for React, powered by a real Rust/WASM core — Tailwind CSS v4 feature parity with Kbach's own color palette.",
5
5
  "keywords": ["css", "react", "tailwind", "utility-first", "wasm", "styling"],
6
6
  "license": "MIT",