@quenty/templateprovider 3.6.0 → 3.7.1-canary.245.97a91ca.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,22 @@
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
+ ## [3.7.1-canary.245.97a91ca.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/templateprovider@3.7.0...@quenty/templateprovider@3.7.1-canary.245.97a91ca.0) (2022-01-08)
7
+
8
+ **Note:** Version bump only for package @quenty/templateprovider
9
+
10
+
11
+
12
+
13
+
14
+ # [3.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/templateprovider@3.6.0...@quenty/templateprovider@3.7.0) (2022-01-07)
15
+
16
+ **Note:** Version bump only for package @quenty/templateprovider
17
+
18
+
19
+
20
+
21
+
6
22
  # [3.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/templateprovider@3.5.1...@quenty/templateprovider@3.6.0) (2022-01-03)
7
23
 
8
24
  **Note:** Version bump only for package @quenty/templateprovider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/templateprovider",
3
- "version": "3.6.0",
3
+ "version": "3.7.1-canary.245.97a91ca.0",
4
4
  "description": "Base of a template retrieval system",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,15 +25,15 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/baseobject": "^3.3.0",
29
- "@quenty/insertserviceutils": "^3.4.0",
30
- "@quenty/loader": "^3.2.0",
31
- "@quenty/maid": "^2.0.2",
32
- "@quenty/promise": "^3.4.0",
33
- "@quenty/string": "^2.2.1"
28
+ "@quenty/baseobject": "3.4.0",
29
+ "@quenty/insertserviceutils": "3.5.1-canary.245.97a91ca.0",
30
+ "@quenty/loader": "3.3.0",
31
+ "@quenty/maid": "2.0.2",
32
+ "@quenty/promise": "3.5.1-canary.245.97a91ca.0",
33
+ "@quenty/string": "2.2.1"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "d910da8f5c7e9a55a8bf76d8efbe5632713dd0fe"
38
+ "gitHead": "97a91ca3f8a2ccb75551912dc6424e9199050bfe"
39
39
  }
@@ -1,5 +1,35 @@
1
1
  --[=[
2
- Base of a template retrieval system
2
+ Base of a template retrieval system. Templates can be retrieved from Roblox, or from the cloud,
3
+ and then retrieved by name. Folders are ignored, so assets may be organized however you want.
4
+
5
+ Templates can repliate to client if desired.
6
+
7
+ ```lua
8
+ -- shared/Templates.lua
9
+
10
+ return TemplateProvider.new(182451181, script) -- Load from Roblox cloud
11
+ ```
12
+
13
+ ```lua
14
+ -- Server
15
+ local serviceBag = ServiceBag.new()
16
+ local templates = serviceBag:GetService(packages.Templates)
17
+ serviceBag:Init()
18
+ serviceBag:Start()
19
+ ```
20
+
21
+ ```lua
22
+ -- Client
23
+ local serviceBag = ServiceBag.new()
24
+ local templates = serviceBag:GetService(packages.Templates)
25
+ serviceBag:Init()
26
+ serviceBag:Start()
27
+
28
+ templates:PromiseClone("Crate"):Then(function(crate)
29
+ print("Got crate from the cloud!")
30
+ end)
31
+ ```
32
+
3
33
  @class TemplateProvider
4
34
  ]=]
5
35
 
@@ -17,7 +47,11 @@ local TemplateProvider = {}
17
47
  TemplateProvider.ClassName = "TemplateProvider"
18
48
  TemplateProvider.__index = TemplateProvider
19
49
 
20
- -- @param[opt=nil] container
50
+ --[=[
51
+ Constructs a new [TemplateProvider].
52
+ @param container Instance | table | number -- Value
53
+ @param replicationParent Instance? -- Place to replicate instances to.
54
+ ]=]
21
55
  function TemplateProvider.new(container, replicationParent)
22
56
  local self = setmetatable({}, TemplateProvider)
23
57
 
@@ -50,7 +84,9 @@ function TemplateProvider.new(container, replicationParent)
50
84
  return self
51
85
  end
52
86
 
53
- -- Initializes the container provider
87
+ --[=[
88
+ Initializes the container provider. Should be done via [ServiceBag].
89
+ ]=]
54
90
  function TemplateProvider:Init()
55
91
  assert(not self._initialized, "Already initialized")
56
92
 
@@ -66,6 +102,11 @@ function TemplateProvider:Init()
66
102
  end
67
103
  end
68
104
 
105
+ --[=[
106
+ Promises to clone the template as soon as it exists.
107
+ @param templateName string
108
+ @return Promise<Instance>
109
+ ]=]
69
110
  function TemplateProvider:PromiseClone(templateName)
70
111
  assert(type(templateName) == "string", "templateName must be a string")
71
112
 
@@ -86,7 +127,7 @@ function TemplateProvider:PromiseClone(templateName)
86
127
  self._maid[promise] = nil
87
128
  end)
88
129
 
89
- delay(5, function()
130
+ task.delay(5, function()
90
131
  if promise:IsPending() then
91
132
  warn(("[TemplateProvider.PromiseClone] - May fail to replicate template %q from cloud. %s")
92
133
  :format(templateName, self:_getReplicationHint()))
@@ -111,7 +152,16 @@ function TemplateProvider:_getReplicationHint()
111
152
  return hint
112
153
  end
113
154
 
114
- -- Clones the template. If it has a prefix of "Template" then it will remove it
155
+ --[=[
156
+ Clones the template.
157
+
158
+ :::info
159
+ If the template name has a prefix of "Template" then it will remove it on the cloned instance.
160
+ :::
161
+
162
+ @param templateName string
163
+ @return Instance?
164
+ ]=]
115
165
  function TemplateProvider:Clone(templateName)
116
166
  assert(type(templateName) == "string", "templateName must be a string")
117
167
 
@@ -128,7 +178,12 @@ function TemplateProvider:Clone(templateName)
128
178
  return newItem
129
179
  end
130
180
 
131
- -- Returns the raw template
181
+ --[=[
182
+ Returns the raw template
183
+
184
+ @param templateName string
185
+ @return Instance?
186
+ ]=]
132
187
  function TemplateProvider:Get(templateName)
133
188
  assert(type(templateName) == "string", "templateName must be a string")
134
189
  self:_verifyInit()
@@ -136,7 +191,11 @@ function TemplateProvider:Get(templateName)
136
191
  return self._registry[templateName]
137
192
  end
138
193
 
139
- -- Adds a new container to the provider for provision of assets
194
+ --[=[
195
+ Adds a new container to the provider for provision of assets.
196
+
197
+ @param container Instance | number
198
+ ]=]
140
199
  function TemplateProvider:AddContainer(container)
141
200
  assert(typeof(container) == "Instance" or type(container) == "number", "Bad container")
142
201
  self:_verifyInit()
@@ -153,6 +212,11 @@ function TemplateProvider:AddContainer(container)
153
212
  end
154
213
  end
155
214
 
215
+ --[=[
216
+ Removes a container from the provisioning set.
217
+
218
+ @param container Instance | number
219
+ ]=]
156
220
  function TemplateProvider:RemoveContainer(container)
157
221
  assert(typeof(container) == "Instance", "Bad container")
158
222
  self:_verifyInit()
@@ -161,7 +225,11 @@ function TemplateProvider:RemoveContainer(container)
161
225
  self._maid[container] = nil
162
226
  end
163
227
 
164
- -- Returns whether or not a template is registered at the time
228
+ --[=[
229
+ Returns whether or not a template is registered at the time
230
+ @param templateName string
231
+ @return boolean
232
+ ]=]
165
233
  function TemplateProvider:IsAvailable(templateName)
166
234
  assert(type(templateName) == "string", "templateName must be a string")
167
235
  self:_verifyInit()
@@ -169,7 +237,11 @@ function TemplateProvider:IsAvailable(templateName)
169
237
  return self._registry[templateName] ~= nil
170
238
  end
171
239
 
172
- -- Returns all current registered items
240
+ --[=[
241
+ Returns all current registered items.
242
+
243
+ @return { Instance }
244
+ ]=]
173
245
  function TemplateProvider:GetAll()
174
246
  self:_verifyInit()
175
247
 
@@ -181,7 +253,11 @@ function TemplateProvider:GetAll()
181
253
  return list
182
254
  end
183
255
 
184
- -- Gets the container
256
+ --[=[
257
+ Gets all current the containers.
258
+
259
+ @return { Instance | number }
260
+ ]=]
185
261
  function TemplateProvider:GetContainers()
186
262
  self:_verifyInit()
187
263
 
@@ -302,6 +378,9 @@ function TemplateProvider:_removeFromRegistry(child)
302
378
  end
303
379
  end
304
380
 
381
+ --[=[
382
+ Cleans up the provider
383
+ ]=]
305
384
  function TemplateProvider:Destroy()
306
385
  self._maid:DoCleaning()
307
386
  end