@buoy-gg/redux 7.0.16 → 7.0.17
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/lib/commonjs/index.js +1 -0
- package/lib/commonjs/redux/utils/snapshotProvider.js +123 -0
- package/lib/module/index.js +3 -0
- package/lib/module/redux/utils/snapshotProvider.js +122 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/redux/utils/snapshotProvider.d.ts +2 -0
- package/lib/typescript/redux/utils/snapshotProvider.d.ts.map +1 -0
- package/package.json +7 -5
package/lib/commonjs/index.js
CHANGED
|
@@ -213,6 +213,7 @@ Object.defineProperty(exports, "withBuoyDevTools", {
|
|
|
213
213
|
return _buoyReduxMiddleware.withBuoyDevTools;
|
|
214
214
|
}
|
|
215
215
|
});
|
|
216
|
+
require("./redux/utils/snapshotProvider");
|
|
216
217
|
var _devtoolsHook = require("./redux/utils/devtoolsHook");
|
|
217
218
|
var _preset = require("./preset");
|
|
218
219
|
var _buoyReduxMiddleware = require("./redux/utils/buoyReduxMiddleware");
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
4
|
+
var _activeStoreRegistry = require("./activeStoreRegistry");
|
|
5
|
+
var _buoyReduxMiddleware = require("./buoyReduxMiddleware");
|
|
6
|
+
/**
|
|
7
|
+
* Time Machine snapshot provider for Redux.
|
|
8
|
+
*
|
|
9
|
+
* Registered into @buoy-gg/shared-ui's stateSnapshotRegistry at module init;
|
|
10
|
+
* consumed by @buoy-gg/time-machine.
|
|
11
|
+
*
|
|
12
|
+
* Restore rides the existing `@@buoy/JUMP_TO_STATE` full-state-replace action:
|
|
13
|
+
* - enhancer path: always handled (wrapReducer).
|
|
14
|
+
* - middleware path: handled ONLY when the app wrapped its root reducer in
|
|
15
|
+
* `withBuoyDevTools()` — unverifiable statically, so restore verifies by
|
|
16
|
+
* reference identity after dispatch (the wrapped reducer returns the payload
|
|
17
|
+
* object itself).
|
|
18
|
+
* - patch path: never handled; restore is reported as unavailable up front.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const ENABLE_HINT = "enable restore by using the Buoy enhancer or wrapping your root reducer in withBuoyDevTools()";
|
|
22
|
+
function status() {
|
|
23
|
+
const {
|
|
24
|
+
mechanism,
|
|
25
|
+
hasStore,
|
|
26
|
+
diagnostic
|
|
27
|
+
} = (0, _activeStoreRegistry.getInstrumentationStatus)();
|
|
28
|
+
if (!hasStore) {
|
|
29
|
+
return {
|
|
30
|
+
canCapture: false,
|
|
31
|
+
canRestore: false,
|
|
32
|
+
detail: diagnostic === "no-react-redux" ? "react-redux not installed" : diagnostic === "no-provider" ? "No Redux <Provider> found" : "No Redux store instrumented"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (mechanism === "patch") {
|
|
36
|
+
return {
|
|
37
|
+
canCapture: true,
|
|
38
|
+
canRestore: false,
|
|
39
|
+
detail: `Auto-instrumented store cannot be restored — ${ENABLE_HINT}`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
canCapture: true,
|
|
44
|
+
canRestore: true,
|
|
45
|
+
detail: mechanism === "middleware" ? "Restore requires withBuoyDevTools(rootReducer) — verified at restore time" : undefined
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function capture() {
|
|
49
|
+
const store = (0, _activeStoreRegistry.getActiveStore)();
|
|
50
|
+
if (!store) {
|
|
51
|
+
return {
|
|
52
|
+
data: null,
|
|
53
|
+
warnings: ["no Redux store instrumented"]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
data: {
|
|
58
|
+
state: store.getState()
|
|
59
|
+
},
|
|
60
|
+
warnings: []
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function restore(data) {
|
|
64
|
+
const snapshot = data;
|
|
65
|
+
const store = (0, _activeStoreRegistry.getActiveStore)();
|
|
66
|
+
if (!store || snapshot === undefined || snapshot === null) {
|
|
67
|
+
return {
|
|
68
|
+
ok: false,
|
|
69
|
+
applied: 0,
|
|
70
|
+
skipped: [{
|
|
71
|
+
id: "redux",
|
|
72
|
+
reason: store ? "empty redux snapshot" : "no Redux store instrumented"
|
|
73
|
+
}],
|
|
74
|
+
warnings: []
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const {
|
|
78
|
+
mechanism
|
|
79
|
+
} = (0, _activeStoreRegistry.getInstrumentationStatus)();
|
|
80
|
+
if (mechanism === "patch") {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
applied: 0,
|
|
84
|
+
skipped: [{
|
|
85
|
+
id: "redux",
|
|
86
|
+
reason: `restore unavailable on auto-instrumented stores — ${ENABLE_HINT}`
|
|
87
|
+
}],
|
|
88
|
+
warnings: []
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const payload = snapshot.state;
|
|
92
|
+
store.dispatch({
|
|
93
|
+
type: _buoyReduxMiddleware.BUOY_JUMP_TO_STATE,
|
|
94
|
+
payload
|
|
95
|
+
});
|
|
96
|
+
// The wrapped reducer returns the payload object itself, so reference
|
|
97
|
+
// identity proves the jump was actually handled (and not silently ignored
|
|
98
|
+
// by an unwrapped middleware-path reducer).
|
|
99
|
+
if (store.getState() === payload) {
|
|
100
|
+
return {
|
|
101
|
+
ok: true,
|
|
102
|
+
applied: 1,
|
|
103
|
+
skipped: [],
|
|
104
|
+
warnings: []
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
ok: false,
|
|
109
|
+
applied: 0,
|
|
110
|
+
skipped: [{
|
|
111
|
+
id: "redux",
|
|
112
|
+
reason: `store ignored the state jump — ${ENABLE_HINT}`
|
|
113
|
+
}],
|
|
114
|
+
warnings: []
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
(0, _sharedUi.registerStateSnapshotProvider)({
|
|
118
|
+
id: "redux",
|
|
119
|
+
label: "Redux",
|
|
120
|
+
status,
|
|
121
|
+
capture,
|
|
122
|
+
restore
|
|
123
|
+
});
|
package/lib/module/index.js
CHANGED
|
@@ -53,6 +53,9 @@
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
|
+
// Side-effect: registers the Time Machine snapshot provider
|
|
57
|
+
import "./redux/utils/snapshotProvider";
|
|
58
|
+
|
|
56
59
|
// SIDE EFFECT (must stay first): claim the Redux DevTools global so stores
|
|
57
60
|
// created after this module loads get the full-capture enhancer. Dev-only,
|
|
58
61
|
// never overrides an existing claimant. See ./redux/utils/devtoolsHook.ts.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Time Machine snapshot provider for Redux.
|
|
5
|
+
*
|
|
6
|
+
* Registered into @buoy-gg/shared-ui's stateSnapshotRegistry at module init;
|
|
7
|
+
* consumed by @buoy-gg/time-machine.
|
|
8
|
+
*
|
|
9
|
+
* Restore rides the existing `@@buoy/JUMP_TO_STATE` full-state-replace action:
|
|
10
|
+
* - enhancer path: always handled (wrapReducer).
|
|
11
|
+
* - middleware path: handled ONLY when the app wrapped its root reducer in
|
|
12
|
+
* `withBuoyDevTools()` — unverifiable statically, so restore verifies by
|
|
13
|
+
* reference identity after dispatch (the wrapped reducer returns the payload
|
|
14
|
+
* object itself).
|
|
15
|
+
* - patch path: never handled; restore is reported as unavailable up front.
|
|
16
|
+
*/
|
|
17
|
+
import { registerStateSnapshotProvider } from "@buoy-gg/shared-ui";
|
|
18
|
+
import { getActiveStore, getInstrumentationStatus } from "./activeStoreRegistry";
|
|
19
|
+
import { BUOY_JUMP_TO_STATE } from "./buoyReduxMiddleware";
|
|
20
|
+
const ENABLE_HINT = "enable restore by using the Buoy enhancer or wrapping your root reducer in withBuoyDevTools()";
|
|
21
|
+
function status() {
|
|
22
|
+
const {
|
|
23
|
+
mechanism,
|
|
24
|
+
hasStore,
|
|
25
|
+
diagnostic
|
|
26
|
+
} = getInstrumentationStatus();
|
|
27
|
+
if (!hasStore) {
|
|
28
|
+
return {
|
|
29
|
+
canCapture: false,
|
|
30
|
+
canRestore: false,
|
|
31
|
+
detail: diagnostic === "no-react-redux" ? "react-redux not installed" : diagnostic === "no-provider" ? "No Redux <Provider> found" : "No Redux store instrumented"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (mechanism === "patch") {
|
|
35
|
+
return {
|
|
36
|
+
canCapture: true,
|
|
37
|
+
canRestore: false,
|
|
38
|
+
detail: `Auto-instrumented store cannot be restored — ${ENABLE_HINT}`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
canCapture: true,
|
|
43
|
+
canRestore: true,
|
|
44
|
+
detail: mechanism === "middleware" ? "Restore requires withBuoyDevTools(rootReducer) — verified at restore time" : undefined
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function capture() {
|
|
48
|
+
const store = getActiveStore();
|
|
49
|
+
if (!store) {
|
|
50
|
+
return {
|
|
51
|
+
data: null,
|
|
52
|
+
warnings: ["no Redux store instrumented"]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
data: {
|
|
57
|
+
state: store.getState()
|
|
58
|
+
},
|
|
59
|
+
warnings: []
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function restore(data) {
|
|
63
|
+
const snapshot = data;
|
|
64
|
+
const store = getActiveStore();
|
|
65
|
+
if (!store || snapshot === undefined || snapshot === null) {
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
applied: 0,
|
|
69
|
+
skipped: [{
|
|
70
|
+
id: "redux",
|
|
71
|
+
reason: store ? "empty redux snapshot" : "no Redux store instrumented"
|
|
72
|
+
}],
|
|
73
|
+
warnings: []
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const {
|
|
77
|
+
mechanism
|
|
78
|
+
} = getInstrumentationStatus();
|
|
79
|
+
if (mechanism === "patch") {
|
|
80
|
+
return {
|
|
81
|
+
ok: false,
|
|
82
|
+
applied: 0,
|
|
83
|
+
skipped: [{
|
|
84
|
+
id: "redux",
|
|
85
|
+
reason: `restore unavailable on auto-instrumented stores — ${ENABLE_HINT}`
|
|
86
|
+
}],
|
|
87
|
+
warnings: []
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const payload = snapshot.state;
|
|
91
|
+
store.dispatch({
|
|
92
|
+
type: BUOY_JUMP_TO_STATE,
|
|
93
|
+
payload
|
|
94
|
+
});
|
|
95
|
+
// The wrapped reducer returns the payload object itself, so reference
|
|
96
|
+
// identity proves the jump was actually handled (and not silently ignored
|
|
97
|
+
// by an unwrapped middleware-path reducer).
|
|
98
|
+
if (store.getState() === payload) {
|
|
99
|
+
return {
|
|
100
|
+
ok: true,
|
|
101
|
+
applied: 1,
|
|
102
|
+
skipped: [],
|
|
103
|
+
warnings: []
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
ok: false,
|
|
108
|
+
applied: 0,
|
|
109
|
+
skipped: [{
|
|
110
|
+
id: "redux",
|
|
111
|
+
reason: `store ignored the state jump — ${ENABLE_HINT}`
|
|
112
|
+
}],
|
|
113
|
+
warnings: []
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
registerStateSnapshotProvider({
|
|
117
|
+
id: "redux",
|
|
118
|
+
label: "Redux",
|
|
119
|
+
status,
|
|
120
|
+
capture,
|
|
121
|
+
restore
|
|
122
|
+
});
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
* });
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
|
+
import "./redux/utils/snapshotProvider";
|
|
53
54
|
import "./redux/utils/devtoolsHook";
|
|
54
55
|
export { reduxToolPreset, createReduxTool } from "./preset";
|
|
55
56
|
export { buoyReduxMiddleware, createBuoyReduxMiddleware, withBuoyDevTools, jumpToState, replayAction, BUOY_JUMP_TO_STATE, BUOY_REPLAY_ACTION, } from "./redux/utils/buoyReduxMiddleware";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAGH,OAAO,gCAAgC,CAAC;AAKxC,OAAO,4BAA4B,CAAC;AAKpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK5D,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAK3C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,yCAAyC,CAAC;AAKjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAKjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG3E,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EACV,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAO9C,OAAO,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAK7E,YAAY,EACV,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAKvB,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotProvider.d.ts","sourceRoot":"","sources":["../../../../src/redux/utils/snapshotProvider.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/redux",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.17",
|
|
4
4
|
"description": "Redux DevTools inside your React Native app — action log, state diffs & time travel with zero store changes. Part of Buoy devtools.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -26,12 +26,14 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": [
|
|
28
28
|
"**/devtoolsHook.js",
|
|
29
|
-
"**/devtoolsHook.ts"
|
|
29
|
+
"**/devtoolsHook.ts",
|
|
30
|
+
"**/snapshotProvider.js",
|
|
31
|
+
"**/snapshotProvider.ts"
|
|
30
32
|
],
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
33
|
-
"@buoy-gg/
|
|
34
|
-
"@buoy-gg/
|
|
34
|
+
"@buoy-gg/shared-ui": "^7.0.17",
|
|
35
|
+
"@buoy-gg/license": "^7.0.17",
|
|
36
|
+
"@buoy-gg/floating-tools-core": "^7.0.17"
|
|
35
37
|
},
|
|
36
38
|
"peerDependencies": {
|
|
37
39
|
"@reduxjs/toolkit": ">=1.9.0",
|