@zenflux/core 0.0.0-abc.8 → 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 +307 -304
- package/dist/es/src/globals.d.ts +0 -12
- package/dist/es/src/index.d.ts +1 -2
- package/dist/es/src/initializer.d.ts +6 -7
- 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 +6 -4
- package/dist/es/zenflux-core.js +303 -300
- 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 +3 -6
- 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 -24
- package/src/globals.ts +0 -22
package/dist/es/zenflux-core.js
CHANGED
|
@@ -1,43 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
var name = "@zenflux/core";
|
|
2
|
+
var version = "0.0.0-abc.20";
|
|
3
|
+
var description = "ZenFlux core";
|
|
4
|
+
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
5
|
+
var scripts = {
|
|
6
|
+
test: "export flow_modules_logger=off && jest",
|
|
7
|
+
build: "rollup --config rollup.config.ts --configPlugin typescript",
|
|
8
|
+
watch: "rollup --config rollup.config.ts --configPlugin typescript --watch"
|
|
9
|
+
};
|
|
10
|
+
var repository = {
|
|
11
|
+
type: "git",
|
|
12
|
+
url: "git+https://github.com/zenflux/core.git"
|
|
13
|
+
};
|
|
14
|
+
var keywords = [
|
|
15
|
+
"zenflux",
|
|
16
|
+
"zen",
|
|
17
|
+
"flux",
|
|
18
|
+
"commands",
|
|
19
|
+
"manager",
|
|
20
|
+
"commands manager"
|
|
21
|
+
];
|
|
22
|
+
var files = [
|
|
23
|
+
"dist",
|
|
24
|
+
"src",
|
|
25
|
+
"types"
|
|
26
|
+
];
|
|
27
|
+
var license = "MIT";
|
|
28
|
+
var main = "dist/cjs/zenflux-core.js";
|
|
29
|
+
var unpkg = "dist/umd/zenflux-core.js";
|
|
30
|
+
var module = "dist/es/zenflux-core.js";
|
|
31
|
+
var types = "types/index.d.ts";
|
|
32
|
+
var devDependencies = {
|
|
33
|
+
"@babel/core": "^7.20.7",
|
|
34
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
35
|
+
"@babel/preset-env": "^7.20.2",
|
|
36
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
37
|
+
"@babel/runtime": "^7.20.7",
|
|
38
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
39
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
41
|
+
"@rollup/plugin-replace": "^5.0.2",
|
|
42
|
+
"@rollup/plugin-terser": "^0.2.1",
|
|
43
|
+
"@rollup/plugin-typescript": "^10.0.1",
|
|
44
|
+
"@types/jest": "^29.2.5",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
46
|
+
"@typescript-eslint/parser": "^5.48.0",
|
|
47
|
+
"babel-jest": "^29.3.1",
|
|
48
|
+
rollup: "^3.9.1",
|
|
49
|
+
"ts-jest": "^29.0.3",
|
|
50
|
+
tslib: "^2.4.1"
|
|
51
|
+
};
|
|
52
|
+
var dependencies = {
|
|
53
|
+
"@babel/runtime": "^7.19.0"
|
|
54
|
+
};
|
|
55
|
+
var pkg = {
|
|
56
|
+
name: name,
|
|
57
|
+
version: version,
|
|
58
|
+
description: description,
|
|
59
|
+
author: author,
|
|
60
|
+
scripts: scripts,
|
|
61
|
+
repository: repository,
|
|
62
|
+
keywords: keywords,
|
|
63
|
+
files: files,
|
|
64
|
+
license: license,
|
|
65
|
+
main: main,
|
|
66
|
+
unpkg: unpkg,
|
|
67
|
+
module: module,
|
|
68
|
+
types: types,
|
|
69
|
+
devDependencies: devDependencies,
|
|
70
|
+
dependencies: dependencies
|
|
71
|
+
};
|
|
41
72
|
|
|
42
73
|
/**
|
|
43
74
|
* Function getCircularReplacer() : Reduce circular references.
|
|
@@ -393,194 +424,75 @@ class Logger {
|
|
|
393
424
|
}
|
|
394
425
|
}
|
|
395
426
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
* - Add validateArgs method or find something better.
|
|
401
|
-
*/
|
|
402
|
-
class CommandBase extends ObjectBase {
|
|
403
|
-
args = {};
|
|
404
|
-
options = {};
|
|
405
|
-
logger;
|
|
406
|
-
constructor(args = {}, options = {}) {
|
|
407
|
-
super();
|
|
408
|
-
const name = this.constructor.getName();
|
|
409
|
-
this.logger = new Logger(name, true, {
|
|
410
|
-
sameColor: true
|
|
411
|
-
});
|
|
412
|
-
this.logger.startWith({
|
|
413
|
-
args,
|
|
414
|
-
options
|
|
415
|
-
});
|
|
416
|
-
this.initialize(args, options);
|
|
417
|
-
}
|
|
418
|
-
initialize(args, options) {
|
|
419
|
-
this.args = args;
|
|
420
|
-
this.options = options;
|
|
421
|
-
}
|
|
422
|
-
apply(args = this.args, options = this.options) {
|
|
423
|
-
throw new ForceMethod(this, "apply");
|
|
424
|
-
}
|
|
425
|
-
async run() {
|
|
426
|
-
this.onBeforeApply && this.onBeforeApply();
|
|
427
|
-
const result = await this.apply(this.args, this.options);
|
|
428
|
-
this.onAfterApply && this.onAfterApply();
|
|
429
|
-
return result;
|
|
430
|
-
}
|
|
431
|
-
getArgs() {
|
|
432
|
-
return this.args;
|
|
433
|
-
}
|
|
434
|
-
getOptions() {
|
|
435
|
-
return this.options;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
427
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
428
|
+
__proto__: null,
|
|
429
|
+
Logger: Logger
|
|
430
|
+
});
|
|
438
431
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
* */
|
|
443
|
-
class CommandPublic extends CommandBase {
|
|
444
|
-
static getName() {
|
|
445
|
-
return 'Core/CommandBases/CommandPublic';
|
|
432
|
+
class CommandAlreadyRegistered extends Error {
|
|
433
|
+
constructor(command) {
|
|
434
|
+
super(`Command: '${command.getName()}' is already registered`);
|
|
446
435
|
}
|
|
447
436
|
}
|
|
448
437
|
|
|
449
438
|
/**
|
|
450
439
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
451
|
-
* @description: Each data command should represent a final REST endpoint.
|
|
452
440
|
*/
|
|
453
|
-
class
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
|
|
459
|
-
* @example
|
|
460
|
-
* ```
|
|
461
|
-
* args = { query: { id: 1 } };
|
|
462
|
-
* getEndpoint() = '/api/v1/users/{id}';
|
|
463
|
-
* result = '/api/v1/users/1';
|
|
464
|
-
* ```
|
|
465
|
-
*/
|
|
466
|
-
getEndpoint() {
|
|
467
|
-
throw new ForceMethod(this, 'getEndpoint');
|
|
468
|
-
}
|
|
469
|
-
apply(args = this.args, options = this.options) {
|
|
470
|
-
const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
471
|
-
return __ZEN_MANAGERS__.data.getClient().fetch(endpoint, __ZEN_MANAGERS__.data.currentHttpMethod, args || null);
|
|
472
|
-
}
|
|
473
|
-
applyEndpointFormat(endpoint, data = {}) {
|
|
474
|
-
// Replace query with `magic` placeholders.
|
|
475
|
-
if (endpoint.includes('{')) {
|
|
476
|
-
endpoint = endpoint.split('/').map(endpointPart => {
|
|
477
|
-
const match = endpointPart.match('\\{(.*?)\\}');
|
|
478
|
-
if (match?.length && 'undefined' !== typeof data[match[1]]) {
|
|
479
|
-
return data[match[1]];
|
|
480
|
-
}
|
|
481
|
-
return endpointPart;
|
|
482
|
-
}).join('/');
|
|
483
|
-
}
|
|
484
|
-
return endpoint;
|
|
441
|
+
class CommandNotFound extends Error {
|
|
442
|
+
constructor(command) {
|
|
443
|
+
super(`Command: '${command}' is not found`);
|
|
485
444
|
}
|
|
486
445
|
}
|
|
487
446
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
*/
|
|
492
|
-
class CommandInternal extends CommandBase {
|
|
493
|
-
static getName() {
|
|
494
|
-
return 'Core/CommandBases/CommandInternal';
|
|
447
|
+
class ControllerAlreadyRegistered extends Error {
|
|
448
|
+
constructor(controller) {
|
|
449
|
+
super(`Controller: '${controller.getName()}' is already registered`);
|
|
495
450
|
}
|
|
496
451
|
}
|
|
497
452
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
var index$5 = /*#__PURE__*/Object.freeze({
|
|
503
|
-
__proto__: null,
|
|
504
|
-
CommandBase: CommandBase,
|
|
505
|
-
CommandData: CommandData,
|
|
506
|
-
CommandInternal: CommandInternal,
|
|
507
|
-
CommandPublic: CommandPublic
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
512
|
-
* @description: Responsible for commands, Aka ( CommandsSpace ).
|
|
513
|
-
*/
|
|
514
|
-
class Controller extends ObjectBase {
|
|
515
|
-
commands;
|
|
516
|
-
data;
|
|
517
|
-
internal;
|
|
518
|
-
static getName() {
|
|
519
|
-
return 'Core/Core/Controller';
|
|
520
|
-
}
|
|
521
|
-
constructor() {
|
|
522
|
-
super();
|
|
523
|
-
this.initialize();
|
|
524
|
-
}
|
|
525
|
-
initialize() {
|
|
526
|
-
this.register();
|
|
527
|
-
this.setupHooks && this.setupHooks();
|
|
528
|
-
}
|
|
529
|
-
register() {
|
|
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);
|
|
533
|
-
}
|
|
534
|
-
getCommands() {
|
|
535
|
-
return {};
|
|
536
|
-
}
|
|
537
|
-
getData() {
|
|
538
|
-
return {};
|
|
453
|
+
class ForceMethodBase extends Error {
|
|
454
|
+
constructor(className, methodName) {
|
|
455
|
+
super(`ForeMethod implementation: at '${className}' method: '${methodName}'`);
|
|
539
456
|
}
|
|
540
|
-
|
|
541
|
-
|
|
457
|
+
}
|
|
458
|
+
class ForceMethod extends Error {
|
|
459
|
+
constructor(context, methodName) {
|
|
460
|
+
super(`ForeMethod implementation: at '${context.getName()}' method: '${methodName}'`);
|
|
542
461
|
}
|
|
543
462
|
}
|
|
544
463
|
|
|
545
464
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
546
465
|
__proto__: null,
|
|
547
|
-
|
|
548
|
-
|
|
466
|
+
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
467
|
+
CommandNotFound: CommandNotFound,
|
|
468
|
+
ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
469
|
+
ForceMethod: ForceMethod
|
|
549
470
|
});
|
|
550
471
|
|
|
551
|
-
class CommandAlreadyRegistered extends Error {
|
|
552
|
-
constructor(command) {
|
|
553
|
-
super(`Command: '${command.getName()}' is already registered`);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
472
|
/**
|
|
558
473
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
474
|
+
* @description: is base class/object for all classes, responsible for: 'getName', implementation.
|
|
559
475
|
*/
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
476
|
+
let IdCounter = 0;
|
|
477
|
+
/**
|
|
478
|
+
* Base class 4 *
|
|
479
|
+
*/
|
|
480
|
+
class ObjectBase {
|
|
481
|
+
virtualId = 0;
|
|
482
|
+
static getName() {
|
|
483
|
+
throw new ForceMethodBase("ObjectBase", "getName");
|
|
484
|
+
}
|
|
485
|
+
constructor() {
|
|
486
|
+
this.virtualId = IdCounter;
|
|
487
|
+
APIIncreaseIdCounter();
|
|
563
488
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
class ControllerAlreadyRegistered extends Error {
|
|
567
|
-
constructor(controller) {
|
|
568
|
-
super(`Controller: '${controller.getName()}' is already registered`);
|
|
489
|
+
getName() {
|
|
490
|
+
return this.constructor.getName();
|
|
569
491
|
}
|
|
570
492
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
575
|
-
CommandNotFound: CommandNotFound,
|
|
576
|
-
ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
577
|
-
ForceMethod: ForceMethod
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
var index$2 = /*#__PURE__*/Object.freeze({
|
|
581
|
-
__proto__: null,
|
|
582
|
-
Logger: Logger
|
|
583
|
-
});
|
|
493
|
+
function APIIncreaseIdCounter() {
|
|
494
|
+
return IdCounter++;
|
|
495
|
+
}
|
|
584
496
|
|
|
585
497
|
/**
|
|
586
498
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
@@ -947,31 +859,197 @@ class Internal extends Commands {
|
|
|
947
859
|
/**
|
|
948
860
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
949
861
|
*/
|
|
862
|
+
const afterInitializeCallbacks = [];
|
|
950
863
|
function initialize(config) {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
864
|
+
commands = new Commands();
|
|
865
|
+
controllers = new Controllers();
|
|
866
|
+
data = new Data(config);
|
|
867
|
+
internal = new Internal();
|
|
955
868
|
}
|
|
956
869
|
function destroy() {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
870
|
+
commands = {};
|
|
871
|
+
controllers = {};
|
|
872
|
+
data = {};
|
|
873
|
+
internal = {};
|
|
961
874
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
875
|
+
var commands = {};
|
|
876
|
+
var controllers = {};
|
|
877
|
+
var data = {};
|
|
878
|
+
var internal = {};
|
|
879
|
+
/*
|
|
880
|
+
__ZEN_MANAGERS__.initialize = initialize;
|
|
881
|
+
__ZEN_MANAGERS__.destroy = destroy;
|
|
966
882
|
|
|
967
|
-
var
|
|
883
|
+
export var commands = __ZEN_MANAGERS__.commands;
|
|
884
|
+
export var controllers = __ZEN_MANAGERS__.controllers;
|
|
885
|
+
export var data = __ZEN_MANAGERS__.data;
|
|
886
|
+
export var internal = __ZEN_MANAGERS__.internal;
|
|
887
|
+
*/
|
|
888
|
+
|
|
889
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
968
890
|
__proto__: null,
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
891
|
+
afterInitializeCallbacks: afterInitializeCallbacks,
|
|
892
|
+
get commands () { return commands; },
|
|
893
|
+
get controllers () { return controllers; },
|
|
894
|
+
get data () { return data; },
|
|
972
895
|
destroy: destroy,
|
|
973
896
|
initialize: initialize,
|
|
974
|
-
internal
|
|
897
|
+
get internal () { return internal; }
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
902
|
+
* @description: Base for all commands, they are all will be managed by the `Commands` managers.
|
|
903
|
+
* @TODO
|
|
904
|
+
* - Add validateArgs method or find something better.
|
|
905
|
+
*/
|
|
906
|
+
class CommandBase extends ObjectBase {
|
|
907
|
+
args = {};
|
|
908
|
+
options = {};
|
|
909
|
+
logger;
|
|
910
|
+
constructor(args = {}, options = {}) {
|
|
911
|
+
super();
|
|
912
|
+
const name = this.constructor.getName();
|
|
913
|
+
this.logger = new Logger(name, true, {
|
|
914
|
+
sameColor: true
|
|
915
|
+
});
|
|
916
|
+
this.logger.startWith({
|
|
917
|
+
args,
|
|
918
|
+
options
|
|
919
|
+
});
|
|
920
|
+
this.initialize(args, options);
|
|
921
|
+
}
|
|
922
|
+
initialize(args, options) {
|
|
923
|
+
this.args = args;
|
|
924
|
+
this.options = options;
|
|
925
|
+
}
|
|
926
|
+
apply(args = this.args, options = this.options) {
|
|
927
|
+
throw new ForceMethod(this, "apply");
|
|
928
|
+
}
|
|
929
|
+
async run() {
|
|
930
|
+
this.onBeforeApply && this.onBeforeApply();
|
|
931
|
+
const result = await this.apply(this.args, this.options);
|
|
932
|
+
this.onAfterApply && this.onAfterApply();
|
|
933
|
+
return result;
|
|
934
|
+
}
|
|
935
|
+
getArgs() {
|
|
936
|
+
return this.args;
|
|
937
|
+
}
|
|
938
|
+
getOptions() {
|
|
939
|
+
return this.options;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
945
|
+
* @description: CommandPublic represents a USER action, every class which inherit from this class will USER action.
|
|
946
|
+
* */
|
|
947
|
+
class CommandPublic extends CommandBase {
|
|
948
|
+
static getName() {
|
|
949
|
+
return 'Core/CommandBases/CommandPublic';
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
955
|
+
* @description: Each data command should represent a final REST endpoint.
|
|
956
|
+
*/
|
|
957
|
+
class CommandData extends CommandBase {
|
|
958
|
+
static getName() {
|
|
959
|
+
return 'Core/CommandBases/CommandData';
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
|
|
963
|
+
* @example
|
|
964
|
+
* ```
|
|
965
|
+
* args = { query: { id: 1 } };
|
|
966
|
+
* getEndpoint() = '/api/v1/users/{id}';
|
|
967
|
+
* result = '/api/v1/users/1';
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
970
|
+
getEndpoint() {
|
|
971
|
+
throw new ForceMethod(this, 'getEndpoint');
|
|
972
|
+
}
|
|
973
|
+
apply(args = this.args, options = this.options) {
|
|
974
|
+
const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
975
|
+
return data.getClient().fetch(endpoint, data.currentHttpMethod, args || null);
|
|
976
|
+
}
|
|
977
|
+
applyEndpointFormat(endpoint, data = {}) {
|
|
978
|
+
// Replace query with `magic` placeholders.
|
|
979
|
+
if (endpoint.includes('{')) {
|
|
980
|
+
endpoint = endpoint.split('/').map(endpointPart => {
|
|
981
|
+
const match = endpointPart.match('\\{(.*?)\\}');
|
|
982
|
+
if (match?.length && 'undefined' !== typeof data[match[1]]) {
|
|
983
|
+
return data[match[1]];
|
|
984
|
+
}
|
|
985
|
+
return endpointPart;
|
|
986
|
+
}).join('/');
|
|
987
|
+
}
|
|
988
|
+
return endpoint;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
994
|
+
* @description: CommandInternal, is used when part of the logic needed to be in the command but not represent a user action.
|
|
995
|
+
*/
|
|
996
|
+
class CommandInternal extends CommandBase {
|
|
997
|
+
static getName() {
|
|
998
|
+
return 'Core/CommandBases/CommandInternal';
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1004
|
+
*/
|
|
1005
|
+
|
|
1006
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
1007
|
+
__proto__: null,
|
|
1008
|
+
CommandBase: CommandBase,
|
|
1009
|
+
CommandData: CommandData,
|
|
1010
|
+
CommandInternal: CommandInternal,
|
|
1011
|
+
CommandPublic: CommandPublic
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
1016
|
+
* @description: Responsible for commands, Aka ( CommandsSpace ).
|
|
1017
|
+
*/
|
|
1018
|
+
class Controller extends ObjectBase {
|
|
1019
|
+
commands;
|
|
1020
|
+
data;
|
|
1021
|
+
internal;
|
|
1022
|
+
static getName() {
|
|
1023
|
+
return 'Core/Core/Controller';
|
|
1024
|
+
}
|
|
1025
|
+
constructor() {
|
|
1026
|
+
super();
|
|
1027
|
+
this.initialize();
|
|
1028
|
+
}
|
|
1029
|
+
initialize() {
|
|
1030
|
+
this.register();
|
|
1031
|
+
this.setupHooks && this.setupHooks();
|
|
1032
|
+
}
|
|
1033
|
+
register() {
|
|
1034
|
+
this.commands = commands.register(this.getCommands(), this);
|
|
1035
|
+
this.data = data.register(this.getData(), this);
|
|
1036
|
+
this.internal = internal.register(this.getInternal(), this);
|
|
1037
|
+
}
|
|
1038
|
+
getCommands() {
|
|
1039
|
+
return {};
|
|
1040
|
+
}
|
|
1041
|
+
getData() {
|
|
1042
|
+
return {};
|
|
1043
|
+
}
|
|
1044
|
+
getInternal() {
|
|
1045
|
+
return {};
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1050
|
+
__proto__: null,
|
|
1051
|
+
Controller: Controller,
|
|
1052
|
+
ObjectBase: ObjectBase
|
|
975
1053
|
});
|
|
976
1054
|
|
|
977
1055
|
/**
|
|
@@ -992,87 +1070,15 @@ Internal: Internal
|
|
|
992
1070
|
|
|
993
1071
|
var exported = /*#__PURE__*/Object.freeze({
|
|
994
1072
|
__proto__: null,
|
|
995
|
-
commandBases: index$
|
|
996
|
-
core: index$
|
|
997
|
-
errors: index$
|
|
1073
|
+
commandBases: index$2,
|
|
1074
|
+
core: index$1,
|
|
1075
|
+
errors: index$4,
|
|
998
1076
|
managerBases: index,
|
|
999
|
-
managers: index$
|
|
1000
|
-
modules: index$
|
|
1077
|
+
managers: index$3,
|
|
1078
|
+
modules: index$5,
|
|
1001
1079
|
utils: index$6
|
|
1002
1080
|
});
|
|
1003
1081
|
|
|
1004
|
-
var name = "@zenflux/core";
|
|
1005
|
-
var version = "0.0.0-abc.7";
|
|
1006
|
-
var description = "ZenFlux core";
|
|
1007
|
-
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
1008
|
-
var scripts = {
|
|
1009
|
-
test: "export flow_modules_logger=off && jest",
|
|
1010
|
-
build: "rollup --config rollup.config.ts --configPlugin typescript",
|
|
1011
|
-
watch: "rollup --config rollup.config.ts --configPlugin typescript --watch"
|
|
1012
|
-
};
|
|
1013
|
-
var repository = {
|
|
1014
|
-
type: "git",
|
|
1015
|
-
url: "git+https://github.com/zenflux/core.git"
|
|
1016
|
-
};
|
|
1017
|
-
var keywords = [
|
|
1018
|
-
"zenflux",
|
|
1019
|
-
"zen",
|
|
1020
|
-
"flux",
|
|
1021
|
-
"commands",
|
|
1022
|
-
"manager",
|
|
1023
|
-
"commands manager"
|
|
1024
|
-
];
|
|
1025
|
-
var files = [
|
|
1026
|
-
"dist",
|
|
1027
|
-
"src",
|
|
1028
|
-
"types"
|
|
1029
|
-
];
|
|
1030
|
-
var license = "MIT";
|
|
1031
|
-
var main = "dist/cjs/zenflux-core.js";
|
|
1032
|
-
var unpkg = "dist/umd/zenflux-core.js";
|
|
1033
|
-
var module = "dist/es/zenflux-core.js";
|
|
1034
|
-
var types = "types/index.d.ts";
|
|
1035
|
-
var devDependencies = {
|
|
1036
|
-
"@babel/core": "^7.20.7",
|
|
1037
|
-
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
1038
|
-
"@babel/preset-env": "^7.20.2",
|
|
1039
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
1040
|
-
"@babel/runtime": "^7.20.7",
|
|
1041
|
-
"@rollup/plugin-babel": "^6.0.3",
|
|
1042
|
-
"@rollup/plugin-json": "^6.0.0",
|
|
1043
|
-
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
1044
|
-
"@rollup/plugin-replace": "^5.0.2",
|
|
1045
|
-
"@rollup/plugin-terser": "^0.2.1",
|
|
1046
|
-
"@rollup/plugin-typescript": "^10.0.1",
|
|
1047
|
-
"@types/jest": "^29.2.5",
|
|
1048
|
-
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
1049
|
-
"@typescript-eslint/parser": "^5.48.0",
|
|
1050
|
-
"babel-jest": "^29.3.1",
|
|
1051
|
-
rollup: "^3.9.1",
|
|
1052
|
-
"ts-jest": "^29.0.3",
|
|
1053
|
-
tslib: "^2.4.1"
|
|
1054
|
-
};
|
|
1055
|
-
var dependencies = {
|
|
1056
|
-
"@babel/runtime": "^7.19.0"
|
|
1057
|
-
};
|
|
1058
|
-
var pkg = {
|
|
1059
|
-
name: name,
|
|
1060
|
-
version: version,
|
|
1061
|
-
description: description,
|
|
1062
|
-
author: author,
|
|
1063
|
-
scripts: scripts,
|
|
1064
|
-
repository: repository,
|
|
1065
|
-
keywords: keywords,
|
|
1066
|
-
files: files,
|
|
1067
|
-
license: license,
|
|
1068
|
-
main: main,
|
|
1069
|
-
unpkg: unpkg,
|
|
1070
|
-
module: module,
|
|
1071
|
-
types: types,
|
|
1072
|
-
devDependencies: devDependencies,
|
|
1073
|
-
dependencies: dependencies
|
|
1074
|
-
};
|
|
1075
|
-
|
|
1076
1082
|
let isInitialized = false;
|
|
1077
1083
|
function errorInitTwice() {
|
|
1078
1084
|
if (isInitialized) {
|
|
@@ -1083,14 +1089,12 @@ errorInitTwice();
|
|
|
1083
1089
|
let config = {
|
|
1084
1090
|
version: pkg.version
|
|
1085
1091
|
};
|
|
1086
|
-
const afterInitializeCallbacks = [];
|
|
1087
1092
|
const CoreAPI = {
|
|
1088
1093
|
initialize: configuration => {
|
|
1089
1094
|
errorInitTwice();
|
|
1090
1095
|
config = configuration || config;
|
|
1091
1096
|
initialize(config);
|
|
1092
1097
|
isInitialized = true;
|
|
1093
|
-
afterInitializeCallbacks.forEach(callback => callback());
|
|
1094
1098
|
},
|
|
1095
1099
|
destroy: () => {
|
|
1096
1100
|
destroy();
|
|
@@ -1100,10 +1104,9 @@ const CoreAPI = {
|
|
|
1100
1104
|
afterInitializeCallbacks.push(callback);
|
|
1101
1105
|
},
|
|
1102
1106
|
config,
|
|
1103
|
-
...exported
|
|
1104
|
-
managers: typeof __ZEN_MANAGERS__ !== 'undefined' ? __ZEN_MANAGERS__ : undefined
|
|
1107
|
+
...exported
|
|
1105
1108
|
};
|
|
1106
1109
|
// TODO: Make it available only for development.
|
|
1107
1110
|
if (!globalThis?.ZenCore) globalThis.ZenCore = CoreAPI;
|
|
1108
1111
|
|
|
1109
|
-
export { index$
|
|
1112
|
+
export { index$2 as commandBases, index$1 as core, CoreAPI as default, index$4 as errors, index as managerBases, index$3 as managers, index$5 as modules, index$6 as utils };
|