@quenty/colorpalette 10.7.0 → 10.9.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,25 @@
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
+ # [10.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorpalette@10.8.0...@quenty/colorpalette@10.9.0) (2024-10-04)
7
+
8
+ **Note:** Version bump only for package @quenty/colorpalette
9
+
10
+
11
+
12
+
13
+
14
+ # [10.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorpalette@10.7.0...@quenty/colorpalette@10.8.0) (2024-09-25)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * Ensure backwards compatibility ([97995a8](https://github.com/Quenty/NevermoreEngine/commit/97995a812c8d1d8489104b16e7ac443fbb2effec))
20
+
21
+
22
+
23
+
24
+
6
25
  # [10.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorpalette@10.6.2...@quenty/colorpalette@10.7.0) (2024-09-25)
7
26
 
8
27
  **Note:** Version bump only for package @quenty/colorpalette
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/colorpalette",
3
- "version": "10.7.0",
3
+ "version": "10.9.0",
4
4
  "description": "Color palette system for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -28,17 +28,18 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@quenty/baseobject": "^10.5.0",
32
- "@quenty/blend": "^12.6.0",
33
- "@quenty/color3utils": "^11.6.0",
34
- "@quenty/colorpicker": "^10.7.0",
35
- "@quenty/loader": "^10.5.0",
36
- "@quenty/maid": "^3.3.0",
31
+ "@quenty/baseobject": "^10.6.0",
32
+ "@quenty/blend": "^12.8.0",
33
+ "@quenty/color3utils": "^11.8.0",
34
+ "@quenty/colorpicker": "^10.9.0",
35
+ "@quenty/loader": "^10.6.0",
36
+ "@quenty/maid": "^3.4.0",
37
37
  "@quenty/math": "^2.7.0",
38
- "@quenty/rx": "^13.6.0",
39
- "@quenty/signal": "^7.5.0",
38
+ "@quenty/observablecollection": "^12.8.0",
39
+ "@quenty/rx": "^13.8.0",
40
+ "@quenty/signal": "^7.7.0",
40
41
  "@quenty/table": "^3.5.0",
41
- "@quenty/valueobject": "^13.6.0"
42
+ "@quenty/valueobject": "^13.8.0"
42
43
  },
43
- "gitHead": "41715b15e2b48b2d22ff4f5277a8d4b7a0d32ef3"
44
+ "gitHead": "035abfa088c854a73e1c65b350267eaa17669646"
44
45
  }
@@ -9,13 +9,11 @@ local ValueObject = require("ValueObject")
9
9
  local ColorSwatch = require("ColorSwatch")
10
10
  local ColorGradePalette = require("ColorGradePalette")
11
11
  local Rx = require("Rx")
12
- local Maid = require("Maid")
13
12
  local Blend = require("Blend")
14
13
  local Observable = require("Observable")
15
- local Signal = require("Signal")
16
- local Table = require("Table")
17
14
  local ColorGradeUtils = require("ColorGradeUtils")
18
15
  local LuvColor3Utils = require("LuvColor3Utils")
16
+ local ObservableMap = require("ObservableMap")
19
17
 
20
18
  local ColorPalette = setmetatable({}, BaseObject)
21
19
  ColorPalette.ClassName = "ColorPalette"
@@ -25,23 +23,20 @@ function ColorPalette.new()
25
23
  local self = setmetatable(BaseObject.new(), ColorPalette)
26
24
 
27
25
  self._gradePalette = self._maid:Add(ColorGradePalette.new())
28
- self._gradeMaid = self._maid:Add(Maid.new())
29
- self._colorMaid = self._maid:Add(Maid.new())
30
- self._vividMaid = self._maid:Add(Maid.new())
31
26
 
32
- self._swatches = {}
27
+ self._swatchMap = self._maid:Add(ObservableMap.new())
28
+ self._colorGradeMap = self._maid:Add(ObservableMap.new())
33
29
  self._colorValues = {}
34
- self._colorGradeValues = {}
35
30
  self._vividnessValues = {}
36
31
 
37
- self.ColorSwatchAdded = self._maid:Add(Signal.new()) -- :Fire(name)
38
- self.ColorGradeAdded = self._maid:Add(Signal.new()) -- :Fire(name)
32
+ self.ColorSwatchAdded = assert(self._swatchMap.KeyAdded, "No KeyAdded") -- :Fire(name)
33
+ self.ColorGradeAdded = assert(self._colorGradeMap.KeyAdded, "No KeyAdded") -- :Fire(name) -- :Fire(name)
39
34
 
40
35
  return self
41
36
  end
42
37
 
43
38
  function ColorPalette:GetSwatchNames()
44
- return Table.keys(self._swatches)
39
+ return self._swatchMap:GetKeyList()
45
40
  end
46
41
 
47
42
  function ColorPalette:ObserveSwatchNames()
@@ -52,8 +47,20 @@ function ColorPalette:ObserveSwatchNames()
52
47
  })
53
48
  end
54
49
 
50
+ function ColorPalette:ObserveSwatchNameList()
51
+ return self._swatchMap:ObserveKeyList()
52
+ end
53
+
54
+ function ColorPalette:ObserveSwatchNamesBrio()
55
+ return self._swatchMap:ObserveKeysBrio()
56
+ end
57
+
55
58
  function ColorPalette:GetGradeNames()
56
- return Table.keys(self._colorGradeValues)
59
+ return self._colorGradeMap:GetKeyList()
60
+ end
61
+
62
+ function ColorPalette:ObserveGradeNameList()
63
+ return self._colorGradeMap:ObserveKeyList()
57
64
  end
58
65
 
59
66
  function ColorPalette:ObserveGradeNames()
@@ -64,6 +71,10 @@ function ColorPalette:ObserveGradeNames()
64
71
  })
65
72
  end
66
73
 
74
+ function ColorPalette:ObserveGradeNamesBrio()
75
+ return self._colorGradeMap:ObserveKeysBrio()
76
+ end
77
+
67
78
  function ColorPalette:GetColorValues()
68
79
  return self._colorValues
69
80
  end
@@ -130,7 +141,7 @@ function ColorPalette:SetDefaultSurfaceName(surfaceName)
130
141
  end
131
142
 
132
143
  function ColorPalette:GetColorSwatch(colorName)
133
- local swatch = self._swatches[colorName]
144
+ local swatch = self._swatchMap:Get(colorName)
134
145
  if not swatch then
135
146
  error(string.format("No swatch with name %q", colorName))
136
147
  end
@@ -236,7 +247,7 @@ function ColorPalette:GetColorValue(colorName)
236
247
  end
237
248
 
238
249
  function ColorPalette:GetGradeValue(gradeName)
239
- local gradeValue = self._colorGradeValues[gradeName]
250
+ local gradeValue = self._colorGradeMap:Get(gradeName)
240
251
  if not gradeValue then
241
252
  error(string.format("No grade with name %q", gradeName))
242
253
  end
@@ -273,7 +284,7 @@ end
273
284
  function ColorPalette:GetSwatch(swatchName)
274
285
  assert(type(swatchName) == "string", "Bad swatchName")
275
286
 
276
- local swatch = self._swatches[swatchName]
287
+ local swatch = self._swatchMap:Get(swatchName)
277
288
  if not swatch then
278
289
  error(string.format("No swatch with name %q", swatchName))
279
290
  end
@@ -281,6 +292,10 @@ function ColorPalette:GetSwatch(swatchName)
281
292
  return swatch
282
293
  end
283
294
 
295
+ --[=[
296
+ @param colorName string
297
+ @param color Observable<Color3> | Color3
298
+ ]=]
284
299
  function ColorPalette:SetColor(colorName, color)
285
300
  assert(type(colorName) == "string", "Bad colorName")
286
301
 
@@ -288,7 +303,7 @@ function ColorPalette:SetColor(colorName, color)
288
303
  error(string.format("No color grade with name %q", colorName))
289
304
  end
290
305
 
291
- self._colorMaid[colorName] = self._colorValues[colorName]:Mount(color)
306
+ return self._colorValues[colorName]:Mount(color)
292
307
  end
293
308
 
294
309
  function ColorPalette:SetVividness(gradeName, vividness)
@@ -298,18 +313,19 @@ function ColorPalette:SetVividness(gradeName, vividness)
298
313
  error(string.format("No vividness with name %q", gradeName))
299
314
  end
300
315
 
301
- self._vividMaid[gradeName] = self._vividnessValues[gradeName]:Mount(vividness)
316
+ return self._vividnessValues[gradeName]:Mount(vividness)
302
317
  end
303
318
 
304
319
  function ColorPalette:SetColorGrade(gradeName, grade)
305
320
  assert(type(gradeName) == "string", "Bad colorName")
306
321
  assert(grade, "Bad grade")
307
322
 
308
- if not self._colorGradeValues[gradeName] then
323
+ local gradeValue = self._colorGradeMap:Get(gradeName)
324
+ if not gradeValue then
309
325
  error(string.format("No color grade with name %q", gradeName))
310
326
  end
311
327
 
312
- self._gradeMaid[gradeName] = self._colorGradeValues[gradeName]:Mount(grade)
328
+ return gradeValue:Mount(grade)
313
329
  end
314
330
 
315
331
 
@@ -322,26 +338,21 @@ end
322
338
  function ColorPalette:DefineColorGrade(gradeName, gradeValue, vividnessValue)
323
339
  assert(type(gradeName) == "string", "Bad gradeName")
324
340
 
325
- if self._colorGradeValues[gradeName] then
341
+ if self._colorGradeMap:Get(gradeName) then
326
342
  warn(string.format("[ColorPalette.DefineColorGrade] - Already defined grade of name %q", gradeName))
327
343
  return
328
344
  end
329
345
 
330
- local colorGrade = ValueObject.new(0, "number")
331
- self._maid:GiveTask(colorGrade)
332
-
333
- local vividness = ValueObject.new(nil)
334
- self._maid:GiveTask(vividness)
346
+ local colorGrade = self._maid:Add(ValueObject.new(0, "number"))
347
+ colorGrade:Mount(gradeValue or 0)
335
348
 
336
- self._gradePalette:Add(gradeName, colorGrade, vividness)
349
+ local vividness = self._maid:Add(ValueObject.new(nil))
350
+ vividness:Mount(vividnessValue)
337
351
 
338
- self._colorGradeValues[gradeName] = colorGrade
339
352
  self._vividnessValues[gradeName] = vividness
340
353
 
341
- self:SetVividness(gradeName, vividnessValue)
342
- self:SetColorGrade(gradeName, gradeValue or 0)
343
-
344
- self.ColorGradeAdded:Fire(gradeName)
354
+ self._gradePalette:Add(gradeName, colorGrade, vividness)
355
+ self._colorGradeMap:Set(gradeName, colorGrade)
345
356
 
346
357
  return colorGrade
347
358
  end
@@ -349,21 +360,17 @@ end
349
360
  function ColorPalette:DefineColorSwatch(colorName, value)
350
361
  assert(type(colorName) == "string", "Bad colorName")
351
362
 
352
- if self._swatches[colorName] then
363
+ if self._swatchMap:Get(colorName) then
353
364
  warn(string.format("[ColorPalette.DefineColorGrade] -Already defined color of name %q", colorName))
354
365
  return
355
366
  end
356
367
 
357
- local colorValue = ValueObject.new(value or Color3.new(0, 0, 0), "Color3")
358
- self._maid:GiveTask(colorValue)
359
-
360
- local colorSwatch = ColorSwatch.new(colorValue)
361
- self._maid:GiveTask(colorSwatch)
368
+ local colorValue = self._maid:Add(ValueObject.new(value or Color3.new(0, 0, 0), "Color3"))
369
+ local colorSwatch = self._maid:Add(ColorSwatch.new(colorValue))
362
370
 
363
371
  self._colorValues[colorName] = colorValue
364
- self._swatches[colorName] = colorSwatch
365
372
 
366
- self.ColorSwatchAdded:Fire(colorName)
373
+ self._swatchMap:Set(colorName, colorSwatch)
367
374
 
368
375
  return colorSwatch
369
376
  end
@@ -7,10 +7,9 @@
7
7
  local require = require(script.Parent.loader).load(script)
8
8
 
9
9
  local BaseObject = require("BaseObject")
10
- local Signal = require("Signal")
11
- local Table = require("Table")
12
10
  local Rx = require("Rx")
13
11
  local ValueObject = require("ValueObject")
12
+ local ObservableSet = require("ObservableSet")
14
13
 
15
14
  local FontPalette = setmetatable({}, BaseObject)
16
15
  FontPalette.ClassName = "FontPalette"
@@ -28,7 +27,9 @@ function FontPalette.new()
28
27
  self._fontFaces = {}
29
28
  self._defaultFontMap = {} -- [name] = Enum.Font.?
30
29
 
31
- self.FontAdded = self._maid:Add(Signal.new()) -- :Fire(name)
30
+ self._fontKeys = self._maid:Add(ObservableSet.new())
31
+
32
+ self.FontAdded = assert(self._fontKeys.ItemAdded, "No ItemAdded") -- :Fire(name)
32
33
 
33
34
  return self
34
35
  end
@@ -39,13 +40,12 @@ end
39
40
  @return { string }
40
41
  ]=]
41
42
  function FontPalette:GetFontNames()
42
- return Table.keys(self._fonts)
43
+ return self._fontKeys:GetList()
43
44
  end
44
45
 
45
46
  --[=[
46
47
  Observes all available font names as they are added starting with
47
48
  existing fonts.
48
-
49
49
  @return Observable<string>
50
50
  ]=]
51
51
  function FontPalette:ObserveFontNames()
@@ -61,6 +61,16 @@ function FontPalette:ObserveFontNames()
61
61
  })
62
62
  end
63
63
 
64
+ --[=[
65
+ Observes all available font names as they are added starting with
66
+ existing fonts.
67
+
68
+ @return Observable<Brio<string>>
69
+ ]=]
70
+ function FontPalette:ObserveFontNamesBrio()
71
+ return self._fontKeys:ObserveItemsBrio()
72
+ end
73
+
64
74
  --[=[
65
75
  Gets a font from name
66
76
 
@@ -181,11 +191,8 @@ function FontPalette:DefineFont(fontName, defaultFont)
181
191
  error("Bad defaultFont")
182
192
  end
183
193
 
184
- local fontValue = ValueObject.new(defaultFontEnum)
185
- self._maid:GiveTask(fontValue)
186
-
187
- local fontFaceValue = ValueObject.new(defaultFontFace)
188
- self._maid:GiveTask(fontFaceValue)
194
+ local fontValue = self._maid:Add(ValueObject.new(defaultFontEnum))
195
+ local fontFaceValue = self._maid:Add(ValueObject.new(defaultFontFace))
189
196
 
190
197
  self._fonts[fontName] = fontValue
191
198
  self._fontFaces[fontName] = fontFaceValue
@@ -204,7 +211,7 @@ function FontPalette:DefineFont(fontName, defaultFont)
204
211
  end
205
212
  end))
206
213
 
207
- self.FontAdded:Fire(fontName)
214
+ self._fontKeys:Add(fontName)
208
215
 
209
216
  return fontValue
210
217
  end