@zenflux/core 0.0.0-abc.9 → 0.0.0-alpha.0
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 +229 -231
- package/dist/es/src/globals.d.ts +0 -12
- package/dist/es/src/initializer.d.ts +2 -1
- package/dist/es/src/interfaces/managers.d.ts +13 -0
- package/dist/es/src/manager-bases/commands.d.ts +2 -1
- package/dist/es/src/manager-bases/controllers.d.ts +2 -1
- package/dist/es/src/managers/index.d.ts +5 -4
- package/dist/es/zenflux-core.js +225 -227
- package/dist/es/zenflux-core.mjs +3 -3
- package/dist/umd/zenflux-core.js +3 -3
- package/package.json +1 -1
- package/src/command-bases/command-data.ts +4 -2
- package/src/core/controller.ts +5 -3
- package/src/initializer.ts +8 -8
- package/src/interfaces/managers.ts +16 -0
- package/src/manager-bases/commands.ts +3 -1
- package/src/manager-bases/controllers.ts +2 -1
- package/src/managers/index.ts +25 -13
- package/src/globals.ts +0 -22
package/dist/cjs/zenflux-core.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@zenflux/core";
|
|
6
|
-
var version = "0.0.0-abc.
|
|
6
|
+
var version = "0.0.0-abc.20";
|
|
7
7
|
var description = "ZenFlux core";
|
|
8
8
|
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
9
9
|
var scripts = {
|
|
@@ -74,42 +74,6 @@ var pkg = {
|
|
|
74
74
|
dependencies: dependencies
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
class ForceMethodBase extends Error {
|
|
78
|
-
constructor(className, methodName) {
|
|
79
|
-
super(`ForeMethod implementation: at '${className}' method: '${methodName}'`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
class ForceMethod extends Error {
|
|
83
|
-
constructor(context, methodName) {
|
|
84
|
-
super(`ForeMethod implementation: at '${context.getName()}' method: '${methodName}'`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
90
|
-
* @description: is base class/object for all classes, responsible for: 'getName', implementation.
|
|
91
|
-
*/
|
|
92
|
-
let IdCounter = 0;
|
|
93
|
-
/**
|
|
94
|
-
* Base class 4 *
|
|
95
|
-
*/
|
|
96
|
-
class ObjectBase {
|
|
97
|
-
virtualId = 0;
|
|
98
|
-
static getName() {
|
|
99
|
-
throw new ForceMethodBase("ObjectBase", "getName");
|
|
100
|
-
}
|
|
101
|
-
constructor() {
|
|
102
|
-
this.virtualId = IdCounter;
|
|
103
|
-
APIIncreaseIdCounter();
|
|
104
|
-
}
|
|
105
|
-
getName() {
|
|
106
|
-
return this.constructor.getName();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function APIIncreaseIdCounter() {
|
|
110
|
-
return IdCounter++;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
77
|
/**
|
|
114
78
|
* Function getCircularReplacer() : Reduce circular references.
|
|
115
79
|
*
|
|
@@ -464,159 +428,9 @@ class Logger {
|
|
|
464
428
|
}
|
|
465
429
|
}
|
|
466
430
|
|
|
467
|
-
/**
|
|
468
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
469
|
-
* @description: Base for all commands, they are all will be managed by the `Commands` managers.
|
|
470
|
-
* @TODO
|
|
471
|
-
* - Add validateArgs method or find something better.
|
|
472
|
-
*/
|
|
473
|
-
class CommandBase extends ObjectBase {
|
|
474
|
-
args = {};
|
|
475
|
-
options = {};
|
|
476
|
-
logger;
|
|
477
|
-
constructor(args = {}, options = {}) {
|
|
478
|
-
super();
|
|
479
|
-
const name = this.constructor.getName();
|
|
480
|
-
this.logger = new Logger(name, true, {
|
|
481
|
-
sameColor: true
|
|
482
|
-
});
|
|
483
|
-
this.logger.startWith({
|
|
484
|
-
args,
|
|
485
|
-
options
|
|
486
|
-
});
|
|
487
|
-
this.initialize(args, options);
|
|
488
|
-
}
|
|
489
|
-
initialize(args, options) {
|
|
490
|
-
this.args = args;
|
|
491
|
-
this.options = options;
|
|
492
|
-
}
|
|
493
|
-
apply(args = this.args, options = this.options) {
|
|
494
|
-
throw new ForceMethod(this, "apply");
|
|
495
|
-
}
|
|
496
|
-
async run() {
|
|
497
|
-
this.onBeforeApply && this.onBeforeApply();
|
|
498
|
-
const result = await this.apply(this.args, this.options);
|
|
499
|
-
this.onAfterApply && this.onAfterApply();
|
|
500
|
-
return result;
|
|
501
|
-
}
|
|
502
|
-
getArgs() {
|
|
503
|
-
return this.args;
|
|
504
|
-
}
|
|
505
|
-
getOptions() {
|
|
506
|
-
return this.options;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
512
|
-
* @description: CommandPublic represents a USER action, every class which inherit from this class will USER action.
|
|
513
|
-
* */
|
|
514
|
-
class CommandPublic extends CommandBase {
|
|
515
|
-
static getName() {
|
|
516
|
-
return 'Core/CommandBases/CommandPublic';
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
522
|
-
* @description: Each data command should represent a final REST endpoint.
|
|
523
|
-
*/
|
|
524
|
-
class CommandData extends CommandBase {
|
|
525
|
-
static getName() {
|
|
526
|
-
return 'Core/CommandBases/CommandData';
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
|
|
530
|
-
* @example
|
|
531
|
-
* ```
|
|
532
|
-
* args = { query: { id: 1 } };
|
|
533
|
-
* getEndpoint() = '/api/v1/users/{id}';
|
|
534
|
-
* result = '/api/v1/users/1';
|
|
535
|
-
* ```
|
|
536
|
-
*/
|
|
537
|
-
getEndpoint() {
|
|
538
|
-
throw new ForceMethod(this, 'getEndpoint');
|
|
539
|
-
}
|
|
540
|
-
apply(args = this.args, options = this.options) {
|
|
541
|
-
const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
542
|
-
return __ZEN_MANAGERS__.data.getClient().fetch(endpoint, __ZEN_MANAGERS__.data.currentHttpMethod, args || null);
|
|
543
|
-
}
|
|
544
|
-
applyEndpointFormat(endpoint, data = {}) {
|
|
545
|
-
// Replace query with `magic` placeholders.
|
|
546
|
-
if (endpoint.includes('{')) {
|
|
547
|
-
endpoint = endpoint.split('/').map(endpointPart => {
|
|
548
|
-
const match = endpointPart.match('\\{(.*?)\\}');
|
|
549
|
-
if (match?.length && 'undefined' !== typeof data[match[1]]) {
|
|
550
|
-
return data[match[1]];
|
|
551
|
-
}
|
|
552
|
-
return endpointPart;
|
|
553
|
-
}).join('/');
|
|
554
|
-
}
|
|
555
|
-
return endpoint;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
561
|
-
* @description: CommandInternal, is used when part of the logic needed to be in the command but not represent a user action.
|
|
562
|
-
*/
|
|
563
|
-
class CommandInternal extends CommandBase {
|
|
564
|
-
static getName() {
|
|
565
|
-
return 'Core/CommandBases/CommandInternal';
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
571
|
-
*/
|
|
572
|
-
|
|
573
431
|
var index$5 = /*#__PURE__*/Object.freeze({
|
|
574
432
|
__proto__: null,
|
|
575
|
-
|
|
576
|
-
CommandData: CommandData,
|
|
577
|
-
CommandInternal: CommandInternal,
|
|
578
|
-
CommandPublic: CommandPublic
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
583
|
-
* @description: Responsible for commands, Aka ( CommandsSpace ).
|
|
584
|
-
*/
|
|
585
|
-
class Controller extends ObjectBase {
|
|
586
|
-
commands;
|
|
587
|
-
data;
|
|
588
|
-
internal;
|
|
589
|
-
static getName() {
|
|
590
|
-
return 'Core/Core/Controller';
|
|
591
|
-
}
|
|
592
|
-
constructor() {
|
|
593
|
-
super();
|
|
594
|
-
this.initialize();
|
|
595
|
-
}
|
|
596
|
-
initialize() {
|
|
597
|
-
this.register();
|
|
598
|
-
this.setupHooks && this.setupHooks();
|
|
599
|
-
}
|
|
600
|
-
register() {
|
|
601
|
-
this.commands = __ZEN_MANAGERS__.commands.register(this.getCommands(), this);
|
|
602
|
-
this.data = __ZEN_MANAGERS__.data.register(this.getData(), this);
|
|
603
|
-
this.internal = __ZEN_MANAGERS__.internal.register(this.getInternal(), this);
|
|
604
|
-
}
|
|
605
|
-
getCommands() {
|
|
606
|
-
return {};
|
|
607
|
-
}
|
|
608
|
-
getData() {
|
|
609
|
-
return {};
|
|
610
|
-
}
|
|
611
|
-
getInternal() {
|
|
612
|
-
return {};
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
var index$4 = /*#__PURE__*/Object.freeze({
|
|
617
|
-
__proto__: null,
|
|
618
|
-
Controller: Controller,
|
|
619
|
-
ObjectBase: ObjectBase
|
|
433
|
+
Logger: Logger
|
|
620
434
|
});
|
|
621
435
|
|
|
622
436
|
class CommandAlreadyRegistered extends Error {
|
|
@@ -640,7 +454,18 @@ class ControllerAlreadyRegistered extends Error {
|
|
|
640
454
|
}
|
|
641
455
|
}
|
|
642
456
|
|
|
643
|
-
|
|
457
|
+
class ForceMethodBase extends Error {
|
|
458
|
+
constructor(className, methodName) {
|
|
459
|
+
super(`ForeMethod implementation: at '${className}' method: '${methodName}'`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
class ForceMethod extends Error {
|
|
463
|
+
constructor(context, methodName) {
|
|
464
|
+
super(`ForeMethod implementation: at '${context.getName()}' method: '${methodName}'`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
644
469
|
__proto__: null,
|
|
645
470
|
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
646
471
|
CommandNotFound: CommandNotFound,
|
|
@@ -648,10 +473,30 @@ ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
|
648
473
|
ForceMethod: ForceMethod
|
|
649
474
|
});
|
|
650
475
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
476
|
+
/**
|
|
477
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
478
|
+
* @description: is base class/object for all classes, responsible for: 'getName', implementation.
|
|
479
|
+
*/
|
|
480
|
+
let IdCounter = 0;
|
|
481
|
+
/**
|
|
482
|
+
* Base class 4 *
|
|
483
|
+
*/
|
|
484
|
+
class ObjectBase {
|
|
485
|
+
virtualId = 0;
|
|
486
|
+
static getName() {
|
|
487
|
+
throw new ForceMethodBase("ObjectBase", "getName");
|
|
488
|
+
}
|
|
489
|
+
constructor() {
|
|
490
|
+
this.virtualId = IdCounter;
|
|
491
|
+
APIIncreaseIdCounter();
|
|
492
|
+
}
|
|
493
|
+
getName() {
|
|
494
|
+
return this.constructor.getName();
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function APIIncreaseIdCounter() {
|
|
498
|
+
return IdCounter++;
|
|
499
|
+
}
|
|
655
500
|
|
|
656
501
|
/**
|
|
657
502
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
@@ -1015,33 +860,39 @@ class Internal extends Commands {
|
|
|
1015
860
|
}
|
|
1016
861
|
}
|
|
1017
862
|
|
|
1018
|
-
if (typeof __ZEN_MANAGERS__ === 'undefined' || !__ZEN_MANAGERS__) {
|
|
1019
|
-
// @ts-ignore
|
|
1020
|
-
globalThis.__ZEN_MANAGERS__ = {};
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
863
|
/**
|
|
1024
864
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1025
865
|
*/
|
|
866
|
+
const afterInitializeCallbacks = [];
|
|
1026
867
|
function initialize(config) {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
868
|
+
commands = new Commands();
|
|
869
|
+
controllers = new Controllers();
|
|
870
|
+
data = new Data(config);
|
|
871
|
+
internal = new Internal();
|
|
1031
872
|
}
|
|
1032
873
|
function destroy() {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
874
|
+
commands = {};
|
|
875
|
+
controllers = {};
|
|
876
|
+
data = {};
|
|
877
|
+
internal = {};
|
|
1037
878
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
879
|
+
var commands = {};
|
|
880
|
+
var controllers = {};
|
|
881
|
+
var data = {};
|
|
882
|
+
var internal = {};
|
|
883
|
+
/*
|
|
884
|
+
__ZEN_MANAGERS__.initialize = initialize;
|
|
885
|
+
__ZEN_MANAGERS__.destroy = destroy;
|
|
1042
886
|
|
|
1043
|
-
var
|
|
887
|
+
export var commands = __ZEN_MANAGERS__.commands;
|
|
888
|
+
export var controllers = __ZEN_MANAGERS__.controllers;
|
|
889
|
+
export var data = __ZEN_MANAGERS__.data;
|
|
890
|
+
export var internal = __ZEN_MANAGERS__.internal;
|
|
891
|
+
*/
|
|
892
|
+
|
|
893
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
1044
894
|
__proto__: null,
|
|
895
|
+
afterInitializeCallbacks: afterInitializeCallbacks,
|
|
1045
896
|
get commands () { return commands; },
|
|
1046
897
|
get controllers () { return controllers; },
|
|
1047
898
|
get data () { return data; },
|
|
@@ -1050,6 +901,161 @@ initialize: initialize,
|
|
|
1050
901
|
get internal () { return internal; }
|
|
1051
902
|
});
|
|
1052
903
|
|
|
904
|
+
/**
|
|
905
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
906
|
+
* @description: Base for all commands, they are all will be managed by the `Commands` managers.
|
|
907
|
+
* @TODO
|
|
908
|
+
* - Add validateArgs method or find something better.
|
|
909
|
+
*/
|
|
910
|
+
class CommandBase extends ObjectBase {
|
|
911
|
+
args = {};
|
|
912
|
+
options = {};
|
|
913
|
+
logger;
|
|
914
|
+
constructor(args = {}, options = {}) {
|
|
915
|
+
super();
|
|
916
|
+
const name = this.constructor.getName();
|
|
917
|
+
this.logger = new Logger(name, true, {
|
|
918
|
+
sameColor: true
|
|
919
|
+
});
|
|
920
|
+
this.logger.startWith({
|
|
921
|
+
args,
|
|
922
|
+
options
|
|
923
|
+
});
|
|
924
|
+
this.initialize(args, options);
|
|
925
|
+
}
|
|
926
|
+
initialize(args, options) {
|
|
927
|
+
this.args = args;
|
|
928
|
+
this.options = options;
|
|
929
|
+
}
|
|
930
|
+
apply(args = this.args, options = this.options) {
|
|
931
|
+
throw new ForceMethod(this, "apply");
|
|
932
|
+
}
|
|
933
|
+
async run() {
|
|
934
|
+
this.onBeforeApply && this.onBeforeApply();
|
|
935
|
+
const result = await this.apply(this.args, this.options);
|
|
936
|
+
this.onAfterApply && this.onAfterApply();
|
|
937
|
+
return result;
|
|
938
|
+
}
|
|
939
|
+
getArgs() {
|
|
940
|
+
return this.args;
|
|
941
|
+
}
|
|
942
|
+
getOptions() {
|
|
943
|
+
return this.options;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
949
|
+
* @description: CommandPublic represents a USER action, every class which inherit from this class will USER action.
|
|
950
|
+
* */
|
|
951
|
+
class CommandPublic extends CommandBase {
|
|
952
|
+
static getName() {
|
|
953
|
+
return 'Core/CommandBases/CommandPublic';
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
959
|
+
* @description: Each data command should represent a final REST endpoint.
|
|
960
|
+
*/
|
|
961
|
+
class CommandData extends CommandBase {
|
|
962
|
+
static getName() {
|
|
963
|
+
return 'Core/CommandBases/CommandData';
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
|
|
967
|
+
* @example
|
|
968
|
+
* ```
|
|
969
|
+
* args = { query: { id: 1 } };
|
|
970
|
+
* getEndpoint() = '/api/v1/users/{id}';
|
|
971
|
+
* result = '/api/v1/users/1';
|
|
972
|
+
* ```
|
|
973
|
+
*/
|
|
974
|
+
getEndpoint() {
|
|
975
|
+
throw new ForceMethod(this, 'getEndpoint');
|
|
976
|
+
}
|
|
977
|
+
apply(args = this.args, options = this.options) {
|
|
978
|
+
const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
979
|
+
return data.getClient().fetch(endpoint, data.currentHttpMethod, args || null);
|
|
980
|
+
}
|
|
981
|
+
applyEndpointFormat(endpoint, data = {}) {
|
|
982
|
+
// Replace query with `magic` placeholders.
|
|
983
|
+
if (endpoint.includes('{')) {
|
|
984
|
+
endpoint = endpoint.split('/').map(endpointPart => {
|
|
985
|
+
const match = endpointPart.match('\\{(.*?)\\}');
|
|
986
|
+
if (match?.length && 'undefined' !== typeof data[match[1]]) {
|
|
987
|
+
return data[match[1]];
|
|
988
|
+
}
|
|
989
|
+
return endpointPart;
|
|
990
|
+
}).join('/');
|
|
991
|
+
}
|
|
992
|
+
return endpoint;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
998
|
+
* @description: CommandInternal, is used when part of the logic needed to be in the command but not represent a user action.
|
|
999
|
+
*/
|
|
1000
|
+
class CommandInternal extends CommandBase {
|
|
1001
|
+
static getName() {
|
|
1002
|
+
return 'Core/CommandBases/CommandInternal';
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1008
|
+
*/
|
|
1009
|
+
|
|
1010
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
1011
|
+
__proto__: null,
|
|
1012
|
+
CommandBase: CommandBase,
|
|
1013
|
+
CommandData: CommandData,
|
|
1014
|
+
CommandInternal: CommandInternal,
|
|
1015
|
+
CommandPublic: CommandPublic
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1020
|
+
* @description: Responsible for commands, Aka ( CommandsSpace ).
|
|
1021
|
+
*/
|
|
1022
|
+
class Controller extends ObjectBase {
|
|
1023
|
+
commands;
|
|
1024
|
+
data;
|
|
1025
|
+
internal;
|
|
1026
|
+
static getName() {
|
|
1027
|
+
return 'Core/Core/Controller';
|
|
1028
|
+
}
|
|
1029
|
+
constructor() {
|
|
1030
|
+
super();
|
|
1031
|
+
this.initialize();
|
|
1032
|
+
}
|
|
1033
|
+
initialize() {
|
|
1034
|
+
this.register();
|
|
1035
|
+
this.setupHooks && this.setupHooks();
|
|
1036
|
+
}
|
|
1037
|
+
register() {
|
|
1038
|
+
this.commands = commands.register(this.getCommands(), this);
|
|
1039
|
+
this.data = data.register(this.getData(), this);
|
|
1040
|
+
this.internal = internal.register(this.getInternal(), this);
|
|
1041
|
+
}
|
|
1042
|
+
getCommands() {
|
|
1043
|
+
return {};
|
|
1044
|
+
}
|
|
1045
|
+
getData() {
|
|
1046
|
+
return {};
|
|
1047
|
+
}
|
|
1048
|
+
getInternal() {
|
|
1049
|
+
return {};
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1054
|
+
__proto__: null,
|
|
1055
|
+
Controller: Controller,
|
|
1056
|
+
ObjectBase: ObjectBase
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1053
1059
|
/**
|
|
1054
1060
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1055
1061
|
*/
|
|
@@ -1068,12 +1074,12 @@ Internal: Internal
|
|
|
1068
1074
|
|
|
1069
1075
|
var exported = /*#__PURE__*/Object.freeze({
|
|
1070
1076
|
__proto__: null,
|
|
1071
|
-
commandBases: index$
|
|
1072
|
-
core: index$
|
|
1073
|
-
errors: index$
|
|
1077
|
+
commandBases: index$2,
|
|
1078
|
+
core: index$1,
|
|
1079
|
+
errors: index$4,
|
|
1074
1080
|
managerBases: index,
|
|
1075
|
-
managers: index$
|
|
1076
|
-
modules: index$
|
|
1081
|
+
managers: index$3,
|
|
1082
|
+
modules: index$5,
|
|
1077
1083
|
utils: index$6
|
|
1078
1084
|
});
|
|
1079
1085
|
|
|
@@ -1087,24 +1093,16 @@ errorInitTwice();
|
|
|
1087
1093
|
let config = {
|
|
1088
1094
|
version: pkg.version
|
|
1089
1095
|
};
|
|
1090
|
-
const afterInitializeCallbacks = [];
|
|
1091
1096
|
const CoreAPI = {
|
|
1092
1097
|
initialize: configuration => {
|
|
1093
1098
|
errorInitTwice();
|
|
1094
1099
|
config = configuration || config;
|
|
1095
|
-
|
|
1096
|
-
controllers = new Controllers();
|
|
1097
|
-
data = new Data(config);
|
|
1098
|
-
internal = new Internal();
|
|
1100
|
+
initialize(config);
|
|
1099
1101
|
isInitialized = true;
|
|
1100
|
-
afterInitializeCallbacks.forEach(callback => callback());
|
|
1101
1102
|
},
|
|
1102
1103
|
destroy: () => {
|
|
1104
|
+
destroy();
|
|
1103
1105
|
isInitialized = false;
|
|
1104
|
-
commands = {};
|
|
1105
|
-
controllers = {};
|
|
1106
|
-
data = {};
|
|
1107
|
-
internal = {};
|
|
1108
1106
|
},
|
|
1109
1107
|
onAfterInitialize: callback => {
|
|
1110
1108
|
afterInitializeCallbacks.push(callback);
|
|
@@ -1115,11 +1113,11 @@ const CoreAPI = {
|
|
|
1115
1113
|
// TODO: Make it available only for development.
|
|
1116
1114
|
if (!globalThis?.ZenCore) globalThis.ZenCore = CoreAPI;
|
|
1117
1115
|
|
|
1118
|
-
exports.commandBases = index$
|
|
1119
|
-
exports.core = index$
|
|
1116
|
+
exports.commandBases = index$2;
|
|
1117
|
+
exports.core = index$1;
|
|
1120
1118
|
exports.default = CoreAPI;
|
|
1121
|
-
exports.errors = index$
|
|
1119
|
+
exports.errors = index$4;
|
|
1122
1120
|
exports.managerBases = index;
|
|
1123
|
-
exports.managers = index$
|
|
1124
|
-
exports.modules = index$
|
|
1121
|
+
exports.managers = index$3;
|
|
1122
|
+
exports.modules = index$5;
|
|
1125
1123
|
exports.utils = index$6;
|
package/dist/es/src/globals.d.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
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 __ZEN_MANAGERS__: {
|
|
7
|
-
commands: Commands;
|
|
8
|
-
controllers: Controllers;
|
|
9
|
-
data: Data;
|
|
10
|
-
internal: Internal;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
1
|
declare global {
|
|
14
2
|
var ZenCore: any;
|
|
15
3
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
import { IAPIConfig } from "./config";
|
|
6
|
+
export interface IManagers {
|
|
7
|
+
initialize: (config: IAPIConfig) => void;
|
|
8
|
+
destroy: () => void;
|
|
9
|
+
commands: Commands;
|
|
10
|
+
controllers: Controllers;
|
|
11
|
+
data: Data;
|
|
12
|
+
internal: Internal;
|
|
13
|
+
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Logger } from "../modules/";
|
|
6
6
|
import { CommandBase } from "../command-bases";
|
|
7
|
-
import
|
|
7
|
+
import ObjectBase from "../core/object-base";
|
|
8
|
+
import Controller from "../core/controller";
|
|
8
9
|
import { ICommandArgsInterface, CommandCallbackType, IOnHookAffectInterface, IOnHookInterface } from "../interfaces/commands";
|
|
9
10
|
export declare class Commands extends ObjectBase {
|
|
10
11
|
static readonly trace: string[];
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
3
3
|
* @description: Responsible for manging controllers, each controller is global singleton instance.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import ObjectBase from "../core/object-base";
|
|
6
|
+
import Controller from "../core/controller";
|
|
6
7
|
export declare class Controllers extends ObjectBase {
|
|
7
8
|
controllers: {
|
|
8
9
|
[key: string]: Controller;
|
|
@@ -7,9 +7,10 @@ import Data from "../manager-bases/data";
|
|
|
7
7
|
import Internal from "../manager-bases/internal";
|
|
8
8
|
import { IAPIConfig } from "../interfaces/config";
|
|
9
9
|
import '../globals';
|
|
10
|
+
export declare const afterInitializeCallbacks: (() => void)[];
|
|
10
11
|
export declare function initialize(config: IAPIConfig): void;
|
|
11
12
|
export declare function destroy(): void;
|
|
12
|
-
export declare
|
|
13
|
-
export declare
|
|
14
|
-
export declare
|
|
15
|
-
export declare
|
|
13
|
+
export declare var commands: Commands;
|
|
14
|
+
export declare var controllers: Controllers;
|
|
15
|
+
export declare var data: Data;
|
|
16
|
+
export declare var internal: Internal;
|