@lionweb/class-core 0.8.0-beta.6 → 0.8.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +7 -0
- package/dist/base-types.d.ts +4 -4
- package/dist/base-types.d.ts.map +1 -1
- package/dist/deltas/appliers.d.ts.map +1 -1
- package/dist/deltas/appliers.js +10 -12
- package/dist/deltas/appliers.js.map +1 -1
- package/dist/deltas/index.d.ts +0 -1
- package/dist/deltas/index.d.ts.map +1 -1
- package/dist/deltas/index.js +0 -1
- package/dist/deltas/index.js.map +1 -1
- package/dist/deltas/inverters.d.ts +1 -1
- package/dist/deltas/inverters.d.ts.map +1 -1
- package/dist/deltas/inverters.js +31 -34
- package/dist/deltas/inverters.js.map +1 -1
- package/dist/deltas/serialization/base.d.ts.map +1 -1
- package/dist/deltas/serialization/base.js +2 -2
- package/dist/deltas/serialization/base.js.map +1 -1
- package/dist/deltas/serialization/deserializer.g.d.ts.map +1 -1
- package/dist/deltas/serialization/deserializer.g.js +59 -63
- package/dist/deltas/serialization/deserializer.g.js.map +1 -1
- package/dist/deltas/serialization/serializer.g.d.ts.map +1 -1
- package/dist/deltas/serialization/serializer.g.js +5 -11
- package/dist/deltas/serialization/serializer.g.js.map +1 -1
- package/dist/deltas/serialization/types.g.d.ts +5 -9
- package/dist/deltas/serialization/types.g.d.ts.map +1 -1
- package/dist/deltas/types.g.d.ts +8 -12
- package/dist/deltas/types.g.d.ts.map +1 -1
- package/dist/deltas/types.g.js +7 -12
- package/dist/deltas/types.g.js.map +1 -1
- package/dist/deserializer.d.ts +1 -1
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +3 -3
- package/dist/deserializer.js.map +1 -1
- package/dist/id-mapping.d.ts +16 -10
- package/dist/id-mapping.d.ts.map +1 -1
- package/dist/id-mapping.js +21 -6
- package/dist/id-mapping.js.map +1 -1
- package/dist/references.d.ts +3 -4
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +1 -1
- package/dist/references.js.map +1 -1
- package/dist/serializer.d.ts +2 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +13 -9
- package/dist/serializer.js.map +1 -1
- package/dist/textualizer.d.ts +2 -1
- package/dist/textualizer.d.ts.map +1 -1
- package/dist/textualizer.js +13 -1
- package/dist/textualizer.js.map +1 -1
- package/dist/value-managers/references.d.ts +8 -8
- package/dist/value-managers/references.d.ts.map +1 -1
- package/dist/value-managers/references.js +3 -5
- package/dist/value-managers/references.js.map +1 -1
- package/package.json +5 -5
- package/src/base-types.ts +4 -4
- package/src/deltas/appliers.ts +16 -19
- package/src/deltas/index.ts +0 -1
- package/src/deltas/inverters.ts +31 -35
- package/src/deltas/serialization/base.ts +2 -2
- package/src/deltas/serialization/deserializer.g.ts +58 -63
- package/src/deltas/serialization/serializer.g.ts +4 -13
- package/src/deltas/serialization/types.g.ts +4 -10
- package/src/deltas/types.g.ts +5 -11
- package/src/deserializer.ts +4 -4
- package/src/id-mapping.ts +29 -14
- package/src/references.ts +3 -5
- package/src/serializer.ts +17 -11
- package/src/textualizer.ts +20 -2
- package/src/value-managers/references.ts +11 -13
- package/dist/deltas/compositor.d.ts +0 -51
- package/dist/deltas/compositor.d.ts.map +0 -1
- package/dist/deltas/compositor.js +0 -95
- package/dist/deltas/compositor.js.map +0 -1
- package/src/deltas/compositor.ts +0 -107
package/src/base-types.ts
CHANGED
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Encodes how a {@link INodeBase} is contained by a parent.
|
|
51
|
-
* If the
|
|
51
|
+
* If the `containingFeature` is `null`, the {@link INodeBase} is an annotation
|
|
52
52
|
* and effectively contained by the {@link INodeBase.annotations} property.
|
|
53
53
|
*/
|
|
54
54
|
export type Parentage = [ parent: INodeBase, containingFeature: Containment | null ];
|
|
@@ -66,7 +66,7 @@ export interface INodeBase extends Node {
|
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* The parent of this node object,
|
|
69
|
-
* or
|
|
69
|
+
* or `undefined` if it's either a root (in which case it `this.classifier` should be a {@link Concept} which is a partition)
|
|
70
70
|
* or (currently/temporarily) an orphan.
|
|
71
71
|
*/
|
|
72
72
|
parent: INodeBase | undefined;
|
|
@@ -107,7 +107,7 @@ export interface INodeBase extends Node {
|
|
|
107
107
|
* @return the value manager for the given {@link Reference reference} feature.
|
|
108
108
|
* @throws if this node('s {@link Classifier classifier}) doesn't have that reference.
|
|
109
109
|
*/
|
|
110
|
-
getReferenceValueManager(reference: Reference): ReferenceValueManager<
|
|
110
|
+
getReferenceValueManager(reference: Reference): ReferenceValueManager<Node>;
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* @return the value manager for the given {@link Feature feature}.
|
|
@@ -247,7 +247,7 @@ export abstract class NodeBase implements INodeBase {
|
|
|
247
247
|
throw new Error(`containment (feature) "${containment.name}" (with key=${containment.key}) doesn't exist on ${this.locationMessage}`);
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
getReferenceValueManager(reference: Reference): ReferenceValueManager<
|
|
250
|
+
getReferenceValueManager(reference: Reference): ReferenceValueManager<Node> {
|
|
251
251
|
throw new Error(`reference (feature) "${reference.name}" (with key=${reference.key}) doesn't exist on ${this.locationMessage}`);
|
|
252
252
|
}
|
|
253
253
|
|
package/src/deltas/appliers.ts
CHANGED
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
ChildMovedFromOtherContainmentInSameParentDelta,
|
|
33
33
|
ChildMovedInSameContainmentDelta,
|
|
34
34
|
ChildReplacedDelta,
|
|
35
|
-
CompositeDelta,
|
|
36
35
|
NoOpDelta,
|
|
37
36
|
PartitionAddedDelta,
|
|
38
37
|
PartitionDeletedDelta,
|
|
@@ -51,7 +50,7 @@ import {
|
|
|
51
50
|
} from "../value-managers/index.js"
|
|
52
51
|
import { INodeBase } from "../base-types.js"
|
|
53
52
|
import { IdMapping } from "../id-mapping.js"
|
|
54
|
-
import { isUnresolvedReference, referenceToSet, SingleRef } from "@lionweb/core"
|
|
53
|
+
import { isUnresolvedReference, Node, referenceToSet, SingleRef } from "@lionweb/core"
|
|
55
54
|
import { IDelta } from "./base.js"
|
|
56
55
|
|
|
57
56
|
|
|
@@ -70,24 +69,21 @@ const deltaApplier = (idMapping?: IdMapping, updatablePartitions?: () => INodeBa
|
|
|
70
69
|
if (idMapping === undefined) {
|
|
71
70
|
return node
|
|
72
71
|
}
|
|
73
|
-
const lookup = idMapping.
|
|
74
|
-
if (lookup === undefined) {
|
|
75
|
-
throw new Error(`look up of node with id=${node.id} failed: node doesn't exist in ID mapping`);
|
|
76
|
-
}
|
|
72
|
+
const lookup = idMapping.nodeBaseFromId(node.id);
|
|
77
73
|
if (node.classifier !== lookup.classifier) {
|
|
78
74
|
throw new Error(`look up of node with id=${node.id} failed: looked-up node has a different classifier than the original one`);
|
|
79
75
|
}
|
|
80
76
|
return lookup;
|
|
81
77
|
};
|
|
82
78
|
|
|
83
|
-
const lookupNodeRefFrom = <T extends
|
|
79
|
+
const lookupNodeRefFrom = <T extends Node>(nodeRef: SingleRef<T>): SingleRef<T> => {
|
|
84
80
|
if (idMapping === undefined) {
|
|
85
81
|
return nodeRef
|
|
86
82
|
}
|
|
87
83
|
if (isUnresolvedReference(nodeRef)) {
|
|
88
84
|
return referenceToSet()
|
|
89
85
|
}
|
|
90
|
-
return
|
|
86
|
+
return idMapping.fromRefId(nodeRef.id) as SingleRef<T>;
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
const applyDelta = (delta: IDelta): void => {
|
|
@@ -313,38 +309,39 @@ const deltaApplier = (idMapping?: IdMapping, updatablePartitions?: () => INodeBa
|
|
|
313
309
|
}
|
|
314
310
|
if (delta instanceof ReferenceAddedDelta) {
|
|
315
311
|
const valueManager = lookupNodeFrom(delta.parent).getReferenceValueManager(delta.reference);
|
|
316
|
-
const newTarget = lookupNodeRefFrom(delta.
|
|
312
|
+
const newTarget = lookupNodeRefFrom(delta.newReference);
|
|
317
313
|
if (delta.reference.multiple) {
|
|
318
|
-
(valueManager as MultiReferenceValueManager<
|
|
314
|
+
(valueManager as MultiReferenceValueManager<Node>).insertAtIndexDirectly(newTarget, delta.index);
|
|
319
315
|
} else {
|
|
320
|
-
(valueManager as SingleReferenceValueManager<
|
|
316
|
+
(valueManager as SingleReferenceValueManager<Node>).setDirectly(newTarget);
|
|
321
317
|
}
|
|
322
318
|
return;
|
|
323
319
|
}
|
|
324
320
|
if (delta instanceof ReferenceDeletedDelta) {
|
|
325
321
|
const valueManager = lookupNodeFrom(delta.parent).getReferenceValueManager(delta.reference);
|
|
326
322
|
if (delta.reference.multiple) {
|
|
327
|
-
|
|
323
|
+
const multiValueManager = valueManager as MultiReferenceValueManager<Node>;
|
|
324
|
+
if (multiValueManager.getDirectly()[delta.index] !== delta.deletedReference) {
|
|
325
|
+
throw new Error(`index ${delta.index} doesn’t match deleted reference`)
|
|
326
|
+
}
|
|
327
|
+
multiValueManager.removeAtIndexDirectly(delta.index);
|
|
328
328
|
} else {
|
|
329
|
-
(valueManager as SingleReferenceValueManager<
|
|
329
|
+
(valueManager as SingleReferenceValueManager<Node>).setDirectly(undefined);
|
|
330
330
|
}
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
if (delta instanceof ReferenceChangedDelta) {
|
|
334
334
|
const valueManager = lookupNodeFrom(delta.parent).getReferenceValueManager(delta.reference);
|
|
335
|
-
const newTarget = lookupNodeRefFrom(delta.
|
|
335
|
+
const newTarget = lookupNodeRefFrom(delta.newReference);
|
|
336
336
|
if (delta.reference.multiple) {
|
|
337
|
-
const multiValueManager = valueManager as MultiReferenceValueManager<
|
|
337
|
+
const multiValueManager = valueManager as MultiReferenceValueManager<Node>;
|
|
338
338
|
multiValueManager.removeAtIndexDirectly(delta.index); // should be delta.oldTarget
|
|
339
339
|
multiValueManager.insertAtIndexDirectly(newTarget, delta.index);
|
|
340
340
|
} else {
|
|
341
|
-
(valueManager as SingleReferenceValueManager<
|
|
341
|
+
(valueManager as SingleReferenceValueManager<Node>).setDirectly(newTarget);
|
|
342
342
|
}
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
345
|
-
if (delta instanceof CompositeDelta) {
|
|
346
|
-
delta.parts.forEach(applyDelta);
|
|
347
|
-
}
|
|
348
345
|
if (delta instanceof NoOpDelta) {
|
|
349
346
|
return;
|
|
350
347
|
}
|
package/src/deltas/index.ts
CHANGED
package/src/deltas/inverters.ts
CHANGED
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
ChildMovedFromOtherContainmentInSameParentDelta,
|
|
33
33
|
ChildMovedInSameContainmentDelta,
|
|
34
34
|
ChildReplacedDelta,
|
|
35
|
-
CompositeDelta,
|
|
36
35
|
NoOpDelta,
|
|
37
36
|
PartitionAddedDelta,
|
|
38
37
|
PartitionDeletedDelta,
|
|
@@ -50,99 +49,96 @@ import { IDelta } from "./base.js"
|
|
|
50
49
|
* @return the inverted version of the given {@link IDelta delta}
|
|
51
50
|
* in the sense that it undoes that delta after it has been applied.
|
|
52
51
|
*/
|
|
53
|
-
export const invertDelta = (delta: IDelta): IDelta => {
|
|
52
|
+
export const invertDelta = (delta: IDelta): IDelta[] => {
|
|
54
53
|
if (delta instanceof PartitionAddedDelta) {
|
|
55
|
-
return new PartitionDeletedDelta(delta.newPartition);
|
|
54
|
+
return [new PartitionDeletedDelta(delta.newPartition)];
|
|
56
55
|
}
|
|
57
56
|
if (delta instanceof PartitionDeletedDelta) {
|
|
58
|
-
return new PartitionAddedDelta(delta.deletedPartition);
|
|
57
|
+
return [new PartitionAddedDelta(delta.deletedPartition)];
|
|
59
58
|
}
|
|
60
59
|
if (delta instanceof PropertyAddedDelta) {
|
|
61
|
-
return new PropertyDeletedDelta(delta.node, delta.property, delta.value);
|
|
60
|
+
return [new PropertyDeletedDelta(delta.node, delta.property, delta.value)];
|
|
62
61
|
}
|
|
63
62
|
if (delta instanceof PropertyDeletedDelta) {
|
|
64
|
-
return new PropertyAddedDelta(delta.node, delta.property, delta.oldValue);
|
|
63
|
+
return [new PropertyAddedDelta(delta.node, delta.property, delta.oldValue)];
|
|
65
64
|
}
|
|
66
65
|
if (delta instanceof PropertyChangedDelta) {
|
|
67
|
-
return new PropertyChangedDelta(delta.node, delta.property, delta.newValue, delta.oldValue);
|
|
66
|
+
return [new PropertyChangedDelta(delta.node, delta.property, delta.newValue, delta.oldValue)];
|
|
68
67
|
}
|
|
69
68
|
if (delta instanceof ChildAddedDelta) {
|
|
70
|
-
return new ChildDeletedDelta(delta.parent, delta.containment, delta.index, delta.newChild);
|
|
69
|
+
return [new ChildDeletedDelta(delta.parent, delta.containment, delta.index, delta.newChild)];
|
|
71
70
|
}
|
|
72
71
|
if (delta instanceof ChildDeletedDelta) {
|
|
73
|
-
return new ChildAddedDelta(delta.parent, delta.containment, delta.index, delta.deletedChild);
|
|
72
|
+
return [new ChildAddedDelta(delta.parent, delta.containment, delta.index, delta.deletedChild)];
|
|
74
73
|
}
|
|
75
74
|
if (delta instanceof ChildReplacedDelta) {
|
|
76
|
-
return new ChildReplacedDelta(delta.parent, delta.containment, delta.index, delta.newChild, delta.replacedChild);
|
|
75
|
+
return [new ChildReplacedDelta(delta.parent, delta.containment, delta.index, delta.newChild, delta.replacedChild)];
|
|
77
76
|
}
|
|
78
77
|
if (delta instanceof ChildMovedFromOtherContainmentDelta) {
|
|
79
|
-
return new ChildMovedFromOtherContainmentDelta(delta.newParent, delta.newContainment, delta.newIndex, delta.oldParent, delta.oldContainment, delta.oldIndex, delta.movedChild);
|
|
78
|
+
return [new ChildMovedFromOtherContainmentDelta(delta.newParent, delta.newContainment, delta.newIndex, delta.oldParent, delta.oldContainment, delta.oldIndex, delta.movedChild)];
|
|
80
79
|
}
|
|
81
80
|
if (delta instanceof ChildMovedFromOtherContainmentInSameParentDelta) {
|
|
82
|
-
return new ChildMovedFromOtherContainmentInSameParentDelta(delta.parent, delta.newContainment, delta.newIndex, delta.movedChild, delta.oldContainment, delta.oldIndex);
|
|
81
|
+
return [new ChildMovedFromOtherContainmentInSameParentDelta(delta.parent, delta.newContainment, delta.newIndex, delta.movedChild, delta.oldContainment, delta.oldIndex)];
|
|
83
82
|
}
|
|
84
83
|
if (delta instanceof ChildMovedInSameContainmentDelta) {
|
|
85
|
-
return new ChildMovedInSameContainmentDelta(delta.parent, delta.containment, delta.newIndex, delta.oldIndex, delta.movedChild);
|
|
84
|
+
return [new ChildMovedInSameContainmentDelta(delta.parent, delta.containment, delta.newIndex, delta.oldIndex, delta.movedChild)];
|
|
86
85
|
}
|
|
87
86
|
if (delta instanceof ChildMovedAndReplacedFromOtherContainmentDelta) {
|
|
88
|
-
return
|
|
87
|
+
return [
|
|
89
88
|
new ChildMovedFromOtherContainmentDelta(delta.newParent, delta.newContainment, delta.newIndex, delta.oldParent, delta.oldContainment, delta.oldIndex, delta.movedChild),
|
|
90
89
|
new ChildAddedDelta(delta.newParent, delta.newContainment, delta.newIndex, delta.replacedChild)
|
|
91
|
-
]
|
|
90
|
+
];
|
|
92
91
|
}
|
|
93
92
|
if (delta instanceof ChildMovedAndReplacedFromOtherContainmentInSameParentDelta) {
|
|
94
|
-
return
|
|
93
|
+
return [
|
|
95
94
|
new ChildMovedFromOtherContainmentInSameParentDelta(delta.parent, delta.newContainment, delta.newIndex, delta.movedChild, delta.oldContainment, delta.oldIndex),
|
|
96
95
|
new ChildAddedDelta(delta.parent, delta.newContainment, delta.newIndex, delta.replacedChild)
|
|
97
|
-
]
|
|
96
|
+
];
|
|
98
97
|
}
|
|
99
98
|
if (delta instanceof ChildMovedAndReplacedInSameContainmentDelta) {
|
|
100
|
-
return
|
|
99
|
+
return [
|
|
101
100
|
new ChildMovedInSameContainmentDelta(delta.parent, delta.containment, delta.newIndex, delta.oldIndex, delta.movedChild),
|
|
102
101
|
new ChildAddedDelta(delta.parent, delta.containment, delta.newIndex, delta.replacedChild)
|
|
103
|
-
]
|
|
102
|
+
];
|
|
104
103
|
}
|
|
105
104
|
if (delta instanceof AnnotationAddedDelta) {
|
|
106
|
-
return new AnnotationDeletedDelta(delta.parent, delta.index, delta.newAnnotation);
|
|
105
|
+
return [new AnnotationDeletedDelta(delta.parent, delta.index, delta.newAnnotation)];
|
|
107
106
|
}
|
|
108
107
|
if (delta instanceof AnnotationDeletedDelta) {
|
|
109
|
-
return new AnnotationAddedDelta(delta.parent, delta.index, delta.deletedAnnotation);
|
|
108
|
+
return [new AnnotationAddedDelta(delta.parent, delta.index, delta.deletedAnnotation)];
|
|
110
109
|
}
|
|
111
110
|
if (delta instanceof AnnotationReplacedDelta) {
|
|
112
|
-
return new AnnotationReplacedDelta(delta.parent, delta.index, delta.newAnnotation, delta.replacedAnnotation);
|
|
111
|
+
return [new AnnotationReplacedDelta(delta.parent, delta.index, delta.newAnnotation, delta.replacedAnnotation)];
|
|
113
112
|
}
|
|
114
113
|
if (delta instanceof AnnotationMovedFromOtherParentDelta) {
|
|
115
|
-
return new AnnotationMovedFromOtherParentDelta(delta.newParent, delta.newIndex, delta.oldParent, delta.oldIndex, delta.movedAnnotation);
|
|
114
|
+
return [new AnnotationMovedFromOtherParentDelta(delta.newParent, delta.newIndex, delta.oldParent, delta.oldIndex, delta.movedAnnotation)];
|
|
116
115
|
}
|
|
117
116
|
if (delta instanceof AnnotationMovedInSameParentDelta) {
|
|
118
|
-
return new AnnotationMovedInSameParentDelta(delta.parent, delta.newIndex, delta.oldIndex, delta.movedAnnotation);
|
|
117
|
+
return [new AnnotationMovedInSameParentDelta(delta.parent, delta.newIndex, delta.oldIndex, delta.movedAnnotation)];
|
|
119
118
|
}
|
|
120
119
|
if (delta instanceof AnnotationMovedAndReplacedFromOtherParentDelta) {
|
|
121
|
-
return
|
|
120
|
+
return [
|
|
122
121
|
new AnnotationMovedFromOtherParentDelta(delta.newParent, delta.newIndex, delta.oldParent, delta.oldIndex, delta.movedAnnotation),
|
|
123
122
|
new AnnotationAddedDelta(delta.newParent, delta.newIndex, delta.replacedAnnotation)
|
|
124
|
-
]
|
|
123
|
+
];
|
|
125
124
|
}
|
|
126
125
|
if (delta instanceof AnnotationMovedAndReplacedInSameParentDelta) {
|
|
127
|
-
return
|
|
126
|
+
return [
|
|
128
127
|
new AnnotationMovedInSameParentDelta(delta.parent, delta.newIndex, delta.oldIndex, delta.movedAnnotation),
|
|
129
128
|
new AnnotationAddedDelta(delta.parent, delta.newIndex, delta.replacedAnnotation)
|
|
130
|
-
]
|
|
129
|
+
];
|
|
131
130
|
}
|
|
132
131
|
if (delta instanceof ReferenceAddedDelta) {
|
|
133
|
-
return new ReferenceDeletedDelta(delta.parent, delta.reference, delta.index, delta.
|
|
132
|
+
return [new ReferenceDeletedDelta(delta.parent, delta.reference, delta.index, delta.newReference)];
|
|
134
133
|
}
|
|
135
134
|
if (delta instanceof ReferenceDeletedDelta) {
|
|
136
|
-
return new ReferenceAddedDelta(delta.parent, delta.reference, delta.index, delta.
|
|
135
|
+
return [new ReferenceAddedDelta(delta.parent, delta.reference, delta.index, delta.deletedReference)];
|
|
137
136
|
}
|
|
138
137
|
if (delta instanceof ReferenceChangedDelta) {
|
|
139
|
-
return new ReferenceChangedDelta(delta.parent, delta.reference, delta.index, delta.
|
|
140
|
-
}
|
|
141
|
-
if (delta instanceof CompositeDelta) {
|
|
142
|
-
return new CompositeDelta(delta.parts.map(invertDelta));
|
|
138
|
+
return [new ReferenceChangedDelta(delta.parent, delta.reference, delta.index, delta.oldReference, delta.newReference)];
|
|
143
139
|
}
|
|
144
140
|
if (delta instanceof NoOpDelta) {
|
|
145
|
-
return delta;
|
|
141
|
+
return [delta];
|
|
146
142
|
}
|
|
147
143
|
|
|
148
144
|
throw new Error(`inversion of delta of class ${delta.constructor.name} not implemented`);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { LionWebVersions } from "@lionweb/core"
|
|
19
19
|
import { IDelta } from "../base.js"
|
|
20
20
|
import { SerializedDelta } from "./types.g.js"
|
|
21
21
|
import { propertyValueSerializerWith } from "../../serializer.js"
|
|
@@ -32,5 +32,5 @@ export type DeltaDeserializer = (delta: SerializedDelta) => IDelta;
|
|
|
32
32
|
* using the same {@link PropertyValueSerializer} instance as the {@link serializeNodeBases} function,
|
|
33
33
|
* and the same treatment of enumeration values.
|
|
34
34
|
*/
|
|
35
|
-
export const defaultPropertyValueSerializer = propertyValueSerializerWith({ primitiveValueSerializer:
|
|
35
|
+
export const defaultPropertyValueSerializer = propertyValueSerializerWith({ primitiveValueSerializer: LionWebVersions.v2023_1.builtinsFacade.propertyValueSerializer })
|
|
36
36
|
|
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
ChildMovedFromOtherContainmentInSameParentDelta,
|
|
42
42
|
ChildMovedInSameContainmentDelta,
|
|
43
43
|
ChildReplacedDelta,
|
|
44
|
-
CompositeDelta,
|
|
45
44
|
NoOpDelta,
|
|
46
45
|
PartitionAddedDelta,
|
|
47
46
|
PartitionDeletedDelta,
|
|
@@ -59,187 +58,183 @@ export const deltaDeserializer = (languageBases: ILanguageBase[], idMapping: IdM
|
|
|
59
58
|
const deserializedDelta = (delta: SerializedDelta): IDelta => {
|
|
60
59
|
switch (delta.kind) {
|
|
61
60
|
case "PartitionAdded": {
|
|
62
|
-
const newPartition = idMapping.
|
|
61
|
+
const newPartition = idMapping.nodeBaseFromId(delta.newPartition);
|
|
63
62
|
return new PartitionAddedDelta(newPartition);
|
|
64
63
|
}
|
|
65
64
|
case "PartitionDeleted": {
|
|
66
|
-
const deletedPartition = idMapping.
|
|
65
|
+
const deletedPartition = idMapping.nodeBaseFromId(delta.deletedPartition);
|
|
67
66
|
return new PartitionDeletedDelta(deletedPartition);
|
|
68
67
|
}
|
|
69
68
|
case "PropertyAdded": {
|
|
70
|
-
const node = idMapping.
|
|
69
|
+
const node = idMapping.nodeBaseFromId(delta.node);
|
|
71
70
|
const property = resolvedPropertyFrom(delta.property, node.classifier);
|
|
72
71
|
const value = delta.value;
|
|
73
72
|
return new PropertyAddedDelta(node, property, value);
|
|
74
73
|
}
|
|
75
74
|
case "PropertyDeleted": {
|
|
76
|
-
const node = idMapping.
|
|
75
|
+
const node = idMapping.nodeBaseFromId(delta.node);
|
|
77
76
|
const property = resolvedPropertyFrom(delta.property, node.classifier);
|
|
78
77
|
const oldValue = delta.oldValue;
|
|
79
78
|
return new PropertyDeletedDelta(node, property, oldValue);
|
|
80
79
|
}
|
|
81
80
|
case "PropertyChanged": {
|
|
82
|
-
const node = idMapping.
|
|
81
|
+
const node = idMapping.nodeBaseFromId(delta.node);
|
|
83
82
|
const property = resolvedPropertyFrom(delta.property, node.classifier);
|
|
84
83
|
const oldValue = delta.oldValue;
|
|
85
84
|
const newValue = delta.newValue;
|
|
86
85
|
return new PropertyChangedDelta(node, property, oldValue, newValue);
|
|
87
86
|
}
|
|
88
87
|
case "ChildAdded": {
|
|
89
|
-
const parent = idMapping.
|
|
88
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
90
89
|
const containment = resolvedContainmentFrom(delta.containment, parent.classifier);
|
|
91
90
|
const index = delta.index;
|
|
92
|
-
const newChild = idMapping.
|
|
91
|
+
const newChild = idMapping.nodeBaseFromId(delta.newChild);
|
|
93
92
|
return new ChildAddedDelta(parent, containment, index, newChild);
|
|
94
93
|
}
|
|
95
94
|
case "ChildDeleted": {
|
|
96
|
-
const parent = idMapping.
|
|
95
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
97
96
|
const containment = resolvedContainmentFrom(delta.containment, parent.classifier);
|
|
98
97
|
const index = delta.index;
|
|
99
|
-
const deletedChild = idMapping.
|
|
98
|
+
const deletedChild = idMapping.nodeBaseFromId(delta.deletedChild);
|
|
100
99
|
return new ChildDeletedDelta(parent, containment, index, deletedChild);
|
|
101
100
|
}
|
|
102
101
|
case "ChildReplaced": {
|
|
103
|
-
const parent = idMapping.
|
|
102
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
104
103
|
const containment = resolvedContainmentFrom(delta.containment, parent.classifier);
|
|
105
104
|
const index = delta.index;
|
|
106
|
-
const replacedChild = idMapping.
|
|
107
|
-
const newChild = idMapping.
|
|
105
|
+
const replacedChild = idMapping.nodeBaseFromId(delta.replacedChild);
|
|
106
|
+
const newChild = idMapping.nodeBaseFromId(delta.newChild);
|
|
108
107
|
return new ChildReplacedDelta(parent, containment, index, replacedChild, newChild);
|
|
109
108
|
}
|
|
110
109
|
case "ChildMovedFromOtherContainment": {
|
|
111
|
-
const oldParent = idMapping.
|
|
110
|
+
const oldParent = idMapping.nodeBaseFromId(delta.oldParent);
|
|
112
111
|
const oldContainment = resolvedContainmentFrom(delta.oldContainment, oldParent.classifier);
|
|
113
112
|
const oldIndex = delta.oldIndex;
|
|
114
|
-
const newParent = idMapping.
|
|
113
|
+
const newParent = idMapping.nodeBaseFromId(delta.newParent);
|
|
115
114
|
const newContainment = resolvedContainmentFrom(delta.newContainment, newParent.classifier);
|
|
116
115
|
const newIndex = delta.newIndex;
|
|
117
|
-
const movedChild = idMapping.
|
|
116
|
+
const movedChild = idMapping.nodeBaseFromId(delta.movedChild);
|
|
118
117
|
return new ChildMovedFromOtherContainmentDelta(oldParent, oldContainment, oldIndex, newParent, newContainment, newIndex, movedChild);
|
|
119
118
|
}
|
|
120
119
|
case "ChildMovedFromOtherContainmentInSameParent": {
|
|
121
|
-
const parent = idMapping.
|
|
120
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
122
121
|
const oldContainment = resolvedContainmentFrom(delta.oldContainment, parent.classifier);
|
|
123
122
|
const oldIndex = delta.oldIndex;
|
|
124
|
-
const movedChild = idMapping.
|
|
123
|
+
const movedChild = idMapping.nodeBaseFromId(delta.movedChild);
|
|
125
124
|
const newContainment = resolvedContainmentFrom(delta.newContainment, parent.classifier);
|
|
126
125
|
const newIndex = delta.newIndex;
|
|
127
126
|
return new ChildMovedFromOtherContainmentInSameParentDelta(parent, oldContainment, oldIndex, movedChild, newContainment, newIndex);
|
|
128
127
|
}
|
|
129
128
|
case "ChildMovedInSameContainment": {
|
|
130
|
-
const parent = idMapping.
|
|
129
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
131
130
|
const containment = resolvedContainmentFrom(delta.containment, parent.classifier);
|
|
132
131
|
const oldIndex = delta.oldIndex;
|
|
133
132
|
const newIndex = delta.newIndex;
|
|
134
|
-
const movedChild = idMapping.
|
|
133
|
+
const movedChild = idMapping.nodeBaseFromId(delta.movedChild);
|
|
135
134
|
return new ChildMovedInSameContainmentDelta(parent, containment, oldIndex, newIndex, movedChild);
|
|
136
135
|
}
|
|
137
136
|
case "ChildMovedAndReplacedFromOtherContainment": {
|
|
138
|
-
const newParent = idMapping.
|
|
137
|
+
const newParent = idMapping.nodeBaseFromId(delta.newParent);
|
|
139
138
|
const newContainment = resolvedContainmentFrom(delta.newContainment, newParent.classifier);
|
|
140
139
|
const newIndex = delta.newIndex;
|
|
141
|
-
const movedChild = idMapping.
|
|
142
|
-
const oldParent = idMapping.
|
|
140
|
+
const movedChild = idMapping.nodeBaseFromId(delta.movedChild);
|
|
141
|
+
const oldParent = idMapping.nodeBaseFromId(delta.oldParent);
|
|
143
142
|
const oldContainment = resolvedContainmentFrom(delta.oldContainment, oldParent.classifier);
|
|
144
143
|
const oldIndex = delta.oldIndex;
|
|
145
|
-
const replacedChild = idMapping.
|
|
144
|
+
const replacedChild = idMapping.nodeBaseFromId(delta.replacedChild);
|
|
146
145
|
return new ChildMovedAndReplacedFromOtherContainmentDelta(newParent, newContainment, newIndex, movedChild, oldParent, oldContainment, oldIndex, replacedChild);
|
|
147
146
|
}
|
|
148
147
|
case "ChildMovedAndReplacedFromOtherContainmentInSameParent": {
|
|
149
|
-
const parent = idMapping.
|
|
148
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
150
149
|
const oldContainment = resolvedContainmentFrom(delta.oldContainment, parent.classifier);
|
|
151
150
|
const oldIndex = delta.oldIndex;
|
|
152
151
|
const newContainment = resolvedContainmentFrom(delta.newContainment, parent.classifier);
|
|
153
152
|
const newIndex = delta.newIndex;
|
|
154
|
-
const movedChild = idMapping.
|
|
155
|
-
const replacedChild = idMapping.
|
|
153
|
+
const movedChild = idMapping.nodeBaseFromId(delta.movedChild);
|
|
154
|
+
const replacedChild = idMapping.nodeBaseFromId(delta.replacedChild);
|
|
156
155
|
return new ChildMovedAndReplacedFromOtherContainmentInSameParentDelta(parent, oldContainment, oldIndex, newContainment, newIndex, movedChild, replacedChild);
|
|
157
156
|
}
|
|
158
157
|
case "ChildMovedAndReplacedInSameContainment": {
|
|
159
|
-
const parent = idMapping.
|
|
158
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
160
159
|
const containment = resolvedContainmentFrom(delta.containment, parent.classifier);
|
|
161
160
|
const oldIndex = delta.oldIndex;
|
|
162
161
|
const newIndex = delta.newIndex;
|
|
163
|
-
const movedChild = idMapping.
|
|
164
|
-
const replacedChild = idMapping.
|
|
162
|
+
const movedChild = idMapping.nodeBaseFromId(delta.movedChild);
|
|
163
|
+
const replacedChild = idMapping.nodeBaseFromId(delta.replacedChild);
|
|
165
164
|
return new ChildMovedAndReplacedInSameContainmentDelta(parent, containment, oldIndex, newIndex, movedChild, replacedChild);
|
|
166
165
|
}
|
|
167
166
|
case "AnnotationAdded": {
|
|
168
|
-
const parent = idMapping.
|
|
167
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
169
168
|
const index = delta.index;
|
|
170
|
-
const newAnnotation = idMapping.
|
|
169
|
+
const newAnnotation = idMapping.nodeBaseFromId(delta.newAnnotation);
|
|
171
170
|
return new AnnotationAddedDelta(parent, index, newAnnotation);
|
|
172
171
|
}
|
|
173
172
|
case "AnnotationDeleted": {
|
|
174
|
-
const parent = idMapping.
|
|
173
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
175
174
|
const index = delta.index;
|
|
176
|
-
const deletedAnnotation = idMapping.
|
|
175
|
+
const deletedAnnotation = idMapping.nodeBaseFromId(delta.deletedAnnotation);
|
|
177
176
|
return new AnnotationDeletedDelta(parent, index, deletedAnnotation);
|
|
178
177
|
}
|
|
179
178
|
case "AnnotationReplaced": {
|
|
180
|
-
const parent = idMapping.
|
|
179
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
181
180
|
const index = delta.index;
|
|
182
|
-
const replacedAnnotation = idMapping.
|
|
183
|
-
const newAnnotation = idMapping.
|
|
181
|
+
const replacedAnnotation = idMapping.nodeBaseFromId(delta.replacedAnnotation);
|
|
182
|
+
const newAnnotation = idMapping.nodeBaseFromId(delta.newAnnotation);
|
|
184
183
|
return new AnnotationReplacedDelta(parent, index, replacedAnnotation, newAnnotation);
|
|
185
184
|
}
|
|
186
185
|
case "AnnotationMovedFromOtherParent": {
|
|
187
|
-
const oldParent = idMapping.
|
|
186
|
+
const oldParent = idMapping.nodeBaseFromId(delta.oldParent);
|
|
188
187
|
const oldIndex = delta.oldIndex;
|
|
189
|
-
const newParent = idMapping.
|
|
188
|
+
const newParent = idMapping.nodeBaseFromId(delta.newParent);
|
|
190
189
|
const newIndex = delta.newIndex;
|
|
191
|
-
const movedAnnotation = idMapping.
|
|
190
|
+
const movedAnnotation = idMapping.nodeBaseFromId(delta.movedAnnotation);
|
|
192
191
|
return new AnnotationMovedFromOtherParentDelta(oldParent, oldIndex, newParent, newIndex, movedAnnotation);
|
|
193
192
|
}
|
|
194
193
|
case "AnnotationMovedInSameParent": {
|
|
195
|
-
const parent = idMapping.
|
|
194
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
196
195
|
const oldIndex = delta.oldIndex;
|
|
197
196
|
const newIndex = delta.newIndex;
|
|
198
|
-
const movedAnnotation = idMapping.
|
|
197
|
+
const movedAnnotation = idMapping.nodeBaseFromId(delta.movedAnnotation);
|
|
199
198
|
return new AnnotationMovedInSameParentDelta(parent, oldIndex, newIndex, movedAnnotation);
|
|
200
199
|
}
|
|
201
200
|
case "AnnotationMovedAndReplacedFromOtherParent": {
|
|
202
|
-
const oldParent = idMapping.
|
|
201
|
+
const oldParent = idMapping.nodeBaseFromId(delta.oldParent);
|
|
203
202
|
const oldIndex = delta.oldIndex;
|
|
204
|
-
const replacedAnnotation = idMapping.
|
|
205
|
-
const newParent = idMapping.
|
|
203
|
+
const replacedAnnotation = idMapping.nodeBaseFromId(delta.replacedAnnotation);
|
|
204
|
+
const newParent = idMapping.nodeBaseFromId(delta.newParent);
|
|
206
205
|
const newIndex = delta.newIndex;
|
|
207
|
-
const movedAnnotation = idMapping.
|
|
206
|
+
const movedAnnotation = idMapping.nodeBaseFromId(delta.movedAnnotation);
|
|
208
207
|
return new AnnotationMovedAndReplacedFromOtherParentDelta(oldParent, oldIndex, replacedAnnotation, newParent, newIndex, movedAnnotation);
|
|
209
208
|
}
|
|
210
209
|
case "AnnotationMovedAndReplacedInSameParent": {
|
|
211
|
-
const parent = idMapping.
|
|
210
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
212
211
|
const oldIndex = delta.oldIndex;
|
|
213
212
|
const newIndex = delta.newIndex;
|
|
214
|
-
const replacedAnnotation = idMapping.
|
|
215
|
-
const movedAnnotation = idMapping.
|
|
213
|
+
const replacedAnnotation = idMapping.nodeBaseFromId(delta.replacedAnnotation);
|
|
214
|
+
const movedAnnotation = idMapping.nodeBaseFromId(delta.movedAnnotation);
|
|
216
215
|
return new AnnotationMovedAndReplacedInSameParentDelta(parent, oldIndex, newIndex, replacedAnnotation, movedAnnotation);
|
|
217
216
|
}
|
|
218
217
|
case "ReferenceAdded": {
|
|
219
|
-
const parent = idMapping.
|
|
218
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
220
219
|
const reference = resolvedReferenceFrom(delta.reference, parent.classifier);
|
|
221
220
|
const index = delta.index;
|
|
222
|
-
const
|
|
223
|
-
return new ReferenceAddedDelta(parent, reference, index,
|
|
221
|
+
const newReference = idMapping.fromRefId(delta.newReference);
|
|
222
|
+
return new ReferenceAddedDelta(parent, reference, index, newReference);
|
|
224
223
|
}
|
|
225
224
|
case "ReferenceDeleted": {
|
|
226
|
-
const parent = idMapping.
|
|
225
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
227
226
|
const reference = resolvedReferenceFrom(delta.reference, parent.classifier);
|
|
228
227
|
const index = delta.index;
|
|
229
|
-
const
|
|
230
|
-
return new ReferenceDeletedDelta(parent, reference, index,
|
|
228
|
+
const deletedReference = idMapping.fromRefId(delta.deletedReference);
|
|
229
|
+
return new ReferenceDeletedDelta(parent, reference, index, deletedReference);
|
|
231
230
|
}
|
|
232
231
|
case "ReferenceChanged": {
|
|
233
|
-
const parent = idMapping.
|
|
232
|
+
const parent = idMapping.nodeBaseFromId(delta.parent);
|
|
234
233
|
const reference = resolvedReferenceFrom(delta.reference, parent.classifier);
|
|
235
234
|
const index = delta.index;
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
return new ReferenceChangedDelta(parent, reference, index,
|
|
239
|
-
}
|
|
240
|
-
case "Composite": {
|
|
241
|
-
const parts = delta.parts.map(deserializedDelta);
|
|
242
|
-
return new CompositeDelta(parts);
|
|
235
|
+
const newReference = idMapping.fromRefId(delta.newReference);
|
|
236
|
+
const oldReference = idMapping.fromRefId(delta.oldReference);
|
|
237
|
+
return new ReferenceChangedDelta(parent, reference, index, newReference, oldReference);
|
|
243
238
|
}
|
|
244
239
|
case "NoOp": {
|
|
245
240
|
return new NoOpDelta();
|
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
ChildMovedFromOtherContainmentInSameParentDelta,
|
|
38
38
|
ChildMovedInSameContainmentDelta,
|
|
39
39
|
ChildReplacedDelta,
|
|
40
|
-
CompositeDelta,
|
|
41
40
|
NoOpDelta,
|
|
42
41
|
PartitionAddedDelta,
|
|
43
42
|
PartitionDeletedDelta,
|
|
@@ -65,7 +64,6 @@ import {
|
|
|
65
64
|
ChildMovedFromOtherContainmentSerializedDelta,
|
|
66
65
|
ChildMovedInSameContainmentSerializedDelta,
|
|
67
66
|
ChildReplacedSerializedDelta,
|
|
68
|
-
CompositeSerializedDelta,
|
|
69
67
|
NoOpSerializedDelta,
|
|
70
68
|
PartitionAddedSerializedDelta,
|
|
71
69
|
PartitionDeletedSerializedDelta,
|
|
@@ -323,7 +321,7 @@ export const serializeDelta = (delta: IDelta): SerializedDelta => {
|
|
|
323
321
|
parent: delta.parent.id,
|
|
324
322
|
reference: metaPointerFor(delta.reference),
|
|
325
323
|
index: delta.index,
|
|
326
|
-
|
|
324
|
+
newReference: idFrom(delta.newReference)
|
|
327
325
|
} as ReferenceAddedSerializedDelta;
|
|
328
326
|
}
|
|
329
327
|
|
|
@@ -333,7 +331,7 @@ export const serializeDelta = (delta: IDelta): SerializedDelta => {
|
|
|
333
331
|
parent: delta.parent.id,
|
|
334
332
|
reference: metaPointerFor(delta.reference),
|
|
335
333
|
index: delta.index,
|
|
336
|
-
|
|
334
|
+
deletedReference: idFrom(delta.deletedReference)
|
|
337
335
|
} as ReferenceDeletedSerializedDelta;
|
|
338
336
|
}
|
|
339
337
|
|
|
@@ -343,18 +341,11 @@ export const serializeDelta = (delta: IDelta): SerializedDelta => {
|
|
|
343
341
|
parent: delta.parent.id,
|
|
344
342
|
reference: metaPointerFor(delta.reference),
|
|
345
343
|
index: delta.index,
|
|
346
|
-
|
|
347
|
-
|
|
344
|
+
newReference: idFrom(delta.newReference),
|
|
345
|
+
oldReference: idFrom(delta.oldReference)
|
|
348
346
|
} as ReferenceChangedSerializedDelta;
|
|
349
347
|
}
|
|
350
348
|
|
|
351
|
-
if (delta instanceof CompositeDelta) {
|
|
352
|
-
return {
|
|
353
|
-
kind: "Composite",
|
|
354
|
-
parts: delta.parts.map(serializeDelta)
|
|
355
|
-
} as CompositeSerializedDelta;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
349
|
if (delta instanceof NoOpDelta) {
|
|
359
350
|
return {
|
|
360
351
|
kind: "NoOp"
|