@vingy/vuebugger 0.1.2 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.mjs +24 -15
  2. package/package.json +3 -1
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getCurrentInstance, getCurrentScope, onBeforeUnmount, toValue, watch } from "vue";
1
+ import { effectScope, getCurrentInstance, getCurrentScope, isReadonly, onScopeDispose, 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;
@@ -837,14 +837,14 @@ let ReactiveFlags = /* @__PURE__ */ function(ReactiveFlags$1) {
837
837
  /**
838
838
  * @from [@vue/reactivity](https://github.com/vuejs/core/blob/1c3327a0fa5983aa9078e3f7bb2330f572435425/packages/reactivity/src/reactive.ts#L330-L332)
839
839
  */
840
- function isReadonly(value) {
840
+ function isReadonly$1(value) {
841
841
  return !!(value && value[ReactiveFlags.IS_READONLY]);
842
842
  }
843
843
  /**
844
844
  * @from [@vue/reactivity](https://github.com/vuejs/core/blob/1c3327a0fa5983aa9078e3f7bb2330f572435425/packages/reactivity/src/reactive.ts#L312-L317)
845
845
  */
846
846
  function isReactive$1(value) {
847
- if (isReadonly(value)) return isReactive$1(value[ReactiveFlags.RAW]);
847
+ if (isReadonly$1(value)) return isReactive$1(value[ReactiveFlags.RAW]);
848
848
  return !!(value && value[ReactiveFlags.IS_REACTIVE]);
849
849
  }
850
850
  function isRef$1(r) {
@@ -3779,6 +3779,11 @@ target.__VUE_DEVTOOLS_KIT_VITE_RPC_SERVER__ ??= null;
3779
3779
  target.__VUE_DEVTOOLS_KIT_BROADCAST_RPC_SERVER__ ??= null;
3780
3780
  const MAX_SERIALIZED_SIZE = 2 * 1024 * 1024;
3781
3781
 
3782
+ //#endregion
3783
+ //#region src/constants.ts
3784
+ const INSPECTOR_ID = "vuebugger-inspector";
3785
+ const TIMELINE_ID = "vuebugger-timeline";
3786
+
3782
3787
  //#endregion
3783
3788
  //#region src/registry.ts
3784
3789
  const byUid = /* @__PURE__ */ new Map();
@@ -3795,7 +3800,6 @@ const upsert = withCallbacks((entry) => {
3795
3800
  const group = byGroupId.get(groupId);
3796
3801
  if (!group) byGroupId.set(groupId, new Set([uid]));
3797
3802
  else group.add(uid);
3798
- console.log("upsert");
3799
3803
  });
3800
3804
  const remove = withCallbacks((entry) => {
3801
3805
  const { uid, groupId } = entry;
@@ -3803,7 +3807,6 @@ const remove = withCallbacks((entry) => {
3803
3807
  const group = byGroupId.get(groupId);
3804
3808
  group?.delete(uid);
3805
3809
  if (group?.size === 0) byGroupId.delete(groupId);
3806
- console.log("remove");
3807
3810
  });
3808
3811
  const onUpdate = (fn) => {
3809
3812
  callbacks.push(fn);
@@ -3811,8 +3814,6 @@ const onUpdate = (fn) => {
3811
3814
 
3812
3815
  //#endregion
3813
3816
  //#region src/devtools.ts
3814
- const INSPECTOR_ID = "vuebugger-inspector";
3815
- const TIMELINE_ID = "vuebugger-timeline";
3816
3817
  const handleGetInspectorTree = (payload) => {
3817
3818
  if (payload.inspectorId === INSPECTOR_ID) {
3818
3819
  const term = payload.filter;
@@ -3845,8 +3846,8 @@ const handleGetInspectorState = (api) => (payload) => {
3845
3846
  if (entry) {
3846
3847
  payload.state = { [payload.nodeId]: Object.entries(entry.debugState).map(([key, value]) => ({
3847
3848
  key,
3848
- value: toValue(value),
3849
- editable: true
3849
+ value,
3850
+ editable: !isReadonly(value)
3850
3851
  })) };
3851
3852
  if (entry.componentInstance) api.highlightElement(entry.componentInstance);
3852
3853
  }
@@ -3857,12 +3858,20 @@ const handleInspectComponent = (payload) => {
3857
3858
  return Object.entries(entry.debugState).map(([key, value]) => ({
3858
3859
  type: entry.uid,
3859
3860
  key,
3860
- value: toValue(value),
3861
- editable: true
3861
+ value,
3862
+ editable: !isReadonly(value)
3862
3863
  }));
3863
3864
  }).toArray();
3864
3865
  payload.instanceData.state.push(...entries);
3865
3866
  };
3867
+ const handleEditInspectorState = (payload) => {
3868
+ if (payload.inspectorId === INSPECTOR_ID) {
3869
+ const uid = payload.nodeId;
3870
+ const entry = byUid.get(uid);
3871
+ if (!entry) return;
3872
+ payload.set(entry.debugState);
3873
+ }
3874
+ };
3866
3875
  function setupComposableDevtools(app) {
3867
3876
  console.log("🐞 Vuebugger ready to use");
3868
3877
  setupDevToolsPlugin({
@@ -3892,14 +3901,14 @@ function setupComposableDevtools(app) {
3892
3901
  time: api.now(),
3893
3902
  data: entry,
3894
3903
  title: `${entry.uid} state change`,
3895
- groupId: entry.uid,
3896
- meta: { vin: "was here" }
3904
+ groupId: entry.uid
3897
3905
  }
3898
3906
  });
3899
3907
  });
3900
3908
  api.on.getInspectorTree(handleGetInspectorTree);
3901
3909
  api.on.getInspectorState(handleGetInspectorState(api));
3902
3910
  api.on.inspectComponent(handleInspectComponent);
3911
+ api.on.editInspectorState(handleEditInspectorState);
3903
3912
  });
3904
3913
  }
3905
3914
 
@@ -3910,8 +3919,8 @@ function debug(groupId, state) {
3910
3919
  const instance = getCurrentInstance();
3911
3920
  const componentName = instance?.type.name || instance?.type.__name || "No component";
3912
3921
  const uid = `${componentName}/${groupId}-${Math.random().toString(36).slice(2, 9)}`;
3913
- getCurrentScope()?.run(() => {
3914
- onBeforeUnmount(() => remove({
3922
+ (getCurrentScope() ?? effectScope()).run(() => {
3923
+ onScopeDispose(() => remove({
3915
3924
  groupId,
3916
3925
  uid,
3917
3926
  componentName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vingy/vuebugger",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Vue devtools plugin to debug anything.",
5
5
  "keywords": [
6
6
  "composable",
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^25.0.10",
38
+ "@vitest/coverage-v8": "4.0.18",
38
39
  "@vue/devtools-api": "^8.0.5",
39
40
  "oxfmt": "^0.27.0",
40
41
  "oxlint": "^1.42.0",
@@ -47,6 +48,7 @@
47
48
  },
48
49
  "scripts": {
49
50
  "test": "vitest",
51
+ "test:ci": "vitest run --coverage",
50
52
  "build": "tsdown",
51
53
  "dev": "tsdown -w"
52
54
  }