@eworkbase/sdk 0.8.4 → 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.
- package/dist/{ExecutionLog.dto-ig9GUWhK.d.ts → ExecutionLog.dto-Bq2u5C90.d.ts} +1 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.js +142 -245
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +9 -2
- package/dist/style.css +4 -98
- package/dist/{types-CRYQB_Tb.d.ts → types-CPObI29j.d.ts} +21 -6
- package/dist/{types-2X-_T_W_.d.ts → types-WIMkhmH4.d.ts} +29 -101
- package/dist/ui/components.d.ts +55 -0
- package/dist/ui/components.js +131 -0
- package/dist/ui/execution-log.d.ts +6 -2
- package/dist/ui/execution-log.js +11 -20
- package/dist/ui/index.css +38 -165
- package/dist/ui/index.d.ts +24 -2
- package/dist/ui/index.js +90 -24
- package/dist/ui/markdown-links.d.ts +1 -1
- package/dist/ui/markdown-links.js +44 -34
- package/dist/ui/model.d.ts +1 -2
- package/dist/ui/model.js +1 -8
- package/dist/ui/theme.css +123 -1
- package/package.json +27 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as ExecutionLogRecord, t as ExecutionLogEntry } from "../ExecutionLog.dto-
|
|
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
|
package/dist/ui/execution-log.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
.
|
|
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-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
.
|
|
115
|
-
|
|
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
|
|
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); }
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
import { A as
|
|
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 PluginUiRepositoryPushOutcome, type PluginUiRepositoryPushResult, type PluginUiRepositoryPushTarget, 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,8 +35,11 @@ function createPluginUiController(definition, options) {
|
|
|
12
35
|
const state = {
|
|
13
36
|
fatalReportPromise: null,
|
|
14
37
|
isInitialized: false,
|
|
38
|
+
isFillLayout: false,
|
|
15
39
|
supportsRepositoryPush: false,
|
|
40
|
+
supportsRepositoryPushAuthorization: false,
|
|
16
41
|
contentHeight: null,
|
|
42
|
+
workspaceId: null,
|
|
17
43
|
recoverableHostErrors: /* @__PURE__ */ new WeakSet()
|
|
18
44
|
};
|
|
19
45
|
const executionListeners = /* @__PURE__ */ new Set();
|
|
@@ -21,6 +47,7 @@ function createPluginUiController(definition, options) {
|
|
|
21
47
|
let initialization = 0;
|
|
22
48
|
let refreshing = false;
|
|
23
49
|
let pending = false;
|
|
50
|
+
let lifecycle = null;
|
|
24
51
|
const clientMethods = {
|
|
25
52
|
filesChanged: async () => {
|
|
26
53
|
pending = true;
|
|
@@ -41,7 +68,10 @@ function createPluginUiController(definition, options) {
|
|
|
41
68
|
initialize: async (payload) => {
|
|
42
69
|
assertInitializationPayload(payload);
|
|
43
70
|
state.isInitialized = true;
|
|
71
|
+
state.isFillLayout = payload.layout === "fill";
|
|
72
|
+
state.workspaceId = payload.workspace.id;
|
|
44
73
|
state.supportsRepositoryPush = payload.supportsRepositoryPush === true;
|
|
74
|
+
state.supportsRepositoryPushAuthorization = payload.supportsRepositoryPushAuthorization === true;
|
|
45
75
|
initialization++;
|
|
46
76
|
try {
|
|
47
77
|
await onInit(payload);
|
|
@@ -49,6 +79,8 @@ function createPluginUiController(definition, options) {
|
|
|
49
79
|
initialization--;
|
|
50
80
|
}
|
|
51
81
|
if (pending) await clientMethods.filesChanged();
|
|
82
|
+
if (state.isFillLayout) return;
|
|
83
|
+
lifecycle?.observeContentHeight();
|
|
52
84
|
await waitForPluginUiPaint(targetWindow);
|
|
53
85
|
await reportContentHeight(hostPromise, {
|
|
54
86
|
targetWindow,
|
|
@@ -59,11 +91,16 @@ function createPluginUiController(definition, options) {
|
|
|
59
91
|
const connection = connectToHost(clientMethods);
|
|
60
92
|
const hostPromise = connection.promise;
|
|
61
93
|
const request = createHostRequest(hostPromise, state);
|
|
62
|
-
bindPluginUiLifecycle({
|
|
94
|
+
lifecycle = bindPluginUiLifecycle({
|
|
63
95
|
connection,
|
|
64
96
|
state,
|
|
65
97
|
targetWindow
|
|
66
98
|
});
|
|
99
|
+
const dispose = () => {
|
|
100
|
+
executionListeners.clear();
|
|
101
|
+
fileListeners.clear();
|
|
102
|
+
lifecycle?.dispose();
|
|
103
|
+
};
|
|
67
104
|
const subscribe = async (onChange) => {
|
|
68
105
|
const listener = (change) => onChange(change);
|
|
69
106
|
executionListeners.add(listener);
|
|
@@ -86,14 +123,16 @@ function createPluginUiController(definition, options) {
|
|
|
86
123
|
};
|
|
87
124
|
return createPluginUiApi(request, {
|
|
88
125
|
targetWindow,
|
|
126
|
+
state,
|
|
127
|
+
dispose,
|
|
89
128
|
subscribe,
|
|
90
129
|
onFilesChanged
|
|
91
130
|
});
|
|
92
131
|
}
|
|
93
132
|
function createHostRequest(hostPromise, state) {
|
|
94
133
|
return async (method, params) => {
|
|
95
|
-
if (!state.isInitialized) throw new Error("
|
|
96
|
-
if (method === "repository.push" && !state.supportsRepositoryPush) {
|
|
134
|
+
if (!state.isInitialized) throw new Error("插件界面尚未初始化完成。");
|
|
135
|
+
if (method === "repository.push" && !state.supportsRepositoryPush || method === "repository.authorizePush" && !state.supportsRepositoryPushAuthorization) {
|
|
97
136
|
const error = /* @__PURE__ */ new Error("当前 Workbase 版本无法在插件内推送,请在工作区同步仓库。");
|
|
98
137
|
state.recoverableHostErrors.add(error);
|
|
99
138
|
throw error;
|
|
@@ -107,11 +146,11 @@ function createHostRequest(hostPromise, state) {
|
|
|
107
146
|
}
|
|
108
147
|
function createHostError(response) {
|
|
109
148
|
const responseError = isRecord(response) && isRecord(response.error) ? response.error : null;
|
|
110
|
-
const message = typeof responseError?.message === "string" ? responseError.message : "
|
|
149
|
+
const message = typeof responseError?.message === "string" ? responseError.message : "宿主操作未完成。";
|
|
111
150
|
const code = typeof responseError?.code === "string" ? responseError.code : "host_error";
|
|
112
151
|
return Object.assign(new Error(message), { code });
|
|
113
152
|
}
|
|
114
|
-
function createPluginUiApi(request, { targetWindow, subscribe, onFilesChanged }) {
|
|
153
|
+
function createPluginUiApi(request, { targetWindow, state, dispose, subscribe, onFilesChanged }) {
|
|
115
154
|
const commands = Object.freeze({
|
|
116
155
|
subscribe,
|
|
117
156
|
reply: (executionId) => request("command.reply", { executionId }),
|
|
@@ -143,28 +182,45 @@ function createPluginUiApi(request, { targetWindow, subscribe, onFilesChanged })
|
|
|
143
182
|
method
|
|
144
183
|
})
|
|
145
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
|
+
};
|
|
146
197
|
return Object.freeze({
|
|
198
|
+
dispose,
|
|
147
199
|
dismiss: () => request("interaction.dismiss", {}),
|
|
148
200
|
respond: (value) => request("interaction.respond", { value }),
|
|
149
|
-
closeOutput: (id) => request("output.close", { id }),
|
|
150
201
|
commands,
|
|
151
202
|
desktop: Object.freeze({ open: (options) => request("desktop.open", options) }),
|
|
152
|
-
repositories: Object.freeze({
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
+
})
|
|
156
209
|
}),
|
|
210
|
+
navigate,
|
|
211
|
+
openPluginView,
|
|
157
212
|
openOutput: (options) => request("output.open", options),
|
|
158
213
|
selectFiles: (options = {}) => request("file.select", options),
|
|
159
214
|
showPrompt: (options) => request("dialog.prompt", options),
|
|
160
215
|
showToast: (options) => request("toast.show", options),
|
|
161
216
|
status,
|
|
162
|
-
updateOutput: (options) => request("output.update", options),
|
|
163
217
|
view
|
|
164
218
|
});
|
|
165
219
|
}
|
|
166
220
|
function bindPluginUiLifecycle({ connection, state, targetWindow }) {
|
|
167
221
|
let resizeFrame = null;
|
|
222
|
+
let resizeObserver = null;
|
|
223
|
+
let isDisposed = false;
|
|
168
224
|
const handleWindowError = (event) => {
|
|
169
225
|
if (!event.error && (event.message === "ResizeObserver loop completed with undelivered notifications." || event.message === "ResizeObserver loop limit exceeded")) return;
|
|
170
226
|
reportFirstFatal(connection.promise, state, event.error ?? event.message);
|
|
@@ -173,31 +229,41 @@ function bindPluginUiLifecycle({ connection, state, targetWindow }) {
|
|
|
173
229
|
if (event.reason instanceof Error && state.recoverableHostErrors.has(event.reason)) return;
|
|
174
230
|
reportFirstFatal(connection.promise, state, event.reason);
|
|
175
231
|
};
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
resizeFrame
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
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
|
+
});
|
|
183
242
|
});
|
|
184
243
|
});
|
|
185
|
-
|
|
244
|
+
resizeObserver.observe(targetWindow.document.body ?? targetWindow.document.documentElement);
|
|
245
|
+
};
|
|
186
246
|
const cleanup = () => {
|
|
247
|
+
if (isDisposed) return;
|
|
248
|
+
isDisposed = true;
|
|
187
249
|
targetWindow.removeEventListener("error", handleWindowError, true);
|
|
188
250
|
targetWindow.removeEventListener("unhandledrejection", handleUnhandledRejection);
|
|
189
251
|
targetWindow.removeEventListener("beforeunload", cleanup);
|
|
190
|
-
resizeObserver
|
|
252
|
+
resizeObserver?.disconnect();
|
|
253
|
+
resizeObserver = null;
|
|
191
254
|
if (resizeFrame !== null) targetWindow.cancelAnimationFrame(resizeFrame);
|
|
192
255
|
connection.destroy();
|
|
193
256
|
state.fatalReportPromise = null;
|
|
194
257
|
state.isInitialized = false;
|
|
195
258
|
};
|
|
196
259
|
ignoreConnectionFailure(connection.promise);
|
|
197
|
-
resizeObserver.observe(targetWindow.document.body ?? targetWindow.document.documentElement);
|
|
198
260
|
targetWindow.addEventListener("error", handleWindowError, true);
|
|
199
261
|
targetWindow.addEventListener("unhandledrejection", handleUnhandledRejection);
|
|
200
262
|
targetWindow.addEventListener("beforeunload", cleanup, { once: true });
|
|
263
|
+
return {
|
|
264
|
+
observeContentHeight: startObservingHeight,
|
|
265
|
+
dispose: cleanup
|
|
266
|
+
};
|
|
201
267
|
}
|
|
202
268
|
async function ignoreConnectionFailure(hostPromise) {
|
|
203
269
|
try {
|
|
@@ -233,7 +299,7 @@ async function reportContentHeight(hostPromise, { targetWindow, state }) {
|
|
|
233
299
|
} catch {}
|
|
234
300
|
}
|
|
235
301
|
function assertInitializationPayload(value) {
|
|
236
|
-
if (!isInitializationPayload(value)) throw new TypeError("
|
|
302
|
+
if (!isInitializationPayload(value)) throw new TypeError("插件界面初始化参数无效。");
|
|
237
303
|
}
|
|
238
304
|
function isInitializationPayload(value) {
|
|
239
305
|
if (!isRecord(value)) return false;
|
|
@@ -253,7 +319,7 @@ function isRecord(value) {
|
|
|
253
319
|
function getFatalMessage(error) {
|
|
254
320
|
if (error instanceof Error) return error.message;
|
|
255
321
|
if (typeof error === "string" && error.trim().length > 0) return error;
|
|
256
|
-
return "
|
|
322
|
+
return "插件界面遇到异常。";
|
|
257
323
|
}
|
|
258
324
|
//#endregion
|
|
259
325
|
//#region src/ui/types.ts
|
|
@@ -297,4 +363,4 @@ function resolveParentOrigins(targetWindow) {
|
|
|
297
363
|
return hostOrigin && hostOrigin !== "null" ? [hostOrigin] : ["*"];
|
|
298
364
|
}
|
|
299
365
|
//#endregion
|
|
300
|
-
export { PluginDesktopTarget, createPluginUiController, defineWorkbasePluginUi };
|
|
366
|
+
export { PluginDesktopTarget, PluginUiHostMethod, createPluginUiController, defineWorkbasePluginUi };
|