@gtkx/css 0.17.3 → 0.18.1

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.
@@ -12,9 +12,11 @@ export declare class StyleSheet {
12
12
  private display;
13
13
  private isRegistered;
14
14
  private hasPendingRules;
15
+ private updateScheduled;
15
16
  constructor(options: StyleSheetOptions);
16
17
  private ensureProvider;
17
18
  private updateProvider;
19
+ private scheduleUpdate;
18
20
  insert(rule: string): void;
19
21
  applyQueuedRules(): void;
20
22
  flush(): void;
@@ -12,7 +12,7 @@ const flushPendingStyles = () => {
12
12
  const registerStartListener = () => {
13
13
  events.once("start", flushPendingStyles);
14
14
  };
15
- if (!isStarted) {
15
+ if (!isStarted()) {
16
16
  registerStartListener();
17
17
  }
18
18
  export class StyleSheet {
@@ -22,6 +22,7 @@ export class StyleSheet {
22
22
  display = null;
23
23
  isRegistered = false;
24
24
  hasPendingRules = false;
25
+ updateScheduled = false;
25
26
  constructor(options) {
26
27
  this.key = options.key;
27
28
  }
@@ -41,11 +42,20 @@ export class StyleSheet {
41
42
  this.provider.loadFromString(css);
42
43
  }
43
44
  }
44
- insert(rule) {
45
- this.rules.push(rule);
46
- if (isStarted) {
45
+ scheduleUpdate() {
46
+ if (this.updateScheduled)
47
+ return;
48
+ this.updateScheduled = true;
49
+ queueMicrotask(() => {
50
+ this.updateScheduled = false;
47
51
  this.ensureProvider();
48
52
  this.updateProvider();
53
+ });
54
+ }
55
+ insert(rule) {
56
+ this.rules.push(rule);
57
+ if (isStarted()) {
58
+ this.scheduleUpdate();
49
59
  }
50
60
  else if (!this.hasPendingRules) {
51
61
  this.hasPendingRules = true;
@@ -68,6 +78,7 @@ export class StyleSheet {
68
78
  this.provider = null;
69
79
  this.display = null;
70
80
  this.hasPendingRules = false;
81
+ this.updateScheduled = false;
71
82
  }
72
83
  hydrate(_elements) { }
73
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/css",
3
- "version": "0.17.3",
3
+ "version": "0.18.1",
4
4
  "description": "Emotion-based CSS-in-JS for GTKX applications",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -39,10 +39,10 @@
39
39
  "dependencies": {
40
40
  "@emotion/cache": "^11.14.0",
41
41
  "@emotion/serialize": "^1.3.3",
42
- "@gtkx/ffi": "0.17.3"
42
+ "@gtkx/ffi": "0.18.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@gtkx/vitest": "0.17.3"
45
+ "@gtkx/vitest": "0.18.1"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsc -b && cp ../../README.md .",