@csszyx/compiler 0.6.2 → 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 +27 -2
- package/dist/color-var.cjs +3 -28
- package/dist/{color-var.js → color-var.mjs} +2 -6
- package/dist/index.cjs +2073 -3202
- package/dist/index.d.cts +12118 -111
- package/dist/index.d.mts +13484 -0
- package/dist/index.mjs +2706 -0
- package/dist/shared/compiler.BIUVmI0H.mjs +2271 -0
- package/dist/{index.js → shared/compiler.C6jT0mcT.cjs} +75 -1609
- package/dist/transform-core.cjs +17 -0
- package/dist/transform-core.d.cts +86 -0
- package/dist/transform-core.d.mts +86 -0
- package/dist/transform-core.mjs +1 -0
- package/package.json +41 -19
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/index.d.ts +0 -1477
- /package/dist/{color-var.d.ts → color-var.d.mts} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const transformCore = require('./shared/compiler.C6jT0mcT.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.BOOLEAN_SHORTHANDS = transformCore.BOOLEAN_SHORTHANDS;
|
|
8
|
+
exports.KNOWN_VARIANTS = transformCore.KNOWN_VARIANTS;
|
|
9
|
+
exports.PROPERTY_MAP = transformCore.PROPERTY_MAP;
|
|
10
|
+
exports.SUGGESTION_MAP = transformCore.SUGGESTION_MAP;
|
|
11
|
+
exports.VARIANT_MAP = transformCore.VARIANT_MAP;
|
|
12
|
+
exports.getVariantPrefix = transformCore.getVariantPrefix;
|
|
13
|
+
exports.isValidSzProp = transformCore.isValidSzProp;
|
|
14
|
+
exports.normalizeArbitraryValue = transformCore.normalizeArbitraryValue;
|
|
15
|
+
exports.normalizeArbitraryVariant = transformCore.normalizeArbitraryVariant;
|
|
16
|
+
exports.normalizeClassName = transformCore.normalizeClassName;
|
|
17
|
+
exports.transform = transformCore.transform;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSX Transform - Converts sz prop to className string.
|
|
3
|
+
*
|
|
4
|
+
* This module handles the transformation of csszyx object syntax into
|
|
5
|
+
* Tailwind CSS class strings. It processes nested objects for variants
|
|
6
|
+
* like hover, focus, etc.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Represents a value in the sz object.
|
|
10
|
+
* Can be a string, number, boolean, or nested object for variants.
|
|
11
|
+
*/
|
|
12
|
+
type SzValue = string | number | boolean | SzObject;
|
|
13
|
+
/**
|
|
14
|
+
* Represents the sz object structure.
|
|
15
|
+
* Keys are CSS property abbreviations, values can be primitives or nested objects.
|
|
16
|
+
*/
|
|
17
|
+
interface SzObject {
|
|
18
|
+
[key: string]: SzValue;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Readonly variant of SzValue — accepts values from `as const` objects.
|
|
22
|
+
*/
|
|
23
|
+
type ReadonlySzValue = string | number | boolean | ReadonlySzObject;
|
|
24
|
+
/**
|
|
25
|
+
* Readonly variant of SzObject — accepts `as const` objects without requiring `as any`.
|
|
26
|
+
* Use this as the parameter type for functions that accept but do not mutate sz objects.
|
|
27
|
+
*/
|
|
28
|
+
interface ReadonlySzObject {
|
|
29
|
+
readonly [key: string]: ReadonlySzValue;
|
|
30
|
+
}
|
|
31
|
+
declare const PROPERTY_MAP: Record<string, string>;
|
|
32
|
+
declare const SUGGESTION_MAP: Record<string, string>;
|
|
33
|
+
declare const VARIANT_MAP: Record<string, string>;
|
|
34
|
+
declare const KNOWN_VARIANTS: Set<string>;
|
|
35
|
+
declare const BOOLEAN_SHORTHANDS: Set<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Represents the result of a transformation.
|
|
38
|
+
*/
|
|
39
|
+
interface TransformResult {
|
|
40
|
+
className: string;
|
|
41
|
+
attributes: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalizes arbitrary variant selectors (removes extra whitespace)
|
|
45
|
+
* @param key - the arbitrary variant key to normalize
|
|
46
|
+
* @returns normalized variant string with whitespace removed
|
|
47
|
+
*/
|
|
48
|
+
declare function normalizeArbitraryVariant(key: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Normalizes arbitrary values for Tailwind
|
|
51
|
+
* @param value - the arbitrary value to normalize
|
|
52
|
+
* @returns normalized value with spaces replaced by underscores
|
|
53
|
+
*/
|
|
54
|
+
declare function normalizeArbitraryValue(value: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the variant prefix from a camelCase key
|
|
57
|
+
* @param key - the camelCase variant key
|
|
58
|
+
* @returns the mapped or kebab-cased variant prefix
|
|
59
|
+
*/
|
|
60
|
+
declare function getVariantPrefix(key: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Transforms a csszyx sz object into a Tailwind CSS className string and extracted attributes.
|
|
63
|
+
*
|
|
64
|
+
* @param {SzObject} szProp - The sz object from JSX
|
|
65
|
+
* @param {string} prefix - Variant prefix for nested properties
|
|
66
|
+
* @param {Record<string, string>} [mangleMap] - Optional map for property name mangling
|
|
67
|
+
* @returns {TransformResult} The transformation result
|
|
68
|
+
*/
|
|
69
|
+
declare function transform(szProp: SzObject, prefix?: string, mangleMap?: Record<string, string>): TransformResult;
|
|
70
|
+
/**
|
|
71
|
+
* Validates that an sz prop object is valid.
|
|
72
|
+
*
|
|
73
|
+
* @param {unknown} szProp - The value to validate
|
|
74
|
+
* @returns {boolean} True if valid, false otherwise
|
|
75
|
+
*/
|
|
76
|
+
declare function isValidSzProp(szProp: unknown): szProp is SzObject;
|
|
77
|
+
/**
|
|
78
|
+
* Normalizes a className string by removing extra whitespace.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} className - The className string to normalize
|
|
81
|
+
* @returns {string} The normalized className string
|
|
82
|
+
*/
|
|
83
|
+
declare function normalizeClassName(className: string): string;
|
|
84
|
+
|
|
85
|
+
export { BOOLEAN_SHORTHANDS, KNOWN_VARIANTS, PROPERTY_MAP, SUGGESTION_MAP, VARIANT_MAP, getVariantPrefix, isValidSzProp, normalizeArbitraryValue, normalizeArbitraryVariant, normalizeClassName, transform };
|
|
86
|
+
export type { ReadonlySzObject, ReadonlySzValue, SzObject, SzValue, TransformResult };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSX Transform - Converts sz prop to className string.
|
|
3
|
+
*
|
|
4
|
+
* This module handles the transformation of csszyx object syntax into
|
|
5
|
+
* Tailwind CSS class strings. It processes nested objects for variants
|
|
6
|
+
* like hover, focus, etc.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Represents a value in the sz object.
|
|
10
|
+
* Can be a string, number, boolean, or nested object for variants.
|
|
11
|
+
*/
|
|
12
|
+
type SzValue = string | number | boolean | SzObject;
|
|
13
|
+
/**
|
|
14
|
+
* Represents the sz object structure.
|
|
15
|
+
* Keys are CSS property abbreviations, values can be primitives or nested objects.
|
|
16
|
+
*/
|
|
17
|
+
interface SzObject {
|
|
18
|
+
[key: string]: SzValue;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Readonly variant of SzValue — accepts values from `as const` objects.
|
|
22
|
+
*/
|
|
23
|
+
type ReadonlySzValue = string | number | boolean | ReadonlySzObject;
|
|
24
|
+
/**
|
|
25
|
+
* Readonly variant of SzObject — accepts `as const` objects without requiring `as any`.
|
|
26
|
+
* Use this as the parameter type for functions that accept but do not mutate sz objects.
|
|
27
|
+
*/
|
|
28
|
+
interface ReadonlySzObject {
|
|
29
|
+
readonly [key: string]: ReadonlySzValue;
|
|
30
|
+
}
|
|
31
|
+
declare const PROPERTY_MAP: Record<string, string>;
|
|
32
|
+
declare const SUGGESTION_MAP: Record<string, string>;
|
|
33
|
+
declare const VARIANT_MAP: Record<string, string>;
|
|
34
|
+
declare const KNOWN_VARIANTS: Set<string>;
|
|
35
|
+
declare const BOOLEAN_SHORTHANDS: Set<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Represents the result of a transformation.
|
|
38
|
+
*/
|
|
39
|
+
interface TransformResult {
|
|
40
|
+
className: string;
|
|
41
|
+
attributes: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalizes arbitrary variant selectors (removes extra whitespace)
|
|
45
|
+
* @param key - the arbitrary variant key to normalize
|
|
46
|
+
* @returns normalized variant string with whitespace removed
|
|
47
|
+
*/
|
|
48
|
+
declare function normalizeArbitraryVariant(key: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Normalizes arbitrary values for Tailwind
|
|
51
|
+
* @param value - the arbitrary value to normalize
|
|
52
|
+
* @returns normalized value with spaces replaced by underscores
|
|
53
|
+
*/
|
|
54
|
+
declare function normalizeArbitraryValue(value: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the variant prefix from a camelCase key
|
|
57
|
+
* @param key - the camelCase variant key
|
|
58
|
+
* @returns the mapped or kebab-cased variant prefix
|
|
59
|
+
*/
|
|
60
|
+
declare function getVariantPrefix(key: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Transforms a csszyx sz object into a Tailwind CSS className string and extracted attributes.
|
|
63
|
+
*
|
|
64
|
+
* @param {SzObject} szProp - The sz object from JSX
|
|
65
|
+
* @param {string} prefix - Variant prefix for nested properties
|
|
66
|
+
* @param {Record<string, string>} [mangleMap] - Optional map for property name mangling
|
|
67
|
+
* @returns {TransformResult} The transformation result
|
|
68
|
+
*/
|
|
69
|
+
declare function transform(szProp: SzObject, prefix?: string, mangleMap?: Record<string, string>): TransformResult;
|
|
70
|
+
/**
|
|
71
|
+
* Validates that an sz prop object is valid.
|
|
72
|
+
*
|
|
73
|
+
* @param {unknown} szProp - The value to validate
|
|
74
|
+
* @returns {boolean} True if valid, false otherwise
|
|
75
|
+
*/
|
|
76
|
+
declare function isValidSzProp(szProp: unknown): szProp is SzObject;
|
|
77
|
+
/**
|
|
78
|
+
* Normalizes a className string by removing extra whitespace.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} className - The className string to normalize
|
|
81
|
+
* @returns {string} The normalized className string
|
|
82
|
+
*/
|
|
83
|
+
declare function normalizeClassName(className: string): string;
|
|
84
|
+
|
|
85
|
+
export { BOOLEAN_SHORTHANDS, KNOWN_VARIANTS, PROPERTY_MAP, SUGGESTION_MAP, VARIANT_MAP, getVariantPrefix, isValidSzProp, normalizeArbitraryValue, normalizeArbitraryVariant, normalizeClassName, transform };
|
|
86
|
+
export type { ReadonlySzObject, ReadonlySzValue, SzObject, SzValue, TransformResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { B as BOOLEAN_SHORTHANDS, K as KNOWN_VARIANTS, P as PROPERTY_MAP, S as SUGGESTION_MAP, V as VARIANT_MAP, b as getVariantPrefix, i as isValidSzProp, e as normalizeArbitraryValue, f as normalizeArbitraryVariant, n as normalizeClassName, t as transform } from './shared/compiler.BIUVmI0H.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Core compiler and transformation logic for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -21,23 +21,39 @@
|
|
|
21
21
|
"url": "https://github.com/nguyennhutien/csszyx/issues"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
|
-
"main": "./dist/index.
|
|
25
|
-
"module": "./dist/index.
|
|
26
|
-
"types": "./dist/index.d.
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
"import": {
|
|
30
|
+
"types": "./dist/index.d.mts",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/index.d.cts",
|
|
35
|
+
"default": "./dist/index.cjs"
|
|
36
|
+
}
|
|
32
37
|
},
|
|
33
38
|
"./browser": {
|
|
34
|
-
"import":
|
|
35
|
-
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/transform-core.d.mts",
|
|
41
|
+
"default": "./dist/transform-core.mjs"
|
|
42
|
+
},
|
|
43
|
+
"require": {
|
|
44
|
+
"types": "./dist/transform-core.d.cts",
|
|
45
|
+
"default": "./dist/transform-core.cjs"
|
|
46
|
+
}
|
|
36
47
|
},
|
|
37
48
|
"./color-var": {
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/color-var.d.mts",
|
|
51
|
+
"default": "./dist/color-var.mjs"
|
|
52
|
+
},
|
|
53
|
+
"require": {
|
|
54
|
+
"types": "./dist/color-var.d.cts",
|
|
55
|
+
"default": "./dist/color-var.cjs"
|
|
56
|
+
}
|
|
41
57
|
}
|
|
42
58
|
},
|
|
43
59
|
"files": [
|
|
@@ -45,22 +61,28 @@
|
|
|
45
61
|
],
|
|
46
62
|
"dependencies": {
|
|
47
63
|
"@babel/core": "^7.23.7",
|
|
48
|
-
"@babel/types": "^7.23.6",
|
|
49
64
|
"@babel/traverse": "^7.23.7",
|
|
50
|
-
"@
|
|
65
|
+
"@babel/types": "^7.23.6",
|
|
66
|
+
"magic-string": "0.30.21",
|
|
67
|
+
"oxc-parser": "0.131.0",
|
|
68
|
+
"@csszyx/core": "0.8.0"
|
|
51
69
|
},
|
|
52
70
|
"devDependencies": {
|
|
53
71
|
"@types/babel__core": "^7.20.5",
|
|
54
72
|
"@types/babel__traverse": "^7.20.5",
|
|
55
73
|
"@types/node": "^20.11.0",
|
|
56
74
|
"csstype": "^3.0.0",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"vitest": "^1.
|
|
75
|
+
"typescript": "^6.0.3",
|
|
76
|
+
"unbuild": "^3.6.1",
|
|
77
|
+
"vitest": "^4.1.6"
|
|
78
|
+
},
|
|
79
|
+
"sideEffects": false,
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=22.12.0"
|
|
60
82
|
},
|
|
61
83
|
"scripts": {
|
|
62
|
-
"build": "
|
|
63
|
-
"dev": "
|
|
84
|
+
"build": "unbuild",
|
|
85
|
+
"dev": "unbuild --stub",
|
|
64
86
|
"test": "vitest run",
|
|
65
87
|
"test:watch": "vitest",
|
|
66
88
|
"type-check": "tsc --noEmit"
|
package/dist/chunk-3RG5ZIWI.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
__require
|
|
10
|
-
};
|