@jetcrab/pi-desk-sdk 1.1.19-dev → 1.1.20-dev
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.md +25 -1
- package/dist/config-api.d.ts +15 -3
- package/dist/config-store.js +62 -21
- package/dist/config.d.ts +3 -1
- package/dist/config.js +10 -1
- package/dist/entry.d.ts +1 -1
- package/dist/host-runtime/base.js +11 -9
- package/dist/react-status-capsule.js +16 -11
- package/dist/session.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
包名:`@jetcrab/pi-desk-sdk`。公开接口以本版本 `package.json` 的 exports 和对应 TypeScript 声明为准。
|
|
4
4
|
|
|
5
|
-
Node 与 Session 插件通过绑定身份的 `plugin.config`
|
|
5
|
+
Node 与 Session 插件通过绑定身份的 `plugin.config` 使用以下四个异步接口,配置按 JSON Pointer 与 `*` 路径选择加解密:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
await plugin.config.set(
|
|
9
|
+
{ server: { port: 2222, password: 'example-password' } },
|
|
10
|
+
{ cwd, encryptPaths: ['/server/password'] }
|
|
11
|
+
)
|
|
12
|
+
const conf = await plugin.config.get({
|
|
13
|
+
cwd,
|
|
14
|
+
defaults: { server: { host: 'localhost', port: 22 } },
|
|
15
|
+
decryptPaths: ['/server/password']
|
|
16
|
+
})
|
|
17
|
+
const encrypted = await plugin.config.encrypt({ token: 'example-token' })
|
|
18
|
+
const value = await plugin.config.decrypt(encrypted)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- `set(conf, options?)`:选项为 `{ cwd?: string, encryptPaths?: readonly string[] }`。仅整体替换选定文件内自身分组,保留其他分组和注释,不保存默认值或继承值。
|
|
22
|
+
- `get(options?)`:选项为 `{ cwd?: string, defaults?: PluginJsonObject, decryptPaths?: readonly string[], inherit?: boolean }`。默认按默认值 → 全局 → 项目递归覆盖对象字段;数组、标量和 `null` 整体替换,`false`、`0`、`''`、`[]` 均有效,空对象继承已有字段。`inherit: false` 只读选定层,不应用 `defaults` 或额外全局继承,供配置编辑和项目发现使用,不增加第五个接口。
|
|
23
|
+
- 不传 `cwd` 时只使用 `<AgentDir>/config/pi-desk.yaml`;传入时项目层固定为 `<cwd>/.pi/pi-desk.yaml`。`cwd` 必须是已存在的绝对普通目录,不读取进程工作目录、不搜索父目录。调用方负责确认项目信任;没有可信项目上下文时不传 `cwd`。
|
|
24
|
+
- 各持久层先按 `decryptPaths` 解密再合并;未指定路径上的密文原样参与覆盖。默认值不自动解密,读取不回写,不修改输入。文件缺失视为空层;YAML、权限或解密错误明确失败,不回退旧格式。
|
|
25
|
+
- 密文内联,系统仅托管主密钥;项目加解密始终使用全局 AgentDir 配置目录的密钥身份。路径数组参数旧调用不再支持。
|
|
26
|
+
|
|
27
|
+
`/config` 提供宿主装配和文件级工具,`getProjectConfigPath(cwd)` 返回固定项目文件位置,`readConfigSection()` 保持全局同步读取合同,不作为第五个插件方法。`/config` 的旧文件级工具与 `/secrets` 的旧凭据接口作为历史工具兼容 API 保留;Pi Desk 自有新版功能不消费旧配置。旧文件不迁移、不删除、不回退读取;原生 Pi 配置位置和格式保持不变,Markdown Agent 定义与 Skills 等资源仍独立。共享 YAML 继续使用跨进程锁、原子写入、Owner 校验、8 MiB 容量限制及符号链接边界。
|
|
28
|
+
|
|
29
|
+
宿主统一备份全局和既有项目的 `pi-desk.yaml`,动态识别 `enc:v1:` 内联密文,并在恢复时用目标 AgentDir 的主密钥重新加密。插件不重复声明共享文件归属,仍可通过 `piDesk.environment.files` 声明自有 data 与配套资源。完整调用与路径合同见[插件指南](../../docs/plugins.md#配置与凭据node)。
|
|
6
30
|
|
|
7
31
|
SDK 的运行依赖为 Zod(协议 Schema)、`yaml`(统一配置)、`proper-lockfile`(Node 跨进程锁)和 `@napi-rs/keyring`(Node 系统持久密钥存储)。协议与 Browser 子入口不加载这些 Node 配置或凭据能力,非 React 使用不要求安装公共 UI 库。
|
|
8
32
|
|
package/dist/config-api.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import type { PluginJsonObject, PluginJsonValue } from './shared.js';
|
|
2
|
-
/**
|
|
2
|
+
/** cwd 由调用方确认可信;仅使用该项目,不搜索父目录。 */
|
|
3
|
+
export interface PluginConfigGetOptions {
|
|
4
|
+
cwd?: string;
|
|
5
|
+
/** false 时只读目标层,不应用全局继承或 defaults。 */
|
|
6
|
+
inherit?: boolean;
|
|
7
|
+
defaults?: PluginJsonObject;
|
|
8
|
+
decryptPaths?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export interface PluginConfigSetOptions {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
encryptPaths?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
/** 宿主按插件身份绑定;不暴露任意文件位置或密钥。 */
|
|
3
15
|
export interface PluginConfig {
|
|
4
16
|
encrypt(value: PluginJsonValue): Promise<string>;
|
|
5
17
|
decrypt(value: string): Promise<PluginJsonValue>;
|
|
6
|
-
set(conf: PluginJsonObject,
|
|
7
|
-
get(
|
|
18
|
+
set(conf: PluginJsonObject, options?: PluginConfigSetOptions): Promise<void>;
|
|
19
|
+
get(options?: PluginConfigGetOptions): Promise<PluginJsonObject>;
|
|
8
20
|
}
|
package/dist/config-store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
2
|
import { parseDocument } from 'yaml';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { getConfigPath } from "./config.js";
|
|
4
|
+
import { getConfigPath, getProjectConfigPath } from "./config.js";
|
|
5
5
|
import { ensureStorageDirectory, readStorageFile, withStorageLock, writeStorageFile } from "./config-storage.js";
|
|
6
6
|
import { configValueLocations, getConfigLocation, setConfigLocation } from "./config-paths.js";
|
|
7
7
|
import { decryptConfigValue, encryptConfigValue, hasEncryptedConfigValue, isEncryptedConfigValue, loadConfigKey } from "./config-encryption.js";
|
|
@@ -26,6 +26,18 @@ function readDocument(path) {
|
|
|
26
26
|
}
|
|
27
27
|
return { previous, document, root };
|
|
28
28
|
}
|
|
29
|
+
function isObject(value) {
|
|
30
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
function mergeConfig(base, override) {
|
|
33
|
+
return {
|
|
34
|
+
...base,
|
|
35
|
+
...Object.fromEntries(Object.entries(override).map(([key, value]) => {
|
|
36
|
+
const previous = Object.hasOwn(base, key) ? base[key] : undefined;
|
|
37
|
+
return [key, isObject(previous) && isObject(value) ? mergeConfig(previous, value) : value];
|
|
38
|
+
}))
|
|
39
|
+
};
|
|
40
|
+
}
|
|
29
41
|
/** 宿主同步启动读取普通配置;插件业务使用四接口,不从这里解密。 */
|
|
30
42
|
export function readConfigSection(namespace, name, agentDir) {
|
|
31
43
|
const { root } = readDocument(getUnifiedConfigPath(agentDir));
|
|
@@ -34,10 +46,11 @@ export function readConfigSection(namespace, name, agentDir) {
|
|
|
34
46
|
/** 供宿主装配与原生绑定使用,业务插件直接使用绑定后的 plugin.config。 */
|
|
35
47
|
export function bindConfigStore(namespace, name, options = {}) {
|
|
36
48
|
name = normalizePluginIdentifier(name, 'pluginName');
|
|
37
|
-
const
|
|
49
|
+
const globalPath = getUnifiedConfigPath(options.agentDir);
|
|
38
50
|
const assertActive = () => options.assertActive?.();
|
|
39
|
-
async function access(action) {
|
|
51
|
+
async function access(path, action) {
|
|
40
52
|
assertActive();
|
|
53
|
+
ensureStorageDirectory(dirname(globalPath));
|
|
41
54
|
ensureStorageDirectory(dirname(path));
|
|
42
55
|
return withStorageLock(path, async (assertLocked) => {
|
|
43
56
|
const assertCurrent = () => {
|
|
@@ -49,7 +62,21 @@ export function bindConfigStore(namespace, name, options = {}) {
|
|
|
49
62
|
let loadedKey;
|
|
50
63
|
try {
|
|
51
64
|
return await action(state, async (required) => {
|
|
52
|
-
|
|
65
|
+
const loadKey = async (assertKeyLocked) => {
|
|
66
|
+
const assertKeyCurrent = () => {
|
|
67
|
+
assertKeyLocked();
|
|
68
|
+
assertCurrent();
|
|
69
|
+
};
|
|
70
|
+
assertKeyCurrent();
|
|
71
|
+
return loadConfigKey(globalPath, required ||
|
|
72
|
+
hasEncryptedConfigValue(state.root) ||
|
|
73
|
+
(path !== globalPath && hasEncryptedConfigValue(readDocument(globalPath).root)), options, assertKeyCurrent);
|
|
74
|
+
};
|
|
75
|
+
// 不同项目共享主密钥;首次创建也必须按全局身份跨进程序列化。
|
|
76
|
+
loadedKey ??=
|
|
77
|
+
path === globalPath
|
|
78
|
+
? await loadKey(assertCurrent)
|
|
79
|
+
: await withStorageLock(globalPath, loadKey);
|
|
53
80
|
assertCurrent();
|
|
54
81
|
return loadedKey;
|
|
55
82
|
}, assertCurrent);
|
|
@@ -61,15 +88,17 @@ export function bindConfigStore(namespace, name, options = {}) {
|
|
|
61
88
|
}
|
|
62
89
|
return {
|
|
63
90
|
async encrypt(value) {
|
|
64
|
-
return access(async (_state, key) => encryptConfigValue(value, await key(false)));
|
|
91
|
+
return access(globalPath, async (_state, key) => encryptConfigValue(value, await key(false)));
|
|
65
92
|
},
|
|
66
93
|
async decrypt(value) {
|
|
67
|
-
return access(async (_state, key) => decryptConfigValue(value, await key(true)));
|
|
94
|
+
return access(globalPath, async (_state, key) => decryptConfigValue(value, await key(true)));
|
|
68
95
|
},
|
|
69
|
-
async set(conf,
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
96
|
+
async set(conf, setOptions = {}) {
|
|
97
|
+
assertActive();
|
|
98
|
+
const path = setOptions.cwd === undefined ? globalPath : getProjectConfigPath(setOptions.cwd);
|
|
99
|
+
const next = structuredClone(dictionary.parse(conf));
|
|
100
|
+
const locations = configValueLocations(next, setOptions.encryptPaths ?? []);
|
|
101
|
+
await access(path, async (state, key, assertCurrent) => {
|
|
73
102
|
for (const location of locations) {
|
|
74
103
|
setConfigLocation(location, encryptConfigValue(getConfigLocation(location), await key(false)));
|
|
75
104
|
}
|
|
@@ -81,18 +110,30 @@ export function bindConfigStore(namespace, name, options = {}) {
|
|
|
81
110
|
writeStorageFile(path, content, state.previous);
|
|
82
111
|
});
|
|
83
112
|
},
|
|
84
|
-
async get(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
113
|
+
async get(getOptions = {}) {
|
|
114
|
+
assertActive();
|
|
115
|
+
const projectPath = getOptions.cwd === undefined ? undefined : getProjectConfigPath(getOptions.cwd);
|
|
116
|
+
const paths = getOptions.inherit === false
|
|
117
|
+
? [projectPath ?? globalPath]
|
|
118
|
+
: projectPath === undefined
|
|
119
|
+
? [globalPath]
|
|
120
|
+
: [globalPath, projectPath];
|
|
121
|
+
let result = structuredClone(dictionary.parse(getOptions.inherit === false ? {} : (getOptions.defaults ?? {})));
|
|
122
|
+
for (const path of paths) {
|
|
123
|
+
const layer = await access(path, async ({ root }, key) => {
|
|
124
|
+
const section = dictionary.parse(root[namespace] ?? {});
|
|
125
|
+
const conf = dictionary.parse(section[name] ?? {});
|
|
126
|
+
for (const location of configValueLocations(conf, getOptions.decryptPaths ?? [])) {
|
|
127
|
+
const value = getConfigLocation(location);
|
|
128
|
+
if (isEncryptedConfigValue(value)) {
|
|
129
|
+
setConfigLocation(location, decryptConfigValue(value, await key(true)));
|
|
130
|
+
}
|
|
92
131
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
132
|
+
return conf;
|
|
133
|
+
});
|
|
134
|
+
result = mergeConfig(result, layer);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
96
137
|
}
|
|
97
138
|
};
|
|
98
139
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export type { PluginConfig } from './config-api.js';
|
|
1
|
+
export type { PluginConfig, PluginConfigGetOptions, PluginConfigSetOptions } from './config-api.js';
|
|
2
2
|
export { bindConfigStore, getUnifiedConfigPath, readConfigSection, type ConfigStoreOptions } from './config-store.ts';
|
|
3
3
|
export declare function getConfigDirectory(agentDir?: string): string;
|
|
4
4
|
export declare function getConfigPath(filename: string, agentDir?: string): string;
|
|
5
|
+
/** 显式项目目录必须已存在;不使用进程 CWD 或搜索父目录。 */
|
|
6
|
+
export declare function getProjectConfigPath(cwd: string): string;
|
|
5
7
|
/** 串行保护同一目标的完整读改写;操作内不能嵌套获取同一目标锁。 */
|
|
6
8
|
export declare function withConfigTransaction<T>(targetPath: string, operation: () => Promise<T>): Promise<T>;
|
|
7
9
|
/** 原子发布 UTF-8 配置;读改写应置于 withConfigTransaction 内,本方法不重复加锁。 */
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { bindConfigStore, getUnifiedConfigPath, readConfigSection } from "./config-store.js";
|
|
2
2
|
import { getAgentDir } from '@earendil-works/pi-coding-agent';
|
|
3
|
-
import {
|
|
3
|
+
import { lstatSync } from 'node:fs';
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
5
|
import { ensureStorageDirectory, readStorageFile, withStorageLock, writeStorageFile } from "./config-storage.js";
|
|
5
6
|
export function getConfigDirectory(agentDir) {
|
|
6
7
|
return join(agentDir ?? getAgentDir(), 'config');
|
|
@@ -11,6 +12,14 @@ export function getConfigPath(filename, agentDir) {
|
|
|
11
12
|
}
|
|
12
13
|
return join(getConfigDirectory(agentDir), filename);
|
|
13
14
|
}
|
|
15
|
+
/** 显式项目目录必须已存在;不使用进程 CWD 或搜索父目录。 */
|
|
16
|
+
export function getProjectConfigPath(cwd) {
|
|
17
|
+
if (!isAbsolute(cwd))
|
|
18
|
+
throw new Error('项目配置 cwd 必须是绝对目录');
|
|
19
|
+
if (!lstatSync(cwd).isDirectory())
|
|
20
|
+
throw new Error('项目配置 cwd 必须是普通目录');
|
|
21
|
+
return join(cwd, '.pi', 'pi-desk.yaml');
|
|
22
|
+
}
|
|
14
23
|
/** 串行保护同一目标的完整读改写;操作内不能嵌套获取同一目标锁。 */
|
|
15
24
|
export async function withConfigTransaction(targetPath, operation) {
|
|
16
25
|
const target = resolve(targetPath);
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginConfig } from './config-api.js';
|
|
2
|
-
export type { PluginConfig } from './config-api.js';
|
|
2
|
+
export type { PluginConfig, PluginConfigGetOptions, PluginConfigSetOptions } from './config-api.js';
|
|
3
3
|
import type { CapabilityDeclarations } from './capabilities.js';
|
|
4
4
|
import type { HostSettings } from './settings.js';
|
|
5
5
|
import type { HostEvents, NodeHostEventMap } from './events.js';
|
|
@@ -178,30 +178,32 @@ textarea.pi-desk-ui-control{min-height:13rem;resize:vertical;font-family:ui-mono
|
|
|
178
178
|
.pi-desk-ui-popover[data-starting-style],.pi-desk-ui-popover[data-ending-style]{opacity:0;transform:scale(.98)}
|
|
179
179
|
@media(prefers-reduced-motion:reduce){.pi-desk-ui-popover{transition:none}}
|
|
180
180
|
`;function w$({open:e,onOpenChange:t,trigger:a,children:o,side:r="bottom",align:n="start",className:l}){let u=(0,Yl.useId)(),i=(0,Yl.useRef)(null),s=(0,Yl.useRef)(!1);return(0,Yl.useLayoutEffect)(()=>{e&&(s.current=!1)},[e]),(0,Jr.jsxs)(ka.Root,{open:e,onOpenChange:t,modal:!1,triggerId:u,children:[(0,Jr.jsx)(ka.Trigger,{ref:i,id:u,render:a}),(0,Jr.jsxs)(ka.Portal,{children:[(0,Jr.jsx)("style",{href:"pi-desk-popover",precedence:"pi-desk-ui",children:wN}),(0,Jr.jsx)(ka.Positioner,{side:r,align:n,sideOffset:6,collisionPadding:8,collisionAvoidance:{side:"none",align:"shift",fallbackAxisSide:"none"},className:"pi-desk-ui-popover-positioner",children:(0,Jr.jsx)(ka.Popup,{render:(0,Jr.jsx)(Ti,{}),className:["pi-desk-ui-popover",l].filter(Boolean).join(" "),"aria-labelledby":u,initialFocus:!1,onFocusCapture:()=>{s.current=!0},onBlurCapture:c=>{s.current=c.relatedTarget instanceof Node&&c.currentTarget.contains(c.relatedTarget)},finalFocus:()=>s.current?i.current??!1:!1,children:o})})]})]})}var Xo=I(A(),1);var yt=I(Ie(),1),TN=`
|
|
181
|
-
.pi-desk-ui-capsule-slot{position:relative;min-width:0;height:0
|
|
181
|
+
.pi-desk-ui-capsule-slot{position:relative;min-width:0;height:0}
|
|
182
|
+
.pi-desk-ui-capsule-slot[data-motion]{transition:height 200ms cubic-bezier(.22,.8,.25,1)}
|
|
182
183
|
.pi-desk-ui-capsule-slot[data-visible]{height:2.75rem}
|
|
183
|
-
.pi-desk-ui-capsule-shell{position:absolute;bottom:.5rem;left:50%;height:2.25rem;max-width:100%;border-radius:2rem;background:var(--
|
|
184
|
+
.pi-desk-ui-capsule-shell{position:absolute;bottom:.5rem;left:50%;height:2.25rem;max-width:100%;border-radius:2rem;background:var(--popover,#fff);color:var(--popover-foreground,#262626);box-shadow:inset 0 0 0 1px var(--border,#ddd);opacity:0;transform:translate(-50%,.5rem) scale(.92);overflow:hidden;pointer-events:none}
|
|
185
|
+
.pi-desk-ui-capsule-slot[data-motion] .pi-desk-ui-capsule-shell{transition:width 200ms cubic-bezier(.22,.8,.25,1),opacity 150ms ease-out,transform 200ms cubic-bezier(.22,.8,.25,1)}
|
|
184
186
|
.pi-desk-ui-capsule-slot[data-visible] .pi-desk-ui-capsule-shell{opacity:1;transform:translate(-50%,0) scale(1);pointer-events:auto}
|
|
185
187
|
.pi-desk-ui-capsule-row{display:flex;align-items:center;width:max-content;max-width:min(22rem,var(--capsule-available-width));height:2.25rem}
|
|
186
188
|
.pi-desk-ui-capsule-trigger{display:flex;align-items:center;gap:.5rem;min-width:0;flex:1;height:2.25rem;padding:0 .875rem;border:0;background:transparent;color:inherit;font:inherit;font-size:.875rem;text-align:left;cursor:pointer;outline:none}
|
|
187
189
|
.pi-desk-ui-capsule-trigger:focus-visible{outline:2px solid currentColor;outline-offset:-4px;border-radius:2rem}
|
|
188
190
|
.pi-desk-ui-capsule-icon{display:flex;flex:none;align-items:center;justify-content:center}
|
|
189
191
|
.pi-desk-ui-capsule-icon>svg{width:1rem;height:1rem}
|
|
190
|
-
.pi-desk-ui-capsule-copy{min-width:0;flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis
|
|
191
|
-
.pi-desk-ui-capsule-meta{flex:none;font-size:.75rem;
|
|
192
|
+
.pi-desk-ui-capsule-copy{min-width:0;flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
|
|
193
|
+
.pi-desk-ui-capsule-meta{flex:none;font-size:.75rem;color:var(--muted-foreground,#707070);font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
192
194
|
.pi-desk-ui-capsule-chevron{flex:none;width:.875rem;height:.875rem;opacity:.75}
|
|
193
195
|
.pi-desk-ui-capsule-actions{display:flex;flex:none;align-items:center;padding-right:.375rem}
|
|
194
196
|
.pi-desk-ui-capsule-actions:empty{display:none}
|
|
195
197
|
.pi-desk-ui-capsule-positioner{z-index:1020;max-width:calc(100vw - 1rem);outline:none;filter:drop-shadow(0 .5rem 1rem rgb(0 0 0 / .16))}
|
|
196
|
-
.pi-desk-ui-capsule-popup[data-pi-desk-ui-root]{display:flex;flex-direction:column;width:26rem;max-width:var(--available-width);max-height:min(28rem,var(--available-height));overflow:hidden;background:var(--
|
|
198
|
+
.pi-desk-ui-capsule-popup[data-pi-desk-ui-root]{display:flex;flex-direction:column;width:26rem;max-width:var(--available-width);max-height:min(28rem,var(--available-height));overflow:hidden;background:var(--popover,#fff);color:var(--popover-foreground,#262626);box-shadow:inset 0 0 0 1px var(--border,#ddd);border-radius:1.125rem;outline:none;clip-path:inset(0 0 0 0 round 1.125rem);transition:clip-path 200ms cubic-bezier(.22,.8,.25,1),opacity 150ms ease-out}
|
|
197
199
|
.pi-desk-ui-capsule-popup[data-starting-style],.pi-desk-ui-capsule-popup[data-ending-style]{clip-path:inset(max(0px,calc(100% - var(--anchor-height))) max(0px,calc((100% - var(--anchor-width))/2)) 0 round 1.125rem)}
|
|
198
200
|
.pi-desk-ui-capsule-body{display:flex;min-width:0;min-height:0;flex:1;flex-direction:column;overflow:auto;overscroll-behavior:contain;opacity:1;transition:opacity 150ms ease-out}
|
|
199
201
|
.pi-desk-ui-capsule-popup[data-starting-style] .pi-desk-ui-capsule-body,.pi-desk-ui-capsule-popup[data-ending-style] .pi-desk-ui-capsule-body{opacity:0}
|
|
200
|
-
.pi-desk-ui-capsule-footer{display:flex;flex:none;min-width:0;
|
|
202
|
+
.pi-desk-ui-capsule-footer{display:flex;flex:none;min-width:0;width:100%;height:2.25rem;margin-inline:auto;box-shadow:0 -1px var(--border,#ddd);transition:width 200ms cubic-bezier(.22,.8,.25,1)}
|
|
203
|
+
.pi-desk-ui-capsule-popup[data-starting-style] .pi-desk-ui-capsule-footer,.pi-desk-ui-capsule-popup[data-ending-style] .pi-desk-ui-capsule-footer{width:var(--anchor-width)}
|
|
201
204
|
.pi-desk-ui-capsule-footer .pi-desk-ui-capsule-chevron{transform:rotate(180deg)}
|
|
202
|
-
@
|
|
203
|
-
|
|
204
|
-
`;function P$({visible:e,open:t,onOpenChange:a,summary:o,icon:r,meta:n,actions:l,children:u,triggerProps:i,openOnHover:s=!1}){let c=(0,Xo.useId)(),h=(0,Xo.useRef)(null),f=(0,Xo.useRef)(null),d=(0,Xo.useRef)(null),x=(0,Xo.useRef)(null),C=(0,Xo.useRef)(!1),v=e&&t;(0,Xo.useLayoutEffect)(()=>{let p=h.current,g=f.current,S=d.current;if(!p||!g||!S)return;let L=()=>{p.style.setProperty("--capsule-available-width",`${p.clientWidth}px`),g.style.width=`${S.offsetWidth}px`};L();let y=new ResizeObserver(L);return y.observe(p),y.observe(S),()=>y.disconnect()},[]),(0,Xo.useLayoutEffect)(()=>{v&&(C.current=!1)},[v]);let m=(0,yt.jsxs)(yt.Fragment,{children:[r?(0,yt.jsx)("span",{className:"pi-desk-ui-capsule-icon",children:r}):null,(0,yt.jsx)("span",{className:"pi-desk-ui-capsule-copy",children:o},o),n?(0,yt.jsx)("span",{className:"pi-desk-ui-capsule-meta",children:n}):null,(0,yt.jsx)(wc,{className:"pi-desk-ui-capsule-chevron","aria-hidden":"true"})]});return(0,yt.jsxs)(ka.Root,{open:v,onOpenChange:a,modal:!1,triggerId:c,children:[(0,yt.jsx)("style",{href:"pi-desk-status-capsule",precedence:"pi-desk-ui",children:TN}),(0,yt.jsx)("div",{ref:h,"data-slot":"status-capsule",className:"pi-desk-ui-capsule-slot","data-visible":e||void 0,children:(0,yt.jsx)("div",{ref:f,"data-slot":"status-capsule-shell",className:"pi-desk-ui-capsule-shell",inert:!e,"aria-hidden":!e,children:(0,yt.jsxs)("div",{ref:d,className:"pi-desk-ui-capsule-row",children:[(0,yt.jsx)(ka.Trigger,{...i,ref:x,id:c,"data-slot":"status-capsule-trigger",className:"pi-desk-ui-capsule-trigger",title:o,openOnHover:s,delay:500,closeDelay:160,children:m}),l?(0,yt.jsx)("div",{className:"pi-desk-ui-capsule-actions",children:l}):null]})})}),(0,yt.jsx)(ka.Portal,{children:(0,yt.jsx)(ka.Positioner,{anchor:f,side:"top",align:"center",sideOffset:({anchor:p})=>-p.height,collisionPadding:8,collisionAvoidance:{side:"none",align:"shift",fallbackAxisSide:"none"},className:"pi-desk-ui-capsule-positioner",children:(0,yt.jsxs)(ka.Popup,{render:(0,yt.jsx)(Ti,{}),className:"pi-desk-ui-capsule-popup","data-slot":"status-capsule-popup","aria-labelledby":c,initialFocus:!1,onFocusCapture:()=>{C.current=!0},onBlurCapture:p=>{C.current=p.relatedTarget instanceof Node&&p.currentTarget.contains(p.relatedTarget)},finalFocus:()=>e&&C.current?x.current??!1:!1,children:[(0,yt.jsx)("div",{className:"pi-desk-ui-capsule-body",children:u}),(0,yt.jsxs)("div",{className:"pi-desk-ui-capsule-footer",children:[(0,yt.jsx)(ka.Close,{...i,"data-slot":"status-capsule-close",className:"pi-desk-ui-capsule-trigger",children:m}),l?(0,yt.jsx)("div",{className:"pi-desk-ui-capsule-actions",children:l}):null]})]})})})]})}var ki=I(Ie(),1);function bC(e){let t=(0,Pa.useCallback)(o=>{let r=e.subscribe(o);return()=>{r()}},[e]),a=(0,Pa.useCallback)(()=>e.getSnapshot(),[e]);return(0,Pa.useSyncExternalStore)(t,a,a)}function D$(e){return bC(e)}function N$(e){return bC(e)}function B$(e,t){(0,Pa.useEffect)(()=>{let a=e.onPush(t);return()=>{a()}},[t,e])}function MN(e){return bC(e)}function H$(e,t=!1){let a=MN(e),o=(0,Pa.useRef)(0),[r,n]=(0,Pa.useState)({handle:e,loading:!1,loaded:!1,error:null}),l=r.handle===e?r:{handle:e,loading:!1,loaded:!1,error:null},u=(0,Pa.useCallback)(async()=>{let i=o.current+1;o.current=i,n({handle:e,loading:!0,loaded:!1,error:null});try{let s=await e.loadDetail();return o.current===i&&n({handle:e,loading:!1,loaded:!0,error:null}),s}catch(s){let c=s instanceof Error?s:new Error(String(s));throw o.current===i&&n({handle:e,loading:!1,loaded:!1,error:c}),c}},[e]);return(0,Pa.useEffect)(()=>{if(!t||l.loading||l.loaded||l.error||a.detail!==void 0||!a.fixed.hasDetail||!("entryId"in a.location))return;let i=!0;return queueMicrotask(()=>{i&&u().catch(()=>{})}),()=>{i=!1}},[t,l.error,l.loaded,l.loading,u,a.detail,a.fixed.hasDetail,a.location]),{detail:a.detail,loading:l.loading,error:l.error,load:u}}var p0=class extends Pa.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,a){this.props.onError?.(t,a)}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error&&this.setState({error:null})}retry=()=>{this.setState({error:null})};render(){let{error:t}=this.state;return t?typeof this.props.fallback=="function"?this.props.fallback(t,this.retry):this.props.fallback!==void 0?this.props.fallback:(0,ki.jsxs)("div",{role:"alert","data-pi-desk-plugin-error":"true",children:[(0,ki.jsx)("p",{children:"\u63D2\u4EF6\u754C\u9762\u52A0\u8F7D\u5931\u8D25"}),(0,ki.jsx)("pre",{children:t.message}),(0,ki.jsx)("button",{type:"button",onClick:this.retry,children:"\u91CD\u8BD5"})]}):this.props.children}};var export_Component=Pt.Component;var export_Fragment=Pt.Fragment;var export_Suspense=Pt.Suspense;var export_cloneElement=Pt.cloneElement;var export_createContext=Pt.createContext;var export_createElement=Pt.createElement;var export_createPortal=PN.createPortal;var export_createRoot=g0.createRoot;var export_default=AN.default;var export_forwardRef=Pt.forwardRef;var export_hydrateRoot=g0.hydrateRoot;var export_isValidElement=Pt.isValidElement;var export_jsx=m0.jsx;var export_jsxDEV=kN.jsxDEV;var export_jsxs=m0.jsxs;var export_lazy=Pt.lazy;var export_memo=Pt.memo;var export_useCallback=Pt.useCallback;var export_useContext=Pt.useContext;var export_useEffect=Pt.useEffect;var export_useId=Pt.useId;var export_useImperativeHandle=Pt.useImperativeHandle;var export_useLayoutEffect=Pt.useLayoutEffect;var export_useMemo=Pt.useMemo;var export_useRef=Pt.useRef;var export_useState=Pt.useState;var export_useSyncExternalStore=Pt.useSyncExternalStore;var export_useTransition=Pt.useTransition;export{export_Component as Component,export_Fragment as Fragment,cN as PluginActionRow,dN as PluginAlert,uQ as PluginBadge,wi as PluginButton,aQ as PluginCard,cQ as PluginCheckbox,iQ as PluginConfirmDialog,oQ as PluginContextMenu,nQ as PluginContextMenuContent,lQ as PluginContextMenuItem,rQ as PluginContextMenuTrigger,pN as PluginDialog,sQ as PluginEmptyState,p0 as PluginErrorBoundary,mN as PluginField,mQ as PluginHostProvider,gN as PluginInput,QZ as PluginKeyValueItem,ZZ as PluginKeyValueList,eQ as PluginList,tQ as PluginListItem,JZ as PluginLoadingState,gQ as PluginLogViewer,YZ as PluginPanelHeader,w$ as PluginPopover,Ac as PluginScroll,hN as PluginSecretInput,jZ as PluginSection,fQ as PluginSelect,fN as PluginSpinner,$Z as PluginSplitView,P$ as PluginStatusCapsule,Ti as PluginSurface,KZ as PluginTab,WZ as PluginTabList,CN as PluginTextarea,export_Suspense as Suspense,export_cloneElement as cloneElement,export_createContext as createContext,export_createElement as createElement,export_createPortal as createPortal,export_createRoot as createRoot,export_default as default,export_forwardRef as forwardRef,export_hydrateRoot as hydrateRoot,export_isValidElement as isValidElement,export_jsx as jsx,export_jsxDEV as jsxDEV,export_jsxs as jsxs,export_lazy as lazy,export_memo as memo,export_useCallback as useCallback,export_useContext as useContext,export_useEffect as useEffect,export_useId as useId,export_useImperativeHandle as useImperativeHandle,export_useLayoutEffect as useLayoutEffect,export_useMemo as useMemo,H$ as useMessageDetail,MN as useMessageHandle,D$ as usePluginConnection,LN as usePluginHost,B$ as usePluginPush,N$ as usePluginWorkSessions,export_useRef as useRef,export_useState as useState,export_useSyncExternalStore as useSyncExternalStore,export_useTransition as useTransition};
|
|
205
|
+
@media(prefers-reduced-motion:reduce){.pi-desk-ui-capsule-slot[data-motion],.pi-desk-ui-capsule-slot[data-motion] .pi-desk-ui-capsule-shell,.pi-desk-ui-capsule-popup,.pi-desk-ui-capsule-body,.pi-desk-ui-capsule-footer{transition:none}}
|
|
206
|
+
`;function P$({visible:e,open:t,onOpenChange:a,summary:o,icon:r,meta:n,actions:l,children:u,triggerProps:i,openOnHover:s=!1}){let c=(0,Xo.useId)(),h=(0,Xo.useRef)(null),f=(0,Xo.useRef)(null),d=(0,Xo.useRef)(null),x=(0,Xo.useRef)(null),C=(0,Xo.useRef)(!1),v=e&&t;(0,Xo.useLayoutEffect)(()=>{let p=h.current,g=f.current,S=d.current;if(!p||!g||!S)return;let L=()=>{p.style.setProperty("--capsule-available-width",`${p.clientWidth}px`),g.style.width=`${Math.ceil(Number.parseFloat(getComputedStyle(S).width))}px`};L(),g.getBoundingClientRect(),p.dataset.motion="";let y=new ResizeObserver(L);return y.observe(p),y.observe(S),()=>y.disconnect()},[]),(0,Xo.useLayoutEffect)(()=>{v&&(C.current=!1)},[v]);let m=(0,yt.jsxs)(yt.Fragment,{children:[r?(0,yt.jsx)("span",{className:"pi-desk-ui-capsule-icon",children:r}):null,(0,yt.jsx)("span",{className:"pi-desk-ui-capsule-copy",children:o}),n?(0,yt.jsx)("span",{className:"pi-desk-ui-capsule-meta",children:n}):null,(0,yt.jsx)(wc,{className:"pi-desk-ui-capsule-chevron","aria-hidden":"true"})]});return(0,yt.jsxs)(ka.Root,{open:v,onOpenChange:a,modal:!1,triggerId:c,children:[(0,yt.jsx)("style",{href:"pi-desk-status-capsule",precedence:"pi-desk-ui",children:TN}),(0,yt.jsx)("div",{ref:h,"data-slot":"status-capsule",className:"pi-desk-ui-capsule-slot","data-visible":e||void 0,children:(0,yt.jsx)("div",{ref:f,"data-slot":"status-capsule-shell",className:"pi-desk-ui-capsule-shell",inert:!e,"aria-hidden":!e,children:(0,yt.jsxs)("div",{ref:d,className:"pi-desk-ui-capsule-row",children:[(0,yt.jsx)(ka.Trigger,{...i,ref:x,id:c,"data-slot":"status-capsule-trigger",className:"pi-desk-ui-capsule-trigger",openOnHover:s,delay:500,closeDelay:160,children:m}),l?(0,yt.jsx)("div",{className:"pi-desk-ui-capsule-actions",children:l}):null]})})}),(0,yt.jsx)(ka.Portal,{children:(0,yt.jsx)(ka.Positioner,{anchor:f,side:"top",align:"center",sideOffset:({anchor:p})=>-p.height,collisionPadding:8,collisionAvoidance:{side:"none",align:"shift",fallbackAxisSide:"none"},className:"pi-desk-ui-capsule-positioner",children:(0,yt.jsxs)(ka.Popup,{render:(0,yt.jsx)(Ti,{}),className:"pi-desk-ui-capsule-popup","data-slot":"status-capsule-popup","aria-labelledby":c,initialFocus:!1,onFocusCapture:()=>{C.current=!0},onBlurCapture:p=>{C.current=p.relatedTarget instanceof Node&&p.currentTarget.contains(p.relatedTarget)},finalFocus:()=>e&&C.current?x.current??!1:!1,children:[(0,yt.jsx)("div",{className:"pi-desk-ui-capsule-body",children:u}),(0,yt.jsxs)("div",{className:"pi-desk-ui-capsule-footer",children:[(0,yt.jsx)(ka.Close,{...i,"data-slot":"status-capsule-close",className:"pi-desk-ui-capsule-trigger",children:m}),l?(0,yt.jsx)("div",{className:"pi-desk-ui-capsule-actions",children:l}):null]})]})})})]})}var ki=I(Ie(),1);function bC(e){let t=(0,Pa.useCallback)(o=>{let r=e.subscribe(o);return()=>{r()}},[e]),a=(0,Pa.useCallback)(()=>e.getSnapshot(),[e]);return(0,Pa.useSyncExternalStore)(t,a,a)}function D$(e){return bC(e)}function N$(e){return bC(e)}function B$(e,t){(0,Pa.useEffect)(()=>{let a=e.onPush(t);return()=>{a()}},[t,e])}function MN(e){return bC(e)}function H$(e,t=!1){let a=MN(e),o=(0,Pa.useRef)(0),[r,n]=(0,Pa.useState)({handle:e,loading:!1,loaded:!1,error:null}),l=r.handle===e?r:{handle:e,loading:!1,loaded:!1,error:null},u=(0,Pa.useCallback)(async()=>{let i=o.current+1;o.current=i,n({handle:e,loading:!0,loaded:!1,error:null});try{let s=await e.loadDetail();return o.current===i&&n({handle:e,loading:!1,loaded:!0,error:null}),s}catch(s){let c=s instanceof Error?s:new Error(String(s));throw o.current===i&&n({handle:e,loading:!1,loaded:!1,error:c}),c}},[e]);return(0,Pa.useEffect)(()=>{if(!t||l.loading||l.loaded||l.error||a.detail!==void 0||!a.fixed.hasDetail||!("entryId"in a.location))return;let i=!0;return queueMicrotask(()=>{i&&u().catch(()=>{})}),()=>{i=!1}},[t,l.error,l.loaded,l.loading,u,a.detail,a.fixed.hasDetail,a.location]),{detail:a.detail,loading:l.loading,error:l.error,load:u}}var p0=class extends Pa.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,a){this.props.onError?.(t,a)}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error&&this.setState({error:null})}retry=()=>{this.setState({error:null})};render(){let{error:t}=this.state;return t?typeof this.props.fallback=="function"?this.props.fallback(t,this.retry):this.props.fallback!==void 0?this.props.fallback:(0,ki.jsxs)("div",{role:"alert","data-pi-desk-plugin-error":"true",children:[(0,ki.jsx)("p",{children:"\u63D2\u4EF6\u754C\u9762\u52A0\u8F7D\u5931\u8D25"}),(0,ki.jsx)("pre",{children:t.message}),(0,ki.jsx)("button",{type:"button",onClick:this.retry,children:"\u91CD\u8BD5"})]}):this.props.children}};var export_Component=Pt.Component;var export_Fragment=Pt.Fragment;var export_Suspense=Pt.Suspense;var export_cloneElement=Pt.cloneElement;var export_createContext=Pt.createContext;var export_createElement=Pt.createElement;var export_createPortal=PN.createPortal;var export_createRoot=g0.createRoot;var export_default=AN.default;var export_forwardRef=Pt.forwardRef;var export_hydrateRoot=g0.hydrateRoot;var export_isValidElement=Pt.isValidElement;var export_jsx=m0.jsx;var export_jsxDEV=kN.jsxDEV;var export_jsxs=m0.jsxs;var export_lazy=Pt.lazy;var export_memo=Pt.memo;var export_useCallback=Pt.useCallback;var export_useContext=Pt.useContext;var export_useEffect=Pt.useEffect;var export_useId=Pt.useId;var export_useImperativeHandle=Pt.useImperativeHandle;var export_useLayoutEffect=Pt.useLayoutEffect;var export_useMemo=Pt.useMemo;var export_useRef=Pt.useRef;var export_useState=Pt.useState;var export_useSyncExternalStore=Pt.useSyncExternalStore;var export_useTransition=Pt.useTransition;export{export_Component as Component,export_Fragment as Fragment,cN as PluginActionRow,dN as PluginAlert,uQ as PluginBadge,wi as PluginButton,aQ as PluginCard,cQ as PluginCheckbox,iQ as PluginConfirmDialog,oQ as PluginContextMenu,nQ as PluginContextMenuContent,lQ as PluginContextMenuItem,rQ as PluginContextMenuTrigger,pN as PluginDialog,sQ as PluginEmptyState,p0 as PluginErrorBoundary,mN as PluginField,mQ as PluginHostProvider,gN as PluginInput,QZ as PluginKeyValueItem,ZZ as PluginKeyValueList,eQ as PluginList,tQ as PluginListItem,JZ as PluginLoadingState,gQ as PluginLogViewer,YZ as PluginPanelHeader,w$ as PluginPopover,Ac as PluginScroll,hN as PluginSecretInput,jZ as PluginSection,fQ as PluginSelect,fN as PluginSpinner,$Z as PluginSplitView,P$ as PluginStatusCapsule,Ti as PluginSurface,KZ as PluginTab,WZ as PluginTabList,CN as PluginTextarea,export_Suspense as Suspense,export_cloneElement as cloneElement,export_createContext as createContext,export_createElement as createElement,export_createPortal as createPortal,export_createRoot as createRoot,export_default as default,export_forwardRef as forwardRef,export_hydrateRoot as hydrateRoot,export_isValidElement as isValidElement,export_jsx as jsx,export_jsxDEV as jsxDEV,export_jsxs as jsxs,export_lazy as lazy,export_memo as memo,export_useCallback as useCallback,export_useContext as useContext,export_useEffect as useEffect,export_useId as useId,export_useImperativeHandle as useImperativeHandle,export_useLayoutEffect as useLayoutEffect,export_useMemo as useMemo,H$ as useMessageDetail,MN as useMessageHandle,D$ as usePluginConnection,LN as usePluginHost,B$ as usePluginPush,N$ as usePluginWorkSessions,export_useRef as useRef,export_useState as useState,export_useSyncExternalStore as useSyncExternalStore,export_useTransition as useTransition};
|
|
205
207
|
/*! Bundled license information:
|
|
206
208
|
|
|
207
209
|
react/cjs/react.production.js:
|
|
@@ -4,29 +4,31 @@ import { ChevronUpIcon } from 'lucide-react';
|
|
|
4
4
|
import { useId, useLayoutEffect, useRef } from 'react';
|
|
5
5
|
import { PluginSurface } from "./react-ui.js";
|
|
6
6
|
const STYLES = `
|
|
7
|
-
.pi-desk-ui-capsule-slot{position:relative;min-width:0;height:0
|
|
7
|
+
.pi-desk-ui-capsule-slot{position:relative;min-width:0;height:0}
|
|
8
|
+
.pi-desk-ui-capsule-slot[data-motion]{transition:height 200ms cubic-bezier(.22,.8,.25,1)}
|
|
8
9
|
.pi-desk-ui-capsule-slot[data-visible]{height:2.75rem}
|
|
9
|
-
.pi-desk-ui-capsule-shell{position:absolute;bottom:.5rem;left:50%;height:2.25rem;max-width:100%;border-radius:2rem;background:var(--
|
|
10
|
+
.pi-desk-ui-capsule-shell{position:absolute;bottom:.5rem;left:50%;height:2.25rem;max-width:100%;border-radius:2rem;background:var(--popover,#fff);color:var(--popover-foreground,#262626);box-shadow:inset 0 0 0 1px var(--border,#ddd);opacity:0;transform:translate(-50%,.5rem) scale(.92);overflow:hidden;pointer-events:none}
|
|
11
|
+
.pi-desk-ui-capsule-slot[data-motion] .pi-desk-ui-capsule-shell{transition:width 200ms cubic-bezier(.22,.8,.25,1),opacity 150ms ease-out,transform 200ms cubic-bezier(.22,.8,.25,1)}
|
|
10
12
|
.pi-desk-ui-capsule-slot[data-visible] .pi-desk-ui-capsule-shell{opacity:1;transform:translate(-50%,0) scale(1);pointer-events:auto}
|
|
11
13
|
.pi-desk-ui-capsule-row{display:flex;align-items:center;width:max-content;max-width:min(22rem,var(--capsule-available-width));height:2.25rem}
|
|
12
14
|
.pi-desk-ui-capsule-trigger{display:flex;align-items:center;gap:.5rem;min-width:0;flex:1;height:2.25rem;padding:0 .875rem;border:0;background:transparent;color:inherit;font:inherit;font-size:.875rem;text-align:left;cursor:pointer;outline:none}
|
|
13
15
|
.pi-desk-ui-capsule-trigger:focus-visible{outline:2px solid currentColor;outline-offset:-4px;border-radius:2rem}
|
|
14
16
|
.pi-desk-ui-capsule-icon{display:flex;flex:none;align-items:center;justify-content:center}
|
|
15
17
|
.pi-desk-ui-capsule-icon>svg{width:1rem;height:1rem}
|
|
16
|
-
.pi-desk-ui-capsule-copy{min-width:0;flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis
|
|
17
|
-
.pi-desk-ui-capsule-meta{flex:none;font-size:.75rem;
|
|
18
|
+
.pi-desk-ui-capsule-copy{min-width:0;flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
|
|
19
|
+
.pi-desk-ui-capsule-meta{flex:none;font-size:.75rem;color:var(--muted-foreground,#707070);font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
18
20
|
.pi-desk-ui-capsule-chevron{flex:none;width:.875rem;height:.875rem;opacity:.75}
|
|
19
21
|
.pi-desk-ui-capsule-actions{display:flex;flex:none;align-items:center;padding-right:.375rem}
|
|
20
22
|
.pi-desk-ui-capsule-actions:empty{display:none}
|
|
21
23
|
.pi-desk-ui-capsule-positioner{z-index:1020;max-width:calc(100vw - 1rem);outline:none;filter:drop-shadow(0 .5rem 1rem rgb(0 0 0 / .16))}
|
|
22
|
-
.pi-desk-ui-capsule-popup[data-pi-desk-ui-root]{display:flex;flex-direction:column;width:26rem;max-width:var(--available-width);max-height:min(28rem,var(--available-height));overflow:hidden;background:var(--
|
|
24
|
+
.pi-desk-ui-capsule-popup[data-pi-desk-ui-root]{display:flex;flex-direction:column;width:26rem;max-width:var(--available-width);max-height:min(28rem,var(--available-height));overflow:hidden;background:var(--popover,#fff);color:var(--popover-foreground,#262626);box-shadow:inset 0 0 0 1px var(--border,#ddd);border-radius:1.125rem;outline:none;clip-path:inset(0 0 0 0 round 1.125rem);transition:clip-path 200ms cubic-bezier(.22,.8,.25,1),opacity 150ms ease-out}
|
|
23
25
|
.pi-desk-ui-capsule-popup[data-starting-style],.pi-desk-ui-capsule-popup[data-ending-style]{clip-path:inset(max(0px,calc(100% - var(--anchor-height))) max(0px,calc((100% - var(--anchor-width))/2)) 0 round 1.125rem)}
|
|
24
26
|
.pi-desk-ui-capsule-body{display:flex;min-width:0;min-height:0;flex:1;flex-direction:column;overflow:auto;overscroll-behavior:contain;opacity:1;transition:opacity 150ms ease-out}
|
|
25
27
|
.pi-desk-ui-capsule-popup[data-starting-style] .pi-desk-ui-capsule-body,.pi-desk-ui-capsule-popup[data-ending-style] .pi-desk-ui-capsule-body{opacity:0}
|
|
26
|
-
.pi-desk-ui-capsule-footer{display:flex;flex:none;min-width:0;
|
|
28
|
+
.pi-desk-ui-capsule-footer{display:flex;flex:none;min-width:0;width:100%;height:2.25rem;margin-inline:auto;box-shadow:0 -1px var(--border,#ddd);transition:width 200ms cubic-bezier(.22,.8,.25,1)}
|
|
29
|
+
.pi-desk-ui-capsule-popup[data-starting-style] .pi-desk-ui-capsule-footer,.pi-desk-ui-capsule-popup[data-ending-style] .pi-desk-ui-capsule-footer{width:var(--anchor-width)}
|
|
27
30
|
.pi-desk-ui-capsule-footer .pi-desk-ui-capsule-chevron{transform:rotate(180deg)}
|
|
28
|
-
@
|
|
29
|
-
@media(prefers-reduced-motion:reduce){.pi-desk-ui-capsule-slot,.pi-desk-ui-capsule-shell,.pi-desk-ui-capsule-popup,.pi-desk-ui-capsule-body{transition:none}.pi-desk-ui-capsule-copy{animation:none}}
|
|
31
|
+
@media(prefers-reduced-motion:reduce){.pi-desk-ui-capsule-slot[data-motion],.pi-desk-ui-capsule-slot[data-motion] .pi-desk-ui-capsule-shell,.pi-desk-ui-capsule-popup,.pi-desk-ui-capsule-body,.pi-desk-ui-capsule-footer{transition:none}}
|
|
30
32
|
`;
|
|
31
33
|
/** 保持挂载并更新 visible,才能完成退场;卸载仍立即释放全部视图资源。 */
|
|
32
34
|
export function PluginStatusCapsule({ visible, open, onOpenChange, summary, icon, meta, actions, children, triggerProps, openOnHover = false }) {
|
|
@@ -46,9 +48,12 @@ export function PluginStatusCapsule({ visible, open, onOpenChange, summary, icon
|
|
|
46
48
|
// 只测量当前真实摘要,不复制插件视图;宽度不反向约束被观察内容。
|
|
47
49
|
const measure = () => {
|
|
48
50
|
slot.style.setProperty('--capsule-available-width', `${slot.clientWidth}px`);
|
|
49
|
-
shell.style.width = `${row.
|
|
51
|
+
shell.style.width = `${Math.ceil(Number.parseFloat(getComputedStyle(row).width))}px`;
|
|
50
52
|
};
|
|
51
53
|
measure();
|
|
54
|
+
// 首次挂载先提交最终几何;仅后续真实状态变化启用过渡。
|
|
55
|
+
shell.getBoundingClientRect();
|
|
56
|
+
slot.dataset.motion = '';
|
|
52
57
|
const observer = new ResizeObserver(measure);
|
|
53
58
|
observer.observe(slot);
|
|
54
59
|
observer.observe(row);
|
|
@@ -58,8 +63,8 @@ export function PluginStatusCapsule({ visible, open, onOpenChange, summary, icon
|
|
|
58
63
|
if (expanded)
|
|
59
64
|
focusInside.current = false;
|
|
60
65
|
}, [expanded]);
|
|
61
|
-
const copy = (_jsxs(_Fragment, { children: [icon ? _jsx("span", { className: "pi-desk-ui-capsule-icon", children: icon }) : null, _jsx("span", { className: "pi-desk-ui-capsule-copy", children: summary }
|
|
62
|
-
return (_jsxs(Popover.Root, { open: expanded, onOpenChange: onOpenChange, modal: false, triggerId: triggerId, children: [_jsx("style", { href: "pi-desk-status-capsule", precedence: "pi-desk-ui", children: STYLES }), _jsx("div", { ref: slotRef, "data-slot": "status-capsule", className: "pi-desk-ui-capsule-slot", "data-visible": visible || undefined, children: _jsx("div", { ref: shellRef, "data-slot": "status-capsule-shell", className: "pi-desk-ui-capsule-shell", inert: !visible, "aria-hidden": !visible, children: _jsxs("div", { ref: rowRef, className: "pi-desk-ui-capsule-row", children: [_jsx(Popover.Trigger, { ...triggerProps, ref: triggerRef, id: triggerId, "data-slot": "status-capsule-trigger", className: "pi-desk-ui-capsule-trigger",
|
|
66
|
+
const copy = (_jsxs(_Fragment, { children: [icon ? _jsx("span", { className: "pi-desk-ui-capsule-icon", children: icon }) : null, _jsx("span", { className: "pi-desk-ui-capsule-copy", children: summary }), meta ? _jsx("span", { className: "pi-desk-ui-capsule-meta", children: meta }) : null, _jsx(ChevronUpIcon, { className: "pi-desk-ui-capsule-chevron", "aria-hidden": "true" })] }));
|
|
67
|
+
return (_jsxs(Popover.Root, { open: expanded, onOpenChange: onOpenChange, modal: false, triggerId: triggerId, children: [_jsx("style", { href: "pi-desk-status-capsule", precedence: "pi-desk-ui", children: STYLES }), _jsx("div", { ref: slotRef, "data-slot": "status-capsule", className: "pi-desk-ui-capsule-slot", "data-visible": visible || undefined, children: _jsx("div", { ref: shellRef, "data-slot": "status-capsule-shell", className: "pi-desk-ui-capsule-shell", inert: !visible, "aria-hidden": !visible, children: _jsxs("div", { ref: rowRef, className: "pi-desk-ui-capsule-row", children: [_jsx(Popover.Trigger, { ...triggerProps, ref: triggerRef, id: triggerId, "data-slot": "status-capsule-trigger", className: "pi-desk-ui-capsule-trigger", openOnHover: openOnHover, delay: 500, closeDelay: 160, children: copy }), actions ? _jsx("div", { className: "pi-desk-ui-capsule-actions", children: actions }) : null] }) }) }), _jsx(Popover.Portal, { children: _jsx(Popover.Positioner, { anchor: shellRef, side: "top", align: "center", sideOffset: ({ anchor }) => -anchor.height, collisionPadding: 8, collisionAvoidance: { side: 'none', align: 'shift', fallbackAxisSide: 'none' }, className: "pi-desk-ui-capsule-positioner", children: _jsxs(Popover.Popup, { render: _jsx(PluginSurface, {}), className: "pi-desk-ui-capsule-popup", "data-slot": "status-capsule-popup", "aria-labelledby": triggerId, initialFocus: false, onFocusCapture: () => {
|
|
63
68
|
focusInside.current = true;
|
|
64
69
|
}, onBlurCapture: (event) => {
|
|
65
70
|
focusInside.current =
|
package/dist/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginConfig } from './config-api.js';
|
|
2
|
-
export type { PluginConfig } from './config-api.js';
|
|
2
|
+
export type { PluginConfig, PluginConfigGetOptions, PluginConfigSetOptions } from './config-api.js';
|
|
3
3
|
import type { AgentSession, ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
4
4
|
import { type PluginJsonObject, type PluginSource } from './shared.ts';
|
|
5
5
|
import type { SessionCapabilityRules } from './capabilities.js';
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "git+https://github.com/JetCrab/pi-desk.git",
|
|
6
6
|
"directory": "plugins/pi-desk-sdk"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.1.
|
|
8
|
+
"version": "1.1.20-dev",
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"registry": "https://registry.npmjs.org",
|
|
@@ -142,6 +142,6 @@
|
|
|
142
142
|
"build": "tsc -p tsconfig.json && node scripts/build-host-runtime.mjs",
|
|
143
143
|
"typecheck:isolated": "tsc -p tsconfig.json --noEmit --isolatedModules",
|
|
144
144
|
"test": "pnpm run build && node --test tests/*.test.mjs && pnpm run test:config",
|
|
145
|
-
"test:config": "node --import tsx --test tests/unified-config.test.ts"
|
|
145
|
+
"test:config": "node --import tsx --test tests/unified-config.test.ts tests/project-config.test.ts tests/project-config-boundaries.test.ts"
|
|
146
146
|
}
|
|
147
147
|
}
|