@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.
- package/dist/{ExecutionLog.dto-ig9GUWhK.d.ts → ExecutionLog.dto-Bq2u5C90.d.ts} +1 -1
- package/dist/build.d.ts +54 -0
- package/dist/build.js +78 -0
- package/dist/components-DxL-99bM.js +131 -0
- package/dist/host-services-cIH3aYQD.js +5 -0
- package/dist/index.d.ts +20 -14
- package/dist/index.js +143 -245
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js +9 -2
- package/dist/style.css +4 -98
- package/dist/{types-2X-_T_W_.d.ts → types-DDEHTBRv.d.ts} +39 -101
- package/dist/{types-CRYQB_Tb.d.ts → types-b6G-gae3.d.ts} +29 -6
- package/dist/ui/components.d.ts +55 -0
- package/dist/ui/components.js +2 -0
- package/dist/ui/execution-log.d.ts +6 -2
- package/dist/ui/execution-log.js +11 -20
- package/dist/ui/hooks.d.ts +70 -0
- package/dist/ui/hooks.js +262 -0
- package/dist/ui/index.css +38 -165
- package/dist/ui/index.d.ts +44 -2
- package/dist/ui/index.js +3 -300
- 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/dist/ui-DGLeDJDe.js +436 -0
- package/package.json +40 -8
- package/tsconfig.node.json +13 -0
- package/tsconfig.ui.json +18 -0
package/dist/ui/index.js
CHANGED
|
@@ -1,300 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const MAX_FATAL_MESSAGE_LENGTH = 1e3;
|
|
5
|
-
const MIN_CONTENT_HEIGHT = 1;
|
|
6
|
-
function createPluginUiController(definition, options) {
|
|
7
|
-
const onInit = definition?.onInit;
|
|
8
|
-
const connectToHost = options?.connectToHost;
|
|
9
|
-
const targetWindow = options?.targetWindow;
|
|
10
|
-
if (typeof onInit !== "function") throw new TypeError("defineWorkbasePluginUi requires an onInit callback.");
|
|
11
|
-
if (!targetWindow || typeof connectToHost !== "function") throw new TypeError("Plugin UI transport is unavailable.");
|
|
12
|
-
const state = {
|
|
13
|
-
fatalReportPromise: null,
|
|
14
|
-
isInitialized: false,
|
|
15
|
-
supportsRepositoryPush: false,
|
|
16
|
-
contentHeight: null,
|
|
17
|
-
recoverableHostErrors: /* @__PURE__ */ new WeakSet()
|
|
18
|
-
};
|
|
19
|
-
const executionListeners = /* @__PURE__ */ new Set();
|
|
20
|
-
const fileListeners = /* @__PURE__ */ new Set();
|
|
21
|
-
let initialization = 0;
|
|
22
|
-
let refreshing = false;
|
|
23
|
-
let pending = false;
|
|
24
|
-
const clientMethods = {
|
|
25
|
-
filesChanged: async () => {
|
|
26
|
-
pending = true;
|
|
27
|
-
if (refreshing || initialization || !state.isInitialized) return;
|
|
28
|
-
refreshing = true;
|
|
29
|
-
try {
|
|
30
|
-
while (pending) {
|
|
31
|
-
pending = false;
|
|
32
|
-
await Promise.all([...fileListeners].map((refresh) => refresh()));
|
|
33
|
-
}
|
|
34
|
-
} finally {
|
|
35
|
-
refreshing = false;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
executionChanged: async (change) => {
|
|
39
|
-
if (state.isInitialized) [...executionListeners].forEach((listener) => listener(change));
|
|
40
|
-
},
|
|
41
|
-
initialize: async (payload) => {
|
|
42
|
-
assertInitializationPayload(payload);
|
|
43
|
-
state.isInitialized = true;
|
|
44
|
-
state.supportsRepositoryPush = payload.supportsRepositoryPush === true;
|
|
45
|
-
initialization++;
|
|
46
|
-
try {
|
|
47
|
-
await onInit(payload);
|
|
48
|
-
} finally {
|
|
49
|
-
initialization--;
|
|
50
|
-
}
|
|
51
|
-
if (pending) await clientMethods.filesChanged();
|
|
52
|
-
await waitForPluginUiPaint(targetWindow);
|
|
53
|
-
await reportContentHeight(hostPromise, {
|
|
54
|
-
targetWindow,
|
|
55
|
-
state
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const connection = connectToHost(clientMethods);
|
|
60
|
-
const hostPromise = connection.promise;
|
|
61
|
-
const request = createHostRequest(hostPromise, state);
|
|
62
|
-
bindPluginUiLifecycle({
|
|
63
|
-
connection,
|
|
64
|
-
state,
|
|
65
|
-
targetWindow
|
|
66
|
-
});
|
|
67
|
-
const subscribe = async (onChange) => {
|
|
68
|
-
const listener = (change) => onChange(change);
|
|
69
|
-
executionListeners.add(listener);
|
|
70
|
-
try {
|
|
71
|
-
await request("command.subscribe", { enabled: true });
|
|
72
|
-
} catch (error) {
|
|
73
|
-
executionListeners.delete(listener);
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
return async () => {
|
|
77
|
-
if (!executionListeners.delete(listener) || executionListeners.size) return;
|
|
78
|
-
await request("command.subscribe", { enabled: false });
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
const onFilesChanged = (refresh) => {
|
|
82
|
-
fileListeners.add(refresh);
|
|
83
|
-
return () => {
|
|
84
|
-
fileListeners.delete(refresh);
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
return createPluginUiApi(request, {
|
|
88
|
-
targetWindow,
|
|
89
|
-
subscribe,
|
|
90
|
-
onFilesChanged
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function createHostRequest(hostPromise, state) {
|
|
94
|
-
return async (method, params) => {
|
|
95
|
-
if (!state.isInitialized) throw new Error("Plugin UI is not initialized.");
|
|
96
|
-
if (method === "repository.push" && !state.supportsRepositoryPush) {
|
|
97
|
-
const error = /* @__PURE__ */ new Error("当前 Workbase 版本无法在插件内推送,请在工作区同步仓库。");
|
|
98
|
-
state.recoverableHostErrors.add(error);
|
|
99
|
-
throw error;
|
|
100
|
-
}
|
|
101
|
-
const response = await (await hostPromise).call(method, params);
|
|
102
|
-
if (isRecord(response) && response.ok === true) return response.result;
|
|
103
|
-
const error = createHostError(response);
|
|
104
|
-
state.recoverableHostErrors.add(error);
|
|
105
|
-
throw error;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function createHostError(response) {
|
|
109
|
-
const responseError = isRecord(response) && isRecord(response.error) ? response.error : null;
|
|
110
|
-
const message = typeof responseError?.message === "string" ? responseError.message : "Host action failed.";
|
|
111
|
-
const code = typeof responseError?.code === "string" ? responseError.code : "host_error";
|
|
112
|
-
return Object.assign(new Error(message), { code });
|
|
113
|
-
}
|
|
114
|
-
function createPluginUiApi(request, { targetWindow, subscribe, onFilesChanged }) {
|
|
115
|
-
const commands = Object.freeze({
|
|
116
|
-
subscribe,
|
|
117
|
-
reply: (executionId) => request("command.reply", { executionId }),
|
|
118
|
-
clear: (executionId) => request("command.clear", executionId === void 0 ? {} : { executionId }),
|
|
119
|
-
start: (commandId, input, options = {}) => request("command.start", {
|
|
120
|
-
commandId,
|
|
121
|
-
input,
|
|
122
|
-
executionId: options.executionId ?? targetWindow.crypto.randomUUID()
|
|
123
|
-
}),
|
|
124
|
-
query: (executionId) => request("command.query", { executionId: executionId ?? null }),
|
|
125
|
-
cancel: (executionId) => request("command.cancel", { executionId }),
|
|
126
|
-
execute: (commandId, input, options = {}) => {
|
|
127
|
-
return request("command.execute", {
|
|
128
|
-
commandId,
|
|
129
|
-
executionId: options.executionId ?? targetWindow.crypto.randomUUID(),
|
|
130
|
-
input
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
const status = Object.freeze({ resolve: (statusId, input) => request("status.resolve", {
|
|
135
|
-
input,
|
|
136
|
-
statusId
|
|
137
|
-
}) });
|
|
138
|
-
const view = Object.freeze({
|
|
139
|
-
onFilesChanged,
|
|
140
|
-
setModified: (modified) => request("view.modified", modified),
|
|
141
|
-
call: (method, input) => request("view.call", {
|
|
142
|
-
input,
|
|
143
|
-
method
|
|
144
|
-
})
|
|
145
|
-
});
|
|
146
|
-
return Object.freeze({
|
|
147
|
-
dismiss: () => request("interaction.dismiss", {}),
|
|
148
|
-
respond: (value) => request("interaction.respond", { value }),
|
|
149
|
-
closeOutput: (id) => request("output.close", { id }),
|
|
150
|
-
commands,
|
|
151
|
-
desktop: Object.freeze({ open: (options) => request("desktop.open", options) }),
|
|
152
|
-
repositories: Object.freeze({ push: (targets) => request("repository.push", targets) }),
|
|
153
|
-
navigate: (to, { replace = false } = {}) => request("navigate", {
|
|
154
|
-
replace,
|
|
155
|
-
to
|
|
156
|
-
}),
|
|
157
|
-
openOutput: (options) => request("output.open", options),
|
|
158
|
-
selectFiles: (options = {}) => request("file.select", options),
|
|
159
|
-
showPrompt: (options) => request("dialog.prompt", options),
|
|
160
|
-
showToast: (options) => request("toast.show", options),
|
|
161
|
-
status,
|
|
162
|
-
updateOutput: (options) => request("output.update", options),
|
|
163
|
-
view
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
function bindPluginUiLifecycle({ connection, state, targetWindow }) {
|
|
167
|
-
let resizeFrame = null;
|
|
168
|
-
const handleWindowError = (event) => {
|
|
169
|
-
if (!event.error && (event.message === "ResizeObserver loop completed with undelivered notifications." || event.message === "ResizeObserver loop limit exceeded")) return;
|
|
170
|
-
reportFirstFatal(connection.promise, state, event.error ?? event.message);
|
|
171
|
-
};
|
|
172
|
-
const handleUnhandledRejection = (event) => {
|
|
173
|
-
if (event.reason instanceof Error && state.recoverableHostErrors.has(event.reason)) return;
|
|
174
|
-
reportFirstFatal(connection.promise, state, event.reason);
|
|
175
|
-
};
|
|
176
|
-
const resizeObserver = new targetWindow.ResizeObserver(() => {
|
|
177
|
-
if (resizeFrame !== null) return;
|
|
178
|
-
resizeFrame = targetWindow.requestAnimationFrame(() => {
|
|
179
|
-
resizeFrame = null;
|
|
180
|
-
if (state.isInitialized) reportContentHeight(connection.promise, {
|
|
181
|
-
targetWindow,
|
|
182
|
-
state
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
const cleanup = () => {
|
|
187
|
-
targetWindow.removeEventListener("error", handleWindowError, true);
|
|
188
|
-
targetWindow.removeEventListener("unhandledrejection", handleUnhandledRejection);
|
|
189
|
-
targetWindow.removeEventListener("beforeunload", cleanup);
|
|
190
|
-
resizeObserver.disconnect();
|
|
191
|
-
if (resizeFrame !== null) targetWindow.cancelAnimationFrame(resizeFrame);
|
|
192
|
-
connection.destroy();
|
|
193
|
-
state.fatalReportPromise = null;
|
|
194
|
-
state.isInitialized = false;
|
|
195
|
-
};
|
|
196
|
-
ignoreConnectionFailure(connection.promise);
|
|
197
|
-
resizeObserver.observe(targetWindow.document.body ?? targetWindow.document.documentElement);
|
|
198
|
-
targetWindow.addEventListener("error", handleWindowError, true);
|
|
199
|
-
targetWindow.addEventListener("unhandledrejection", handleUnhandledRejection);
|
|
200
|
-
targetWindow.addEventListener("beforeunload", cleanup, { once: true });
|
|
201
|
-
}
|
|
202
|
-
async function ignoreConnectionFailure(hostPromise) {
|
|
203
|
-
try {
|
|
204
|
-
await hostPromise;
|
|
205
|
-
} catch {}
|
|
206
|
-
}
|
|
207
|
-
async function waitForPluginUiPaint(targetWindow) {
|
|
208
|
-
await new Promise((resolve) => {
|
|
209
|
-
targetWindow.requestAnimationFrame(() => {
|
|
210
|
-
targetWindow.requestAnimationFrame(() => resolve());
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
async function reportFirstFatal(hostPromise, state, error) {
|
|
215
|
-
if (!state.fatalReportPromise) state.fatalReportPromise = sendFatalReport(hostPromise, getFatalMessage(error).slice(0, MAX_FATAL_MESSAGE_LENGTH));
|
|
216
|
-
await state.fatalReportPromise;
|
|
217
|
-
}
|
|
218
|
-
async function sendFatalReport(hostPromise, message) {
|
|
219
|
-
try {
|
|
220
|
-
await (await hostPromise).reportFatal(message);
|
|
221
|
-
} catch {}
|
|
222
|
-
}
|
|
223
|
-
async function reportContentHeight(hostPromise, { targetWindow, state }) {
|
|
224
|
-
const contentElement = targetWindow.document.body ?? targetWindow.document.documentElement;
|
|
225
|
-
const height = Math.max(contentElement.offsetHeight, contentElement.scrollHeight);
|
|
226
|
-
if (!Number.isFinite(height)) return;
|
|
227
|
-
try {
|
|
228
|
-
const host = await hostPromise;
|
|
229
|
-
const contentHeight = Math.min(Math.max(Math.ceil(height), MIN_CONTENT_HEIGHT), MAX_CONTENT_HEIGHT);
|
|
230
|
-
if (!state.isInitialized || state.contentHeight === contentHeight) return;
|
|
231
|
-
state.contentHeight = contentHeight;
|
|
232
|
-
await host.reportContentHeight(contentHeight);
|
|
233
|
-
} catch {}
|
|
234
|
-
}
|
|
235
|
-
function assertInitializationPayload(value) {
|
|
236
|
-
if (!isInitializationPayload(value)) throw new TypeError("Plugin UI initialization payload is invalid.");
|
|
237
|
-
}
|
|
238
|
-
function isInitializationPayload(value) {
|
|
239
|
-
if (!isRecord(value)) return false;
|
|
240
|
-
if (value.configurationRevision !== void 0 && typeof value.configurationRevision !== "string") return false;
|
|
241
|
-
if (value.activationGeneration !== void 0 && (!Number.isSafeInteger(value.activationGeneration) || Number(value.activationGeneration) < 0)) return false;
|
|
242
|
-
return isContextIdentity(value.project) && isContextIdentity(value.workspace) && isViewIdentity(value.view);
|
|
243
|
-
}
|
|
244
|
-
function isContextIdentity(value) {
|
|
245
|
-
return isRecord(value) && typeof value.id === "string" && value.id.length > 0;
|
|
246
|
-
}
|
|
247
|
-
function isViewIdentity(value) {
|
|
248
|
-
return isContextIdentity(value) && isRecord(value) && typeof value.pluginId === "string" && value.pluginId.length > 0 && typeof value.title === "string" && value.title.length > 0;
|
|
249
|
-
}
|
|
250
|
-
function isRecord(value) {
|
|
251
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
252
|
-
}
|
|
253
|
-
function getFatalMessage(error) {
|
|
254
|
-
if (error instanceof Error) return error.message;
|
|
255
|
-
if (typeof error === "string" && error.trim().length > 0) return error;
|
|
256
|
-
return "Plugin UI failed.";
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/ui/types.ts
|
|
260
|
-
let PluginDesktopTarget = /* @__PURE__ */ function(PluginDesktopTarget) {
|
|
261
|
-
PluginDesktopTarget["Editor"] = "editor";
|
|
262
|
-
PluginDesktopTarget["Terminal"] = "terminal";
|
|
263
|
-
PluginDesktopTarget["Folder"] = "folder";
|
|
264
|
-
PluginDesktopTarget["Chatgpt"] = "chatgpt";
|
|
265
|
-
return PluginDesktopTarget;
|
|
266
|
-
}({});
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/ui/index.ts
|
|
269
|
-
/**
|
|
270
|
-
* Penpal browser entry for trusted Workbase plugin views.
|
|
271
|
-
*/
|
|
272
|
-
const BRIDGE_CHANNEL = "workbase-plugin-ui-v1";
|
|
273
|
-
const HOST_ORIGIN_PARAMETER = "__workbaseHostOrigin";
|
|
274
|
-
function defineWorkbasePluginUi(definition) {
|
|
275
|
-
const targetWindow = window;
|
|
276
|
-
return createPluginUiController(definition, {
|
|
277
|
-
connectToHost: (methods) => createPenpalConnection(targetWindow, methods),
|
|
278
|
-
targetWindow
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
function createPenpalConnection(targetWindow, methods) {
|
|
282
|
-
const connection = connect({
|
|
283
|
-
channel: BRIDGE_CHANNEL,
|
|
284
|
-
messenger: new WindowMessenger({
|
|
285
|
-
allowedOrigins: resolveParentOrigins(targetWindow),
|
|
286
|
-
remoteWindow: targetWindow.parent
|
|
287
|
-
}),
|
|
288
|
-
methods
|
|
289
|
-
});
|
|
290
|
-
return {
|
|
291
|
-
destroy: connection.destroy,
|
|
292
|
-
promise: connection.promise
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
function resolveParentOrigins(targetWindow) {
|
|
296
|
-
const hostOrigin = new URL(targetWindow.location.href).searchParams.get(HOST_ORIGIN_PARAMETER);
|
|
297
|
-
return hostOrigin && hostOrigin !== "null" ? [hostOrigin] : ["*"];
|
|
298
|
-
}
|
|
299
|
-
//#endregion
|
|
300
|
-
export { PluginDesktopTarget, createPluginUiController, defineWorkbasePluginUi };
|
|
1
|
+
import { t as DEFAULT_VIEW_STATE_TOPIC } from "../host-services-cIH3aYQD.js";
|
|
2
|
+
import { a as createPluginUiController, i as PluginUiHostMethod, n as defineWorkbasePluginUi, r as PluginDesktopTarget, t as createPluginClient } from "../ui-DGLeDJDe.js";
|
|
3
|
+
export { DEFAULT_VIEW_STATE_TOPIC, PluginDesktopTarget, PluginUiHostMethod, createPluginClient, createPluginUiController, defineWorkbasePluginUi };
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { t as parseMarkdownLink } from "../markdown-link-C-qw7xuN.js";
|
|
2
|
-
import { renderMarkdownPreview } from "./markdown-editor.js";
|
|
3
2
|
import { memo, useCallback, useEffect, useId, useRef, useState } from "react";
|
|
4
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import Markdown from "react-markdown";
|
|
5
|
+
import remarkGfm from "remark-gfm";
|
|
5
6
|
//#region src/ui/MarkdownLinks.tsx
|
|
6
7
|
/** Keeps Markdown navigation inside its document context while preserving mounted editors. */
|
|
7
8
|
const MAXIMUM_CACHED_DOCUMENTS = 8;
|
|
8
9
|
const DOCUMENT_SOURCE_SELECTOR = "[data-markdown-source]";
|
|
9
10
|
const HEADING_SELECTOR = "h1,h2,h3,h4,h5,h6";
|
|
10
|
-
const
|
|
11
|
+
const DISALLOWED_PREVIEW_ELEMENTS = [
|
|
12
|
+
"img",
|
|
13
|
+
"iframe",
|
|
14
|
+
"object",
|
|
15
|
+
"embed",
|
|
16
|
+
"audio",
|
|
17
|
+
"video",
|
|
18
|
+
"source",
|
|
19
|
+
"script",
|
|
20
|
+
"style",
|
|
21
|
+
"link",
|
|
22
|
+
"meta",
|
|
23
|
+
"base",
|
|
24
|
+
"form",
|
|
25
|
+
"button"
|
|
26
|
+
];
|
|
27
|
+
const REMARK_PLUGINS = [remarkGfm];
|
|
28
|
+
const PREVIEW_COMPONENTS = { input: DisabledPreviewCheckbox };
|
|
11
29
|
const MarkdownLinks = memo(function MarkdownLinks(props) {
|
|
12
30
|
return /* @__PURE__ */ jsx(MarkdownLinkBoundary, { ...props }, props.contextKey);
|
|
13
31
|
});
|
|
@@ -187,49 +205,41 @@ function MarkdownLinkBoundary({ host, children }) {
|
|
|
187
205
|
}
|
|
188
206
|
const MarkdownPreview = memo(function MarkdownPreview({ document: markdownDocument, onError }) {
|
|
189
207
|
const container = useRef(null);
|
|
190
|
-
const [isRendering, setRendering] = useState(true);
|
|
191
208
|
useEffect(() => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const template = document.createElement("template");
|
|
199
|
-
template.innerHTML = html;
|
|
200
|
-
template.content.querySelectorAll(INACTIVE_PREVIEW_ELEMENTS).forEach((element) => element.remove());
|
|
201
|
-
template.content.querySelectorAll("input[type=\"checkbox\"]").forEach((checkbox) => {
|
|
202
|
-
checkbox.disabled = true;
|
|
203
|
-
});
|
|
204
|
-
container.current.replaceChildren(template.content);
|
|
205
|
-
if (markdownDocument.fragment) scrollToAnchor(container.current, markdownDocument.fragment);
|
|
206
|
-
} catch (failure) {
|
|
207
|
-
if (!stopped) onError(readableError(failure));
|
|
208
|
-
} finally {
|
|
209
|
-
if (!stopped) setRendering(false);
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
render();
|
|
213
|
-
return () => {
|
|
214
|
-
stopped = true;
|
|
215
|
-
};
|
|
209
|
+
if (!markdownDocument.fragment || !container.current) return;
|
|
210
|
+
try {
|
|
211
|
+
scrollToAnchor(container.current, markdownDocument.fragment);
|
|
212
|
+
} catch (failure) {
|
|
213
|
+
onError(readableError(failure));
|
|
214
|
+
}
|
|
216
215
|
}, [
|
|
217
216
|
markdownDocument.content,
|
|
218
217
|
markdownDocument.fragment,
|
|
219
218
|
markdownDocument.revision,
|
|
220
219
|
onError
|
|
221
220
|
]);
|
|
222
|
-
return /* @__PURE__ */
|
|
221
|
+
return /* @__PURE__ */ jsx("div", {
|
|
223
222
|
"data-markdown-source": markdownDocument.path,
|
|
224
|
-
children:
|
|
225
|
-
role: "status",
|
|
226
|
-
children: "正在排版文档…"
|
|
227
|
-
}) : null, /* @__PURE__ */ jsx("div", {
|
|
223
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
228
224
|
ref: container,
|
|
229
|
-
className: "markdown-document-body
|
|
230
|
-
|
|
225
|
+
className: "markdown-document-body",
|
|
226
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
227
|
+
remarkPlugins: REMARK_PLUGINS,
|
|
228
|
+
disallowedElements: DISALLOWED_PREVIEW_ELEMENTS,
|
|
229
|
+
skipHtml: true,
|
|
230
|
+
components: PREVIEW_COMPONENTS,
|
|
231
|
+
children: markdownDocument.content
|
|
232
|
+
})
|
|
233
|
+
})
|
|
231
234
|
});
|
|
232
235
|
});
|
|
236
|
+
function DisabledPreviewCheckbox(props) {
|
|
237
|
+
if (props.type === "checkbox") return /* @__PURE__ */ jsx("input", {
|
|
238
|
+
...props,
|
|
239
|
+
disabled: true
|
|
240
|
+
});
|
|
241
|
+
return /* @__PURE__ */ jsx("input", { ...props });
|
|
242
|
+
}
|
|
233
243
|
function scrollToAnchor(root, fragment) {
|
|
234
244
|
if (!root) return;
|
|
235
245
|
if (!fragment) {
|
package/dist/ui/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as WorkbasePluginUi, O as PluginUiToastOptions } from "../types-b6G-gae3.js";
|
|
2
2
|
//#region src/ui/model.d.ts
|
|
3
3
|
/** A notification transport failure must not turn a completed operation into a failed one. */
|
|
4
4
|
export declare function showOperationToast(host: Pick<WorkbasePluginUi, "showToast">, options: PluginUiToastOptions): void;
|
|
@@ -18,7 +18,6 @@ export declare function configurationSavedMessage(publication: {
|
|
|
18
18
|
readonly warning: string | null;
|
|
19
19
|
}): string;
|
|
20
20
|
export declare function formatActionOutput(title: string, result: unknown, logs: unknown): PluginActionOutput;
|
|
21
|
-
export declare function formatActionError(title: string, error: unknown): PluginActionOutput;
|
|
22
21
|
export declare function readableError(error: unknown, fallback: string): string;
|
|
23
22
|
/** Keeps the actual cause visible while leaving stack frames in technical details. */
|
|
24
23
|
export declare function errorSummary(message: string): string;
|
package/dist/ui/model.js
CHANGED
|
@@ -23,13 +23,6 @@ function formatActionOutput(title, result, logs) {
|
|
|
23
23
|
title
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function formatActionError(title, error) {
|
|
27
|
-
return {
|
|
28
|
-
content: readableError(error, `${title}失败。`),
|
|
29
|
-
status: "failed",
|
|
30
|
-
title
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
26
|
function readableError(error, fallback) {
|
|
34
27
|
return error instanceof Error && error.message.trim().length > 0 ? error.message : fallback;
|
|
35
28
|
}
|
|
@@ -54,4 +47,4 @@ function isRecord(value) {
|
|
|
54
47
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
55
48
|
}
|
|
56
49
|
//#endregion
|
|
57
|
-
export { ConfigurationMode, TEAM_CONFIGURATION_NOTICE, configurationSavedMessage, errorSummary,
|
|
50
|
+
export { ConfigurationMode, TEAM_CONFIGURATION_NOTICE, configurationSavedMessage, errorSummary, formatActionOutput, readableError, showOperationToast };
|
package/dist/ui/theme.css
CHANGED
|
@@ -81,6 +81,17 @@
|
|
|
81
81
|
|
|
82
82
|
.workbase-brand-control[data-variant="subtle"] { color: var(--color-muted); }
|
|
83
83
|
|
|
84
|
+
.workbase-danger-control:not(:disabled):not([data-disabled]) {
|
|
85
|
+
border-color: var(--color-danger);
|
|
86
|
+
color: var(--color-inverse, #ffffff);
|
|
87
|
+
background: var(--color-danger);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.workbase-danger-control:active:not(:disabled):not([data-disabled]) {
|
|
91
|
+
background: #902908;
|
|
92
|
+
box-shadow: inset 0 1px 2px rgb(0 0 0 / 18%);
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
.mantine-Button-root:focus-visible,
|
|
85
96
|
.mantine-ActionIcon-root:focus-visible,
|
|
86
97
|
.mantine-Tabs-tab:focus-visible {
|
|
@@ -136,6 +147,11 @@
|
|
|
136
147
|
color: var(--color-brand-deep);
|
|
137
148
|
background: var(--color-surface-muted);
|
|
138
149
|
}
|
|
150
|
+
|
|
151
|
+
.workbase-danger-control:hover:not(:disabled):not([data-disabled]) {
|
|
152
|
+
border-color: #a52f09;
|
|
153
|
+
background: #a52f09;
|
|
154
|
+
}
|
|
139
155
|
}
|
|
140
156
|
|
|
141
157
|
.mantine-Button-root:disabled,
|
|
@@ -295,9 +311,115 @@
|
|
|
295
311
|
.mantine-Switch-track[data-checked] { border-color: var(--color-primary-hover); }
|
|
296
312
|
|
|
297
313
|
.mantine-UnstyledButton-root:focus-visible {
|
|
298
|
-
outline: 2px solid var(--color-
|
|
314
|
+
outline: 2px solid var(--color-accent);
|
|
299
315
|
outline-offset: 2px;
|
|
300
316
|
}
|
|
317
|
+
|
|
318
|
+
.workbase-pill {
|
|
319
|
+
--workbase-pill-color: var(--color-muted);
|
|
320
|
+
display: inline-flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
gap: 6px;
|
|
323
|
+
width: fit-content;
|
|
324
|
+
min-height: 24px;
|
|
325
|
+
flex-shrink: 0;
|
|
326
|
+
padding: 2px 8px;
|
|
327
|
+
border-radius: 4px;
|
|
328
|
+
color: var(--workbase-pill-color);
|
|
329
|
+
background: color-mix(in srgb, var(--workbase-pill-color) 8%, transparent);
|
|
330
|
+
font-size: var(--workbase-type-meta);
|
|
331
|
+
font-weight: 500;
|
|
332
|
+
line-height: 16px;
|
|
333
|
+
white-space: nowrap;
|
|
334
|
+
}
|
|
335
|
+
.workbase-pill[data-tone="success"] { --workbase-pill-color: var(--color-success); }
|
|
336
|
+
.workbase-pill[data-tone="warning"] { --workbase-pill-color: var(--color-warning); }
|
|
337
|
+
.workbase-pill[data-tone="danger"] { --workbase-pill-color: var(--color-danger); }
|
|
338
|
+
.workbase-pill[data-tone="info"] { --workbase-pill-color: var(--color-accent); }
|
|
339
|
+
.workbase-pill[data-tone="neutral"] { --workbase-pill-color: var(--color-muted); background: transparent; }
|
|
340
|
+
.workbase-pill-dot {
|
|
341
|
+
width: 6px;
|
|
342
|
+
height: 6px;
|
|
343
|
+
flex-shrink: 0;
|
|
344
|
+
border-radius: 50%;
|
|
345
|
+
background: currentColor;
|
|
346
|
+
opacity: 0.8;
|
|
347
|
+
}
|
|
348
|
+
.workbase-pill-spinner {
|
|
349
|
+
width: 11px;
|
|
350
|
+
height: 11px;
|
|
351
|
+
flex-shrink: 0;
|
|
352
|
+
border: 1.5px solid color-mix(in srgb, currentColor 28%, transparent);
|
|
353
|
+
border-top-color: currentColor;
|
|
354
|
+
border-radius: 50%;
|
|
355
|
+
animation: workbase-spin 0.8s linear infinite;
|
|
356
|
+
}
|
|
357
|
+
@keyframes workbase-spin { to { transform: rotate(360deg); } }
|
|
358
|
+
|
|
359
|
+
.workbase-empty-state {
|
|
360
|
+
display: grid;
|
|
361
|
+
min-height: 140px;
|
|
362
|
+
place-content: center;
|
|
363
|
+
justify-items: center;
|
|
364
|
+
gap: 6px;
|
|
365
|
+
padding: 32px 20px;
|
|
366
|
+
text-align: center;
|
|
367
|
+
}
|
|
368
|
+
.workbase-empty-icon {
|
|
369
|
+
display: inline-grid;
|
|
370
|
+
place-items: center;
|
|
371
|
+
width: 36px;
|
|
372
|
+
height: 36px;
|
|
373
|
+
margin-bottom: 4px;
|
|
374
|
+
border-radius: 10px;
|
|
375
|
+
background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
|
|
376
|
+
color: var(--color-accent);
|
|
377
|
+
}
|
|
378
|
+
.workbase-empty-title {
|
|
379
|
+
margin: 0;
|
|
380
|
+
color: var(--color-foreground);
|
|
381
|
+
font-size: var(--workbase-type-section);
|
|
382
|
+
font-weight: 600;
|
|
383
|
+
line-height: 1.4;
|
|
384
|
+
}
|
|
385
|
+
.workbase-empty-description {
|
|
386
|
+
margin: 0;
|
|
387
|
+
max-width: 56ch;
|
|
388
|
+
color: var(--color-muted);
|
|
389
|
+
font-size: var(--workbase-type-body);
|
|
390
|
+
line-height: 1.6;
|
|
391
|
+
}
|
|
392
|
+
.workbase-empty-action {
|
|
393
|
+
display: flex;
|
|
394
|
+
flex-wrap: wrap;
|
|
395
|
+
justify-content: center;
|
|
396
|
+
gap: 8px;
|
|
397
|
+
margin-top: 8px;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.workbase-error-boundary {
|
|
401
|
+
width: 100%;
|
|
402
|
+
min-height: 100%;
|
|
403
|
+
padding-block: 16px;
|
|
404
|
+
background: var(--color-surface-raised);
|
|
405
|
+
}
|
|
406
|
+
.workbase-error-retry {
|
|
407
|
+
display: inline-flex;
|
|
408
|
+
align-items: center;
|
|
409
|
+
justify-content: center;
|
|
410
|
+
min-height: 32px;
|
|
411
|
+
padding: 4px 12px;
|
|
412
|
+
border: 1px solid var(--color-border-strong);
|
|
413
|
+
border-radius: 6px;
|
|
414
|
+
background: var(--color-surface);
|
|
415
|
+
color: var(--color-foreground);
|
|
416
|
+
font: inherit;
|
|
417
|
+
font-size: var(--workbase-type-meta);
|
|
418
|
+
font-weight: 600;
|
|
419
|
+
cursor: pointer;
|
|
420
|
+
}
|
|
421
|
+
.workbase-error-retry:hover { background: var(--color-surface-muted); }
|
|
422
|
+
.workbase-error-retry:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
|
|
301
423
|
}
|
|
302
424
|
|
|
303
425
|
@layer components {
|