@quenty/rodux-undo 8.13.0 → 8.14.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/CHANGELOG.md +10 -189
- package/package.json +2 -2
- package/src/Shared/UndoableReducer.lua +21 -17
package/CHANGELOG.md
CHANGED
|
@@ -3,380 +3,201 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [8.
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @quenty/rodux-undo
|
|
6
|
+
# [8.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.13.0...@quenty/rodux-undo@8.14.0) (2026-07-14)
|
|
9
7
|
|
|
8
|
+
### Features
|
|
10
9
|
|
|
10
|
+
- **rodux-undo:** convert package to --!strict ([11fa490](https://github.com/Quenty/NevermoreEngine/commit/11fa4900ecfa3747eacc43e80a2b3f702ab5fe11))
|
|
11
11
|
|
|
12
|
+
# [8.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.12.0...@quenty/rodux-undo@8.13.0) (2026-04-23)
|
|
12
13
|
|
|
14
|
+
**Note:** Version bump only for package @quenty/rodux-undo
|
|
13
15
|
|
|
14
16
|
# [8.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.11.2...@quenty/rodux-undo@8.12.0) (2026-02-17)
|
|
15
17
|
|
|
16
18
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
20
|
## [8.11.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.11.1...@quenty/rodux-undo@8.11.2) (2026-01-12)
|
|
23
21
|
|
|
24
|
-
|
|
25
22
|
### Bug Fixes
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
- Fix dependency installation process for pnpm ([9651b09](https://github.com/Quenty/NevermoreEngine/commit/9651b09af34f252ef3f9c7c539793cc878dd8cba))
|
|
32
25
|
|
|
33
26
|
## [8.11.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.11.0...@quenty/rodux-undo@8.11.1) (2026-01-10)
|
|
34
27
|
|
|
35
28
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
30
|
# [8.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.10.1...@quenty/rodux-undo@8.11.0) (2026-01-04)
|
|
42
31
|
|
|
43
32
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
34
|
## [8.10.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.10.0...@quenty/rodux-undo@8.10.1) (2026-01-03)
|
|
50
35
|
|
|
51
36
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
52
37
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
38
|
# [8.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.9.4...@quenty/rodux-undo@8.10.0) (2025-05-10)
|
|
58
39
|
|
|
59
40
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
60
41
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
42
|
## [8.9.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.9.3...@quenty/rodux-undo@8.9.4) (2025-04-10)
|
|
66
43
|
|
|
67
44
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
68
45
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
46
|
## [8.9.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.9.1...@quenty/rodux-undo@8.9.3) (2025-04-07)
|
|
74
47
|
|
|
75
|
-
|
|
76
48
|
### Bug Fixes
|
|
77
49
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
50
|
+
- Bump package versions for republishing ([ba47c62](https://github.com/Quenty/NevermoreEngine/commit/ba47c62e32170bf74377b0c658c60b84306dc294))
|
|
83
51
|
|
|
84
52
|
## [8.9.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.9.1...@quenty/rodux-undo@8.9.2) (2025-04-07)
|
|
85
53
|
|
|
86
54
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
87
55
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
56
|
## [8.9.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.9.0...@quenty/rodux-undo@8.9.1) (2025-03-21)
|
|
93
57
|
|
|
94
58
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
95
59
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
60
|
# [8.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.8.0...@quenty/rodux-undo@8.9.0) (2025-02-18)
|
|
101
61
|
|
|
102
62
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
103
63
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
64
|
# [8.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.7.1...@quenty/rodux-undo@8.8.0) (2024-11-13)
|
|
109
65
|
|
|
110
66
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
111
67
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
68
|
## [8.7.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.7.0...@quenty/rodux-undo@8.7.1) (2024-11-04)
|
|
117
69
|
|
|
118
70
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
119
71
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
72
|
# [8.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.6.0...@quenty/rodux-undo@8.7.0) (2024-10-06)
|
|
125
73
|
|
|
126
74
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
127
75
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
76
|
# [8.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.5.0...@quenty/rodux-undo@8.6.0) (2024-10-04)
|
|
133
77
|
|
|
134
78
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
135
79
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
80
|
# [8.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.4.0...@quenty/rodux-undo@8.5.0) (2024-09-25)
|
|
141
81
|
|
|
142
82
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
143
83
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
84
|
# [8.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.3.0...@quenty/rodux-undo@8.4.0) (2024-09-12)
|
|
149
85
|
|
|
150
86
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
151
87
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
88
|
# [8.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.2.0...@quenty/rodux-undo@8.3.0) (2024-05-09)
|
|
157
89
|
|
|
158
|
-
|
|
159
90
|
### Bug Fixes
|
|
160
91
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
92
|
+
- Fix .package-lock.json replicating in packages ([75d0efe](https://github.com/Quenty/NevermoreEngine/commit/75d0efeef239f221d93352af71a5b3e930ec23c5))
|
|
166
93
|
|
|
167
94
|
# [8.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.1.0...@quenty/rodux-undo@8.2.0) (2024-04-27)
|
|
168
95
|
|
|
169
96
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
170
97
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
98
|
# [8.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@8.0.0...@quenty/rodux-undo@8.1.0) (2024-03-09)
|
|
176
99
|
|
|
177
100
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
178
101
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
102
|
# [8.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@7.0.0...@quenty/rodux-undo@8.0.0) (2024-02-14)
|
|
184
103
|
|
|
185
104
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
186
105
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
106
|
# [7.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@6.0.0...@quenty/rodux-undo@7.0.0) (2024-02-13)
|
|
192
107
|
|
|
193
108
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
194
109
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
110
|
# [6.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@5.2.0...@quenty/rodux-undo@6.0.0) (2024-02-13)
|
|
200
111
|
|
|
201
112
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
202
113
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
114
|
# [5.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@5.1.0...@quenty/rodux-undo@5.2.0) (2024-01-08)
|
|
208
115
|
|
|
209
116
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
210
117
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
118
|
# [5.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@5.0.0...@quenty/rodux-undo@5.1.0) (2023-12-14)
|
|
216
119
|
|
|
217
120
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
218
121
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
122
|
# [5.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@4.3.0...@quenty/rodux-undo@5.0.0) (2023-10-11)
|
|
224
123
|
|
|
225
124
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
226
125
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
126
|
# [4.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@4.2.1...@quenty/rodux-undo@4.3.0) (2023-08-23)
|
|
232
127
|
|
|
233
128
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
234
129
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
130
|
## [4.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@4.2.0...@quenty/rodux-undo@4.2.1) (2023-04-07)
|
|
240
131
|
|
|
241
132
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
242
133
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
134
|
# [4.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@4.1.0...@quenty/rodux-undo@4.2.0) (2023-03-05)
|
|
248
135
|
|
|
249
136
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
250
137
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
138
|
# [4.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@4.0.1...@quenty/rodux-undo@4.1.0) (2023-02-21)
|
|
256
139
|
|
|
257
140
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
258
141
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
142
|
## [4.0.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@4.0.0...@quenty/rodux-undo@4.0.1) (2022-11-04)
|
|
264
143
|
|
|
265
144
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
266
145
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
146
|
# [4.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@3.1.1...@quenty/rodux-undo@4.0.0) (2022-09-27)
|
|
272
147
|
|
|
273
148
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
274
149
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
150
|
## [3.1.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@3.1.0...@quenty/rodux-undo@3.1.1) (2022-08-16)
|
|
280
151
|
|
|
281
152
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
282
153
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
154
|
# [3.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@3.0.0...@quenty/rodux-undo@3.1.0) (2022-06-21)
|
|
288
155
|
|
|
289
156
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
290
157
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
158
|
# [3.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@2.1.0...@quenty/rodux-undo@3.0.0) (2022-05-21)
|
|
296
159
|
|
|
297
160
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
298
161
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
162
|
# [2.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@2.0.0...@quenty/rodux-undo@2.1.0) (2022-03-27)
|
|
304
163
|
|
|
305
164
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
306
165
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
166
|
# [2.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@1.5.0...@quenty/rodux-undo@2.0.0) (2022-03-06)
|
|
312
167
|
|
|
313
168
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
314
169
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
170
|
# [1.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@1.4.0...@quenty/rodux-undo@1.5.0) (2022-01-17)
|
|
320
171
|
|
|
321
172
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
322
173
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
174
|
# [1.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@1.3.0...@quenty/rodux-undo@1.4.0) (2022-01-07)
|
|
328
175
|
|
|
329
176
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
330
177
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
178
|
# [1.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@1.2.1...@quenty/rodux-undo@1.3.0) (2022-01-03)
|
|
336
179
|
|
|
337
180
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
338
181
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
182
|
## [1.2.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@1.2.0...@quenty/rodux-undo@1.2.1) (2021-12-30)
|
|
344
183
|
|
|
345
184
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
346
185
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
186
|
# [1.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@1.1.1...@quenty/rodux-undo@1.2.0) (2021-11-20)
|
|
352
187
|
|
|
353
|
-
|
|
354
188
|
### Bug Fixes
|
|
355
189
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
190
|
+
- Support MacOS syncing ([#225](https://github.com/Quenty/NevermoreEngine/issues/225)) ([03f9183](https://github.com/Quenty/NevermoreEngine/commit/03f918392c6a5bdd33f8a17c38de371d1e06c67a))
|
|
361
191
|
|
|
362
192
|
## [1.1.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rodux-undo@1.1.0...@quenty/rodux-undo@1.1.1) (2021-10-30)
|
|
363
193
|
|
|
364
194
|
**Note:** Version bump only for package @quenty/rodux-undo
|
|
365
195
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
196
|
# 1.1.0 (2021-10-02)
|
|
371
197
|
|
|
372
|
-
|
|
373
198
|
### Features
|
|
374
199
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
200
|
+
- Move rodux code to packages ([838bfdf](https://github.com/Quenty/NevermoreEngine/commit/838bfdfe78884a46218cc0ce1acd03ffdfca41eb))
|
|
380
201
|
|
|
381
202
|
# v1.1.0 (Sat Oct 02 2021)
|
|
382
203
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/rodux-undo",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.14.0",
|
|
4
4
|
"description": "Undo stack for rodux",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "13f0162f4971a77378e55e9b7236aea94f0dd3a8"
|
|
38
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Simple undo redo stack history
|
|
4
4
|
@class UndoableReducer
|
|
@@ -10,11 +10,15 @@ local Table = require("Table")
|
|
|
10
10
|
|
|
11
11
|
local HISTORY_LIMIT = 50
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
type Action = { type: string?, [string]: any }
|
|
14
|
+
type UndoableState = { past: { any }, present: any, future: { any } }
|
|
15
|
+
type Reducer = (state: any, action: Action) -> any
|
|
16
|
+
|
|
17
|
+
local function insert(state: UndoableState, reduced: any): UndoableState
|
|
14
18
|
local start = math.max(1, #state.past - HISTORY_LIMIT + 2)
|
|
15
19
|
local _end = math.min(#state.past, start + HISTORY_LIMIT)
|
|
16
20
|
|
|
17
|
-
local newPast = {}
|
|
21
|
+
local newPast: { any } = {}
|
|
18
22
|
for i = start, _end do
|
|
19
23
|
newPast[#newPast + 1] = state.past[i]
|
|
20
24
|
end
|
|
@@ -27,14 +31,14 @@ local function insert(state, reduced)
|
|
|
27
31
|
}
|
|
28
32
|
end
|
|
29
33
|
|
|
30
|
-
return function(reducer)
|
|
31
|
-
local actions = {
|
|
32
|
-
undo = function(state, _action)
|
|
34
|
+
return function(reducer: Reducer): (state: UndoableState?, action: Action) -> UndoableState
|
|
35
|
+
local actions: { [string]: (state: UndoableState, action: Action) -> UndoableState } = {
|
|
36
|
+
undo = function(state: UndoableState, _action: Action): UndoableState
|
|
33
37
|
if #state.past == 0 then
|
|
34
38
|
return state
|
|
35
39
|
end
|
|
36
40
|
|
|
37
|
-
local newPast = {}
|
|
41
|
+
local newPast: { any } = {}
|
|
38
42
|
for i = 1, #state.past - 1 do
|
|
39
43
|
newPast[#newPast + 1] = state.past[i]
|
|
40
44
|
end
|
|
@@ -45,12 +49,12 @@ return function(reducer)
|
|
|
45
49
|
future = Table.mergeLists(state.future, { state.present }),
|
|
46
50
|
}
|
|
47
51
|
end,
|
|
48
|
-
redo = function(state, _action)
|
|
52
|
+
redo = function(state: UndoableState, _action: Action): UndoableState
|
|
49
53
|
if #state.future == 0 then
|
|
50
54
|
return state
|
|
51
55
|
end
|
|
52
56
|
|
|
53
|
-
local newFuture = {}
|
|
57
|
+
local newFuture: { any } = {}
|
|
54
58
|
for i = 1, #state.future - 1 do
|
|
55
59
|
newFuture[#newFuture + 1] = state.future[i]
|
|
56
60
|
end
|
|
@@ -63,25 +67,25 @@ return function(reducer)
|
|
|
63
67
|
end,
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
return function(state
|
|
67
|
-
|
|
70
|
+
return function(state: UndoableState?, action: Action): UndoableState
|
|
71
|
+
local currentState: UndoableState = state or {
|
|
68
72
|
past = {},
|
|
69
73
|
present = reducer(nil, {}),
|
|
70
74
|
future = {},
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
if not action.type then
|
|
74
|
-
return
|
|
78
|
+
return currentState
|
|
75
79
|
elseif actions[action.type] then
|
|
76
|
-
return actions[action.type](
|
|
80
|
+
return actions[action.type](currentState, action)
|
|
77
81
|
else
|
|
78
|
-
local reduced = reducer(
|
|
82
|
+
local reduced = reducer(currentState.present, action)
|
|
79
83
|
|
|
80
|
-
if
|
|
81
|
-
return
|
|
84
|
+
if currentState.present == reduced then
|
|
85
|
+
return currentState
|
|
82
86
|
end
|
|
83
87
|
|
|
84
|
-
return insert(
|
|
88
|
+
return insert(currentState, reduced)
|
|
85
89
|
end
|
|
86
90
|
end
|
|
87
91
|
end
|