@quenty/soundgroup 1.20.2 → 1.20.3

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,14 @@
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.20.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/soundgroup@1.20.2...@quenty/soundgroup@1.20.3) (2025-04-10)
7
+
8
+ **Note:** Version bump only for package @quenty/soundgroup
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.20.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/soundgroup@1.20.0...@quenty/soundgroup@1.20.2) (2025-04-07)
7
15
 
8
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/soundgroup",
3
- "version": "1.20.2",
3
+ "version": "1.20.3",
4
4
  "description": "Service and utility methods to working with sound groups and sounds in Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,18 +25,18 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/baseobject": "^10.8.2",
29
- "@quenty/counter": "^7.17.2",
30
- "@quenty/instanceutils": "^13.17.2",
31
- "@quenty/loader": "^10.8.2",
32
- "@quenty/maid": "^3.4.2",
33
- "@quenty/observablecollection": "^12.20.2",
34
- "@quenty/rx": "^13.17.2",
35
- "@quenty/table": "^3.7.3",
36
- "@quenty/valueobject": "^13.17.2"
28
+ "@quenty/baseobject": "^10.8.3",
29
+ "@quenty/counter": "^7.17.3",
30
+ "@quenty/instanceutils": "^13.17.3",
31
+ "@quenty/loader": "^10.8.3",
32
+ "@quenty/maid": "^3.4.3",
33
+ "@quenty/observablecollection": "^12.20.3",
34
+ "@quenty/rx": "^13.17.3",
35
+ "@quenty/table": "^3.7.4",
36
+ "@quenty/valueobject": "^13.17.3"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "64def70499ec067077ee39f279936b620b217847"
41
+ "gitHead": "b06c070ae91d5dab7bd8de6e290ad2caabb15d8f"
42
42
  }
@@ -1,4 +1,7 @@
1
+ --!strict
1
2
  --[=[
3
+ Holds sound effects to be applied
4
+
2
5
  @class SoundEffectsList
3
6
  ]=]
4
7
 
@@ -11,13 +14,29 @@ local MaidTaskUtils = require("MaidTaskUtils")
11
14
  local ValueObject = require("ValueObject")
12
15
  local Counter = require("Counter")
13
16
  local Rx = require("Rx")
17
+ local _Signal = require("Signal")
18
+ local _Observable = require("Observable")
14
19
 
15
20
  local SoundEffectsList = setmetatable({}, BaseObject)
16
21
  SoundEffectsList.ClassName = "SoundEffectsList"
17
22
  SoundEffectsList.__index = SoundEffectsList
18
23
 
19
- function SoundEffectsList.new()
20
- local self = setmetatable(BaseObject.new(), SoundEffectsList)
24
+ export type SoundEffectApplier = (SoundGroup | Sound) -> MaidTaskUtils.MaidTask?
25
+
26
+ export type SoundEffectsList = typeof(setmetatable(
27
+ {} :: {
28
+ _effectList: ObservableList.ObservableList<SoundEffectApplier>,
29
+ _appliedCount: Counter.Counter,
30
+ _isActive: ValueObject.ValueObject<boolean>,
31
+ _hasEffects: ValueObject.ValueObject<boolean>,
32
+ IsActiveChanged: _Signal.Signal<boolean>,
33
+ HasEffects: () -> boolean,
34
+ },
35
+ {} :: typeof({ __index = SoundEffectsList })
36
+ )) & BaseObject.BaseObject
37
+
38
+ function SoundEffectsList.new(): SoundEffectsList
39
+ local self: SoundEffectsList = setmetatable(BaseObject.new() :: any, SoundEffectsList)
21
40
 
22
41
  self._effectList = self._maid:Add(ObservableList.new())
23
42
  self._appliedCount = self._maid:Add(Counter.new())
@@ -26,11 +45,11 @@ function SoundEffectsList.new()
26
45
  self._isActive = self._maid:Add(ValueObject.new(false, "boolean"))
27
46
  self._hasEffects = self._maid:Add(ValueObject.new(false, "boolean"))
28
47
 
29
- self.IsActiveChanged = assert(self._isActive.Changed, "No Changed")
48
+ self.IsActiveChanged = assert(self._isActive.Changed :: any, "No Changed")
30
49
 
31
50
  self._maid:GiveTask(Rx.combineLatest({
32
- appliedCount = self._appliedCount:Observe();
33
- effectCount = self._effectList:ObserveCount();
51
+ appliedCount = self._appliedCount:Observe(),
52
+ effectCount = self._effectList:ObserveCount(),
34
53
  }):Subscribe(function(state)
35
54
  self._hasEffects.Value = state.effectCount > 0
36
55
  self._isActive.Value = state.appliedCount > 0 or state.effectCount > 0
@@ -39,15 +58,28 @@ function SoundEffectsList.new()
39
58
  return self
40
59
  end
41
60
 
42
- function SoundEffectsList:HasEffects()
61
+ --[=[
62
+ Returns the number of effects that are currently applied.
63
+
64
+ @return boolean
65
+ ]=]
66
+ function SoundEffectsList.HasEffects(self: SoundEffectsList): boolean
43
67
  return self._hasEffects.Value
44
68
  end
45
69
 
46
- function SoundEffectsList:ObserveHasEffects()
70
+ --[=[
71
+ Observes whether the list has any effects.
72
+
73
+ @return Observable<boolean>
74
+ ]=]
75
+ function SoundEffectsList.ObserveHasEffects(self: SoundEffectsList): _Observable.Observable<boolean>
47
76
  return self._hasEffects:Observe()
48
77
  end
49
78
 
50
- function SoundEffectsList:IsActive(): boolean
79
+ --[=[
80
+ Rounds whether the list is effective or not.
81
+ ]=]
82
+ function SoundEffectsList.IsActive(self: SoundEffectsList): boolean
51
83
  return self._isActive.Value
52
84
  end
53
85
 
@@ -58,7 +90,7 @@ end
58
90
  @param effect (instance) -> MaidTask
59
91
  @return () -> () -- Cleanup call
60
92
  ]=]
61
- function SoundEffectsList:PushEffect(effect: () -> ())
93
+ function SoundEffectsList.PushEffect(self: SoundEffectsList, effect: SoundEffectApplier): () -> ()
62
94
  assert(type(effect) == "function", "Bad effect")
63
95
 
64
96
  return self._effectList:Add(effect)
@@ -71,7 +103,7 @@ end
71
103
  @param instance SoundGroup | Sound
72
104
  @return () -> () -- Cleanup call
73
105
  ]=]
74
- function SoundEffectsList:ApplyEffects(instance)
106
+ function SoundEffectsList.ApplyEffects(self: SoundEffectsList, instance: SoundGroup | Sound): () -> ()
75
107
  assert(typeof(instance) == "Instance" and (instance:IsA("SoundGroup") or instance:IsA("Sound")), "Bad instance")
76
108
 
77
109
  local topMaid = Maid.new()
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Allows us to independently apply sound effects to both sound groups and to
3
4
  individual sounds.
@@ -13,13 +14,23 @@ local ObservableMap = require("ObservableMap")
13
14
  local SoundEffectsList = require("SoundEffectsList")
14
15
  local SoundGroupPathUtils = require("SoundGroupPathUtils")
15
16
  local ObservableSet = require("ObservableSet")
17
+ local _Observable = require("Observable")
18
+ local _Brio = require("Brio")
16
19
 
17
20
  local SoundEffectsRegistry = setmetatable({}, BaseObject)
18
21
  SoundEffectsRegistry.ClassName = "SoundEffectsRegistry"
19
22
  SoundEffectsRegistry.__index = SoundEffectsRegistry
20
23
 
21
- function SoundEffectsRegistry.new()
22
- local self = setmetatable(BaseObject.new(), SoundEffectsRegistry)
24
+ export type SoundEffectsRegistry = typeof(setmetatable(
25
+ {} :: {
26
+ _pathToEffectList: ObservableMap.ObservableMap<string, SoundEffectsList.SoundEffectsList>,
27
+ _activeEffectsPathSet: ObservableSet.ObservableSet<string>,
28
+ },
29
+ {} :: typeof({ __index = SoundEffectsRegistry })
30
+ )) & BaseObject.BaseObject
31
+
32
+ function SoundEffectsRegistry.new(): SoundEffectsRegistry
33
+ local self: SoundEffectsRegistry = setmetatable(BaseObject.new() :: any, SoundEffectsRegistry)
23
34
 
24
35
  self._pathToEffectList = self._maid:Add(ObservableMap.new())
25
36
  self._activeEffectsPathSet = self._maid:Add(ObservableSet.new())
@@ -27,7 +38,11 @@ function SoundEffectsRegistry.new()
27
38
  return self
28
39
  end
29
40
 
30
- function SoundEffectsRegistry:PushEffect(soundGroupPath, effect)
41
+ function SoundEffectsRegistry.PushEffect(
42
+ self: SoundEffectsRegistry,
43
+ soundGroupPath: string,
44
+ effect: SoundEffectsList.SoundEffectApplier
45
+ ): () -> ()
31
46
  assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
32
47
  assert(type(effect) == "function", "Bad effect")
33
48
 
@@ -35,7 +50,11 @@ function SoundEffectsRegistry:PushEffect(soundGroupPath, effect)
35
50
  return effectsList:PushEffect(effect)
36
51
  end
37
52
 
38
- function SoundEffectsRegistry:ApplyEffects(soundGroupPath, instance)
53
+ function SoundEffectsRegistry.ApplyEffects(
54
+ self: SoundEffectsRegistry,
55
+ soundGroupPath: string,
56
+ instance: SoundGroup | Sound
57
+ ): () -> ()
39
58
  assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
40
59
  assert(typeof(instance) == "Instance" and (instance:IsA("SoundGroup") or instance:IsA("Sound")), "Bad instance")
41
60
 
@@ -43,11 +62,13 @@ function SoundEffectsRegistry:ApplyEffects(soundGroupPath, instance)
43
62
  return effectsList:ApplyEffects(instance)
44
63
  end
45
64
 
46
- function SoundEffectsRegistry:ObserveActiveEffectsPathBrios()
47
- return self._activeEffectsPathSet:ObserveItemsBrio()
65
+ function SoundEffectsRegistry.ObserveActiveEffectsPathBrios(
66
+ self: SoundEffectsRegistry
67
+ ): _Observable.Observable<_Brio.Brio<string>>
68
+ return self._activeEffectsPathSet:ObserveItemsBrio() :: any
48
69
  end
49
70
 
50
- function SoundEffectsRegistry:_getOrCreateEffectList(soundGroupPath)
71
+ function SoundEffectsRegistry._getOrCreateEffectList(self: SoundEffectsRegistry, soundGroupPath: string): SoundEffectsList.SoundEffectsList
51
72
  assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
52
73
 
53
74
  local found = self._pathToEffectList:Get(soundGroupPath)
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  @class WellKnownSoundGroups
3
4
  ]=]
@@ -6,10 +7,17 @@ local require = require(script.Parent.loader).load(script)
6
7
 
7
8
  local Table = require("Table")
8
9
 
10
+ export type WellKnownSoundGroups = {
11
+ MASTER: "Master",
12
+ SFX: "Master.SoundEffects",
13
+ MUSIC: "Master.Music",
14
+ VOICE: "Master.Voice",
15
+ }
16
+
9
17
  return Table.readonly({
10
- MASTER = "Master";
18
+ MASTER = "Master",
11
19
 
12
- SFX = "Master.SoundEffects";
13
- MUSIC = "Master.Music";
14
- VOICE = "Master.Voice";
15
- })
20
+ SFX = "Master.SoundEffects",
21
+ MUSIC = "Master.Music",
22
+ VOICE = "Master.Voice",
23
+ } :: WellKnownSoundGroups)
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  @class SoundGroupTracker
3
4
  ]=]
@@ -9,7 +10,7 @@ local RxInstanceUtils = require("RxInstanceUtils")
9
10
  local ObservableMapList = require("ObservableMapList")
10
11
  local Maid = require("Maid")
11
12
  local ObservableMap = require("ObservableMap")
12
- local SoundGroupPathUtils= require("SoundGroupPathUtils")
13
+ local SoundGroupPathUtils = require("SoundGroupPathUtils")
13
14
  local Rx = require("Rx")
14
15
  local Observable = require("Observable")
15
16
 
@@ -17,8 +18,16 @@ local SoundGroupTracker = setmetatable({}, BaseObject)
17
18
  SoundGroupTracker.ClassName = "SoundGroupTracker"
18
19
  SoundGroupTracker.__index = SoundGroupTracker
19
20
 
20
- function SoundGroupTracker.new(root)
21
- local self = setmetatable(BaseObject.new(), SoundGroupTracker)
21
+ export type SoundGroupTracker = typeof(setmetatable(
22
+ {} :: {
23
+ _pathToSoundGroupList: ObservableMapList.ObservableMapList<string, SoundGroup>,
24
+ _soundGroupToPath: ObservableMap.ObservableMap<SoundGroup, string>,
25
+ },
26
+ {} :: typeof({ __index = SoundGroupTracker })
27
+ )) & BaseObject.BaseObject
28
+
29
+ function SoundGroupTracker.new(root): SoundGroupTracker
30
+ local self: SoundGroupTracker = setmetatable(BaseObject.new() :: any, SoundGroupTracker)
22
31
 
23
32
  -- Handle edge case of multiple sound groups with the same name...
24
33
  self._pathToSoundGroupList = self._maid:Add(ObservableMapList.new())
@@ -31,39 +40,39 @@ function SoundGroupTracker.new(root)
31
40
  return self
32
41
  end
33
42
 
34
- function SoundGroupTracker:GetFirstSoundGroup(soundGroupPath)
43
+ function SoundGroupTracker.GetFirstSoundGroup(self: SoundGroupTracker, soundGroupPath)
35
44
  assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
36
45
 
37
46
  return self._pathToSoundGroupList:GetAtListIndex(soundGroupPath, 1)
38
47
  end
39
48
 
40
- function SoundGroupTracker:ObserveSoundGroup(soundGroupPath)
49
+ function SoundGroupTracker.ObserveSoundGroup(self: SoundGroupTracker, soundGroupPath)
41
50
  assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
42
51
 
43
52
  return self._pathToSoundGroupList:ObserveAtListIndex(soundGroupPath, 1)
44
53
  end
45
54
 
46
- function SoundGroupTracker:ObserveSoundGroupBrio(soundGroupPath)
55
+ function SoundGroupTracker.ObserveSoundGroupBrio(self: SoundGroupTracker, soundGroupPath)
47
56
  assert(SoundGroupPathUtils.isSoundGroupPath(soundGroupPath), "Bad soundGroupPath")
48
57
 
49
58
  return self._pathToSoundGroupList:ObserveAtListIndexBrio(soundGroupPath, 1)
50
59
  end
51
60
 
52
- function SoundGroupTracker:ObserveSoundGroupsBrio()
61
+ function SoundGroupTracker.ObserveSoundGroupsBrio(self: SoundGroupTracker)
53
62
  return self._soundGroupToPath:ObserveKeysBrio()
54
63
  end
55
64
 
56
- function SoundGroupTracker:Track(parent)
65
+ function SoundGroupTracker.Track(self: SoundGroupTracker, parent)
57
66
  return self:_track(nil, parent)
58
67
  end
59
68
 
60
- function SoundGroupTracker:ObserveSoundGroupPath(soundGroup)
69
+ function SoundGroupTracker.ObserveSoundGroupPath(self: SoundGroupTracker, soundGroup)
61
70
  assert(typeof(soundGroup) == "Instance" and soundGroup:IsA("SoundGroup"), "Bad soundGroup")
62
71
 
63
72
  return self._soundGroupToPath:ObserveAtKey(soundGroup)
64
73
  end
65
74
 
66
- function SoundGroupTracker:_track(observeRootPath, parent)
75
+ function SoundGroupTracker._track(self: SoundGroupTracker, observeRootPath, parent)
67
76
  assert(Observable.isObservable(observeRootPath) or observeRootPath == nil, "Bad observeRootPath")
68
77
  assert(typeof(parent) == "Instance", "Bad parent")
69
78
 
@@ -76,6 +85,7 @@ function SoundGroupTracker:_track(observeRootPath, parent)
76
85
 
77
86
  local maid, soundGroup = brio:ToMaidAndValue()
78
87
 
88
+ -- stylua: ignore
79
89
  local observePath = Rx.combineLatest({
80
90
  rootPath = observeRootPath or nil;
81
91
  name = RxInstanceUtils.observeProperty(soundGroup, "Name");
@@ -87,11 +97,11 @@ function SoundGroupTracker:_track(observeRootPath, parent)
87
97
  else
88
98
  return state.name
89
99
  end
90
- end)
100
+ end) :: any
91
101
  })
92
102
 
93
103
  maid:Add(observePath:Subscribe(function(path)
94
- maid._currentPath = self._soundGroupToPath:Set(soundGroup, path)
104
+ maid._currentPath = self._soundGroupToPath:Set(soundGroup :: SoundGroup, path)
95
105
  end))
96
106
  maid:Add(self._pathToSoundGroupList:Push(observePath, soundGroup))
97
107