@zenflux/core 0.0.0-abc.6 → 0.0.0-abc.8
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/cjs/zenflux-core.js +60 -44
- package/dist/es/src/globals.d.ts +15 -0
- package/dist/es/src/index.d.ts +1 -0
- package/dist/es/src/initializer.d.ts +6 -4
- package/dist/es/src/managers/index.d.ts +7 -4
- package/dist/es/zenflux-core.js +56 -40
- package/dist/es/zenflux-core.mjs +3 -3
- package/dist/umd/zenflux-core.js +3 -3
- package/package.json +3 -2
- package/src/command-bases/command-data.ts +2 -4
- package/src/core/controller.ts +3 -5
- package/src/exports.ts +0 -1
- package/src/globals.ts +22 -0
- package/src/index.ts +2 -1
- package/src/initializer.ts +8 -13
- package/src/managers/index.ts +33 -4
- package/types/index.d.ts +4 -1
package/dist/cjs/zenflux-core.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
globalThis.__ZEN_MANAGERS__ = {};
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
class ForceMethodBase extends Error {
|
|
6
11
|
constructor(className, methodName) {
|
|
7
12
|
super(`ForeMethod implementation: at '${className}' method: '${methodName}'`);
|
|
@@ -445,19 +450,6 @@ class CommandPublic extends CommandBase {
|
|
|
445
450
|
}
|
|
446
451
|
}
|
|
447
452
|
|
|
448
|
-
let commands = {};
|
|
449
|
-
let controllers = {};
|
|
450
|
-
let data = {};
|
|
451
|
-
let internal = {};
|
|
452
|
-
|
|
453
|
-
var index$5 = /*#__PURE__*/Object.freeze({
|
|
454
|
-
__proto__: null,
|
|
455
|
-
commands: commands,
|
|
456
|
-
controllers: controllers,
|
|
457
|
-
data: data,
|
|
458
|
-
internal: internal
|
|
459
|
-
});
|
|
460
|
-
|
|
461
453
|
/**
|
|
462
454
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
463
455
|
* @description: Each data command should represent a final REST endpoint.
|
|
@@ -480,7 +472,7 @@ class CommandData extends CommandBase {
|
|
|
480
472
|
}
|
|
481
473
|
apply(args = this.args, options = this.options) {
|
|
482
474
|
const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
483
|
-
return data.getClient().fetch(endpoint, data.currentHttpMethod, args || null);
|
|
475
|
+
return __ZEN_MANAGERS__.data.getClient().fetch(endpoint, __ZEN_MANAGERS__.data.currentHttpMethod, args || null);
|
|
484
476
|
}
|
|
485
477
|
applyEndpointFormat(endpoint, data = {}) {
|
|
486
478
|
// Replace query with `magic` placeholders.
|
|
@@ -511,7 +503,7 @@ class CommandInternal extends CommandBase {
|
|
|
511
503
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
512
504
|
*/
|
|
513
505
|
|
|
514
|
-
var index$
|
|
506
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
515
507
|
__proto__: null,
|
|
516
508
|
CommandBase: CommandBase,
|
|
517
509
|
CommandData: CommandData,
|
|
@@ -539,9 +531,9 @@ class Controller extends ObjectBase {
|
|
|
539
531
|
this.setupHooks && this.setupHooks();
|
|
540
532
|
}
|
|
541
533
|
register() {
|
|
542
|
-
this.commands = commands.register(this.getCommands(), this);
|
|
543
|
-
this.data = data.register(this.getData(), this);
|
|
544
|
-
this.internal = internal.register(this.getInternal(), this);
|
|
534
|
+
this.commands = __ZEN_MANAGERS__.commands.register(this.getCommands(), this);
|
|
535
|
+
this.data = __ZEN_MANAGERS__.data.register(this.getData(), this);
|
|
536
|
+
this.internal = __ZEN_MANAGERS__.internal.register(this.getInternal(), this);
|
|
545
537
|
}
|
|
546
538
|
getCommands() {
|
|
547
539
|
return {};
|
|
@@ -554,7 +546,7 @@ class Controller extends ObjectBase {
|
|
|
554
546
|
}
|
|
555
547
|
}
|
|
556
548
|
|
|
557
|
-
var index$
|
|
549
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
558
550
|
__proto__: null,
|
|
559
551
|
Controller: Controller,
|
|
560
552
|
ObjectBase: ObjectBase
|
|
@@ -581,7 +573,7 @@ class ControllerAlreadyRegistered extends Error {
|
|
|
581
573
|
}
|
|
582
574
|
}
|
|
583
575
|
|
|
584
|
-
var index$
|
|
576
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
585
577
|
__proto__: null,
|
|
586
578
|
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
587
579
|
CommandNotFound: CommandNotFound,
|
|
@@ -589,7 +581,7 @@ ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
|
589
581
|
ForceMethod: ForceMethod
|
|
590
582
|
});
|
|
591
583
|
|
|
592
|
-
var index$
|
|
584
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
593
585
|
__proto__: null,
|
|
594
586
|
Logger: Logger
|
|
595
587
|
});
|
|
@@ -956,6 +948,36 @@ class Internal extends Commands {
|
|
|
956
948
|
}
|
|
957
949
|
}
|
|
958
950
|
|
|
951
|
+
/**
|
|
952
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
953
|
+
*/
|
|
954
|
+
function initialize(config) {
|
|
955
|
+
__ZEN_MANAGERS__.commands = new Commands();
|
|
956
|
+
__ZEN_MANAGERS__.controllers = new Controllers();
|
|
957
|
+
__ZEN_MANAGERS__.data = new Data(config);
|
|
958
|
+
__ZEN_MANAGERS__.internal = new Internal();
|
|
959
|
+
}
|
|
960
|
+
function destroy() {
|
|
961
|
+
__ZEN_MANAGERS__.commands = {};
|
|
962
|
+
__ZEN_MANAGERS__.controllers = {};
|
|
963
|
+
__ZEN_MANAGERS__.data = {};
|
|
964
|
+
__ZEN_MANAGERS__.internal = {};
|
|
965
|
+
}
|
|
966
|
+
const controllers = __ZEN_MANAGERS__.controllers;
|
|
967
|
+
const commands = __ZEN_MANAGERS__.commands;
|
|
968
|
+
const data = __ZEN_MANAGERS__.data;
|
|
969
|
+
const internal = __ZEN_MANAGERS__.internal;
|
|
970
|
+
|
|
971
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
972
|
+
__proto__: null,
|
|
973
|
+
commands: commands,
|
|
974
|
+
controllers: controllers,
|
|
975
|
+
data: data,
|
|
976
|
+
destroy: destroy,
|
|
977
|
+
initialize: initialize,
|
|
978
|
+
internal: internal
|
|
979
|
+
});
|
|
980
|
+
|
|
959
981
|
/**
|
|
960
982
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
961
983
|
*/
|
|
@@ -974,22 +996,23 @@ Internal: Internal
|
|
|
974
996
|
|
|
975
997
|
var exported = /*#__PURE__*/Object.freeze({
|
|
976
998
|
__proto__: null,
|
|
977
|
-
commandBases: index$
|
|
978
|
-
core: index$
|
|
979
|
-
errors: index$
|
|
999
|
+
commandBases: index$5,
|
|
1000
|
+
core: index$4,
|
|
1001
|
+
errors: index$3,
|
|
980
1002
|
managerBases: index,
|
|
981
|
-
managers: index$
|
|
982
|
-
modules: index$
|
|
1003
|
+
managers: index$1,
|
|
1004
|
+
modules: index$2,
|
|
983
1005
|
utils: index$6
|
|
984
1006
|
});
|
|
985
1007
|
|
|
986
1008
|
var name = "@zenflux/core";
|
|
987
|
-
var version = "0.0.0-abc.
|
|
1009
|
+
var version = "0.0.0-abc.7";
|
|
988
1010
|
var description = "ZenFlux core";
|
|
989
1011
|
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
990
1012
|
var scripts = {
|
|
991
1013
|
test: "export flow_modules_logger=off && jest",
|
|
992
|
-
build: "rollup --config rollup.config.ts --configPlugin typescript"
|
|
1014
|
+
build: "rollup --config rollup.config.ts --configPlugin typescript",
|
|
1015
|
+
watch: "rollup --config rollup.config.ts --configPlugin typescript --watch"
|
|
993
1016
|
};
|
|
994
1017
|
var repository = {
|
|
995
1018
|
type: "git",
|
|
@@ -1069,36 +1092,29 @@ const CoreAPI = {
|
|
|
1069
1092
|
initialize: configuration => {
|
|
1070
1093
|
errorInitTwice();
|
|
1071
1094
|
config = configuration || config;
|
|
1072
|
-
|
|
1073
|
-
managers.commands = new Commands();
|
|
1074
|
-
managers.controllers = new Controllers();
|
|
1075
|
-
managers.data = new Data(config);
|
|
1076
|
-
managers.internal = new Internal();
|
|
1095
|
+
initialize(config);
|
|
1077
1096
|
isInitialized = true;
|
|
1078
1097
|
afterInitializeCallbacks.forEach(callback => callback());
|
|
1079
1098
|
},
|
|
1080
1099
|
destroy: () => {
|
|
1100
|
+
destroy();
|
|
1081
1101
|
isInitialized = false;
|
|
1082
|
-
const managers = index$5;
|
|
1083
|
-
managers.commands = {};
|
|
1084
|
-
managers.controllers = {};
|
|
1085
|
-
managers.data = {};
|
|
1086
|
-
managers.internal = {};
|
|
1087
1102
|
},
|
|
1088
1103
|
onAfterInitialize: callback => {
|
|
1089
1104
|
afterInitializeCallbacks.push(callback);
|
|
1090
1105
|
},
|
|
1091
1106
|
config,
|
|
1092
|
-
...exported
|
|
1107
|
+
...exported,
|
|
1108
|
+
managers: typeof __ZEN_MANAGERS__ !== 'undefined' ? __ZEN_MANAGERS__ : undefined
|
|
1093
1109
|
};
|
|
1094
1110
|
// TODO: Make it available only for development.
|
|
1095
1111
|
if (!globalThis?.ZenCore) globalThis.ZenCore = CoreAPI;
|
|
1096
1112
|
|
|
1097
|
-
exports.commandBases = index$
|
|
1098
|
-
exports.core = index$
|
|
1113
|
+
exports.commandBases = index$5;
|
|
1114
|
+
exports.core = index$4;
|
|
1099
1115
|
exports.default = CoreAPI;
|
|
1100
|
-
exports.errors = index$
|
|
1116
|
+
exports.errors = index$3;
|
|
1101
1117
|
exports.managerBases = index;
|
|
1102
|
-
exports.managers = index$
|
|
1103
|
-
exports.modules = index$
|
|
1118
|
+
exports.managers = index$1;
|
|
1119
|
+
exports.modules = index$2;
|
|
1104
1120
|
exports.utils = index$6;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Commands from "./manager-bases/commands";
|
|
2
|
+
import Controllers from "./manager-bases/controllers";
|
|
3
|
+
import Data from "./manager-bases/data";
|
|
4
|
+
import Internal from "./manager-bases/internal";
|
|
5
|
+
declare global {
|
|
6
|
+
var ZenCore: any;
|
|
7
|
+
}
|
|
8
|
+
declare global {
|
|
9
|
+
var __ZEN_MANAGERS__: {
|
|
10
|
+
commands: Commands;
|
|
11
|
+
controllers: Controllers;
|
|
12
|
+
data: Data;
|
|
13
|
+
internal: Internal;
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist/es/src/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as exported from './exports';
|
|
2
2
|
import { IAPIConfig } from "./interfaces/config";
|
|
3
|
-
declare global {
|
|
4
|
-
var ZenCore: any;
|
|
5
|
-
}
|
|
6
3
|
export declare let config: IAPIConfig;
|
|
7
4
|
export declare const CoreAPI: {
|
|
5
|
+
managers: {
|
|
6
|
+
commands: exported.managerBases.Commands;
|
|
7
|
+
controllers: exported.managerBases.Controllers;
|
|
8
|
+
data: exported.managerBases.Data;
|
|
9
|
+
internal: exported.managerBases.Internal;
|
|
10
|
+
} | undefined;
|
|
8
11
|
commandBases: typeof exported.commandBases;
|
|
9
12
|
core: typeof exported.core;
|
|
10
13
|
errors: typeof exported.errors;
|
|
11
|
-
managers: typeof exported.managers;
|
|
12
14
|
managerBases: typeof exported.managerBases;
|
|
13
15
|
modules: typeof exported.modules;
|
|
14
16
|
utils: typeof exported.utils;
|
|
@@ -5,7 +5,10 @@ import Commands from "../manager-bases/commands";
|
|
|
5
5
|
import Controllers from "../manager-bases/controllers";
|
|
6
6
|
import Data from "../manager-bases/data";
|
|
7
7
|
import Internal from "../manager-bases/internal";
|
|
8
|
-
|
|
9
|
-
export declare
|
|
10
|
-
export declare
|
|
11
|
-
export declare
|
|
8
|
+
import { IAPIConfig } from "../interfaces/config";
|
|
9
|
+
export declare function initialize(config: IAPIConfig): void;
|
|
10
|
+
export declare function destroy(): void;
|
|
11
|
+
export declare const controllers: Controllers;
|
|
12
|
+
export declare const commands: Commands;
|
|
13
|
+
export declare const data: Data;
|
|
14
|
+
export declare const internal: Internal;
|
package/dist/es/zenflux-core.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
globalThis.__ZEN_MANAGERS__ = {};
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
class ForceMethodBase extends Error {
|
|
2
7
|
constructor(className, methodName) {
|
|
3
8
|
super(`ForeMethod implementation: at '${className}' method: '${methodName}'`);
|
|
@@ -441,19 +446,6 @@ class CommandPublic extends CommandBase {
|
|
|
441
446
|
}
|
|
442
447
|
}
|
|
443
448
|
|
|
444
|
-
let commands = {};
|
|
445
|
-
let controllers = {};
|
|
446
|
-
let data = {};
|
|
447
|
-
let internal = {};
|
|
448
|
-
|
|
449
|
-
var index$5 = /*#__PURE__*/Object.freeze({
|
|
450
|
-
__proto__: null,
|
|
451
|
-
commands: commands,
|
|
452
|
-
controllers: controllers,
|
|
453
|
-
data: data,
|
|
454
|
-
internal: internal
|
|
455
|
-
});
|
|
456
|
-
|
|
457
449
|
/**
|
|
458
450
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
459
451
|
* @description: Each data command should represent a final REST endpoint.
|
|
@@ -476,7 +468,7 @@ class CommandData extends CommandBase {
|
|
|
476
468
|
}
|
|
477
469
|
apply(args = this.args, options = this.options) {
|
|
478
470
|
const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
479
|
-
return data.getClient().fetch(endpoint, data.currentHttpMethod, args || null);
|
|
471
|
+
return __ZEN_MANAGERS__.data.getClient().fetch(endpoint, __ZEN_MANAGERS__.data.currentHttpMethod, args || null);
|
|
480
472
|
}
|
|
481
473
|
applyEndpointFormat(endpoint, data = {}) {
|
|
482
474
|
// Replace query with `magic` placeholders.
|
|
@@ -507,7 +499,7 @@ class CommandInternal extends CommandBase {
|
|
|
507
499
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
508
500
|
*/
|
|
509
501
|
|
|
510
|
-
var index$
|
|
502
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
511
503
|
__proto__: null,
|
|
512
504
|
CommandBase: CommandBase,
|
|
513
505
|
CommandData: CommandData,
|
|
@@ -535,9 +527,9 @@ class Controller extends ObjectBase {
|
|
|
535
527
|
this.setupHooks && this.setupHooks();
|
|
536
528
|
}
|
|
537
529
|
register() {
|
|
538
|
-
this.commands = commands.register(this.getCommands(), this);
|
|
539
|
-
this.data = data.register(this.getData(), this);
|
|
540
|
-
this.internal = internal.register(this.getInternal(), this);
|
|
530
|
+
this.commands = __ZEN_MANAGERS__.commands.register(this.getCommands(), this);
|
|
531
|
+
this.data = __ZEN_MANAGERS__.data.register(this.getData(), this);
|
|
532
|
+
this.internal = __ZEN_MANAGERS__.internal.register(this.getInternal(), this);
|
|
541
533
|
}
|
|
542
534
|
getCommands() {
|
|
543
535
|
return {};
|
|
@@ -550,7 +542,7 @@ class Controller extends ObjectBase {
|
|
|
550
542
|
}
|
|
551
543
|
}
|
|
552
544
|
|
|
553
|
-
var index$
|
|
545
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
554
546
|
__proto__: null,
|
|
555
547
|
Controller: Controller,
|
|
556
548
|
ObjectBase: ObjectBase
|
|
@@ -577,7 +569,7 @@ class ControllerAlreadyRegistered extends Error {
|
|
|
577
569
|
}
|
|
578
570
|
}
|
|
579
571
|
|
|
580
|
-
var index$
|
|
572
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
581
573
|
__proto__: null,
|
|
582
574
|
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
583
575
|
CommandNotFound: CommandNotFound,
|
|
@@ -585,7 +577,7 @@ ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
|
585
577
|
ForceMethod: ForceMethod
|
|
586
578
|
});
|
|
587
579
|
|
|
588
|
-
var index$
|
|
580
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
589
581
|
__proto__: null,
|
|
590
582
|
Logger: Logger
|
|
591
583
|
});
|
|
@@ -952,6 +944,36 @@ class Internal extends Commands {
|
|
|
952
944
|
}
|
|
953
945
|
}
|
|
954
946
|
|
|
947
|
+
/**
|
|
948
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
949
|
+
*/
|
|
950
|
+
function initialize(config) {
|
|
951
|
+
__ZEN_MANAGERS__.commands = new Commands();
|
|
952
|
+
__ZEN_MANAGERS__.controllers = new Controllers();
|
|
953
|
+
__ZEN_MANAGERS__.data = new Data(config);
|
|
954
|
+
__ZEN_MANAGERS__.internal = new Internal();
|
|
955
|
+
}
|
|
956
|
+
function destroy() {
|
|
957
|
+
__ZEN_MANAGERS__.commands = {};
|
|
958
|
+
__ZEN_MANAGERS__.controllers = {};
|
|
959
|
+
__ZEN_MANAGERS__.data = {};
|
|
960
|
+
__ZEN_MANAGERS__.internal = {};
|
|
961
|
+
}
|
|
962
|
+
const controllers = __ZEN_MANAGERS__.controllers;
|
|
963
|
+
const commands = __ZEN_MANAGERS__.commands;
|
|
964
|
+
const data = __ZEN_MANAGERS__.data;
|
|
965
|
+
const internal = __ZEN_MANAGERS__.internal;
|
|
966
|
+
|
|
967
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
968
|
+
__proto__: null,
|
|
969
|
+
commands: commands,
|
|
970
|
+
controllers: controllers,
|
|
971
|
+
data: data,
|
|
972
|
+
destroy: destroy,
|
|
973
|
+
initialize: initialize,
|
|
974
|
+
internal: internal
|
|
975
|
+
});
|
|
976
|
+
|
|
955
977
|
/**
|
|
956
978
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
957
979
|
*/
|
|
@@ -970,22 +992,23 @@ Internal: Internal
|
|
|
970
992
|
|
|
971
993
|
var exported = /*#__PURE__*/Object.freeze({
|
|
972
994
|
__proto__: null,
|
|
973
|
-
commandBases: index$
|
|
974
|
-
core: index$
|
|
975
|
-
errors: index$
|
|
995
|
+
commandBases: index$5,
|
|
996
|
+
core: index$4,
|
|
997
|
+
errors: index$3,
|
|
976
998
|
managerBases: index,
|
|
977
|
-
managers: index$
|
|
978
|
-
modules: index$
|
|
999
|
+
managers: index$1,
|
|
1000
|
+
modules: index$2,
|
|
979
1001
|
utils: index$6
|
|
980
1002
|
});
|
|
981
1003
|
|
|
982
1004
|
var name = "@zenflux/core";
|
|
983
|
-
var version = "0.0.0-abc.
|
|
1005
|
+
var version = "0.0.0-abc.7";
|
|
984
1006
|
var description = "ZenFlux core";
|
|
985
1007
|
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
986
1008
|
var scripts = {
|
|
987
1009
|
test: "export flow_modules_logger=off && jest",
|
|
988
|
-
build: "rollup --config rollup.config.ts --configPlugin typescript"
|
|
1010
|
+
build: "rollup --config rollup.config.ts --configPlugin typescript",
|
|
1011
|
+
watch: "rollup --config rollup.config.ts --configPlugin typescript --watch"
|
|
989
1012
|
};
|
|
990
1013
|
var repository = {
|
|
991
1014
|
type: "git",
|
|
@@ -1065,29 +1088,22 @@ const CoreAPI = {
|
|
|
1065
1088
|
initialize: configuration => {
|
|
1066
1089
|
errorInitTwice();
|
|
1067
1090
|
config = configuration || config;
|
|
1068
|
-
|
|
1069
|
-
managers.commands = new Commands();
|
|
1070
|
-
managers.controllers = new Controllers();
|
|
1071
|
-
managers.data = new Data(config);
|
|
1072
|
-
managers.internal = new Internal();
|
|
1091
|
+
initialize(config);
|
|
1073
1092
|
isInitialized = true;
|
|
1074
1093
|
afterInitializeCallbacks.forEach(callback => callback());
|
|
1075
1094
|
},
|
|
1076
1095
|
destroy: () => {
|
|
1096
|
+
destroy();
|
|
1077
1097
|
isInitialized = false;
|
|
1078
|
-
const managers = index$5;
|
|
1079
|
-
managers.commands = {};
|
|
1080
|
-
managers.controllers = {};
|
|
1081
|
-
managers.data = {};
|
|
1082
|
-
managers.internal = {};
|
|
1083
1098
|
},
|
|
1084
1099
|
onAfterInitialize: callback => {
|
|
1085
1100
|
afterInitializeCallbacks.push(callback);
|
|
1086
1101
|
},
|
|
1087
1102
|
config,
|
|
1088
|
-
...exported
|
|
1103
|
+
...exported,
|
|
1104
|
+
managers: typeof __ZEN_MANAGERS__ !== 'undefined' ? __ZEN_MANAGERS__ : undefined
|
|
1089
1105
|
};
|
|
1090
1106
|
// TODO: Make it available only for development.
|
|
1091
1107
|
if (!globalThis?.ZenCore) globalThis.ZenCore = CoreAPI;
|
|
1092
1108
|
|
|
1093
|
-
export { index$
|
|
1109
|
+
export { index$5 as commandBases, index$4 as core, CoreAPI as default, index$3 as errors, index as managerBases, index$1 as managers, index$2 as modules, index$6 as utils };
|
package/dist/es/zenflux-core.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
class t extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class e extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let r=0;class s{virtualId=0;static getName(){throw new t("ObjectBase","getName")}constructor(){this.virtualId=r,r++}getName(){return this.constructor.getName()}}
|
|
1
|
+
"undefined"!=typeof __ZEN_MANAGERS__&&__ZEN_MANAGERS__||(globalThis.__ZEN_MANAGERS__={});class t extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class e extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let r=0;class s{virtualId=0;static getName(){throw new t("ObjectBase","getName")}constructor(){this.virtualId=r,r++}getName(){return this.constructor.getName()}}
|
|
2
2
|
/**
|
|
3
3
|
* Function getCircularReplacer() : Reduce circular references.
|
|
4
4
|
*
|
|
5
5
|
* @copyright https://stackoverflow.com/a/53731154
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const n=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},o=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);let c=255-Math.abs(r-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
|
|
8
8
|
/**
|
|
9
9
|
* Function hexColorDelta() : Return color difference in ratio decimal point.
|
|
10
10
|
*
|
|
11
11
|
* @copyright http://jsfiddle.net/96sME/
|
|
12
|
-
*/var a=Object.freeze({__proto__:null,getCircularReplacer:o,hexColorDelta:n});class i{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){i.wrappers={},i.wrapperDepth=0,i.colorsInUse=[],i.sharedData={}}static createCustomWrapper(t,e){i.wrappers[t]||(i.wrappers[t.name]=[]),i.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(i.sharedData[this.name]||(i.sharedData[this.name]=this.getRandomColor()),this.color=i.sharedData[this.name]):(this.color=this.getRandomColor(),i.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;i.wrapperDepth++;let r={...t};return Object.values(i.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>i.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),i.wrapperDepth--,r):(i.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",i.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=i.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let o=Object.values(t)[0];"object"==typeof o?this.printNextLineObject(e,r,s,o||{}):"function"==typeof o?this.printInLineFunction(e,r,s,o):this.printInLineElement(e,r,s,o)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const r=i.getCallerName();t=Object.create(t);for(let s in t)"object"==typeof t[s]&&(t[s]=JSON.stringify(this.useWrapper(t[s]),o())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${r}%c() [${e}] ->> ${s}: '${t[s]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",i.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=i.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",i.getCallerName(),t),r&&this.printNextLineObject("tw",i.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=i.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(r).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in r){let e=r[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),o()):"function"==typeof r[t]&&(e=i.getFunctionView(e)),this.out.call(this,"%c"+t+": `"+this.useWrapper(e)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return i.colorsInUse.some((e=>n(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}class c extends s{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new i(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,r=this.options){throw new e(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}let l={},h={},u={};var p=Object.freeze({__proto__:null,commands:l,controllers:{},data:h,internal:u});var g=Object.freeze({__proto__:null,CommandBase:c,CommandData:class extends c{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new e(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return h.getClient().fetch(r,h.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends c{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends c{static getName(){return"Core/CommandBases/CommandPublic"}}});var m=Object.freeze({__proto__:null,Controller:class extends s{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=l.register(this.getCommands(),this),this.data=h.register(this.getData(),this),this.internal=u.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:s});class d extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class f extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class C extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var y,b=Object.freeze({__proto__:null,CommandAlreadyRegistered:d,CommandNotFound:f,ControllerAlreadyRegistered:C,ForceMethod:e}),N=Object.freeze({__proto__:null,Logger:i});class w extends s{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let o=0;s>o;++o){const s=!0===r.pop?t.pop():t[o];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new i(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new d(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new f(t);return new s(e,r)}onBefore(t,e){w.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){w.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){w.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){w.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){w.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){w.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await w.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await w.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&w.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),w.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],w.trace.pop(),this.trace.pop()}}class O extends s{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new C(t);return this.controllers[t.getName()]=t,t}}!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(y||(y={}));class A extends s{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new i(A.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},o={};[y.POST,y.PUT,y.PATCH].includes(e)?(Object.assign(o,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:o,body:JSON.stringify(r)})):Object.assign(s,{headers:o});const n=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await n.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class k extends w{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),k.client=new A(t.baseURL)}getClient(){return k.client}get(t,e={},r={}){return this.currentHttpMethod=y.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=y.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=y.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=y.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return y.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=y.__EMPTY__,e.result}}class E extends w{static getName(){return"Core/Managers/Internal"}}var H=Object.freeze({__proto__:null,Commands:w,Controllers:O,Data:k,Internal:E}),_=Object.freeze({__proto__:null,commandBases:g,core:m,errors:b,managerBases:H,managers:p,modules:N,utils:a}),j="0.0.0-abc.4";let I=!1;function $(){if(I)throw Error("ZenCore is already initialized.")}$();let B={version:j};const T=[],M={initialize:t=>{$(),B=t||B;const e=p;e.commands=new w,e.controllers=new O,e.data=new k(B),e.internal=new E,I=!0,T.forEach((t=>t()))},destroy:()=>{I=!1;const t=p;t.commands={},t.controllers={},t.data={},t.internal={}},onAfterInitialize:t=>{T.push(t)},config:B,..._};globalThis?.ZenCore||(globalThis.ZenCore=M);export{g as commandBases,m as core,M as default,b as errors,H as managerBases,p as managers,N as modules,a as utils};
|
|
12
|
+
*/var a=Object.freeze({__proto__:null,getCircularReplacer:n,hexColorDelta:o});class i{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){i.wrappers={},i.wrapperDepth=0,i.colorsInUse=[],i.sharedData={}}static createCustomWrapper(t,e){i.wrappers[t]||(i.wrappers[t.name]=[]),i.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(i.sharedData[this.name]||(i.sharedData[this.name]=this.getRandomColor()),this.color=i.sharedData[this.name]):(this.color=this.getRandomColor(),i.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;i.wrapperDepth++;let r={...t};return Object.values(i.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>i.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),i.wrapperDepth--,r):(i.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",i.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=i.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const r=i.getCallerName();t=Object.create(t);for(let s in t)"object"==typeof t[s]&&(t[s]=JSON.stringify(this.useWrapper(t[s]),n())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${r}%c() [${e}] ->> ${s}: '${t[s]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",i.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=i.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",i.getCallerName(),t),r&&this.printNextLineObject("tw",i.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=i.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(r).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in r){let e=r[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),n()):"function"==typeof r[t]&&(e=i.getFunctionView(e)),this.out.call(this,"%c"+t+": `"+this.useWrapper(e)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return i.colorsInUse.some((e=>o(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}class c extends s{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new i(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,r=this.options){throw new e(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}var l=Object.freeze({__proto__:null,CommandBase:c,CommandData:class extends c{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new e(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return __ZEN_MANAGERS__.data.getClient().fetch(r,__ZEN_MANAGERS__.data.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends c{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends c{static getName(){return"Core/CommandBases/CommandPublic"}}});var h=Object.freeze({__proto__:null,Controller:class extends s{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=__ZEN_MANAGERS__.commands.register(this.getCommands(),this),this.data=__ZEN_MANAGERS__.data.register(this.getData(),this),this.internal=__ZEN_MANAGERS__.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:s});class u extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class p extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class g extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var m,d=Object.freeze({__proto__:null,CommandAlreadyRegistered:u,CommandNotFound:p,ControllerAlreadyRegistered:g,ForceMethod:e}),_=Object.freeze({__proto__:null,Logger:i});class f extends s{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new i(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new u(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new p(t);return new s(e,r)}onBefore(t,e){f.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){f.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){f.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){f.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){f.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){f.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await f.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await f.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&f.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),f.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],f.trace.pop(),this.trace.pop()}}class N extends s{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new g(t);return this.controllers[t.getName()]=t,t}}!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(m||(m={}));class A extends s{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new i(A.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},n={};[m.POST,m.PUT,m.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class E extends f{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),E.client=new A(t.baseURL)}getClient(){return E.client}get(t,e={},r={}){return this.currentHttpMethod=m.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=m.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=m.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=m.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return m.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=m.__EMPTY__,e.result}}class C extends f{static getName(){return"Core/Managers/Internal"}}function y(t){__ZEN_MANAGERS__.commands=new f,__ZEN_MANAGERS__.controllers=new N,__ZEN_MANAGERS__.data=new E(t),__ZEN_MANAGERS__.internal=new C}function b(){__ZEN_MANAGERS__.commands={},__ZEN_MANAGERS__.controllers={},__ZEN_MANAGERS__.data={},__ZEN_MANAGERS__.internal={}}const w=__ZEN_MANAGERS__.controllers,O=__ZEN_MANAGERS__.commands,M=__ZEN_MANAGERS__.data,k=__ZEN_MANAGERS__.internal;var H=Object.freeze({__proto__:null,commands:O,controllers:w,data:M,destroy:b,initialize:y,internal:k}),j=Object.freeze({__proto__:null,Commands:f,Controllers:N,Data:E,Internal:C}),I=Object.freeze({__proto__:null,commandBases:l,core:h,errors:d,managerBases:j,managers:H,modules:_,utils:a}),S="0.0.0-abc.7";let R=!1;function $(){if(R)throw Error("ZenCore is already initialized.")}$();let B={version:S};const T=[],G={initialize:t=>{$(),B=t||B,y(B),R=!0,T.forEach((t=>t()))},destroy:()=>{b(),R=!1},onAfterInitialize:t=>{T.push(t)},config:B,...I,managers:"undefined"!=typeof __ZEN_MANAGERS__?__ZEN_MANAGERS__:void 0};globalThis?.ZenCore||(globalThis.ZenCore=G);export{l as commandBases,h as core,G as default,d as errors,j as managerBases,H as managers,_ as modules,a as utils};
|
package/dist/umd/zenflux-core.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@zenflux/core"]={})}(this,(function(t){"use strict";class e extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class r extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let s=0;class
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@zenflux/core"]={})}(this,(function(t){"use strict";"undefined"!=typeof __ZEN_MANAGERS__&&__ZEN_MANAGERS__||(globalThis.__ZEN_MANAGERS__={});class e extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t}' method: '${e}'`)}}class r extends Error{constructor(t,e){super(`ForeMethod implementation: at '${t.getName()}' method: '${e}'`)}}let s=0;class n{virtualId=0;static getName(){throw new e("ObjectBase","getName")}constructor(){this.virtualId=s,s++}getName(){return this.constructor.getName()}}
|
|
2
2
|
/**
|
|
3
3
|
* Function getCircularReplacer() : Reduce circular references.
|
|
4
4
|
*
|
|
5
5
|
* @copyright https://stackoverflow.com/a/53731154
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const o=()=>{const t=new WeakSet;return(e,r)=>{if("object"==typeof r&&null!==r){if(t.has(r))return;t.add(r)}return r}},a=function(t,e){t=t.replace("#",""),e=e.replace("#","");const r=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),n=parseInt(t.substring(4,6),16),o=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16);let c=255-Math.abs(r-o),l=255-Math.abs(s-a),h=255-Math.abs(n-i);return c/=255,l/=255,h/=255,(c+l+h)/3};
|
|
8
8
|
/**
|
|
9
9
|
* Function hexColorDelta() : Return color difference in ratio decimal point.
|
|
10
10
|
*
|
|
11
11
|
* @copyright http://jsfiddle.net/96sME/
|
|
12
|
-
*/var i=Object.freeze({__proto__:null,getCircularReplacer:n,hexColorDelta:a});class c{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){c.wrappers={},c.wrapperDepth=0,c.colorsInUse=[],c.sharedData={}}static createCustomWrapper(t,e){c.wrappers[t]||(c.wrappers[t.name]=[]),c.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(c.sharedData[this.name]||(c.sharedData[this.name]=this.getRandomColor()),this.color=c.sharedData[this.name]):(this.color=this.getRandomColor(),c.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;c.wrapperDepth++;let r={...t};return Object.values(c.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>c.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),c.wrapperDepth--,r):(c.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",c.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=c.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let o=Object.values(t)[0];"object"==typeof o?this.printNextLineObject(e,r,s,o||{}):"function"==typeof o?this.printInLineFunction(e,r,s,o):this.printInLineElement(e,r,s,o)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const r=c.getCallerName();t=Object.create(t);for(let s in t)"object"==typeof t[s]&&(t[s]=JSON.stringify(this.useWrapper(t[s]),n())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${r}%c() [${e}] ->> ${s}: '${t[s]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",c.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=c.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",c.getCallerName(),t),r&&this.printNextLineObject("tw",c.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=c.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(r).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in r){let e=r[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),n()):"function"==typeof r[t]&&(e=c.getFunctionView(e)),this.out.call(this,"%c"+t+": `"+this.useWrapper(e)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return c.colorsInUse.some((e=>a(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}class l extends o{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new c(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,e=this.options){throw new r(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}let h={},u={},p={};var g=Object.freeze({__proto__:null,commands:h,controllers:{},data:u,internal:p});var m=Object.freeze({__proto__:null,CommandBase:l,CommandData:class extends l{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new r(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return u.getClient().fetch(r,u.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends l{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends l{static getName(){return"Core/CommandBases/CommandPublic"}}});var d=Object.freeze({__proto__:null,Controller:class extends o{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=h.register(this.getCommands(),this),this.data=u.register(this.getData(),this),this.internal=p.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:o});class f extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class C extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class y extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var b,N=Object.freeze({__proto__:null,CommandAlreadyRegistered:f,CommandNotFound:C,ControllerAlreadyRegistered:y,ForceMethod:r}),w=Object.freeze({__proto__:null,Logger:c});class O extends o{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let o=0;s>o;++o){const s=!0===r.pop?t.pop():t[o];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new c(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new f(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new C(t);return new s(e,r)}onBefore(t,e){O.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){O.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){O.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){O.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){O.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){O.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await O.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await O.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&O.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),O.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],O.trace.pop(),this.trace.pop()}}class A extends o{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new y(t);return this.controllers[t.getName()]=t,t}}!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(b||(b={}));class k extends o{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new c(k.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},o={};[b.POST,b.PUT,b.PATCH].includes(e)?(Object.assign(o,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:o,body:JSON.stringify(r)})):Object.assign(s,{headers:o});const n=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await n.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class E extends O{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),E.client=new k(t.baseURL)}getClient(){return E.client}get(t,e={},r={}){return this.currentHttpMethod=b.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=b.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=b.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=b.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return b.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=b.__EMPTY__,e.result}}class _ extends O{static getName(){return"Core/Managers/Internal"}}var j=Object.freeze({__proto__:null,Commands:O,Controllers:A,Data:E,Internal:_}),H=Object.freeze({__proto__:null,commandBases:m,core:d,errors:N,managerBases:j,managers:g,modules:w,utils:i}),I="0.0.0-abc.4";let $=!1;function T(){if($)throw Error("ZenCore is already initialized.")}T();let B={version:I};const M=[],x={initialize:t=>{T(),B=t||B;const e=g;e.commands=new O,e.controllers=new A,e.data=new E(B),e.internal=new _,$=!0,M.forEach((t=>t()))},destroy:()=>{$=!1;const t=g;t.commands={},t.controllers={},t.data={},t.internal={}},onAfterInitialize:t=>{M.push(t)},config:B,...H};globalThis?.ZenCore||(globalThis.ZenCore=x),t.commandBases=m,t.core=d,t.default=x,t.errors=N,t.managerBases=j,t.managers=g,t.modules=w,t.utils=i,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
12
|
+
*/var i=Object.freeze({__proto__:null,getCircularReplacer:o,hexColorDelta:a});class c{static wrappers={};static wrapperDepth=0;static sharedData={};static colorsInUse=[];defaultStyle;color;outputHandler;args={};name;state=!1;static getName(){return"Core/Modules/Logger"}static reset(){c.wrappers={},c.wrapperDepth=0,c.colorsInUse=[],c.sharedData={}}static createCustomWrapper(t,e){c.wrappers[t]||(c.wrappers[t.name]=[]),c.wrappers[t.name].push({classType:t,callback:e})}static getCallerName(){const t=Error(),e=t.stack?t.stack.split("\n")[3].trim():"_UNKNOWN_CALLER_NAME_";return e.startsWith("at new")?"constructor":e.split(".")[1].split(" ")[0]}static getFunctionView(t){let e="anonymous function()";return"string"!=typeof t&&0!==t.name.length&&(e=t.name.split(" ")[1]+"()"),e}constructor(t,e=!1,r={}){"off"!==globalThis.process?.env.flow_modules_logger&&(this.state=e,this.args=r,this.name="",this.name="string"==typeof t?t:t.constructor.name,e&&this.initialize())}initialize(){this.args.sameColor?(c.sharedData[this.name]||(c.sharedData[this.name]=this.getRandomColor()),this.color=c.sharedData[this.name]):(this.color=this.getRandomColor(),c.colorsInUse.push(this.color)),this.outputHandler=console.log,this.defaultStyle=["color: grey;font-size:7px","display: block","color: "+this.color,"color: grey","font-weight: bold","color: #607D8B","font-size: 16px;color: red;font-weight:800"]}setOutputHandler(t){this.outputHandler=t}useWrapper(t,e=!0){if(!t||"object"!=typeof t||Array.isArray(t))return t;c.wrapperDepth++;let r={...t};return Object.values(c.wrappers).forEach((([e])=>{t instanceof e.classType&&(r=e.callback(t)||r)})),4>c.wrapperDepth?(e&&r&&Object.entries(r).forEach((([t,e])=>{r[t]=this.useWrapper(e,!0)})),c.wrapperDepth--,r):(c.wrapperDepth--,r)}startEmpty(t=""){this.state&&this.printFunctionNotify("se",c.getCallerName(),t)}startWith(t){if(!this.state)return;t=Object.assign({},t);const e="se",r=c.getCallerName();if("string"==typeof t)this.printInLineString(e,r,t);else if(1===Object.keys(t).length){const s=Object.keys(t)[0];let n=Object.values(t)[0];"object"==typeof n?this.printNextLineObject(e,r,s,n||{}):"function"==typeof n?this.printInLineFunction(e,r,s,n):this.printInLineElement(e,r,s,n)}else this.printMultiLineObject(e,r,t)}object(t={},e=""){if(!this.state)return;const r=c.getCallerName();t=Object.create(t);for(let s in t)"object"==typeof t[s]&&(t[s]=JSON.stringify(this.useWrapper(t[s]),o())),this.out.apply(this,[`%c(ob)-> %c%c${this.name}%c::%c${r}%c() [${e}] ->> ${s}: '${t[s]}'%c`].concat(this.defaultStyle))}debug(t){this.state&&this.printFunctionNotify("db",c.getCallerName(),t)}drop(t,e){if(!this.state)return;const r=c.getCallerName();for(let e in t)this.out.apply(this,[`%c(dr)-> %c%c${this.name}%c::%c${r}%c() ->> corresponding ${e}: '${t[e]}' RESULT: %c↓`].concat(this.defaultStyle));this.out(e)}throw(t,e="null",r={}){throw this.printFunctionNotify("tw",c.getCallerName(),t),r&&this.printNextLineObject("tw",c.getCallerName(),e,r),Error().stack}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}printFunctionNotify(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ${r}%c`].concat(this.defaultStyle))}printInLineElement(t,e,r,s){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r}: '${s}'%c`].concat(this.defaultStyle))}printInLineFunction(t,e,r,s){s=c.getFunctionView(s),this.printInLineElement(t,e,r,s)}printInLineString(t,e,r){this.printInLineElement(t,e,"(string)",r)}printNextLineObject(t,e,r,s){s=this.useWrapper(s),this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c() ->> ${r} %c↓`].concat(this.defaultStyle)),this.out(s)}printMultiLineObject(t,e,r){this.out.apply(this,[`%c(${t})-> %c%c${this.name}%c::%c${e}%c(${Object.keys(r).join(", ")}) %c↓`].concat(this.defaultStyle));for(let t in r){let e=r[t];"object"==typeof e?e=JSON.stringify(this.useWrapper(e),o()):"function"==typeof r[t]&&(e=c.getFunctionView(e)),this.out.call(this,"%c"+t+": `"+this.useWrapper(e)+"`","color: #a3a3a3")}}getRandomColor(){let t="#";for(let e=0;6>e;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return c.colorsInUse.some((e=>a(t,e)>=.8))?this.getRandomColor():t}out(...t){this.outputHandler.apply(this,t)}}class l extends n{args={};options={};logger;constructor(t={},e={}){super();const r=this.constructor.getName();this.logger=new c(r,!0,{sameColor:!0}),this.logger.startWith({args:t,options:e}),this.initialize(t,e)}initialize(t,e){this.args=t,this.options=e}apply(t=this.args,e=this.options){throw new r(this,"apply")}async run(){this.onBeforeApply&&this.onBeforeApply();const t=await this.apply(this.args,this.options);return this.onAfterApply&&this.onAfterApply(),t}getArgs(){return this.args}getOptions(){return this.options}}var h=Object.freeze({__proto__:null,CommandBase:l,CommandData:class extends l{static getName(){return"Core/CommandBases/CommandData"}getEndpoint(){throw new r(this,"getEndpoint")}apply(t=this.args,e=this.options){const r=this.applyEndpointFormat(this.getEndpoint(),t);return __ZEN_MANAGERS__.data.getClient().fetch(r,__ZEN_MANAGERS__.data.currentHttpMethod,t||null)}applyEndpointFormat(t,e={}){return t.includes("{")&&(t=t.split("/").map((t=>{const r=t.match("\\{(.*?)\\}");return r?.length&&void 0!==e[r[1]]?e[r[1]]:t})).join("/")),t}},CommandInternal:class extends l{static getName(){return"Core/CommandBases/CommandInternal"}},CommandPublic:class extends l{static getName(){return"Core/CommandBases/CommandPublic"}}});var u=Object.freeze({__proto__:null,Controller:class extends n{commands;data;internal;static getName(){return"Core/Core/Controller"}constructor(){super(),this.initialize()}initialize(){this.register(),this.setupHooks&&this.setupHooks()}register(){this.commands=__ZEN_MANAGERS__.commands.register(this.getCommands(),this),this.data=__ZEN_MANAGERS__.data.register(this.getData(),this),this.internal=__ZEN_MANAGERS__.internal.register(this.getInternal(),this)}getCommands(){return{}}getData(){return{}}getInternal(){return{}}},ObjectBase:n});class p extends Error{constructor(t){super(`Command: '${t.getName()}' is already registered`)}}class g extends Error{constructor(t){super(`Command: '${t}' is not found`)}}class m extends Error{constructor(t){super(`Controller: '${t.getName()}' is already registered`)}}var d,_=Object.freeze({__proto__:null,CommandAlreadyRegistered:p,CommandNotFound:g,ControllerAlreadyRegistered:m,ForceMethod:r}),f=Object.freeze({__proto__:null,Logger:c});class N extends n{static trace=[];current={};currentArgs={};trace=[];commands={};onBeforeHooks={};onBeforeUIHooks={};onAfterHooks={};onAfterOnceHooks={};onAfterUIHooks={};onAfterAffectHooks={};logger;static getName(){return"Core/Managers/Commands"}static async runCallbacks(t,e={},r={}){const s=t?.length||0;for(let n=0;s>n;++n){const s=!0===r.pop?t.pop():t[n];if(!s)throw Error("Callback is not defined.");await s(e,r)}}static hookCommand(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}constructor(){super(),this.logger=new c(this.getName(),!0),this.logger.startEmpty()}async run(t,e={},r={}){"string"==typeof t&&(t=this.getCommandInstance(t,e,r)),this.attachCurrent(t,e);const s=await this.runInstance(t,e,r);return this.detachCurrent(t),s}register(t,e){const r={};return Object.values(t).forEach((t=>{const e=t.getName();if(this.commands[e])throw new p(t);this.commands[e]=t,r[e]=t})),r}getAll(){return this.commands}getByName(t){return this.commands[t]}getLogger(){return this.logger}getCommandInstance(t,e={},r={}){const s=this.commands[t];if(!s)throw new g(t);return new s(e,r)}onBefore(t,e){N.hookCommand(this.onBeforeHooks,t,e)}onBeforeUI(t,e){N.hookCommand(this.onBeforeUIHooks,t,e)}onAfter(t,e){N.hookCommand(this.onAfterHooks,t,e)}onAfterUI(t,e){N.hookCommand(this.onAfterUIHooks,t,e)}onAfterOnce(t,e){N.hookCommand(this.onAfterOnceHooks,t,e)}onAfterAffect(t,e){N.hookCommand(this.onAfterAffectHooks,t,e)}onBeforeRun(t,e={},r={}){if(this.onBeforeHooks[t.getName()]){this.onBeforeHooks[t.getName()].forEach((t=>t(e,r)))}if(this.onBeforeUIHooks[t.getName()]){this.onBeforeUIHooks[t.getName()].forEach((t=>t(e,r)))}}async runInstance(t,e={},r={}){let s=null;return Object.keys(e).length?(this.logger.startWith({command:t.getName(),options:r,CommandArgs:"->"}),this.logger.debug("CommandArgs:"),this.logger.object(e)):this.logger.startWith({command:t.getName(),options:r,args:e}),this.onBeforeRun(t,e,r),s=await t.run(),await this.onAfterRun(t,e,r,s),s}async onAfterRun(t,e,r,s){return r=Object.assign({},r),this.onAfterAffectHooks[t.getName()]&&(this.onAfterAffectHooks[t.getName()].forEach((t=>{e.result=s,s=this.run(""+t,e,r)})),s=await s),this.onAfterHooks&&(e.result=s,await N.runCallbacks(Object.assign([],this.onAfterHooks[t.getName()]),e,r)),this.onAfterOnceHooks&&await N.runCallbacks(this.onAfterOnceHooks[t.getName()],e,{...r,pop:!0}),this.onAfterUIHooks&&N.runCallbacks(Object.assign([],this.onAfterUIHooks[t.getName()]),e,r),s}attachCurrent(t,e={}){this.current[t.getName()]=t,this.currentArgs[t.getName()]=e,this.trace.push(t.getName()),N.trace.push(t.getName())}detachCurrent(t){delete this.current[t.getName()],delete this.currentArgs[t.getName()],N.trace.pop(),this.trace.pop()}}class A extends n{controllers={};static getName(){return"Core/Managers/Controllers"}get(t){return this.controllers[t]}getAll(){return this.controllers}register(t){if(this.controllers[t.getName()])throw new m(t);return this.controllers[t.getName()]=t,t}}!function(t){t.DELETE="DELETE",t.GET="GET",t.OPTIONS="OPTIONS",t.PATCH="PATCH",t.POST="POST",t.PUT="PUT",t.__EMPTY__=""}(d||(d={}));class E extends n{logger;apiBaseUrl;static getName(){return"Core/Clients/Http"}constructor(t="http://localhost"){super(),this.logger=new c(E.getName(),!0),this.logger.startWith({apiBaseUrl:t}),this.apiBaseUrl=t+"/"}async fetch(t,e,r=null){this.logger.startWith({path:t,method:e,body:r});const s={credentials:"include"},n={};[d.POST,d.PUT,d.PATCH].includes(e)?(Object.assign(n,{"Content-Type":"application/json"}),Object.assign(s,{method:e,headers:n,body:JSON.stringify(r)})):Object.assign(s,{headers:n});const o=await globalThis.fetch(this.apiBaseUrl+t,s);let a;try{a=await o.json()}catch(t){return console.error(t),!1}if(a?.error&&a?.global&&a?.message)throw Error(a.message);return this.logger.drop({path:t},a),a}}class y extends N{static client;currentHttpMethod;static getName(){return"Core/Managers/Data"}constructor(t){super(),y.client=new E(t.baseURL)}getClient(){return y.client}get(t,e={},r={}){return this.currentHttpMethod=d.GET,super.run(t,e,r)}update(t,e={},r={}){return this.currentHttpMethod=d.PATCH,super.run(t,e,r)}delete(t,e={},r={}){return this.currentHttpMethod=d.DELETE,super.run(t,e,r)}create(t,e={},r={}){return this.currentHttpMethod=d.POST,super.run(t,e,r)}async runInstance(t,e={},r={}){if(!this.currentHttpMethod)throw Error('Cannot run directly use one of the http methods: "get", "update", "delete, "create');const s={type:this.currentHttpMethod,args:{query:{},data:{}}};return d.GET===this.currentHttpMethod?s.args.query=e:s.args.data=e,e.result=await super.runInstance(t,s,r),this.currentHttpMethod=d.__EMPTY__,e.result}}class C extends N{static getName(){return"Core/Managers/Internal"}}function b(t){__ZEN_MANAGERS__.commands=new N,__ZEN_MANAGERS__.controllers=new A,__ZEN_MANAGERS__.data=new y(t),__ZEN_MANAGERS__.internal=new C}function w(){__ZEN_MANAGERS__.commands={},__ZEN_MANAGERS__.controllers={},__ZEN_MANAGERS__.data={},__ZEN_MANAGERS__.internal={}}const O=__ZEN_MANAGERS__.controllers,M=__ZEN_MANAGERS__.commands,k=__ZEN_MANAGERS__.data,j=__ZEN_MANAGERS__.internal;var H=Object.freeze({__proto__:null,commands:M,controllers:O,data:k,destroy:w,initialize:b,internal:j}),I=Object.freeze({__proto__:null,Commands:N,Controllers:A,Data:y,Internal:C}),S=Object.freeze({__proto__:null,commandBases:h,core:u,errors:_,managerBases:I,managers:H,modules:f,utils:i}),R="0.0.0-abc.7";let T=!1;function $(){if(T)throw Error("ZenCore is already initialized.")}$();let B={version:R};const G=[],x={initialize:t=>{$(),B=t||B,b(B),T=!0,G.forEach((t=>t()))},destroy:()=>{w(),T=!1},onAfterInitialize:t=>{G.push(t)},config:B,...S,managers:"undefined"!=typeof __ZEN_MANAGERS__?__ZEN_MANAGERS__:void 0};globalThis?.ZenCore||(globalThis.ZenCore=x),t.commandBases=h,t.core=u,t.default=x,t.errors=_,t.managerBases=I,t.managers=H,t.modules=f,t.utils=i,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenflux/core",
|
|
3
|
-
"version": "0.0.0-abc.
|
|
3
|
+
"version": "0.0.0-abc.8",
|
|
4
4
|
"description": "ZenFlux core",
|
|
5
5
|
"author": "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "export flow_modules_logger=off && jest",
|
|
8
|
-
"build": "rollup --config rollup.config.ts --configPlugin typescript"
|
|
8
|
+
"build": "rollup --config rollup.config.ts --configPlugin typescript",
|
|
9
|
+
"watch": "rollup --config rollup.config.ts --configPlugin typescript --watch"
|
|
9
10
|
},
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
import { ForceMethod } from '../errors/force-method';
|
|
6
6
|
import { CommandBase } from './command-base';
|
|
7
7
|
|
|
8
|
-
import { data } from '../managers/';
|
|
9
|
-
|
|
10
8
|
export abstract class CommandData extends CommandBase {
|
|
11
9
|
static getName() {
|
|
12
10
|
return 'Core/CommandBases/CommandData';
|
|
@@ -28,8 +26,8 @@ export abstract class CommandData extends CommandBase {
|
|
|
28
26
|
apply( args = this.args, options = this.options ) {// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
29
27
|
const endpoint = this.applyEndpointFormat( this.getEndpoint(), args );
|
|
30
28
|
|
|
31
|
-
return data.getClient().fetch(
|
|
32
|
-
endpoint, data.currentHttpMethod, args || null
|
|
29
|
+
return __ZEN_MANAGERS__.data.getClient().fetch(
|
|
30
|
+
endpoint, __ZEN_MANAGERS__.data.currentHttpMethod, args || null
|
|
33
31
|
);
|
|
34
32
|
}
|
|
35
33
|
|
package/src/core/controller.ts
CHANGED
|
@@ -6,8 +6,6 @@ import ObjectBase from "./object-base";
|
|
|
6
6
|
|
|
7
7
|
import { CommandData, CommandInternal, CommandPublic } from "../command-bases";
|
|
8
8
|
|
|
9
|
-
import * as managers from "../managers/";
|
|
10
|
-
|
|
11
9
|
export abstract class Controller extends ObjectBase {
|
|
12
10
|
commands: { [ key: string ]: typeof CommandPublic };
|
|
13
11
|
data: { [ key: string ]: typeof CommandData };
|
|
@@ -30,13 +28,13 @@ export abstract class Controller extends ObjectBase {
|
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
register() {
|
|
33
|
-
this.commands =
|
|
31
|
+
this.commands = __ZEN_MANAGERS__.commands.register( this.getCommands(), this ) as
|
|
34
32
|
{ [ key: string ]: typeof CommandPublic };
|
|
35
33
|
|
|
36
|
-
this.data =
|
|
34
|
+
this.data = __ZEN_MANAGERS__.data.register( this.getData(), this ) as
|
|
37
35
|
{ [ key: string ]: typeof CommandData };
|
|
38
36
|
|
|
39
|
-
this.internal =
|
|
37
|
+
this.internal = __ZEN_MANAGERS__.internal.register( this.getInternal(), this ) as
|
|
40
38
|
{ [ key: string ]: typeof CommandInternal };
|
|
41
39
|
}
|
|
42
40
|
|
package/src/exports.ts
CHANGED
package/src/globals.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
if ( typeof __ZEN_MANAGERS__ === 'undefined' || ! __ZEN_MANAGERS__ ) {
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
globalThis.__ZEN_MANAGERS__ = {};
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
import Commands from "./manager-bases/commands";
|
|
7
|
+
import Controllers from "./manager-bases/controllers";
|
|
8
|
+
import Data from "./manager-bases/data";
|
|
9
|
+
import Internal from "./manager-bases/internal";
|
|
10
|
+
|
|
11
|
+
declare global {
|
|
12
|
+
var ZenCore: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare global {
|
|
16
|
+
var __ZEN_MANAGERS__: {
|
|
17
|
+
commands: Commands;
|
|
18
|
+
controllers: Controllers;
|
|
19
|
+
data: Data;
|
|
20
|
+
internal: Internal;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
CHANGED
package/src/initializer.ts
CHANGED
|
@@ -4,6 +4,9 @@ import * as exported from './exports';
|
|
|
4
4
|
|
|
5
5
|
import { IAPIConfig } from "./interfaces/config";
|
|
6
6
|
|
|
7
|
+
import { destroy, initialize } from "./managers";
|
|
8
|
+
|
|
9
|
+
|
|
7
10
|
declare global {
|
|
8
11
|
var ZenCore: any;
|
|
9
12
|
}
|
|
@@ -30,12 +33,7 @@ export const CoreAPI = {
|
|
|
30
33
|
|
|
31
34
|
config = configuration || config;
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
managers.commands = new exported.managerBases.Commands();
|
|
36
|
-
managers.controllers = new exported.managerBases.Controllers();
|
|
37
|
-
managers.data = new exported.managerBases.Data( config );
|
|
38
|
-
managers.internal = new exported.managerBases.Internal();
|
|
36
|
+
initialize( config )
|
|
39
37
|
|
|
40
38
|
isInitialized = true;
|
|
41
39
|
|
|
@@ -43,14 +41,9 @@ export const CoreAPI = {
|
|
|
43
41
|
},
|
|
44
42
|
|
|
45
43
|
destroy: () => {
|
|
46
|
-
|
|
44
|
+
destroy();
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
managers.commands = {} as exported.managerBases.Commands;
|
|
51
|
-
managers.controllers = {} as exported.managerBases.Controllers
|
|
52
|
-
managers.data = {} as exported.managerBases.Data;
|
|
53
|
-
managers.internal = {} as exported.managerBases.Internal;
|
|
46
|
+
isInitialized = false;
|
|
54
47
|
},
|
|
55
48
|
|
|
56
49
|
onAfterInitialize: ( callback: () => void ) => {
|
|
@@ -60,6 +53,8 @@ export const CoreAPI = {
|
|
|
60
53
|
config,
|
|
61
54
|
|
|
62
55
|
...exported,
|
|
56
|
+
|
|
57
|
+
managers: typeof __ZEN_MANAGERS__ !== 'undefined' ? __ZEN_MANAGERS__ : undefined,
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
// TODO: Make it available only for development.
|
package/src/managers/index.ts
CHANGED
|
@@ -5,8 +5,37 @@ import Commands from "../manager-bases/commands";
|
|
|
5
5
|
import Controllers from "../manager-bases/controllers";
|
|
6
6
|
import Data from "../manager-bases/data";
|
|
7
7
|
import Internal from "../manager-bases/internal";
|
|
8
|
+
import { IAPIConfig } from "../interfaces/config";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if ( typeof __ZEN_MANAGERS__ === 'undefined' || ! __ZEN_MANAGERS__ ) {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
globalThis.__ZEN_MANAGERS__ = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare global {
|
|
16
|
+
var __ZEN_MANAGERS__: {
|
|
17
|
+
commands: Commands;
|
|
18
|
+
controllers: Controllers;
|
|
19
|
+
data: Data;
|
|
20
|
+
internal: Internal;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function initialize( config: IAPIConfig ) {
|
|
25
|
+
__ZEN_MANAGERS__.commands = new Commands();
|
|
26
|
+
__ZEN_MANAGERS__.controllers = new Controllers();
|
|
27
|
+
__ZEN_MANAGERS__.data = new Data( config );
|
|
28
|
+
__ZEN_MANAGERS__.internal = new Internal();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function destroy() {
|
|
32
|
+
__ZEN_MANAGERS__.commands = {} as Commands;
|
|
33
|
+
__ZEN_MANAGERS__.controllers = {} as Controllers;
|
|
34
|
+
__ZEN_MANAGERS__.data = {} as Data;
|
|
35
|
+
__ZEN_MANAGERS__.internal = {} as Internal;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const controllers = __ZEN_MANAGERS__.controllers;
|
|
39
|
+
export const commands = __ZEN_MANAGERS__.commands;
|
|
40
|
+
export const data = __ZEN_MANAGERS__.data;
|
|
41
|
+
export const internal = __ZEN_MANAGERS__.internal;
|