@csszyx/compiler 0.7.0 → 0.9.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,38 @@ 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. Retained as the final compatibility fallback.
99
+
100
+ #### `transformOxc(source: string, filename?: string, options?: TransformSourceCodeOptions): TransformOxcResult` _(since v0.8.0)_
101
+
102
+ oxc-parser + magic-string source transform. Same return shape as
103
+ `transformSourceCode` so consumers (and the parity harness) can diff
104
+ both implementations cleanly. JavaScript fallback when the native Rust
105
+ engine is unavailable (e.g. unsupported platform). Set
106
+ `build.parser: 'oxc'` to use this path.
107
+
108
+ #### `transformRust(source: string, filename?: string, options?: TransformSourceCodeOptions): TransformRustResult` _(default since v0.9.0)_
109
+
110
+ Native Rust engine via napi-rs. Fastest parser path. Requires the
111
+ matching optional `@csszyx/core-*` platform package. Missing native
112
+ packages surface `CsszyxNativeUnavailableError`.
113
+
114
+ All three transform paths preserve every byte the user wrote outside the
115
+ touched `sz`/`szRecover` ranges.
87
116
 
88
117
  #### `isValidSzProp(szProp: unknown): boolean`
89
118
 
@@ -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;
@@ -30,9 +7,8 @@ function __szColorVar(v) {
30
7
  if (v.startsWith("--")) {
31
8
  return `var(${v})`;
32
9
  }
10
+ if (/[);\s\\]/.test(v)) return v;
33
11
  return `var(--color-${v})`;
34
12
  }
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- __szColorVar
38
- });
13
+
14
+ 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;
@@ -8,8 +5,8 @@ function __szColorVar(v) {
8
5
  if (v.startsWith("--")) {
9
6
  return `var(${v})`;
10
7
  }
8
+ if (/[);\s\\]/.test(v)) return v;
11
9
  return `var(--color-${v})`;
12
10
  }
13
- export {
14
- __szColorVar
15
- };
11
+
12
+ export { __szColorVar };