@jetcrab/pi-desk-sdk 1.1.18-dev → 1.1.19-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 +2 -2
- package/dist/browser.d.ts +14 -0
- package/dist/config-api.d.ts +8 -0
- package/dist/config-api.js +1 -0
- package/dist/config-encryption.d.ts +10 -0
- package/dist/config-encryption.js +114 -0
- package/dist/config-paths.d.ts +9 -0
- package/dist/config-paths.js +50 -0
- package/dist/config-storage.d.ts +1 -1
- package/dist/config-storage.js +6 -2
- package/dist/config-store.d.ts +13 -0
- package/dist/config-store.js +98 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +1 -0
- package/dist/entry.d.ts +3 -0
- package/dist/host-runtime/base.js +34 -9
- package/dist/react-base.d.ts +1 -0
- package/dist/react-base.js +1 -0
- package/dist/react-status-capsule.d.ts +16 -0
- package/dist/react-status-capsule.js +69 -0
- package/dist/session.d.ts +3 -0
- package/dist/session.js +2 -0
- package/package.json +5 -2
package/dist/react-base.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { BrowserConnectionHost, BrowserConnectionSnapshot, BrowserMessageHa
|
|
|
4
4
|
export * from './react-ui.tsx';
|
|
5
5
|
export * from './react-log.tsx';
|
|
6
6
|
export * from './react-popover.tsx';
|
|
7
|
+
export * from './react-status-capsule.tsx';
|
|
7
8
|
export declare function usePluginConnection(connection: BrowserConnectionHost): BrowserConnectionSnapshot;
|
|
8
9
|
export declare function usePluginWorkSessions(workSessions: BrowserWorkSessionHost): readonly PluginWorkSession[];
|
|
9
10
|
export declare function usePluginPush(plugin: Pick<BrowserPluginFacade, 'onPush'>, listener: (message: PluginPushMessage) => void): void;
|
package/dist/react-base.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Component, useCallback, useEffect, useRef, useState, useSyncExternalSto
|
|
|
3
3
|
export * from "./react-ui.js";
|
|
4
4
|
export * from "./react-log.js";
|
|
5
5
|
export * from "./react-popover.js";
|
|
6
|
+
export * from "./react-status-capsule.js";
|
|
6
7
|
function useExternalSnapshot(owner) {
|
|
7
8
|
const subscribe = useCallback((listener) => {
|
|
8
9
|
const dispose = owner.subscribe(listener);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Popover } from '@base-ui/react/popover';
|
|
2
|
+
import { type ButtonHTMLAttributes, type ReactNode } from 'react';
|
|
3
|
+
export interface PluginStatusCapsuleProps {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
open: boolean;
|
|
6
|
+
onOpenChange: NonNullable<Popover.Root.Props['onOpenChange']>;
|
|
7
|
+
summary: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
meta?: ReactNode;
|
|
10
|
+
actions?: ReactNode;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
triggerProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onClick'>;
|
|
13
|
+
openOnHover?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** 保持挂载并更新 visible,才能完成退场;卸载仍立即释放全部视图资源。 */
|
|
16
|
+
export declare function PluginStatusCapsule({ visible, open, onOpenChange, summary, icon, meta, actions, children, triggerProps, openOnHover }: PluginStatusCapsuleProps): React.JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Popover } from '@base-ui/react/popover';
|
|
3
|
+
import { ChevronUpIcon } from 'lucide-react';
|
|
4
|
+
import { useId, useLayoutEffect, useRef } from 'react';
|
|
5
|
+
import { PluginSurface } from "./react-ui.js";
|
|
6
|
+
const STYLES = `
|
|
7
|
+
.pi-desk-ui-capsule-slot{position:relative;min-width:0;height:0;transition:height 200ms cubic-bezier(.22,.8,.25,1)}
|
|
8
|
+
.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(--primary,#262626);color:var(--primary-foreground,#fafafa);opacity:0;transform:translate(-50%,.5rem) scale(.92);overflow:hidden;pointer-events:none;transition:width 200ms cubic-bezier(.22,.8,.25,1),opacity 150ms ease-out,transform 200ms cubic-bezier(.22,.8,.25,1)}
|
|
10
|
+
.pi-desk-ui-capsule-slot[data-visible] .pi-desk-ui-capsule-shell{opacity:1;transform:translate(-50%,0) scale(1);pointer-events:auto}
|
|
11
|
+
.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
|
+
.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
|
+
.pi-desk-ui-capsule-trigger:focus-visible{outline:2px solid currentColor;outline-offset:-4px;border-radius:2rem}
|
|
14
|
+
.pi-desk-ui-capsule-icon{display:flex;flex:none;align-items:center;justify-content:center}
|
|
15
|
+
.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;animation:pi-desk-capsule-copy 150ms ease-out}
|
|
17
|
+
.pi-desk-ui-capsule-meta{flex:none;font-size:.75rem;opacity:.75;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
18
|
+
.pi-desk-ui-capsule-chevron{flex:none;width:.875rem;height:.875rem;opacity:.75}
|
|
19
|
+
.pi-desk-ui-capsule-actions{display:flex;flex:none;align-items:center;padding-right:.375rem}
|
|
20
|
+
.pi-desk-ui-capsule-actions:empty{display:none}
|
|
21
|
+
.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(--primary,#262626);color:var(--primary-foreground,#fafafa);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
|
+
.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
|
+
.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
|
+
.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;min-height:2.25rem;border-top:1px solid color-mix(in srgb,currentColor 18%,transparent)}
|
|
27
|
+
.pi-desk-ui-capsule-footer .pi-desk-ui-capsule-chevron{transform:rotate(180deg)}
|
|
28
|
+
@keyframes pi-desk-capsule-copy{from{opacity:0;transform:translateY(.25rem)}to{opacity:1;transform:translateY(0)}}
|
|
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}}
|
|
30
|
+
`;
|
|
31
|
+
/** 保持挂载并更新 visible,才能完成退场;卸载仍立即释放全部视图资源。 */
|
|
32
|
+
export function PluginStatusCapsule({ visible, open, onOpenChange, summary, icon, meta, actions, children, triggerProps, openOnHover = false }) {
|
|
33
|
+
const triggerId = useId();
|
|
34
|
+
const slotRef = useRef(null);
|
|
35
|
+
const shellRef = useRef(null);
|
|
36
|
+
const rowRef = useRef(null);
|
|
37
|
+
const triggerRef = useRef(null);
|
|
38
|
+
const focusInside = useRef(false);
|
|
39
|
+
const expanded = visible && open;
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
const slot = slotRef.current;
|
|
42
|
+
const shell = shellRef.current;
|
|
43
|
+
const row = rowRef.current;
|
|
44
|
+
if (!slot || !shell || !row)
|
|
45
|
+
return;
|
|
46
|
+
// 只测量当前真实摘要,不复制插件视图;宽度不反向约束被观察内容。
|
|
47
|
+
const measure = () => {
|
|
48
|
+
slot.style.setProperty('--capsule-available-width', `${slot.clientWidth}px`);
|
|
49
|
+
shell.style.width = `${row.offsetWidth}px`;
|
|
50
|
+
};
|
|
51
|
+
measure();
|
|
52
|
+
const observer = new ResizeObserver(measure);
|
|
53
|
+
observer.observe(slot);
|
|
54
|
+
observer.observe(row);
|
|
55
|
+
return () => observer.disconnect();
|
|
56
|
+
}, []);
|
|
57
|
+
useLayoutEffect(() => {
|
|
58
|
+
if (expanded)
|
|
59
|
+
focusInside.current = false;
|
|
60
|
+
}, [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 }, summary), meta ? _jsx("span", { className: "pi-desk-ui-capsule-meta", children: meta }) : null, _jsx(ChevronUpIcon, { className: "pi-desk-ui-capsule-chevron", "aria-hidden": "true" })] }));
|
|
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", title: summary, 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
|
+
focusInside.current = true;
|
|
64
|
+
}, onBlurCapture: (event) => {
|
|
65
|
+
focusInside.current =
|
|
66
|
+
event.relatedTarget instanceof Node &&
|
|
67
|
+
event.currentTarget.contains(event.relatedTarget);
|
|
68
|
+
}, finalFocus: () => visible && focusInside.current ? (triggerRef.current ?? false) : false, children: [_jsx("div", { className: "pi-desk-ui-capsule-body", children: children }), _jsxs("div", { className: "pi-desk-ui-capsule-footer", children: [_jsx(Popover.Close, { ...triggerProps, "data-slot": "status-capsule-close", className: "pi-desk-ui-capsule-trigger", children: copy }), actions ? _jsx("div", { className: "pi-desk-ui-capsule-actions", children: actions }) : null] })] }) }) })] }));
|
|
69
|
+
}
|
package/dist/session.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { PluginConfig } from './config-api.js';
|
|
2
|
+
export type { PluginConfig } from './config-api.js';
|
|
1
3
|
import type { AgentSession, ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
2
4
|
import { type PluginJsonObject, type PluginSource } from './shared.ts';
|
|
3
5
|
import type { SessionCapabilityRules } from './capabilities.js';
|
|
@@ -44,6 +46,7 @@ export type SessionPluginMethodEvent = {
|
|
|
44
46
|
};
|
|
45
47
|
export interface SessionPluginFacade {
|
|
46
48
|
readonly name: string;
|
|
49
|
+
readonly config: PluginConfig;
|
|
47
50
|
setState(state: PluginJsonObject | null): void;
|
|
48
51
|
addPreviewDirectory(directory: string, options?: {
|
|
49
52
|
default?: boolean;
|
package/dist/session.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { bindConfigStore } from "./config-store.js";
|
|
2
3
|
import { normalizePluginIdentifier } from "./shared.js";
|
|
3
4
|
export { PluginMethodError, isPluginMethodError } from "./errors.js";
|
|
4
5
|
export const SESSION_PLUGIN_STATE_EVENT = 'pi-desk:session-plugins';
|
|
@@ -10,6 +11,7 @@ export function bindSessionPlugin(pi, pluginName) {
|
|
|
10
11
|
const name = normalizePluginIdentifier(pluginName, 'pluginName');
|
|
11
12
|
return {
|
|
12
13
|
name,
|
|
14
|
+
config: bindConfigStore('plugins', name),
|
|
13
15
|
setState(state) {
|
|
14
16
|
pi.events.emit(SESSION_PLUGIN_STATE_EVENT, { [name]: state });
|
|
15
17
|
},
|
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.19-dev",
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"registry": "https://registry.npmjs.org",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@napi-rs/keyring": "2.1.2",
|
|
89
89
|
"proper-lockfile": "^4.1.2",
|
|
90
|
+
"yaml": "^2.9.0",
|
|
90
91
|
"zod": "^4.4.3"
|
|
91
92
|
},
|
|
92
93
|
"peerDependencies": {
|
|
@@ -131,6 +132,7 @@
|
|
|
131
132
|
"@streamdown/cjk": "^1.0.3",
|
|
132
133
|
"@streamdown/code": "^1.1.1",
|
|
133
134
|
"esbuild": "^0.28.2",
|
|
135
|
+
"tsx": "^4.23.12",
|
|
134
136
|
"lucide-react": "^1.31.0",
|
|
135
137
|
"react": "19.2.8",
|
|
136
138
|
"react-dom": "19.2.8",
|
|
@@ -139,6 +141,7 @@
|
|
|
139
141
|
"scripts": {
|
|
140
142
|
"build": "tsc -p tsconfig.json && node scripts/build-host-runtime.mjs",
|
|
141
143
|
"typecheck:isolated": "tsc -p tsconfig.json --noEmit --isolatedModules",
|
|
142
|
-
"test": "pnpm run build && node --test tests/*.test.mjs"
|
|
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"
|
|
143
146
|
}
|
|
144
147
|
}
|