css-in-js-engine-pb 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.
@@ -1 +1 @@
1
- {"version":3,"file":"insertWithBucket.d.ts","sourceRoot":"","sources":["../src/insertWithBucket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,WAAW,QAqBtB"}
1
+ {"version":3,"file":"insertWithBucket.d.ts","sourceRoot":"","sources":["../src/insertWithBucket.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAiB5C,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,WAAW,QAwBtB"}
@@ -1,8 +1,8 @@
1
1
  import { insertRulesOnce } from './insertOnce';
2
2
  import { StyleBucket } from './StyleBucket';
3
- const bucketedRules = new Map();
4
- const flushedBuckets = new Set();
5
- const orderedBuckets = [
3
+ const bucketRules = new Map();
4
+ let highestFlushedBucket = -1;
5
+ const ORDER = [
6
6
  StyleBucket.Reset,
7
7
  StyleBucket.Base,
8
8
  StyleBucket.Appearance,
@@ -15,21 +15,22 @@ const orderedBuckets = [
15
15
  export function insertRulesWithBucket(rules, bucket) {
16
16
  if (!rules.length)
17
17
  return;
18
- const existing = bucketedRules.get(bucket);
18
+ const existing = bucketRules.get(bucket);
19
19
  if (existing) {
20
20
  existing.push(...rules);
21
21
  }
22
22
  else {
23
- bucketedRules.set(bucket, [...rules]);
23
+ bucketRules.set(bucket, [...rules]);
24
24
  }
25
- for (const b of orderedBuckets) {
26
- if (flushedBuckets.has(b))
27
- continue;
28
- const bucketRules = bucketedRules.get(b);
29
- if (bucketRules && bucketRules.length) {
30
- insertRulesOnce(bucketRules);
31
- bucketedRules.set(b, []);
32
- flushedBuckets.add(b);
25
+ const bucketIndex = ORDER.indexOf(bucket);
26
+ // Flush all buckets up to this one
27
+ for (let i = highestFlushedBucket + 1; i <= bucketIndex; i++) {
28
+ const b = ORDER[i];
29
+ const r = bucketRules.get(b);
30
+ if (r && r.length) {
31
+ insertRulesOnce(r);
32
+ bucketRules.set(b, []);
33
33
  }
34
34
  }
35
+ highestFlushedBucket = Math.max(highestFlushedBucket, bucketIndex);
35
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-in-js-engine-pb",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A lightweight atomic CSS-in-JS engine built on the native CSS cascade",
5
5
  "license": "MIT",
6
6
  "type": "module",