@quenty/pagesutils 5.11.4 → 5.11.5-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
+ ## [5.11.5-canary.11a5dcf.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/pagesutils@5.11.4...@quenty/pagesutils@5.11.5-canary.11a5dcf.0) (2025-05-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add even more types ([b31717d](https://github.com/Quenty/NevermoreEngine/commit/b31717d8c9f7620c457f5018a2affa760a65334a))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [5.11.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/pagesutils@5.11.3...@quenty/pagesutils@5.11.4) (2025-04-10)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/pagesutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/pagesutils",
3
- "version": "5.11.4",
3
+ "version": "5.11.5-canary.11a5dcf.0",
4
4
  "description": "Utilities to advance over the Roblox pages API surface",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,12 +26,12 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/ducktype": "^5.8.4",
30
- "@quenty/loader": "^10.8.3",
31
- "@quenty/promise": "^10.10.4"
29
+ "@quenty/ducktype": "5.8.5-canary.11a5dcf.0",
30
+ "@quenty/loader": "10.8.4-canary.11a5dcf.0",
31
+ "@quenty/promise": "10.10.5-canary.11a5dcf.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "b06c070ae91d5dab7bd8de6e290ad2caabb15d8f"
36
+ "gitHead": "11a5dcf7d4c7a0bfbf3337e97d30e8346ea09d3f"
37
37
  }
@@ -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 PagesProxy = require("PagesProxy")
10
+ local Promise = require("Promise")
11
11
 
12
12
  local PagesUtils = {}
13
13
 
@@ -17,7 +17,7 @@ local PagesUtils = {}
17
17
  @param pages Pages
18
18
  @return { any }
19
19
  ]=]
20
- function PagesUtils.promiseAdvanceToNextPage(pages: Pages): Promise.Promise<({any})>
20
+ function PagesUtils.promiseAdvanceToNextPage(pages: Pages): Promise.Promise<({ any })>
21
21
  assert(typeof(pages) == "Instance" and pages:IsA("Pages") or PagesProxy.isPagesProxy(pages), "Bad pages")
22
22
 
23
23
  return Promise.spawn(function(resolve, reject)
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  @class PagesDatabase
3
4
  ]=]
@@ -10,8 +11,17 @@ local PagesDatabase = {}
10
11
  PagesDatabase.ClassName = "PagesDatabase"
11
12
  PagesDatabase.__index = PagesDatabase
12
13
 
13
- function PagesDatabase.new(pages: Pages)
14
- local self = setmetatable({}, PagesDatabase)
14
+ export type PagesDatabase = typeof(setmetatable(
15
+ {} :: {
16
+ _pages: Pages,
17
+ _lastIncrementedIndex: number,
18
+ _pageData: { [number]: { currentPage: any, isFinished: boolean } },
19
+ },
20
+ {} :: typeof({ __index = PagesDatabase })
21
+ ))
22
+
23
+ function PagesDatabase.new(pages: Pages): PagesDatabase
24
+ local self: PagesDatabase = setmetatable({} :: any, PagesDatabase)
15
25
 
16
26
  self._pages = assert(pages, "No pages")
17
27
  self._lastIncrementedIndex = 1
@@ -26,7 +36,7 @@ function PagesDatabase.isPagesDatabase(value): boolean
26
36
  return DuckTypeUtils.isImplementation(PagesDatabase, value)
27
37
  end
28
38
 
29
- function PagesDatabase:IncrementToPageIdAsync(pageId: number)
39
+ function PagesDatabase.IncrementToPageIdAsync(self: PagesDatabase, pageId: number)
30
40
  while self._lastIncrementedIndex < pageId do
31
41
  self._lastIncrementedIndex += 1
32
42
  self._pages:AdvanceToNextPageAsync()
@@ -34,25 +44,25 @@ function PagesDatabase:IncrementToPageIdAsync(pageId: number)
34
44
  end
35
45
  end
36
46
 
37
- function PagesDatabase:GetPage(pageId: number)
47
+ function PagesDatabase.GetPage(self: PagesDatabase, pageId: number)
38
48
  assert(type(pageId) == "number", "Bad pageId")
39
49
 
40
50
  return self:_getPageState(pageId).currentPage
41
51
  end
42
52
 
43
- function PagesDatabase:GetIsFinished(pageId: number)
53
+ function PagesDatabase.GetIsFinished(self: PagesDatabase, pageId: number): boolean
44
54
  assert(type(pageId) == "number", "Bad pageId")
45
55
 
46
56
  return self:_getPageState(pageId).isFinished
47
57
  end
48
58
 
49
- function PagesDatabase:_getPageState(pageId: number)
59
+ function PagesDatabase._getPageState(self: PagesDatabase, pageId: number)
50
60
  assert(pageId > 0 and pageId <= self._lastIncrementedIndex, "pageId is out of bounds")
51
61
 
52
62
  return assert(self._pageData[pageId], "Missing data")
53
63
  end
54
64
 
55
- function PagesDatabase:_storeState()
65
+ function PagesDatabase._storeState(self: PagesDatabase)
56
66
  self._pageData[self._lastIncrementedIndex] = {
57
67
  currentPage = self._pages:GetCurrentPage(),
58
68
  isFinished = self._pages.IsFinished,
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Proxy pages and cache the results to allow for reuse
3
4
 
@@ -13,11 +14,19 @@ local PagesProxy = {}
13
14
  PagesProxy.ClassName = "PagesProxy"
14
15
  PagesProxy.__index = PagesProxy
15
16
 
16
- function PagesProxy.new(database)
17
- local self = setmetatable({}, PagesProxy)
17
+ export type PagesProxy = typeof(setmetatable(
18
+ {} :: {
19
+ _database: PagesDatabase.PagesDatabase,
20
+ _currentPageIndex: number,
21
+ },
22
+ {} :: typeof({ __index = PagesProxy })
23
+ ))
24
+
25
+ function PagesProxy.new(database: PagesDatabase.PagesDatabase | Pages): PagesProxy
26
+ local self: PagesProxy = setmetatable({} :: any, PagesProxy)
18
27
 
19
28
  if PagesDatabase.isPagesDatabase(database) then
20
- self._database = database
29
+ self._database = database :: any
21
30
  elseif typeof(database) == "Instance" and database:IsA("Pages") then
22
31
  -- Convenient for consumers
23
32
  self._database = PagesDatabase.new(database)
@@ -34,7 +43,7 @@ function PagesProxy.isPagesProxy(value): boolean
34
43
  return DuckTypeUtils.isImplementation(PagesProxy, value)
35
44
  end
36
45
 
37
- function PagesProxy:AdvanceToNextPageAsync()
46
+ function PagesProxy.AdvanceToNextPageAsync(self: PagesProxy): ()
38
47
  if self._database:GetIsFinished(self._currentPageIndex) then
39
48
  error("Already finished, cannot increment more")
40
49
  end
@@ -44,18 +53,18 @@ function PagesProxy:AdvanceToNextPageAsync()
44
53
  return self._database:IncrementToPageIdAsync(self._currentPageIndex)
45
54
  end
46
55
 
47
- function PagesProxy:GetCurrentPage()
56
+ function PagesProxy.GetCurrentPage(self: PagesProxy): Pages
48
57
  return self._database:GetPage(self._currentPageIndex)
49
58
  end
50
59
 
51
- function PagesProxy:Clone()
60
+ function PagesProxy.Clone(self: PagesProxy): PagesProxy
52
61
  local copy = PagesProxy.new(self._database)
53
62
  copy._currentPageIndex = self._currentPageIndex
54
63
 
55
64
  return copy
56
65
  end
57
66
 
58
- function PagesProxy:__index(index)
67
+ (PagesProxy :: any).__index = function(self: PagesProxy, index)
59
68
  if index == nil then
60
69
  error("Attempt to index with a nil value")
61
70
  elseif PagesProxy[index] then
@@ -63,7 +72,7 @@ function PagesProxy:__index(index)
63
72
  elseif index == "IsFinished" then
64
73
  return self._database:GetIsFinished(self._currentPageIndex)
65
74
  elseif type(index) == "string" then
66
- return rawget(self, index)
75
+ return rawget(self :: any, index)
67
76
  else
68
77
  error("Bad index")
69
78
  end