catom 2.0.1 → 2.0.3

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/css.js CHANGED
@@ -1,4 +1,4 @@
1
- import { murmur2 } from "./hash";
1
+ import { murmur2 } from "./hash.js";
2
2
  const KEBAB_CASE_RE = /([a-z0-9]|(?=[A-Z]))([A-Z])/g;
3
3
  const NUMERIC_START = /^[0-9-]/;
4
4
  function toKebabCase(prop) {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { Properties } from "csstype";
2
- export { default } from "./plugin";
3
- export type { CatomOptions } from "./plugin";
4
- export { processStyleObject, generateRule, dedupeRules } from "./css";
5
- export type { CSSRule, StyleObject, ProcessResult } from "./css";
2
+ export { default } from "./plugin.js";
3
+ export type { CatomOptions } from "./plugin.js";
4
+ export { processStyleObject, generateRule, dedupeRules } from "./css.js";
5
+ export type { CSSRule, StyleObject, ProcessResult } from "./css.js";
6
6
  /**
7
7
  * Define atomic CSS styles. Transformed at build time to class names.
8
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACtE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,GAAG,CACjB,OAAO,EAAE,UAAU,GAAG;IACpB,KAAK,CAAC,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;IACxC,MAAM,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;CAC7C,GACA,MAAM,CAKR"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACzE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,GAAG,CACjB,OAAO,EAAE,UAAU,GAAG;IACpB,KAAK,CAAC,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;IACxC,MAAM,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;CAC7C,GACA,MAAM,CAKR"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { default } from "./plugin";
1
+ export { default } from "./plugin.js";
2
2
  // Re-export utilities for advanced usage
3
- export { processStyleObject, generateRule, dedupeRules } from "./css";
3
+ export { processStyleObject, generateRule, dedupeRules } from "./css.js";
4
4
  /**
5
5
  * Define atomic CSS styles. Transformed at build time to class names.
6
6
  *
package/dist/plugin.d.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  import type { Plugin } from "vite";
2
- import { transform } from "lightningcss";
3
2
  export interface CatomOptions {
4
3
  /** Function name to transform. Default: "css" */
5
4
  functionName?: string;
6
- /** LightningCSS browser targets */
7
- targets?: Parameters<typeof transform>[0]["targets"];
8
- /** Minify CSS output. Default: true in production */
9
- minify?: boolean;
10
5
  /** File patterns to include. Default: /\.[jt]sx?$/ */
11
6
  include?: RegExp | RegExp[];
12
7
  /** File patterns to exclude */
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAKzC,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrD,qDAAqD;IACrD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B;AAWD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,MAAM,EAAE,CAwHlE"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B;AAKD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,MAAM,EAAE,CAoFlE"}
package/dist/plugin.js CHANGED
@@ -1,20 +1,13 @@
1
- import { transform } from "lightningcss";
2
1
  import AST from "unplugin-ast/vite";
3
- import { createCatomTransformer } from "./transformer";
4
- import { dedupeRules } from "./css";
2
+ import { createCatomTransformer } from "./transformer.js";
3
+ import { dedupeRules } from "./css.js";
5
4
  const VIRTUAL_ID = "virtual:catom.css";
6
5
  const RESOLVED_VIRTUAL_ID = "\0" + VIRTUAL_ID;
7
- const DEFAULT_TARGETS = {
8
- chrome: 80 << 16,
9
- firefox: 80 << 16,
10
- safari: 14 << 16,
11
- };
12
6
  export default function catom(options = {}) {
13
- const { functionName = "css", targets = DEFAULT_TARGETS, minify, include = /\.[jt]sx?$/, exclude, } = options;
7
+ const { functionName = "css", include = /\.[jt]sx?$/, exclude, } = options;
14
8
  // Collect CSS rules from all files.
15
9
  // Using a Set for automatic deduplication (deterministic hashing means same rule = same string)
16
10
  const collectedRules = new Set();
17
- let isDev = false;
18
11
  // The AST plugin handles transformation
19
12
  const astPlugin = AST({
20
13
  include: Array.isArray(include) ? include : [include],
@@ -32,9 +25,6 @@ export default function catom(options = {}) {
32
25
  const cssPlugin = {
33
26
  name: "catom:css",
34
27
  enforce: "post",
35
- configResolved(config) {
36
- isDev = config.command === "serve";
37
- },
38
28
  buildStart() {
39
29
  // Clear collected rules at the start of each build
40
30
  collectedRules.clear();
@@ -58,26 +48,11 @@ export default function catom(options = {}) {
58
48
  if (collectedRules.size === 0)
59
49
  return [];
60
50
  const css = dedupeRules([...collectedRules]);
61
- const shouldMinify = minify ?? !isDev;
62
- let finalCss;
63
- try {
64
- const { code } = transform({
65
- code: Buffer.from(css),
66
- filename: "catom.css",
67
- minify: shouldMinify,
68
- targets,
69
- });
70
- finalCss = code.toString();
71
- }
72
- catch {
73
- // Fallback if lightningcss fails
74
- finalCss = css;
75
- }
76
51
  return [
77
52
  {
78
53
  tag: "style",
79
54
  attrs: { "data-catom": "" },
80
- children: finalCss,
55
+ children: css,
81
56
  injectTo: "head",
82
57
  },
83
58
  ];
@@ -88,24 +63,10 @@ export default function catom(options = {}) {
88
63
  if (collectedRules.size === 0)
89
64
  return;
90
65
  const css = dedupeRules([...collectedRules]);
91
- const shouldMinify = minify ?? true;
92
- let finalCss;
93
- try {
94
- const { code } = transform({
95
- code: Buffer.from(css),
96
- filename: "catom.css",
97
- minify: shouldMinify,
98
- targets,
99
- });
100
- finalCss = code.toString();
101
- }
102
- catch {
103
- finalCss = css;
104
- }
105
66
  this.emitFile({
106
67
  type: "asset",
107
68
  fileName: "catom.css",
108
- source: finalCss,
69
+ source: css,
109
70
  });
110
71
  },
111
72
  };
@@ -1,4 +1,4 @@
1
- import { processStyleObject } from "./css";
1
+ import { processStyleObject } from "./css.js";
2
2
  /**
3
3
  * Extract a JS value from a Babel AST node.
4
4
  * Only handles static, compile-time constant values.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catom",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Zero-runtime atomic CSS-in-JS for Vite",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,8 +29,7 @@
29
29
  ],
30
30
  "license": "MIT",
31
31
  "peerDependencies": {
32
- "vite": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
33
- "lightningcss": "^1.16.0"
32
+ "vite": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
34
33
  },
35
34
  "dependencies": {
36
35
  "unplugin-ast": "^0.15.4",
@@ -40,7 +39,6 @@
40
39
  "@babel/types": "^7.26.0",
41
40
  "@types/node": "^20.0.0",
42
41
  "typescript": "^5.0.0",
43
- "vite": "^5.0.0",
44
- "lightningcss": "^1.28.0"
42
+ "vite": "^5.0.0"
45
43
  }
46
44
  }