@lionweb/core 0.6.13-beta.7 → 0.7.0-alpha.10
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 +29 -7
- package/dist/deserializer.d.ts +18 -9
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +40 -43
- package/dist/deserializer.js.map +1 -1
- package/dist/dynamic-facade.d.ts +15 -6
- 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/functions.d.ts +4 -3
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +1 -1
- package/dist/functions.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- 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 +66 -44
- package/dist/m3/builtins.js.map +1 -1
- package/dist/m3/constraints.d.ts.map +1 -1
- package/dist/m3/constraints.js +10 -5
- package/dist/m3/constraints.js.map +1 -1
- package/dist/m3/deserializer.d.ts +3 -3
- package/dist/m3/deserializer.d.ts.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 +17 -9
- package/dist/m3/facade.js.map +1 -1
- package/dist/m3/factory.d.ts +2 -2
- package/dist/m3/factory.d.ts.map +1 -1
- package/dist/m3/factory.js.map +1 -1
- package/dist/m3/functions.d.ts +33 -12
- package/dist/m3/functions.d.ts.map +1 -1
- package/dist/m3/functions.js +32 -14
- package/dist/m3/functions.js.map +1 -1
- package/dist/m3/index.d.ts +1 -0
- package/dist/m3/index.d.ts.map +1 -1
- package/dist/m3/index.js +1 -0
- package/dist/m3/index.js.map +1 -1
- package/dist/m3/lioncore.d.ts +2 -0
- package/dist/m3/lioncore.d.ts.map +1 -1
- package/dist/m3/lioncore.js +25 -60
- package/dist/m3/lioncore.js.map +1 -1
- package/dist/m3/reference-checker.d.ts.map +1 -1
- package/dist/m3/reference-checker.js +2 -2
- package/dist/m3/reference-checker.js.map +1 -1
- package/dist/m3/serializer.d.ts +2 -2
- 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 +26 -21
- 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/references.d.ts +3 -3
- package/dist/references.d.ts.map +1 -1
- package/dist/serializer.d.ts +31 -10
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +111 -109
- package/dist/serializer.js.map +1 -1
- package/dist/symbol-table.d.ts +15 -15
- package/dist/symbol-table.d.ts.map +1 -1
- package/dist/symbol-table.js +2 -9
- package/dist/symbol-table.js.map +1 -1
- package/dist/types.d.ts +2 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -6
- package/dist/types.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 +13 -7
- package/dist/facade.d.ts +0 -84
- package/dist/facade.d.ts.map +0 -1
- package/dist/facade.js +0 -41
- package/dist/facade.js.map +0 -1
- package/dist/serialization.d.ts +0 -52
- package/dist/serialization.d.ts.map +0 -1
- package/dist/serialization.js +0 -7
- package/dist/serialization.js.map +0 -1
- package/dist/utils/array-helpers.d.ts +0 -14
- package/dist/utils/array-helpers.d.ts.map +0 -1
- package/dist/utils/array-helpers.js +0 -15
- package/dist/utils/array-helpers.js.map +0 -1
- package/dist/utils/cycles.d.ts +0 -8
- package/dist/utils/cycles.d.ts.map +0 -1
- package/dist/utils/cycles.js +0 -26
- package/dist/utils/cycles.js.map +0 -1
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -7
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/map-helpers.d.ts +0 -26
- package/dist/utils/map-helpers.d.ts.map +0 -1
- package/dist/utils/map-helpers.js +0 -41
- package/dist/utils/map-helpers.js.map +0 -1
- package/dist/utils/recursion.d.ts +0 -13
- package/dist/utils/recursion.d.ts.map +0 -1
- package/dist/utils/recursion.js +0 -21
- package/dist/utils/recursion.js.map +0 -1
- package/dist/utils/sorting.d.ts +0 -7
- package/dist/utils/sorting.d.ts.map +0 -1
- package/dist/utils/sorting.js +0 -7
- package/dist/utils/sorting.js.map +0 -1
- package/dist/utils/string-mapping.d.ts +0 -6
- package/dist/utils/string-mapping.d.ts.map +0 -1
- package/dist/utils/string-mapping.js +0 -10
- package/dist/utils/string-mapping.js.map +0 -1
package/dist/m3/types.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* TypeScript type definitions for the `LionCore` M3 (=meta-meta) model.
|
|
3
3
|
* A LionWeb language (at the M2 meta level) can be represented as an instance of the {@link Language} type.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { LionWebId, LionWebJsonMetaPointer, LionWebKey } from "@lionweb/json";
|
|
6
|
+
import { ResolveInfoDeducer } from "../reading.js";
|
|
6
7
|
import { MultiRef, SingleRef } from "../references.js";
|
|
7
|
-
import {
|
|
8
|
-
import { Id, Node } from "../types.js";
|
|
8
|
+
import { Node } from "../types.js";
|
|
9
9
|
/**
|
|
10
10
|
* The key of the LionCore language containing the built-ins.
|
|
11
11
|
* (It's defined here because of instantiation order.)
|
|
@@ -17,7 +17,7 @@ interface INamed {
|
|
|
17
17
|
declare const isINamed: (node: object) => node is INamed;
|
|
18
18
|
declare const simpleNameDeducer: ResolveInfoDeducer<Node>;
|
|
19
19
|
interface IKeyed extends INamed {
|
|
20
|
-
key:
|
|
20
|
+
key: LionWebId;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* An interface with one method to return a meta type,
|
|
@@ -34,23 +34,23 @@ interface IMetaTyped {
|
|
|
34
34
|
declare abstract class M3Node implements IKeyed, IMetaTyped {
|
|
35
35
|
metaType(): string;
|
|
36
36
|
parent?: M3Node;
|
|
37
|
-
readonly id:
|
|
37
|
+
readonly id: LionWebId;
|
|
38
38
|
name: string;
|
|
39
|
-
key:
|
|
40
|
-
protected constructor(id:
|
|
41
|
-
havingKey(key:
|
|
39
|
+
key: LionWebId;
|
|
40
|
+
protected constructor(id: LionWebId, name: string, key: LionWebId, parent?: M3Node);
|
|
41
|
+
havingKey(key: LionWebId): this;
|
|
42
42
|
annotations: Node[];
|
|
43
43
|
}
|
|
44
44
|
declare abstract class Feature extends M3Node {
|
|
45
45
|
optional: boolean;
|
|
46
|
-
constructor(classifier: Classifier, name: string, key:
|
|
46
|
+
constructor(classifier: Classifier, name: string, key: LionWebKey, id: LionWebId);
|
|
47
47
|
isOptional(): this;
|
|
48
48
|
get classifier(): Classifier;
|
|
49
49
|
}
|
|
50
50
|
declare class Property extends Feature {
|
|
51
51
|
metaType(): string;
|
|
52
|
-
type: SingleRef<
|
|
53
|
-
ofType(type:
|
|
52
|
+
type: SingleRef<DataType>;
|
|
53
|
+
ofType(type: DataType): Property;
|
|
54
54
|
}
|
|
55
55
|
declare abstract class Link extends Feature {
|
|
56
56
|
multiple: boolean;
|
|
@@ -65,13 +65,13 @@ declare class Reference extends Link {
|
|
|
65
65
|
metaType(): string;
|
|
66
66
|
}
|
|
67
67
|
declare abstract class LanguageEntity extends M3Node {
|
|
68
|
-
constructor(language: Language, name: string, key:
|
|
68
|
+
constructor(language: Language, name: string, key: LionWebId, id: LionWebId);
|
|
69
69
|
get language(): Language;
|
|
70
70
|
}
|
|
71
71
|
declare abstract class Classifier extends LanguageEntity {
|
|
72
72
|
features: Feature[];
|
|
73
73
|
havingFeatures(...features: Feature[]): this;
|
|
74
|
-
metaPointer():
|
|
74
|
+
metaPointer(): LionWebJsonMetaPointer;
|
|
75
75
|
}
|
|
76
76
|
declare class Concept extends Classifier {
|
|
77
77
|
metaType(): string;
|
|
@@ -79,7 +79,7 @@ declare class Concept extends Classifier {
|
|
|
79
79
|
partition: boolean;
|
|
80
80
|
extends?: SingleRef<Concept>;
|
|
81
81
|
implements: MultiRef<Interface>;
|
|
82
|
-
constructor(language: Language, name: string, key:
|
|
82
|
+
constructor(language: Language, name: string, key: LionWebKey, id: LionWebId, abstract: boolean, extends_?: SingleRef<Concept>);
|
|
83
83
|
implementing(...interfaces: Interface[]): Concept;
|
|
84
84
|
isPartition(): Concept;
|
|
85
85
|
}
|
|
@@ -88,7 +88,7 @@ declare class Annotation extends Classifier {
|
|
|
88
88
|
extends?: SingleRef<Annotation>;
|
|
89
89
|
implements: MultiRef<Interface>;
|
|
90
90
|
annotates: SingleRef<Classifier>;
|
|
91
|
-
constructor(language: Language, name: string, key:
|
|
91
|
+
constructor(language: Language, name: string, key: LionWebKey, id: LionWebId, extends_?: SingleRef<Annotation>);
|
|
92
92
|
implementing(...interfaces: Interface[]): Annotation;
|
|
93
93
|
annotating(classifier: Classifier): Annotation;
|
|
94
94
|
}
|
|
@@ -97,19 +97,24 @@ declare class Interface extends Classifier {
|
|
|
97
97
|
extends: MultiRef<Interface>;
|
|
98
98
|
extending(...interfaces: Interface[]): Interface;
|
|
99
99
|
}
|
|
100
|
-
declare abstract class
|
|
100
|
+
declare abstract class DataType extends LanguageEntity {
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Misspelled alias of {@link DataType}, kept for backward compatibility, and to be deprecated and removed later.
|
|
104
|
+
*/
|
|
105
|
+
declare abstract class Datatype extends DataType {
|
|
106
|
+
}
|
|
107
|
+
declare class PrimitiveType extends DataType {
|
|
103
108
|
metaType(): string;
|
|
104
109
|
}
|
|
105
|
-
declare class Enumeration extends
|
|
110
|
+
declare class Enumeration extends DataType {
|
|
106
111
|
metaType(): string;
|
|
107
112
|
literals: EnumerationLiteral[];
|
|
108
113
|
havingLiterals(...literals: EnumerationLiteral[]): this;
|
|
109
114
|
}
|
|
110
115
|
declare class EnumerationLiteral extends M3Node {
|
|
111
116
|
metaType(): string;
|
|
112
|
-
constructor(enumeration: Enumeration, name: string, key:
|
|
117
|
+
constructor(enumeration: Enumeration, name: string, key: LionWebKey, id: LionWebId);
|
|
113
118
|
get enumeration(): Enumeration;
|
|
114
119
|
}
|
|
115
120
|
declare class Language extends M3Node {
|
|
@@ -117,7 +122,7 @@ declare class Language extends M3Node {
|
|
|
117
122
|
version: string;
|
|
118
123
|
entities: LanguageEntity[];
|
|
119
124
|
dependsOn: MultiRef<Language>;
|
|
120
|
-
constructor(name: string, version: string, id:
|
|
125
|
+
constructor(name: string, version: string, id: LionWebId, key: LionWebKey);
|
|
121
126
|
havingEntities(...entities: LanguageEntity[]): Language;
|
|
122
127
|
dependingOn(...languages: Language[]): Language;
|
|
123
128
|
equals(that: Language): boolean;
|
|
@@ -128,6 +133,6 @@ declare class Language extends M3Node {
|
|
|
128
133
|
* so they also implement {@link INamed} and {@link IKeyed}.
|
|
129
134
|
*/
|
|
130
135
|
type M3Concept = Annotation | Concept | Containment | Enumeration | EnumerationLiteral | Interface | Language | PrimitiveType | Property | Reference;
|
|
131
|
-
export { Annotation, Classifier, Concept, Containment, Datatype, Enumeration, EnumerationLiteral, Feature, Interface, Language, LanguageEntity, Link, PrimitiveType, Property, Reference, isINamed, lioncoreBuiltinsKey, simpleNameDeducer };
|
|
136
|
+
export { Annotation, Classifier, Concept, Containment, DataType, Datatype, Enumeration, EnumerationLiteral, Feature, Interface, Language, LanguageEntity, Link, PrimitiveType, Property, Reference, isINamed, lioncoreBuiltinsKey, simpleNameDeducer };
|
|
132
137
|
export type { IKeyed, IMetaTyped, INamed, M3Concept, M3Node };
|
|
133
138
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/m3/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/m3/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/m3/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAc,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGlC;;;GAGG;AACH,QAAA,MAAM,mBAAmB,sBAAsB,CAAA;AAO/C,UAAU,MAAM;IACZ,IAAI,EAAE,MAAM,CAAA;CACf;AAED,QAAA,MAAM,QAAQ,SAAU,MAAM,mBACqB,CAAA;AAEnD,QAAA,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,IAAI,CACU,CAAA;AAG1D,UAAU,MAAO,SAAQ,MAAM;IAC3B,GAAG,EAAE,SAAS,CAAA;CACjB;AAGD;;;;GAIG;AACH,UAAU,UAAU;IAChB,QAAQ,IAAI,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,uBAAe,MAAO,YAAW,MAAM,EAAE,UAAU;IAC/C,QAAQ,IAAI,MAAM;IAGlB,MAAM,CAAC,EAAE,MAAM,CAAA;IAMf,QAAQ,CAAC,EAAE,EAAE,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,EACb,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,mBAAmB,EACnB,iBAAiB,EACpB,CAAA;AAED,YAAY,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,SAAS,EACT,MAAM,EACT,CAAA"}
|
package/dist/m3/types.js
CHANGED
|
@@ -163,14 +163,19 @@ class Interface extends Classifier {
|
|
|
163
163
|
return this;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
class
|
|
166
|
+
class DataType extends LanguageEntity {
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Misspelled alias of {@link DataType}, kept for backward compatibility, and to be deprecated and removed later.
|
|
170
|
+
*/
|
|
171
|
+
class Datatype extends DataType {
|
|
172
|
+
}
|
|
173
|
+
class PrimitiveType extends DataType {
|
|
169
174
|
metaType() {
|
|
170
175
|
return "PrimitiveType";
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
|
-
class Enumeration extends
|
|
178
|
+
class Enumeration extends DataType {
|
|
174
179
|
constructor() {
|
|
175
180
|
super(...arguments);
|
|
176
181
|
this.literals = []; // (containment)
|
|
@@ -218,5 +223,5 @@ class Language extends M3Node {
|
|
|
218
223
|
return this.key === that.key && this.version === that.version;
|
|
219
224
|
}
|
|
220
225
|
}
|
|
221
|
-
export { Annotation, Classifier, Concept, Containment, Datatype, Enumeration, EnumerationLiteral, Feature, Interface, Language, LanguageEntity, Link, PrimitiveType, Property, Reference, isINamed, lioncoreBuiltinsKey, simpleNameDeducer };
|
|
226
|
+
export { Annotation, Classifier, Concept, Containment, DataType, Datatype, Enumeration, EnumerationLiteral, Feature, Interface, Language, LanguageEntity, Link, PrimitiveType, Property, Reference, isINamed, lioncoreBuiltinsKey, simpleNameDeducer };
|
|
222
227
|
//# sourceMappingURL=types.js.map
|
package/dist/m3/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/m3/types.ts"],"names":[],"mappings":"A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CAAC,CAClE,CAAA;QACD,OAAO,IAAI,CAAA;IACf,CAAC;IACD,MAAM,CAAC,IAAc;QACjB,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,CAAA;IACjE,CAAC;CACJ;AAqBD,OAAO,EACH,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,SAAS,EACT,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,mBAAmB,EACnB,iBAAiB,EACpB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Classifier, Enumeration, EnumerationLiteral, Feature } from "./m3/index.js";
|
|
2
|
+
import { Node } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Type def. for functions that deduce the {@link Classifier classifier} of a given {@link Node node}.
|
|
5
|
+
*/
|
|
6
|
+
export type ClassifierDeducer<NT extends Node> = (node: NT) => Classifier;
|
|
7
|
+
/**
|
|
8
|
+
* Type def. for functions that deduce the string value of the `resolveInfo` field of a
|
|
9
|
+
* {@link LionWebJsonReferenceTarget serialized reference target}, or {@code undefined}
|
|
10
|
+
* to indicate that no `resolveInfo` could be derived.
|
|
11
|
+
*/
|
|
12
|
+
export type ResolveInfoDeducer<NT extends Node> = (node: NT) => string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* An interface that's used to parametrize generic serialization of
|
|
15
|
+
* (in-memory) nodes of the given type (parameter).
|
|
16
|
+
* Implementations of these interfaces {w|c}ould be:
|
|
17
|
+
* - specific to LionCore (so to match m3/types.ts)
|
|
18
|
+
* - generic to serialize {@link DynamicNode dynamic nodes}
|
|
19
|
+
*/
|
|
20
|
+
export interface Reader<NT extends Node> {
|
|
21
|
+
/**
|
|
22
|
+
* @return The {@link Concept concept} of the given node
|
|
23
|
+
*/
|
|
24
|
+
classifierOf: ClassifierDeducer<NT>;
|
|
25
|
+
/**
|
|
26
|
+
* @return The value of the given {@link Feature feature} on the given node.
|
|
27
|
+
*/
|
|
28
|
+
getFeatureValue: (node: NT, feature: Feature) => unknown;
|
|
29
|
+
/**
|
|
30
|
+
* @return The {@link EnumerationLiteral} corresponding to
|
|
31
|
+
* the given {@link Enumeration} and the runtime encoding of a literal of it,
|
|
32
|
+
*/
|
|
33
|
+
enumerationLiteralFrom: (encoding: unknown, enumeration: Enumeration) => EnumerationLiteral | null;
|
|
34
|
+
/**
|
|
35
|
+
* @return The string value of the `resolveInfo` field of a {@link LionWebJsonReferenceTarget serialized reference target},
|
|
36
|
+
* or {@code undefined} to indicate that no `resolveInfo` could be derived.
|
|
37
|
+
*/
|
|
38
|
+
resolveInfoFor?: ResolveInfoDeducer<NT>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Alias for {@link Reader}, kept for backward compatibility, and to be deprecated and removed later.
|
|
42
|
+
*/
|
|
43
|
+
export interface ExtractionFacade<NT extends Node> extends Reader<NT> {
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=reading.d.ts.map
|
|
@@ -0,0 +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,MAAM,eAAe,CAAA;AACpF,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;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,MAAM,GAAG,SAAS,CAAA;AAElF;;;;;;GAMG;AACH,MAAM,WAAW,MAAM,CAAC,EAAE,SAAS,IAAI;IAEnC;;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;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,EAAE,SAAS,IAAI,CAAE,SAAQ,MAAM,CAAC,EAAE,CAAC;CAAG"}
|
package/dist/reading.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reading.js","sourceRoot":"","sources":["../src/reading.ts"],"names":[],"mappings":""}
|
package/dist/references.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LionWebId } from "@lionweb/json";
|
|
2
2
|
/**
|
|
3
3
|
* The `unresolved` symbol indicates a reference value which hasn't been resolved yet.
|
|
4
4
|
* It differs from an unset (`undefined`) value.
|
|
@@ -17,7 +17,7 @@ export declare const isRef: <T>(ref?: SingleRef<T> | undefined) => ref is T;
|
|
|
17
17
|
*/
|
|
18
18
|
export type MultiRef<T> = T[];
|
|
19
19
|
/**
|
|
20
|
-
* A type that expresses a value is either an {@link
|
|
20
|
+
* A type that expresses a value is either an {@link LionWebId} or a value to indicate that resolution to a node previously failed.
|
|
21
21
|
*/
|
|
22
|
-
export type IdOrUnresolved =
|
|
22
|
+
export type IdOrUnresolved = LionWebId | typeof unresolved;
|
|
23
23
|
//# sourceMappingURL=references.d.ts.map
|
package/dist/references.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC;;;GAGG;AACH,eAAO,MAAM,UAAU,MAAO,CAAA;AAE9B;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,OAAO,UAAU,GAAG,CAAC,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,KAAK,iDACyB,CAAA;AAE3C;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAA;AAG7B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,UAAU,CAAC"}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { LionWebJsonChunk, LionWebJsonMetaPointer } from "@lionweb/json";
|
|
2
|
+
import { Reader } from "./reading.js";
|
|
3
3
|
import { Node } from "./types.js";
|
|
4
4
|
import { Feature, Property } from "./m3/types.js";
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
* @return the {@link
|
|
37
|
+
* @return the {@link LionWebJsonMetaPointer} for the given {@link Feature}.
|
|
38
|
+
*/
|
|
39
|
+
export declare const metaPointerFor: (feature: Feature) => LionWebJsonMetaPointer;
|
|
40
|
+
/**
|
|
41
|
+
* @return a function that serializes the {@link Node nodes} passed to it.
|
|
22
42
|
*/
|
|
23
|
-
export declare const
|
|
43
|
+
export declare const nodeSerializer: <NT extends Node>(reader: Reader<NT>, serializationOptions?: SerializationOptions) => (nodes: NT[]) => LionWebJsonChunk;
|
|
24
44
|
/**
|
|
25
|
-
* @return a {@link
|
|
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,15 +1,12 @@
|
|
|
1
|
-
import { currentSerializationFormatVersion } from "
|
|
1
|
+
import { currentSerializationFormatVersion } from "@lionweb/json";
|
|
2
|
+
import { asArray } from "@lionweb/ts-utils";
|
|
2
3
|
import { asIds } from "./functions.js";
|
|
3
|
-
import {
|
|
4
|
+
import { BuiltinPropertyValueSerializer } from "./m3/builtins.js";
|
|
4
5
|
import { allFeaturesOf } from "./m3/functions.js";
|
|
5
6
|
import { Containment, Enumeration, PrimitiveType, Property, Reference, simpleNameDeducer } from "./m3/types.js";
|
|
6
|
-
|
|
7
|
-
const isPrimitiveTypeSerializer = (value) => typeof value === "object"
|
|
8
|
-
&& value !== null
|
|
9
|
-
&& "serializeValue" in value
|
|
10
|
-
&& typeof value.serializeValue === "function";
|
|
7
|
+
const isPropertyValueSerializer = (value) => typeof value === "object" && value !== null && "serializeValue" in value && typeof value.serializeValue === "function";
|
|
11
8
|
/**
|
|
12
|
-
* @return the {@link
|
|
9
|
+
* @return the {@link LionWebJsonMetaPointer} for the given {@link Feature}.
|
|
13
10
|
*/
|
|
14
11
|
export const metaPointerFor = (feature) => {
|
|
15
12
|
const { language } = feature.classifier;
|
|
@@ -20,117 +17,122 @@ export const metaPointerFor = (feature) => {
|
|
|
20
17
|
};
|
|
21
18
|
};
|
|
22
19
|
/**
|
|
23
|
-
* @return a
|
|
20
|
+
* @return a function that serializes the {@link Node nodes} passed to it.
|
|
24
21
|
*/
|
|
25
|
-
export const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
languagesUsed.push(language);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const visit = (node, parent) => {
|
|
41
|
-
if (ids[node.id]) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const classifier = extractionFacade.classifierOf(node);
|
|
45
|
-
const language = classifier.language;
|
|
46
|
-
registerLanguageUsed(language);
|
|
47
|
-
const serializedNode = {
|
|
48
|
-
id: node.id,
|
|
49
|
-
classifier: classifier.metaPointer(),
|
|
50
|
-
properties: [],
|
|
51
|
-
containments: [],
|
|
52
|
-
references: [],
|
|
53
|
-
annotations: [],
|
|
54
|
-
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
|
|
55
34
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
+
});
|
|
66
77
|
return;
|
|
67
78
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
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
|
-
if (feature instanceof Containment) {
|
|
85
|
-
const children = asArray(value);
|
|
86
|
-
if (children.length === 0 && !serializeEmptyFeatures) {
|
|
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
|
+
});
|
|
87
95
|
return;
|
|
88
96
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
children.forEach((childOrNull) => {
|
|
96
|
-
if (childOrNull !== null) {
|
|
97
|
-
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;
|
|
98
102
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
+
});
|
|
106
113
|
return;
|
|
107
114
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
const annotations = asArray(node.annotations); // assumes that annotations also all are of type NT (which is not unreasonable)
|
|
124
|
-
serializedNode.annotations = annotations.map((annotation) => annotation.id);
|
|
125
|
-
annotations.forEach((annotation) => visit(annotation, node));
|
|
126
|
-
serializedNode.parent = parent?.id ?? null; // (undefined -> null)
|
|
127
|
-
};
|
|
128
|
-
nodes.forEach((node) => visit(node, undefined));
|
|
129
|
-
return {
|
|
130
|
-
serializationFormatVersion: currentSerializationFormatVersion,
|
|
131
|
-
languages: languagesUsed
|
|
132
|
-
.map(({ key, version }) => ({ key, version })),
|
|
133
|
-
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
|
+
};
|
|
134
127
|
};
|
|
135
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);
|
|
136
138
|
//# sourceMappingURL=serializer.js.map
|