@mbws/plugin-sdk 0.3.9 → 0.3.11

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/client.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * 安全定位:客户端只是包装不是防线——插件绕过客户端手发消息伪造调用,
14
14
  * broker 对每条进入的消息仍按 manifest 独立校验(防线在宿主侧)。
15
15
  */
16
- import type { AttachmentState, CapsAttachmentEvent, CapsPickFileRequest, CapsUploadEvent, ExecJob, LocalizedInput, RegisteredOutput, ReservedOutput, UploadStatusPayload } from "./caps.js";
16
+ import type { AttachmentState, CapsAttachmentEvent, CapsPickFileRequest, CapsUploadEvent, ExecJob, HostCapabilities, LocalizedInput, MbwsRef, RegisteredOutput, 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";
@@ -43,7 +43,11 @@ export interface MbwsClient<C extends MbwsContractTypes = MbwsContractTypes> {
43
43
  /** 工人会话数据面:inputs/outputs 整体取数(对称)+ blob 换签名 URL + apply 写回。
44
44
  * 泛型 C 来自契约快照(mbws.contract.gen.ts)时,键与值类型随之收紧 */
45
45
  data?: {
46
- /** 全部输入 slot 值(契约输入键 → 值;按 manifest.inputs 圈定,数据最小化) */
46
+ /**
47
+ * 全部输入 slot 值(契约输入键 → 值;按 manifest.inputs 圈定,数据最小化)。
48
+ * 媒体字段的值是**引用句柄**(MbwsRef:local: 占位 / OSS objectKey),不是
49
+ * 展示名——取名/展示经 caps.exec.localize(ref).filename,不要对值做字符串解析
50
+ */
47
51
  inputs(): Promise<MbwsContractInputs<C>>;
48
52
  /**
49
53
  * 上次产出反演:本插件绑定输出字段的当前值(契约输出键 → 已产出值)。
@@ -91,15 +95,28 @@ export interface MbwsClient<C extends MbwsContractTypes = MbwsContractTypes> {
91
95
  panel: {
92
96
  resize(height: number): void;
93
97
  /**
94
- * 注册 before-close 应答者。promise 语义:回调返回 boolean/Promise<boolean>
95
- * 时 SDK 自动应答(true = 有未保存,宿主先弹「确认放弃」;false = 放行);
96
- * 返回 undefined 保持旧式——等插件稍后显式 replyBeforeClose。宿主等待
97
- * PANEL_BEFORE_CLOSE_TIMEOUT_MS(500ms)超时按放行关(防锁死),且插件
98
- * 无硬否决:dirty 应答后用户确认放弃仍会关。
98
+ * 自适应高度样板收敛:ResizeObserver 盯目标元素(缺省 document.body),尺寸变化
99
+ * 即上报 panel:resize,订阅即先报一次当前高度;返回停止观察函数。
100
+ * DOM/ResizeObserver 缺席时 no-op(返回空函数)。
101
+ */
102
+ autoResize(target?: HTMLElement | (() => HTMLElement)): () => void;
103
+ /**
104
+ * 注册 before-close 应答者。promise 语义:回调返回 boolean /
105
+ * `{ dirty, message? }` / Promise 同形时 SDK 自动应答(dirty=true 宿主先弹
106
+ * 「确认放弃」,message 可自定义弹窗文案如「当前段落将丢失,已完成段落已保存」,
107
+ * 200 字符内);返回 undefined 保持旧式——等插件稍后显式 replyBeforeClose。
108
+ * 宿主等待 PANEL_BEFORE_CLOSE_TIMEOUT_MS(500ms)超时按放行关(防锁死),
109
+ * 且插件无硬否决:dirty 应答后用户确认放弃仍会关。
99
110
  */
100
- onBeforeClose(cb: () => boolean | Promise<boolean> | undefined): void;
101
- /** 应答宿主的 before-close 询问(dirty=true 宿主先弹确认再关);旧式回调用 */
102
- replyBeforeClose(dirty: boolean): void;
111
+ onBeforeClose(cb: () => boolean | {
112
+ dirty: boolean;
113
+ message?: string;
114
+ } | Promise<boolean | {
115
+ dirty: boolean;
116
+ message?: string;
117
+ }> | undefined): void;
118
+ /** 应答宿主的 before-close 询问(dirty=true 宿主先弹确认再关,message 自定义文案);旧式回调用 */
119
+ replyBeforeClose(dirty: boolean, message?: string): void;
103
120
  /**
104
121
  * 插件主动请求关闭面板(加工+写回+上传全部完成后的自行收尾)。fire-and-forget:
105
122
  * 宿主收到后同样先走一次关闭询问(插件自己应答,自关闭场景一般回 false 放行)
@@ -128,20 +145,46 @@ export interface MbwsClient<C extends MbwsContractTypes = MbwsContractTypes> {
128
145
  * 主通道是 onAttachment 事件;本方法是轮询兜底与首屏快照读取。
129
146
  */
130
147
  attachmentStatus(name: string): Promise<AttachmentState>;
131
- /** 输入本地化:OSS objectKey 或 local: 占位 → job 沙箱相对路径(args 直接引用) */
132
- localize(ref: string): Promise<LocalizedInput>;
133
- /** 启动附件执行(args 插件全权组装,cwd = job 沙箱),返回 job 句柄 */
148
+ /**
149
+ * 输入本地化:OSS objectKey 或 local: 占位 → job 沙箱相对路径(args 直接引用)。
150
+ * 返回的 filename 是解码后的原始文件名——取名/展示直接用它(ref 是引用句柄,
151
+ * 对它 split("/").pop() 会得到乱码——local: 占位值是 URL 编码串)
152
+ */
153
+ localize(ref: MbwsRef | string): Promise<LocalizedInput>;
154
+ /**
155
+ * 启动附件执行(args 插件全权组装,cwd = job 沙箱),返回 job 句柄。
156
+ * spawn 是「派发任务」语义:队列执行方式(并发池/优先级/暂停恢复)归宿主决定,
157
+ * 插件无感;宿主保证行流与 exit 事件的顺序性(attachJob 回放/续流)与 jobResult
158
+ * 兜底语义不变。
159
+ *
160
+ * progress(进度声明化,可选):给出「分母」即把编码进度反显交宿主——args 需
161
+ * 自带 `-progress pipe:1 -nostats`(宿主不注入),宿主按 stdout 的 `out_time_us=`
162
+ * 行折算 ratio 并持有(面板关闭后上传中心仍显示「编码中 42%」,编码完成自动转正)。
163
+ * 面板开着时插件用同一条 onLine 流画自己的进度条,互不干扰。不声明零影响。
164
+ */
134
165
  spawn(req: {
135
166
  attachment: string;
136
167
  args: string[];
137
168
  timeoutMs?: number;
169
+ progress?: {
170
+ totalSeconds: number;
171
+ };
138
172
  }): Promise<ExecJob>;
173
+ /**
174
+ * 重挂后台 job(面板关闭再开续看):运行中返回 ExecJob——onLine 首订阅先回放
175
+ * 最近 200 行再续流实时行;已结束/不存在返回 null(走 jobResult 兜底拿结果)。
176
+ * 宿主侧 job 不随面板关闭被杀,编码在后台继续
177
+ */
178
+ attachJob(jobId: string): Promise<ExecJob | null>;
139
179
  /**
140
180
  * spawn 前产物名预占 + 覆盖预检(编码几分钟,跑完才发现同名冲突太浪费)。
141
181
  * 冲突源:dir 内既有同名文件 / 上传队列同路径条目。onConflict 缺省
142
182
  * auto-rename(返回可用最终名,`名 (1).ext` 递增);reject 返回 conflict 由插件处置。
143
183
  * dir 缺省 = job 沙箱 out/;绝对路径须在本会话 pickDirectory/pickFile 选中范围内。
144
184
  * 预占会在上传中心立一条 reserved 条目(编码中可见),registerOutput 到达转正。
185
+ *
186
+ * 占位符先行(0.3.10+):返回带 placeholder(与后续 registerOutput 返回同一值),
187
+ * 编码开始前即可 apply/commit 字段值;旧宿主不返回该字段(探测降级回编码后登记)
145
188
  */
146
189
  reserveOutput(req: {
147
190
  filename: string;
@@ -161,8 +204,12 @@ export interface MbwsClient<C extends MbwsContractTypes = MbwsContractTypes> {
161
204
  filename: string;
162
205
  contentType?: string;
163
206
  }): Promise<RegisteredOutput>;
164
- /** 媒体预览 URL:local: 占位 / OSS key → media-local://(桌面)或签名 URL */
165
- mediaUrl(ref: string): Promise<{
207
+ /**
208
+ * 媒体预览 URL:local: 占位 / OSS key → media-local://(桌面)或签名 URL。
209
+ * 产物还在编码(文件未落盘)时抛 E_NOT_READY(error.data 带 { status })——
210
+ * 据此渲染「编码中」占位卡,不是异常路径
211
+ */
212
+ mediaUrl(ref: MbwsRef | string): Promise<{
166
213
  url: string;
167
214
  mime?: string;
168
215
  }>;
@@ -196,12 +243,41 @@ export interface MbwsClient<C extends MbwsContractTypes = MbwsContractTypes> {
196
243
  onUpload(cb: (e: CapsUploadEvent) => void): () => void;
197
244
  };
198
245
  };
246
+ /**
247
+ * 宿主能力探测面(0.3.10 起恒授予):一次性拿宿主实际可调用的方法清单,
248
+ * 集中降级——替代散落各处的 `typeof mbws.caps?.exec?.xxx === "function"` 探测。
249
+ * 探测口径:invoke 方法(会进 methods 清单的)统一用 `can()`;订阅型成员
250
+ * (onChange 等不在清单的)用 `typeof`——两类口径不要混用。
251
+ */
252
+ host: {
253
+ /** 宿主方法面 + 所配 SDK 版本;面板启动调一次,按 methods.includes(...) 降级 */
254
+ capabilities(): Promise<HostCapabilities>;
255
+ /** 探测宿主是否支持某 invoke 方法(capabilities().methods.includes 的 memo 包装;0.3.11+) */
256
+ can(method: string): Promise<boolean>;
257
+ };
258
+ /**
259
+ * viewer 反显面(viewer 容器宿主授予;panel 宿主缺席 → undefined):
260
+ * `value()` 主动拉当前字段值(invoke,进 host.capabilities().methods);
261
+ * `onChange` 订阅运行期值变更(订阅不进 methods,探测走 typeof)。
262
+ * 加载期引导初值仍可走 receiveMbwsViewValue(window 通道)——两条通道分工:
263
+ * 全局位只承载引导初值,运行期变更只走 onChange,互不回写。
264
+ */
265
+ viewer?: {
266
+ value(): Promise<unknown>;
267
+ onChange(cb: (value: unknown) => void): () => void;
268
+ };
199
269
  /**
200
270
  * 数据结构(契约)面:拉关联任务的最新契约。不经宿主端口——服务端按插件编号
201
271
  * (manifest.id)公开派生,dev 预览/宿主内同一调用;故不随 grants 增减、恒在。
202
272
  */
203
273
  contract: {
204
274
  get(opts?: FetchContractOptions): Promise<PluginContract>;
275
+ /**
276
+ * 写回前探问:outputKey 的 fieldPath(点分路径,如 "segments.sourceRanges")
277
+ * 是否在契约 outputs schema 允许范围内——免得 apply 撞 write gate 才发现。
278
+ * 内部缓存契约(首次拉取后不再重复请求)
279
+ */
280
+ allows(outputKey: string, fieldPath: string): Promise<boolean>;
205
281
  };
206
282
  }
207
283
  /** 调用被拒时抛出的规范错误(error.code 是 9 错误码之一) */
package/dist/client.js CHANGED
@@ -1,5 +1,5 @@
1
- import { mergeAttachmentEvent, mergeUploadEvent } from "./caps.js";
2
- import { fetchContract } from "./contract.js";
1
+ import { asMbwsRef, mergeAttachmentEvent, mergeUploadEvent } from "./caps.js";
2
+ import { contractFieldAllowed, fetchContract, } from "./contract.js";
3
3
  import { createDevMockMbws } from "./dev-mock.js";
4
4
  import { MBWS_ERROR_CODES } from "./errors.js";
5
5
  import { parseMbwsMessage } from "./protocol.js";
@@ -66,6 +66,13 @@ export function connectMbwsPort(port, init, opts = {}) {
66
66
  // list() 结果按「缺才种入」并入(事件更新的条目比 list 响应新,不回退)
67
67
  const uploadStates = new Map();
68
68
  const uploadCbs = new Set();
69
+ // viewer 值变更订阅:事件只进订阅者,**不写 __MBWS_VALUE__**(全局位仅承载
70
+ // receiveMbwsViewValue 的加载期引导初值——单事实源,运行期变更只走 onChange)
71
+ const viewerCbs = new Set();
72
+ // host.capabilities 单次探测 memo:can() 高频细粒度调用,方法面会话内不漂移
73
+ let capabilitiesMemo = null;
74
+ // 契约单槽缓存(contract.allows 内部拉取用;显式 get(opts) 不动它)
75
+ let contractSnapshot = null;
69
76
  const jobSessionOf = (jobId) => {
70
77
  let session = jobSessions.get(jobId);
71
78
  if (!session) {
@@ -142,6 +149,12 @@ export function connectMbwsPort(port, init, opts = {}) {
142
149
  cancel: () => invoke("caps.exec", "cancelJob", { jobId }),
143
150
  onLine: (cb) => {
144
151
  const session = jobSessionOf(jobId);
152
+ // attach 回放:首个订阅者先吃 attach 前累积的行,此后走实时流
153
+ if (session.replayLines && session.replayLines.length > 0) {
154
+ for (const line of session.replayLines)
155
+ cb(line);
156
+ session.replayLines = [];
157
+ }
145
158
  session.lineCbs.add(cb);
146
159
  return () => session.lineCbs.delete(cb);
147
160
  },
@@ -172,9 +185,14 @@ export function connectMbwsPort(port, init, opts = {}) {
172
185
  break;
173
186
  }
174
187
  case "mbws:event": {
175
- // 取消事件桥到 AbortSignal;job/attachment/upload 事件路由进 caps 会话
188
+ // 取消事件桥到 AbortSignal;job/attachment/upload 事件路由进 caps 会话;
189
+ // viewer 事件只进订阅者(不回写 __MBWS_VALUE__——单事实源)
176
190
  if (message.event === "cancel")
177
191
  abortController.abort();
192
+ else if (message.event === "viewer") {
193
+ for (const cb of viewerCbs)
194
+ cb(message.payload);
195
+ }
178
196
  else if (message.event === "job" ||
179
197
  message.event === "attachment" ||
180
198
  message.event === "upload") {
@@ -183,12 +201,22 @@ export function connectMbwsPort(port, init, opts = {}) {
183
201
  break;
184
202
  }
185
203
  case "panel:before-close": {
186
- // promise 语义:回调返回 boolean/Promise 时自动应答;返回 undefined 保持
187
- // 旧式(等插件显式 replyBeforeClose);回调抛错按放行应答(防插件锁死面板)
204
+ // promise 语义:回调返回 boolean/{ dirty, message? }/Promise 同形时自动应答;
205
+ // 返回 undefined 保持旧式(等插件显式 replyBeforeClose);回调抛错按放行应答
206
+ // (防插件锁死面板)。message 随应答同发(H7 自定义关闭文案)。
188
207
  const result = beforeCloseCb?.();
189
208
  if (result !== undefined) {
190
209
  Promise.resolve(result)
191
- .then((dirty) => post({ v: PROTOCOL_VERSION, type: "panel:before-close-reply", dirty }))
210
+ .then((reply) => {
211
+ const dirty = typeof reply === "boolean" ? reply : reply.dirty;
212
+ const message = typeof reply === "boolean" || reply === undefined ? undefined : reply.message;
213
+ post({
214
+ v: PROTOCOL_VERSION,
215
+ type: "panel:before-close-reply",
216
+ dirty,
217
+ ...(message !== undefined ? { message } : {}),
218
+ });
219
+ })
192
220
  .catch((error) => {
193
221
  console.warn("[mbws] onBeforeClose 回调抛错,按放行应答", error);
194
222
  post({ v: PROTOCOL_VERSION, type: "panel:before-close-reply", dirty: false });
@@ -261,8 +289,28 @@ export function connectMbwsPort(port, init, opts = {}) {
261
289
  const spawned = (await invoke("caps.exec", "spawn", req));
262
290
  return makeExecJob(spawned.jobId);
263
291
  },
264
- reserveOutput: (req) => invoke("caps.exec", "reserveOutput", req),
265
- registerOutput: (req) => invoke("caps.exec", "registerOutput", req),
292
+ attachJob: async (jobId) => {
293
+ const attached = (await invoke("caps.exec", "attachJob", {
294
+ jobId,
295
+ }));
296
+ if (!attached)
297
+ return null; // 已结束/不存在——插件走 jobResult 兜底
298
+ const session = jobSessionOf(jobId);
299
+ session.replayLines = attached.replay;
300
+ return makeExecJob(jobId);
301
+ },
302
+ reserveOutput: async (req) => {
303
+ const reserved = (await invoke("caps.exec", "reserveOutput", req));
304
+ // 占位符先行:预占即发——拿到即可 apply/commit 字段值
305
+ if (reserved.placeholder)
306
+ reserved.placeholder = asMbwsRef(reserved.placeholder);
307
+ return reserved;
308
+ },
309
+ registerOutput: async (req) => {
310
+ const registered = (await invoke("caps.exec", "registerOutput", req));
311
+ registered.placeholder = asMbwsRef(registered.placeholder);
312
+ return registered;
313
+ },
266
314
  mediaUrl: (ref) => invoke("caps.exec", "mediaUrl", { ref }),
267
315
  pickDirectory: () => invoke("caps.exec", "pickDirectory", {}),
268
316
  pickFile: (req) => invoke("caps.exec", "pickFile", req ?? {}),
@@ -331,19 +379,81 @@ export function connectMbwsPort(port, init, opts = {}) {
331
379
  : {}),
332
380
  panel: {
333
381
  resize: (height) => post({ v: PROTOCOL_VERSION, type: "panel:resize", height }),
382
+ autoResize: (target) => {
383
+ // DOM/ResizeObserver 缺席(SSR/测试环境)no-op——面板高度自适应是尽力而为
384
+ if (typeof ResizeObserver === "undefined" || typeof document === "undefined") {
385
+ return () => { };
386
+ }
387
+ let el = null;
388
+ try {
389
+ el = typeof target === "function" ? target() : (target ?? document.body);
390
+ }
391
+ catch {
392
+ el = null;
393
+ }
394
+ if (!el)
395
+ return () => { };
396
+ const report = () => post({
397
+ v: PROTOCOL_VERSION,
398
+ type: "panel:resize",
399
+ height: Math.max(1, el.scrollHeight),
400
+ });
401
+ const observer = new ResizeObserver(report);
402
+ observer.observe(el);
403
+ report(); // 订阅即上报当前高度(宿主 clamp 自适应)
404
+ return () => observer.disconnect();
405
+ },
334
406
  onBeforeClose(cb) {
335
407
  beforeCloseCb = cb;
336
408
  },
337
- replyBeforeClose: (dirty) => post({ v: PROTOCOL_VERSION, type: "panel:before-close-reply", dirty }),
409
+ replyBeforeClose: (dirty, message) => post({
410
+ v: PROTOCOL_VERSION,
411
+ type: "panel:before-close-reply",
412
+ dirty,
413
+ ...(message !== undefined ? { message } : {}),
414
+ }),
338
415
  // fire-and-forget:是否真关由宿主关闭询问裁决(插件自关闭场景应答 false 放行)
339
416
  close: () => {
340
417
  post({ v: PROTOCOL_VERSION, type: "panel:close" });
341
418
  return Promise.resolve();
342
419
  },
343
420
  },
421
+ // 能力探测面:恒在(0.3.10+ 宿主 broker 常驻 case;旧宿主报 E_UNKNOWN_METHOD,
422
+ // 插件按 catch 降级——与探测语义一致)。can 是 capabilities 的 memo 包装,
423
+ // 探测失败按「不支持」处理(旧宿主 E_UNKNOWN_METHOD → false)
424
+ host: {
425
+ capabilities: () => (capabilitiesMemo ??= invoke("host", "capabilities")),
426
+ can: async (method) => {
427
+ try {
428
+ capabilitiesMemo ??= invoke("host", "capabilities");
429
+ const caps = await capabilitiesMemo;
430
+ return caps.methods.includes(method);
431
+ }
432
+ catch {
433
+ return false;
434
+ }
435
+ },
436
+ },
437
+ // viewer 反显面:viewer 容器授予(mbws:init grants 含 "viewer")才构造
438
+ ...(has("viewer")
439
+ ? {
440
+ viewer: {
441
+ value: () => invoke("viewer", "value"),
442
+ onChange: (cb) => {
443
+ viewerCbs.add(cb);
444
+ return () => viewerCbs.delete(cb);
445
+ },
446
+ },
447
+ }
448
+ : {}),
344
449
  // 契约面与端口无关(HTTP 直连),端口客户端/dev mock 同形,插件代码零分支
345
450
  contract: {
346
451
  get: (opts = {}) => fetchContract(opts),
452
+ allows: async (outputKey, fieldPath) => {
453
+ // 单槽缓存:allows 高频细粒度调用,契约拉一次够用(get 显式传 opts 时绕过缓存)
454
+ contractSnapshot ??= await fetchContract();
455
+ return contractFieldAllowed(contractSnapshot.outputs, outputKey, fieldPath);
456
+ },
347
457
  },
348
458
  };
349
459
  }
@@ -39,3 +39,13 @@ export interface FetchContractOptions {
39
39
  }
40
40
  /** 按插件编号拉关联任务的最新契约。非 2xx 抛带状态码与后端 message 的 Error。 */
41
41
  export declare function fetchContract(opts?: FetchContractOptions): Promise<PluginContract>;
42
+ /**
43
+ * 契约 outputs 探测:outputKey 下 fieldPath 是否被 schema 允许(写回前探问,
44
+ * 免得 apply 撞 write gate 才发现)。fieldPath 是点分路径(数组段用数字下标,
45
+ * 如 "segments.0.sourceRanges" 或省略下标直接 "segments.sourceRanges")。
46
+ *
47
+ * 逐段下行规则:object 看 properties 命中 / additionalProperties(false 拒、
48
+ * true 或缺省放行);array 钻 items 后按数字段剥掉继续;布尔 true 空 schema 恒真。
49
+ * 未声明的 outputKey 一律 false。
50
+ */
51
+ export declare function contractFieldAllowed(outputsSchemas: Record<string, unknown>, outputKey: string, fieldPath: string): boolean;
package/dist/contract.js CHANGED
@@ -70,3 +70,53 @@ export async function fetchContract(opts = {}) {
70
70
  updatedAt: String(data.updated_at ?? ""),
71
71
  };
72
72
  }
73
+ /**
74
+ * 契约 outputs 探测:outputKey 下 fieldPath 是否被 schema 允许(写回前探问,
75
+ * 免得 apply 撞 write gate 才发现)。fieldPath 是点分路径(数组段用数字下标,
76
+ * 如 "segments.0.sourceRanges" 或省略下标直接 "segments.sourceRanges")。
77
+ *
78
+ * 逐段下行规则:object 看 properties 命中 / additionalProperties(false 拒、
79
+ * true 或缺省放行);array 钻 items 后按数字段剥掉继续;布尔 true 空 schema 恒真。
80
+ * 未声明的 outputKey 一律 false。
81
+ */
82
+ export function contractFieldAllowed(outputsSchemas, outputKey, fieldPath) {
83
+ let schema = outputsSchemas[outputKey];
84
+ if (schema === undefined)
85
+ return false;
86
+ for (const rawSeg of fieldPath.split(".").filter(Boolean)) {
87
+ if (schema === true)
88
+ return true;
89
+ if (schema === false || typeof schema !== "object")
90
+ return false;
91
+ const node = schema;
92
+ // array 段:钻 items(数字下标剥掉;items 缺失视为元素无约束)
93
+ if (node.type === "array") {
94
+ schema = node.items ?? true;
95
+ if (/^\d+$/.test(rawSeg))
96
+ continue;
97
+ }
98
+ if (schema === true)
99
+ return true;
100
+ if (typeof schema !== "object")
101
+ return false;
102
+ // 标量 schema(string/number/…)下没有子路径可走——继续下行即不合法
103
+ const nodeType = schema.type;
104
+ if (typeof nodeType === "string" && nodeType !== "object" && nodeType !== "array") {
105
+ return false;
106
+ }
107
+ const obj = schema;
108
+ const props = obj.properties ?? undefined;
109
+ if (props && rawSeg in props) {
110
+ schema = props[rawSeg];
111
+ continue;
112
+ }
113
+ // 未在 properties 命中:additionalProperties 裁决(false 拒;true/缺省/schema 放行)
114
+ const additional = obj.additionalProperties;
115
+ if (additional === false)
116
+ return false;
117
+ if (additional === undefined || additional === true)
118
+ return true;
119
+ schema = additional; // schema 值:以该子 schema 继续下行
120
+ }
121
+ return true;
122
+ }
@@ -27,5 +27,7 @@ export declare function parseDevAttachmentFailure(stderrTail: string): CapsAttac
27
27
  /**
28
28
  * 创建 dev mock 客户端。固定命名空间 + caps 全部构造(dev 无授权语义),
29
29
  * panel 生命周期面上报/应答均无宿主可收,no-op 即可。
30
+ * MBWS_DEV_HOST_FACE=<ver> 时按方法引入版本摘掉新方法(对象属性真删——
31
+ * typeof 探测在旧 face 下真实失败,降级分支浏览器 dev 可测)。
30
32
  */
31
33
  export declare function createDevMockMbws(): MbwsClient;