css-in-js-engine-pb 0.1.7 → 0.1.8
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;AAqB5C,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,
|
|
@@ -19,26 +20,36 @@ function bucketName(bucket) {
|
|
|
19
20
|
export function insertRulesWithBucket(rules, bucket) {
|
|
20
21
|
console.groupCollapsed(`[STYLE] insertRulesWithBucket → ${bucketName(bucket)}`);
|
|
21
22
|
console.log('incoming rules.length:', rules.length);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.groupEnd();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
23
|
+
// mark bucket as seen
|
|
24
|
+
seenBuckets.add(bucket);
|
|
27
25
|
// collect rules
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
existing
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
if (rules.length) {
|
|
27
|
+
const existing = bucketRules.get(bucket);
|
|
28
|
+
if (existing) {
|
|
29
|
+
existing.push(...rules);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
bucketRules.set(bucket, [...rules]);
|
|
33
|
+
}
|
|
34
34
|
}
|
|
35
35
|
console.log('bucketRules:', Array.from(bucketRules.entries()).map(([b, r]) => `${bucketName(b)}=${r.length}`));
|
|
36
|
-
|
|
36
|
+
console.log('seenBuckets:', Array.from(seenBuckets).map(bucketName));
|
|
37
|
+
// try flushing in strict ORDER
|
|
37
38
|
for (const b of ORDER) {
|
|
38
39
|
if (flushedBuckets.has(b)) {
|
|
39
40
|
console.log(`⏭ ${bucketName(b)} already flushed`);
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
43
|
+
// 🚨 critical guard
|
|
44
|
+
// do NOT flush if an earlier bucket has not been seen yet
|
|
45
|
+
const bIndex = ORDER.indexOf(b);
|
|
46
|
+
const hasUnseenEarlier = ORDER
|
|
47
|
+
.slice(0, bIndex)
|
|
48
|
+
.some(prev => !seenBuckets.has(prev));
|
|
49
|
+
if (hasUnseenEarlier) {
|
|
50
|
+
console.log(`⛔ ${bucketName(b)} blocked (earlier bucket not seen yet)`);
|
|
51
|
+
break; // cannot flush further
|
|
52
|
+
}
|
|
42
53
|
const r = bucketRules.get(b);
|
|
43
54
|
if (!r || r.length === 0) {
|
|
44
55
|
console.log(`⏳ ${bucketName(b)} has no rules yet`);
|