@buoy-gg/redux 3.0.2 → 4.0.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.
@@ -5,6 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.reduxSyncAdapter = void 0;
7
7
  var _reduxActionStore = require("../utils/reduxActionStore");
8
+ var _autoInstrument = require("../utils/autoInstrument");
9
+ /** Top-level slice names of the state tree, for the compact (no-values) view. */
10
+ function topLevelKeys(state) {
11
+ return state && typeof state === "object" && !Array.isArray(state) ? Object.keys(state) : [];
12
+ }
13
+
8
14
  /**
9
15
  * Sync adapter for the redux tool, consumed by @buoy-gg/external-sync's
10
16
  * `useExternalSync` (structurally matches its ToolSyncAdapter interface so
@@ -13,6 +19,11 @@ var _reduxActionStore = require("../utils/reduxActionStore");
13
19
  * Actions are captured by the auto-instrumentation middleware (installed when
14
20
  * FloatingDevTools mounts), independent of whether a dashboard is watching —
15
21
  * subscribing here only streams what the store already records.
22
+ *
23
+ * `getState`/`dispatch` read & drive the live instrumented store (via
24
+ * getActiveStore()) so a remote driver (MCP/LLM) can inspect current state and
25
+ * dispatch actions — redux is action-based, so the *current state* isn't in the
26
+ * action-log snapshot.
16
27
  */
17
28
  const reduxSyncAdapter = exports.reduxSyncAdapter = {
18
29
  version: 1,
@@ -21,6 +32,47 @@ const reduxSyncAdapter = exports.reduxSyncAdapter = {
21
32
  actions: {
22
33
  clearEvents: () => {
23
34
  _reduxActionStore.reduxActionStore.clearActions();
35
+ },
36
+ /**
37
+ * Compact current-state reader: the instrumented store's slice names, and
38
+ * the full state tree only when `includeValues` is set (heavy).
39
+ */
40
+ getState: params => {
41
+ const {
42
+ includeValues = false
43
+ } = params ?? {};
44
+ const store = (0, _autoInstrument.getActiveStore)();
45
+ if (!store) {
46
+ return {
47
+ available: false,
48
+ slices: []
49
+ };
50
+ }
51
+ const state = store.getState();
52
+ return {
53
+ available: true,
54
+ slices: topLevelKeys(state),
55
+ ...(includeValues ? {
56
+ state
57
+ } : {})
58
+ };
59
+ },
60
+ /** Dispatch a plain action object to the instrumented store. */
61
+ dispatch: params => {
62
+ const {
63
+ action
64
+ } = params;
65
+ const store = (0, _autoInstrument.getActiveStore)();
66
+ if (!store) {
67
+ return {
68
+ dispatched: false
69
+ };
70
+ }
71
+ store.dispatch(action);
72
+ return {
73
+ dispatched: true,
74
+ type: action?.type
75
+ };
24
76
  }
25
77
  }
26
78
  };
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  import { reduxActionStore } from "../utils/reduxActionStore";
4
+ import { getActiveStore } from "../utils/autoInstrument";
5
+ /** Top-level slice names of the state tree, for the compact (no-values) view. */
6
+ function topLevelKeys(state) {
7
+ return state && typeof state === "object" && !Array.isArray(state) ? Object.keys(state) : [];
8
+ }
4
9
 
5
10
  /**
6
11
  * Sync adapter for the redux tool, consumed by @buoy-gg/external-sync's
@@ -10,6 +15,11 @@ import { reduxActionStore } from "../utils/reduxActionStore";
10
15
  * Actions are captured by the auto-instrumentation middleware (installed when
11
16
  * FloatingDevTools mounts), independent of whether a dashboard is watching —
12
17
  * subscribing here only streams what the store already records.
18
+ *
19
+ * `getState`/`dispatch` read & drive the live instrumented store (via
20
+ * getActiveStore()) so a remote driver (MCP/LLM) can inspect current state and
21
+ * dispatch actions — redux is action-based, so the *current state* isn't in the
22
+ * action-log snapshot.
13
23
  */
14
24
  export const reduxSyncAdapter = {
15
25
  version: 1,
@@ -18,6 +28,47 @@ export const reduxSyncAdapter = {
18
28
  actions: {
19
29
  clearEvents: () => {
20
30
  reduxActionStore.clearActions();
31
+ },
32
+ /**
33
+ * Compact current-state reader: the instrumented store's slice names, and
34
+ * the full state tree only when `includeValues` is set (heavy).
35
+ */
36
+ getState: params => {
37
+ const {
38
+ includeValues = false
39
+ } = params ?? {};
40
+ const store = getActiveStore();
41
+ if (!store) {
42
+ return {
43
+ available: false,
44
+ slices: []
45
+ };
46
+ }
47
+ const state = store.getState();
48
+ return {
49
+ available: true,
50
+ slices: topLevelKeys(state),
51
+ ...(includeValues ? {
52
+ state
53
+ } : {})
54
+ };
55
+ },
56
+ /** Dispatch a plain action object to the instrumented store. */
57
+ dispatch: params => {
58
+ const {
59
+ action
60
+ } = params;
61
+ const store = getActiveStore();
62
+ if (!store) {
63
+ return {
64
+ dispatched: false
65
+ };
66
+ }
67
+ store.dispatch(action);
68
+ return {
69
+ dispatched: true,
70
+ type: action?.type
71
+ };
21
72
  }
22
73
  }
23
74
  };
@@ -6,6 +6,11 @@
6
6
  * Actions are captured by the auto-instrumentation middleware (installed when
7
7
  * FloatingDevTools mounts), independent of whether a dashboard is watching —
8
8
  * subscribing here only streams what the store already records.
9
+ *
10
+ * `getState`/`dispatch` read & drive the live instrumented store (via
11
+ * getActiveStore()) so a remote driver (MCP/LLM) can inspect current state and
12
+ * dispatch actions — redux is action-based, so the *current state* isn't in the
13
+ * action-log snapshot.
9
14
  */
10
15
  export declare const reduxSyncAdapter: {
11
16
  version: number;
@@ -13,6 +18,23 @@ export declare const reduxSyncAdapter: {
13
18
  subscribe: (onChange: () => void) => () => void;
14
19
  actions: {
15
20
  clearEvents: () => void;
21
+ /**
22
+ * Compact current-state reader: the instrumented store's slice names, and
23
+ * the full state tree only when `includeValues` is set (heavy).
24
+ */
25
+ getState: (params: unknown) => {
26
+ state?: any;
27
+ available: boolean;
28
+ slices: string[];
29
+ };
30
+ /** Dispatch a plain action object to the instrumented store. */
31
+ dispatch: (params: unknown) => {
32
+ dispatched: boolean;
33
+ type?: undefined;
34
+ } | {
35
+ dispatched: boolean;
36
+ type: string;
37
+ };
16
38
  };
17
39
  };
18
40
  //# sourceMappingURL=reduxSyncAdapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reduxSyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/redux/sync/reduxSyncAdapter.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB;;;0BAGL,MAAM,IAAI;;;;CAMjC,CAAC"}
1
+ {"version":3,"file":"reduxSyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/redux/sync/reduxSyncAdapter.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB;;;0BAGL,MAAM,IAAI;;;QAK9B;;;WAGG;2BACgB,OAAO;;;;;QAc1B,gEAAgE;2BAC7C,OAAO;;;;;;;;CAU7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/redux",
3
- "version": "3.0.2",
3
+ "version": "4.0.2",
4
4
  "description": "Redux Toolkit DevTools for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -26,9 +26,9 @@
26
26
  ],
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
- "@buoy-gg/shared-ui": "3.0.2",
30
- "@buoy-gg/license": "3.0.2",
31
- "@buoy-gg/floating-tools-core": "3.0.2"
29
+ "@buoy-gg/shared-ui": "4.0.2",
30
+ "@buoy-gg/floating-tools-core": "4.0.2",
31
+ "@buoy-gg/license": "4.0.2"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@reduxjs/toolkit": ">=2.0.0",