@dp-bohrium/widget-sdk 0.2.0 → 0.3.0
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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/compatibility/testing.js +1 -1
- package/dist/index.js +5 -5
- package/dist/manifest.d.ts +1 -1
- package/dist/{protocol-endpoint-I78q3jVT.js → protocol-endpoint-CDz-YDGT.js} +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/{runtime-Dute9ozh.js → runtime-Drr96Awx.js} +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
本文件只记录影响使用者的变更:运行时 API、事件订阅、Manifest 要求。
|
|
4
4
|
|
|
5
|
+
## 0.3.0
|
|
6
|
+
|
|
7
|
+
### 破坏性变更
|
|
8
|
+
|
|
9
|
+
**1. RenderRequest 与 content 删除旧字段:slot 改为 contribution、panelType 改为 id**
|
|
10
|
+
|
|
11
|
+
- 已发布的 0.2.0 运行时仍读取 `request.slot`。本版改为用 `request.contribution` 收窄 `request.content`;`request.slot` 不再存在。
|
|
12
|
+
- `content.panelType` 改为 `content.id`,其余 `content` 的 `slot` 改为 `contribution`。
|
|
13
|
+
- `compileWidgetPluginManifest` 生成的宿主清单字段由 `widgetConfig.slot` 改为 `widgetConfig.contribution`;作者 Manifest 写法不变。
|
|
14
|
+
|
|
15
|
+
### 修复
|
|
16
|
+
|
|
17
|
+
**2. 同步公开类型文档**
|
|
18
|
+
|
|
19
|
+
- SDK 与 contracts 锁定同一版本,公开类型说明与 schema 一致。widget-cli 单独以 `0.1.0` 发布,不进入这次 SDK Tag。
|
|
20
|
+
|
|
5
21
|
## 0.2.0
|
|
6
22
|
|
|
7
23
|
### 新增
|
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ import type { WidgetContext } from "@dp-bohrium/widget-sdk";
|
|
|
45
45
|
|
|
46
46
|
export function activate(context: WidgetContext) {
|
|
47
47
|
context.render((request, renderContext) => {
|
|
48
|
-
|
|
48
|
+
renderContribution(request.contribution, request.content, renderContext.phase);
|
|
49
49
|
});
|
|
50
50
|
context.events.on("tool-call-result", () => {
|
|
51
51
|
void context.ui.present("floating");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as MemoryTransport, t as ProtocolEndpoint } from "../protocol-endpoint-
|
|
1
|
+
import { n as MemoryTransport, t as ProtocolEndpoint } from "../protocol-endpoint-CDz-YDGT.js";
|
|
2
2
|
//#region src/runtime/mock-host.ts
|
|
3
3
|
const widgetMessageTypes = /* @__PURE__ */ new Set([
|
|
4
4
|
"ready",
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { i as createWidgetClient, l as WIDGET_SDK_VERSION } from "./runtime-
|
|
1
|
+
import { i as createWidgetClient, l as WIDGET_SDK_VERSION } from "./runtime-Drr96Awx.js";
|
|
2
2
|
import { WIDGET_ACTIVATION_EVENTS, WIDGET_EVENT_NAMES, isWidgetActivationEvent, isWidgetEventName } from "@dp-bohrium/widget-contracts";
|
|
3
3
|
//#region src/manifest.ts
|
|
4
|
-
function
|
|
4
|
+
function compiledContribution(contribution) {
|
|
5
5
|
switch (contribution.type) {
|
|
6
6
|
case "panel": return {
|
|
7
7
|
type: "panel",
|
|
8
|
-
|
|
8
|
+
id: contribution.id,
|
|
9
9
|
...contribution.placement === void 0 ? {} : { placement: contribution.placement }
|
|
10
10
|
};
|
|
11
11
|
case "file-preview": return {
|
|
@@ -18,7 +18,7 @@ function compiledSlot(contribution) {
|
|
|
18
18
|
* 将开发者维护的插件清单编译为宿主可加载的宿主清单。
|
|
19
19
|
*
|
|
20
20
|
* 这是构建工具的边界函数,不是类型提示入口:作者直接编辑带 `$schema` 的 JSON,
|
|
21
|
-
* SDK 版本从当前安装包读取,宿主入口默认落到 dist/widget.js,内部
|
|
21
|
+
* SDK 版本从当前安装包读取,宿主入口默认落到 dist/widget.js,内部 contribution 标识只在这里生成。
|
|
22
22
|
*/
|
|
23
23
|
function compileWidgetPluginManifest(manifest, options = {}) {
|
|
24
24
|
const samples = options.samples ?? manifest.samples;
|
|
@@ -34,7 +34,7 @@ function compileWidgetPluginManifest(manifest, options = {}) {
|
|
|
34
34
|
hostApiVersion: 1,
|
|
35
35
|
widgetSdkVersion: WIDGET_SDK_VERSION,
|
|
36
36
|
entry: options.hostEntry ?? "dist/widget.js",
|
|
37
|
-
|
|
37
|
+
contribution: compiledContribution(manifest.contributes.widget),
|
|
38
38
|
...activationEvents === void 0 ? {} : { activationEvents },
|
|
39
39
|
...manifest.capabilities === void 0 ? {} : { requestedCapabilities: manifest.capabilities },
|
|
40
40
|
...manifest.runtime === void 0 ? {} : { runtime: manifest.runtime },
|
package/dist/manifest.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export interface CompileWidgetPluginManifestOptions {
|
|
|
8
8
|
* 将开发者维护的插件清单编译为宿主可加载的宿主清单。
|
|
9
9
|
*
|
|
10
10
|
* 这是构建工具的边界函数,不是类型提示入口:作者直接编辑带 `$schema` 的 JSON,
|
|
11
|
-
* SDK 版本从当前安装包读取,宿主入口默认落到 dist/widget.js,内部
|
|
11
|
+
* SDK 版本从当前安装包读取,宿主入口默认落到 dist/widget.js,内部 contribution 标识只在这里生成。
|
|
12
12
|
*/
|
|
13
13
|
export declare function compileWidgetPluginManifest(manifest: WidgetPluginManifest, options?: CompileWidgetPluginManifestOptions): WidgetManifest;
|
|
@@ -37,7 +37,7 @@ function isProtocolPayload(type, payload) {
|
|
|
37
37
|
const revision = property(payload, "revision");
|
|
38
38
|
const context = property(payload, "context");
|
|
39
39
|
const content = property(payload, "content");
|
|
40
|
-
return property(payload, "schemaVersion") === 1 && typeof property(payload, "requestId") === "string" && typeof property(payload, "instanceId") === "string" && typeof revision === "number" && Number.isSafeInteger(revision) && revision >= 1 && typeof property(payload, "
|
|
40
|
+
return property(payload, "schemaVersion") === 1 && typeof property(payload, "requestId") === "string" && typeof property(payload, "instanceId") === "string" && typeof revision === "number" && Number.isSafeInteger(revision) && revision >= 1 && typeof property(payload, "contribution") === "string" && typeof property(payload, "state") === "string" && isRecord(context) && isRecord(content);
|
|
41
41
|
}
|
|
42
42
|
case "event": return typeof property(payload, "type") === "string" && isRecord(property(payload, "payload"));
|
|
43
43
|
case "capability-result": return typeof property(payload, "requestId") === "string" && isRecord(property(payload, "result"));
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as isWidgetHostConnectMessage, c as WidgetClient, i as createWidgetClient, l as WIDGET_SDK_VERSION, n as WIDGET_HOST_CONNECT, o as PRESENTATION_CONFIRMATION_TIMEOUT_MS, r as WidgetRuntimeClient, s as REGION_CONFIRMATION_TIMEOUT_MS, t as WIDGET_BOOTSTRAP_READY } from "../runtime-
|
|
2
|
-
import { i as isWidgetProtocolMessage, r as MessagePortTransport } from "../protocol-endpoint-
|
|
1
|
+
import { a as isWidgetHostConnectMessage, c as WidgetClient, i as createWidgetClient, l as WIDGET_SDK_VERSION, n as WIDGET_HOST_CONNECT, o as PRESENTATION_CONFIRMATION_TIMEOUT_MS, r as WidgetRuntimeClient, s as REGION_CONFIRMATION_TIMEOUT_MS, t as WIDGET_BOOTSTRAP_READY } from "../runtime-Drr96Awx.js";
|
|
2
|
+
import { i as isWidgetProtocolMessage, r as MessagePortTransport } from "../protocol-endpoint-CDz-YDGT.js";
|
|
3
3
|
export { MessagePortTransport, PRESENTATION_CONFIRMATION_TIMEOUT_MS, REGION_CONFIRMATION_TIMEOUT_MS, WIDGET_BOOTSTRAP_READY, WIDGET_HOST_CONNECT, WIDGET_SDK_VERSION, WidgetClient, WidgetRuntimeClient, createWidgetClient, isWidgetHostConnectMessage, isWidgetProtocolMessage };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as MessagePortTransport, t as ProtocolEndpoint } from "./protocol-endpoint-
|
|
1
|
+
import { r as MessagePortTransport, t as ProtocolEndpoint } from "./protocol-endpoint-CDz-YDGT.js";
|
|
2
2
|
//#endregion
|
|
3
3
|
//#region src/runtime/version.ts
|
|
4
4
|
/** 从当前安装的 SDK package.json 读取版本,插件作者不需要重复填写。 */
|
|
5
|
-
const WIDGET_SDK_VERSION = "0.
|
|
5
|
+
const WIDGET_SDK_VERSION = "0.3.0";
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/runtime/network.ts
|
|
8
8
|
const failureReasons = /* @__PURE__ */ new Set([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dp-bohrium/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Bohrium Widget 开发者 SDK:在 Widget Bundle 内与 Host 建立 Bridge,并暴露生命周期与能力协议。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@dp-bohrium/widget-contracts": "0.
|
|
51
|
+
"@dp-bohrium/widget-contracts": "0.3.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@biomejs/biome": "^2.2.0",
|