# Changelog
Starts with version 3.4.15, please see commit history for earlier changes.

## [3.4.15]
- Chore: Upgrade lit to 2.7.2

## [3.4.16]
- Chore: Upgrade lit to 3.0.2

## [3.4.17]
- Chore: Upgrade lit to 3.1.1

## [4.0.0]
- Feat(set-state): Added options parameter with entryPath for easier state navigation
- Feat(set-state): Correctly type and describe entryPath
- Feat(deepReduce): Exempt "Element"
- Chore(deps): Upgrade dependencies
- Chore(Readme): Fix typos
- Chore(deps): Bump versions
- Fix(types): Add StateEntryPath type
- Fix(types): Refine State EntryPath type
- WIP(state-path): Replace all other path definitions by StatePath
- fix(getSubscriptionData): Fix condition for array index segments
- fix(litElementStateful): Fix typing
- Chore(Changelog): Add breaking changes
 
### 🚨 BREAKING CHANGE:
This version replaces the parameter based targeting of state with an array based approach, the new ``StatePath`` interface.
To subscribe state the function call was:
```
LitElementStateful.connectState(
    "path", "to", "my", "state", "myLitElementProperty", { options }
)

or

LitElementStateful.subscribeState(
    "path", "to", "my", "state", "myLitElementProperty", stateChange => { ...do something with stateChange... },  { options }
)

or

LitElementStateService.subscribe(
    "path", "to", "my", "state", stateChange => { ...do something with stateChange... }, { options }
)
```

This becomes:

```
LitElementStateful.connectState(
    ["path", "to", "my", "state"], "myLitElementProperty", { options }
)

or

LitElementStateful.subscribeState(
    ["path", "to", "my", "state"], "myLitElementProperty", stateChange => { ...do something with stateChange... },  { options }
)

or

LitElementStateService.subscribe(
    ["path", "to", "my", "state"], stateChange => { ...do something with stateChange... }, { options }
)
```
This makes it easier to type the path and also to reuse paths as variables.

### 🚨 BREAKING CHANGE:
This version moves the cacheHandler parameter on the ``LitElementStateful.setState`` & ``LitElementStateService.set`` methods into a ``SetStateOptions`` object.
When cacheHandlers have been used like e.g.:
```
setSate(
    { myProp: 'test' }, 
    'myCacheHandlerName'
)
```
the usages have to be re-written to:
```
setSate(
    { myProp: 'test' }, 
    { cacheHandlerName: 'myCacheHandlerName' }
)
```
## [4.0.1]
- Chore(Readme): Update Readme
- Chore: Update version
- Fix(typing): Reduce typing support for StatePath to 10 levels max

## [4.0.2]
- Fix(typing): Reduce typing support for StatePath to 6 levels max

## [4.0.3]
- Fix(typing): Revert to recursive type with additional condition

## [4.0.4]
- Fix(typing): Make state object "Required" in StatePath

## [5.0.0]
- Fix(StatePath): Change to non-recursive typing, revert array element selection

### 🚨🚨: I strongly recommend not using v4 and upgrade to this version

### 🚨 BREAKING CHANGE:
Since recursive typing proved to be super slow for large states and impossible to properly use intellisense, 
I had to revert to multiple function overloads.
As a consequence the StatePath array element selection had to be changed / reverted:
```
['library', 'books', 1] or ['library', 'books', book => book.title === 'Harry Potter']
```
Needs to be reverted to that:
```
['library', { array: 'books', get: 1}] or ['library', { array: 'books', get: book => book.title === 'Harry Potter'}]
```

## [5.0.1]
- Fix(deep-reduce): Add Date to exceptions from deepReduce

## [5.0.2]
- fix(cacheHandlers): Improve array handling for localstorage cacheHandler
- fix(cacheHandlers): Fix typing error in localstorage cacheHandler

## [5.0.3]
- fix(cacheHandlers): Fix array merge error in localstorage cacheHandler

## [5.0.4]
- fix(cacheHandlers): Fix path creation in localstorage cacheHandler

## [5.0.5]
- fix(cacheHandlers): Fix path creation in localstorage cacheHandler

## [5.0.6]
- fix(cacheHandlers): Take full path in localstorage cacheHandler on array update

## [5.0.7]
- fix(cacheHandlers): Fix loading of array from localstorage

## [5.0.8]
- chore(deps): Bump versions

## [5.0.9]
- fix(deepCompare): handle NaN
- chore(deps): Bump versions

## [5.1.0]
- chore(deps): Bump versions
- feat(cacheHandlers): Allow exceptions from caching

## [5.1.1]
- fix(localStorageCacheHandler): fix array handling

## [5.1.2]
- fix(localStorageCacheHandler): add missing null check

## [5.1.3]
- fix(localStorageCacheHandler): correct check order

## [5.1.4]
- chore: build step was forgotten in last version - use this instead of 5.1.3

## [5.1.5]
- fix(localStorageCacheHandler): typo in condition for arrays

## [5.1.6]
- chore(deps): Bump versions

## [6.0.0]
- fix(types): Rework types, dependencies and packaging
- **BREAKING (packaging)**: Added an `exports` map. The root entry (`@stefanholzapfel/lit-state`) exposes the service, the stateful element base class, the subscription and the shared types; the localStorage cache handler is available via the dedicated subpath `@stefanholzapfel/lit-state/localStorageCacheHandler.js`. Arbitrary deep imports into `dist/` are no longer resolvable.
- **BREAKING (types only)**: consumers must be on TypeScript >= 5.0 (the signatures use a `const` type parameter).

## [6.0.1]
- chore: export helpers

## [6.0.2]
- fix(types): better tyes for set() 

## [7.0.0]
- feat(types): `StatePath` is now the fully typed path type (formerly `StatePathConstraint`) — dynamic path variables get per-segment validation, IDE suggestions and predicate auto-typing, other refactors

- **BREAKING (types only)**: consumers must be on TypeScript >= 6.0 (`NoInfer_` polyfill removed)
- **BREAKING (types only)**: `SetStateOptions` is no longer generic and no longer contains `entryPath`, `entryPath` now lives on the `set()` / `setState()` overloads themselves.
- **BREAKING**: `getUntyped()` removed

## [8.0.0]
- chore(types): make the CacheHandler's set and load async so handlers that won't work sync can be implemented

- **BREAKING**: CachHandler load & set are now async

## [8.0.1]
- chore(feat): move initial state loading into separate async load method

## [8.0.2]
- fix(state.service): re-add reducer mode in array changes for correct behavior

## [8.0.3]
- fix(state.service): further improve array deepReducing by leveraging recursion in more cases

## [8.0.4]
- chore: Forgot to build the new versions 8.0.2 & 8.0.3 - done now

## [8.1.0]
- Feat(caching): Allow to store paths as JSON