@rinova/devtools 0.0.0-stage → 0.10.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 +25 -3
- 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 +42 -0
- package/dist/core/runtime.d.ts +59 -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 +12 -0
- package/dist/index.js +3233 -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/network.d.ts +2 -0
- package/dist/plugins/settings.d.ts +2 -0
- package/dist/plugins/storage.d.ts +2 -0
- package/dist/types.d.ts +306 -0
- package/dist/ui/dom.d.ts +38 -0
- package/dist/ui/shell.d.ts +133 -0
- package/dist/utils/curl.d.ts +4 -0
- package/dist/utils/format.d.ts +15 -0
- package/dist/utils/hotkey.d.ts +22 -0
- package/dist/version.d.ts +1 -0
- package/package.json +51 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jove
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @rinova/devtools
|
|
2
|
+
|
|
3
|
+
框架无关的前端调试面板内核。提供悬浮球、停靠面板、配置、网络、存储、日志、快捷操作与插件系统。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add @rinova/devtools
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createDevtools } from '@rinova/devtools'
|
|
11
|
+
|
|
12
|
+
createDevtools({
|
|
13
|
+
appName: 'My App',
|
|
14
|
+
enabled: import.meta.env.DEV,
|
|
15
|
+
config: [{ key: 'apiBase', type: 'text', label: 'API 地址' }]
|
|
16
|
+
}).mount()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- 只依赖 DOM 与 Shadow DOM,可接入 Vue / React / Svelte / 原生页面
|
|
20
|
+
- 无 UI 组件库、无遥测、无远程资源
|
|
21
|
+
- 网络面板支持复制 cURL、重放请求;配置 schema 驱动、即时生效
|
|
22
|
+
|
|
23
|
+
完整文档见仓库 `docs/`:架构、配置、插件开发、框架接入、内置面板、路线图。
|
|
24
|
+
|
|
25
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConfigChangePayload, ConfigField, ConfigGroup, ConfigValue, ValueMap } from '../types.js';
|
|
2
|
+
import type { SafeStorage } from './storage.js';
|
|
3
|
+
export declare function fieldDefault(field: ConfigField): ConfigValue;
|
|
4
|
+
export declare class ConfigStore {
|
|
5
|
+
private storage;
|
|
6
|
+
private fieldsMap;
|
|
7
|
+
private groupOrder;
|
|
8
|
+
private state;
|
|
9
|
+
private persisted;
|
|
10
|
+
private listeners;
|
|
11
|
+
constructor(fields: ConfigField[], storage: SafeStorage, groups?: ConfigGroup[], initial?: ValueMap);
|
|
12
|
+
private buildState;
|
|
13
|
+
private isPersistent;
|
|
14
|
+
private persist;
|
|
15
|
+
get fields(): ConfigField[];
|
|
16
|
+
get groups(): ConfigGroup[];
|
|
17
|
+
fieldsOf(groupId: string): ConfigField[];
|
|
18
|
+
get(): ValueMap;
|
|
19
|
+
getValue<T extends ConfigValue = ConfigValue>(key: string, fallback?: T): T;
|
|
20
|
+
registerField(field: ConfigField): () => void;
|
|
21
|
+
set(key: string, raw: ConfigValue, source?: ConfigChangePayload['source']): boolean;
|
|
22
|
+
setMany(patch: ValueMap, source?: ConfigChangePayload['source']): boolean;
|
|
23
|
+
reset(): void;
|
|
24
|
+
subscribe(listener: (payload: ConfigChangePayload) => void): () => void;
|
|
25
|
+
private emit;
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LogEntry } from '../types.js';
|
|
2
|
+
type LogListener = (entry: LogEntry) => void;
|
|
3
|
+
/** console 采集:保留原 console 行为,只做旁路记录 */
|
|
4
|
+
export declare class ConsoleCapture {
|
|
5
|
+
private maxEntries;
|
|
6
|
+
private list;
|
|
7
|
+
private listeners;
|
|
8
|
+
private changeListeners;
|
|
9
|
+
private originals;
|
|
10
|
+
private started;
|
|
11
|
+
private seq;
|
|
12
|
+
private onError;
|
|
13
|
+
private onRejection;
|
|
14
|
+
constructor(maxEntries?: number);
|
|
15
|
+
start(): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
entries(): LogEntry[];
|
|
18
|
+
subscribe(listener: LogListener): () => void;
|
|
19
|
+
subscribeChange(listener: () => void): () => void;
|
|
20
|
+
clear(): void;
|
|
21
|
+
private append;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Handler = (payload: never) => void;
|
|
2
|
+
/** 极小事件总线:核心不依赖框架的响应式系统 */
|
|
3
|
+
export declare class Emitter {
|
|
4
|
+
private map;
|
|
5
|
+
on<T>(event: string, handler: (payload: T) => void): () => void;
|
|
6
|
+
off(event: string, handler: Handler): void;
|
|
7
|
+
emit<T>(event: string, payload: T): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { NetworkCaptureOptions, NetworkEntry } from '../types.js';
|
|
2
|
+
type EntryListener = (entry: NetworkEntry) => void;
|
|
3
|
+
/**
|
|
4
|
+
* 网络采集器:直接补丁 window.fetch / XMLHttpRequest。
|
|
5
|
+
* 只在 mount 时启动一次,面板打开/关闭不影响采集。
|
|
6
|
+
*/
|
|
7
|
+
export declare class NetworkCapture {
|
|
8
|
+
private list;
|
|
9
|
+
private listeners;
|
|
10
|
+
private changeListeners;
|
|
11
|
+
private maxEntries;
|
|
12
|
+
private captureResponseBody;
|
|
13
|
+
private ignore;
|
|
14
|
+
private started;
|
|
15
|
+
private originalFetch?;
|
|
16
|
+
private originalXhrOpen?;
|
|
17
|
+
private originalXhrSend?;
|
|
18
|
+
private enabled;
|
|
19
|
+
private changeScheduled;
|
|
20
|
+
constructor(options?: NetworkCaptureOptions);
|
|
21
|
+
start(): void;
|
|
22
|
+
stop(): void;
|
|
23
|
+
capturing(): boolean;
|
|
24
|
+
setCapturing(value: boolean): void;
|
|
25
|
+
entries(): NetworkEntry[];
|
|
26
|
+
clear(): void;
|
|
27
|
+
subscribe(listener: EntryListener): () => void;
|
|
28
|
+
subscribeChange(listener: () => void): () => void;
|
|
29
|
+
private shouldIgnore;
|
|
30
|
+
private push;
|
|
31
|
+
private update;
|
|
32
|
+
/**
|
|
33
|
+
* 同一 tick 内的多次 push/update 合并成一次通知:
|
|
34
|
+
* 1000 条记录批量到达时,面板只重建一次可视窗口。
|
|
35
|
+
*/
|
|
36
|
+
private scheduleChange;
|
|
37
|
+
private notifyChange;
|
|
38
|
+
private patchFetch;
|
|
39
|
+
private patchXhr;
|
|
40
|
+
replay(entryId: string): Promise<NetworkEntry | undefined>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ConfigValue, DevtoolsAction, DevtoolsInstance, DevtoolsOptions, DevtoolsTheme, DevtoolsThemeDefinition, PanelPosition, PanelSize, ToastTone, ValueMap } from '../types.js';
|
|
2
|
+
import type { ConfigStore } from './config-store.js';
|
|
3
|
+
import type { ConsoleCapture } from './console-capture.js';
|
|
4
|
+
import type { Emitter } from './emitter.js';
|
|
5
|
+
import type { NetworkCapture } from './network-capture.js';
|
|
6
|
+
import type { SafeStorage } from './storage.js';
|
|
7
|
+
/** 解析后的配置:默认值已补齐 */
|
|
8
|
+
export interface ResolvedOptions extends DevtoolsOptions {
|
|
9
|
+
appName: string;
|
|
10
|
+
version: string;
|
|
11
|
+
theme: DevtoolsTheme;
|
|
12
|
+
size: PanelSize;
|
|
13
|
+
shortcut: string | false;
|
|
14
|
+
storagePrefix: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RuntimeUi {
|
|
17
|
+
getTheme(): DevtoolsTheme;
|
|
18
|
+
getThemes(): DevtoolsThemeDefinition[];
|
|
19
|
+
getSize(): PanelSize;
|
|
20
|
+
getCollapsed(): boolean;
|
|
21
|
+
getAutoTuck(): boolean;
|
|
22
|
+
getPanelPos(): PanelPosition | null;
|
|
23
|
+
/** 生效中的快捷键(已合并用户覆盖与 options 默认值) */
|
|
24
|
+
getShortcut(): string | false;
|
|
25
|
+
setTheme(theme: DevtoolsTheme): void;
|
|
26
|
+
setSize(size: PanelSize): void;
|
|
27
|
+
setCollapsed(collapsed: boolean): void;
|
|
28
|
+
setAutoTuck(autoTuck: boolean): void;
|
|
29
|
+
setPanelPos(pos: PanelPosition | null): void;
|
|
30
|
+
/** null 表示恢复 options.shortcut */
|
|
31
|
+
setShortcut(shortcut: string | false | null): void;
|
|
32
|
+
resetLauncher(): void;
|
|
33
|
+
resetAll(): void;
|
|
34
|
+
activePlugin(): string;
|
|
35
|
+
activate(pluginId: string): void;
|
|
36
|
+
}
|
|
37
|
+
/** 内置与第三方插件共享的运行时,避免插件直接依赖内部实现细节 */
|
|
38
|
+
export interface Runtime {
|
|
39
|
+
options: ResolvedOptions;
|
|
40
|
+
storage: SafeStorage;
|
|
41
|
+
config: ConfigStore;
|
|
42
|
+
network: NetworkCapture;
|
|
43
|
+
logs: ConsoleCapture;
|
|
44
|
+
bus: Emitter;
|
|
45
|
+
actions: DevtoolsAction[];
|
|
46
|
+
themes: Map<string, DevtoolsThemeDefinition>;
|
|
47
|
+
ui: RuntimeUi;
|
|
48
|
+
app: {
|
|
49
|
+
name: string;
|
|
50
|
+
version: string;
|
|
51
|
+
mode: string;
|
|
52
|
+
};
|
|
53
|
+
getInstance(): DevtoolsInstance;
|
|
54
|
+
toast(text: string, tone?: ToastTone): void;
|
|
55
|
+
copy(text: string): Promise<boolean>;
|
|
56
|
+
open(pluginId?: string): void;
|
|
57
|
+
close(): void;
|
|
58
|
+
}
|
|
59
|
+
export declare function readValue<T extends ConfigValue = ConfigValue>(values: ValueMap, key: string, fallback: T): T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** 带命名空间的 localStorage 访问;不可用时退化为内存,保证隐私模式不崩 */
|
|
2
|
+
export declare class SafeStorage {
|
|
3
|
+
private prefix;
|
|
4
|
+
private memory;
|
|
5
|
+
private available;
|
|
6
|
+
constructor(prefix: string);
|
|
7
|
+
private get store();
|
|
8
|
+
private full;
|
|
9
|
+
get(key: string): string | null;
|
|
10
|
+
set(key: string, value: string): void;
|
|
11
|
+
remove(key: string): void;
|
|
12
|
+
getJSON<T>(key: string, fallback: T): T;
|
|
13
|
+
setJSON(key: string, value: unknown): void;
|
|
14
|
+
/** 清理本命名空间下的所有键(其他工具的数据不受影响) */
|
|
15
|
+
clearNamespace(): void;
|
|
16
|
+
}
|
|
17
|
+
/** 拷贝到剪贴板,返回是否成功(含非安全上下文降级) */
|
|
18
|
+
export declare function copyText(text: string): Promise<boolean>;
|
|
19
|
+
/** 触发浏览器下载(导出配置等) */
|
|
20
|
+
export declare function downloadText(filename: string, content: string, mime?: string): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DevtoolsInstance, DevtoolsOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* 创建 devtools 实例。
|
|
4
|
+
*
|
|
5
|
+
* 该函数不依赖任何框架;Vue/React 适配器只是对它的薄封装。
|
|
6
|
+
* 未调用 mount() 前不会修改 DOM,也不会补丁任何全局函数。
|
|
7
|
+
*/
|
|
8
|
+
export declare function createDevtools(options?: DevtoolsOptions): DevtoolsInstance;
|
package/dist/icons.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createDevtools } from './create-devtools.js';
|
|
2
|
+
import type { ConfigField, DevtoolsPlugin } from './types.js';
|
|
3
|
+
export { createDevtools };
|
|
4
|
+
export { VERSION } from './version.js';
|
|
5
|
+
export { h, icon, button, field, empty, tag, segmented } from './ui/dom.js';
|
|
6
|
+
export { formatBytes, formatDuration, formatClock, previewValue, prettyJSON } from './utils/format.js';
|
|
7
|
+
export { toCurl } from './utils/curl.js';
|
|
8
|
+
export type { ActionTone, BuiltinPluginId, ConfigChangePayload, ConfigField, ConfigGroup, ConfigOption, ConfigValue, DevtoolsAction, DevtoolsActionContext, DevtoolsBuiltinTheme, DevtoolsDensity, DevtoolsInstance, DevtoolsOptions, DevtoolsPlugin, DevtoolsTheme, DevtoolsThemeDefinition, DockSide, FloatRect, IconName, LauncherOptions, LogEntry, LogLevel, NetworkApi, NetworkCaptureOptions, NetworkEntry, PanelPosition, PanelSize, PluginContext, ToastTone, ValueMap } from './types.js';
|
|
9
|
+
/** 仅用于获得类型推断,运行时原样返回 */
|
|
10
|
+
export declare function definePlugin(plugin: DevtoolsPlugin): DevtoolsPlugin;
|
|
11
|
+
/** 仅用于获得类型推断,运行时原样返回 */
|
|
12
|
+
export declare function defineConfig(fields: ConfigField[]): ConfigField[];
|