@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.
@@ -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"),
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-parameters */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 = !action.state
33
+ const { payload, state } = action;
34
+ const nextState = !state
35
35
  ? null
36
- : JSON.parse(action.state);
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());
@@ -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 +1,2 @@
1
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-parameters */
1
2
  export {};
@@ -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 = !action.state
30
+ const { payload, state } = action;
31
+ const nextState = !state
32
32
  ? null
33
- : JSON.parse(action.state);
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.1",
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.1",
42
- "@yaasl/utils": "0.11.0-alpha.1"
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
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["./src"],
4
- "exclude": ["./**/*.test.ts"],
5
- "compilerOptions": {
6
- "declaration": false,
7
- "noEmit": false,
8
- }
9
- }