@treenity/core 1.0.34 → 1.0.36
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 +73 -1
- package/dist/context.mjs.map +1 -0
- package/dist/contexts/node-engine.mjs +7 -1
- package/dist/contexts/node-engine.mjs.map +1 -0
- package/dist/contexts/object.mjs +15 -1
- package/dist/contexts/object.mjs.map +1 -0
- package/dist/contexts/proto.mjs +7 -1
- package/dist/contexts/proto.mjs.map +1 -0
- package/dist/contexts/react-context.mjs +24 -1
- package/dist/contexts/react-context.mjs.map +1 -0
- package/dist/contexts/service.mjs +7 -1
- package/dist/contexts/service.mjs.map +1 -0
- package/dist/get-type-cache.mjs +7 -1
- package/dist/get-type-cache.mjs.map +1 -0
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -0
- package/dist/link/link.mjs +72 -1
- package/dist/link/link.mjs.map +1 -0
- package/dist/meta-type.mjs +84 -1
- package/dist/meta-type.mjs.map +1 -0
- package/dist/meta.mjs +19 -1
- package/dist/meta.mjs.map +1 -0
- package/dist/types.mjs +16 -1
- package/dist/types.mjs.map +1 -0
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
package/dist/context.mjs
CHANGED
|
@@ -1 +1,73 @@
|
|
|
1
|
-
import{SynchronousPromise
|
|
1
|
+
import { SynchronousPromise } from 'synchronous-promise';
|
|
2
|
+
import { getTypeCache } from './get-type-cache.mjs';
|
|
3
|
+
import { metaType } from './meta-type.mjs';
|
|
4
|
+
|
|
5
|
+
const registerComp = (type, component) => (ctx) => ctx.add(type, component);
|
|
6
|
+
class ContextImpl {
|
|
7
|
+
name;
|
|
8
|
+
items = new Map();
|
|
9
|
+
constructor(name) {
|
|
10
|
+
this.name = name;
|
|
11
|
+
getTypeCache()[name] = this;
|
|
12
|
+
}
|
|
13
|
+
// add(...args: Pro<Context<C, O>['add']>): TypeContextInfo<C, O>;
|
|
14
|
+
// add(...args: ArgumentTypes<Context<C, O>['add']>): TypeContextInfo<C, O> {
|
|
15
|
+
add(...args) {
|
|
16
|
+
if (args.length <= 3)
|
|
17
|
+
args.unshift(undefined);
|
|
18
|
+
let [subContext, typeName, component, options = {}] = args;
|
|
19
|
+
typeName = metaType(typeName, subContext);
|
|
20
|
+
const contextType = typeName.$id;
|
|
21
|
+
const t = {
|
|
22
|
+
id: contextType,
|
|
23
|
+
context: this.name,
|
|
24
|
+
subContext,
|
|
25
|
+
component,
|
|
26
|
+
options,
|
|
27
|
+
};
|
|
28
|
+
this.items.set(contextType, t);
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
metaType(subContext, typeName) {
|
|
32
|
+
if (!typeName) {
|
|
33
|
+
typeName = subContext;
|
|
34
|
+
subContext = undefined;
|
|
35
|
+
}
|
|
36
|
+
return metaType(typeName, subContext);
|
|
37
|
+
}
|
|
38
|
+
// get(typeName: string): Promise<TypeContextInfo<C, O>>;
|
|
39
|
+
// get(subContext: string, typeName: string): Promise<TypeContextInfo<C, O>>;
|
|
40
|
+
getInfo(subContext, typeName) {
|
|
41
|
+
const type = this.metaType(subContext, typeName);
|
|
42
|
+
const contextType = type.$id;
|
|
43
|
+
const item = this.items.get(contextType);
|
|
44
|
+
if (!item) {
|
|
45
|
+
return SynchronousPromise.reject(new Error('not found: ' + contextType + ' in ' + this.name + ' context'));
|
|
46
|
+
}
|
|
47
|
+
return SynchronousPromise.resolve(item);
|
|
48
|
+
}
|
|
49
|
+
get(subContext, typeName) {
|
|
50
|
+
return this.getInfo(subContext, typeName).then(({ component, options }) => [
|
|
51
|
+
component,
|
|
52
|
+
options,
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
async search(subContext, query) {
|
|
56
|
+
const result = [];
|
|
57
|
+
if (!query) {
|
|
58
|
+
query = subContext;
|
|
59
|
+
subContext = undefined;
|
|
60
|
+
}
|
|
61
|
+
for (let t of Array.from(this.items.values())) {
|
|
62
|
+
const subEqual = (!t.subContext && !subContext) || t.subContext === subContext;
|
|
63
|
+
if (subEqual && t.id.includes(query)) {
|
|
64
|
+
result.push(t);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Node engine script context type
|
|
71
|
+
|
|
72
|
+
export { ContextImpl, registerComp };
|
|
73
|
+
//# sourceMappingURL=context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.mjs","sources":["../src/context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAkBa,MAAA,YAAY,GAAG,CAAI,IAAiB,EAAE,SAAc,KAAK,CAAC,GAAqB,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS;MA2B3G,WAAW,CAAA;AAGH,IAAA,IAAA;AAFnB,IAAA,KAAK,GAAuC,IAAI,GAAG,EAAE;AAErD,IAAA,WAAA,CAAmB,IAAY,EAAA;QAAZ,IAAI,CAAA,IAAA,GAAJ,IAAI;AACrB,QAAA,YAAY,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI;;;;IAK7B,GAAG,CAAC,GAAG,IAAW,EAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;AAC7C,QAAA,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,GAAG,EAAO,CAAC,GAAG,IAE1D;AACD,QAAA,QAAQ,GAAG,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;AACzC,QAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG;AAChC,QAAA,MAAM,CAAC,GAA0B;AAC/B,YAAA,EAAE,EAAE,WAAW;YACf,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,UAAU;YACV,SAAS;YACT,OAAO;SACR;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CA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,UAAU,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,KAAK,UAAU;YAC9E,IAAI,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpC,gBAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;;;AAGlB,QAAA,OAAO,MAAM;;AAEhB;AAED;;;;"}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{ContextImpl
|
|
1
|
+
import { ContextImpl } from '../context.mjs';
|
|
2
|
+
|
|
3
|
+
class NodeEngineTypeContextImpl extends ContextImpl {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { NodeEngineTypeContextImpl };
|
|
7
|
+
//# sourceMappingURL=node-engine.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-engine.mjs","sources":["../../src/contexts/node-engine.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAaM,MAAO,yBACX,SAAQ,WAAiD,CAAA;AACtB;;;;"}
|
package/dist/contexts/object.mjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
import{ContextImpl
|
|
1
|
+
import { ContextImpl } from '../context.mjs';
|
|
2
|
+
|
|
3
|
+
class ObjectTypeContextImpl extends ContextImpl {
|
|
4
|
+
getInfo(subContext, typeName) {
|
|
5
|
+
return super.getInfo(subContext, typeName).catch(error => {
|
|
6
|
+
if (!subContext || !typeName)
|
|
7
|
+
throw error;
|
|
8
|
+
// try empty context if specified not found
|
|
9
|
+
return super.getInfo('', typeName);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { ObjectTypeContextImpl };
|
|
15
|
+
//# sourceMappingURL=object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.mjs","sources":["../../src/contexts/object.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAcM,MAAO,qBACX,SAAQ,WAA0D,CAAA;IAGlE,OAAO,CACL,UAAkB,EAClB,QAAsB,EAAA;AAEtB,QAAA,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,IAAG;AACvD,YAAA,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ;AAAE,gBAAA,MAAM,KAAK;;YAEzC,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC;AACpC,SAAC,CAAC;;AAEL;;;;"}
|
package/dist/contexts/proto.mjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{ContextImpl
|
|
1
|
+
import { ContextImpl } from '../context.mjs';
|
|
2
|
+
|
|
3
|
+
class ProtoTypeContextImpl extends ContextImpl {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { ProtoTypeContextImpl };
|
|
7
|
+
//# sourceMappingURL=proto.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto.mjs","sources":["../../src/contexts/proto.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAUM,MAAO,oBACX,SAAQ,WAA8C,CAAA;AACxB;;;;"}
|
|
@@ -1 +1,24 @@
|
|
|
1
|
-
import{capitalize
|
|
1
|
+
import { capitalize } from '@treenity/js-shared/utils';
|
|
2
|
+
import { ContextImpl } from '../context.mjs';
|
|
3
|
+
import { getTypeName } from '../meta.mjs';
|
|
4
|
+
|
|
5
|
+
class ReactTypeContextImpl extends ContextImpl {
|
|
6
|
+
add(...args) {
|
|
7
|
+
if (args.length === 4) {
|
|
8
|
+
const [, typeName, component] = args;
|
|
9
|
+
if (!component.displayName && !component.name) {
|
|
10
|
+
component.displayName = capitalize(getTypeName(typeName));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const [typeName, component] = args;
|
|
15
|
+
if (!component.displayName && !component.name) {
|
|
16
|
+
component.displayName = capitalize(getTypeName(typeName));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return super.add(...args);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { ReactTypeContextImpl };
|
|
24
|
+
//# sourceMappingURL=react-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-context.mjs","sources":["../../src/contexts/react-context.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAyBM,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;;;;"}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{ContextImpl
|
|
1
|
+
import { ContextImpl } from '../context.mjs';
|
|
2
|
+
|
|
3
|
+
class ServiceTypeContextImpl extends ContextImpl {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { ServiceTypeContextImpl };
|
|
7
|
+
//# sourceMappingURL=service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.mjs","sources":["../../src/contexts/service.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAWM,MAAO,sBACX,SAAQ,WAA2C,CAAA;AACnB;;;;"}
|
package/dist/get-type-cache.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-type-cache.mjs","sources":["../src/get-type-cache.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAwB,EAAE;SAE1B,YAAY,GAAA;AAC1B,IAAA,OAAO,UAAU;AACnB;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
export{ContextImpl,registerComp}from
|
|
1
|
+
export { ContextImpl, registerComp } from './context.mjs';
|
|
2
|
+
export { default as Link } from './link/link.mjs';
|
|
3
|
+
export { types } from './types.mjs';
|
|
4
|
+
export { MetaSymbolType, getMeta, getMetaRaw, getTypeName, serializeMeta } from './meta.mjs';
|
|
5
|
+
export { ServiceTypeContextImpl } from './contexts/service.mjs';
|
|
6
|
+
export { ProtoTypeContextImpl } from './contexts/proto.mjs';
|
|
7
|
+
export { NodeEngineTypeContextImpl } from './contexts/node-engine.mjs';
|
|
8
|
+
export { ReactTypeContextImpl } from './contexts/react-context.mjs';
|
|
9
|
+
export { AntTypeImpl, AnyType, MetaTypeImpl, makeTypeId, metaType, pathToString } from './meta-type.mjs';
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/dist/link/link.mjs
CHANGED
|
@@ -1 +1,72 @@
|
|
|
1
|
-
import{stripSlashes
|
|
1
|
+
import { stripSlashes } from '@treenity/js-shared/utils';
|
|
2
|
+
|
|
3
|
+
const PROTO_REGEXP = /^([a-z-0-9\-_+]+):/;
|
|
4
|
+
class Link extends URL {
|
|
5
|
+
// @ts-ignore - field will be set in constructor
|
|
6
|
+
path; // path without meta and field
|
|
7
|
+
// @ts-ignore - field will be set in constructor
|
|
8
|
+
node; // node name or id
|
|
9
|
+
// @ts-ignore - field will be set in constructor
|
|
10
|
+
meta; // meta name
|
|
11
|
+
// @ts-ignore - field will be set in constructor
|
|
12
|
+
metaPath; // meta name
|
|
13
|
+
// @ts-ignore - field will be set in constructor
|
|
14
|
+
field;
|
|
15
|
+
constructor(source, override) {
|
|
16
|
+
if (source instanceof Link) {
|
|
17
|
+
if (!override) {
|
|
18
|
+
return source;
|
|
19
|
+
}
|
|
20
|
+
source = source.toString();
|
|
21
|
+
}
|
|
22
|
+
else if (source instanceof URL) {
|
|
23
|
+
source = source.href;
|
|
24
|
+
}
|
|
25
|
+
const protocol = override?.protocol ?? 'tree:';
|
|
26
|
+
if (!PROTO_REGEXP.test(source))
|
|
27
|
+
source = `${protocol}/` + stripSlashes(source);
|
|
28
|
+
super(source);
|
|
29
|
+
const [path, rest] = source.split('$');
|
|
30
|
+
let [meta, field] = rest?.split(/[#^]/) ?? [];
|
|
31
|
+
let pathname = this.pathname;
|
|
32
|
+
if (pathname.endsWith('/'))
|
|
33
|
+
this.pathname = pathname = pathname.slice(0, -1);
|
|
34
|
+
this.path = pathname.split('$')[0];
|
|
35
|
+
this.node = this.path.split('/').pop();
|
|
36
|
+
if (override?.meta !== undefined) {
|
|
37
|
+
meta = override.meta;
|
|
38
|
+
this.pathname = this.path;
|
|
39
|
+
}
|
|
40
|
+
if (override?.field !== undefined) {
|
|
41
|
+
this.hash = field = override.field;
|
|
42
|
+
}
|
|
43
|
+
if (override?.host !== undefined) {
|
|
44
|
+
this.host = override.host;
|
|
45
|
+
}
|
|
46
|
+
if (override?.protocol !== undefined) {
|
|
47
|
+
this.protocol = override.protocol;
|
|
48
|
+
}
|
|
49
|
+
this.meta = meta;
|
|
50
|
+
this.metaPath = meta ? `${this.path}$${meta}` : this.path;
|
|
51
|
+
this.field = field;
|
|
52
|
+
Object.freeze(this);
|
|
53
|
+
}
|
|
54
|
+
get context() {
|
|
55
|
+
return this.protocol.replace(':', '');
|
|
56
|
+
}
|
|
57
|
+
get contextAndHost() {
|
|
58
|
+
return `${this.protocol}//${this.host}`;
|
|
59
|
+
}
|
|
60
|
+
parent() {
|
|
61
|
+
if (this.hash) {
|
|
62
|
+
return new Link(this, { field: '' });
|
|
63
|
+
}
|
|
64
|
+
if (this.meta) {
|
|
65
|
+
return new Link(this, { meta: '' });
|
|
66
|
+
}
|
|
67
|
+
return new Link(new URL('.', this));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { Link as default };
|
|
72
|
+
//# sourceMappingURL=link.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.mjs","sources":["../../src/link/link.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAaA,MAAM,YAAY,GAAG,oBAAoB;AAIzC,MAAM,IAAK,SAAQ,GAAG,CAAA;;IAEX,IAAI,CAAS;;IAEb,IAAI,CAAS;;IAEb,IAAI,CAAS;;IAEb,QAAQ,CAAS;;AAEjB,IAAA,KAAK;IAEd,WAAY,CAAA,MAA2B,EAAE,QAAwB,EAAA;AAC/D,QAAA,IAAI,MAAM,YAAY,IAAI,EAAE;YAC1B,IAAI,CAAC,QAAQ,EAAE;AACb,gBAAA,OAAO,MAAM;;AAEf,YAAA,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE;;AACrB,aAAA,IAAI,MAAM,YAAY,GAAG,EAAE;AAChC,YAAA,MAAM,GAAG,MAAM,CAAC,IAAI;;AAGtB,QAAA,MAAM,QAAQ,GAAG,QAAQ,EAAE,QAAQ,IAAI,OAAO;AAE9C,QAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,MAAM,GAAG,GAAG,QAAQ,CAAA,CAAA,CAAG,GAAG,YAAY,CAAC,MAAM,CAAC;QAC9E,KAAK,CAAC,MAAM,CAAC;AAEb,QAAA,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AACtC,QAAA,IAAI,CAAC,IAA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,IAAI,CAAC;;AAGrB,IAAA,IAAI,OAAO,GAAA;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;;AAGvC,IAAA,IAAI,cAAc,GAAA;QAChB,OAAO,CAAA,EAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAA,CAAE;;IAGzC,MAAM,GAAA;AACJ,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;;AAEtC,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;;QAGrC,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;;AAEtC;;;;"}
|
package/dist/meta-type.mjs
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
|
-
import{getFileFromStack
|
|
1
|
+
import { getFileFromStack } from '@treenity/js-shared/utils';
|
|
2
|
+
import { getTypeName } from './meta.mjs';
|
|
3
|
+
|
|
4
|
+
function makeTypeId(type, context) {
|
|
5
|
+
return context ? `${context}:${type}` : type;
|
|
6
|
+
}
|
|
7
|
+
class MetaTypeImpl {
|
|
8
|
+
$type;
|
|
9
|
+
$context;
|
|
10
|
+
$item;
|
|
11
|
+
$loc = 'unknown';
|
|
12
|
+
constructor(type, context) {
|
|
13
|
+
this.$type = type;
|
|
14
|
+
this.$context = context;
|
|
15
|
+
}
|
|
16
|
+
toJSON() {
|
|
17
|
+
return {
|
|
18
|
+
$type: this.$type,
|
|
19
|
+
$context: this.$context,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
get $id() {
|
|
23
|
+
return makeTypeId(this.$type, this.$context);
|
|
24
|
+
}
|
|
25
|
+
get server() {
|
|
26
|
+
return this.$context === 'server' ? this : this.inContext('server');
|
|
27
|
+
}
|
|
28
|
+
get client() {
|
|
29
|
+
return this.$context === 'client' ? this : this.inContext('client');
|
|
30
|
+
}
|
|
31
|
+
get empty() {
|
|
32
|
+
return !this.$context ? this : this.inContext('');
|
|
33
|
+
}
|
|
34
|
+
inContext(context) {
|
|
35
|
+
return metaType(this, context);
|
|
36
|
+
}
|
|
37
|
+
toString() {
|
|
38
|
+
return `[${this.$id}]`;
|
|
39
|
+
}
|
|
40
|
+
isEqual(other, context) {
|
|
41
|
+
// if context boolean – it indicates if we should count context while comparison
|
|
42
|
+
if (typeof context === 'boolean') {
|
|
43
|
+
other = metaType(other);
|
|
44
|
+
return this.$type === other.$type && (!context || this.$context === other.$context);
|
|
45
|
+
}
|
|
46
|
+
other = metaType(other, context);
|
|
47
|
+
return this.$type === other.$type && this.$context === other.$context;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function pathToString(path) {
|
|
51
|
+
return typeof path === 'string' ? path : path.toString();
|
|
52
|
+
}
|
|
53
|
+
function metaType(type, subContext) {
|
|
54
|
+
subContext ??= typeof type === 'string' ? '' : type.$context;
|
|
55
|
+
type = getTypeName(type);
|
|
56
|
+
const metaType = _metaTypes[makeTypeId(type, subContext)];
|
|
57
|
+
if (metaType)
|
|
58
|
+
return metaType;
|
|
59
|
+
const newType = new MetaTypeImpl(type, subContext);
|
|
60
|
+
newType.$loc = getFileFromStack(3);
|
|
61
|
+
_metaTypes[makeTypeId(type, subContext)] = Object.freeze(newType);
|
|
62
|
+
return newType;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Any type equals to any other type and has no context
|
|
66
|
+
*/
|
|
67
|
+
class AntTypeImpl extends MetaTypeImpl {
|
|
68
|
+
constructor() {
|
|
69
|
+
super('any', '');
|
|
70
|
+
}
|
|
71
|
+
isEqual(other, context) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
inContext(context) {
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const _metaTypes = {
|
|
79
|
+
any: new AntTypeImpl(),
|
|
80
|
+
};
|
|
81
|
+
const AnyType = metaType('any');
|
|
82
|
+
|
|
83
|
+
export { AntTypeImpl, AnyType, MetaTypeImpl, makeTypeId, metaType, pathToString };
|
|
84
|
+
//# sourceMappingURL=meta-type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-type.mjs","sources":["../src/meta-type.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAKgB,SAAA,UAAU,CAAC,IAAY,EAAE,OAAgB,EAAA;AACvD,IAAA,OAAO,OAAO,GAAG,CAAG,EAAA,OAAO,CAAI,CAAA,EAAA,IAAI,CAAE,CAAA,GAAG,IAAI;AAC9C;MAEa,YAAY,CAAA;AACvB,IAAA,KAAK;AACL,IAAA,QAAQ;AACR,IAAA,KAAK;IACL,IAAI,GAAW,SAAS;IAExB,WAAY,CAAA,IAAY,EAAE,OAAe,EAAA;AACvC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;AACjB,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;IAGzB,MAAM,GAAA;QACJ,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB;;AAGH,IAAA,IAAI,GAAG,GAAA;QACL,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;;AAG9C,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;AAGrE,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;AAGrE,IAAA,IAAI,KAAK,GAAA;AACP,QA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,CAAC;AACrD,IAAA,OAAO,CAAC,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAE;AAEnC,IAAA,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;AAEjE,IAAA,OAAO,OAAO;AAChB;AAEA;;AAEG;AACG,MAAO,WAAY,SAAQ,YAAiB,CAAA;AAChD,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;;IAGlB,OAAO,CAAC,KAAoB,EAAE,OAA0B,EAAA;AACtD,QAAA,OAAO,IAAI;;AAGb,IAAA,SAAS,CAAW,OAAe,EAAA;AACjC,QAAA,OAAO,IAAqB;;AAE/B;AAED,MAAM,UAAU,GAA4C;IAC1D,GAAG,EAAE,IAAI,WAAW,EAAE;CACvB;MAEY,OAAO,GAAG,QAAQ,CAAM,KAAK;;;;"}
|
package/dist/meta.mjs
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import{getSymbolField
|
|
1
|
+
import { getSymbolField } from '@treenity/js-shared/utils';
|
|
2
|
+
|
|
3
|
+
//& NodeCallSignature;
|
|
4
|
+
const MetaSymbolType = Symbol.for('$meta');
|
|
5
|
+
function getMeta(entity) {
|
|
6
|
+
return getSymbolField(entity, MetaSymbolType);
|
|
7
|
+
}
|
|
8
|
+
function getMetaRaw(entity) {
|
|
9
|
+
return getSymbolField(entity, MetaSymbolType).$raw;
|
|
10
|
+
}
|
|
11
|
+
function serializeMeta(meta) {
|
|
12
|
+
return typeof meta.toJSON === 'function' ? meta.toJSON() : JSON.parse(JSON.stringify(meta));
|
|
13
|
+
}
|
|
14
|
+
function getTypeName(metaName) {
|
|
15
|
+
return typeof metaName === 'string' ? metaName : metaName.$type;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { MetaSymbolType, getMeta, getMetaRaw, getTypeName, serializeMeta };
|
|
19
|
+
//# sourceMappingURL=meta.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.mjs","sources":["../src/meta.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA0BA;AAEa,MAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO;AAE1C,SAAU,OAAO,CAAI,MAAS,EAAA;AAClC,IAAA,OAAO,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC;AAC/C;AAEM,SAAU,UAAU,CAAI,MAAS,EAAA;IACrC,OAAQ,cAAc,CAAC,MAAM,EAAE,cAAc,CAAS,CAAC,IAAc;AACvE;AAEM,SAAU,aAAa,CAAC,IAAS,EAAA;IACrC,OAAO,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7F;AAEM,SAAU,WAAW,CAAC,QAAuB,EAAA;AACjD,IAAA,OAAO,OAAO,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK;AACjE;;;;"}
|
package/dist/types.mjs
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeEngineTypeContextImpl } from './contexts/node-engine.mjs';
|
|
2
|
+
import { ObjectTypeContextImpl } from './contexts/object.mjs';
|
|
3
|
+
import { ProtoTypeContextImpl } from './contexts/proto.mjs';
|
|
4
|
+
import { ReactTypeContextImpl } from './contexts/react-context.mjs';
|
|
5
|
+
import { ServiceTypeContextImpl } from './contexts/service.mjs';
|
|
6
|
+
import { getTypeCache } from './get-type-cache.mjs';
|
|
7
|
+
|
|
8
|
+
const types = getTypeCache();
|
|
9
|
+
new ReactTypeContextImpl('react');
|
|
10
|
+
new ProtoTypeContextImpl('proto');
|
|
11
|
+
new ServiceTypeContextImpl('jsSrv');
|
|
12
|
+
new NodeEngineTypeContextImpl('noflo');
|
|
13
|
+
new ObjectTypeContextImpl('entity');
|
|
14
|
+
|
|
15
|
+
export { types };
|
|
16
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../src/types.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAea,MAAA,KAAK,GAAiB,YAAY;AAE/C,IAAI,oBAAoB,CAAC,OAAO,CAAC;AACjC,IAAI,oBAAoB,CAAC,OAAO,CAAC;AACjC,IAAI,sBAAsB,CAAC,OAAO,CAAC;AACnC,IAAI,yBAAyB,CAAC,OAAO,CAAC;AACtC,IAAI,qBAAqB,CAAC,QAAQ,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treenity/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"description": "treenity core",
|
|
5
5
|
"author": "Treenity",
|
|
6
6
|
"license": "ISC",
|
|
@@ -14,30 +14,31 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@treenity/call-chain": "1.0.25",
|
|
17
18
|
"@treenity/js-shared": "1.0.27",
|
|
18
19
|
"json-schema": "^0.4.0",
|
|
19
|
-
"json-schema-to-ts": "3.1.0",
|
|
20
|
+
"json-schema-to-ts": "^3.1.0",
|
|
20
21
|
"synchronous-promise": "2.0.17",
|
|
21
|
-
"tslib": "2.8.0"
|
|
22
|
+
"tslib": "^2.8.0"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
24
25
|
"react": "^18.3.1"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@testing-library/dom": "^8.17.1",
|
|
28
|
-
"@testing-library/jest-dom": "6.4.
|
|
29
|
-
"@treenity/build-utils": "1.1.
|
|
29
|
+
"@testing-library/jest-dom": "^6.4.8",
|
|
30
|
+
"@treenity/build-utils": "1.1.24",
|
|
30
31
|
"@treenity/tsconfig": "1.0.10",
|
|
31
|
-
"@types/jest": "29.5.12",
|
|
32
|
+
"@types/jest": "^29.5.12",
|
|
32
33
|
"@types/json-schema": "^7.0.15",
|
|
33
34
|
"@types/node": "^22.7.5",
|
|
34
35
|
"@types/prop-types": "^15.7.5",
|
|
35
36
|
"@types/react": "18.2.51",
|
|
36
37
|
"ajv": "^8.12.0",
|
|
37
|
-
"jest": "29.7.0",
|
|
38
|
-
"react": "18.3.1",
|
|
39
|
-
"rollup": "^4.
|
|
40
|
-
"typescript": "5.4.5"
|
|
38
|
+
"jest": "^29.7.0",
|
|
39
|
+
"react": "^18.3.1",
|
|
40
|
+
"rollup": "^4.26.0",
|
|
41
|
+
"typescript": "^5.4.5"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"build": "rollup -c",
|