@deepseek-ai/dsh-client-resources 0.1.5-rc.2 → 0.1.6-alpha.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/README.i18n.yaml CHANGED
@@ -3,4 +3,4 @@
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/client/resources/README.md
5
5
  README.md: 6b5afc82230be6930c41a01a584aeed39f596c37
6
- README.zh.md: 6b928883bb54cd4663efa7a20a7bc768d4f8399e
6
+ README.zh.md: b56ee6bcdefa9311b284386ab2be9f2bc5d1dcfc
package/README.zh.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "客户端资源模型:按协议注册的提供方把 URL 地址变成活数据,任何 slot 组件都通过 useResource 标准 hook 读取。"
2
+ description: "客户端资源模型:按协议注册的提供方把 URL 地址解析为实时值,任何 slot 组件都通过 useResource 标准钩子读取。"
3
3
  kind: "package-reference"
4
4
  ---
5
5
  # @deepseek-ai/dsh-client-resources
@@ -8,7 +8,7 @@ kind: "package-reference"
8
8
 
9
9
  ## 概述
10
10
 
11
- 当组件只知道活数据的 URL 地址,而数据由另一个客户端包拥有时,请使用客户端资源;例如 tab 记录、链接或提及。资源地址使用 `dsh-resource://<type>/…`;需要作用域的协议把作用域编进路径。组件通过公开的 `useResource` hook 接收当前值与后续更新。不支持的协议与非资源 scheme(例如 `sidebar://guide`)不指向任何资源。
11
+ 当组件只知道实时数据的 URL 地址,而数据由另一个客户端包拥有时,请使用客户端资源;例如 tab 记录、链接或提及。资源地址使用 `dsh-resource://<type>/…`;需要作用域的协议把作用域编进路径。组件通过公开的 `useResource` 钩子接收当前值与后续更新。不支持的协议与非资源 scheme(例如 `sidebar://guide`)不指向任何资源。
12
12
 
13
13
  ## 目录
14
14
 
@@ -28,12 +28,12 @@ kind: "package-reference"
28
28
  <a id="use-this-package"></a>
29
29
  ## 使用本包
30
30
 
31
- 挂载无需任何配置:插件提供 `ctx.resources`,并通过 `ctx.slots.provideRoot` 贡献 `resource` 根 keyed hook,因此每个 slot 组件不论作用域都能收到它。
31
+ 挂载无需任何配置:插件提供 `ctx.resources`,并通过 `ctx.slots.provideRoot` 贡献 `resource` 根 keyed 钩子,因此每个 slot 组件不论作用域都能收到它。
32
32
 
33
33
  <a id="read-a-resource"></a>
34
34
  ### 读取资源
35
35
 
36
- 每个 slot 组件都在 props 上收到 `useResource`。`useResource<P>(address)` 以类型参数命名协议,返回 `{ status, value, failure }`:地址协议没有提供方(或地址不是 `dsh-resource://` URL)时为 `none`,提供方尚未产出值时为 `loading`,`live` 携带最新一个 `ok` 帧的值,`failed` 表示最新一帧报告了失败,失败放在最后一个值旁。通过 hook 订阅就是钉住资源的方式;另一个持有者让资源保持存活时,新挂载的组件立刻读到最新值。
36
+ 每个 slot 组件都在 props 上收到 `useResource`。`useResource<P>(address)` 以类型参数命名协议,返回 `{ status, value, failure }`:地址协议没有提供方(或地址不是 `dsh-resource://` URL)时为 `none`,提供方尚未产出值时为 `loading`,`live` 携带最新一个 `ok` 帧的值,`failed` 表示最新一帧报告了失败,失败放在最后一个值旁。通过钩子订阅就是钉住资源的方式;另一个持有者让资源保持存活时,新挂载的组件立刻读到最新值。
37
37
 
38
38
  <a id="provide-a-protocol"></a>
39
39
  ### 提供协议
@@ -58,12 +58,12 @@ export function apply(ctx) {
58
58
  }
59
59
  ```
60
60
 
61
- 一个协议恰有一个提供方;第二次注册会抛错。提供方注册时若其协议的地址已被持有,则立即开流;提供方 dispose 时结束这些流并让它们回到 `none`。
61
+ 一个协议恰有一个提供方;第二次注册会抛错。提供方注册时若其协议的地址已被持有,则立即开流;提供方 dispose(资源释放)时结束这些流并让它们回到 `none`。
62
62
 
63
63
  <a id="hold-a-resource-open"></a>
64
64
  ### 钉住资源
65
65
 
66
- `ctx.resources.pin(address, signal)` 在不订阅的情况下让资源保持打开,直到 `signal` 中止。右侧 Sidebar 在 tab 记录的存续期内钉住每个已打开 tab 的地址,因此切换 tab 卸载正文不会关闭其流,切回时读到最新值。`ctx.resources.source(address)` 是 hook 背后的裸 observable,供 React 之外的调用方使用。
66
+ `ctx.resources.pin(address, signal)` 在不订阅的情况下让资源保持打开,直到 `signal` 中止。右侧 Sidebar 在 tab 记录的存续期内钉住每个已打开 tab 的地址,因此切换 tab 卸载正文不会关闭其流,切回时读到最新值。`ctx.resources.source(address)` 是钩子背后的裸 observable,供 React 之外的调用方使用。
67
67
 
68
68
  <a id="understand-the-implementation"></a>
69
69
  ## 理解实现
@@ -71,7 +71,7 @@ export function apply(ctx) {
71
71
  <a id="lifecycle"></a>
72
72
  ### 生命周期
73
73
 
74
- 每个地址一条记录,持有一个快照 store、一个持有者计数(hook 订阅者加 pin)与运行中流的 `AbortController`。第一个持有者打开提供方的流;之后的持有者共享它;最后一个持有者释放时中止流并把快照重置为空闲(有提供方为 `loading`,没有为 `none`)。记录在页面存续期内保留,使 `source()` 在 React 渲染到订阅的窗口与 StrictMode 重挂载之间保持引用稳定。
74
+ 每个地址一条记录,持有一个快照存储、一个持有者计数(钩子订阅者加 pin)与运行中流的 `AbortController`。第一个持有者打开提供方的流;之后的持有者共享它;最后一个持有者释放时中止流并把快照重置为空闲(有提供方为 `loading`,没有为 `none`)。记录在页面存续期内保留,使 `source()` 在 React 从渲染到订阅的窗口期以及 StrictMode 重挂载期间保持引用稳定。
75
75
 
76
76
  <a id="failures"></a>
77
77
  ### 失败
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-client-resources",
3
3
  "description": "Unified client resource model: protocol-registered providers turn URL addresses into live values, consumed through the useResource global standard hook",
4
- "version": "0.1.5-rc.2",
4
+ "version": "0.1.6-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -39,11 +39,11 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@deepseek-ai/cordis": "^4.0.2",
42
- "@deepseek-ai/dsh-client-test-runtime": "^0.1.5-rc.2",
43
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.5-rc.2",
44
- "@deepseek-ai/dsh-client-ui-renderer": "^0.1.5-rc.2",
45
- "@deepseek-ai/dsh-typert-protocol": "^0.1.5-rc.2",
46
- "@deepseek-ai/dsh-client-store": "^0.1.5-rc.2"
42
+ "@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2",
43
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.1.6-alpha.2",
44
+ "@deepseek-ai/dsh-client-test-runtime": "^0.1.6-alpha.2",
45
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.6-alpha.2",
46
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.6-alpha.2"
47
47
  },
48
48
  "files": [
49
49
  "lib/index.js",