@buoy-gg/redux 7.0.41 → 7.0.42

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 (78) hide show
  1. package/README.md +11 -106
  2. package/lib/commonjs/index.js +1 -256
  3. package/lib/commonjs/preset.js +1 -90
  4. package/lib/commonjs/redux/components/ReduxActionButton.js +1 -131
  5. package/lib/commonjs/redux/components/ReduxActionDetailContent.js +1 -437
  6. package/lib/commonjs/redux/components/ReduxActionDetailView.js +1 -401
  7. package/lib/commonjs/redux/components/ReduxActionInfoView.js +1 -836
  8. package/lib/commonjs/redux/components/ReduxActionItem.js +1 -337
  9. package/lib/commonjs/redux/components/ReduxAutoInstrument.js +1 -20
  10. package/lib/commonjs/redux/components/ReduxDetailViewToggle.js +1 -50
  11. package/lib/commonjs/redux/components/ReduxIcon.js +1 -18
  12. package/lib/commonjs/redux/components/ReduxModal.js +1 -703
  13. package/lib/commonjs/redux/hooks/reduxPeer.js +1 -17
  14. package/lib/commonjs/redux/hooks/reduxPeer.web.js +1 -10
  15. package/lib/commonjs/redux/hooks/useAutoInstrumentRedux.js +1 -177
  16. package/lib/commonjs/redux/hooks/useReduxActions.js +1 -58
  17. package/lib/commonjs/redux/sync/reduxSyncAdapter.js +1 -191
  18. package/lib/commonjs/redux/types/index.js +1 -1
  19. package/lib/commonjs/redux/utils/activeStoreRegistry.js +1 -104
  20. package/lib/commonjs/redux/utils/autoInstrument.js +1 -231
  21. package/lib/commonjs/redux/utils/buoyReduxMiddleware.js +1 -202
  22. package/lib/commonjs/redux/utils/createReduxHistoryAdapter.js +1 -146
  23. package/lib/commonjs/redux/utils/devtoolsHook.js +1 -152
  24. package/lib/commonjs/redux/utils/reduxActionStore.js +1 -473
  25. package/lib/commonjs/redux/utils/snapshotProvider.js +1 -158
  26. package/lib/commonjs/redux/utils/testIDs.js +1 -75
  27. package/lib/module/index.js +1 -125
  28. package/lib/module/preset.js +1 -87
  29. package/lib/module/redux/components/ReduxActionButton.js +1 -128
  30. package/lib/module/redux/components/ReduxActionDetailContent.js +1 -433
  31. package/lib/module/redux/components/ReduxActionDetailView.js +1 -397
  32. package/lib/module/redux/components/ReduxActionInfoView.js +1 -831
  33. package/lib/module/redux/components/ReduxActionItem.js +1 -333
  34. package/lib/module/redux/components/ReduxAutoInstrument.js +1 -17
  35. package/lib/module/redux/components/ReduxDetailViewToggle.js +1 -45
  36. package/lib/module/redux/components/ReduxIcon.js +1 -8
  37. package/lib/module/redux/components/ReduxModal.js +1 -698
  38. package/lib/module/redux/hooks/reduxPeer.js +1 -13
  39. package/lib/module/redux/hooks/reduxPeer.web.js +1 -6
  40. package/lib/module/redux/hooks/useAutoInstrumentRedux.js +1 -173
  41. package/lib/module/redux/hooks/useReduxActions.js +1 -54
  42. package/lib/module/redux/sync/reduxSyncAdapter.js +1 -188
  43. package/lib/module/redux/types/index.js +1 -1
  44. package/lib/module/redux/utils/activeStoreRegistry.js +1 -92
  45. package/lib/module/redux/utils/autoInstrument.js +1 -201
  46. package/lib/module/redux/utils/buoyReduxMiddleware.js +1 -188
  47. package/lib/module/redux/utils/createReduxHistoryAdapter.js +1 -142
  48. package/lib/module/redux/utils/devtoolsHook.js +1 -145
  49. package/lib/module/redux/utils/reduxActionStore.js +1 -465
  50. package/lib/module/redux/utils/snapshotProvider.js +1 -157
  51. package/lib/module/redux/utils/testIDs.js +1 -68
  52. package/lib/web/index.mjs +1 -2
  53. package/package.json +4 -4
  54. package/lib/typescript/index.d.ts.map +0 -1
  55. package/lib/typescript/preset.d.ts.map +0 -1
  56. package/lib/typescript/redux/components/ReduxActionButton.d.ts.map +0 -1
  57. package/lib/typescript/redux/components/ReduxActionDetailContent.d.ts.map +0 -1
  58. package/lib/typescript/redux/components/ReduxActionDetailView.d.ts.map +0 -1
  59. package/lib/typescript/redux/components/ReduxActionInfoView.d.ts.map +0 -1
  60. package/lib/typescript/redux/components/ReduxActionItem.d.ts.map +0 -1
  61. package/lib/typescript/redux/components/ReduxAutoInstrument.d.ts.map +0 -1
  62. package/lib/typescript/redux/components/ReduxDetailViewToggle.d.ts.map +0 -1
  63. package/lib/typescript/redux/components/ReduxIcon.d.ts.map +0 -1
  64. package/lib/typescript/redux/components/ReduxModal.d.ts.map +0 -1
  65. package/lib/typescript/redux/hooks/reduxPeer.d.ts.map +0 -1
  66. package/lib/typescript/redux/hooks/reduxPeer.web.d.ts.map +0 -1
  67. package/lib/typescript/redux/hooks/useAutoInstrumentRedux.d.ts.map +0 -1
  68. package/lib/typescript/redux/hooks/useReduxActions.d.ts.map +0 -1
  69. package/lib/typescript/redux/sync/reduxSyncAdapter.d.ts.map +0 -1
  70. package/lib/typescript/redux/types/index.d.ts.map +0 -1
  71. package/lib/typescript/redux/utils/activeStoreRegistry.d.ts.map +0 -1
  72. package/lib/typescript/redux/utils/autoInstrument.d.ts.map +0 -1
  73. package/lib/typescript/redux/utils/buoyReduxMiddleware.d.ts.map +0 -1
  74. package/lib/typescript/redux/utils/createReduxHistoryAdapter.d.ts.map +0 -1
  75. package/lib/typescript/redux/utils/devtoolsHook.d.ts.map +0 -1
  76. package/lib/typescript/redux/utils/reduxActionStore.d.ts.map +0 -1
  77. package/lib/typescript/redux/utils/snapshotProvider.d.ts.map +0 -1
  78. package/lib/typescript/redux/utils/testIDs.d.ts.map +0 -1
@@ -1,17 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getReactReduxUseStore = getReactReduxUseStore;
7
- function getReactReduxUseStore() {
8
- try {
9
- // Dynamic require to handle cases where react-redux isn't installed
10
- // eslint-disable-next-line @typescript-eslint/no-var-requires
11
- const reactRedux = require("react-redux");
12
- return reactRedux.useStore;
13
- } catch {
14
- // react-redux not available
15
- return null;
16
- }
17
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getReactReduxUseStore=getReactReduxUseStore;function getReactReduxUseStore(){try{const e=require("react-redux");return e.useStore}catch{return null}}
@@ -1,10 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getReactReduxUseStore = getReactReduxUseStore;
7
- var _reactRedux = require("react-redux");
8
- function getReactReduxUseStore() {
9
- return _reactRedux.useStore;
10
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getReactReduxUseStore=getReactReduxUseStore;var _reactRedux=require("react-redux");function getReactReduxUseStore(){return _reactRedux.useStore}
@@ -1,177 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useAutoInstrumentRedux = useAutoInstrumentRedux;
7
- exports.useReduxAvailability = useReduxAvailability;
8
- var _reduxPeer = require("./reduxPeer");
9
- var _react = require("react");
10
- var _autoInstrument = require("../utils/autoInstrument");
11
- var _activeStoreRegistry = require("../utils/activeStoreRegistry");
12
- /**
13
- * React hook for auto-instrumenting Redux stores
14
- *
15
- * Mounted for the app's lifetime by FloatingDevTools (via ReduxAutoInstrument)
16
- * and also called by the Redux modal. Binds Buoy to the store from react-redux
17
- * context:
18
- * - If the store was created through the devtools-hook enhancer, capture is
19
- * already live — this just keeps the registry pointed at it.
20
- * - Otherwise it applies the dispatch-patch fallback (top-level-only capture).
21
- * - If react-redux is missing or there's no Provider above, it fails
22
- * gracefully and records WHY (surfaced by the sync adapter / MCP).
23
- *
24
- * Re-instruments when the store INSTANCE changes (hosts that rebuild their
25
- * store at runtime), so the registry never pins a dead store.
26
- */
27
-
28
- // ============================================
29
- // Safe Module Loading
30
- // ============================================
31
-
32
- /**
33
- * Safely attempt to load react-redux and get useStore hook
34
- */
35
-
36
- // ============================================
37
- // Hook Types
38
- // ============================================
39
-
40
- // ============================================
41
- // Main Hook
42
- // ============================================
43
-
44
- function useAutoInstrumentRedux(options = {}) {
45
- const {
46
- autoStart = true
47
- } = options;
48
-
49
- // Options live in a ref: this hook is app-lifetime-mounted, and a fresh
50
- // `{...rest}` object every render would churn startInstrumentation's
51
- // identity and re-run the effect on every render.
52
- const optionsRef = (0, _react.useRef)(options);
53
- optionsRef.current = options;
54
- const [isInstrumented, setIsInstrumented] = (0, _react.useState)(false);
55
- const [isLoading, setIsLoading] = (0, _react.useState)(true);
56
- const [error, setError] = (0, _react.useState)(null);
57
- const [store, setStore] = (0, _react.useState)(null);
58
- const cleanupRef = (0, _react.useRef)(null);
59
-
60
- // Check if react-redux is available
61
- const useStoreHook = (0, _reduxPeer.getReactReduxUseStore)();
62
- const isReactReduxAvailable = useStoreHook !== null;
63
-
64
- // Try to get the store using react-redux's useStore
65
- // This must be called unconditionally due to hooks rules
66
- let reduxStore = null;
67
- let storeError = null;
68
- let storeDiagnostic = null;
69
- if (useStoreHook) {
70
- try {
71
- // eslint-disable-next-line react-hooks/rules-of-hooks
72
- reduxStore = useStoreHook();
73
- } catch (e) {
74
- // Not inside a Provider or other error
75
- storeDiagnostic = "no-provider";
76
- storeError = e instanceof Error ? e.message : "Failed to access Redux store. Make sure your app is wrapped in a Redux Provider.";
77
- }
78
- } else {
79
- storeDiagnostic = "no-react-redux";
80
- storeError = "react-redux is not installed or not available";
81
- }
82
-
83
- // Function to start instrumentation
84
- const startInstrumentation = (0, _react.useCallback)(() => {
85
- if (!reduxStore) {
86
- // Record the failure reason for non-React surfaces (sync adapter/MCP).
87
- (0, _activeStoreRegistry.setReduxDiagnostic)(storeDiagnostic);
88
- setError(storeError || "No Redux store available");
89
- setIsLoading(false);
90
- return;
91
- }
92
- try {
93
- // Instrument the store. Idempotent per store: enhancer-created and
94
- // already-patched stores just get (re)registered, so a store SWAP at
95
- // runtime re-binds the registry to the new instance.
96
- const cleanup = (0, _autoInstrument.instrumentStore)(reduxStore, optionsRef.current);
97
- cleanupRef.current = cleanup;
98
- setIsInstrumented(true);
99
- setStore(reduxStore);
100
- setError(null);
101
- } catch (e) {
102
- setError(e instanceof Error ? e.message : "Failed to instrument Redux store");
103
- setIsInstrumented(false);
104
- } finally {
105
- setIsLoading(false);
106
- }
107
- // eslint-disable-next-line react-hooks/exhaustive-deps -- storeError/storeDiagnostic derive from reduxStore
108
- }, [reduxStore]);
109
-
110
- // Function to stop instrumentation
111
- const stopInstrumentation = (0, _react.useCallback)(() => {
112
- if (cleanupRef.current) {
113
- cleanupRef.current();
114
- cleanupRef.current = null;
115
- }
116
- if (store) {
117
- (0, _autoInstrument.uninstrumentStore)(store);
118
- }
119
- setIsInstrumented(false);
120
- setStore(null);
121
- }, [store]);
122
-
123
- // Auto-start instrumentation on mount, and again whenever the store
124
- // INSTANCE changes (hosts that rebuild their store re-point the registry).
125
- (0, _react.useEffect)(() => {
126
- if (autoStart) {
127
- startInstrumentation();
128
- } else {
129
- setIsLoading(false);
130
- }
131
-
132
- // Cleanup on unmount
133
- return () => {
134
- // Note: We intentionally DON'T uninstrument on unmount
135
- // This allows actions to continue being captured even when
136
- // the DevTools modal is closed. The instrumentation persists
137
- // for the lifetime of the app, similar to network/storage tools.
138
- };
139
- }, [autoStart, startInstrumentation]);
140
- return {
141
- isInstrumented,
142
- isLoading,
143
- error,
144
- isReactReduxAvailable,
145
- captureMechanism: (0, _autoInstrument.getInstrumentationStatus)().mechanism,
146
- startInstrumentation,
147
- stopInstrumentation,
148
- store
149
- };
150
- }
151
-
152
- /**
153
- * Lightweight hook to just check if Redux is available
154
- * without auto-instrumenting
155
- */
156
- function useReduxAvailability() {
157
- const useStoreHook = (0, _reduxPeer.getReactReduxUseStore)();
158
- if (!useStoreHook) {
159
- return {
160
- isAvailable: false,
161
- error: "react-redux is not installed"
162
- };
163
- }
164
- try {
165
- // eslint-disable-next-line react-hooks/rules-of-hooks
166
- const store = useStoreHook();
167
- return {
168
- isAvailable: store !== null && store !== undefined,
169
- error: null
170
- };
171
- } catch (e) {
172
- return {
173
- isAvailable: false,
174
- error: e instanceof Error ? e.message : "Not inside a Redux Provider"
175
- };
176
- }
177
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useAutoInstrumentRedux=useAutoInstrumentRedux;exports.useReduxAvailability=useReduxAvailability;var _reduxPeer=require("./reduxPeer");var _react=require("react");var _autoInstrument=require("../utils/autoInstrument");var _activeStoreRegistry=require("../utils/activeStoreRegistry");function useAutoInstrumentRedux(r={}){const{autoStart:e=true}=r;const x=(0,_react.useRef)(r);x.current=r;const[m,a]=(0,_react.useState)(false);const[v,o]=(0,_react.useState)(true);const[S,l]=(0,_react.useState)(null);const[u,R]=(0,_react.useState)(null);const n=(0,_react.useRef)(null);const i=(0,_reduxPeer.getReactReduxUseStore)();const g=i!==null;let s=null;let c=null;let d=null;if(i){try{s=i()}catch(t){d="no-provider";c=t instanceof Error?t.message:"Failed to access Redux store. Make sure your app is wrapped in a Redux Provider."}}else{d="no-react-redux";c="react-redux is not installed or not available"}const f=(0,_react.useCallback)(()=>{if(!s){(0,_activeStoreRegistry.setReduxDiagnostic)(d);l(c||"No Redux store available");o(false);return}try{const t=(0,_autoInstrument.instrumentStore)(s,x.current);n.current=t;a(true);R(s);l(null)}catch(t){l(t instanceof Error?t.message:"Failed to instrument Redux store");a(false)}finally{o(false)}},[s]);const p=(0,_react.useCallback)(()=>{if(n.current){n.current();n.current=null}if(u){(0,_autoInstrument.uninstrumentStore)(u)}a(false);R(null)},[u]);(0,_react.useEffect)(()=>{if(e){f()}else{o(false)}return()=>{}},[e,f]);return{isInstrumented:m,isLoading:v,error:S,isReactReduxAvailable:g,captureMechanism:(0,_autoInstrument.getInstrumentationStatus)().mechanism,startInstrumentation:f,stopInstrumentation:p,store:u}}function useReduxAvailability(){const r=(0,_reduxPeer.getReactReduxUseStore)();if(!r){return{isAvailable:false,error:"react-redux is not installed"}}try{const e=r();return{isAvailable:e!==null&&e!==void 0,error:null}}catch(e){return{isAvailable:false,error:e instanceof Error?e.message:"Not inside a Redux Provider"}}}
@@ -1,58 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useReduxActions = useReduxActions;
7
- var _react = require("react");
8
- var _sharedUi = require("@buoy-gg/shared-ui");
9
- var _reduxActionStore = require("../utils/reduxActionStore");
10
- /**
11
- * Hook for consuming Redux actions from the store
12
- *
13
- * The subscribe / filter / pause / clear plumbing is shared `useChangeLog`;
14
- * this file owns the redux-specific stats, action types and selection.
15
- */
16
-
17
- const filterActions = (_actions, filter) => _reduxActionStore.reduxActionStore.filterActions(filter);
18
- function useReduxActions() {
19
- const log = (0, _sharedUi.useChangeLog)(_reduxActionStore.reduxActionStore, {
20
- filterItems: filterActions
21
- });
22
- const [selectedAction, setSelectedAction] = (0, _react.useState)(null);
23
-
24
- // Get stats
25
- const stats = (0, _react.useMemo)(() => {
26
- return _reduxActionStore.reduxActionStore.getStats();
27
- }, [log.items]);
28
-
29
- // Get unique action types
30
- const actionTypes = (0, _react.useMemo)(() => {
31
- return _reduxActionStore.reduxActionStore.getUniqueActionTypes();
32
- }, [log.items]);
33
-
34
- // Clear actions
35
- const clearActions = (0, _react.useCallback)(() => {
36
- _reduxActionStore.reduxActionStore.clearActions();
37
- setSelectedAction(null);
38
- }, []);
39
-
40
- // Get action by ID
41
- const getActionById = (0, _react.useCallback)(id => {
42
- return _reduxActionStore.reduxActionStore.getActionById(id);
43
- }, []);
44
- return {
45
- actions: log.items,
46
- filteredActions: log.filteredItems,
47
- filter: log.filter,
48
- setFilter: log.setFilter,
49
- stats,
50
- clearActions,
51
- isEnabled: log.isEnabled,
52
- toggleCapture: log.toggleCapture,
53
- actionTypes,
54
- getActionById,
55
- selectedAction,
56
- setSelectedAction
57
- };
58
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useReduxActions=useReduxActions;var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _reduxActionStore=require("../utils/reduxActionStore");const filterActions=(e,t)=>_reduxActionStore.reduxActionStore.filterActions(t);function useReduxActions(){const e=(0,_sharedUi.useChangeLog)(_reduxActionStore.reduxActionStore,{filterItems:filterActions});const[t,r]=(0,_react.useState)(null);const o=(0,_react.useMemo)(()=>{return _reduxActionStore.reduxActionStore.getStats()},[e.items]);const s=(0,_react.useMemo)(()=>{return _reduxActionStore.reduxActionStore.getUniqueActionTypes()},[e.items]);const i=(0,_react.useCallback)(()=>{_reduxActionStore.reduxActionStore.clearActions();r(null)},[]);const n=(0,_react.useCallback)(c=>{return _reduxActionStore.reduxActionStore.getActionById(c)},[]);return{actions:e.items,filteredActions:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:o,clearActions:i,isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,actionTypes:s,getActionById:n,selectedAction:t,setSelectedAction:r}}
@@ -1,191 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.reduxSyncAdapter = void 0;
7
- var _reduxActionStore = require("../utils/reduxActionStore");
8
- var _sharedUi = require("@buoy-gg/shared-ui");
9
- var _autoInstrument = require("../utils/autoInstrument");
10
- /** Per-action budget for `payload`/`action`/`meta.arg`/`error` on the snapshot wire. */
11
- const toWireValue = value => (0, _sharedUi.toWire)(value, _reduxActionStore.PAYLOAD_ON_DEVICE);
12
-
13
- /**
14
- * Per-action wire cache. `reduxActionStore` never mutates an action in place —
15
- * it prepends, and `replaceActions` maps to fresh objects — so keying on
16
- * identity is correct and self-invalidating. Without it, every payload,
17
- * `action`, `meta.arg` and `error` in the list is re-measured on all ~5
18
- * snapshots per second for as long as it stays in the list.
19
- */
20
- const toWireAction = (0, _sharedUi.memoByIdentity)(a => {
21
- const wire = (0, _reduxActionStore.isEvictedState)(a.prevState) ? {
22
- ...a
23
- } : {
24
- ...a,
25
- prevState: _reduxActionStore.STATE_ON_DEVICE,
26
- nextState: _reduxActionStore.STATE_ON_DEVICE
27
- };
28
- // A dispatched payload can itself be huge (rehydration actions carry whole
29
- // state trees). The list view renders payloadPreview anyway — oversized /
30
- // unserializable values stay on-device behind markers. `meta.arg` is a
31
- // leftover: RTK copies the thunk argument there, and capping `action` still
32
- // left the extracted copy on the wire.
33
- wire.payload = toWireValue(wire.payload);
34
- wire.action = toWireValue(wire.action);
35
- wire.error = toWireValue(wire.error);
36
- if (wire.meta) {
37
- const arg = toWireValue(wire.meta.arg);
38
- if (arg !== wire.meta.arg) wire.meta = {
39
- ...wire.meta,
40
- arg
41
- };
42
- }
43
- return wire;
44
- });
45
- /** Top-level slice names of the state tree, for the compact (no-values) view. */
46
- function topLevelKeys(state) {
47
- return state && typeof state === "object" && !Array.isArray(state) ? Object.keys(state) : [];
48
- }
49
-
50
- /**
51
- * Why there's no bound store, in a shape remote drivers (MCP/desktop) can turn
52
- * into a SPECIFIC remedy instead of a generic "check your setup".
53
- */
54
- function unavailable() {
55
- const status = (0, _autoInstrument.getInstrumentationStatus)();
56
- const reason = status.diagnostic ?? "not-instrumented";
57
- return {
58
- available: false,
59
- slices: [],
60
- /** 'no-react-redux' | 'no-provider' | 'not-instrumented' */
61
- reason
62
- };
63
- }
64
-
65
- /**
66
- * Sync adapter for the redux tool, consumed by @buoy-gg/external-sync's
67
- * `useExternalSync` (structurally matches its ToolSyncAdapter interface so
68
- * this package doesn't need a dependency on it).
69
- *
70
- * Actions are captured from app startup — by the store-creation enhancer or
71
- * the explicit middleware (full capture), or by the dispatch-patch fallback
72
- * mounted with FloatingDevTools (top-level-only) — independent of whether a
73
- * dashboard is watching. Subscribing here only streams what's already
74
- * recorded.
75
- *
76
- * `getState`/`dispatch` read & drive the live instrumented store (via
77
- * getActiveStore()) so a remote driver (MCP/LLM) can inspect current state and
78
- * dispatch actions — redux is action-based, so the *current state* isn't in the
79
- * action-log snapshot.
80
- */
81
- const reduxSyncAdapter = exports.reduxSyncAdapter = (0, _sharedUi.createSyncAdapter)({
82
- version: 2,
83
- /**
84
- * WIRE-FORM snapshot: actions WITHOUT raw prevState/nextState trees.
85
- * Shipping the trees serialized up to 25×2 full state trees through
86
- * socket.emit per action — no guard on that path — which froze and
87
- * native-OOM-crashed enterprise-scale apps whenever a dashboard was
88
- * connected (root cause confirmed by patch-and-retest). Dashboards fetch
89
- * trees on demand via `getActionDetail`; already-evicted entries keep the
90
- * eviction sentinel so consumers can distinguish "fetchable" from "gone".
91
- */
92
- getSnapshot: () => _reduxActionStore.reduxActionStore.getActions().map(toWireAction),
93
- subscribe: onChange => _reduxActionStore.reduxActionStore.subscribe(onChange),
94
- actions: {
95
- clearEvents: () => {
96
- _reduxActionStore.reduxActionStore.clearActions();
97
- },
98
- /**
99
- * On-demand detail: one action's real prevState/nextState trees.
100
- * The per-snapshot stream stays tree-free; this is the explicit,
101
- * size-guarded channel for the detail pane.
102
- */
103
- getActionDetail: params => {
104
- const {
105
- id
106
- } = (0, _sharedUi.readParams)(params);
107
- if (!id) return {
108
- found: false,
109
- reason: "missing id"
110
- };
111
- const action = _reduxActionStore.reduxActionStore.getActionById(id);
112
- if (!action) return {
113
- found: false,
114
- reason: "unknown id"
115
- };
116
- if ((0, _reduxActionStore.isEvictedState)(action.prevState)) {
117
- return {
118
- found: true,
119
- id,
120
- evicted: true,
121
- reason: `Raw state was evicted (retained for recent actions only).`
122
- };
123
- }
124
- // Per-field cap: oversized fields degrade individually instead of
125
- // failing the whole detail (a giant payload shouldn't hide the trees).
126
- const cap = value => (0, _sharedUi.capDetail)(value, _sharedUi.WIRE_DETAIL_LIMIT_BYTES);
127
- const capMeta = meta => {
128
- if (!meta) return meta;
129
- const arg = cap(meta.arg);
130
- return arg === meta.arg ? meta : {
131
- ...meta,
132
- arg
133
- };
134
- };
135
- return {
136
- found: true,
137
- id,
138
- prevState: cap(action.prevState),
139
- nextState: cap(action.nextState),
140
- payload: cap(action.payload),
141
- action: cap(action.action),
142
- meta: capMeta(action.meta),
143
- error: cap(action.error)
144
- };
145
- },
146
- /**
147
- * Compact current-state reader: the instrumented store's slice names, and
148
- * the full state tree only when `includeValues` is set (heavy).
149
- */
150
- getState: params => {
151
- const {
152
- includeValues = false
153
- } = (0, _sharedUi.readParams)(params);
154
- const store = (0, _autoInstrument.getActiveStore)();
155
- if (!store) {
156
- return unavailable();
157
- }
158
- const state = store.getState();
159
- const status = (0, _autoInstrument.getInstrumentationStatus)();
160
- return {
161
- available: true,
162
- slices: topLevelKeys(state),
163
- /** 'full' | 'top-level-only' — what the live capture mechanism sees. */
164
- capture: status.capture,
165
- mechanism: status.mechanism,
166
- ...(includeValues ? {
167
- state
168
- } : {})
169
- };
170
- },
171
- /** Dispatch a plain action object to the instrumented store. */
172
- dispatch: params => {
173
- const {
174
- action
175
- } = (0, _sharedUi.readParams)(params);
176
- const store = (0, _autoInstrument.getActiveStore)();
177
- if (!store) {
178
- return {
179
- dispatched: false,
180
- ...unavailable()
181
- };
182
- }
183
- if (!action) throw new Error("dispatch requires an `action`");
184
- store.dispatch(action);
185
- return {
186
- dispatched: true,
187
- type: action.type
188
- };
189
- }
190
- }
191
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.reduxSyncAdapter=void 0;var _reduxActionStore=require("../utils/reduxActionStore");var _sharedUi=require("@buoy-gg/shared-ui");var _autoInstrument=require("../utils/autoInstrument");const toWireValue=e=>(0,_sharedUi.toWire)(e,_reduxActionStore.PAYLOAD_ON_DEVICE);const toWireAction=(0,_sharedUi.memoByIdentity)(e=>{const t=(0,_reduxActionStore.isEvictedState)(e.prevState)?{...e}:{...e,prevState:_reduxActionStore.STATE_ON_DEVICE,nextState:_reduxActionStore.STATE_ON_DEVICE};t.payload=toWireValue(t.payload);t.action=toWireValue(t.action);t.error=toWireValue(t.error);if(t.meta){const r=toWireValue(t.meta.arg);if(r!==t.meta.arg)t.meta={...t.meta,arg:r}}return t});function topLevelKeys(e){return e&&typeof e==="object"&&!Array.isArray(e)?Object.keys(e):[]}function unavailable(){const e=(0,_autoInstrument.getInstrumentationStatus)();const t=e.diagnostic??"not-instrumented";return{available:false,slices:[],reason:t}}const reduxSyncAdapter=exports.reduxSyncAdapter=(0,_sharedUi.createSyncAdapter)({version:2,getSnapshot:()=>_reduxActionStore.reduxActionStore.getActions().map(toWireAction),subscribe:e=>_reduxActionStore.reduxActionStore.subscribe(e),actions:{clearEvents:()=>{_reduxActionStore.reduxActionStore.clearActions()},getActionDetail:e=>{const{id:t}=(0,_sharedUi.readParams)(e);if(!t)return{found:false,reason:"missing id"};const r=_reduxActionStore.reduxActionStore.getActionById(t);if(!r)return{found:false,reason:"unknown id"};if((0,_reduxActionStore.isEvictedState)(r.prevState)){return{found:true,id:t,evicted:true,reason:`Raw state was evicted (retained for recent actions only).`}}const a=n=>(0,_sharedUi.capDetail)(n,_sharedUi.WIRE_DETAIL_LIMIT_BYTES);const o=n=>{if(!n)return n;const i=a(n.arg);return i===n.arg?n:{...n,arg:i}};return{found:true,id:t,prevState:a(r.prevState),nextState:a(r.nextState),payload:a(r.payload),action:a(r.action),meta:o(r.meta),error:a(r.error)}},getState:e=>{const{includeValues:t=false}=(0,_sharedUi.readParams)(e);const r=(0,_autoInstrument.getActiveStore)();if(!r){return unavailable()}const a=r.getState();const o=(0,_autoInstrument.getInstrumentationStatus)();return{available:true,slices:topLevelKeys(a),capture:o.capture,mechanism:o.mechanism,...t?{state:a}:{}}},dispatch:e=>{const{action:t}=(0,_sharedUi.readParams)(e);const r=(0,_autoInstrument.getActiveStore)();if(!r){return{dispatched:false,...unavailable()}}if(!t)throw new Error("dispatch requires an `action`");r.dispatch(t);return{dispatched:true,type:t.type}}}});
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";
@@ -1,104 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ENHANCER_SYMBOL = void 0;
7
- exports.getActiveStore = getActiveStore;
8
- exports.getCaptureMechanism = getCaptureMechanism;
9
- exports.getInstrumentationStatus = getInstrumentationStatus;
10
- exports.isTimeTravelAvailable = isTimeTravelAvailable;
11
- exports.markTimeTravelReducer = markTimeTravelReducer;
12
- exports.registerActiveStore = registerActiveStore;
13
- exports.setReduxDiagnostic = setReduxDiagnostic;
14
- exports.unregisterActiveStore = unregisterActiveStore;
15
- /**
16
- * Shared registry for the one live Redux store Buoy is bound to, plus how it
17
- * got bound (the capture mechanism) and why binding failed when it did.
18
- *
19
- * Lives in its own module so the three capture paths (devtools-hook enhancer,
20
- * explicit middleware, dispatch-patch fallback) and the sync adapter can all
21
- * import it without cycles.
22
- */
23
-
24
- /** The minimum store surface Buoy needs (middleware storeApi satisfies this). */
25
-
26
- /**
27
- * How the store got instrumented:
28
- * - `enhancer` — store-creation-time enhancer via the Redux DevTools global.
29
- * FULL capture (thunk-internal & RTK Query actions included).
30
- * - `middleware` — user-added buoyReduxMiddleware. FULL capture.
31
- * - `patch` — store.dispatch patched after creation (auto-instrumentation
32
- * fallback). TOP-LEVEL-ONLY capture: actions dispatched from
33
- * inside middleware/thunks bypass the patch.
34
- */
35
-
36
- /** Why there is no bound store, when there isn't one. */
37
-
38
- /** Marks stores created through the Buoy devtools-hook enhancer. */
39
- const ENHANCER_SYMBOL = exports.ENHANCER_SYMBOL = Symbol.for("@@buoy/enhancerInstrumented");
40
- let activeStore = null;
41
- let mechanism = null;
42
- let diagnostic = null;
43
- let timeTravelReducer = false;
44
- function registerActiveStore(store, mech) {
45
- activeStore = store;
46
- mechanism = mech;
47
- diagnostic = null;
48
- }
49
- function unregisterActiveStore(store) {
50
- if (activeStore === store) {
51
- activeStore = null;
52
- mechanism = null;
53
- }
54
- }
55
- function getActiveStore() {
56
- return activeStore;
57
- }
58
- function getCaptureMechanism() {
59
- return mechanism;
60
- }
61
-
62
- /**
63
- * Record that a reducer able to serve `BUOY_JUMP_TO_STATE` is in the store.
64
- *
65
- * Called by the devtools-hook enhancer and by `withBuoyDevTools` — the only
66
- * two things that wrap the root reducer. Capture and time travel are separate
67
- * capabilities and they are wired separately: a store can be fully captured
68
- * through `buoyReduxMiddleware` and still have no way to restore a state,
69
- * because middleware sits ABOVE the reducer and cannot replace what it
70
- * returns.
71
- */
72
- function markTimeTravelReducer() {
73
- timeTravelReducer = true;
74
- }
75
-
76
- /**
77
- * Whether pressing JUMP can actually do anything.
78
- *
79
- * Worth a first-class answer rather than a try-and-see, because the failure is
80
- * invisible: `jumpToState` dispatches into a store that simply does not
81
- * recognise the action, the reducer returns the state it already had, and the
82
- * screen does not move. From the outside that is indistinguishable from a
83
- * devtool that is broken.
84
- */
85
- function isTimeTravelAvailable() {
86
- return timeTravelReducer && activeStore !== null;
87
- }
88
-
89
- /**
90
- * Recorded by the auto-instrument hook so non-React surfaces (sync adapter,
91
- * MCP) can report WHY there's no store instead of a generic failure.
92
- */
93
- function setReduxDiagnostic(d) {
94
- diagnostic = d;
95
- }
96
- function getInstrumentationStatus() {
97
- return {
98
- mechanism,
99
- capture: mechanism === "enhancer" || mechanism === "middleware" ? "full" : mechanism === "patch" ? "top-level-only" : "none",
100
- hasStore: activeStore !== null,
101
- timeTravel: isTimeTravelAvailable(),
102
- diagnostic
103
- };
104
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ENHANCER_SYMBOL=void 0;exports.getActiveStore=getActiveStore;exports.getCaptureMechanism=getCaptureMechanism;exports.getInstrumentationStatus=getInstrumentationStatus;exports.isTimeTravelAvailable=isTimeTravelAvailable;exports.markTimeTravelReducer=markTimeTravelReducer;exports.registerActiveStore=registerActiveStore;exports.setReduxDiagnostic=setReduxDiagnostic;exports.unregisterActiveStore=unregisterActiveStore;const ENHANCER_SYMBOL=exports.ENHANCER_SYMBOL=Symbol.for("@@buoy/enhancerInstrumented");let activeStore=null;let mechanism=null;let diagnostic=null;let timeTravelReducer=false;function registerActiveStore(e,t){activeStore=e;mechanism=t;diagnostic=null}function unregisterActiveStore(e){if(activeStore===e){activeStore=null;mechanism=null}}function getActiveStore(){return activeStore}function getCaptureMechanism(){return mechanism}function markTimeTravelReducer(){timeTravelReducer=true}function isTimeTravelAvailable(){return timeTravelReducer&&activeStore!==null}function setReduxDiagnostic(e){diagnostic=e}function getInstrumentationStatus(){return{mechanism,capture:mechanism==="enhancer"||mechanism==="middleware"?"full":mechanism==="patch"?"top-level-only":"none",hasStore:activeStore!==null,timeTravel:isTimeTravelAvailable(),diagnostic}}