@lionweb/core 0.7.0-alpha.5 → 0.7.0-alpha.7
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 +20 -4
- package/dist/deserializer.d.ts +15 -6
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +13 -13
- package/dist/deserializer.js.map +1 -1
- package/dist/dynamic-facade.d.ts +14 -5
- package/dist/dynamic-facade.d.ts.map +1 -1
- package/dist/dynamic-facade.js +13 -5
- package/dist/dynamic-facade.js.map +1 -1
- package/dist/extraction.d.ts +15 -0
- package/dist/extraction.d.ts.map +1 -0
- package/dist/extraction.js +17 -0
- package/dist/extraction.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/m1/reference-utils.d.ts +7 -7
- package/dist/m1/reference-utils.d.ts.map +1 -1
- package/dist/m1/reference-utils.js +10 -10
- package/dist/m1/reference-utils.js.map +1 -1
- package/dist/m3/builtins.d.ts +38 -17
- package/dist/m3/builtins.d.ts.map +1 -1
- package/dist/m3/builtins.js +53 -28
- package/dist/m3/builtins.js.map +1 -1
- package/dist/m3/deserializer.js +4 -4
- package/dist/m3/deserializer.js.map +1 -1
- package/dist/m3/facade.d.ts +13 -4
- package/dist/m3/facade.d.ts.map +1 -1
- package/dist/m3/facade.js +12 -4
- package/dist/m3/facade.js.map +1 -1
- package/dist/m3/functions.d.ts +3 -3
- package/dist/m3/functions.d.ts.map +1 -1
- package/dist/m3/functions.js.map +1 -1
- package/dist/m3/lioncore.js +7 -7
- package/dist/m3/serializer.d.ts.map +1 -1
- package/dist/m3/serializer.js +3 -3
- package/dist/m3/serializer.js.map +1 -1
- package/dist/m3/types.d.ts +12 -7
- package/dist/m3/types.d.ts.map +1 -1
- package/dist/m3/types.js +9 -4
- package/dist/m3/types.js.map +1 -1
- package/dist/reading.d.ts +45 -0
- package/dist/reading.d.ts.map +1 -0
- package/dist/reading.js +2 -0
- package/dist/reading.js.map +1 -0
- package/dist/serializer.d.ts +28 -7
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +108 -100
- package/dist/serializer.js.map +1 -1
- package/dist/writing.d.ts +49 -0
- package/dist/writing.d.ts.map +1 -0
- package/dist/writing.js +30 -0
- package/dist/writing.js.map +1 -0
- package/package.json +3 -3
- package/dist/facade.d.ts +0 -85
- package/dist/facade.d.ts.map +0 -1
- package/dist/facade.js +0 -42
- package/dist/facade.js.map +0 -1
package/dist/serializer.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { LionWebJsonChunk, LionWebJsonMetaPointer } from "@lionweb/json";
|
|
2
|
-
import {
|
|
3
|
-
import { Feature, Property } from "./m3/types.js";
|
|
2
|
+
import { Reader } from "./reading.js";
|
|
4
3
|
import { Node } from "./types.js";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { Feature, Property } from "./m3/types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Interface for objects that expose a method to serialize a property's value.
|
|
7
|
+
*/
|
|
8
|
+
export interface PropertyValueSerializer {
|
|
9
|
+
serializeValue(value: unknown, property: Property): string | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Misspelled alias of {@link PropertyValueSerializer}, kept for backward compatibility, and to be deprecated and removed later.
|
|
13
|
+
*/
|
|
14
|
+
export interface PrimitiveTypeSerializer extends PropertyValueSerializer {
|
|
7
15
|
}
|
|
8
16
|
/**
|
|
9
|
-
* Type to provide options to the serializer.
|
|
17
|
+
* Type to provide (non-required) options to the serializer.
|
|
10
18
|
*/
|
|
11
19
|
export type SerializationOptions = Partial<{
|
|
12
20
|
/**
|
|
@@ -15,14 +23,27 @@ export type SerializationOptions = Partial<{
|
|
|
15
23
|
* Default = true, meaning that empty feature values are *not* skipped.
|
|
16
24
|
*/
|
|
17
25
|
serializeEmptyFeatures: boolean;
|
|
18
|
-
|
|
26
|
+
/**
|
|
27
|
+
* A {@link PropertyValueSerializer} implementation.
|
|
28
|
+
* Default = DefaultPropertyValueSerializer.
|
|
29
|
+
*/
|
|
30
|
+
propertyValueSerializer: PropertyValueSerializer;
|
|
31
|
+
/**
|
|
32
|
+
* Misspelled alias of {@link #propertyValueSerializer}, kept for backward compatibility, and to be deprecated and removed later.
|
|
33
|
+
*/
|
|
34
|
+
primitiveTypeSerializer: PropertyValueSerializer;
|
|
19
35
|
}>;
|
|
20
36
|
/**
|
|
21
37
|
* @return the {@link LionWebJsonMetaPointer} for the given {@link Feature}.
|
|
22
38
|
*/
|
|
23
39
|
export declare const metaPointerFor: (feature: Feature) => LionWebJsonMetaPointer;
|
|
40
|
+
/**
|
|
41
|
+
* @return a function that serializes the {@link Node nodes} passed to it.
|
|
42
|
+
*/
|
|
43
|
+
export declare const nodeSerializer: <NT extends Node>(reader: Reader<NT>, serializationOptions?: SerializationOptions) => (nodes: NT[]) => LionWebJsonChunk;
|
|
24
44
|
/**
|
|
25
45
|
* @return a {@link LionWebJsonChunk} of the given model (i.e., an array of {@link Node nodes} - the first argument) to the LionWeb serialization JSON format.
|
|
46
|
+
* <em>Note:</em> this function will be deprecated and removed later — use {@link nodeSerializer} instead.
|
|
26
47
|
*/
|
|
27
|
-
export declare const serializeNodes: <NT extends Node>(nodes: NT[],
|
|
48
|
+
export declare const serializeNodes: <NT extends Node>(nodes: NT[], reader: Reader<NT>, propertyValueSerializerOrOptions?: PropertyValueSerializer | SerializationOptions) => LionWebJsonChunk;
|
|
28
49
|
//# sourceMappingURL=serializer.d.ts.map
|
package/dist/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,gBAAgB,EAChB,sBAAsB,EAEzB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC,OAAO,EAGH,OAAO,EAGP,QAAQ,EAGX,MAAM,eAAe,CAAA;AAGtB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAA;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;CAAG;AAQ3E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC;IACvC;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAA;IAE/B;;;OAGG;IACH,uBAAuB,EAAE,uBAAuB,CAAA;IAEhD;;OAEG;IACH,uBAAuB,EAAE,uBAAuB,CAAA;CACnD,CAAC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,YAAa,OAAO,KAAG,sBAOjD,CAAA;AAGD;;GAEG;AACH,eAAO,MAAM,cAAc,+DAAgE,oBAAoB,sBAKrF,gBA8GzB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,wFAGY,uBAAuB,GAAG,oBAAoB,KAClF,gBAQS,CAAA"}
|
package/dist/serializer.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { currentSerializationFormatVersion } from "@lionweb/json";
|
|
2
2
|
import { asArray } from "@lionweb/ts-utils";
|
|
3
3
|
import { asIds } from "./functions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BuiltinPropertyValueSerializer } from "./m3/builtins.js";
|
|
5
5
|
import { allFeaturesOf } from "./m3/functions.js";
|
|
6
6
|
import { Containment, Enumeration, PrimitiveType, Property, Reference, simpleNameDeducer } from "./m3/types.js";
|
|
7
|
-
const
|
|
7
|
+
const isPropertyValueSerializer = (value) => typeof value === "object" && value !== null && "serializeValue" in value && typeof value.serializeValue === "function";
|
|
8
8
|
/**
|
|
9
9
|
* @return the {@link LionWebJsonMetaPointer} for the given {@link Feature}.
|
|
10
10
|
*/
|
|
@@ -17,114 +17,122 @@ export const metaPointerFor = (feature) => {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* @return a
|
|
20
|
+
* @return a function that serializes the {@link Node nodes} passed to it.
|
|
21
21
|
*/
|
|
22
|
-
export const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
languagesUsed.push(language);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const visit = (node, parent) => {
|
|
38
|
-
if (ids[node.id]) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const classifier = extractionFacade.classifierOf(node);
|
|
42
|
-
const language = classifier.language;
|
|
43
|
-
registerLanguageUsed(language);
|
|
44
|
-
const serializedNode = {
|
|
45
|
-
id: node.id,
|
|
46
|
-
classifier: classifier.metaPointer(),
|
|
47
|
-
properties: [],
|
|
48
|
-
containments: [],
|
|
49
|
-
references: [],
|
|
50
|
-
annotations: [],
|
|
51
|
-
parent: null
|
|
22
|
+
export const nodeSerializer = (reader, serializationOptions) => {
|
|
23
|
+
const propertyValueSerializer = serializationOptions?.propertyValueSerializer ?? serializationOptions?.primitiveTypeSerializer ?? new BuiltinPropertyValueSerializer();
|
|
24
|
+
const serializeEmptyFeatures = serializationOptions?.serializeEmptyFeatures ?? true;
|
|
25
|
+
return (nodes) => {
|
|
26
|
+
const serializedNodes = []; // keep nodes as much as possible "in order"
|
|
27
|
+
const ids = {}; // maintain a map to keep track of IDs of nodes that have been serialized
|
|
28
|
+
const languagesUsed = [];
|
|
29
|
+
const registerLanguageUsed = (language) => {
|
|
30
|
+
if (!languagesUsed.some(languageUsed => language.equals(languageUsed))) {
|
|
31
|
+
languagesUsed.push(language);
|
|
32
|
+
}
|
|
33
|
+
// TODO could make this more efficient by using a hash table
|
|
52
34
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
35
|
+
const visit = (node, parent) => {
|
|
36
|
+
if (node.id in ids) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const classifier = reader.classifierOf(node);
|
|
40
|
+
const language = classifier.language;
|
|
41
|
+
registerLanguageUsed(language);
|
|
42
|
+
const serializedNode = {
|
|
43
|
+
id: node.id,
|
|
44
|
+
classifier: classifier.metaPointer(),
|
|
45
|
+
properties: [],
|
|
46
|
+
containments: [],
|
|
47
|
+
references: [],
|
|
48
|
+
annotations: [],
|
|
49
|
+
parent: null
|
|
50
|
+
};
|
|
51
|
+
serializedNodes.push(serializedNode);
|
|
52
|
+
ids[node.id] = true;
|
|
53
|
+
allFeaturesOf(classifier).forEach(feature => {
|
|
54
|
+
const value = reader.getFeatureValue(node, feature);
|
|
55
|
+
const featureLanguage = feature.classifier.language;
|
|
56
|
+
registerLanguageUsed(featureLanguage);
|
|
57
|
+
const featureMetaPointer = metaPointerFor(feature);
|
|
58
|
+
if (feature instanceof Property) {
|
|
59
|
+
if (value === undefined && !serializeEmptyFeatures) {
|
|
60
|
+
// for immediate backward compatibility: skip empty property values regardless of options?.skipEmptyValues
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const encodedValue = (() => {
|
|
64
|
+
// (could also just inspect type of value:)
|
|
65
|
+
if (feature.type instanceof PrimitiveType) {
|
|
66
|
+
return propertyValueSerializer.serializeValue(value, feature);
|
|
67
|
+
}
|
|
68
|
+
if (feature.type instanceof Enumeration) {
|
|
69
|
+
return reader.enumerationLiteralFrom(value, feature.type)?.key;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
})();
|
|
73
|
+
serializedNode.properties.push({
|
|
74
|
+
property: featureMetaPointer,
|
|
75
|
+
value: encodedValue ?? null // (undefined -> null)
|
|
76
|
+
});
|
|
63
77
|
return;
|
|
64
78
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
if (feature.type instanceof Enumeration) {
|
|
71
|
-
return extractionFacade.enumerationLiteralFrom(value, feature.type)?.key;
|
|
79
|
+
if (feature instanceof Containment) {
|
|
80
|
+
const children = asArray(value);
|
|
81
|
+
if (children.length === 0 && !serializeEmptyFeatures) {
|
|
82
|
+
return;
|
|
72
83
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
serializedNode.containments.push({
|
|
85
|
+
containment: featureMetaPointer,
|
|
86
|
+
children: asIds(children)
|
|
87
|
+
.filter(childId => childId !== null)
|
|
88
|
+
.map(childId => childId)
|
|
89
|
+
});
|
|
90
|
+
children.forEach(childOrNull => {
|
|
91
|
+
if (childOrNull !== null) {
|
|
92
|
+
visit(childOrNull, node);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
84
95
|
return;
|
|
85
96
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
children.forEach(childOrNull => {
|
|
93
|
-
if (childOrNull !== null) {
|
|
94
|
-
visit(childOrNull, node);
|
|
97
|
+
if (feature instanceof Reference) {
|
|
98
|
+
// Note: value can be null === typeof unresolved, e.g. on an unset (or previously unresolved) single-valued reference
|
|
99
|
+
const targets = asArray(value);
|
|
100
|
+
if (targets.length === 0 && !serializeEmptyFeatures) {
|
|
101
|
+
return;
|
|
95
102
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
serializedNode.references.push({
|
|
104
|
+
reference: featureMetaPointer,
|
|
105
|
+
targets: targets
|
|
106
|
+
.filter(tOrNull => tOrNull !== null) // (skip "non-connected" targets)
|
|
107
|
+
.map(t => t)
|
|
108
|
+
.map(t => ({
|
|
109
|
+
resolveInfo: (reader.resolveInfoFor ? reader.resolveInfoFor(t) : simpleNameDeducer(t)) ?? null,
|
|
110
|
+
reference: t.id
|
|
111
|
+
}))
|
|
112
|
+
});
|
|
103
113
|
return;
|
|
104
114
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
const annotations = asArray(node.annotations); // assumes that annotations also all are of type NT (which is not unreasonable)
|
|
119
|
-
serializedNode.annotations = annotations.map(annotation => annotation.id);
|
|
120
|
-
annotations.forEach(annotation => visit(annotation, node));
|
|
121
|
-
serializedNode.parent = parent?.id ?? null; // (undefined -> null)
|
|
122
|
-
};
|
|
123
|
-
nodes.forEach(node => visit(node, undefined));
|
|
124
|
-
return {
|
|
125
|
-
serializationFormatVersion: currentSerializationFormatVersion,
|
|
126
|
-
languages: languagesUsed.map(({ key, version }) => ({ key, version })),
|
|
127
|
-
nodes: serializedNodes
|
|
115
|
+
});
|
|
116
|
+
const annotations = asArray(node.annotations); // assumes that annotations also all are of type NT (which is not unreasonable)
|
|
117
|
+
serializedNode.annotations = annotations.map(annotation => annotation.id);
|
|
118
|
+
annotations.forEach(annotation => visit(annotation, node));
|
|
119
|
+
serializedNode.parent = parent?.id ?? null; // (undefined -> null)
|
|
120
|
+
};
|
|
121
|
+
nodes.forEach(node => visit(node, undefined));
|
|
122
|
+
return {
|
|
123
|
+
serializationFormatVersion: currentSerializationFormatVersion,
|
|
124
|
+
languages: languagesUsed.map(({ key, version }) => ({ key, version })),
|
|
125
|
+
nodes: serializedNodes
|
|
126
|
+
};
|
|
128
127
|
};
|
|
129
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* @return a {@link LionWebJsonChunk} of the given model (i.e., an array of {@link Node nodes} - the first argument) to the LionWeb serialization JSON format.
|
|
131
|
+
* <em>Note:</em> this function will be deprecated and removed later — use {@link nodeSerializer} instead.
|
|
132
|
+
*/
|
|
133
|
+
export const serializeNodes = (nodes, reader, propertyValueSerializerOrOptions) => nodeSerializer(reader, isPropertyValueSerializer(propertyValueSerializerOrOptions)
|
|
134
|
+
? {
|
|
135
|
+
propertyValueSerializer: propertyValueSerializerOrOptions
|
|
136
|
+
}
|
|
137
|
+
: propertyValueSerializerOrOptions)(nodes);
|
|
130
138
|
//# sourceMappingURL=serializer.js.map
|
package/dist/serializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iCAAiC,EAKpC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAGtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EACH,WAAW,EACX,WAAW,EAGX,aAAa,EACb,QAAQ,EACR,SAAS,EACT,iBAAiB,EACpB,MAAM,eAAe,CAAA;AAgBtB,MAAM,yBAAyB,GAAG,CAAC,KAAc,EAAoC,EAAE,CACnF,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,gBAAgB,IAAI,KAAK,IAAI,O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AED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,KAAW,EACX,MAAkB,EAClB,gCAAiF,EACjE,EAAE,CAClB,cAAc,CACV,MAAM,EACN,yBAAyB,CAAC,gCAAgC,CAAC;IACvD,CAAC,CAAC;QACE,uBAAuB,EAAE,gCAAgC;KAC5D;IACD,CAAC,CAAC,gCAAgC,CACzC,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LionWebId, LionWebKey } from "@lionweb/json";
|
|
2
|
+
import { Classifier, EnumerationLiteral, Feature } from "./m3/types.js";
|
|
3
|
+
import { Node } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* An interface that's used to parametrize generic deserialization of serialization chunks to
|
|
6
|
+
* (in-memory) nodes of the given type (parameter).
|
|
7
|
+
* Implementations of these interfaces {w|c}ould be:
|
|
8
|
+
* - specific to LionCore (so to match m3/types.ts)
|
|
9
|
+
* - generic to deserialize into {@link DynamicNode dynamic nodes}
|
|
10
|
+
*/
|
|
11
|
+
export interface Writer<NT extends Node, PNT extends Node = NT> {
|
|
12
|
+
/**
|
|
13
|
+
* @return An instance of the given concept, also given its parent (or {@link undefined} for root nodes),
|
|
14
|
+
* its ID and the values of the node's properties ("settings").
|
|
15
|
+
* (The latter may be required as arguments for the constructor of a class, whose instances represent nodes.)
|
|
16
|
+
*/
|
|
17
|
+
nodeFor: (parent: PNT | undefined, classifier: Classifier, id: LionWebId, propertySettings: {
|
|
18
|
+
[propertyKey: LionWebKey]: unknown;
|
|
19
|
+
}) => NT;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the *single* given value of the indicated {@link Feature} on the given node.
|
|
22
|
+
* This means adding it in case the feature is multi-valued, meaning it is a {@link Link} with {@code multiple = true}.
|
|
23
|
+
*/
|
|
24
|
+
setFeatureValue: (node: NT, feature: Feature, value: unknown) => void;
|
|
25
|
+
/**
|
|
26
|
+
* @return The runtime encoding of the given {@link EnumerationLiteral}.
|
|
27
|
+
*/
|
|
28
|
+
encodingOf: (literal: EnumerationLiteral) => unknown;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Alias for {@link Writer}, kept for backward compatibility, and to be deprecated and removed later.
|
|
32
|
+
*/
|
|
33
|
+
export interface InstantiationFacade<NT extends Node, PNT extends Node = NT> extends Writer<NT, PNT> {
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Type def. for functions that update features’ values on a settings object.
|
|
37
|
+
*/
|
|
38
|
+
export type SettingsUpdater = (settings: Record<string, unknown>, feature: Feature, value: unknown) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
41
|
+
* (either a {@link Node node} or a sub object of it), using the feature's *name*.
|
|
42
|
+
*/
|
|
43
|
+
export declare const updateSettingsNameBased: SettingsUpdater;
|
|
44
|
+
/**
|
|
45
|
+
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
46
|
+
* (either a {@link Node node} or a sub object of it), using the feature's *key*.
|
|
47
|
+
*/
|
|
48
|
+
export declare const updateSettingsKeyBased: SettingsUpdater;
|
|
49
|
+
//# sourceMappingURL=writing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writing.d.ts","sourceRoot":"","sources":["../src/writing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAQ,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC;;;;;;GAMG;AACH,MAAM,WAAW,MAAM,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE;IAE1D;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE;QAAE,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAA;KAAE,KAAK,EAAE,CAAA;IAGzI;;;OAGG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAGrE;;OAEG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAA;CAEvD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE,CAAE,SAAQ,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;CAAG;AAGvG;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;AAqB3G;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAAyC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,iBAAyB,CAAA"}
|
package/dist/writing.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Link } from "./m3/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* @return a {@link SettingsUpdater} that uses the given “meta key” – which is a property/key on the {@link Feature} type –
|
|
4
|
+
* to look up what key to look a feature’s value up on a settings object.
|
|
5
|
+
* <em>Note:</em> for internal use only — use with some care!
|
|
6
|
+
*/
|
|
7
|
+
const settingsUpdater = (metaKey) => (settings, feature, value) => {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
const key = feature[metaKey];
|
|
10
|
+
if (feature instanceof Link && feature.multiple) {
|
|
11
|
+
if (!Array.isArray(settings[key])) {
|
|
12
|
+
settings[key] = [];
|
|
13
|
+
}
|
|
14
|
+
settings[key].push(value);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
settings[key] = value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
22
|
+
* (either a {@link Node node} or a sub object of it), using the feature's *name*.
|
|
23
|
+
*/
|
|
24
|
+
export const updateSettingsNameBased = settingsUpdater("name");
|
|
25
|
+
/**
|
|
26
|
+
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
27
|
+
* (either a {@link Node node} or a sub object of it), using the feature's *key*.
|
|
28
|
+
*/
|
|
29
|
+
export const updateSettingsKeyBased = settingsUpdater("key");
|
|
30
|
+
//# sourceMappingURL=writing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writing.js","sourceRoot":"","sources":["../src/writing.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2C,IAAI,EAAE,MAAM,eAAe,CAAA;AA8C7E;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,OAAsB,EAAmB,EAAE,CAChE,CAAC,QAAiC,EAAE,OAAgB,EAAE,KAAc,EAAQ,EAAE;IAClF,8DAA8D;IACtD,MAAM,GAAG,GAAI,OAAe,CAAC,OAAO,CAAW,CAAA;IAC/C,IAAI,OAAO,YAAY,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAChC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QACtB,CAAC;QACA,QAAQ,CAAC,GAAG,CAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;SAAM,CAAC;QACJ,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACzB,CAAC;AACL,CAAC,CAAA;AAEL;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAoB,eAAe,CAAC,MAAM,CAAC,CAAA;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/core",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.7",
|
|
4
4
|
"description": "LionWeb core for {Java|Type}Script",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"release": "npm publish"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@lionweb/json": "0.7.0-alpha.
|
|
31
|
-
"@lionweb/ts-utils": "0.7.0-alpha.
|
|
30
|
+
"@lionweb/json": "0.7.0-alpha.7",
|
|
31
|
+
"@lionweb/ts-utils": "0.7.0-alpha.7"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/facade.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { LionWebId, LionWebKey } from "@lionweb/json";
|
|
2
|
-
import { Classifier, Enumeration, EnumerationLiteral, Feature } from "./m3/types.js";
|
|
3
|
-
import { Node } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* Type def. for functions that deduce the {@link Classifier classifier} of a given {@link Node node}.
|
|
6
|
-
*/
|
|
7
|
-
type ClassifierDeducer<NT extends Node> = (node: NT) => Classifier;
|
|
8
|
-
/**
|
|
9
|
-
* Type def. for functions that deduce the string value of the `resolveInfo` field of a
|
|
10
|
-
* {@link LionWebJsonReferenceTarget serialized reference target}, or {@code undefined}
|
|
11
|
-
* to indicate that no `resolveInfo` could be derived.
|
|
12
|
-
*/
|
|
13
|
-
type ResolveInfoDeducer<NT extends Node> = (node: NT) => string | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Two interfaces that defines façades for in-memory models.
|
|
16
|
-
* Instances/implementations of this interface parametrize generic (de-)serialization.
|
|
17
|
-
* Implementations of these interfaces {w|c}ould be:
|
|
18
|
-
* - specific to Lioncore (so to match m3/types.ts)
|
|
19
|
-
* - generic to deserialize into @link DynamicNode}
|
|
20
|
-
*/
|
|
21
|
-
interface ExtractionFacade<NT extends Node> {
|
|
22
|
-
/**
|
|
23
|
-
* @return The {@link Concept concept} of the given node
|
|
24
|
-
*/
|
|
25
|
-
classifierOf: ClassifierDeducer<NT>;
|
|
26
|
-
/**
|
|
27
|
-
* @return The value of the given {@link Feature feature} on the given node.
|
|
28
|
-
*/
|
|
29
|
-
getFeatureValue: (node: NT, feature: Feature) => unknown;
|
|
30
|
-
/**
|
|
31
|
-
* @return The {@link EnumerationLiteral} corresponding to
|
|
32
|
-
* the given {@link Enumeration} and the runtime encoding of a literal of it,
|
|
33
|
-
*/
|
|
34
|
-
enumerationLiteralFrom: (encoding: unknown, enumeration: Enumeration) => EnumerationLiteral | null;
|
|
35
|
-
/**
|
|
36
|
-
* @return The string value of the `resolveInfo` field of a {@link LionWebJsonReferenceTarget serialized reference target},
|
|
37
|
-
* or {@code undefined} to indicate that no `resolveInfo` could be derived.
|
|
38
|
-
*/
|
|
39
|
-
resolveInfoFor?: ResolveInfoDeducer<NT>;
|
|
40
|
-
}
|
|
41
|
-
interface InstantiationFacade<NT extends Node, PNT extends Node = NT> {
|
|
42
|
-
/**
|
|
43
|
-
* @return An instance of the given concept, also given its parent (or {@link undefined} for root nodes),
|
|
44
|
-
* its ID and the values of the node's properties ("settings").
|
|
45
|
-
* (The latter may be required as arguments for the constructor of a class, whose instances represent nodes.)
|
|
46
|
-
*/
|
|
47
|
-
nodeFor: (parent: PNT | undefined, classifier: Classifier, id: LionWebId, propertySettings: {
|
|
48
|
-
[propertyKey: LionWebKey]: unknown;
|
|
49
|
-
}) => NT;
|
|
50
|
-
/**
|
|
51
|
-
* Sets the *single* given value of the indicated {@link Feature} on the given node.
|
|
52
|
-
* This means adding it in case the feature is multi-valued, meaning it is a {@link Link} with {@code multiple = true}.
|
|
53
|
-
*/
|
|
54
|
-
setFeatureValue: (node: NT, feature: Feature, value: unknown) => void;
|
|
55
|
-
/**
|
|
56
|
-
* @return The runtime encoding of the given {@link EnumerationLiteral}.
|
|
57
|
-
*/
|
|
58
|
-
encodingOf: (literal: EnumerationLiteral) => unknown;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Type def. for functions that extract {@link Node nodes} from a given one.
|
|
62
|
-
*/
|
|
63
|
-
type NodesExtractor<NT extends Node> = (node: NT) => NT[];
|
|
64
|
-
/**
|
|
65
|
-
* @return A function that extracts the children from a given node.
|
|
66
|
-
*/
|
|
67
|
-
declare const childrenExtractorUsing: <NT extends Node>(extractionFacade: ExtractionFacade<NT>) => NodesExtractor<NT>;
|
|
68
|
-
/**
|
|
69
|
-
* @return a function that extracts *all* nodes from a given start node - usually a root node.
|
|
70
|
-
*/
|
|
71
|
-
declare const nodesExtractorUsing: <NT extends Node>(extractionFacade: ExtractionFacade<NT>) => NodesExtractor<NT>;
|
|
72
|
-
type SettingsUpdater = (settings: Record<string, unknown>, feature: Feature, value: unknown) => void;
|
|
73
|
-
/**
|
|
74
|
-
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
75
|
-
* (either a {@link Node node} or a sub object of it), using the feature's *name*.
|
|
76
|
-
*/
|
|
77
|
-
declare const updateSettingsNameBased: SettingsUpdater;
|
|
78
|
-
/**
|
|
79
|
-
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
80
|
-
* (either a {@link Node node} or a sub object of it), using the feature's *key*.
|
|
81
|
-
*/
|
|
82
|
-
declare const updateSettingsKeyBased: SettingsUpdater;
|
|
83
|
-
export type { ClassifierDeducer, ExtractionFacade, InstantiationFacade, NodesExtractor, ResolveInfoDeducer };
|
|
84
|
-
export { childrenExtractorUsing, nodesExtractorUsing, updateSettingsKeyBased, updateSettingsNameBased };
|
|
85
|
-
//# sourceMappingURL=facade.d.ts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A;KAAE,KAAK,EAAE,CAAA;IAGzI;;;OAGG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAGrE;;OAEG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAA;CAEvD;AAED;;GAEG;AACH,KAAK,cAAc,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAA;AAEzD;;GAEG;AACH,QAAA,MAAM,sBAAsB,iFAOf,CAAA;AAGb;;GAEG;AACH,QAAA,MAAM,mBAAmB,iFACsE,CAAA;AAG/F,KAAK,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;AAiBpG;;;GAGG;AACH,QAAA,MAAM,uBAAuB,EAAE,eAAyC,CAAA;AAExE;;;GAGG;AACH,QAAA,MAAM,sBAAsB,iBAAyB,CAAA;AAErD,YAAY,EACR,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EACrB,CAAA;AAED,OAAO,EACH,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EAC1B,CAAA"}
|
package/dist/facade.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { flatMapNonCyclingFollowing, trivialFlatMapper } from "@lionweb/ts-utils";
|
|
2
|
-
import { allFeaturesOf, isContainment } from "./m3/functions.js";
|
|
3
|
-
import { Link } from "./m3/types.js";
|
|
4
|
-
/**
|
|
5
|
-
* @return A function that extracts the children from a given node.
|
|
6
|
-
*/
|
|
7
|
-
const childrenExtractorUsing = (extractionFacade) => (node) => [
|
|
8
|
-
...(allFeaturesOf(extractionFacade.classifierOf(node))
|
|
9
|
-
.filter(isContainment)
|
|
10
|
-
.flatMap((containment) => extractionFacade.getFeatureValue(node, containment) ?? [])),
|
|
11
|
-
// FIXME there's NO guarantee about the result of extractionFacade.getFeatureValue(node, containment) !!!
|
|
12
|
-
...node.annotations
|
|
13
|
-
];
|
|
14
|
-
/**
|
|
15
|
-
* @return a function that extracts *all* nodes from a given start node - usually a root node.
|
|
16
|
-
*/
|
|
17
|
-
const nodesExtractorUsing = (extractionFacade) => flatMapNonCyclingFollowing(trivialFlatMapper, childrenExtractorUsing(extractionFacade));
|
|
18
|
-
const settingsUpdater = (metaKey) => (settings, feature, value) => {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
const key = feature[metaKey];
|
|
21
|
-
if (feature instanceof Link && feature.multiple) {
|
|
22
|
-
if (!Array.isArray(settings[key])) {
|
|
23
|
-
settings[key] = [];
|
|
24
|
-
}
|
|
25
|
-
settings[key].push(value);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
settings[key] = value;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
33
|
-
* (either a {@link Node node} or a sub object of it), using the feature's *name*.
|
|
34
|
-
*/
|
|
35
|
-
const updateSettingsNameBased = settingsUpdater("name");
|
|
36
|
-
/**
|
|
37
|
-
* Updates the value of the given {@link Feature feature} on the given "settings" object
|
|
38
|
-
* (either a {@link Node node} or a sub object of it), using the feature's *key*.
|
|
39
|
-
*/
|
|
40
|
-
const updateSettingsKeyBased = settingsUpdater("key");
|
|
41
|
-
export { childrenExtractorUsing, nodesExtractorUsing, updateSettingsKeyBased, updateSettingsNameBased };
|
|
42
|
-
//# sourceMappingURL=facade.js.map
|
package/dist/facade.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../src/facade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,E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