@ethisyscore/plugin-ui 1.111.0 → 1.112.0

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.
@@ -27,6 +27,7 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
+ var reactQuery__namespace = /*#__PURE__*/_interopNamespace(reactQuery);
30
31
  var extensionRuntime__namespace = /*#__PURE__*/_interopNamespace(extensionRuntime);
31
32
 
32
33
  // src/platform-react/definePlatformReactPluginPage.tsx
@@ -109,6 +110,39 @@ function createPluginQueryClient(config) {
109
110
  }
110
111
  });
111
112
  }
113
+
114
+ // src/platform-react/hostQueryClient.ts
115
+ var hostRealmExposesContext = isReactContext(reactQuery__namespace.QueryClientContext);
116
+ var resolvedHostContext = hostRealmExposesContext ? reactQuery__namespace.QueryClientContext : react.createContext(void 0);
117
+ function isReactContext(value) {
118
+ return typeof value === "object" && value !== null && "Provider" in value;
119
+ }
120
+ var bundleQueryClient;
121
+ function pluginBundleQueryClient() {
122
+ bundleQueryClient ??= createPluginQueryClient();
123
+ return bundleQueryClient;
124
+ }
125
+ var warnedAboutMissingHostClient = false;
126
+ function warnOnceAboutMissingHostClient() {
127
+ if (warnedAboutMissingHostClient) {
128
+ return;
129
+ }
130
+ warnedAboutMissingHostClient = true;
131
+ console.warn(
132
+ "[plugin-ui] The host realm provides no QueryClient" + (hostRealmExposesContext ? " (@tanstack/react-query is served, but this surface renders outside the host's QueryClientProvider)" : " (the host's @tanstack/react-query namespace has no QueryClientContext export)") + ". This surface falls back to a client of its own, so a mutation here will not invalidate another surface's cache. Deploy a host that mounts plugin surfaces inside its QueryClientProvider to share one cache."
133
+ );
134
+ }
135
+ function useSurfaceQueryClient(override) {
136
+ const hostQueryClient = react.useContext(resolvedHostContext);
137
+ if (override !== void 0) {
138
+ return override;
139
+ }
140
+ if (hostQueryClient !== void 0) {
141
+ return hostQueryClient;
142
+ }
143
+ warnOnceAboutMissingHostClient();
144
+ return pluginBundleQueryClient();
145
+ }
112
146
  var TemplateContext = react.createContext(null);
113
147
  function injectPluginStyles(id, css) {
114
148
  if (typeof document === "undefined") return;
@@ -328,7 +362,6 @@ function useReportingCurrencySync() {
328
362
  }
329
363
 
330
364
  // src/platform-react/definePlatformReactPluginPage.tsx
331
- var defaultQueryClient = createPluginQueryClient();
332
365
  var EHX_PLUGIN_ROOT_CLASS = "ehx-plugin-root";
333
366
  function definePlatformReactPluginPage(Page, options) {
334
367
  const {
@@ -336,10 +369,11 @@ function definePlatformReactPluginPage(Page, options) {
336
369
  rootClassName,
337
370
  styleId,
338
371
  css,
339
- queryClient = defaultQueryClient,
372
+ queryClient: queryClientOverride,
340
373
  wrapPage
341
374
  } = options;
342
375
  function PluginPage(props) {
376
+ const queryClient = useSurfaceQueryClient(queryClientOverride);
343
377
  useOrgFormatSync();
344
378
  useReportingCurrencySync();
345
379
  const page = react.createElement(Page, props);
@@ -819,18 +853,19 @@ function useOverlayHost() {
819
853
  }
820
854
  return api;
821
855
  }
822
- var defaultQueryClient2 = createPluginQueryClient();
823
856
  function definePlatformReactPluginOverlay(Overlay, options) {
824
- const { rootClassName, styleId, css, manifest = {}, queryClient = defaultQueryClient2, wrapOverlay } = options;
857
+ const { rootClassName, styleId, css, manifest = {}, queryClient: queryClientOverride, wrapOverlay } = options;
825
858
  return function MountedOverlay(props) {
859
+ const queryClient = useSurfaceQueryClient(queryClientOverride);
826
860
  useOrgFormatSync();
827
861
  useReportingCurrencySync();
828
862
  const tree = react.createElement(
829
863
  OverlayHostContext.Provider,
830
864
  { value: props.overlayHost },
831
- // react-query provider — an overlay bundle has its own react-query module
832
- // instance, so the host's app-wide client is invisible across the bundle
833
- // boundary; it needs its own provider exactly as each page gets one.
865
+ // react-query provider. Normally re-providing the host's own client, which
866
+ // is a no-op for the subtree and deliberate: the tree shape stays identical
867
+ // whichever client `useSurfaceQueryClient` returned, so the fallback path is
868
+ // not a second code path through the renderer.
834
869
  react.createElement(
835
870
  reactQuery.QueryClientProvider,
836
871
  { client: queryClient },
@@ -1289,6 +1324,7 @@ exports.useOrgFormatSync = useOrgFormatSync;
1289
1324
  exports.useOverlayHost = useOverlayHost;
1290
1325
  exports.usePluginRealtime = usePluginRealtime;
1291
1326
  exports.useReportingCurrencySync = useReportingCurrencySync;
1327
+ exports.useSurfaceQueryClient = useSurfaceQueryClient;
1292
1328
  exports.useSurfaceUrl = useSurfaceUrl;
1293
1329
  exports.useToolInvoker = useToolInvoker;
1294
1330
  exports.useToolInvokerMap = useToolInvokerMap;