grist-widget-sdk 0.2.1 → 0.2.15

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.
@@ -2,7 +2,7 @@ import {
2
2
  resetEmbeddedHandshakeManagerForTests,
3
3
  resetGristEventsForTests,
4
4
  resetGristReadyCacheForTests
5
- } from "../chunk-XE2SKNLH.js";
5
+ } from "../chunk-KOVYBNPJ.js";
6
6
  import {
7
7
  createGristEmulator,
8
8
  presets
package/dist/index.cjs CHANGED
@@ -2771,14 +2771,24 @@ var ACCESS_RANK2 = {
2771
2771
  };
2772
2772
  var inFlight2 = null;
2773
2773
  var lastAccess = null;
2774
- function shouldReinit(next) {
2774
+ var lastColumnNames = null;
2775
+ function columnNamesOf(columns) {
2776
+ return new Set((columns ?? []).map((c) => typeof c === "string" ? c : c.name));
2777
+ }
2778
+ function shouldReinit(next, nextColumns) {
2775
2779
  if (!lastAccess) return true;
2776
- return ACCESS_RANK2[next] > ACCESS_RANK2[lastAccess];
2780
+ if (ACCESS_RANK2[next] > ACCESS_RANK2[lastAccess]) return true;
2781
+ for (const name of nextColumns) {
2782
+ if (!lastColumnNames?.has(name)) return true;
2783
+ }
2784
+ return false;
2777
2785
  }
2778
2786
  function ensureGristReady(payload) {
2779
2787
  const access = payload.requiredAccess ?? "read table";
2780
- if (inFlight2 && !shouldReinit(access)) return inFlight2;
2788
+ const columns = columnNamesOf(payload.columns);
2789
+ if (inFlight2 && !shouldReinit(access, columns)) return inFlight2;
2781
2790
  lastAccess = access;
2791
+ lastColumnNames = columns;
2782
2792
  const next = Promise.resolve().then(() => {
2783
2793
  const result = grist.ready(payload);
2784
2794
  return result instanceof Promise ? result : Promise.resolve();
@@ -2786,6 +2796,7 @@ function ensureGristReady(payload) {
2786
2796
  inFlight2 = next.catch((err) => {
2787
2797
  inFlight2 = null;
2788
2798
  lastAccess = null;
2799
+ lastColumnNames = null;
2789
2800
  throw err;
2790
2801
  });
2791
2802
  return inFlight2;
@@ -2793,6 +2804,7 @@ function ensureGristReady(payload) {
2793
2804
  function resetGristReadySingleton() {
2794
2805
  inFlight2 = null;
2795
2806
  lastAccess = null;
2807
+ lastColumnNames = null;
2796
2808
  }
2797
2809
 
2798
2810
  // src/sdk/internal/build-manager-options.ts