mani-game-engine 1.0.0-pre.12 → 1.0.0-pre.15

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/lib/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export * from './gameEngine';
2
- export * from './entity';
3
- export * from './types';
4
- export * from './scope/scopeContext';
5
- export * from './systemContext';
6
- export { EcsInjector, EntityComponent, GetComponent, GetEntity, GetContext, GetSignal, OnSignal } from './ecsInjector';
7
- import { ID, Inject, InjectId, Injector, InjectType, putIfAbsent } from 'mani-injector';
8
- import { Signal, SignalBinding, SignalCallback } from 'mani-signal';
9
- import { Clock } from './clock';
10
- export { Injector, InjectType, InjectId, Inject, putIfAbsent, ID };
11
- export { Clock };
12
- export { Signal, SignalBinding, SignalCallback };
1
+ export * from './gameEngine';
2
+ export * from './entity';
3
+ export * from './types';
4
+ export * from './scope/scopeContext';
5
+ export * from './systemContext';
6
+ export { EcsInjector, EntityComponent, GetComponent, GetEntity, GetContext, GetSignal, OnSignal } from './ecsInjector';
7
+ import { ID, Inject, InjectId, Injector, InjectType, putIfAbsent } from 'mani-injector';
8
+ import { Signal, SignalBinding, SignalCallback } from 'mani-signal';
9
+ import { Clock } from './clock';
10
+ export { Injector, InjectType, InjectId, Inject, putIfAbsent, ID };
11
+ export { Clock };
12
+ export { Signal, SignalBinding, SignalCallback };
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
- export * from './gameEngine';
2
- export * from './entity';
3
- export * from './types';
4
- export * from './scope/scopeContext';
5
- export * from './systemContext';
6
- export { EcsInjector, EntityComponent, GetComponent, GetEntity, GetContext, GetSignal, OnSignal } from './ecsInjector';
7
- import { Inject, InjectId, Injector, InjectType, putIfAbsent } from 'mani-injector';
8
- import { Signal } from 'mani-signal';
9
- export { Injector, InjectType, InjectId, Inject, putIfAbsent };
10
- export { Signal };
1
+ export * from './gameEngine';
2
+ export * from './entity';
3
+ export * from './types';
4
+ export * from './scope/scopeContext';
5
+ export * from './systemContext';
6
+ export { EcsInjector, EntityComponent, GetComponent, GetEntity, GetContext, GetSignal, OnSignal } from './ecsInjector';
7
+ import { Inject, InjectId, Injector, InjectType, putIfAbsent } from 'mani-injector';
8
+ import { Signal } from 'mani-signal';
9
+ export { Injector, InjectType, InjectId, Inject, putIfAbsent };
10
+ export { Signal };
11
11
  //# sourceMappingURL=index.js.map
@@ -1,54 +1,54 @@
1
- import { Class, EcsInjector, Signal, SignalCallback } from '../index';
2
- import { ID } from 'mani-injector';
3
- export declare type ScopeSignalOptions = {
4
- keepAlive?: boolean | Scope[];
5
- group?: string;
6
- };
7
- export declare const scopeSignalHandlers: Map<Object, [string, ID, (ScopeSignalOptions | undefined)?][]>;
8
- export declare const OnScopeSignal: (id: ID, options?: ScopeSignalOptions | undefined) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
9
- export interface Scope {
10
- [propName: string]: any;
11
- onEnter?(): void;
12
- onExit?(): void;
13
- onSubReturn?(): void;
14
- onSubExit?(): void;
15
- onActivate?(): void;
16
- onDeactivate?(): void;
17
- }
18
- export declare type ScopeMapping = (params: {
19
- injector: EcsInjector;
20
- registerScopeService: (serviceClass: Class) => void;
21
- }) => void;
22
- interface AddScopeSignalOptions extends ScopeSignalOptions {
23
- context?: unknown;
24
- }
25
- export declare class ScopeContext {
26
- private parent?;
27
- readonly scope: Scope;
28
- readonly injector: EcsInjector;
29
- private readonly stack;
30
- private readonly signalBindings;
31
- private serviceBindings;
32
- private closed;
33
- private muteKeepAliveSignals;
34
- constructor(injector: EcsInjector, scopeClass: Class, mapping?: ScopeMapping, parent?: ScopeContext | undefined);
35
- get isRoot(): boolean;
36
- get target(): Scope | undefined;
37
- get isActive(): boolean;
38
- get activeContext(): ScopeContext;
39
- enterScope(scopeClass: Class, mapping?: ScopeMapping): ScopeContext | undefined;
40
- exitScope(target?: Scope): void;
41
- closeSubScopes(): void;
42
- private logStack;
43
- getStackClasses(): Scope[];
44
- addScopeSignal<T>(signal: Signal<T>, callback: SignalCallback<T>, params?: AddScopeSignalOptions): void;
45
- disableKeepAliveSignals(): void;
46
- enableKeepAliveSignals(): void;
47
- private updateSignalBindings;
48
- private detachSignalBindings;
49
- private mapScopeSignals;
50
- private mapServiceSignals;
51
- private detachServiceBindings;
52
- private exitThis;
53
- }
54
- export {};
1
+ import { Class, EcsInjector, Signal, SignalCallback } from '../index';
2
+ import { ID } from 'mani-injector';
3
+ export declare type ScopeSignalOptions = {
4
+ keepAlive?: boolean | Scope[];
5
+ group?: string;
6
+ };
7
+ export declare const scopeSignalHandlers: Map<Object, [string, ID, (ScopeSignalOptions | undefined)?][]>;
8
+ export declare const OnScopeSignal: (id: ID, options?: ScopeSignalOptions | undefined) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
9
+ export interface Scope {
10
+ [propName: string]: any;
11
+ onEnter?(): void;
12
+ onExit?(): void;
13
+ onSubReturn?(): void;
14
+ onSubExit?(): void;
15
+ onActivate?(): void;
16
+ onDeactivate?(): void;
17
+ }
18
+ export declare type ScopeMapping = (params: {
19
+ injector: EcsInjector;
20
+ registerScopeService: (serviceClass: Class) => void;
21
+ }) => void;
22
+ interface AddScopeSignalOptions extends ScopeSignalOptions {
23
+ context?: unknown;
24
+ }
25
+ export declare class ScopeContext {
26
+ private parent?;
27
+ readonly scope: Scope;
28
+ readonly injector: EcsInjector;
29
+ private readonly stack;
30
+ private readonly signalBindings;
31
+ private serviceBindings;
32
+ private closed;
33
+ private muteKeepAliveSignals;
34
+ constructor(injector: EcsInjector, scopeClass: Class, mapping?: ScopeMapping, parent?: ScopeContext | undefined);
35
+ get isRoot(): boolean;
36
+ get target(): Scope | undefined;
37
+ get isActive(): boolean;
38
+ get activeContext(): ScopeContext;
39
+ enterScope(scopeClass: Class, mapping?: ScopeMapping): ScopeContext | undefined;
40
+ exitScope(target?: Scope): void;
41
+ closeSubScopes(): void;
42
+ private logStack;
43
+ getStackClasses(): Scope[];
44
+ addScopeSignal<T>(signal: Signal<T>, callback: SignalCallback<T>, params?: AddScopeSignalOptions): void;
45
+ disableKeepAliveSignals(): void;
46
+ enableKeepAliveSignals(): void;
47
+ private updateSignalBindings;
48
+ private detachSignalBindings;
49
+ private mapScopeSignals;
50
+ private mapServiceSignals;
51
+ private detachServiceBindings;
52
+ private exitThis;
53
+ }
54
+ export {};
@@ -1,245 +1,245 @@
1
- import { putIfAbsent } from 'mani-injector';
2
- import { signalHandlers } from '../ecsInjector';
3
- export const scopeSignalHandlers = new Map();
4
- export const OnScopeSignal = (id, options) => (target, propertyKey, descriptor) => {
5
- if (target instanceof Function) {
6
- throw new Error('only allowed on non static methods');
7
- }
8
- else {
9
- const mappingList = putIfAbsent(scopeSignalHandlers, target.constructor, () => []);
10
- mappingList.push([propertyKey, id, options]);
11
- }
12
- };
13
- class ScopeSignalBinding {
14
- constructor(signalBinding, options) {
15
- this.signalBinding = signalBinding;
16
- this.keepAlive = options === null || options === void 0 ? void 0 : options.keepAlive;
17
- this.group = options === null || options === void 0 ? void 0 : options.group;
18
- }
19
- activate() {
20
- this.signalBinding.setActive(true);
21
- }
22
- deactivate() {
23
- this.signalBinding.setActive(false);
24
- }
25
- detach() {
26
- this.signalBinding.detach();
27
- }
28
- }
29
- class ScopeStack {
30
- constructor(rootScope) {
31
- this.rootScope = rootScope;
32
- this.stack = [];
33
- this.queuedScopeChanges = [];
34
- this.ongoingChange = false;
35
- this.stack.push(rootScope);
36
- }
37
- get rootContext() {
38
- return this.stack[0];
39
- }
40
- get activeContext() {
41
- return this.stack[this.stack.length - 1];
42
- }
43
- }
44
- export class ScopeContext {
45
- constructor(injector, scopeClass, mapping, parent) {
46
- var _a, _b, _c, _d;
47
- this.parent = parent;
48
- this.signalBindings = [];
49
- this.serviceBindings = [];
50
- this.closed = false;
51
- this.muteKeepAliveSignals = false;
52
- if (!parent) {
53
- this.stack = new ScopeStack(this);
54
- }
55
- else {
56
- this.stack = parent.stack;
57
- this.stack.stack.push(this);
58
- }
59
- this.injector = injector.createChild();
60
- this.injector.map(scopeClass).toSingleton();
61
- this.injector.map(ScopeContext).toValue(this);
62
- mapping === null || mapping === void 0 ? void 0 : mapping({
63
- injector: this.injector,
64
- registerScopeService: serviceClass => {
65
- this.injector.map(serviceClass).toSingleton();
66
- this.mapServiceSignals(this.injector.get(serviceClass));
67
- },
68
- });
69
- this.scope = this.injector.get(scopeClass);
70
- this.mapScopeSignals();
71
- this.updateSignalBindings();
72
- (_b = (_a = this.scope).onEnter) === null || _b === void 0 ? void 0 : _b.call(_a);
73
- (_d = (_c = this.scope).onActivate) === null || _d === void 0 ? void 0 : _d.call(_c);
74
- }
75
- get isRoot() {
76
- return this === this.stack.rootScope;
77
- }
78
- get target() {
79
- return this.stack.target;
80
- }
81
- get isActive() {
82
- return this === this.stack.activeContext;
83
- }
84
- get activeContext() { return this.stack.activeContext; }
85
- enterScope(scopeClass, mapping) {
86
- let newContext;
87
- const doChange = () => {
88
- var _a, _b, _c, _d;
89
- (_b = (_a = this.activeContext.scope).onSubExit) === null || _b === void 0 ? void 0 : _b.call(_a);
90
- (_d = (_c = this.activeContext.scope).onDeactivate) === null || _d === void 0 ? void 0 : _d.call(_c);
91
- newContext = new ScopeContext(this.activeContext.injector, scopeClass, mapping, this.activeContext);
92
- this.logStack();
93
- const nextChange = this.stack.queuedScopeChanges.shift();
94
- if (nextChange) {
95
- nextChange();
96
- }
97
- else {
98
- this.stack.ongoingChange = false;
99
- }
100
- };
101
- if (!this.stack.ongoingChange) {
102
- this.stack.ongoingChange = true;
103
- doChange();
104
- }
105
- else {
106
- this.stack.queuedScopeChanges.push(doChange);
107
- }
108
- return newContext;
109
- }
110
- exitScope(target) {
111
- const doChange = () => {
112
- if (this.closed)
113
- throw new Error(`Scope already closed`);
114
- this.stack.target = target || this.scope.constructor;
115
- while (true) {
116
- const ctx = this.stack.stack.pop();
117
- if (!ctx) {
118
- throw new Error('no scope in stack');
119
- }
120
- ctx.exitThis();
121
- if (ctx.scope.constructor === this.stack.target) {
122
- break;
123
- }
124
- }
125
- this.stack.target = undefined;
126
- const nextChange = this.stack.queuedScopeChanges.shift();
127
- if (nextChange) {
128
- nextChange();
129
- }
130
- else {
131
- this.stack.ongoingChange = false;
132
- }
133
- };
134
- if (!this.stack.ongoingChange) {
135
- this.stack.ongoingChange = true;
136
- doChange();
137
- }
138
- else {
139
- this.stack.queuedScopeChanges.push(doChange);
140
- }
141
- }
142
- closeSubScopes() {
143
- this.stack.target = this.scope.constructor;
144
- while (!this.isActive) {
145
- const ctx = this.stack.stack.pop();
146
- if (!ctx) {
147
- throw new Error('no scope in stack');
148
- }
149
- ctx.exitThis();
150
- }
151
- this.stack.target = undefined;
152
- }
153
- logStack() {
154
- console.debug('%c' + this.stack.stack.map(c => c.scope.constructor.name).join(' -> '), 'color:yellow');
155
- }
156
- getStackClasses() {
157
- return this.stack.stack.map(context => context.scope.constructor);
158
- }
159
- addScopeSignal(signal, callback, params) {
160
- const signalBinding = new ScopeSignalBinding(signal.add(callback, params === null || params === void 0 ? void 0 : params.context), params);
161
- this.signalBindings.push(signalBinding);
162
- }
163
- disableKeepAliveSignals() {
164
- this.muteKeepAliveSignals = true;
165
- this.updateSignalBindings();
166
- }
167
- enableKeepAliveSignals() {
168
- this.muteKeepAliveSignals = false;
169
- this.updateSignalBindings();
170
- }
171
- updateSignalBindings(muteKeepAlive = false) {
172
- var _a;
173
- for (const binding of this.signalBindings) {
174
- if (this.isActive) {
175
- binding.activate();
176
- }
177
- else if (muteKeepAlive) {
178
- binding.deactivate();
179
- }
180
- else if (binding.keepAlive === true) {
181
- binding.activate();
182
- }
183
- else if (!!(binding.keepAlive)) {
184
- if (binding.keepAlive.indexOf(this.activeContext.scope.constructor) != -1) {
185
- binding.activate();
186
- }
187
- else {
188
- binding.deactivate();
189
- }
190
- }
191
- else {
192
- binding.deactivate();
193
- }
194
- }
195
- muteKeepAlive = muteKeepAlive || this.muteKeepAliveSignals;
196
- (_a = this.parent) === null || _a === void 0 ? void 0 : _a.updateSignalBindings(muteKeepAlive);
197
- }
198
- detachSignalBindings() {
199
- for (const signalBinding of this.signalBindings) {
200
- signalBinding.detach();
201
- }
202
- }
203
- mapScopeSignals() {
204
- const handlers = scopeSignalHandlers.get(this.scope.constructor);
205
- if (!handlers)
206
- return;
207
- for (const [field, id, options] of handlers) {
208
- const signal = this.injector.getSignal(id);
209
- const callback = this.scope[field];
210
- this.addScopeSignal(signal, callback, Object.assign(Object.assign({}, options), { context: this.scope }));
211
- }
212
- }
213
- mapServiceSignals(scopeService) {
214
- const handlers = signalHandlers.get(scopeService.constructor);
215
- if (!handlers)
216
- return;
217
- for (const [field, id] of handlers) {
218
- const signal = this.injector.getSignal(id);
219
- const signalBinding = signal.add(scopeService[field], scopeService);
220
- this.serviceBindings.push(signalBinding);
221
- }
222
- }
223
- detachServiceBindings() {
224
- for (const binding of this.serviceBindings) {
225
- binding.detach();
226
- }
227
- this.serviceBindings = [];
228
- }
229
- exitThis() {
230
- var _a, _b, _c, _d, _e, _f, _g, _h;
231
- if (!this.parent) {
232
- throw new Error('can\'t exit root scope?!');
233
- }
234
- this.logStack();
235
- this.detachSignalBindings();
236
- this.detachServiceBindings();
237
- (_b = (_a = this.scope).onDeactivate) === null || _b === void 0 ? void 0 : _b.call(_a);
238
- (_d = (_c = this.scope).onExit) === null || _d === void 0 ? void 0 : _d.call(_c);
239
- this.parent.updateSignalBindings();
240
- (_f = (_e = this.parent.scope).onSubReturn) === null || _f === void 0 ? void 0 : _f.call(_e);
241
- (_h = (_g = this.parent.scope).onActivate) === null || _h === void 0 ? void 0 : _h.call(_g);
242
- this.closed = true;
243
- }
244
- }
1
+ import { putIfAbsent } from 'mani-injector';
2
+ import { signalHandlers } from '../ecsInjector';
3
+ export const scopeSignalHandlers = new Map();
4
+ export const OnScopeSignal = (id, options) => (target, propertyKey, descriptor) => {
5
+ if (target instanceof Function) {
6
+ throw new Error('only allowed on non static methods');
7
+ }
8
+ else {
9
+ const mappingList = putIfAbsent(scopeSignalHandlers, target.constructor, () => []);
10
+ mappingList.push([propertyKey, id, options]);
11
+ }
12
+ };
13
+ class ScopeSignalBinding {
14
+ constructor(signalBinding, options) {
15
+ this.signalBinding = signalBinding;
16
+ this.keepAlive = options === null || options === void 0 ? void 0 : options.keepAlive;
17
+ this.group = options === null || options === void 0 ? void 0 : options.group;
18
+ }
19
+ activate() {
20
+ this.signalBinding.setActive(true);
21
+ }
22
+ deactivate() {
23
+ this.signalBinding.setActive(false);
24
+ }
25
+ detach() {
26
+ this.signalBinding.detach();
27
+ }
28
+ }
29
+ class ScopeStack {
30
+ constructor(rootScope) {
31
+ this.rootScope = rootScope;
32
+ this.stack = [];
33
+ this.queuedScopeChanges = [];
34
+ this.ongoingChange = false;
35
+ this.stack.push(rootScope);
36
+ }
37
+ get rootContext() {
38
+ return this.stack[0];
39
+ }
40
+ get activeContext() {
41
+ return this.stack[this.stack.length - 1];
42
+ }
43
+ }
44
+ export class ScopeContext {
45
+ constructor(injector, scopeClass, mapping, parent) {
46
+ var _a, _b, _c, _d;
47
+ this.parent = parent;
48
+ this.signalBindings = [];
49
+ this.serviceBindings = [];
50
+ this.closed = false;
51
+ this.muteKeepAliveSignals = false;
52
+ if (!parent) {
53
+ this.stack = new ScopeStack(this);
54
+ }
55
+ else {
56
+ this.stack = parent.stack;
57
+ this.stack.stack.push(this);
58
+ }
59
+ this.injector = injector.createChild();
60
+ this.injector.map(scopeClass).toSingleton();
61
+ this.injector.map(ScopeContext).toValue(this);
62
+ mapping === null || mapping === void 0 ? void 0 : mapping({
63
+ injector: this.injector,
64
+ registerScopeService: serviceClass => {
65
+ this.injector.map(serviceClass).toSingleton();
66
+ this.mapServiceSignals(this.injector.get(serviceClass));
67
+ },
68
+ });
69
+ this.scope = this.injector.get(scopeClass);
70
+ this.mapScopeSignals();
71
+ this.updateSignalBindings();
72
+ (_b = (_a = this.scope).onEnter) === null || _b === void 0 ? void 0 : _b.call(_a);
73
+ (_d = (_c = this.scope).onActivate) === null || _d === void 0 ? void 0 : _d.call(_c);
74
+ }
75
+ get isRoot() {
76
+ return this === this.stack.rootScope;
77
+ }
78
+ get target() {
79
+ return this.stack.target;
80
+ }
81
+ get isActive() {
82
+ return this === this.stack.activeContext;
83
+ }
84
+ get activeContext() { return this.stack.activeContext; }
85
+ enterScope(scopeClass, mapping) {
86
+ let newContext;
87
+ const doChange = () => {
88
+ var _a, _b, _c, _d;
89
+ (_b = (_a = this.activeContext.scope).onSubExit) === null || _b === void 0 ? void 0 : _b.call(_a);
90
+ (_d = (_c = this.activeContext.scope).onDeactivate) === null || _d === void 0 ? void 0 : _d.call(_c);
91
+ newContext = new ScopeContext(this.activeContext.injector, scopeClass, mapping, this.activeContext);
92
+ this.logStack();
93
+ const nextChange = this.stack.queuedScopeChanges.shift();
94
+ if (nextChange) {
95
+ nextChange();
96
+ }
97
+ else {
98
+ this.stack.ongoingChange = false;
99
+ }
100
+ };
101
+ if (!this.stack.ongoingChange) {
102
+ this.stack.ongoingChange = true;
103
+ doChange();
104
+ }
105
+ else {
106
+ this.stack.queuedScopeChanges.push(doChange);
107
+ }
108
+ return newContext;
109
+ }
110
+ exitScope(target) {
111
+ const doChange = () => {
112
+ if (this.closed)
113
+ throw new Error(`Scope already closed`);
114
+ this.stack.target = target || this.scope.constructor;
115
+ while (true) {
116
+ const ctx = this.stack.stack.pop();
117
+ if (!ctx) {
118
+ throw new Error('no scope in stack');
119
+ }
120
+ ctx.exitThis();
121
+ if (ctx.scope.constructor === this.stack.target) {
122
+ break;
123
+ }
124
+ }
125
+ this.stack.target = undefined;
126
+ const nextChange = this.stack.queuedScopeChanges.shift();
127
+ if (nextChange) {
128
+ nextChange();
129
+ }
130
+ else {
131
+ this.stack.ongoingChange = false;
132
+ }
133
+ };
134
+ if (!this.stack.ongoingChange) {
135
+ this.stack.ongoingChange = true;
136
+ doChange();
137
+ }
138
+ else {
139
+ this.stack.queuedScopeChanges.push(doChange);
140
+ }
141
+ }
142
+ closeSubScopes() {
143
+ this.stack.target = this.scope.constructor;
144
+ while (!this.isActive) {
145
+ const ctx = this.stack.stack.pop();
146
+ if (!ctx) {
147
+ throw new Error('no scope in stack');
148
+ }
149
+ ctx.exitThis();
150
+ }
151
+ this.stack.target = undefined;
152
+ }
153
+ logStack() {
154
+ console.debug('%c' + this.stack.stack.map(c => c.scope.constructor.name).join(' -> '), 'color:yellow');
155
+ }
156
+ getStackClasses() {
157
+ return this.stack.stack.map(context => context.scope.constructor);
158
+ }
159
+ addScopeSignal(signal, callback, params) {
160
+ const signalBinding = new ScopeSignalBinding(signal.add(callback, params === null || params === void 0 ? void 0 : params.context), params);
161
+ this.signalBindings.push(signalBinding);
162
+ }
163
+ disableKeepAliveSignals() {
164
+ this.muteKeepAliveSignals = true;
165
+ this.updateSignalBindings();
166
+ }
167
+ enableKeepAliveSignals() {
168
+ this.muteKeepAliveSignals = false;
169
+ this.updateSignalBindings();
170
+ }
171
+ updateSignalBindings(muteKeepAlive = false) {
172
+ var _a;
173
+ for (const binding of this.signalBindings) {
174
+ if (this.isActive) {
175
+ binding.activate();
176
+ }
177
+ else if (muteKeepAlive) {
178
+ binding.deactivate();
179
+ }
180
+ else if (binding.keepAlive === true) {
181
+ binding.activate();
182
+ }
183
+ else if (!!(binding.keepAlive)) {
184
+ if (binding.keepAlive.indexOf(this.activeContext.scope.constructor) != -1) {
185
+ binding.activate();
186
+ }
187
+ else {
188
+ binding.deactivate();
189
+ }
190
+ }
191
+ else {
192
+ binding.deactivate();
193
+ }
194
+ }
195
+ muteKeepAlive = muteKeepAlive || this.muteKeepAliveSignals;
196
+ (_a = this.parent) === null || _a === void 0 ? void 0 : _a.updateSignalBindings(muteKeepAlive);
197
+ }
198
+ detachSignalBindings() {
199
+ for (const signalBinding of this.signalBindings) {
200
+ signalBinding.detach();
201
+ }
202
+ }
203
+ mapScopeSignals() {
204
+ const handlers = scopeSignalHandlers.get(this.scope.constructor);
205
+ if (!handlers)
206
+ return;
207
+ for (const [field, id, options] of handlers) {
208
+ const signal = this.injector.getSignal(id);
209
+ const callback = this.scope[field];
210
+ this.addScopeSignal(signal, callback, Object.assign(Object.assign({}, options), { context: this.scope }));
211
+ }
212
+ }
213
+ mapServiceSignals(scopeService) {
214
+ const handlers = signalHandlers.get(scopeService.constructor);
215
+ if (!handlers)
216
+ return;
217
+ for (const [field, id] of handlers) {
218
+ const signal = this.injector.getSignal(id);
219
+ const signalBinding = signal.add(scopeService[field], scopeService);
220
+ this.serviceBindings.push(signalBinding);
221
+ }
222
+ }
223
+ detachServiceBindings() {
224
+ for (const binding of this.serviceBindings) {
225
+ binding.detach();
226
+ }
227
+ this.serviceBindings = [];
228
+ }
229
+ exitThis() {
230
+ var _a, _b, _c, _d, _e, _f, _g, _h;
231
+ if (!this.parent) {
232
+ throw new Error('can\'t exit root scope?!');
233
+ }
234
+ this.logStack();
235
+ this.detachSignalBindings();
236
+ this.detachServiceBindings();
237
+ (_b = (_a = this.scope).onDeactivate) === null || _b === void 0 ? void 0 : _b.call(_a);
238
+ (_d = (_c = this.scope).onExit) === null || _d === void 0 ? void 0 : _d.call(_c);
239
+ this.parent.updateSignalBindings();
240
+ (_f = (_e = this.parent.scope).onSubReturn) === null || _f === void 0 ? void 0 : _f.call(_e);
241
+ (_h = (_g = this.parent.scope).onActivate) === null || _h === void 0 ? void 0 : _h.call(_g);
242
+ this.closed = true;
243
+ }
244
+ }
245
245
  //# sourceMappingURL=scopeContext.js.map