@ethisyscore/plugin-ui 1.86.0 → 1.88.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.
@@ -288,6 +288,42 @@ declare function PluginStyleScope({ id, css }: {
288
288
  css: string;
289
289
  }): null;
290
290
 
291
+ /**
292
+ * Reserved host resource carrying the caller organisation's effective date/time
293
+ * display formats. The host proxies it (see coreconnect-web
294
+ * `surfaceMcpTransport.ts`) from the permission-free
295
+ * `/organisations/current/display-formats` endpoint. The URI string is hardcoded
296
+ * on both sides of the runtime host↔plugin contract, exactly like
297
+ * `ethisys:user-permissions`.
298
+ */
299
+ declare const ORGANISATION_SETTINGS_URI = "ethisys:organisation-settings";
300
+ /**
301
+ * Reads the caller organisation's effective date/time display formats from the
302
+ * reserved {@link ORGANISATION_SETTINGS_URI} host resource and stamps them into
303
+ * the core-utils org-format refs, so THIS plugin bundle's org-aware formatters
304
+ * (`@ethisyscore/core-utils/date/org-format`) and `DateInput` picker masks render
305
+ * in the organisation's configured format.
306
+ *
307
+ * Each plugin bundle owns its own copy of those module refs, so this must run per
308
+ * bundle — `definePlatformReactPluginPage` and `definePlatformReactPluginOverlay`
309
+ * auto-call it once per surface mount, so plugins wire nothing.
310
+ *
311
+ * Reactive: the org format arrives asynchronously, after the surface (and its
312
+ * `DateInput`s) have already rendered on the UK fallback. The module refs are
313
+ * non-React, so a `useState` bump here re-renders the surface once the formats
314
+ * resolve, letting already-mounted formatters and picker masks pick them up. The
315
+ * effect is also keyed on the active organisation id, so switching organisation
316
+ * without a remount refetches.
317
+ *
318
+ * Fails open. It resolves the transport via the OPTIONAL accessor (not
319
+ * `useMcpResource`, which throws when no provider is present) so a surface that
320
+ * renders without a host transport — a standalone/mock-mode run or an isolated
321
+ * unit test — degrades to a no-op and the formatters use the UK fallback, rather
322
+ * than crashing the page. On a rejected/failed fetch the refs are reset to the UK
323
+ * fallback rather than left holding a previous organisation's format.
324
+ */
325
+ declare function useOrgFormatSync(): void;
326
+
291
327
  /**
292
328
  * Class on the portal container element rendered at the end of a plugin surface.
293
329
  * `plugin-base.css` positions it; the class is exported so a plugin can target it
@@ -1306,4 +1342,4 @@ interface MenuConfigHostSidebarOptions {
1306
1342
  */
1307
1343
  declare function menuConfigToHostSidebarInput(config: HeaderMenuItem[], opts: MenuConfigHostSidebarOptions): HostSidebarHookInput;
1308
1344
 
1309
- export { type AuthenticatedQueryResult, BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, type PlatformReactOverlayProps, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, PluginStyleScope, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, type ToolInvoker, TypedMcpService, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, injectPluginStyles, isComponent, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useManagedLifecycle, useMcpUpload, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useView };
1345
+ export { type AuthenticatedQueryResult, BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, type PlatformReactOverlayProps, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, PluginStyleScope, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, type ToolInvoker, TypedMcpService, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, injectPluginStyles, isComponent, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useManagedLifecycle, useMcpUpload, useOrgFormatSync, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useView };
@@ -288,6 +288,42 @@ declare function PluginStyleScope({ id, css }: {
288
288
  css: string;
289
289
  }): null;
290
290
 
291
+ /**
292
+ * Reserved host resource carrying the caller organisation's effective date/time
293
+ * display formats. The host proxies it (see coreconnect-web
294
+ * `surfaceMcpTransport.ts`) from the permission-free
295
+ * `/organisations/current/display-formats` endpoint. The URI string is hardcoded
296
+ * on both sides of the runtime host↔plugin contract, exactly like
297
+ * `ethisys:user-permissions`.
298
+ */
299
+ declare const ORGANISATION_SETTINGS_URI = "ethisys:organisation-settings";
300
+ /**
301
+ * Reads the caller organisation's effective date/time display formats from the
302
+ * reserved {@link ORGANISATION_SETTINGS_URI} host resource and stamps them into
303
+ * the core-utils org-format refs, so THIS plugin bundle's org-aware formatters
304
+ * (`@ethisyscore/core-utils/date/org-format`) and `DateInput` picker masks render
305
+ * in the organisation's configured format.
306
+ *
307
+ * Each plugin bundle owns its own copy of those module refs, so this must run per
308
+ * bundle — `definePlatformReactPluginPage` and `definePlatformReactPluginOverlay`
309
+ * auto-call it once per surface mount, so plugins wire nothing.
310
+ *
311
+ * Reactive: the org format arrives asynchronously, after the surface (and its
312
+ * `DateInput`s) have already rendered on the UK fallback. The module refs are
313
+ * non-React, so a `useState` bump here re-renders the surface once the formats
314
+ * resolve, letting already-mounted formatters and picker masks pick them up. The
315
+ * effect is also keyed on the active organisation id, so switching organisation
316
+ * without a remount refetches.
317
+ *
318
+ * Fails open. It resolves the transport via the OPTIONAL accessor (not
319
+ * `useMcpResource`, which throws when no provider is present) so a surface that
320
+ * renders without a host transport — a standalone/mock-mode run or an isolated
321
+ * unit test — degrades to a no-op and the formatters use the UK fallback, rather
322
+ * than crashing the page. On a rejected/failed fetch the refs are reset to the UK
323
+ * fallback rather than left holding a previous organisation's format.
324
+ */
325
+ declare function useOrgFormatSync(): void;
326
+
291
327
  /**
292
328
  * Class on the portal container element rendered at the end of a plugin surface.
293
329
  * `plugin-base.css` positions it; the class is exported so a plugin can target it
@@ -1306,4 +1342,4 @@ interface MenuConfigHostSidebarOptions {
1306
1342
  */
1307
1343
  declare function menuConfigToHostSidebarInput(config: HeaderMenuItem[], opts: MenuConfigHostSidebarOptions): HostSidebarHookInput;
1308
1344
 
1309
- export { type AuthenticatedQueryResult, BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, type PlatformReactOverlayProps, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, PluginStyleScope, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, type ToolInvoker, TypedMcpService, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, injectPluginStyles, isComponent, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useManagedLifecycle, useMcpUpload, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useView };
1345
+ export { type AuthenticatedQueryResult, BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, type PlatformReactOverlayProps, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, PluginStyleScope, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, type ToolInvoker, TypedMcpService, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, injectPluginStyles, isComponent, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useManagedLifecycle, useMcpUpload, useOrgFormatSync, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useView };
@@ -1,9 +1,10 @@
1
1
  import { createContext, useEffect, useContext, useState, useMemo, createElement, useRef, useCallback, useSyncExternalStore } from 'react';
2
2
  import { QueryClient, useQuery, useQueries, QueryClientProvider } from '@tanstack/react-query';
3
3
  import { definePlatformReactPage, emitNavigation } from '@ethisyscore/components-react';
4
- import { useHostIdentity, useMcpTool, usePluginRealtimeSource, useExtensionRuntimeTransport } from '@ethisyscore/extension-runtime/plugin';
4
+ import { useHostIdentity, useOptionalExtensionRuntimeTransport, useMcpTool, usePluginRealtimeSource, useExtensionRuntimeTransport } from '@ethisyscore/extension-runtime/plugin';
5
5
  import { useTheme, ThemeProvider } from '@mui/material';
6
6
  import { jsxs, jsx } from 'react/jsx-runtime';
7
+ import { setOrgFormats } from '@ethisyscore/core-utils/date/org-format';
7
8
 
8
9
  // src/platform-react/definePlatformReactPluginPage.tsx
9
10
  var TemplateContext = createContext(null);
@@ -147,6 +148,28 @@ function PluginPortalScope({ children }) {
147
148
  /* @__PURE__ */ jsx("div", { ref: setContainer, className: EHX_PLUGIN_PORTAL_CLASS, ...{ [EHX_PLUGIN_PORTAL_ATTR]: "" } })
148
149
  ] });
149
150
  }
151
+ var ORGANISATION_SETTINGS_URI = "ethisys:organisation-settings";
152
+ function useOrgFormatSync() {
153
+ const transport = useOptionalExtensionRuntimeTransport();
154
+ const organisationId = useHostIdentity()?.organisationId ?? null;
155
+ const [, bumpVersion] = useState(0);
156
+ useEffect(() => {
157
+ setOrgFormats(null, null);
158
+ bumpVersion((v) => v + 1);
159
+ if (!transport) return;
160
+ const controller = new AbortController();
161
+ transport.getResource(ORGANISATION_SETTINGS_URI, controller.signal).then((result) => {
162
+ if (controller.signal.aborted) return;
163
+ setOrgFormats(result.data?.dateFormat ?? null, result.data?.timeFormat ?? null);
164
+ bumpVersion((v) => v + 1);
165
+ }).catch(() => {
166
+ if (controller.signal.aborted) return;
167
+ setOrgFormats(null, null);
168
+ bumpVersion((v) => v + 1);
169
+ });
170
+ return () => controller.abort();
171
+ }, [transport, organisationId]);
172
+ }
150
173
 
151
174
  // src/platform-react/definePlatformReactPluginPage.tsx
152
175
  function makeDefaultQueryClient() {
@@ -172,6 +195,7 @@ function definePlatformReactPluginPage(Page, options) {
172
195
  wrapPage
173
196
  } = options;
174
197
  function PluginPage(props) {
198
+ useOrgFormatSync();
175
199
  const page = createElement(Page, props);
176
200
  const body = wrapPage ? wrapPage(page) : page;
177
201
  const surfaceTree = createElement(
@@ -580,6 +604,7 @@ var defaultQueryClient2 = makeDefaultQueryClient2();
580
604
  function definePlatformReactPluginOverlay(Overlay, options) {
581
605
  const { rootClassName, styleId, css, manifest = {}, queryClient = defaultQueryClient2, wrapOverlay } = options;
582
606
  return function MountedOverlay(props) {
607
+ useOrgFormatSync();
583
608
  const tree = createElement(
584
609
  OverlayHostContext.Provider,
585
610
  { value: props.overlayHost },
@@ -902,6 +927,6 @@ function menuConfigToHostSidebarInput(config, opts) {
902
927
  return { mode: "actions", actions };
903
928
  }
904
929
 
905
- export { BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HOST_CHROME_CONTRACT_VERSION, HostSidebarActionsContext, MissingViewFallback, OVERLAY_HOST_CONTRACT_VERSION, OverlayHostContext, PluginPortalScope, PluginStyleScope, SIDEBAR_MODE, SurfaceBaseContext, TemplateContext, TypedMcpService, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, injectPluginStyles, isComponent, isHostChromeCompatible, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, reportHostChromeDiagnostic, resolveSurfaceBase, setHostChromeDiagnosticSink, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useHostSidebarActions, useManagedLifecycle, useMcpUpload, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useView };
930
+ export { BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HOST_CHROME_CONTRACT_VERSION, HostSidebarActionsContext, MissingViewFallback, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, OverlayHostContext, PluginPortalScope, PluginStyleScope, SIDEBAR_MODE, SurfaceBaseContext, TemplateContext, TypedMcpService, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, injectPluginStyles, isComponent, isHostChromeCompatible, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, reportHostChromeDiagnostic, resolveSurfaceBase, setHostChromeDiagnosticSink, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useHostSidebarActions, useManagedLifecycle, useMcpUpload, useOrgFormatSync, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useView };
906
931
  //# sourceMappingURL=index.js.map
907
932
  //# sourceMappingURL=index.js.map