@quenty/inputmode 7.8.0 → 7.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,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
+ # [7.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputmode@7.8.0...@quenty/inputmode@7.9.0) (2023-02-21)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Cache keys and retain order in InputModeType ([256a7a2](https://github.com/Quenty/NevermoreEngine/commit/256a7a2b8585ecafd47a484d69185fa29542129f))
12
+
13
+
14
+
15
+
16
+
6
17
  # [7.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/inputmode@7.7.0...@quenty/inputmode@7.8.0) (2023-01-11)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/inputmode
package/README.md CHANGED
@@ -13,9 +13,9 @@
13
13
 
14
14
  Trace input mode state and trigger changes correctly. This is a more customizable version of UserInputService:GetLastInputType() or LastInputTypeChanged.
15
15
 
16
- <div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/INPUT_MODES">View docs →</a></div>
16
+ <div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/InputMode">View docs →</a></div>
17
17
 
18
18
  ## Installation
19
19
  ```
20
20
  npm install @quenty/inputmode --save
21
- ```
21
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/inputmode",
3
- "version": "7.8.0",
3
+ "version": "7.9.0",
4
4
  "description": "Trace input mode state and trigger changes correctly",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,15 +25,15 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/loader": "^6.0.1",
28
+ "@quenty/loader": "^6.1.0",
29
29
  "@quenty/maid": "^2.4.0",
30
- "@quenty/servicebag": "^6.4.0",
30
+ "@quenty/servicebag": "^6.5.0",
31
31
  "@quenty/signal": "^2.3.0",
32
- "@quenty/table": "^3.1.0",
33
- "@quenty/valueobject": "^7.4.0"
32
+ "@quenty/table": "^3.2.0",
33
+ "@quenty/valueobject": "^7.5.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "db2db00ab4e24a3eab0449b77a00bee6d91f2755"
38
+ "gitHead": "e084b0cc097ddbcb7c782b8ecbd9c2d619c49354"
39
39
  }
@@ -19,6 +19,7 @@ function InputModeType.new(name, typesAndInputModes)
19
19
  local self = setmetatable({}, InputModeType)
20
20
 
21
21
  self._valid = {}
22
+ self._keys = {}
22
23
  self.Name = name or "Unnamed"
23
24
 
24
25
  self:_addValidTypesFromTable(typesAndInputModes)
@@ -51,17 +52,16 @@ end
51
52
  @return { UserInputType | KeyCode | string }
52
53
  ]=]
53
54
  function InputModeType:GetKeys()
54
- local keys = {}
55
- for key, _ in pairs(self._valid) do
56
- table.insert(keys, key)
57
- end
58
- return keys
55
+ return self._keys
59
56
  end
60
57
 
61
58
  function InputModeType:_addValidTypesFromTable(keys)
62
59
  for _, key in pairs(keys) do
63
60
  if typeof(key) == "EnumItem" then
64
- self._valid[key] = true
61
+ if not self._valid[key] then
62
+ self._valid[key] = true
63
+ table.insert(self._keys, key)
64
+ end
65
65
  elseif InputModeType.isInputModeType(key) then
66
66
  self:_addInputModeType(key)
67
67
  else
@@ -73,8 +73,11 @@ end
73
73
  function InputModeType:_addInputModeType(inputModeType)
74
74
  assert(InputModeType.isInputModeType(inputModeType), "Bad inputModeType")
75
75
 
76
- for key, _ in pairs(inputModeType._valid) do
77
- self._valid[key] = true
76
+ for key, _ in pairs(inputModeType._keys) do
77
+ if not self._valid[key] then
78
+ self._valid[key] = true
79
+ table.insert(self._keys, key)
80
+ end
78
81
  end
79
82
  end
80
83