little-state-machine
Advanced tools
Comparing version 3.0.0 to 3.0.1
export declare const STORE_DEFAULT_NAME = "__STATE_MACHINE__"; | ||
export declare const STORE_ACTION_NAME = "__STATE_MACHINE_ACTION_NAME__"; | ||
export declare const STATE_MACHINE_DEBUG_NAME = "___STATE_MACHINE_DEBUG__"; | ||
export declare const STATE_MACHINE_DEV_TOOL_CONFIG = "___STATE_MACHINE_DEV_CONFIG__"; | ||
export declare const COLORS: { | ||
primary: string; | ||
secondary: string; | ||
}; | ||
export declare const Z_INDEX: { | ||
top: number; | ||
second: number; | ||
}; |
@@ -1,3 +0,2 @@ | ||
import * as React from 'react'; | ||
import { createContext, useState, useMemo, createElement, useContext } from 'react'; | ||
import { createContext, useState, useMemo, createElement, useContext, useCallback } from 'react'; | ||
@@ -90,4 +89,4 @@ const STORE_DEFAULT_NAME = '__STATE_MACHINE__'; | ||
values.forEach((value) => { | ||
store = Object.assign(Object.assign({}, store), { | ||
[value]: Object.assign(Object.assign({}, store[value]), browserStore[value]), | ||
store = Object.assign({}, store, { | ||
[value]: Object.assign({}, store[value], browserStore[value]), | ||
}); | ||
@@ -104,3 +103,2 @@ }); | ||
const { useCallback } = React; | ||
const isClient = typeof window !== 'undefined'; | ||
@@ -174,3 +172,3 @@ const isDevMode = process.env.NODE_ENV !== 'production'; | ||
if (Array.isArray(middleWaresArray) && middleWaresArray.length) { | ||
pipeData = middleWaresArray.reduce((currentValue, currentFunction) => currentFunction(currentValue), pipeData); | ||
pipeData = middleWaresArray.reduce((currentValue, currentFunction) => currentFunction(currentValue) || currentValue, pipeData); | ||
} | ||
@@ -184,3 +182,3 @@ updateStore(pipeData); | ||
return { | ||
actions: Object.entries(updateStoreFunction).reduce((previous, [key, callback]) => (Object.assign(Object.assign({}, previous), { [key]: useCallback(actionTemplate({ | ||
actions: Object.entries(updateStoreFunction).reduce((previous, [key, callback]) => (Object.assign({}, previous, { [key]: useCallback(actionTemplate({ | ||
options, | ||
@@ -187,0 +185,0 @@ callback, |
@@ -93,4 +93,4 @@ 'use strict'; | ||
values.forEach((value) => { | ||
store = Object.assign(Object.assign({}, store), { | ||
[value]: Object.assign(Object.assign({}, store[value]), browserStore[value]), | ||
store = Object.assign({}, store, { | ||
[value]: Object.assign({}, store[value], browserStore[value]), | ||
}); | ||
@@ -107,3 +107,2 @@ }); | ||
const { useCallback } = React; | ||
const isClient = typeof window !== 'undefined'; | ||
@@ -177,3 +176,3 @@ const isDevMode = process.env.NODE_ENV !== 'production'; | ||
if (Array.isArray(middleWaresArray) && middleWaresArray.length) { | ||
pipeData = middleWaresArray.reduce((currentValue, currentFunction) => currentFunction(currentValue), pipeData); | ||
pipeData = middleWaresArray.reduce((currentValue, currentFunction) => currentFunction(currentValue) || currentValue, pipeData); | ||
} | ||
@@ -187,3 +186,3 @@ updateStore(pipeData); | ||
return { | ||
actions: Object.entries(updateStoreFunction).reduce((previous, [key, callback]) => (Object.assign(Object.assign({}, previous), { [key]: useCallback(actionTemplate({ | ||
actions: Object.entries(updateStoreFunction).reduce((previous, [key, callback]) => (Object.assign({}, previous, { [key]: React.useCallback(actionTemplate({ | ||
options, | ||
@@ -199,3 +198,3 @@ callback, | ||
actions: {}, | ||
action: useCallback(updateStoreFunction | ||
action: React.useCallback(updateStoreFunction | ||
? actionTemplate({ | ||
@@ -202,0 +201,0 @@ options, |
{ | ||
"name": "little-state-machine", | ||
"sideEffects": false, | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.es.js", |
@@ -18,3 +18,3 @@ <div align="center"><a href="https://lrz5wloklm.csb.app/"><img src="https://github.com/bluebill1049/little-state-machine/blob/master/docs/logo.png?raw=true" alt="Little State Machine - React Hooks for state management" width="140px" /></a> | ||
- Tiny with 0 dependency and simple (less than 1.5kb) | ||
- Persist state by default (`sessionStorage`) | ||
- Persist state by default (`sessionStorage` or `localStorage`) | ||
- Build with React Hooks | ||
@@ -118,20 +118,2 @@ - Compatible with React Native | ||
<h2>⚒ DevTool</h2> | ||
Built-in DevTool component to track your state change and action. | ||
```jsx | ||
import { DevTool } from 'little-state-machine-devtools'; | ||
<StateMachineProvider> | ||
{process.env.NODE_ENV !== 'production' && <DevTool />} | ||
</StateMachineProvider>; | ||
``` | ||
<div align="center"> | ||
<a href="https://lrz5wloklm.csb.app/"> | ||
<img width="500" src="https://github.com/bluebill1049/little-state-machine/blob/master/docs/DevToolScreen.png?raw=true" /> | ||
</a> | ||
</div> | ||
<h2>📖 Example</h2> | ||
@@ -160,3 +142,3 @@ | ||
<StateMachineProvider> | ||
{process.env.NODE_ENV !== 'production' && <DevTool />} | ||
<DevTool /> | ||
<YourComponent /> | ||
@@ -208,1 +190,19 @@ </StateMachineProvider> | ||
``` | ||
<h2>⚒ Little State Machine DevTool</h2> | ||
[DevTool](https://github.com/bluebill1049/little-state-machine-dev-tools) component to track your state change and action. | ||
```jsx | ||
import { DevTool } from 'little-state-machine-devtools'; | ||
<StateMachineProvider> | ||
<DevTool /> | ||
</StateMachineProvider>; | ||
``` | ||
<div align="center"> | ||
<a href="https://lrz5wloklm.csb.app/"> | ||
<img width="500" src="https://github.com/bluebill1049/little-state-machine/blob/master/docs/DevToolScreen.png?raw=true" /> | ||
</a> | ||
</div> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31781
17
464
1