@mbws/plugin-sdk 0.3.1 → 0.3.2

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/version.d.ts CHANGED
@@ -12,4 +12,4 @@ export declare const PROTOCOL_VERSION: 1;
12
12
  * SDK 自身版本(与 package.json version 保持一致)。
13
13
  * init-ack 上报给宿主做审计,与 manifest.sdk(build 写入)交叉核对。
14
14
  */
15
- export declare const SDK_VERSION = "0.3.1";
15
+ export declare const SDK_VERSION = "0.3.2";
package/dist/version.js CHANGED
@@ -12,4 +12,4 @@ export const PROTOCOL_VERSION = 1;
12
12
  * SDK 自身版本(与 package.json version 保持一致)。
13
13
  * init-ack 上报给宿主做审计,与 manifest.sdk(build 写入)交叉核对。
14
14
  */
15
- export const SDK_VERSION = "0.3.1";
15
+ export const SDK_VERSION = "0.3.2";
package/dist/vite.js CHANGED
@@ -32,6 +32,14 @@ const DEFAULT_API_BASE = "https://union.mobiwusi.com";
32
32
  function resolveApiBase(config) {
33
33
  return (config.apiBaseUrl ?? process.env.MBWS_API_BASE_URL ?? DEFAULT_API_BASE).replace(/\/+$/, "");
34
34
  }
35
+ /**
36
+ * 官方附件库地址(构建期解析 platforms hash 用):env > 线上,**刻意不走
37
+ * config.apiBaseUrl**——它是本地联调字段,而附件库是平台生产设施,产物 hash 必须
38
+ * 钉生产库(在线构建容器里按本地地址 fetch 会不可达)。
39
+ */
40
+ function attachmentApiBase() {
41
+ return (process.env.MBWS_API_BASE_URL ?? DEFAULT_API_BASE).replace(/\/+$/, "");
42
+ }
35
43
  /** 读请求体(POST 等带 body 的转发用;GET/HEAD 直接跳过) */
36
44
  function readRequestBody(req) {
37
45
  return new Promise((resolve, reject) => {
@@ -59,7 +67,7 @@ export function mbwsVitePlugin(opts) {
59
67
  return [];
60
68
  if (resolvedAttachmentsCache)
61
69
  return resolvedAttachmentsCache;
62
- resolvedAttachmentsCache = await resolveAttachmentRefs(refs, resolveApiBase(config));
70
+ resolvedAttachmentsCache = await resolveAttachmentRefs(refs, attachmentApiBase());
63
71
  return resolvedAttachmentsCache;
64
72
  };
65
73
  // manifest 是纯派生物,构建/供给共用同一序列化姿势(尾换行对齐文件写习惯)。
@@ -182,7 +190,7 @@ export function mbwsVitePlugin(opts) {
182
190
  // mkdir 容错:在线构建场景 outDir 被平台覆盖,本目录可能不存在(写失败会炸构建)
183
191
  fs.mkdirSync(outDir, { recursive: true });
184
192
  const refs = config.attachments ?? [];
185
- const decls = refs.length > 0 ? await resolveAttachmentRefs(refs, resolveApiBase(config)) : [];
193
+ const decls = refs.length > 0 ? await resolveAttachmentRefs(refs, attachmentApiBase()) : [];
186
194
  fs.writeFileSync(path.join(outDir, "manifest.json"), `${JSON.stringify(buildManifest(config, { resolvedAttachments: decls }), null, 2)}\n`);
187
195
  },
188
196
  };
@@ -336,7 +344,7 @@ async function ensureLibraryAttachment(config, root, name, log) {
336
344
  let resolved = devAttachmentResolves.get(resolveKey);
337
345
  if (!resolved) {
338
346
  try {
339
- const response = await fetch(`${resolveApiBase(config)}/api/plugin-attachments/resolve` +
347
+ const response = await fetch(`${attachmentApiBase()}/api/plugin-attachments/resolve` +
340
348
  `?name=${encodeURIComponent(name)}&version=${encodeURIComponent(ref.version)}` +
341
349
  `&platform=${platform}`);
342
350
  // 未登记/平台缺失/后端不可达都归「dev 不可用」,交给调用方 501 文案
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbws/plugin-sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Moye 插件开发 SDK——panel/viewer 与宿主的类型定义与运行时端口适配",
5
5
  "license": "MIT",
6
6
  "type": "module",