bard-legends-framework 0.10.8 → 0.10.9
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/entity/entity.d.ts +3 -4
- package/dist/game-entities/entity/entity.js +7 -9
- package/dist/game-entities/entity/entity.test.js +25 -23
- package/dist/game-entities/index.d.ts +0 -2
- package/dist/game-entities/index.js +1 -18
- package/dist/game-entities/scene/scene.d.ts +2 -2
- package/dist/game-entities/scene/scene.js +2 -2
- package/dist/game-entities/scene/scene.test.js +10 -4
- package/dist/game-entities/view/view.d.ts +3 -3
- package/dist/game-entities/view/view.js +12 -9
- package/dist/game-entities/view/view.test.js +30 -12
- package/dist/physics/entity-types/physics-entity.d.ts +1 -1
- package/dist/physics/entity-types/physics-entity.js +7 -5
- 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 +1 -1
- package/dist/pixi/components/mouse-wheel-listener.ui.js +6 -4
- 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 +2 -2
- package/dist/pixi/display-object/container-attributes.js +1 -1
- package/dist/pixi/display-object/container.d.ts +3 -4
- package/dist/pixi/display-object/container.js +6 -8
- 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/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/modules/CAMERA//360/237/247/251views/camera.view.d.ts +1 -1
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +5 -3
- 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 +5 -5
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { Action } from 'actions-lib';
|
|
2
|
-
export declare
|
|
2
|
+
export declare class Attachable {
|
|
3
|
+
readonly id: string;
|
|
3
4
|
private attachedParent;
|
|
5
|
+
private attachments;
|
|
4
6
|
private _attachIsCalled;
|
|
5
7
|
private _destroyed;
|
|
6
8
|
get destroyed(): boolean;
|
|
7
9
|
readonly onDestroy: Action<void>;
|
|
8
10
|
constructor();
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
destroy(): void;
|
|
12
|
+
attach(parent: Attachable | string): this;
|
|
13
|
+
attachToRoot(): this;
|
|
14
|
+
private setAttachment;
|
|
15
|
+
private removeAttachment;
|
|
16
|
+
private checkCircularAttachment;
|
|
17
|
+
private destroyAttachment;
|
|
11
18
|
}
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Attachable = void 0;
|
|
4
4
|
const actions_lib_1 = require("actions-lib");
|
|
5
|
-
const
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
6
|
+
const attachable_store_1 = require("./helpers/attachable.store");
|
|
6
7
|
class Attachable {
|
|
7
8
|
get destroyed() {
|
|
8
9
|
return this._destroyed;
|
|
9
10
|
}
|
|
10
11
|
constructor() {
|
|
12
|
+
this.id = attachable_store_1.AttachableStore.registerAttachmentTarget(this);
|
|
13
|
+
this.attachments = [];
|
|
11
14
|
this._attachIsCalled = false;
|
|
12
15
|
this._destroyed = false;
|
|
13
16
|
this.onDestroy = new actions_lib_1.Action();
|
|
@@ -17,39 +20,32 @@ class Attachable {
|
|
|
17
20
|
}
|
|
18
21
|
});
|
|
19
22
|
}
|
|
20
|
-
/** @internal */
|
|
21
23
|
destroy() {
|
|
22
24
|
if (!this._destroyed) {
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
|
|
25
|
+
this.attachedParent?.removeAttachment(this);
|
|
26
|
+
this.attachedParent = undefined;
|
|
27
|
+
attachable_store_1.AttachableStore.unregisterAttachmentTarget(this);
|
|
28
|
+
let onDestroyListeners = [...this.onDestroy['notificationHandler']['listenersMap'].values()];
|
|
29
|
+
let attachedEntities = [...this.attachments];
|
|
30
|
+
attachedEntities.forEach(item => this.destroyAttachment(item));
|
|
31
|
+
this.attachments = [];
|
|
26
32
|
this._destroyed = true;
|
|
33
|
+
onDestroyListeners.forEach(listener => listener());
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
|
-
afterDestroy() { }
|
|
30
|
-
destroySelf() {
|
|
31
|
-
this.onDestroy.trigger();
|
|
32
|
-
this.attachedParent?.removeAttachment(this);
|
|
33
|
-
this.attachedParent = undefined;
|
|
34
|
-
}
|
|
35
|
-
/** @internal */
|
|
36
36
|
attach(parent) {
|
|
37
37
|
if (this._attachIsCalled) {
|
|
38
38
|
throw new Error(`Attachable: The object is already attached to something!`);
|
|
39
39
|
}
|
|
40
40
|
this._attachIsCalled = true;
|
|
41
41
|
if (!this._destroyed) {
|
|
42
|
-
let parentEntity =
|
|
43
|
-
|
|
44
|
-
if (parentEntity === this) {
|
|
45
|
-
throw new Error(`Entity cannot be attach to itself! entity: "${this.constructor.name}"`);
|
|
46
|
-
}
|
|
42
|
+
let parentEntity = attachable_store_1.AttachableStore.findAttachmentTarget(parent);
|
|
43
|
+
this.checkCircularAttachment(parentEntity);
|
|
47
44
|
this.attachedParent = parentEntity;
|
|
48
45
|
parentEntity.setAttachment(this);
|
|
49
46
|
}
|
|
50
47
|
return this;
|
|
51
48
|
}
|
|
52
|
-
/** @internal */
|
|
53
49
|
attachToRoot() {
|
|
54
50
|
if (this._attachIsCalled) {
|
|
55
51
|
throw new Error(`Attachable: The object is already attached to something!`);
|
|
@@ -57,6 +53,42 @@ class Attachable {
|
|
|
57
53
|
this._attachIsCalled = true;
|
|
58
54
|
return this;
|
|
59
55
|
}
|
|
56
|
+
setAttachment(child) {
|
|
57
|
+
if (this.destroyed) {
|
|
58
|
+
this.destroyAttachment(child);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.attachments.push(child);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
removeAttachment(child) {
|
|
65
|
+
let index = this.attachments.indexOf(child);
|
|
66
|
+
if (index >= 0) {
|
|
67
|
+
this.attachments.splice(index, 1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
checkCircularAttachment(parentEntity) {
|
|
71
|
+
while (parentEntity) {
|
|
72
|
+
if (parentEntity === this) {
|
|
73
|
+
throw new Error(`Circular attachment detected!`);
|
|
74
|
+
}
|
|
75
|
+
parentEntity = parentEntity.attachedParent;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
destroyAttachment(object) {
|
|
79
|
+
if (helpers_lib_1.Comparator.isObject(object)) {
|
|
80
|
+
let item = object;
|
|
81
|
+
if (helpers_lib_1.Comparator.isFunction(item.destroy)) {
|
|
82
|
+
item.destroy();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
else if (helpers_lib_1.Comparator.isFunction(item.unsubscribe)) {
|
|
86
|
+
item.unsubscribe();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`AttachmentTarget: destroyAttachment is used with not supperted type! Target: "${object}"`);
|
|
91
|
+
}
|
|
60
92
|
}
|
|
61
93
|
exports.Attachable = Attachable;
|
|
62
94
|
//# sourceMappingURL=attachable.js.map
|
|
@@ -15,12 +15,6 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
19
|
if (mod && mod.__esModule) return mod;
|
|
26
20
|
var result = {};
|
|
@@ -28,112 +22,104 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
22
|
__setModuleDefault(result, mod);
|
|
29
23
|
return result;
|
|
30
24
|
};
|
|
31
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
-
};
|
|
34
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
26
|
const ActionsLib = __importStar(require("actions-lib"));
|
|
36
|
-
const actions_lib_1 = require("actions-lib");
|
|
37
27
|
const vitest_1 = require("vitest");
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const update_cycle_1 = require("../update-cycle");
|
|
28
|
+
const attachable_1 = require("./attachable");
|
|
29
|
+
const attachable_store_1 = require("./helpers/attachable.store");
|
|
41
30
|
const decorate_actions_lib_1 = require("./helpers/decorate-actions-lib");
|
|
42
31
|
decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
43
|
-
(0, vitest_1.describe)('
|
|
32
|
+
(0, vitest_1.describe)('Attachable', () => {
|
|
44
33
|
(0, vitest_1.beforeEach)(() => {
|
|
45
|
-
|
|
46
|
-
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
47
|
-
};
|
|
48
|
-
SampleScene = __decorate([
|
|
49
|
-
(0, scene_1.SceneDecorator)()
|
|
50
|
-
], SampleScene);
|
|
51
|
-
SampleScene.open(undefined);
|
|
34
|
+
attachable_store_1.AttachableStore.hardReset();
|
|
52
35
|
});
|
|
53
|
-
(0, vitest_1.test)('
|
|
54
|
-
|
|
36
|
+
(0, vitest_1.test)('attach to self should throw error', () => {
|
|
37
|
+
class Sample extends attachable_1.Attachable {
|
|
38
|
+
}
|
|
39
|
+
let sample = new Sample();
|
|
40
|
+
(0, vitest_1.expect)(() => {
|
|
41
|
+
sample.attach(sample);
|
|
42
|
+
}).toThrow('Circular attachment detected!');
|
|
55
43
|
});
|
|
56
|
-
(0, vitest_1.test)('
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
Sample = __decorate([
|
|
60
|
-
(0, entity_1.EntityDecorator)()
|
|
61
|
-
], Sample);
|
|
62
|
-
class Foo {
|
|
63
|
-
constructor() {
|
|
64
|
-
this.destroyed = false;
|
|
65
|
-
}
|
|
66
|
-
destroy() {
|
|
67
|
-
this.destroyed = true;
|
|
68
|
-
}
|
|
44
|
+
(0, vitest_1.test)('circular attachment should throw error', () => {
|
|
45
|
+
class Sample extends attachable_1.Attachable {
|
|
69
46
|
}
|
|
70
|
-
let
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
47
|
+
let sample1 = new Sample();
|
|
48
|
+
let sample2 = new Sample();
|
|
49
|
+
(0, vitest_1.expect)(() => {
|
|
50
|
+
sample2.attach(sample1);
|
|
51
|
+
sample1.attach(sample2);
|
|
52
|
+
}).toThrow('Circular attachment detected!');
|
|
53
|
+
});
|
|
54
|
+
(0, vitest_1.test)('when attachment target is destroyed, it should destroy its attachments', () => {
|
|
55
|
+
class Target extends attachable_1.Attachable {
|
|
56
|
+
}
|
|
57
|
+
class Attachment extends attachable_1.Attachable {
|
|
58
|
+
}
|
|
59
|
+
let target = new Target();
|
|
60
|
+
let attachment = new Attachment().attach(target);
|
|
61
|
+
target.destroy();
|
|
62
|
+
(0, vitest_1.expect)(attachment.destroyed).toBeTruthy();
|
|
76
63
|
});
|
|
77
|
-
(0, vitest_1.test)('
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
Sample = __decorate([
|
|
81
|
-
(0, entity_1.EntityDecorator)()
|
|
82
|
-
], Sample);
|
|
83
|
-
class Foo {
|
|
64
|
+
(0, vitest_1.test)('attached on constructor', () => {
|
|
65
|
+
let child;
|
|
66
|
+
class Target extends attachable_1.Attachable {
|
|
84
67
|
constructor() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
destroy() {
|
|
88
|
-
this.destroyed = true;
|
|
68
|
+
super();
|
|
69
|
+
child = new Attachment().attach(this);
|
|
89
70
|
}
|
|
90
71
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
class Attachment extends attachable_1.Attachable {
|
|
73
|
+
}
|
|
74
|
+
let parent = new Target().attachToRoot();
|
|
75
|
+
parent.destroy();
|
|
76
|
+
(0, vitest_1.expect)(child?.destroyed).toBeTruthy();
|
|
77
|
+
});
|
|
78
|
+
(0, vitest_1.test)('onDestroy should be triggered when destroy is called', () => {
|
|
79
|
+
class Sample extends attachable_1.Attachable {
|
|
80
|
+
}
|
|
81
|
+
let parent = new Sample().attachToRoot();
|
|
82
|
+
let sample = new Sample().attachToRoot();
|
|
83
|
+
let destroyCalled = false;
|
|
84
|
+
sample.onDestroy
|
|
85
|
+
.subscribe(() => {
|
|
86
|
+
destroyCalled = true;
|
|
87
|
+
})
|
|
88
|
+
.attach(parent);
|
|
94
89
|
sample.destroy();
|
|
95
|
-
|
|
96
|
-
(0, vitest_1.expect)(foo.destroyed).toBeTruthy();
|
|
90
|
+
(0, vitest_1.expect)(destroyCalled).toBeTruthy();
|
|
97
91
|
});
|
|
98
|
-
(0, vitest_1.test)('
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(0, vitest_1.expect)(foo.listenerCount).toEqual(1);
|
|
92
|
+
(0, vitest_1.test)('onDestroy should be triggered when destroy listener is attached to itself', () => {
|
|
93
|
+
class Sample extends attachable_1.Attachable {
|
|
94
|
+
}
|
|
95
|
+
let sample = new Sample().attachToRoot();
|
|
96
|
+
let destroyCalled = false;
|
|
97
|
+
sample.onDestroy
|
|
98
|
+
.subscribe(() => {
|
|
99
|
+
destroyCalled = true;
|
|
100
|
+
})
|
|
101
|
+
.attach(sample);
|
|
109
102
|
sample.destroy();
|
|
110
|
-
|
|
111
|
-
(0, vitest_1.expect)(foo.listenerCount).toEqual(0);
|
|
103
|
+
(0, vitest_1.expect)(destroyCalled).toBeTruthy();
|
|
112
104
|
});
|
|
113
|
-
(0, vitest_1.test)('
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
(0, entity_1.EntityDecorator)()
|
|
132
|
-
], Child);
|
|
133
|
-
let parent = new Parent().attach(scene_1.Scene.getActiveSceneOrFail());
|
|
134
|
-
parent.destroy();
|
|
135
|
-
await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
|
|
136
|
-
(0, vitest_1.expect)(childDestoyIsCalled).toBeTruthy();
|
|
105
|
+
(0, vitest_1.test)('onDestroy calls should be executed attached first then parent', () => {
|
|
106
|
+
class Sample extends attachable_1.Attachable {
|
|
107
|
+
}
|
|
108
|
+
let sample1 = new Sample().attachToRoot();
|
|
109
|
+
let sample2 = new Sample().attach(sample1);
|
|
110
|
+
let heap = [];
|
|
111
|
+
sample1.onDestroy
|
|
112
|
+
.subscribe(() => {
|
|
113
|
+
heap.push('sample1');
|
|
114
|
+
})
|
|
115
|
+
.attach(sample1);
|
|
116
|
+
sample2.onDestroy
|
|
117
|
+
.subscribe(() => {
|
|
118
|
+
heap.push('sample2');
|
|
119
|
+
})
|
|
120
|
+
.attach(sample2);
|
|
121
|
+
sample1.destroy();
|
|
122
|
+
(0, vitest_1.expect)(heap).toEqual(['sample2', 'sample1']);
|
|
137
123
|
});
|
|
138
124
|
});
|
|
139
125
|
//# sourceMappingURL=attachable.test.js.map
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
private static nextAvailableIds;
|
|
4
|
-
private static attachables;
|
|
5
|
-
static findAttachableParent(attachableCandidate: IAttachmentTarget | string): IAttachmentTarget;
|
|
6
|
-
static registerAttachable(attachable: IAttachmentTarget): string;
|
|
7
|
-
static unregisterAttachable(attachable: IAttachmentTarget): void;
|
|
8
|
-
}
|
|
1
|
+
import { Attachable } from '../attachable';
|
|
2
|
+
export type AttachableConstructor = new (...args: any[]) => Attachable;
|
|
@@ -3,37 +3,66 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AttachableStore = void 0;
|
|
4
4
|
const helpers_lib_1 = require("helpers-lib");
|
|
5
5
|
const update_cycle_1 = require("../../update-cycle");
|
|
6
|
+
/** @internal */
|
|
6
7
|
class AttachableStore {
|
|
7
|
-
static { this.
|
|
8
|
-
static { this.
|
|
9
|
-
static
|
|
10
|
-
|
|
8
|
+
static { this.nextClassId = 1; }
|
|
9
|
+
static { this.classToClassId = new WeakMap(); }
|
|
10
|
+
static { this.nextAvailableIds = new WeakMap(); }
|
|
11
|
+
static { this.idToAttachmentTarget = new Map(); }
|
|
12
|
+
static { this.idToAttachmentTargetClass = new Map(); }
|
|
13
|
+
static findAttachmentTarget(attachableCandidate) {
|
|
14
|
+
let attachmentTarget;
|
|
11
15
|
if (helpers_lib_1.Comparator.isString(attachableCandidate)) {
|
|
12
16
|
let attachableId = attachableCandidate;
|
|
13
|
-
|
|
14
|
-
if (!
|
|
17
|
+
attachmentTarget = this.idToAttachmentTarget.get(attachableId);
|
|
18
|
+
if (!attachmentTarget) {
|
|
15
19
|
throw new Error(`Attachable: attachable not found by id! id: ${attachableId}`);
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
|
-
|
|
23
|
+
attachmentTarget = attachableCandidate;
|
|
20
24
|
}
|
|
21
|
-
return
|
|
25
|
+
return attachmentTarget;
|
|
22
26
|
}
|
|
23
|
-
static
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
static registerAttachmentTarget(attachmentTarget) {
|
|
28
|
+
let Class = attachmentTarget.constructor;
|
|
29
|
+
let numberPartOfTheId = this.nextAvailableIds.get(Class) || 1;
|
|
30
|
+
this.nextAvailableIds.set(Class, numberPartOfTheId + 1);
|
|
31
|
+
let classId = this.getClassId(Class);
|
|
32
|
+
let id = `${classId}:${numberPartOfTheId}`;
|
|
33
|
+
this.idToAttachmentTarget.set(id, attachmentTarget);
|
|
34
|
+
this.idToAttachmentTargetClass.set(id, Class);
|
|
28
35
|
return id;
|
|
29
36
|
}
|
|
30
|
-
static
|
|
31
|
-
|
|
37
|
+
static unregisterAttachmentTarget(attachmentTarget) {
|
|
38
|
+
this.idToAttachmentTarget.delete(attachmentTarget.id);
|
|
39
|
+
this.idToAttachmentTargetClass.delete(attachmentTarget.id);
|
|
40
|
+
}
|
|
41
|
+
static validateIdForClass(id, expectedConstructor) {
|
|
42
|
+
let actualConstructor = this.idToAttachmentTargetClass.get(id);
|
|
43
|
+
return actualConstructor === expectedConstructor;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Required to be called before or after each unit test to reset the store
|
|
47
|
+
*/
|
|
48
|
+
static hardReset() {
|
|
49
|
+
this.nextClassId = 1;
|
|
50
|
+
this.classToClassId = new WeakMap();
|
|
51
|
+
this.nextAvailableIds = new WeakMap();
|
|
52
|
+
this.idToAttachmentTarget.clear();
|
|
53
|
+
this.idToAttachmentTargetClass.clear();
|
|
54
|
+
}
|
|
55
|
+
static getClassId(Class) {
|
|
56
|
+
let id = this.classToClassId.get(Class);
|
|
57
|
+
if (!id) {
|
|
58
|
+
id = `${this.nextClassId++}`;
|
|
59
|
+
this.classToClassId.set(Class, id);
|
|
60
|
+
}
|
|
61
|
+
return id;
|
|
32
62
|
}
|
|
33
63
|
}
|
|
34
64
|
exports.AttachableStore = AttachableStore;
|
|
35
65
|
update_cycle_1.UpdateCycle.hardResetAction.subscribe(() => {
|
|
36
|
-
AttachableStore
|
|
37
|
-
AttachableStore['attachables'].clear();
|
|
66
|
+
AttachableStore.hardReset();
|
|
38
67
|
});
|
|
39
68
|
//# sourceMappingURL=attachable.store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|