@prostojs/mate 0.1.10 → 0.1.12
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/mate.cjs.prod.js +17 -14
- package/dist/mate.d.ts +2 -0
- package/dist/mate.esm-bundler.js +17 -14
- package/dist/src/mate.d.ts +2 -0
- package/dist/src/mate.d.ts.map +1 -1
- package/dist/src/reflect.d.ts.map +1 -1
- package/dist/src/tests/mate.artifacts.d.ts +2 -0
- package/dist/src/tests/mate.artifacts.d.ts.map +1 -1
- package/dist/src/types.d.ts +4 -4
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -6
- package/dist/mate.esm-browser.prod.js +0 -1
- package/dist/mate.global.prod.js +0 -1
package/dist/mate.cjs.prod.js
CHANGED
|
@@ -11,15 +11,6 @@ function isConstructor(v) {
|
|
|
11
11
|
return typeof v === 'function' && Object.getOwnPropertyNames(v).includes('prototype') && !Object.getOwnPropertyNames(v).includes('caller') && !!v.name;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
15
|
-
|
|
16
|
-
function warn(text) {
|
|
17
|
-
console.log('[33m' + banner() + text + '[0m');
|
|
18
|
-
}
|
|
19
|
-
function logError(error) {
|
|
20
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
const classMetadata = {};
|
|
24
15
|
const paramMetadata = {};
|
|
25
16
|
const root = typeof global === 'object' ? global : typeof self === 'object' ? self : {};
|
|
@@ -56,19 +47,20 @@ else {
|
|
|
56
47
|
'metadata',
|
|
57
48
|
];
|
|
58
49
|
const target = root.Reflect;
|
|
59
|
-
let isOriginalReflectMetadata = true;
|
|
60
50
|
for (const func of funcs) {
|
|
61
51
|
if (typeof target[func] !== 'function') {
|
|
62
52
|
Object.defineProperty(target, func, { configurable: true, writable: true, value: _reflect[func] });
|
|
63
|
-
isOriginalReflectMetadata = false;
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
|
-
if (!isOriginalReflectMetadata) {
|
|
67
|
-
warn('A limited \'reflect-metadata\' implementation is used. In case of any issues include original \'reflect-metadata\' package and require it before any @prostojs/mate import.');
|
|
68
|
-
}
|
|
69
55
|
}
|
|
70
56
|
const Reflect$1 = _reflect;
|
|
71
57
|
|
|
58
|
+
const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
59
|
+
|
|
60
|
+
function logError(error) {
|
|
61
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
62
|
+
}
|
|
63
|
+
|
|
72
64
|
function panic(error) {
|
|
73
65
|
logError(error);
|
|
74
66
|
return new Error(error);
|
|
@@ -110,6 +102,17 @@ class Mate {
|
|
|
110
102
|
data = data.params[index];
|
|
111
103
|
}
|
|
112
104
|
}
|
|
105
|
+
else if (!index && !args.descriptor && args.propKey && this.options.collectPropKeys && args.level !== 'CLASS') {
|
|
106
|
+
this.set({ ...args, level: 'CLASS' }, (meta) => {
|
|
107
|
+
if (!meta.properties) {
|
|
108
|
+
meta.properties = [args.propKey];
|
|
109
|
+
}
|
|
110
|
+
else if (!meta.properties.includes(args.propKey)) {
|
|
111
|
+
meta.properties.push(args.propKey);
|
|
112
|
+
}
|
|
113
|
+
return meta;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
113
116
|
if (typeof key !== 'function') {
|
|
114
117
|
if (isArray) {
|
|
115
118
|
const newArray = (data[key] || []);
|
package/dist/mate.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare type TFunction = Function;
|
|
|
29
29
|
export declare interface TMateOptions<T extends TProstoMetadata = TProstoMetadata> {
|
|
30
30
|
readReturnType?: boolean;
|
|
31
31
|
readType?: boolean;
|
|
32
|
+
collectPropKeys?: boolean;
|
|
32
33
|
inherit?: boolean | ((classMeta: T, propKey?: string, methodMeta?: T) => boolean);
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -44,6 +45,7 @@ declare type TObject = object;
|
|
|
44
45
|
|
|
45
46
|
export declare interface TProstoMetadata<TParams extends TProstoParamsMetadata = TProstoParamsMetadata> {
|
|
46
47
|
params: TParams[];
|
|
48
|
+
properties?: (string | symbol)[];
|
|
47
49
|
type?: TFunction;
|
|
48
50
|
returnType?: TFunction;
|
|
49
51
|
}
|
package/dist/mate.esm-bundler.js
CHANGED
|
@@ -7,15 +7,6 @@ function isConstructor(v) {
|
|
|
7
7
|
return typeof v === 'function' && Object.getOwnPropertyNames(v).includes('prototype') && !Object.getOwnPropertyNames(v).includes('caller') && !!v.name;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
11
|
-
|
|
12
|
-
function warn(text) {
|
|
13
|
-
console.log('[33m' + banner() + text + '[0m');
|
|
14
|
-
}
|
|
15
|
-
function logError(error) {
|
|
16
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
10
|
const classMetadata = {};
|
|
20
11
|
const paramMetadata = {};
|
|
21
12
|
const root = typeof global === 'object' ? global : typeof self === 'object' ? self : {};
|
|
@@ -52,19 +43,20 @@ else {
|
|
|
52
43
|
'metadata',
|
|
53
44
|
];
|
|
54
45
|
const target = root.Reflect;
|
|
55
|
-
let isOriginalReflectMetadata = true;
|
|
56
46
|
for (const func of funcs) {
|
|
57
47
|
if (typeof target[func] !== 'function') {
|
|
58
48
|
Object.defineProperty(target, func, { configurable: true, writable: true, value: _reflect[func] });
|
|
59
|
-
isOriginalReflectMetadata = false;
|
|
60
49
|
}
|
|
61
50
|
}
|
|
62
|
-
if (!isOriginalReflectMetadata) {
|
|
63
|
-
warn('A limited \'reflect-metadata\' implementation is used. In case of any issues include original \'reflect-metadata\' package and require it before any @prostojs/mate import.');
|
|
64
|
-
}
|
|
65
51
|
}
|
|
66
52
|
const Reflect$1 = _reflect;
|
|
67
53
|
|
|
54
|
+
const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
55
|
+
|
|
56
|
+
function logError(error) {
|
|
57
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
58
|
+
}
|
|
59
|
+
|
|
68
60
|
function panic(error) {
|
|
69
61
|
logError(error);
|
|
70
62
|
return new Error(error);
|
|
@@ -106,6 +98,17 @@ class Mate {
|
|
|
106
98
|
data = data.params[index];
|
|
107
99
|
}
|
|
108
100
|
}
|
|
101
|
+
else if (!index && !args.descriptor && args.propKey && this.options.collectPropKeys && args.level !== 'CLASS') {
|
|
102
|
+
this.set({ ...args, level: 'CLASS' }, (meta) => {
|
|
103
|
+
if (!meta.properties) {
|
|
104
|
+
meta.properties = [args.propKey];
|
|
105
|
+
}
|
|
106
|
+
else if (!meta.properties.includes(args.propKey)) {
|
|
107
|
+
meta.properties.push(args.propKey);
|
|
108
|
+
}
|
|
109
|
+
return meta;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
109
112
|
if (typeof key !== 'function') {
|
|
110
113
|
if (isArray) {
|
|
111
114
|
const newArray = (data[key] || []);
|
package/dist/src/mate.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface TMergedDecoratorArgs {
|
|
|
8
8
|
}
|
|
9
9
|
export interface TProstoMetadata<TParams extends TProstoParamsMetadata = TProstoParamsMetadata> {
|
|
10
10
|
params: TParams[];
|
|
11
|
+
properties?: (string | symbol)[];
|
|
11
12
|
type?: TFunction;
|
|
12
13
|
returnType?: TFunction;
|
|
13
14
|
}
|
|
@@ -17,6 +18,7 @@ export interface TProstoParamsMetadata {
|
|
|
17
18
|
export interface TMateOptions<T extends TProstoMetadata = TProstoMetadata> {
|
|
18
19
|
readReturnType?: boolean;
|
|
19
20
|
readType?: boolean;
|
|
21
|
+
collectPropKeys?: boolean;
|
|
20
22
|
inherit?: boolean | ((classMeta: T, propKey?: string, methodMeta?: T) => boolean);
|
|
21
23
|
}
|
|
22
24
|
export declare class Mate<T extends TProstoMetadata = TProstoMetadata> {
|
package/dist/src/mate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mate.d.ts","sourceRoot":"","sources":["../../src/mate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAK,SAAS,CAAA;AAMjD,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAA;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;CAC/B;AAED,MAAM,WAAW,eAAe,CAAC,OAAO,SAAS,qBAAqB,GAAG,qBAAqB;IAC1F,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,UAAU,CAAC,EAAE,SAAS,CAAA;CACzB;AAED,MAAM,WAAW,qBAAqB;IAClC,IAAI,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe;IACrE,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,KAAO,OAAO,CAAC,CAAA;CACtF;AAED,qBAAa,IAAI,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe;IAC7C,SAAS,CAAC,SAAS,EAAE,MAAM;IAAE,SAAS,CAAC,OAAO,EA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,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,GAC5D,eAAe,GAAG,cAAc,GAAG,kBAAkB,GAAG,iBAAiB;IAE5E,aAAa,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAC9C,GAAG,EAAG,MAAM,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,EACrD,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,EAC3D,OAAO,EAAE,OAAO,GAAG,SAAS,GAC7B,eAAe,GAAG,cAAc,GAAG,kBAAkB,GAAG,iBAAiB;CAS/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../src/reflect.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../src/reflect.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAsD5C,eAAO,MAAM,OAAO;wBAnCI,MAAM,GAAG,MAAM,UAAU,OAAO,GAAG,SAAS,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO;wBAG9E,MAAM,GAAG,MAAM,QAAQ,OAAO,UAAU,OAAO,GAAG,SAAS,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI;kBAIhG,MAAM,GAAG,MAAM,QAAQ,OAAO,GAAG,cAAc,GAAG,eAAe,GAAG,kBAAkB;CA4BzE,CAAA"}
|
|
@@ -5,6 +5,8 @@ export declare const mate: Mate<{
|
|
|
5
5
|
} & TProstoMetadata<import("..").TProstoParamsMetadata>>;
|
|
6
6
|
export declare class MateTestClass {
|
|
7
7
|
constructor(_a: string);
|
|
8
|
+
prop1?: string;
|
|
9
|
+
prop2?: number;
|
|
8
10
|
test(_b: string): string;
|
|
9
11
|
viaCB(_c: string): void;
|
|
10
12
|
param: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mate.artifacts.d.ts","sourceRoot":"","sources":["../../../src/tests/mate.artifacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAE1C,eAAO,MAAM,IAAI;;;
|
|
1
|
+
{"version":3,"file":"mate.artifacts.d.ts","sourceRoot":"","sources":["../../../src/tests/mate.artifacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAE1C,eAAO,MAAM,IAAI;;;wDAUf,CAAA;AAMF,qBAGa,aAAa;gBAKd,EAAE,EAAE,MAAM;IAMlB,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,KAAK,CAAC,EAAE,MAAM,CAAA;IAKd,IAAI,CAII,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB3B,KAAK,CAMG,EAAE,EAAE,MAAM;IAWlB,KAAK,EAAE,MAAM,CAAK;CACrB;AAED,qBACa,cAAc;gBACX,CAAC,EAAE,MAAM;IAOrB,IAAI,CAGD,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;IAM9B,eAAe;CAGlB;AAED,qBACa,cAAe,SAAQ,cAAc;;IAM9C,KAAK;IAML,eAAe;CAGlB;AAED,qBACa,cAAe,SAAQ,cAAc;;IAM9C,KAAK;IAKL,eAAe;CAGlB"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export type TAny = any;
|
|
2
|
+
export type TObject = object;
|
|
3
|
+
export type TFunction = Function;
|
|
4
|
+
export type TClassConstructor<T = unknown> = new (...args: TAny[]) => T;
|
|
5
5
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,IAAI,GAAG,GAAG,CAAA;AACtB,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAC5B,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAA;AAChC,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAG,IAAI,EAAE,KAAK,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prostojs/mate",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "MATE is TS Metadata Organizer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/mate.esm-bundler.js",
|
|
7
|
-
"unpkg": "dist/mate.global.prod.js",
|
|
8
|
-
"jsdelivr": "dist/mate.global.prod.js",
|
|
9
7
|
"types": "dist/mate.d.ts",
|
|
10
8
|
"files": [
|
|
11
9
|
"index.js",
|
|
@@ -34,9 +32,7 @@
|
|
|
34
32
|
"name": "ProstoMate",
|
|
35
33
|
"formats": [
|
|
36
34
|
"esm-bundler",
|
|
37
|
-
"
|
|
38
|
-
"cjs",
|
|
39
|
-
"global"
|
|
35
|
+
"cjs"
|
|
40
36
|
]
|
|
41
37
|
},
|
|
42
38
|
"dependencies": {},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){return t(e)?e:e.constructor?e.constructor:Object.getPrototypeOf(e).constructor}function t(e){return"function"==typeof e&&Object.getOwnPropertyNames(e).includes("prototype")&&!Object.getOwnPropertyNames(e).includes("caller")&&!!e.name}const o=()=>`[prostojs/mate][${(new Date).toISOString().replace("T"," ").replace(/\.\d{3}z$/i,"")}] `;const r={},a={},n="object"==typeof global?global:"object"==typeof self?self:{};function i(t,o){const n=void 0!==o,i=n?a:r,s=Symbol.for(e(t));let p=i[s]=i[s]||{};return n&&(p=p[o]=p[o]||{}),p}const s={getOwnMetadata:(e,t,o)=>i(t,o)[e],defineMetadata(e,t,o,r){i(o,r)[e]=t},metadata:(e,t)=>(o,r)=>{c.defineMetadata(e,t,o,r)}};if(n.Reflect){const e=["getOwnMetadata","defineMetadata","metadata"],t=n.Reflect;let r=!0;for(const o of e)"function"!=typeof t[o]&&(Object.defineProperty(t,o,{configurable:!0,writable:!0,value:s[o]}),r=!1);r||(p="A limited 'reflect-metadata' implementation is used. In case of any issues include original 'reflect-metadata' package and require it before any @prostojs/mate import.",console.log("[33m"+o()+p+"[0m"))}else n.Reflect=s;var p;const c=s;function l(e){return function(e){console.error("[91m[1m"+o()+e+"[0m")}(e),new Error(e)}const f=(null===global||void 0===global?void 0:global.Reflect)||(null===self||void 0===self?void 0:self.Reflect)||c;class d{constructor(e,t={}){this.workspace=e,this.options=t}set(e,t,o,r){var a;const n="CLASS"===e.level?{target:e.target}:"PROPERTY"===e.level?{target:e.target,propKey:e.propKey}:e;let i=f.getOwnMetadata(this.workspace,n.target,n.propKey)||{};n.propKey&&this.options.readReturnType&&!i.returnType&&(i.returnType=f.getOwnMetadata("design:returntype",n.target,n.propKey)),n.propKey&&this.options.readType&&!i.type&&(i.type=f.getOwnMetadata("design:type",n.target,n.propKey));const{index:s}=n,p="function"==typeof t?t:void 0;let c=i;if(c.params||(c.params=null===(a=f.getOwnMetadata("design:paramtypes",n.target,n.propKey))||void 0===a?void 0:a.map((e=>({type:e})))),"number"==typeof s&&(c.params=c.params||[],c.params[s]=c.params[s]||{type:void 0},p?c.params[s]=p(c.params[s],e.propKey,"number"==typeof e.index?e.index:void 0):c=c.params[s]),"function"!=typeof t)if(r){const e=c[t]||[];Array.isArray(e)||l("Mate.add (isArray=true) called for non-array metadata"),e.unshift(o),c[t]=e}else c[t]=o;else p&&"number"!=typeof s&&(i=p(c,e.propKey,"number"==typeof e.index?e.index:void 0));f.defineMetadata(this.workspace,i,n.target,n.propKey)}read(o,r,a){const n=t(o)?o:e(o);let i=f.getOwnMetadata(this.workspace,"string"==typeof r?n.prototype:n,r);if(this.options.inherit){const e="function"==typeof this.options.inherit?this.options.inherit:void 0;let t=this.options.inherit;if(e)if("string"==typeof r){t=e(f.getOwnMetadata(this.workspace,n),r,i)}else t=e(i);if(t){const e=Object.getPrototypeOf(n);if("function"==typeof e&&e!==y&&e!==n){i={...this.read(e,r),...i,params:null==i?void 0:i.params}}}}return i}apply(...e){return(t,o,r)=>{for(const a of e)a(t,o,r)}}decorate(e,t,o,r){return(a,n,i)=>{this.set({target:a,propKey:n,descriptor:"number"==typeof i?void 0:i,index:"number"==typeof i?i:void 0,level:r},e,t,o)}}decorateClass(e,t,o){return this.decorate(e,t,o,"CLASS")}}const y=Object.getPrototypeOf(Function);export{d as Mate,e as getConstructor,t as isConstructor};
|
package/dist/mate.global.prod.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var ProstoMate=function(e){"use strict";function t(e){return o(e)?e:e.constructor?e.constructor:Object.getPrototypeOf(e).constructor}function o(e){return"function"==typeof e&&Object.getOwnPropertyNames(e).includes("prototype")&&!Object.getOwnPropertyNames(e).includes("caller")&&!!e.name}const r=()=>`[prostojs/mate][${(new Date).toISOString().replace("T"," ").replace(/\.\d{3}z$/i,"")}] `;const a={},n={},i="object"==typeof global?global:"object"==typeof self?self:{};function s(e,o){const r=void 0!==o,i=r?n:a,s=Symbol.for(t(e));let p=i[s]=i[s]||{};return r&&(p=p[o]=p[o]||{}),p}const p={getOwnMetadata:(e,t,o)=>s(t,o)[e],defineMetadata(e,t,o,r){s(o,r)[e]=t},metadata:(e,t)=>(o,r)=>{l.defineMetadata(e,t,o,r)}};if(i.Reflect){const e=["getOwnMetadata","defineMetadata","metadata"],t=i.Reflect;let o=!0;for(const r of e)"function"!=typeof t[r]&&(Object.defineProperty(t,r,{configurable:!0,writable:!0,value:p[r]}),o=!1);o||(c="A limited 'reflect-metadata' implementation is used. In case of any issues include original 'reflect-metadata' package and require it before any @prostojs/mate import.",console.log("[33m"+r()+c+"[0m"))}else i.Reflect=p;var c;const l=p;function f(e){return function(e){console.error("[91m[1m"+r()+e+"[0m")}(e),new Error(e)}const d=(null===global||void 0===global?void 0:global.Reflect)||(null===self||void 0===self?void 0:self.Reflect)||l;const y=Object.getPrototypeOf(Function);return e.Mate=class{constructor(e,t={}){this.workspace=e,this.options=t}set(e,t,o,r){var a;const n="CLASS"===e.level?{target:e.target}:"PROPERTY"===e.level?{target:e.target,propKey:e.propKey}:e;let i=d.getOwnMetadata(this.workspace,n.target,n.propKey)||{};n.propKey&&this.options.readReturnType&&!i.returnType&&(i.returnType=d.getOwnMetadata("design:returntype",n.target,n.propKey)),n.propKey&&this.options.readType&&!i.type&&(i.type=d.getOwnMetadata("design:type",n.target,n.propKey));const{index:s}=n,p="function"==typeof t?t:void 0;let c=i;if(c.params||(c.params=null===(a=d.getOwnMetadata("design:paramtypes",n.target,n.propKey))||void 0===a?void 0:a.map((e=>({type:e})))),"number"==typeof s&&(c.params=c.params||[],c.params[s]=c.params[s]||{type:void 0},p?c.params[s]=p(c.params[s],e.propKey,"number"==typeof e.index?e.index:void 0):c=c.params[s]),"function"!=typeof t)if(r){const e=c[t]||[];Array.isArray(e)||f("Mate.add (isArray=true) called for non-array metadata"),e.unshift(o),c[t]=e}else c[t]=o;else p&&"number"!=typeof s&&(i=p(c,e.propKey,"number"==typeof e.index?e.index:void 0));d.defineMetadata(this.workspace,i,n.target,n.propKey)}read(e,r,a){const n=o(e)?e:t(e);let i=d.getOwnMetadata(this.workspace,"string"==typeof r?n.prototype:n,r);if(this.options.inherit){const e="function"==typeof this.options.inherit?this.options.inherit:void 0;let t=this.options.inherit;if(e)if("string"==typeof r){t=e(d.getOwnMetadata(this.workspace,n),r,i)}else t=e(i);if(t){const e=Object.getPrototypeOf(n);if("function"==typeof e&&e!==y&&e!==n){i={...this.read(e,r),...i,params:null==i?void 0:i.params}}}}return i}apply(...e){return(t,o,r)=>{for(const a of e)a(t,o,r)}}decorate(e,t,o,r){return(a,n,i)=>{this.set({target:a,propKey:n,descriptor:"number"==typeof i?void 0:i,index:"number"==typeof i?i:void 0,level:r},e,t,o)}}decorateClass(e,t,o){return this.decorate(e,t,o,"CLASS")}},e.getConstructor=t,e.isConstructor=o,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|