@csszyx/compiler 0.7.0 → 0.8.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/README.md CHANGED
@@ -81,9 +81,34 @@ const manifest = builder.build();
81
81
 
82
82
  ### Transform
83
83
 
84
- #### `transform(szProp: SzObject, prefix?: string): string`
84
+ Two layers — a pure object compile (`transform`) and two source-string
85
+ transforms (`transformSourceCode` for the Babel path, `transformOxc` for
86
+ the oxc-parser + magic-string path).
85
87
 
86
- Transforms a CSSzyx sz object into a Tailwind CSS className string.
88
+ #### `transform(szProp: SzObject, prefix?: string, mangleMap?: Record<string, string>): TransformResult`
89
+
90
+ Pure compile from a sz object to `{ className, attributes }`. Browser-safe
91
+ (no parser dependency); also exposed at `@csszyx/compiler/browser` for
92
+ runtime consumers like `@csszyx/dynamic`.
93
+
94
+ #### `transformSourceCode(source: string, filename?: string, options?: TransformSourceCodeOptions): { code, transformed, usesRuntime, usesMerge, usesColorVar, classes, rawClassNames, diagnostics, recoveryTokens }`
95
+
96
+ Babel-based source transform. Parses TSX/JSX, walks the AST, rewrites
97
+ `sz`/`szRecover`/`_sz` constructs, emits the new source via Babel's
98
+ code generator. Source of truth before v0.8.0; retained as the fallback
99
+ path in v0.8.0+.
100
+
101
+ #### `transformOxc(source: string, filename?: string, options?: TransformSourceCodeOptions): TransformOxcResult` _(since v0.8.0)_
102
+
103
+ oxc-parser + magic-string source transform. Same return shape as
104
+ `transformSourceCode` so consumers (and the parity harness) can diff
105
+ both implementations cleanly. Throws `OxcNotImplementedError` only for
106
+ patterns that fall outside the curated Phase D coverage; the unplugin
107
+ catches that error and routes to `transformSourceCode` as the fallback.
108
+
109
+ Surgical edits preserve every byte the user wrote outside the touched
110
+ `sz`/`szRecover` ranges — Babel's pretty-printer would have collapsed
111
+ or expanded surrounding whitespace.
87
112
 
88
113
  #### `isValidSzProp(szProp: unknown): boolean`
89
114
 
@@ -1,28 +1,5 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/color-var.ts
21
- var color_var_exports = {};
22
- __export(color_var_exports, {
23
- __szColorVar: () => __szColorVar
24
- });
25
- module.exports = __toCommonJS(color_var_exports);
26
3
  function __szColorVar(v) {
27
4
  if (v.startsWith("#") || v.startsWith("rgb") || v.startsWith("hsl") || v.startsWith("oklch")) {
28
5
  return v;
@@ -32,7 +9,5 @@ function __szColorVar(v) {
32
9
  }
33
10
  return `var(--color-${v})`;
34
11
  }
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- __szColorVar
38
- });
12
+
13
+ exports.__szColorVar = __szColorVar;
@@ -1,6 +1,3 @@
1
- import "./chunk-3RG5ZIWI.js";
2
-
3
- // src/color-var.ts
4
1
  function __szColorVar(v) {
5
2
  if (v.startsWith("#") || v.startsWith("rgb") || v.startsWith("hsl") || v.startsWith("oklch")) {
6
3
  return v;
@@ -10,6 +7,5 @@ function __szColorVar(v) {
10
7
  }
11
8
  return `var(--color-${v})`;
12
9
  }
13
- export {
14
- __szColorVar
15
- };
10
+
11
+ export { __szColorVar };