css-in-js-engine-pb 0.1.7 → 0.1.9
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,CACjC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,WAAW,QAuEtB"}
|
package/dist/insertWithBucket.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { insertRulesOnce } from './insertOnce';
|
|
2
2
|
import { StyleBucket } from './StyleBucket';
|
|
3
3
|
const bucketRules = new Map();
|
|
4
|
+
const seenBuckets = new Set();
|
|
4
5
|
const flushedBuckets = new Set();
|
|
5
6
|
const ORDER = [
|
|
6
7
|
StyleBucket.Reset,
|
|
@@ -12,6 +13,19 @@ const ORDER = [
|
|
|
12
13
|
StyleBucket.Focus,
|
|
13
14
|
StyleBucket.User,
|
|
14
15
|
];
|
|
16
|
+
// Buckets that should NOT block ordering if unused
|
|
17
|
+
const OPTIONAL_BUCKETS = [
|
|
18
|
+
StyleBucket.Base,
|
|
19
|
+
StyleBucket.Size,
|
|
20
|
+
StyleBucket.Shape,
|
|
21
|
+
StyleBucket.State,
|
|
22
|
+
StyleBucket.Focus,
|
|
23
|
+
StyleBucket.User,
|
|
24
|
+
];
|
|
25
|
+
// Mark optional buckets as seen by default
|
|
26
|
+
for (const b of OPTIONAL_BUCKETS) {
|
|
27
|
+
seenBuckets.add(b);
|
|
28
|
+
}
|
|
15
29
|
function bucketName(bucket) {
|
|
16
30
|
var _a;
|
|
17
31
|
return (_a = StyleBucket[bucket]) !== null && _a !== void 0 ? _a : `UNKNOWN(${bucket})`;
|
|
@@ -19,26 +33,36 @@ function bucketName(bucket) {
|
|
|
19
33
|
export function insertRulesWithBucket(rules, bucket) {
|
|
20
34
|
console.groupCollapsed(`[STYLE] insertRulesWithBucket → ${bucketName(bucket)}`);
|
|
21
35
|
console.log('incoming rules.length:', rules.length);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.groupEnd();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
36
|
+
// mark bucket as seen
|
|
37
|
+
seenBuckets.add(bucket);
|
|
27
38
|
// collect rules
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
existing
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
if (rules.length) {
|
|
40
|
+
const existing = bucketRules.get(bucket);
|
|
41
|
+
if (existing) {
|
|
42
|
+
existing.push(...rules);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
bucketRules.set(bucket, [...rules]);
|
|
46
|
+
}
|
|
34
47
|
}
|
|
35
48
|
console.log('bucketRules:', Array.from(bucketRules.entries()).map(([b, r]) => `${bucketName(b)}=${r.length}`));
|
|
36
|
-
|
|
49
|
+
console.log('seenBuckets:', Array.from(seenBuckets).map(bucketName));
|
|
50
|
+
// try flushing in strict ORDER
|
|
37
51
|
for (const b of ORDER) {
|
|
38
52
|
if (flushedBuckets.has(b)) {
|
|
39
53
|
console.log(`⏭ ${bucketName(b)} already flushed`);
|
|
40
54
|
continue;
|
|
41
55
|
}
|
|
56
|
+
// 🚨 critical guard
|
|
57
|
+
// do NOT flush if an earlier bucket has not been seen yet
|
|
58
|
+
const bIndex = ORDER.indexOf(b);
|
|
59
|
+
const hasUnseenEarlier = ORDER
|
|
60
|
+
.slice(0, bIndex)
|
|
61
|
+
.some(prev => !seenBuckets.has(prev));
|
|
62
|
+
if (hasUnseenEarlier) {
|
|
63
|
+
console.log(`⛔ ${bucketName(b)} blocked (earlier bucket not seen yet)`);
|
|
64
|
+
break; // cannot flush further
|
|
65
|
+
}
|
|
42
66
|
const r = bucketRules.get(b);
|
|
43
67
|
if (!r || r.length === 0) {
|
|
44
68
|
console.log(`⏳ ${bucketName(b)} has no rules yet`);
|