-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateJSBundle.ts
More file actions
80 lines (65 loc) · 3.32 KB
/
CreateJSBundle.ts
File metadata and controls
80 lines (65 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
import { IBundle, IContext, ILogger, instanceOfType } from "@robotlegsjs/core";
import { IContextView } from "../../extensions/contextView/api/IContextView";
import { ContextView } from "../../extensions/contextView/impl/ContextView";
import { ContextViewListenerConfig } from "../../extensions/contextView/impl/ContextViewListenerConfig";
import { ContextViewExtension } from "../../extensions/contextView/ContextViewExtension";
import { MediatorMapExtension } from "../../extensions/mediatorMap/MediatorMapExtension";
import { StageCrawlerExtension } from "../../extensions/viewManager/StageCrawlerExtension";
import { StageObserverExtension } from "../../extensions/viewManager/StageObserverExtension";
import { ViewManagerExtension } from "../../extensions/viewManager/ViewManagerExtension";
import { applyCreateJSPatch } from "./patch/createjs-patch";
/**
* For that Classic Robotlegs flavour
*
* <p>This bundle installs a number of extensions commonly used
* in typical Robotlegs applications and modules.</p>
*/
export class CreateJSBundle implements IBundle {
/*============================================================================*/
/* Private Properties */
/*============================================================================*/
private _context: IContext;
private _logger: ILogger;
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
/**
* @inheritDoc
*/
public extend(context: IContext): void {
this._context = context;
this._logger = context.getLogger(this);
this._context.install(
ContextViewExtension,
ViewManagerExtension,
StageObserverExtension,
MediatorMapExtension,
StageCrawlerExtension
);
this._context.addConfigHandler(instanceOfType(ContextView), this.handleContextView.bind(this));
this._context.whenInitializing(this.whenInitializing.bind(this));
this._context.afterDestroying(this.afterDestroying.bind(this));
}
/*============================================================================*/
/* Private Functions */
/*============================================================================*/
private handleContextView(contextView: ContextView): void {
applyCreateJSPatch(<any>contextView.view);
this._context.configure(ContextViewListenerConfig);
}
private whenInitializing(): void {
if (!this._context.injector.isBound(IContextView)) {
this._logger.error("CreateJSBundle requires IContextView.");
}
}
private afterDestroying(): void {
this._context = null;
this._logger = null;
}
}