@dp-bohrium/widget-sdk 0.7.0 → 0.8.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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export type { CapabilityRequest, CapabilityResult, FileDownloadResult, FileMutationId, FilePreviewContent, FilePreviewRenderRequest, FileReadInput, FileReadResult, FileReference, FileRevision, FileWriteInput, FileWriteResult, GrantedCapability, JsonValue, PanelContent, PanelRenderRequest, RenderRequest, RenderState, TaskObservationBatch, TaskObservationEvent, TaskObservationSnapshot, Theme, ThemeMode, WidgetActivationEvent, WidgetActivationEvents, WidgetContribution, WidgetError, WidgetErrorCode, WidgetEventName, WidgetFilePreviewContribution, WidgetLiveEvent, WidgetNetworkFetchInput, WidgetNetworkFetchOutput, WidgetPanelContribution, WidgetPluginContributions, WidgetPluginManifest, WidgetToolPhase, } from "./protocol/index.js";
2
- export { isWidgetActivationEvent, isWidgetEventName, WIDGET_ACTIVATION_EVENTS, WIDGET_EVENT_NAMES, } from "./protocol/index.js";
3
1
  export type { CompileWidgetPluginManifestOptions } from "./manifest.js";
4
2
  export { compileWidgetPluginManifest } from "./manifest.js";
3
+ export type { CapabilityRequest, CapabilityResult, FileDownloadResult, FileMutationId, FilePreviewContent, FilePreviewRenderRequest, FileReadInput, FileReadResult, FileReference, FileRevision, FileWriteInput, FileWriteResult, GrantedCapability, JsonValue, PanelContent, PanelRenderRequest, RenderRequest, RenderState, TaskObservationBatch, TaskObservationEvent, TaskObservationSnapshot, Theme, ThemeMode, WidgetActivationEvent, WidgetActivationEvents, WidgetContribution, WidgetError, WidgetErrorCode, WidgetEventName, WidgetFilePreviewContribution, WidgetLiveEvent, WidgetNetworkFetchInput, WidgetNetworkFetchOutput, WidgetPanelContribution, WidgetPluginContributions, WidgetPluginManifest, WidgetToolPhase, } from "./protocol/index.js";
4
+ export { isWidgetActivationEvent, isWidgetEventName, WIDGET_ACTIVATION_EVENTS, WIDGET_EVENT_NAMES, } from "./protocol/index.js";
5
5
  export type { HostUserEmail, HostUserEmailResult, HostUserProfile, HostUserProfileResult, WidgetHostUserClient, } from "./runtime/service.js";
6
6
  export type { FileDownloadCapabilityResult, FileReadCapabilityResult, FileWriteCapabilityResult, TaskListCapabilityResult, TaskWatchCapabilityResult, UiStateReadCapabilityResult, UiStateWriteCapabilityResult, WidgetActivation, WidgetCapabilityApi, WidgetContext, WidgetDisposable, WidgetEventApi, WidgetFileApi, WidgetHandle, WidgetHostOptions, WidgetModule, WidgetRenderContext, WidgetRenderHandler, WidgetTaskApi, WidgetUiApi, WidgetUiStateApi, } from "./widget.js";
7
7
  export { runWidgetHost } from "./widget.js";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { i as isWidgetActivationEvent, n as isWidgetEventName, r as WIDGET_ACTIVATION_EVENTS, t as WIDGET_EVENT_NAMES } from "./widget-events-BT0QxR-H.js";
2
- import { i as createWidgetClient, l as WIDGET_SDK_VERSION } from "./runtime-DZA7Gqzl.js";
3
- //#region ../widget-project/src/manifest-compiler.mjs
1
+ import { i as createWidgetClient, l as WIDGET_SDK_VERSION } from "./runtime-D2xmZVSb.js";
2
+ import { i as isWidgetActivationEvent, n as isWidgetEventName, r as WIDGET_ACTIVATION_EVENTS, t as WIDGET_EVENT_NAMES } from "./widget-events-gsKJbjqg.js";
3
+ //#region src/manifest.ts
4
4
  function compiledContribution(contribution) {
5
5
  switch (contribution.type) {
6
6
  case "panel": return {
@@ -14,8 +14,13 @@ function compiledContribution(contribution) {
14
14
  };
15
15
  }
16
16
  }
17
- /** 只编译协议数据;SDK 版本由可信调用方绑定,不读取安装或执行环境。 */
18
- function compileWidgetPluginManifest$1(manifest, sdkVersion, options = {}) {
17
+ /**
18
+ * 将开发者维护的插件清单编译为宿主可加载的宿主清单。
19
+ *
20
+ * 这是构建工具的边界函数,不是类型提示入口:作者直接编辑带 `$schema` 的 JSON,
21
+ * SDK 版本从当前安装包读取,宿主入口默认落到 dist/widget.js,内部 contribution 标识只在这里生成。
22
+ */
23
+ function compileWidgetPluginManifest(manifest, options = {}) {
19
24
  const samples = options.samples ?? manifest.samples;
20
25
  if (!samples || samples.length === 0) throw new Error("Widget Plugin Manifest must provide at least one sample before packaging");
21
26
  const contribution = manifest.contributes.widget;
@@ -27,9 +32,9 @@ function compileWidgetPluginManifest$1(manifest, sdkVersion, options = {}) {
27
32
  widgetConfig: {
28
33
  schemaVersion: 1,
29
34
  hostApiVersion: 1,
30
- widgetSdkVersion: sdkVersion,
35
+ widgetSdkVersion: WIDGET_SDK_VERSION,
31
36
  entry: options.hostEntry ?? "dist/widget.js",
32
- contribution: compiledContribution(manifest.contributes.widget),
37
+ contribution: compiledContribution(contribution),
33
38
  ...activationEvents === void 0 ? {} : { activationEvents },
34
39
  ...manifest.capabilities === void 0 ? {} : { requestedCapabilities: manifest.capabilities },
35
40
  ...manifest.runtime === void 0 ? {} : { runtime: manifest.runtime },
@@ -38,17 +43,6 @@ function compileWidgetPluginManifest$1(manifest, sdkVersion, options = {}) {
38
43
  };
39
44
  }
40
45
  //#endregion
41
- //#region src/manifest.ts
42
- /**
43
- * 将开发者维护的插件清单编译为宿主可加载的宿主清单。
44
- *
45
- * 这是构建工具的边界函数,不是类型提示入口:作者直接编辑带 `$schema` 的 JSON,
46
- * SDK 版本从当前安装包读取,宿主入口默认落到 dist/widget.js,内部 contribution 标识只在这里生成。
47
- */
48
- function compileWidgetPluginManifest(manifest, options = {}) {
49
- return compileWidgetPluginManifest$1(manifest, WIDGET_SDK_VERSION, options);
50
- }
51
- //#endregion
52
46
  //#region src/lifetime.ts
53
47
  function createWidgetLifetime(onError) {
54
48
  const controller = new AbortController();
@@ -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-DZA7Gqzl.js";
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-D2xmZVSb.js";
2
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 };
@@ -2,7 +2,7 @@ import { r as MessagePortTransport, t as ProtocolEndpoint } from "./protocol-end
2
2
  //#endregion
3
3
  //#region src/runtime/version.ts
4
4
  /** 从当前安装的 SDK package.json 读取版本,插件作者不需要重复填写。 */
5
- const WIDGET_SDK_VERSION = "0.7.0";
5
+ const WIDGET_SDK_VERSION = "0.8.0";
6
6
  //#endregion
7
7
  //#region src/runtime/network.ts
8
8
  const failureReasons = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- //#region ../contracts/src/plugin-manifest.ts
1
+ //#region src/protocol/plugin-manifest.ts
2
2
  /**
3
3
  * Widget Host 公开的固定激活事件。数组同时作为清单编辑器文档和 Host
4
4
  * 运行时校验的单一事实源;带工具名的事件使用下方的动态形式。
@@ -31,7 +31,7 @@ function isWidgetActivationEvent(value) {
31
31
  return typeof value === "string" && (WIDGET_ACTIVATION_EVENTS.includes(value) || TOOL_EVENT_PATTERN.test(value));
32
32
  }
33
33
  //#endregion
34
- //#region ../contracts/src/widget-events.ts
34
+ //#region src/protocol/widget-events.ts
35
35
  /**
36
36
  * Host 主动推送给已激活 Widget 的实时事件。`session.start` 只用于激活索引,
37
37
  * 不属于这组运行期事件;激活后首个可用快照通过 `context.render` 交付。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dp-bohrium/widget-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Bohrium Widget 开发者 SDK:在 Widget Bundle 内与 Host 建立 Bridge,并暴露生命周期与能力协议。",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "files": [
48
48
  "dist",
49
+ "!dist/validation",
49
50
  "assets",
50
51
  "schemas",
51
52
  "conformance",
@@ -66,26 +67,26 @@
66
67
  "tsdown": "0.22.14",
67
68
  "typescript": "^5.8.3",
68
69
  "vitest": "^3.2.4",
69
- "@dp-bohrium/widget-contracts": "0.7.0",
70
- "@dp-bohrium/widget-contract-testing": "0.1.0-alpha.0"
70
+ "ajv": "^8.17.1"
71
71
  },
72
72
  "scripts": {
73
- "build:runtime": "pnpm --filter @dp-bohrium/widget-contracts run build && tsdown && tsc -b tsconfig.build.json --force --pretty false && node ../../scripts/schema/build-sdk-assets.mjs",
74
- "build:cli": "node ../../scripts/schema/build-sdk-cli-assets.mjs && tsdown --config widget-cli.tsdown.config.ts && node --check dist/cli.mjs",
75
- "build": "pnpm build:runtime && pnpm --filter @dp-bohrium/widget-contract-testing build && pnpm build:cli",
76
- "typecheck": "tsc --noEmit",
73
+ "build:runtime": "node ../../scripts/build/widget-build.mjs runtime",
74
+ "build": "node ../../scripts/build/widget-build.mjs sdk",
75
+ "typecheck": "pnpm schema:check && tsc --noEmit",
77
76
  "test": "vitest run",
78
77
  "test:coverage": "vitest run --coverage --coverage.thresholds.lines=80 --coverage.thresholds.functions=80 --coverage.thresholds.statements=80 --coverage.thresholds.branches=70",
79
78
  "test:watch": "vitest",
80
- "fixture:build": "tsdown --config minimal-widget.tsdown.config.ts",
81
- "fixture:pack": "node ../../scripts/fixtures/pack-minimal-sdk-widget.mjs",
79
+ "fixture:build": "node ../../scripts/build/with-build.mjs sdk -- tsdown --config minimal-widget.tsdown.config.ts",
80
+ "fixture:pack": "node ../../scripts/build/with-build.mjs sdk -- node ../../scripts/fixtures/pack-minimal-sdk-widget.mjs",
82
81
  "fixture:pack:test": "node --test ../../scripts/fixtures/pack-minimal-sdk-widget.test.mjs",
83
- "fixture:check": "node ../../scripts/fixtures/check-minimal-sdk-widget.mjs",
82
+ "fixture:check": "node ../../scripts/build/with-build.mjs sdk -- node ../../scripts/fixtures/check-minimal-sdk-widget.mjs",
84
83
  "lint": "biome check src test",
85
84
  "format:check": "biome check --linter-enabled=false src test",
86
85
  "package:contents": "node ../../scripts/quality/check-sdk-package-contents.mjs ../../.artifacts/dp-bohrium-widget-sdk-*.tgz",
87
86
  "consumer:canary": "node ../../scripts/consumer/consumer-sdk-install.mjs ../../.artifacts/dp-bohrium-widget-sdk-*.tgz",
88
87
  "release:check-version": "WIDGET_PACKAGE_NAME=@dp-bohrium/widget-sdk node ../../scripts/release/check-registry-version.mjs",
89
- "check": "pnpm typecheck && pnpm test && pnpm fixture:build && pnpm fixture:pack:test && pnpm lint && pnpm format:check && pnpm --filter @dp-bohrium/widget-contract-testing build && pnpm build && pnpm fixture:pack && pnpm fixture:check"
88
+ "check": "pnpm typecheck && pnpm test && pnpm fixture:build && pnpm fixture:pack:test && pnpm lint && pnpm format:check && pnpm build && pnpm fixture:pack && pnpm fixture:check",
89
+ "schema:check": "node ../../scripts/schema/generate-types.mjs --check && node ../../scripts/schema/check-drift.mjs",
90
+ "build:tools": "node ../../scripts/build/widget-build.mjs tools"
90
91
  }
91
92
  }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 DP Technology
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.