@mbws/plugin-sdk 0.3.17 → 0.3.19
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/caps.d.ts +14 -1
- package/dist/caps.js +2 -0
- package/dist/client.d.ts +10 -1
- package/dist/client.js +5 -0
- package/dist/dev-mock.js +33 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/caps.d.ts
CHANGED
|
@@ -189,6 +189,19 @@ export interface ReservedOutput {
|
|
|
189
189
|
export interface RegisteredOutput {
|
|
190
190
|
placeholder: MbwsRef;
|
|
191
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* caps.exec.renameOutput 返回:同目录物理改名结果。
|
|
194
|
+
* placeholder 与入参相同(已 commit 字段 / 上传主键冻结);filename 为最终落盘名。
|
|
195
|
+
*/
|
|
196
|
+
export interface RenamedOutput {
|
|
197
|
+
placeholder: MbwsRef;
|
|
198
|
+
/** 最终文件名(可能被 auto-rename 调整) */
|
|
199
|
+
filename: string;
|
|
200
|
+
/** 所在目录(未变) */
|
|
201
|
+
dirname: string;
|
|
202
|
+
/** onConflict:"reject" 且撞名时 */
|
|
203
|
+
conflict?: boolean;
|
|
204
|
+
}
|
|
192
205
|
/** caps.exec.spawn 返回的裸句柄(SDK 包装成 ExecJob;jobResult 断线兜底同形)。 */
|
|
193
206
|
export interface SpawnedJob {
|
|
194
207
|
jobId: string;
|
|
@@ -224,7 +237,7 @@ export interface ExecJob {
|
|
|
224
237
|
read(path: string, maxBytes?: number): Promise<string | null>;
|
|
225
238
|
}
|
|
226
239
|
/** caps.exec 方法白名单(宿主 broker 路由 + 参数校验依据,防调到桥内部方法)。 */
|
|
227
|
-
export declare const CAPS_EXEC_METHODS: readonly ["ensureAttachment", "attachmentStatus", "localize", "expandZip", "spawn", "attachJob", "jobResult", "cancelJob", "readFile", "reserveOutput", "registerOutput", "mediaUrl", "pickDirectory", "pickFile"];
|
|
240
|
+
export declare const CAPS_EXEC_METHODS: readonly ["ensureAttachment", "attachmentStatus", "localize", "expandZip", "spawn", "attachJob", "jobResult", "cancelJob", "readFile", "reserveOutput", "registerOutput", "renameOutput", "mediaUrl", "pickDirectory", "pickFile"];
|
|
228
241
|
export declare const CAPS_UPLOADS_METHODS: readonly ["status", "list"];
|
|
229
242
|
export type CapsExecMethod = (typeof CAPS_EXEC_METHODS)[number];
|
|
230
243
|
export type CapsUploadsMethod = (typeof CAPS_UPLOADS_METHODS)[number];
|
package/dist/caps.js
CHANGED
|
@@ -107,6 +107,7 @@ export const CAPS_EXEC_METHODS = [
|
|
|
107
107
|
"readFile",
|
|
108
108
|
"reserveOutput",
|
|
109
109
|
"registerOutput",
|
|
110
|
+
"renameOutput",
|
|
110
111
|
"mediaUrl",
|
|
111
112
|
"pickDirectory",
|
|
112
113
|
"pickFile",
|
|
@@ -140,6 +141,7 @@ export const METHOD_INTRODUCED_AT = {
|
|
|
140
141
|
"caps.exec.cancelJob": "0.3.0",
|
|
141
142
|
"caps.exec.readFile": "0.3.0",
|
|
142
143
|
"caps.exec.registerOutput": "0.3.0",
|
|
144
|
+
"caps.exec.renameOutput": "0.3.18",
|
|
143
145
|
"caps.exec.mediaUrl": "0.3.0",
|
|
144
146
|
"caps.exec.pickDirectory": "0.3.7",
|
|
145
147
|
"caps.exec.pickFile": "0.3.7",
|
package/dist/client.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 安全定位:客户端只是包装不是防线——插件绕过客户端手发消息伪造调用,
|
|
14
14
|
* broker 对每条进入的消息仍按 manifest 独立校验(防线在宿主侧)。
|
|
15
15
|
*/
|
|
16
|
-
import type { AttachmentState, CapsAttachmentEvent, CapsPickFileRequest, CapsUploadEvent, ExecJob, ExpandedZipResult, HostCapabilities, LocalizedInput, MbwsRef, RegisteredOutput, ReservedOutput, UploadStatusPayload } from "./caps.js";
|
|
16
|
+
import type { AttachmentState, CapsAttachmentEvent, CapsPickFileRequest, CapsUploadEvent, ExecJob, ExpandedZipResult, HostCapabilities, LocalizedInput, MbwsRef, RegisteredOutput, RenamedOutput, ReservedOutput, UploadStatusPayload } from "./caps.js";
|
|
17
17
|
import { type FetchContractOptions, type PluginContract } from "./contract.js";
|
|
18
18
|
import { type MbwsErrorCode } from "./errors.js";
|
|
19
19
|
import type { MbwsErrorPayload } from "./protocol.js";
|
|
@@ -211,6 +211,15 @@ export interface MbwsClient<C extends MbwsContractTypes = MbwsContractTypes> {
|
|
|
211
211
|
filename: string;
|
|
212
212
|
contentType?: string;
|
|
213
213
|
}): Promise<RegisteredOutput>;
|
|
214
|
+
/**
|
|
215
|
+
* 同目录物理改名已登记产物。placeholder 不变(已 commit 字段 / 上传主键冻结);
|
|
216
|
+
* 返回最终 filename。冲突缺省 auto-rename。可选——旧宿主不进 capabilities。
|
|
217
|
+
*/
|
|
218
|
+
renameOutput(req: {
|
|
219
|
+
placeholder: MbwsRef | string;
|
|
220
|
+
filename: string;
|
|
221
|
+
onConflict?: "auto-rename" | "reject";
|
|
222
|
+
}): Promise<RenamedOutput>;
|
|
214
223
|
/**
|
|
215
224
|
* 媒体预览 URL:local: 占位 / OSS key → media-local://(桌面)或签名 URL。
|
|
216
225
|
* 产物还在编码(文件未落盘)时抛 E_NOT_READY(error.data 带 { status })——
|
package/dist/client.js
CHANGED
|
@@ -311,6 +311,11 @@ export function connectMbwsPort(port, init, opts = {}) {
|
|
|
311
311
|
registered.placeholder = asMbwsRef(registered.placeholder);
|
|
312
312
|
return registered;
|
|
313
313
|
},
|
|
314
|
+
renameOutput: async (req) => {
|
|
315
|
+
const renamed = (await invoke("caps.exec", "renameOutput", req));
|
|
316
|
+
renamed.placeholder = asMbwsRef(renamed.placeholder);
|
|
317
|
+
return renamed;
|
|
318
|
+
},
|
|
314
319
|
mediaUrl: (ref) => invoke("caps.exec", "mediaUrl", { ref }),
|
|
315
320
|
pickDirectory: () => invoke("caps.exec", "pickDirectory", {}),
|
|
316
321
|
pickFile: (req) => invoke("caps.exec", "pickFile", req ?? {}),
|
package/dist/dev-mock.js
CHANGED
|
@@ -664,6 +664,39 @@ export function createDevMockMbws() {
|
|
|
664
664
|
simulateDevUpload(placeholder);
|
|
665
665
|
return { placeholder: asMbwsRef(placeholder) };
|
|
666
666
|
},
|
|
667
|
+
// dev 无真磁盘:只更新上传镜像展示名;placeholder 不变(与宿主同形)
|
|
668
|
+
renameOutput: async (req) => {
|
|
669
|
+
if (!req.filename || /[\\/]/.test(req.filename)) {
|
|
670
|
+
throw new Error("filename 必须是非空纯文件名(不含路径分隔符)");
|
|
671
|
+
}
|
|
672
|
+
const seeded = devUploadStates.get(req.placeholder);
|
|
673
|
+
if (!seeded)
|
|
674
|
+
throw new Error("local: 引用未登记");
|
|
675
|
+
if (seeded.status === "uploading")
|
|
676
|
+
throw new Error("上传中不可改名");
|
|
677
|
+
let finalName = req.filename;
|
|
678
|
+
if (devReservedNames.has(req.filename) && seeded.filename !== req.filename) {
|
|
679
|
+
if (req.onConflict === "reject") {
|
|
680
|
+
return {
|
|
681
|
+
placeholder: asMbwsRef(req.placeholder),
|
|
682
|
+
filename: req.filename,
|
|
683
|
+
dirname: "",
|
|
684
|
+
conflict: true,
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
finalName = devAvailableFilename(req.filename, (n) => n === seeded.filename ? false : devReservedNames.has(n));
|
|
688
|
+
}
|
|
689
|
+
if (seeded.filename)
|
|
690
|
+
devReservedNames.delete(seeded.filename);
|
|
691
|
+
devReservedNames.add(finalName);
|
|
692
|
+
seeded.filename = finalName;
|
|
693
|
+
console.info(`[mbws:dev] renameOutput(${req.placeholder})→${finalName}——dev 仅更新展示名`);
|
|
694
|
+
return {
|
|
695
|
+
placeholder: asMbwsRef(req.placeholder),
|
|
696
|
+
filename: finalName,
|
|
697
|
+
dirname: "",
|
|
698
|
+
};
|
|
699
|
+
},
|
|
667
700
|
mediaUrl: async (ref) => {
|
|
668
701
|
// 占位符先行:编码中(reserved,文件未落盘)→ E_NOT_READY 带 status,
|
|
669
702
|
// 插件/viewer 据此渲染「编码中」占位卡(与宿主同形)
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED