@flashist/appframework 0.0.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.
- package/gulp/tasks/clean.js +9 -0
- package/gulp/tasks/compile.js +27 -0
- package/gulp/tasks/copy-to-dist.js +15 -0
- package/gulp/tasks/generate-definitions.js +86 -0
- package/gulpfile.js +22 -0
- package/package.json +30 -0
- package/src/app/AppModule.ts +26 -0
- package/src/app/AppSettings.ts +9 -0
- package/src/app/commands/LoadAppConfigCommand.ts +61 -0
- package/src/app/commands/ParseStaticItemsConfigCommand.ts +32 -0
- package/src/app/data/AppConfigType.ts +1 -0
- package/src/app/data/AppConfigVO.ts +27 -0
- package/src/app/data/IAppModelStorageVO.ts +4 -0
- package/src/app/data/IItemsConfigVO.ts +5 -0
- package/src/app/managers/AppManager.ts +68 -0
- package/src/app/models/AppConfigModel.ts +20 -0
- package/src/app/models/AppModel.ts +18 -0
- package/src/app/views/AppMainContainer.ts +23 -0
- package/src/assets/AssetsModule.ts +13 -0
- package/src/assets/commands/ParseAssetsConfigCommand.ts +25 -0
- package/src/assets/data/IAssetsConfigVO.ts +5 -0
- package/src/assets/models/AssetsModel.ts +7 -0
- package/src/base/BaseObjectWithGlobalDispatcher.ts +23 -0
- package/src/base/commands/BaseAppCommand.ts +22 -0
- package/src/base/data/BaseAppObjectWithStaticVO.ts +15 -0
- package/src/base/managers/BaseAppManager.ts +5 -0
- package/src/base/mediators/BaseAppMediator.ts +24 -0
- package/src/base/models/BaseAppGenericObjectsModel.ts +23 -0
- package/src/base/models/BaseAppModel.ts +5 -0
- package/src/base/modules/AppModulesManager.ts +44 -0
- package/src/base/modules/BaseAppModule.ts +17 -0
- package/src/base/views/BaseAppView.ts +25 -0
- package/src/containers/ContainersModule.ts +13 -0
- package/src/containers/managers/ContainersManager.ts +27 -0
- package/src/data/IAppGenericObjectVO.ts +5 -0
- package/src/date/DateSettings.ts +6 -0
- package/src/debug/DebugModule.ts +22 -0
- package/src/dependencies/DependenciesModule.ts +13 -0
- package/src/display/data/IGetSizable.ts +5 -0
- package/src/display/tools/GetSizeTools.ts +25 -0
- package/src/display/views/AppContainer.ts +20 -0
- package/src/display/views/button/BaseBtn.ts +325 -0
- package/src/display/views/button/BaseBtnEvent.ts +4 -0
- package/src/display/views/button/BaseBtnState.ts +31 -0
- package/src/display/views/button/BaseBtnView.ts +230 -0
- package/src/display/views/button/DefaultButtonViewConfig.ts +10 -0
- package/src/display/views/button/IButtonViewConfig.ts +16 -0
- package/src/display/views/button/ISimpleButtonConfig.ts +22 -0
- package/src/display/views/button/SimpleButtonState.ts +31 -0
- package/src/display/views/button/SimpleButtonView.ts +226 -0
- package/src/display/views/getsize/GetSizeTools.ts +32 -0
- package/src/display/views/getsize/IGetSizeObject.ts +5 -0
- package/src/display/views/layout/BaseLayout.ts +160 -0
- package/src/display/views/layout/ColumnLayout.ts +120 -0
- package/src/display/views/layout/LayoutConfig.ts +15 -0
- package/src/display/views/layout/RowLayout.ts +115 -0
- package/src/display/views/layout/container/BaseLayoutableContainer.ts +21 -0
- package/src/display/views/layout/container/ILayoutableChild.ts +3 -0
- package/src/display/views/layout/container/ILayoutableContainer.ts +18 -0
- package/src/display/views/resize/IResizable.ts +6 -0
- package/src/display/views/resize/ResizableContainer.ts +80 -0
- package/src/display/views/simplelist/ISimpleListItem.ts +5 -0
- package/src/display/views/simplelist/SimpleList.ts +318 -0
- package/src/display/views/simplelist/SimpleListEvent.ts +4 -0
- package/src/display/views/sizedistributor/ISizeDistributorChild.ts +5 -0
- package/src/display/views/sizedistributor/SizeDistributor.ts +129 -0
- package/src/display/views/sizedistributor/SizeDistributorConfig.ts +12 -0
- package/src/display/views/togglegroup/IToggableItem.ts +6 -0
- package/src/display/views/togglegroup/IToggleGroupItem.ts +6 -0
- package/src/display/views/togglegroup/ToggleGroup.ts +140 -0
- package/src/display/views/togglegroup/ToggleGroupEvent.ts +3 -0
- package/src/display/views/viewstack/IViewStackItem.ts +7 -0
- package/src/display/views/viewstack/ViewLazyCreationServiceLocatorStack.ts +19 -0
- package/src/display/views/viewstack/ViewLazyCreationStack.ts +47 -0
- package/src/display/views/viewstack/ViewStack.ts +93 -0
- package/src/display/views/viewstack/ViewStackLazyCreation.ts +45 -0
- package/src/events/commands/DispatchGlobalEventCommand.ts +22 -0
- package/src/facade/Facade.ts +194 -0
- package/src/facade/IFacadeOptions.ts +7 -0
- package/src/globaleventdispatcher/GlobalEventDispatcherModule.ts +16 -0
- package/src/globaleventdispatcher/commands/WaitGlobalEventCommand.ts +25 -0
- package/src/globaleventdispatcher/dispatcher/GlobalEventDispatcher.ts +53 -0
- package/src/globaleventdispatcher/dispatcher/GlobalEventDispatcherEvent.ts +4 -0
- package/src/globaleventdispatcher/dispatcher/IGlobalDispatchEventVO.ts +4 -0
- package/src/globaleventdispatcher/managers/GlobalEventsCommandManager.ts +26 -0
- package/src/hints/commands/AnimateHintCommand.ts +99 -0
- package/src/hints/data/DefaultHintConfig.ts +22 -0
- package/src/hints/data/HintContainerId.ts +1 -0
- package/src/hints/data/IHintConfig.ts +20 -0
- package/src/html/HTMLModule.ts +13 -0
- package/src/html/managers/HTMLManager.ts +32 -0
- package/src/index.ts +21 -0
- package/src/init/commands/InitApplicationCommand.ts +34 -0
- package/src/init/commands/InitApplicationDataCommand.ts +19 -0
- package/src/init/commands/InitApplicationDataEvent.ts +3 -0
- package/src/load/LoadGroupName.ts +5 -0
- package/src/load/LoadModule.ts +23 -0
- package/src/load/LoaderId.ts +5 -0
- package/src/locales/LocalesModule.ts +11 -0
- package/src/locales/commands/ParseLocaleConfigCommand.ts +28 -0
- package/src/package.json +36 -0
- package/src/pages/PageId.ts +4 -0
- package/src/pages/PagesModule.ts +13 -0
- package/src/pages/commands/ChangePageCommand.ts +18 -0
- package/src/pages/models/PagesModel.ts +38 -0
- package/src/pages/models/PagesModelEvent.ts +3 -0
- package/src/pages/views/BasePageView.ts +75 -0
- package/src/pages/views/PagesView.ts +57 -0
- package/src/pool/ObjectsPoolModule.ts +13 -0
- package/src/renderer/RendererModule.ts +14 -0
- package/src/renderer/events/RendererManagerEvent.ts +3 -0
- package/src/renderer/managers/RendererManager.ts +52 -0
- package/src/server/ServerModule.ts +14 -0
- package/src/server/commands/BaseServerCommand.ts +39 -0
- package/src/server/data/IServerRequestVO.ts +12 -0
- package/src/server/data/IServerResponseVO.ts +15 -0
- package/src/server/data/ServerErrorCode.ts +3 -0
- package/src/server/models/ServerModel.ts +34 -0
- package/src/sounds/SoundsModule.ts +24 -0
- package/src/sounds/SoundsSettings.ts +5 -0
- package/src/sounds/managers/BackgroundMusicManager.ts +48 -0
- package/src/sounds/managers/SoundsStorageManager.ts +45 -0
- package/src/storage/StorageModule.ts +13 -0
- package/src/storage/StorageModuleConfig.ts +3 -0
- package/src/storage/managers/StorageManager.ts +159 -0
- package/src/strategy/managers/BaseStrategyManager.ts +37 -0
- package/src/strategy/models/BaseStrategyModel.ts +40 -0
- package/src/strategy/strategies/BaseStrategy.ts +21 -0
- package/src/time/TimeModule.ts +16 -0
- package/src/time/managers/TimeManager.ts +29 -0
- package/src/time/models/TimeModel.ts +29 -0
- package/src/time/models/TimeModelEvent.ts +3 -0
- package/src/windows/data/IWindowConfigVO.ts +9 -0
- package/src/windows/managers/IShowWindowVO.ts +4 -0
- package/src/windows/managers/WindowsManager.ts +72 -0
- package/src/windows/views/BaseWindow.ts +22 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var gulp = require("gulp");
|
|
2
|
+
var shell = require('gulp-shell');
|
|
3
|
+
|
|
4
|
+
gulp.task(
|
|
5
|
+
"compile",
|
|
6
|
+
function (cb) {
|
|
7
|
+
|
|
8
|
+
gulp.src(".", {read: false})
|
|
9
|
+
.pipe(
|
|
10
|
+
shell(
|
|
11
|
+
["tsc"]
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
).on(
|
|
15
|
+
"end",
|
|
16
|
+
function () {
|
|
17
|
+
cb();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
).on(
|
|
21
|
+
"error",
|
|
22
|
+
function () {
|
|
23
|
+
console.error("ERROR! compile.js");
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var gulp = require("gulp");
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
var path = require("path");
|
|
4
|
+
var glob = require("glob");
|
|
5
|
+
|
|
6
|
+
gulp.task(
|
|
7
|
+
"generate-definitions",
|
|
8
|
+
async () => {
|
|
9
|
+
|
|
10
|
+
await new Promise(
|
|
11
|
+
(resolve) => {
|
|
12
|
+
|
|
13
|
+
// console.log("START! generate-definitions.js");
|
|
14
|
+
|
|
15
|
+
var getSafeDirPath = function(dirPath) {
|
|
16
|
+
dirPath += dirPath.charAt(dirPath.length - 1) == "/" ? "" : "/";
|
|
17
|
+
return dirPath;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var argv = {};
|
|
21
|
+
|
|
22
|
+
var basePath = "./src/";
|
|
23
|
+
// console.log("BEFORE argv.src: " + argv.src);
|
|
24
|
+
argv.src = argv.src ? argv.src : basePath;
|
|
25
|
+
// Adding a closing slash to make correct folder path (if needed)
|
|
26
|
+
argv.src = getSafeDirPath(argv.src);
|
|
27
|
+
// console.log("AFTER argv.src: " + argv.src);
|
|
28
|
+
|
|
29
|
+
// console.log("BEFORE argv.outFile: " + argv.outFile);
|
|
30
|
+
argv.outFile = argv.outFile ? argv.outFile : "index";
|
|
31
|
+
// console.log("AFTER argv.outFile: " + argv.outFile);
|
|
32
|
+
|
|
33
|
+
// console.log("BEFORE argv.outDir: " + argv.outDir);
|
|
34
|
+
argv.outDir = argv.outDir ? argv.outDir : basePath;
|
|
35
|
+
argv.outDir = getSafeDirPath(argv.outDir);
|
|
36
|
+
// console.log("AFTER argv.outDir: " + argv.outDir);
|
|
37
|
+
|
|
38
|
+
var outFileName = argv.outFile + ".ts";
|
|
39
|
+
// console.log("outFileName: " + outFileName);
|
|
40
|
+
// Remove prev index file
|
|
41
|
+
if (fs.existsSync(basePath + outFileName)) {
|
|
42
|
+
fs.unlinkSync(basePath + outFileName);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var resultDeclarationText = "";
|
|
46
|
+
|
|
47
|
+
// console.log("Imported files:");
|
|
48
|
+
var tempSettings = `${argv.src}**/*.ts`;
|
|
49
|
+
|
|
50
|
+
glob(
|
|
51
|
+
tempSettings,
|
|
52
|
+
(error, files) => {
|
|
53
|
+
var filesCount = files.length;
|
|
54
|
+
for (var fileIndex = 0; fileIndex < filesCount; fileIndex++) {
|
|
55
|
+
var singleFile = files[fileIndex];
|
|
56
|
+
console.log("singleFile: ", singleFile);
|
|
57
|
+
|
|
58
|
+
let importPath = path.relative(basePath, singleFile);
|
|
59
|
+
if (importPath.indexOf(".d.ts") != -1) {
|
|
60
|
+
importPath = importPath.substr(0, importPath.lastIndexOf(".d.ts"));
|
|
61
|
+
} else if (importPath.indexOf(".ts") != -1) {
|
|
62
|
+
importPath = importPath.substr(0, importPath.lastIndexOf(".ts"));
|
|
63
|
+
}
|
|
64
|
+
// console.log("- " + importPath);
|
|
65
|
+
|
|
66
|
+
resultDeclarationText += "export * from '" + "./" + importPath + "'";
|
|
67
|
+
resultDeclarationText += "\n";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log("Declarations: ");
|
|
71
|
+
console.log(resultDeclarationText);
|
|
72
|
+
|
|
73
|
+
fs.writeFile(
|
|
74
|
+
argv.outDir + outFileName,
|
|
75
|
+
resultDeclarationText,
|
|
76
|
+
() => {
|
|
77
|
+
console.log("WRITE COMPLETE!");
|
|
78
|
+
resolve();
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
package/gulpfile.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var gulp = require("gulp");
|
|
2
|
+
var requireDir = require("require-dir");
|
|
3
|
+
|
|
4
|
+
var tasks = requireDir("./gulp/tasks");
|
|
5
|
+
|
|
6
|
+
gulp.task(
|
|
7
|
+
'build',
|
|
8
|
+
gulp.series(
|
|
9
|
+
"clean",
|
|
10
|
+
// "generate-definitions",
|
|
11
|
+
"copy-to-dist",
|
|
12
|
+
"compile"
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// Default
|
|
17
|
+
gulp.task(
|
|
18
|
+
"default",
|
|
19
|
+
gulp.series(
|
|
20
|
+
"build"
|
|
21
|
+
)
|
|
22
|
+
);
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flashist/appframework",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "gulp",
|
|
6
|
+
"publish:patch": "npm version patch && npm run build && cd ./dist && npm publish",
|
|
7
|
+
"publish:minor": "npm version minor && npm run build && cd ./dist && npm publish",
|
|
8
|
+
"publish:major": "npm version major && npm run build && cd ./dist && npm publish"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"private": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/flashist/appframework"
|
|
15
|
+
},
|
|
16
|
+
"main": "index.js",
|
|
17
|
+
"typings": "index.d.ts",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@flashist/flibs": "0.x",
|
|
20
|
+
"@flashist/fconsole": "0.x"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/webfontloader": "^1.6.29",
|
|
24
|
+
"gulp": "^4.0.2",
|
|
25
|
+
"gulp-shell": "^0.8.0",
|
|
26
|
+
"require-dir": "^1.2.0",
|
|
27
|
+
"rimraf": "^3.0.2",
|
|
28
|
+
"typescript": "^4.0.2"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {GenericObjectsByTypeModel, getInstance, serviceLocatorAdd} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
import {BaseAppModule} from "../base/modules/BaseAppModule";
|
|
4
|
+
import {AppModel} from "./models/AppModel";
|
|
5
|
+
import {AppConfigModel} from "./models/AppConfigModel";
|
|
6
|
+
import {AppManager} from "./managers/AppManager";
|
|
7
|
+
|
|
8
|
+
export class AppModule extends BaseAppModule {
|
|
9
|
+
|
|
10
|
+
init(): void {
|
|
11
|
+
super.init();
|
|
12
|
+
|
|
13
|
+
serviceLocatorAdd(AppModel, {isSingleton: true});
|
|
14
|
+
serviceLocatorAdd(AppConfigModel, {isSingleton: true});
|
|
15
|
+
|
|
16
|
+
serviceLocatorAdd(AppManager, {isSingleton: true, forceCreation: true});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
activateCompleteHook(): void {
|
|
20
|
+
super.activateCompleteHook();
|
|
21
|
+
|
|
22
|
+
const genericObjectsByTypeModel: GenericObjectsByTypeModel = getInstance(GenericObjectsByTypeModel);
|
|
23
|
+
const model: AppConfigModel = getInstance(AppConfigModel);
|
|
24
|
+
genericObjectsByTypeModel.mapModelToType(model, model.itemsType);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {CommandErrorCode} from "@flashist/fcore";
|
|
2
|
+
import {
|
|
3
|
+
GenericObjectsByTypeModel,
|
|
4
|
+
getInstance,
|
|
5
|
+
LoadItemCommand,
|
|
6
|
+
LoadItemsListCommand,
|
|
7
|
+
LoadManager
|
|
8
|
+
} from "@flashist/flibs";
|
|
9
|
+
|
|
10
|
+
import {AppConfigModel} from "../models/AppConfigModel";
|
|
11
|
+
import {BaseAppCommand} from "../../base/commands/BaseAppCommand";
|
|
12
|
+
import {AppSettings} from "../AppSettings";
|
|
13
|
+
import {AppConfigVO} from "../data/AppConfigVO";
|
|
14
|
+
|
|
15
|
+
export class LoadAppConfigCommand extends BaseAppCommand {
|
|
16
|
+
BasePageView
|
|
17
|
+
protected executeInternal(): void {
|
|
18
|
+
const appConfigModel: AppConfigModel = getInstance(AppConfigModel);
|
|
19
|
+
new LoadItemCommand(
|
|
20
|
+
{
|
|
21
|
+
src: AppSettings.appConfigPath,
|
|
22
|
+
id: AppSettings.appConfigPath
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
.execute()
|
|
26
|
+
.then(
|
|
27
|
+
(data: AppConfigVO) => {
|
|
28
|
+
console.log("LoadAppConfigCommand | executeInternal __ data: ", data);
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
const genericObjectsByTypeModel: GenericObjectsByTypeModel = getInstance(GenericObjectsByTypeModel);
|
|
32
|
+
genericObjectsByTypeModel.commitItems([data]);
|
|
33
|
+
|
|
34
|
+
//
|
|
35
|
+
const loadManager: LoadManager = getInstance(LoadManager);
|
|
36
|
+
loadManager.addSubstituteParams(
|
|
37
|
+
{
|
|
38
|
+
locale: appConfigModel.appConfig.locale
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
//
|
|
43
|
+
if (data.files) {
|
|
44
|
+
new LoadItemsListCommand(appConfigModel.appConfig.files)
|
|
45
|
+
.execute();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.notifyComplete();
|
|
49
|
+
},
|
|
50
|
+
() => {
|
|
51
|
+
const errorText: string = "LoadAppConfigCommand | executeInternal __ ERROR! Can't load the app-config.json file!";
|
|
52
|
+
console.error(errorText);
|
|
53
|
+
alert(errorText);
|
|
54
|
+
|
|
55
|
+
this.errorCode = CommandErrorCode.GENERAL_ERROR;
|
|
56
|
+
this.terminate();
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {CommandErrorCode} from "@flashist/fcore";
|
|
2
|
+
import {AbstractLoadItem, GenericObjectsByTypeModel, getInstance, LoadManager} from "@flashist/flibs";
|
|
3
|
+
|
|
4
|
+
import {BaseAppCommand} from "../../base/commands/BaseAppCommand";
|
|
5
|
+
import {AppSettings} from "../AppSettings";
|
|
6
|
+
import {IItemsConfigVO} from "../data/IItemsConfigVO";
|
|
7
|
+
|
|
8
|
+
export class ParseStaticItemsConfigCommand extends BaseAppCommand {
|
|
9
|
+
|
|
10
|
+
protected executeInternal(): void {
|
|
11
|
+
|
|
12
|
+
let loadManager: LoadManager = getInstance(LoadManager);
|
|
13
|
+
let staticItemsConfigFileItem: AbstractLoadItem = loadManager.getLoadItem(AppSettings.staticItemsFileId);
|
|
14
|
+
if (staticItemsConfigFileItem && staticItemsConfigFileItem.data) {
|
|
15
|
+
const staticData: IItemsConfigVO = staticItemsConfigFileItem.data;
|
|
16
|
+
|
|
17
|
+
let genericObjectsByTypeModel: GenericObjectsByTypeModel = getInstance(GenericObjectsByTypeModel);
|
|
18
|
+
if (staticData.items) {
|
|
19
|
+
genericObjectsByTypeModel.commitItems(staticData.items);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.notifyComplete();
|
|
23
|
+
|
|
24
|
+
} else {
|
|
25
|
+
console.error("ParseStaticItemsCommand | executeInternal __ ERROR! Can't find config file!");
|
|
26
|
+
this.errorCode = CommandErrorCode.GENERAL_ERROR;
|
|
27
|
+
this.terminate();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AppConfigType: string = "appConfig";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {BaseDataVO, ILoadItemConfig, Rectangle} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
export class AppConfigVO extends BaseDataVO {
|
|
4
|
+
|
|
5
|
+
files?: ILoadItemConfig[];
|
|
6
|
+
|
|
7
|
+
locale?: string;
|
|
8
|
+
|
|
9
|
+
targetFps?: number;
|
|
10
|
+
sizeArea?: Partial<Rectangle>;
|
|
11
|
+
|
|
12
|
+
// Param for app-specific settings (type can be specified in app-level classes)
|
|
13
|
+
appSettings?: any;
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
this.explicitSourcePropertyNames.push(
|
|
19
|
+
"files",
|
|
20
|
+
"locale",
|
|
21
|
+
"targetFps",
|
|
22
|
+
"sizeArea",
|
|
23
|
+
"appSettings"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {getInstance} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
import {BaseAppManager} from "../../base/managers/BaseAppManager";
|
|
4
|
+
import {AppModel} from "../models/AppModel";
|
|
5
|
+
import {StorageManager} from "../../storage/managers/StorageManager";
|
|
6
|
+
import {AppSettings} from "../AppSettings";
|
|
7
|
+
import {IAppModelStorageVO} from "../data/IAppModelStorageVO";
|
|
8
|
+
|
|
9
|
+
export class AppManager extends BaseAppManager {
|
|
10
|
+
|
|
11
|
+
protected appModel: AppModel;
|
|
12
|
+
protected storageManager: StorageManager;
|
|
13
|
+
|
|
14
|
+
protected updateTimeInterval: any;
|
|
15
|
+
|
|
16
|
+
protected construction(...args): void {
|
|
17
|
+
super.construction(args);
|
|
18
|
+
|
|
19
|
+
this.appModel = getInstance(AppModel);
|
|
20
|
+
this.storageManager = getInstance(StorageManager);
|
|
21
|
+
|
|
22
|
+
const appModelStorageData: IAppModelStorageVO = this.storageManager.getParam<IAppModelStorageVO>(AppSettings.storageParamId);
|
|
23
|
+
this.applyStorageData(appModelStorageData);
|
|
24
|
+
|
|
25
|
+
this.appModel.previousSessionTotalUsageTime = this.appModel.totalUsageDuration;
|
|
26
|
+
this.appModel.sessionStartTime = Date.now();
|
|
27
|
+
|
|
28
|
+
// Increase app launch counter
|
|
29
|
+
this.appModel.appLaunchesCount++;
|
|
30
|
+
|
|
31
|
+
this.updateStorageData();
|
|
32
|
+
this.updateTimeInterval = setInterval(
|
|
33
|
+
() => {
|
|
34
|
+
this.updateUsageTime();
|
|
35
|
+
},
|
|
36
|
+
// 1 min
|
|
37
|
+
1000 * 60
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected updateUsageTime(): void {
|
|
42
|
+
let sessionTimeDelta: number = Date.now() - this.appModel.sessionStartTime;
|
|
43
|
+
this.appModel.totalUsageDuration = this.appModel.previousSessionTotalUsageTime + sessionTimeDelta;
|
|
44
|
+
|
|
45
|
+
this.updateStorageData();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected applyStorageData(data: IAppModelStorageVO): void {
|
|
49
|
+
if (!data) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.appModel.appLaunchesCount = data.appLaunchesCount;
|
|
54
|
+
this.appModel.totalUsageDuration = data.totalUsageTime;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected updateStorageData(): void {
|
|
58
|
+
const storageData: IAppModelStorageVO = this.generateStorageData();
|
|
59
|
+
this.storageManager.setParam<IAppModelStorageVO>(AppSettings.storageParamId, storageData);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected generateStorageData(): IAppModelStorageVO {
|
|
63
|
+
return {
|
|
64
|
+
appLaunchesCount: this.appModel.appLaunchesCount,
|
|
65
|
+
totalUsageTime: this.appModel.totalUsageDuration
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {GenericObjectsModel} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
import {AppConfigVO} from "../data/AppConfigVO";
|
|
4
|
+
import {AppConfigType} from "../data/AppConfigType";
|
|
5
|
+
|
|
6
|
+
export class AppConfigModel<ConfigDataType extends AppConfigVO = AppConfigVO>
|
|
7
|
+
extends GenericObjectsModel<ConfigDataType> {
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this.itemsType = AppConfigType;
|
|
13
|
+
this.DefaultItemClass = (AppConfigVO as any);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public get appConfig(): ConfigDataType {
|
|
17
|
+
return this.items.getItemByIndex(0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {BaseAppGenericObjectsModel} from "../../base/models/BaseAppGenericObjectsModel";
|
|
2
|
+
|
|
3
|
+
export class AppModel extends BaseAppGenericObjectsModel {
|
|
4
|
+
|
|
5
|
+
public appLaunchesCount: number;
|
|
6
|
+
public totalUsageDuration: number;
|
|
7
|
+
|
|
8
|
+
public sessionStartTime: number;
|
|
9
|
+
public previousSessionTotalUsageTime: number;
|
|
10
|
+
|
|
11
|
+
protected construction(...args): void {
|
|
12
|
+
super.construction(args);
|
|
13
|
+
|
|
14
|
+
this.appLaunchesCount = 0;
|
|
15
|
+
this.totalUsageDuration = 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {PagesView} from "../../pages/views/PagesView";
|
|
2
|
+
import {ResizableContainer} from "../../display/views/resize/ResizableContainer";
|
|
3
|
+
|
|
4
|
+
export class AppMainContainer extends ResizableContainer {
|
|
5
|
+
|
|
6
|
+
protected pagesView: PagesView;
|
|
7
|
+
|
|
8
|
+
protected construction(...args): void {
|
|
9
|
+
super.construction(...args);
|
|
10
|
+
|
|
11
|
+
this.pagesView = new PagesView();
|
|
12
|
+
this.addChild(this.pagesView);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected arrange(): void {
|
|
16
|
+
super.arrange();
|
|
17
|
+
|
|
18
|
+
this.pagesView.resize(
|
|
19
|
+
this.resizeSize.x,
|
|
20
|
+
this.resizeSize.y
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {serviceLocatorAdd} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
import {BaseAppModule} from "../base/modules/BaseAppModule";
|
|
4
|
+
import {AssetsModel} from "./models/AssetsModel";
|
|
5
|
+
|
|
6
|
+
export class AssetsModule extends BaseAppModule {
|
|
7
|
+
|
|
8
|
+
init(): void {
|
|
9
|
+
super.init();
|
|
10
|
+
|
|
11
|
+
serviceLocatorAdd(AssetsModel, {isSingleton: true});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {AbstractLoadItem, getInstance, LoadItemsListCommand, LoadManager} from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
import {BaseAppCommand} from "../../base/commands/BaseAppCommand";
|
|
4
|
+
import {AppSettings} from "../../app/AppSettings";
|
|
5
|
+
|
|
6
|
+
export class ParseAssetsConfigCommand extends BaseAppCommand {
|
|
7
|
+
|
|
8
|
+
protected executeInternal(): void {
|
|
9
|
+
let loadManager: LoadManager = getInstance(LoadManager);
|
|
10
|
+
let assetsConfigFileLoadItem: AbstractLoadItem = loadManager.getLoadItem(AppSettings.assetsConfigFileId);
|
|
11
|
+
|
|
12
|
+
if (assetsConfigFileLoadItem && assetsConfigFileLoadItem.data) {
|
|
13
|
+
if (assetsConfigFileLoadItem.data.files) {
|
|
14
|
+
new LoadItemsListCommand(assetsConfigFileLoadItem.data.files)
|
|
15
|
+
.execute();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
this.notifyComplete();
|
|
19
|
+
|
|
20
|
+
} else {
|
|
21
|
+
console.error("ParseAssetsConfigCommand | executeInternal __ ERROR! Can't find config file!");
|
|
22
|
+
this.terminate();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {BaseObject} from "@flashist/fcore";
|
|
2
|
+
import {getInstance} from "@flashist/flibs";
|
|
3
|
+
|
|
4
|
+
import {GlobalEventDispatcher} from "../globaleventdispatcher/dispatcher/GlobalEventDispatcher";
|
|
5
|
+
|
|
6
|
+
export class BaseObjectWithGlobalDispatcher extends BaseObject {
|
|
7
|
+
|
|
8
|
+
protected globalDispatcher: GlobalEventDispatcher;
|
|
9
|
+
|
|
10
|
+
protected construction(...args): void {
|
|
11
|
+
super.construction(...args);
|
|
12
|
+
|
|
13
|
+
this.globalDispatcher = getInstance(GlobalEventDispatcher);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
dispatchEvent(event: string, ...args: any[]): void {
|
|
17
|
+
super.dispatchEvent(event, ...args);
|
|
18
|
+
|
|
19
|
+
// Redispatch event to the global level
|
|
20
|
+
this.globalDispatcher.dispatchEvent(event, ...args);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Command} from "@flashist/fcore";
|
|
2
|
+
import {GlobalEventDispatcher} from "../../globaleventdispatcher/dispatcher/GlobalEventDispatcher";
|
|
3
|
+
import {getInstance} from "@flashist/flibs";
|
|
4
|
+
|
|
5
|
+
export abstract class BaseAppCommand<ResolveType = any> extends Command<ResolveType> {
|
|
6
|
+
|
|
7
|
+
protected globalDispatcher: GlobalEventDispatcher;
|
|
8
|
+
|
|
9
|
+
protected construction(...args): void {
|
|
10
|
+
super.construction(...args);
|
|
11
|
+
|
|
12
|
+
this.globalDispatcher = getInstance(GlobalEventDispatcher);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
dispatchEvent(event: string, ...args: any[]): void {
|
|
16
|
+
super.dispatchEvent(event, ...args);
|
|
17
|
+
|
|
18
|
+
// Redispatch event to the global level
|
|
19
|
+
this.globalDispatcher.dispatchEvent(event, ...args);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseDataVO, GenericObjectsWithStaticTools, IGenericObjectVO, IGenericObjectWithStaticVO } from "@flashist/flibs";
|
|
2
|
+
|
|
3
|
+
export class BaseAppObjectWithStaticVO<StaticDataType extends IGenericObjectVO = IGenericObjectVO>
|
|
4
|
+
extends BaseDataVO
|
|
5
|
+
implements IGenericObjectWithStaticVO<StaticDataType> {
|
|
6
|
+
|
|
7
|
+
staticId: string;
|
|
8
|
+
staticType: string;
|
|
9
|
+
|
|
10
|
+
staticData?: StaticDataType;
|
|
11
|
+
|
|
12
|
+
// get staticData(): StaticDataType {
|
|
13
|
+
// return GenericObjectsWithStaticTools.getStaticObject<StaticDataType>(this);
|
|
14
|
+
// }
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IDefaultEventDispatcher, IEventListenerCallback } from "@flashist/fcore";
|
|
2
|
+
import { IActivatee } from "@flashist/flibs";
|
|
3
|
+
|
|
4
|
+
import { BaseObjectWithGlobalDispatcher } from "../BaseObjectWithGlobalDispatcher";
|
|
5
|
+
|
|
6
|
+
export class BaseAppMediator<ActivatorType extends IDefaultEventDispatcher<any> = IDefaultEventDispatcher<any>> extends BaseObjectWithGlobalDispatcher implements IActivatee {
|
|
7
|
+
protected activator: ActivatorType;
|
|
8
|
+
|
|
9
|
+
onActivatorStart(activator: ActivatorType): void {
|
|
10
|
+
this.activator = activator;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
onActivatorEnd(): void {
|
|
14
|
+
this.destruction();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public addActivatorListener(type: string, listener: IEventListenerCallback): void {
|
|
18
|
+
this.eventListenerHelper.addEventListener(
|
|
19
|
+
this.activator,
|
|
20
|
+
type,
|
|
21
|
+
listener
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|