@lionweb/core 0.10.0-alpha.0 → 0.10.0-alpha.2
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 +17 -0
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +27 -22
- package/dist/deserializer.js.map +1 -1
- package/dist/functions.d.ts +18 -5
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +19 -4
- package/dist/functions.js.map +1 -1
- package/dist/m1/reference-utils.d.ts.map +1 -1
- package/dist/m1/reference-utils.js +0 -1
- package/dist/m1/reference-utils.js.map +1 -1
- package/dist/m3/builtins-common.js +3 -3
- package/dist/m3/builtins-common.js.map +1 -1
- package/dist/m3/constraints.d.ts +5 -0
- package/dist/m3/constraints.d.ts.map +1 -1
- package/dist/m3/constraints.js +1 -1
- package/dist/m3/constraints.js.map +1 -1
- package/dist/m3/functions.d.ts.map +1 -1
- package/dist/m3/functions.js.map +1 -1
- package/dist/m3/symbol-table.d.ts +1 -1
- package/dist/m3/types.d.ts.map +1 -1
- package/dist/m3/types.js +3 -3
- package/dist/m3/types.js.map +1 -1
- package/dist/m3/versions/v2023_1/builtins-legacy.js +3 -3
- package/dist/m3/versions/v2023_1/builtins-legacy.js.map +1 -1
- package/dist/references.d.ts +31 -8
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +41 -6
- package/dist/references.js.map +1 -1
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +25 -11
- package/dist/serializer.js.map +1 -1
- package/package.json +3 -3
- package/src/deserializer.ts +30 -27
- package/src/functions.ts +26 -7
- package/src/m1/reference-utils.ts +0 -1
- package/src/m3/builtins-common.ts +3 -3
- package/src/m3/constraints.ts +1 -1
- package/src/m3/functions.ts +1 -1
- package/src/m3/symbol-table.ts +1 -1
- package/src/m3/types.ts +3 -3
- package/src/m3/versions/v2023_1/builtins-legacy.ts +3 -3
- package/src/references.ts +46 -11
- package/src/serializer.ts +28 -13
package/dist/references.d.ts
CHANGED
|
@@ -1,32 +1,55 @@
|
|
|
1
|
+
import { LionWebId } from "@lionweb/json";
|
|
1
2
|
import { Node } from "./types.js";
|
|
3
|
+
import { INamed } from "./m3/index.js";
|
|
2
4
|
/**
|
|
3
|
-
* The `unresolved` symbol indicates a reference value which hasn't been resolved yet.
|
|
5
|
+
* The `unresolved` “symbol” indicates a reference value which hasn't been resolved yet.
|
|
4
6
|
* It differs from an unset (`undefined`) value.
|
|
5
7
|
* This value shouldn’t be manipulated/compared to directly!
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Use {@link referenceToSet} or {@link UnresolvedReference} instead.
|
|
6
10
|
*/
|
|
7
11
|
export declare const unresolved: null;
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Representation of an unresolved reference.
|
|
14
|
+
* At most one of `targetId` or `resolveInfo` can be `undefined`.
|
|
15
|
+
*
|
|
16
|
+
* *Note* that this instance will **not** exhibit object equality,
|
|
17
|
+
* i.e.: the resolved target of an unresolved reference will be a different object!
|
|
10
18
|
*/
|
|
11
|
-
export
|
|
19
|
+
export declare class UnresolvedReference {
|
|
20
|
+
readonly targetId?: LionWebId | undefined;
|
|
21
|
+
resolveInfo?: string | undefined;
|
|
22
|
+
constructor(targetId?: LionWebId | undefined, resolveInfo?: string | undefined);
|
|
23
|
+
toString: () => string;
|
|
24
|
+
}
|
|
12
25
|
/**
|
|
13
|
-
*
|
|
26
|
+
* A singleton representing an unset reference that’s meant to be set,
|
|
27
|
+
* distinguishing that from a reference that’s intentionally not set
|
|
28
|
+
* — which can only happen if that reference is (defined as) optional.
|
|
14
29
|
*/
|
|
15
|
-
export declare const referenceToSet:
|
|
30
|
+
export declare const referenceToSet: unique symbol;
|
|
16
31
|
/**
|
|
17
32
|
* A type definition for a reference value that can be unresolved.
|
|
18
33
|
* Note: this type is primarily meant to be used to type nodes’ properties,
|
|
19
34
|
* but should be avoided as a return type for “auxiliary” functions.
|
|
20
35
|
*/
|
|
21
|
-
export type SingleRef<NT extends Node> = NT | UnresolvedReference;
|
|
36
|
+
export type SingleRef<NT extends Node> = NT | UnresolvedReference | typeof referenceToSet;
|
|
22
37
|
/**
|
|
23
|
-
* @return whether
|
|
38
|
+
* @return whether the given {@link UnresolvedReference} corresponds to an (explicitly-)unset (yet-to-set) reference.
|
|
24
39
|
*/
|
|
25
|
-
export declare const
|
|
40
|
+
export declare const isReferenceToSet: <T extends Node>(ref?: SingleRef<T>) => ref is typeof referenceToSet;
|
|
26
41
|
/**
|
|
27
42
|
* Type function for the {@link UnresolvedReference} type.
|
|
28
43
|
*/
|
|
29
44
|
export declare const isUnresolvedReference: <NT extends Node>(ref?: SingleRef<NT>) => ref is UnresolvedReference;
|
|
45
|
+
/**
|
|
46
|
+
* @return whether a given (at most) single-valued reference actually refers to something.
|
|
47
|
+
*/
|
|
48
|
+
export declare const isRef: <NT extends Node>(ref?: SingleRef<NT>) => ref is NT;
|
|
49
|
+
/**
|
|
50
|
+
* @return either the referenced node’s name, or the `resolveInfo` if the reference is unresolved, or `undefined`.
|
|
51
|
+
*/
|
|
52
|
+
export declare const tryToRenderAsText: <T extends Node & INamed>(ref?: SingleRef<T>) => string | undefined;
|
|
30
53
|
/**
|
|
31
54
|
* A type alias for a multi-valued reference, to make it look consistent with {@link SingleRef}.
|
|
32
55
|
* Note: this type is primarily meant to be used to type nodes’ properties,
|
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,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtC;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,MAAO,CAAA;AAG9B;;;;;;GAMG;AACH,qBAAa,mBAAmB;aACA,QAAQ,CAAC,EAAE,SAAS;IAAS,WAAW,CAAC,EAAE,MAAM;gBAAjD,QAAQ,CAAC,EAAE,SAAS,YAAA,EAAS,WAAW,CAAC,EAAE,MAAM,YAAA;IAC7E,QAAQ,eACsF;CACjG;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,eAA8B,CAAA;AAEzD;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,EAAE,SAAS,IAAI,IAAI,EAAE,GAAG,mBAAmB,GAAG,OAAO,cAAc,CAAA;AAEzF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,IAAI,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,KAAG,GAAG,IAAI,OAAO,cAC1D,CAAA;AAE1B;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,EAAE,SAAS,IAAI,EAAE,MAAM,SAAS,CAAC,EAAE,CAAC,KAAG,GAAG,IAAI,mBAC9C,CAAA;AAEtC;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,EAAE,SAAS,IAAI,EAAE,MAAM,SAAS,CAAC,EAAE,CAAC,KAAG,GAAG,IAAI,EACU,CAAA;AAE9E;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,IAAI,GAAG,MAAM,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,KAAG,MAAM,GAAG,SAQxF,CAAA;AAGD;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,EAAE,SAAS,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE,CAAA"}
|
package/dist/references.js
CHANGED
|
@@ -1,19 +1,54 @@
|
|
|
1
|
+
import { stringifyPropertiesOf } from "@lionweb/ts-utils";
|
|
1
2
|
/**
|
|
2
|
-
* The `unresolved` symbol indicates a reference value which hasn't been resolved yet.
|
|
3
|
+
* The `unresolved` “symbol” indicates a reference value which hasn't been resolved yet.
|
|
3
4
|
* It differs from an unset (`undefined`) value.
|
|
4
5
|
* This value shouldn’t be manipulated/compared to directly!
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Use {@link referenceToSet} or {@link UnresolvedReference} instead.
|
|
5
8
|
*/
|
|
6
9
|
export const unresolved = null;
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Representation of an unresolved reference.
|
|
12
|
+
* At most one of `targetId` or `resolveInfo` can be `undefined`.
|
|
13
|
+
*
|
|
14
|
+
* *Note* that this instance will **not** exhibit object equality,
|
|
15
|
+
* i.e.: the resolved target of an unresolved reference will be a different object!
|
|
9
16
|
*/
|
|
10
|
-
export
|
|
17
|
+
export class UnresolvedReference {
|
|
18
|
+
constructor(targetId, resolveInfo) {
|
|
19
|
+
this.targetId = targetId;
|
|
20
|
+
this.resolveInfo = resolveInfo;
|
|
21
|
+
this.toString = () => `unresolved reference to target:` + stringifyPropertiesOf(this, "targetId", "resolveInfo");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
11
24
|
/**
|
|
12
|
-
*
|
|
25
|
+
* A singleton representing an unset reference that’s meant to be set,
|
|
26
|
+
* distinguishing that from a reference that’s intentionally not set
|
|
27
|
+
* — which can only happen if that reference is (defined as) optional.
|
|
28
|
+
*/
|
|
29
|
+
export const referenceToSet = Symbol("<unset reference>");
|
|
30
|
+
/**
|
|
31
|
+
* @return whether the given {@link UnresolvedReference} corresponds to an (explicitly-)unset (yet-to-set) reference.
|
|
13
32
|
*/
|
|
14
|
-
export const
|
|
33
|
+
export const isReferenceToSet = (ref) => ref === referenceToSet;
|
|
15
34
|
/**
|
|
16
35
|
* Type function for the {@link UnresolvedReference} type.
|
|
17
36
|
*/
|
|
18
|
-
export const isUnresolvedReference = (ref) => ref
|
|
37
|
+
export const isUnresolvedReference = (ref) => ref instanceof UnresolvedReference;
|
|
38
|
+
/**
|
|
39
|
+
* @return whether a given (at most) single-valued reference actually refers to something.
|
|
40
|
+
*/
|
|
41
|
+
export const isRef = (ref) => ref !== undefined && !isReferenceToSet(ref) && !isUnresolvedReference(ref);
|
|
42
|
+
/**
|
|
43
|
+
* @return either the referenced node’s name, or the `resolveInfo` if the reference is unresolved, or `undefined`.
|
|
44
|
+
*/
|
|
45
|
+
export const tryToRenderAsText = (ref) => {
|
|
46
|
+
if (ref === undefined || isReferenceToSet(ref)) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (isUnresolvedReference(ref)) {
|
|
50
|
+
return ref.resolveInfo;
|
|
51
|
+
}
|
|
52
|
+
return ref.name;
|
|
53
|
+
};
|
|
19
54
|
//# sourceMappingURL=references.js.map
|
package/dist/references.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAMzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAA;AAG9B;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAC5B,YAA4B,QAAoB,EAAS,WAAoB;QAAjD,aAAQ,GAAR,QAAQ,CAAY;QAAS,gBAAW,GAAX,WAAW,CAAS;QAC7E,aAAQ,GAAG,GAAG,EAAE,CACZ,iCAAiC,GAAG,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;IAFd,CAAC;CAGpF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AASzD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAiB,GAAkB,EAAgC,EAAE,CACjG,GAAG,KAAK,cAAc,CAAA;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAkB,GAAmB,EAA8B,EAAE,CACtG,GAAG,YAAY,mBAAmB,CAAA;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAkB,GAAmB,EAAa,EAAE,CACrE,GAAG,KAAK,SAAS,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAA0B,GAAkB,EAAsB,EAAE;IACjG,IAAI,GAAG,KAAK,SAAS,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,OAAO,SAAS,CAAA;IACpB,CAAC;IACD,IAAI,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC,WAAW,CAAA;IAC1B,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,CAAA;AACnB,CAAC,CAAA"}
|
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,
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAA+C,MAAM,eAAe,CAAA;AAGxG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,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,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,EACtB,mCAAmC,uBAAuB,GAAG,oBAAoB,KAClF,gBAQS,CAAA"}
|
package/dist/serializer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { asArray, keepDefineds, lazyMapGet, uniquesAmong } from "@lionweb/ts-utils";
|
|
2
|
-
import { asIds,
|
|
2
|
+
import { asIds, metaPointerForFeature } from "./functions.js";
|
|
3
|
+
import { isRef, isReferenceToSet, UnresolvedReference } from "./references.js";
|
|
3
4
|
import { inheritsDirectlyFrom } from "./m3/functions.js";
|
|
4
5
|
import { Containment, Enumeration, PrimitiveType, Property, Reference, simpleNameDeducer } from "./m3/types.js";
|
|
5
6
|
import { LionWebVersions } from "./m3/versions.js";
|
|
@@ -65,7 +66,7 @@ export const serializerWith = (configuration) => {
|
|
|
65
66
|
const value = reader.getFeatureValue(node, feature);
|
|
66
67
|
const featureLanguage = feature.classifier.language;
|
|
67
68
|
registerLanguageUsed(featureLanguage);
|
|
68
|
-
const featureMetaPointer =
|
|
69
|
+
const featureMetaPointer = metaPointerForFeature(feature);
|
|
69
70
|
if (feature instanceof Property) {
|
|
70
71
|
if (value === undefined && !serializeEmptyFeatures) {
|
|
71
72
|
// for immediate backward compatibility: skip empty property values regardless of options?.skipEmptyValues
|
|
@@ -94,8 +95,7 @@ export const serializerWith = (configuration) => {
|
|
|
94
95
|
}
|
|
95
96
|
serializedNode.containments.push({
|
|
96
97
|
containment: featureMetaPointer,
|
|
97
|
-
children: keepDefineds(
|
|
98
|
-
.map(childId => childId)
|
|
98
|
+
children: asIds(keepDefineds(children))
|
|
99
99
|
});
|
|
100
100
|
children.forEach(childOrNull => {
|
|
101
101
|
if (childOrNull !== null) {
|
|
@@ -105,18 +105,32 @@ export const serializerWith = (configuration) => {
|
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
if (feature instanceof Reference) {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const targets = asArray(value).filter((ref) => {
|
|
109
|
+
if (isRef(ref)) {
|
|
110
|
+
return true; // (1) ref is a node, having an ID
|
|
111
|
+
}
|
|
112
|
+
if (isReferenceToSet(ref)) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return ref.targetId !== undefined || ref.resolveInfo !== undefined; // (2) not both are undefined
|
|
116
|
+
});
|
|
110
117
|
if (targets.length === 0 && !serializeEmptyFeatures) {
|
|
111
118
|
return;
|
|
112
119
|
}
|
|
113
120
|
serializedNode.references.push({
|
|
114
121
|
reference: featureMetaPointer,
|
|
115
|
-
targets:
|
|
116
|
-
.map(t =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
targets: targets
|
|
123
|
+
.map((t) => t instanceof UnresolvedReference
|
|
124
|
+
? {
|
|
125
|
+
resolveInfo: t.resolveInfo ?? null,
|
|
126
|
+
reference: t.targetId ?? null
|
|
127
|
+
// at least one of these will be non-null <== (2)
|
|
128
|
+
}
|
|
129
|
+
: {
|
|
130
|
+
resolveInfo: (reader.resolveInfoFor ? reader.resolveInfoFor(t, feature) : simpleNameDeducer(t, feature)) ?? null,
|
|
131
|
+
reference: t.id
|
|
132
|
+
// reference will be a non-null string (~(1))
|
|
133
|
+
})
|
|
120
134
|
});
|
|
121
135
|
return;
|
|
122
136
|
}
|
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,
|
|
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,qBAAqB,EAAE,MAAM,gBAAgB,C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,CAAC,0BAA0B;YACrE,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;YACtE,KAAK,EAAE,eAAe;SACzB,CAAA;IACL,CAAC,CAAA;AACL,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,KAAW,EACX,MAAsB,EACtB,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/core",
|
|
3
|
-
"version": "0.10.0-alpha.
|
|
3
|
+
"version": "0.10.0-alpha.2",
|
|
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.10.0-alpha.
|
|
31
|
-
"@lionweb/ts-utils": "0.10.0-alpha.
|
|
30
|
+
"@lionweb/json": "0.10.0-alpha.2",
|
|
31
|
+
"@lionweb/ts-utils": "0.10.0-alpha.2"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/deserializer.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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
8
|
import { LionWebVersions } from "./m3/versions.js"
|
|
9
|
-
import {
|
|
9
|
+
import { UnresolvedReference } from "./references.js"
|
|
10
10
|
import { Node } from "./types.js"
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -105,7 +105,7 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
105
105
|
return node
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
type ReferenceToInstall = [node: NT, feature: Reference, refId: LionWebId]
|
|
108
|
+
type ReferenceToInstall = [node: NT, feature: Reference, refId: LionWebId, resolveInfo?: string]
|
|
109
109
|
const referencesToInstall: ReferenceToInstall[] = []
|
|
110
110
|
|
|
111
111
|
const tryInstantiate = (
|
|
@@ -156,7 +156,6 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
156
156
|
if (properties !== undefined) {
|
|
157
157
|
allFeatures
|
|
158
158
|
.filter(feature => feature instanceof Property)
|
|
159
|
-
.map(feature => feature as Property)
|
|
160
159
|
.forEach(property => {
|
|
161
160
|
if (property.key in serializedPropertiesPerKey) {
|
|
162
161
|
const value = serializedPropertiesPerKey[property.key][0].value
|
|
@@ -190,29 +189,33 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
190
189
|
writer.setFeatureValue(node, feature, propertySettings[feature.key])
|
|
191
190
|
} else if (feature instanceof Containment && containments !== undefined && feature.key in serializedContainmentsPerKey) {
|
|
192
191
|
const childIds = serializedContainmentsPerKey[feature.key].flatMap(serChildren => serChildren.children) as LionWebId[]
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// just set the 1st one:
|
|
202
|
-
const firstChildId = childIds[0]
|
|
203
|
-
if (firstChildId in serializedNodeById) {
|
|
204
|
-
writer.setFeatureValue(node, feature, instantiateMemoised(serializedNodeById[firstChildId], node))
|
|
192
|
+
const deserializeChild = (childId: LionWebId) => {
|
|
193
|
+
if (childId in serializedNodeById) {
|
|
194
|
+
const child = instantiateMemoised(serializedNodeById[childId], node)
|
|
195
|
+
if (child !== null) {
|
|
196
|
+
writer.setFeatureValue(node, feature, child)
|
|
197
|
+
} else {
|
|
198
|
+
problemReporter.reportProblem(`child with id=${childId} is not instantiable, so can’t add it to containment ${feature.name} on node with id=${node.id}`)
|
|
199
|
+
// TODO set/add an UnresolvedContainment?
|
|
205
200
|
}
|
|
201
|
+
} else {
|
|
202
|
+
problemReporter.reportProblem(`child with id=${childId} doesn’t reside in this serialization chunk, so can’t add it to containment ${feature.name} on node with id=${node.id}`)
|
|
206
203
|
}
|
|
207
204
|
}
|
|
205
|
+
if (feature.multiple) {
|
|
206
|
+
childIds.forEach(deserializeChild)
|
|
207
|
+
} else if (childIds.length > 0) {
|
|
208
|
+
// just set the 1st one:
|
|
209
|
+
deserializeChild(childIds[0])
|
|
210
|
+
}
|
|
208
211
|
} else if (feature instanceof Reference && references !== undefined && feature.key in serializedReferencesPerKey) {
|
|
209
212
|
const serRefs = (serializedReferencesPerKey[feature.key] ?? []).flatMap(serReferences =>
|
|
210
|
-
serReferences.targets
|
|
213
|
+
serReferences.targets
|
|
211
214
|
)
|
|
212
215
|
referencesToInstall.push(
|
|
213
|
-
...(serRefs.
|
|
214
|
-
|
|
215
|
-
)
|
|
216
|
+
...(serRefs.map(
|
|
217
|
+
({reference, resolveInfo}) => [node, feature, reference, resolveInfo] as ReferenceToInstall
|
|
218
|
+
))
|
|
216
219
|
)
|
|
217
220
|
}
|
|
218
221
|
})
|
|
@@ -236,17 +239,17 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
236
239
|
|
|
237
240
|
const dependentNodesById = byIdMap(dependentNodes)
|
|
238
241
|
|
|
239
|
-
referencesToInstall.forEach(([node, reference, refId]) => {
|
|
242
|
+
referencesToInstall.forEach(([node, reference, refId, resolveInfo]) => {
|
|
240
243
|
const target = deserializedNodeById[refId] ?? dependentNodesById[refId]
|
|
241
244
|
const value = (() => {
|
|
242
|
-
if (target
|
|
243
|
-
|
|
244
|
-
problemReporter.reportProblem(
|
|
245
|
-
`couldn't resolve the target with id=${refId} of a "${reference.name}" reference on the node with id=${node.id}${metaTypeMessage}`
|
|
246
|
-
)
|
|
247
|
-
return unresolved
|
|
245
|
+
if (target !== undefined) {
|
|
246
|
+
return target
|
|
248
247
|
}
|
|
249
|
-
|
|
248
|
+
const metaTypeMessage = "concept" in node ? ` and (meta-)type ${node.concept}` : ""
|
|
249
|
+
problemReporter.reportProblem(
|
|
250
|
+
`couldn't resolve the target with id=${refId} of a "${reference.name}" reference on the node with id=${node.id}${metaTypeMessage}`
|
|
251
|
+
)
|
|
252
|
+
return new UnresolvedReference(refId, resolveInfo)
|
|
250
253
|
})()
|
|
251
254
|
writer.setFeatureValue(node, reference, value)
|
|
252
255
|
})
|
package/src/functions.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LionWebId, LionWebJsonMetaPointer } from "@lionweb/json"
|
|
1
|
+
import { LionWebId, LionWebJsonMetaPointer, LionWebJsonUsedLanguage } from "@lionweb/json"
|
|
2
2
|
import { flatMapNonCyclingFollowing, trivialFlatMapper } from "@lionweb/ts-utils"
|
|
3
3
|
import { Node } from "./types.js"
|
|
4
|
-
import { Feature } from "./m3/index.js"
|
|
4
|
+
import { Classifier, Feature, Language } from "./m3/index.js"
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -14,11 +14,10 @@ export const containmentChain = (node: Node): Node[] => {
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Maps an array of {@link Node AST nodes}
|
|
18
|
-
* These `null`s might be the result of unresolved children.
|
|
17
|
+
* Maps an array of {@link Node AST nodes} to their IDs.
|
|
19
18
|
*/
|
|
20
|
-
export const asIds = (
|
|
21
|
-
|
|
19
|
+
export const asIds = (nodes: Node[]): LionWebId[] =>
|
|
20
|
+
nodes.map(idOf)
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -31,7 +30,7 @@ export const idOf = <T extends Node>({id}: T): LionWebId =>
|
|
|
31
30
|
/**
|
|
32
31
|
* @return the {@link LionWebJsonMetaPointer} for the given {@link Feature}.
|
|
33
32
|
*/
|
|
34
|
-
export const
|
|
33
|
+
export const metaPointerForFeature = (feature: Feature): LionWebJsonMetaPointer => {
|
|
35
34
|
const { language } = feature.classifier
|
|
36
35
|
return {
|
|
37
36
|
language: language.key,
|
|
@@ -40,3 +39,23 @@ export const metaPointerFor = (feature: Feature): LionWebJsonMetaPointer => {
|
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Legacy version of {@link metaPointerForFeature} that wasn’t name-distinguished from other `metaPointerFor{Classifier|Feature|Language}` yet.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated Use {@link metaPointerForFeature} instead.
|
|
46
|
+
*/
|
|
47
|
+
export const metaPointerFor = metaPointerForFeature
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @return the {@link LionWebJsonMetaPointer} for the given {@link Classifier}.
|
|
51
|
+
*/
|
|
52
|
+
export const metaPointerForClassifier = (classifier: Classifier): LionWebJsonMetaPointer =>
|
|
53
|
+
classifier.metaPointer()
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @return the {@link LionWebJsonUsedLanguage meta-pointer} for the given {@link Language}.
|
|
57
|
+
*/
|
|
58
|
+
export const metaPointerForLanguage = ({ key, version }: Language): LionWebJsonUsedLanguage => ({
|
|
59
|
+
key, version
|
|
60
|
+
})
|
|
61
|
+
|
|
@@ -54,7 +54,6 @@ export const referenceValues = <NT extends Node, RT extends Node = NT>(
|
|
|
54
54
|
.flatMap((sourceNode) =>
|
|
55
55
|
allFeaturesOf(reader.classifierOf(sourceNode))
|
|
56
56
|
.filter((feature) => feature instanceof Reference)
|
|
57
|
-
.map((feature) => feature as Reference)
|
|
58
57
|
.flatMap((reference) => visit(sourceNode, reference))
|
|
59
58
|
)
|
|
60
59
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StringsMapper } from "@lionweb/ts-utils"
|
|
2
2
|
import { PropertyValueDeserializer } from "../deserializer.js"
|
|
3
3
|
import { Concept, DataType, Interface, Language, PrimitiveType, Property } from "./types.js"
|
|
4
|
-
import {
|
|
4
|
+
import { isRef } from "../references.js"
|
|
5
5
|
import { PropertyValueSerializer } from "../serializer.js"
|
|
6
6
|
|
|
7
7
|
|
|
@@ -49,7 +49,7 @@ export const propertyValueDeserializerFrom = (registry: Map<DataType, PropertyVa
|
|
|
49
49
|
throw new Error(`can't deserialize undefined as the value of required property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}")`)
|
|
50
50
|
}
|
|
51
51
|
const { type } = property
|
|
52
|
-
if (
|
|
52
|
+
if (!isRef(type)) {
|
|
53
53
|
throw new Error(`can't deserialize property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") with unspecified type`)
|
|
54
54
|
}
|
|
55
55
|
const specificDeserializer = byType(type)
|
|
@@ -89,7 +89,7 @@ export const propertyValueSerializerFrom = (registry: Map<DataType, PropertyValu
|
|
|
89
89
|
throw new Error(`can't serialize undefined as the value of required property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}")`)
|
|
90
90
|
}
|
|
91
91
|
const { type } = property
|
|
92
|
-
if (
|
|
92
|
+
if (!isRef(type)) {
|
|
93
93
|
throw new Error(`can't serialize property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") with unspecified type`)
|
|
94
94
|
}
|
|
95
95
|
const specificSerializer = byType(type)
|
package/src/m3/constraints.ts
CHANGED
|
@@ -22,7 +22,7 @@ const base64urlRegex = /^[A-Za-z0-9_-]+$/
|
|
|
22
22
|
* @return whether the given string is a valid identifier according to the LionWeb specification – see [here](https://github.com/LionWeb-io/specification/blob/main/2023.1/metametamodel/metametamodel.adoc#identifiers) for the relevant part.
|
|
23
23
|
* This is essentially whether the given string is a valid, non-empty [Base64url](https://en.wikipedia.org/wiki/Base64#Variants_summary_table) string.
|
|
24
24
|
*/
|
|
25
|
-
const isValidIdentifier = (str: string): boolean =>
|
|
25
|
+
export const isValidIdentifier = (str: string): boolean =>
|
|
26
26
|
base64urlRegex.test(str)
|
|
27
27
|
|
|
28
28
|
|
package/src/m3/functions.ts
CHANGED
|
@@ -303,7 +303,7 @@ const metaTypedBasedClassifierDeducerFor = <NT extends Node & IMetaTyped>(langua
|
|
|
303
303
|
* @return all {@link Concept concepts} defined in the given {@link Language language}.
|
|
304
304
|
*/
|
|
305
305
|
const conceptsOf = (language: Language): Concept[] =>
|
|
306
|
-
language.entities.filter((entity) => entity instanceof Concept)
|
|
306
|
+
language.entities.filter((entity) => entity instanceof Concept)
|
|
307
307
|
|
|
308
308
|
|
|
309
309
|
const isInstantiableClassifier = (entity: LanguageEntity): boolean =>
|
package/src/m3/symbol-table.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Classifier, Feature, Language, LanguageEntity } from "./types.js"
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Interface for objects that can look up within languages, based on given {@link LionWebJsonMetaPointer meta
|
|
8
|
+
* Interface for objects that can look up within languages, based on given {@link LionWebJsonMetaPointer meta-pointers}.
|
|
9
9
|
* This is meant to be able to properly encapsulate performance optimizations, also outside of the context
|
|
10
10
|
* of deserialization.
|
|
11
11
|
*/
|
package/src/m3/types.ts
CHANGED
|
@@ -88,7 +88,7 @@ class Property extends Feature {
|
|
|
88
88
|
metaType(): string {
|
|
89
89
|
return "Property"
|
|
90
90
|
}
|
|
91
|
-
type: SingleRef<DataType> = referenceToSet
|
|
91
|
+
type: SingleRef<DataType> = referenceToSet // (reference)
|
|
92
92
|
ofType(type: DataType): Property {
|
|
93
93
|
this.type = type
|
|
94
94
|
return this
|
|
@@ -97,7 +97,7 @@ class Property extends Feature {
|
|
|
97
97
|
|
|
98
98
|
abstract class Link extends Feature {
|
|
99
99
|
multiple /*: boolean */ = false
|
|
100
|
-
type: SingleRef<Classifier> = referenceToSet
|
|
100
|
+
type: SingleRef<Classifier> = referenceToSet // (reference)
|
|
101
101
|
isMultiple() {
|
|
102
102
|
this.multiple = true
|
|
103
103
|
return this
|
|
@@ -176,7 +176,7 @@ class Annotation extends Classifier {
|
|
|
176
176
|
}
|
|
177
177
|
extends?: SingleRef<Annotation> // (reference)
|
|
178
178
|
readonly implements: MultiRef<Interface> = [] // (reference)
|
|
179
|
-
annotates: SingleRef<Classifier> = referenceToSet
|
|
179
|
+
annotates: SingleRef<Classifier> = referenceToSet // (reference)
|
|
180
180
|
constructor(language: Language, name: string, key: LionWebKey, id: LionWebId, extends_?: SingleRef<Annotation>) {
|
|
181
181
|
super(language, name, key, id)
|
|
182
182
|
this.extends = extends_
|
|
@@ -2,7 +2,7 @@ import { asMinimalJsonString } from "@lionweb/ts-utils"
|
|
|
2
2
|
import { shouldBeIdentical } from "../../builtins-common.js"
|
|
3
3
|
import { DataType, Property } from "../../types.js"
|
|
4
4
|
import { PropertyValueDeserializer } from "../../../deserializer.js"
|
|
5
|
-
import {
|
|
5
|
+
import { isRef } from "../../../references.js"
|
|
6
6
|
import { PropertyValueSerializer } from "../../../serializer.js"
|
|
7
7
|
import { v2023_1 } from "./version.js"
|
|
8
8
|
|
|
@@ -62,7 +62,7 @@ export class BuiltinPropertyValueDeserializer
|
|
|
62
62
|
throw new Error(`can't deserialize undefined as the value of required property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}")`)
|
|
63
63
|
}
|
|
64
64
|
const { type } = property
|
|
65
|
-
if (
|
|
65
|
+
if (!isRef(type)) {
|
|
66
66
|
throw new Error(`can't deserialize property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") with unspecified type`)
|
|
67
67
|
}
|
|
68
68
|
const specificDeserializer = this.byType(type)
|
|
@@ -104,7 +104,7 @@ export class BuiltinPropertyValueSerializer extends DataTypeRegistry<(value: unk
|
|
|
104
104
|
throw new Error(`can't serialize undefined as the value of required property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}")`)
|
|
105
105
|
}
|
|
106
106
|
const { type } = property
|
|
107
|
-
if (
|
|
107
|
+
if (!isRef(type)) {
|
|
108
108
|
throw new Error(`can't serialize property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") with unspecified type`)
|
|
109
109
|
}
|
|
110
110
|
const specificSerializer = this.byType(type)
|