@csszyx/core 0.1.1 β 0.1.2
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 +37 -67
- package/package.json +1 -1
- package/pkg/README.md +37 -67
- package/pkg/csszyx_core_bg.wasm +0 -0
- package/pkg-node/README.md +37 -67
- package/pkg-node/csszyx_core_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,113 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @csszyx/core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<img src="https://img.shields.io/badge/WASM-Powered-624de3?style=for-the-badge&logo=webassembly" alt="WASM Powered" />
|
|
5
|
-
<img src="https://img.shields.io/badge/Rust-Core-dea584?style=for-the-badge&logo=rust" alt="Rust Core" />
|
|
6
|
-
<img src="https://img.shields.io/badge/TypeScript-Ready-3178c6?style=for-the-badge&logo=typescript" alt="TypeScript Ready" />
|
|
7
|
-
</p>
|
|
3
|
+
> Rust/WASM core for csszyx -- encoder, checksum, collision detection, and recovery tokens.
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
Compiled to WebAssembly, this package provides the performance-critical operations for the csszyx ecosystem. It runs in Node.js, browsers, and edge environments.
|
|
10
6
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
`@csszyx/core` is a high-performance, precision-engineered Rust core for the **csszyx** ecosystem. Compiled to WebAssembly, it brings near-native performance to Node.js, Browsers, and Edge environments.
|
|
14
|
-
|
|
15
|
-
### π₯ Why Core?
|
|
16
|
-
|
|
17
|
-
- **Blazing Speed**: Offloads performance-critical operations (Hashing, Transformation, Encoding) to optimized Rust.
|
|
18
|
-
- **Universal Integrity**: Ensures bit-perfect mangle map consistency between SSR and hydration.
|
|
19
|
-
- **Security-First**: Uses SHA-256 and Base62 for tamper-proof tokens and collision-free variable names.
|
|
20
|
-
- **Zero Dependencies**: Lightweight WASM binary with no external runtimes required.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## π Quick Start
|
|
7
|
+
## Installation
|
|
25
8
|
|
|
26
9
|
```bash
|
|
27
10
|
pnpm add @csszyx/core
|
|
28
11
|
```
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
## Initialization
|
|
31
14
|
|
|
32
15
|
```typescript
|
|
33
|
-
import { init } from
|
|
16
|
+
import { init } from "@csszyx/core";
|
|
34
17
|
|
|
35
|
-
|
|
36
|
-
await init();
|
|
37
|
-
// Core is ready to flow π
|
|
38
|
-
}
|
|
18
|
+
await init();
|
|
39
19
|
```
|
|
40
20
|
|
|
41
|
-
|
|
21
|
+
## Modules
|
|
42
22
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### πΊοΈ Mangle Map Integrity
|
|
23
|
+
### Mangle Map Integrity
|
|
46
24
|
|
|
47
25
|
Deterministic SHA-256 checksums to synchronize server-side class names with client-side hydration.
|
|
48
26
|
|
|
49
27
|
```typescript
|
|
50
|
-
import { compute_mangle_checksum, verify_mangle_checksum } from
|
|
28
|
+
import { compute_mangle_checksum, verify_mangle_checksum } from "@csszyx/core";
|
|
51
29
|
|
|
52
|
-
const mangleMap = {
|
|
30
|
+
const mangleMap = { "p-4": "z", "m-2": "y" };
|
|
53
31
|
const checksum = compute_mangle_checksum(mangleMap);
|
|
54
|
-
//
|
|
32
|
+
// Returns a deterministic 16-char hex hash
|
|
55
33
|
```
|
|
56
34
|
|
|
57
|
-
###
|
|
35
|
+
### Transformer
|
|
58
36
|
|
|
59
|
-
|
|
37
|
+
Converts object-based Tailwind syntax into class strings.
|
|
60
38
|
|
|
61
39
|
```typescript
|
|
62
|
-
import { transform_sz } from
|
|
40
|
+
import { transform_sz } from "@csszyx/core";
|
|
63
41
|
|
|
64
|
-
// Supports: Negatives, Opacity, Nesting, Integers
|
|
65
42
|
transform_sz({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
m: -4,
|
|
44
|
+
bg: "blue-500/20",
|
|
45
|
+
hover: { scale: 110 },
|
|
69
46
|
});
|
|
70
47
|
// "-m-4 bg-blue-500/20 hover:scale-110"
|
|
71
48
|
```
|
|
72
49
|
|
|
73
|
-
###
|
|
50
|
+
### Tiered Encoder
|
|
74
51
|
|
|
75
|
-
|
|
52
|
+
CSS-compliant class name generator using reversed tier encoding (z -> y -> x).
|
|
76
53
|
|
|
77
|
-
| Tier
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
54
|
+
| Tier | Range | Format | Example |
|
|
55
|
+
| :----- | :--------- | :---------------- | :------------ |
|
|
56
|
+
| Tier 1 | 0 - 51 | \[z-aZ-A\] | `z`, `y`, `x` |
|
|
57
|
+
| Tier 2 | 52 - 571 | \[z-aZ-A\]\[9-0\] | `z9`, `y8` |
|
|
58
|
+
| Tier 3 | 572 - 3275 | \[z-aZ-A\]{2} | `zz`, `zy` |
|
|
82
59
|
|
|
83
|
-
###
|
|
60
|
+
### Collision Detector
|
|
84
61
|
|
|
85
62
|
Dual-hash resolution strategy for unique CSS variable names.
|
|
86
63
|
|
|
87
64
|
```typescript
|
|
88
|
-
import { WasmCollisionDetector } from
|
|
65
|
+
import { WasmCollisionDetector } from "@csszyx/core";
|
|
89
66
|
|
|
90
67
|
const detector = new WasmCollisionDetector();
|
|
91
|
-
const varId = detector.add(
|
|
68
|
+
const varId = detector.add("#ff0000"); // "--v-a1b2c3"
|
|
92
69
|
```
|
|
93
70
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
## β‘ Performance Matrix
|
|
97
|
-
|
|
98
|
-
Benchmarks performed on Apple M2 (WASM Node v20 target)
|
|
99
|
-
|
|
100
|
-
| Operation | WASM (Rust) | Pure JS (Legacy) | Improvement |
|
|
101
|
-
| :--- | :--- | :--- | :--- |
|
|
102
|
-
| **Integrity Check** | < 1ms | ~15ms | **15x faster** |
|
|
103
|
-
| **ID Encoding** | ~5ns | ~50ns | **10x faster** |
|
|
104
|
-
| **Token Auth** | ~25ns | ~250ns | **10x faster** |
|
|
105
|
-
| **Transformer** | Optimized | Variable | Stable π |
|
|
71
|
+
## Performance
|
|
106
72
|
|
|
107
|
-
|
|
73
|
+
Benchmarks on Apple M2 (WASM, Node v20):
|
|
108
74
|
|
|
109
|
-
|
|
75
|
+
| Operation | WASM (Rust) | Pure JS | Speedup |
|
|
76
|
+
| :-------------- | :---------- | :------ | :------ |
|
|
77
|
+
| Integrity Check | < 1ms | ~15ms | 15x |
|
|
78
|
+
| ID Encoding | ~5ns | ~50ns | 10x |
|
|
79
|
+
| Token Auth | ~25ns | ~250ns | 10x |
|
|
110
80
|
|
|
111
|
-
##
|
|
81
|
+
## License
|
|
112
82
|
|
|
113
|
-
MIT
|
|
83
|
+
MIT
|
package/package.json
CHANGED
package/pkg/README.md
CHANGED
|
@@ -1,113 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @csszyx/core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<img src="https://img.shields.io/badge/WASM-Powered-624de3?style=for-the-badge&logo=webassembly" alt="WASM Powered" />
|
|
5
|
-
<img src="https://img.shields.io/badge/Rust-Core-dea584?style=for-the-badge&logo=rust" alt="Rust Core" />
|
|
6
|
-
<img src="https://img.shields.io/badge/TypeScript-Ready-3178c6?style=for-the-badge&logo=typescript" alt="TypeScript Ready" />
|
|
7
|
-
</p>
|
|
3
|
+
> Rust/WASM core for csszyx -- encoder, checksum, collision detection, and recovery tokens.
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
Compiled to WebAssembly, this package provides the performance-critical operations for the csszyx ecosystem. It runs in Node.js, browsers, and edge environments.
|
|
10
6
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
`@csszyx/core` is a high-performance, precision-engineered Rust core for the **csszyx** ecosystem. Compiled to WebAssembly, it brings near-native performance to Node.js, Browsers, and Edge environments.
|
|
14
|
-
|
|
15
|
-
### π₯ Why Core?
|
|
16
|
-
|
|
17
|
-
- **Blazing Speed**: Offloads performance-critical operations (Hashing, Transformation, Encoding) to optimized Rust.
|
|
18
|
-
- **Universal Integrity**: Ensures bit-perfect mangle map consistency between SSR and hydration.
|
|
19
|
-
- **Security-First**: Uses SHA-256 and Base62 for tamper-proof tokens and collision-free variable names.
|
|
20
|
-
- **Zero Dependencies**: Lightweight WASM binary with no external runtimes required.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## π Quick Start
|
|
7
|
+
## Installation
|
|
25
8
|
|
|
26
9
|
```bash
|
|
27
10
|
pnpm add @csszyx/core
|
|
28
11
|
```
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
## Initialization
|
|
31
14
|
|
|
32
15
|
```typescript
|
|
33
|
-
import { init } from
|
|
16
|
+
import { init } from "@csszyx/core";
|
|
34
17
|
|
|
35
|
-
|
|
36
|
-
await init();
|
|
37
|
-
// Core is ready to flow π
|
|
38
|
-
}
|
|
18
|
+
await init();
|
|
39
19
|
```
|
|
40
20
|
|
|
41
|
-
|
|
21
|
+
## Modules
|
|
42
22
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### πΊοΈ Mangle Map Integrity
|
|
23
|
+
### Mangle Map Integrity
|
|
46
24
|
|
|
47
25
|
Deterministic SHA-256 checksums to synchronize server-side class names with client-side hydration.
|
|
48
26
|
|
|
49
27
|
```typescript
|
|
50
|
-
import { compute_mangle_checksum, verify_mangle_checksum } from
|
|
28
|
+
import { compute_mangle_checksum, verify_mangle_checksum } from "@csszyx/core";
|
|
51
29
|
|
|
52
|
-
const mangleMap = {
|
|
30
|
+
const mangleMap = { "p-4": "z", "m-2": "y" };
|
|
53
31
|
const checksum = compute_mangle_checksum(mangleMap);
|
|
54
|
-
//
|
|
32
|
+
// Returns a deterministic 16-char hex hash
|
|
55
33
|
```
|
|
56
34
|
|
|
57
|
-
###
|
|
35
|
+
### Transformer
|
|
58
36
|
|
|
59
|
-
|
|
37
|
+
Converts object-based Tailwind syntax into class strings.
|
|
60
38
|
|
|
61
39
|
```typescript
|
|
62
|
-
import { transform_sz } from
|
|
40
|
+
import { transform_sz } from "@csszyx/core";
|
|
63
41
|
|
|
64
|
-
// Supports: Negatives, Opacity, Nesting, Integers
|
|
65
42
|
transform_sz({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
m: -4,
|
|
44
|
+
bg: "blue-500/20",
|
|
45
|
+
hover: { scale: 110 },
|
|
69
46
|
});
|
|
70
47
|
// "-m-4 bg-blue-500/20 hover:scale-110"
|
|
71
48
|
```
|
|
72
49
|
|
|
73
|
-
###
|
|
50
|
+
### Tiered Encoder
|
|
74
51
|
|
|
75
|
-
|
|
52
|
+
CSS-compliant class name generator using reversed tier encoding (z -> y -> x).
|
|
76
53
|
|
|
77
|
-
| Tier
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
54
|
+
| Tier | Range | Format | Example |
|
|
55
|
+
| :----- | :--------- | :---------------- | :------------ |
|
|
56
|
+
| Tier 1 | 0 - 51 | \[z-aZ-A\] | `z`, `y`, `x` |
|
|
57
|
+
| Tier 2 | 52 - 571 | \[z-aZ-A\]\[9-0\] | `z9`, `y8` |
|
|
58
|
+
| Tier 3 | 572 - 3275 | \[z-aZ-A\]{2} | `zz`, `zy` |
|
|
82
59
|
|
|
83
|
-
###
|
|
60
|
+
### Collision Detector
|
|
84
61
|
|
|
85
62
|
Dual-hash resolution strategy for unique CSS variable names.
|
|
86
63
|
|
|
87
64
|
```typescript
|
|
88
|
-
import { WasmCollisionDetector } from
|
|
65
|
+
import { WasmCollisionDetector } from "@csszyx/core";
|
|
89
66
|
|
|
90
67
|
const detector = new WasmCollisionDetector();
|
|
91
|
-
const varId = detector.add(
|
|
68
|
+
const varId = detector.add("#ff0000"); // "--v-a1b2c3"
|
|
92
69
|
```
|
|
93
70
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
## β‘ Performance Matrix
|
|
97
|
-
|
|
98
|
-
Benchmarks performed on Apple M2 (WASM Node v20 target)
|
|
99
|
-
|
|
100
|
-
| Operation | WASM (Rust) | Pure JS (Legacy) | Improvement |
|
|
101
|
-
| :--- | :--- | :--- | :--- |
|
|
102
|
-
| **Integrity Check** | < 1ms | ~15ms | **15x faster** |
|
|
103
|
-
| **ID Encoding** | ~5ns | ~50ns | **10x faster** |
|
|
104
|
-
| **Token Auth** | ~25ns | ~250ns | **10x faster** |
|
|
105
|
-
| **Transformer** | Optimized | Variable | Stable π |
|
|
71
|
+
## Performance
|
|
106
72
|
|
|
107
|
-
|
|
73
|
+
Benchmarks on Apple M2 (WASM, Node v20):
|
|
108
74
|
|
|
109
|
-
|
|
75
|
+
| Operation | WASM (Rust) | Pure JS | Speedup |
|
|
76
|
+
| :-------------- | :---------- | :------ | :------ |
|
|
77
|
+
| Integrity Check | < 1ms | ~15ms | 15x |
|
|
78
|
+
| ID Encoding | ~5ns | ~50ns | 10x |
|
|
79
|
+
| Token Auth | ~25ns | ~250ns | 10x |
|
|
110
80
|
|
|
111
|
-
##
|
|
81
|
+
## License
|
|
112
82
|
|
|
113
|
-
MIT
|
|
83
|
+
MIT
|
package/pkg/csszyx_core_bg.wasm
CHANGED
|
Binary file
|
package/pkg-node/README.md
CHANGED
|
@@ -1,113 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @csszyx/core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<img src="https://img.shields.io/badge/WASM-Powered-624de3?style=for-the-badge&logo=webassembly" alt="WASM Powered" />
|
|
5
|
-
<img src="https://img.shields.io/badge/Rust-Core-dea584?style=for-the-badge&logo=rust" alt="Rust Core" />
|
|
6
|
-
<img src="https://img.shields.io/badge/TypeScript-Ready-3178c6?style=for-the-badge&logo=typescript" alt="TypeScript Ready" />
|
|
7
|
-
</p>
|
|
3
|
+
> Rust/WASM core for csszyx -- encoder, checksum, collision detection, and recovery tokens.
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
Compiled to WebAssembly, this package provides the performance-critical operations for the csszyx ecosystem. It runs in Node.js, browsers, and edge environments.
|
|
10
6
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
`@csszyx/core` is a high-performance, precision-engineered Rust core for the **csszyx** ecosystem. Compiled to WebAssembly, it brings near-native performance to Node.js, Browsers, and Edge environments.
|
|
14
|
-
|
|
15
|
-
### π₯ Why Core?
|
|
16
|
-
|
|
17
|
-
- **Blazing Speed**: Offloads performance-critical operations (Hashing, Transformation, Encoding) to optimized Rust.
|
|
18
|
-
- **Universal Integrity**: Ensures bit-perfect mangle map consistency between SSR and hydration.
|
|
19
|
-
- **Security-First**: Uses SHA-256 and Base62 for tamper-proof tokens and collision-free variable names.
|
|
20
|
-
- **Zero Dependencies**: Lightweight WASM binary with no external runtimes required.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## π Quick Start
|
|
7
|
+
## Installation
|
|
25
8
|
|
|
26
9
|
```bash
|
|
27
10
|
pnpm add @csszyx/core
|
|
28
11
|
```
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
## Initialization
|
|
31
14
|
|
|
32
15
|
```typescript
|
|
33
|
-
import { init } from
|
|
16
|
+
import { init } from "@csszyx/core";
|
|
34
17
|
|
|
35
|
-
|
|
36
|
-
await init();
|
|
37
|
-
// Core is ready to flow π
|
|
38
|
-
}
|
|
18
|
+
await init();
|
|
39
19
|
```
|
|
40
20
|
|
|
41
|
-
|
|
21
|
+
## Modules
|
|
42
22
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### πΊοΈ Mangle Map Integrity
|
|
23
|
+
### Mangle Map Integrity
|
|
46
24
|
|
|
47
25
|
Deterministic SHA-256 checksums to synchronize server-side class names with client-side hydration.
|
|
48
26
|
|
|
49
27
|
```typescript
|
|
50
|
-
import { compute_mangle_checksum, verify_mangle_checksum } from
|
|
28
|
+
import { compute_mangle_checksum, verify_mangle_checksum } from "@csszyx/core";
|
|
51
29
|
|
|
52
|
-
const mangleMap = {
|
|
30
|
+
const mangleMap = { "p-4": "z", "m-2": "y" };
|
|
53
31
|
const checksum = compute_mangle_checksum(mangleMap);
|
|
54
|
-
//
|
|
32
|
+
// Returns a deterministic 16-char hex hash
|
|
55
33
|
```
|
|
56
34
|
|
|
57
|
-
###
|
|
35
|
+
### Transformer
|
|
58
36
|
|
|
59
|
-
|
|
37
|
+
Converts object-based Tailwind syntax into class strings.
|
|
60
38
|
|
|
61
39
|
```typescript
|
|
62
|
-
import { transform_sz } from
|
|
40
|
+
import { transform_sz } from "@csszyx/core";
|
|
63
41
|
|
|
64
|
-
// Supports: Negatives, Opacity, Nesting, Integers
|
|
65
42
|
transform_sz({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
m: -4,
|
|
44
|
+
bg: "blue-500/20",
|
|
45
|
+
hover: { scale: 110 },
|
|
69
46
|
});
|
|
70
47
|
// "-m-4 bg-blue-500/20 hover:scale-110"
|
|
71
48
|
```
|
|
72
49
|
|
|
73
|
-
###
|
|
50
|
+
### Tiered Encoder
|
|
74
51
|
|
|
75
|
-
|
|
52
|
+
CSS-compliant class name generator using reversed tier encoding (z -> y -> x).
|
|
76
53
|
|
|
77
|
-
| Tier
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
54
|
+
| Tier | Range | Format | Example |
|
|
55
|
+
| :----- | :--------- | :---------------- | :------------ |
|
|
56
|
+
| Tier 1 | 0 - 51 | \[z-aZ-A\] | `z`, `y`, `x` |
|
|
57
|
+
| Tier 2 | 52 - 571 | \[z-aZ-A\]\[9-0\] | `z9`, `y8` |
|
|
58
|
+
| Tier 3 | 572 - 3275 | \[z-aZ-A\]{2} | `zz`, `zy` |
|
|
82
59
|
|
|
83
|
-
###
|
|
60
|
+
### Collision Detector
|
|
84
61
|
|
|
85
62
|
Dual-hash resolution strategy for unique CSS variable names.
|
|
86
63
|
|
|
87
64
|
```typescript
|
|
88
|
-
import { WasmCollisionDetector } from
|
|
65
|
+
import { WasmCollisionDetector } from "@csszyx/core";
|
|
89
66
|
|
|
90
67
|
const detector = new WasmCollisionDetector();
|
|
91
|
-
const varId = detector.add(
|
|
68
|
+
const varId = detector.add("#ff0000"); // "--v-a1b2c3"
|
|
92
69
|
```
|
|
93
70
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
## β‘ Performance Matrix
|
|
97
|
-
|
|
98
|
-
Benchmarks performed on Apple M2 (WASM Node v20 target)
|
|
99
|
-
|
|
100
|
-
| Operation | WASM (Rust) | Pure JS (Legacy) | Improvement |
|
|
101
|
-
| :--- | :--- | :--- | :--- |
|
|
102
|
-
| **Integrity Check** | < 1ms | ~15ms | **15x faster** |
|
|
103
|
-
| **ID Encoding** | ~5ns | ~50ns | **10x faster** |
|
|
104
|
-
| **Token Auth** | ~25ns | ~250ns | **10x faster** |
|
|
105
|
-
| **Transformer** | Optimized | Variable | Stable π |
|
|
71
|
+
## Performance
|
|
106
72
|
|
|
107
|
-
|
|
73
|
+
Benchmarks on Apple M2 (WASM, Node v20):
|
|
108
74
|
|
|
109
|
-
|
|
75
|
+
| Operation | WASM (Rust) | Pure JS | Speedup |
|
|
76
|
+
| :-------------- | :---------- | :------ | :------ |
|
|
77
|
+
| Integrity Check | < 1ms | ~15ms | 15x |
|
|
78
|
+
| ID Encoding | ~5ns | ~50ns | 10x |
|
|
79
|
+
| Token Auth | ~25ns | ~250ns | 10x |
|
|
110
80
|
|
|
111
|
-
##
|
|
81
|
+
## License
|
|
112
82
|
|
|
113
|
-
MIT
|
|
83
|
+
MIT
|
|
Binary file
|