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