@rinova/devtools 0.0.0-stage → 0.11.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/LICENSE +21 -0
- package/README.md +24 -2
- package/dist/core/config-store.d.ts +26 -0
- package/dist/core/console-capture.d.ts +23 -0
- package/dist/core/emitter.d.ts +10 -0
- package/dist/core/network-capture.d.ts +49 -0
- package/dist/core/runtime.d.ts +58 -0
- package/dist/core/storage.d.ts +20 -0
- package/dist/create-devtools.d.ts +8 -0
- package/dist/icons.d.ts +4 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +6838 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/actions.d.ts +2 -0
- package/dist/plugins/config.d.ts +2 -0
- package/dist/plugins/console.d.ts +2 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/master-detail.d.ts +65 -0
- package/dist/plugins/network.d.ts +2 -0
- package/dist/plugins/settings.d.ts +2 -0
- package/dist/plugins/storage.d.ts +2 -0
- package/dist/plugins/table-state.d.ts +11 -0
- package/dist/types.d.ts +319 -0
- package/dist/ui/choice-groups.d.ts +28 -0
- package/dist/ui/code-editor.d.ts +15 -0
- package/dist/ui/component.d.ts +20 -0
- package/dist/ui/date-picker.d.ts +18 -0
- package/dist/ui/dialog.d.ts +27 -0
- package/dist/ui/dom.d.ts +66 -0
- package/dist/ui/form-controls.d.ts +109 -0
- package/dist/ui/inspectors.d.ts +32 -0
- package/dist/ui/layout-watch.d.ts +10 -0
- package/dist/ui/layout.d.ts +43 -0
- package/dist/ui/maximize.d.ts +30 -0
- package/dist/ui/overlays.d.ts +54 -0
- package/dist/ui/page-layer.d.ts +9 -0
- package/dist/ui/popup.d.ts +26 -0
- package/dist/ui/select.d.ts +43 -0
- package/dist/ui/shell-chrome.d.ts +28 -0
- package/dist/ui/shell.d.ts +157 -0
- package/dist/ui/splitter.d.ts +16 -0
- package/dist/ui/table.d.ts +79 -0
- package/dist/ui/tabs.d.ts +20 -0
- package/dist/utils/curl.d.ts +4 -0
- package/dist/utils/format.d.ts +15 -0
- package/dist/version.d.ts +1 -0
- package/package.json +51 -4
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DevtoolsPlugin } from '../types.js';
|
|
2
|
+
import type { Runtime } from '../core/runtime.js';
|
|
3
|
+
export declare const BUILTIN_PLUGIN_IDS: readonly ["config", "actions", "network", "console", "storage", "settings"];
|
|
4
|
+
/** 内置面板按侧栏顺序创建;第三方插件用 order 插空 */
|
|
5
|
+
export declare function createBuiltinPlugins(rt: Runtime): DevtoolsPlugin[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Runtime, SplitPlugin } from '../core/runtime.js';
|
|
2
|
+
/** 插件内容区实宽 W 达到该值且详情打开时才分栏(交互设计 6.4) */
|
|
3
|
+
export declare const SPLIT_MIN_WIDTH = 584;
|
|
4
|
+
/** Splitter 手柄宽度,两栏可分配宽度 A = W − 8 */
|
|
5
|
+
export declare const SPLIT_HANDLE = 8;
|
|
6
|
+
/** 列表默认占 A 的百分比;双击回到该值 */
|
|
7
|
+
export declare const SPLIT_DEFAULT = 67;
|
|
8
|
+
/** 列表比例的绝对下限 / 上限(%) */
|
|
9
|
+
export declare const SPLIT_MIN = 50;
|
|
10
|
+
export declare const SPLIT_MAX = 75;
|
|
11
|
+
/** 详情宽度下限(px) */
|
|
12
|
+
export declare const SPLIT_DETAIL_MIN = 176;
|
|
13
|
+
/** 列表宽度下限 L(px):默认列合计 + 18px 滚动条与舍入余量 */
|
|
14
|
+
export declare const SPLIT_LIST_MIN: Readonly<Record<SplitPlugin, number>>;
|
|
15
|
+
/**
|
|
16
|
+
* 按插件内容区实宽 W 计算列表比例的拖动范围(交互设计 6.4、设计规范 5.4):
|
|
17
|
+
* A = W − 8;min = max(50, ceil(100 × L / A));max = min(75, floor(100 × (A − 176) / A))。
|
|
18
|
+
* 窄到上下限交叉时(W 低于阈值,本不该分栏)上限取下限,保证范围非空。
|
|
19
|
+
*/
|
|
20
|
+
export declare function splitRange(width: number, plugin: SplitPlugin): {
|
|
21
|
+
min: number;
|
|
22
|
+
max: number;
|
|
23
|
+
};
|
|
24
|
+
export interface MasterDetail {
|
|
25
|
+
/** 承载列表与详情的容器 */
|
|
26
|
+
readonly el: HTMLElement;
|
|
27
|
+
/** 详情顶栏「返回」之后的标题区 */
|
|
28
|
+
readonly title: HTMLElement;
|
|
29
|
+
/** 详情顶栏之下的可滚动内容区 */
|
|
30
|
+
readonly content: HTMLElement;
|
|
31
|
+
/** 当前是否显示详情 */
|
|
32
|
+
isOpen(): boolean;
|
|
33
|
+
/** 当前是否为分栏形态 */
|
|
34
|
+
isSplit(): boolean;
|
|
35
|
+
/** 打开详情(已打开时只换内容,不重放进入动效) */
|
|
36
|
+
open(): void;
|
|
37
|
+
/** 关闭详情回到列表占满;`focus` 为 true 时调用 onClosed 让插件把焦点还给列表 */
|
|
38
|
+
close(focus?: boolean): void;
|
|
39
|
+
/** 重新判断分栏 / 替换形态 */
|
|
40
|
+
relayout(): void;
|
|
41
|
+
/** 把 Escape 监听挂到插件根(含工具栏、页签与详情),焦点在其中任一处都能先关详情 */
|
|
42
|
+
bindEscape(scope: HTMLElement): void;
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
|
45
|
+
export interface MasterDetailOptions {
|
|
46
|
+
rt: Runtime;
|
|
47
|
+
plugin: SplitPlugin;
|
|
48
|
+
/** 列表区域(工具栏之下) */
|
|
49
|
+
list: HTMLElement;
|
|
50
|
+
/** 列表的滚动容器,形态切换时保留其滚动位置 */
|
|
51
|
+
scroller: () => HTMLElement | null;
|
|
52
|
+
detailLabel: string;
|
|
53
|
+
/** 用户点「返回」或按 Escape 关闭详情后调用 */
|
|
54
|
+
onClosed: (focus: boolean) => void;
|
|
55
|
+
}
|
|
56
|
+
/** 网络、存储共用的「列表 + 详情」两栏:宽时官方 Splitter,窄时详情替换列表 */
|
|
57
|
+
export declare function createMasterDetail(options: MasterDetailOptions): MasterDetail;
|
|
58
|
+
/**
|
|
59
|
+
* 一个委托式 Tooltip:鼠标停在或焦点落在 `[data-tip]` 元素上时立即显示全文。
|
|
60
|
+
* 千行表格里不必为每个单元格各挂一个 Tooltip。
|
|
61
|
+
*/
|
|
62
|
+
export declare function createCellTooltip(root: HTMLElement): {
|
|
63
|
+
hide: () => void;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TableSort } from '../ui/table.js';
|
|
2
|
+
/** 表格排序与列宽持久化到插件命名空间(ctx.storage),刷新后恢复 */
|
|
3
|
+
export declare function persistTableState(storage: {
|
|
4
|
+
get<T>(key: string, fallback: T): T;
|
|
5
|
+
set(key: string, value: unknown): void;
|
|
6
|
+
}, key?: string): {
|
|
7
|
+
defaultSort: TableSort | undefined;
|
|
8
|
+
defaultColumnWidths: Record<string, number> | undefined;
|
|
9
|
+
onSortChange: (next: TableSort | null) => void;
|
|
10
|
+
onColumnWidthChange: (next: Record<string, number>) => void;
|
|
11
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @rinova/devtools 公共类型定义。
|
|
3
|
+
*
|
|
4
|
+
* 这一层不依赖任何框架:所有类型都是可 JSON 序列化的描述,
|
|
5
|
+
* 适配器(Vue / React / 原生)只负责把宿主状态翻译成这些描述。
|
|
6
|
+
*/
|
|
7
|
+
export type DevtoolsBuiltinTheme = 'dark' | 'light' | 'auto';
|
|
8
|
+
export type DevtoolsTheme = DevtoolsBuiltinTheme | (string & {});
|
|
9
|
+
/** 面板视图大小档位:小 (300×320) · 默认 (380×420) · 大 (580×520 双栏) */
|
|
10
|
+
export type PanelSize = 'sm' | 'md' | 'lg';
|
|
11
|
+
/** 面板与悬浮球的出厂默认角,同时约束首次展开、缩小落点、悬浮球初始位置和复位位置 */
|
|
12
|
+
export type DefaultCorner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
13
|
+
export interface PanelPosition {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}
|
|
17
|
+
/** @deprecated 停靠切换已移除,面板支持任意位置拖拽并按 PanelSize 三档自适应 */
|
|
18
|
+
export type DockSide = 'right' | 'left' | 'bottom' | 'float';
|
|
19
|
+
/** @deprecated 已由 PanelSize ('sm' | 'md' | 'lg') 统一驱动视图密度与尺寸 */
|
|
20
|
+
export type DevtoolsDensity = 'compact' | 'comfortable';
|
|
21
|
+
export interface DevtoolsThemeDefinition {
|
|
22
|
+
/** 唯一主题标识,写入 data-theme 属性 */
|
|
23
|
+
id: string;
|
|
24
|
+
/** 设置面板展示名称 */
|
|
25
|
+
label: string;
|
|
26
|
+
/** 继承基准:未声明的 token 自动回退到 dark 或 light */
|
|
27
|
+
base: 'dark' | 'light';
|
|
28
|
+
/** 预览色 [背景色, 强调色] */
|
|
29
|
+
preview?: [string, string];
|
|
30
|
+
/** 增量覆盖的 CSS 变量表(键名可带或不带 --rdt- 前缀) */
|
|
31
|
+
tokens: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
export interface LauncherOptions {
|
|
34
|
+
draggable?: boolean;
|
|
35
|
+
/** 空闲 4s 自动向吸附边缘半隐藏,默认 true */
|
|
36
|
+
autoTuck?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface FloatRect {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
}
|
|
44
|
+
export type ConfigValue = string | number | boolean | null;
|
|
45
|
+
export type ValueMap = Record<string, ConfigValue>;
|
|
46
|
+
export type ToastTone = 'success' | 'error' | 'info' | 'warning';
|
|
47
|
+
export interface ToastMessage {
|
|
48
|
+
id: number;
|
|
49
|
+
text: string;
|
|
50
|
+
tone: ToastTone;
|
|
51
|
+
}
|
|
52
|
+
export interface ConfigOption {
|
|
53
|
+
label: string;
|
|
54
|
+
value: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
/** 用户运行时新增的选项,可删除 */
|
|
57
|
+
custom?: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface ConfigFieldBase {
|
|
60
|
+
/** 唯一键,同时作为持久化与业务读取的键 */
|
|
61
|
+
key: string;
|
|
62
|
+
label: string;
|
|
63
|
+
/** 分组 id,对应 {@link ConfigGroup.id};缺省归入“常规” */
|
|
64
|
+
group?: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* 是否写入 localStorage,默认 true。
|
|
69
|
+
* token / 密钥等敏感值设为 false:只在当前页面内存中保留,刷新后回到默认值。
|
|
70
|
+
*/
|
|
71
|
+
persist?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface SelectField extends ConfigFieldBase {
|
|
74
|
+
type: 'select';
|
|
75
|
+
options: ConfigOption[];
|
|
76
|
+
/** 允许输入预设之外的值(写入并保留为自定义项) */
|
|
77
|
+
allowCustom?: boolean;
|
|
78
|
+
placeholder?: string;
|
|
79
|
+
defaultValue?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface TextField extends ConfigFieldBase {
|
|
82
|
+
type: 'text';
|
|
83
|
+
placeholder?: string;
|
|
84
|
+
/** 只读且带复制按钮(token / 灰度号等) */
|
|
85
|
+
copyable?: boolean;
|
|
86
|
+
mono?: boolean;
|
|
87
|
+
defaultValue?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface TextareaField extends ConfigFieldBase {
|
|
90
|
+
type: 'textarea';
|
|
91
|
+
placeholder?: string;
|
|
92
|
+
rows?: number;
|
|
93
|
+
mono?: boolean;
|
|
94
|
+
defaultValue?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface NumberField extends ConfigFieldBase {
|
|
97
|
+
type: 'number';
|
|
98
|
+
min?: number;
|
|
99
|
+
max?: number;
|
|
100
|
+
step?: number;
|
|
101
|
+
defaultValue?: number;
|
|
102
|
+
}
|
|
103
|
+
export interface SwitchField extends ConfigFieldBase {
|
|
104
|
+
type: 'switch';
|
|
105
|
+
defaultValue?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export type ConfigField = SelectField | TextField | TextareaField | NumberField | SwitchField;
|
|
108
|
+
export interface ConfigGroup {
|
|
109
|
+
id: string;
|
|
110
|
+
label: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
}
|
|
113
|
+
export type IconName = 'activity' | 'alert-circle' | 'arrow-down' | 'arrow-left' | 'arrow-up' | 'arrow-up-down' | 'arrow-up-right' | 'box' | 'bug' | 'calendar' | 'check' | 'chevron-down' | 'chevron-right' | 'chevron-up' | 'circle' | 'clipboard' | 'copy' | 'database' | 'eraser' | 'external-link' | 'eye' | 'eye-off' | 'filter' | 'ghost' | 'globe' | 'key' | 'layers' | 'list-filter' | 'maximize-2' | 'minimize-2' | 'minus' | 'moon' | 'palette' | 'panel-bottom' | 'panel-left' | 'panel-right' | 'pip' | 'play' | 'plus' | 'radar' | 'refresh-cw' | 'rotate-ccw' | 'search' | 'send' | 'settings' | 'sliders-horizontal' | 'sparkles' | 'square-terminal' | 'sun' | 'terminal' | 'trash' | 'users' | 'x' | 'zap';
|
|
114
|
+
export interface NetworkEntry {
|
|
115
|
+
id: string;
|
|
116
|
+
kind: 'fetch' | 'xhr' | 'img' | 'socket';
|
|
117
|
+
method: string;
|
|
118
|
+
url: string;
|
|
119
|
+
status: number;
|
|
120
|
+
statusText: string;
|
|
121
|
+
/** 状态码为 2xx / 3xx 时为 true(Fetch、XHR 与 IMG 同口径;Socket 握手成功为 true);网络错误或其它状态为 false */
|
|
122
|
+
ok: boolean;
|
|
123
|
+
pending: boolean;
|
|
124
|
+
startAt: number;
|
|
125
|
+
duration: number;
|
|
126
|
+
requestHeaders: Record<string, string>;
|
|
127
|
+
requestBody?: string;
|
|
128
|
+
responseHeaders: Record<string, string>;
|
|
129
|
+
responseBody?: string;
|
|
130
|
+
responseSize: number;
|
|
131
|
+
error?: string;
|
|
132
|
+
}
|
|
133
|
+
export type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
134
|
+
export interface LogEntry {
|
|
135
|
+
id: number;
|
|
136
|
+
level: LogLevel;
|
|
137
|
+
at: number;
|
|
138
|
+
args: string;
|
|
139
|
+
count: number;
|
|
140
|
+
}
|
|
141
|
+
export interface DevtoolsActionContext {
|
|
142
|
+
devtools: DevtoolsInstance;
|
|
143
|
+
values: ValueMap;
|
|
144
|
+
getValue<T extends ConfigValue = ConfigValue>(key: string, fallback?: T): T;
|
|
145
|
+
setValue(key: string, value: ConfigValue): void;
|
|
146
|
+
open(pluginId?: string): void;
|
|
147
|
+
close(): void;
|
|
148
|
+
toast(text: string, tone?: ToastTone): void;
|
|
149
|
+
copy(text: string): Promise<boolean>;
|
|
150
|
+
}
|
|
151
|
+
export type ActionTone = 'default' | 'danger';
|
|
152
|
+
export interface DevtoolsAction {
|
|
153
|
+
id: string;
|
|
154
|
+
label: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
icon?: IconName;
|
|
157
|
+
tone?: ActionTone;
|
|
158
|
+
/** 执行前确认文案;true 使用默认文案 */
|
|
159
|
+
confirm?: boolean | string;
|
|
160
|
+
run(ctx: DevtoolsActionContext): void | Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
export interface NetworkApi {
|
|
163
|
+
entries(): NetworkEntry[];
|
|
164
|
+
clear(): void;
|
|
165
|
+
replay(id: string): Promise<NetworkEntry | undefined>;
|
|
166
|
+
capturing(): boolean;
|
|
167
|
+
setCapturing(value: boolean): void;
|
|
168
|
+
}
|
|
169
|
+
export interface PluginContext {
|
|
170
|
+
id: string;
|
|
171
|
+
/** shadow root,可用于挂弹层;普通渲染请用 container */
|
|
172
|
+
root: ShadowRoot;
|
|
173
|
+
/** 插件独占的内容容器(面板切换时保留现场) */
|
|
174
|
+
container: HTMLElement;
|
|
175
|
+
/** 当前插件内容是否正在显示(已选中、面板已打开且未折叠) */
|
|
176
|
+
isActive(): boolean;
|
|
177
|
+
/** 在插件内容从隐藏变为显示时调用,返回取消监听函数 */
|
|
178
|
+
onActivate(fn: () => void): () => void;
|
|
179
|
+
/** 向共享 ShadowRoot 注入样式,返回移除函数;插件卸载时自动清理 */
|
|
180
|
+
addStyle(cssText: string): () => void;
|
|
181
|
+
app: {
|
|
182
|
+
name: string;
|
|
183
|
+
version: string;
|
|
184
|
+
};
|
|
185
|
+
get values(): ValueMap;
|
|
186
|
+
getValue<T extends ConfigValue = ConfigValue>(key: string, fallback?: T): T;
|
|
187
|
+
setValue(key: string, value: ConfigValue): void;
|
|
188
|
+
/** 监听配置变更,返回取消函数 */
|
|
189
|
+
onChange(handler: (payload: ConfigChangePayload) => void): () => void;
|
|
190
|
+
/** 监听任意 devtools 事件,返回取消函数 */
|
|
191
|
+
on<T = unknown>(event: string, handler: (payload: T) => void): () => void;
|
|
192
|
+
emit(event: string, payload?: unknown): void;
|
|
193
|
+
/** 命名空间为本插件 id 的持久化存储 */
|
|
194
|
+
storage: {
|
|
195
|
+
get<T>(key: string, fallback: T): T;
|
|
196
|
+
set(key: string, value: unknown): void;
|
|
197
|
+
remove(key: string): void;
|
|
198
|
+
};
|
|
199
|
+
network: NetworkApi;
|
|
200
|
+
toast(text: string, tone?: ToastTone): void;
|
|
201
|
+
copy(text: string): Promise<boolean>;
|
|
202
|
+
/** 在插件被移除 / devtools 销毁时执行 */
|
|
203
|
+
onDispose(fn: () => void): void;
|
|
204
|
+
devtools: DevtoolsInstance;
|
|
205
|
+
}
|
|
206
|
+
export interface DevtoolsPlugin {
|
|
207
|
+
id: string;
|
|
208
|
+
title: string;
|
|
209
|
+
icon?: IconName;
|
|
210
|
+
/** 侧栏排序,数字小的在前 */
|
|
211
|
+
order?: number;
|
|
212
|
+
/** 面板标题下方的说明文案 */
|
|
213
|
+
subtitle?: string | (() => string);
|
|
214
|
+
enabled?: boolean | (() => boolean);
|
|
215
|
+
/** 侧栏角标,返回 null 表示不显示 */
|
|
216
|
+
badge?: () => number | string | null;
|
|
217
|
+
/**
|
|
218
|
+
* 渲染入口。注册时创建容器并渲染,之后切换标签不复建。
|
|
219
|
+
* 需要清理的资源请用 ctx.onDispose 注册。
|
|
220
|
+
*/
|
|
221
|
+
render(container: HTMLElement, ctx: PluginContext): void;
|
|
222
|
+
/** 插件自身的内部状态变更时调用,驱动角标刷新 */
|
|
223
|
+
refresh?(): void;
|
|
224
|
+
}
|
|
225
|
+
export interface ConfigChangePayload {
|
|
226
|
+
values: ValueMap;
|
|
227
|
+
changed: string;
|
|
228
|
+
source: 'user' | 'program' | 'reset';
|
|
229
|
+
}
|
|
230
|
+
export interface NetworkCaptureOptions {
|
|
231
|
+
maxEntries?: number;
|
|
232
|
+
/** 是否捕获响应体,默认 true,单条上限 200KB */
|
|
233
|
+
responseBody?: boolean;
|
|
234
|
+
/** 额外跳过的 URL 片段 */
|
|
235
|
+
ignore?: string[];
|
|
236
|
+
}
|
|
237
|
+
export interface DevtoolsOptions {
|
|
238
|
+
/** 面板标题与应用名,默认取 document.title */
|
|
239
|
+
appName?: string;
|
|
240
|
+
version?: string;
|
|
241
|
+
/** false 时完全不挂载(生产环境常用) */
|
|
242
|
+
enabled?: boolean | (() => boolean);
|
|
243
|
+
theme?: DevtoolsTheme;
|
|
244
|
+
/** 自定义主题列表,也可在运行时通过 registerTheme 动态添加 */
|
|
245
|
+
themes?: DevtoolsThemeDefinition[];
|
|
246
|
+
/** 面板视图大小档位:'sm'(小)| 'md'(中)| 'lg'(大),出厂默认 'lg' */
|
|
247
|
+
size?: PanelSize;
|
|
248
|
+
/**
|
|
249
|
+
* 面板与悬浮球的出厂默认角,默认 `'bottom-left'`。
|
|
250
|
+
* 同一取值同时约束:无拖拽记忆时的首次展开停靠、悬浮球初始位置、缩小落点和「复位位置」。
|
|
251
|
+
* 用户拖拽后的本地记忆优先,直到复位。
|
|
252
|
+
*/
|
|
253
|
+
defaultCorner?: DefaultCorner;
|
|
254
|
+
/** @deprecated 已移除视图停靠切换,请使用 size 控制视图档位,面板支持直接拖拽 */
|
|
255
|
+
dock?: DockSide;
|
|
256
|
+
/** @deprecated 请使用 size: 'sm' | 'md' | 'lg' */
|
|
257
|
+
density?: DevtoolsDensity;
|
|
258
|
+
/** @deprecated 请使用 size: 'sm' | 'md' | 'lg' */
|
|
259
|
+
width?: number;
|
|
260
|
+
/** @deprecated 请使用 size: 'sm' | 'md' | 'lg' */
|
|
261
|
+
minWidth?: number;
|
|
262
|
+
/** @deprecated 请使用 size: 'sm' | 'md' | 'lg' */
|
|
263
|
+
maxWidth?: number;
|
|
264
|
+
/** 悬浮球;false 表示不显示(只保留程序调用) */
|
|
265
|
+
launcher?: boolean | LauncherOptions;
|
|
266
|
+
/**
|
|
267
|
+
* 严格 CSP 环境下的 style nonce:`style-src 'nonce-...'`。
|
|
268
|
+
* 传入函数时每次挂载重新求值(适配服务端注入的随机 nonce)。
|
|
269
|
+
*/
|
|
270
|
+
styleNonce?: string | (() => string);
|
|
271
|
+
/** localStorage 前缀,默认 rinova-devtools */
|
|
272
|
+
storagePrefix?: string;
|
|
273
|
+
config?: ConfigField[];
|
|
274
|
+
groups?: ConfigGroup[];
|
|
275
|
+
/** 初始值,优先级低于用户本地保存值 */
|
|
276
|
+
values?: ValueMap;
|
|
277
|
+
actions?: DevtoolsAction[];
|
|
278
|
+
plugins?: DevtoolsPlugin[];
|
|
279
|
+
/** 内置面板白名单,false 表示全部不装 */
|
|
280
|
+
builtinPlugins?: BuiltinPluginId[] | false;
|
|
281
|
+
captureNetwork?: boolean;
|
|
282
|
+
captureConsole?: boolean;
|
|
283
|
+
network?: NetworkCaptureOptions;
|
|
284
|
+
maxLogEntries?: number;
|
|
285
|
+
/** 挂到 window.__RINOVA_DEVTOOLS__,便于控制台调试 */
|
|
286
|
+
exposeGlobal?: boolean | string;
|
|
287
|
+
onConfigChange?(payload: ConfigChangePayload): void;
|
|
288
|
+
onOpen?(): void;
|
|
289
|
+
onClose?(): void;
|
|
290
|
+
}
|
|
291
|
+
export type BuiltinPluginId = 'config' | 'network' | 'storage' | 'console' | 'actions' | 'settings';
|
|
292
|
+
export interface DevtoolsInstance {
|
|
293
|
+
readonly version: string;
|
|
294
|
+
readonly appName: string;
|
|
295
|
+
readonly mounted: boolean;
|
|
296
|
+
mount(): DevtoolsInstance;
|
|
297
|
+
destroy(): void;
|
|
298
|
+
open(pluginId?: string): void;
|
|
299
|
+
close(): void;
|
|
300
|
+
toggle(): void;
|
|
301
|
+
isOpen(): boolean;
|
|
302
|
+
registerPlugin(plugin: DevtoolsPlugin): () => void;
|
|
303
|
+
removePlugin(id: string): void;
|
|
304
|
+
listPlugins(): DevtoolsPlugin[];
|
|
305
|
+
registerAction(action: DevtoolsAction): () => void;
|
|
306
|
+
registerConfigField(field: ConfigField): () => void;
|
|
307
|
+
registerTheme(theme: DevtoolsThemeDefinition): () => void;
|
|
308
|
+
listThemes(): DevtoolsThemeDefinition[];
|
|
309
|
+
getValues(): ValueMap;
|
|
310
|
+
getValue<T extends ConfigValue = ConfigValue>(key: string, fallback?: T): T;
|
|
311
|
+
setValue(key: string, value: ConfigValue): void;
|
|
312
|
+
setValues(patch: ValueMap): void;
|
|
313
|
+
resetConfig(): void;
|
|
314
|
+
on<T = unknown>(event: string, handler: (payload: T) => void): () => void;
|
|
315
|
+
off(event: string, handler: (payload: never) => void): void;
|
|
316
|
+
toast(text: string, tone?: ToastTone): void;
|
|
317
|
+
network: NetworkApi;
|
|
318
|
+
}
|
|
319
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ComponentDef } from './component.js';
|
|
2
|
+
export interface ChoiceGroupOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface ChoiceGroupProps<Value> {
|
|
8
|
+
label: string;
|
|
9
|
+
options: readonly ChoiceGroupOption[];
|
|
10
|
+
name?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
readonly?: boolean;
|
|
13
|
+
orientation?: 'horizontal' | 'vertical';
|
|
14
|
+
value?: Value;
|
|
15
|
+
defaultValue?: Value;
|
|
16
|
+
onChange?: (value: Value) => void;
|
|
17
|
+
}
|
|
18
|
+
export type RadioGroupProps = ChoiceGroupProps<string | null>;
|
|
19
|
+
export type CheckboxGroupProps = ChoiceGroupProps<readonly string[]>;
|
|
20
|
+
export declare const RadioGroup: ComponentDef<RadioGroupProps, {
|
|
21
|
+
change: string | null;
|
|
22
|
+
}, HTMLFieldSetElement>;
|
|
23
|
+
export declare const CheckboxGroup: ComponentDef<CheckboxGroupProps, {
|
|
24
|
+
change: readonly string[];
|
|
25
|
+
}, HTMLFieldSetElement>;
|
|
26
|
+
export declare function radioGroup({ value, ...props }: RadioGroupProps): HTMLFieldSetElement;
|
|
27
|
+
export declare function checkboxGroup({ value, ...props }: CheckboxGroupProps): HTMLFieldSetElement;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CopyResult } from './inspectors.js';
|
|
2
|
+
/** 超过该行数时不再做语法高亮,只保留纯文本与行号 */
|
|
3
|
+
export declare const CODE_EDITOR_HIGHLIGHT_MAX_LINES = 500;
|
|
4
|
+
export interface CodeEditorProps {
|
|
5
|
+
code: string;
|
|
6
|
+
language?: 'text' | 'json' | 'js' | 'css' | 'html';
|
|
7
|
+
ariaLabel?: string;
|
|
8
|
+
lineNumbers?: boolean;
|
|
9
|
+
toolbar?: boolean;
|
|
10
|
+
searchable?: boolean;
|
|
11
|
+
onCopy?: (result: CopyResult) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const CodeEditor: import("./component.js").ComponentDef<CodeEditorProps, {
|
|
14
|
+
copy: CopyResult;
|
|
15
|
+
}, HTMLElement>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ComponentView<P, El extends HTMLElement = HTMLElement> {
|
|
2
|
+
el: El;
|
|
3
|
+
update(props: P): void;
|
|
4
|
+
dispose?(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface ComponentDef<P, E, El extends HTMLElement = HTMLElement> {
|
|
7
|
+
name: string;
|
|
8
|
+
create(props: P, emit: <K extends keyof E>(event: K, payload: E[K]) => void): ComponentView<P, El>;
|
|
9
|
+
}
|
|
10
|
+
export interface ComponentHandle<P, E, El extends HTMLElement = HTMLElement> {
|
|
11
|
+
readonly el: El;
|
|
12
|
+
/** Replace the current props with a complete snapshot. Framework adapters should keep using this. */
|
|
13
|
+
setProps(props: P): void;
|
|
14
|
+
/** Shallow-merge props for imperative plugin use. Does not replace unspecified keys. */
|
|
15
|
+
patchProps(props: Partial<P>): void;
|
|
16
|
+
on<K extends keyof E>(event: K, fn: (payload: E[K]) => void): () => void;
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function defineComponent<P, E, El extends HTMLElement = HTMLElement>(def: ComponentDef<P, E, El>): ComponentDef<P, E, El>;
|
|
20
|
+
export declare function mount<P, E, El extends HTMLElement>(def: ComponentDef<P, E, El>, props: P, parent?: HTMLElement): ComponentHandle<P, E, El>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DateRange = readonly [start: string, end: string];
|
|
2
|
+
export type DatePickerValue = string | DateRange | null;
|
|
3
|
+
export interface DatePickerProps {
|
|
4
|
+
ariaLabel: string;
|
|
5
|
+
range?: boolean;
|
|
6
|
+
value?: DatePickerValue;
|
|
7
|
+
defaultValue?: DatePickerValue;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
min?: string;
|
|
11
|
+
max?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
onChange?: (value: DatePickerValue) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const DatePicker: import("./component.js").ComponentDef<DatePickerProps, {
|
|
17
|
+
change: DatePickerValue;
|
|
18
|
+
}, HTMLElement>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type DialogResult = 'confirm' | 'cancel';
|
|
2
|
+
export interface DialogProps {
|
|
3
|
+
label?: string;
|
|
4
|
+
title: string;
|
|
5
|
+
content?: Node | string;
|
|
6
|
+
trigger?: Node;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
confirmLabel?: string;
|
|
10
|
+
cancelLabel?: string;
|
|
11
|
+
confirmTone?: 'primary' | 'danger';
|
|
12
|
+
confirmDisabled?: boolean;
|
|
13
|
+
hideCancel?: boolean;
|
|
14
|
+
closeOnBackdrop?: boolean;
|
|
15
|
+
/** `page` locks the host page without `showModal()` so window chrome stays usable; `panel` scopes the backdrop to the panel content area. */
|
|
16
|
+
modal?: 'page' | 'panel';
|
|
17
|
+
/**
|
|
18
|
+
* 是否显示遮罩,默认 true。与 `modal`、`closeOnBackdrop` 独立。
|
|
19
|
+
* 无遮罩时不可点遮罩关闭;若仍是模态,焦点仍锁在对话框内。
|
|
20
|
+
*/
|
|
21
|
+
mask?: boolean;
|
|
22
|
+
onConfirm?: () => void | Promise<void>;
|
|
23
|
+
onClose?: (result: DialogResult) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const Dialog: import("./component.js").ComponentDef<DialogProps, {
|
|
26
|
+
close: DialogResult;
|
|
27
|
+
}, HTMLElement>;
|
package/dist/ui/dom.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { IconName } from '../types.js';
|
|
2
|
+
type Child = Node | string | number | null | undefined | false;
|
|
3
|
+
type Children = Child | Children[];
|
|
4
|
+
export interface ElementAttrs {
|
|
5
|
+
class?: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
html?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
style?: Partial<CSSStyleDeclaration> | Record<string, string>;
|
|
15
|
+
dataset?: Record<string, string>;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: ElementAttrs | null, children?: Children): HTMLElementTagNameMap[K];
|
|
19
|
+
export declare function append(parent: Element, children?: Children): void;
|
|
20
|
+
export declare function icon(name: IconName | undefined, size?: number | 'sm' | 'md', strokeWidth?: number): SVGSVGElement;
|
|
21
|
+
export declare function clear(node: Element): void;
|
|
22
|
+
export interface ButtonOptions {
|
|
23
|
+
icon?: IconName;
|
|
24
|
+
tone?: 'default' | 'primary' | 'danger' | 'ghost';
|
|
25
|
+
size?: 'sm' | 'md';
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
title?: string;
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
onClick?: (event: MouseEvent) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function paintButton(el: HTMLButtonElement, label: string, opts: ButtonOptions): void;
|
|
33
|
+
export declare function button(label: string, opts?: ButtonOptions): HTMLButtonElement;
|
|
34
|
+
export declare const COPY_FEEDBACK_MS = 1200;
|
|
35
|
+
/** 复制反馈默认使用绿色对勾,也可以临时切换按钮中预留的文案。 */
|
|
36
|
+
export declare function flashCopied(btn: HTMLButtonElement, feedback?: {
|
|
37
|
+
label: string;
|
|
38
|
+
ok: boolean;
|
|
39
|
+
}): void;
|
|
40
|
+
export interface FieldOptions {
|
|
41
|
+
hint?: string;
|
|
42
|
+
error?: string;
|
|
43
|
+
layout?: 'vertical' | 'horizontal';
|
|
44
|
+
}
|
|
45
|
+
/** Associate a Field label with the first focusable control and mark error state. */
|
|
46
|
+
export declare function bindFieldControl(control: Node | undefined, options: {
|
|
47
|
+
id: string;
|
|
48
|
+
invalid?: boolean;
|
|
49
|
+
describedBy?: string;
|
|
50
|
+
}): string | undefined;
|
|
51
|
+
export declare function field(label: string, control: Node, hint?: string | FieldOptions): HTMLElement;
|
|
52
|
+
export interface EmptyOptions {
|
|
53
|
+
icon?: IconName;
|
|
54
|
+
action?: Node;
|
|
55
|
+
compact?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare function empty(text: string, iconName?: IconName | EmptyOptions): HTMLElement;
|
|
58
|
+
export declare function tag(text: string, tone?: 'neutral' | 'ok' | 'warn' | 'error' | 'info'): HTMLElement;
|
|
59
|
+
export declare function segmented<T extends string>(items: Array<{
|
|
60
|
+
value: T;
|
|
61
|
+
label: string;
|
|
62
|
+
icon?: IconName;
|
|
63
|
+
}>, value: T, onPick: (value: T) => void, options?: {
|
|
64
|
+
ariaLabel?: string;
|
|
65
|
+
}): HTMLElement;
|
|
66
|
+
export {};
|