@yaasl/devtools 0.11.0-alpha.1 → 0.11.0-alpha.3
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/cjs/logger.js +1 -0
- package/dist/cjs/redux-devtools/ExtensionOptions.js +1 -0
- package/dist/cjs/redux-devtools/getReduxExtension.js +3 -0
- package/dist/cjs/reduxDevtools.js +9 -0
- package/dist/cjs/utils/subscribeStore.js +3 -3
- package/dist/esm/logger.js +1 -0
- package/dist/esm/redux-devtools/ExtensionOptions.js +1 -0
- package/dist/esm/redux-devtools/getReduxExtension.js +4 -1
- package/dist/esm/reduxDevtools.js +9 -0
- package/dist/esm/utils/subscribeStore.js +3 -3
- package/package.json +3 -8
- package/tsconfig.json +0 -3
- package/tsconfig.node.json +0 -9
package/dist/cjs/logger.js
CHANGED
|
@@ -15,6 +15,7 @@ const createLogger = (text) => ({ atom, value, options }) => {
|
|
|
15
15
|
* @returns The effect to be used on atoms.
|
|
16
16
|
**/
|
|
17
17
|
exports.logger = (0, core_1.createEffect)({
|
|
18
|
+
sort: "post",
|
|
18
19
|
init: createLogger("Initialize"),
|
|
19
20
|
didInit: createLogger("Finished initialization"),
|
|
20
21
|
set: createLogger("Set value"),
|
|
@@ -5,6 +5,9 @@ const utils_1 = require("@yaasl/utils");
|
|
|
5
5
|
let didWarn = false;
|
|
6
6
|
/** Returns the global redux extension object if available */
|
|
7
7
|
const getReduxExtension = () => {
|
|
8
|
+
const window = (0, utils_1.getWindow)();
|
|
9
|
+
if (!window)
|
|
10
|
+
return null;
|
|
8
11
|
const reduxExtension = window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
9
12
|
if (!reduxExtension) {
|
|
10
13
|
if (!didWarn) {
|
|
@@ -35,6 +35,15 @@ exports.reduxDevtools = (0, core_1.createEffect)(({ atom, options = {} }) => {
|
|
|
35
35
|
return {};
|
|
36
36
|
(0, exports.connectAtom)(connection, atom);
|
|
37
37
|
return {
|
|
38
|
+
sort: "post",
|
|
39
|
+
init: ({ value }) => {
|
|
40
|
+
cache_1.cache.setAtomValue(atom, value);
|
|
41
|
+
connection.send({ type: `INIT/${atom.name}` }, cache_1.cache.getStore());
|
|
42
|
+
},
|
|
43
|
+
didInit: ({ value }) => {
|
|
44
|
+
cache_1.cache.setAtomValue(atom, value);
|
|
45
|
+
connection.send({ type: `DID_INIT/${atom.name}` }, cache_1.cache.getStore());
|
|
46
|
+
},
|
|
38
47
|
set: ({ atom, value }) => {
|
|
39
48
|
isInitPhase = false;
|
|
40
49
|
if (updates_1.updates.isPaused())
|
|
@@ -30,10 +30,10 @@ const subscribeStore = (atom, connection) => {
|
|
|
30
30
|
return;
|
|
31
31
|
didInit = true;
|
|
32
32
|
connection.subscribe(action => {
|
|
33
|
-
const { payload } = action;
|
|
34
|
-
const nextState = !
|
|
33
|
+
const { payload, state } = action;
|
|
34
|
+
const nextState = !state
|
|
35
35
|
? null
|
|
36
|
-
: JSON.parse(
|
|
36
|
+
: JSON.parse(state);
|
|
37
37
|
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
38
38
|
case "COMMIT":
|
|
39
39
|
connection.init(cache_1.cache.getStore());
|
package/dist/esm/logger.js
CHANGED
|
@@ -12,6 +12,7 @@ const createLogger = (text) => ({ atom, value, options }) => {
|
|
|
12
12
|
* @returns The effect to be used on atoms.
|
|
13
13
|
**/
|
|
14
14
|
export const logger = createEffect({
|
|
15
|
+
sort: "post",
|
|
15
16
|
init: createLogger("Initialize"),
|
|
16
17
|
didInit: createLogger("Finished initialization"),
|
|
17
18
|
set: createLogger("Set value"),
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { log } from "@yaasl/utils";
|
|
1
|
+
import { getWindow, log } from "@yaasl/utils";
|
|
2
2
|
let didWarn = false;
|
|
3
3
|
/** Returns the global redux extension object if available */
|
|
4
4
|
export const getReduxExtension = () => {
|
|
5
|
+
const window = getWindow();
|
|
6
|
+
if (!window)
|
|
7
|
+
return null;
|
|
5
8
|
const reduxExtension = window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
6
9
|
if (!reduxExtension) {
|
|
7
10
|
if (!didWarn) {
|
|
@@ -31,6 +31,15 @@ export const reduxDevtools = createEffect(({ atom, options = {} }) => {
|
|
|
31
31
|
return {};
|
|
32
32
|
connectAtom(connection, atom);
|
|
33
33
|
return {
|
|
34
|
+
sort: "post",
|
|
35
|
+
init: ({ value }) => {
|
|
36
|
+
cache.setAtomValue(atom, value);
|
|
37
|
+
connection.send({ type: `INIT/${atom.name}` }, cache.getStore());
|
|
38
|
+
},
|
|
39
|
+
didInit: ({ value }) => {
|
|
40
|
+
cache.setAtomValue(atom, value);
|
|
41
|
+
connection.send({ type: `DID_INIT/${atom.name}` }, cache.getStore());
|
|
42
|
+
},
|
|
34
43
|
set: ({ atom, value }) => {
|
|
35
44
|
isInitPhase = false;
|
|
36
45
|
if (updates.isPaused())
|
|
@@ -27,10 +27,10 @@ export const subscribeStore = (atom, connection) => {
|
|
|
27
27
|
return;
|
|
28
28
|
didInit = true;
|
|
29
29
|
connection.subscribe(action => {
|
|
30
|
-
const { payload } = action;
|
|
31
|
-
const nextState = !
|
|
30
|
+
const { payload, state } = action;
|
|
31
|
+
const nextState = !state
|
|
32
32
|
? null
|
|
33
|
-
: JSON.parse(
|
|
33
|
+
: JSON.parse(state);
|
|
34
34
|
switch (payload?.type) {
|
|
35
35
|
case "COMMIT":
|
|
36
36
|
connection.init(cache.getStore());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaasl/devtools",
|
|
3
|
-
"version": "0.11.0-alpha.
|
|
3
|
+
"version": "0.11.0-alpha.3",
|
|
4
4
|
"description": "yaasl debugging tools (e.g. redux-devtools-extension middleware)",
|
|
5
5
|
"author": "PrettyCoffee",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,13 +38,8 @@
|
|
|
38
38
|
"validate": "run-s lint test build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@yaasl/core": "0.11.0-alpha.
|
|
42
|
-
"@yaasl/utils": "0.11.0-alpha.
|
|
43
|
-
},
|
|
44
|
-
"eslintConfig": {
|
|
45
|
-
"extends": [
|
|
46
|
-
"../../.eslintrc"
|
|
47
|
-
]
|
|
41
|
+
"@yaasl/core": "0.11.0-alpha.3",
|
|
42
|
+
"@yaasl/utils": "0.11.0-alpha.3"
|
|
48
43
|
},
|
|
49
44
|
"lint-staged": {
|
|
50
45
|
"*.{ts,tsx}": [
|
package/tsconfig.json
DELETED