@zenflux/core 0.0.0-abc.2 → 0.0.0-abc.20
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 +323 -294
- package/dist/es/src/exports.d.ts +1 -0
- package/dist/es/src/globals.d.ts +3 -0
- package/dist/es/src/index.d.ts +1 -1
- package/dist/es/src/initializer.d.ts +3 -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 +13 -8
- package/dist/es/zenflux-core.js +318 -290
- 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 +1 -1
- package/src/core/controller.ts +1 -1
- package/src/exports.ts +1 -1
- package/src/index.ts +2 -1
- package/src/initializer.ts +8 -13
- 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 +36 -7
- package/types/index.d.ts +4 -1
package/dist/cjs/zenflux-core.js
CHANGED
|
@@ -2,41 +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
|
-
|
|
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
|
+
};
|
|
40
76
|
|
|
41
77
|
/**
|
|
42
78
|
* Function getCircularReplacer() : Reduce circular references.
|
|
@@ -84,7 +120,7 @@ const hexColorDelta = function (hex1, hex2) {
|
|
|
84
120
|
return (r + g + b) / 3;
|
|
85
121
|
};
|
|
86
122
|
|
|
87
|
-
var index$
|
|
123
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
88
124
|
__proto__: null,
|
|
89
125
|
getCircularReplacer: getCircularReplacer,
|
|
90
126
|
hexColorDelta: hexColorDelta
|
|
@@ -392,202 +428,76 @@ class Logger {
|
|
|
392
428
|
}
|
|
393
429
|
}
|
|
394
430
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
* - Add validateArgs method or find something better.
|
|
400
|
-
*/
|
|
401
|
-
class CommandBase extends ObjectBase {
|
|
402
|
-
args = {};
|
|
403
|
-
options = {};
|
|
404
|
-
logger;
|
|
405
|
-
constructor(args = {}, options = {}) {
|
|
406
|
-
super();
|
|
407
|
-
const name = this.constructor.getName();
|
|
408
|
-
this.logger = new Logger(name, true, {
|
|
409
|
-
sameColor: true
|
|
410
|
-
});
|
|
411
|
-
this.logger.startWith({
|
|
412
|
-
args,
|
|
413
|
-
options
|
|
414
|
-
});
|
|
415
|
-
this.initialize(args, options);
|
|
416
|
-
}
|
|
417
|
-
initialize(args, options) {
|
|
418
|
-
this.args = args;
|
|
419
|
-
this.options = options;
|
|
420
|
-
}
|
|
421
|
-
apply(args = this.args, options = this.options) {
|
|
422
|
-
throw new ForceMethod(this, "apply");
|
|
423
|
-
}
|
|
424
|
-
async run() {
|
|
425
|
-
this.onBeforeApply && this.onBeforeApply();
|
|
426
|
-
const result = await this.apply(this.args, this.options);
|
|
427
|
-
this.onAfterApply && this.onAfterApply();
|
|
428
|
-
return result;
|
|
429
|
-
}
|
|
430
|
-
getArgs() {
|
|
431
|
-
return this.args;
|
|
432
|
-
}
|
|
433
|
-
getOptions() {
|
|
434
|
-
return this.options;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
431
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
432
|
+
__proto__: null,
|
|
433
|
+
Logger: Logger
|
|
434
|
+
});
|
|
437
435
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
* */
|
|
442
|
-
class CommandPublic extends CommandBase {
|
|
443
|
-
static getName() {
|
|
444
|
-
return 'Core/CommandBases/CommandPublic';
|
|
436
|
+
class CommandAlreadyRegistered extends Error {
|
|
437
|
+
constructor(command) {
|
|
438
|
+
super(`Command: '${command.getName()}' is already registered`);
|
|
445
439
|
}
|
|
446
440
|
}
|
|
447
441
|
|
|
448
|
-
const managers = {
|
|
449
|
-
commands: {},
|
|
450
|
-
controllers: {},
|
|
451
|
-
data: {},
|
|
452
|
-
internal: {}
|
|
453
|
-
};
|
|
454
|
-
|
|
455
442
|
/**
|
|
456
443
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
457
|
-
* @description: Each data command should represent a final REST endpoint.
|
|
458
444
|
*/
|
|
459
|
-
class
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Function getEndpoint() : Override this method is required to determine endpoint and magic query params.
|
|
465
|
-
* @example
|
|
466
|
-
* ```
|
|
467
|
-
* args = { query: { id: 1 } };
|
|
468
|
-
* getEndpoint() = '/api/v1/users/{id}';
|
|
469
|
-
* result = '/api/v1/users/1';
|
|
470
|
-
* ```
|
|
471
|
-
*/
|
|
472
|
-
getEndpoint() {
|
|
473
|
-
throw new ForceMethod(this, 'getEndpoint');
|
|
474
|
-
}
|
|
475
|
-
apply(args = this.args, options = this.options) {
|
|
476
|
-
const endpoint = this.applyEndpointFormat(this.getEndpoint(), args);
|
|
477
|
-
return managers.data.getClient().fetch(endpoint, managers.data.currentHttpMethod, args || null);
|
|
478
|
-
}
|
|
479
|
-
applyEndpointFormat(endpoint, data = {}) {
|
|
480
|
-
// Replace query with `magic` placeholders.
|
|
481
|
-
if (endpoint.includes('{')) {
|
|
482
|
-
endpoint = endpoint.split('/').map(endpointPart => {
|
|
483
|
-
const match = endpointPart.match('\\{(.*?)\\}');
|
|
484
|
-
if (match?.length && 'undefined' !== typeof data[match[1]]) {
|
|
485
|
-
return data[match[1]];
|
|
486
|
-
}
|
|
487
|
-
return endpointPart;
|
|
488
|
-
}).join('/');
|
|
489
|
-
}
|
|
490
|
-
return endpoint;
|
|
445
|
+
class CommandNotFound extends Error {
|
|
446
|
+
constructor(command) {
|
|
447
|
+
super(`Command: '${command}' is not found`);
|
|
491
448
|
}
|
|
492
449
|
}
|
|
493
450
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
*/
|
|
498
|
-
class CommandInternal extends CommandBase {
|
|
499
|
-
static getName() {
|
|
500
|
-
return 'Core/CommandBases/CommandInternal';
|
|
451
|
+
class ControllerAlreadyRegistered extends Error {
|
|
452
|
+
constructor(controller) {
|
|
453
|
+
super(`Controller: '${controller.getName()}' is already registered`);
|
|
501
454
|
}
|
|
502
455
|
}
|
|
503
456
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
+
}
|
|
507
467
|
|
|
508
468
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
509
469
|
__proto__: null,
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
470
|
+
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
471
|
+
CommandNotFound: CommandNotFound,
|
|
472
|
+
ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
473
|
+
ForceMethod: ForceMethod
|
|
514
474
|
});
|
|
515
475
|
|
|
516
476
|
/**
|
|
517
477
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
518
|
-
* @description:
|
|
478
|
+
* @description: is base class/object for all classes, responsible for: 'getName', implementation.
|
|
519
479
|
*/
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
480
|
+
let IdCounter = 0;
|
|
481
|
+
/**
|
|
482
|
+
* Base class 4 *
|
|
483
|
+
*/
|
|
484
|
+
class ObjectBase {
|
|
485
|
+
virtualId = 0;
|
|
524
486
|
static getName() {
|
|
525
|
-
|
|
487
|
+
throw new ForceMethodBase("ObjectBase", "getName");
|
|
526
488
|
}
|
|
527
489
|
constructor() {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
initialize() {
|
|
532
|
-
this.register();
|
|
533
|
-
this.setupHooks && this.setupHooks();
|
|
534
|
-
}
|
|
535
|
-
register() {
|
|
536
|
-
this.commands = managers.commands.register(this.getCommands(), this);
|
|
537
|
-
this.data = managers.data.register(this.getData(), this);
|
|
538
|
-
this.internal = managers.internal.register(this.getInternal(), this);
|
|
539
|
-
}
|
|
540
|
-
getCommands() {
|
|
541
|
-
return {};
|
|
542
|
-
}
|
|
543
|
-
getData() {
|
|
544
|
-
return {};
|
|
545
|
-
}
|
|
546
|
-
getInternal() {
|
|
547
|
-
return {};
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
var index$3 = /*#__PURE__*/Object.freeze({
|
|
552
|
-
__proto__: null,
|
|
553
|
-
Controller: Controller,
|
|
554
|
-
ObjectBase: ObjectBase
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
class CommandAlreadyRegistered extends Error {
|
|
558
|
-
constructor(command) {
|
|
559
|
-
super(`Command: '${command.getName()}' is already registered`);
|
|
490
|
+
this.virtualId = IdCounter;
|
|
491
|
+
APIIncreaseIdCounter();
|
|
560
492
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
565
|
-
*/
|
|
566
|
-
class CommandNotFound extends Error {
|
|
567
|
-
constructor(command) {
|
|
568
|
-
super(`Command: '${command}' is not found`);
|
|
493
|
+
getName() {
|
|
494
|
+
return this.constructor.getName();
|
|
569
495
|
}
|
|
570
496
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
constructor(controller) {
|
|
574
|
-
super(`Controller: '${controller.getName()}' is already registered`);
|
|
575
|
-
}
|
|
497
|
+
function APIIncreaseIdCounter() {
|
|
498
|
+
return IdCounter++;
|
|
576
499
|
}
|
|
577
500
|
|
|
578
|
-
var index$2 = /*#__PURE__*/Object.freeze({
|
|
579
|
-
__proto__: null,
|
|
580
|
-
CommandAlreadyRegistered: CommandAlreadyRegistered,
|
|
581
|
-
CommandNotFound: CommandNotFound,
|
|
582
|
-
ControllerAlreadyRegistered: ControllerAlreadyRegistered,
|
|
583
|
-
ForceMethod: ForceMethod
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
var index$1 = /*#__PURE__*/Object.freeze({
|
|
587
|
-
__proto__: null,
|
|
588
|
-
Logger: Logger
|
|
589
|
-
});
|
|
590
|
-
|
|
591
501
|
/**
|
|
592
502
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
593
503
|
* @description: Responsible for manging/running/hooking commands.
|
|
@@ -950,6 +860,202 @@ class Internal extends Commands {
|
|
|
950
860
|
}
|
|
951
861
|
}
|
|
952
862
|
|
|
863
|
+
/**
|
|
864
|
+
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
865
|
+
*/
|
|
866
|
+
const afterInitializeCallbacks = [];
|
|
867
|
+
function initialize(config) {
|
|
868
|
+
commands = new Commands();
|
|
869
|
+
controllers = new Controllers();
|
|
870
|
+
data = new Data(config);
|
|
871
|
+
internal = new Internal();
|
|
872
|
+
}
|
|
873
|
+
function destroy() {
|
|
874
|
+
commands = {};
|
|
875
|
+
controllers = {};
|
|
876
|
+
data = {};
|
|
877
|
+
internal = {};
|
|
878
|
+
}
|
|
879
|
+
var commands = {};
|
|
880
|
+
var controllers = {};
|
|
881
|
+
var data = {};
|
|
882
|
+
var internal = {};
|
|
883
|
+
/*
|
|
884
|
+
__ZEN_MANAGERS__.initialize = initialize;
|
|
885
|
+
__ZEN_MANAGERS__.destroy = destroy;
|
|
886
|
+
|
|
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({
|
|
894
|
+
__proto__: null,
|
|
895
|
+
afterInitializeCallbacks: afterInitializeCallbacks,
|
|
896
|
+
get commands () { return commands; },
|
|
897
|
+
get controllers () { return controllers; },
|
|
898
|
+
get data () { return data; },
|
|
899
|
+
destroy: destroy,
|
|
900
|
+
initialize: initialize,
|
|
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
|
|
1057
|
+
});
|
|
1058
|
+
|
|
953
1059
|
/**
|
|
954
1060
|
* @author: Leonid Vinikov <leonidvinikov@gmail.com>
|
|
955
1061
|
*/
|
|
@@ -968,85 +1074,15 @@ Internal: Internal
|
|
|
968
1074
|
|
|
969
1075
|
var exported = /*#__PURE__*/Object.freeze({
|
|
970
1076
|
__proto__: null,
|
|
971
|
-
commandBases: index$
|
|
972
|
-
core: index$
|
|
973
|
-
errors: index$
|
|
1077
|
+
commandBases: index$2,
|
|
1078
|
+
core: index$1,
|
|
1079
|
+
errors: index$4,
|
|
974
1080
|
managerBases: index,
|
|
975
|
-
|
|
976
|
-
|
|
1081
|
+
managers: index$3,
|
|
1082
|
+
modules: index$5,
|
|
1083
|
+
utils: index$6
|
|
977
1084
|
});
|
|
978
1085
|
|
|
979
|
-
var name = "@zenflux/core";
|
|
980
|
-
var version = "0.0.0-abc.1";
|
|
981
|
-
var description = "ZenFlux core";
|
|
982
|
-
var author = "Leonid Vinikov <leonidvinikov@gmail.com> (https://github.com/iNewLegend)";
|
|
983
|
-
var scripts = {
|
|
984
|
-
test: "export flow_modules_logger=off && jest",
|
|
985
|
-
build: "rollup --config rollup.config.ts --configPlugin typescript"
|
|
986
|
-
};
|
|
987
|
-
var repository = {
|
|
988
|
-
type: "git",
|
|
989
|
-
url: "git+https://github.com/zenflux/core.git"
|
|
990
|
-
};
|
|
991
|
-
var keywords = [
|
|
992
|
-
"zenflux",
|
|
993
|
-
"zen",
|
|
994
|
-
"flux",
|
|
995
|
-
"commands",
|
|
996
|
-
"manager",
|
|
997
|
-
"commands manager"
|
|
998
|
-
];
|
|
999
|
-
var files = [
|
|
1000
|
-
"dist",
|
|
1001
|
-
"src",
|
|
1002
|
-
"types"
|
|
1003
|
-
];
|
|
1004
|
-
var license = "MIT";
|
|
1005
|
-
var main = "dist/cjs/zenflux-core.js";
|
|
1006
|
-
var unpkg = "dist/umd/zenflux-core.js";
|
|
1007
|
-
var module$1 = "dist/es/zenflux-core.js";
|
|
1008
|
-
var types = "types/index.d.ts";
|
|
1009
|
-
var devDependencies = {
|
|
1010
|
-
"@babel/core": "^7.20.7",
|
|
1011
|
-
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
1012
|
-
"@babel/preset-env": "^7.20.2",
|
|
1013
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
1014
|
-
"@babel/runtime": "^7.20.7",
|
|
1015
|
-
"@rollup/plugin-babel": "^6.0.3",
|
|
1016
|
-
"@rollup/plugin-json": "^6.0.0",
|
|
1017
|
-
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
1018
|
-
"@rollup/plugin-replace": "^5.0.2",
|
|
1019
|
-
"@rollup/plugin-terser": "^0.2.1",
|
|
1020
|
-
"@rollup/plugin-typescript": "^10.0.1",
|
|
1021
|
-
"@types/jest": "^29.2.5",
|
|
1022
|
-
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
1023
|
-
"@typescript-eslint/parser": "^5.48.0",
|
|
1024
|
-
"babel-jest": "^29.3.1",
|
|
1025
|
-
rollup: "^3.9.1",
|
|
1026
|
-
"ts-jest": "^29.0.3",
|
|
1027
|
-
tslib: "^2.4.1"
|
|
1028
|
-
};
|
|
1029
|
-
var dependencies = {
|
|
1030
|
-
"@babel/runtime": "^7.19.0"
|
|
1031
|
-
};
|
|
1032
|
-
var pkg = {
|
|
1033
|
-
name: name,
|
|
1034
|
-
version: version,
|
|
1035
|
-
description: description,
|
|
1036
|
-
author: author,
|
|
1037
|
-
scripts: scripts,
|
|
1038
|
-
repository: repository,
|
|
1039
|
-
keywords: keywords,
|
|
1040
|
-
files: files,
|
|
1041
|
-
license: license,
|
|
1042
|
-
main: main,
|
|
1043
|
-
unpkg: unpkg,
|
|
1044
|
-
module: module$1,
|
|
1045
|
-
types: types,
|
|
1046
|
-
devDependencies: devDependencies,
|
|
1047
|
-
dependencies: dependencies
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
1086
|
let isInitialized = false;
|
|
1051
1087
|
function errorInitTwice() {
|
|
1052
1088
|
if (isInitialized) {
|
|
@@ -1057,24 +1093,16 @@ errorInitTwice();
|
|
|
1057
1093
|
let config = {
|
|
1058
1094
|
version: pkg.version
|
|
1059
1095
|
};
|
|
1060
|
-
const afterInitializeCallbacks = [];
|
|
1061
1096
|
const CoreAPI = {
|
|
1062
1097
|
initialize: configuration => {
|
|
1063
1098
|
errorInitTwice();
|
|
1064
1099
|
config = configuration || config;
|
|
1065
|
-
|
|
1066
|
-
managers.controllers = new Controllers();
|
|
1067
|
-
managers.data = new Data(config);
|
|
1068
|
-
managers.internal = new Internal();
|
|
1100
|
+
initialize(config);
|
|
1069
1101
|
isInitialized = true;
|
|
1070
|
-
afterInitializeCallbacks.forEach(callback => callback());
|
|
1071
1102
|
},
|
|
1072
1103
|
destroy: () => {
|
|
1104
|
+
destroy();
|
|
1073
1105
|
isInitialized = false;
|
|
1074
|
-
managers.commands = {};
|
|
1075
|
-
managers.controllers = {};
|
|
1076
|
-
managers.data = {};
|
|
1077
|
-
managers.internal = {};
|
|
1078
1106
|
},
|
|
1079
1107
|
onAfterInitialize: callback => {
|
|
1080
1108
|
afterInitializeCallbacks.push(callback);
|
|
@@ -1085,10 +1113,11 @@ const CoreAPI = {
|
|
|
1085
1113
|
// TODO: Make it available only for development.
|
|
1086
1114
|
if (!globalThis?.ZenCore) globalThis.ZenCore = CoreAPI;
|
|
1087
1115
|
|
|
1088
|
-
exports.commandBases = index$
|
|
1089
|
-
exports.core = index$
|
|
1116
|
+
exports.commandBases = index$2;
|
|
1117
|
+
exports.core = index$1;
|
|
1090
1118
|
exports.default = CoreAPI;
|
|
1091
|
-
exports.errors = index$
|
|
1119
|
+
exports.errors = index$4;
|
|
1092
1120
|
exports.managerBases = index;
|
|
1093
|
-
exports.
|
|
1094
|
-
exports.
|
|
1121
|
+
exports.managers = index$3;
|
|
1122
|
+
exports.modules = index$5;
|
|
1123
|
+
exports.utils = index$6;
|