@eworkbase/sdk 0.8.4 → 0.8.6

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.
@@ -0,0 +1,262 @@
1
+ import { t as DEFAULT_VIEW_STATE_TOPIC } from "../host-services-cIH3aYQD.js";
2
+ import { n as defineWorkbasePluginUi } from "../ui-DGLeDJDe.js";
3
+ import { n as PluginErrorBoundary } from "../components-DxL-99bM.js";
4
+ import { initializeWorkbaseUiStyles } from "./theme.js";
5
+ import { Fragment, useCallback, useEffect, useRef, useState } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ //#region src/ui/hooks.tsx
8
+ /**
9
+ * React view mounting, state-sync subscription and serialized action hooks for Workbase plugins.
10
+ */
11
+ const DEFAULT_ROOT_ELEMENT_ID = "root";
12
+ const DEFAULT_LOAD_ERROR = "插件数据读取失败,请重试。";
13
+ /** Mounts a Workbase plugin view with shared style nonce, error boundary and workspace key isolation. */
14
+ function mountPluginView(options) {
15
+ const { createRoot, elementId = DEFAULT_ROOT_ELEMENT_ID, errorTitle, errorScope, errorRecovery, keyFor = buildViewContextKey, wrap, render } = options;
16
+ const container = document.getElementById(elementId);
17
+ if (!container) throw new Error(`插件视图挂载节点 #${elementId} 不存在。`);
18
+ initializeWorkbaseUiStyles();
19
+ const root = createRoot(container);
20
+ const host = defineWorkbasePluginUi({ onInit(initialization) {
21
+ const contextKey = keyFor(initialization);
22
+ const content = /* @__PURE__ */ jsx(PluginErrorBoundary, {
23
+ title: errorTitle,
24
+ scope: errorScope,
25
+ recovery: errorRecovery,
26
+ children: /* @__PURE__ */ jsx(Fragment, { children: render({
27
+ host,
28
+ initialization,
29
+ contextKey
30
+ }) }, contextKey)
31
+ });
32
+ root.render(wrap ? wrap(content) : content);
33
+ } });
34
+ return host;
35
+ }
36
+ /**
37
+ * Manages cached view state, stale-response protection, in-flight deduplication,
38
+ * backend State Sync pushes, file-change notifications and visibility-aware polling.
39
+ */
40
+ function usePluginViewState(options) {
41
+ const { host, initialState = null, stateTopic = DEFAULT_VIEW_STATE_TOPIC, refreshOnFocus = false, refreshOnFilesChanged = false, observeVisibility = false, focusCooldownMs = 0, fallbackError = DEFAULT_LOAD_ERROR, loadOnMount = !observeVisibility } = options;
42
+ const [viewElement, setViewElement] = useState(null);
43
+ const mountedRef = useRef(true);
44
+ const requestVersionRef = useRef(0);
45
+ const pendingRef = useRef(null);
46
+ const lastReadAtRef = useRef(0);
47
+ const dataRef = useRef(initialState);
48
+ const loadRef = useRef(options.load);
49
+ const onStateRef = useRef(options.onState);
50
+ const pollIntervalRef = useRef(options.pollIntervalMs);
51
+ const isBlockedRef = useRef(options.isBlocked);
52
+ loadRef.current = options.load;
53
+ onStateRef.current = options.onState;
54
+ pollIntervalRef.current = options.pollIntervalMs;
55
+ isBlockedRef.current = options.isBlocked;
56
+ const [data, setData] = useState(initialState);
57
+ const [error, setError] = useState(null);
58
+ const [isRefreshing, setIsRefreshing] = useState(false);
59
+ const [isVisible, setIsVisible] = useState(!observeVisibility);
60
+ const acceptData = useCallback((next) => {
61
+ const previous = dataRef.current;
62
+ dataRef.current = next;
63
+ lastReadAtRef.current = Date.now();
64
+ requestVersionRef.current += 1;
65
+ setData(next);
66
+ setError(null);
67
+ onStateRef.current?.(next, previous);
68
+ }, []);
69
+ const invalidatePending = useCallback(() => {
70
+ requestVersionRef.current += 1;
71
+ pendingRef.current = null;
72
+ setIsRefreshing(false);
73
+ }, []);
74
+ const clearError = useCallback(() => setError(null), []);
75
+ const refresh = useCallback(async () => {
76
+ if (pendingRef.current) return pendingRef.current;
77
+ if (!mountedRef.current || isBlockedRef.current?.()) return null;
78
+ const version = requestVersionRef.current;
79
+ setIsRefreshing(true);
80
+ const emit = (partial) => {
81
+ if (!mountedRef.current || requestVersionRef.current !== version) return;
82
+ const previous = dataRef.current;
83
+ dataRef.current = partial;
84
+ setData(partial);
85
+ onStateRef.current?.(partial, previous);
86
+ };
87
+ const request = (async () => {
88
+ try {
89
+ const next = await loadRef.current(emit);
90
+ if (!mountedRef.current || requestVersionRef.current !== version) return null;
91
+ const previous = dataRef.current;
92
+ dataRef.current = next;
93
+ lastReadAtRef.current = Date.now();
94
+ setData(next);
95
+ setError(null);
96
+ onStateRef.current?.(next, previous);
97
+ return next;
98
+ } catch (failure) {
99
+ if (mountedRef.current && requestVersionRef.current === version) setError(readableErrorMessage(failure, fallbackError));
100
+ return null;
101
+ } finally {
102
+ if (requestVersionRef.current === version) {
103
+ pendingRef.current = null;
104
+ if (mountedRef.current) setIsRefreshing(false);
105
+ }
106
+ }
107
+ })();
108
+ pendingRef.current = request;
109
+ return request;
110
+ }, [fallbackError]);
111
+ useEffect(() => {
112
+ mountedRef.current = true;
113
+ return () => {
114
+ mountedRef.current = false;
115
+ requestVersionRef.current += 1;
116
+ pendingRef.current = null;
117
+ };
118
+ }, []);
119
+ useEffect(() => {
120
+ if (loadOnMount) refresh();
121
+ }, [loadOnMount, refresh]);
122
+ useEffect(() => {
123
+ if (stateTopic === null || typeof host.view.onStateChanged !== "function") return;
124
+ return host.view.onStateChanged((pushed) => {
125
+ if (!mountedRef.current) return;
126
+ acceptData(pushed);
127
+ }, stateTopic);
128
+ }, [
129
+ acceptData,
130
+ host,
131
+ stateTopic
132
+ ]);
133
+ useEffect(() => {
134
+ if (!refreshOnFilesChanged || typeof host.view.onFilesChanged !== "function") return;
135
+ return host.view.onFilesChanged(() => {
136
+ refresh();
137
+ });
138
+ }, [
139
+ host,
140
+ refresh,
141
+ refreshOnFilesChanged
142
+ ]);
143
+ useEffect(() => {
144
+ if (!observeVisibility) {
145
+ setIsVisible(true);
146
+ return;
147
+ }
148
+ let isIntersecting = false;
149
+ const syncVisibility = () => setIsVisible(isIntersecting && document.visibilityState === "visible");
150
+ const observer = new IntersectionObserver(([entry]) => {
151
+ isIntersecting = Boolean(entry?.isIntersecting);
152
+ syncVisibility();
153
+ });
154
+ if (viewElement) observer.observe(viewElement);
155
+ document.addEventListener("visibilitychange", syncVisibility);
156
+ return () => {
157
+ observer.disconnect();
158
+ document.removeEventListener("visibilitychange", syncVisibility);
159
+ };
160
+ }, [observeVisibility, viewElement]);
161
+ useEffect(() => {
162
+ if (!isVisible) return;
163
+ const triggerRefresh = () => {
164
+ if (document.visibilityState !== "visible") return;
165
+ if (isBlockedRef.current?.()) return;
166
+ if (focusCooldownMs > 0 && Date.now() - lastReadAtRef.current < focusCooldownMs) return;
167
+ refresh();
168
+ };
169
+ if (observeVisibility) triggerRefresh();
170
+ if (!refreshOnFocus) return;
171
+ window.addEventListener("focus", triggerRefresh);
172
+ if (!observeVisibility) document.addEventListener("visibilitychange", triggerRefresh);
173
+ return () => {
174
+ window.removeEventListener("focus", triggerRefresh);
175
+ if (!observeVisibility) document.removeEventListener("visibilitychange", triggerRefresh);
176
+ };
177
+ }, [
178
+ focusCooldownMs,
179
+ isVisible,
180
+ observeVisibility,
181
+ refresh,
182
+ refreshOnFocus
183
+ ]);
184
+ useEffect(() => {
185
+ if (!isVisible) return;
186
+ const resolver = pollIntervalRef.current;
187
+ const interval = typeof resolver === "function" ? resolver(data, error) : resolver;
188
+ if (typeof interval !== "number" || interval <= 0) return;
189
+ const delay = interval;
190
+ let cancelled = false;
191
+ let timer = window.setTimeout(poll, delay);
192
+ async function poll() {
193
+ await refresh();
194
+ if (!cancelled) timer = window.setTimeout(poll, delay);
195
+ }
196
+ return () => {
197
+ cancelled = true;
198
+ window.clearTimeout(timer);
199
+ };
200
+ }, [
201
+ data,
202
+ error,
203
+ isVisible,
204
+ refresh
205
+ ]);
206
+ return {
207
+ data,
208
+ error,
209
+ isRefreshing,
210
+ isVisible,
211
+ viewRef: setViewElement,
212
+ setError,
213
+ clearError,
214
+ refresh,
215
+ acceptData,
216
+ invalidatePending
217
+ };
218
+ }
219
+ /** Serializes mutating plugin actions so concurrent clicks never overlap or leak stale errors. */
220
+ function usePluginAction(options = {}) {
221
+ const { fallbackError = "操作未完成,请重试。" } = options;
222
+ const mountedRef = useRef(true);
223
+ const isBusyRef = useRef(false);
224
+ const onErrorRef = useRef(options.onError);
225
+ onErrorRef.current = options.onError;
226
+ const [busyAction, setBusyAction] = useState(null);
227
+ useEffect(() => {
228
+ mountedRef.current = true;
229
+ return () => {
230
+ mountedRef.current = false;
231
+ };
232
+ }, []);
233
+ const run = useCallback(async (actionId, task) => {
234
+ if (!mountedRef.current || isBusyRef.current) return;
235
+ isBusyRef.current = true;
236
+ setBusyAction(actionId);
237
+ try {
238
+ return await task();
239
+ } catch (failure) {
240
+ if (mountedRef.current) onErrorRef.current?.(readableErrorMessage(failure, fallbackError));
241
+ return;
242
+ } finally {
243
+ isBusyRef.current = false;
244
+ if (mountedRef.current) setBusyAction(null);
245
+ }
246
+ }, [fallbackError]);
247
+ return {
248
+ busyAction,
249
+ isBusy: busyAction !== null,
250
+ isBusyRef,
251
+ isMountedRef: mountedRef,
252
+ run
253
+ };
254
+ }
255
+ function buildViewContextKey(payload) {
256
+ return `${payload.project.id}:${payload.workspace.id}:${payload.activationGeneration ?? 0}`;
257
+ }
258
+ function readableErrorMessage(error, fallback) {
259
+ return error instanceof Error && error.message.trim() ? error.message : fallback;
260
+ }
261
+ //#endregion
262
+ export { buildViewContextKey, mountPluginView, usePluginAction, usePluginViewState };
package/dist/ui/index.css CHANGED
@@ -25,6 +25,7 @@
25
25
  --color-danger: #b9360a;
26
26
  --color-success: #087c75;
27
27
  --color-warning: #9a5600;
28
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
28
29
  color: var(--color-foreground);
29
30
  background: transparent;
30
31
  font-family:
@@ -73,178 +74,33 @@ h2 {
73
74
  background: var(--color-surface);
74
75
  }
75
76
 
76
- .page-header,
77
- .panel-heading,
78
- .form-actions,
79
- .button-row,
80
- .checkbox-row {
77
+ .button-row {
81
78
  display: flex;
79
+ flex-wrap: wrap;
82
80
  align-items: center;
81
+ justify-content: flex-end;
82
+ gap: 8px;
83
83
  }
84
84
 
85
- .page-header,
86
- .panel-heading,
87
- .form-actions {
88
- justify-content: space-between;
89
- gap: 12px;
90
- }
91
-
92
- .eyebrow {
93
- margin-bottom: 3px;
94
- color: var(--color-brand);
95
- font-size: 12px;
96
- font-weight: 700;
97
- }
98
-
99
- .page-description,
100
- .panel-heading p {
85
+ .page-description {
101
86
  margin-bottom: 0;
102
87
  color: var(--color-muted);
103
88
  font-size: var(--workbase-type-body);
104
89
  line-height: 1.5;
105
90
  }
106
91
 
107
- .summary-grid {
108
- display: grid;
109
- grid-template-columns: repeat(3, minmax(0, 1fr));
110
- gap: 8px;
111
- }
112
-
113
- .summary-card,
114
- .panel {
115
- border: 1px solid var(--color-border);
116
- border-radius: 8px;
117
- background: var(--color-surface);
118
- }
119
-
120
- .summary-card {
121
- display: grid;
122
- gap: 5px;
123
- min-width: 0;
124
- padding: 12px;
125
- }
126
-
127
- .summary-card span {
128
- color: var(--color-muted);
129
- font-size: 12px;
130
- }
131
-
132
- .summary-card strong {
133
- overflow: hidden;
134
- font-size: 14px;
135
- text-overflow: ellipsis;
136
- white-space: nowrap;
137
- }
138
-
139
- .panel {
140
- padding: 14px;
141
- }
142
-
143
- .two-column-layout {
144
- display: grid;
145
- grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
146
- gap: 12px;
147
- }
148
-
149
- .button-row {
150
- flex-wrap: wrap;
151
- justify-content: flex-end;
152
- gap: 8px;
153
- }
154
-
155
- .form-grid,
156
- .stack-form {
157
- display: grid;
158
- gap: 12px;
159
- margin-top: 14px;
160
- }
161
-
162
- .form-grid {
163
- grid-template-columns: repeat(2, minmax(0, 1fr));
164
- }
165
-
166
- .form-grid label,
167
- .stack-form label {
168
- display: grid;
169
- gap: 6px;
170
- color: var(--color-muted);
171
- font-size: 12px;
172
- font-weight: 700;
173
- }
174
-
175
- .form-span {
176
- grid-column: 1 / -1;
177
- }
178
-
179
- .form-grid .checkbox-row,
180
- .target-form .checkbox-row {
181
- display: flex;
182
- gap: 8px;
183
- color: var(--color-foreground);
184
- font-weight: 500;
185
- }
186
-
187
- .form-actions {
188
- min-height: 36px;
189
- color: var(--color-muted);
190
- font-size: 12px;
191
- }
192
-
193
- .form-actions a {
194
- color: var(--color-accent);
195
- font-weight: 700;
196
- text-decoration: none;
197
- }
198
-
199
- .panel-actions {
200
- margin-top: 24px;
201
- }
202
-
203
- .target-form {
204
- display: flex;
205
- flex-wrap: wrap;
206
- align-items: center;
207
- gap: 10px 18px;
208
- margin-top: 14px;
209
- }
210
-
211
- .target-form .button {
212
- margin-left: auto;
213
- }
214
-
215
- .output-panel[data-status="failed"] {
216
- border-color: color-mix(in srgb, var(--color-danger) 35%, var(--color-border));
217
- }
218
-
219
- .output-panel pre {
220
- max-height: 220px;
221
- padding: 10px;
222
- margin: 12px 0 0;
223
- overflow: auto;
224
- border-radius: 7px;
225
- color: var(--color-foreground);
226
- background: var(--color-surface-muted);
227
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
228
- font-size: 12px;
229
- line-height: 1.55;
230
- white-space: pre-wrap;
92
+ @media (prefers-reduced-motion: reduce) {
93
+ *,
94
+ *::before,
95
+ *::after {
96
+ animation-duration: 0.01ms !important;
97
+ animation-iteration-count: 1 !important;
98
+ scroll-behavior: auto !important;
99
+ transition-duration: 0.01ms !important;
100
+ }
231
101
  }
232
102
 
233
103
  @media (max-width: 760px) {
234
- .summary-grid,
235
- .two-column-layout,
236
- .form-grid { grid-template-columns: 1fr; }
237
-
238
- .form-span {
239
- grid-column: auto;
240
- }
241
-
242
- .page-header,
243
- .panel-heading {
244
- align-items: flex-start;
245
- flex-direction: column;
246
- }
247
-
248
104
  .button-row {
249
105
  justify-content: flex-start;
250
106
  }
@@ -252,11 +108,6 @@ h2 {
252
108
 
253
109
  }
254
110
 
255
- @layer components {
256
- .maintenance-panel .mantine-Accordion-control { padding: 11px 14px; font-size: 13px; }
257
- .error-message, .notice-card { margin: 12px 0 0; }
258
- }
259
-
260
111
  /** Shared configuration workbench: navigation, reading and explicit editing. */
261
112
  [hidden] { display: none !important; }
262
113
  .configuration-toolbar, .configuration-toolbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@@ -274,7 +125,7 @@ h2 {
274
125
  .plugin-toolbar[data-tone="yellow"] { --plugin-icon-color: var(--color-primary-foreground); }
275
126
  .plugin-title-icon { flex: none; box-sizing: content-box; width: 20px; height: 20px; padding: 7px; border-radius: 10px; color: var(--plugin-icon-color); background: color-mix(in srgb, var(--plugin-icon-color) 10%, var(--color-surface)); stroke-width: 1.7; }
276
127
  .plugin-toolbar[data-tone="yellow"] .plugin-title-icon { background: color-mix(in srgb, var(--color-primary) 34%, var(--color-surface)); }
277
- .plugin-toolbar :is(.page-description, .change-name) { padding-inline-start: 43px; font-size: var(--workbase-type-meta); line-height: 1.6; }
128
+ .plugin-toolbar .page-description { padding-inline-start: 43px; font-size: var(--workbase-type-meta); line-height: 1.6; }
278
129
  .plugin-toolbar:has(> .configuration-page-tabs) {
279
130
  display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); align-content: start; align-items: center;
280
131
  justify-content: start; grid-auto-rows: minmax(40px, auto);
@@ -503,3 +354,25 @@ h2 {
503
354
  .configuration-manager .configuration-list-footer { grid-column: 1 / -1; margin: 0; padding: 0; background: transparent; }
504
355
  .configuration-manager p.configuration-list-footer { display: none; }
505
356
  }
357
+
358
+
359
+ /** Shared linked Markdown document preview boundary (independent of Vditor). */
360
+ .workbase-markdown-links { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
361
+ .markdown-document-preview { min-width: 0; margin-bottom: 20px; padding: 20px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface); color: var(--color-foreground); }
362
+ .markdown-document-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
363
+ .markdown-document-heading h2 { margin: 0; font-size: 18px; line-height: 1.5; }
364
+ .markdown-document-heading p { margin: 8px 0 0; color: var(--color-muted); overflow-wrap: anywhere; }
365
+ .markdown-document-heading button { flex-shrink: 0; padding: 6px 10px; border: 1px solid var(--color-border-strong); border-radius: 6px; background: var(--color-surface); color: var(--color-foreground); font: inherit; cursor: pointer; }
366
+ .markdown-document-heading button:hover { background: var(--color-surface-muted); }
367
+ .markdown-document-preview:focus-visible, .workbase-markdown-links button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
368
+ .workbase-markdown-links .markdown-document-body { max-width: 75ch; max-height: 65vh; overflow: auto; color: var(--color-foreground); font-family: inherit; font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; }
369
+ .markdown-document-body :is(h1,h2,h3,h4,h5,h6) { color: var(--color-foreground); margin: 20px 0 10px; line-height: 1.45; }
370
+ .markdown-document-body > :first-child { margin-top: 0; }
371
+ .markdown-document-body a { color: var(--color-accent); text-underline-offset: 3px; }
372
+ .markdown-document-body code { padding: 2px 4px; border-radius: 3px; background: var(--color-surface-muted); font-family: var(--font-mono); font-size: .9em; }
373
+ .markdown-document-body pre { overflow: auto; padding: 12px 14px; border-radius: 6px; background: var(--color-surface-muted); }
374
+ .markdown-document-body pre code { padding: 0; background: transparent; }
375
+ .markdown-document-body blockquote { margin: 12px 0; padding: 4px 14px; border-left: 3px solid var(--color-border-strong); color: var(--color-muted); }
376
+ .markdown-document-body table { display: block; max-width: 100%; overflow: auto; border-collapse: collapse; }
377
+ .markdown-document-body :is(td, th) { padding: 6px 10px; border: 1px solid var(--color-border); text-align: left; }
378
+ .markdown-document-body ::selection { background: var(--color-brand-weak); color: var(--color-foreground); }
@@ -1,8 +1,50 @@
1
- import { A as WorkbasePluginUi, C as PluginUiRepositoryPushResult, D as PluginUiTransportConnection, E as PluginUiToastOptions, O as PluginUiView, S as PluginUiRepositoryPushOutcome, T as PluginUiStatus, _ as PluginUiNavigateOptions, a as PluginUiContextIdentity, b as PluginUiPromptOptions, c as PluginUiDesktopOpenResult, d as PluginUiFileSelectOptions, f as PluginUiFileSelectionItemType, g as PluginUiInitializationPayload, h as PluginUiHostMethods, i as PluginUiCommands, j as WorkbasePluginUiDefinition, k as PluginUiViewIdentity, l as PluginUiExecutionChange, m as PluginUiHostError, n as PluginUiClientMethods, o as PluginUiControllerOptions, p as PluginUiFileSelectionScope, r as PluginUiCommandExecuteOptions, s as PluginUiDesktopOpenOptions, t as PluginDesktopTarget, u as PluginUiFileFilter, v as PluginUiOutputOptions, w as PluginUiRepositoryPushTarget, x as PluginUiPromptType, y as PluginUiPromptChoice } from "../types-CRYQB_Tb.js";
1
+ import { et as DEFAULT_VIEW_STATE_TOPIC, f as PluginCommandExecutionResult } from "../types-DDEHTBRv.js";
2
+ import { A as PluginUiView, C as PluginUiRepositoryPushOutcome, D as PluginUiStatus, E as PluginUiStateChange, M as WorkbasePluginUi, N as WorkbasePluginUiDefinition, O as PluginUiToastOptions, S as PluginUiPromptType, T as PluginUiRepositoryPushTarget, _ as PluginUiNavigateOptions, a as PluginUiContextIdentity, b as PluginUiPromptChoice, c as PluginUiDesktopOpenResult, d as PluginUiFileSelectOptions, f as PluginUiFileSelectionItemType, g as PluginUiInitializationPayload, h as PluginUiHostMethods, i as PluginUiCommands, j as PluginUiViewIdentity, k as PluginUiTransportConnection, l as PluginUiExecutionChange, m as PluginUiHostError, n as PluginUiClientMethods, o as PluginUiControllerOptions, p as PluginUiFileSelectionScope, r as PluginUiCommandExecuteOptions, s as PluginUiDesktopOpenOptions, t as PluginDesktopTarget, u as PluginUiFileFilter, v as PluginUiOpenViewOptions, w as PluginUiRepositoryPushResult, x as PluginUiPromptOptions, y as PluginUiOutputOptions } from "../types-b6G-gae3.js";
2
3
  //#region src/ui/controller.d.ts
4
+ export declare enum PluginUiHostMethod {
5
+ InteractionDismiss = "interaction.dismiss",
6
+ InteractionRespond = "interaction.respond",
7
+ CommandSubscribe = "command.subscribe",
8
+ CommandCancel = "command.cancel",
9
+ CommandStart = "command.start",
10
+ CommandQuery = "command.query",
11
+ CommandReply = "command.reply",
12
+ CommandClear = "command.clear",
13
+ CommandExecute = "command.execute",
14
+ DialogPrompt = "dialog.prompt",
15
+ DesktopOpen = "desktop.open",
16
+ RepositoryAuthorizePush = "repository.authorizePush",
17
+ RepositoryPush = "repository.push",
18
+ FileSelect = "file.select",
19
+ Navigate = "navigate",
20
+ OutputOpen = "output.open",
21
+ StatusResolve = "status.resolve",
22
+ ToastShow = "toast.show",
23
+ ViewCall = "view.call",
24
+ ViewModified = "view.modified"
25
+ }
3
26
  export declare function createPluginUiController(definition: WorkbasePluginUiDefinition, options: PluginUiControllerOptions): WorkbasePluginUi;
4
27
  //#endregion
5
28
  //#region src/ui/index.d.ts
29
+ type ContractEndpoint = (...args: never[]) => unknown;
30
+ type EndpointOutput<Endpoint extends ContractEndpoint> = Awaited<ReturnType<Endpoint>>;
31
+ type CallArgs<Endpoint extends ContractEndpoint> = Parameters<Endpoint>;
32
+ type CommandArgs<Endpoint extends ContractEndpoint> = [] extends Parameters<Endpoint> ? [input?: Parameters<Endpoint>[0], options?: PluginUiCommandExecuteOptions] : [input: Parameters<Endpoint>[0], options?: PluginUiCommandExecuteOptions];
33
+ export interface PluginContract {
34
+ readonly views?: Readonly<Record<string, ContractEndpoint>>;
35
+ readonly commands?: Readonly<Record<string, ContractEndpoint>>;
36
+ readonly statuses?: Readonly<Record<string, ContractEndpoint>>;
37
+ readonly states?: Readonly<Record<string, unknown>>;
38
+ }
39
+ export interface PluginTypedClient<Contract extends PluginContract> {
40
+ readonly host: WorkbasePluginUi;
41
+ readonly view: <Method extends keyof NonNullable<Contract['views']> & string>(method: Method, ...args: CallArgs<NonNullable<Contract['views']>[Method]>) => Promise<EndpointOutput<NonNullable<Contract['views']>[Method]>>;
42
+ readonly command: <CommandId extends keyof NonNullable<Contract['commands']> & string>(commandId: CommandId, ...args: CommandArgs<NonNullable<Contract['commands']>[CommandId]>) => Promise<PluginCommandExecutionResult<EndpointOutput<NonNullable<Contract['commands']>[CommandId]>>>;
43
+ readonly status: <StatusId extends keyof NonNullable<Contract['statuses']> & string>(statusId: StatusId, ...args: CallArgs<NonNullable<Contract['statuses']>[StatusId]>) => Promise<EndpointOutput<NonNullable<Contract['statuses']>[StatusId]>>;
44
+ readonly onState: <Topic extends keyof NonNullable<Contract['states']> & string>(topic: Topic, listener: (state: NonNullable<Contract['states']>[Topic]) => void) => () => void;
45
+ }
46
+ /** Creates an end-to-end typed wrapper over the Workbase plugin UI bridge with zero runtime schema overhead. */
47
+ export declare function createPluginClient<Contract extends PluginContract>(host: WorkbasePluginUi): PluginTypedClient<Contract>;
6
48
  export declare function defineWorkbasePluginUi(definition: WorkbasePluginUiDefinition): WorkbasePluginUi;
7
49
  //#endregion
8
- export { PluginDesktopTarget, type PluginUiClientMethods, type PluginUiCommandExecuteOptions, type PluginUiCommands, type PluginUiContextIdentity, type PluginUiControllerOptions, type PluginUiDesktopOpenOptions, type PluginUiDesktopOpenResult, type PluginUiExecutionChange, type PluginUiFileFilter, type PluginUiFileSelectOptions, type PluginUiFileSelectionItemType, type PluginUiFileSelectionScope, type PluginUiHostError, type PluginUiHostMethods, type PluginUiInitializationPayload, type PluginUiNavigateOptions, type PluginUiOutputOptions, type PluginUiPromptChoice, type PluginUiPromptOptions, type PluginUiPromptType, type PluginUiRepositoryPushOutcome, type PluginUiRepositoryPushResult, type PluginUiRepositoryPushTarget, type PluginUiStatus, type PluginUiToastOptions, type PluginUiTransportConnection, type PluginUiView, type PluginUiViewIdentity, type WorkbasePluginUi, type WorkbasePluginUiDefinition };
50
+ export { DEFAULT_VIEW_STATE_TOPIC, PluginDesktopTarget, type PluginUiClientMethods, type PluginUiCommandExecuteOptions, type PluginUiCommands, type PluginUiContextIdentity, type PluginUiControllerOptions, type PluginUiDesktopOpenOptions, type PluginUiDesktopOpenResult, type PluginUiExecutionChange, type PluginUiFileFilter, type PluginUiFileSelectOptions, type PluginUiFileSelectionItemType, type PluginUiFileSelectionScope, type PluginUiHostError, type PluginUiHostMethods, type PluginUiInitializationPayload, type PluginUiNavigateOptions, type PluginUiOpenViewOptions, type PluginUiOutputOptions, type PluginUiPromptChoice, type PluginUiPromptOptions, type PluginUiPromptType, type PluginUiRepositoryPushOutcome, type PluginUiRepositoryPushResult, type PluginUiRepositoryPushTarget, type PluginUiStateChange, type PluginUiStatus, type PluginUiToastOptions, type PluginUiTransportConnection, type PluginUiView, type PluginUiViewIdentity, type WorkbasePluginUi, type WorkbasePluginUiDefinition };