From 4ed2a465f82ce7f57dd014e7de5e0f1f46885e0b Mon Sep 17 00:00:00 2001 From: Layton Whiteley Date: Thu, 4 Jul 2024 05:24:10 +0200 Subject: [PATCH] chore: release v0.3.4 --- CHANGELOG.md | 10 +++ package.json | 2 +- packages/history-utility/docs/modules.md | 105 +++++++++++------------ packages/history-utility/package.json | 2 +- 4 files changed, 64 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbd5323..aa2efd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v0.3.4](https://github.com/valtiojs/valtio-history/compare/v0.3.3...v0.3.4) + +- fix: declare explicit return type for getNode [`#16`](https://github.com/valtiojs/valtio-history/pull/16) +- ci: upgrade action versions [`79b1db9`](https://github.com/valtiojs/valtio-history/commit/79b1db99436fc3a0ef5deb1690d5bf7947d72d2c) +- build: upgrade nx to latest [`db78d8e`](https://github.com/valtiojs/valtio-history/commit/db78d8ecbf179796d3cb03a950ce76b652d5e9df) +- chore: remove migrations.json [`b8250b3`](https://github.com/valtiojs/valtio-history/commit/b8250b32f1255269e99bb40d01e3be0057601c61) + #### [v0.3.3](https://github.com/valtiojs/valtio-history/compare/v0.3.2...v0.3.3) +> 29 April 2024 + - fix: update history when a state property is set to undefined [`#14`](https://github.com/valtiojs/valtio-history/pull/14) +- chore: release v0.3.3 [`21daf8f`](https://github.com/valtiojs/valtio-history/commit/21daf8f903599b765589e616b777278da3db2e01) #### [v0.3.2](https://github.com/valtiojs/valtio-history/compare/v0.3.1...v0.3.2) diff --git a/package.json b/package.json index 2563503..57c206e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "valtio-history", - "version": "0.3.3", + "version": "0.3.4", "license": "MIT", "author": "Daishi Kato", "repository": { diff --git a/packages/history-utility/docs/modules.md b/packages/history-utility/docs/modules.md index 8be5eb7..53c54f6 100644 --- a/packages/history-utility/docs/modules.md +++ b/packages/history-utility/docs/modules.md @@ -23,22 +23,22 @@ #### Type parameters | Name | -| :--- | -| `T` | +| :------ | +| `T` | #### Type declaration -| Name | Type | Description | -| :------ | :----------------------------------------------- | :-------------------------------------------------------------- | -| `index` | `number` | the history index of the current snapshot | -| `nodes` | [`HistoryNode`](modules.md#historynode)\<`T`\>[] | the nodes of the history for each change | -| `wip` | `Snapshot`\<`T`\> \| typeof `EMPTY_WIP` | field for holding sandbox changes; used to avoid infinite loops | +| Name | Type | Description | +| :------ | :------ | :------ | +| `index` | `number` | the history index of the current snapshot | +| `nodes` | [`HistoryNode`](modules.md#historynode)\<`T`\>[] | the nodes of the history for each change | +| `wip` | `Snapshot`\<`T`\> \| typeof `EMPTY_WIP` | field for holding sandbox changes; used to avoid infinite loops | #### Defined in -[packages/history-utility/src/index.ts:28](https://github.com/valtiojs/valtio-history/blob/ec38985/packages/history-utility/src/index.ts#L28) +[packages/history-utility/src/index.ts:28](https://github.com/valtiojs/valtio-history/blob/44dcf22/packages/history-utility/src/index.ts#L28) ---- +___ ### HistoryNode @@ -47,22 +47,22 @@ #### Type parameters | Name | -| :--- | -| `T` | +| :------ | +| `T` | #### Type declaration -| Name | Type | Description | -| :----------- | :---------------- | :----------------------------------------------------------------------------------- | -| `createdAt` | `Date` | The date when the node was created | -| `snapshot` | `Snapshot`\<`T`\> | The snapshot being tracked | -| `updatedAt?` | `Date` | The date when the node was updated. Will be undefined if the node was never updated. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `createdAt` | `Date` | The date when the node was created | +| `snapshot` | `Snapshot`\<`T`\> | The snapshot being tracked | +| `updatedAt?` | `Date` | The date when the node was updated. Will be undefined if the node was never updated. | #### Defined in -[packages/history-utility/src/index.ts:10](https://github.com/valtiojs/valtio-history/blob/ec38985/packages/history-utility/src/index.ts#L10) +[packages/history-utility/src/index.ts:10](https://github.com/valtiojs/valtio-history/blob/44dcf22/packages/history-utility/src/index.ts#L10) ---- +___ ### HistoryOptions @@ -70,13 +70,13 @@ #### Type declaration -| Name | Type | Description | -| :--------------- | :-------- | :---------------------------------------------------------------- | +| Name | Type | Description | +| :------ | :------ | :------ | | `skipSubscribe?` | `boolean` | determines if the internal subscribe behaviour should be skipped. | #### Defined in -[packages/history-utility/src/index.ts:45](https://github.com/valtiojs/valtio-history/blob/ec38985/packages/history-utility/src/index.ts#L45) +[packages/history-utility/src/index.ts:45](https://github.com/valtiojs/valtio-history/blob/44dcf22/packages/history-utility/src/index.ts#L45) ## Functions @@ -86,7 +86,6 @@ This creates a new proxy with history support (ProxyHistoryObject). It includes following main properties:
- - value: any value (does not have to be an object)
- history: an object holding the history of snapshots and other metadata
- history.index: the history index of the current snapshot
@@ -100,15 +99,15 @@ Notes:
#### Type parameters | Name | -| :--- | -| `V` | +| :------ | +| `V` | #### Parameters -| Name | Type | Description | -| :------------- | :--------------------------------------------------------- | :--------------------------------------------- | -| `initialValue` | `V` | any value to be tracked | -| `options?` | `boolean` \| [`HistoryOptions`](modules.md#historyoptions) | use to configure the proxyWithHistory utility. | +| Name | Type | Description | +| :------ | :------ | :------ | +| `initialValue` | `V` | any value to be tracked | +| `options?` | `boolean` \| [`HistoryOptions`](modules.md#historyoptions) | use to configure the proxyWithHistory utility. | #### Returns @@ -116,38 +115,38 @@ Notes:
proxyObject -| Name | Type | Description | -| :------------------------ | :-------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `canRedo` | () => `boolean` | a function to return true if redo is available **`Deprecated`** **`See`** [https://github.com/valtiojs/valtio-history/issues/10](https://github.com/valtiojs/valtio-history/issues/10) | -| `canUndo` | () => `boolean` | a function to return true if undo is available **`Deprecated`** **`See`** [https://github.com/valtiojs/valtio-history/issues/10](https://github.com/valtiojs/valtio-history/issues/10) | -| `clone` | \(`value`: `T`) => `T` | utility to clone a snapshot | -| `getCurrentChangeDate` | () => `undefined` \| `Date` | get the date when a node was entered into history. **`Deprecated`** **`See`** [https://github.com/valtiojs/valtio-history/issues/10](https://github.com/valtiojs/valtio-history/issues/10) | -| `getNode` | (`index`: `number`) => `undefined` \| \{ `createdAt`: `Date` ; `snapshot`: `Snapshot`\<`V`\> ; `updatedAt?`: `Date` } | utility method to get a history node. The snapshot within this node is already cloned and will not affect the original value if updated. | -| `goTo` | (`index`: `number`) => `void` | a function to go to a specific index in history | -| `history` | [`History`](modules.md#history)\<`V`\> & `AsRef` | an object holding the history of snapshots and other metadata
- history.index: the history index to the current snapshot
- history.nodes: the nodes of the history for each change
- history.wip: field for holding sandbox changes; used to avoid infinite loops
| -| `redo` | () => `void` | a function to go forward in history | -| `remove` | (`index`: `number`) => `undefined` \| [`HistoryNode`](modules.md#historynode)\<`V`\> | The remove method is only invoked when there are more than one nodes and when a valid index is provided. If the current index is removed, An index greater than the current index will be preferred as the next value. | -| `replace` | (`index`: `number`, `value`: `INTERNAL_Snapshot`\<`V`\>) => `void` | utility to replace a value in history. The history changes will not be affected, only the value to be replaced. If a base value is needed to operate on, the `getNode` utility can be used to retrieve a cloned historyNode.

Notes:
- No operations are done on the value provided to this utility.
- This is an advanced method, please ensure the value provided is a snapshot of the same type of the value being tracked.
| -| `saveHistory` | () => `void` | a function to execute saving history when changes are made to `value` | -| `shouldSaveHistory` | (`ops`: `Op`[]) => `boolean` | a function that returns true when the history should be updated | -| `subscribe` | () => () => `void` | a function to subscribe to changes made to `value` | -| `undo` | () => `void` | a function to go back in history | -| `value` | `V` | any value to be tracked (does not have to be an object) | -| `get currentChangeDate()` | `undefined` \| `Date` | - | -| `get currentIndex()` | `number` | - | -| `get historyNodeCount()` | `number` | - | -| `get isRedoEnabled()` | `boolean` | - | -| `get isUndoEnabled()` | `boolean` | - | +| Name | Type | Description | +| :------ | :------ | :------ | +| `canRedo` | () => `boolean` | a function to return true if redo is available **`Deprecated`** **`See`** [https://github.com/valtiojs/valtio-history/issues/10](https://github.com/valtiojs/valtio-history/issues/10) | +| `canUndo` | () => `boolean` | a function to return true if undo is available **`Deprecated`** **`See`** [https://github.com/valtiojs/valtio-history/issues/10](https://github.com/valtiojs/valtio-history/issues/10) | +| `clone` | \(`value`: `T`) => `T` | utility to clone a snapshot | +| `getCurrentChangeDate` | () => `undefined` \| `Date` | get the date when a node was entered into history. **`Deprecated`** **`See`** [https://github.com/valtiojs/valtio-history/issues/10](https://github.com/valtiojs/valtio-history/issues/10) | +| `getNode` | (`index`: `number`) => `undefined` \| [`HistoryNode`](modules.md#historynode)\<`V`\> | utility method to get a history node. The snapshot within this node is already cloned and will not affect the original value if updated. | +| `goTo` | (`index`: `number`) => `void` | a function to go to a specific index in history | +| `history` | [`History`](modules.md#history)\<`V`\> & `AsRef` | an object holding the history of snapshots and other metadata
- history.index: the history index to the current snapshot
- history.nodes: the nodes of the history for each change
- history.wip: field for holding sandbox changes; used to avoid infinite loops
| +| `redo` | () => `void` | a function to go forward in history | +| `remove` | (`index`: `number`) => `undefined` \| [`HistoryNode`](modules.md#historynode)\<`V`\> | The remove method is only invoked when there are more than one nodes and when a valid index is provided. If the current index is removed, An index greater than the current index will be preferred as the next value. | +| `replace` | (`index`: `number`, `value`: `INTERNAL_Snapshot`\<`V`\>) => `void` | utility to replace a value in history. The history changes will not be affected, only the value to be replaced. If a base value is needed to operate on, the `getNode` utility can be used to retrieve a cloned historyNode.

Notes:
- No operations are done on the value provided to this utility.
- This is an advanced method, please ensure the value provided is a snapshot of the same type of the value being tracked.
| +| `saveHistory` | () => `void` | a function to execute saving history when changes are made to `value` | +| `shouldSaveHistory` | (`ops`: `Op`[]) => `boolean` | a function that returns true when the history should be updated | +| `subscribe` | () => () => `void` | a function to subscribe to changes made to `value` | +| `undo` | () => `void` | a function to go back in history | +| `value` | `V` | any value to be tracked (does not have to be an object) | +| `get currentChangeDate()` | `undefined` \| `Date` | - | +| `get currentIndex()` | `number` | - | +| `get historyNodeCount()` | `number` | - | +| `get isRedoEnabled()` | `boolean` | - | +| `get isUndoEnabled()` | `boolean` | - | **`Example`** ```ts -import { proxyWithHistory } from 'valtio-history'; +import { proxyWithHistory } from 'valtio-history' const state = proxyWithHistory({ count: 1, -}); +}) ``` #### Defined in -[packages/history-utility/src/index.ts:122](https://github.com/valtiojs/valtio-history/blob/ec38985/packages/history-utility/src/index.ts#L122) +[packages/history-utility/src/index.ts:122](https://github.com/valtiojs/valtio-history/blob/44dcf22/packages/history-utility/src/index.ts#L122) diff --git a/packages/history-utility/package.json b/packages/history-utility/package.json index 055451d..8c2a177 100644 --- a/packages/history-utility/package.json +++ b/packages/history-utility/package.json @@ -1,6 +1,6 @@ { "name": "valtio-history", - "version": "0.3.3", + "version": "0.3.4", "author": "Daishi Kato", "repository": { "type": "git",