@quenty/saveslot 1.5.0 → 1.7.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 CHANGED
@@ -3,6 +3,23 @@
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
+ # [1.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@1.6.0...@quenty/saveslot@1.7.0) (2026-07-20)
7
+
8
+ ### Bug Fixes
9
+
10
+ - Strict typing on tests ([efbc458](https://github.com/Quenty/NevermoreEngine/commit/efbc45882fac95755ea4ff4e007c5f71bedebf6f))
11
+
12
+ ### Features
13
+
14
+ - Integrate teleport data service directly into save slots for cross-game continuation ([ffa7496](https://github.com/Quenty/NevermoreEngine/commit/ffa7496047b80a82623440221c019fdfe09e31ea))
15
+ - **saveslot:** add last-active replication and continue/new-game/wipe APIs ([f5f4045](https://github.com/Quenty/NevermoreEngine/commit/f5f4045b5849482f95a780fce5ba298682afe173))
16
+ - Support deselecting the active save slot ([d7da61d](https://github.com/Quenty/NevermoreEngine/commit/d7da61d80742f56987e2cf69e7fb108e9b18fa2d))
17
+ - Support unbounded save slots via SetUnlimitedSlots ([ec34e9a](https://github.com/Quenty/NevermoreEngine/commit/ec34e9aa6c9fce0cab4dd4f6f88780581e3cd1e5))
18
+
19
+ # [1.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@1.5.0...@quenty/saveslot@1.6.0) (2026-07-18)
20
+
21
+ **Note:** Version bump only for package @quenty/saveslot
22
+
6
23
  # [1.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@1.4.1...@quenty/saveslot@1.5.0) (2026-07-18)
7
24
 
8
25
  **Note:** Version bump only for package @quenty/saveslot
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/saveslot",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "PlayerDataStoreService wrapper for save slots",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -28,30 +28,31 @@
28
28
  "Quenty"
29
29
  ],
30
30
  "dependencies": {
31
- "@quenty/adorneedata": "7.35.0",
32
- "@quenty/baseobject": "10.13.0",
33
- "@quenty/binder": "14.38.0",
34
- "@quenty/brio": "14.31.0",
35
- "@quenty/cmdrservice": "13.48.0",
36
- "@quenty/datastore": "13.41.0",
37
- "@quenty/instanceutils": "13.31.0",
31
+ "@quenty/adorneedata": "7.36.0",
32
+ "@quenty/baseobject": "10.14.0",
33
+ "@quenty/binder": "14.39.0",
34
+ "@quenty/brio": "14.32.0",
35
+ "@quenty/cmdrservice": "13.49.0",
36
+ "@quenty/datastore": "13.42.0",
37
+ "@quenty/instanceutils": "13.32.0",
38
38
  "@quenty/loader": "10.11.0",
39
- "@quenty/maid": "3.9.0",
39
+ "@quenty/maid": "3.10.0",
40
40
  "@quenty/nevermore-test-runner": "1.4.0",
41
- "@quenty/playerbinder": "14.38.0",
42
- "@quenty/promise": "10.19.0",
43
- "@quenty/propertyvalue": "7.31.0",
44
- "@quenty/remoting": "12.33.0",
45
- "@quenty/rx": "13.29.0",
46
- "@quenty/servicebag": "11.18.1",
41
+ "@quenty/playerbinder": "14.39.0",
42
+ "@quenty/promise": "10.20.0",
43
+ "@quenty/propertyvalue": "7.32.0",
44
+ "@quenty/remoting": "12.34.0",
45
+ "@quenty/rx": "13.30.0",
46
+ "@quenty/servicebag": "11.19.0",
47
47
  "@quenty/signal": "7.13.1",
48
48
  "@quenty/table": "3.9.2",
49
- "@quenty/tie": "10.42.0",
50
- "@quenty/valueobject": "13.32.0",
49
+ "@quenty/teleportserviceutils": "9.34.0",
50
+ "@quenty/tie": "10.43.0",
51
+ "@quenty/valueobject": "13.33.0",
51
52
  "@quentystudios/jest-lua": "3.10.0-quenty.2"
52
53
  },
53
54
  "publishConfig": {
54
55
  "access": "public"
55
56
  },
56
- "gitHead": "cbbb89635bfdcbf32f26a40422ac736292917cca"
57
+ "gitHead": "2c903e91ae2ea1702ae1ce94af20af83af81e4fe"
57
58
  }
@@ -12,8 +12,10 @@ local HasSaveSlotsBase = require("HasSaveSlotsBase")
12
12
  local HasSaveSlotsInterface = require("HasSaveSlotsInterface")
13
13
  local Promise = require("Promise")
14
14
  local Remoting = require("Remoting")
15
+ local SaveSlotConstants = require("SaveSlotConstants")
15
16
  local SaveSlotData = require("SaveSlotData")
16
17
  local ServiceBag = require("ServiceBag")
18
+ local TeleportDataServiceClient = require("TeleportDataServiceClient")
17
19
 
18
20
  local HasSaveSlotsClient = setmetatable({}, HasSaveSlotsBase)
19
21
  HasSaveSlotsClient.ClassName = "HasSaveSlotsClient"
@@ -25,6 +27,7 @@ export type HasSaveSlotsClient =
25
27
  _obj: Player,
26
28
  _serviceBag: ServiceBag.ServiceBag,
27
29
  _remoting: any,
30
+ _teleportDataServiceClient: any,
28
31
  },
29
32
  {} :: typeof({ __index = HasSaveSlotsClient })
30
33
  ))
@@ -38,6 +41,7 @@ function HasSaveSlotsClient.new(player: Player, serviceBag: ServiceBag.ServiceBa
38
41
  local self: HasSaveSlotsClient = setmetatable(HasSaveSlotsBase.new(player, serviceBag) :: any, HasSaveSlotsClient)
39
42
 
40
43
  self._serviceBag = assert(serviceBag, "No serviceBag")
44
+ self._teleportDataServiceClient = self._serviceBag:GetService(TeleportDataServiceClient)
41
45
 
42
46
  self._remoting = self._maid:Add(Remoting.Client.new(self._obj, "HasSaveSlots"))
43
47
 
@@ -125,4 +129,14 @@ function HasSaveSlotsClient.PromiseSlotIdFromIndex(
125
129
  return self._remoting.PromiseSlotIdFromIndex:PromiseInvokeServer(slotIndex)
126
130
  end
127
131
 
132
+ -- Client realm hook for HasSaveSlotsBase: the incoming slot id is whatever the local player
133
+ -- teleported in with, read from their local teleport data via TeleportDataServiceClient.
134
+ function HasSaveSlotsClient._getIncomingSlotId(self: HasSaveSlotsClient): SaveSlotData.SlotId?
135
+ local slotId = self._teleportDataServiceClient:GetArrivedValue(SaveSlotConstants.TELEPORT_DATA_SLOT_KEY)
136
+ if type(slotId) == "string" then
137
+ return slotId
138
+ end
139
+ return nil
140
+ end
141
+
128
142
  return Binder.new("HasSaveSlots", HasSaveSlotsClient :: any) :: Binder.Binder<HasSaveSlotsClient>
@@ -9,7 +9,9 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage")
9
9
 
10
10
  local Maid = require("Maid")
11
11
  local Remoting = require("Remoting")
12
+ local SaveSlotConstants = require("SaveSlotConstants")
12
13
  local ServiceBag = require("ServiceBag")
14
+ local TeleportDataServiceClient = require("TeleportDataServiceClient")
13
15
 
14
16
  local SaveSlotServiceClient = {}
15
17
  SaveSlotServiceClient.ServiceName = "SaveSlotServiceClient"
@@ -19,6 +21,7 @@ export type SaveSlotServiceClient = typeof(setmetatable(
19
21
  _serviceBag: ServiceBag.ServiceBag,
20
22
  _maid: Maid.Maid,
21
23
  _remoting: any,
24
+ _teleportDataServiceClient: any,
22
25
  },
23
26
  {} :: typeof({ __index = SaveSlotServiceClient })
24
27
  ))
@@ -28,6 +31,9 @@ function SaveSlotServiceClient.Init(self: SaveSlotServiceClient, serviceBag: Ser
28
31
  self._serviceBag = assert(serviceBag, "No serviceBag")
29
32
  self._maid = Maid.new()
30
33
 
34
+ -- External
35
+ self._teleportDataServiceClient = self._serviceBag:GetService(TeleportDataServiceClient)
36
+
31
37
  -- Internal
32
38
  self._serviceBag:GetService(require("SaveSlotCmdrServiceClient"))
33
39
  self._serviceBag:GetService(require("SaveSlotDataService"))
@@ -38,6 +44,17 @@ function SaveSlotServiceClient.Init(self: SaveSlotServiceClient, serviceBag: Ser
38
44
  self._remoting = self._maid:Add(Remoting.Client.new(ReplicatedStorage, "SaveSlotService"))
39
45
  end
40
46
 
47
+ --[=[
48
+ Returns whether the local player teleported in carrying a save-slot id -- i.e. arrived via an
49
+ internal slot teleport rather than a fresh join. Sync, presence-only (mirrors the server's
50
+ [SaveSlotService.IsInternalTeleport]).
51
+
52
+ @return boolean
53
+ ]=]
54
+ function SaveSlotServiceClient.IsInternalTeleport(self: SaveSlotServiceClient): boolean
55
+ return self._teleportDataServiceClient:HasArrivedValue(SaveSlotConstants.TELEPORT_DATA_SLOT_KEY)
56
+ end
57
+
41
58
  --[=[
42
59
  Returns whether explicit slot selection is required
43
60
  ]=]
@@ -23,6 +23,7 @@ local RxBrioUtils = require("RxBrioUtils")
23
23
  local SaveSlotConstants = require("SaveSlotConstants")
24
24
  local SaveSlotData = require("SaveSlotData")
25
25
  local ServiceBag = require("ServiceBag")
26
+ local TeleportDataService = require("TeleportDataService")
26
27
  local ValueObject = require("ValueObject")
27
28
 
28
29
  export type SaveSlotSummaryProvider = (Player, any) -> Observable.Observable<string>
@@ -46,6 +47,7 @@ export type HasSaveSlots =
46
47
  _metadataStore: any,
47
48
  _summaryProvider: ValueObject.ValueObject<SaveSlotSummaryProvider?>,
48
49
  _lastActiveSlotId: SaveSlotData.SlotId?,
50
+ _teleportDataService: any,
49
51
  },
50
52
  {} :: typeof({ __index = HasSaveSlots })
51
53
  ))
@@ -56,6 +58,7 @@ function HasSaveSlots.new(player: Player, serviceBag: ServiceBag.ServiceBag): Ha
56
58
 
57
59
  self._serviceBag = assert(serviceBag, "No serviceBag")
58
60
  self._playerDataStoreService = self._serviceBag:GetService(PlayerDataStoreService)
61
+ self._teleportDataService = self._serviceBag:GetService(TeleportDataService)
59
62
 
60
63
  self._slotContainer = self._maid:Add(Instance.new("Folder"))
61
64
  self._slotContainer.Name = SaveSlotConstants.METADATA_CONTAINER_NAME
@@ -156,6 +159,26 @@ function HasSaveSlots.PromiseSelectSlot(self: HasSaveSlots, slotId: SaveSlotData
156
159
  end)
157
160
  end
158
161
 
162
+ --[=[
163
+ Clears the active slot selection, returning the player to a no-slot state --
164
+ the counterpart to [HasSaveSlots.PromiseSelectSlot], backing a "back to menu"
165
+ affordance. The active slot's progress is flushed first (mirroring the save
166
+ PromiseSelectSlot runs when switching away), and the last-active slot is
167
+ remembered, so [HasSaveSlots.PromiseSelectLastSaveSlot] can resume it later.
168
+ A no-op when no slot is active.
169
+ ]=]
170
+ function HasSaveSlots.PromiseDeselectSlot(self: HasSaveSlots): Promise.Promise<()>
171
+ return (self._loadPromise :: any):Then(function()
172
+ if self.ActiveSlotId.Value == nil then
173
+ return -- Already deselected
174
+ end
175
+
176
+ return self._dataStore:Save():Then(function()
177
+ self.ActiveSlotId.Value = nil
178
+ end)
179
+ end)
180
+ end
181
+
159
182
  --[=[
160
183
  Creates a slot at the given index
161
184
  ]=]
@@ -205,6 +228,14 @@ function HasSaveSlots.PromiseDeleteSlot(self: HasSaveSlots, slotId: SaveSlotData
205
228
 
206
229
  self._maid[slotId] = nil
207
230
 
231
+ -- The continue pointer must not outlive its slot. When the deleted slot is the one the player
232
+ -- would resume on (e.g. the just-deselected active slot, or a never-reselected last-active),
233
+ -- clear the last-active memory so "Continue" stops offering a slot that no longer exists.
234
+ if slotId == self._lastActiveSlotId then
235
+ self._lastActiveSlotId = nil
236
+ self.LastActiveSlotId.Value = nil
237
+ end
238
+
208
239
  -- Wipe default slot
209
240
  local slotIndex = SaveSlotData.SlotIndex:Get(slot)
210
241
  local deletePromise = nil
@@ -232,6 +263,34 @@ function HasSaveSlots.PromiseDeleteSlot(self: HasSaveSlots, slotId: SaveSlotData
232
263
  end)
233
264
  end
234
265
 
266
+ --[=[
267
+ Deletes every slot for the player and clears the active/last-active
268
+ selection, resetting the player to a fresh state. Resolves once all slots
269
+ are gone.
270
+ ]=]
271
+ function HasSaveSlots.PromiseDeleteAllSlots(self: HasSaveSlots): Promise.Promise<any>
272
+ return (self._loadPromise :: any):Then(function()
273
+ -- Clear the selection first so the previously active slot is deletable
274
+ self.ActiveSlotId.Value = nil
275
+ self._lastActiveSlotId = nil
276
+ self.LastActiveSlotId.Value = nil
277
+
278
+ local slotIds = {}
279
+ for slotId in self._slotMap do
280
+ table.insert(slotIds, slotId)
281
+ end
282
+
283
+ -- Delete sequentially to avoid concurrent datastore saves
284
+ local promise = (Promise :: any).resolved()
285
+ for _, slotId in slotIds do
286
+ promise = promise:Then(function()
287
+ return self:PromiseDeleteSlot(slotId)
288
+ end)
289
+ end
290
+ return promise
291
+ end)
292
+ end
293
+
235
294
  --[=[
236
295
  Sets the metadata for the slot with the given ID
237
296
  ]=]
@@ -295,6 +354,62 @@ function HasSaveSlots.PromiseLastActiveSlotId(self: HasSaveSlots): Promise.Promi
295
354
  end)
296
355
  end
297
356
 
357
+ --[=[
358
+ Selects the player's last active slot if one still exists, resolving to the
359
+ selected slot id -- or nil when there is no slot to continue on. Backs a
360
+ "Continue" affordance that every save-slot consumer tends to need.
361
+ ]=]
362
+ function HasSaveSlots.PromiseSelectLastSaveSlot(self: HasSaveSlots): Promise.Promise<SaveSlotData.SlotId?>
363
+ return self:PromiseLastActiveSlotId():Then(function(lastActiveSlotId: SaveSlotData.SlotId?)
364
+ if not lastActiveSlotId then
365
+ return nil
366
+ end
367
+
368
+ return self:PromiseHasSlot(lastActiveSlotId):Then(function(hasLastSlot: boolean)
369
+ if not hasLastSlot then
370
+ return nil
371
+ end
372
+
373
+ return self:PromiseSelectSlot(lastActiveSlotId):Then(function()
374
+ return lastActiveSlotId
375
+ end)
376
+ end)
377
+ end)
378
+ end
379
+
380
+ --[=[
381
+ Creates a new slot at the lowest free index and selects it, resolving to the
382
+ new slot id -- or nil when every slot is already in use. Backs a "New Game"
383
+ affordance.
384
+ ]=]
385
+ function HasSaveSlots.PromiseSelectNewSaveSlot(self: HasSaveSlots): Promise.Promise<SaveSlotData.SlotId?>
386
+ return (self._loadPromise :: any):Then(function(): any
387
+ local usedIndices = {}
388
+ for _, slot in self._slotMap do
389
+ usedIndices[SaveSlotData.SlotIndex:Get(slot)] = true
390
+ end
391
+
392
+ -- Lowest free positive index. Fills gaps left by deletions (delete slot 2 of
393
+ -- [1,2,3] and the next new slot reuses index 2). With a finite MaxSlotCount this
394
+ -- returns nil once [1, MaxSlotCount] is full; with an unbounded count (math.huge)
395
+ -- there is always a next integer, so it never returns nil.
396
+ local freeIndex = 1
397
+ while usedIndices[freeIndex] do
398
+ freeIndex += 1
399
+ end
400
+
401
+ if freeIndex > self.MaxSlotCount.Value then
402
+ return nil
403
+ end
404
+
405
+ return self:PromiseCreateSlot(freeIndex):Then(function(slotId: SaveSlotData.SlotId)
406
+ return self:PromiseSelectSlot(slotId):Then(function()
407
+ return slotId
408
+ end)
409
+ end)
410
+ end)
411
+ end
412
+
298
413
  --[=[
299
414
  Sets the summary provider
300
415
  ]=]
@@ -302,6 +417,16 @@ function HasSaveSlots.SetSummaryProvider(self: HasSaveSlots, provider: SaveSlotS
302
417
  self._summaryProvider.Value = provider
303
418
  end
304
419
 
420
+ -- Server realm hook for HasSaveSlotsBase: the incoming slot id is whatever the player teleported in
421
+ -- with, read from their join data via TeleportDataService.
422
+ function HasSaveSlots._getIncomingSlotId(self: HasSaveSlots): SaveSlotData.SlotId?
423
+ local slotId = self._teleportDataService:GetArrivedValue(self._obj, SaveSlotConstants.TELEPORT_DATA_SLOT_KEY)
424
+ if type(slotId) == "string" then
425
+ return slotId
426
+ end
427
+ return nil
428
+ end
429
+
305
430
  function HasSaveSlots._promiseLoadSlots(self: HasSaveSlots): Promise.Promise<{}>
306
431
  return self._playerDataStoreService:PromiseDataStore(self._obj):Then(function(dataStore)
307
432
  self._dataStore = dataStore
@@ -315,7 +440,17 @@ function HasSaveSlots._promiseLoadSlots(self: HasSaveSlots): Promise.Promise<{}>
315
440
 
316
441
  return self._systemStore:Load("activeSlotId"):Then(function(activeId: SaveSlotData.SlotId?)
317
442
  self._lastActiveSlotId = activeId
443
+ self.LastActiveSlotId.Value = activeId
318
444
  self._maid:GiveTask(self._systemStore:StoreOnValueChange("activeSlotId", self.ActiveSlotId))
445
+
446
+ -- Keep the replicated last-active in sync as the player selects slots this session
447
+ self._maid:GiveTask(self.ActiveSlotId.Changed:Connect(function()
448
+ local active = self.ActiveSlotId.Value
449
+ if active ~= nil then
450
+ self._lastActiveSlotId = active
451
+ self.LastActiveSlotId.Value = active
452
+ end
453
+ end))
319
454
  end)
320
455
  end)
321
456
  end)