@vingy/vuebugger 0.1.1 → 0.1.2
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/dist/index.mjs +34 -13
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCurrentInstance, toValue, watch } from "vue";
|
|
1
|
+
import { getCurrentInstance, getCurrentScope, onBeforeUnmount, toValue, watch } from "vue";
|
|
2
2
|
|
|
3
3
|
//#region node_modules/.pnpm/@vue+devtools-shared@8.0.5/node_modules/@vue/devtools-shared/dist/index.js
|
|
4
4
|
var __create$1 = Object.create;
|
|
@@ -3784,10 +3784,10 @@ const MAX_SERIALIZED_SIZE = 2 * 1024 * 1024;
|
|
|
3784
3784
|
const byUid = /* @__PURE__ */ new Map();
|
|
3785
3785
|
const byGroupId = /* @__PURE__ */ new Map();
|
|
3786
3786
|
const callbacks = [];
|
|
3787
|
-
const runCallbacks = (
|
|
3787
|
+
const runCallbacks = (entry) => callbacks.forEach((cb) => cb(entry));
|
|
3788
3788
|
const withCallbacks = (fn) => (entry) => {
|
|
3789
3789
|
fn(entry);
|
|
3790
|
-
runCallbacks(entry
|
|
3790
|
+
runCallbacks(entry);
|
|
3791
3791
|
};
|
|
3792
3792
|
const upsert = withCallbacks((entry) => {
|
|
3793
3793
|
const { uid, groupId } = entry;
|
|
@@ -3795,6 +3795,7 @@ const upsert = withCallbacks((entry) => {
|
|
|
3795
3795
|
const group = byGroupId.get(groupId);
|
|
3796
3796
|
if (!group) byGroupId.set(groupId, new Set([uid]));
|
|
3797
3797
|
else group.add(uid);
|
|
3798
|
+
console.log("upsert");
|
|
3798
3799
|
});
|
|
3799
3800
|
const remove = withCallbacks((entry) => {
|
|
3800
3801
|
const { uid, groupId } = entry;
|
|
@@ -3802,6 +3803,7 @@ const remove = withCallbacks((entry) => {
|
|
|
3802
3803
|
const group = byGroupId.get(groupId);
|
|
3803
3804
|
group?.delete(uid);
|
|
3804
3805
|
if (group?.size === 0) byGroupId.delete(groupId);
|
|
3806
|
+
console.log("remove");
|
|
3805
3807
|
});
|
|
3806
3808
|
const onUpdate = (fn) => {
|
|
3807
3809
|
callbacks.push(fn);
|
|
@@ -3809,7 +3811,8 @@ const onUpdate = (fn) => {
|
|
|
3809
3811
|
|
|
3810
3812
|
//#endregion
|
|
3811
3813
|
//#region src/devtools.ts
|
|
3812
|
-
const INSPECTOR_ID = "
|
|
3814
|
+
const INSPECTOR_ID = "vuebugger-inspector";
|
|
3815
|
+
const TIMELINE_ID = "vuebugger-timeline";
|
|
3813
3816
|
const handleGetInspectorTree = (payload) => {
|
|
3814
3817
|
if (payload.inspectorId === INSPECTOR_ID) {
|
|
3815
3818
|
const term = payload.filter;
|
|
@@ -3874,10 +3877,25 @@ function setupComposableDevtools(app) {
|
|
|
3874
3877
|
icon: "https://raw.githubusercontent.com/vinpogo/vuebugger/main/logo.png",
|
|
3875
3878
|
treeFilterPlaceholder: "Search by composable or component name..."
|
|
3876
3879
|
});
|
|
3877
|
-
|
|
3880
|
+
api.addTimelineLayer({
|
|
3881
|
+
id: TIMELINE_ID,
|
|
3882
|
+
label: "Vuebugger",
|
|
3883
|
+
color: 155
|
|
3884
|
+
});
|
|
3885
|
+
onUpdate((entry) => {
|
|
3878
3886
|
api.sendInspectorTree(INSPECTOR_ID);
|
|
3879
3887
|
api.sendInspectorState(INSPECTOR_ID);
|
|
3880
|
-
api.notifyComponentUpdate(componentInstance);
|
|
3888
|
+
api.notifyComponentUpdate(entry.componentInstance);
|
|
3889
|
+
api.addTimelineEvent({
|
|
3890
|
+
layerId: TIMELINE_ID,
|
|
3891
|
+
event: {
|
|
3892
|
+
time: api.now(),
|
|
3893
|
+
data: entry,
|
|
3894
|
+
title: `${entry.uid} state change`,
|
|
3895
|
+
groupId: entry.uid,
|
|
3896
|
+
meta: { vin: "was here" }
|
|
3897
|
+
}
|
|
3898
|
+
});
|
|
3881
3899
|
});
|
|
3882
3900
|
api.on.getInspectorTree(handleGetInspectorTree);
|
|
3883
3901
|
api.on.getInspectorState(handleGetInspectorState(api));
|
|
@@ -3892,24 +3910,27 @@ function debug(groupId, state) {
|
|
|
3892
3910
|
const instance = getCurrentInstance();
|
|
3893
3911
|
const componentName = instance?.type.name || instance?.type.__name || "No component";
|
|
3894
3912
|
const uid = `${componentName}/${groupId}-${Math.random().toString(36).slice(2, 9)}`;
|
|
3895
|
-
|
|
3896
|
-
|
|
3913
|
+
getCurrentScope()?.run(() => {
|
|
3914
|
+
onBeforeUnmount(() => remove({
|
|
3897
3915
|
groupId,
|
|
3898
3916
|
uid,
|
|
3899
3917
|
componentName,
|
|
3900
3918
|
componentInstance: instance,
|
|
3901
|
-
debugState:
|
|
3902
|
-
});
|
|
3903
|
-
|
|
3904
|
-
|
|
3919
|
+
debugState: state
|
|
3920
|
+
}));
|
|
3921
|
+
watch(() => state, (value, _) => {
|
|
3922
|
+
upsert({
|
|
3905
3923
|
groupId,
|
|
3906
3924
|
uid,
|
|
3907
3925
|
componentName,
|
|
3908
3926
|
componentInstance: instance,
|
|
3909
3927
|
debugState: value
|
|
3910
3928
|
});
|
|
3929
|
+
}, {
|
|
3930
|
+
immediate: true,
|
|
3931
|
+
deep: true
|
|
3911
3932
|
});
|
|
3912
|
-
}
|
|
3933
|
+
});
|
|
3913
3934
|
return state;
|
|
3914
3935
|
}
|
|
3915
3936
|
|