@ethisyscore/plugin-ui 1.45.0 → 1.46.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.
- package/dist/components/layout/index.cjs +47 -0
- package/dist/components/layout/index.cjs.map +1 -1
- package/dist/components/layout/index.d.cts +19 -151
- package/dist/components/layout/index.d.ts +19 -151
- package/dist/components/layout/index.js +47 -1
- package/dist/components/layout/index.js.map +1 -1
- package/dist/pageHeaderTypes-PWZpiwp6.d.cts +198 -0
- package/dist/pageHeaderTypes-PWZpiwp6.d.ts +198 -0
- package/dist/platform-react/index.cjs +66 -0
- package/dist/platform-react/index.cjs.map +1 -1
- package/dist/platform-react/index.d.cts +52 -2
- package/dist/platform-react/index.d.ts +52 -2
- package/dist/platform-react/index.js +66 -1
- package/dist/platform-react/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,9 @@ import { QueryClient, UseQueryResult, UseQueryOptions, QueryKey } from '@tanstac
|
|
|
5
5
|
import { PlatformReactPageProps } from '@ethisyscore/components-react';
|
|
6
6
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
7
7
|
import { McpTransport, UploadDocumentResult } from '@ethisyscore/extension-runtime/plugin';
|
|
8
|
-
|
|
8
|
+
import { k as HostSidebarInput } from '../useHostSidebarActions-DFZPen7T.js';
|
|
9
|
+
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 HostSidebarContribution, l as HostSidebarNavItem, S as SIDEBAR_MODE, m as isHostChromeCompatible, r as reportHostChromeDiagnostic, s as setHostChromeDiagnosticSink, u as useHostSidebarActions } from '../useHostSidebarActions-DFZPen7T.js';
|
|
10
|
+
import { g as PluginDetailContext } from '../pageHeaderTypes-PWZpiwp6.js';
|
|
9
11
|
|
|
10
12
|
/** A view component resolved from the template manifest. Props are open. */
|
|
11
13
|
type ViewComponent = ComponentType<Record<string, unknown>>;
|
|
@@ -1063,4 +1065,52 @@ declare function surfacePathFor(opts: {
|
|
|
1063
1065
|
suffix?: string;
|
|
1064
1066
|
}): string;
|
|
1065
1067
|
|
|
1066
|
-
|
|
1068
|
+
/**
|
|
1069
|
+
* Options for {@link toHostSidebarInput}.
|
|
1070
|
+
*/
|
|
1071
|
+
interface ToHostSidebarInputOptions {
|
|
1072
|
+
/** The plugin's mount base (e.g. `/extensions/projects`). Stripped from hrefs. */
|
|
1073
|
+
basePath: string;
|
|
1074
|
+
/**
|
|
1075
|
+
* The entity token the host matches to the current route. Use the bare entity id
|
|
1076
|
+
* — the host segment-matches it across an entity's sub-pages
|
|
1077
|
+
* (`deriveEntityToken`/`tokenMatches`). When absent the result is `{mode:"none"}`.
|
|
1078
|
+
*/
|
|
1079
|
+
entityToken: string | undefined;
|
|
1080
|
+
/**
|
|
1081
|
+
* Dispatch bridge for `actionId` actions — pass a page's `useTriggerSidebarAction()`
|
|
1082
|
+
* so a sidebar click reaches the same `useSidebarActions` handler the header uses.
|
|
1083
|
+
* (Kept as a parameter rather than called internally so this stays a PURE mapper
|
|
1084
|
+
* and avoids the cross-entry `SidebarActionContext` singleton pitfall.)
|
|
1085
|
+
*/
|
|
1086
|
+
onDispatch: (actionId: string) => void;
|
|
1087
|
+
/**
|
|
1088
|
+
* Slug-relative fallback for a back link that can't be confined (e.g. the plugin
|
|
1089
|
+
* root, whose path is empty and which the host rejects). Defaults to `""` which,
|
|
1090
|
+
* if the primary back link is also unconfinable, yields no back link.
|
|
1091
|
+
*/
|
|
1092
|
+
backHrefFallback?: string;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Map a plugin {@link PluginDetailContext} to a {@link HostSidebarInput} for
|
|
1096
|
+
* `useHostSidebarActions(mode:"detail")` — the plugin-side of the host left-sidebar
|
|
1097
|
+
* detail panel (back link + sub-page nav + Quick actions), the companion of
|
|
1098
|
+
* `useDetailHeaderActions` (the header surface).
|
|
1099
|
+
*
|
|
1100
|
+
* Encodes the host-contract rules so no plugin has to re-derive them from host
|
|
1101
|
+
* source (getting them wrong SILENTLY BLANKS the panel):
|
|
1102
|
+
* - hrefs are made SLUG-RELATIVE (basePath stripped); absolute/cross-module hrefs
|
|
1103
|
+
* are dropped (the host rejects them and `mode:"detail"` atomic-drops on a bad
|
|
1104
|
+
* nav/back href).
|
|
1105
|
+
* - the host action contract is FLAT (no nested children), so children-bearing
|
|
1106
|
+
* actions (e.g. Lifecycle / Share) are flattened to their leaves.
|
|
1107
|
+
* - `actionId` → `kind:"dispatch"` with `onSelect` wired to `onDispatch`; `href` →
|
|
1108
|
+
* `kind:"navigate"`; a bare `onClick` → `kind:"dispatch"` with that handler.
|
|
1109
|
+
* - duplicate action ids are removed (the host rejects the whole contribution on a
|
|
1110
|
+
* duplicate id).
|
|
1111
|
+
* - no context / no entity token → `{mode:"none"}` (suppresses without clobbering
|
|
1112
|
+
* the static manifest).
|
|
1113
|
+
*/
|
|
1114
|
+
declare function toHostSidebarInput(context: PluginDetailContext | null | undefined, opts: ToHostSidebarInputOptions): HostSidebarInput;
|
|
1115
|
+
|
|
1116
|
+
export { type AuthenticatedQueryResult, BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, type DefinePlatformReactPluginOverlayOptions, type DefinePlatformReactPluginPageOptions, EHX_PLUGIN_ROOT_CLASS, HostSidebarInput, type InsetLease, type ManagedLifecycle, MissingViewFallback, OVERLAY_HOST_CONTRACT_VERSION, type OverlayHostApi, type OverlayHostCapabilities, OverlayHostContext, type PlatformReactOverlayProps, type PluginOverlayDefinerConfig, type PluginPageDefinerConfig, PluginStyleScope, type ReactRouterShimOptions, SurfaceBaseContext, type SurfaceBaseValue, TemplateContext, type TemplateManifest, type ToHostSidebarInputOptions, type ToolInvoker, type UseMcpUploadOptions, type UseMcpUploadResult, type UseMcpUploadTarget, type ViewComponent, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, injectPluginStyles, isComponent, normaliseSlug, notViaMcp, resolveSurfaceBase, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useManagedLifecycle, useMcpUpload, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useView };
|
|
@@ -646,6 +646,71 @@ function useHostSidebarActions(input) {
|
|
|
646
646
|
}, [compatible, key]);
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
-
|
|
649
|
+
// src/platform-react/toHostSidebarInput.ts
|
|
650
|
+
function toHostSidebarInput(context, opts) {
|
|
651
|
+
if (!context || !opts.entityToken) {
|
|
652
|
+
return { mode: "none" };
|
|
653
|
+
}
|
|
654
|
+
const navItems = context.navItems.map((n) => ({ id: n.id, label: n.label, icon: n.icon, href: slugRelative(n.href, opts.basePath) })).filter((n) => isConfinable(n.href));
|
|
655
|
+
const mappedBack = slugRelative(context.backHref, opts.basePath);
|
|
656
|
+
const backHref = isConfinable(mappedBack) ? mappedBack : opts.backHrefFallback ?? "";
|
|
657
|
+
return {
|
|
658
|
+
mode: "detail",
|
|
659
|
+
entityToken: opts.entityToken,
|
|
660
|
+
title: context.title,
|
|
661
|
+
navSectionLabel: context.navSectionLabel ?? "Sections",
|
|
662
|
+
navItems,
|
|
663
|
+
backHref,
|
|
664
|
+
backLabel: context.backLabel ?? "Back",
|
|
665
|
+
actions: toHostActions(context.actions ?? [], opts)
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function slugRelative(href, basePath) {
|
|
669
|
+
if (!href) return "";
|
|
670
|
+
const base = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
|
|
671
|
+
if (href === base) return "";
|
|
672
|
+
const prefix = `${base}/`;
|
|
673
|
+
return href.startsWith(prefix) ? href.slice(prefix.length) : href;
|
|
674
|
+
}
|
|
675
|
+
function isConfinable(slugRelativeHref) {
|
|
676
|
+
return slugRelativeHref.length > 0 && !slugRelativeHref.startsWith("/") && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(slugRelativeHref) && !slugRelativeHref.includes("#");
|
|
677
|
+
}
|
|
678
|
+
function flattenLeaves(items) {
|
|
679
|
+
const out = [];
|
|
680
|
+
for (const item of items) {
|
|
681
|
+
if (item.children?.length) out.push(...flattenLeaves(item.children));
|
|
682
|
+
else out.push(item);
|
|
683
|
+
}
|
|
684
|
+
return out;
|
|
685
|
+
}
|
|
686
|
+
function toHostActions(actions, opts) {
|
|
687
|
+
const out = [];
|
|
688
|
+
for (const item of flattenLeaves(actions)) {
|
|
689
|
+
const mapped = toHostAction(item, opts);
|
|
690
|
+
if (mapped) out.push(mapped);
|
|
691
|
+
}
|
|
692
|
+
const seen = /* @__PURE__ */ new Set();
|
|
693
|
+
return out.filter((a) => seen.has(a.id) ? false : (seen.add(a.id), true));
|
|
694
|
+
}
|
|
695
|
+
function toHostAction(item, opts) {
|
|
696
|
+
const slot = item.slot === "primary" ? "primary" : item.slot === "sidebar-only" ? "sidebar-only" : "overflow";
|
|
697
|
+
const variant = item.variant === "danger" ? "danger" : void 0;
|
|
698
|
+
const shared = { id: item.id, label: item.label, icon: item.icon, slot, variant, disabled: item.disabled };
|
|
699
|
+
if (item.href) {
|
|
700
|
+
const href = slugRelative(item.href, opts.basePath);
|
|
701
|
+
if (!isConfinable(href)) return null;
|
|
702
|
+
return { ...shared, kind: "navigate", href };
|
|
703
|
+
}
|
|
704
|
+
if (item.actionId) {
|
|
705
|
+
const actionId = item.actionId;
|
|
706
|
+
return { ...shared, kind: "dispatch", onSelect: () => opts.onDispatch(actionId) };
|
|
707
|
+
}
|
|
708
|
+
if (item.onClick) {
|
|
709
|
+
return { ...shared, kind: "dispatch", onSelect: item.onClick };
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export { BaseMcpService, DEFAULT_MAX_UPLOAD_BYTES, EHX_PLUGIN_ROOT_CLASS, HOST_CHROME_CONTRACT_VERSION, HostSidebarActionsContext, MissingViewFallback, OVERLAY_HOST_CONTRACT_VERSION, OverlayHostContext, PluginStyleScope, SIDEBAR_MODE, SurfaceBaseContext, TemplateContext, buildSurfaceUrl, createPluginOverlayDefiner, createPluginPageDefiner, createReactRouterShim, createUseView, definePlatformReactPluginOverlay, definePlatformReactPluginPage, injectPluginStyles, isComponent, isHostChromeCompatible, normaliseSlug, notViaMcp, reportHostChromeDiagnostic, resolveSurfaceBase, setHostChromeDiagnosticSink, surfacePathFor, toHostSidebarInput, useAuthenticatedQueries, useAuthenticatedQuery, useHostSidebarActions, useManagedLifecycle, useMcpUpload, useOverlayHost, usePluginRealtime, useSurfaceUrl, useToolInvoker, useToolInvokerMap, useView };
|
|
650
715
|
//# sourceMappingURL=index.js.map
|
|
651
716
|
//# sourceMappingURL=index.js.map
|