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