chartgpu 0.1.4 → 0.1.5

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.
@@ -54,11 +54,10 @@ export declare function startRenderScheduler(state: RenderSchedulerState, callba
54
54
  */
55
55
  export declare function stopRenderScheduler(state: RenderSchedulerState): RenderSchedulerState;
56
56
  /**
57
- * Marks the current frame as dirty, indicating it needs to be rendered.
57
+ * Marks the current frame as dirty and schedules a render if idle.
58
58
  *
59
- * This function is prepared for future optimization where frames can be
60
- * skipped if nothing has changed. Currently, all frames render regardless
61
- * of the dirty flag.
59
+ * This function implements render-on-demand: it schedules a frame when the
60
+ * scheduler is idle. Multiple calls coalesce into a single frame.
62
61
  *
63
62
  * @param state - The scheduler state
64
63
  * @throws {Error} If state is invalid
@@ -1 +1 @@
1
- {"version":3,"file":"RenderScheduler.d.ts","sourceRoot":"","sources":["../../src/core/RenderScheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAmBD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CAgB5D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,cAAc,GACvB,oBAAoB,CAyDtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,CAkBrF;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAQ/D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB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BAAoB,CAoBxF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,cAAc,GAAG,oBAAoB,CAGzF;AAED;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAuB;IAErC;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;;IAKH;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAIrC;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,aAAa,IAAI,IAAI;IAIrB;;;OAGG;IACH,OAAO,IAAI,IAAI;CAGhB"}
package/dist/index.js CHANGED
@@ -6940,7 +6940,8 @@ function qr() {
6940
6940
  rafId: null,
6941
6941
  callback: null,
6942
6942
  lastFrameTime: 0,
6943
- dirty: !1
6943
+ dirty: !1,
6944
+ frameHandler: null
6944
6945
  }), t;
6945
6946
  }
6946
6947
  function $s(e, t) {
@@ -6956,12 +6957,16 @@ function $s(e, t) {
6956
6957
  const o = Wt.get(r);
6957
6958
  if (!o || !o.callback)
6958
6959
  return;
6959
- const l = s - o.lastFrameTime;
6960
- o.lastFrameTime = s, o.dirty && (o.dirty = !1), o.callback(l);
6961
- const c = Wt.get(r);
6962
- c && c.callback && (c.rafId = requestAnimationFrame(i));
6960
+ o.rafId = null;
6961
+ let l = s - o.lastFrameTime;
6962
+ const c = 100;
6963
+ if (l > c && (l = c), o.lastFrameTime = s, o.dirty) {
6964
+ o.dirty = !1, o.callback(l);
6965
+ const f = Wt.get(r);
6966
+ f && f.callback && f.dirty && (f.rafId = requestAnimationFrame(i));
6967
+ }
6963
6968
  };
6964
- return n.rafId = requestAnimationFrame(i), {
6969
+ return n.frameHandler = i, n.rafId = requestAnimationFrame(i), {
6965
6970
  id: e.id,
6966
6971
  running: !0
6967
6972
  };
@@ -6970,7 +6975,7 @@ function ru(e) {
6970
6975
  const t = Wt.get(e.id);
6971
6976
  if (!t)
6972
6977
  throw new Error("Invalid scheduler state. Use createRenderScheduler() to create a new state.");
6973
- return t.callback = null, t.rafId !== null && (cancelAnimationFrame(t.rafId), t.rafId = null), {
6978
+ return t.callback = null, t.frameHandler = null, t.rafId !== null && (cancelAnimationFrame(t.rafId), t.rafId = null), {
6974
6979
  id: e.id,
6975
6980
  running: !1
6976
6981
  };
@@ -6979,11 +6984,11 @@ function iu(e) {
6979
6984
  const t = Wt.get(e.id);
6980
6985
  if (!t)
6981
6986
  throw new Error("Invalid scheduler state. Use createRenderScheduler() to create a new state.");
6982
- t.dirty = !0;
6987
+ t.dirty = !0, t.callback !== null && t.rafId === null && (t.lastFrameTime = performance.now(), t.frameHandler && (t.rafId = requestAnimationFrame(t.frameHandler)));
6983
6988
  }
6984
6989
  function su(e) {
6985
6990
  const t = Wt.get(e.id);
6986
- return t && (t.rafId !== null && (cancelAnimationFrame(t.rafId), t.rafId = null), t.callback = null, Wt.delete(e.id)), qr();
6991
+ return t && (t.rafId !== null && (cancelAnimationFrame(t.rafId), t.rafId = null), t.callback = null, t.frameHandler = null, Wt.delete(e.id)), qr();
6987
6992
  }
6988
6993
  function xu(e) {
6989
6994
  const t = qr();