@eworkbase/sdk 0.8.2 → 0.8.4
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/README.md
ADDED
|
@@ -15,6 +15,7 @@ interface PluginUiInitializationPayload {
|
|
|
15
15
|
readonly configurationRevision?: string;
|
|
16
16
|
/** Changes when the workspace is prepared again; route changes retain the same generation. */
|
|
17
17
|
readonly activationGeneration?: number;
|
|
18
|
+
readonly supportsRepositoryPush?: boolean;
|
|
18
19
|
readonly locale: string;
|
|
19
20
|
readonly params: Readonly<Record<string, unknown>>;
|
|
20
21
|
readonly project: PluginUiContextIdentity;
|
|
@@ -113,6 +114,23 @@ interface PluginUiDesktopOpenResult {
|
|
|
113
114
|
readonly path: string;
|
|
114
115
|
readonly targetId: string;
|
|
115
116
|
}
|
|
117
|
+
interface PluginUiRepositoryPushTarget {
|
|
118
|
+
readonly repositoryId: string;
|
|
119
|
+
readonly expectedHead: string;
|
|
120
|
+
}
|
|
121
|
+
type PluginUiRepositoryPushOutcome = {
|
|
122
|
+
readonly repositoryId: string;
|
|
123
|
+
} & ({
|
|
124
|
+
readonly status: 'up-to-date' | 'pending' | 'behind' | 'diverged' | 'unavailable';
|
|
125
|
+
readonly logId: string;
|
|
126
|
+
} | {
|
|
127
|
+
readonly status: 'failed';
|
|
128
|
+
readonly error: string;
|
|
129
|
+
});
|
|
130
|
+
interface PluginUiRepositoryPushResult {
|
|
131
|
+
readonly confirmed: boolean;
|
|
132
|
+
readonly results: readonly PluginUiRepositoryPushOutcome[];
|
|
133
|
+
}
|
|
116
134
|
interface WorkbasePluginUi {
|
|
117
135
|
/** Hides a resumable interaction without answering or cancelling it. */
|
|
118
136
|
readonly dismiss: () => Promise<void>;
|
|
@@ -124,6 +142,10 @@ interface WorkbasePluginUi {
|
|
|
124
142
|
readonly desktop: {
|
|
125
143
|
readonly open: (options: PluginUiDesktopOpenOptions) => Promise<PluginUiDesktopOpenResult>;
|
|
126
144
|
};
|
|
145
|
+
/** Requests host confirmation and pushes only the confirmed managed repository commits. */
|
|
146
|
+
readonly repositories: {
|
|
147
|
+
readonly push: (targets: readonly PluginUiRepositoryPushTarget[]) => Promise<PluginUiRepositoryPushResult>;
|
|
148
|
+
};
|
|
127
149
|
/** Plugin destinations open in a separate window; other app routes use ordinary navigation. */
|
|
128
150
|
readonly navigate: <Result = unknown>(to: string, options?: PluginUiNavigateOptions) => Promise<Result>;
|
|
129
151
|
readonly openOutput: <Result = unknown>(options: PluginUiOutputOptions) => Promise<Result>;
|
|
@@ -156,4 +178,4 @@ interface PluginUiControllerOptions {
|
|
|
156
178
|
readonly targetWindow: Window & typeof globalThis;
|
|
157
179
|
}
|
|
158
180
|
//#endregion
|
|
159
|
-
export {
|
|
181
|
+
export { WorkbasePluginUi as A, PluginUiRepositoryPushResult as C, PluginUiTransportConnection as D, PluginUiToastOptions as E, PluginUiView as O, PluginUiRepositoryPushOutcome as S, PluginUiStatus as T, PluginUiNavigateOptions as _, PluginUiContextIdentity as a, PluginUiPromptOptions as b, PluginUiDesktopOpenResult as c, PluginUiFileSelectOptions as d, PluginUiFileSelectionItemType as f, PluginUiInitializationPayload as g, PluginUiHostMethods as h, PluginUiCommands as i, WorkbasePluginUiDefinition as j, PluginUiViewIdentity as k, PluginUiExecutionChange as l, PluginUiHostError as m, PluginUiClientMethods as n, PluginUiControllerOptions as o, PluginUiFileSelectionScope as p, PluginUiCommandExecuteOptions as r, PluginUiDesktopOpenOptions as s, PluginDesktopTarget as t, PluginUiFileFilter as u, PluginUiOutputOptions as v, PluginUiRepositoryPushTarget as w, PluginUiPromptType as x, PluginUiPromptChoice as y };
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as WorkbasePluginUi, C as PluginUiRepositoryPushResult, D as PluginUiTransportConnection, E as PluginUiToastOptions, O as PluginUiView, S as PluginUiRepositoryPushOutcome, T as PluginUiStatus, _ as PluginUiNavigateOptions, a as PluginUiContextIdentity, b as PluginUiPromptOptions, c as PluginUiDesktopOpenResult, d as PluginUiFileSelectOptions, f as PluginUiFileSelectionItemType, g as PluginUiInitializationPayload, h as PluginUiHostMethods, i as PluginUiCommands, j as WorkbasePluginUiDefinition, k as PluginUiViewIdentity, l as PluginUiExecutionChange, m as PluginUiHostError, n as PluginUiClientMethods, o as PluginUiControllerOptions, p as PluginUiFileSelectionScope, r as PluginUiCommandExecuteOptions, s as PluginUiDesktopOpenOptions, t as PluginDesktopTarget, u as PluginUiFileFilter, v as PluginUiOutputOptions, w as PluginUiRepositoryPushTarget, x as PluginUiPromptType, y as PluginUiPromptChoice } from "../types-CRYQB_Tb.js";
|
|
2
2
|
//#region src/ui/controller.d.ts
|
|
3
3
|
export declare function createPluginUiController(definition: WorkbasePluginUiDefinition, options: PluginUiControllerOptions): WorkbasePluginUi;
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/ui/index.d.ts
|
|
6
6
|
export declare function defineWorkbasePluginUi(definition: WorkbasePluginUiDefinition): WorkbasePluginUi;
|
|
7
7
|
//#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 };
|
|
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 };
|
package/dist/ui/index.js
CHANGED
|
@@ -12,6 +12,7 @@ function createPluginUiController(definition, options) {
|
|
|
12
12
|
const state = {
|
|
13
13
|
fatalReportPromise: null,
|
|
14
14
|
isInitialized: false,
|
|
15
|
+
supportsRepositoryPush: false,
|
|
15
16
|
contentHeight: null,
|
|
16
17
|
recoverableHostErrors: /* @__PURE__ */ new WeakSet()
|
|
17
18
|
};
|
|
@@ -40,6 +41,7 @@ function createPluginUiController(definition, options) {
|
|
|
40
41
|
initialize: async (payload) => {
|
|
41
42
|
assertInitializationPayload(payload);
|
|
42
43
|
state.isInitialized = true;
|
|
44
|
+
state.supportsRepositoryPush = payload.supportsRepositoryPush === true;
|
|
43
45
|
initialization++;
|
|
44
46
|
try {
|
|
45
47
|
await onInit(payload);
|
|
@@ -91,6 +93,11 @@ function createPluginUiController(definition, options) {
|
|
|
91
93
|
function createHostRequest(hostPromise, state) {
|
|
92
94
|
return async (method, params) => {
|
|
93
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
|
+
}
|
|
94
101
|
const response = await (await hostPromise).call(method, params);
|
|
95
102
|
if (isRecord(response) && response.ok === true) return response.result;
|
|
96
103
|
const error = createHostError(response);
|
|
@@ -142,6 +149,7 @@ function createPluginUiApi(request, { targetWindow, subscribe, onFilesChanged })
|
|
|
142
149
|
closeOutput: (id) => request("output.close", { id }),
|
|
143
150
|
commands,
|
|
144
151
|
desktop: Object.freeze({ open: (options) => request("desktop.open", options) }),
|
|
152
|
+
repositories: Object.freeze({ push: (targets) => request("repository.push", targets) }),
|
|
145
153
|
navigate: (to, { replace = false } = {}) => request("navigate", {
|
|
146
154
|
replace,
|
|
147
155
|
to
|
package/dist/ui/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as WorkbasePluginUi, E as PluginUiToastOptions } from "../types-CRYQB_Tb.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;
|