@quenty/saveslot 1.9.0 → 1.10.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 +4 -0
- package/package.json +3 -3
- package/src/Client/Binders/HasSaveSlotsClient.lua +12 -8
- package/src/Client/SaveSlotServiceClient.lua +25 -6
- package/src/Server/Binders/HasSaveSlots.lua +13 -7
- package/src/Server/SaveSlotService.lua +7 -7
- package/src/Server/SaveSlotService.spec.lua +43 -7
- package/src/Shared/HasSaveSlotsBase.lua +24 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@1.9.0...@quenty/saveslot@1.10.0) (2026-07-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/saveslot
|
|
9
|
+
|
|
6
10
|
# [1.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/saveslot@1.8.0...@quenty/saveslot@1.9.0) (2026-07-21)
|
|
7
11
|
|
|
8
12
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/saveslot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "PlayerDataStoreService wrapper for save slots",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@quenty/servicebag": "11.19.0",
|
|
49
49
|
"@quenty/signal": "7.13.1",
|
|
50
50
|
"@quenty/table": "3.9.2",
|
|
51
|
-
"@quenty/teleportserviceutils": "9.
|
|
51
|
+
"@quenty/teleportserviceutils": "9.36.0",
|
|
52
52
|
"@quenty/tie": "10.43.0",
|
|
53
53
|
"@quenty/valueobject": "13.33.0",
|
|
54
54
|
"@quentystudios/jest-lua": "3.10.0-quenty.2"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "8bd905a5c7e7f1fd4e178b54beeadef94a615d1d"
|
|
60
60
|
}
|
|
@@ -129,14 +129,18 @@ function HasSaveSlotsClient.PromiseSlotIdFromIndex(
|
|
|
129
129
|
return self._remoting.PromiseSlotIdFromIndex:PromiseInvokeServer(slotIndex)
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
-- Client realm hook for HasSaveSlotsBase: the incoming slot id is whatever the local player
|
|
133
|
-
--
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
-- Client realm hook for HasSaveSlotsBase: the incoming slot id is whatever the local player teleported
|
|
133
|
+
-- in with, read from the unified TeleportDataServiceClient view (a promise for symmetry with the
|
|
134
|
+
-- server; on the client it resolves immediately from local teleport data).
|
|
135
|
+
function HasSaveSlotsClient.PromiseIncomingSlotId(self: HasSaveSlotsClient): Promise.Promise<SaveSlotData.SlotId?>
|
|
136
|
+
return self._teleportDataServiceClient
|
|
137
|
+
:PromiseArrivedValue(SaveSlotConstants.TELEPORT_DATA_SLOT_KEY)
|
|
138
|
+
:Then(function(slotId): SaveSlotData.SlotId?
|
|
139
|
+
if type(slotId) == "string" then
|
|
140
|
+
return slotId
|
|
141
|
+
end
|
|
142
|
+
return nil
|
|
143
|
+
end)
|
|
140
144
|
end
|
|
141
145
|
|
|
142
146
|
return Binder.new("HasSaveSlots", HasSaveSlotsClient :: any) :: Binder.Binder<HasSaveSlotsClient>
|
|
@@ -7,6 +7,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
7
7
|
|
|
8
8
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
9
9
|
|
|
10
|
+
local HasSaveSlotsData = require("HasSaveSlotsData")
|
|
10
11
|
local Maid = require("Maid")
|
|
11
12
|
local Remoting = require("Remoting")
|
|
12
13
|
local SaveSlotConstants = require("SaveSlotConstants")
|
|
@@ -44,15 +45,33 @@ function SaveSlotServiceClient.Init(self: SaveSlotServiceClient, serviceBag: Ser
|
|
|
44
45
|
self._remoting = self._maid:Add(Remoting.Client.new(ReplicatedStorage, "SaveSlotService"))
|
|
45
46
|
end
|
|
46
47
|
|
|
48
|
+
function SaveSlotServiceClient.Start(self: SaveSlotServiceClient)
|
|
49
|
+
-- Symmetric mirror of the server's provider ([SaveSlotService.Start]): a teleport the client builds
|
|
50
|
+
-- carries the local player's active slot id, so a client-initiated teleport resumes on the same slot
|
|
51
|
+
-- without any menu re-attaching it by hand.
|
|
52
|
+
self._maid:GiveTask(
|
|
53
|
+
self._teleportDataServiceClient:RegisterPerPlayerTeleportDataProvider(
|
|
54
|
+
function(player: Player): { [string]: any }?
|
|
55
|
+
local slotId = HasSaveSlotsData.ActiveSlotId:Get(player)
|
|
56
|
+
if type(slotId) == "string" then
|
|
57
|
+
return { [SaveSlotConstants.TELEPORT_DATA_SLOT_KEY] = slotId }
|
|
58
|
+
end
|
|
59
|
+
return nil
|
|
60
|
+
end
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
47
65
|
--[=[
|
|
48
|
-
|
|
49
|
-
internal slot teleport rather than a fresh join.
|
|
50
|
-
[SaveSlotService.
|
|
66
|
+
Resolves whether the local player teleported in carrying a save-slot id -- i.e. arrived via an
|
|
67
|
+
internal slot teleport rather than a fresh join. Presence-only. A promise for symmetry with the
|
|
68
|
+
server's [SaveSlotService.PromiseIsInternalTeleport]; on the client it resolves immediately from
|
|
69
|
+
local teleport data.
|
|
51
70
|
|
|
52
|
-
@return boolean
|
|
71
|
+
@return Promise<boolean>
|
|
53
72
|
]=]
|
|
54
|
-
function SaveSlotServiceClient.
|
|
55
|
-
return self._teleportDataServiceClient:
|
|
73
|
+
function SaveSlotServiceClient.PromiseIsInternalTeleport(self: SaveSlotServiceClient): any
|
|
74
|
+
return self._teleportDataServiceClient:PromiseHasArrivedValue(SaveSlotConstants.TELEPORT_DATA_SLOT_KEY)
|
|
56
75
|
end
|
|
57
76
|
|
|
58
77
|
--[=[
|
|
@@ -582,13 +582,19 @@ function HasSaveSlots.RegisterSummaryProvider(self: HasSaveSlots, name: string,
|
|
|
582
582
|
end
|
|
583
583
|
|
|
584
584
|
-- Server realm hook for HasSaveSlotsBase: the incoming slot id is whatever the player teleported in
|
|
585
|
-
-- with, read from
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
585
|
+
-- with, read from the unified TeleportDataService view. It is a promise because a client-initiated
|
|
586
|
+
-- teleport only reaches the server once the client replicates its arrived data. The slot id is a
|
|
587
|
+
-- client *request* -- fine here, because PromiseLoadSaveSlotFromTeleport re-validates ownership via
|
|
588
|
+
-- PromiseHasSlot before selecting it.
|
|
589
|
+
function HasSaveSlots.PromiseIncomingSlotId(self: HasSaveSlots): Promise.Promise<SaveSlotData.SlotId?>
|
|
590
|
+
return self._teleportDataService
|
|
591
|
+
:PromiseArrivedValue(self._obj, SaveSlotConstants.TELEPORT_DATA_SLOT_KEY)
|
|
592
|
+
:Then(function(slotId): SaveSlotData.SlotId?
|
|
593
|
+
if type(slotId) == "string" then
|
|
594
|
+
return slotId
|
|
595
|
+
end
|
|
596
|
+
return nil
|
|
597
|
+
end)
|
|
592
598
|
end
|
|
593
599
|
|
|
594
600
|
function HasSaveSlots._promiseLoadSlots(self: HasSaveSlots): Promise.Promise<{}>
|
|
@@ -161,16 +161,16 @@ function SaveSlotService.GetExplicitSelectionRequired(self: SaveSlotService): bo
|
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
--[=[
|
|
164
|
-
|
|
165
|
-
slot teleport rather than a fresh join.
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
Resolves whether the player teleported in carrying a save-slot id -- i.e. arrived via an internal
|
|
165
|
+
slot teleport rather than a fresh join. Presence-only (it does not validate the slot still exists);
|
|
166
|
+
use [HasSaveSlots.PromiseHasSaveSlotFromTeleport] when existence matters. It is a promise because a
|
|
167
|
+
client-initiated teleport only reaches the server once the client replicates its arrived data.
|
|
168
168
|
|
|
169
169
|
@param player Player
|
|
170
|
-
@return boolean
|
|
170
|
+
@return Promise<boolean>
|
|
171
171
|
]=]
|
|
172
|
-
function SaveSlotService.
|
|
173
|
-
return self._teleportDataService:
|
|
172
|
+
function SaveSlotService.PromiseIsInternalTeleport(self: SaveSlotService, player: Player): Promise.Promise<boolean>
|
|
173
|
+
return self._teleportDataService:PromiseHasArrivedValue(player, SaveSlotConstants.TELEPORT_DATA_SLOT_KEY)
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
--[=[
|
|
@@ -12,6 +12,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
12
12
|
local DataStoreMock = require("DataStoreMock")
|
|
13
13
|
local Jest = require("Jest")
|
|
14
14
|
local PlayerDataStoreService = require("PlayerDataStoreService")
|
|
15
|
+
local PromiseTestUtils = require("PromiseTestUtils")
|
|
15
16
|
local SaveSlotConstants = require("SaveSlotConstants")
|
|
16
17
|
local SaveSlotService = require("SaveSlotService")
|
|
17
18
|
local ServiceBag = require("ServiceBag")
|
|
@@ -243,21 +244,56 @@ describe("SaveSlotService internal teleport", function()
|
|
|
243
244
|
serviceBag:Destroy()
|
|
244
245
|
end)
|
|
245
246
|
|
|
246
|
-
|
|
247
|
+
-- Awaits a boolean read promise and returns its fulfilled value.
|
|
248
|
+
local function awaitBool(promise: any): boolean
|
|
249
|
+
expect(PromiseTestUtils.awaitSettled(promise, 5)).toEqual(true)
|
|
250
|
+
local ok, value = promise:Yield()
|
|
251
|
+
expect(ok).toEqual(true)
|
|
252
|
+
return value
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it("should report a client-initiated teleport (non-trusted band) as internal", function()
|
|
256
|
+
-- This is the fix: a slot the *client* attached only reaches the server via replication, and the
|
|
257
|
+
-- server must still see it.
|
|
247
258
|
local serviceBag, saveSlotService, teleportDataService = newServiceBag()
|
|
248
259
|
serviceBag:Start()
|
|
249
260
|
|
|
250
|
-
local arrived = fakePlayer()
|
|
251
|
-
teleportDataService:
|
|
261
|
+
local arrived = fakePlayer(111)
|
|
262
|
+
teleportDataService:SetNonTrustedArrivedTeleportDataForTesting(arrived, {
|
|
252
263
|
[SaveSlotConstants.TELEPORT_DATA_SLOT_KEY] = "slot-1",
|
|
253
264
|
})
|
|
254
|
-
expect(saveSlotService:IsInternalTeleport(arrived)).toEqual(true)
|
|
255
265
|
|
|
256
|
-
|
|
257
|
-
teleportDataService:SetArrivedTeleportDataForTesting(fresh, {})
|
|
258
|
-
expect(saveSlotService:IsInternalTeleport(fresh)).toEqual(false)
|
|
266
|
+
expect(awaitBool(saveSlotService:PromiseIsInternalTeleport(arrived))).toEqual(true)
|
|
259
267
|
|
|
260
268
|
arrived:Destroy()
|
|
269
|
+
serviceBag:Destroy()
|
|
270
|
+
end)
|
|
271
|
+
|
|
272
|
+
it("should report a server-initiated teleport (trusted band) as internal", function()
|
|
273
|
+
local serviceBag, saveSlotService, teleportDataService = newServiceBag()
|
|
274
|
+
serviceBag:Start()
|
|
275
|
+
|
|
276
|
+
local arrived = fakePlayer(111)
|
|
277
|
+
teleportDataService:SetTrustedArrivedTeleportDataForTesting(arrived, {
|
|
278
|
+
[SaveSlotConstants.TELEPORT_DATA_SLOT_KEY] = "slot-1",
|
|
279
|
+
})
|
|
280
|
+
teleportDataService:SetNonTrustedArrivedTeleportDataForTesting(arrived, nil) -- no client band; seals
|
|
281
|
+
|
|
282
|
+
expect(awaitBool(saveSlotService:PromiseIsInternalTeleport(arrived))).toEqual(true)
|
|
283
|
+
|
|
284
|
+
arrived:Destroy()
|
|
285
|
+
serviceBag:Destroy()
|
|
286
|
+
end)
|
|
287
|
+
|
|
288
|
+
it("should report a fresh join (no arrived data) as not internal", function()
|
|
289
|
+
local serviceBag, saveSlotService, teleportDataService = newServiceBag()
|
|
290
|
+
serviceBag:Start()
|
|
291
|
+
|
|
292
|
+
local fresh = fakePlayer(111)
|
|
293
|
+
teleportDataService:SetNonTrustedArrivedTeleportDataForTesting(fresh, nil) -- fresh-join sentinel; seals
|
|
294
|
+
|
|
295
|
+
expect(awaitBool(saveSlotService:PromiseIsInternalTeleport(fresh))).toEqual(false)
|
|
296
|
+
|
|
261
297
|
fresh:Destroy()
|
|
262
298
|
serviceBag:Destroy()
|
|
263
299
|
end)
|
|
@@ -51,15 +51,16 @@ function HasSaveSlotsBase.new(player: Player, serviceBag: ServiceBag.ServiceBag)
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
--[=[
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[TeleportDataService]
|
|
57
|
-
"no incoming
|
|
54
|
+
Resolves the save-slot id the player teleported in with, or nil. Realm hook: the server reads it from
|
|
55
|
+
the client-replicated teleport data, the client from the local player's teleport data (both via the
|
|
56
|
+
[TeleportDataService] unified read, which is a promise because the server must wait for the client to
|
|
57
|
+
replicate). The base default resolves nil so a realm that never sets one degrades to "no incoming
|
|
58
|
+
slot".
|
|
58
59
|
|
|
59
|
-
@return SaveSlotData.SlotId
|
|
60
|
+
@return Promise<SaveSlotData.SlotId?>
|
|
60
61
|
]=]
|
|
61
|
-
function HasSaveSlotsBase.
|
|
62
|
-
return nil
|
|
62
|
+
function HasSaveSlotsBase.PromiseIncomingSlotId(_self: HasSaveSlotsBase): Promise.Promise<SaveSlotData.SlotId?>
|
|
63
|
+
return (Promise :: any).resolved(nil)
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
--[=[
|
|
@@ -69,12 +70,13 @@ end
|
|
|
69
70
|
@return Promise<boolean>
|
|
70
71
|
]=]
|
|
71
72
|
function HasSaveSlotsBase.PromiseHasSaveSlotFromTeleport(self: HasSaveSlotsBase): Promise.Promise<boolean>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
return self:PromiseIncomingSlotId():Then(function(slotId: SaveSlotData.SlotId?)
|
|
74
|
+
if type(slotId) ~= "string" then
|
|
75
|
+
return false
|
|
76
|
+
end
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
return (self :: any):PromiseHasSlot(slotId)
|
|
79
|
+
end)
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
--[=[
|
|
@@ -85,18 +87,19 @@ end
|
|
|
85
87
|
@return Promise<SaveSlotData.SlotId?>
|
|
86
88
|
]=]
|
|
87
89
|
function HasSaveSlotsBase.PromiseLoadSaveSlotFromTeleport(self: HasSaveSlotsBase): Promise.Promise<SaveSlotData.SlotId?>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return (Promise :: any).resolved(nil)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
return (self :: any):PromiseHasSlot(slotId):Then(function(hasSlot: boolean)
|
|
94
|
-
if not hasSlot then
|
|
90
|
+
return self:PromiseIncomingSlotId():Then(function(slotId: SaveSlotData.SlotId?)
|
|
91
|
+
if type(slotId) ~= "string" then
|
|
95
92
|
return nil
|
|
96
93
|
end
|
|
97
94
|
|
|
98
|
-
return (self :: any):
|
|
99
|
-
|
|
95
|
+
return (self :: any):PromiseHasSlot(slotId):Then(function(hasSlot: boolean)
|
|
96
|
+
if not hasSlot then
|
|
97
|
+
return nil
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
return (self :: any):PromiseSelectSlot(slotId):Then(function()
|
|
101
|
+
return slotId
|
|
102
|
+
end)
|
|
100
103
|
end)
|
|
101
104
|
end)
|
|
102
105
|
end
|