css-in-js-engine-pb 0.2.3 → 0.2.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insertWithBucket.d.ts","sourceRoot":"","sources":["../src/insertWithBucket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"insertWithBucket.d.ts","sourceRoot":"","sources":["../src/insertWithBucket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAoC5C,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,QAgDzE"}
|
package/dist/insertWithBucket.js
CHANGED
|
@@ -14,6 +14,7 @@ const ORDER = [
|
|
|
14
14
|
];
|
|
15
15
|
const OPTIONAL_BUCKETS = [
|
|
16
16
|
StyleBucket.Base,
|
|
17
|
+
StyleBucket.Appearance,
|
|
17
18
|
StyleBucket.Size,
|
|
18
19
|
StyleBucket.Shape,
|
|
19
20
|
StyleBucket.State,
|
|
@@ -47,8 +48,6 @@ export function insertRulesWithBucket(rules, bucket) {
|
|
|
47
48
|
console.groupEnd();
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
|
-
// Don’t insert beyond unseen required buckets
|
|
51
|
-
// (Reset + Appearance are required; Base/Size/Shape/State/Focus/User are optional via pre-seed)
|
|
52
51
|
for (let i = 0; i <= targetIndex; i++) {
|
|
53
52
|
if (!seenBuckets.has(ORDER[i])) {
|
|
54
53
|
console.log(`⛔ blocked at ${bucketName(ORDER[i])} (not seen yet)`);
|
|
@@ -56,8 +55,6 @@ export function insertRulesWithBucket(rules, bucket) {
|
|
|
56
55
|
return;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
// Insert buckets in order up to targetIndex.
|
|
60
|
-
// IMPORTANT: we do NOT “flush forever”. We may insert more later.
|
|
61
58
|
for (let i = 0; i <= targetIndex; i++) {
|
|
62
59
|
const b = ORDER[i];
|
|
63
60
|
const r = bucketRules.get(b);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveStyleRules.d.ts","sourceRoot":"","sources":["../src/resolveStyleRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveStyleRules.d.ts","sourceRoot":"","sources":["../src/resolveStyleRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmDhD,wBAAgB,yBAAyB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACnE,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,EACnC,WAAW,CAAC,EAAE,eAAe,GAC9B,aAAa,CAAC,KAAK,CAAC,CAetB"}
|
|
@@ -1,49 +1,32 @@
|
|
|
1
1
|
import { camelToKebab, resolveValue } from './utils/css';
|
|
2
2
|
import { AtomicRuleCache } from './atomicCache';
|
|
3
|
-
function buildAtomicClasses(rule, cache, cssRulesOut, atRule
|
|
3
|
+
function buildAtomicClasses(rule, cache, cssRulesOut, atRule) {
|
|
4
4
|
const classNames = [];
|
|
5
5
|
for (const key in rule) {
|
|
6
6
|
const val = rule[key];
|
|
7
7
|
if (val == null)
|
|
8
8
|
continue;
|
|
9
|
-
// --- at-rules (@media, @supports, etc.)
|
|
10
9
|
if (key.startsWith('@') && typeof val === 'object') {
|
|
11
|
-
const nested = buildAtomicClasses(val, cache, cssRulesOut, key
|
|
10
|
+
const nested = buildAtomicClasses(val, cache, cssRulesOut, key);
|
|
12
11
|
classNames.push(...nested);
|
|
13
12
|
continue;
|
|
14
13
|
}
|
|
15
|
-
// --- pseudo selectors (:hover, :active, etc.)
|
|
16
14
|
if (key.startsWith(':') && typeof val === 'object') {
|
|
17
|
-
const selector = `&${key}`;
|
|
18
15
|
for (const prop in val) {
|
|
19
16
|
const v = val[prop];
|
|
20
17
|
if (v == null || typeof v === 'object')
|
|
21
18
|
continue;
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
// 👇 LAST ONE WINS — drop earlier declarations
|
|
25
|
-
if (seenDecls.has(declKey))
|
|
26
|
-
continue;
|
|
27
|
-
seenDecls.add(declKey);
|
|
28
|
-
const decl = `${cssProp}:${resolveValue(v)}`;
|
|
29
|
-
const res = cache.getOrCreate(selector, decl, atRule);
|
|
19
|
+
const decl = `${camelToKebab(prop)}:${resolveValue(v)}`;
|
|
20
|
+
const res = cache.getOrCreate(`&${key}`, decl, atRule);
|
|
30
21
|
classNames.push(res.className);
|
|
31
22
|
if (res.ruleText)
|
|
32
23
|
cssRulesOut.push(res.ruleText);
|
|
33
24
|
}
|
|
34
25
|
continue;
|
|
35
26
|
}
|
|
36
|
-
// --- normal properties
|
|
37
27
|
if (typeof val !== 'object') {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const declKey = `${atRule !== null && atRule !== void 0 ? atRule : ''}|${selector}|${cssProp}`;
|
|
41
|
-
// 👇 LAST ONE WINS — drop earlier declarations
|
|
42
|
-
if (seenDecls.has(declKey))
|
|
43
|
-
continue;
|
|
44
|
-
seenDecls.add(declKey);
|
|
45
|
-
const decl = `${cssProp}:${resolveValue(val)}`;
|
|
46
|
-
const res = cache.getOrCreate(selector, decl, atRule);
|
|
28
|
+
const decl = `${camelToKebab(key)}:${resolveValue(val)}`;
|
|
29
|
+
const res = cache.getOrCreate('&', decl, atRule);
|
|
47
30
|
classNames.push(res.className);
|
|
48
31
|
if (res.ruleText)
|
|
49
32
|
cssRulesOut.push(res.ruleText);
|
|
@@ -57,9 +40,7 @@ export function resolveStyleRulesForSlots(stylesBySlots, sharedCache) {
|
|
|
57
40
|
const classNamesBySlot = {};
|
|
58
41
|
for (const slot in stylesBySlots) {
|
|
59
42
|
const rule = stylesBySlots[slot];
|
|
60
|
-
|
|
61
|
-
const seenDecls = new Set();
|
|
62
|
-
const atomicClasses = buildAtomicClasses(rule !== null && rule !== void 0 ? rule : {}, cache, cssRules, undefined, seenDecls);
|
|
43
|
+
const atomicClasses = buildAtomicClasses(rule !== null && rule !== void 0 ? rule : {}, cache, cssRules);
|
|
63
44
|
classNamesBySlot[slot] = atomicClasses.join(' ');
|
|
64
45
|
}
|
|
65
46
|
return { classNamesBySlot, cssRules };
|