@ethisyscore/plugin-ui 1.136.0 → 1.138.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.
@@ -6,7 +6,8 @@ import { PlatformReactPageProps } from '@ethisyscore/components-react';
6
6
  import { T as ToolInvoker } from '../mcpService-4h3sKDpW.cjs';
7
7
  export { B as BaseMcpService, n as notViaMcp, u as useToolInvoker, a as useToolInvokerMap } from '../mcpService-4h3sKDpW.cjs';
8
8
  import * as _tanstack_query_core from '@tanstack/query-core';
9
- import { McpTransport, UploadDocumentResult } from '@ethisyscore/extension-runtime/plugin';
9
+ import { McpTransport, UploadDocumentResult, UploadToStorageResult, PluginStorageUploadError } from '@ethisyscore/extension-runtime/plugin';
10
+ export { PLUGIN_STORAGE_UPLOAD_CONTENT_TYPES, PluginStorageUploadError, PluginStorageUploadErrorReason, UploadToStorageResult, isPluginStorageUploadError, resolvePluginStorageContentType, validatePluginStoragePrefix } from '@ethisyscore/extension-runtime/plugin';
10
11
  import { l as HostSidebarInput, p as HostSidebarHookInput } from '../activeNavHref-BfoAQCGU.cjs';
11
12
  export { H as HOST_CHROME_CONTRACT_VERSION, a as HostChromeDiagnostic, b as HostSidebarAction, c as HostSidebarActionDescriptor, d as HostSidebarActionSlot, e as HostSidebarActionVariant, f as HostSidebarActionsApi, g as HostSidebarActionsCapabilities, h as HostSidebarActionsContext, i as HostSidebarActionsPageProps, j as HostSidebarActiveNav, k as HostSidebarContribution, q as HostSidebarDerivedInput, m as HostSidebarNavItem, R as ResolveActiveNavHrefOptions, S as SIDEBAR_MODE, n as isHostChromeCompatible, r as reportHostChromeDiagnostic, o as resolveActiveNavHref, s as setHostChromeDiagnosticSink, u as useHostSidebarActions, w as withActiveNavHref } from '../activeNavHref-BfoAQCGU.cjs';
12
13
  import { g as PluginDetailContext, H as HeaderMenuItem } from '../pageHeaderTypes-PWZpiwp6.cjs';
@@ -1248,6 +1249,54 @@ interface UseMcpUploadResult {
1248
1249
  */
1249
1250
  declare function useMcpUpload(opts?: UseMcpUploadOptions): UseMcpUploadResult;
1250
1251
 
1252
+ /** Per-call options for {@link UseUploadToStorageResult.upload}. */
1253
+ interface UploadToStorageTarget {
1254
+ /**
1255
+ * Folder inside the app's own storage namespace: `/`-separated segments of `[A-Za-z0-9_-]`, at
1256
+ * most 84 characters, no leading or trailing `/` (HR: `cvs`; Legal:
1257
+ * `governance/{documentId}/{versionId}`). Validated here with the server's rules so a bad prefix
1258
+ * fails before the file is read; it is refused, never repaired, and sent exactly as given.
1259
+ */
1260
+ pathPrefix: string;
1261
+ /** Overrides the file's own name (required for an `ArrayBuffer`). Its extension must be on the allow-list. */
1262
+ fileName?: string;
1263
+ /** Overrides the file's own MIME type. */
1264
+ contentType?: string;
1265
+ }
1266
+ interface UseUploadToStorageOptions {
1267
+ /** Override the transport resolved from the runtime provider (tests / advanced hosts). */
1268
+ transport?: McpTransport;
1269
+ /** Client-side max byte size, never above the server's 30 MB cap (the default). */
1270
+ maxSizeBytes?: number;
1271
+ }
1272
+ interface UseUploadToStorageResult {
1273
+ /**
1274
+ * Stream `file` into this app's own plugin storage and resolve the server-chosen `path`
1275
+ * (`{pathPrefix}/{guid}{ext}`), the exact string the app's backend reads with `IPluginStorage`.
1276
+ * Record it with the app's own command. Rejects with a {@link PluginStorageUploadError}: branch on
1277
+ * `reason` (`too_large`, `quota_exceeded`, `unsupported_type`, `invalid_prefix`, `timeout`,
1278
+ * `busy`, ...); `message` is the server's when the server answered. A file whose extension is
1279
+ * not on `PLUGIN_STORAGE_UPLOAD_CONTENT_TYPES` fails with `unsupported_type` before it is read.
1280
+ */
1281
+ upload: (file: File | Blob | ArrayBuffer, target: UploadToStorageTarget) => Promise<UploadToStorageResult>;
1282
+ /** Phase-based progress in [0, 1]: 0 idle, 1 on completion. The FE→host leg is not byte-streamed. */
1283
+ progress: number;
1284
+ loading: boolean;
1285
+ error: PluginStorageUploadError | undefined;
1286
+ }
1287
+ /**
1288
+ * Upload a browser file from a platform-react plugin surface into the app's OWN plugin storage.
1289
+ *
1290
+ * Browser uploads go through this (the `uploadToStorage` request kind); never base64 a file
1291
+ * through a tool call. The bytes never touch the plugin backend and the plugin never sees the
1292
+ * capability token: the host streams them to `extensions/storage/upload-stream`, and the kernel
1293
+ * derives the namespace from the token. For the legacy CORE `StoredDocument` route, see
1294
+ * `useMcpUpload`.
1295
+ *
1296
+ * Unmounting, or starting another upload, aborts the one in flight.
1297
+ */
1298
+ declare function useUploadToStorage(opts?: UseUploadToStorageOptions): UseUploadToStorageResult;
1299
+
1251
1300
  declare const OVERLAY_HOST_CONTRACT_VERSION = "1.0.0";
1252
1301
  /** Canonical inset-lease identity — the SAME shape the web host layout store uses (Codex R2 M1:
1253
1302
  * one lease shape across SDK/web/store, no adapter). The store's handle extends this with `source`. */
@@ -1568,4 +1617,4 @@ interface MenuConfigHostSidebarOptions {
1568
1617
  */
1569
1618
  declare function menuConfigToHostSidebarInput(config: HeaderMenuItem[], opts: MenuConfigHostSidebarOptions): HostSidebarHookInput;
1570
1619
 
1571
- export { type AuthenticatedQueryResult, type CurrencyInfo, type CurrencySelector, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, LIST_CURRENCIES_TOOL, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, OPERATION_FALLBACK_POLL_MS, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, PLUGIN_OPERATION_STATE_CHANGED, PLUGIN_OPERATION_TOOLS, type PlatformReactOverlayProps, type PluginOperation, type PluginOperationStateChanged, type PluginOperationStatus, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, type PluginQueryMeta, PluginStyleScope, REPORTING_CURRENCY_TOOL, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, ToolInvoker, TypedMcpService, type UseCurrencyResult, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createPluginQueryClient, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, hasKind, hasParentEntityType, injectPluginStyles, isComponent, isTerminalOperationStatus, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, pluginOperationKeys, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useBackgroundOperation, useCurrency, useLatestTerminalOperationByParent, useManagedLifecycle, useMcpUpload, useOperationsByParent, useOrgFormatSync, useOverlayHost, usePluginRealtime, useReportingCurrencySync, useSurfaceQueryClient, useSurfaceUrl, useTypedToolInvokerMap, useView };
1620
+ export { type AuthenticatedQueryResult, type CurrencyInfo, type CurrencySelector, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, LIST_CURRENCIES_TOOL, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, OPERATION_FALLBACK_POLL_MS, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, PLUGIN_OPERATION_STATE_CHANGED, PLUGIN_OPERATION_TOOLS, type PlatformReactOverlayProps, type PluginOperation, type PluginOperationStateChanged, type PluginOperationStatus, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, type PluginQueryMeta, PluginStyleScope, REPORTING_CURRENCY_TOOL, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, ToolInvoker, TypedMcpService, type UploadToStorageTarget, type UseCurrencyResult, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type UseUploadToStorageOptions, type UseUploadToStorageResult, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createPluginQueryClient, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, hasKind, hasParentEntityType, injectPluginStyles, isComponent, isTerminalOperationStatus, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, pluginOperationKeys, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useBackgroundOperation, useCurrency, useLatestTerminalOperationByParent, useManagedLifecycle, useMcpUpload, useOperationsByParent, useOrgFormatSync, useOverlayHost, usePluginRealtime, useReportingCurrencySync, useSurfaceQueryClient, useSurfaceUrl, useTypedToolInvokerMap, useUploadToStorage, useView };
@@ -6,7 +6,8 @@ import { PlatformReactPageProps } from '@ethisyscore/components-react';
6
6
  import { T as ToolInvoker } from '../mcpService-4h3sKDpW.js';
7
7
  export { B as BaseMcpService, n as notViaMcp, u as useToolInvoker, a as useToolInvokerMap } from '../mcpService-4h3sKDpW.js';
8
8
  import * as _tanstack_query_core from '@tanstack/query-core';
9
- import { McpTransport, UploadDocumentResult } from '@ethisyscore/extension-runtime/plugin';
9
+ import { McpTransport, UploadDocumentResult, UploadToStorageResult, PluginStorageUploadError } from '@ethisyscore/extension-runtime/plugin';
10
+ export { PLUGIN_STORAGE_UPLOAD_CONTENT_TYPES, PluginStorageUploadError, PluginStorageUploadErrorReason, UploadToStorageResult, isPluginStorageUploadError, resolvePluginStorageContentType, validatePluginStoragePrefix } from '@ethisyscore/extension-runtime/plugin';
10
11
  import { l as HostSidebarInput, p as HostSidebarHookInput } from '../activeNavHref-BrYVWRiO.js';
11
12
  export { H as HOST_CHROME_CONTRACT_VERSION, a as HostChromeDiagnostic, b as HostSidebarAction, c as HostSidebarActionDescriptor, d as HostSidebarActionSlot, e as HostSidebarActionVariant, f as HostSidebarActionsApi, g as HostSidebarActionsCapabilities, h as HostSidebarActionsContext, i as HostSidebarActionsPageProps, j as HostSidebarActiveNav, k as HostSidebarContribution, q as HostSidebarDerivedInput, m as HostSidebarNavItem, R as ResolveActiveNavHrefOptions, S as SIDEBAR_MODE, n as isHostChromeCompatible, r as reportHostChromeDiagnostic, o as resolveActiveNavHref, s as setHostChromeDiagnosticSink, u as useHostSidebarActions, w as withActiveNavHref } from '../activeNavHref-BrYVWRiO.js';
12
13
  import { g as PluginDetailContext, H as HeaderMenuItem } from '../pageHeaderTypes-PWZpiwp6.js';
@@ -1248,6 +1249,54 @@ interface UseMcpUploadResult {
1248
1249
  */
1249
1250
  declare function useMcpUpload(opts?: UseMcpUploadOptions): UseMcpUploadResult;
1250
1251
 
1252
+ /** Per-call options for {@link UseUploadToStorageResult.upload}. */
1253
+ interface UploadToStorageTarget {
1254
+ /**
1255
+ * Folder inside the app's own storage namespace: `/`-separated segments of `[A-Za-z0-9_-]`, at
1256
+ * most 84 characters, no leading or trailing `/` (HR: `cvs`; Legal:
1257
+ * `governance/{documentId}/{versionId}`). Validated here with the server's rules so a bad prefix
1258
+ * fails before the file is read; it is refused, never repaired, and sent exactly as given.
1259
+ */
1260
+ pathPrefix: string;
1261
+ /** Overrides the file's own name (required for an `ArrayBuffer`). Its extension must be on the allow-list. */
1262
+ fileName?: string;
1263
+ /** Overrides the file's own MIME type. */
1264
+ contentType?: string;
1265
+ }
1266
+ interface UseUploadToStorageOptions {
1267
+ /** Override the transport resolved from the runtime provider (tests / advanced hosts). */
1268
+ transport?: McpTransport;
1269
+ /** Client-side max byte size, never above the server's 30 MB cap (the default). */
1270
+ maxSizeBytes?: number;
1271
+ }
1272
+ interface UseUploadToStorageResult {
1273
+ /**
1274
+ * Stream `file` into this app's own plugin storage and resolve the server-chosen `path`
1275
+ * (`{pathPrefix}/{guid}{ext}`), the exact string the app's backend reads with `IPluginStorage`.
1276
+ * Record it with the app's own command. Rejects with a {@link PluginStorageUploadError}: branch on
1277
+ * `reason` (`too_large`, `quota_exceeded`, `unsupported_type`, `invalid_prefix`, `timeout`,
1278
+ * `busy`, ...); `message` is the server's when the server answered. A file whose extension is
1279
+ * not on `PLUGIN_STORAGE_UPLOAD_CONTENT_TYPES` fails with `unsupported_type` before it is read.
1280
+ */
1281
+ upload: (file: File | Blob | ArrayBuffer, target: UploadToStorageTarget) => Promise<UploadToStorageResult>;
1282
+ /** Phase-based progress in [0, 1]: 0 idle, 1 on completion. The FE→host leg is not byte-streamed. */
1283
+ progress: number;
1284
+ loading: boolean;
1285
+ error: PluginStorageUploadError | undefined;
1286
+ }
1287
+ /**
1288
+ * Upload a browser file from a platform-react plugin surface into the app's OWN plugin storage.
1289
+ *
1290
+ * Browser uploads go through this (the `uploadToStorage` request kind); never base64 a file
1291
+ * through a tool call. The bytes never touch the plugin backend and the plugin never sees the
1292
+ * capability token: the host streams them to `extensions/storage/upload-stream`, and the kernel
1293
+ * derives the namespace from the token. For the legacy CORE `StoredDocument` route, see
1294
+ * `useMcpUpload`.
1295
+ *
1296
+ * Unmounting, or starting another upload, aborts the one in flight.
1297
+ */
1298
+ declare function useUploadToStorage(opts?: UseUploadToStorageOptions): UseUploadToStorageResult;
1299
+
1251
1300
  declare const OVERLAY_HOST_CONTRACT_VERSION = "1.0.0";
1252
1301
  /** Canonical inset-lease identity — the SAME shape the web host layout store uses (Codex R2 M1:
1253
1302
  * one lease shape across SDK/web/store, no adapter). The store's handle extends this with `source`. */
@@ -1568,4 +1617,4 @@ interface MenuConfigHostSidebarOptions {
1568
1617
  */
1569
1618
  declare function menuConfigToHostSidebarInput(config: HeaderMenuItem[], opts: MenuConfigHostSidebarOptions): HostSidebarHookInput;
1570
1619
 
1571
- export { type AuthenticatedQueryResult, type CurrencyInfo, type CurrencySelector, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, LIST_CURRENCIES_TOOL, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, OPERATION_FALLBACK_POLL_MS, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, PLUGIN_OPERATION_STATE_CHANGED, PLUGIN_OPERATION_TOOLS, type PlatformReactOverlayProps, type PluginOperation, type PluginOperationStateChanged, type PluginOperationStatus, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, type PluginQueryMeta, PluginStyleScope, REPORTING_CURRENCY_TOOL, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, ToolInvoker, TypedMcpService, type UseCurrencyResult, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createPluginQueryClient, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, hasKind, hasParentEntityType, injectPluginStyles, isComponent, isTerminalOperationStatus, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, pluginOperationKeys, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useBackgroundOperation, useCurrency, useLatestTerminalOperationByParent, useManagedLifecycle, useMcpUpload, useOperationsByParent, useOrgFormatSync, useOverlayHost, usePluginRealtime, useReportingCurrencySync, useSurfaceQueryClient, useSurfaceUrl, useTypedToolInvokerMap, useView };
1620
+ export { type AuthenticatedQueryResult, type CurrencyInfo, type CurrencySelector, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HostSidebarHookInput, HostSidebarInput, type InsetLease, LIST_CURRENCIES_TOOL, type ManagedLifecycle, type McpToolArgs, type McpToolContract, type McpToolContracts, type McpToolResult, type MenuConfigHostSidebarOptions, MissingViewFallback, OPERATION_FALLBACK_POLL_MS, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, PLUGIN_OPERATION_STATE_CHANGED, PLUGIN_OPERATION_TOOLS, type PlatformReactOverlayProps, type PluginOperation, type PluginOperationStateChanged, type PluginOperationStatus, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginPortalScope, type PluginQueryMeta, PluginStyleScope, REPORTING_CURRENCY_TOOL, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, ToolInvoker, TypedMcpService, type UploadToStorageTarget, type UseCurrencyResult, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type UseUploadToStorageOptions, type UseUploadToStorageResult, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createPluginQueryClient, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, hasKind, hasParentEntityType, injectPluginStyles, isComponent, isTerminalOperationStatus, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, pluginOperationKeys, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useBackgroundOperation, useCurrency, useLatestTerminalOperationByParent, useManagedLifecycle, useMcpUpload, useOperationsByParent, useOrgFormatSync, useOverlayHost, usePluginRealtime, useReportingCurrencySync, useSurfaceQueryClient, useSurfaceUrl, useTypedToolInvokerMap, useUploadToStorage, useView };
@@ -3,7 +3,8 @@ import * as reactQuery from '@tanstack/react-query';
3
3
  import { QueryClient, MutationCache, QueryCache, useQuery, useQueries, useQueryClient, QueryClientProvider } from '@tanstack/react-query';
4
4
  import { definePlatformReactPage, emitNavigation } from '@ethisyscore/components-react';
5
5
  import * as extensionRuntime from '@ethisyscore/extension-runtime/plugin';
6
- import { useHostIdentity, useMcpTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource, useExtensionRuntimeTransport } from '@ethisyscore/extension-runtime/plugin';
6
+ import { useHostIdentity, useMcpTool, useOptionalExtensionRuntimeTransport, usePluginRealtimeSource, useExtensionRuntimeTransport, uploadFileToPluginStorage, toPluginStorageUploadError } from '@ethisyscore/extension-runtime/plugin';
7
+ export { PLUGIN_STORAGE_UPLOAD_CONTENT_TYPES, PluginStorageUploadError, isPluginStorageUploadError, resolvePluginStorageContentType, validatePluginStoragePrefix } from '@ethisyscore/extension-runtime/plugin';
7
8
  import { useTheme, ThemeProvider } from '@mui/material';
8
9
  import { jsxs, jsx } from 'react/jsx-runtime';
9
10
  import { setOrgFormats } from '@ethisyscore/core-utils/date/org-format';
@@ -964,6 +965,63 @@ function useMcpUpload(opts) {
964
965
  );
965
966
  return { upload, progress, loading, error };
966
967
  }
968
+ function useUploadToStorage(opts) {
969
+ const transport = useExtensionRuntimeTransport(opts?.transport);
970
+ const maxSizeBytes = opts?.maxSizeBytes;
971
+ const [progress, setProgress] = useState(0);
972
+ const [loading, setLoading] = useState(false);
973
+ const [error, setError] = useState(void 0);
974
+ const controllerRef = useRef(null);
975
+ const mountedRef = useRef(true);
976
+ useEffect(() => {
977
+ mountedRef.current = true;
978
+ return () => {
979
+ mountedRef.current = false;
980
+ controllerRef.current?.abort();
981
+ };
982
+ }, []);
983
+ const upload = useCallback(
984
+ async (file, target) => {
985
+ const controller = new AbortController();
986
+ controllerRef.current?.abort();
987
+ controllerRef.current = controller;
988
+ const applyState = (fn) => {
989
+ if (mountedRef.current && !controller.signal.aborted) {
990
+ fn();
991
+ }
992
+ };
993
+ applyState(() => {
994
+ setLoading(true);
995
+ setError(void 0);
996
+ setProgress(0);
997
+ });
998
+ try {
999
+ const result = await uploadFileToPluginStorage(transport, file, {
1000
+ pathPrefix: target.pathPrefix,
1001
+ fileName: target.fileName,
1002
+ contentType: target.contentType,
1003
+ maxSizeBytes,
1004
+ signal: controller.signal
1005
+ });
1006
+ applyState(() => {
1007
+ setProgress(1);
1008
+ setLoading(false);
1009
+ });
1010
+ return result;
1011
+ } catch (err) {
1012
+ const typed = toPluginStorageUploadError(err);
1013
+ applyState(() => {
1014
+ setError(typed);
1015
+ setLoading(false);
1016
+ setProgress(0);
1017
+ });
1018
+ throw typed;
1019
+ }
1020
+ },
1021
+ [transport, maxSizeBytes]
1022
+ );
1023
+ return { upload, progress, loading, error };
1024
+ }
967
1025
  var OVERLAY_HOST_CONTRACT_VERSION = "1.0.0";
968
1026
  var OverlayHostContext = createContext(null);
969
1027
  function useOverlayHost() {
@@ -1393,6 +1451,6 @@ function withActiveNavHref(input, activeNavHref) {
1393
1451
  return { ...input, activeNavHref };
1394
1452
  }
1395
1453
 
1396
- export { BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HOST_CHROME_CONTRACT_VERSION, HostSidebarActionsContext, LIST_CURRENCIES_TOOL, MissingViewFallback, OPERATION_FALLBACK_POLL_MS, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, OverlayHostContext, PLUGIN_OPERATION_STATE_CHANGED, PLUGIN_OPERATION_TOOLS, PluginPortalScope, PluginStyleScope, REPORTING_CURRENCY_TOOL2 as REPORTING_CURRENCY_TOOL, SIDEBAR_MODE, SurfaceBaseContext, TemplateContext, TypedMcpService, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createPluginQueryClient, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, hasKind, hasParentEntityType, injectPluginStyles, isComponent, isHostChromeCompatible, isTerminalOperationStatus, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, pluginOperationKeys, reportHostChromeDiagnostic, resolveActiveNavHref, resolveSurfaceBase, setHostChromeDiagnosticSink, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useBackgroundOperation, useCurrency, useHostSidebarActions, useLatestTerminalOperationByParent, useManagedLifecycle, useMcpUpload, useOperationsByParent, useOrgFormatSync, useOverlayHost, usePluginRealtime, useReportingCurrencySync, useSurfaceQueryClient, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useView, withActiveNavHref };
1454
+ export { BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, EHX_PLUGIN_PORTAL_ATTR, EHX_PLUGIN_PORTAL_CLASS, EHX_PLUGIN_ROOT_CLASS, HOST_CHROME_CONTRACT_VERSION, HostSidebarActionsContext, LIST_CURRENCIES_TOOL, MissingViewFallback, OPERATION_FALLBACK_POLL_MS, ORGANISATION_SETTINGS_URI, OVERLAY_HOST_CONTRACT_VERSION, OverlayHostContext, PLUGIN_OPERATION_STATE_CHANGED, PLUGIN_OPERATION_TOOLS, PluginPortalScope, PluginStyleScope, REPORTING_CURRENCY_TOOL2 as REPORTING_CURRENCY_TOOL, SIDEBAR_MODE, SurfaceBaseContext, TemplateContext, TypedMcpService, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createPluginQueryClient, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, deriveHostEntityToken, hasKind, hasParentEntityType, injectPluginStyles, isComponent, isHostChromeCompatible, isTerminalOperationStatus, mcpTool, menuConfigToHostSidebarInput, normaliseSlug, notViaMcp, pluginOperationKeys, reportHostChromeDiagnostic, resolveActiveNavHref, resolveSurfaceBase, setHostChromeDiagnosticSink, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useBackgroundOperation, useCurrency, useHostSidebarActions, useLatestTerminalOperationByParent, useManagedLifecycle, useMcpUpload, useOperationsByParent, useOrgFormatSync, useOverlayHost, usePluginRealtime, useReportingCurrencySync, useSurfaceQueryClient, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useTypedToolInvokerMap, useUploadToStorage, useView, withActiveNavHref };
1397
1455
  //# sourceMappingURL=index.js.map
1398
1456
  //# sourceMappingURL=index.js.map