@eworkbase/sdk 0.8.3 → 0.8.5

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.
@@ -1,4 +1,4 @@
1
- import { r as ExecutionLogRecord, t as ExecutionLogEntry } from "../ExecutionLog.dto-ig9GUWhK.js";
1
+ import { r as ExecutionLogRecord, t as ExecutionLogEntry } from "../ExecutionLog.dto-Bq2u5C90.js";
2
2
  //#region src/ui/ExecutionLogTimeline.dto.d.ts
3
3
  export declare enum ExecutionLogDisplay {
4
4
  Full = "full",
@@ -36,12 +36,16 @@ interface ExecutionLogTimelineProps {
36
36
  readonly limit?: number;
37
37
  readonly isLoading?: boolean;
38
38
  readonly error?: string | null;
39
+ readonly phaseLabels?: Readonly<Record<string, string>>;
39
40
  readonly onOpenLog?: (logId: string) => void;
40
41
  }
41
42
  //#endregion
42
43
  //#region src/ui/execution-log-model.d.ts
44
+ interface BuildExecutionLogItemsOptions {
45
+ readonly phaseLabels?: Readonly<Record<string, string>>;
46
+ }
43
47
  /** Merge loaded related records into the same reader; unresolved calls retain their navigation. */
44
- export declare function buildExecutionLogItems(record: ExecutionLogRecord, relatedRecords?: readonly ExecutionLogRecord[]): readonly ExecutionLogTimelineItem[];
48
+ export declare function buildExecutionLogItems(record: ExecutionLogRecord, relatedRecords?: readonly ExecutionLogRecord[], options?: BuildExecutionLogItemsOptions): readonly ExecutionLogTimelineItem[];
45
49
  export declare function executionLogStatusLabel(status: string): string;
46
50
  //#endregion
47
51
  //#region src/ui/ExecutionLogTimeline.d.ts
@@ -22,22 +22,11 @@ const LOG_STATUS_LABELS = /* @__PURE__ */ new Map([
22
22
  ["warning", "有警告"],
23
23
  ["unknown", "未记录"]
24
24
  ]);
25
- const LOG_PHASE_LABELS = /* @__PURE__ */ new Map([
26
- ["preflight", "访问检查"],
27
- ["tools", "工具准备"],
28
- ["repositories", "仓库处理"],
29
- ["environment", "项目环境"],
30
- ["plugins", "插件"],
31
- ["verification", "结果检查"],
32
- ["configuration", "项目配置"],
33
- ["publication", "配置发布"],
34
- ["execution", "执行任务"]
35
- ]);
36
25
  /** Merge loaded related records into the same reader; unresolved calls retain their navigation. */
37
- function buildExecutionLogItems(record, relatedRecords = []) {
26
+ function buildExecutionLogItems(record, relatedRecords = [], options = {}) {
38
27
  const records = [...new Map([record, ...relatedRecords].map((source) => [source.id, source])).values()];
39
28
  const loadedIds = new Set(records.map(({ id }) => id));
40
- return records.flatMap((source) => recordItems(source).map((item) => {
29
+ return records.flatMap((source) => recordItems(source, options.phaseLabels).map((item) => {
41
30
  const logId = item.logId && !loadedIds.has(item.logId) ? item.logId : void 0;
42
31
  return source.id === record.id ? {
43
32
  ...item,
@@ -77,18 +66,18 @@ function normalizeLogStatus(status) {
77
66
  ].includes(status)) return "needs_action";
78
67
  return status;
79
68
  }
80
- function recordItems(record) {
69
+ function recordItems(record, phaseLabels) {
81
70
  const entries = (record.entries ?? []).map(logEntryItem);
82
71
  const calls = [...new Map((record.children ?? []).map((call) => [call.id, call])).values()];
83
72
  const steps = record.steps ?? [];
84
73
  const wrapper = Boolean(record.execution && entries.length && steps.length === 1 && steps[0].target?.kind === "plugin" && steps[0].target.id === record.execution.pluginId);
85
74
  const items = [
86
75
  ...entries,
87
- ...wrapper ? [] : steps.map(logStepItem),
76
+ ...wrapper ? [] : steps.map((step) => logStepItem(step, phaseLabels)),
88
77
  ...calls.map(logCallItem)
89
78
  ];
90
79
  if (wrapper) {
91
- const result = logStepItem(steps[0]);
80
+ const result = logStepItem(steps[0], phaseLabels);
92
81
  items.push({
93
82
  ...result,
94
83
  id: "execution-evidence",
@@ -146,7 +135,7 @@ function logEntryItem(entry) {
146
135
  }] : []
147
136
  };
148
137
  }
149
- function logStepItem(step) {
138
+ function logStepItem(step, phaseLabels) {
150
139
  const evidence = [
151
140
  {
152
141
  kind: "command",
@@ -164,9 +153,10 @@ function logStepItem(step) {
164
153
  content: step.stderr
165
154
  }
166
155
  ].filter((block) => Boolean(block.content));
156
+ const phaseLabel = step.phase ? phaseLabels?.[step.phase] ?? step.phase : void 0;
167
157
  const context = [...new Set([
168
158
  step.target?.label,
169
- LOG_PHASE_LABELS.get(step.phase ?? "") ?? step.phase,
159
+ phaseLabel,
170
160
  step.provider
171
161
  ].filter((label) => Boolean(label)))];
172
162
  const timing = step.timing;
@@ -227,7 +217,7 @@ const COPY_SUCCESS_MESSAGE = "已复制";
227
217
  const COPY_CONFIRMATION_MS = 2e3;
228
218
  const LATEST_SCROLL_THRESHOLD = 24;
229
219
  const LOG_KIND_LABELS = /* @__PURE__ */ new Map([["question", "提问"], ["answer", "回答"]]);
230
- const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, record, relatedRecords, display = "full", executionId, limit = RECENT_ENTRY_LIMIT, isLoading, error, onOpenLog }) {
220
+ const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, record, relatedRecords, display = "full", executionId, limit = RECENT_ENTRY_LIMIT, isLoading, error, phaseLabels, onOpenLog }) {
231
221
  const viewport = useRef(null);
232
222
  const following = useRef(true);
233
223
  const [isFollowing, setIsFollowing] = useState(true);
@@ -236,8 +226,9 @@ const ExecutionLogTimeline = memo(function ExecutionLogTimeline({ entries, recor
236
226
  id: "",
237
227
  title: "",
238
228
  entries: [...entries ?? []]
239
- }, relatedRecords), [
229
+ }, relatedRecords, { phaseLabels }), [
240
230
  entries,
231
+ phaseLabels,
241
232
  record,
242
233
  relatedRecords
243
234
  ]);
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,30 @@
1
- import { C as PluginUiToastOptions, D as WorkbasePluginUi, E as PluginUiViewIdentity, O as WorkbasePluginUiDefinition, S as PluginUiStatus, T as PluginUiView, _ 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, 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 PluginUiTransportConnection, x as PluginUiPromptType, y as PluginUiPromptChoice } from "../types-DXhRV5dI.js";
1
+ import { A as PluginUiViewIdentity, C as PluginUiRepositoryPushOutcome, D as PluginUiToastOptions, E as PluginUiStatus, M as WorkbasePluginUiDefinition, O as PluginUiTransportConnection, 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 WorkbasePluginUi, k as PluginUiView, 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-CPObI29j.js";
2
2
  //#region src/ui/controller.d.ts
3
+ export declare enum PluginUiHostMethod {
4
+ InteractionDismiss = "interaction.dismiss",
5
+ InteractionRespond = "interaction.respond",
6
+ CommandSubscribe = "command.subscribe",
7
+ CommandCancel = "command.cancel",
8
+ CommandStart = "command.start",
9
+ CommandQuery = "command.query",
10
+ CommandReply = "command.reply",
11
+ CommandClear = "command.clear",
12
+ CommandExecute = "command.execute",
13
+ DialogPrompt = "dialog.prompt",
14
+ DesktopOpen = "desktop.open",
15
+ RepositoryAuthorizePush = "repository.authorizePush",
16
+ RepositoryPush = "repository.push",
17
+ FileSelect = "file.select",
18
+ Navigate = "navigate",
19
+ OutputOpen = "output.open",
20
+ StatusResolve = "status.resolve",
21
+ ToastShow = "toast.show",
22
+ ViewCall = "view.call",
23
+ ViewModified = "view.modified"
24
+ }
3
25
  export declare function createPluginUiController(definition: WorkbasePluginUiDefinition, options: PluginUiControllerOptions): WorkbasePluginUi;
4
26
  //#endregion
5
27
  //#region src/ui/index.d.ts
6
28
  export declare function defineWorkbasePluginUi(definition: WorkbasePluginUiDefinition): WorkbasePluginUi;
7
29
  //#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 PluginUiStatus, type PluginUiToastOptions, type PluginUiTransportConnection, type PluginUiView, type PluginUiViewIdentity, type WorkbasePluginUi, type WorkbasePluginUiDefinition };
30
+ 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 PluginUiOpenViewOptions, 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 };
package/dist/ui/index.js CHANGED
@@ -3,6 +3,29 @@ import { WindowMessenger, connect } from "penpal";
3
3
  const MAX_CONTENT_HEIGHT = 1e4;
4
4
  const MAX_FATAL_MESSAGE_LENGTH = 1e3;
5
5
  const MIN_CONTENT_HEIGHT = 1;
6
+ let PluginUiHostMethod = /* @__PURE__ */ function(PluginUiHostMethod) {
7
+ PluginUiHostMethod["InteractionDismiss"] = "interaction.dismiss";
8
+ PluginUiHostMethod["InteractionRespond"] = "interaction.respond";
9
+ PluginUiHostMethod["CommandSubscribe"] = "command.subscribe";
10
+ PluginUiHostMethod["CommandCancel"] = "command.cancel";
11
+ PluginUiHostMethod["CommandStart"] = "command.start";
12
+ PluginUiHostMethod["CommandQuery"] = "command.query";
13
+ PluginUiHostMethod["CommandReply"] = "command.reply";
14
+ PluginUiHostMethod["CommandClear"] = "command.clear";
15
+ PluginUiHostMethod["CommandExecute"] = "command.execute";
16
+ PluginUiHostMethod["DialogPrompt"] = "dialog.prompt";
17
+ PluginUiHostMethod["DesktopOpen"] = "desktop.open";
18
+ PluginUiHostMethod["RepositoryAuthorizePush"] = "repository.authorizePush";
19
+ PluginUiHostMethod["RepositoryPush"] = "repository.push";
20
+ PluginUiHostMethod["FileSelect"] = "file.select";
21
+ PluginUiHostMethod["Navigate"] = "navigate";
22
+ PluginUiHostMethod["OutputOpen"] = "output.open";
23
+ PluginUiHostMethod["StatusResolve"] = "status.resolve";
24
+ PluginUiHostMethod["ToastShow"] = "toast.show";
25
+ PluginUiHostMethod["ViewCall"] = "view.call";
26
+ PluginUiHostMethod["ViewModified"] = "view.modified";
27
+ return PluginUiHostMethod;
28
+ }({});
6
29
  function createPluginUiController(definition, options) {
7
30
  const onInit = definition?.onInit;
8
31
  const connectToHost = options?.connectToHost;
@@ -12,7 +35,11 @@ function createPluginUiController(definition, options) {
12
35
  const state = {
13
36
  fatalReportPromise: null,
14
37
  isInitialized: false,
38
+ isFillLayout: false,
39
+ supportsRepositoryPush: false,
40
+ supportsRepositoryPushAuthorization: false,
15
41
  contentHeight: null,
42
+ workspaceId: null,
16
43
  recoverableHostErrors: /* @__PURE__ */ new WeakSet()
17
44
  };
18
45
  const executionListeners = /* @__PURE__ */ new Set();
@@ -20,6 +47,7 @@ function createPluginUiController(definition, options) {
20
47
  let initialization = 0;
21
48
  let refreshing = false;
22
49
  let pending = false;
50
+ let lifecycle = null;
23
51
  const clientMethods = {
24
52
  filesChanged: async () => {
25
53
  pending = true;
@@ -40,6 +68,10 @@ function createPluginUiController(definition, options) {
40
68
  initialize: async (payload) => {
41
69
  assertInitializationPayload(payload);
42
70
  state.isInitialized = true;
71
+ state.isFillLayout = payload.layout === "fill";
72
+ state.workspaceId = payload.workspace.id;
73
+ state.supportsRepositoryPush = payload.supportsRepositoryPush === true;
74
+ state.supportsRepositoryPushAuthorization = payload.supportsRepositoryPushAuthorization === true;
43
75
  initialization++;
44
76
  try {
45
77
  await onInit(payload);
@@ -47,6 +79,8 @@ function createPluginUiController(definition, options) {
47
79
  initialization--;
48
80
  }
49
81
  if (pending) await clientMethods.filesChanged();
82
+ if (state.isFillLayout) return;
83
+ lifecycle?.observeContentHeight();
50
84
  await waitForPluginUiPaint(targetWindow);
51
85
  await reportContentHeight(hostPromise, {
52
86
  targetWindow,
@@ -57,11 +91,16 @@ function createPluginUiController(definition, options) {
57
91
  const connection = connectToHost(clientMethods);
58
92
  const hostPromise = connection.promise;
59
93
  const request = createHostRequest(hostPromise, state);
60
- bindPluginUiLifecycle({
94
+ lifecycle = bindPluginUiLifecycle({
61
95
  connection,
62
96
  state,
63
97
  targetWindow
64
98
  });
99
+ const dispose = () => {
100
+ executionListeners.clear();
101
+ fileListeners.clear();
102
+ lifecycle?.dispose();
103
+ };
65
104
  const subscribe = async (onChange) => {
66
105
  const listener = (change) => onChange(change);
67
106
  executionListeners.add(listener);
@@ -84,13 +123,20 @@ function createPluginUiController(definition, options) {
84
123
  };
85
124
  return createPluginUiApi(request, {
86
125
  targetWindow,
126
+ state,
127
+ dispose,
87
128
  subscribe,
88
129
  onFilesChanged
89
130
  });
90
131
  }
91
132
  function createHostRequest(hostPromise, state) {
92
133
  return async (method, params) => {
93
- if (!state.isInitialized) throw new Error("Plugin UI is not initialized.");
134
+ if (!state.isInitialized) throw new Error("插件界面尚未初始化完成。");
135
+ if (method === "repository.push" && !state.supportsRepositoryPush || method === "repository.authorizePush" && !state.supportsRepositoryPushAuthorization) {
136
+ const error = /* @__PURE__ */ new Error("当前 Workbase 版本无法在插件内推送,请在工作区同步仓库。");
137
+ state.recoverableHostErrors.add(error);
138
+ throw error;
139
+ }
94
140
  const response = await (await hostPromise).call(method, params);
95
141
  if (isRecord(response) && response.ok === true) return response.result;
96
142
  const error = createHostError(response);
@@ -100,11 +146,11 @@ function createHostRequest(hostPromise, state) {
100
146
  }
101
147
  function createHostError(response) {
102
148
  const responseError = isRecord(response) && isRecord(response.error) ? response.error : null;
103
- const message = typeof responseError?.message === "string" ? responseError.message : "Host action failed.";
149
+ const message = typeof responseError?.message === "string" ? responseError.message : "宿主操作未完成。";
104
150
  const code = typeof responseError?.code === "string" ? responseError.code : "host_error";
105
151
  return Object.assign(new Error(message), { code });
106
152
  }
107
- function createPluginUiApi(request, { targetWindow, subscribe, onFilesChanged }) {
153
+ function createPluginUiApi(request, { targetWindow, state, dispose, subscribe, onFilesChanged }) {
108
154
  const commands = Object.freeze({
109
155
  subscribe,
110
156
  reply: (executionId) => request("command.reply", { executionId }),
@@ -136,27 +182,45 @@ function createPluginUiApi(request, { targetWindow, subscribe, onFilesChanged })
136
182
  method
137
183
  })
138
184
  });
185
+ const navigate = (to, { replace = false } = {}) => request("navigate", {
186
+ replace,
187
+ to
188
+ });
189
+ const openPluginView = async ({ pluginId, viewId, workspaceId, route, params, replace = false }) => {
190
+ const resolvedWorkspaceId = workspaceId ?? state.workspaceId;
191
+ const search = new URLSearchParams({ viewId });
192
+ if (resolvedWorkspaceId) search.set("workspaceId", resolvedWorkspaceId);
193
+ if (route) search.set("route", route);
194
+ if (params && Object.keys(params).length > 0) search.set("params", JSON.stringify(params));
195
+ await navigate(`/plugins/${encodeURIComponent(pluginId)}?${search.toString()}`, { replace });
196
+ };
139
197
  return Object.freeze({
198
+ dispose,
140
199
  dismiss: () => request("interaction.dismiss", {}),
141
200
  respond: (value) => request("interaction.respond", { value }),
142
- closeOutput: (id) => request("output.close", { id }),
143
201
  commands,
144
202
  desktop: Object.freeze({ open: (options) => request("desktop.open", options) }),
145
- navigate: (to, { replace = false } = {}) => request("navigate", {
146
- replace,
147
- to
203
+ repositories: Object.freeze({
204
+ authorizePush: (repositoryIds) => request("repository.authorizePush", repositoryIds),
205
+ push: (targets, authorizationId) => request("repository.push", authorizationId === void 0 ? targets : {
206
+ targets,
207
+ authorizationId
208
+ })
148
209
  }),
210
+ navigate,
211
+ openPluginView,
149
212
  openOutput: (options) => request("output.open", options),
150
213
  selectFiles: (options = {}) => request("file.select", options),
151
214
  showPrompt: (options) => request("dialog.prompt", options),
152
215
  showToast: (options) => request("toast.show", options),
153
216
  status,
154
- updateOutput: (options) => request("output.update", options),
155
217
  view
156
218
  });
157
219
  }
158
220
  function bindPluginUiLifecycle({ connection, state, targetWindow }) {
159
221
  let resizeFrame = null;
222
+ let resizeObserver = null;
223
+ let isDisposed = false;
160
224
  const handleWindowError = (event) => {
161
225
  if (!event.error && (event.message === "ResizeObserver loop completed with undelivered notifications." || event.message === "ResizeObserver loop limit exceeded")) return;
162
226
  reportFirstFatal(connection.promise, state, event.error ?? event.message);
@@ -165,31 +229,41 @@ function bindPluginUiLifecycle({ connection, state, targetWindow }) {
165
229
  if (event.reason instanceof Error && state.recoverableHostErrors.has(event.reason)) return;
166
230
  reportFirstFatal(connection.promise, state, event.reason);
167
231
  };
168
- const resizeObserver = new targetWindow.ResizeObserver(() => {
169
- if (resizeFrame !== null) return;
170
- resizeFrame = targetWindow.requestAnimationFrame(() => {
171
- resizeFrame = null;
172
- if (state.isInitialized) reportContentHeight(connection.promise, {
173
- targetWindow,
174
- state
232
+ const startObservingHeight = () => {
233
+ if (isDisposed || resizeObserver || state.isFillLayout) return;
234
+ resizeObserver = new targetWindow.ResizeObserver(() => {
235
+ if (resizeFrame !== null) return;
236
+ resizeFrame = targetWindow.requestAnimationFrame(() => {
237
+ resizeFrame = null;
238
+ if (state.isInitialized && !state.isFillLayout) reportContentHeight(connection.promise, {
239
+ targetWindow,
240
+ state
241
+ });
175
242
  });
176
243
  });
177
- });
244
+ resizeObserver.observe(targetWindow.document.body ?? targetWindow.document.documentElement);
245
+ };
178
246
  const cleanup = () => {
247
+ if (isDisposed) return;
248
+ isDisposed = true;
179
249
  targetWindow.removeEventListener("error", handleWindowError, true);
180
250
  targetWindow.removeEventListener("unhandledrejection", handleUnhandledRejection);
181
251
  targetWindow.removeEventListener("beforeunload", cleanup);
182
- resizeObserver.disconnect();
252
+ resizeObserver?.disconnect();
253
+ resizeObserver = null;
183
254
  if (resizeFrame !== null) targetWindow.cancelAnimationFrame(resizeFrame);
184
255
  connection.destroy();
185
256
  state.fatalReportPromise = null;
186
257
  state.isInitialized = false;
187
258
  };
188
259
  ignoreConnectionFailure(connection.promise);
189
- resizeObserver.observe(targetWindow.document.body ?? targetWindow.document.documentElement);
190
260
  targetWindow.addEventListener("error", handleWindowError, true);
191
261
  targetWindow.addEventListener("unhandledrejection", handleUnhandledRejection);
192
262
  targetWindow.addEventListener("beforeunload", cleanup, { once: true });
263
+ return {
264
+ observeContentHeight: startObservingHeight,
265
+ dispose: cleanup
266
+ };
193
267
  }
194
268
  async function ignoreConnectionFailure(hostPromise) {
195
269
  try {
@@ -225,7 +299,7 @@ async function reportContentHeight(hostPromise, { targetWindow, state }) {
225
299
  } catch {}
226
300
  }
227
301
  function assertInitializationPayload(value) {
228
- if (!isInitializationPayload(value)) throw new TypeError("Plugin UI initialization payload is invalid.");
302
+ if (!isInitializationPayload(value)) throw new TypeError("插件界面初始化参数无效。");
229
303
  }
230
304
  function isInitializationPayload(value) {
231
305
  if (!isRecord(value)) return false;
@@ -245,7 +319,7 @@ function isRecord(value) {
245
319
  function getFatalMessage(error) {
246
320
  if (error instanceof Error) return error.message;
247
321
  if (typeof error === "string" && error.trim().length > 0) return error;
248
- return "Plugin UI failed.";
322
+ return "插件界面遇到异常。";
249
323
  }
250
324
  //#endregion
251
325
  //#region src/ui/types.ts
@@ -289,4 +363,4 @@ function resolveParentOrigins(targetWindow) {
289
363
  return hostOrigin && hostOrigin !== "null" ? [hostOrigin] : ["*"];
290
364
  }
291
365
  //#endregion
292
- export { PluginDesktopTarget, createPluginUiController, defineWorkbasePluginUi };
366
+ export { PluginDesktopTarget, PluginUiHostMethod, createPluginUiController, defineWorkbasePluginUi };
@@ -1,4 +1,4 @@
1
- import { D as WorkbasePluginUi } from "../types-DXhRV5dI.js";
1
+ import { j as WorkbasePluginUi } from "../types-CPObI29j.js";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/ui/MarkdownLinks.dto.d.ts
4
4
  interface MarkdownLinksProps {