@rbxts/covenant 1.0.2 → 1.0.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/covenant",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "src/init.lua",
5
5
  "scripts": {
6
6
  "build": "rbxtsc",
package/src/covenant.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare class Covenant {
16
16
  private systems;
17
17
  private worldChangesForReplication;
18
18
  private worldChangesForPrediction;
19
- private underivedStringifiedComponents;
19
+ private undefinedStringifiedComponents;
20
20
  private replicatedStringifiedComponents;
21
21
  private predictedStringifiedComponents;
22
22
  private started;
@@ -41,16 +41,16 @@ export declare class Covenant {
41
41
  subscribeComponent<T>(component: Entity<T>, subscriber: (entity: Entity, state: T | undefined, previousState: T | undefined) => void): () => void;
42
42
  private worldDelete;
43
43
  worldComponent<T extends defined>(): Entity<T>;
44
- private checkComponentDerived;
44
+ private checkComponentDefined;
45
45
  private defineComponentNetworkBehavior;
46
- deriveComponent<T extends defined>({ component, queriedComponents, recipe, replicated, predictionValidator, }: {
46
+ defineComputedComponent<T extends defined>({ component, queriedComponents, recipe, replicated, predictionValidator, }: {
47
47
  replicated: boolean;
48
48
  predictionValidator: ComponentPredictionValidator | false;
49
49
  component: Entity<T>;
50
50
  queriedComponents: Entity[][];
51
51
  recipe: (entity: Entity, lastState: T | undefined, updateId: number, hooks: CovenantHooks) => T | undefined;
52
52
  }): void;
53
- deriveChildren<T extends defined>({ parentComponent, parentEntityTrackerComponent, childIdentityComponent, getIdentifier, queriedComponents, recipe, replicated, predictionValidator, }: {
53
+ defineManagedChildren<T extends defined>({ parentComponent, parentEntityTrackerComponent, childIdentityComponent, getIdentifier, queriedComponents, recipe, replicated, predictionValidator, }: {
54
54
  replicated: boolean;
55
55
  predictionValidator: ComponentPredictionValidator | false;
56
56
  parentComponent: Entity<ReadonlyArray<T>>;
@@ -60,12 +60,12 @@ export declare class Covenant {
60
60
  queriedComponents: Entity[][];
61
61
  recipe: (entity: Entity, lastChildrenStates: ReadonlyArray<T>, updateId: number, hooks: CovenantHooks) => ReadonlyArray<T>;
62
62
  }): void;
63
- deriveRootEntity<T extends defined>({ identityComponent, recipe, replicated, }: {
63
+ defineEntitySource<T extends defined>({ identityComponent, recipe, replicated, }: {
64
64
  replicated: boolean;
65
65
  identityComponent: Entity<T>;
66
66
  recipe: (updateId: number, hooks: CovenantHooks) => {
67
- statesToCreate: ReadonlyArray<T>;
68
- entitiesToDelete: ReadonlyArray<Entity>;
67
+ statesToCreate?: ReadonlyArray<T>;
68
+ entitiesToDelete?: ReadonlyArray<Entity>;
69
69
  };
70
70
  }): void;
71
71
  private worldEntity;
package/src/covenant.luau CHANGED
@@ -48,7 +48,7 @@ do
48
48
  self.systems = {}
49
49
  self.worldChangesForReplication = {}
50
50
  self.worldChangesForPrediction = {}
51
- self.underivedStringifiedComponents = {}
51
+ self.undefinedStringifiedComponents = {}
52
52
  self.replicatedStringifiedComponents = {}
53
53
  self.predictedStringifiedComponents = {}
54
54
  self.started = false
@@ -235,14 +235,14 @@ do
235
235
  function Covenant:start()
236
236
  local _arg0 = not self.started
237
237
  assert(_arg0, "Already started")
238
- local _exp = next(self.underivedStringifiedComponents) == nil
238
+ local _exp = next(self.undefinedStringifiedComponents) == nil
239
239
  -- ▼ ReadonlySet.size ▼
240
240
  local _size = 0
241
- for _ in self.underivedStringifiedComponents do
241
+ for _ in self.undefinedStringifiedComponents do
242
242
  _size += 1
243
243
  end
244
244
  -- ▲ ReadonlySet.size ▲
245
- local _arg1 = `There are {_size} components that are not derived`
245
+ local _arg1 = `There are {_size} components that are not defined`
246
246
  assert(_exp, _arg1)
247
247
  self.started = true
248
248
  local _exp_1 = self.systems
@@ -439,15 +439,15 @@ do
439
439
  local c = self._world:component()
440
440
  return c
441
441
  end
442
- function Covenant:checkComponentDerived(component)
443
- local _underivedStringifiedComponents = self.underivedStringifiedComponents
442
+ function Covenant:checkComponentDefined(component)
443
+ local _undefinedStringifiedComponents = self.undefinedStringifiedComponents
444
444
  local _arg0 = tostring(component)
445
- local _arg0_1 = _underivedStringifiedComponents[_arg0] ~= nil
446
- local _arg1 = `Component {component} is already derived`
445
+ local _arg0_1 = _undefinedStringifiedComponents[_arg0] ~= nil
446
+ local _arg1 = `Component {component} is already defined`
447
447
  assert(_arg0_1, _arg1)
448
- local _underivedStringifiedComponents_1 = self.underivedStringifiedComponents
448
+ local _undefinedStringifiedComponents_1 = self.undefinedStringifiedComponents
449
449
  local _arg0_2 = tostring(component)
450
- _underivedStringifiedComponents_1[_arg0_2] = nil
450
+ _undefinedStringifiedComponents_1[_arg0_2] = nil
451
451
  end
452
452
  function Covenant:defineComponentNetworkBehavior(component, replicated, predictionValidator)
453
453
  if replicated then
@@ -465,13 +465,13 @@ do
465
465
  _stringifiedComponentValidators[_arg0_1] = _predictionValidator
466
466
  end
467
467
  end
468
- function Covenant:deriveComponent(_param)
468
+ function Covenant:defineComputedComponent(_param)
469
469
  local component = _param.component
470
470
  local queriedComponents = _param.queriedComponents
471
471
  local recipe = _param.recipe
472
472
  local replicated = _param.replicated
473
473
  local predictionValidator = _param.predictionValidator
474
- self:checkComponentDerived(component)
474
+ self:checkComponentDefined(component)
475
475
  self:defineComponentNetworkBehavior(component, replicated, predictionValidator)
476
476
  local queryThisComponent = self:worldQuery(component):cached()
477
477
  local willUpdate = true
@@ -581,7 +581,7 @@ do
581
581
  updater()
582
582
  end)
583
583
  end
584
- function Covenant:deriveChildren(_param)
584
+ function Covenant:defineManagedChildren(_param)
585
585
  local parentComponent = _param.parentComponent
586
586
  local parentEntityTrackerComponent = _param.parentEntityTrackerComponent
587
587
  local childIdentityComponent = _param.childIdentityComponent
@@ -590,9 +590,9 @@ do
590
590
  local recipe = _param.recipe
591
591
  local replicated = _param.replicated
592
592
  local predictionValidator = _param.predictionValidator
593
- self:checkComponentDerived(parentComponent)
594
- self:checkComponentDerived(parentEntityTrackerComponent)
595
- self:checkComponentDerived(childIdentityComponent)
593
+ self:checkComponentDefined(parentComponent)
594
+ self:checkComponentDefined(parentEntityTrackerComponent)
595
+ self:checkComponentDefined(childIdentityComponent)
596
596
  self:defineComponentNetworkBehavior(parentComponent, replicated, predictionValidator)
597
597
  local queryParentComponent = self:worldQuery(parentComponent):cached()
598
598
  local willUpdate = true
@@ -769,11 +769,11 @@ do
769
769
  updater()
770
770
  end)
771
771
  end
772
- function Covenant:deriveRootEntity(_param)
772
+ function Covenant:defineEntitySource(_param)
773
773
  local identityComponent = _param.identityComponent
774
774
  local recipe = _param.recipe
775
775
  local replicated = _param.replicated
776
- self:checkComponentDerived(identityComponent)
776
+ self:checkComponentDefined(identityComponent)
777
777
  self:defineComponentNetworkBehavior(identityComponent, replicated, false)
778
778
  local willUpdate = true
779
779
  local function indicateUpdate()
@@ -791,23 +791,29 @@ do
791
791
  local _binding = recipe(lastUpdateId, hooks)
792
792
  local statesToCreate = _binding.statesToCreate
793
793
  local entitiesToDelete = _binding.entitiesToDelete
794
- -- ReadonlyArray.forEach
795
- local _callback = function(state)
796
- local entity = self:worldEntity()
797
- self:worldSet(entity, identityComponent, state)
798
- end
799
- for _k, _v in statesToCreate do
800
- _callback(_v, _k - 1, statesToCreate)
801
- end
802
- -- ReadonlyArray.forEach
803
- -- ▼ ReadonlyArray.forEach ▼
804
- local _callback_1 = function(entity)
805
- self:worldDelete(entity)
794
+ local _result = statesToCreate
795
+ if _result ~= nil then
796
+ -- ReadonlyArray.forEach
797
+ local _callback = function(state)
798
+ local entity = self:worldEntity()
799
+ self:worldSet(entity, identityComponent, state)
800
+ end
801
+ for _k, _v in _result do
802
+ _callback(_v, _k - 1, _result)
803
+ end
804
+ -- ReadonlyArray.forEach
806
805
  end
807
- for _k, _v in entitiesToDelete do
808
- _callback_1(_v, _k - 1, entitiesToDelete)
806
+ local _result_1 = entitiesToDelete
807
+ if _result_1 ~= nil then
808
+ -- ▼ ReadonlyArray.forEach ▼
809
+ local _callback = function(entity)
810
+ self:worldDelete(entity)
811
+ end
812
+ for _k, _v in _result_1 do
813
+ _callback(_v, _k - 1, _result_1)
814
+ end
815
+ -- ▲ ReadonlyArray.forEach ▲
809
816
  end
810
- -- ▲ ReadonlyArray.forEach ▲
811
817
  end
812
818
  self:schedule(RunService.Heartbeat, function()
813
819
  if not willUpdate then