@kbach/browser 1.0.0-beta.3 → 1.0.0-beta.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.
package/AGENTS.md CHANGED
@@ -1,132 +1,134 @@
1
- # `@kbach/browser` — reference for AI assistants
2
-
3
- Kbach from a CDN: one classic `<script>` for a plain HTML page, with no
4
- bundler, no npm install and no React. This file covers `@kbach/browser`
5
- only. For the cross-package overview, see the repo root's
6
- [AGENTS.md](https://github.com/semsakadanupol/kbach/blob/main/AGENTS.md).
7
-
8
- ```html
9
- <script>window.kbachConfig = { darkMode: 'class', extend: { colors: { brand: '#ff6b35' } } };</script>
10
- <script src="https://cdn.jsdelivr.net/npm/@kbach/browser"></script>
11
- ```
12
-
13
- `https://cdn.jsdelivr.net/npm/@kbach/browser` and
14
- `https://unpkg.com/@kbach/browser` serve `dist/kbach.js` via package.json's
15
- `jsdelivr`/`unpkg` fields.
16
-
17
- ---
18
-
19
- ## 1. What it does
20
-
21
- `src/index.ts` (entry) → `startKbachCdn` (`src/runtime.ts`):
22
-
23
- 1. Reads `window.kbachConfig` once (same shape as `kbach.config.js`),
24
- resolves it with `@kbach/react`'s `resolveKbachConfig`, and applies it
25
- before the engine loads, so dark-mode state and color variables are on
26
- `<html>` from the start.
27
- 2. Fetches `kbach_core_engine_bg.wasm` from the URL that
28
- `src/wasmUrl.ts`'s `resolveWasmUrl` derives from its own
29
- `<script>` (`document.currentScript`): the `data-wasm` attribute if
30
- set. Otherwise, for a CDN package-root src
31
- (`…/npm/@kbach/browser`, `…@beta`, `https://unpkg.com/@kbach/browser`),
32
- `@kbach/browser@<this build's exact version>/dist/`. Otherwise, the
33
- file next to the script. Plain relative resolution of the short URL
34
- lands one level too high (`…/npm/@kbach/kbach_core_engine_bg.wasm`, a
35
- 404). The version is baked in at build time (tsup `define`
36
- `__KBACH_BROWSER_VERSION__` from package.json), so the `.wasm` always
37
- matches the running glue even after a tag moves.
38
- 3. Styles every `class` token on the page through `@kbach/react`'s `kb()`,
39
- which injects rules into `<style data-kbach>` plus the base reset. Each
40
- token is resolved at most once per config (`seen` set, one batched
41
- `kb()` call per scan). Non-Kbach classes produce no rules.
42
- 4. Watches `<html>` with a `MutationObserver` (added nodes plus `class`
43
- attribute changes), started after the first full scan.
44
- 5. Exposes `window.Kbach`: `ready`, `config(cfg)` (re-resolve plus a full
45
- re-scan), `refresh()`, `setMode()`, `toggle()` (the last two are
46
- `@kbach/react`'s dark-mode store).
47
-
48
- **Mode-aware colors are mapped to CSS variables, not expanded**
49
- (`src/cdnTheme.ts`, `toCdnTheme`). For a `{ light, dark }` pair, the
50
- engine rewrites `bg-surface` to `bg-[#…] dark:bg-[#…]` and generates rules
51
- only for that text, which `kb()` callers handle by using the returned
52
- className. A CDN script can't rewrite the page's own `class` attributes, so
53
- each hex pair becomes `rgb(var(--kb-color-<name>))`, and
54
- `ensureColorVariablesInjected` supplies the light/dark values for the
55
- configured strategy. Opacity suffixes on them (`bg-surface/50`) go through
56
- `color-mix(in srgb, …)`; `@kbach/browser` 1.0.0-beta.2 and earlier bundled
57
- an engine that dropped the opacity, so `bg-card/80` rendered fully opaque.
58
-
59
- ## 2. How it's built — it bundles `@kbach/react`'s SOURCE
60
-
61
- There is no second copy of any runtime logic here. `src/*.ts` imports
62
- `../../react/src/{kb,theme,config,colorVariables,darkModeStore,wasmLoader}`
63
- directly. None of those import React. They aren't public exports of
64
- `@kbach/react`, and importing its built entry would pull in React
65
- components. Consequences:
66
-
67
- - `@kbach/react` is a `devDependency` (`"*"`, the workspace copy) only so
68
- Turbo orders and cache-keys this build after react's. It is NOT a runtime
69
- dependency: everything is bundled into `dist/kbach.js`.
70
- - `wasmLoader.ts`'s `initKbachFrom(url)` is internal to `@kbach/react`
71
- (not exported from its index) and exists for this package. Renaming or
72
- removing it breaks this build, and the tests here catch that.
73
- - **The `.wasm` and the bundled glue come from the `@kbach/core-engine`
74
- that `react/src/wasmLoader.ts` resolves** (react's `dependencies`
75
- version), never from this package. `scripts/copy-wasm.mjs` resolves the
76
- `.wasm` from that same file on purpose, since a mismatched glue/binary
77
- pair fails at load time.
78
-
79
- `npm run build` = `tsup` (`tsup.config.ts`: IIFE, browser, minified,
80
- `noExternal: [/.*/]`, no source map) → `scripts/copy-wasm.mjs` →
81
- `scripts/verify-bundle.mjs`. The last step loads the BUILT
82
- `dist/kbach.js` into jsdom **through a real `<script src>`** (served by a
83
- jsdom `requestInterceptor`), with the real `.wasm`, twice: from the short
84
- CDN URL and self-hosted. Its fake `fetch` serves the `.wasm` only at the
85
- exact URL each case must request. The build fails unless that URL is
86
- right, existing, added and changed classes are styled, mode-aware colors
87
- use their variable, the page's `class` is never rewritten, and `toggle()`
88
- flips `<html>`. Don't "simplify" it back to `window.eval(bundle)`: with no
89
- `currentScript`, the `.wasm` lookup never runs, which is exactly how the
90
- 1.0.0-beta.0 bug shipped.
91
-
92
- Tests (`npm run test`): `src/cdnTheme.test.ts` and `src/runtime.test.ts`,
93
- which runs the real Node-target engine in place of the browser loader,
94
- under jsdom with `@kbach/react`'s `test-setup.ts`.
95
-
96
- Sizes (2026-11-07, gzipped): `kbach.js` ~7 KB, `.wasm` ~158 KB.
97
-
98
- **Sandbox:** `apps/web-cdn` (`npm run dev -w web-cdn`, port 5174) is one
99
- plain `index.html` and a dependency-free `serve.mjs`. `/` is the page as-is,
100
- using the LIVE `cdn.jsdelivr.net/npm/@kbach/browser@beta`. It also works
101
- opened straight from disk, since jsDelivr serves the `.wasm` with CORS.
102
- `/local` swaps in the LOCAL `dist/` (rebuild with
103
- `npm run build -w @kbach/browser`, then reload) and needs the server,
104
- because a `file://` page can't fetch a local `.wasm`. The page covers
105
- utility classes, a config color, mode-aware colors with a toggle, added
106
- elements and class changes. Note that jsDelivr caches `@beta` for a while
107
- after a publish, so use a pinned `@1.0.0-beta.N` URL to see a new release
108
- immediately.
109
-
110
- ## 3. Common failure modes
111
-
112
- - **Nothing is styled, and the network tab shows a 404 for
113
- `…/npm/@kbach/kbach_core_engine_bg.wasm`**: you're on `1.0.0-beta.0`,
114
- whose `.wasm` lookup was broken for the short CDN URL (only the full
115
- `…/dist/kbach.js` URL worked). Fixed in `1.0.0-beta.1`. Use `@beta` or
116
- `@1.0.0-beta.1` or later. jsDelivr may keep serving beta.0 for a bare
117
- or `@beta` URL for a while after the release, so pin the version (or
118
- purge `https://purge.jsdelivr.net/npm/@kbach/browser@beta`).
119
- - **Nothing is styled (any other case).** Check the network tab for the `.wasm` request. A
120
- 404 means `kbach_core_engine_bg.wasm` isn't next to `kbach.js` (when
121
- self-hosting, copy both files, or set `data-wasm`). Opening the HTML as
122
- `file://` fails too: browsers won't `fetch()` a local file, so serve the
123
- folder (`npx serve`).
124
- - **A custom color isn't applied.** `window.kbachConfig` was set AFTER
125
- the `<script src>` tag. It's read once at load. Set it before, or call
126
- `Kbach.config({...})` later.
127
- - **`Kbach.toggle()` does nothing visible.** The default
128
- `darkMode: 'media'` follows the OS only. Set `darkMode: 'class'` or
129
- `'attribute'` in `window.kbachConfig`.
130
- - **A brief unstyled flash on load.** Expected: classes resolve in the
131
- browser after the WASM loads, like Tailwind's Play CDN. Use
132
- `@kbach/react`'s build plugin for production.
1
+ # `@kbach/browser` — reference for AI assistants
2
+
3
+ Kbach from a CDN: one classic `<script>` for a plain HTML page, with no
4
+ bundler, no npm install and no React. This file covers `@kbach/browser`
5
+ only. For the cross-package overview, see the repo root's
6
+ [AGENTS.md](https://github.com/semsakadanupol/kbach/blob/main/AGENTS.md).
7
+
8
+ ```html
9
+ <script>window.kbachConfig = { darkMode: 'class', extend: { colors: { brand: '#ff6b35' } } };</script>
10
+ <script src="https://cdn.jsdelivr.net/npm/@kbach/browser"></script>
11
+ ```
12
+
13
+ `https://cdn.jsdelivr.net/npm/@kbach/browser` and
14
+ `https://unpkg.com/@kbach/browser` serve `dist/kbach.js` via package.json's
15
+ `jsdelivr`/`unpkg` fields.
16
+
17
+ ---
18
+
19
+ ## 1. What it does
20
+
21
+ `src/index.ts` (entry) → `startKbachCdn` (`src/runtime.ts`):
22
+
23
+ 1. Reads `window.kbachConfig` once (same shape as `kbach.config.js`),
24
+ resolves it with `@kbach/react`'s `resolveKbachConfig`, and applies it
25
+ before the engine loads, so dark-mode state and color variables are on
26
+ `<html>` from the start.
27
+ 2. Fetches `kbach_core_engine_bg.wasm` from the URL that
28
+ `src/wasmUrl.ts`'s `resolveWasmUrl` derives from its own
29
+ `<script>` (`document.currentScript`): the `data-wasm` attribute if
30
+ set. Otherwise, for a CDN package-root src
31
+ (`…/npm/@kbach/browser`, `…@beta`, `https://unpkg.com/@kbach/browser`),
32
+ `@kbach/browser@<this build's exact version>/dist/`. Otherwise, the
33
+ file next to the script. Plain relative resolution of the short URL
34
+ lands one level too high (`…/npm/@kbach/kbach_core_engine_bg.wasm`, a
35
+ 404). The version is baked in at build time (tsup `define`
36
+ `__KBACH_BROWSER_VERSION__` from package.json), so the `.wasm` always
37
+ matches the running glue even after a tag moves.
38
+ 3. Styles every `class` token on the page through `@kbach/react`'s `kb()`,
39
+ which injects rules into `<style data-kbach>` plus the base reset. Each
40
+ token is resolved at most once per config (`seen` set, one batched
41
+ `kb()` call per scan). Non-Kbach classes produce no rules.
42
+ 4. Watches `<html>` with a `MutationObserver` (added nodes plus `class`
43
+ attribute changes), started after the first full scan.
44
+ 5. Exposes `window.Kbach`: `ready`, `config(cfg)` (re-resolve plus a full
45
+ re-scan), `refresh()`, `setMode()`, `toggle()` (the last two are
46
+ `@kbach/react`'s dark-mode store).
47
+
48
+ **Mode-aware colors are mapped to CSS variables, not expanded**
49
+ (`src/cdnTheme.ts`, `toCdnTheme`, a thin wrapper over `@kbach/react`'s
50
+ `withColorVariables` in `react/src/colorVariables.ts`, which the static
51
+ Vite/PostCSS plugins use for the same reason). For a `{ light, dark }` pair, the
52
+ engine rewrites `bg-surface` to `bg-[#…] dark:bg-[#…]` and generates rules
53
+ only for that text, which `kb()` callers handle by using the returned
54
+ className. A CDN script can't rewrite the page's own `class` attributes, so
55
+ each hex pair becomes `rgb(var(--kb-color-<name>))`, and
56
+ `ensureColorVariablesInjected` supplies the light/dark values for the
57
+ configured strategy. Opacity suffixes on them (`bg-surface/50`) go through
58
+ `color-mix(in srgb, …)`; `@kbach/browser` 1.0.0-beta.2 and earlier bundled
59
+ an engine that dropped the opacity, so `bg-card/80` rendered fully opaque.
60
+
61
+ ## 2. How it's built — it bundles `@kbach/react`'s SOURCE
62
+
63
+ There is no second copy of any runtime logic here. `src/*.ts` imports
64
+ `../../react/src/{kb,theme,config,colorVariables,darkModeStore,wasmLoader}`
65
+ directly. None of those import React. They aren't public exports of
66
+ `@kbach/react`, and importing its built entry would pull in React
67
+ components. Consequences:
68
+
69
+ - `@kbach/react` is a `devDependency` (`"*"`, the workspace copy) only so
70
+ Turbo orders and cache-keys this build after react's. It is NOT a runtime
71
+ dependency: everything is bundled into `dist/kbach.js`.
72
+ - `wasmLoader.ts`'s `initKbachFrom(url)` is internal to `@kbach/react`
73
+ (not exported from its index) and exists for this package. Renaming or
74
+ removing it breaks this build, and the tests here catch that.
75
+ - **The `.wasm` and the bundled glue come from the `@kbach/core-engine`
76
+ that `react/src/wasmLoader.ts` resolves** (react's `dependencies`
77
+ version), never from this package. `scripts/copy-wasm.mjs` resolves the
78
+ `.wasm` from that same file on purpose, since a mismatched glue/binary
79
+ pair fails at load time.
80
+
81
+ `npm run build` = `tsup` (`tsup.config.ts`: IIFE, browser, minified,
82
+ `noExternal: [/.*/]`, no source map) → `scripts/copy-wasm.mjs` →
83
+ `scripts/verify-bundle.mjs`. The last step loads the BUILT
84
+ `dist/kbach.js` into jsdom **through a real `<script src>`** (served by a
85
+ jsdom `requestInterceptor`), with the real `.wasm`, twice: from the short
86
+ CDN URL and self-hosted. Its fake `fetch` serves the `.wasm` only at the
87
+ exact URL each case must request. The build fails unless that URL is
88
+ right, existing, added and changed classes are styled, mode-aware colors
89
+ use their variable, the page's `class` is never rewritten, and `toggle()`
90
+ flips `<html>`. Don't "simplify" it back to `window.eval(bundle)`: with no
91
+ `currentScript`, the `.wasm` lookup never runs, which is exactly how the
92
+ 1.0.0-beta.0 bug shipped.
93
+
94
+ Tests (`npm run test`): `src/cdnTheme.test.ts` and `src/runtime.test.ts`,
95
+ which runs the real Node-target engine in place of the browser loader,
96
+ under jsdom with `@kbach/react`'s `test-setup.ts`.
97
+
98
+ Sizes (2026-11-07, gzipped): `kbach.js` ~7 KB, `.wasm` ~158 KB.
99
+
100
+ **Sandbox:** `apps/web-cdn` (`npm run dev -w web-cdn`, port 5174) is one
101
+ plain `index.html` and a dependency-free `serve.mjs`. `/` is the page as-is,
102
+ using the LIVE `cdn.jsdelivr.net/npm/@kbach/browser@beta`. It also works
103
+ opened straight from disk, since jsDelivr serves the `.wasm` with CORS.
104
+ `/local` swaps in the LOCAL `dist/` (rebuild with
105
+ `npm run build -w @kbach/browser`, then reload) and needs the server,
106
+ because a `file://` page can't fetch a local `.wasm`. The page covers
107
+ utility classes, a config color, mode-aware colors with a toggle, added
108
+ elements and class changes. Note that jsDelivr caches `@beta` for a while
109
+ after a publish, so use a pinned `@1.0.0-beta.N` URL to see a new release
110
+ immediately.
111
+
112
+ ## 3. Common failure modes
113
+
114
+ - **Nothing is styled, and the network tab shows a 404 for
115
+ `…/npm/@kbach/kbach_core_engine_bg.wasm`**: you're on `1.0.0-beta.0`,
116
+ whose `.wasm` lookup was broken for the short CDN URL (only the full
117
+ `…/dist/kbach.js` URL worked). Fixed in `1.0.0-beta.1`. Use `@beta` or
118
+ `@1.0.0-beta.1` or later. jsDelivr may keep serving beta.0 for a bare
119
+ or `@beta` URL for a while after the release, so pin the version (or
120
+ purge `https://purge.jsdelivr.net/npm/@kbach/browser@beta`).
121
+ - **Nothing is styled (any other case).** Check the network tab for the `.wasm` request. A
122
+ 404 means `kbach_core_engine_bg.wasm` isn't next to `kbach.js` (when
123
+ self-hosting, copy both files, or set `data-wasm`). Opening the HTML as
124
+ `file://` fails too: browsers won't `fetch()` a local file, so serve the
125
+ folder (`npx serve`).
126
+ - **A custom color isn't applied.** `window.kbachConfig` was set AFTER
127
+ the `<script src>` tag. It's read once at load. Set it before, or call
128
+ `Kbach.config({...})` later.
129
+ - **`Kbach.toggle()` does nothing visible.** The default
130
+ `darkMode: 'media'` follows the OS only. Set `darkMode: 'class'` or
131
+ `'attribute'` in `window.kbachConfig`.
132
+ - **A brief unstyled flash on load.** Expected: classes resolve in the
133
+ browser after the WASM loads, like Tailwind's Play CDN. Use
134
+ `@kbach/react`'s build plugin for production.
package/dist/kbach.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";(()=>{var xe={};function z(e,t){let n,r;try{let o=$(e,f.__wbindgen_malloc,f.__wbindgen_realloc),a=E,i=$(t,f.__wbindgen_malloc,f.__wbindgen_realloc),s=E,c=f.generate_css(o,a,i,s);return n=c[0],r=c[1],pe(c[0],c[1])}finally{f.__wbindgen_free(n,r,1)}}function be(){return{__proto__:null,"./kbach_core_engine_bg.js":{__proto__:null,__wbindgen_init_externref_table:function(){let t=f.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}function pe(e,t){return ye(e>>>0,t)}var _=null;function C(){return(_===null||_.byteLength===0)&&(_=new Uint8Array(f.memory.buffer)),_}function $(e,t,n){if(n===void 0){let s=w.encode(e),c=t(s.length,1)>>>0;return C().subarray(c,c+s.length).set(s),E=s.length,c}let r=e.length,o=t(r,1)>>>0,a=C(),i=0;for(;i<r;i++){let s=e.charCodeAt(i);if(s>127)break;a[o+i]=s}if(i!==r){i!==0&&(e=e.slice(i)),o=n(o,r,r=i+e.length*3,1)>>>0;let s=C().subarray(o+i,o+r),c=w.encodeInto(e,s);i+=c.written,o=n(o,r,i,1)>>>0}return E=i,o}var x=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});x.decode();var he=2146435072,S=0;function ye(e,t){return S+=t,S>=he&&(x=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),x.decode(),S=t),x.decode(C().subarray(e,e+t))}var w=new TextEncoder;"encodeInto"in w||(w.encodeInto=function(e,t){let n=w.encode(e);return t.set(n),{read:e.length,written:n.length}});var E=0,_e,we,f;function ke(e,t){return we=e,f=e.exports,_e=t,_=null,f.__wbindgen_start(),f}async function Ce(e,t){if(typeof Response=="function"&&e instanceof Response){if(!e.ok)throw new Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function A(e){if(f!==void 0)return f;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("kbach_core_engine_bg.wasm",xe.url));let t=be();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Ce(await e,t);return ke(n,r)}var D=null,U=!1;function N(e){return D||(D=(e===void 0?A():A({module_or_path:e})).then(()=>{U=!0})),D}function P(e,t){if(!U)throw new Error("[Kbach] generateCss() was called before initKbach() resolved. Call `await initKbach()` once at startup (e.g. before rendering your app) before using kb().");return z(e,t)}var G={"amber-1":"#fffbeb","amber-10":"#78350f","amber-11":"#451a03","amber-12":"#291002","amber-2":"#fef3c7","amber-3":"#fde68a","amber-4":"#fcd34d","amber-5":"#fbbf24","amber-6":"#f59e0b","amber-7":"#d97706","amber-8":"#b45309","amber-9":"#92400e",black:"#000000","blue-1":"#eff6ff","blue-10":"#1e3a8a","blue-11":"#172554","blue-12":"#0d1633","blue-2":"#dbeafe","blue-3":"#bfdbfe","blue-4":"#93c5fd","blue-5":"#60a5fa","blue-6":"#3b82f6","blue-7":"#2563eb","blue-8":"#1d4ed8","blue-9":"#1e40af",bronze:"#cd7f32",coal:"#1c1c1c",copper:"#b87333",current:"currentColor","cyan-1":"#ecfeff","cyan-10":"#164e63","cyan-11":"#083344","cyan-12":"#041e28","cyan-2":"#cffafe","cyan-3":"#a5f3fc","cyan-4":"#67e8f9","cyan-5":"#22d3ee","cyan-6":"#06b6d4","cyan-7":"#0891b2","cyan-8":"#0e7490","cyan-9":"#155e75","emerald-1":"#ecfdf5","emerald-10":"#064e3b","emerald-11":"#022c22","emerald-12":"#011a14","emerald-2":"#d1fae5","emerald-3":"#a7f3d0","emerald-4":"#6ee7b7","emerald-5":"#34d399","emerald-6":"#10b981","emerald-7":"#059669","emerald-8":"#047857","emerald-9":"#065f46","fuchsia-1":"#fdf4ff","fuchsia-10":"#701a75","fuchsia-11":"#4a044e","fuchsia-12":"#2d022f","fuchsia-2":"#fae8ff","fuchsia-3":"#f5d0fe","fuchsia-4":"#f0abfc","fuchsia-5":"#e879f9","fuchsia-6":"#d946ef","fuchsia-7":"#c026d3","fuchsia-8":"#a21caf","fuchsia-9":"#86198f",gold:"#d4af37","gray-1":"#f9fafb","gray-10":"#111827","gray-11":"#030712","gray-12":"#020409","gray-2":"#f3f4f6","gray-3":"#e5e7eb","gray-4":"#d1d5db","gray-5":"#9ca3af","gray-6":"#6b7280","gray-7":"#4b5563","gray-8":"#374151","gray-9":"#1f2937","green-1":"#f0fdf4","green-10":"#14532d","green-11":"#052e16","green-12":"#031b0d","green-2":"#dcfce7","green-3":"#bbf7d0","green-4":"#86efac","green-5":"#4ade80","green-6":"#22c55e","green-7":"#16a34a","green-8":"#15803d","green-9":"#166534","indigo-1":"#eef2ff","indigo-10":"#312e81","indigo-11":"#1e1b4b","indigo-12":"#12102d","indigo-2":"#e0e7ff","indigo-3":"#c7d2fe","indigo-4":"#a5b4fc","indigo-5":"#818cf8","indigo-6":"#6366f1","indigo-7":"#4f46e5","indigo-8":"#4338ca","indigo-9":"#3730a3","lime-1":"#f7fee7","lime-10":"#365314","lime-11":"#1a2e05","lime-12":"#0f1b03","lime-2":"#ecfccb","lime-3":"#d9f99d","lime-4":"#bef264","lime-5":"#a3e635","lime-6":"#84cc16","lime-7":"#65a30d","lime-8":"#4d7c0f","lime-9":"#3f6212","neutral-1":"#fafafa","neutral-10":"#171717","neutral-11":"#0a0a0a","neutral-12":"#050505","neutral-2":"#f5f5f5","neutral-3":"#e5e5e5","neutral-4":"#d4d4d4","neutral-5":"#a3a3a3","neutral-6":"#737373","neutral-7":"#525252","neutral-8":"#404040","neutral-9":"#262626","orange-1":"#fff7ed","orange-10":"#7c2d12","orange-11":"#431407","orange-12":"#270c04","orange-2":"#ffedd5","orange-3":"#fed7aa","orange-4":"#fdba74","orange-5":"#fb923c","orange-6":"#f97316","orange-7":"#ea580c","orange-8":"#c2410c","orange-9":"#9a3412","pink-1":"#fdf2f8","pink-10":"#831843","pink-11":"#500724","pink-12":"#300415","pink-2":"#fce7f3","pink-3":"#fbcfe8","pink-4":"#f9a8d4","pink-5":"#f472b6","pink-6":"#ec4899","pink-7":"#db2777","pink-8":"#be185d","pink-9":"#9d174d","purple-1":"#faf5ff","purple-10":"#581c87","purple-11":"#3b0764","purple-12":"#23043c","purple-2":"#f3e8ff","purple-3":"#e9d5ff","purple-4":"#d8b4fe","purple-5":"#c084fc","purple-6":"#a855f7","purple-7":"#9333ea","purple-8":"#7e22ce","purple-9":"#6b21a8","red-1":"#fef2f2","red-10":"#7f1d1d","red-11":"#450a0a","red-12":"#280606","red-2":"#fee2e2","red-3":"#fecaca","red-4":"#fca5a5","red-5":"#f87171","red-6":"#ef4444","red-7":"#dc2626","red-8":"#b91c1c","red-9":"#991b1b","rose-1":"#fff1f2","rose-10":"#881337","rose-11":"#4c0519","rose-12":"#2d030e","rose-2":"#ffe4e6","rose-3":"#fecdd3","rose-4":"#fda4af","rose-5":"#fb7185","rose-6":"#f43f5e","rose-7":"#e11d48","rose-8":"#be123c","rose-9":"#9f1239",silver:"#c0c0c0","sky-1":"#f0f9ff","sky-10":"#0c4a6e","sky-11":"#082f49","sky-12":"#041b2b","sky-2":"#e0f2fe","sky-3":"#bae6fd","sky-4":"#7dd3fc","sky-5":"#38bdf8","sky-6":"#0ea5e9","sky-7":"#0284c7","sky-8":"#0369a1","sky-9":"#075985","slate-1":"#f8fafc","slate-10":"#0f172a","slate-11":"#020617","slate-12":"#01020a","slate-2":"#f1f5f9","slate-3":"#e2e8f0","slate-4":"#cbd5e1","slate-5":"#94a3b8","slate-6":"#64748b","slate-7":"#475569","slate-8":"#334155","slate-9":"#1e293b","stone-1":"#fafaf9","stone-10":"#1c1917","stone-11":"#0c0a09","stone-12":"#070605","stone-2":"#f5f5f4","stone-3":"#e7e5e4","stone-4":"#d6d3d1","stone-5":"#a8a29e","stone-6":"#78716c","stone-7":"#57534e","stone-8":"#44403c","stone-9":"#292524","teal-1":"#f0fdfa","teal-10":"#134e4a","teal-11":"#042f2e","teal-12":"#021c1b","teal-2":"#ccfbf1","teal-3":"#99f6e4","teal-4":"#5eead4","teal-5":"#2dd4bf","teal-6":"#14b8a6","teal-7":"#0d9488","teal-8":"#0f766e","teal-9":"#115e59",transparent:"transparent","violet-1":"#f5f3ff","violet-10":"#4c1d95","violet-11":"#2e1065","violet-12":"#1c0a3d","violet-2":"#ede9fe","violet-3":"#ddd6fe","violet-4":"#c4b5fd","violet-5":"#a78bfa","violet-6":"#8b5cf6","violet-7":"#7c3aed","violet-8":"#6d28d9","violet-9":"#5b21b6",white:"#ffffff","yellow-1":"#fefce8","yellow-10":"#713f12","yellow-11":"#422006","yellow-12":"#271304","yellow-2":"#fef9c3","yellow-3":"#fef08a","yellow-4":"#fde047","yellow-5":"#facc15","yellow-6":"#eab308","yellow-7":"#ca8a04","yellow-8":"#a16207","yellow-9":"#854d0e","zinc-1":"#fafafa","zinc-10":"#18181b","zinc-11":"#09090b","zinc-12":"#050506","zinc-2":"#f4f4f5","zinc-3":"#e4e4e7","zinc-4":"#d4d4d8","zinc-5":"#a1a1aa","zinc-6":"#71717a","zinc-7":"#52525b","zinc-8":"#3f3f46","zinc-9":"#27272a"};var v={colors:{...G,surface:{light:"#f9fafb",dark:"#111827"}},spacing:{0:0,px:1,"0.5":2,1:4,"1.5":6,2:8,"2.5":10,3:12,"3.5":14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},screens:{sm:640,md:768,lg:1024,xl:1280,"2xl":1536},fontFamily:{sans:'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',serif:'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',mono:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},darkMode:"media",container:{}},T=v,H=JSON.stringify(v);function R(e){T=e,H=JSON.stringify(e)}function J(){return T}function V(){return H}var Ee=new Set(["attribute","class","media"]);function Y(){if(typeof document>"u")return;let e=getComputedStyle(document.documentElement).getPropertyValue("--kb-dark-mode").trim();!Ee.has(e)||e===T.darkMode||R({...T,darkMode:e})}var K="kbach-reset",Te=[{css:"*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: currentColor; }"},{css:"body { margin: 0; padding: 0; }"},{css:"h1, h2, h3, h4, h5, h6 { margin: 0; font-size: inherit; font-weight: inherit; }",tags:["h1","h2","h3","h4","h5","h6"]},{css:"p { margin: 0; }",tags:["p"]},{css:"a { color: inherit; text-decoration: none; }",tags:["a"]},{css:"ul, ol { margin: 0; padding: 0; list-style: none; }",tags:["ul","ol"]},{css:"img, video, svg { display: block; max-width: 100%; }",tags:["img","video","svg"]},{css:"input:where(:not([type='checkbox']):not([type='radio'])), textarea { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; line-height: inherit; }",tags:["input","textarea"]},{css:":where(input[type='checkbox'], input[type='radio'], input[type='range']) { margin: 0; font: inherit; accent-color: currentColor; }",tags:["input"]},{css:"select { margin: 0; font: inherit; color: inherit; line-height: inherit; }",tags:["select"]},{css:"button { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; line-height: inherit; text-align: inherit; }",tags:["button"]},{css:"button, [role='button'] { cursor: pointer; }",tags:["button"]},{css:":disabled { cursor: default; }",tags:["button","input","select","textarea"]},{css:"textarea { resize: vertical; }",tags:["textarea"]},{css:"::placeholder { opacity: 1; }",tags:["input","textarea"]},{css:"input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-outer-spin-button { margin: 0; }",tags:["input"]},{css:"input[type='search']::-webkit-search-decoration, input[type='search']::-webkit-search-cancel-button { -webkit-appearance: none; }",tags:["input"]},{css:"fieldset { padding: 0; margin: 0; }",tags:["fieldset"]},{css:"table { border-collapse: collapse; border-spacing: 0; }",tags:["table"]}],q=Te.map(e=>e.css).join(`
2
- `);var ve=!1;var h=null,j=[],O=new Map;function Re(){return h||(h=document.createElement("style"),h.setAttribute("data-kbach",""),document.head.appendChild(h),h)}function Me(e){let t=0,n=j.length;for(;t<n;){let r=t+n>>>1;O.get(j[r])>e?n=r:t=r+1}return t}function Se(e,t){if(O.has(e))return;let n=Re().sheet;if(!n)return;let r=Me(t);try{n.insertRule(e,r)}catch{return}j.splice(r,0,e),O.set(e,t)}var X=!1;function Ae(){if(X||(X=!0,document.getElementById(K)))return;let e=document.createElement("style");e.id=K,e.textContent=q,document.head.insertBefore(e,document.head.firstChild)}var De=500,k=new Map,Q=null;function Z(e){let t=V();t!==Q&&(k.clear(),Q=t);let n=k.get(e);if(n===void 0){let a=P(e,t);n=JSON.parse(a),k.size>=De&&k.clear(),k.set(e,n)}let{className:r,rules:o}=n;if(!ve){Ae();for(let{rule:a,order:i}of o)Se(a,i)}return r}function m(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;let n=t[1];n.length===3&&(n=n.split("").map(o=>o+o).join(""));let r=parseInt(n,16);return[r>>16&255,r>>8&255,r&255]}function Ke(e,t){switch(e){case"class":return`.dark { ${t} }`;case"media":return`@media (prefers-color-scheme: dark) { :root { ${t} } }`;default:return`[data-theme="dark"] { ${t} }`}}var ee="kbach-colors",te=null;function ne(e){if(typeof document>"u"||te===e)return;te=e;let t=[],n=[];for(let[o,a]of Object.entries(e.colors)){if(typeof a=="string")continue;let i=m(a.light),s=m(a.dark);!i||!s||(t.push(`--kb-color-${o}: ${i.join(",")};`),n.push(`--kb-color-${o}: ${s.join(",")};`))}let r=document.getElementById(ee);if(t.length===0){r?.remove();return}r||(r=document.createElement("style"),r.id=ee,document.head.insertBefore(r,document.head.firstChild)),r.textContent=`:root { ${t.join(" ")} }
3
- ${Ke(e.darkMode,n.join(" "))}`}var re="kbach-theme",je=new Set;function Oe(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function oe(){return typeof window>"u"?null:window.localStorage}function Ie(){let e=oe();if(!e)return null;try{let t=e.getItem(re);return t==="light"||t==="dark"||t==="system"?t:null}catch{return null}}function ie(e){return e==="system"?Oe():e==="dark"}function M(e){if(typeof document>"u")return;let t=document.documentElement,n=J().darkMode;t.classList.toggle("dark",n==="class"&&e),t.classList.toggle("light",n==="class"&&!e),n==="attribute"?t.setAttribute("data-theme",e?"dark":"light"):t.removeAttribute("data-theme")}Y();var Le=Ie();var I=Le??"system",b=ie(I);M(b);if(typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)"),t=n=>{I==="system"&&(b=n.matches,M(b),se())};e.addEventListener?e.addEventListener("change",t):e.addListener(t)}function se(){for(let e of je)e()}function L(){M(b)}function F(e){I=e,b=ie(e),M(b);let t=oe();if(t)try{t.setItem(re,e)}catch{}se()}function ae(){F(b?"light":"dark")}function W(e,t){let n=m(e);if(!n)return e;let r=Number(t)/100,o=Number.isFinite(r)?Math.min(1,Math.max(0,r)):1;return`rgba(${n.join(",")},${o})`}function ce(e,t){if(typeof e!="string")return e;let n=e.indexOf("/"),r=n===-1?e:e.slice(0,n),o=n===-1?void 0:e.slice(n+1),a=t(r);return a===void 0?e:o===void 0?a:typeof a=="string"?W(a,o):{light:W(a.light,o),dark:W(a.dark,o)}}function Fe(e,t){let{dark:n,...r}=e,o={},a=i=>o[i]??t[i];for(let[i,s]of Object.entries(r))typeof s=="object"&&s!==null&&!("light"in s)&&!("dark"in s)||(o[i]=ce(s,a));if(n){let i={},s=c=>{let u=i[c]??t[c];return typeof u=="string"?u:void 0};for(let[c,u]of Object.entries(n)){let g=ce(u,s);i[c]=typeof g=="string"?g:g.dark}for(let[c,u]of Object.entries(i)){let g=o[c];g===void 0||typeof g!="string"||(o[c]={light:g,dark:u})}}return o}function fe(e){let t={...v,...e.theme};return e.extend?.colors&&(t={...t,colors:{...t.colors,...Fe(e.extend.colors,t.colors)}}),e.extend?.spacing&&(t={...t,spacing:{...t.spacing,...e.extend.spacing}}),e.extend?.screens&&(t={...t,screens:{...t.screens,...e.extend.screens}}),e.extend?.fontFamily&&(t={...t,fontFamily:{...t.fontFamily,...e.extend.fontFamily}}),e.extend?.container&&(t={...t,container:{...t.container,...e.extend.container}}),e.darkMode&&(t={...t,darkMode:e.darkMode}),t}function le(e){let t=!1,n={};for(let[r,o]of Object.entries(e.colors))typeof o!="string"&&m(o.light)&&m(o.dark)?(n[r]=`rgb(var(--kb-color-${r}))`,t=!0):n[r]=o;return t?{...e,colors:n}:e}function We(e){let t=e.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}function de({document:e,wasmUrl:t,config:n}){let r=new Set,o=!1,a=l=>{if(!o)return;let d=[];for(let y of l)for(let p of We(y))r.has(p)||(r.add(p),d.push(p));d.length>0&&Z(d.join(" "))},i=l=>[l,...Array.from(l.querySelectorAll("[class]"))],s=()=>a(i(e.documentElement)),c=l=>{let d=fe(l??{});R(le(d)),ne(d),L()};c(n);let u=new e.defaultView.MutationObserver(l=>{let d=[];for(let y of l)if(y.type==="attributes")d.push(y.target);else for(let p of Array.from(y.addedNodes))p.nodeType===1&&d.push(...i(p));a(d)});return{ready:N(t).then(()=>{o=!0,s(),u.observe(e.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class"]})}),config(l){c(l),r.clear(),s()},refresh:s,setMode:F,toggle:ae}}var B="kbach_core_engine_bg.wasm",ue=/(\/@kbach\/browser)(@[^/]*)?\/?$/;function ge(e,t,n,r){if(t)return new URL(t,n).href;if(!e)return new URL(B,n).href;let o=new URL(e,n);return ue.test(o.pathname)?(o.pathname=o.pathname.replace(ue,`$1@${r}/dist/${B}`),o.search="",o.hash="",o.href):new URL(B,o).href}var me=document.currentScript,Be=ge(me?.src||void 0,me?.dataset.wasm,document.baseURI,"1.0.0-beta.3");window.Kbach=de({document,wasmUrl:Be,config:window.kbachConfig});})();
1
+ "use strict";(()=>{var Ke={};function q(e,t){let n,r;try{let o=Y(e,f.__wbindgen_malloc,f.__wbindgen_realloc),c=E,i=Y(t,f.__wbindgen_malloc,f.__wbindgen_realloc),a=E,s=f.generate_css(o,c,i,a);return n=s[0],r=s[1],Ee(s[0],s[1])}finally{f.__wbindgen_free(n,r,1)}}function xe(){return{__proto__:null,"./kbach_core_engine_bg.js":{__proto__:null,__wbindgen_init_externref_table:function(){let t=f.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}function Ee(e,t){return ve(e>>>0,t)}var w=null;function T(){return(w===null||w.byteLength===0)&&(w=new Uint8Array(f.memory.buffer)),w}function Y(e,t,n){if(n===void 0){let a=k.encode(e),s=t(a.length,1)>>>0;return T().subarray(s,s+a.length).set(a),E=a.length,s}let r=e.length,o=t(r,1)>>>0,c=T(),i=0;for(;i<r;i++){let a=e.charCodeAt(i);if(a>127)break;c[o+i]=a}if(i!==r){i!==0&&(e=e.slice(i)),o=n(o,r,r=i+e.length*3,1)>>>0;let a=T().subarray(o+i,o+r),s=k.encodeInto(e,a);i+=s.written,o=n(o,r,i,1)>>>0}return E=i,o}var x=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});x.decode();var Re=2146435072,K=0;function ve(e,t){return K+=t,K>=Re&&(x=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),x.decode(),K=t),x.decode(T().subarray(e,e+t))}var k=new TextEncoder;"encodeInto"in k||(k.encodeInto=function(e,t){let n=k.encode(e);return t.set(n),{read:e.length,written:n.length}});var E=0,Me,Ae,f;function De(e,t){return Ae=e,f=e.exports,Me=t,w=null,f.__wbindgen_start(),f}async function je(e,t){if(typeof Response=="function"&&e instanceof Response){if(!e.ok)throw new Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function O(e){if(f!==void 0)return f;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("kbach_core_engine_bg.wasm",Ke.url));let t=xe();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await je(await e,t);return De(n,r)}var I=null,X=!1;function Q(e){return I||(I=(e===void 0?O():O({module_or_path:e})).then(()=>{X=!0})),I}function Z(e,t){if(!X)throw new Error("[Kbach] generateCss() was called before initKbach() resolved. Call `await initKbach()` once at startup (e.g. before rendering your app) before using kb().");return q(e,t)}var ee={"amber-1":"#fffbeb","amber-10":"#78350f","amber-11":"#451a03","amber-12":"#291002","amber-2":"#fef3c7","amber-3":"#fde68a","amber-4":"#fcd34d","amber-5":"#fbbf24","amber-6":"#f59e0b","amber-7":"#d97706","amber-8":"#b45309","amber-9":"#92400e",black:"#000000","blue-1":"#eff6ff","blue-10":"#1e3a8a","blue-11":"#172554","blue-12":"#0d1633","blue-2":"#dbeafe","blue-3":"#bfdbfe","blue-4":"#93c5fd","blue-5":"#60a5fa","blue-6":"#3b82f6","blue-7":"#2563eb","blue-8":"#1d4ed8","blue-9":"#1e40af",bronze:"#cd7f32",coal:"#1c1c1c",copper:"#b87333",current:"currentColor","cyan-1":"#ecfeff","cyan-10":"#164e63","cyan-11":"#083344","cyan-12":"#041e28","cyan-2":"#cffafe","cyan-3":"#a5f3fc","cyan-4":"#67e8f9","cyan-5":"#22d3ee","cyan-6":"#06b6d4","cyan-7":"#0891b2","cyan-8":"#0e7490","cyan-9":"#155e75","emerald-1":"#ecfdf5","emerald-10":"#064e3b","emerald-11":"#022c22","emerald-12":"#011a14","emerald-2":"#d1fae5","emerald-3":"#a7f3d0","emerald-4":"#6ee7b7","emerald-5":"#34d399","emerald-6":"#10b981","emerald-7":"#059669","emerald-8":"#047857","emerald-9":"#065f46","fuchsia-1":"#fdf4ff","fuchsia-10":"#701a75","fuchsia-11":"#4a044e","fuchsia-12":"#2d022f","fuchsia-2":"#fae8ff","fuchsia-3":"#f5d0fe","fuchsia-4":"#f0abfc","fuchsia-5":"#e879f9","fuchsia-6":"#d946ef","fuchsia-7":"#c026d3","fuchsia-8":"#a21caf","fuchsia-9":"#86198f",gold:"#d4af37","gray-1":"#f9fafb","gray-10":"#111827","gray-11":"#030712","gray-12":"#020409","gray-2":"#f3f4f6","gray-3":"#e5e7eb","gray-4":"#d1d5db","gray-5":"#9ca3af","gray-6":"#6b7280","gray-7":"#4b5563","gray-8":"#374151","gray-9":"#1f2937","green-1":"#f0fdf4","green-10":"#14532d","green-11":"#052e16","green-12":"#031b0d","green-2":"#dcfce7","green-3":"#bbf7d0","green-4":"#86efac","green-5":"#4ade80","green-6":"#22c55e","green-7":"#16a34a","green-8":"#15803d","green-9":"#166534","indigo-1":"#eef2ff","indigo-10":"#312e81","indigo-11":"#1e1b4b","indigo-12":"#12102d","indigo-2":"#e0e7ff","indigo-3":"#c7d2fe","indigo-4":"#a5b4fc","indigo-5":"#818cf8","indigo-6":"#6366f1","indigo-7":"#4f46e5","indigo-8":"#4338ca","indigo-9":"#3730a3","lime-1":"#f7fee7","lime-10":"#365314","lime-11":"#1a2e05","lime-12":"#0f1b03","lime-2":"#ecfccb","lime-3":"#d9f99d","lime-4":"#bef264","lime-5":"#a3e635","lime-6":"#84cc16","lime-7":"#65a30d","lime-8":"#4d7c0f","lime-9":"#3f6212","neutral-1":"#fafafa","neutral-10":"#171717","neutral-11":"#0a0a0a","neutral-12":"#050505","neutral-2":"#f5f5f5","neutral-3":"#e5e5e5","neutral-4":"#d4d4d4","neutral-5":"#a3a3a3","neutral-6":"#737373","neutral-7":"#525252","neutral-8":"#404040","neutral-9":"#262626","orange-1":"#fff7ed","orange-10":"#7c2d12","orange-11":"#431407","orange-12":"#270c04","orange-2":"#ffedd5","orange-3":"#fed7aa","orange-4":"#fdba74","orange-5":"#fb923c","orange-6":"#f97316","orange-7":"#ea580c","orange-8":"#c2410c","orange-9":"#9a3412","pink-1":"#fdf2f8","pink-10":"#831843","pink-11":"#500724","pink-12":"#300415","pink-2":"#fce7f3","pink-3":"#fbcfe8","pink-4":"#f9a8d4","pink-5":"#f472b6","pink-6":"#ec4899","pink-7":"#db2777","pink-8":"#be185d","pink-9":"#9d174d","purple-1":"#faf5ff","purple-10":"#581c87","purple-11":"#3b0764","purple-12":"#23043c","purple-2":"#f3e8ff","purple-3":"#e9d5ff","purple-4":"#d8b4fe","purple-5":"#c084fc","purple-6":"#a855f7","purple-7":"#9333ea","purple-8":"#7e22ce","purple-9":"#6b21a8","red-1":"#fef2f2","red-10":"#7f1d1d","red-11":"#450a0a","red-12":"#280606","red-2":"#fee2e2","red-3":"#fecaca","red-4":"#fca5a5","red-5":"#f87171","red-6":"#ef4444","red-7":"#dc2626","red-8":"#b91c1c","red-9":"#991b1b","rose-1":"#fff1f2","rose-10":"#881337","rose-11":"#4c0519","rose-12":"#2d030e","rose-2":"#ffe4e6","rose-3":"#fecdd3","rose-4":"#fda4af","rose-5":"#fb7185","rose-6":"#f43f5e","rose-7":"#e11d48","rose-8":"#be123c","rose-9":"#9f1239",silver:"#c0c0c0","sky-1":"#f0f9ff","sky-10":"#0c4a6e","sky-11":"#082f49","sky-12":"#041b2b","sky-2":"#e0f2fe","sky-3":"#bae6fd","sky-4":"#7dd3fc","sky-5":"#38bdf8","sky-6":"#0ea5e9","sky-7":"#0284c7","sky-8":"#0369a1","sky-9":"#075985","slate-1":"#f8fafc","slate-10":"#0f172a","slate-11":"#020617","slate-12":"#01020a","slate-2":"#f1f5f9","slate-3":"#e2e8f0","slate-4":"#cbd5e1","slate-5":"#94a3b8","slate-6":"#64748b","slate-7":"#475569","slate-8":"#334155","slate-9":"#1e293b","stone-1":"#fafaf9","stone-10":"#1c1917","stone-11":"#0c0a09","stone-12":"#070605","stone-2":"#f5f5f4","stone-3":"#e7e5e4","stone-4":"#d6d3d1","stone-5":"#a8a29e","stone-6":"#78716c","stone-7":"#57534e","stone-8":"#44403c","stone-9":"#292524","teal-1":"#f0fdfa","teal-10":"#134e4a","teal-11":"#042f2e","teal-12":"#021c1b","teal-2":"#ccfbf1","teal-3":"#99f6e4","teal-4":"#5eead4","teal-5":"#2dd4bf","teal-6":"#14b8a6","teal-7":"#0d9488","teal-8":"#0f766e","teal-9":"#115e59",transparent:"transparent","violet-1":"#f5f3ff","violet-10":"#4c1d95","violet-11":"#2e1065","violet-12":"#1c0a3d","violet-2":"#ede9fe","violet-3":"#ddd6fe","violet-4":"#c4b5fd","violet-5":"#a78bfa","violet-6":"#8b5cf6","violet-7":"#7c3aed","violet-8":"#6d28d9","violet-9":"#5b21b6",white:"#ffffff","yellow-1":"#fefce8","yellow-10":"#713f12","yellow-11":"#422006","yellow-12":"#271304","yellow-2":"#fef9c3","yellow-3":"#fef08a","yellow-4":"#fde047","yellow-5":"#facc15","yellow-6":"#eab308","yellow-7":"#ca8a04","yellow-8":"#a16207","yellow-9":"#854d0e","zinc-1":"#fafafa","zinc-10":"#18181b","zinc-11":"#09090b","zinc-12":"#050506","zinc-2":"#f4f4f5","zinc-3":"#e4e4e7","zinc-4":"#d4d4d8","zinc-5":"#a1a1aa","zinc-6":"#71717a","zinc-7":"#52525b","zinc-8":"#3f3f46","zinc-9":"#27272a"};var v={colors:{...ee,surface:{light:"#f9fafb",dark:"#111827"}},spacing:{0:0,px:1,"0.5":2,1:4,"1.5":6,2:8,"2.5":10,3:12,"3.5":14,4:16,5:20,6:24,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384},screens:{sm:640,md:768,lg:1024,xl:1280,"2xl":1536},fontFamily:{sans:'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',serif:'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',mono:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},darkMode:"media",container:{}},R=v,te=JSON.stringify(v);function M(e){R=e,te=JSON.stringify(e)}function C(){return R}function L(){return te}var Oe=new Set(["attribute","class","media"]);function ne(){if(typeof document>"u")return;let e=getComputedStyle(document.documentElement).getPropertyValue("--kb-dark-mode").trim();!Oe.has(e)||e===R.darkMode||M({...R,darkMode:e})}function h(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;let n=t[1];n.length===3&&(n=n.split("").map(o=>o+o).join(""));let r=parseInt(n,16);return[r>>16&255,r>>8&255,r&255]}function Ie(e,t){switch(e){case"class":return`.dark { ${t} }`;case"media":return`@media (prefers-color-scheme: dark) { :root { ${t} } }`;default:return`[data-theme="dark"] { ${t} }`}}function Le(e){let t=[],n=[];for(let[r,o]of Object.entries(e.colors)){if(typeof o=="string")continue;let c=h(o.light),i=h(o.dark);!c||!i||(t.push(`--kb-color-${r}: ${c.join(",")};`),n.push(`--kb-color-${r}: ${i.join(",")};`))}return{light:t,dark:n}}function Fe(e){let{light:t,dark:n}=Le(e);return t.length===0?"":`:root { ${t.join(" ")} }
2
+ ${Ie(e.darkMode,n.join(" "))}`}function A(e){let t=!1,n={};for(let[r,o]of Object.entries(e.colors))typeof o!="string"&&h(o.light)&&h(o.dark)?(n[r]=`rgb(var(--kb-color-${r}))`,t=!0):n[r]=o;return t?{...e,colors:n}:e}var re="kbach-colors",oe=null;function D(e){if(typeof document>"u"||oe===e)return;oe=e;let t=Fe(e),n=document.getElementById(re);if(!t){n?.remove();return}n||(n=document.createElement("style"),n.id=re,document.head.insertBefore(n,document.head.firstChild)),n.textContent=t}var F="kbach-reset",We=[{css:"*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: currentColor; }"},{css:"body { margin: 0; padding: 0; }"},{css:"h1, h2, h3, h4, h5, h6 { margin: 0; font-size: inherit; font-weight: inherit; }",tags:["h1","h2","h3","h4","h5","h6"]},{css:"p { margin: 0; }",tags:["p"]},{css:"a { color: inherit; text-decoration: none; }",tags:["a"]},{css:"ul, ol { margin: 0; padding: 0; list-style: none; }",tags:["ul","ol"]},{css:"img, video, svg { display: block; max-width: 100%; }",tags:["img","video","svg"]},{css:"input:where(:not([type='checkbox']):not([type='radio'])), textarea { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; line-height: inherit; }",tags:["input","textarea"]},{css:":where(input[type='checkbox'], input[type='radio'], input[type='range']) { margin: 0; font: inherit; accent-color: currentColor; }",tags:["input"]},{css:"select { margin: 0; font: inherit; color: inherit; line-height: inherit; }",tags:["select"]},{css:"button { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; line-height: inherit; text-align: inherit; }",tags:["button"]},{css:"button, [role='button'] { cursor: pointer; }",tags:["button"]},{css:":disabled { cursor: default; }",tags:["button","input","select","textarea"]},{css:"textarea { resize: vertical; }",tags:["textarea"]},{css:"::placeholder { opacity: 1; }",tags:["input","textarea"]},{css:"input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-outer-spin-button { margin: 0; }",tags:["input"]},{css:"input[type='search']::-webkit-search-decoration, input[type='search']::-webkit-search-cancel-button { -webkit-appearance: none; }",tags:["input"]},{css:"fieldset { padding: 0; margin: 0; }",tags:["fieldset"]},{css:"table { border-collapse: collapse; border-spacing: 0; }",tags:["table"]}],ie=We.map(e=>e.css).join(`
3
+ `);var se=!1;var m=null,$=[],z=new Map;function Be(){return m||(m=document.createElement("style"),m.setAttribute("data-kbach",""),document.head.appendChild(m),m)}function $e(e){let t=0,n=$.length;for(;t<n;){let r=t+n>>>1;z.get($[r])>e?n=r:t=r+1}return t}function ze(e,t){if(z.has(e))return;let n=Be().sheet;if(!n)return;let r=$e(t);try{n.insertRule(e,r)}catch{return}$.splice(r,0,e),z.set(e,t)}var ae=!1;function Ne(){if(ae||(ae=!0,document.getElementById(F)))return;let e=document.createElement("style");e.id=F,e.textContent=ie,document.head.insertBefore(e,document.head.firstChild)}var Ue=500,S=new Map,ce=null,de="",N=!1;function Pe(){let e=C(),t=A(e);N=t!==e,de=N?JSON.stringify(t):L()}var W=null,B=null,le=-1,y=new Set;function Ge(e){return e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(t,n)=>String.fromCodePoint(parseInt(n,16))).replace(/\\(.)/g,"$1")}function fe(e){try{return Array.from(e.cssRules).some(t=>t instanceof CSSStyleRule&&t.selectorText===":root"&&t.cssText.includes("--kb-dark-mode"))}catch{return!1}}function ue(e,t){for(let n of Array.from(e))if(n instanceof CSSStyleRule)for(let r of n.selectorText.matchAll(/\.((?:\\[0-9a-fA-F]{1,6}\s?|\\.|[\w-])+)/g))t.add(Ge(r[1]));else"cssRules"in n&&ue(n.cssRules,t)}function Ve(){if(typeof document>"u")return y;let e=W&&W.sheet;return(!e||!fe(e))&&(e=Array.from(document.styleSheets).find(t=>t!==m?.sheet&&fe(t))??null,W=e?.ownerNode??null),e?((e!==B||e.cssRules.length!==le)&&(B=e,le=e.cssRules.length,y=new Set,ue(e.cssRules,y)),y):(B=null,y=new Set,y)}function ge(e){let t=L();t!==ce&&(S.clear(),ce=t,Pe());let n=se?null:Ve(),r=e,o="";if(n&&n.size>0){let s=e.split(/\s+/).filter(Boolean);r=s.filter(l=>!n.has(l)).join(" "),o=s.filter(l=>n.has(l)).join(" ")}let c=S.get(r);if(c===void 0){let s=Z(r,de);c=JSON.parse(s),S.size>=Ue&&S.clear(),S.set(r,c)}let{className:i,rules:a}=c;if(!se){Ne(),N&&D(C());for(let{rule:s,order:l}of a)ze(s,l)}return o?(o+" "+i).trim():i}var me="kbach-theme",He=new Set;function Je(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function be(){return typeof window>"u"?null:window.localStorage}function Ye(){let e=be();if(!e)return null;try{let t=e.getItem(me);return t==="light"||t==="dark"||t==="system"?t:null}catch{return null}}function pe(e){return e==="system"?Je():e==="dark"}function j(e){if(typeof document>"u")return;let t=document.documentElement,n=C().darkMode;t.classList.toggle("dark",n==="class"&&e),t.classList.toggle("light",n==="class"&&!e),n==="attribute"?t.setAttribute("data-theme",e?"dark":"light"):t.removeAttribute("data-theme")}ne();var qe=Ye();var U=qe??"system",b=pe(U);j(b);if(typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)"),t=n=>{U==="system"&&(b=n.matches,j(b),he())};e.addEventListener?e.addEventListener("change",t):e.addListener(t)}function he(){for(let e of He)e()}function P(){j(b)}function G(e){U=e,b=pe(e),j(b);let t=be();if(t)try{t.setItem(me,e)}catch{}he()}function ye(){G(b?"light":"dark")}function V(e,t){let n=h(e);if(!n)return e;let r=Number(t)/100,o=Number.isFinite(r)?Math.min(1,Math.max(0,r)):1;return`rgba(${n.join(",")},${o})`}function H(e,t){if(typeof e!="string"){let i=(a,s)=>{let l=H(a,t);return typeof l=="string"?l:l[s]};return{light:i(e.light,"light"),dark:i(e.dark,"dark")}}let n=e.indexOf("/"),r=n===-1?e:e.slice(0,n),o=n===-1?void 0:e.slice(n+1),c=t(r);return c===void 0?e:o===void 0?c:typeof c=="string"?V(c,o):{light:V(c.light,o),dark:V(c.dark,o)}}function Xe(e,t){let{dark:n,...r}=e,o={},c=i=>o[i]??t[i];for(let[i,a]of Object.entries(r))typeof a=="object"&&a!==null&&!("light"in a)&&!("dark"in a)||(o[i]=H(a,c));if(n){let i={},a=s=>{let l=i[s]??t[s];return typeof l=="string"?l:void 0};for(let[s,l]of Object.entries(n)){let g=H(l,a);i[s]=typeof g=="string"?g:g.dark}for(let[s,l]of Object.entries(i)){let g=o[s];g===void 0||typeof g!="string"||(o[s]={light:g,dark:l})}}return o}function _e(e){let t={...v,...e.theme};return e.extend?.colors&&(t={...t,colors:{...t.colors,...Xe(e.extend.colors,t.colors)}}),e.extend?.spacing&&(t={...t,spacing:{...t.spacing,...e.extend.spacing}}),e.extend?.screens&&(t={...t,screens:{...t.screens,...e.extend.screens}}),e.extend?.fontFamily&&(t={...t,fontFamily:{...t.fontFamily,...e.extend.fontFamily}}),e.extend?.container&&(t={...t,container:{...t.container,...e.extend.container}}),e.darkMode&&(t={...t,darkMode:e.darkMode}),t}function we(e){return A(e)}function Qe(e){let t=e.getAttribute("class");return t?t.split(/\s+/).filter(Boolean):[]}function ke({document:e,wasmUrl:t,config:n}){let r=new Set,o=!1,c=d=>{if(!o)return;let u=[];for(let _ of d)for(let p of Qe(_))r.has(p)||(r.add(p),u.push(p));u.length>0&&ge(u.join(" "))},i=d=>[d,...Array.from(d.querySelectorAll("[class]"))],a=()=>c(i(e.documentElement)),s=d=>{let u=_e(d??{});M(we(u)),D(u),P()};s(n);let l=new e.defaultView.MutationObserver(d=>{let u=[];for(let _ of d)if(_.type==="attributes")u.push(_.target);else for(let p of Array.from(_.addedNodes))p.nodeType===1&&u.push(...i(p));c(u)});return{ready:Q(t).then(()=>{o=!0,a(),l.observe(e.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class"]})}),config(d){s(d),r.clear(),a()},refresh:a,setMode:G,toggle:ye}}var J="kbach_core_engine_bg.wasm",Ce=/(\/@kbach\/browser)(@[^/]*)?\/?$/;function Se(e,t,n,r){if(t)return new URL(t,n).href;if(!e)return new URL(J,n).href;let o=new URL(e,n);return Ce.test(o.pathname)?(o.pathname=o.pathname.replace(Ce,`$1@${r}/dist/${J}`),o.search="",o.hash="",o.href):new URL(J,o).href}var Te=document.currentScript,Ze=Se(Te?.src||void 0,Te?.dataset.wasm,document.baseURI,"1.0.0-beta.4");window.Kbach=ke({document,wasmUrl:Ze,config:window.kbachConfig});})();
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/browser",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Kbach from a CDN: one <script> tag styles a plain HTML page with Kbach's utility classes. No build step, no bundler, no React.",
5
5
  "keywords": [
6
6
  "css",