@quenty/timesyncservice 13.18.3 → 13.18.4-canary.11a5dcf.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,17 @@
|
|
|
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
|
+
## [13.18.4-canary.11a5dcf.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/timesyncservice@13.18.3...@quenty/timesyncservice@13.18.4-canary.11a5dcf.0) (2025-05-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [13.18.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/timesyncservice@13.18.2...@quenty/timesyncservice@13.18.3) (2025-04-10)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/timesyncservice
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/timesyncservice",
|
|
3
|
-
"version": "13.18.
|
|
3
|
+
"version": "13.18.4-canary.11a5dcf.0",
|
|
4
4
|
"description": "Quenty's TimeSyncService keeps time synchronized between all clients and the server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/baseobject": "
|
|
30
|
-
"@quenty/loader": "
|
|
31
|
-
"@quenty/maid": "
|
|
32
|
-
"@quenty/promise": "
|
|
33
|
-
"@quenty/remoting": "
|
|
34
|
-
"@quenty/rx": "
|
|
35
|
-
"@quenty/signal": "
|
|
36
|
-
"@quenty/table": "
|
|
37
|
-
"@quenty/valueobject": "
|
|
29
|
+
"@quenty/baseobject": "10.8.4-canary.11a5dcf.0",
|
|
30
|
+
"@quenty/loader": "10.8.4-canary.11a5dcf.0",
|
|
31
|
+
"@quenty/maid": "3.4.4-canary.11a5dcf.0",
|
|
32
|
+
"@quenty/promise": "10.10.5-canary.11a5dcf.0",
|
|
33
|
+
"@quenty/remoting": "12.18.4-canary.11a5dcf.0",
|
|
34
|
+
"@quenty/rx": "13.17.4-canary.11a5dcf.0",
|
|
35
|
+
"@quenty/signal": "7.10.4-canary.11a5dcf.0",
|
|
36
|
+
"@quenty/table": "3.7.5-canary.11a5dcf.0",
|
|
37
|
+
"@quenty/valueobject": "13.17.4-canary.11a5dcf.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "11a5dcf7d4c7a0bfbf3337e97d30e8346ea09d3f"
|
|
43
43
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
|
|
3
|
+
local require = require(script.Parent.loader).load(script)
|
|
4
|
+
|
|
5
|
+
local Observable = require("Observable")
|
|
6
|
+
|
|
7
|
+
export type ClockFunction = () -> number
|
|
8
|
+
|
|
9
|
+
export type BaseClock = {
|
|
10
|
+
GetTime: (self: BaseClock) -> number,
|
|
11
|
+
GetPing: (self: BaseClock) -> number,
|
|
12
|
+
IsSynced: (self: BaseClock) -> boolean,
|
|
13
|
+
ObservePing: (self: BaseClock) -> Observable.Observable<number>,
|
|
14
|
+
GetClockFunction: (self: BaseClock) -> ClockFunction,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {}
|
|
@@ -6,24 +6,23 @@
|
|
|
6
6
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
|
+
local BaseClock = require("BaseClock")
|
|
9
10
|
local BaseObject = require("BaseObject")
|
|
11
|
+
local Observable = require("Observable")
|
|
10
12
|
local Rx = require("Rx")
|
|
11
|
-
local _Observable = require("Observable")
|
|
12
13
|
|
|
13
14
|
local MasterClock = setmetatable({}, BaseObject)
|
|
14
15
|
MasterClock.__index = MasterClock
|
|
15
16
|
MasterClock.ClassName = "MasterClock"
|
|
16
17
|
|
|
17
|
-
export type ClockFunction = () -> number
|
|
18
|
-
|
|
19
18
|
export type MasterClock = typeof(setmetatable(
|
|
20
19
|
{} :: {
|
|
21
20
|
_remoteEvent: RemoteEvent,
|
|
22
21
|
_remoteFunction: RemoteFunction,
|
|
23
|
-
_clockFunction: ClockFunction,
|
|
22
|
+
_clockFunction: BaseClock.ClockFunction,
|
|
24
23
|
},
|
|
25
24
|
{} :: typeof({ __index = MasterClock })
|
|
26
|
-
)) & BaseObject.BaseObject
|
|
25
|
+
)) & BaseObject.BaseObject & BaseClock.BaseClock
|
|
27
26
|
|
|
28
27
|
--[=[
|
|
29
28
|
Constructs a new MasterClock
|
|
@@ -69,7 +68,7 @@ end
|
|
|
69
68
|
|
|
70
69
|
@return function
|
|
71
70
|
]=]
|
|
72
|
-
function MasterClock.GetClockFunction(self: MasterClock): ClockFunction
|
|
71
|
+
function MasterClock.GetClockFunction(self: MasterClock): BaseClock.ClockFunction
|
|
73
72
|
return self._clockFunction
|
|
74
73
|
end
|
|
75
74
|
|
|
@@ -78,7 +77,7 @@ end
|
|
|
78
77
|
|
|
79
78
|
@return Observable<number>
|
|
80
79
|
]=]
|
|
81
|
-
function MasterClock.ObservePing(_self: MasterClock):
|
|
80
|
+
function MasterClock.ObservePing(_self: MasterClock): Observable.Observable<number>
|
|
82
81
|
return Rx.of(0) :: any
|
|
83
82
|
end
|
|
84
83
|
|
|
@@ -6,22 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
|
+
local BaseClock = require("BaseClock")
|
|
9
10
|
local BaseObject = require("BaseObject")
|
|
11
|
+
local Observable = require("Observable")
|
|
10
12
|
local ValueObject = require("ValueObject")
|
|
11
|
-
local _Observable = require("Observable")
|
|
12
13
|
|
|
13
14
|
local SlaveClock = setmetatable({}, BaseObject)
|
|
14
15
|
SlaveClock.__index = SlaveClock
|
|
15
16
|
SlaveClock.ClassName = "SlaveClock"
|
|
16
17
|
SlaveClock._offset = -1 -- Set uncalculated values to -1
|
|
17
18
|
|
|
18
|
-
export type ClockFunction = () -> number
|
|
19
|
-
|
|
20
19
|
export type SlaveClock = typeof(setmetatable(
|
|
21
20
|
{} :: {
|
|
22
21
|
_remoteEvent: RemoteEvent,
|
|
23
22
|
_remoteFunction: RemoteFunction,
|
|
24
|
-
_clockFunction: ClockFunction,
|
|
23
|
+
_clockFunction: BaseClock.ClockFunction,
|
|
25
24
|
_ping: ValueObject.ValueObject<number>,
|
|
26
25
|
_offset: number,
|
|
27
26
|
_pneWayDelay: number,
|
|
@@ -30,7 +29,7 @@ export type SlaveClock = typeof(setmetatable(
|
|
|
30
29
|
SyncedEvent: RBXScriptSignal,
|
|
31
30
|
},
|
|
32
31
|
{} :: typeof({ __index = SlaveClock })
|
|
33
|
-
)) & BaseObject.BaseObject
|
|
32
|
+
)) & BaseObject.BaseObject & BaseClock.BaseClock
|
|
34
33
|
|
|
35
34
|
--[=[
|
|
36
35
|
Constructs a new SlaveClock
|
|
@@ -67,11 +66,11 @@ end
|
|
|
67
66
|
|
|
68
67
|
@return function
|
|
69
68
|
]=]
|
|
70
|
-
function SlaveClock.GetClockFunction(self: SlaveClock): ClockFunction
|
|
69
|
+
function SlaveClock.GetClockFunction(self: SlaveClock): BaseClock.ClockFunction
|
|
71
70
|
return self._clockFunction
|
|
72
71
|
end
|
|
73
72
|
|
|
74
|
-
function SlaveClock.ObservePing(self: SlaveClock):
|
|
73
|
+
function SlaveClock.ObservePing(self: SlaveClock): Observable.Observable<number>
|
|
75
74
|
return self._ping:Observe()
|
|
76
75
|
end
|
|
77
76
|
|
|
@@ -10,10 +10,12 @@ local require = require(script.Parent.loader).load(script)
|
|
|
10
10
|
|
|
11
11
|
local RunService = game:GetService("RunService")
|
|
12
12
|
|
|
13
|
+
local BaseClock = require("BaseClock")
|
|
13
14
|
local GetRemoteEvent = require("GetRemoteEvent")
|
|
14
15
|
local GetRemoteFunction = require("GetRemoteFunction")
|
|
15
16
|
local Maid = require("Maid")
|
|
16
17
|
local MasterClock = require("MasterClock")
|
|
18
|
+
local Observable = require("Observable")
|
|
17
19
|
local Promise = require("Promise")
|
|
18
20
|
local PromiseGetRemoteEvent = require("PromiseGetRemoteEvent")
|
|
19
21
|
local PromiseGetRemoteFunction = require("PromiseGetRemoteFunction")
|
|
@@ -22,12 +24,11 @@ local Rx = require("Rx")
|
|
|
22
24
|
local SlaveClock = require("SlaveClock")
|
|
23
25
|
local TimeSyncConstants = require("TimeSyncConstants")
|
|
24
26
|
local TimeSyncUtils = require("TimeSyncUtils")
|
|
25
|
-
local _Observable = require("Observable")
|
|
26
27
|
|
|
27
28
|
local TimeSyncService = {}
|
|
28
29
|
TimeSyncService.ServiceName = "TimeSyncService"
|
|
29
30
|
|
|
30
|
-
export type SyncedClock =
|
|
31
|
+
export type SyncedClock = BaseClock.BaseClock
|
|
31
32
|
|
|
32
33
|
export type TimeSyncService = typeof(setmetatable(
|
|
33
34
|
{} :: {
|
|
@@ -75,6 +76,32 @@ function TimeSyncService.IsSynced(self: TimeSyncService): boolean
|
|
|
75
76
|
return self._clockPromise:IsFulfilled()
|
|
76
77
|
end
|
|
77
78
|
|
|
79
|
+
local function buildMockClock(): SyncedClock
|
|
80
|
+
local mock = {}
|
|
81
|
+
|
|
82
|
+
function mock.IsSynced(_this: SyncedClock): boolean
|
|
83
|
+
return true
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
function mock.GetTime(_this: SyncedClock): number
|
|
87
|
+
return tick()
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
function mock.GetPing(_this: SyncedClock): number
|
|
91
|
+
return 0
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
function mock.GetClockFunction(_this: SyncedClock): BaseClock.ClockFunction
|
|
95
|
+
return tick
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
function mock.ObservePing(_this: SyncedClock): Observable.Observable<number>
|
|
99
|
+
return Rx.of(0) :: any
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
return mock
|
|
103
|
+
end
|
|
104
|
+
|
|
78
105
|
--[=[
|
|
79
106
|
Waits for the synced clock, or throws an error.
|
|
80
107
|
|
|
@@ -83,7 +110,7 @@ end
|
|
|
83
110
|
]=]
|
|
84
111
|
function TimeSyncService.WaitForSyncedClock(self: TimeSyncService): SyncedClock
|
|
85
112
|
if not RunService:IsRunning() then
|
|
86
|
-
return
|
|
113
|
+
return buildMockClock()
|
|
87
114
|
end
|
|
88
115
|
|
|
89
116
|
assert(self._clockPromise, "TimeSyncService is not initialized")
|
|
@@ -97,7 +124,7 @@ end
|
|
|
97
124
|
]=]
|
|
98
125
|
function TimeSyncService.GetSyncedClock(self: TimeSyncService): SyncedClock?
|
|
99
126
|
if not RunService:IsRunning() then
|
|
100
|
-
return
|
|
127
|
+
return buildMockClock()
|
|
101
128
|
end
|
|
102
129
|
|
|
103
130
|
assert(self._clockPromise, "TimeSyncService is not initialized")
|
|
@@ -115,35 +142,17 @@ end
|
|
|
115
142
|
]=]
|
|
116
143
|
function TimeSyncService.PromiseSyncedClock(self: TimeSyncService): Promise.Promise<SyncedClock>
|
|
117
144
|
if not RunService:IsRunning() then
|
|
118
|
-
return Promise.resolved(
|
|
145
|
+
return Promise.resolved(buildMockClock())
|
|
119
146
|
end
|
|
120
147
|
|
|
121
148
|
assert(self._clockPromise, "TimeSyncService is not initialized")
|
|
122
149
|
return Promise.resolved(self._clockPromise)
|
|
123
150
|
end
|
|
124
151
|
|
|
125
|
-
function TimeSyncService.ObserveSyncedClock(self: TimeSyncService):
|
|
152
|
+
function TimeSyncService.ObserveSyncedClock(self: TimeSyncService): Observable.Observable<SyncedClock>
|
|
126
153
|
return Rx.fromPromise(self:PromiseSyncedClock()) :: any
|
|
127
154
|
end
|
|
128
155
|
|
|
129
|
-
function TimeSyncService._buildMockClock(_self: TimeSyncService): any
|
|
130
|
-
local mock = {}
|
|
131
|
-
|
|
132
|
-
function mock.IsSynced(_self)
|
|
133
|
-
return true
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
function mock.GetTime(_self)
|
|
137
|
-
return tick()
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
function mock.GetPing(_self)
|
|
141
|
-
return 0
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
return mock
|
|
145
|
-
end
|
|
146
|
-
|
|
147
156
|
function TimeSyncService._buildMasterClock(self: TimeSyncService): MasterClock.MasterClock
|
|
148
157
|
local remoteEvent = GetRemoteEvent(TimeSyncConstants.REMOTE_EVENT_NAME)
|
|
149
158
|
local remoteFunction = GetRemoteFunction(TimeSyncConstants.REMOTE_FUNCTION_NAME)
|
|
@@ -173,4 +182,4 @@ function TimeSyncService.Destroy(self: TimeSyncService)
|
|
|
173
182
|
self._maid:DoCleaning()
|
|
174
183
|
end
|
|
175
184
|
|
|
176
|
-
return TimeSyncService
|
|
185
|
+
return TimeSyncService
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
|
-
local Promise = require("Promise")
|
|
10
9
|
local Maid = require("Maid")
|
|
10
|
+
local Promise = require("Promise")
|
|
11
11
|
|
|
12
12
|
local TimeSyncUtils = {}
|
|
13
13
|
|
|
@@ -40,4 +40,4 @@ function TimeSyncUtils.promiseClockSynced(clock: any): Promise.Promise<any>
|
|
|
40
40
|
return promise
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
return TimeSyncUtils
|
|
43
|
+
return TimeSyncUtils
|