@treenity/core 1.0.40 → 1.0.42
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 +15 -0
- package/dist/context.d.ts +4 -0
- package/dist/context.mjs +10 -7
- package/dist/context.mjs.map +1 -1
- package/dist/contexts/react-context.d.ts +1 -0
- package/dist/contexts/react-context.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @treenity/core
|
|
2
2
|
|
|
3
|
+
## 1.0.42
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update version
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @treenity/call-chain@1.0.27
|
|
10
|
+
- @treenity/js-shared@1.0.31
|
|
11
|
+
|
|
12
|
+
## 1.0.41
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Update version
|
|
17
|
+
|
|
3
18
|
## 1.0.40
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/context.d.ts
CHANGED
|
@@ -16,12 +16,15 @@ export declare const registerComp: <T>(type: MetaName<T>, component: any) => (ct
|
|
|
16
16
|
}>, import("./contexts/react-context").ReactContextOptions>;
|
|
17
17
|
export interface Context<C, O> {
|
|
18
18
|
name: string;
|
|
19
|
+
items: Map<string, TypeContextInfo<C, O>>;
|
|
19
20
|
add<T, C1 extends C>(typeName: MetaName<T>, component: C1, options?: O): TypeContextInfo<C, O>;
|
|
20
21
|
add<T, C1 extends C>(subContext: string, typeName: MetaName<T>, component: C1, options?: O): TypeContextInfo<C, O>;
|
|
21
22
|
get<T>(typeName: MetaName<T>): Promise<[C, O]>;
|
|
22
23
|
get<T>(subContext: string, typeName: MetaName<T>): Promise<[C, O]>;
|
|
23
24
|
getInfo<T>(typeName: MetaName<T>): Promise<TypeContextInfo<C, O>>;
|
|
24
25
|
getInfo<T>(subContext: string, typeName: MetaName<T>): Promise<TypeContextInfo<C, O>>;
|
|
26
|
+
getSync<T>(typeName: MetaName<T>): TypeContextInfo<C, O> | undefined;
|
|
27
|
+
getSync<T>(subContext: string, typeName: MetaName<T>): TypeContextInfo<C, O> | undefined;
|
|
25
28
|
search(query: string): Promise<TypeContextInfo<C, O>[]>;
|
|
26
29
|
search(subContext: string, query: string): Promise<TypeContextInfo<C, O>[]>;
|
|
27
30
|
}
|
|
@@ -32,6 +35,7 @@ export declare class ContextImpl<C, O> implements Context<C, O> {
|
|
|
32
35
|
add(...args: any[]): TypeContextInfo<C, O>;
|
|
33
36
|
metaType<T>(subContext: string, typeName?: MetaName<T>): MetaType<any>;
|
|
34
37
|
getInfo<T>(subContext: string, typeName?: MetaName<T>): Promise<TypeContextInfo<C, O>>;
|
|
38
|
+
getSync<T>(subContext: string, typeName?: MetaName<T>): TypeContextInfo<C, O> | undefined;
|
|
35
39
|
get<T>(subContext: string, typeName?: MetaName<T>): Promise<[C, O]>;
|
|
36
40
|
search(subContext: string, query?: string): Promise<TypeContextInfo<C, O>[]>;
|
|
37
41
|
}
|
package/dist/context.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { SynchronousPromise } from 'synchronous-promise';
|
|
|
2
2
|
import { getTypeCache } from './get-type-cache.mjs';
|
|
3
3
|
import { metaType } from './meta-type.mjs';
|
|
4
4
|
|
|
5
|
-
const registerComp = (type, component) => (ctx) => ctx.add(type, component);
|
|
5
|
+
const registerComp = (type, component) => (ctx) => ctx.add(type, component, { replace: true });
|
|
6
6
|
class ContextImpl {
|
|
7
7
|
name;
|
|
8
8
|
items = new Map();
|
|
@@ -25,8 +25,8 @@ class ContextImpl {
|
|
|
25
25
|
component,
|
|
26
26
|
options,
|
|
27
27
|
};
|
|
28
|
-
if (this.items.has(contextType)) {
|
|
29
|
-
console.
|
|
28
|
+
if (!options.replace && this.items.has(contextType)) {
|
|
29
|
+
console.warn('Type of', contextType, 'in context', this.name, 'already exists');
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
this.items.set(contextType, t);
|
|
@@ -43,14 +43,17 @@ class ContextImpl {
|
|
|
43
43
|
// get(typeName: string): Promise<TypeContextInfo<C, O>>;
|
|
44
44
|
// get(subContext: string, typeName: string): Promise<TypeContextInfo<C, O>>;
|
|
45
45
|
getInfo(subContext, typeName) {
|
|
46
|
-
const
|
|
47
|
-
const contextType = type.$id;
|
|
48
|
-
const item = this.items.get(contextType);
|
|
46
|
+
const item = this.getSync(subContext, typeName);
|
|
49
47
|
if (!item) {
|
|
50
|
-
return SynchronousPromise.reject(new Error('not found: ' +
|
|
48
|
+
return SynchronousPromise.reject(new Error('not found: ' + this.metaType(subContext, typeName).$id + ' in ' + this.name + ' context'));
|
|
51
49
|
}
|
|
52
50
|
return SynchronousPromise.resolve(item);
|
|
53
51
|
}
|
|
52
|
+
getSync(subContext, typeName) {
|
|
53
|
+
const type = this.metaType(subContext, typeName);
|
|
54
|
+
const item = this.items.get(type.$id);
|
|
55
|
+
return item;
|
|
56
|
+
}
|
|
54
57
|
get(subContext, typeName) {
|
|
55
58
|
return this.getInfo(subContext, typeName).then(({ component, options }) => [
|
|
56
59
|
component,
|
package/dist/context.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.mjs","sources":["../src/context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"context.mjs","sources":["../src/context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAgBO,MAAM,YAAY,GACvB,CAAI,IAAiB,EAAE,SAAc,KACrC,CAAC,GAAqB,KACpB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;MA+BjC,WAAW,CAAA;AAGH,IAAA,IAAA;AAFnB,IAAA,KAAK,GAAuC,IAAI,GAAG,EAAE;AAErD,IAAA,WAAA,CAAmB,IAAY,EAAA;QAAZ,IAAI,CAAA,IAA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;;AAEhB;AAED;;;;"}
|
|
@@ -4,6 +4,7 @@ import { Context, ContextImpl, TypeContextInfo } from '../context';
|
|
|
4
4
|
import { Node } from '../node';
|
|
5
5
|
export interface ReactContextOptions {
|
|
6
6
|
props?: Obj<any>;
|
|
7
|
+
replace?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export type IReactContextProps<T = any, P = {}, N extends Node = Node> = {
|
|
9
10
|
value: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-context.mjs","sources":["../../src/contexts/react-context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"react-context.mjs","sources":["../../src/contexts/react-context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA0BM,MAAO,oBACX,SAAQ,WAA8D,CAAA;IAGtE,GAAG,CAAC,GAAG,IAAW,EAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,GAAG,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI;YACpC,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7C,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;;;aAEtD;AACL,YAAA,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI;YAClC,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7C,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;;;AAG7D,QAAA,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;;AAE5B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treenity/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "treenity core",
|
|
5
5
|
"author": "Treenity",
|
|
6
6
|
"license": "ISC",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@treenity/call-chain": "1.0.
|
|
18
|
-
"@treenity/js-shared": "1.0.
|
|
17
|
+
"@treenity/call-chain": "1.0.27",
|
|
18
|
+
"@treenity/js-shared": "1.0.31",
|
|
19
19
|
"json-schema": "^0.4.0",
|
|
20
20
|
"json-schema-to-ts": "^3.1.0",
|
|
21
21
|
"synchronous-promise": "2.0.17",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@testing-library/dom": "^8.17.1",
|
|
29
29
|
"@testing-library/jest-dom": "^6.4.8",
|
|
30
|
-
"@treenity/build-utils": "1.1.
|
|
30
|
+
"@treenity/build-utils": "1.1.27",
|
|
31
31
|
"@treenity/tsconfig": "1.0.11",
|
|
32
32
|
"@types/jest": "^29.5.12",
|
|
33
33
|
"@types/json-schema": "^7.0.15",
|