bard-legends-framework 0.10.8 → 0.11.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/dist/game-entities/base/attachable.d.ts +10 -3
- package/dist/game-entities/base/attachable.js +50 -18
- package/dist/game-entities/base/attachable.test.js +81 -95
- package/dist/game-entities/base/helpers/attachable.store.d.ts +2 -8
- package/dist/game-entities/base/helpers/attachable.store.js +46 -17
- package/dist/game-entities/base/helpers/attachable.store.test.d.ts +1 -0
- package/dist/game-entities/base/helpers/attachable.store.test.js +234 -0
- package/dist/game-entities/base/helpers/decorate-actions-lib.d.ts +3 -3
- package/dist/game-entities/base/helpers/decorate-actions-lib.js +5 -5
- package/dist/game-entities/base/helpers/referance-variable.d.ts +2 -2
- package/dist/game-entities/base/helpers/referance-variable.js +2 -2
- package/dist/game-entities/controller/controller.d.ts +0 -1
- package/dist/game-entities/controller/controller.js +1 -0
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +10 -9
- package/dist/game-entities/entity/entity.js +9 -13
- package/dist/game-entities/entity/entity.test.js +47 -139
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
- package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
- package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +1 -1
- package/dist/game-entities/entity/helpers/entity-views.helper.js +5 -3
- package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
- package/dist/game-entities/entity/singleton-entity.js +1 -1
- package/dist/game-entities/entity/singleton-entity.test.js +2 -29
- package/dist/game-entities/index.d.ts +1 -5
- package/dist/game-entities/index.js +3 -24
- package/dist/game-entities/scene/scene.d.ts +4 -4
- package/dist/game-entities/scene/scene.js +31 -25
- package/dist/game-entities/scene/scene.test.js +14 -36
- package/dist/game-entities/service/service.js +5 -3
- package/dist/game-entities/service/service.test.js +2 -28
- package/dist/game-entities/unit-test.helper.d.ts +5 -0
- package/dist/game-entities/unit-test.helper.js +14 -0
- package/dist/game-entities/update-cycle.d.ts +15 -4
- package/dist/game-entities/update-cycle.js +14 -9
- package/dist/game-entities/view/view.d.ts +7 -8
- package/dist/game-entities/view/view.js +12 -21
- package/dist/game-entities/view/view.test.js +54 -244
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -3
- package/dist/physics/entity-types/immovable-physics-entity.js +1 -3
- package/dist/physics/entity-types/movable-entity.js +4 -4
- package/dist/physics/entity-types/movable-physics-entity.d.ts +2 -3
- package/dist/physics/entity-types/movable-physics-entity.js +5 -6
- package/dist/physics/entity-types/physics-entity.d.ts +3 -2
- package/dist/physics/entity-types/physics-entity.js +10 -7
- package/dist/physics/interfaces.d.ts +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +17 -7
- package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +1 -2
- package/dist/pixi/components/helpers/smooth-scroller.js +1 -3
- package/dist/pixi/components/helpers/smooth-scroller.test.js +5 -5
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +3 -2
- package/dist/pixi/components/mouse-wheel-listener.ui.js +10 -7
- package/dist/pixi/components/scroll-area.ui.d.ts +0 -1
- package/dist/pixi/components/scroll-area.ui.js +1 -4
- package/dist/pixi/display-object/container-attributes.d.ts +3 -4
- package/dist/pixi/display-object/container-attributes.js +2 -3
- package/dist/pixi/display-object/container.d.ts +0 -4
- package/dist/pixi/display-object/container.js +5 -17
- package/dist/pixi/display-object/objects/graphics/graphics.d.ts +1 -1
- package/dist/pixi/display-object/objects/graphics/graphics.js +5 -3
- package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
- package/dist/pixi/display-object/objects/placeholder.js +5 -3
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +5 -3
- package/dist/pixi/display-object/objects/sprite/sprite.d.ts +1 -1
- package/dist/pixi/display-object/objects/sprite/sprite.js +12 -10
- package/dist/pixi/display-object/objects/text/text.d.ts +1 -1
- package/dist/pixi/display-object/objects/text/text.js +5 -3
- package/dist/pixi/game.d.ts +6 -2
- package/dist/pixi/game.js +14 -5
- package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +1 -1
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +6 -4
- package/dist/pixi/services/keyboard/keyboard.d.ts +4 -2
- package/dist/pixi/services/keyboard/keyboard.js +6 -4
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +2 -1
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +6 -5
- package/dist/pixi/services/mouse/mouse.service.d.ts +15 -5
- package/dist/pixi/services/mouse/mouse.service.js +38 -18
- package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
- package/dist/utilities/animator/animations.d.ts +37 -0
- package/dist/utilities/animator/animations.js +88 -0
- package/dist/utilities/animator/animator.d.ts +61 -0
- package/dist/utilities/animator/animator.js +315 -0
- package/dist/utilities/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator.test.js +867 -0
- package/dist/utilities/animator/index.d.ts +7 -0
- package/dist/utilities/animator/index.js +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
- package/dist/utilities/animator/state-animation/state-animation.js +146 -0
- package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
- package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
- package/dist/utilities/delta-time/delta-time.d.ts +3 -0
- package/dist/utilities/delta-time/delta-time.js +10 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
- package/dist/utilities/index.d.ts +6 -6
- package/dist/utilities/index.js +6 -6
- package/dist/utilities/libraries/animator/animator.d.ts +3 -5
- package/dist/utilities/libraries/animator/animator.js +17 -19
- package/dist/utilities/libraries/animator/state-animation/slide-state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/slide-state-animation.js +1 -1
- package/dist/utilities/libraries/animator/state-animation/state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/state-animation.js +1 -1
- package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const attachable_1 = require("../attachable");
|
|
5
|
+
const attachable_store_1 = require("./attachable.store");
|
|
6
|
+
(0, vitest_1.describe)('AttachableStore', () => {
|
|
7
|
+
(0, vitest_1.beforeEach)(() => {
|
|
8
|
+
attachable_store_1.AttachableStore.hardReset();
|
|
9
|
+
});
|
|
10
|
+
(0, vitest_1.describe)('registerAttachmentTarget', () => {
|
|
11
|
+
(0, vitest_1.test)('generates unique id for single instance', () => {
|
|
12
|
+
class TestClass extends attachable_1.Attachable {
|
|
13
|
+
}
|
|
14
|
+
let instance = new TestClass().attachToRoot();
|
|
15
|
+
let id = instance.id;
|
|
16
|
+
(0, vitest_1.expect)(id).toBe('1:1');
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.test)('generates sequential ids for multiple instances of same class', () => {
|
|
19
|
+
class TestClass extends attachable_1.Attachable {
|
|
20
|
+
}
|
|
21
|
+
let instance1 = new TestClass().attachToRoot();
|
|
22
|
+
let instance2 = new TestClass().attachToRoot();
|
|
23
|
+
let instance3 = new TestClass().attachToRoot();
|
|
24
|
+
(0, vitest_1.expect)([instance1.id, instance2.id, instance3.id]).toEqual(['1:1', '1:2', '1:3']);
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.test)('generates different class ids for different classes', () => {
|
|
27
|
+
class TestClass1 extends attachable_1.Attachable {
|
|
28
|
+
}
|
|
29
|
+
class TestClass2 extends attachable_1.Attachable {
|
|
30
|
+
}
|
|
31
|
+
let instance1 = new TestClass1().attachToRoot();
|
|
32
|
+
let instance2 = new TestClass2().attachToRoot();
|
|
33
|
+
(0, vitest_1.expect)(instance1.id).toBe('1:1');
|
|
34
|
+
(0, vitest_1.expect)(instance2.id).toBe('2:1');
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.test)('maintains separate numbering for different classes', () => {
|
|
37
|
+
class TestClass1 extends attachable_1.Attachable {
|
|
38
|
+
}
|
|
39
|
+
class TestClass2 extends attachable_1.Attachable {
|
|
40
|
+
}
|
|
41
|
+
let instance1a = new TestClass1().attachToRoot();
|
|
42
|
+
let instance2a = new TestClass2().attachToRoot();
|
|
43
|
+
let instance1b = new TestClass1().attachToRoot();
|
|
44
|
+
let instance2b = new TestClass2().attachToRoot();
|
|
45
|
+
(0, vitest_1.expect)([instance1a.id, instance2a.id, instance1b.id, instance2b.id]).toEqual(['1:1', '2:1', '1:2', '2:2']);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.describe)('findAttachmentTarget', () => {
|
|
49
|
+
(0, vitest_1.test)('finds registered attachable by string id', () => {
|
|
50
|
+
class TestClass extends attachable_1.Attachable {
|
|
51
|
+
}
|
|
52
|
+
let instance = new TestClass().attachToRoot();
|
|
53
|
+
let found = attachable_store_1.AttachableStore.findAttachmentTarget(instance.id);
|
|
54
|
+
(0, vitest_1.expect)(found).toBe(instance);
|
|
55
|
+
});
|
|
56
|
+
(0, vitest_1.test)('returns same object when passed an Attachable instance', () => {
|
|
57
|
+
class TestClass extends attachable_1.Attachable {
|
|
58
|
+
}
|
|
59
|
+
let instance = new TestClass().attachToRoot();
|
|
60
|
+
let found = attachable_store_1.AttachableStore.findAttachmentTarget(instance);
|
|
61
|
+
(0, vitest_1.expect)(found).toBe(instance);
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.test)('throws error for non-existent id', () => {
|
|
64
|
+
(0, vitest_1.expect)(() => {
|
|
65
|
+
attachable_store_1.AttachableStore.findAttachmentTarget('999:999');
|
|
66
|
+
}).toThrow('Attachable: attachable not found by id! id: 999:999');
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.test)('throws error for empty string id', () => {
|
|
69
|
+
(0, vitest_1.expect)(() => {
|
|
70
|
+
attachable_store_1.AttachableStore.findAttachmentTarget('');
|
|
71
|
+
}).toThrow('Attachable: attachable not found by id! id: ');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.describe)('unregisterAttachmentTarget', () => {
|
|
75
|
+
(0, vitest_1.test)('removes attachable from store', () => {
|
|
76
|
+
class TestClass extends attachable_1.Attachable {
|
|
77
|
+
}
|
|
78
|
+
let instance = new TestClass().attachToRoot();
|
|
79
|
+
let id = instance.id;
|
|
80
|
+
attachable_store_1.AttachableStore.unregisterAttachmentTarget(instance);
|
|
81
|
+
(0, vitest_1.expect)(() => {
|
|
82
|
+
attachable_store_1.AttachableStore.findAttachmentTarget(id);
|
|
83
|
+
}).toThrow(`Attachable: attachable not found by id! id: ${id}`);
|
|
84
|
+
});
|
|
85
|
+
(0, vitest_1.test)('allows reusing id after unregister and hardReset', () => {
|
|
86
|
+
class TestClass extends attachable_1.Attachable {
|
|
87
|
+
}
|
|
88
|
+
let instance1 = new TestClass().attachToRoot();
|
|
89
|
+
let firstId = instance1.id;
|
|
90
|
+
attachable_store_1.AttachableStore.unregisterAttachmentTarget(instance1);
|
|
91
|
+
attachable_store_1.AttachableStore.hardReset();
|
|
92
|
+
let instance2 = new TestClass().attachToRoot();
|
|
93
|
+
let secondId = instance2.id;
|
|
94
|
+
(0, vitest_1.expect)(secondId).toBe(firstId);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
(0, vitest_1.describe)('validateIdForClass', () => {
|
|
98
|
+
(0, vitest_1.test)('returns true for matching class', () => {
|
|
99
|
+
class TestClass extends attachable_1.Attachable {
|
|
100
|
+
}
|
|
101
|
+
let instance = new TestClass().attachToRoot();
|
|
102
|
+
let isValid = attachable_store_1.AttachableStore.validateIdForClass(instance.id, TestClass);
|
|
103
|
+
(0, vitest_1.expect)(isValid).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
(0, vitest_1.test)('returns false for non-matching class', () => {
|
|
106
|
+
class TestClass1 extends attachable_1.Attachable {
|
|
107
|
+
}
|
|
108
|
+
class TestClass2 extends attachable_1.Attachable {
|
|
109
|
+
}
|
|
110
|
+
let instance = new TestClass1().attachToRoot();
|
|
111
|
+
let isValid = attachable_store_1.AttachableStore.validateIdForClass(instance.id, TestClass2);
|
|
112
|
+
(0, vitest_1.expect)(isValid).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.test)('returns false for non-existent id', () => {
|
|
115
|
+
class TestClass extends attachable_1.Attachable {
|
|
116
|
+
}
|
|
117
|
+
let isValid = attachable_store_1.AttachableStore.validateIdForClass('999:999', TestClass);
|
|
118
|
+
(0, vitest_1.expect)(isValid).toBe(false);
|
|
119
|
+
});
|
|
120
|
+
(0, vitest_1.test)('validates correctly for derived classes', () => {
|
|
121
|
+
class BaseClass extends attachable_1.Attachable {
|
|
122
|
+
}
|
|
123
|
+
class DerivedClass extends BaseClass {
|
|
124
|
+
}
|
|
125
|
+
let instance = new DerivedClass().attachToRoot();
|
|
126
|
+
let isValidForDerived = attachable_store_1.AttachableStore.validateIdForClass(instance.id, DerivedClass);
|
|
127
|
+
let isValidForBase = attachable_store_1.AttachableStore.validateIdForClass(instance.id, BaseClass);
|
|
128
|
+
(0, vitest_1.expect)(isValidForDerived).toBe(true);
|
|
129
|
+
(0, vitest_1.expect)(isValidForBase).toBe(false);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
(0, vitest_1.describe)('hardReset', () => {
|
|
133
|
+
(0, vitest_1.test)('resets class id counter', () => {
|
|
134
|
+
class TestClass1 extends attachable_1.Attachable {
|
|
135
|
+
}
|
|
136
|
+
class TestClass2 extends attachable_1.Attachable {
|
|
137
|
+
}
|
|
138
|
+
new TestClass1().attachToRoot();
|
|
139
|
+
new TestClass2().attachToRoot();
|
|
140
|
+
attachable_store_1.AttachableStore.hardReset();
|
|
141
|
+
class TestClass3 extends attachable_1.Attachable {
|
|
142
|
+
}
|
|
143
|
+
let instance = new TestClass3().attachToRoot();
|
|
144
|
+
(0, vitest_1.expect)(instance.id).toBe('1:1');
|
|
145
|
+
});
|
|
146
|
+
(0, vitest_1.test)('resets instance id counters', () => {
|
|
147
|
+
class TestClass extends attachable_1.Attachable {
|
|
148
|
+
}
|
|
149
|
+
new TestClass().attachToRoot();
|
|
150
|
+
new TestClass().attachToRoot();
|
|
151
|
+
attachable_store_1.AttachableStore.hardReset();
|
|
152
|
+
let instance = new TestClass().attachToRoot();
|
|
153
|
+
(0, vitest_1.expect)(instance.id).toBe('1:1');
|
|
154
|
+
});
|
|
155
|
+
(0, vitest_1.test)('clears all registered attachables', () => {
|
|
156
|
+
class TestClass extends attachable_1.Attachable {
|
|
157
|
+
}
|
|
158
|
+
let instance = new TestClass().attachToRoot();
|
|
159
|
+
let id = instance.id;
|
|
160
|
+
attachable_store_1.AttachableStore.hardReset();
|
|
161
|
+
(0, vitest_1.expect)(() => {
|
|
162
|
+
attachable_store_1.AttachableStore.findAttachmentTarget(id);
|
|
163
|
+
}).toThrow(`Attachable: attachable not found by id! id: ${id}`);
|
|
164
|
+
});
|
|
165
|
+
(0, vitest_1.test)('clears class validation data', () => {
|
|
166
|
+
class TestClass extends attachable_1.Attachable {
|
|
167
|
+
}
|
|
168
|
+
let instance = new TestClass().attachToRoot();
|
|
169
|
+
let id = instance.id;
|
|
170
|
+
attachable_store_1.AttachableStore.hardReset();
|
|
171
|
+
let isValid = attachable_store_1.AttachableStore.validateIdForClass(id, TestClass);
|
|
172
|
+
(0, vitest_1.expect)(isValid).toBe(false);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
(0, vitest_1.describe)('multiple classes interaction', () => {
|
|
176
|
+
(0, vitest_1.test)('handles multiple classes with multiple instances each', () => {
|
|
177
|
+
class ClassA extends attachable_1.Attachable {
|
|
178
|
+
}
|
|
179
|
+
class ClassB extends attachable_1.Attachable {
|
|
180
|
+
}
|
|
181
|
+
class ClassC extends attachable_1.Attachable {
|
|
182
|
+
}
|
|
183
|
+
let a1 = new ClassA().attachToRoot();
|
|
184
|
+
let a2 = new ClassA().attachToRoot();
|
|
185
|
+
let b1 = new ClassB().attachToRoot();
|
|
186
|
+
let c1 = new ClassC().attachToRoot();
|
|
187
|
+
let c2 = new ClassC().attachToRoot();
|
|
188
|
+
let c3 = new ClassC().attachToRoot();
|
|
189
|
+
(0, vitest_1.expect)([a1.id, a2.id, b1.id, c1.id, c2.id, c3.id]).toEqual(['1:1', '1:2', '2:1', '3:1', '3:2', '3:3']);
|
|
190
|
+
});
|
|
191
|
+
(0, vitest_1.test)('finds correct instances after complex registration', () => {
|
|
192
|
+
class ClassA extends attachable_1.Attachable {
|
|
193
|
+
}
|
|
194
|
+
class ClassB extends attachable_1.Attachable {
|
|
195
|
+
}
|
|
196
|
+
let a1 = new ClassA().attachToRoot();
|
|
197
|
+
let b1 = new ClassB().attachToRoot();
|
|
198
|
+
let a2 = new ClassA().attachToRoot();
|
|
199
|
+
let foundA1 = attachable_store_1.AttachableStore.findAttachmentTarget(a1.id);
|
|
200
|
+
let foundB1 = attachable_store_1.AttachableStore.findAttachmentTarget(b1.id);
|
|
201
|
+
let foundA2 = attachable_store_1.AttachableStore.findAttachmentTarget(a2.id);
|
|
202
|
+
(0, vitest_1.expect)(foundA1).toBe(a1);
|
|
203
|
+
(0, vitest_1.expect)(foundB1).toBe(b1);
|
|
204
|
+
(0, vitest_1.expect)(foundA2).toBe(a2);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
(0, vitest_1.describe)('edge cases', () => {
|
|
208
|
+
(0, vitest_1.test)('handles rapid registration and unregistration', () => {
|
|
209
|
+
class TestClass extends attachable_1.Attachable {
|
|
210
|
+
}
|
|
211
|
+
let instance1 = new TestClass().attachToRoot();
|
|
212
|
+
let id1 = instance1.id;
|
|
213
|
+
attachable_store_1.AttachableStore.unregisterAttachmentTarget(instance1);
|
|
214
|
+
let instance2 = new TestClass().attachToRoot();
|
|
215
|
+
let id2 = instance2.id;
|
|
216
|
+
(0, vitest_1.expect)(id2).toBe('1:2');
|
|
217
|
+
(0, vitest_1.expect)(() => {
|
|
218
|
+
attachable_store_1.AttachableStore.findAttachmentTarget(id1);
|
|
219
|
+
}).toThrow();
|
|
220
|
+
});
|
|
221
|
+
(0, vitest_1.test)('validates after partial unregistration', () => {
|
|
222
|
+
class TestClass extends attachable_1.Attachable {
|
|
223
|
+
}
|
|
224
|
+
let instance1 = new TestClass().attachToRoot();
|
|
225
|
+
let instance2 = new TestClass().attachToRoot();
|
|
226
|
+
attachable_store_1.AttachableStore.unregisterAttachmentTarget(instance1);
|
|
227
|
+
let isValid1 = attachable_store_1.AttachableStore.validateIdForClass(instance1.id, TestClass);
|
|
228
|
+
let isValid2 = attachable_store_1.AttachableStore.validateIdForClass(instance2.id, TestClass);
|
|
229
|
+
(0, vitest_1.expect)(isValid1).toBe(false);
|
|
230
|
+
(0, vitest_1.expect)(isValid2).toBe(true);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
//# sourceMappingURL=attachable.store.test.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Attachable } from '../attachable';
|
|
2
2
|
declare module 'actions-lib' {
|
|
3
3
|
interface ActionSubscription {
|
|
4
|
-
attach(parent:
|
|
4
|
+
attach(parent: Attachable | string): ActionSubscription;
|
|
5
5
|
attachToRoot(): ActionSubscription;
|
|
6
6
|
decorateActionSubscription(): ActionSubscription;
|
|
7
7
|
}
|
|
8
8
|
interface ReducerEffectChannel<EffectType, ResponseType> {
|
|
9
|
-
attach(parent:
|
|
9
|
+
attach(parent: Attachable | string): ReducerEffectChannel<EffectType, ResponseType>;
|
|
10
10
|
attachToRoot(): ReducerEffectChannel<EffectType, ResponseType>;
|
|
11
11
|
decorateEffectChannel(): ReducerEffectChannel<EffectType, ResponseType>;
|
|
12
12
|
}
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ActionsLibDecorator = void 0;
|
|
27
27
|
const ActionsLib = __importStar(require("actions-lib"));
|
|
28
|
-
const
|
|
28
|
+
const attachable_store_1 = require("./attachable.store");
|
|
29
29
|
class ActionsLibDecorator {
|
|
30
30
|
static decorate(actionsLib) {
|
|
31
31
|
this.decorateAttachFunctions(actionsLib);
|
|
@@ -38,7 +38,7 @@ class ActionsLibDecorator {
|
|
|
38
38
|
}
|
|
39
39
|
static decorateAttachFunctions(actionsLib) {
|
|
40
40
|
actionsLib.ActionSubscription.prototype.attach = function (parent) {
|
|
41
|
-
let parentEntity =
|
|
41
|
+
let parentEntity = attachable_store_1.AttachableStore.findAttachmentTarget(parent);
|
|
42
42
|
parentEntity['setAttachment'](this);
|
|
43
43
|
this.$meta = { attachIsCalled: true, attachedParent: parentEntity };
|
|
44
44
|
return this;
|
|
@@ -61,7 +61,7 @@ class ActionsLibDecorator {
|
|
|
61
61
|
return originalCombine(subscriptions);
|
|
62
62
|
};
|
|
63
63
|
actionsLib.ReducerEffectChannel.prototype.attach = function (parent) {
|
|
64
|
-
let parentEntity =
|
|
64
|
+
let parentEntity = attachable_store_1.AttachableStore.findAttachmentTarget(parent);
|
|
65
65
|
parentEntity['setAttachment'](this);
|
|
66
66
|
this.$meta = { attachIsCalled: true, attachedParent: parentEntity };
|
|
67
67
|
return this;
|
|
@@ -84,7 +84,7 @@ class ActionsLibDecorator {
|
|
|
84
84
|
actionsLib.ActionSubscription.prototype.unsubscribe = function () {
|
|
85
85
|
let parentEntity = this.$meta?.attachedParent;
|
|
86
86
|
if (parentEntity) {
|
|
87
|
-
parentEntity
|
|
87
|
+
parentEntity.removeAttachment(this);
|
|
88
88
|
this.$meta.attachedParent = undefined;
|
|
89
89
|
}
|
|
90
90
|
originalUnsubscribe.call(this);
|
|
@@ -93,7 +93,7 @@ class ActionsLibDecorator {
|
|
|
93
93
|
actionsLib.ReducerEffectChannel.prototype.unsubscribe = function () {
|
|
94
94
|
let parentEntity = this.$meta?.attachedParent;
|
|
95
95
|
if (parentEntity) {
|
|
96
|
-
parentEntity
|
|
96
|
+
parentEntity.removeAttachment(this);
|
|
97
97
|
this.$meta.attachedParent = undefined;
|
|
98
98
|
}
|
|
99
99
|
originalEffectUnsubscribe.call(this);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActionListenerCallbackFunction, ActionSubscription, IVariable } from 'actions-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { Attachable } from '../attachable';
|
|
3
3
|
export declare class ReferanceVariable implements IVariable<string | undefined> {
|
|
4
4
|
private options;
|
|
5
5
|
private variable;
|
|
@@ -8,7 +8,7 @@ export declare class ReferanceVariable implements IVariable<string | undefined>
|
|
|
8
8
|
set value(value: string | undefined);
|
|
9
9
|
get listenerCount(): number;
|
|
10
10
|
constructor(options: {
|
|
11
|
-
attachTo:
|
|
11
|
+
attachTo: Attachable;
|
|
12
12
|
});
|
|
13
13
|
set(data: string | undefined): this;
|
|
14
14
|
subscribe(callback: ActionListenerCallbackFunction<string | undefined>): ActionSubscription;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReferanceVariable = void 0;
|
|
4
4
|
const actions_lib_1 = require("actions-lib");
|
|
5
|
-
const
|
|
5
|
+
const attachable_store_1 = require("./attachable.store");
|
|
6
6
|
class ReferanceVariable {
|
|
7
7
|
get value() {
|
|
8
8
|
return this.variable.value;
|
|
@@ -22,7 +22,7 @@ class ReferanceVariable {
|
|
|
22
22
|
this.destroySubscription?.unsubscribe();
|
|
23
23
|
this.destroySubscription = undefined;
|
|
24
24
|
if (data) {
|
|
25
|
-
this.destroySubscription =
|
|
25
|
+
this.destroySubscription = attachable_store_1.AttachableStore.findAttachmentTarget(data)
|
|
26
26
|
.onDestroy.subscribe(() => {
|
|
27
27
|
this.set(undefined);
|
|
28
28
|
})
|
|
@@ -8,11 +8,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const vitest_1 = require("vitest");
|
|
10
10
|
const service_1 = require("../service/service");
|
|
11
|
-
const
|
|
11
|
+
const unit_test_helper_1 = require("../unit-test.helper");
|
|
12
12
|
const controller_1 = require("./controller");
|
|
13
13
|
(0, vitest_1.describe)('CONTROLLER', () => {
|
|
14
14
|
(0, vitest_1.beforeEach)(() => {
|
|
15
|
-
|
|
15
|
+
unit_test_helper_1.UnitTestHelper.hardReset();
|
|
16
16
|
});
|
|
17
17
|
(0, vitest_1.test)('when gateway triggers service link, it should trigger the controller function', () => {
|
|
18
18
|
let sampleLink = new controller_1.ControllerLink();
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type EntityClassType = new (...args: any[]) =>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
static
|
|
1
|
+
import { Attachable } from 'actions-lib';
|
|
2
|
+
export type EntityClassType<T extends Entity = Entity> = (new (...args: any[]) => T) & {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function EntityDecorator(): <T extends Entity>(EntityClass: EntityClassType<T>) => any;
|
|
6
|
+
export declare abstract class Entity extends Attachable {
|
|
7
|
+
static getInstanceById<T extends Entity>(this: EntityClassType<T>, entityId: string | undefined): T | undefined;
|
|
8
|
+
static getInstanceByIdOrFail<T extends Entity>(this: EntityClassType<T>, entityId: string): T;
|
|
9
|
+
static getEntities<T extends Entity>(this: EntityClassType<T>): T[];
|
|
8
10
|
private viewCreationHelper;
|
|
9
11
|
constructor();
|
|
10
12
|
destroy(): void;
|
|
11
|
-
|
|
12
|
-
attach(parent: AttachmentTarget | string): this;
|
|
13
|
+
attach(parent: Attachable | string): this;
|
|
13
14
|
attachToRoot(): this;
|
|
14
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Entity = exports.EntityDecorator = void 0;
|
|
4
|
-
const
|
|
4
|
+
const actions_lib_1 = require("actions-lib");
|
|
5
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");
|
|
@@ -14,14 +14,14 @@ function EntityDecorator() {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
exports.EntityDecorator = EntityDecorator;
|
|
17
|
-
class Entity extends
|
|
17
|
+
class Entity extends actions_lib_1.Attachable {
|
|
18
18
|
static getInstanceById(entityId) {
|
|
19
19
|
if (entityId) {
|
|
20
|
-
return entity_store_helper_1.EntityStoreHelper.
|
|
20
|
+
return entity_store_helper_1.EntityStoreHelper.getEntity(this, entityId);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
static getInstanceByIdOrFail(entityId) {
|
|
24
|
-
let entity = entity_store_helper_1.EntityStoreHelper.
|
|
24
|
+
let entity = entity_store_helper_1.EntityStoreHelper.getEntity(this, entityId);
|
|
25
25
|
if (!entity) {
|
|
26
26
|
throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${entityId}"`);
|
|
27
27
|
}
|
|
@@ -43,22 +43,18 @@ class Entity extends attachment_target_1.AttachmentTarget {
|
|
|
43
43
|
})
|
|
44
44
|
.attach(this);
|
|
45
45
|
}
|
|
46
|
-
// make the destroy function non-internal
|
|
47
46
|
destroy() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
entity_store_helper_1.EntityStoreHelper.unregisterEntity(this.constructor.name, this.id);
|
|
47
|
+
if (!this.destroyed) {
|
|
48
|
+
this.viewCreationHelper.destroyViews();
|
|
49
|
+
entity_store_helper_1.EntityStoreHelper.unregisterEntity(this.constructor, this.id);
|
|
50
|
+
super.destroy();
|
|
51
|
+
}
|
|
54
52
|
}
|
|
55
|
-
// make the destroy function non-internal
|
|
56
53
|
attach(parent) {
|
|
57
54
|
super.attach(parent);
|
|
58
55
|
this.viewCreationHelper.createViews();
|
|
59
56
|
return this;
|
|
60
57
|
}
|
|
61
|
-
// make the destroy function non-internal
|
|
62
58
|
attachToRoot() {
|
|
63
59
|
super.attachToRoot();
|
|
64
60
|
this.viewCreationHelper.createViews();
|