Skip to content

Commit

Permalink
chore: release v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lwhiteley committed Feb 6, 2024
1 parent 0a91bd0 commit 0e57f94
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 50 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ 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.2.1](https://github.com/valtiojs/valtio-history/compare/v0.2.0...v0.2.1)

- refactor: remove barrel export for history utility [`#8`](https://github.com/valtiojs/valtio-history/pull/8)

#### [v0.2.0](https://github.com/valtiojs/valtio-history/compare/v0.1.0...v0.2.0)

> 9 January 2024
- refactor: use `options` as second parameter [`#5`](https://github.com/valtiojs/valtio-history/pull/5)
- feat: add goTo utility [`#4`](https://github.com/valtiojs/valtio-history/pull/4)
- chore: release v0.2.0 [`3f12f1b`](https://github.com/valtiojs/valtio-history/commit/3f12f1b878bc80c4e56b9f457dcf26703957651a)

#### [v0.1.0](https://github.com/valtiojs/valtio-history/compare/v0.0.2...v0.1.0)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "valtio-history",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"author": "Daishi Kato",
"repository": {
Expand Down
95 changes: 47 additions & 48 deletions packages/history-utility/docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`\> | 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`\> | field for holding sandbox changes; used to avoid infinite loops |

#### Defined in

[packages/history-utility/src/history-utility.ts:26](https://github.com/valtiojs/valtio-history/blob/43e2fcd/packages/history-utility/src/history-utility.ts#L26)
[packages/history-utility/src/index.ts:26](https://github.com/valtiojs/valtio-history/blob/0a91bd0/packages/history-utility/src/index.ts#L26)

---
___

### HistoryNode

Expand All @@ -47,36 +47,36 @@
#### 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/history-utility.ts:10](https://github.com/valtiojs/valtio-history/blob/43e2fcd/packages/history-utility/src/history-utility.ts#L10)
[packages/history-utility/src/index.ts:10](https://github.com/valtiojs/valtio-history/blob/0a91bd0/packages/history-utility/src/index.ts#L10)

---
___

### HistoryOptions

Ƭ **HistoryOptions**: `Object`

#### 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/history-utility.ts:43](https://github.com/valtiojs/valtio-history/blob/43e2fcd/packages/history-utility/src/history-utility.ts#L43)
[packages/history-utility/src/index.ts:43](https://github.com/valtiojs/valtio-history/blob/0a91bd0/packages/history-utility/src/index.ts#L43)

## Functions

Expand All @@ -86,7 +86,6 @@

This creates a new proxy with history support (ProxyHistoryObject).
It includes following main properties:<br>

- value: any value (does not have to be an object)<br>
- history: an object holding the history of snapshots and other metadata<br>
- history.index: the history index of the current snapshot<br>
Expand All @@ -109,49 +108,49 @@ Notes: <br>
#### 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

`Object`

proxyObject

| Name | Type | Description |
| :--------------------- | :-------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `canRedo` | () => `boolean` | a function to return true if redo is available |
| `canUndo` | () => `boolean` | a function to return true if undo is available |
| `clone` | \<T\>(`value`: `T`) => `T` | utility to clone a snapshot |
| `getCurrentChangeDate` | () => `undefined` \| `Date` | get the date when a node was entered into history. |
| `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 <br> - history.index: the history index to the current snapshot <br> - history.nodes: the nodes of the history for each change <br> - history.wip: field for holding sandbox changes; used to avoid infinite loops<br> |
| `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. <br> <br> Notes: <br> - No operations are done on the value provided to this utility. <br> - This is an advanced method, please ensure the value provided is a snapshot of the same type of the value being tracked. <br> |
| `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) |
| Name | Type | Description |
| :------ | :------ | :------ |
| `canRedo` | () => `boolean` | a function to return true if redo is available |
| `canUndo` | () => `boolean` | a function to return true if undo is available |
| `clone` | \<T\>(`value`: `T`) => `T` | utility to clone a snapshot |
| `getCurrentChangeDate` | () => `undefined` \| `Date` | get the date when a node was entered into history. |
| `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 <br> - history.index: the history index to the current snapshot <br> - history.nodes: the nodes of the history for each change <br> - history.wip: field for holding sandbox changes; used to avoid infinite loops<br> |
| `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. <br> <br> Notes: <br> - No operations are done on the value provided to this utility. <br> - This is an advanced method, please ensure the value provided is a snapshot of the same type of the value being tracked. <br> |
| `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) |

**`Example`**

```ts
import { proxyWithHistory } from 'valtio-history';
import { proxyWithHistory } from 'valtio-history'
const state = proxyWithHistory({
count: 1,
});
})
```

#### Defined in

[packages/history-utility/src/history-utility.ts:129](https://github.com/valtiojs/valtio-history/blob/43e2fcd/packages/history-utility/src/history-utility.ts#L129)
[packages/history-utility/src/index.ts:129](https://github.com/valtiojs/valtio-history/blob/0a91bd0/packages/history-utility/src/index.ts#L129)
2 changes: 1 addition & 1 deletion packages/history-utility/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "valtio-history",
"version": "0.2.0",
"version": "0.2.1",
"author": "Daishi Kato",
"repository": {
"type": "git",
Expand Down

0 comments on commit 0e57f94

Please sign in to comment.