@treenity/core 1.0.20 → 1.0.22
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/CHANGELOG.md +14 -0
- package/dist/context.mjs +97 -1
- package/dist/context.mjs.map +1 -0
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -0
- package/dist/meta.mjs +9 -1
- package/dist/meta.mjs.map +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
package/dist/context.mjs
CHANGED
|
@@ -1 +1,97 @@
|
|
|
1
|
-
import{capitalize
|
|
1
|
+
import { capitalize } from '@treenity/js-shared/utils';
|
|
2
|
+
import { SynchronousPromise } from 'synchronous-promise';
|
|
3
|
+
|
|
4
|
+
class ContextImpl {
|
|
5
|
+
name;
|
|
6
|
+
items = new Map();
|
|
7
|
+
constructor(name) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
types[name] = this;
|
|
11
|
+
}
|
|
12
|
+
// add(...args: Pro<Context<C, O>['add']>): TypeContextInfo<C, O>;
|
|
13
|
+
// add(...args: ArgumentTypes<Context<C, O>['add']>): TypeContextInfo<C, O> {
|
|
14
|
+
add(...args) {
|
|
15
|
+
if (args.length <= 3)
|
|
16
|
+
args.unshift('');
|
|
17
|
+
const [subContext, typeName, component, options] = args;
|
|
18
|
+
const contextType = subContext ? subContext + ':' + typeName : typeName;
|
|
19
|
+
const t = {
|
|
20
|
+
id: contextType,
|
|
21
|
+
context: this.name,
|
|
22
|
+
subContext,
|
|
23
|
+
component,
|
|
24
|
+
options,
|
|
25
|
+
};
|
|
26
|
+
this.items.set(contextType, t);
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
// get(typeName: string): Promise<TypeContextInfo<C, O>>;
|
|
30
|
+
// get(subContext: string, typeName: string): Promise<TypeContextInfo<C, O>>;
|
|
31
|
+
getInfo(subContext, typeName) {
|
|
32
|
+
if (!typeName) {
|
|
33
|
+
typeName = subContext;
|
|
34
|
+
subContext = '';
|
|
35
|
+
}
|
|
36
|
+
const contextType = subContext ? subContext + ':' + typeName : typeName;
|
|
37
|
+
const item = this.items.get(contextType);
|
|
38
|
+
if (!item) {
|
|
39
|
+
return SynchronousPromise.reject(new Error('not found: ' + contextType));
|
|
40
|
+
}
|
|
41
|
+
return SynchronousPromise.resolve(item);
|
|
42
|
+
}
|
|
43
|
+
get(subContext, typeName) {
|
|
44
|
+
return this.getInfo(subContext, typeName).then(({ component, options }) => [
|
|
45
|
+
component,
|
|
46
|
+
options,
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
search(subContext, query) {
|
|
50
|
+
const result = [];
|
|
51
|
+
if (!query) {
|
|
52
|
+
query = subContext;
|
|
53
|
+
subContext = '';
|
|
54
|
+
}
|
|
55
|
+
for (let t of this.items.values()) {
|
|
56
|
+
const matchesContext = t.subContext === subContext;
|
|
57
|
+
const matchesQuery = t.id.includes(query);
|
|
58
|
+
if (matchesContext && matchesQuery) {
|
|
59
|
+
result.push(t);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
class ReactTypeContextImpl extends ContextImpl {
|
|
66
|
+
add(...args) {
|
|
67
|
+
if (args.length === 4) {
|
|
68
|
+
const [, typeName, component] = args;
|
|
69
|
+
if (!component.displayName && !component.name)
|
|
70
|
+
component.displayName = capitalize(typeName);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const [typeName, component] = args;
|
|
74
|
+
if (!component.displayName && !component.name)
|
|
75
|
+
component.displayName = capitalize(typeName);
|
|
76
|
+
}
|
|
77
|
+
return super.add(...args);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
class ServiceTypeContextImpl extends ContextImpl {
|
|
81
|
+
}
|
|
82
|
+
class NodeEngineTypeContextImpl extends ContextImpl {
|
|
83
|
+
}
|
|
84
|
+
class MetaTypeContextImpl extends ContextImpl {
|
|
85
|
+
}
|
|
86
|
+
class ProtoTypeContextImpl extends ContextImpl {
|
|
87
|
+
}
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
const types = {};
|
|
90
|
+
new ReactTypeContextImpl('react');
|
|
91
|
+
new MetaTypeContextImpl('meta');
|
|
92
|
+
new ProtoTypeContextImpl('proto');
|
|
93
|
+
new ServiceTypeContextImpl('jsSrv');
|
|
94
|
+
new NodeEngineTypeContextImpl('noflo');
|
|
95
|
+
|
|
96
|
+
export { ContextImpl, types };
|
|
97
|
+
//# sourceMappingURL=context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.mjs","sources":["../src/context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAgCa,WAAW,CAAA;AAGH,IAAA,IAAA,CAAA;AAFnB,IAAA,KAAK,GAAuC,IAAI,GAAG,EAAE,CAAC;AAEtD,IAAA,WAAA,CAAmB,IAAY,EAAA;QAAZ,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAQ;;AAE7B,QAAA,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KACpB;;;IAID,GAAG,CAAC,GAAG,IAAW,EAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,IAAwC,CAAC;AAC5F,QAAA,MAAM,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxE,QAAA,MAAM,CAAC,GAA0B;AAC/B,YAAA,EAAE,EAAE,WAAW;YACf,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,UAAU;YACV,SAAS;YACT,OAAO;SACR,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC/B,QAA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1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/meta.mjs
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
function
|
|
1
|
+
function toString() {
|
|
2
|
+
return `[${this.$type}]`;
|
|
3
|
+
}
|
|
4
|
+
function metaType(type, item) {
|
|
5
|
+
return { $type: type, $item: item, toString };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { metaType };
|
|
9
|
+
//# sourceMappingURL=meta.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.mjs","sources":["../src/meta.ts"],"sourcesContent":[null],"names":[],"mappings":"AA6CA,SAAS,QAAQ,GAAA;AACf,IAAA,OAAO,CAAI,CAAA,EAAA,IAAI,CAAC,KAAK,GAAG,CAAC;AAC3B,CAAC;AAEe,SAAA,QAAQ,CAAI,IAAY,EAAE,IAAiB,EAAA;IACzD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAA0B,CAAC;AACxE;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treenity/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "treenity core",
|
|
5
5
|
"author": "Treenity",
|
|
6
6
|
"license": "ISC",
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@treenity/js-shared": "1.0.
|
|
17
|
+
"@treenity/js-shared": "1.0.20",
|
|
18
18
|
"json-schema-to-ts": "3.0.0",
|
|
19
19
|
"synchronous-promise": "2.0.17",
|
|
20
|
-
"tslib": "2.6.
|
|
20
|
+
"tslib": "2.6.3"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "^18.2.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@testing-library/dom": "^8.17.1",
|
|
27
|
-
"@testing-library/jest-dom": "
|
|
27
|
+
"@testing-library/jest-dom": "6.4.5",
|
|
28
28
|
"@testing-library/preact": "3.2.3",
|
|
29
|
-
"@treenity/build-utils": "1.1.
|
|
29
|
+
"@treenity/build-utils": "1.1.12",
|
|
30
30
|
"@treenity/tsconfig": "1.0.9",
|
|
31
31
|
"@types/jest": "29.5.12",
|
|
32
32
|
"@types/node": "20.11.16",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"jest": "29.7.0",
|
|
37
37
|
"react": "18.2.0",
|
|
38
38
|
"rollup": "4.9.6",
|
|
39
|
-
"ts-jest": "29.
|
|
39
|
+
"ts-jest": "29.1.4",
|
|
40
40
|
"typescript": "5.4.5"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|