@proteus-vue/devtools 0.1.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/README.md +114 -0
- package/dist/component-trace.d.ts +35 -0
- package/dist/device-info.d.ts +5 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +3323 -0
- package/dist/install.d.ts +76 -0
- package/dist/ownership-info.d.ts +77 -0
- package/dist/panel.d.ts +39 -0
- package/dist/panel.js +9172 -0
- package/dist/plugins/network.d.ts +2 -0
- package/dist/plugins.d.ts +64 -0
- package/dist/session-io.d.ts +35 -0
- package/dist/snapshot-io.d.ts +37 -0
- package/dist/source.d.ts +22 -0
- package/dist/tooltip.d.ts +21 -0
- package/dist/views/components.d.ts +26 -0
- package/dist/views/device.d.ts +43 -0
- package/dist/views/errors.d.ts +5 -0
- package/dist/views/flamegraph.d.ts +20 -0
- package/dist/views/graph.d.ts +5 -0
- package/dist/views/inspector.d.ts +9 -0
- package/dist/views/ownership.d.ts +4 -0
- package/dist/views/pages.d.ts +18 -0
- package/dist/views/route.d.ts +5 -0
- package/dist/views/state.d.ts +26 -0
- package/dist/views/timeline-interaction.d.ts +12 -0
- package/dist/views/timeline.d.ts +16 -0
- package/dist/vue-devtools.d.ts +133 -0
- package/dist/ws-bridge.d.ts +21 -0
- package/package.json +43 -0
- package/panel.html +26 -0
- package/style.css +1248 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import type { TraceBus } from '@proteus-vue/devtools-runtime';
|
|
3
|
+
import type { PagesViewData } from './views/pages';
|
|
4
|
+
import type { OwnershipGraph, OwnershipHistory } from '@proteus-vue/render-backend';
|
|
5
|
+
/** style-safety 守卫的结构类型(零硬依赖——@proteus-vue/style-safety 实例直接可传) */
|
|
6
|
+
export interface StyleGuardLike {
|
|
7
|
+
records(): Array<{
|
|
8
|
+
prop: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
reason: string;
|
|
11
|
+
ts: number;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
/** pinia 实例结构类型(createStoreTracer 消费 + onApplyState 状态恢复 + 面板创建补发快照) */
|
|
15
|
+
export interface PiniaLike {
|
|
16
|
+
use(fn: (ctx: {
|
|
17
|
+
store: unknown;
|
|
18
|
+
}) => void): unknown;
|
|
19
|
+
_s: Map<string, {
|
|
20
|
+
$patch(state: Record<string, unknown>): void;
|
|
21
|
+
$state?: Record<string, unknown>;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/** vite import.meta.hot 结构类型(HMR 事件 → TraceBus;零硬依赖,业务侧传 import.meta.hot) */
|
|
25
|
+
export interface HmrLike {
|
|
26
|
+
on(event: string, cb: (...args: unknown[]) => void): (() => void) | void;
|
|
27
|
+
}
|
|
28
|
+
export interface InstallDevtoolsOptions {
|
|
29
|
+
/** pinia 实例(提供 → store 变更追踪:面板 state 视图 + Pinia Inspector 原生) */
|
|
30
|
+
pinia?: PiniaLike;
|
|
31
|
+
/** app-config 读取(App Config Inspector 数据源;缺省空对象) */
|
|
32
|
+
getConfig?: () => Record<string, unknown>;
|
|
33
|
+
/** app-config 更新(编辑回写双向调试) */
|
|
34
|
+
setConfig?: (patch: Record<string, unknown>) => void;
|
|
35
|
+
/** style-safety 守卫(提供 → Style Safety Inspector 拦截记录数据源) */
|
|
36
|
+
styleGuard?: StyleGuardLike;
|
|
37
|
+
/** 本地面板 pages 数据(路由表 + 页面栈 → pages/依赖图面板) */
|
|
38
|
+
pages?: PagesViewData;
|
|
39
|
+
/** 是否挂载本地面板浮动窗口(缺省 true;仅挂载一次——重复调用复用) */
|
|
40
|
+
mount?: boolean;
|
|
41
|
+
/** vite HMR 句柄(传 import.meta.hot):热更新事件 → TraceBus(timeline 显示 vite:update/full-reload/error 记录) */
|
|
42
|
+
hmr?: HmrLike;
|
|
43
|
+
/**
|
|
44
|
+
* 远程查看(移动端/真机场景):TraceBus → WS(devtoolsRelayPlugin 的 /proteus-source 端点)→
|
|
45
|
+
* 电脑浏览器 panel.html?ws= 下行查看。true = 同源自动(ws://location.host/proteus-source);
|
|
46
|
+
* 对象形态可指定 path 与 appInfo(默认取 pages 数据)
|
|
47
|
+
*/
|
|
48
|
+
remote?: boolean | {
|
|
49
|
+
path?: string;
|
|
50
|
+
appInfo?: () => unknown;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* ★G-43 B4 所有权面板(缺省 true——挂全局默认图 getProteusOwnershipGraph + 内部 history):
|
|
54
|
+
* 业务/容器已显式建图时可传 { graph }(或同时传 history 复用既有历史);false 关闭。
|
|
55
|
+
* 数据进面板第十视图(本地面板)+ Proteus.ownership 远程命令(远程面板)。
|
|
56
|
+
*/
|
|
57
|
+
ownership?: boolean | {
|
|
58
|
+
graph?: OwnershipGraph;
|
|
59
|
+
history?: OwnershipHistory;
|
|
60
|
+
};
|
|
61
|
+
/** 显式 traceBus(缺省 getProteusTraceBus 惰性单例) */
|
|
62
|
+
traceBus?: TraceBus;
|
|
63
|
+
}
|
|
64
|
+
export interface InstalledDevtools {
|
|
65
|
+
/** 业务侧发射端注入用(与 getProteusTraceBus 同实例) */
|
|
66
|
+
traceBus: TraceBus;
|
|
67
|
+
/** 卸载:store tracer dispose + 组件树订阅解绑 + 面板移除 */
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 一键接入 Web 端 devtools(开发模式调用;生产 import.meta.env.DEV=false 且无 PROTEUS_DEBUG=1 时 bus 零开销 + 本地面板守卫挂载无事件)
|
|
72
|
+
* 用法(main.ts,interactive 阶段):
|
|
73
|
+
* const devtools = installProteusDevtools(app, { pinia, getConfig, setConfig, styleGuard, pages })
|
|
74
|
+
* // 发射端同源:createRouter(routes, { traceBus: getProteusTraceBus() }) / createApi({ traceBus: getProteusTraceBus() })
|
|
75
|
+
*/
|
|
76
|
+
export declare function installProteusDevtools(app: App, options?: InstallDevtoolsOptions): InstalledDevtools;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { OwnershipGraph, OwnershipHistory, OwnershipRecord, GraphNode } from '@proteus-vue/render-backend';
|
|
2
|
+
export interface OwnershipResourceItem {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly type: string;
|
|
5
|
+
readonly byteSize: number;
|
|
6
|
+
readonly owner: string | null;
|
|
7
|
+
readonly state: GraphNode['state'];
|
|
8
|
+
readonly sourceLocation: string | null;
|
|
9
|
+
/** 活跃借用方(borrows edges from) */
|
|
10
|
+
readonly borrowedBy: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface OwnershipViewData {
|
|
13
|
+
readonly summary: {
|
|
14
|
+
alive: number;
|
|
15
|
+
total: number;
|
|
16
|
+
bytesAlive: number;
|
|
17
|
+
byType: Record<string, {
|
|
18
|
+
allocated: number;
|
|
19
|
+
alive: number;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
readonly diagnosis: {
|
|
23
|
+
orphans: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
type: string;
|
|
26
|
+
byteSize: number;
|
|
27
|
+
sourceLocation: string | null;
|
|
28
|
+
}>;
|
|
29
|
+
leaks: Array<{
|
|
30
|
+
resourceId: string;
|
|
31
|
+
type: string;
|
|
32
|
+
byteSize: number;
|
|
33
|
+
sourceLocation: string | null;
|
|
34
|
+
referenceChain: string[];
|
|
35
|
+
}>;
|
|
36
|
+
longBorrows: Array<{
|
|
37
|
+
resourceId: string;
|
|
38
|
+
borrowedBy: string;
|
|
39
|
+
owner: string | null;
|
|
40
|
+
}>;
|
|
41
|
+
crossPageRefs: Array<{
|
|
42
|
+
resourceId: string;
|
|
43
|
+
owner: string | null;
|
|
44
|
+
heldBy: string;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
/** 按 owner 分组的存活资源(Graph 主视图——🟢 Owner + 📍 源码位置) */
|
|
48
|
+
readonly resources: Array<{
|
|
49
|
+
owner: string;
|
|
50
|
+
items: OwnershipResourceItem[];
|
|
51
|
+
}>;
|
|
52
|
+
/** alloc/drop 时间线(V-06 配对 + 未配对高亮;截断 tail 保留最新) */
|
|
53
|
+
readonly timeline: {
|
|
54
|
+
events: Array<OwnershipRecord & {
|
|
55
|
+
matchedAllocId?: string;
|
|
56
|
+
}>;
|
|
57
|
+
unpairedIds: string[];
|
|
58
|
+
truncated: boolean;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface OwnershipTracer {
|
|
62
|
+
/** 采集视图数据(面板 rerender / WS 响应共用;幂等纯读) */
|
|
63
|
+
collect(): OwnershipViewData;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
}
|
|
66
|
+
export interface OwnershipTracerOptions {
|
|
67
|
+
/** 所有权图(缺省 getProteusOwnershipGraph 全局单例) */
|
|
68
|
+
graph?: OwnershipGraph;
|
|
69
|
+
/** 已有历史(业务在 graph 创建时挂的 createOwnershipHistory——缺省内部自建,从挂载时刻起记录) */
|
|
70
|
+
history?: OwnershipHistory;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* ★G-43 B4:所有权 tracer——history + counters 常驻挂接,collect 一次跑齐视图数据。
|
|
74
|
+
* ★存量快照:history 只记录订阅后事件(面板后开场景)——collect 时对图内未出现过的节点补
|
|
75
|
+
* 'alloc' 快照记录(视为面板接入前已分配),时间线/未配对判定不丢存量。
|
|
76
|
+
*/
|
|
77
|
+
export declare function createOwnershipTracer(options?: OwnershipTracerOptions): OwnershipTracer;
|
package/dist/panel.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DevtoolsSource } from './source';
|
|
2
|
+
import type { PagesViewData } from './views/pages';
|
|
3
|
+
import type { DeviceInfo } from './views/device';
|
|
4
|
+
import type { OwnershipViewData } from './views/ownership';
|
|
5
|
+
import type { StoreRestoreEntry } from './snapshot-io';
|
|
6
|
+
import type { DevToolsPlugin, KVStorage } from './plugins';
|
|
7
|
+
export interface DevtoolsPanelOptions {
|
|
8
|
+
source: DevtoolsSource;
|
|
9
|
+
/** 时间旅行命令下发(缺省 no-op——业务侧适配器接入后生效) */
|
|
10
|
+
onTimeTravel?: (index: number) => void;
|
|
11
|
+
/** ★P1:状态应用(时间旅行回放 / 导入快照恢复共用)——panel 把 restore 快照交给 caller(install → pinia.$patch);缺省仅面板内回放 */
|
|
12
|
+
onApplyState?: (stores: StoreRestoreEntry[]) => void;
|
|
13
|
+
/** ★P1:组件视图选中 → 页面元素高亮(install 侧 scrollIntoView + 描边闪烁) */
|
|
14
|
+
onSelectComponent?: (id: number) => void;
|
|
15
|
+
/** M9 插件:第三方自定义视图/事件订阅/命令(激活拓扑序,循环依赖报错,崩溃隔离) */
|
|
16
|
+
plugins?: DevToolsPlugin[];
|
|
17
|
+
/** 插件持久化存储(缺省内存 KV) */
|
|
18
|
+
storage?: KVStorage;
|
|
19
|
+
/** ★pages/依赖图面板:应用路由表 + 页面栈(缺省取 source.appInfo() 路由表;均无 → 空态) */
|
|
20
|
+
pages?: PagesViewData;
|
|
21
|
+
/** ★M8 设备面板:环境/能力信息钩子(本地面板 install 侧采集;缺省取 source.deviceInfo() 远程命令缓存;均无 → 空态) */
|
|
22
|
+
deviceInfo?: () => DeviceInfo;
|
|
23
|
+
/** ★G-43 B4 所有权面板:视图数据钩子(本地面板 install 侧 tracer 采集;缺省取 source.ownership() 远程命令缓存;均无 → 空态) */
|
|
24
|
+
ownershipData?: () => OwnershipViewData | undefined;
|
|
25
|
+
}
|
|
26
|
+
export interface DevtoolsPanel {
|
|
27
|
+
destroy(): void;
|
|
28
|
+
/** 切换视图('timeline' | 'flamegraph' | 'state' | 'route' | 'errors' | 'components' | 'pages' | 'graph' | 'device' | 'ownership') */
|
|
29
|
+
show(view: string): void;
|
|
30
|
+
/** ★P0:导出 store 快照 JSON(序列化 + Blob 下载,文件名 proteus-store-snapshot.json;返回序列化文本供程序化消费) */
|
|
31
|
+
exportSnapshot(): string;
|
|
32
|
+
/** ★P0:导入 store 快照 JSON(解析校验 → 数据重建 → 视图刷新 → onApplyState 应用回应用) */
|
|
33
|
+
importSnapshot(json: string): void;
|
|
34
|
+
/** ★M11 可观测性(M8.2):导出 SessionBundle(可重放事件日志 + 设备 + store 快照;Blob 下载 proteus-session.json;返回序列化文本) */
|
|
35
|
+
exportSession(): string;
|
|
36
|
+
/** ★M11 可观测性(M8.2):导入 SessionBundle(清空聚合 → 重放事件全视图重建 → onApplyState 应用最新状态) */
|
|
37
|
+
importSession(json: string): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function createDevtoolsPanel(root: HTMLElement, options: DevtoolsPanelOptions): DevtoolsPanel;
|