@lionweb/core 0.8.0-beta.6 → 0.8.0-beta.8
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 +6 -2
- package/dist/deserializer.d.ts +3 -3
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +4 -4
- package/dist/deserializer.js.map +1 -1
- package/dist/dynamic-facade.d.ts +2 -2
- package/dist/dynamic-facade.d.ts.map +1 -1
- package/dist/dynamic-facade.js +3 -2
- package/dist/dynamic-facade.js.map +1 -1
- package/dist/extraction.d.ts +2 -2
- package/dist/extraction.d.ts.map +1 -1
- package/dist/extraction.js.map +1 -1
- package/dist/m1/reference-utils.d.ts +3 -3
- package/dist/m1/reference-utils.d.ts.map +1 -1
- package/dist/m1/reference-utils.js.map +1 -1
- package/dist/m3/builtins-function.js +2 -2
- package/dist/m3/builtins-function.js.map +1 -1
- package/dist/m3/deserializer.d.ts +1 -1
- package/dist/m3/deserializer.d.ts.map +1 -1
- package/dist/m3/deserializer.js +2 -2
- package/dist/m3/deserializer.js.map +1 -1
- package/dist/m3/reading-writing.d.ts +1 -1
- package/dist/m3/reading-writing.d.ts.map +1 -1
- package/dist/m3/reading-writing.js +3 -3
- package/dist/m3/reading-writing.js.map +1 -1
- package/dist/m3/serializer.d.ts +2 -2
- package/dist/m3/serializer.js +3 -3
- package/dist/m3/serializer.js.map +1 -1
- package/dist/m3/symbol-table.d.ts +3 -3
- package/dist/m3/types.d.ts +2 -2
- package/dist/m3/types.d.ts.map +1 -1
- package/dist/m3/types.js +1 -1
- package/dist/m3/types.js.map +1 -1
- package/dist/m3/versions/v2023_1/lioncore.d.ts +3 -3
- package/dist/m3/versions/v2023_1/lioncore.js +3 -3
- package/dist/m3/versions.d.ts +1 -5
- package/dist/m3/versions.d.ts.map +1 -1
- package/dist/m3/versions.js +1 -5
- package/dist/m3/versions.js.map +1 -1
- package/dist/reading.d.ts +8 -6
- package/dist/reading.d.ts.map +1 -1
- package/dist/serializer.d.ts +7 -7
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +2 -3
- package/dist/serializer.js.map +1 -1
- package/dist/writing.d.ts +1 -1
- package/package.json +3 -3
- package/src/deserializer.ts +6 -6
- package/src/dynamic-facade.ts +3 -2
- package/src/extraction.ts +3 -3
- package/src/m1/reference-utils.ts +6 -6
- package/src/m3/builtins-function.ts +2 -2
- package/src/m3/deserializer.ts +3 -3
- package/src/m3/reading-writing.ts +3 -3
- package/src/m3/serializer.ts +4 -4
- package/src/m3/symbol-table.ts +3 -3
- package/src/m3/types.ts +2 -2
- package/src/m3/versions/v2023_1/lioncore.ts +3 -3
- package/src/m3/versions.ts +1 -6
- package/src/reading.ts +8 -6
- package/src/serializer.ts +12 -13
- package/src/writing.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/m3/versions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAW,CAAA;AAG7C;;GAEG;AACH,eAAO,MAAM,eAAe;;CAGlB,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBAAiC,CAAA;AAEhE
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/m3/versions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAW,CAAA;AAG7C;;GAEG;AACH,eAAO,MAAM,eAAe;;CAGlB,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBAAiC,CAAA;AAEhE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,4BAA4B,MAAM,KAAG,cAAc,GAAG,SACkB,CAAA"}
|
package/dist/m3/versions.js
CHANGED
|
@@ -2,7 +2,7 @@ import { v2023_1 } from "./versions/v2023_1/version.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The *current* release(d) version.
|
|
4
4
|
*
|
|
5
|
-
* @deprecated Use
|
|
5
|
+
* @deprecated Use `LionWebVersions.v2023_1.serializationFormatVersion` instead.
|
|
6
6
|
*/
|
|
7
7
|
export const currentReleaseVersion = "2023.1";
|
|
8
8
|
/**
|
|
@@ -16,10 +16,6 @@ export const LionWebVersions = {
|
|
|
16
16
|
* All LionWeb versions.
|
|
17
17
|
*/
|
|
18
18
|
export const allLionWebVersions = Object.values(LionWebVersions);
|
|
19
|
-
/**
|
|
20
|
-
* The current default LionWeb version.
|
|
21
|
-
*/
|
|
22
|
-
export const defaultLionWebVersion = LionWebVersions.v2023_1;
|
|
23
19
|
/**
|
|
24
20
|
* @return the {@link LionWebVersion} matching the given `serializationFormatVersion` string,
|
|
25
21
|
* or {@link undefined} if there’s none.
|
package/dist/m3/versions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/m3/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAA;AAIvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAAA;AAG7C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,uFAAuF;IACvF,OAAO;CACD,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;AAEhE
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/m3/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAA;AAIvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAAA;AAG7C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,uFAAuF;IACvF,OAAO;CACD,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,0BAAkC,EAA8B,EAAE,CACjG,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,0BAA0B,KAAK,0BAA0B,CAAC,CAAA"}
|
package/dist/reading.d.ts
CHANGED
|
@@ -7,18 +7,20 @@ export type ClassifierDeducer<NT extends Node> = (node: NT) => Classifier;
|
|
|
7
7
|
/**
|
|
8
8
|
* Type def. for functions that deduce the string value of the `resolveInfo` field of a
|
|
9
9
|
* {@link LionWebJsonReferenceTarget serialized reference target},
|
|
10
|
-
* or
|
|
10
|
+
* or `undefined` to indicate that no `resolveInfo` could be derived.
|
|
11
11
|
* The function’s arguments are the target {@link Node} and its containing {@link Reference}.
|
|
12
12
|
*/
|
|
13
13
|
export type ResolveInfoDeducer<NT extends Node> = (node: NT, reference: Reference) => string | undefined;
|
|
14
14
|
/**
|
|
15
15
|
* An interface that's used to parametrize generic serialization of
|
|
16
|
-
* (in-memory) nodes of the given type (parameter)
|
|
16
|
+
* (in-memory) nodes of the given type (parameter) `NT`.
|
|
17
17
|
* Implementations of these interfaces {w|c}ould be:
|
|
18
18
|
* - specific to LionCore (so to match m3/types.ts)
|
|
19
19
|
* - generic to serialize {@link DynamicNode dynamic nodes}
|
|
20
|
+
* The `RT` type (parameter) is the type of any *referenced* node,
|
|
21
|
+
* which could e.g. be wider – most likely – or narrower than `NT`.
|
|
20
22
|
*/
|
|
21
|
-
export interface Reader<NT extends Node> {
|
|
23
|
+
export interface Reader<NT extends Node, RT extends Node = NT> {
|
|
22
24
|
/**
|
|
23
25
|
* @return The {@link Concept concept} of the given node
|
|
24
26
|
*/
|
|
@@ -34,15 +36,15 @@ export interface Reader<NT extends Node> {
|
|
|
34
36
|
enumerationLiteralFrom: (encoding: unknown, enumeration: Enumeration) => EnumerationLiteral | null;
|
|
35
37
|
/**
|
|
36
38
|
* @return The string value of the `resolveInfo` field of a {@link LionWebJsonReferenceTarget serialized reference target},
|
|
37
|
-
* or
|
|
39
|
+
* or `undefined` to indicate that no `resolveInfo` could be derived.
|
|
38
40
|
*/
|
|
39
|
-
resolveInfoFor?: ResolveInfoDeducer<
|
|
41
|
+
resolveInfoFor?: ResolveInfoDeducer<RT>;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Alias for {@link Reader}, kept for backward compatibility, and to be deprecated and removed later.
|
|
43
45
|
*
|
|
44
46
|
* @deprecated Use {@link Reader} instead.
|
|
45
47
|
*/
|
|
46
|
-
export interface ExtractionFacade<NT extends Node> extends Reader<NT> {
|
|
48
|
+
export interface ExtractionFacade<NT extends Node, RT extends Node> extends Reader<NT, RT> {
|
|
47
49
|
}
|
|
48
50
|
//# sourceMappingURL=reading.d.ts.map
|
package/dist/reading.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../src/reading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC/F,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,UAAU,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,KAAK,MAAM,GAAG,SAAS,CAAA;AAExG
|
|
1
|
+
{"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../src/reading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC/F,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,UAAU,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,KAAK,MAAM,GAAG,SAAS,CAAA;AAExG;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM,CAAC,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,EAAE;IAEzD;;OAEG;IACH,YAAY,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAA;IAEnC;;OAEG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;IAGxD;;;OAGG;IACH,sBAAsB,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,KAAK,kBAAkB,GAAG,IAAI,CAAA;IAElG;;;OAGG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAA;CAE1C;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,IAAI,CAAE,SAAQ,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC;CAAG"}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type SerializationOptions = Partial<{
|
|
|
33
33
|
/**
|
|
34
34
|
* A {@link PropertyValueSerializer} implementation.
|
|
35
35
|
* Default = the value of the `propertyValueSerializer` property of the {@link LionWebVersion version} of the LionWeb serialization format,
|
|
36
|
-
* configured through
|
|
36
|
+
* configured through `SerializerConfiguration.lionWebVersion` (which itself defaults to `LionWebVersions.v2023_1`).
|
|
37
37
|
*/
|
|
38
38
|
propertyValueSerializer: PropertyValueSerializer;
|
|
39
39
|
/**
|
|
@@ -50,14 +50,14 @@ export type SerializationOptions = Partial<{
|
|
|
50
50
|
* and `primitiveTypeSerializer` (which is a legacy alias for `propertyValueSerializer`)
|
|
51
51
|
* properties are optional, with defined defaults.
|
|
52
52
|
*/
|
|
53
|
-
export type SerializerConfiguration<NT extends Node> = {
|
|
53
|
+
export type SerializerConfiguration<NT extends Node, RT extends Node = NT> = {
|
|
54
54
|
/**
|
|
55
55
|
* An interface with functions to “read” – i.e., introspect – nodes.
|
|
56
56
|
*/
|
|
57
|
-
reader: Reader<NT>;
|
|
57
|
+
reader: Reader<NT, RT>;
|
|
58
58
|
/**
|
|
59
59
|
* The version of the LionWeb serialization format to serialize in.
|
|
60
|
-
* Default = {@link
|
|
60
|
+
* Default = {@link LionWebVersions.v2023_1}.
|
|
61
61
|
*/
|
|
62
62
|
lionWebVersion?: LionWebVersion;
|
|
63
63
|
} & SerializationOptions;
|
|
@@ -68,15 +68,15 @@ export type SerializerConfiguration<NT extends Node> = {
|
|
|
68
68
|
*
|
|
69
69
|
* This is a legacy version of {@link serializerWith}, kept for backward compatibility, and to be deprecated and removed later.
|
|
70
70
|
*/
|
|
71
|
-
export declare const nodeSerializer: <NT extends Node>(reader: Reader<NT>, serializationOptions?: SerializationOptions) => Serializer<NT>;
|
|
71
|
+
export declare const nodeSerializer: <NT extends Node, RT extends Node = NT>(reader: Reader<NT, RT>, serializationOptions?: SerializationOptions) => Serializer<NT>;
|
|
72
72
|
/**
|
|
73
73
|
* @return a {@link Serializer} function that serializes the {@link Node nodes} passed to it,
|
|
74
74
|
* configured through a `configuration` {@link SerializerConfiguration} object.
|
|
75
75
|
*/
|
|
76
|
-
export declare const serializerWith: <NT extends Node>(configuration: SerializerConfiguration<NT>) => Serializer<NT>;
|
|
76
|
+
export declare const serializerWith: <NT extends Node, RT extends Node = NT>(configuration: SerializerConfiguration<NT, RT>) => Serializer<NT>;
|
|
77
77
|
/**
|
|
78
78
|
* @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.
|
|
79
79
|
* *Note:* this function will be deprecated and removed later — use {@link nodeSerializer} instead.
|
|
80
80
|
*/
|
|
81
|
-
export declare const serializeNodes: <NT extends Node>(nodes: NT[], reader: Reader<NT>, propertyValueSerializerOrOptions?: PropertyValueSerializer | SerializationOptions) => LionWebJsonChunk;
|
|
81
|
+
export declare const serializeNodes: <NT extends Node, RT extends Node = NT>(nodes: NT[], reader: Reader<NT, RT>, propertyValueSerializerOrOptions?: PropertyValueSerializer | SerializationOptions) => LionWebJsonChunk;
|
|
82
82
|
//# 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,EAAa,gBAAgB,EAAmB,MAAM,eAAe,CAAA;AAG5E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAOH,QAAQ,EAGX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIhD;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,gBAAgB,CAAA;AAG3E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAA;CACpE;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;CAA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SAAS,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,EAAE,IAAI;IACzE;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAEtB;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAA;CAClC,GAAG,oBAAoB,CAAA;AAGxB;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,EAAE,EAAE,QAAQ,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,uBAAuB,oBAAoB,KAAG,UAAU,CAAC,EAAE,CAClG,CAAA;AAGvD;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,EAAE,EAAE,eAAe,uBAAuB,CAAC,EAAE,EAAE,EAAE,CAAC,KAAG,UAAU,CAAC,EAAE,CA4InI,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,EAAE,SAAS,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,EAAE,EAChE,OAAO,EAAE,EAAE,EACX,QAAQ,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,EACtB,mCAAmC,uBAAuB,GAAG,oBAAoB,KAClF,gBAQS,CAAA"}
|
package/dist/serializer.js
CHANGED
|
@@ -2,7 +2,7 @@ import { asArray, keepDefineds, lazyMapGet, uniquesAmong } from "@lionweb/ts-uti
|
|
|
2
2
|
import { asIds, metaPointerFor } from "./functions.js";
|
|
3
3
|
import { inheritsDirectlyFrom } from "./m3/functions.js";
|
|
4
4
|
import { Containment, Enumeration, PrimitiveType, Property, Reference, simpleNameDeducer } from "./m3/types.js";
|
|
5
|
-
import {
|
|
5
|
+
import { LionWebVersions } from "./m3/versions.js";
|
|
6
6
|
const isPropertyValueSerializer = (value) => typeof value === "object" && value !== null && "serializeValue" in value && typeof value.serializeValue === "function";
|
|
7
7
|
/**
|
|
8
8
|
* @return a {@link Serializer} function that serializes the {@link Node nodes} passed to it,
|
|
@@ -18,7 +18,7 @@ export const nodeSerializer = (reader, serializationOptions) => serializerWith({
|
|
|
18
18
|
*/
|
|
19
19
|
export const serializerWith = (configuration) => {
|
|
20
20
|
const { reader } = configuration;
|
|
21
|
-
const lionWebVersion = configuration?.lionWebVersion ??
|
|
21
|
+
const lionWebVersion = configuration?.lionWebVersion ?? LionWebVersions.v2023_1;
|
|
22
22
|
const propertyValueSerializer = configuration.propertyValueSerializer ?? configuration.primitiveTypeSerializer ?? lionWebVersion.builtinsFacade.propertyValueSerializer;
|
|
23
23
|
const serializeEmptyFeatures = configuration.serializeEmptyFeatures ?? true;
|
|
24
24
|
const languageKey2version2classifierKey2allFeatures = {};
|
|
@@ -113,7 +113,6 @@ export const serializerWith = (configuration) => {
|
|
|
113
113
|
serializedNode.references.push({
|
|
114
114
|
reference: featureMetaPointer,
|
|
115
115
|
targets: keepDefineds(targets) // (skip "non-connected" targets)
|
|
116
|
-
.map(t => t)
|
|
117
116
|
.map(t => ({
|
|
118
117
|
resolveInfo: (reader.resolveInfoFor ? reader.resolveInfoFor(t, feature) : simpleNameDeducer(t, feature)) ?? null,
|
|
119
118
|
reference: t.id
|
package/dist/serializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAc,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/F,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAEH,WAAW,EACX,WAAW,EAGX,aAAa,EACb,QAAQ,EACR,SAAS,EACT,iBAAiB,EACpB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,
|
|
1
|
+
{"version":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jE,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"}
|
package/dist/writing.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface Writer<NT extends Node, PNT extends Node = NT> {
|
|
|
19
19
|
}) => NT;
|
|
20
20
|
/**
|
|
21
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
|
|
22
|
+
* This means adding it in case the feature is multi-valued, meaning it is a {@link Link} with `multiple = true`.
|
|
23
23
|
*/
|
|
24
24
|
setFeatureValue: (node: NT, feature: Feature, value: unknown) => void;
|
|
25
25
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/core",
|
|
3
|
-
"version": "0.8.0-beta.
|
|
3
|
+
"version": "0.8.0-beta.8",
|
|
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.8.0-beta.
|
|
31
|
-
"@lionweb/ts-utils": "0.8.0-beta.
|
|
30
|
+
"@lionweb/json": "0.8.0-beta.8",
|
|
31
|
+
"@lionweb/ts-utils": "0.8.0-beta.8"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/deserializer.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { consoleProblemReporter, ProblemReporter } from "./reporter.js"
|
|
|
5
5
|
import { MemoisingSymbolTable } from "./m3/symbol-table.js"
|
|
6
6
|
import { Classifier, Containment, Enumeration, Language, PrimitiveType, Property, Reference } from "./m3/types.js"
|
|
7
7
|
import { LionWebVersion } from "./m3/version.js"
|
|
8
|
-
import {
|
|
8
|
+
import { LionWebVersions } from "./m3/versions.js"
|
|
9
9
|
import { unresolved } from "./references.js"
|
|
10
10
|
import { Node } from "./types.js"
|
|
11
11
|
|
|
@@ -42,7 +42,7 @@ export type DeserializerConfiguration<NT extends Node> = {
|
|
|
42
42
|
writer: Writer<NT>,
|
|
43
43
|
/**
|
|
44
44
|
* The version of the LionWeb serialization format to deserialize from.
|
|
45
|
-
* Default = {@link
|
|
45
|
+
* Default = {@link LionWebVersions.v2023_1}.
|
|
46
46
|
*/
|
|
47
47
|
lionWebVersion?: LionWebVersion
|
|
48
48
|
/**
|
|
@@ -51,7 +51,7 @@ export type DeserializerConfiguration<NT extends Node> = {
|
|
|
51
51
|
languages: Language[],
|
|
52
52
|
/**
|
|
53
53
|
* A deserializer for values of properties.
|
|
54
|
-
* Default: `(lionWebVersion ??
|
|
54
|
+
* Default: `(lionWebVersion ?? LionWebVersions.v2023_1).builtinsFacade.propertyValueDeserializer`.
|
|
55
55
|
*/
|
|
56
56
|
propertyValueDeserializer?: PropertyValueDeserializer,
|
|
57
57
|
/**
|
|
@@ -72,7 +72,7 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
72
72
|
const symbolTable = new MemoisingSymbolTable(configuration.languages)
|
|
73
73
|
const { writer } = configuration
|
|
74
74
|
|
|
75
|
-
const lionWebVersion = configuration?.lionWebVersion ??
|
|
75
|
+
const lionWebVersion = configuration?.lionWebVersion ?? LionWebVersions.v2023_1
|
|
76
76
|
const propertyValueDeserializer = configuration.propertyValueDeserializer ?? lionWebVersion.builtinsFacade.propertyValueDeserializer
|
|
77
77
|
const problemReporter = configuration.problemReporter ?? consoleProblemReporter
|
|
78
78
|
|
|
@@ -264,7 +264,7 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
264
264
|
* @param writer - a {@link Writer} that is used to instantiate nodes and set values on them
|
|
265
265
|
* @param languages - {@link Language languages} that the serialized model is expected to conform to
|
|
266
266
|
* @param dependentNodes - a collection of nodes from dependent models against which all references in the serialized model are supposed to resolve against
|
|
267
|
-
* @param propertyValueDeserializer - a deserializer for values of properties (by default `
|
|
267
|
+
* @param propertyValueDeserializer - a deserializer for values of properties (by default `LionWebVersions.v2023_1.builtinsFacade.propertyValueDeserializer`)
|
|
268
268
|
* @param problemReporter - an object for reporting problems (by default a {@link consoleProblemReporter})
|
|
269
269
|
*
|
|
270
270
|
* This is a legacy variant of {@link deserializerWith}, kept for backward compatibility, and to be deprecated and removed later.
|
|
@@ -276,7 +276,7 @@ export const deserializeSerializationChunk = <NT extends Node>(
|
|
|
276
276
|
// TODO facades <--> languages, so it's weird that it looks split up like this
|
|
277
277
|
dependentNodes: Node[],
|
|
278
278
|
// TODO (#13) see if you can turn this into [nodes: Node[], writer: Writer<Node>][] after all
|
|
279
|
-
propertyValueDeserializer: PropertyValueDeserializer =
|
|
279
|
+
propertyValueDeserializer: PropertyValueDeserializer = LionWebVersions.v2023_1.builtinsFacade.propertyValueDeserializer,
|
|
280
280
|
problemReporter: ProblemReporter = consoleProblemReporter
|
|
281
281
|
): NT[] => deserializerWith({ writer, languages, propertyValueDeserializer, problemReporter: problemReporter })(serializationChunk, dependentNodes)
|
|
282
282
|
|
package/src/dynamic-facade.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LionWebKey } from "@lionweb/json"
|
|
2
|
-
import { Classifier,
|
|
2
|
+
import { Classifier, LionWebVersions } from "./m3/index.js"
|
|
3
3
|
import { Reader, ResolveInfoDeducer } from "./reading.js"
|
|
4
4
|
import { Node } from "./types.js"
|
|
5
5
|
import { updateSettingsKeyBased, Writer } from "./writing.js"
|
|
@@ -32,7 +32,8 @@ export const dynamicReader: Reader<DynamicNode> = ({
|
|
|
32
32
|
enumerationLiteralFrom: (value, enumeration) =>
|
|
33
33
|
enumeration.literals.find(({key}) => key === value)
|
|
34
34
|
?? null, // (undefined -> null)
|
|
35
|
-
resolveInfoFor: propertyGetterFor(
|
|
35
|
+
resolveInfoFor: propertyGetterFor(LionWebVersions.v2023_1.builtinsFacade.features.inamed_name.key)
|
|
36
|
+
// TODO have this parametrized in the LionWeb version, instead of relying on keys not changing between versions
|
|
36
37
|
})
|
|
37
38
|
|
|
38
39
|
/**
|
package/src/extraction.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type NodesExtractor<NT extends Node> = (node: NT) => NT[]
|
|
|
13
13
|
/**
|
|
14
14
|
* @return A function that extracts the children from a given node.
|
|
15
15
|
*/
|
|
16
|
-
export const childrenExtractorUsing = <NT extends Node>(reader: Reader<NT>): NodesExtractor<NT> =>
|
|
16
|
+
export const childrenExtractorUsing = <NT extends Node, RT extends Node = NT>(reader: Reader<NT, RT>): NodesExtractor<NT> =>
|
|
17
17
|
(node: NT): NT[] => [
|
|
18
18
|
...(allFeaturesOf(reader.classifierOf(node))
|
|
19
19
|
.filter(isContainment)
|
|
@@ -26,6 +26,6 @@ export const childrenExtractorUsing = <NT extends Node>(reader: Reader<NT>): Nod
|
|
|
26
26
|
/**
|
|
27
27
|
* @return a function that extracts *all* nodes from a given start node - usually a root node.
|
|
28
28
|
*/
|
|
29
|
-
export const nodesExtractorUsing = <NT extends Node>(reader: Reader<NT>): NodesExtractor<NT> =>
|
|
30
|
-
flatMapNonCyclingFollowing(trivialFlatMapper, childrenExtractorUsing<NT>(reader))
|
|
29
|
+
export const nodesExtractorUsing = <NT extends Node, RT extends Node = NT>(reader: Reader<NT, RT>): NodesExtractor<NT> =>
|
|
30
|
+
flatMapNonCyclingFollowing(trivialFlatMapper, childrenExtractorUsing<NT, RT>(reader))
|
|
31
31
|
|
|
@@ -29,9 +29,9 @@ export class ReferenceValue<NT extends Node> {
|
|
|
29
29
|
* @param reader - a {@link Reader} to reflect on nodes.
|
|
30
30
|
* _Note_ that it's assumed that its {@link getFeatureValue} function doesn't throw.
|
|
31
31
|
*/
|
|
32
|
-
export const referenceValues = <NT extends Node>(
|
|
32
|
+
export const referenceValues = <NT extends Node, RT extends Node = NT>(
|
|
33
33
|
scope: NT[],
|
|
34
|
-
reader: Reader<NT>
|
|
34
|
+
reader: Reader<NT, RT>
|
|
35
35
|
): ReferenceValue<NT>[] => {
|
|
36
36
|
const visit = (sourceNode: NT, reference: Reference): ReferenceValue<NT>[] => {
|
|
37
37
|
if (reference.multiple) {
|
|
@@ -74,10 +74,10 @@ export const referenceValues = <NT extends Node>(
|
|
|
74
74
|
* @param reader - a {@link Reader} to reflect on nodes.
|
|
75
75
|
* _Note_ that it's assumed that its {@link getFeatureValue} function doesn't throw.
|
|
76
76
|
*/
|
|
77
|
-
export const incomingReferences = <NT extends Node>(
|
|
77
|
+
export const incomingReferences = <NT extends Node, RT extends Node = NT>(
|
|
78
78
|
targetNodeOrNodes: NT[] | NT,
|
|
79
79
|
scope: NT[],
|
|
80
|
-
reader: Reader<NT>
|
|
80
|
+
reader: Reader<NT, RT>
|
|
81
81
|
): ReferenceValue<NT>[] => {
|
|
82
82
|
const targetNodes = Array.isArray(targetNodeOrNodes) ? targetNodeOrNodes : [targetNodeOrNodes]
|
|
83
83
|
return referenceValues(scope, reader)
|
|
@@ -97,9 +97,9 @@ export const incomingReferences = <NT extends Node>(
|
|
|
97
97
|
* @param reader - a {@link Reader} to reflect on nodes.
|
|
98
98
|
* _Note_ that it's assumed that its {@link getFeatureValue} function doesn't throw.
|
|
99
99
|
*/
|
|
100
|
-
export const referencesToOutOfScopeNodes = <NT extends Node>(
|
|
100
|
+
export const referencesToOutOfScopeNodes = <NT extends Node, RT extends Node = NT>(
|
|
101
101
|
scope: NT[],
|
|
102
|
-
reader: Reader<NT>
|
|
102
|
+
reader: Reader<NT, RT>
|
|
103
103
|
): ReferenceValue<NT>[] =>
|
|
104
104
|
referenceValues(scope, reader)
|
|
105
105
|
.filter((referenceValue) => scope.indexOf(referenceValue.targetNode) === -1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Classifier, Concept } from "./types.js"
|
|
2
2
|
import { LionWebVersion } from "./version.js"
|
|
3
|
-
import {
|
|
3
|
+
import { LionWebVersions } from "./versions.js"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @return whether the given {@link Classifier} is the built-in `Node` {@link Concept}
|
|
@@ -8,7 +8,7 @@ import { defaultLionWebVersion } from "./versions.js"
|
|
|
8
8
|
* or of the version belonging to the designated {@link LionWebVersion}.
|
|
9
9
|
*/
|
|
10
10
|
export const isBuiltinNodeConcept = (classifier: Classifier, lionWebVersion?: LionWebVersion): boolean => {
|
|
11
|
-
const { builtinsFacade } = lionWebVersion ??
|
|
11
|
+
const { builtinsFacade } = lionWebVersion ?? LionWebVersions.v2023_1
|
|
12
12
|
return classifier instanceof Concept
|
|
13
13
|
&& (classifier as Concept).abstract
|
|
14
14
|
&& classifier.language.key === builtinsFacade.language.key
|
package/src/m3/deserializer.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { consoleProblemReporter, ProblemReporter } from "../reporter.js"
|
|
|
5
5
|
import { lioncoreReaderFor, lioncoreWriterFor } from "./reading-writing.js"
|
|
6
6
|
import { Language } from "./types.js"
|
|
7
7
|
import { LionWebVersion } from "./version.js"
|
|
8
|
-
import {
|
|
8
|
+
import { LionWebVersions } from "./versions.js"
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -15,7 +15,7 @@ export type LanguageDeserializationData = {
|
|
|
15
15
|
serializationChunk: LionWebJsonChunk
|
|
16
16
|
/**
|
|
17
17
|
* The version of the LionWeb serialization format to deserialize from.
|
|
18
|
-
* Default = {@link
|
|
18
|
+
* Default = {@link LionWebVersions.v2023_1}.
|
|
19
19
|
*/
|
|
20
20
|
lionWebVersion?: LionWebVersion
|
|
21
21
|
dependentLanguages?: Language[]
|
|
@@ -28,7 +28,7 @@ export type LanguageDeserializationData = {
|
|
|
28
28
|
/**
|
|
29
29
|
* @return languages serialized to the {@link LionWebJsonChunk serialization chunk} passed in the {@link LanguageDeserializationData data object}.
|
|
30
30
|
*/
|
|
31
|
-
export const deserializeLanguagesFrom = ({serializationChunk, dependentLanguages, problemReporter, lionWebVersion =
|
|
31
|
+
export const deserializeLanguagesFrom = ({serializationChunk, dependentLanguages, problemReporter, lionWebVersion = LionWebVersions.v2023_1}: LanguageDeserializationData): Language[] =>
|
|
32
32
|
deserializerWith({
|
|
33
33
|
writer: lioncoreWriterFor(lionWebVersion),
|
|
34
34
|
languages: [lionWebVersion.lioncoreFacade.language, ...(dependentLanguages ?? [])],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { metaTypedBasedClassifierDeducerFor, qualifiedNameOf } from "./functions.js"
|
|
2
2
|
import { LionWebVersion } from "./version.js"
|
|
3
|
-
import {
|
|
3
|
+
import { LionWebVersions } from "./versions.js"
|
|
4
4
|
import { Reader } from "../reading.js"
|
|
5
5
|
import {
|
|
6
6
|
Annotation,
|
|
@@ -37,7 +37,7 @@ export const lioncoreReaderFor = (version: LionWebVersion): Reader<M3Concept> =>
|
|
|
37
37
|
*
|
|
38
38
|
* @deprecated Use {@link lioncoreReaderFor} instead.
|
|
39
39
|
*/
|
|
40
|
-
export const lioncoreReader: Reader<M3Concept> = lioncoreReaderFor(
|
|
40
|
+
export const lioncoreReader: Reader<M3Concept> = lioncoreReaderFor(LionWebVersions.v2023_1)
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Alias for {@link lioncoreReader}, kept for backward compatibility, and to be removed later.
|
|
@@ -149,7 +149,7 @@ export const lioncoreWriterFor = (version: LionWebVersion): Writer<M3Concept> =>
|
|
|
149
149
|
*
|
|
150
150
|
* @deprecated Use {@link lioncoreWriterFor} instead.
|
|
151
151
|
*/
|
|
152
|
-
export const lioncoreWriter: Writer<M3Concept> = lioncoreWriterFor(
|
|
152
|
+
export const lioncoreWriter: Writer<M3Concept> = lioncoreWriterFor(LionWebVersions.v2023_1)
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* Alias for {@link lioncoreWriter}, kept for backward compatibility, and to be deprecated and removed later.
|
package/src/m3/serializer.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { serializerWith } from "../serializer.js"
|
|
|
3
3
|
import { lioncoreReaderFor } from "./reading-writing.js"
|
|
4
4
|
import { Language } from "./types.js"
|
|
5
5
|
import { LionWebVersion } from "./version.js"
|
|
6
|
-
import {
|
|
6
|
+
import { LionWebVersions } from "./versions.js"
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -12,7 +12,7 @@ import { defaultLionWebVersion, LionWebVersions } from "./versions.js"
|
|
|
12
12
|
export type LanguageSerializationData = {
|
|
13
13
|
/**
|
|
14
14
|
* The version of the LionWeb serialization format to serialize in.
|
|
15
|
-
* Default = {@link
|
|
15
|
+
* Default = {@link LionWebVersions.v2023_1}.
|
|
16
16
|
*/
|
|
17
17
|
lionWebVersion?: LionWebVersion
|
|
18
18
|
languages: Language[]
|
|
@@ -20,10 +20,10 @@ export type LanguageSerializationData = {
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @return the {@link LionWebJsonChunk serialization chunk} serializing the given languages (M2s, as instances of the LionCore M3),
|
|
23
|
-
* according to the configured {@link LionWebVersion} (which itself defaults to {@link
|
|
23
|
+
* according to the configured {@link LionWebVersion} (which itself defaults to {@link LionWebVersions.v2023_1}).
|
|
24
24
|
*/
|
|
25
25
|
export const serializeLanguagesFor = (data: LanguageSerializationData) => {
|
|
26
|
-
const lionwebVersion = data.lionWebVersion ??
|
|
26
|
+
const lionwebVersion = data.lionWebVersion ?? LionWebVersions.v2023_1
|
|
27
27
|
return serializerWith({ reader: lioncoreReaderFor(lionwebVersion) })(data.languages)
|
|
28
28
|
}
|
|
29
29
|
|
package/src/m3/symbol-table.ts
CHANGED
|
@@ -18,15 +18,15 @@ interface SymbolTable {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Looks up the {@link LanguageEntity}, as pointed to by the given {@link LionWebJsonMetaPointer},
|
|
21
|
-
* or
|
|
21
|
+
* or `undefined` if it couldn't be found.
|
|
22
22
|
*/
|
|
23
23
|
entityMatching(entityMetaPointer: LionWebJsonMetaPointer): LanguageEntity | undefined
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Looks up the {@link Feature}, as pointed to by the {@link LionWebJsonMetaPointer} given second,
|
|
27
27
|
* as a feature of the {@link Classifier}, as pointed to by the {@link LionWebJsonMetaPointer} given first,
|
|
28
|
-
* or
|
|
29
|
-
* *Note* that the
|
|
28
|
+
* or `undefined` it it couldn't be found.
|
|
29
|
+
* *Note* that the `language` and `version` values of both {@link LionWebJsonMetaPointer}-typed arguments should coincide,
|
|
30
30
|
* although this is typically not checked!
|
|
31
31
|
*/
|
|
32
32
|
featureMatching(entityMetaPointer: LionWebJsonMetaPointer, featureMetaPointer: LionWebJsonMetaPointer): Feature | undefined
|
package/src/m3/types.ts
CHANGED
|
@@ -298,6 +298,7 @@ export {
|
|
|
298
298
|
EnumerationLiteral,
|
|
299
299
|
Feature,
|
|
300
300
|
Interface,
|
|
301
|
+
M3Node,
|
|
301
302
|
Language,
|
|
302
303
|
LanguageEntity,
|
|
303
304
|
Link,
|
|
@@ -313,7 +314,6 @@ export type {
|
|
|
313
314
|
IKeyed,
|
|
314
315
|
IMetaTyped,
|
|
315
316
|
INamed,
|
|
316
|
-
M3Concept
|
|
317
|
-
M3Node
|
|
317
|
+
M3Concept
|
|
318
318
|
}
|
|
319
319
|
|
|
@@ -17,7 +17,7 @@ const factory = new LanguageFactory(
|
|
|
17
17
|
/**
|
|
18
18
|
* Definition of LionCore in terms of itself.
|
|
19
19
|
*
|
|
20
|
-
* @deprecated Use
|
|
20
|
+
* @deprecated Use `lioncoreFacade.language` instead.
|
|
21
21
|
*/
|
|
22
22
|
export const lioncore = factory.language.havingKey("LionCore-M3")
|
|
23
23
|
|
|
@@ -105,12 +105,12 @@ export const lioncoreFacade: LionCoreFacade = {
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
|
-
* @deprecated Use
|
|
108
|
+
* @deprecated Use `<LionWeb version>.lioncoreFacade.metaConcepts` instead.
|
|
109
109
|
*/
|
|
110
110
|
export const metaConcepts = lioncoreFacade.metaConcepts
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
* @deprecated Use
|
|
113
|
+
* @deprecated Use `<LionWeb version>.lioncoreFacade.metaFeatures` instead.
|
|
114
114
|
*/
|
|
115
115
|
export const metaFeatures = lioncoreFacade.metaFeatures
|
|
116
116
|
|
package/src/m3/versions.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { LionWebVersion } from "./version.js"
|
|
|
5
5
|
/**
|
|
6
6
|
* The *current* release(d) version.
|
|
7
7
|
*
|
|
8
|
-
* @deprecated Use
|
|
8
|
+
* @deprecated Use `LionWebVersions.v2023_1.serializationFormatVersion` instead.
|
|
9
9
|
*/
|
|
10
10
|
export const currentReleaseVersion = "2023.1"
|
|
11
11
|
|
|
@@ -23,11 +23,6 @@ export const LionWebVersions = {
|
|
|
23
23
|
*/
|
|
24
24
|
export const allLionWebVersions = Object.values(LionWebVersions)
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* The current default LionWeb version.
|
|
28
|
-
*/
|
|
29
|
-
export const defaultLionWebVersion = LionWebVersions.v2023_1
|
|
30
|
-
|
|
31
26
|
/**
|
|
32
27
|
* @return the {@link LionWebVersion} matching the given `serializationFormatVersion` string,
|
|
33
28
|
* or {@link undefined} if there’s none.
|
package/src/reading.ts
CHANGED
|
@@ -10,19 +10,21 @@ export type ClassifierDeducer<NT extends Node> = (node: NT) => Classifier
|
|
|
10
10
|
/**
|
|
11
11
|
* Type def. for functions that deduce the string value of the `resolveInfo` field of a
|
|
12
12
|
* {@link LionWebJsonReferenceTarget serialized reference target},
|
|
13
|
-
* or
|
|
13
|
+
* or `undefined` to indicate that no `resolveInfo` could be derived.
|
|
14
14
|
* The function’s arguments are the target {@link Node} and its containing {@link Reference}.
|
|
15
15
|
*/
|
|
16
16
|
export type ResolveInfoDeducer<NT extends Node> = (node: NT, reference: Reference) => string | undefined
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* An interface that's used to parametrize generic serialization of
|
|
20
|
-
* (in-memory) nodes of the given type (parameter)
|
|
20
|
+
* (in-memory) nodes of the given type (parameter) `NT`.
|
|
21
21
|
* Implementations of these interfaces {w|c}ould be:
|
|
22
22
|
* - specific to LionCore (so to match m3/types.ts)
|
|
23
23
|
* - generic to serialize {@link DynamicNode dynamic nodes}
|
|
24
|
+
* The `RT` type (parameter) is the type of any *referenced* node,
|
|
25
|
+
* which could e.g. be wider – most likely – or narrower than `NT`.
|
|
24
26
|
*/
|
|
25
|
-
export interface Reader<NT extends Node> {
|
|
27
|
+
export interface Reader<NT extends Node, RT extends Node = NT> {
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* @return The {@link Concept concept} of the given node
|
|
@@ -43,9 +45,9 @@ export interface Reader<NT extends Node> {
|
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* @return The string value of the `resolveInfo` field of a {@link LionWebJsonReferenceTarget serialized reference target},
|
|
46
|
-
* or
|
|
48
|
+
* or `undefined` to indicate that no `resolveInfo` could be derived.
|
|
47
49
|
*/
|
|
48
|
-
resolveInfoFor?: ResolveInfoDeducer<
|
|
50
|
+
resolveInfoFor?: ResolveInfoDeducer<RT>
|
|
49
51
|
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -54,5 +56,5 @@ export interface Reader<NT extends Node> {
|
|
|
54
56
|
*
|
|
55
57
|
* @deprecated Use {@link Reader} instead.
|
|
56
58
|
*/
|
|
57
|
-
export interface ExtractionFacade<NT extends Node> extends Reader<NT> {}
|
|
59
|
+
export interface ExtractionFacade<NT extends Node, RT extends Node> extends Reader<NT, RT> {}
|
|
58
60
|
|