@treenity/core 1.0.34 → 1.0.35
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 +8 -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 +3 -2
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,EAAE;MA2B7G,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;AAC7B,QAAA,YAAY,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC7B;;;IAID,GAAG,CAAC,GAAG,IAAW,EAAA;AAChB,QAAA,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC9C,QAAA,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,GAAG,EAAO,CAAC,GAAG,IAE1D,CAAC;AACF,QAAA,QAAQ,GAAG,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC1C,QAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC;AACjC,QAAA,MAAM,CAAC,GAA0B;AAC/B,YAAA,EAAE,EAAE,WAAW;YACf,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,UAAU;YACV,SAAS;YACT,OAAO;SACR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AC;SACzB;AAED,QAAA,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;AAC7C,YAAA,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC;YAC/E,IAAI,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACpC,gBAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAChB;SACF;AACD,QAAA,OAAO,MAAM,CAAC;KACf;AACF,CAAA;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,CAAC;;YAE1C,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AACrC,SAAC,CAAC,CAAC;KACJ;AACF;;;;"}
|
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,CAAC;YACrC,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7C,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC3D;SACF;aAAM;AACL,YAAA,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;gBAC7C,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC3D;SACF;AACD,QAAA,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;KAC3B;AACF;;;;"}
|
|
@@ -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,CAAC;SAE3B,YAAY,GAAA;AAC1B,IAAA,OAAO,UAAU,CAAC;AACpB;;;;"}
|
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,CAAC;AAI1C,MAAM,IAAK,SAAQ,GAAG,CAAA;;IAEX,IAAI,CAAS;;IAEb,IAAI,CAAS;;IAEb,IAAI,CAAS;;IAEb,QAAQ,CAAS;;AAEjB,IAAA,KAAK,CAAS;IAEvB,WAAY,CAAA,MAA2B,EAAE,QAAwB,EAAA;AAC/D,QAAA,IAAI,MAAM,YAAY,IAAI,EAAE;YAC1B,IAAI,CAAC,QAAQ,EAAE;AACb,gBAAA,OAAO,MAAM,CAAC;aACf;AACD,YAAA,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;SAC5B;AAAM,aAAA,IAAI,MAAM,YAAY,GAAG,EAAE;AAChC,YAAA,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;SACtB;AAED,QAAA,MAAM,QAAQ,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
|
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,CAAC;AAC/C,CAAC;MAEY,YAAY,CAAA;AACvB,IAAA,KAAK,CAAS;AACd,IAAA,QAAQ,CAAS;AACjB,IAAA,KAAK,CAAK;IACV,IAAI,GAAW,SAAS,CAAC;IAEzB,WAAY,CAAA,IAAY,EAAE,OAAe,EAAA;AACvC,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;AAClB,QAAA,IAAI,CAAC,QAAQ,GA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GAA4C;IAC1D,GAAG,EAAE,IAAI,WAAW,EAAE;CACvB,CAAC;MAEW,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,EAAE;AAE5C,SAAU,OAAO,CAAI,MAAS,EAAA;AAClC,IAAA,OAAO,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAChD,CAAC;AAEK,SAAU,UAAU,CAAI,MAAS,EAAA;IACrC,OAAQ,cAAc,CAAC,MAAM,EAAE,cAAc,CAAS,CAAC,IAAc,CAAC;AACxE,CAAC;AAEK,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,CAAC;AAC9F,CAAC;AAEK,SAAU,WAAW,CAAC,QAAuB,EAAA;AACjD,IAAA,OAAO,OAAO,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;AAClE;;;;"}
|
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,GAAmB;AAElE,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAClC,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAClC,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;AACpC,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;AACvC,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.35",
|
|
4
4
|
"description": "treenity core",
|
|
5
5
|
"author": "Treenity",
|
|
6
6
|
"license": "ISC",
|
|
@@ -14,6 +14,7 @@
|
|
|
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
20
|
"json-schema-to-ts": "3.1.0",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@testing-library/dom": "^8.17.1",
|
|
28
29
|
"@testing-library/jest-dom": "6.4.5",
|
|
29
|
-
"@treenity/build-utils": "1.1.
|
|
30
|
+
"@treenity/build-utils": "1.1.23",
|
|
30
31
|
"@treenity/tsconfig": "1.0.10",
|
|
31
32
|
"@types/jest": "29.5.12",
|
|
32
33
|
"@types/json-schema": "^7.0.15",
|