valtio-history 0.0.2 → 0.2.0

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.
package/README.md CHANGED
@@ -6,6 +6,8 @@ valtio utility for creating a proxy state with history tracking
6
6
 
7
7
  https://valtio.pmnd.rs/docs/api/utils/proxyWithHistory
8
8
 
9
+ see detailed [api docs](https://github.com/valtiojs/valtio-history/blob/main/packages/history-utility/docs/modules.md) for more info.
10
+
9
11
  ---
10
12
 
11
13
  ## Migrating from `valtio/utils`
@@ -35,7 +37,10 @@ export default function App() {
35
37
  history,
36
38
  canUndo,
37
39
  canRedo,
38
- getCurrentChangeDate
40
+ getCurrentChangeDate,
41
+ getNode,
42
+ remove,
43
+ replace,
39
44
  } = useSnapshot(state);
40
45
 
41
46
  ...
@@ -46,4 +51,5 @@ export default function App() {
46
51
 
47
52
  - the `history` object has changes
48
53
  - `history.snapshots` is renamed to `history.nodes`
49
- - a `HistoryNode` has the structure `{ createdAt: Date; snapshot: Snapshot<T> }`
54
+ - a `HistoryNode` has the structure `{ snapshot: Snapshot<T>; createdAt: Date; updatedAt?: Date; }`
55
+ - The second parameter of `proxyWithHistory` is now an object instead of a `boolean`. `{ skipSubscribe?: boolean }`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valtio-history",
3
- "version": "0.0.2",
3
+ "version": "0.2.0",
4
4
  "author": "Daishi Kato",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,8 @@
21
21
  "peerDependencies": {
22
22
  "valtio": ">=1.0.0"
23
23
  },
24
- "type": "commonjs",
24
+ "type": "module",
25
25
  "main": "./src/index.js",
26
- "typings": "./src/index.d.ts"
26
+ "typings": "./src/index.d.ts",
27
+ "module": "./src/index.js"
27
28
  }
@@ -1,32 +1,64 @@
1
1
  import type { INTERNAL_Snapshot as Snapshot } from 'valtio/vanilla';
2
2
  export type HistoryNode<T> = {
3
- createdAt: Date;
3
+ /**
4
+ * The snapshot being tracked
5
+ */
4
6
  snapshot: Snapshot<T>;
7
+ /**
8
+ * The date when the node was created
9
+ */
10
+ createdAt: Date;
11
+ /**
12
+ * The date when the node was updated. Will be undefined if
13
+ * the node was never updated.
14
+ */
15
+ updatedAt?: Date;
5
16
  };
6
17
  export type History<T> = {
18
+ /**
19
+ * field for holding sandbox changes; used to avoid infinite loops
20
+ */
7
21
  wip?: Snapshot<T>;
22
+ /**
23
+ * the nodes of the history for each change
24
+ */
8
25
  nodes: HistoryNode<T>[];
26
+ /**
27
+ * the history index of the current snapshot
28
+ */
9
29
  index: number;
10
30
  };
31
+ export type HistoryOptions = {
32
+ /**
33
+ * determines if the internal subscribe behaviour should be skipped.
34
+ */
35
+ skipSubscribe?: boolean;
36
+ };
11
37
  /**
12
- * proxyWithHistory
38
+ * This creates a new proxy with history support (ProxyHistoryObject).
39
+ * It includes following main properties:<br>
40
+ * - value: any value (does not have to be an object)<br>
41
+ * - history: an object holding the history of snapshots and other metadata<br>
42
+ * - history.index: the history index of the current snapshot<br>
43
+ * - history.nodes: the nodes of the history for each change<br>
44
+ * - history.wip: field for holding sandbox changes; used to avoid infinite loops<br>
45
+ * - canUndo: a function to return true if undo is available <br>
46
+ * - undo: a function to go back history <br>
47
+ * - canRedo: a function to return true if redo is available <br>
48
+ * - redo: a function to go forward history <br>
49
+ * - saveHistory: a function to save history <br>
50
+ * - getCurrentChangeDate: gets the date of the current change <br>
51
+ * - remove: a function to remove a specified history index <br>
52
+ * - replace: a function to replace a snapshot at a specified history index <br>
53
+ * - getNode: a function to get the node at a specified history index <br>
13
54
  *
14
- * This creates a new proxy with history support.
15
- * It includes following properties:
16
- * - value: any value (does not have to be an object)
17
- * - history: an object holding the history of snapshots and other metadata
18
- * - history.index: the history index to the current snapshot
19
- * - history.nodes: the nodes of the history for each change
20
- * - history.wip: field for holding sandbox changes; used to avoid infinite loops
21
- * - canUndo: a function to return true if undo is available
22
- * - undo: a function to go back history
23
- * - canRedo: a function to return true if redo is available
24
- * - redo: a function to go forward history
25
- * - saveHistory: a function to save history
26
- * - getCurrentChangeDate: gets the date of the current change
55
+ * <br>
56
+ * Notes: <br>
57
+ * - Suspense/promise is not supported. <br>
27
58
  *
28
- * [Notes]
29
- * - Suspense/promise is not supported.
59
+ * @param initialValue - any value to be tracked
60
+ * @param options - use to configure the proxyWithHistory utility.
61
+ * @returns proxyObject
30
62
  *
31
63
  * @example
32
64
  * import { proxyWithHistory } from 'valtio-history'
@@ -34,17 +66,135 @@ export type History<T> = {
34
66
  * count: 1,
35
67
  * })
36
68
  */
37
- export declare function proxyWithHistory<V>(initialValue: V, skipSubscribe?: boolean): {
69
+ export declare function proxyWithHistory<V>(initialValue: V, options?: HistoryOptions | boolean): {
70
+ /**
71
+ * any value to be tracked (does not have to be an object)
72
+ */
38
73
  value: V;
74
+ /**
75
+ * an object holding the history of snapshots and other metadata <br>
76
+ * - history.index: the history index to the current snapshot <br>
77
+ * - history.nodes: the nodes of the history for each change <br>
78
+ * - history.wip: field for holding sandbox changes; used to avoid infinite loops<br>
79
+ */
39
80
  history: History<V> & {
40
81
  $$valtioRef: true;
41
82
  };
42
- getCurrentChangeDate: () => Date;
43
- clone: <T>(value: T) => T;
83
+ /**
84
+ * get the date when a node was entered into history.
85
+ *
86
+ * @returns date
87
+ */
88
+ getCurrentChangeDate: () => Date | undefined;
89
+ /**
90
+ * utility method to get a history node.
91
+ * The snapshot within this node is already cloned and
92
+ * will not affect the original value if updated.
93
+ *
94
+ * @param index
95
+ * @returns historyNode
96
+ */
97
+ getNode: (index: number) => {
98
+ snapshot: V extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
99
+ $$valtioRef: true;
100
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? V : V extends Promise<unknown> ? Awaited<V> : V extends object ? { readonly [K in keyof V]: V[K] extends infer T ? T extends V[K] ? T extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
101
+ $$valtioRef: true;
102
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T : T extends Promise<unknown> ? Awaited<T> : T extends object ? { readonly [K_1 in keyof T]: T[K_1] extends infer T_1 ? T_1 extends T[K_1] ? T_1 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
103
+ $$valtioRef: true;
104
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_1 : T_1 extends Promise<unknown> ? Awaited<T_1> : T_1 extends object ? { readonly [K_2 in keyof T_1]: T_1[K_2] extends infer T_2 ? T_2 extends T_1[K_2] ? T_2 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
105
+ $$valtioRef: true;
106
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_2 : T_2 extends Promise<unknown> ? Awaited<T_2> : T_2 extends object ? { readonly [K_3 in keyof T_2]: T_2[K_3] extends infer T_3 ? T_3 extends T_2[K_3] ? T_3 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
107
+ $$valtioRef: true;
108
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_3 : T_3 extends Promise<unknown> ? Awaited<T_3> : T_3 extends object ? { readonly [K_4 in keyof T_3]: T_3[K_4] extends infer T_4 ? T_4 extends T_3[K_4] ? T_4 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
109
+ $$valtioRef: true;
110
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_4 : T_4 extends Promise<unknown> ? Awaited<T_4> : T_4 extends object ? { readonly [K_5 in keyof T_4]: T_4[K_5] extends infer T_5 ? T_5 extends T_4[K_5] ? T_5 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
111
+ $$valtioRef: true;
112
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_5 : T_5 extends Promise<unknown> ? Awaited<T_5> : T_5 extends object ? { readonly [K_6 in keyof T_5]: T_5[K_6] extends infer T_6 ? T_6 extends T_5[K_6] ? T_6 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
113
+ $$valtioRef: true;
114
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_6 : T_6 extends Promise<unknown> ? Awaited<T_6> : T_6 extends object ? { readonly [K_7 in keyof T_6]: T_6[K_7] extends infer T_7 ? T_7 extends T_6[K_7] ? T_7 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
115
+ $$valtioRef: true;
116
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_7 : T_7 extends Promise<unknown> ? Awaited<T_7> : T_7 extends object ? { readonly [K_8 in keyof T_7]: T_7[K_8] extends infer T_8 ? T_8 extends T_7[K_8] ? T_8 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
117
+ $$valtioRef: true;
118
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_8 : T_8 extends Promise<unknown> ? Awaited<T_8> : T_8 extends object ? { readonly [K_9 in keyof T_8]: T_8[K_9] extends infer T_9 ? T_9 extends T_8[K_9] ? T_9 extends RegExp | Date | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | {
119
+ $$valtioRef: true;
120
+ } | Error | ((...args: any[]) => any) | (string | number | bigint | boolean | symbol | null | undefined) ? T_9 : T_9 extends Promise<unknown> ? Awaited<T_9> : T_9 extends object ? { readonly [K_10 in keyof T_9]: any; } : T_9 : never : never; } : T_8 : never : never; } : T_7 : never : never; } : T_6 : never : never; } : T_5 : never : never; } : T_4 : never : never; } : T_3 : never : never; } : T_2 : never : never; } : T_1 : never : never; } : T : never : never; } : V;
121
+ /**
122
+ * The date when the node was created
123
+ */
124
+ createdAt: Date;
125
+ /**
126
+ * The date when the node was updated. Will be undefined if
127
+ * the node was never updated.
128
+ */
129
+ updatedAt?: Date | undefined;
130
+ } | undefined;
131
+ /**
132
+ * utility to clone a snapshot
133
+ */
134
+ clone: <T_10>(value: T_10) => T_10;
135
+ /**
136
+ * a function to go to a specific index in history
137
+ */
138
+ goTo: (index: number) => void;
139
+ /**
140
+ * a function to return true if undo is available
141
+ * @returns boolean
142
+ */
44
143
  canUndo: () => boolean;
144
+ /**
145
+ * a function to go back in history
146
+ */
45
147
  undo: () => void;
148
+ /**
149
+ * a function to return true if redo is available
150
+ * @returns boolean
151
+ */
46
152
  canRedo: () => boolean;
153
+ /**
154
+ * a function to go forward in history
155
+ */
47
156
  redo: () => void;
157
+ /**
158
+ * a function to execute saving history when changes are made to `value`
159
+ */
48
160
  saveHistory: () => void;
161
+ /**
162
+ * a function that returns true when the history should be updated
163
+ *
164
+ * @param ops - subscribeOps from subscribe callback
165
+ * @returns boolean
166
+ */
167
+ shouldSaveHistory: (ops: ([op: "set", path: (string | symbol)[], value: unknown, prevValue: unknown] | [op: "delete", path: (string | symbol)[], prevValue: unknown] | [op: "resolve", path: (string | symbol)[], value: unknown] | [op: "reject", path: (string | symbol)[], error: unknown])[]) => boolean;
168
+ /**
169
+ * a function to subscribe to changes made to `value`
170
+ */
49
171
  subscribe: () => () => void;
172
+ /**
173
+ * The remove method is only invoked when there are
174
+ * more than one nodes and when a valid index is provided.
175
+ * If the current index is removed,
176
+ * An index greater than the current index will be preferred as the next
177
+ * value.
178
+ *
179
+ * @param index - index of the node to remove
180
+ * @returns removedNode
181
+ */
182
+ remove: (index: number) => HistoryNode<V> | undefined;
183
+ /**
184
+ * utility to replace a value in history. The history
185
+ * changes will not be affected, only the value to be replaced.
186
+ * If a base value is needed to operate on,
187
+ * the `getNode` utility can be used to retrieve
188
+ * a cloned historyNode.
189
+ *
190
+ * <br> <br>
191
+ * Notes: <br>
192
+ * - No operations are done on the value provided to this utility. <br>
193
+ * - This is an advanced method, please ensure the value provided
194
+ * is a snapshot of the same type of the value being tracked. <br>
195
+ *
196
+ * @param index - index to replace value for
197
+ * @param value - the updated snapshot to be stored at the index
198
+ */
199
+ replace: (index: number, value: Snapshot<V>) => void;
50
200
  };
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.proxyWithHistory = void 0;
4
- const vanilla_1 = require("valtio/vanilla");
1
+ import { unstable_buildProxyFunction as buildProxyFunction, proxy, ref, snapshot, subscribe, } from 'valtio/vanilla';
5
2
  const isObject = (value) => !!value && typeof value === 'object';
6
3
  let refSet;
7
4
  const deepClone = (value) => {
8
5
  if (!refSet) {
9
- refSet = (0, vanilla_1.unstable_buildProxyFunction)()[2];
6
+ refSet = buildProxyFunction()[2];
10
7
  }
11
8
  if (!isObject(value) || refSet.has(value)) {
12
9
  return value;
@@ -19,25 +16,52 @@ const deepClone = (value) => {
19
16
  });
20
17
  return baseObject;
21
18
  };
19
+ const normalizeOptions = (options) => {
20
+ if (typeof options === 'boolean') {
21
+ if (import.meta.env?.MODE !== 'production') {
22
+ console.warn(`The second parameter of 'proxyWithHistory' as boolean is deprecated and support for boolean will be removed
23
+ in the next major version. Please use the object syntax instead:
24
+
25
+ { skipSubscribe: boolean }
26
+ `);
27
+ }
28
+ return { skipSubscribe: options };
29
+ }
30
+ const defaultOptions = {
31
+ skipSubscribe: false,
32
+ };
33
+ if (!options)
34
+ return defaultOptions;
35
+ return {
36
+ ...defaultOptions,
37
+ ...options,
38
+ };
39
+ };
22
40
  /**
23
- * proxyWithHistory
41
+ * This creates a new proxy with history support (ProxyHistoryObject).
42
+ * It includes following main properties:<br>
43
+ * - value: any value (does not have to be an object)<br>
44
+ * - history: an object holding the history of snapshots and other metadata<br>
45
+ * - history.index: the history index of the current snapshot<br>
46
+ * - history.nodes: the nodes of the history for each change<br>
47
+ * - history.wip: field for holding sandbox changes; used to avoid infinite loops<br>
48
+ * - canUndo: a function to return true if undo is available <br>
49
+ * - undo: a function to go back history <br>
50
+ * - canRedo: a function to return true if redo is available <br>
51
+ * - redo: a function to go forward history <br>
52
+ * - saveHistory: a function to save history <br>
53
+ * - getCurrentChangeDate: gets the date of the current change <br>
54
+ * - remove: a function to remove a specified history index <br>
55
+ * - replace: a function to replace a snapshot at a specified history index <br>
56
+ * - getNode: a function to get the node at a specified history index <br>
24
57
  *
25
- * This creates a new proxy with history support.
26
- * It includes following properties:
27
- * - value: any value (does not have to be an object)
28
- * - history: an object holding the history of snapshots and other metadata
29
- * - history.index: the history index to the current snapshot
30
- * - history.nodes: the nodes of the history for each change
31
- * - history.wip: field for holding sandbox changes; used to avoid infinite loops
32
- * - canUndo: a function to return true if undo is available
33
- * - undo: a function to go back history
34
- * - canRedo: a function to return true if redo is available
35
- * - redo: a function to go forward history
36
- * - saveHistory: a function to save history
37
- * - getCurrentChangeDate: gets the date of the current change
58
+ * <br>
59
+ * Notes: <br>
60
+ * - Suspense/promise is not supported. <br>
38
61
  *
39
- * [Notes]
40
- * - Suspense/promise is not supported.
62
+ * @param initialValue - any value to be tracked
63
+ * @param options - use to configure the proxyWithHistory utility.
64
+ * @returns proxyObject
41
65
  *
42
66
  * @example
43
67
  * import { proxyWithHistory } from 'valtio-history'
@@ -45,53 +69,184 @@ const deepClone = (value) => {
45
69
  * count: 1,
46
70
  * })
47
71
  */
48
- function proxyWithHistory(initialValue, skipSubscribe = false) {
49
- const proxyObject = (0, vanilla_1.proxy)({
72
+ export function proxyWithHistory(initialValue, options) {
73
+ const utilOptions = normalizeOptions(options);
74
+ const proxyObject = proxy({
75
+ /**
76
+ * any value to be tracked (does not have to be an object)
77
+ */
50
78
  value: initialValue,
51
- history: (0, vanilla_1.ref)({
79
+ /**
80
+ * an object holding the history of snapshots and other metadata <br>
81
+ * - history.index: the history index to the current snapshot <br>
82
+ * - history.nodes: the nodes of the history for each change <br>
83
+ * - history.wip: field for holding sandbox changes; used to avoid infinite loops<br>
84
+ */
85
+ history: ref({
52
86
  wip: undefined,
53
87
  nodes: [],
54
88
  index: -1,
55
89
  }),
90
+ /**
91
+ * get the date when a node was entered into history.
92
+ *
93
+ * @returns date
94
+ */
56
95
  getCurrentChangeDate: () => {
57
96
  const node = proxyObject.history.nodes[proxyObject.history.index];
58
- return node === null || node === void 0 ? void 0 : node.createdAt;
97
+ return node?.createdAt;
98
+ },
99
+ /**
100
+ * utility method to get a history node.
101
+ * The snapshot within this node is already cloned and
102
+ * will not affect the original value if updated.
103
+ *
104
+ * @param index
105
+ * @returns historyNode
106
+ */
107
+ getNode: (index) => {
108
+ const node = proxyObject.history.nodes[index];
109
+ return node
110
+ ? { ...node, snapshot: proxyObject.clone(node.snapshot) }
111
+ : undefined;
59
112
  },
113
+ /**
114
+ * utility to clone a snapshot
115
+ */
60
116
  clone: deepClone,
117
+ /**
118
+ * a function to go to a specific index in history
119
+ */
120
+ goTo: (index) => {
121
+ const node = proxyObject.history.nodes[index];
122
+ if (!node)
123
+ return;
124
+ proxyObject.history.wip = proxyObject.clone(node.snapshot);
125
+ proxyObject.value = proxyObject.history.wip;
126
+ proxyObject.history.index = index;
127
+ },
128
+ /**
129
+ * a function to return true if undo is available
130
+ * @returns boolean
131
+ */
61
132
  canUndo: () => proxyObject.history.index > 0,
133
+ /**
134
+ * a function to go back in history
135
+ */
62
136
  undo: () => {
63
- var _a;
64
137
  if (proxyObject.canUndo()) {
65
- proxyObject.value = (proxyObject.history.wip = proxyObject.clone((_a = proxyObject.history.nodes[--proxyObject.history.index]) === null || _a === void 0 ? void 0 : _a.snapshot));
138
+ proxyObject.history.wip = proxyObject.clone(proxyObject.history.nodes[--proxyObject.history.index]?.snapshot);
139
+ proxyObject.value = proxyObject.history.wip;
66
140
  }
67
141
  },
142
+ /**
143
+ * a function to return true if redo is available
144
+ * @returns boolean
145
+ */
68
146
  canRedo: () => proxyObject.history.index < proxyObject.history.nodes.length - 1,
147
+ /**
148
+ * a function to go forward in history
149
+ */
69
150
  redo: () => {
70
- var _a;
71
151
  if (proxyObject.canRedo()) {
72
- proxyObject.value = (proxyObject.history.wip = proxyObject.clone((_a = proxyObject.history.nodes[++proxyObject.history.index]) === null || _a === void 0 ? void 0 : _a.snapshot));
152
+ proxyObject.history.wip = proxyObject.clone(proxyObject.history.nodes[++proxyObject.history.index]?.snapshot);
153
+ proxyObject.value = proxyObject.history.wip;
73
154
  }
74
155
  },
156
+ /**
157
+ * a function to execute saving history when changes are made to `value`
158
+ */
75
159
  saveHistory: () => {
76
160
  proxyObject.history.nodes.splice(proxyObject.history.index + 1);
77
161
  proxyObject.history.nodes.push({
78
162
  createdAt: new Date(),
79
- snapshot: (0, vanilla_1.snapshot)(proxyObject).value,
163
+ snapshot: snapshot(proxyObject).value,
80
164
  });
81
165
  ++proxyObject.history.index;
82
166
  },
83
- subscribe: () => (0, vanilla_1.subscribe)(proxyObject, (ops) => {
84
- if (ops.every((op) => op[1][0] === 'value' &&
85
- (op[0] !== 'set' || op[2] !== proxyObject.history.wip))) {
167
+ /**
168
+ * a function that returns true when the history should be updated
169
+ *
170
+ * @param ops - subscribeOps from subscribe callback
171
+ * @returns boolean
172
+ */
173
+ shouldSaveHistory: (ops) => ops.every((op) => op[1][0] === 'value' &&
174
+ (op[0] !== 'set' || op[2] !== proxyObject.history.wip)),
175
+ /**
176
+ * a function to subscribe to changes made to `value`
177
+ */
178
+ subscribe: () => subscribe(proxyObject, (ops) => {
179
+ if (proxyObject.shouldSaveHistory(ops))
86
180
  proxyObject.saveHistory();
87
- }
88
181
  }),
182
+ // history rewrite utilities
183
+ /**
184
+ * The remove method is only invoked when there are
185
+ * more than one nodes and when a valid index is provided.
186
+ * If the current index is removed,
187
+ * An index greater than the current index will be preferred as the next
188
+ * value.
189
+ *
190
+ * @param index - index of the node to remove
191
+ * @returns removedNode
192
+ */
193
+ remove: (index) => {
194
+ const node = proxyObject.history.nodes[index];
195
+ const isCurrentIndex = proxyObject.history.index === index;
196
+ const lastIndex = proxyObject.history.nodes.length - 1;
197
+ const isLastIndex = lastIndex === index;
198
+ if (!node || proxyObject.history.nodes.length < 2)
199
+ return;
200
+ if (isCurrentIndex) {
201
+ const resolvedIndex = isLastIndex ? index - 1 : index + 1;
202
+ const resolvedNode = proxyObject.history.nodes[resolvedIndex];
203
+ proxyObject.history.wip = proxyObject.clone(resolvedNode?.snapshot);
204
+ proxyObject.value = proxyObject.history.wip;
205
+ if (isLastIndex)
206
+ proxyObject.history.index--;
207
+ }
208
+ proxyObject.history.nodes.splice(index, 1);
209
+ if (!isCurrentIndex && proxyObject.history.index > index) {
210
+ proxyObject.history.index--;
211
+ }
212
+ return node;
213
+ },
214
+ /**
215
+ * utility to replace a value in history. The history
216
+ * changes will not be affected, only the value to be replaced.
217
+ * If a base value is needed to operate on,
218
+ * the `getNode` utility can be used to retrieve
219
+ * a cloned historyNode.
220
+ *
221
+ * <br> <br>
222
+ * Notes: <br>
223
+ * - No operations are done on the value provided to this utility. <br>
224
+ * - This is an advanced method, please ensure the value provided
225
+ * is a snapshot of the same type of the value being tracked. <br>
226
+ *
227
+ * @param index - index to replace value for
228
+ * @param value - the updated snapshot to be stored at the index
229
+ */
230
+ replace: (index, value) => {
231
+ const node = proxyObject.history.nodes[index];
232
+ const isCurrentIndex = proxyObject.history.index === index;
233
+ if (!node)
234
+ return;
235
+ proxyObject.history.nodes[index] = {
236
+ ...node,
237
+ snapshot: value,
238
+ updatedAt: new Date(),
239
+ };
240
+ if (isCurrentIndex) {
241
+ proxyObject.history.wip = value;
242
+ proxyObject.value = proxyObject.history.wip;
243
+ }
244
+ },
89
245
  });
90
246
  proxyObject.saveHistory();
91
- if (!skipSubscribe) {
247
+ if (!utilOptions.skipSubscribe) {
92
248
  proxyObject.subscribe();
93
249
  }
94
250
  return proxyObject;
95
251
  }
96
- exports.proxyWithHistory = proxyWithHistory;
97
252
  //# sourceMappingURL=history-utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"history-utility.js","sourceR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AA,kBAAQ,EAAC,WAAW,CAAC,CAAC,KAAK;aACtC,CAAC,CAAC;YACH,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;QAC9B,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CACd,IAAA,mBAAS,EAAC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE;YAC7B,IACE,GAAG,CAAC,KAAK,CACP,CAAC,EAAE,EAAE,EAAE,CACL,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO;gBACpB,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CACzD,EACD;gBACA,WAAW,CAAC,WAAW,EAAE,CAAC;aAC3B;QACH,CAAC,CAAC;KACL,CAAC,CAAC;IAEH,WAAW,CAAC,WAAW,EAAE,CAAC;IAE1B,IAAI,CAAC,aAAa,EAAE;QAClB,WAAW,CAAC,SAAS,EAAE,CAAC;KACzB;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AA3DD,4CA2DC"}
1
+ {"version":3,"file":"history-utility.js","sourceRoot":"","sources":["../../../../packages/history-utility/src/history-utility.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,IAAI,kBAAkB,EACjD,KAAK,EACL,GAAG,EACH,QAAQ,EACR,SAAS,GACV,MAAM,gBAAgB,CAAC;AA2CxB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CACnD,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAEvC,IAAI,MAAmC,CAAC;AAExC,MAAM,SAAS,GAAG,CAAI,KAAQ,EAAK,EAAE;IACnC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,GAAG,kBAAkB,EAAE,CAAC,CAAC,CAAC,CAAC;KAClC;IACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC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C;aAC9C;YAED,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAE3C,IAAI,CAAC,cAAc,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,EAAE;gBACxD,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;aAC7B;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;;;;;;;;;;;;WAeG;QACH,OAAO,EAAE,CAAC,KAAa,EAAE,KAAkB,EAAE,EAAE;YAC7C,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC9C,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC;YAE3D,IAAI,CAAC,IAAI;gBAAE,OAAO;YAElB,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG;gBACjC,GAAG,IAAI;gBACP,QAAQ,EAAE,KAAK;gBACf,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC;YAEF,IAAI,cAAc,EAAE;gBAClB,WAAW,CAAC,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;gBAChC,WAAW,CAAC,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,GAAQ,CAAC;aAClD;QACH,CAAC;KACF,CAAC,CAAC;IAEH,WAAW,CAAC,WAAW,EAAE,CAAC;IAE1B,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE;QAC9B,WAAW,CAAC,SAAS,EAAE,CAAC;KACzB;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
package/src/index.js CHANGED
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./history-utility"), exports);
1
+ export * from './history-utility';
5
2
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/history-utility/src/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/history-utility/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,235 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const react_2 = require("@testing-library/react");
7
- const valtio_1 = require("valtio");
8
- const vitest_1 = require("vitest");
9
- const history_utility_1 = require("./history-utility");
10
- (0, vitest_1.describe)('proxyWithHistory', () => {
11
- (0, vitest_1.it)('should provide basic history functionality', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
12
- const state = (0, history_utility_1.proxyWithHistory)({ count: 0 });
13
- yield Promise.resolve();
14
- (0, vitest_1.expect)(state.value.count).toEqual(0);
15
- state.value.count += 1;
16
- yield Promise.resolve();
17
- (0, vitest_1.expect)(state.value.count).toEqual(1);
18
- state.undo();
19
- yield Promise.resolve();
20
- (0, vitest_1.expect)(state.value.count).toEqual(0);
21
- state.redo();
22
- yield Promise.resolve();
23
- (0, vitest_1.expect)(state.value.count).toEqual(1);
24
- }));
25
- (0, vitest_1.it)('should provide basic sequential undo functionality', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
26
- const state = (0, history_utility_1.proxyWithHistory)({ count: 0 });
27
- yield Promise.resolve();
28
- (0, vitest_1.expect)(state.value.count).toEqual(0);
29
- (0, vitest_1.expect)(state.canRedo()).toEqual(false);
30
- (0, vitest_1.expect)(state.canUndo()).toEqual(false);
31
- state.value.count += 1;
32
- yield Promise.resolve();
33
- (0, vitest_1.expect)(state.value.count).toEqual(1);
34
- (0, vitest_1.expect)(state.canRedo()).toEqual(false);
35
- (0, vitest_1.expect)(state.canUndo()).toEqual(true);
36
- state.value.count += 1;
37
- yield Promise.resolve();
38
- (0, vitest_1.expect)(state.value.count).toEqual(2);
39
- (0, vitest_1.expect)(state.canRedo()).toEqual(false);
40
- (0, vitest_1.expect)(state.canUndo()).toEqual(true);
41
- state.undo();
42
- yield Promise.resolve();
43
- (0, vitest_1.expect)(state.value.count).toEqual(1);
44
- (0, vitest_1.expect)(state.canRedo()).toEqual(true);
45
- (0, vitest_1.expect)(state.canUndo()).toEqual(true);
46
- state.undo();
47
- yield Promise.resolve();
48
- (0, vitest_1.expect)(state.value.count).toEqual(0);
49
- (0, vitest_1.expect)(state.canRedo()).toEqual(true);
50
- (0, vitest_1.expect)(state.canUndo()).toEqual(false);
51
- }));
52
- (0, vitest_1.it)('should provide basic sequential redo functionality', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
53
- const state = (0, history_utility_1.proxyWithHistory)({ count: 0 });
54
- state.value.count += 1;
55
- yield Promise.resolve();
56
- state.value.count += 1;
57
- yield Promise.resolve();
58
- state.value.count += 1;
59
- yield Promise.resolve();
60
- state.undo();
61
- yield Promise.resolve();
62
- state.undo();
63
- yield Promise.resolve();
64
- state.undo();
65
- yield Promise.resolve();
66
- (0, vitest_1.expect)(state.value.count).toEqual(0);
67
- (0, vitest_1.expect)(state.canRedo()).toEqual(true);
68
- (0, vitest_1.expect)(state.canUndo()).toEqual(false);
69
- state.redo();
70
- yield Promise.resolve();
71
- (0, vitest_1.expect)(state.value.count).toEqual(1);
72
- (0, vitest_1.expect)(state.canRedo()).toEqual(true);
73
- (0, vitest_1.expect)(state.canUndo()).toEqual(true);
74
- state.redo();
75
- yield Promise.resolve();
76
- (0, vitest_1.expect)(state.value.count).toEqual(2);
77
- (0, vitest_1.expect)(state.canRedo()).toEqual(true);
78
- (0, vitest_1.expect)(state.canUndo()).toEqual(true);
79
- state.redo();
80
- yield Promise.resolve();
81
- (0, vitest_1.expect)(state.value.count).toEqual(3);
82
- (0, vitest_1.expect)(state.canRedo()).toEqual(false);
83
- (0, vitest_1.expect)(state.canUndo()).toEqual(true);
84
- }));
85
- });
86
- (0, vitest_1.describe)('proxyWithHistory react', () => {
87
- (0, vitest_1.it)('should do simple count', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
88
- const state = (0, history_utility_1.proxyWithHistory)(0);
89
- const Counter = () => {
90
- const snap = (0, valtio_1.useSnapshot)(state);
91
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: ["count: ", snap.value] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => ++state.value, children: "inc" }), (0, jsx_runtime_1.jsx)("button", { onClick: snap.undo, children: "undo" }), (0, jsx_runtime_1.jsx)("button", { onClick: snap.redo, children: "redo" })] }));
92
- };
93
- const { getByText, findByText } = (0, react_2.render)((0, jsx_runtime_1.jsx)(react_1.StrictMode, { children: (0, jsx_runtime_1.jsx)(Counter, {}) }));
94
- yield findByText('count: 0');
95
- react_2.fireEvent.click(getByText('inc'));
96
- yield findByText('count: 1');
97
- react_2.fireEvent.click(getByText('inc'));
98
- yield findByText('count: 2');
99
- react_2.fireEvent.click(getByText('inc'));
100
- yield findByText('count: 3');
101
- react_2.fireEvent.click(getByText('undo'));
102
- yield findByText('count: 2');
103
- react_2.fireEvent.click(getByText('redo'));
104
- yield findByText('count: 3');
105
- react_2.fireEvent.click(getByText('undo'));
106
- yield findByText('count: 2');
107
- react_2.fireEvent.click(getByText('undo'));
108
- yield findByText('count: 1');
109
- react_2.fireEvent.click(getByText('undo'));
110
- yield findByText('count: 0');
111
- react_2.fireEvent.click(getByText('inc'));
112
- yield findByText('count: 1');
113
- react_2.fireEvent.click(getByText('undo'));
114
- yield findByText('count: 0');
115
- }));
116
- (0, vitest_1.it)('should count in object', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
117
- const state = (0, history_utility_1.proxyWithHistory)({ count: 0 });
118
- const Counter = () => {
119
- const snap = (0, valtio_1.useSnapshot)(state);
120
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: ["count: ", snap.value.count] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => ++state.value.count, children: "inc" }), (0, jsx_runtime_1.jsx)("button", { onClick: snap.undo, children: "undo" }), (0, jsx_runtime_1.jsx)("button", { onClick: snap.redo, children: "redo" })] }));
121
- };
122
- const { getByText, findByText } = (0, react_2.render)((0, jsx_runtime_1.jsx)(react_1.StrictMode, { children: (0, jsx_runtime_1.jsx)(Counter, {}) }));
123
- yield findByText('count: 0');
124
- react_2.fireEvent.click(getByText('inc'));
125
- yield findByText('count: 1');
126
- react_2.fireEvent.click(getByText('inc'));
127
- yield findByText('count: 2');
128
- react_2.fireEvent.click(getByText('inc'));
129
- yield findByText('count: 3');
130
- react_2.fireEvent.click(getByText('undo'));
131
- yield findByText('count: 2');
132
- react_2.fireEvent.click(getByText('redo'));
133
- yield findByText('count: 3');
134
- react_2.fireEvent.click(getByText('undo'));
135
- yield findByText('count: 2');
136
- react_2.fireEvent.click(getByText('undo'));
137
- yield findByText('count: 1');
138
- react_2.fireEvent.click(getByText('undo'));
139
- yield findByText('count: 0');
140
- react_2.fireEvent.click(getByText('inc'));
141
- yield findByText('count: 1');
142
- react_2.fireEvent.click(getByText('undo'));
143
- yield findByText('count: 0');
144
- }));
145
- (0, vitest_1.it)('should count in nested object', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
146
- const state = (0, history_utility_1.proxyWithHistory)({ nested: { count: 0 } });
147
- const Counter = () => {
148
- const snap = (0, valtio_1.useSnapshot)(state);
149
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: ["count: ", snap.value.nested.count] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => ++state.value.nested.count, children: "inc" }), (0, jsx_runtime_1.jsx)("button", { onClick: snap.undo, children: "undo" }), (0, jsx_runtime_1.jsx)("button", { onClick: snap.redo, children: "redo" })] }));
150
- };
151
- const { getByText, findByText } = (0, react_2.render)((0, jsx_runtime_1.jsx)(react_1.StrictMode, { children: (0, jsx_runtime_1.jsx)(Counter, {}) }));
152
- yield findByText('count: 0');
153
- react_2.fireEvent.click(getByText('inc'));
154
- yield findByText('count: 1');
155
- react_2.fireEvent.click(getByText('inc'));
156
- yield findByText('count: 2');
157
- react_2.fireEvent.click(getByText('inc'));
158
- yield findByText('count: 3');
159
- react_2.fireEvent.click(getByText('undo'));
160
- yield findByText('count: 2');
161
- react_2.fireEvent.click(getByText('redo'));
162
- yield findByText('count: 3');
163
- react_2.fireEvent.click(getByText('undo'));
164
- yield findByText('count: 2');
165
- react_2.fireEvent.click(getByText('undo'));
166
- yield findByText('count: 1');
167
- react_2.fireEvent.click(getByText('undo'));
168
- yield findByText('count: 0');
169
- react_2.fireEvent.click(getByText('inc'));
170
- yield findByText('count: 1');
171
- react_2.fireEvent.click(getByText('undo'));
172
- yield findByText('count: 0');
173
- }));
174
- (0, vitest_1.it)('should do multiple redos at once (#323)', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
175
- const state = (0, history_utility_1.proxyWithHistory)({ nested: { count: 0 } });
176
- const Counter = () => {
177
- const snap = (0, valtio_1.useSnapshot)(state);
178
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: ["count: ", snap.value.nested.count] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => ++state.value.nested.count, children: "inc" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
179
- state.undo();
180
- state.undo();
181
- }, children: "undo twice" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
182
- state.redo();
183
- state.redo();
184
- }, children: "redo twice" })] }));
185
- };
186
- const { getByText, findByText } = (0, react_2.render)((0, jsx_runtime_1.jsx)(react_1.StrictMode, { children: (0, jsx_runtime_1.jsx)(Counter, {}) }));
187
- yield findByText('count: 0');
188
- react_2.fireEvent.click(getByText('inc'));
189
- yield findByText('count: 1');
190
- react_2.fireEvent.click(getByText('inc'));
191
- yield findByText('count: 2');
192
- react_2.fireEvent.click(getByText('undo twice'));
193
- yield findByText('count: 0');
194
- react_2.fireEvent.click(getByText('redo twice'));
195
- yield findByText('count: 2');
196
- }));
197
- (0, vitest_1.it)('should update with nested arrays (#516)', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
198
- const state = (0, history_utility_1.proxyWithHistory)({
199
- level0Values: [{ level1Values: [0, 1] }, { level1Values: [2, 3] }],
200
- });
201
- const NestedArray = () => {
202
- const snap = (0, valtio_1.useSnapshot)(state);
203
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { children: ["values: ", JSON.stringify(snap.value)] }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
204
- state.undo();
205
- }, children: "undo" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
206
- if (state.value.level0Values[1]) {
207
- state.value.level0Values[1].level1Values[0] = 10;
208
- }
209
- }, children: "change 2 to 10" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
210
- if (state.value.level0Values[1]) {
211
- state.value.level0Values[1].level1Values[0] = 11;
212
- }
213
- }, children: "change 10 to 11" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
214
- if (state.value.level0Values[0]) {
215
- state.value.level0Values[0].level1Values[0] = 12;
216
- }
217
- }, children: "change 0 to 12" })] }));
218
- };
219
- const { getByText, findByText } = (0, react_2.render)((0, jsx_runtime_1.jsx)(react_1.StrictMode, { children: (0, jsx_runtime_1.jsx)(NestedArray, {}) }));
220
- yield findByText('values: {"level0Values":[{"level1Values":[0,1]},{"level1Values":[2,3]}]}');
221
- react_2.fireEvent.click(getByText('change 2 to 10'));
222
- yield findByText('values: {"level0Values":[{"level1Values":[0,1]},{"level1Values":[10,3]}]}');
223
- react_2.fireEvent.click(getByText('change 10 to 11'));
224
- yield findByText('values: {"level0Values":[{"level1Values":[0,1]},{"level1Values":[11,3]}]}');
225
- react_2.fireEvent.click(getByText('undo')); // => 11 back to 10
226
- yield findByText('values: {"level0Values":[{"level1Values":[0,1]},{"level1Values":[10,3]}]}');
227
- react_2.fireEvent.click(getByText('change 0 to 12'));
228
- yield findByText('values: {"level0Values":[{"level1Values":[12,1]},{"level1Values":[10,3]}]}');
229
- react_2.fireEvent.click(getByText('undo')); // => 12 back to 0
230
- yield findByText('values: {"level0Values":[{"level1Values":[0,1]},{"level1Values":[10,3]}]}');
231
- react_2.fireEvent.click(getByText('undo')); // => 10 back to 2
232
- yield findByText('values: {"level0Values":[{"level1Values":[0,1]},{"level1Values":[2,3]}]}');
233
- }));
234
- });
235
- //# sourceMappingURL=history-utility.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"history-utility.spec.js","sourceRoot":"","sources":["../../../../packages/history-utility/src/history-utility.spec.tsx"],"names":[],"mappings":";;;;AAAA,iCAAmC;AACnC,kDAA2D;AAC3D,mCAAqC;AACrC,mCAA8C;AAE9C,uDAAqD;AAErD,IAAA,iBAAQ,EAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAA,WAAE,EAAC,4CAA4C,EAAE,GAAS,EAAE;QAC1D,MAAM,KAAK,GAAG,IAAA,kCAAgB,EAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7C,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,IAAA,eAAM,EAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAErC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QACvB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACxB,IAAA,eAAM,EAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAErC,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,MAAM,OAA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