@kodiak-finance/orderly-hooks 2.8.4 → 2.8.6

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.
package/dist/index.mjs CHANGED
@@ -3171,6 +3171,20 @@ var CalculatorService = class {
3171
3171
  this.referenceCount = /* @__PURE__ */ new Map();
3172
3172
  this.isPaused = false;
3173
3173
  this.calculators = new Map(calculators);
3174
+ this.bindVisibilityListener();
3175
+ }
3176
+ bindVisibilityListener() {
3177
+ if (typeof document !== "undefined") {
3178
+ this.visibilityListener = () => {
3179
+ if (document.visibilityState === "visible") {
3180
+ this.onTabBecomeVisible();
3181
+ }
3182
+ };
3183
+ document.addEventListener("visibilitychange", this.visibilityListener);
3184
+ }
3185
+ }
3186
+ onTabBecomeVisible() {
3187
+ this.calcQueue = [];
3174
3188
  }
3175
3189
  register(scope, calculator) {
3176
3190
  const ref_count_name = `${scope}_${calculator.name}`;
@@ -3247,6 +3261,9 @@ var CalculatorService = class {
3247
3261
  stop() {
3248
3262
  this.calcQueue = [];
3249
3263
  this.ctx?.clearCache();
3264
+ if (this.visibilityListener && typeof document !== "undefined") {
3265
+ document.removeEventListener("visibilitychange", this.visibilityListener);
3266
+ }
3250
3267
  }
3251
3268
  get windowIsVisible() {
3252
3269
  if (typeof document === "undefined") {