@quenty/templateprovider 11.18.0-canary.544.de8fcee.0 → 11.18.1-canary.545.2374fb2.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,7 +3,26 @@
|
|
|
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
|
-
|
|
6
|
+
## [11.18.1-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/templateprovider@11.18.0...@quenty/templateprovider@11.18.1-canary.545.2374fb2.0) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [11.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/templateprovider@11.17.4...@quenty/templateprovider@11.18.0) (2025-04-02)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @quenty/templateprovider
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [11.17.4](https://github.com/Quenty/NevermoreEngine/compare/@quenty/templateprovider@11.17.3...@quenty/templateprovider@11.17.4) (2025-03-31)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @quenty/templateprovider
|
|
9
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/templateprovider",
|
|
3
|
-
"version": "11.18.
|
|
3
|
+
"version": "11.18.1-canary.545.2374fb2.0",
|
|
4
4
|
"description": "Base of a template retrieval system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,24 +25,24 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/baseobject": "10.8.0",
|
|
29
|
-
"@quenty/brio": "14.17.
|
|
30
|
-
"@quenty/collectionserviceutils": "8.17.
|
|
31
|
-
"@quenty/ducktype": "5.8.
|
|
32
|
-
"@quenty/insertserviceutils": "10.10.
|
|
33
|
-
"@quenty/instanceutils": "13.17.
|
|
34
|
-
"@quenty/loader": "10.8.0",
|
|
35
|
-
"@quenty/maid": "3.4.0",
|
|
36
|
-
"@quenty/observablecollection": "12.20.
|
|
37
|
-
"@quenty/promise": "10.10.
|
|
38
|
-
"@quenty/promisemaid": "5.10.
|
|
39
|
-
"@quenty/remoting": "12.18.
|
|
40
|
-
"@quenty/rx": "13.17.
|
|
41
|
-
"@quenty/string": "3.3.
|
|
42
|
-
"@quenty/table": "3.7.
|
|
28
|
+
"@quenty/baseobject": "10.8.1-canary.545.2374fb2.0",
|
|
29
|
+
"@quenty/brio": "14.17.1-canary.545.2374fb2.0",
|
|
30
|
+
"@quenty/collectionserviceutils": "8.17.1-canary.545.2374fb2.0",
|
|
31
|
+
"@quenty/ducktype": "5.8.2-canary.545.2374fb2.0",
|
|
32
|
+
"@quenty/insertserviceutils": "10.10.2-canary.545.2374fb2.0",
|
|
33
|
+
"@quenty/instanceutils": "13.17.1-canary.545.2374fb2.0",
|
|
34
|
+
"@quenty/loader": "10.8.1-canary.545.2374fb2.0",
|
|
35
|
+
"@quenty/maid": "3.4.1-canary.545.2374fb2.0",
|
|
36
|
+
"@quenty/observablecollection": "12.20.1-canary.545.2374fb2.0",
|
|
37
|
+
"@quenty/promise": "10.10.2-canary.545.2374fb2.0",
|
|
38
|
+
"@quenty/promisemaid": "5.10.2-canary.545.2374fb2.0",
|
|
39
|
+
"@quenty/remoting": "12.18.1-canary.545.2374fb2.0",
|
|
40
|
+
"@quenty/rx": "13.17.1-canary.545.2374fb2.0",
|
|
41
|
+
"@quenty/string": "3.3.2-canary.545.2374fb2.0",
|
|
42
|
+
"@quenty/table": "3.7.2-canary.545.2374fb2.0"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
|
|
48
48
|
}
|
|
@@ -39,7 +39,7 @@ function ModuleProvider:Init()
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
if self._initModule then
|
|
42
|
-
for moduleScript, _module in
|
|
42
|
+
for moduleScript, _module in self._moduleScriptToModule do
|
|
43
43
|
self._initModule(_module, moduleScript)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -61,7 +61,7 @@ function ModuleProvider:GetFromName(name)
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
function ModuleProvider:_processFolder(folder)
|
|
64
|
-
for _, moduleScript in
|
|
64
|
+
for _, moduleScript in folder:GetChildren() do
|
|
65
65
|
if moduleScript:IsA("ModuleScript") then
|
|
66
66
|
self:_addToRegistery(moduleScript)
|
|
67
67
|
else
|
|
@@ -11,7 +11,7 @@ local RxCollectionServiceUtils = require("RxCollectionServiceUtils")
|
|
|
11
11
|
|
|
12
12
|
local TaggedTemplateProvider = {}
|
|
13
13
|
|
|
14
|
-
function TaggedTemplateProvider.new(providerName, tagName)
|
|
14
|
+
function TaggedTemplateProvider.new(providerName: string, tagName: string)
|
|
15
15
|
assert(type(providerName) == "string", "bad providerName")
|
|
16
16
|
assert(type(tagName) == "string", "Bad tagName")
|
|
17
17
|
|
|
@@ -60,6 +60,7 @@ local RxInstanceUtils = require("RxInstanceUtils")
|
|
|
60
60
|
local String = require("String")
|
|
61
61
|
local TemplateReplicationModes = require("TemplateReplicationModes")
|
|
62
62
|
local TemplateReplicationModesUtils = require("TemplateReplicationModesUtils")
|
|
63
|
+
local _ServiceBag = require("ServiceBag")
|
|
63
64
|
|
|
64
65
|
local TOMBSTONE_ID_ATTRIBUTE = "UnreplicatedTemplateId"
|
|
65
66
|
local TOMBSTONE_NAME_POSTFIX_UNLOADED = "_Unloaded"
|
|
@@ -81,7 +82,7 @@ TemplateProvider.__index = TemplateProvider
|
|
|
81
82
|
@param providerName string
|
|
82
83
|
@param initialTemplates Template
|
|
83
84
|
]=]
|
|
84
|
-
function TemplateProvider.new(providerName, initialTemplates)
|
|
85
|
+
function TemplateProvider.new(providerName: string, initialTemplates)
|
|
85
86
|
assert(type(providerName) == "string", "Bad providerName")
|
|
86
87
|
local self = setmetatable({}, TemplateProvider)
|
|
87
88
|
|
|
@@ -89,7 +90,13 @@ function TemplateProvider.new(providerName, initialTemplates)
|
|
|
89
90
|
self._initialTemplates = initialTemplates
|
|
90
91
|
|
|
91
92
|
if not (self:_isValidTemplate(self._initialTemplates) or self._initialTemplates == nil) then
|
|
92
|
-
error(
|
|
93
|
+
error(
|
|
94
|
+
string.format(
|
|
95
|
+
"[TemplateProvider.%s] - Bad initialTemplates of type %s",
|
|
96
|
+
self.ServiceName,
|
|
97
|
+
typeof(initialTemplates)
|
|
98
|
+
)
|
|
99
|
+
)
|
|
93
100
|
end
|
|
94
101
|
|
|
95
102
|
return self
|
|
@@ -102,7 +109,7 @@ end
|
|
|
102
109
|
@return boolean
|
|
103
110
|
]=]
|
|
104
111
|
|
|
105
|
-
function TemplateProvider.isTemplateProvider(value)
|
|
112
|
+
function TemplateProvider.isTemplateProvider(value: any): boolean
|
|
106
113
|
return DuckTypeUtils.isImplementation(TemplateProvider, value)
|
|
107
114
|
end
|
|
108
115
|
|
|
@@ -111,7 +118,7 @@ end
|
|
|
111
118
|
|
|
112
119
|
@param serviceBag ServiceBag
|
|
113
120
|
]=]
|
|
114
|
-
function TemplateProvider:Init(serviceBag)
|
|
121
|
+
function TemplateProvider:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
115
122
|
assert(not self._serviceBag, "Already initialized")
|
|
116
123
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
117
124
|
self._maid = Maid.new()
|
|
@@ -179,14 +186,16 @@ function TemplateProvider:_setupTemplateCache()
|
|
|
179
186
|
end
|
|
180
187
|
|
|
181
188
|
local containerMaid, container = containerBrio:ToMaidAndValue()
|
|
182
|
-
self:_handleContainer(containerMaid,
|
|
189
|
+
self:_handleContainer(containerMaid, container)
|
|
183
190
|
end))
|
|
184
191
|
end
|
|
185
192
|
|
|
186
|
-
function TemplateProvider:_handleContainer(containerMaid, container)
|
|
187
|
-
if
|
|
193
|
+
function TemplateProvider:_handleContainer(containerMaid: Maid.Maid, container: Instance)
|
|
194
|
+
if
|
|
195
|
+
self._replicationMode == TemplateReplicationModes.SERVER
|
|
188
196
|
and not container:IsA("Camera")
|
|
189
|
-
and not container:FindFirstAncestorWhichIsA("Camera")
|
|
197
|
+
and not container:FindFirstAncestorWhichIsA("Camera")
|
|
198
|
+
then
|
|
190
199
|
-- Prevent replication to client immediately
|
|
191
200
|
|
|
192
201
|
local camera = containerMaid:Add(Instance.new("Camera"))
|
|
@@ -206,7 +215,7 @@ function TemplateProvider:_handleContainer(containerMaid, container)
|
|
|
206
215
|
|
|
207
216
|
containerMaid:GiveTask(container.ChildAdded:Connect(handleChild))
|
|
208
217
|
|
|
209
|
-
for _, child in
|
|
218
|
+
for _, child in container:GetChildren() do
|
|
210
219
|
handleChild(child)
|
|
211
220
|
end
|
|
212
221
|
|
|
@@ -225,7 +234,7 @@ function TemplateProvider:_handleContainer(containerMaid, container)
|
|
|
225
234
|
end))
|
|
226
235
|
end
|
|
227
236
|
|
|
228
|
-
function TemplateProvider:_replicateTombstones(topMaid, unreplicatedParent, replicatedParent)
|
|
237
|
+
function TemplateProvider:_replicateTombstones(topMaid: Maid.Maid, unreplicatedParent, replicatedParent)
|
|
229
238
|
assert(self._replicationMode == TemplateReplicationModes.SERVER, "Only should be invoked on server")
|
|
230
239
|
|
|
231
240
|
-- Tombstone each child so the client knows what is replicated
|
|
@@ -265,25 +274,25 @@ end
|
|
|
265
274
|
@param templateName string
|
|
266
275
|
@return Observable<Instance>
|
|
267
276
|
]=]
|
|
268
|
-
function TemplateProvider:ObserveTemplate(templateName)
|
|
269
|
-
assert(type(templateName) == "string", "templateName
|
|
277
|
+
function TemplateProvider:ObserveTemplate(templateName: string): Observable.Observable<Instance>
|
|
278
|
+
assert(type(templateName) == "string", "Bad templateName")
|
|
270
279
|
|
|
271
280
|
return self._templateMapList:ObserveList(templateName):Pipe({
|
|
272
281
|
Rx.switchMap(function(list)
|
|
273
282
|
if not list then
|
|
274
|
-
return Rx.of(nil)
|
|
283
|
+
return Rx.of(nil)
|
|
275
284
|
end
|
|
276
285
|
|
|
277
286
|
return list:ObserveAtIndex(-1)
|
|
278
|
-
end)
|
|
287
|
+
end),
|
|
279
288
|
})
|
|
280
289
|
end
|
|
281
290
|
|
|
282
|
-
function TemplateProvider:ObserveTemplateNamesBrio()
|
|
291
|
+
function TemplateProvider:ObserveTemplateNamesBrio(): Observable.Observable<Brio.Brio<string>>
|
|
283
292
|
return self._templateMapList:ObserveKeysBrio()
|
|
284
293
|
end
|
|
285
294
|
|
|
286
|
-
function TemplateProvider:ObserveUnreplicatedTemplateNamesBrio()
|
|
295
|
+
function TemplateProvider:ObserveUnreplicatedTemplateNamesBrio(): Observable.Observable<Brio.Brio<string>>
|
|
287
296
|
return self._unreplicatedTemplateMapList:ObserveKeysBrio()
|
|
288
297
|
end
|
|
289
298
|
|
|
@@ -293,8 +302,8 @@ end
|
|
|
293
302
|
@param templateName string
|
|
294
303
|
@return Instance?
|
|
295
304
|
]=]
|
|
296
|
-
function TemplateProvider:GetTemplate(templateName)
|
|
297
|
-
assert(type(templateName) == "string", "templateName
|
|
305
|
+
function TemplateProvider:GetTemplate(templateName: string): Instance?
|
|
306
|
+
assert(type(templateName) == "string", "Bad templateName")
|
|
298
307
|
|
|
299
308
|
return self._templateMapList:GetItemForKeyAtIndex(templateName, -1)
|
|
300
309
|
end
|
|
@@ -305,13 +314,12 @@ end
|
|
|
305
314
|
@param templateName string
|
|
306
315
|
@return Promise<Instance>
|
|
307
316
|
]=]
|
|
308
|
-
function TemplateProvider:PromiseCloneTemplate(templateName)
|
|
309
|
-
assert(type(templateName) == "string", "templateName
|
|
317
|
+
function TemplateProvider:PromiseCloneTemplate(templateName: string): Promise.Promise<Instance>
|
|
318
|
+
assert(type(templateName) == "string", "Bad templateName")
|
|
310
319
|
|
|
311
|
-
return self:PromiseTemplate(templateName)
|
|
312
|
-
:
|
|
313
|
-
|
|
314
|
-
end)
|
|
320
|
+
return self:PromiseTemplate(templateName):Then(function(template)
|
|
321
|
+
return self:_cloneTemplate(template)
|
|
322
|
+
end)
|
|
315
323
|
end
|
|
316
324
|
|
|
317
325
|
--[=[
|
|
@@ -320,8 +328,8 @@ end
|
|
|
320
328
|
@param templateName string
|
|
321
329
|
@return Promise<Instance>
|
|
322
330
|
]=]
|
|
323
|
-
function TemplateProvider:PromiseTemplate(templateName)
|
|
324
|
-
assert(type(templateName) == "string", "templateName
|
|
331
|
+
function TemplateProvider:PromiseTemplate(templateName: string): Promise.Promise<Instance>
|
|
332
|
+
assert(type(templateName) == "string", "Bad templateName")
|
|
325
333
|
|
|
326
334
|
local foundTemplate = self._templateMapList:GetItemForKeyAtIndex(templateName, -1)
|
|
327
335
|
if foundTemplate then
|
|
@@ -346,41 +354,68 @@ function TemplateProvider:PromiseTemplate(templateName)
|
|
|
346
354
|
-- There's a chance an external process will stream in our template
|
|
347
355
|
|
|
348
356
|
topMaid:GiveTask(task.delay(5, function()
|
|
349
|
-
warn(
|
|
357
|
+
warn(
|
|
358
|
+
string.format(
|
|
359
|
+
"[TemplateProvider.%s.PromiseTemplate] - Missing template %q",
|
|
360
|
+
self.ServiceName,
|
|
361
|
+
templateName
|
|
362
|
+
)
|
|
363
|
+
)
|
|
350
364
|
end))
|
|
351
365
|
elseif self._replicationMode == TemplateReplicationModes.CLIENT then
|
|
352
366
|
-- Replicate from the unfound area
|
|
353
|
-
topMaid:GiveTask(
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
367
|
+
topMaid:GiveTask(
|
|
368
|
+
self._unreplicatedTemplateMapList:ObserveAtListIndexBrio(templateName, -1):Subscribe(function(brio)
|
|
369
|
+
if brio:IsDead() then
|
|
370
|
+
return
|
|
371
|
+
end
|
|
357
372
|
|
|
358
|
-
|
|
373
|
+
local maid, templateTombstone = brio:ToMaidAndValue()
|
|
359
374
|
|
|
360
|
-
|
|
375
|
+
local originalName = templateTombstone.Name
|
|
361
376
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
377
|
+
maid:GivePromise(self:_promiseReplicateTemplateFromTombstone(templateTombstone))
|
|
378
|
+
:Then(function(template)
|
|
379
|
+
-- Cache the template here which then loads it into the known templates naturally
|
|
380
|
+
templateTombstone.Name = String.removePostfix(originalName, TOMBSTONE_NAME_POSTFIX_UNLOADED)
|
|
381
|
+
.. TOMBSTONE_NAME_POSTFIX_LOADED
|
|
382
|
+
template.Parent = templateTombstone
|
|
367
383
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
384
|
+
promiseTemplate:Resolve(template)
|
|
385
|
+
end)
|
|
386
|
+
end)
|
|
387
|
+
)
|
|
371
388
|
|
|
372
389
|
topMaid:GiveTask(task.delay(5, function()
|
|
373
390
|
if self._unreplicatedTemplateMapList:GetListForKey(templateName) then
|
|
374
|
-
warn(
|
|
391
|
+
warn(
|
|
392
|
+
string.format(
|
|
393
|
+
"[TemplateProvider.%s.PromiseTemplate] - Failed to replicate template %q from server to client",
|
|
394
|
+
self.ServiceName,
|
|
395
|
+
templateName
|
|
396
|
+
)
|
|
397
|
+
)
|
|
375
398
|
else
|
|
376
|
-
warn(
|
|
399
|
+
warn(
|
|
400
|
+
string.format(
|
|
401
|
+
"[TemplateProvider.%s.PromiseTemplate] - Template %q is not a known template",
|
|
402
|
+
self.ServiceName,
|
|
403
|
+
templateName
|
|
404
|
+
)
|
|
405
|
+
)
|
|
377
406
|
end
|
|
378
407
|
end))
|
|
379
408
|
elseif self._replicationMode == TemplateReplicationModes.SHARED then
|
|
380
409
|
-- There's a chance an external process will stream in our template
|
|
381
410
|
|
|
382
411
|
topMaid:GiveTask(task.delay(5, function()
|
|
383
|
-
warn(
|
|
412
|
+
warn(
|
|
413
|
+
string.format(
|
|
414
|
+
"[TemplateProvider.%s.PromiseTemplate] - Missing template %q",
|
|
415
|
+
self.ServiceName,
|
|
416
|
+
templateName
|
|
417
|
+
)
|
|
418
|
+
)
|
|
384
419
|
end))
|
|
385
420
|
else
|
|
386
421
|
error("Bad replicationMode")
|
|
@@ -398,7 +433,7 @@ function TemplateProvider:PromiseTemplate(templateName)
|
|
|
398
433
|
return promiseTemplate
|
|
399
434
|
end
|
|
400
435
|
|
|
401
|
-
function TemplateProvider:_promiseReplicateTemplateFromTombstone(templateTombstone)
|
|
436
|
+
function TemplateProvider:_promiseReplicateTemplateFromTombstone(templateTombstone: Instance): Promise.Promise<Instance>
|
|
402
437
|
assert(self._replicationMode == TemplateReplicationModes.CLIENT, "Bad replicationMode")
|
|
403
438
|
assert(typeof(templateTombstone) == "Instance", "Bad templateTombstone")
|
|
404
439
|
|
|
@@ -414,10 +449,12 @@ function TemplateProvider:_promiseReplicateTemplateFromTombstone(templateTombsto
|
|
|
414
449
|
local promiseTemplate = Promise.new()
|
|
415
450
|
|
|
416
451
|
PromiseMaidUtils.whilePromise(promiseTemplate, function(topMaid)
|
|
417
|
-
topMaid
|
|
452
|
+
topMaid
|
|
453
|
+
:GivePromise(self._remoting.ReplicateTemplate:PromiseInvokeServer(tombstoneId))
|
|
418
454
|
:Then(function(tempTemplate)
|
|
419
455
|
if not tempTemplate then
|
|
420
|
-
|
|
456
|
+
Promise.rejected("Failed to get any template")
|
|
457
|
+
return
|
|
421
458
|
end
|
|
422
459
|
|
|
423
460
|
-- This tempTemplate will get destroyed by the server soon to free up server memory
|
|
@@ -450,20 +487,30 @@ end
|
|
|
450
487
|
@param templateName string
|
|
451
488
|
@return Instance?
|
|
452
489
|
]=]
|
|
453
|
-
function TemplateProvider:CloneTemplate(templateName)
|
|
454
|
-
assert(type(templateName) == "string", "templateName
|
|
490
|
+
function TemplateProvider:CloneTemplate(templateName: string): Instance?
|
|
491
|
+
assert(type(templateName) == "string", "Bad templateName")
|
|
455
492
|
|
|
456
493
|
local template = self._templateMapList:GetItemForKeyAtIndex(templateName, -1)
|
|
457
494
|
if not template then
|
|
458
495
|
local unreplicated = self._unreplicatedTemplateMapList:GetListForKey(templateName)
|
|
459
496
|
|
|
460
497
|
if unreplicated then
|
|
461
|
-
error(
|
|
498
|
+
error(
|
|
499
|
+
string.format(
|
|
500
|
+
"[TemplateProvider.%s.CloneTemplate] - Template %q is not replicated. Use PromiseCloneTemplate instead",
|
|
501
|
+
self.ServiceName,
|
|
502
|
+
tostring(templateName)
|
|
503
|
+
)
|
|
504
|
+
)
|
|
462
505
|
else
|
|
463
|
-
error(
|
|
506
|
+
error(
|
|
507
|
+
string.format(
|
|
508
|
+
"[TemplateProvider.%s.CloneTemplate] - Cannot provide template %q",
|
|
509
|
+
self.ServiceName,
|
|
510
|
+
tostring(templateName)
|
|
511
|
+
)
|
|
512
|
+
)
|
|
464
513
|
end
|
|
465
|
-
|
|
466
|
-
return nil
|
|
467
514
|
end
|
|
468
515
|
|
|
469
516
|
return self:_cloneTemplate(template)
|
|
@@ -481,7 +528,7 @@ end
|
|
|
481
528
|
@param container Template
|
|
482
529
|
@return MaidTask
|
|
483
530
|
]=]
|
|
484
|
-
function TemplateProvider:AddTemplates(container)
|
|
531
|
+
function TemplateProvider:AddTemplates(container): Maid.Maid
|
|
485
532
|
assert(self:_isValidTemplate(container), "Bad container")
|
|
486
533
|
|
|
487
534
|
if typeof(container) == "Instance" then
|
|
@@ -502,14 +549,20 @@ function TemplateProvider:AddTemplates(container)
|
|
|
502
549
|
elseif type(container) == "table" then
|
|
503
550
|
local topMaid = Maid.new()
|
|
504
551
|
|
|
505
|
-
for _, value in
|
|
552
|
+
for _, value in container do
|
|
506
553
|
if typeof(value) == "Instance" then
|
|
507
554
|
-- Always add these as we explicitly ask for this to be a root too.
|
|
508
555
|
topMaid:GiveTask(self._containerRootCountingMap:Add(value))
|
|
509
556
|
elseif Observable.isObservable(value) then
|
|
510
557
|
self:_addObservableTemplates(topMaid, value)
|
|
511
558
|
else
|
|
512
|
-
error(
|
|
559
|
+
error(
|
|
560
|
+
string.format(
|
|
561
|
+
"[TemplateProvider.%s] - Bad value of type %q in container table",
|
|
562
|
+
self.ServiceName,
|
|
563
|
+
typeof(value)
|
|
564
|
+
)
|
|
565
|
+
)
|
|
513
566
|
end
|
|
514
567
|
end
|
|
515
568
|
|
|
@@ -524,7 +577,7 @@ function TemplateProvider:AddTemplates(container)
|
|
|
524
577
|
end
|
|
525
578
|
end
|
|
526
579
|
|
|
527
|
-
function TemplateProvider:_addObservableTemplates(topMaid, observable)
|
|
580
|
+
function TemplateProvider:_addObservableTemplates(topMaid: Maid.Maid, observable)
|
|
528
581
|
topMaid:GiveTask(observable:Subscribe(function(result)
|
|
529
582
|
if Brio.isBrio(result) then
|
|
530
583
|
if result:IsDead() then
|
|
@@ -543,24 +596,27 @@ function TemplateProvider:_addObservableTemplates(topMaid, observable)
|
|
|
543
596
|
end))
|
|
544
597
|
end
|
|
545
598
|
|
|
546
|
-
function TemplateProvider:_addInstanceTemplate(topMaid, template)
|
|
599
|
+
function TemplateProvider:_addInstanceTemplate(topMaid: Maid.Maid, template: Instance)
|
|
547
600
|
if self:_shouldAddChildrenAsTemplates(template) then
|
|
548
601
|
topMaid:GiveTask(self._containerRootCountingMap:Add(template))
|
|
549
602
|
end
|
|
550
603
|
|
|
551
604
|
if template:GetAttribute(TOMBSTONE_ID_ATTRIBUTE) then
|
|
552
|
-
topMaid:GiveTask(self._unreplicatedTemplateMapList:Push(
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
605
|
+
topMaid:GiveTask(self._unreplicatedTemplateMapList:Push(
|
|
606
|
+
RxInstanceUtils.observeProperty(template, "Name"):Pipe({
|
|
607
|
+
Rx.map(function(name)
|
|
608
|
+
if String.endsWith(name, TOMBSTONE_NAME_POSTFIX_UNLOADED) then
|
|
609
|
+
return String.removePostfix(name, TOMBSTONE_NAME_POSTFIX_UNLOADED)
|
|
610
|
+
elseif String.endsWith(name, TOMBSTONE_NAME_POSTFIX_LOADED) then
|
|
611
|
+
return String.removePostfix(name, TOMBSTONE_NAME_POSTFIX_LOADED)
|
|
612
|
+
else
|
|
613
|
+
return name
|
|
614
|
+
end
|
|
615
|
+
end),
|
|
616
|
+
Rx.distinct(),
|
|
617
|
+
}),
|
|
618
|
+
template
|
|
619
|
+
))
|
|
564
620
|
else
|
|
565
621
|
topMaid:GiveTask(self._templateMapList:Push(RxInstanceUtils.observeProperty(template, "Name"), template))
|
|
566
622
|
end
|
|
@@ -572,8 +628,8 @@ end
|
|
|
572
628
|
@param templateName string
|
|
573
629
|
@return boolean
|
|
574
630
|
]=]
|
|
575
|
-
function TemplateProvider:IsTemplateAvailable(templateName)
|
|
576
|
-
assert(type(templateName) == "string", "templateName
|
|
631
|
+
function TemplateProvider:IsTemplateAvailable(templateName: string)
|
|
632
|
+
assert(type(templateName) == "string", "Bad templateName")
|
|
577
633
|
|
|
578
634
|
return self._templateMapList:GetItemForKeyAtIndex(templateName, -1) ~= nil
|
|
579
635
|
end
|
|
@@ -583,7 +639,7 @@ end
|
|
|
583
639
|
|
|
584
640
|
@return { Instance }
|
|
585
641
|
]=]
|
|
586
|
-
function TemplateProvider:GetTemplateList()
|
|
642
|
+
function TemplateProvider:GetTemplateList(): { Instance }
|
|
587
643
|
return self._templateMapList:GetListOfValuesAtListIndex(-1)
|
|
588
644
|
end
|
|
589
645
|
|
|
@@ -592,7 +648,7 @@ end
|
|
|
592
648
|
|
|
593
649
|
@return { Instance }
|
|
594
650
|
]=]
|
|
595
|
-
function TemplateProvider:GetContainerList()
|
|
651
|
+
function TemplateProvider:GetContainerList(): { Instance }
|
|
596
652
|
return self._containerRootCountingMap:GetList()
|
|
597
653
|
end
|
|
598
654
|
|
|
@@ -604,17 +660,17 @@ TemplateProvider.PromiseClone = assert(TemplateProvider.PromiseCloneTemplate, "M
|
|
|
604
660
|
TemplateProvider.GetAllTemplates = assert(TemplateProvider.GetTemplateList, "Missing method")
|
|
605
661
|
TemplateProvider.GetAll = assert(TemplateProvider.GetTemplateList, "Missing method")
|
|
606
662
|
|
|
607
|
-
function TemplateProvider:_cloneTemplate(template)
|
|
663
|
+
function TemplateProvider:_cloneTemplate(template: Instance): Instance
|
|
608
664
|
local newItem = template:Clone()
|
|
609
665
|
newItem.Name = String.removePostfix(template.Name, "Template")
|
|
610
666
|
return newItem
|
|
611
667
|
end
|
|
612
668
|
|
|
613
|
-
function TemplateProvider:_shouldAddChildrenAsTemplates(container)
|
|
669
|
+
function TemplateProvider:_shouldAddChildrenAsTemplates(container: Instance): boolean
|
|
614
670
|
return container:IsA("Folder")
|
|
615
671
|
end
|
|
616
672
|
|
|
617
|
-
function TemplateProvider:_isValidTemplate(container)
|
|
673
|
+
function TemplateProvider:_isValidTemplate(container): boolean
|
|
618
674
|
return typeof(container) == "Instance"
|
|
619
675
|
or Observable.isObservable(container)
|
|
620
676
|
or type(container) == "table"
|