mnemonica 0.9.94 → 0.9.98
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/README.md +40 -13
- package/build/api/errors/bindedMethodErrorHandler.js +50 -50
- package/build/api/errors/exceptionConstructor.js +98 -98
- package/build/api/errors/index.d.ts +1 -1
- package/build/api/errors/index.js +45 -45
- package/build/api/errors/throwModificationError.js +94 -94
- package/build/api/hooks/flowCheckers.d.ts +1 -1
- package/build/api/hooks/flowCheckers.js +9 -9
- package/build/api/hooks/index.js +7 -7
- package/build/api/hooks/invokeHook.js +44 -44
- package/build/api/hooks/registerHook.js +17 -17
- package/build/api/index.d.ts +1 -1
- package/build/api/index.js +9 -9
- package/build/api/types/InstanceCreator.d.ts +1 -1
- package/build/api/types/InstanceCreator.js +237 -237
- package/build/api/types/InstanceModificator.js +8 -8
- package/build/api/types/Mnemosyne.d.ts +2 -2
- package/build/api/types/Mnemosyne.js +127 -127
- package/build/api/types/TypeProxy.js +132 -132
- package/build/api/types/addProps.js +60 -60
- package/build/api/types/compileNewModificatorFunctionBody.d.ts +1 -1
- package/build/api/types/compileNewModificatorFunctionBody.js +37 -27
- package/build/api/types/createInstanceModificator.js +26 -27
- package/build/api/types/createInstanceModificator200XthWay.js +29 -30
- package/build/api/types/index.js +157 -157
- package/build/api/types/obeyConstructor.js +23 -23
- package/build/api/utils/index.d.ts +20 -8
- package/build/api/utils/index.js +122 -122
- package/build/constants/index.js +61 -61
- package/build/descriptors/errors/index.js +7 -7
- package/build/descriptors/index.js +5 -5
- package/build/descriptors/namespaces/index.js +70 -70
- package/build/descriptors/types/index.js +141 -141
- package/build/index.d.ts +39 -5
- package/build/index.js +63 -32
- package/build/types/index.d.ts +16 -17
- package/build/types/index.js +1 -1
- package/build/utils/collectConstructors.js +50 -50
- package/build/utils/defineStackCleaner.js +7 -7
- package/build/utils/extract.js +14 -14
- package/build/utils/hop.js +1 -1
- package/build/utils/index.js +27 -27
- package/build/utils/merge.js +13 -13
- package/build/utils/parent.js +15 -15
- package/build/utils/parse.js +40 -40
- package/build/utils/pick.js +19 -19
- package/build/utils/toJSON.js +25 -25
- package/package.json +92 -92
|
@@ -1,103 +1,103 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
Object.defineProperty(exports,
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.throwModificationError = void 0;
|
|
4
|
-
const constants_1 = require(
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
5
|
const { odp, SymbolReplaceGaia, } = constants_1.constants;
|
|
6
|
-
const errors_1 = require(
|
|
6
|
+
const errors_1 = require("../../descriptors/errors");
|
|
7
7
|
const { BASE_MNEMONICA_ERROR } = errors_1.ErrorsTypes;
|
|
8
|
-
const _1 = require(
|
|
9
|
-
const utils_1 = require(
|
|
8
|
+
const _1 = require("./");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
10
|
const { makeFakeModificatorType } = utils_1.default;
|
|
11
|
-
const utils_2 = require(
|
|
11
|
+
const utils_2 = require("../../utils");
|
|
12
12
|
const { parse } = utils_2.utils;
|
|
13
|
-
const InstanceModificator_1 = require(
|
|
13
|
+
const InstanceModificator_1 = require("../types/InstanceModificator");
|
|
14
14
|
const throwModificationError = function (error) {
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
15
|
+
const self = this;
|
|
16
|
+
const { TypeName, type: { stack: typeStack }, args } = self;
|
|
17
|
+
const exceptionReason = error.exceptionReason || error;
|
|
18
|
+
if (error.exceptionReason !== undefined) {
|
|
19
|
+
error.reasons.push(error.exceptionReason);
|
|
20
|
+
error.surplus.push(error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
odp(error, 'exceptionReason', {
|
|
24
|
+
get() {
|
|
25
|
+
return exceptionReason;
|
|
26
|
+
},
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
const reasons = [exceptionReason];
|
|
30
|
+
odp(error, 'reasons', {
|
|
31
|
+
get() {
|
|
32
|
+
return reasons;
|
|
33
|
+
},
|
|
34
|
+
enumerable: true
|
|
35
|
+
});
|
|
36
|
+
const surplus = [];
|
|
37
|
+
odp(error, 'surplus', {
|
|
38
|
+
get() {
|
|
39
|
+
return surplus;
|
|
40
|
+
},
|
|
41
|
+
enumerable: true
|
|
42
|
+
});
|
|
43
|
+
self.ModificatorType = makeFakeModificatorType(TypeName);
|
|
44
|
+
self.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(self);
|
|
45
|
+
const erroredInstance = new self.InstanceModificator();
|
|
46
|
+
erroredInstance[SymbolReplaceGaia](error);
|
|
47
|
+
const stack = [];
|
|
48
|
+
if (error instanceof BASE_MNEMONICA_ERROR) {
|
|
49
|
+
stack.push(error.stack);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const title = `\n<-- creation of [ ${TypeName} ] traced -->`;
|
|
53
|
+
_1.getStack.call(erroredInstance, title, [], exports.throwModificationError);
|
|
54
|
+
stack.push(...erroredInstance.stack);
|
|
55
|
+
const errorStack = error.stack.split('\n');
|
|
56
|
+
stack.push('<-- with the following error -->');
|
|
57
|
+
errorStack.forEach((line) => {
|
|
58
|
+
if (!stack.includes(line)) {
|
|
59
|
+
stack.push(line);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
stack.push('\n<-- of constructor definitions stack -->');
|
|
63
|
+
stack.push(...typeStack);
|
|
64
|
+
}
|
|
65
|
+
erroredInstance.stack = (0, _1.cleanupStack)(stack).join('\n');
|
|
66
|
+
self.inheritedInstance = erroredInstance;
|
|
67
|
+
const results = self.invokePostHooks();
|
|
68
|
+
const { type, collection, namespace } = results;
|
|
69
|
+
if (type.has(true) || collection.has(true) || namespace.has(true)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
odp(erroredInstance, 'args', {
|
|
73
|
+
get() {
|
|
74
|
+
return args;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
odp(erroredInstance, 'originalError', {
|
|
78
|
+
get() {
|
|
79
|
+
return error;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
odp(erroredInstance, 'instance', {
|
|
83
|
+
get() {
|
|
84
|
+
return erroredInstance;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
odp(erroredInstance, 'extract', {
|
|
88
|
+
get() {
|
|
89
|
+
return () => {
|
|
90
|
+
return erroredInstance.__self__.extract();
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
odp(erroredInstance, 'parse', {
|
|
95
|
+
get() {
|
|
96
|
+
return () => {
|
|
97
|
+
return parse(erroredInstance);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
throw erroredInstance;
|
|
102
102
|
};
|
|
103
103
|
exports.throwModificationError = throwModificationError;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const flowCheckers: WeakMap<object, any>;
|
|
2
|
-
export declare const registerFlowChecker: (this: any, cb:
|
|
2
|
+
export declare const registerFlowChecker: (this: any, cb: () => unknown) => void;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
Object.defineProperty(exports,
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerFlowChecker = exports.flowCheckers = void 0;
|
|
4
|
-
const errors_1 = require(
|
|
4
|
+
const errors_1 = require("../../descriptors/errors");
|
|
5
5
|
const { MISSING_CALLBACK_ARGUMENT, FLOW_CHECKER_REDEFINITION, } = errors_1.ErrorsTypes;
|
|
6
6
|
exports.flowCheckers = new WeakMap();
|
|
7
7
|
const registerFlowChecker = function (cb) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
if (typeof cb !== 'function') {
|
|
9
|
+
throw new MISSING_CALLBACK_ARGUMENT;
|
|
10
|
+
}
|
|
11
|
+
if (exports.flowCheckers.has(this)) {
|
|
12
|
+
throw new FLOW_CHECKER_REDEFINITION;
|
|
13
|
+
}
|
|
14
|
+
exports.flowCheckers.set(this, cb);
|
|
15
15
|
};
|
|
16
16
|
exports.registerFlowChecker = registerFlowChecker;
|
package/build/api/hooks/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
Object.defineProperty(exports,
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerFlowChecker = exports.registerHook = exports.invokeHook = void 0;
|
|
4
|
-
var invokeHook_1 = require(
|
|
5
|
-
Object.defineProperty(exports,
|
|
6
|
-
var registerHook_1 = require(
|
|
7
|
-
Object.defineProperty(exports,
|
|
8
|
-
var flowCheckers_1 = require(
|
|
9
|
-
Object.defineProperty(exports,
|
|
4
|
+
var invokeHook_1 = require("./invokeHook");
|
|
5
|
+
Object.defineProperty(exports, "invokeHook", { enumerable: true, get: function () { return invokeHook_1.invokeHook; } });
|
|
6
|
+
var registerHook_1 = require("./registerHook");
|
|
7
|
+
Object.defineProperty(exports, "registerHook", { enumerable: true, get: function () { return registerHook_1.registerHook; } });
|
|
8
|
+
var flowCheckers_1 = require("./flowCheckers");
|
|
9
|
+
Object.defineProperty(exports, "registerFlowChecker", { enumerable: true, get: function () { return flowCheckers_1.registerFlowChecker; } });
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
Object.defineProperty(exports,
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.invokeHook = void 0;
|
|
4
|
-
const constants_1 = require(
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
5
|
const { MNEMONICA, } = constants_1.constants;
|
|
6
|
-
const flowCheckers_1 = require(
|
|
7
|
-
const hop_1 = require(
|
|
6
|
+
const flowCheckers_1 = require("./flowCheckers");
|
|
7
|
+
const hop_1 = require("../../utils/hop");
|
|
8
8
|
const invokeHook = function (hookType, opts) {
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
9
|
+
const { type, existentInstance, inheritedInstance, args, creator } = opts;
|
|
10
|
+
const invocationResults = new Set();
|
|
11
|
+
const self = this;
|
|
12
|
+
if ((0, hop_1.hop)(self.hooks, hookType)) {
|
|
13
|
+
const { TypeName, } = type;
|
|
14
|
+
const hookArgs = {
|
|
15
|
+
type,
|
|
16
|
+
TypeName,
|
|
17
|
+
existentInstance: existentInstance.constructor.name === MNEMONICA ?
|
|
18
|
+
null : existentInstance,
|
|
19
|
+
args,
|
|
20
|
+
};
|
|
21
|
+
if (typeof inheritedInstance === 'object') {
|
|
22
|
+
Object.assign(hookArgs, {
|
|
23
|
+
inheritedInstance,
|
|
24
|
+
bindMethod(name, method) {
|
|
25
|
+
creator.bindMethod(inheritedInstance, name, method);
|
|
26
|
+
},
|
|
27
|
+
bindProtoMethods() {
|
|
28
|
+
creator.bindProtoMethods();
|
|
29
|
+
},
|
|
30
|
+
throwModificationError(error) {
|
|
31
|
+
creator.throwModificationError(error);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
this.hooks[hookType].forEach((hook) => {
|
|
36
|
+
const result = hook.call(self, hookArgs);
|
|
37
|
+
invocationResults.add(result);
|
|
38
|
+
});
|
|
39
|
+
const flowChecker = flowCheckers_1.flowCheckers.get(this);
|
|
40
|
+
if (typeof flowChecker === 'function') {
|
|
41
|
+
flowChecker
|
|
42
|
+
.call(this, Object.assign({}, {
|
|
43
|
+
invocationResults,
|
|
44
|
+
hookType,
|
|
45
|
+
}, hookArgs));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return invocationResults;
|
|
49
49
|
};
|
|
50
50
|
exports.invokeHook = invokeHook;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
Object.defineProperty(exports,
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerHook = void 0;
|
|
4
|
-
const errors_1 = require(
|
|
4
|
+
const errors_1 = require("../../descriptors/errors");
|
|
5
5
|
const { WRONG_HOOK_TYPE, MISSING_HOOK_CALLBACK, } = errors_1.ErrorsTypes;
|
|
6
6
|
const hooksTypes = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
'preCreation',
|
|
8
|
+
'postCreation',
|
|
9
|
+
'creationError',
|
|
10
10
|
];
|
|
11
11
|
const registerHook = function (hookType, cb) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
if (!hooksTypes.includes(hookType)) {
|
|
13
|
+
throw new WRONG_HOOK_TYPE;
|
|
14
|
+
}
|
|
15
|
+
if (typeof cb !== 'function') {
|
|
16
|
+
throw new MISSING_HOOK_CALLBACK;
|
|
17
|
+
}
|
|
18
|
+
if (!this.hooks[hookType]) {
|
|
19
|
+
this.hooks[hookType] = new Set([cb]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.hooks[hookType].add(cb);
|
|
23
|
+
}
|
|
24
24
|
};
|
|
25
25
|
exports.registerHook = registerHook;
|
package/build/api/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const hooks: {
|
|
|
4
4
|
[index: string]: any;
|
|
5
5
|
}) => Set<unknown>;
|
|
6
6
|
registerHook: (this: any, hookType: string, cb: CallableFunction) => void;
|
|
7
|
-
registerFlowChecker: (this: any, cb:
|
|
7
|
+
registerFlowChecker: (this: any, cb: () => unknown) => void;
|
|
8
8
|
};
|
|
9
9
|
export declare const types: {
|
|
10
10
|
define: any;
|
package/build/api/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
Object.defineProperty(exports,
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.types = exports.hooks = exports.errors = void 0;
|
|
4
|
-
const hooks_1 = require(
|
|
5
|
-
const types_1 = require(
|
|
6
|
-
exports.errors = require(
|
|
4
|
+
const hooks_1 = require("./hooks");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
exports.errors = require("./errors");
|
|
7
7
|
exports.hooks = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
invokeHook: hooks_1.invokeHook,
|
|
9
|
+
registerHook: hooks_1.registerHook,
|
|
10
|
+
registerFlowChecker: hooks_1.registerFlowChecker,
|
|
11
11
|
};
|
|
12
12
|
exports.types = {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
define: types_1.define,
|
|
14
|
+
lookup: types_1.lookup,
|
|
15
15
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConstructorFunction } from '../../types';
|
|
2
2
|
export declare const InstanceCreator: ConstructorFunction<{
|
|
3
|
-
getExistentAsyncStack: (existentInstance:
|
|
3
|
+
getExistentAsyncStack: (existentInstance: import("../utils").asyncStack) => unknown;
|
|
4
4
|
postProcessing: (this: any, continuationOf: any) => void;
|
|
5
5
|
bindMethod: (this: any, instance: any, methodName: string, MethodItself: any) => void;
|
|
6
6
|
bindProtoMethods: (this: any) => void;
|