@lionweb/class-core 0.6.13-beta.0
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/LICENSE +201 -0
- package/README.md +157 -0
- package/dist/base-types.d.ts +167 -0
- package/dist/base-types.d.ts.map +1 -0
- package/dist/base-types.js +147 -0
- package/dist/base-types.js.map +1 -0
- package/dist/convenience.d.ts +49 -0
- package/dist/convenience.d.ts.map +1 -0
- package/dist/convenience.js +75 -0
- package/dist/convenience.js.map +1 -0
- package/dist/deltas/appliers.d.ts +42 -0
- package/dist/deltas/appliers.d.ts.map +1 -0
- package/dist/deltas/appliers.js +274 -0
- package/dist/deltas/appliers.js.map +1 -0
- package/dist/deltas/base.d.ts +6 -0
- package/dist/deltas/base.d.ts.map +1 -0
- package/dist/deltas/base.js +18 -0
- package/dist/deltas/base.js.map +1 -0
- package/dist/deltas/handlers.d.ts +17 -0
- package/dist/deltas/handlers.d.ts.map +1 -0
- package/dist/deltas/handlers.js +43 -0
- package/dist/deltas/handlers.js.map +1 -0
- package/dist/deltas/index.d.ts +7 -0
- package/dist/deltas/index.d.ts.map +1 -0
- package/dist/deltas/index.js +23 -0
- package/dist/deltas/index.js.map +1 -0
- package/dist/deltas/inverters.d.ts +7 -0
- package/dist/deltas/inverters.d.ts.map +1 -0
- package/dist/deltas/inverters.js +82 -0
- package/dist/deltas/inverters.js.map +1 -0
- package/dist/deltas/serialization/base.d.ts +7 -0
- package/dist/deltas/serialization/base.d.ts.map +1 -0
- package/dist/deltas/serialization/base.js +18 -0
- package/dist/deltas/serialization/base.js.map +1 -0
- package/dist/deltas/serialization/deserializer.g.d.ts +5 -0
- package/dist/deltas/serialization/deserializer.g.d.ts.map +1 -0
- package/dist/deltas/serialization/deserializer.g.js +164 -0
- package/dist/deltas/serialization/deserializer.g.js.map +1 -0
- package/dist/deltas/serialization/index.d.ts +5 -0
- package/dist/deltas/serialization/index.d.ts.map +1 -0
- package/dist/deltas/serialization/index.js +21 -0
- package/dist/deltas/serialization/index.js.map +1 -0
- package/dist/deltas/serialization/serializer-helpers.d.ts +12 -0
- package/dist/deltas/serialization/serializer-helpers.d.ts.map +1 -0
- package/dist/deltas/serialization/serializer-helpers.js +28 -0
- package/dist/deltas/serialization/serializer-helpers.js.map +1 -0
- package/dist/deltas/serialization/serializer.g.d.ts +4 -0
- package/dist/deltas/serialization/serializer.g.d.ts.map +1 -0
- package/dist/deltas/serialization/serializer.g.js +208 -0
- package/dist/deltas/serialization/serializer.g.js.map +1 -0
- package/dist/deltas/serialization/types.g.d.ts +147 -0
- package/dist/deltas/serialization/types.g.d.ts.map +1 -0
- package/dist/deltas/serialization/types.g.js +18 -0
- package/dist/deltas/serialization/types.g.js.map +1 -0
- package/dist/deltas/types.g.d.ts +149 -0
- package/dist/deltas/types.g.d.ts.map +1 -0
- package/dist/deltas/types.g.js +180 -0
- package/dist/deltas/types.g.js.map +1 -0
- package/dist/deserializer.d.ts +27 -0
- package/dist/deserializer.d.ts.map +1 -0
- package/dist/deserializer.js +168 -0
- package/dist/deserializer.js.map +1 -0
- package/dist/duplicator.d.ts +19 -0
- package/dist/duplicator.d.ts.map +1 -0
- package/dist/duplicator.js +87 -0
- package/dist/duplicator.js.map +1 -0
- package/dist/id-mapping.d.ts +19 -0
- package/dist/id-mapping.d.ts.map +1 -0
- package/dist/id-mapping.js +44 -0
- package/dist/id-mapping.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/linking.d.ts +20 -0
- package/dist/linking.d.ts.map +1 -0
- package/dist/linking.js +18 -0
- package/dist/linking.js.map +1 -0
- package/dist/lionCore_builtins.g.d.ts +35 -0
- package/dist/lionCore_builtins.g.d.ts.map +1 -0
- package/dist/lionCore_builtins.g.js +96 -0
- package/dist/lionCore_builtins.g.js.map +1 -0
- package/dist/serializer.d.ts +17 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +70 -0
- package/dist/serializer.js.map +1 -0
- package/dist/textualizer.d.ts +7 -0
- package/dist/textualizer.d.ts.map +1 -0
- package/dist/textualizer.js +82 -0
- package/dist/textualizer.js.map +1 -0
- package/dist/value-managers/annotations.d.ts +33 -0
- package/dist/value-managers/annotations.d.ts.map +1 -0
- package/dist/value-managers/annotations.js +192 -0
- package/dist/value-managers/annotations.js.map +1 -0
- package/dist/value-managers/base.d.ts +53 -0
- package/dist/value-managers/base.d.ts.map +1 -0
- package/dist/value-managers/base.js +102 -0
- package/dist/value-managers/base.js.map +1 -0
- package/dist/value-managers/containments.d.ts +58 -0
- package/dist/value-managers/containments.d.ts.map +1 -0
- package/dist/value-managers/containments.js +408 -0
- package/dist/value-managers/containments.js.map +1 -0
- package/dist/value-managers/index.d.ts +6 -0
- package/dist/value-managers/index.d.ts.map +1 -0
- package/dist/value-managers/index.js +22 -0
- package/dist/value-managers/index.js.map +1 -0
- package/dist/value-managers/properties.d.ts +24 -0
- package/dist/value-managers/properties.d.ts.map +1 -0
- package/dist/value-managers/properties.js +191 -0
- package/dist/value-managers/properties.js.map +1 -0
- package/dist/value-managers/references.d.ts +58 -0
- package/dist/value-managers/references.d.ts.map +1 -0
- package/dist/value-managers/references.js +346 -0
- package/dist/value-managers/references.js.map +1 -0
- package/package.json +35 -0
- package/src/base-types.ts +353 -0
- package/src/convenience.ts +101 -0
- package/src/deltas/appliers.ts +317 -0
- package/src/deltas/base.ts +23 -0
- package/src/deltas/handlers.ts +64 -0
- package/src/deltas/index.ts +23 -0
- package/src/deltas/inverters.ts +111 -0
- package/src/deltas/serialization/base.ts +26 -0
- package/src/deltas/serialization/deserializer.g.ts +193 -0
- package/src/deltas/serialization/index.ts +22 -0
- package/src/deltas/serialization/serializer-helpers.ts +36 -0
- package/src/deltas/serialization/serializer.g.ts +272 -0
- package/src/deltas/serialization/types.g.ts +209 -0
- package/src/deltas/types.g.ts +231 -0
- package/src/deserializer.ts +234 -0
- package/src/duplicator.ts +111 -0
- package/src/id-mapping.ts +58 -0
- package/src/index.ts +29 -0
- package/src/linking.ts +39 -0
- package/src/lionCore_builtins.g.ts +141 -0
- package/src/serializer.ts +86 -0
- package/src/textualizer.ts +104 -0
- package/src/value-managers/annotations.ts +139 -0
- package/src/value-managers/base.ts +123 -0
- package/src/value-managers/containments.ts +323 -0
- package/src/value-managers/index.ts +22 -0
- package/src/value-managers/properties.ts +127 -0
- package/src/value-managers/references.ts +268 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
// Warning: this file is generated!
|
|
19
|
+
// Modifying it by hand is useless at best, and sabotage at worst.
|
|
20
|
+
|
|
21
|
+
import {Containment, MemoisingSymbolTable, Property, Reference} from "@lionweb/core";
|
|
22
|
+
|
|
23
|
+
import {ILanguageBase} from "../../base-types.js";
|
|
24
|
+
import {IdMapping} from "../../id-mapping.js";
|
|
25
|
+
import {SerializedDelta} from "./types.g.js";
|
|
26
|
+
import {DeltaDeserializer} from "./base.js";
|
|
27
|
+
import {
|
|
28
|
+
AnnotationAddedDelta,
|
|
29
|
+
AnnotationDeletedDelta,
|
|
30
|
+
AnnotationMovedFromOtherParentDelta,
|
|
31
|
+
AnnotationMovedInSameParentDelta,
|
|
32
|
+
AnnotationReplacedDelta,
|
|
33
|
+
ChildAddedDelta,
|
|
34
|
+
ChildDeletedDelta,
|
|
35
|
+
ChildMovedDelta,
|
|
36
|
+
ChildMovedInSameContainmentDelta,
|
|
37
|
+
ChildReplacedDelta,
|
|
38
|
+
NoOpDelta,
|
|
39
|
+
PropertyAddedDelta,
|
|
40
|
+
PropertyChangedDelta,
|
|
41
|
+
PropertyDeletedDelta,
|
|
42
|
+
ReferenceAddedDelta,
|
|
43
|
+
ReferenceDeletedDelta,
|
|
44
|
+
ReferenceMovedDelta,
|
|
45
|
+
ReferenceMovedInSameReferenceDelta,
|
|
46
|
+
ReferenceReplacedDelta
|
|
47
|
+
} from "../types.g.js";
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export const deltaDeserializer = (languageBases: ILanguageBase[], idMapping: IdMapping): DeltaDeserializer => {
|
|
51
|
+
const symbolTable = new MemoisingSymbolTable(languageBases.map(({language}) => language));
|
|
52
|
+
return (delta: SerializedDelta) => {
|
|
53
|
+
switch (delta.kind) {
|
|
54
|
+
case "NoOp": {
|
|
55
|
+
return new NoOpDelta();
|
|
56
|
+
}
|
|
57
|
+
case "PropertyAdded": {
|
|
58
|
+
const container = idMapping.fromId(delta.container);
|
|
59
|
+
const property = symbolTable.featureMatching(container.classifier.metaPointer(), delta.property) as Property;
|
|
60
|
+
const value = delta.value;
|
|
61
|
+
return new PropertyAddedDelta(container, property, value);
|
|
62
|
+
}
|
|
63
|
+
case "PropertyDeleted": {
|
|
64
|
+
const container = idMapping.fromId(delta.container);
|
|
65
|
+
const property = symbolTable.featureMatching(container.classifier.metaPointer(), delta.property) as Property;
|
|
66
|
+
const oldValue = delta.oldValue;
|
|
67
|
+
return new PropertyDeletedDelta(container, property, oldValue);
|
|
68
|
+
}
|
|
69
|
+
case "PropertyChanged": {
|
|
70
|
+
const container = idMapping.fromId(delta.container);
|
|
71
|
+
const property = symbolTable.featureMatching(container.classifier.metaPointer(), delta.property) as Property;
|
|
72
|
+
const oldValue = delta.oldValue;
|
|
73
|
+
const newValue = delta.newValue;
|
|
74
|
+
return new PropertyChangedDelta(container, property, oldValue, newValue);
|
|
75
|
+
}
|
|
76
|
+
case "ChildAdded": {
|
|
77
|
+
const parent = idMapping.fromId(delta.parent);
|
|
78
|
+
const containment = symbolTable.featureMatching(parent.classifier.metaPointer(), delta.containment) as Containment;
|
|
79
|
+
const index = delta.index;
|
|
80
|
+
const newChild = idMapping.fromId(delta.newChild);
|
|
81
|
+
return new ChildAddedDelta(parent, containment, index, newChild);
|
|
82
|
+
}
|
|
83
|
+
case "ChildDeleted": {
|
|
84
|
+
const parent = idMapping.fromId(delta.parent);
|
|
85
|
+
const containment = symbolTable.featureMatching(parent.classifier.metaPointer(), delta.containment) as Containment;
|
|
86
|
+
const index = delta.index;
|
|
87
|
+
const deletedChild = idMapping.fromId(delta.deletedChild);
|
|
88
|
+
return new ChildDeletedDelta(parent, containment, index, deletedChild);
|
|
89
|
+
}
|
|
90
|
+
case "ChildReplaced": {
|
|
91
|
+
const parent = idMapping.fromId(delta.parent);
|
|
92
|
+
const containment = symbolTable.featureMatching(parent.classifier.metaPointer(), delta.containment) as Containment;
|
|
93
|
+
const index = delta.index;
|
|
94
|
+
const replacedChild = idMapping.fromId(delta.replacedChild);
|
|
95
|
+
const newChild = idMapping.fromId(delta.newChild);
|
|
96
|
+
return new ChildReplacedDelta(parent, containment, index, replacedChild, newChild);
|
|
97
|
+
}
|
|
98
|
+
case "ChildMoved": {
|
|
99
|
+
const oldParent = idMapping.fromId(delta.oldParent);
|
|
100
|
+
const oldContainment = symbolTable.featureMatching(oldParent.classifier.metaPointer(), delta.oldContainment) as Containment;
|
|
101
|
+
const oldIndex = delta.oldIndex;
|
|
102
|
+
const newParent = idMapping.fromId(delta.newParent);
|
|
103
|
+
const newContainment = symbolTable.featureMatching(newParent.classifier.metaPointer(), delta.newContainment) as Containment;
|
|
104
|
+
const newIndex = delta.newIndex;
|
|
105
|
+
const child = idMapping.fromId(delta.child);
|
|
106
|
+
return new ChildMovedDelta(oldParent, oldContainment, oldIndex, newParent, newContainment, newIndex, child);
|
|
107
|
+
}
|
|
108
|
+
case "ChildMovedInSameContainment": {
|
|
109
|
+
const parent = idMapping.fromId(delta.parent);
|
|
110
|
+
const containment = symbolTable.featureMatching(parent.classifier.metaPointer(), delta.containment) as Containment;
|
|
111
|
+
const oldIndex = delta.oldIndex;
|
|
112
|
+
const newIndex = delta.newIndex;
|
|
113
|
+
const child = idMapping.fromId(delta.child);
|
|
114
|
+
return new ChildMovedInSameContainmentDelta(parent, containment, oldIndex, newIndex, child);
|
|
115
|
+
}
|
|
116
|
+
case "ReferenceAdded": {
|
|
117
|
+
const container = idMapping.fromId(delta.container);
|
|
118
|
+
const reference = symbolTable.featureMatching(container.classifier.metaPointer(), delta.reference) as Reference;
|
|
119
|
+
const index = delta.index;
|
|
120
|
+
const newTarget = idMapping.fromRefId(delta.newTarget);
|
|
121
|
+
return new ReferenceAddedDelta(container, reference, index, newTarget);
|
|
122
|
+
}
|
|
123
|
+
case "ReferenceDeleted": {
|
|
124
|
+
const container = idMapping.fromId(delta.container);
|
|
125
|
+
const reference = symbolTable.featureMatching(container.classifier.metaPointer(), delta.reference) as Reference;
|
|
126
|
+
const index = delta.index;
|
|
127
|
+
const deletedTarget = idMapping.fromRefId(delta.deletedTarget);
|
|
128
|
+
return new ReferenceDeletedDelta(container, reference, index, deletedTarget);
|
|
129
|
+
}
|
|
130
|
+
case "ReferenceReplaced": {
|
|
131
|
+
const container = idMapping.fromId(delta.container);
|
|
132
|
+
const reference = symbolTable.featureMatching(container.classifier.metaPointer(), delta.reference) as Reference;
|
|
133
|
+
const index = delta.index;
|
|
134
|
+
const replacedTarget = idMapping.fromRefId(delta.replacedTarget);
|
|
135
|
+
const newTarget = idMapping.fromRefId(delta.newTarget);
|
|
136
|
+
return new ReferenceReplacedDelta(container, reference, index, replacedTarget, newTarget);
|
|
137
|
+
}
|
|
138
|
+
case "ReferenceMoved": {
|
|
139
|
+
const oldContainer = idMapping.fromId(delta.oldContainer);
|
|
140
|
+
const oldReference = symbolTable.featureMatching(oldContainer.classifier.metaPointer(), delta.oldReference) as Reference;
|
|
141
|
+
const oldIndex = delta.oldIndex;
|
|
142
|
+
const newContainer = idMapping.fromId(delta.newContainer);
|
|
143
|
+
const newReference = symbolTable.featureMatching(newContainer.classifier.metaPointer(), delta.newReference) as Reference;
|
|
144
|
+
const newIndex = delta.newIndex;
|
|
145
|
+
const target = idMapping.fromRefId(delta.target);
|
|
146
|
+
return new ReferenceMovedDelta(oldContainer, oldReference, oldIndex, newContainer, newReference, newIndex, target);
|
|
147
|
+
}
|
|
148
|
+
case "ReferenceMovedInSameReference": {
|
|
149
|
+
const container = idMapping.fromId(delta.container);
|
|
150
|
+
const reference = symbolTable.featureMatching(container.classifier.metaPointer(), delta.reference) as Reference;
|
|
151
|
+
const oldIndex = delta.oldIndex;
|
|
152
|
+
const newIndex = delta.newIndex;
|
|
153
|
+
const target = idMapping.fromRefId(delta.target);
|
|
154
|
+
return new ReferenceMovedInSameReferenceDelta(container, reference, oldIndex, newIndex, target);
|
|
155
|
+
}
|
|
156
|
+
case "AnnotationAdded": {
|
|
157
|
+
const parent = idMapping.fromId(delta.parent);
|
|
158
|
+
const index = delta.index;
|
|
159
|
+
const newAnnotation = idMapping.fromId(delta.newAnnotation);
|
|
160
|
+
return new AnnotationAddedDelta(parent, index, newAnnotation);
|
|
161
|
+
}
|
|
162
|
+
case "AnnotationDeleted": {
|
|
163
|
+
const parent = idMapping.fromId(delta.parent);
|
|
164
|
+
const index = delta.index;
|
|
165
|
+
const deletedAnnotation = idMapping.fromId(delta.deletedAnnotation);
|
|
166
|
+
return new AnnotationDeletedDelta(parent, index, deletedAnnotation);
|
|
167
|
+
}
|
|
168
|
+
case "AnnotationReplaced": {
|
|
169
|
+
const parent = idMapping.fromId(delta.parent);
|
|
170
|
+
const index = delta.index;
|
|
171
|
+
const replacedAnnotation = idMapping.fromId(delta.replacedAnnotation);
|
|
172
|
+
const newAnnotation = idMapping.fromId(delta.newAnnotation);
|
|
173
|
+
return new AnnotationReplacedDelta(parent, index, replacedAnnotation, newAnnotation);
|
|
174
|
+
}
|
|
175
|
+
case "AnnotationMovedFromOtherParent": {
|
|
176
|
+
const oldParent = idMapping.fromId(delta.oldParent);
|
|
177
|
+
const oldIndex = delta.oldIndex;
|
|
178
|
+
const newParent = idMapping.fromId(delta.newParent);
|
|
179
|
+
const newIndex = delta.newIndex;
|
|
180
|
+
const movedAnnotation = idMapping.fromId(delta.movedAnnotation);
|
|
181
|
+
return new AnnotationMovedFromOtherParentDelta(oldParent, oldIndex, newParent, newIndex, movedAnnotation);
|
|
182
|
+
}
|
|
183
|
+
case "AnnotationMovedInSameParent": {
|
|
184
|
+
const parent = idMapping.fromId(delta.parent);
|
|
185
|
+
const oldIndex = delta.oldIndex;
|
|
186
|
+
const newIndex = delta.newIndex;
|
|
187
|
+
const movedAnnotation = idMapping.fromId(delta.movedAnnotation);
|
|
188
|
+
return new AnnotationMovedInSameParentDelta(parent, oldIndex, newIndex, movedAnnotation);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
export type {DeltaDeserializer} from "./base.js";
|
|
19
|
+
export * from "./deserializer.g.js";
|
|
20
|
+
export * from "./serializer.g.js";
|
|
21
|
+
// skip serializer-helpers.js: none of its members need to be visible outside this package
|
|
22
|
+
export * from "./types.g.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
import {DefaultPrimitiveTypeSerializer, IdOrUnresolved, Property, SingleRef, unresolved} from "@lionweb/core";
|
|
19
|
+
import {INodeBase} from "../../base-types.js";
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const defaultPrimitiveValueSerializer = new DefaultPrimitiveTypeSerializer(); // (suffices because serializeNodeBases also uses this class)
|
|
23
|
+
/**
|
|
24
|
+
* A function that serializes the given value of the given {@link Property property},
|
|
25
|
+
* using (an instance of) the same {@link DefaultPrimitiveTypeSerializer} class as the {@link serializeNodeBases} function.
|
|
26
|
+
*/
|
|
27
|
+
export const serializePropertyValue = <T>(value: T, property: Property): string =>
|
|
28
|
+
defaultPrimitiveValueSerializer.serializeValue(value, property)!
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @return the ID of a given reference to a {@link INodeBase}, or {@link unresolved} if that reference was previously unresolved.
|
|
33
|
+
*/
|
|
34
|
+
export const idFrom = (ref: SingleRef<INodeBase>): IdOrUnresolved =>
|
|
35
|
+
ref === unresolved ? null : ref.id
|
|
36
|
+
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
// Warning: this file is generated!
|
|
19
|
+
// Modifying it by hand is useless at best, and sabotage at worst.
|
|
20
|
+
|
|
21
|
+
import {metaPointerFor} from "@lionweb/core";
|
|
22
|
+
import {IDelta} from "../base.js";
|
|
23
|
+
import {
|
|
24
|
+
AnnotationAddedDelta,
|
|
25
|
+
AnnotationDeletedDelta,
|
|
26
|
+
AnnotationMovedFromOtherParentDelta,
|
|
27
|
+
AnnotationMovedInSameParentDelta,
|
|
28
|
+
AnnotationReplacedDelta,
|
|
29
|
+
ChildAddedDelta,
|
|
30
|
+
ChildDeletedDelta,
|
|
31
|
+
ChildMovedDelta,
|
|
32
|
+
ChildMovedInSameContainmentDelta,
|
|
33
|
+
ChildReplacedDelta,
|
|
34
|
+
NoOpDelta,
|
|
35
|
+
PropertyAddedDelta,
|
|
36
|
+
PropertyChangedDelta,
|
|
37
|
+
PropertyDeletedDelta,
|
|
38
|
+
ReferenceAddedDelta,
|
|
39
|
+
ReferenceDeletedDelta,
|
|
40
|
+
ReferenceMovedDelta,
|
|
41
|
+
ReferenceMovedInSameReferenceDelta,
|
|
42
|
+
ReferenceReplacedDelta
|
|
43
|
+
} from "../types.g.js";
|
|
44
|
+
import {
|
|
45
|
+
AnnotationAddedSerializedDelta,
|
|
46
|
+
AnnotationDeletedSerializedDelta,
|
|
47
|
+
AnnotationMovedFromOtherParentSerializedDelta,
|
|
48
|
+
AnnotationMovedInSameParentSerializedDelta,
|
|
49
|
+
AnnotationReplacedSerializedDelta,
|
|
50
|
+
ChildAddedSerializedDelta,
|
|
51
|
+
ChildDeletedSerializedDelta,
|
|
52
|
+
ChildMovedInSameContainmentSerializedDelta,
|
|
53
|
+
ChildMovedSerializedDelta,
|
|
54
|
+
ChildReplacedSerializedDelta,
|
|
55
|
+
NoOpSerializedDelta,
|
|
56
|
+
PropertyAddedSerializedDelta,
|
|
57
|
+
PropertyChangedSerializedDelta,
|
|
58
|
+
PropertyDeletedSerializedDelta,
|
|
59
|
+
ReferenceAddedSerializedDelta,
|
|
60
|
+
ReferenceDeletedSerializedDelta,
|
|
61
|
+
ReferenceMovedInSameReferenceSerializedDelta,
|
|
62
|
+
ReferenceMovedSerializedDelta,
|
|
63
|
+
ReferenceReplacedSerializedDelta
|
|
64
|
+
} from "./types.g.js";
|
|
65
|
+
import {idFrom, serializePropertyValue} from "./serializer-helpers.js";
|
|
66
|
+
import {serializeNodeBases} from "../../serializer.js";
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export const serializeDelta = (delta: IDelta) => {
|
|
70
|
+
if (delta instanceof NoOpDelta) {
|
|
71
|
+
return {
|
|
72
|
+
kind: "NoOp"
|
|
73
|
+
} as NoOpSerializedDelta;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (delta instanceof PropertyAddedDelta) {
|
|
77
|
+
return {
|
|
78
|
+
kind: "PropertyAdded",
|
|
79
|
+
container: delta.container.id,
|
|
80
|
+
property: metaPointerFor(delta.property),
|
|
81
|
+
value: serializePropertyValue(delta.value, delta.property)
|
|
82
|
+
} as PropertyAddedSerializedDelta;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (delta instanceof PropertyDeletedDelta) {
|
|
86
|
+
return {
|
|
87
|
+
kind: "PropertyDeleted",
|
|
88
|
+
container: delta.container.id,
|
|
89
|
+
property: metaPointerFor(delta.property),
|
|
90
|
+
oldValue: serializePropertyValue(delta.oldValue, delta.property)
|
|
91
|
+
} as PropertyDeletedSerializedDelta;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (delta instanceof PropertyChangedDelta) {
|
|
95
|
+
return {
|
|
96
|
+
kind: "PropertyChanged",
|
|
97
|
+
container: delta.container.id,
|
|
98
|
+
property: metaPointerFor(delta.property),
|
|
99
|
+
oldValue: serializePropertyValue(delta.oldValue, delta.property),
|
|
100
|
+
newValue: serializePropertyValue(delta.newValue, delta.property)
|
|
101
|
+
} as PropertyChangedSerializedDelta;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (delta instanceof ChildAddedDelta) {
|
|
105
|
+
return {
|
|
106
|
+
kind: "ChildAdded",
|
|
107
|
+
parent: delta.parent.id,
|
|
108
|
+
containment: metaPointerFor(delta.containment),
|
|
109
|
+
index: delta.index,
|
|
110
|
+
newChild: delta.newChild.id,
|
|
111
|
+
newNodes: serializeNodeBases([delta.newChild])
|
|
112
|
+
} as ChildAddedSerializedDelta;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (delta instanceof ChildDeletedDelta) {
|
|
116
|
+
return {
|
|
117
|
+
kind: "ChildDeleted",
|
|
118
|
+
parent: delta.parent.id,
|
|
119
|
+
containment: metaPointerFor(delta.containment),
|
|
120
|
+
index: delta.index,
|
|
121
|
+
deletedChild: delta.deletedChild.id,
|
|
122
|
+
deletedNodes: serializeNodeBases([delta.deletedChild])
|
|
123
|
+
} as ChildDeletedSerializedDelta;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (delta instanceof ChildReplacedDelta) {
|
|
127
|
+
return {
|
|
128
|
+
kind: "ChildReplaced",
|
|
129
|
+
parent: delta.parent.id,
|
|
130
|
+
containment: metaPointerFor(delta.containment),
|
|
131
|
+
index: delta.index,
|
|
132
|
+
replacedChild: delta.replacedChild.id,
|
|
133
|
+
replacedNodes: serializeNodeBases([delta.replacedChild]),
|
|
134
|
+
newChild: delta.newChild.id,
|
|
135
|
+
newNodes: serializeNodeBases([delta.newChild])
|
|
136
|
+
} as ChildReplacedSerializedDelta;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (delta instanceof ChildMovedDelta) {
|
|
140
|
+
return {
|
|
141
|
+
kind: "ChildMoved",
|
|
142
|
+
oldParent: delta.oldParent.id,
|
|
143
|
+
oldContainment: metaPointerFor(delta.oldContainment),
|
|
144
|
+
oldIndex: delta.oldIndex,
|
|
145
|
+
newParent: delta.newParent.id,
|
|
146
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
147
|
+
newIndex: delta.newIndex,
|
|
148
|
+
child: delta.child.id
|
|
149
|
+
} as ChildMovedSerializedDelta;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (delta instanceof ChildMovedInSameContainmentDelta) {
|
|
153
|
+
return {
|
|
154
|
+
kind: "ChildMovedInSameContainment",
|
|
155
|
+
parent: delta.parent.id,
|
|
156
|
+
containment: metaPointerFor(delta.containment),
|
|
157
|
+
oldIndex: delta.oldIndex,
|
|
158
|
+
newIndex: delta.newIndex,
|
|
159
|
+
child: delta.child.id
|
|
160
|
+
} as ChildMovedInSameContainmentSerializedDelta;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (delta instanceof ReferenceAddedDelta) {
|
|
164
|
+
return {
|
|
165
|
+
kind: "ReferenceAdded",
|
|
166
|
+
container: delta.container.id,
|
|
167
|
+
reference: metaPointerFor(delta.reference),
|
|
168
|
+
index: delta.index,
|
|
169
|
+
newTarget: idFrom(delta.newTarget)
|
|
170
|
+
} as ReferenceAddedSerializedDelta;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (delta instanceof ReferenceDeletedDelta) {
|
|
174
|
+
return {
|
|
175
|
+
kind: "ReferenceDeleted",
|
|
176
|
+
container: delta.container.id,
|
|
177
|
+
reference: metaPointerFor(delta.reference),
|
|
178
|
+
index: delta.index,
|
|
179
|
+
deletedTarget: idFrom(delta.deletedTarget)
|
|
180
|
+
} as ReferenceDeletedSerializedDelta;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (delta instanceof ReferenceReplacedDelta) {
|
|
184
|
+
return {
|
|
185
|
+
kind: "ReferenceReplaced",
|
|
186
|
+
container: delta.container.id,
|
|
187
|
+
reference: metaPointerFor(delta.reference),
|
|
188
|
+
index: delta.index,
|
|
189
|
+
replacedTarget: idFrom(delta.replacedTarget),
|
|
190
|
+
newTarget: idFrom(delta.newTarget)
|
|
191
|
+
} as ReferenceReplacedSerializedDelta;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (delta instanceof ReferenceMovedDelta) {
|
|
195
|
+
return {
|
|
196
|
+
kind: "ReferenceMoved",
|
|
197
|
+
oldContainer: delta.oldContainer.id,
|
|
198
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
199
|
+
oldIndex: delta.oldIndex,
|
|
200
|
+
newContainer: delta.newContainer.id,
|
|
201
|
+
newReference: metaPointerFor(delta.newReference),
|
|
202
|
+
newIndex: delta.newIndex,
|
|
203
|
+
target: idFrom(delta.target)
|
|
204
|
+
} as ReferenceMovedSerializedDelta;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (delta instanceof ReferenceMovedInSameReferenceDelta) {
|
|
208
|
+
return {
|
|
209
|
+
kind: "ReferenceMovedInSameReference",
|
|
210
|
+
container: delta.container.id,
|
|
211
|
+
reference: metaPointerFor(delta.reference),
|
|
212
|
+
oldIndex: delta.oldIndex,
|
|
213
|
+
newIndex: delta.newIndex,
|
|
214
|
+
target: idFrom(delta.target)
|
|
215
|
+
} as ReferenceMovedInSameReferenceSerializedDelta;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (delta instanceof AnnotationAddedDelta) {
|
|
219
|
+
return {
|
|
220
|
+
kind: "AnnotationAdded",
|
|
221
|
+
parent: delta.parent.id,
|
|
222
|
+
index: delta.index,
|
|
223
|
+
newAnnotation: delta.newAnnotation.id,
|
|
224
|
+
newAnnotationNodes: serializeNodeBases([delta.newAnnotation])
|
|
225
|
+
} as AnnotationAddedSerializedDelta;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (delta instanceof AnnotationDeletedDelta) {
|
|
229
|
+
return {
|
|
230
|
+
kind: "AnnotationDeleted",
|
|
231
|
+
parent: delta.parent.id,
|
|
232
|
+
index: delta.index,
|
|
233
|
+
deletedAnnotation: delta.deletedAnnotation.id,
|
|
234
|
+
deletedAnnotationNodes: serializeNodeBases([delta.deletedAnnotation])
|
|
235
|
+
} as AnnotationDeletedSerializedDelta;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (delta instanceof AnnotationReplacedDelta) {
|
|
239
|
+
return {
|
|
240
|
+
kind: "AnnotationReplaced",
|
|
241
|
+
parent: delta.parent.id,
|
|
242
|
+
index: delta.index,
|
|
243
|
+
replacedAnnotation: delta.replacedAnnotation.id,
|
|
244
|
+
replacedAnnotationNodes: serializeNodeBases([delta.replacedAnnotation]),
|
|
245
|
+
newAnnotation: delta.newAnnotation.id,
|
|
246
|
+
newAnnotationNodes: serializeNodeBases([delta.newAnnotation])
|
|
247
|
+
} as AnnotationReplacedSerializedDelta;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (delta instanceof AnnotationMovedFromOtherParentDelta) {
|
|
251
|
+
return {
|
|
252
|
+
kind: "AnnotationMovedFromOtherParent",
|
|
253
|
+
oldParent: delta.oldParent.id,
|
|
254
|
+
oldIndex: delta.oldIndex,
|
|
255
|
+
newParent: delta.newParent.id,
|
|
256
|
+
newIndex: delta.newIndex,
|
|
257
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
258
|
+
} as AnnotationMovedFromOtherParentSerializedDelta;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (delta instanceof AnnotationMovedInSameParentDelta) {
|
|
262
|
+
return {
|
|
263
|
+
kind: "AnnotationMovedInSameParent",
|
|
264
|
+
parent: delta.parent.id,
|
|
265
|
+
oldIndex: delta.oldIndex,
|
|
266
|
+
newIndex: delta.newIndex,
|
|
267
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
268
|
+
} as AnnotationMovedInSameParentSerializedDelta;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
throw new Error(`serialization of delta of class ${delta.constructor.name} not implemented`);
|
|
272
|
+
}
|