@dp-bohrium/widget-sdk 0.5.0 → 0.7.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/AGENTS.md +13 -4
- package/CHANGELOG.md +39 -1
- package/README.md +33 -20
- package/assets/licenses/ajv@8.20.0/LICENSE +22 -0
- package/assets/licenses/fast-deep-equal@3.1.3/LICENSE +21 -0
- package/assets/licenses/fast-uri@3.1.6/LICENSE +30 -0
- package/assets/licenses/json-schema-traverse@1.0.0/LICENSE +21 -0
- package/assets/licenses/require-from-string@2.0.2/license +21 -0
- package/assets/licenses/widget-contracts.LICENSE +21 -0
- package/assets/licenses/widget-sdk.LICENSE +21 -0
- package/assets/schemas/host-runtime-config.schema.json +305 -0
- package/assets/schemas/widget-manifest.schema.json +361 -0
- package/assets/schemas/widget-plugin-manifest.schema.json +162 -0
- package/assets/schemas/widget-runtime-contracts.schema.json +2874 -0
- package/assets/toolchain.json +28 -0
- package/conformance/bridge/capability-request.json +23 -0
- package/conformance/bridge/files-download-request.json +23 -0
- package/conformance/bridge/files-read-versioned-request.json +25 -0
- package/conformance/bridge/files-write-request.json +25 -0
- package/conformance/bridge/files-write-success.json +25 -0
- package/conformance/bridge/network-fetch-denied.json +16 -0
- package/conformance/bridge/network-fetch-request.json +19 -0
- package/conformance/bridge/network-fetch-success.json +22 -0
- package/conformance/bridge/presentation-change-surface-request.json +14 -0
- package/conformance/bridge/presentation-close-request.json +14 -0
- package/conformance/bridge/presentation-close-success.json +11 -0
- package/conformance/bridge/presentation-downgrade-success.json +14 -0
- package/conformance/bridge/presentation-focus-backward-request.json +14 -0
- package/conformance/bridge/presentation-focus-boundary-success.json +14 -0
- package/conformance/bridge/presentation-focus-forward-request.json +14 -0
- package/conformance/bridge/presentation-init.json +70 -0
- package/conformance/bridge/presentation-policy-denied.json +16 -0
- package/conformance/bridge/presentation-present-request.json +14 -0
- package/conformance/bridge/presentation-user-denied.json +16 -0
- package/conformance/bridge/ready.json +11 -0
- package/conformance/bridge/region-acquire-request.json +14 -0
- package/conformance/bridge/tasks-list-request.json +17 -0
- package/conformance/bridge/tasks-watch-request.json +18 -0
- package/conformance/bridge/ui-state-write-request.json +18 -0
- package/conformance/bundles/minimal-file-preview/entry.js +1 -0
- package/conformance/bundles/minimal-file-preview/manifest.json +12 -0
- package/conformance/bundles/minimal-file-preview/samples/file-preview.json +1 -0
- package/conformance/bundles/minimal-panel/entry.js +1 -0
- package/conformance/bundles/minimal-panel/manifest.json +11 -0
- package/conformance/bundles/minimal-panel/samples/panel.json +1 -0
- package/conformance/bundles/minimal-tool-result/entry.js +1 -0
- package/conformance/bundles/minimal-tool-result/manifest.json +11 -0
- package/conformance/bundles/minimal-tool-result/samples/tool-result.json +1 -0
- package/conformance/file-grants/write.json +8 -0
- package/conformance/file-responses/list.json +1 -0
- package/conformance/file-responses/metadata.json +11 -0
- package/conformance/file-responses/mutation-conflict.json +6 -0
- package/conformance/file-responses/permission-denied.json +6 -0
- package/conformance/file-responses/read-revision-only.json +8 -0
- package/conformance/file-responses/read-unversioned-range.json +12 -0
- package/conformance/file-responses/read-versioned.json +12 -0
- package/conformance/file-responses/resource-limit.json +1 -0
- package/conformance/file-responses/revision-conflict.json +6 -0
- package/conformance/file-responses/text-content.json +7 -0
- package/conformance/file-responses/write-outcome-unknown.json +6 -0
- package/conformance/file-responses/write-success.json +15 -0
- package/conformance/host-runtime-config/invalid-host-service-expiry.json +85 -0
- package/conformance/host-runtime-config/invalid-host-service-identity.json +85 -0
- package/conformance/host-runtime-config/invalid-host-service-permission.json +85 -0
- package/conformance/host-runtime-config/invalid-host-service-status.json +65 -0
- package/conformance/host-runtime-config/invalid-missing-manifest-fields.json +55 -0
- package/conformance/host-runtime-config/invalid-static-origins.json +60 -0
- package/conformance/host-runtime-config/valid-host-service-authorization-required.json +65 -0
- package/conformance/host-runtime-config/valid-host-service-authorization.json +85 -0
- package/conformance/host-runtime-config/valid-no-requested-permissions.json +52 -0
- package/conformance/host-runtime-config/valid.json +85 -0
- package/conformance/invalid-bridge-messages/network-fetch-mixed-case-forbidden-header.json +21 -0
- package/conformance/invalid-file-grants/extra-file-scope.json +9 -0
- package/conformance/invalid-file-grants/missing-write-limits.json +4 -0
- package/conformance/invalid-file-requests/arbitrary-path.json +16 -0
- package/conformance/invalid-file-requests/missing-expected-revision.json +14 -0
- package/conformance/invalid-file-requests/missing-mutation-id.json +14 -0
- package/conformance/invalid-file-requests/path-in-reference.json +16 -0
- package/conformance/invalid-file-results/read-empty-revision.json +5 -0
- package/conformance/invalid-file-results/read-null-revision.json +5 -0
- package/conformance/invalid-file-results/write-missing-mutation-id.json +11 -0
- package/conformance/invalid-manifests/missing-target.json +11 -0
- package/conformance/invalid-manifests/presentation-duplicate-surfaces.json +16 -0
- package/conformance/invalid-manifests/presentation-empty-surfaces.json +14 -0
- package/conformance/invalid-manifests/presentation-unknown-surface.json +16 -0
- package/conformance/invalid-manifests/unknown-field.json +12 -0
- package/conformance/invalid-network-requests/mixed-case-forbidden-header.json +11 -0
- package/conformance/invalid-presentation-grants/duplicate-surfaces.json +5 -0
- package/conformance/invalid-presentation-grants/empty-surfaces.json +5 -0
- package/conformance/invalid-presentation-grants/false-confirmation.json +5 -0
- package/conformance/invalid-presentation-grants/missing-confirmation.json +4 -0
- package/conformance/invalid-presentation-grants/unknown-surface.json +5 -0
- package/conformance/invalid-presentation-requests/change-surface-missing-surface.json +4 -0
- package/conformance/invalid-presentation-requests/close-with-surface.json +4 -0
- package/conformance/invalid-presentation-requests/focus-boundary-missing-direction.json +4 -0
- package/conformance/invalid-presentation-requests/focus-boundary-unknown-direction.json +4 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-coordinates.json +9 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-event-provenance.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-generation.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-identity.json +12 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-key.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-modifiers.json +11 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-selector.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-surface.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-target.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-timestamp.json +8 -0
- package/conformance/invalid-presentation-requests/focus-boundary-with-z-index.json +8 -0
- package/conformance/invalid-presentation-requests/present-missing-surface.json +4 -0
- package/conformance/invalid-presentation-requests/unknown-surface.json +4 -0
- package/conformance/invalid-presentation-requests/widget-controls-coordinates.json +9 -0
- package/conformance/invalid-presentation-requests/widget-controls-geometry.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-instance-id.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-principal.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-run-id.json +4 -0
- package/conformance/invalid-presentation-requests/widget-controls-widget-id.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-widget-version-id.json +8 -0
- package/conformance/invalid-presentation-requests/widget-controls-z-index.json +4 -0
- package/conformance/invalid-render-inputs/malformed.json +17 -0
- package/conformance/manifests/valid-file-preview.json +12 -0
- package/conformance/manifests/valid-file-write-preview.json +30 -0
- package/conformance/manifests/valid-network.json +15 -0
- package/conformance/manifests/valid-panel.json +11 -0
- package/conformance/manifests/valid-presentation-panel.json +21 -0
- package/conformance/manifests/valid-region-panel.json +18 -0
- package/conformance/manifests/valid-tool-result.json +14 -0
- package/conformance/render-inputs/compatibility/literature-search-paper-results.json +75 -0
- package/conformance/render-inputs/compatibility/scientific-bibliography-bibtex.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-dataset-csv.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-manuscript-latex.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-manuscript-markdown.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-molecule-mol.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-molecule-mol2.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-notebook-ipynb.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-paper-pdf.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-protein-pdb.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-source-python.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-structure-cif.json +47 -0
- package/conformance/render-inputs/compatibility/scientific-structure-poscar.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-structure-stru.json +10 -0
- package/conformance/render-inputs/compatibility/scientific-trajectory-xyz.json +10 -0
- package/conformance/render-inputs/compatibility/thinking-process-paper-search.json +25 -0
- package/conformance/render-inputs/compatibility/thinking-process-scholar-search.json +25 -0
- package/conformance/render-inputs/compatibility/thinking-process-web-search.json +25 -0
- package/conformance/render-inputs/compatibility/workspace-file-search.json +24 -0
- package/conformance/render-inputs/compatibility/workspace-file-tree.json +24 -0
- package/conformance/render-inputs/empty.json +10 -0
- package/conformance/render-inputs/file-preview.json +10 -0
- package/conformance/render-inputs/incremental-update.json +10 -0
- package/conformance/render-inputs/large.json +10 -0
- package/conformance/render-inputs/malformed.json +1 -0
- package/conformance/render-inputs/panel.json +10 -0
- package/conformance/render-inputs/partial-state-full-snapshot.json +40 -0
- package/conformance/render-inputs/tool-result.json +10 -0
- package/conformance/resource-budgets/corpus.json +431 -0
- package/dist/cli.mjs +15618 -0
- package/dist/contracts.d.ts +2 -0
- package/dist/contracts.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -11
- package/dist/manifest.d.ts +1 -1
- package/dist/protocol/generated-host-runtime-config.d.ts +551 -0
- package/dist/protocol/generated-manifest.d.ts +192 -0
- package/dist/protocol/generated-plugin-manifest.d.ts +176 -0
- package/dist/protocol/generated-runtime-contracts.d.ts +1224 -0
- package/dist/protocol/index.d.ts +43 -0
- package/dist/protocol/plugin-manifest.d.ts +30 -0
- package/dist/protocol/widget-events.d.ts +13 -0
- package/dist/runtime/bootstrap.d.ts +1 -1
- package/dist/runtime/client.d.ts +1 -1
- package/dist/runtime/event-validation.d.ts +1 -1
- package/dist/runtime/events.d.ts +1 -1
- package/dist/runtime/files.d.ts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/mock-host.d.ts +1 -1
- package/dist/runtime/network.d.ts +1 -1
- package/dist/runtime/protocol-endpoint.d.ts +1 -1
- package/dist/runtime/service.d.ts +2 -2
- package/dist/runtime/transport.d.ts +1 -1
- package/dist/{runtime-DVFTv55x.js → runtime-DZA7Gqzl.js} +1 -1
- package/dist/widget-events-BT0QxR-H.js +65 -0
- package/dist/widget.d.ts +2 -2
- package/llms.txt +8 -1
- package/package.json +18 -6
- package/schemas/host-runtime-config.schema.json +305 -0
- package/schemas/widget-manifest.schema.json +361 -0
- package/schemas/widget-plugin-manifest.schema.json +162 -0
- package/schemas/widget-runtime-contracts.schema.json +2874 -0
package/AGENTS.md
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
# Widget SDK Agent 使用说明
|
|
2
2
|
|
|
3
|
-
`@dp-bohrium/widget-sdk` 是
|
|
3
|
+
`@dp-bohrium/widget-sdk` 是 Widget 作者的统一代码、类型与 Schema 入口。Agent 先读取 `llms.txt`,再
|
|
4
4
|
根据任务选择高层 Widget API、低层 Runtime API 或测试入口;不要自行实现 Bridge 握手。
|
|
5
5
|
|
|
6
6
|
## 常用动作
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
pnpm add @dp-bohrium/widget-sdk
|
|
10
|
+
pnpm dlx @dp-bohrium/widget-sdk create my-widget --template panel
|
|
10
11
|
```
|
|
11
12
|
|
|
12
|
-
1. 用 `activate(context)` 实现 Widget
|
|
13
|
+
1. 用 SDK 自带的 `bohr-widget` 创建工程,再用 `activate(context)` 实现 Widget;生成工程只直接依赖 SDK。
|
|
13
14
|
2. 在 Manifest 中声明所需 capability,再使用 `context.capabilities`、`context.files`、
|
|
14
15
|
`context.tasks`、`context.ui` 或 `context.network`。
|
|
15
16
|
3. 在测试中使用 `@dp-bohrium/widget-sdk/testing` 的 `MockWidgetHost`;生产 Bundle 使用
|
|
16
17
|
根入口,不把 testing 入口打进产物。
|
|
17
|
-
4.
|
|
18
|
+
4. 常用作者类型从根入口获取;完整协议用 `/contracts`,编辑器 Schema 用 `/schemas/*.json`。
|
|
19
|
+
SDK 与开发工具负责核对内置协议资产与摘要,生成的作者工程不需要重复安装 Contracts 或 CLI。
|
|
20
|
+
升级旧作者工程时,在新目录准备迁移候选并重新构建,不复用不匹配的执行器。
|
|
21
|
+
5. 低层协议客户端从 `@dp-bohrium/widget-sdk/runtime` 导入。根入口的 `WidgetRenderContext`
|
|
22
|
+
表示渲染回调的 phase/signal,协议同名类型从 `/contracts` 导入。
|
|
18
23
|
|
|
19
24
|
## 错误恢复
|
|
20
25
|
|
|
@@ -30,4 +35,8 @@ pnpm add @dp-bohrium/widget-sdk
|
|
|
30
35
|
|
|
31
36
|
SDK 不授予权限、不上传或发布 Bundle、不决定 iframe/CSP 策略,也不保证脱离 Host 可以运行。
|
|
32
37
|
`ok=true` 只表示当前调用被 Runtime/Host 接受;真实授权、渲染和生产绑定由 Host 与平台负责。
|
|
33
|
-
|
|
38
|
+
工程依赖使用精确 SemVer;升级 SDK 时让开发工具核对配套协议和生成 Bundle 的 digest。
|
|
39
|
+
SDK 的 Node 命令与浏览器 Runtime 使用独立构建入口;不要从根入口或 `/runtime` 导入 CLI 模块。
|
|
40
|
+
|
|
41
|
+
当前执行器采用 integration v3、toolchain v3、工程锁 v2 和 receipt v2。SDK 自包含协议与声明,
|
|
42
|
+
`protocol` 记录固定协议字段版本及 Schema 内容摘要;旧锁或 receipt 必须显式迁移或重新构建。
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
# `@dp-bohrium/widget-sdk` 变更记录
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- af5aee4: 破坏性变更:取消 `files.read` 的累计字节额度,让文件预览和 Panel 可以持续读取已授权文件。
|
|
8
|
+
`resourceBudget.files.readBytesPerRun` 与读取 grant 的 `bytesPerRun` 改为已废弃的可选历史字段;
|
|
9
|
+
新宿主不再下发或执行这两项额度。单次大小、调用频率、并发、授权以及写入、下载和状态预算不变。
|
|
10
|
+
|
|
11
|
+
消费者须先升级协议与宿主校验器,再省略旧字段;仍要求历史字段的旧宿主不能消费新配置。
|
|
12
|
+
- 破坏性变更:SDK 自包含协议类型、Schema、测试语料和 `bohr-widget` 命令,Widget 工程只需安装 SDK。
|
|
13
|
+
Host 或控制面可使用 SDK 的协议子入口,也可独立安装同版 `@dp-bohrium/widget-contracts@0.7.0`。
|
|
14
|
+
|
|
15
|
+
integration/toolchain 升为 v3,工程锁和构建回执(receipt)升为 v2。旧工程须保留原源码,
|
|
16
|
+
在新目录按当前模板迁移并重新构建;旧格式的锁和回执不能直接复用。
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 86773d8: 修复开发 Host 面板投影使用 `snapshot.id` 而被正式 Host 拒绝的问题,统一输出既有契约要求的
|
|
21
|
+
`snapshot.panelType`,并同步开发会话类型声明。Manifest 的 `contribution.id` 和
|
|
22
|
+
RenderRequest 的 `content.id` 保持原义。
|
|
23
|
+
|
|
24
|
+
## 0.6.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- 7c21acf: SDK 发布包新增 `bohr-widget` 可执行入口并内置固定工具链资产,使新工程只需精确安装 SDK 即可完成
|
|
29
|
+
创建、构建、校验、开发和打包。现有 widget-cli 暂按现行发布治理复用同一份命令实现与原有分发身份,
|
|
30
|
+
作为过渡兼容分发;两种入口创建或迁移的新工程都只依赖 SDK,SDK bin 不根据旧工程依赖回选历史执行器。
|
|
31
|
+
两包同时安装时不保证同名命令保留旧 CLI 身份;旧工程须移除 CLI、重新安装,并由 SDK 重新构建 receipt
|
|
32
|
+
后再校验与打包,receipt 严格校验不变。
|
|
33
|
+
复用的命令源码与构建输入纳入 SDK 版本门禁;本次不改变 integration v2、工程锁或发布 Tag 协议。
|
|
34
|
+
Widget 作者 skill 同步改用 SDK 创建入口,避免 Agent 为新工程重新引入独立 CLI 依赖。
|
|
35
|
+
- 31e930e: 统一 Widget 作者入口:SDK 根入口导出常用作者类型,并新增 `/contracts`、`/schemas/*.json` 和
|
|
36
|
+
`/conformance/*` 子入口,使作者与 Host 无需直接安装 contracts。直接声明或导入 contracts 的旧用法
|
|
37
|
+
进入迁移期,统一入口切换发布 R1 前应迁移到 SDK;规范协议类型仍由 contracts 唯一维护。
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- @dp-bohrium/widget-contracts@0.6.0
|
|
4
42
|
|
|
5
43
|
## 0.5.0
|
|
6
44
|
|
package/README.md
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
# @dp-bohrium/widget-sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Widget 开发者 SDK。普通作者只实现 `activate(context)` 和可选的 `deactivate()`;CLI
|
|
7
|
-
会生成 Widget Host 入口,负责向 Host 宣告 Bundle、接收转移过来的 `MessagePort`,并暴露共享的
|
|
3
|
+
Widget 开发者 SDK,也是创建、构建、校验、开发和打包 Widget 的统一安装入口。普通作者只实现
|
|
4
|
+
`activate(context)` 和可选的 `deactivate()`;SDK 自带的 `bohr-widget` 会生成 Widget Host 入口,
|
|
5
|
+
负责向 Host 宣告 Bundle、接收转移过来的 `MessagePort`,并暴露共享的
|
|
8
6
|
生命周期与能力协议。作者无需直接处理 `window.postMessage`,也无需手动启动插件。
|
|
9
7
|
|
|
8
|
+
使用 Agent 开发时,先读 [`llms.txt`](./llms.txt) 获取文档索引,再读 [`AGENTS.md`](./AGENTS.md)
|
|
9
|
+
了解安装、运行时调用和错误恢复规则。
|
|
10
|
+
|
|
10
11
|
激活事件目录、`context.events` 与低层 `topic` 的边界以本包的 `AGENTS.md`、本 README
|
|
11
|
-
|
|
12
|
+
和本包公开的类型与 Schema 为准;协议实现保持同一份事实源。
|
|
12
13
|
|
|
13
14
|
## 环境要求
|
|
14
15
|
|
|
15
16
|
| 项 | 要求 |
|
|
16
17
|
| --- | --- |
|
|
17
|
-
| Node.js | ≥ 20
|
|
18
|
+
| Node.js | ≥ 20(执行 `bohr-widget` 与构建时;Widget 产物运行在浏览器 iframe 内) |
|
|
18
19
|
| 源码格式 | 纯 ESM,必须经打包器处理后交付 |
|
|
19
20
|
| 运行环境 | 必须由 Bohrium Host 加载,脱离 Host 无法完成握手 |
|
|
20
21
|
| 产物格式 | Host iframe 为 `sandbox="allow-scripts"` 且无 `allow-same-origin` 时,打成 classic script / IIFE(隔离源下 `type="module"` 需要 CORS) |
|
|
21
22
|
|
|
22
23
|
## 安装
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
[`@dp-bohrium/widget-contracts`](https://www.npmjs.com/package/@dp-bohrium/widget-contracts)
|
|
26
|
-
即可。
|
|
25
|
+
安装 SDK 即可获得 Widget API、协议类型、JSON Schema、测试工具和 `bohr-widget` 命令。
|
|
27
26
|
|
|
28
27
|
```bash
|
|
29
28
|
npm install @dp-bohrium/widget-sdk
|
|
@@ -31,9 +30,20 @@ pnpm add @dp-bohrium/widget-sdk
|
|
|
31
30
|
yarn add @dp-bohrium/widget-sdk
|
|
32
31
|
```
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
新建工程只需调用 SDK 自带的命令,生成结果也只直接声明精确 SDK 版本:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm dlx @dp-bohrium/widget-sdk create my-widget --template panel
|
|
37
|
+
cd my-widget
|
|
38
|
+
pnpm install
|
|
39
|
+
pnpm exec bohr-widget build .
|
|
40
|
+
pnpm exec bohr-widget check .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
常用作者类型从本包根入口导入;完整协议从 `@dp-bohrium/widget-sdk/contracts` 导入,
|
|
44
|
+
编辑器 Schema 使用 `@dp-bohrium/widget-sdk/schemas/*.json`,协议测试语料使用
|
|
45
|
+
`@dp-bohrium/widget-sdk/conformance/*`。升级已有工程时,参照
|
|
46
|
+
[版本兼容](https://dev.dp.tech/bohrium-widget-sdk/reference/versioning)。
|
|
37
47
|
|
|
38
48
|
在自己的 `package.json` 里钉死精确 SemVer,不要用 `^` 或裸 `latest`。SDK 运行时会从已安装
|
|
39
49
|
包自身读取版本,插件源码和 Manifest 不需要再次填写 SDK 版本。
|
|
@@ -101,7 +111,7 @@ Manifest 是插件的静态声明,SDK 代码是隔离 iframe 内的运行时
|
|
|
101
111
|
|
|
102
112
|
```json
|
|
103
113
|
{
|
|
104
|
-
"$schema": "@dp-bohrium/widget-
|
|
114
|
+
"$schema": "@dp-bohrium/widget-sdk/schemas/widget-plugin-manifest.schema.json",
|
|
105
115
|
"name": "research",
|
|
106
116
|
"version": "1.0.0",
|
|
107
117
|
"entry": "src/widget.ts",
|
|
@@ -150,8 +160,8 @@ Manifest 的 `contributes.widget` 决定;运行时代码只认识统一的 `co
|
|
|
150
160
|
`context.render`、`context.capabilities` 和 `context.ui`。首帧和后续快照通过
|
|
151
161
|
`renderContext.phase` 区分,不需要维护两套回调。
|
|
152
162
|
|
|
153
|
-
Manifest
|
|
154
|
-
|
|
163
|
+
Manifest 的编辑器提示来自本包 `/schemas` 的 JSON Schema 和公开 TypeScript 类型,
|
|
164
|
+
不依赖某个 `defineManifest` 工厂。构建工具调用
|
|
155
165
|
`compileWidgetPluginManifest`,自动补齐 `schemaVersion`、`hostApiVersion`、SDK 版本和
|
|
156
166
|
宿主加载字段;它会直接读取 Manifest 内的 `samples`,只有构建器从别处生成样例时
|
|
157
167
|
才需要传入第二个参数。`createWidgetClient` 是协议级基础实现,不属于 Widget 作者 API;当前根入口只提供统一 Widget API,协议级代码应从
|
|
@@ -159,19 +169,23 @@ TypeScript 类型,不依赖某个 `defineManifest` 工厂。构建工具调用
|
|
|
159
169
|
|
|
160
170
|
受信任的内部 Host/协议测试仍可直接构造低层 Tool Result RenderRequest,但该能力不属于外部作者清单或公共示例。
|
|
161
171
|
|
|
162
|
-
SDK 发布包会生成 `dist/index.d.ts`
|
|
172
|
+
SDK 发布包会生成 `dist/index.d.ts` 与各子入口声明,并通过 `package.json` 的
|
|
163
173
|
`types`/`exports` 暴露。插件安装 `@dp-bohrium/widget-sdk` 后,编辑器会直接获得
|
|
164
174
|
`WidgetContext`、事件名、能力请求、渲染请求和生命周期返回值的类型提示;Manifest
|
|
165
|
-
|
|
175
|
+
编辑器提示由本包的 `/schemas` 和声明文件提供,Schema 在构建时从协议唯一源生成。
|
|
166
176
|
|
|
167
177
|
## 包入口
|
|
168
178
|
|
|
169
179
|
| 入口 | 内容 | 用途 |
|
|
170
180
|
| --- | --- | --- |
|
|
171
|
-
| `.` | `runWidgetHost`、`compileWidgetPluginManifest`
|
|
181
|
+
| `.` | `runWidgetHost`、`compileWidgetPluginManifest` 和常用作者类型 | 生成的生产 Bundle |
|
|
182
|
+
| `./contracts` | 完整协议类型、事件目录与判定函数 | 高级协议集成;同名协议类型显式从此处获取 |
|
|
183
|
+
| `./conformance/*` | 同源协议校验语料 | Host/控制面验证 |
|
|
184
|
+
| `./schemas/*.json` | 作者清单、宿主清单、运行配置与消息 Schema | 编辑器提示和工具校验 |
|
|
172
185
|
| `./testing` | `MemoryTransport`、`MockWidgetHost` | 单元测试 |
|
|
173
186
|
| `./runtime` | 低层 `WidgetClient`、transport 与 bootstrap 常量 | 协议级集成 |
|
|
174
187
|
| `./package.json` | 已安装包的元数据 | SDK 和构建工具自动读取版本,作者无需复制版本字符串 |
|
|
188
|
+
| `bohr-widget` | Node.js 命令入口 | 创建、构建、校验、开发和打包工程;不进入浏览器 Bundle |
|
|
175
189
|
|
|
176
190
|
根入口只导出插件运行时和 Manifest 编译所需的少量值,其余均为类型。低层
|
|
177
191
|
`MessagePortTransport` 与 bootstrap 消息不属于普通 Widget API。
|
|
@@ -339,7 +353,6 @@ import { MockWidgetHost } from "@dp-bohrium/widget-sdk/testing";
|
|
|
339
353
|
本地等待,已发出的服务端读取可能完成,但结果被忽略。
|
|
340
354
|
- Host 发来畸形 Bridge 信封或载荷时,transport 报结构化 `MESSAGE_INVALID` 并关闭
|
|
341
355
|
连接,不会让 Widget 悬等。
|
|
342
|
-
- Schema 与类型校验以 `@dp-bohrium/widget-contracts` 为准。
|
|
343
356
|
|
|
344
357
|
## 许可证
|
|
345
358
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2021 Evgeny Poberezkin
|
|
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.
|
|
22
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Evgeny Poberezkin
|
|
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.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
|
|
2
|
+
Copyright (c) 2021-present The Fastify team <https://github.com/fastify/fastify#team>
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
documentation and/or other materials provided with the distribution.
|
|
12
|
+
* The names of any contributors may not be used to endorse or promote
|
|
13
|
+
products derived from this software without specific prior written
|
|
14
|
+
permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
|
|
20
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
23
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
* * *
|
|
28
|
+
|
|
29
|
+
The complete list of contributors can be found at:
|
|
30
|
+
- https://github.com/garycourt/uri-js/graphs/contributors
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Evgeny Poberezkin
|
|
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.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> (github.com/floatdrop)
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
|
@@ -0,0 +1,21 @@
|
|
|
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.
|