bard-legends-framework 0.10.2 → 0.10.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.
Files changed (26) hide show
  1. package/dist/game-entities/base/destroyable.d.ts +1 -1
  2. package/dist/game-entities/base/destroyable.js +1 -1
  3. package/dist/game-entities/base/helpers/decorate-actions-lib.d.ts +2 -2
  4. package/dist/game-entities/base/helpers/decorate-actions-lib.js +3 -3
  5. package/dist/game-entities/entity/entity.d.ts +2 -9
  6. package/dist/game-entities/entity/entity.js +13 -21
  7. package/dist/game-entities/entity/singleton-entity.js +3 -3
  8. package/dist/game-entities/scene/scene.d.ts +0 -4
  9. package/dist/game-entities/scene/scene.js +2 -19
  10. package/dist/game-entities/update-cycle.js +1 -1
  11. package/dist/game-entities/view/view.js +1 -1
  12. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +6 -6
  13. package/dist/pixi/components/helpers/smooth-scroller.test.js +5 -5
  14. package/dist/pixi/display-object/objects/graphics/graphics.js +1 -1
  15. package/dist/pixi/game.js +1 -1
  16. package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +1 -1
  17. package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +1 -1
  18. package/dist/pixi/services/keyboard/keyboard.js +1 -1
  19. package/dist/pixi/services/mouse/mouse-target-focus.service.js +1 -1
  20. package/dist/pixi/services/mouse/mouse.service.js +2 -2
  21. package/dist/utilities/libraries/animator/animator.js +9 -9
  22. package/dist/utilities/libraries/animator/animator.test.js +66 -66
  23. package/dist/utilities/libraries/animator/state-animation/slide-state-animation.test.js +1 -1
  24. package/dist/utilities/libraries/animator/state-animation/state-animation.test.js +3 -3
  25. package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.test.js +1 -1
  26. package/package.json +1 -1
@@ -12,6 +12,6 @@ export declare abstract class Destroyable {
12
12
  protected afterDestroy(): void;
13
13
  protected destroySelf(): void;
14
14
  attach(parent: IAttachable | string): this;
15
- skipAttachCheck(): this;
15
+ attachToRoot(): this;
16
16
  protected destroyAttachment(object: CanBeAttached): void;
17
17
  }
@@ -50,7 +50,7 @@ class Destroyable {
50
50
  }
51
51
  return this;
52
52
  }
53
- skipAttachCheck() {
53
+ attachToRoot() {
54
54
  if (this._attachIsCalled) {
55
55
  throw new Error(`Destroyable: The object is already attached to something!`);
56
56
  }
@@ -2,12 +2,12 @@ import { Attachable } from '../attachable';
2
2
  declare module 'actions-lib' {
3
3
  interface ActionSubscription {
4
4
  attach(parent: Attachable | string): ActionSubscription;
5
- skipAttachCheck(): ActionSubscription;
5
+ attachToRoot(): ActionSubscription;
6
6
  decorateActionSubscription(): ActionSubscription;
7
7
  }
8
8
  interface ReducerEffectChannel<EffectType, ResponseType> {
9
9
  attach(parent: Attachable | string): ReducerEffectChannel<EffectType, ResponseType>;
10
- skipAttachCheck(): ReducerEffectChannel<EffectType, ResponseType>;
10
+ attachToRoot(): ReducerEffectChannel<EffectType, ResponseType>;
11
11
  decorateEffectChannel(): ReducerEffectChannel<EffectType, ResponseType>;
12
12
  }
13
13
  }
@@ -43,7 +43,7 @@ class ActionsLibDecorator {
43
43
  this.$meta = { attachIsCalled: true, attachedParent: parentEntity };
44
44
  return this;
45
45
  };
46
- actionsLib.ActionSubscription.prototype.skipAttachCheck = function () {
46
+ actionsLib.ActionSubscription.prototype.attachToRoot = function () {
47
47
  this.$meta = { attachIsCalled: true };
48
48
  return this;
49
49
  };
@@ -57,7 +57,7 @@ class ActionsLibDecorator {
57
57
  };
58
58
  let originalCombine = actionsLib.ActionSubscription.combine;
59
59
  actionsLib.ActionSubscription.combine = function (subscriptions) {
60
- subscriptions.forEach(subscription => subscription.skipAttachCheck());
60
+ subscriptions.forEach(subscription => subscription.attachToRoot());
61
61
  return originalCombine(subscriptions);
62
62
  };
63
63
  actionsLib.ReducerEffectChannel.prototype.attach = function (parent) {
@@ -66,7 +66,7 @@ class ActionsLibDecorator {
66
66
  this.$meta = { attachIsCalled: true, attachedParent: parentEntity };
67
67
  return this;
68
68
  };
69
- actionsLib.ReducerEffectChannel.prototype.skipAttachCheck = function () {
69
+ actionsLib.ReducerEffectChannel.prototype.attachToRoot = function () {
70
70
  this.$meta = { attachIsCalled: true };
71
71
  return this;
72
72
  };
@@ -1,12 +1,6 @@
1
1
  import { Attachable } from '../base/attachable';
2
2
  export type EntityClassType = new (...args: any[]) => Entity;
3
- /**
4
- * @param destroyOnSceneClose - Default: true. If true, the entity will be destroyed when the scene is closed.
5
- */
6
- export interface EntityDecoratorMeta {
7
- destroyOnSceneClose: boolean;
8
- }
9
- export declare function EntityDecorator(meta?: EntityDecoratorMeta): (EntityClass: EntityClassType) => any;
3
+ export declare function EntityDecorator(): (EntityClass: EntityClassType) => any;
10
4
  export declare abstract class Entity extends Attachable {
11
5
  static getInstanceById<T extends Entity>(this: new (...args: any[]) => T, entityId: string | undefined): T | undefined;
12
6
  static getInstanceByIdOrFail<T extends Entity>(this: new (...args: any[]) => T, entityId: string): T;
@@ -15,7 +9,6 @@ export declare abstract class Entity extends Attachable {
15
9
  constructor();
16
10
  protected destroySelf(): void;
17
11
  attach(parent: Attachable | string): this;
18
- skipAttachCheck(): this;
12
+ attachToRoot(): this;
19
13
  update(time: number, delta: number): void;
20
- private updateTick;
21
14
  }
@@ -2,14 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Entity = exports.EntityDecorator = void 0;
4
4
  const attachable_1 = require("../base/attachable");
5
- const scene_1 = require("../scene/scene");
5
+ const update_cycle_1 = require("../update-cycle");
6
6
  const entity_store_helper_1 = require("./helpers/entity-store.helper");
7
7
  const entity_views_helper_1 = require("./helpers/entity-views.helper");
8
- function EntityDecorator(meta) {
8
+ function EntityDecorator() {
9
9
  return function (EntityClass) {
10
10
  EntityClass.$meta = {
11
- type: 'entity',
12
- destroyOnSceneClose: meta?.destroyOnSceneClose ?? true
11
+ type: 'entity'
13
12
  };
14
13
  entity_store_helper_1.EntityStoreHelper.registerEntityClass(EntityClass);
15
14
  };
@@ -34,19 +33,19 @@ class Entity extends attachable_1.Attachable {
34
33
  constructor() {
35
34
  super();
36
35
  this.viewCreationHelper = new entity_views_helper_1.EntityViewsHelper(this);
37
- let destroyOnSceneClose = this.constructor.$meta.destroyOnSceneClose;
38
- if (destroyOnSceneClose) {
39
- scene_1.Scene['registerEntity'](this);
40
- }
41
36
  entity_store_helper_1.EntityStoreHelper.registerEntity(this);
37
+ update_cycle_1.UpdateCycle.sceneUpdateAction
38
+ .subscribe(updateData => {
39
+ if (!this.destroyed) {
40
+ this.update(updateData.time, updateData.delta);
41
+ this.viewCreationHelper.updateViews(updateData.time, updateData.delta);
42
+ }
43
+ })
44
+ .attach(this);
42
45
  }
43
46
  destroySelf() {
44
47
  super.destroySelf();
45
48
  this.viewCreationHelper.destroyViews();
46
- let destroyOnSceneClose = this.constructor.$meta.destroyOnSceneClose;
47
- if (destroyOnSceneClose) {
48
- scene_1.Scene['unregisterEntity'](this);
49
- }
50
49
  entity_store_helper_1.EntityStoreHelper.unregisterEntity(this.constructor.name, this.id);
51
50
  }
52
51
  attach(parent) {
@@ -54,19 +53,12 @@ class Entity extends attachable_1.Attachable {
54
53
  this.viewCreationHelper.createViews();
55
54
  return this;
56
55
  }
57
- skipAttachCheck() {
58
- super.skipAttachCheck();
56
+ attachToRoot() {
57
+ super.attachToRoot();
59
58
  this.viewCreationHelper.createViews();
60
59
  return this;
61
60
  }
62
61
  update(time, delta) { }
63
- // Triggered by Scene
64
- updateTick(time, delta) {
65
- if (!this.destroyed) {
66
- this.update(time, delta);
67
- this.viewCreationHelper.updateViews(time, delta);
68
- }
69
- }
70
62
  }
71
63
  exports.Entity = Entity;
72
64
  //# sourceMappingURL=entity.js.map
@@ -26,7 +26,7 @@ class SingletonEntity extends entity_1.Entity {
26
26
  resolve(createdEntity);
27
27
  }
28
28
  })
29
- .skipAttachCheck();
29
+ .attachToRoot();
30
30
  });
31
31
  }
32
32
  }
@@ -51,7 +51,7 @@ class SingletonEntity extends entity_1.Entity {
51
51
  subscribe();
52
52
  }
53
53
  })
54
- .skipAttachCheck();
54
+ .attachToRoot();
55
55
  }
56
56
  });
57
57
  };
@@ -66,7 +66,7 @@ class SingletonEntity extends entity_1.Entity {
66
66
  super();
67
67
  let entities = this.constructor.getEntities();
68
68
  if (entities.length > 1) {
69
- this.skipAttachCheck();
69
+ this.attachToRoot();
70
70
  throw new Error(`SingletonEntity: entity is decorated as singleton but multiple instances are created! Name: "${this.constructor.name}"`);
71
71
  }
72
72
  else {
@@ -9,12 +9,8 @@ export declare abstract class Scene<InputType> extends Attachable {
9
9
  static isActive<T extends Scene<any>>(this: new (...args: any[]) => T): boolean;
10
10
  static getInstance<T extends Scene<any>>(this: new (...args: any[]) => T): T | undefined;
11
11
  static getInstanceOrFail<T extends Scene<any>>(this: new (...args: any[]) => T): T;
12
- private static registerEntity;
13
- private static unregisterEntity;
14
12
  static open<InputType>(this: new (...args: any[]) => Scene<InputType>, input: InputType): Promise<void>;
15
13
  static close(): Promise<void>;
16
- private entities;
17
- private updateSubscription;
18
14
  constructor();
19
15
  protected destroySelf(): void;
20
16
  protected init(input: InputType): Promise<void>;
@@ -40,18 +40,6 @@ class Scene extends attachable_1.Attachable {
40
40
  }
41
41
  return Scene.sceneInstance;
42
42
  }
43
- static registerEntity(entity) {
44
- if (!Scene.activeScene) {
45
- throw new Error(`Scene: registerEntity is called when there is no active scene!`);
46
- }
47
- Scene.activeScene.entities.add(entity);
48
- }
49
- static unregisterEntity(entity) {
50
- if (!Scene.activeScene) {
51
- throw new Error(`Scene: unregisterEntity is called when there is no active scene!`);
52
- }
53
- Scene.activeScene.entities.delete(entity);
54
- }
55
43
  static async open(input) {
56
44
  if (!Scene.sceneTransitioning) {
57
45
  Scene.sceneTransitioning = true;
@@ -76,22 +64,17 @@ class Scene extends attachable_1.Attachable {
76
64
  }
77
65
  constructor() {
78
66
  super();
79
- this.entities = new Set();
80
- this.skipAttachCheck(); // Scene is always attached to itself
81
- this.updateSubscription = update_cycle_1.UpdateCycle.sceneUpdateAction
67
+ this.attachToRoot(); // Scene is always attached to itself
68
+ update_cycle_1.UpdateCycle.sceneUpdateAction
82
69
  .subscribe(updateData => {
83
70
  if (!this.destroyed) {
84
71
  this.update(updateData.time, updateData.delta);
85
- this.entities.forEach(entity => entity['updateTick'](updateData.time, updateData.delta));
86
72
  }
87
73
  })
88
74
  .attach(this);
89
75
  }
90
76
  destroySelf() {
91
77
  super.destroySelf();
92
- this.updateSubscription.unsubscribe();
93
- this.entities.forEach(entity => entity.destroy());
94
- this.entities = new Set();
95
78
  }
96
79
  async init(input) { }
97
80
  update(time, delta) { }
@@ -18,7 +18,7 @@ class UpdateCycle {
18
18
  resolve();
19
19
  }
20
20
  })
21
- .skipAttachCheck();
21
+ .attachToRoot();
22
22
  });
23
23
  }
24
24
  static registerUpdateModifier(callback) {
@@ -46,7 +46,7 @@ class View extends attachable_1.Attachable {
46
46
  constructor() {
47
47
  super();
48
48
  this.childUpdate = this.update.bind(this);
49
- this.skipAttachCheck(); // View is always attached to its entity
49
+ this.attachToRoot(); // View is always attached to its entity
50
50
  this._entityId = entity_views_helper_1.EntityViewsHelper.currentEntityId;
51
51
  this.getViewInstances().set(this._entityId, this);
52
52
  this.update = function (time, delta) {
@@ -51,7 +51,7 @@ let TestVisualsService = class TestVisualsService {
51
51
  .setRotation(direction)
52
52
  .attach(physicsWorldId);
53
53
  }
54
- let animator = new utilities_1.Animator(sprite, 'alpha', { duration: 1000, animation: new utilities_1.AnimationEaseIn() }).skipAttachCheck();
54
+ let animator = new utilities_1.Animator(sprite, 'alpha', { duration: 1000, animation: new utilities_1.AnimationEaseIn() }).attachToRoot();
55
55
  animator.animate({ alpha: 0 }).then(() => {
56
56
  sprite.destroy();
57
57
  animator.destroy();
@@ -71,7 +71,7 @@ let TestVisualsService = class TestVisualsService {
71
71
  let color = ray.hits.length > 0 ? helpers_lib_1.ColorHelper.red : helpers_lib_1.ColorHelper.white;
72
72
  pixi_1.Graphics.createVector(explosionCenter, ray.line.to, color).toSprite().displayParent(lineContainer).attach(physicsWorld);
73
73
  });
74
- let animator = new utilities_1.Animator(lineContainer, 'alpha', { duration, animation: new utilities_1.AnimationEaseIn() }).skipAttachCheck();
74
+ let animator = new utilities_1.Animator(lineContainer, 'alpha', { duration, animation: new utilities_1.AnimationEaseIn() }).attachToRoot();
75
75
  animator.animate({ alpha: 0 }).then(() => {
76
76
  lineContainer.destroy();
77
77
  animator.destroy();
@@ -90,7 +90,7 @@ let TestVisualsService = class TestVisualsService {
90
90
  let color = ray.hits.length > 0 ? helpers_lib_1.ColorHelper.red : helpers_lib_1.ColorHelper.white;
91
91
  pixi_1.Graphics.createVector(ray.line.from, ray.line.to, color).toSprite().displayParent(lineContainer).attach(physicsWorld);
92
92
  });
93
- let animator = new utilities_1.Animator(lineContainer, 'alpha', { duration, animation: new utilities_1.AnimationEaseIn() }).skipAttachCheck();
93
+ let animator = new utilities_1.Animator(lineContainer, 'alpha', { duration, animation: new utilities_1.AnimationEaseIn() }).attachToRoot();
94
94
  animator.animate({ alpha: 0 }).then(() => {
95
95
  lineContainer.destroy();
96
96
  animator.destroy();
@@ -105,12 +105,12 @@ let TestVisualsService = class TestVisualsService {
105
105
  .setPosition(position, { round: false })
106
106
  .setRotation(rotation)
107
107
  .setAlpha(0.5)
108
- .skipAttachCheck();
108
+ .attachToRoot();
109
109
  p2Body.shapes.forEach(shape => {
110
110
  let displayObject = this.drawShape(shape, color);
111
- displayObject.displayParent(container).skipAttachCheck();
111
+ displayObject.displayParent(container).attachToRoot();
112
112
  });
113
- let animator = new utilities_1.Animator(container, 'alpha', { duration: 1000, animation: new utilities_1.AnimationEaseIn() }).skipAttachCheck();
113
+ let animator = new utilities_1.Animator(container, 'alpha', { duration: 1000, animation: new utilities_1.AnimationEaseIn() }).attachToRoot();
114
114
  animator.animate({ alpha: 0 }).then(() => {
115
115
  container.destroy();
116
116
  animator.destroy();
@@ -21,7 +21,7 @@ class Container {
21
21
  let bottom = areaHeight - padding - container.size.y;
22
22
  (0, vitest_1.beforeEach)(() => {
23
23
  container = new Container();
24
- scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'start').skipAttachCheck();
24
+ scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'start').attachToRoot();
25
25
  });
26
26
  (0, vitest_1.describe)('Big Content', () => {
27
27
  (0, vitest_1.describe)('Starting Top', () => {
@@ -108,22 +108,22 @@ class Container {
108
108
  container.size = new helpers_lib_1.Vector(0, 100);
109
109
  });
110
110
  (0, vitest_1.test)('sample 1 - start', () => {
111
- scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'start').skipAttachCheck();
111
+ scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'start').attachToRoot();
112
112
  scroller.update(10);
113
113
  (0, vitest_1.expect)(container.y).toEqual(padding);
114
114
  });
115
115
  (0, vitest_1.test)('sample 2 - center', () => {
116
- scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'center').skipAttachCheck();
116
+ scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'center').attachToRoot();
117
117
  scroller.update(10);
118
118
  (0, vitest_1.expect)(container.y).toEqual((areaHeight - 100) * 0.5);
119
119
  });
120
120
  (0, vitest_1.test)('sample 3 - bottom', () => {
121
- scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'end').skipAttachCheck();
121
+ scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'end').attachToRoot();
122
122
  scroller.update(10);
123
123
  (0, vitest_1.expect)(container.y).toEqual(areaHeight - 100 - padding);
124
124
  });
125
125
  (0, vitest_1.test)('sample 4 - size change smooth scrolling', () => {
126
- scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'end').skipAttachCheck();
126
+ scroller = new smooth_scroller_1.SmoothScroller(container, areaHeight, padding, 'end').attachToRoot();
127
127
  scroller.update(10);
128
128
  (0, vitest_1.expect)(container.y).toEqual(areaHeight - 100 - padding);
129
129
  container.size = new helpers_lib_1.Vector(0, 200);
@@ -171,7 +171,7 @@ class Graphics extends container_1.Container {
171
171
  destroyAssetOnDestroy: !options.cache
172
172
  };
173
173
  let sprite = new sprite_1.Sprite(spriteDefinition, { texturePosition: textureConversion.bounds, ignoreAnchor: true });
174
- this.skipAttachCheck();
174
+ this.attachToRoot();
175
175
  this.destroy();
176
176
  return sprite;
177
177
  }
package/dist/pixi/game.js CHANGED
@@ -75,7 +75,7 @@ class Game {
75
75
  await Promise.all([game_assets_1.GameAssets.loadGameAssets(assetDefinitions)]);
76
76
  Game._instance = this;
77
77
  // @ts-ignore
78
- this.stage = new _1.Container().skipAttachCheck();
78
+ this.stage = new _1.Container().attachToRoot();
79
79
  // @ts-ignore
80
80
  this.stage.pixiContainer = this.pixiApp.stage;
81
81
  // @ts-ignore
@@ -16,7 +16,7 @@ const camera_entity_1 = require("../\uD83E\uDDCAentities/camera.entity");
16
16
  const FOCUS_ANIMATION_DURATION = 1500;
17
17
  let CameraService = class CameraService {
18
18
  createCamera() {
19
- let cameraEntity = new camera_entity_1.CameraEntity().skipAttachCheck();
19
+ let cameraEntity = new camera_entity_1.CameraEntity().attachToRoot();
20
20
  return cameraEntity;
21
21
  }
22
22
  getCameraPosition() {
@@ -21,6 +21,6 @@ let CameraEntity = class CameraEntity extends game_entities_1.SingletonEntity {
21
21
  };
22
22
  exports.CameraEntity = CameraEntity;
23
23
  exports.CameraEntity = CameraEntity = __decorate([
24
- (0, game_entities_1.EntityDecorator)({ destroyOnSceneClose: false })
24
+ (0, game_entities_1.EntityDecorator)()
25
25
  ], CameraEntity);
26
26
  //# sourceMappingURL=camera.entity.js.map
@@ -35,7 +35,7 @@ let KeyboardService = class KeyboardService {
35
35
  .subscribe(() => {
36
36
  this.listOfJustPressedKeys.clear();
37
37
  })
38
- .skipAttachCheck();
38
+ .attachToRoot();
39
39
  }
40
40
  isKeyDown(key) {
41
41
  return this.listOfPressedKeys.has(key);
@@ -31,7 +31,7 @@ let MouseTargetFocusService = class MouseTargetFocusService {
31
31
  this._lastFocusedPosition = undefined;
32
32
  update_cycle_1.UpdateCycle.beforeSceneUpdateAction
33
33
  .subscribe((event) => this.update(event.delta))
34
- .skipAttachCheck();
34
+ .attachToRoot();
35
35
  }
36
36
  update(delta) {
37
37
  if (this.mouseStagePositionPrevious) {
@@ -54,7 +54,7 @@ let MouseService = class MouseService {
54
54
  .subscribe(() => {
55
55
  this.screenPosition.value = mouseScreenPosition;
56
56
  })
57
- .skipAttachCheck();
57
+ .attachToRoot();
58
58
  update_cycle_1.UpdateCycle.afterSceneUpdateAction
59
59
  .subscribe(() => {
60
60
  let newStagePosition = __1.Game.instance.screenPositonToStagePosition(this.screenPosition.value);
@@ -70,7 +70,7 @@ let MouseService = class MouseService {
70
70
  this.stagePosition.value = newStagePosition;
71
71
  }
72
72
  })
73
- .skipAttachCheck();
73
+ .attachToRoot();
74
74
  }
75
75
  };
76
76
  exports.MouseService = MouseService;
@@ -34,7 +34,7 @@ class Animator extends destroyable_1.Destroyable {
34
34
  this.running = true;
35
35
  this.propertyStates = new Map();
36
36
  if (!helpers_lib_1.Comparator.isObject(target)) {
37
- this.skipAttachCheck();
37
+ this.attachToRoot();
38
38
  throw new Error(`Animator: target is not an object! Target: "${target}"`);
39
39
  }
40
40
  this.effectOn = helpers_lib_1.Comparator.isArray(effectOn) ? new Set(effectOn) : new Set([effectOn]);
@@ -45,7 +45,7 @@ class Animator extends destroyable_1.Destroyable {
45
45
  }
46
46
  this.effectOn.forEach(key => {
47
47
  if (animatedObjectProperties.has(key)) {
48
- this.skipAttachCheck();
48
+ this.attachToRoot();
49
49
  throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(target, undefined, 2)}", Property: "${key}"`);
50
50
  }
51
51
  animatedObjectProperties.add(key);
@@ -57,18 +57,18 @@ class Animator extends destroyable_1.Destroyable {
57
57
  this.defaultCompleteAnimationsHandling = options.completeAnimationsHandling ?? DEFAULT_COMPLETE_ANIMATIONS_HANDLING;
58
58
  this.effectOn.forEach(key => {
59
59
  if (!helpers_lib_1.Comparator.hasProperty(target, key)) {
60
- this.skipAttachCheck();
60
+ this.attachToRoot();
61
61
  throw new Error(`Animator: target does not have property. Target property: "${key}"`);
62
62
  }
63
63
  else if (!helpers_lib_1.Comparator.isNumber(target[key])) {
64
- this.skipAttachCheck();
64
+ this.attachToRoot();
65
65
  throw new Error(`Animator: target property is not a number. Target property: "${key}"`);
66
66
  }
67
67
  });
68
68
  }
69
69
  onChange(callback) {
70
70
  if (this.onChangeCallback) {
71
- this.skipAttachCheck();
71
+ this.attachToRoot();
72
72
  throw new Error('Animator: onChangeCallback is already set!');
73
73
  }
74
74
  this.onChangeCallback = callback;
@@ -76,7 +76,7 @@ class Animator extends destroyable_1.Destroyable {
76
76
  }
77
77
  onComplete(callback) {
78
78
  if (this.onCompleteCallback) {
79
- this.skipAttachCheck();
79
+ this.attachToRoot();
80
80
  throw new Error('Animator: onCompleteCallback is already set!');
81
81
  }
82
82
  this.onCompleteCallback = callback;
@@ -208,7 +208,7 @@ class Animator extends destroyable_1.Destroyable {
208
208
  let previousState = this.propertyStates.get(key);
209
209
  if (previousState) {
210
210
  if (reAnimateHandling === ReAnimateHandlingType.throwError) {
211
- this.skipAttachCheck();
211
+ this.attachToRoot();
212
212
  throw new Error(`Animator: property is already being animated. Property: "${key}"`);
213
213
  }
214
214
  else if (reAnimateHandling === ReAnimateHandlingType.ignoreNewAnimation) {
@@ -280,7 +280,7 @@ class Animator extends destroyable_1.Destroyable {
280
280
  this.unsubscribeUpdateCycle();
281
281
  }
282
282
  })
283
- .skipAttachCheck();
283
+ .attachToRoot();
284
284
  }
285
285
  }
286
286
  unsubscribeUpdateCycle() {
@@ -289,7 +289,7 @@ class Animator extends destroyable_1.Destroyable {
289
289
  }
290
290
  checkPropertyValidity(key) {
291
291
  if (!this.effectOn.has(key)) {
292
- this.skipAttachCheck();
292
+ this.attachToRoot();
293
293
  throw new Error(`Animator: not effected property is tried to update. Key: "${key}", EffectOn: "${this.effectOn}"`);
294
294
  }
295
295
  }
@@ -36,33 +36,33 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
36
36
  (0, vitest_1.test)('constructor should throw error if target is not an object', () => {
37
37
  let obj = 'string';
38
38
  (0, vitest_1.expect)(() => {
39
- new animator_1.Animator(obj, 'x').skipAttachCheck();
39
+ new animator_1.Animator(obj, 'x').attachToRoot();
40
40
  }).toThrow('Animator: target is not an object! Target: "string"');
41
41
  });
42
42
  (0, vitest_1.test)('constructor should throw error if target does not have all target properties', () => {
43
43
  let obj = { x: 1, y: 2, z: 3 };
44
44
  (0, vitest_1.expect)(() => {
45
- new animator_1.Animator(obj, ['x', 't']).skipAttachCheck();
45
+ new animator_1.Animator(obj, ['x', 't']).attachToRoot();
46
46
  }).toThrow('Animator: target does not have property. Target property: "t"');
47
47
  });
48
48
  (0, vitest_1.test)('constructor should throw error if target property is not a number', () => {
49
49
  let obj = { x: 'fail' };
50
50
  (0, vitest_1.expect)(() => {
51
- new animator_1.Animator(obj, ['x']).skipAttachCheck();
51
+ new animator_1.Animator(obj, ['x']).attachToRoot();
52
52
  }).toThrow('Animator: target property is not a number. Target property: "x"');
53
53
  });
54
54
  (0, vitest_1.test)('animate should throw error if non effected property tried to animate', () => {
55
55
  (0, vitest_1.expect)(() => {
56
56
  let obj = { x: 0, y: 0 };
57
- let animator = new animator_1.Animator(obj, ['x', 't']).skipAttachCheck();
57
+ let animator = new animator_1.Animator(obj, ['x', 't']).attachToRoot();
58
58
  animator.animate({ x: 5, y: 5 });
59
59
  }).toThrow('Animator: target does not have property. Target property: "t"');
60
60
  });
61
61
  (0, vitest_1.test)('should throw error if multiple animators decorate the same property', () => {
62
62
  (0, vitest_1.expect)(() => {
63
63
  let obj = { x: 0 };
64
- new animator_1.Animator(obj, 'x').skipAttachCheck();
65
- new animator_1.Animator(obj, 'x').skipAttachCheck();
64
+ new animator_1.Animator(obj, 'x').attachToRoot();
65
+ new animator_1.Animator(obj, 'x').attachToRoot();
66
66
  }).toThrow(`Animator: target property is already animated! Target: "{\n "x": 0\n}", Property: "x"`);
67
67
  });
68
68
  (0, vitest_1.test)('setting multiple update callbacks should throw error', () => {
@@ -71,20 +71,20 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
71
71
  new animator_1.Animator(obj, 'x')
72
72
  .onChange(() => { })
73
73
  .onChange(() => { })
74
- .skipAttachCheck();
74
+ .attachToRoot();
75
75
  }).toThrow('Animator: onChangeCallback is already set!');
76
76
  });
77
77
  });
78
78
  (0, vitest_1.describe)('Animate', () => {
79
79
  (0, vitest_1.test)('animate should not change the value before the update ticks', () => {
80
80
  let obj = { x: 0 };
81
- let animator = new animator_1.Animator(obj, 'x').skipAttachCheck();
81
+ let animator = new animator_1.Animator(obj, 'x').attachToRoot();
82
82
  animator.animate({ x: 5 });
83
83
  (0, vitest_1.expect)(obj.x).toEqual(0);
84
84
  });
85
85
  (0, vitest_1.test)('animate should not take action if the target value is the same', () => {
86
86
  let obj = { x: 0 };
87
- let animator = new animator_1.Animator(obj, 'x', { duration: 4 }).skipAttachCheck();
87
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4 }).attachToRoot();
88
88
  animator.animate({ x: 0 });
89
89
  animator['update'](1);
90
90
  (0, vitest_1.expect)(obj.x).toEqual(0);
@@ -92,7 +92,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
92
92
  });
93
93
  (0, vitest_1.test)('animate should take action if the target value is the same and the animation is loop', () => {
94
94
  let obj = { x: 0 };
95
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, loop: true }).skipAttachCheck();
95
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, loop: true }).attachToRoot();
96
96
  animator.animate({ x: 0 });
97
97
  animator['update'](1);
98
98
  (0, vitest_1.expect)(obj.x).toEqual(0);
@@ -100,7 +100,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
100
100
  });
101
101
  (0, vitest_1.test)('animate to target in lineer', () => {
102
102
  let obj = { x: 0 };
103
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
103
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
104
104
  animator.animate({ x: 4 });
105
105
  animator['update'](1);
106
106
  (0, vitest_1.expect)(obj.x).toEqual(1);
@@ -113,21 +113,21 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
113
113
  });
114
114
  (0, vitest_1.test)('animate to target with overriden duration', () => {
115
115
  let obj = { x: 0 };
116
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
116
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
117
117
  animator.animate({ x: 4 }, { duration: 2 });
118
118
  animator['update'](1);
119
119
  (0, vitest_1.expect)(obj.x).toEqual(2);
120
120
  });
121
121
  (0, vitest_1.test)('animate to target with overriden instant duration', () => {
122
122
  let obj = { x: 0 };
123
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
123
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
124
124
  animator.animate({ x: 4 }, { duration: 0 });
125
125
  animator['update'](1);
126
126
  (0, vitest_1.expect)(obj.x).toEqual(4);
127
127
  });
128
128
  (0, vitest_1.test)('animate only one property should not effect the other', () => {
129
129
  let obj = { x: 0, y: 0 };
130
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
130
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
131
131
  animator.animate({ x: 4 });
132
132
  animator['update'](1);
133
133
  (0, vitest_1.expect)(obj).toEqual({ x: 1, y: 0 });
@@ -140,7 +140,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
140
140
  });
141
141
  (0, vitest_1.test)('animate with custom values should override the default settings', () => {
142
142
  let obj = { x: 0 };
143
- let animator = new animator_1.Animator(obj, 'x', { duration: 10, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
143
+ let animator = new animator_1.Animator(obj, 'x', { duration: 10, animation: new animations_1.AnimationLineer() }).attachToRoot();
144
144
  animator.animate({ x: 10 }, { duration: 4, animation: new animations_1.AnimationEaseInOut() });
145
145
  animator['update'](1);
146
146
  (0, vitest_1.expect)(obj).toEqual({ x: 1.25 });
@@ -153,7 +153,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
153
153
  });
154
154
  (0, vitest_1.test)('animate to target in easeInOut starting from zero', () => {
155
155
  let obj = { x: 0 };
156
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationEaseInOut() }).skipAttachCheck();
156
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
157
157
  animator.animate({ x: 10 });
158
158
  animator['update'](1);
159
159
  (0, vitest_1.expect)(obj.x).toEqual(1.25);
@@ -166,7 +166,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
166
166
  });
167
167
  (0, vitest_1.test)('animate to target in easeInOut starting from different value than zero', () => {
168
168
  let obj = { x: 10 };
169
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationEaseInOut() }).skipAttachCheck();
169
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
170
170
  animator.animate({ x: 20 });
171
171
  animator['update'](1);
172
172
  (0, vitest_1.expect)(obj.x).toEqual(11.25);
@@ -179,7 +179,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
179
179
  });
180
180
  (0, vitest_1.test)('animate to target and return back', () => {
181
181
  let obj = { x: 0 };
182
- let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
182
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).attachToRoot();
183
183
  animator.animate({ x: 4 });
184
184
  animator['update'](1);
185
185
  animator.animate({ x: 0 });
@@ -195,7 +195,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
195
195
  valueFromOnStep = item.x;
196
196
  onStepCallCount++;
197
197
  })
198
- .skipAttachCheck();
198
+ .attachToRoot();
199
199
  animator.animate({ x: 10 });
200
200
  (0, vitest_1.expect)(valueFromOnStep).toEqual(0);
201
201
  (0, vitest_1.expect)(onStepCallCount).toEqual(0);
@@ -222,14 +222,14 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
222
222
  .onChange(() => {
223
223
  onStepCallCount++;
224
224
  })
225
- .skipAttachCheck();
225
+ .attachToRoot();
226
226
  animator['update'](1);
227
227
  (0, vitest_1.expect)(onStepCallCount).toEqual(0);
228
228
  });
229
229
  (0, vitest_1.test)('animation complete promise', async () => {
230
230
  let obj = { x: 0 };
231
231
  let completed = false;
232
- let animator = new animator_1.Animator(obj, 'x').skipAttachCheck();
232
+ let animator = new animator_1.Animator(obj, 'x').attachToRoot();
233
233
  animator.animate({ x: 1 }, { duration: 2 }).then(() => {
234
234
  completed = true;
235
235
  });
@@ -253,7 +253,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
253
253
  }
254
254
  }
255
255
  let obj = new Foo();
256
- let animator = new animator_1.Animator(obj, ['x'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).skipAttachCheck();
256
+ let animator = new animator_1.Animator(obj, ['x'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
257
257
  animator.animate({ x: 20 });
258
258
  animator['update'](1);
259
259
  (0, vitest_1.expect)(obj.x).toEqual(11.25);
@@ -265,13 +265,13 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
265
265
  (0, vitest_1.expect)(obj.x).toEqual(20);
266
266
  });
267
267
  (0, vitest_1.test)('is animating should return true if it is animating', () => {
268
- let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
268
+ let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).attachToRoot();
269
269
  animator.animate({ x: 1 });
270
270
  (0, vitest_1.expect)(animator.isAnimating).toBeTruthy();
271
271
  });
272
272
  (0, vitest_1.test)('is animating should return false if it is not animating', () => {
273
273
  let obj = { x: 0 };
274
- let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
274
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).attachToRoot();
275
275
  (0, vitest_1.expect)(animator.isAnimating).toBeFalsy();
276
276
  animator.animate({ x: 1 });
277
277
  animator['update'](1);
@@ -281,7 +281,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
281
281
  (0, vitest_1.describe)('Animation Cycle Changes', () => {
282
282
  (0, vitest_1.test)('pause animations should halt the progress', async () => {
283
283
  let obj = { x: 0 };
284
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
284
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
285
285
  animator.animate({ x: 4 });
286
286
  animator['update'](1);
287
287
  (0, vitest_1.expect)(obj).toEqual({ x: 1 });
@@ -300,7 +300,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
300
300
  });
301
301
  (0, vitest_1.test)('new animations should not proceed while the animations are paused', async () => {
302
302
  let obj = { x: 0 };
303
- let animator = new animator_1.Animator(obj, 'x', { duration: 2, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
303
+ let animator = new animator_1.Animator(obj, 'x', { duration: 2, animation: new animations_1.AnimationLineer() }).attachToRoot();
304
304
  animator.pauseAnimations();
305
305
  animator.animate({ x: 2 });
306
306
  animator['update'](1);
@@ -315,7 +315,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
315
315
  });
316
316
  (0, vitest_1.test)('animation loop', async () => {
317
317
  let obj = { x: 0 };
318
- let animator = new animator_1.Animator(obj, 'x', { duration: 2, animation: new animations_1.AnimationLineer(), loop: true }).skipAttachCheck();
318
+ let animator = new animator_1.Animator(obj, 'x', { duration: 2, animation: new animations_1.AnimationLineer(), loop: true }).attachToRoot();
319
319
  animator.animate({ x: 2 }, { duration: 2 });
320
320
  animator['update'](1);
321
321
  (0, vitest_1.expect)(obj.x).toEqual(1);
@@ -335,7 +335,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
335
335
  let animator = new animator_1.Animator(obj, 'x', {
336
336
  duration: 4,
337
337
  reAnimateHandling: animator_1.ReAnimateHandlingType.throwError
338
- }).skipAttachCheck();
338
+ }).attachToRoot();
339
339
  animator.animate({ x: 1 });
340
340
  (0, vitest_1.expect)(async () => await animator.animate({ x: 0 })).rejects.toThrow();
341
341
  animator['update'](1);
@@ -346,7 +346,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
346
346
  let animator = new animator_1.Animator(obj, 'x', {
347
347
  duration: 1,
348
348
  reAnimateHandling: animator_1.ReAnimateHandlingType.ignoreNewAnimation
349
- }).skipAttachCheck();
349
+ }).attachToRoot();
350
350
  animator.animate({ x: 1 });
351
351
  animator.animate({ x: 2 });
352
352
  animator['update'](1);
@@ -357,7 +357,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
357
357
  let animator = new animator_1.Animator(obj, ['x', 'y'], {
358
358
  duration: 1,
359
359
  reAnimateHandling: animator_1.ReAnimateHandlingType.ignoreNewAnimation
360
- }).skipAttachCheck();
360
+ }).attachToRoot();
361
361
  animator.animate({ x: 1 });
362
362
  animator.animate({ x: 2, y: 1 });
363
363
  animator['update'](1);
@@ -365,7 +365,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
365
365
  });
366
366
  (0, vitest_1.test)('animate switch after finishes to a different animation type should not throw error', () => {
367
367
  let obj = { x: 1 };
368
- let animator = new animator_1.Animator(obj, 'x', { duration: 1 }).skipAttachCheck();
368
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1 }).attachToRoot();
369
369
  animator.animate({ x: 0 }, { animation: new animations_1.AnimationLineer() });
370
370
  animator['update'](1);
371
371
  (0, vitest_1.expect)(obj.x).toEqual(0);
@@ -384,7 +384,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
384
384
  let animator = new animator_1.Animator(obj, 'x', {
385
385
  duration: 1,
386
386
  reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious
387
- }).skipAttachCheck();
387
+ }).attachToRoot();
388
388
  animator.animate({ x: 1 });
389
389
  animator.animate({ x: 2 });
390
390
  animator['update'](1);
@@ -395,7 +395,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
395
395
  let animator = new animator_1.Animator(obj, ['x', 'y'], {
396
396
  duration: 1,
397
397
  reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious
398
- }).skipAttachCheck();
398
+ }).attachToRoot();
399
399
  animator.animate({ x: 1 });
400
400
  animator.animate({ x: 2, y: 1 });
401
401
  animator['update'](1);
@@ -406,7 +406,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
406
406
  let animator = new animator_1.Animator(obj, 'x', {
407
407
  duration: 2,
408
408
  reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious
409
- }).skipAttachCheck();
409
+ }).attachToRoot();
410
410
  animator.animate({ x: 2 });
411
411
  animator['update'](1);
412
412
  animator.animate({ x: 3 });
@@ -419,21 +419,21 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
419
419
  });
420
420
  (0, vitest_1.describe)('Set', () => {
421
421
  (0, vitest_1.test)('it should throw error if it is animating', () => {
422
- let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 1 }).skipAttachCheck();
422
+ let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 1 }).attachToRoot();
423
423
  animator.animate({ x: 1 });
424
424
  (0, vitest_1.expect)(() => {
425
425
  animator.set({ x: 0 });
426
426
  }).toThrow();
427
427
  });
428
428
  (0, vitest_1.test)('it should throw error if the property is not valid', () => {
429
- let animator = new animator_1.Animator({ x: 0 }, 'x').skipAttachCheck();
429
+ let animator = new animator_1.Animator({ x: 0 }, 'x').attachToRoot();
430
430
  (0, vitest_1.expect)(() => {
431
431
  animator.set({ t: 0 });
432
432
  }).toThrow();
433
433
  });
434
434
  (0, vitest_1.test)('it should change the original value', () => {
435
435
  let obj = { x: 0, y: 1, z: 2 };
436
- let animator = new animator_1.Animator(obj, ['x', 'y', 'z']).skipAttachCheck();
436
+ let animator = new animator_1.Animator(obj, ['x', 'y', 'z']).attachToRoot();
437
437
  animator.set({ x: 3, y: 4 });
438
438
  (0, vitest_1.expect)(obj).toEqual({ x: 3, y: 4, z: 2 });
439
439
  });
@@ -446,7 +446,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
446
446
  valueFromOnStep = item.x;
447
447
  onStepCallCount++;
448
448
  })
449
- .skipAttachCheck();
449
+ .attachToRoot();
450
450
  animator.set({ x: 1 });
451
451
  (0, vitest_1.expect)(valueFromOnStep).toEqual(1);
452
452
  (0, vitest_1.expect)(onStepCallCount).toEqual(1);
@@ -458,7 +458,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
458
458
  .onChange(() => {
459
459
  onStepCallCount++;
460
460
  })
461
- .skipAttachCheck();
461
+ .attachToRoot();
462
462
  animator.set({ x: 0 });
463
463
  (0, vitest_1.expect)(onStepCallCount).toEqual(0);
464
464
  });
@@ -470,7 +470,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
470
470
  duration: 4,
471
471
  animation: new animations_1.AnimationLineer(),
472
472
  reAnimateHandling: animator_1.ReAnimateHandlingType.ignoreNewAnimation
473
- }).skipAttachCheck();
473
+ }).attachToRoot();
474
474
  animator.animate({ x: 1 });
475
475
  animator['update'](1);
476
476
  (0, vitest_1.expect)(obj.x).toEqual(0.25);
@@ -485,7 +485,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
485
485
  animation: new animations_1.AnimationLineer(),
486
486
  reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
487
487
  completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.stayInCurrentState
488
- }).skipAttachCheck();
488
+ }).attachToRoot();
489
489
  animator.animate({ x: 1 });
490
490
  animator['update'](1);
491
491
  (0, vitest_1.expect)(obj.x).toEqual(0.25);
@@ -501,7 +501,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
501
501
  duration: 1,
502
502
  animation: new animations_1.AnimationLineer(),
503
503
  completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.returnToOriginal
504
- }).skipAttachCheck();
504
+ }).attachToRoot();
505
505
  animator.animate({ x: 1 });
506
506
  animator['update'](1);
507
507
  (0, vitest_1.expect)(obj.x).toEqual(0);
@@ -509,7 +509,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
509
509
  (0, vitest_1.test)('complete animations should finalize the ongoing animation', async () => {
510
510
  let obj = { x: 0 };
511
511
  let completed = false;
512
- let animator = new animator_1.Animator(obj, 'x').skipAttachCheck();
512
+ let animator = new animator_1.Animator(obj, 'x').attachToRoot();
513
513
  animator.animate({ x: 1 }, { duration: 4 }).then(() => {
514
514
  completed = true;
515
515
  });
@@ -524,7 +524,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
524
524
  let completed1 = false;
525
525
  let completed2 = false;
526
526
  let obj = { x: 0, y: 0 };
527
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).skipAttachCheck();
527
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
528
528
  animator.animate({ y: 10 }, { loop: true }).then(() => {
529
529
  completed1 = true;
530
530
  });
@@ -543,7 +543,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
543
543
  });
544
544
  (0, vitest_1.test)('complete animations stay in current state', async () => {
545
545
  let obj = { x: 0 };
546
- let animator = new animator_1.Animator(obj, 'x').skipAttachCheck();
546
+ let animator = new animator_1.Animator(obj, 'x').attachToRoot();
547
547
  animator.animate({ x: 4 }, {
548
548
  duration: 4,
549
549
  animation: new animations_1.AnimationLineer(),
@@ -559,7 +559,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
559
559
  });
560
560
  (0, vitest_1.test)('complete animations jump to end', async () => {
561
561
  let obj = { x: 0 };
562
- let animator = new animator_1.Animator(obj, 'x').skipAttachCheck();
562
+ let animator = new animator_1.Animator(obj, 'x').attachToRoot();
563
563
  animator.animate({ x: 4 }, {
564
564
  duration: 4,
565
565
  animation: new animations_1.AnimationLineer(),
@@ -575,7 +575,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
575
575
  });
576
576
  (0, vitest_1.test)('complete animations return to original', async () => {
577
577
  let obj = { x: 0 };
578
- let animator = new animator_1.Animator(obj, 'x').skipAttachCheck();
578
+ let animator = new animator_1.Animator(obj, 'x').attachToRoot();
579
579
  animator.animate({ x: 4 }, {
580
580
  duration: 4,
581
581
  animation: new animations_1.AnimationLineer(),
@@ -593,7 +593,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
593
593
  let obj = { x: 0 };
594
594
  let animator = new animator_1.Animator(obj, 'x', {
595
595
  completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.returnToOriginal
596
- }).skipAttachCheck();
596
+ }).attachToRoot();
597
597
  animator.animate({ x: 4 }, {
598
598
  duration: 4,
599
599
  animation: new animations_1.AnimationLineer(),
@@ -611,7 +611,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
611
611
  let obj = { x: 0 };
612
612
  let animator = new animator_1.Animator(obj, 'x', {
613
613
  completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.returnToOriginal
614
- }).skipAttachCheck();
614
+ }).attachToRoot();
615
615
  animator.animate({ x: 4 }, {
616
616
  duration: 4,
617
617
  animation: new animations_1.AnimationLineer(),
@@ -633,7 +633,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
633
633
  completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.stayInCurrentState
634
634
  })
635
635
  .onChange(value => heap.push(value.x))
636
- .skipAttachCheck();
636
+ .attachToRoot();
637
637
  animator.animate({ x: 1 });
638
638
  animator['update'](1);
639
639
  await (0, helpers_lib_1.Wait)();
@@ -647,7 +647,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
647
647
  let heap = [];
648
648
  let animator = new animator_1.Animator(obj, 'x', { duration: 4, completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.jumpToEnd })
649
649
  .onChange(value => heap.push(value.x))
650
- .skipAttachCheck();
650
+ .attachToRoot();
651
651
  animator.animate({ x: 1 });
652
652
  animator['update'](1);
653
653
  await (0, helpers_lib_1.Wait)();
@@ -664,7 +664,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
664
664
  completeAnimationsHandling: animator_1.CompleteAnimationsHandlingType.returnToOriginal
665
665
  })
666
666
  .onChange(value => heap.push(value.x))
667
- .skipAttachCheck();
667
+ .attachToRoot();
668
668
  animator.animate({ x: 1 });
669
669
  animator['update'](1);
670
670
  await (0, helpers_lib_1.Wait)();
@@ -679,7 +679,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
679
679
  .onChange(() => {
680
680
  completed = true;
681
681
  })
682
- .skipAttachCheck();
682
+ .attachToRoot();
683
683
  animator.completeAnimations();
684
684
  await (0, helpers_lib_1.Wait)();
685
685
  (0, vitest_1.expect)(completed).toBeFalsy();
@@ -687,7 +687,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
687
687
  (0, vitest_1.test)('complete animations should not trigger on change if the value change is already triggered', async () => {
688
688
  let obj = { x: 0 };
689
689
  let heap = [];
690
- let animator = new animator_1.Animator(obj, 'x', { duration: 2 }).onChange(value => heap.push(value.x)).skipAttachCheck();
690
+ let animator = new animator_1.Animator(obj, 'x', { duration: 2 }).onChange(value => heap.push(value.x)).attachToRoot();
691
691
  animator.animate({ x: 1 });
692
692
  animator['update'](1);
693
693
  await (0, helpers_lib_1.Wait)();
@@ -701,7 +701,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
701
701
  duration: 4,
702
702
  animation: new animations_1.AnimationLineer(),
703
703
  reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious
704
- }).skipAttachCheck();
704
+ }).attachToRoot();
705
705
  animator.animate({ x: 4 });
706
706
  animator['update'](1);
707
707
  await (0, helpers_lib_1.Wait)();
@@ -716,7 +716,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
716
716
  (0, vitest_1.test)('complete callback should trigger when the animation is done', async () => {
717
717
  let obj = { x: 0 };
718
718
  let completed = false;
719
- let animator = new animator_1.Animator(obj, 'x', { duration: 1 }).onComplete(() => (completed = true)).skipAttachCheck();
719
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1 }).onComplete(() => (completed = true)).attachToRoot();
720
720
  animator.animate({ x: 1 });
721
721
  animator['update'](1);
722
722
  await (0, helpers_lib_1.Wait)();
@@ -724,13 +724,13 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
724
724
  });
725
725
  (0, vitest_1.test)('complete callback should not trigger when the animation is not done', async () => {
726
726
  let completed = false;
727
- let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 1 }).onComplete(() => (completed = true)).skipAttachCheck();
727
+ let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 1 }).onComplete(() => (completed = true)).attachToRoot();
728
728
  animator.animate({ x: 1 });
729
729
  (0, vitest_1.expect)(completed).toBeFalsy();
730
730
  });
731
731
  (0, vitest_1.test)('re-animate should take action in complete callback', async () => {
732
732
  let obj = { x: 0 };
733
- let animator = new animator_1.Animator(obj, 'x', { duration: 2 }).skipAttachCheck();
733
+ let animator = new animator_1.Animator(obj, 'x', { duration: 2 }).attachToRoot();
734
734
  animator.onComplete(() => {
735
735
  animator.animate({ x: 0 });
736
736
  });
@@ -746,7 +746,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
746
746
  (0, vitest_1.describe)('Mixing Different Configurations', () => {
747
747
  (0, vitest_1.test)('animate multiple properties without mixing animation type', () => {
748
748
  let obj = { x: 0, y: 10 };
749
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).skipAttachCheck();
749
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
750
750
  animator.animate({ x: 10, y: 0 });
751
751
  animator['update'](1);
752
752
  (0, vitest_1.expect)(obj).toEqual({ x: 1.25, y: 8.75 });
@@ -759,7 +759,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
759
759
  });
760
760
  (0, vitest_1.test)('animate multiple properties with mixing animation type', () => {
761
761
  let obj = { x: 0, y: 4 };
762
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4 }).skipAttachCheck();
762
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4 }).attachToRoot();
763
763
  animator.animate({ x: 10 }, { animation: new animations_1.AnimationEaseInOut() });
764
764
  animator.animate({ y: 0 }, { animation: new animations_1.AnimationLineer() });
765
765
  animator['update'](1);
@@ -773,7 +773,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
773
773
  });
774
774
  (0, vitest_1.test)('animate multiple properties async', () => {
775
775
  let obj = { x: 0, y: 0 };
776
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).skipAttachCheck();
776
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
777
777
  animator.animate({ y: 10 });
778
778
  animator['update'](1);
779
779
  (0, vitest_1.expect)(obj).toEqual({ x: 0, y: 1.25 });
@@ -789,7 +789,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
789
789
  });
790
790
  (0, vitest_1.test)('animate multiple properties mixed with loop', () => {
791
791
  let obj = { x: 0, y: 0 };
792
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).skipAttachCheck();
792
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationEaseInOut() }).attachToRoot();
793
793
  animator.animate({ y: 10 }, { loop: true });
794
794
  animator['update'](1);
795
795
  (0, vitest_1.expect)(obj).toEqual({ x: 0, y: 1.25 });
@@ -809,7 +809,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
809
809
  let completed1 = false;
810
810
  let completed2 = false;
811
811
  let obj = { x: 0, y: 0 };
812
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4 }).skipAttachCheck();
812
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4 }).attachToRoot();
813
813
  animator.animate({ y: 10 }).then(() => {
814
814
  completed1 = true;
815
815
  });
@@ -832,7 +832,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
832
832
  });
833
833
  (0, vitest_1.test)('pause animations with mixed commands', async () => {
834
834
  let obj = { x: 0, y: 0 };
835
- let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
835
+ let animator = new animator_1.Animator(obj, ['x', 'y'], { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
836
836
  animator.resumeAnimations();
837
837
  animator.animate({ x: 4 });
838
838
  animator['update'](1);
@@ -857,7 +857,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
857
857
  (0, vitest_1.describe)('Update Cycle', () => {
858
858
  (0, vitest_1.test)('testing with update cycle', async () => {
859
859
  let obj = { x: 0 };
860
- let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
860
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: new animations_1.AnimationLineer() }).attachToRoot();
861
861
  animator.animate({ x: 4 });
862
862
  await game_entities_1.UpdateCycle.triggerUpdateTick(1);
863
863
  (0, vitest_1.expect)(obj.x).toEqual(1);
@@ -872,7 +872,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
872
872
  (0, vitest_1.describe)('Destroyed Animator', () => {
873
873
  (0, vitest_1.test)('destroyed animator should not animate', async () => {
874
874
  let obj = { x: 0 };
875
- let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).skipAttachCheck();
875
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).attachToRoot();
876
876
  animator.destroy();
877
877
  await game_entities_1.UpdateCycle.triggerUpdateTick(1);
878
878
  animator.animate({ x: 1 });
@@ -41,7 +41,7 @@ const slide_state_animation_1 = require("./slide-state-animation");
41
41
  stateAnimation = new slide_state_animation_1.SlideStateAnimation({ duration: 4, animation: new animations_1.AnimationLineer() })
42
42
  .onStateChange((state, index) => heap.push({ state, index }))
43
43
  .onValueChange((value, index) => heap.push({ value, index }))
44
- .skipAttachCheck();
44
+ .attachToRoot();
45
45
  });
46
46
  (0, vitest_1.describe)('Creation', () => {
47
47
  (0, vitest_1.test)('initial values', () => {
@@ -40,7 +40,7 @@ game_entities_1.ActionsLibDecorator.decorate(ActionsLib);
40
40
  stateAnimation = new state_animation_1.StateAnimation({ duration: 4 })
41
41
  .onStateChange((state, nextState) => heap.push({ state, nextState }))
42
42
  .onValueChange(value => heap.push(value))
43
- .skipAttachCheck();
43
+ .attachToRoot();
44
44
  });
45
45
  (0, vitest_1.describe)('Creation', () => {
46
46
  (0, vitest_1.test)('default values', () => {
@@ -257,7 +257,7 @@ game_entities_1.ActionsLibDecorator.decorate(ActionsLib);
257
257
  });
258
258
  });
259
259
  (0, vitest_1.test)('edge case, setting zero', async () => {
260
- let stateAnimationNumber = new state_animation_1.StateAnimation({ duration: 4 }).skipAttachCheck();
260
+ let stateAnimationNumber = new state_animation_1.StateAnimation({ duration: 4 }).attachToRoot();
261
261
  stateAnimationNumber.setState(2, { instant: true });
262
262
  stateAnimationNumber.setState(1);
263
263
  await game_entities_1.UpdateCycle.triggerUpdateTick(2);
@@ -340,7 +340,7 @@ game_entities_1.ActionsLibDecorator.decorate(ActionsLib);
340
340
  });
341
341
  });
342
342
  (0, vitest_1.test)('edge case, setting zero', async () => {
343
- let stateAnimationNumber = new state_animation_1.StateAnimation({ duration: 4 }).skipAttachCheck();
343
+ let stateAnimationNumber = new state_animation_1.StateAnimation({ duration: 4 }).attachToRoot();
344
344
  stateAnimationNumber.setState(2, { instant: true });
345
345
  stateAnimationNumber.setState(1);
346
346
  await game_entities_1.UpdateCycle.triggerUpdateTick(2);
@@ -40,7 +40,7 @@ game_entities_1.ActionsLibDecorator.decorate(ActionsLib);
40
40
  stateAnimation = new visit_disappear_state_animation_1.VisitDisappearStateAnimation({ duration: 4 })
41
41
  .onStateChange(state => heap.push(state))
42
42
  .onValueChange(value => heap.push(value))
43
- .skipAttachCheck();
43
+ .attachToRoot();
44
44
  });
45
45
  (0, vitest_1.describe)('Appearing', () => {
46
46
  (0, vitest_1.test)('default values', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bard-legends-framework",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Bard Legends Framework",
5
5
  "main": "dist/index.js",
6
6
  "files": [