@bamboocss/vite 1.21.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,36 @@
1
+ import { Plugin } from "vite";
1
2
  import { Context } from "@bamboocss/core";
2
3
  import { Dict, ParserResultInterface } from "@bamboocss/types";
3
4
  import MagicString from "magic-string";
4
- import { Plugin } from "vite";
5
5
 
6
+ //#region src/css.d.ts
7
+ /**
8
+ * What a project imports to get the stylesheet.
9
+ *
10
+ * Spelled with a `.css` extension because that is how vite decides what a module is: the
11
+ * id is all it has for a module with no file behind it, so `virtual:bamboo` would be
12
+ * bundled as javascript and injected as a script.
13
+ */
14
+ declare const VIRTUAL_CSS_ID = "virtual:bamboo.css";
15
+ interface BambooCssPluginOptions {
16
+ configPath?: string;
17
+ cwd?: string;
18
+ }
19
+ /**
20
+ * Serve bamboo's stylesheet as a virtual module, in dev and in build.
21
+ *
22
+ * This is the integration itself, not an optimisation: without it nothing emits css and
23
+ * the generated `styled-system` runtime names classes no rule exists for.
24
+ *
25
+ * A virtual module rather than a file written to disk, because vite already owns the two
26
+ * things a file would have to reimplement. In dev it injects css over the websocket and
27
+ * replaces it in place, so an edit repaints without reloading; in build it hashes the
28
+ * content into the asset graph and lets the bundler decide where it lands. Writing
29
+ * `styles.css` and asking the project to import it means the build reads a file the same
30
+ * process just wrote, which is a race on any watch rebuild.
31
+ */
32
+ declare const bamboocssCss: (options?: BambooCssPluginOptions) => Plugin;
33
+ //#endregion
6
34
  //#region src/runtime-css.d.ts
7
35
  /**
8
36
  * The generated runtime's `css`, rebuilt in-process from a resolved context.
@@ -33,7 +61,7 @@ declare const createRuntimeCss: (ctx: Context) => RuntimeCss;
33
61
  * Why a call site was left alone. Surfaced through `panda`-style diagnostics so a
34
62
  * user can tell the difference between "this folded" and "this silently didn't".
35
63
  */
36
- type SkipReason = 'dynamic' | 'raw-call' | 'not-foldable' | 'unsupported-kind' | 'not-imported' | 'no-call-expression' | 'overlapping' | 'empty' | 'unresolved-token';
64
+ type SkipReason = 'dynamic' | 'raw-call' | 'not-foldable' | 'recipe-call' | 'unsupported-kind' | 'not-imported' | 'no-call-expression' | 'overlapping' | 'empty' | 'unresolved-token';
37
65
  interface FoldedCall {
38
66
  name: string;
39
67
  /**
@@ -144,18 +172,35 @@ interface BambooVitePluginOptions {
144
172
  * @default true
145
173
  */
146
174
  reportSummary?: boolean;
175
+ /**
176
+ * Fail the build when a `css()` or pattern call is left for the runtime.
177
+ *
178
+ * The fold's value is not the per-call CPU it saves — it is that a bundle where *every*
179
+ * such call folded no longer imports `styled-system/css` at all, and the engine behind it
180
+ * drops out. One survivor keeps the whole thing, so a coverage percentage cannot tell you
181
+ * whether you got the prize. This can.
182
+ *
183
+ * Deliberately silent about `cva`/`sva`. A `cva(...)` definition returns a function and can
184
+ * never collapse to a class string, so failing on it would make this unusable for anyone
185
+ * writing recipes — and recipes keep their own much smaller runtime by design. What this
186
+ * guarantees is narrower and checkable: nothing still calls `css()`.
187
+ *
188
+ * @default false
189
+ */
190
+ strict?: boolean;
147
191
  }
148
192
  /**
149
193
  * Vite integration for Bamboo CSS.
150
194
  *
151
- * This plugin does not emit CSS keep your existing PostCSS setup for that. Its only
152
- * job is the optional build-time fold.
195
+ * Two plugins, because they do unrelated jobs on different schedules. The first emits the
196
+ * stylesheet as a virtual module and runs in dev and build alike — that is the integration,
197
+ * and nothing styles without it. The second is the optional build-time fold.
153
198
  *
154
- * It runs with `enforce: 'pre'` so it sees module source as close as possible to what
199
+ * The fold runs with `enforce: 'pre'` so it sees module source as close as possible to what
155
200
  * the CSS extractor reads off disk. A plugin that rewrites style calls before bamboo
156
201
  * sees them would otherwise make the two disagree, and a folded class could end up
157
202
  * with no matching rule.
158
203
  */
159
- declare const bamboocss: (options?: BambooVitePluginOptions) => Plugin;
204
+ declare const bamboocss: (options?: BambooVitePluginOptions) => Plugin[];
160
205
  //#endregion
161
- export { type BambooVitePluginOptions, type FoldOptions, type FoldResult, type FoldedCall, type RuntimeCss, type SkipReason, type SkippedCall, bamboocss, bamboocss as default, createRuntimeCss, foldSource };
206
+ export { type BambooCssPluginOptions, type BambooVitePluginOptions, type FoldOptions, type FoldResult, type FoldedCall, type RuntimeCss, type SkipReason, type SkippedCall, VIRTUAL_CSS_ID, bamboocss, bamboocss as default, bamboocssCss, createRuntimeCss, foldSource };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,36 @@
1
1
  import MagicString from "magic-string";
2
2
  import { Context } from "@bamboocss/core";
3
- import { Dict, ParserResultInterface } from "@bamboocss/types";
4
3
  import { Plugin } from "vite";
4
+ import { Dict, ParserResultInterface } from "@bamboocss/types";
5
5
 
6
+ //#region src/css.d.ts
7
+ /**
8
+ * What a project imports to get the stylesheet.
9
+ *
10
+ * Spelled with a `.css` extension because that is how vite decides what a module is: the
11
+ * id is all it has for a module with no file behind it, so `virtual:bamboo` would be
12
+ * bundled as javascript and injected as a script.
13
+ */
14
+ declare const VIRTUAL_CSS_ID = "virtual:bamboo.css";
15
+ interface BambooCssPluginOptions {
16
+ configPath?: string;
17
+ cwd?: string;
18
+ }
19
+ /**
20
+ * Serve bamboo's stylesheet as a virtual module, in dev and in build.
21
+ *
22
+ * This is the integration itself, not an optimisation: without it nothing emits css and
23
+ * the generated `styled-system` runtime names classes no rule exists for.
24
+ *
25
+ * A virtual module rather than a file written to disk, because vite already owns the two
26
+ * things a file would have to reimplement. In dev it injects css over the websocket and
27
+ * replaces it in place, so an edit repaints without reloading; in build it hashes the
28
+ * content into the asset graph and lets the bundler decide where it lands. Writing
29
+ * `styles.css` and asking the project to import it means the build reads a file the same
30
+ * process just wrote, which is a race on any watch rebuild.
31
+ */
32
+ declare const bamboocssCss: (options?: BambooCssPluginOptions) => Plugin;
33
+ //#endregion
6
34
  //#region src/runtime-css.d.ts
7
35
  /**
8
36
  * The generated runtime's `css`, rebuilt in-process from a resolved context.
@@ -33,7 +61,7 @@ declare const createRuntimeCss: (ctx: Context) => RuntimeCss;
33
61
  * Why a call site was left alone. Surfaced through `panda`-style diagnostics so a
34
62
  * user can tell the difference between "this folded" and "this silently didn't".
35
63
  */
36
- type SkipReason = 'dynamic' | 'raw-call' | 'not-foldable' | 'unsupported-kind' | 'not-imported' | 'no-call-expression' | 'overlapping' | 'empty' | 'unresolved-token';
64
+ type SkipReason = 'dynamic' | 'raw-call' | 'not-foldable' | 'recipe-call' | 'unsupported-kind' | 'not-imported' | 'no-call-expression' | 'overlapping' | 'empty' | 'unresolved-token';
37
65
  interface FoldedCall {
38
66
  name: string;
39
67
  /**
@@ -144,18 +172,35 @@ interface BambooVitePluginOptions {
144
172
  * @default true
145
173
  */
146
174
  reportSummary?: boolean;
175
+ /**
176
+ * Fail the build when a `css()` or pattern call is left for the runtime.
177
+ *
178
+ * The fold's value is not the per-call CPU it saves — it is that a bundle where *every*
179
+ * such call folded no longer imports `styled-system/css` at all, and the engine behind it
180
+ * drops out. One survivor keeps the whole thing, so a coverage percentage cannot tell you
181
+ * whether you got the prize. This can.
182
+ *
183
+ * Deliberately silent about `cva`/`sva`. A `cva(...)` definition returns a function and can
184
+ * never collapse to a class string, so failing on it would make this unusable for anyone
185
+ * writing recipes — and recipes keep their own much smaller runtime by design. What this
186
+ * guarantees is narrower and checkable: nothing still calls `css()`.
187
+ *
188
+ * @default false
189
+ */
190
+ strict?: boolean;
147
191
  }
148
192
  /**
149
193
  * Vite integration for Bamboo CSS.
150
194
  *
151
- * This plugin does not emit CSS keep your existing PostCSS setup for that. Its only
152
- * job is the optional build-time fold.
195
+ * Two plugins, because they do unrelated jobs on different schedules. The first emits the
196
+ * stylesheet as a virtual module and runs in dev and build alike — that is the integration,
197
+ * and nothing styles without it. The second is the optional build-time fold.
153
198
  *
154
- * It runs with `enforce: 'pre'` so it sees module source as close as possible to what
199
+ * The fold runs with `enforce: 'pre'` so it sees module source as close as possible to what
155
200
  * the CSS extractor reads off disk. A plugin that rewrites style calls before bamboo
156
201
  * sees them would otherwise make the two disagree, and a folded class could end up
157
202
  * with no matching rule.
158
203
  */
159
- declare const bamboocss: (options?: BambooVitePluginOptions) => Plugin;
204
+ declare const bamboocss: (options?: BambooVitePluginOptions) => Plugin[];
160
205
  //#endregion
161
- export { type BambooVitePluginOptions, type FoldOptions, type FoldResult, type FoldedCall, type RuntimeCss, type SkipReason, type SkippedCall, bamboocss, bamboocss as default, createRuntimeCss, foldSource };
206
+ export { type BambooCssPluginOptions, type BambooVitePluginOptions, type FoldOptions, type FoldResult, type FoldedCall, type RuntimeCss, type SkipReason, type SkippedCall, VIRTUAL_CSS_ID, bamboocss, bamboocss as default, bamboocssCss, createRuntimeCss, foldSource };