@rbxts/covenant 2.0.0 → 2.0.2
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/package.json +1 -1
- package/src/covenant.d.ts +1 -1
- package/src/covenant.luau +5 -1
- package/src/helpers.d.ts +0 -21
- package/src/helpers.luau +0 -71
package/package.json
CHANGED
package/src/covenant.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class Covenant {
|
|
|
68
68
|
recipe: (entities: ReadonlyMap<T, Entity>, updateId: number, hooks: CovenantHooks) => {
|
|
69
69
|
statesToCreate?: T[];
|
|
70
70
|
statesToDelete?: T[];
|
|
71
|
-
};
|
|
71
|
+
} | undefined;
|
|
72
72
|
}): void;
|
|
73
73
|
private worldEntity;
|
|
74
74
|
worldQuery<T extends Id[]>(...components: T): import("@rbxts/jecs").Query<import("@rbxts/jecs").InferComponents<T>>;
|
package/src/covenant.luau
CHANGED
|
@@ -672,7 +672,11 @@ do
|
|
|
672
672
|
local updater = function()
|
|
673
673
|
lastUpdateId += 1
|
|
674
674
|
local updateId = lastUpdateId
|
|
675
|
-
local
|
|
675
|
+
local modifiers = recipe(entities, updateId, hooks)
|
|
676
|
+
if modifiers == nil then
|
|
677
|
+
return nil
|
|
678
|
+
end
|
|
679
|
+
local _binding = modifiers
|
|
676
680
|
local statesToCreate = _binding.statesToCreate
|
|
677
681
|
local statesToDelete = _binding.statesToDelete
|
|
678
682
|
local _result = statesToCreate
|
package/src/helpers.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Discriminator } from "./hooks";
|
|
2
|
-
|
|
3
|
-
export declare function turnArrayWithIdentifierToMap<T extends defined>(
|
|
4
|
-
array: ReadonlyArray<T>,
|
|
5
|
-
getIdentifier: (state: T) => Discriminator,
|
|
6
|
-
): Map<defined, T>;
|
|
7
|
-
export declare function compareMaps<TKey extends Discriminator, TValue extends defined>(
|
|
8
|
-
previousMap: ReadonlyMap<TKey, TValue>,
|
|
9
|
-
newMap: ReadonlyMap<TKey, TValue>,
|
|
10
|
-
): {
|
|
11
|
-
entriesAdded: {
|
|
12
|
-
key: TKey;
|
|
13
|
-
value: TValue;
|
|
14
|
-
}[];
|
|
15
|
-
entriesChanged: {
|
|
16
|
-
key: TKey;
|
|
17
|
-
value: TValue;
|
|
18
|
-
previousValue: TValue;
|
|
19
|
-
}[];
|
|
20
|
-
keysRemoved: TKey[];
|
|
21
|
-
};
|
package/src/helpers.luau
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
-- Manually modified
|
|
3
|
-
local function turnArrayWithIdentifierToMap(array, getIdentifier)
|
|
4
|
-
local newMap = {}
|
|
5
|
-
-- ▼ ReadonlyArray.forEach ▼
|
|
6
|
-
local _callback = function(value)
|
|
7
|
-
local identifier = getIdentifier(value)
|
|
8
|
-
local _value = value
|
|
9
|
-
newMap[identifier] = _value
|
|
10
|
-
end
|
|
11
|
-
for _k, _v in array do
|
|
12
|
-
_callback(_v)
|
|
13
|
-
end
|
|
14
|
-
-- ▲ ReadonlyArray.forEach ▲
|
|
15
|
-
return newMap
|
|
16
|
-
end
|
|
17
|
-
local function compareMaps(previousMap, newMap)
|
|
18
|
-
local entriesAdded = {}
|
|
19
|
-
local entriesChanged = {}
|
|
20
|
-
local keysRemoved = {}
|
|
21
|
-
-- ▼ ReadonlyMap.forEach ▼
|
|
22
|
-
local _callback = function(value, key)
|
|
23
|
-
local _previousMap = previousMap
|
|
24
|
-
local _key = key
|
|
25
|
-
if not (_previousMap[_key] ~= nil) then
|
|
26
|
-
local _arg0 = {
|
|
27
|
-
key = key,
|
|
28
|
-
value = value,
|
|
29
|
-
}
|
|
30
|
-
table.insert(entriesAdded, _arg0)
|
|
31
|
-
else
|
|
32
|
-
local _previousMap_1 = previousMap
|
|
33
|
-
local _key_1 = key
|
|
34
|
-
local previousValue = _previousMap_1[_key_1]
|
|
35
|
-
if previousValue ~= value then
|
|
36
|
-
local _arg0 = {
|
|
37
|
-
key = key,
|
|
38
|
-
value = value,
|
|
39
|
-
previousValue = previousValue,
|
|
40
|
-
}
|
|
41
|
-
table.insert(entriesChanged, _arg0)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
for _k, _v in newMap do
|
|
46
|
-
_callback(_v, _k, newMap)
|
|
47
|
-
end
|
|
48
|
-
-- ▲ ReadonlyMap.forEach ▲
|
|
49
|
-
-- ▼ ReadonlyMap.forEach ▼
|
|
50
|
-
local _callback_1 = function(_, key)
|
|
51
|
-
local _newMap = newMap
|
|
52
|
-
local _key = key
|
|
53
|
-
if not (_newMap[_key] ~= nil) then
|
|
54
|
-
local _key_1 = key
|
|
55
|
-
table.insert(keysRemoved, _key_1)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
for _k, _v in previousMap do
|
|
59
|
-
_callback_1(_v, _k, previousMap)
|
|
60
|
-
end
|
|
61
|
-
-- ▲ ReadonlyMap.forEach ▲
|
|
62
|
-
return {
|
|
63
|
-
entriesAdded = entriesAdded,
|
|
64
|
-
entriesChanged = entriesChanged,
|
|
65
|
-
keysRemoved = keysRemoved,
|
|
66
|
-
}
|
|
67
|
-
end
|
|
68
|
-
return {
|
|
69
|
-
turnArrayWithIdentifierToMap = turnArrayWithIdentifierToMap,
|
|
70
|
-
compareMaps = compareMaps,
|
|
71
|
-
}
|