@lionweb/class-core 0.6.13-beta.2 → 0.6.13-beta.5
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/README.md +1 -1
- package/dist/base-types.d.ts +5 -4
- package/dist/base-types.d.ts.map +1 -1
- package/dist/base-types.js.map +1 -1
- package/dist/convenience.d.ts +4 -3
- package/dist/convenience.d.ts.map +1 -1
- package/dist/convenience.js.map +1 -1
- package/dist/deltas/appliers.d.ts.map +1 -1
- package/dist/deltas/appliers.js +1 -1
- package/dist/deltas/appliers.js.map +1 -1
- package/dist/deltas/handlers.d.ts.map +1 -1
- package/dist/deltas/handlers.js.map +1 -1
- package/dist/deltas/inverters.d.ts.map +1 -1
- package/dist/deltas/inverters.js.map +1 -1
- package/dist/deltas/serialization/base.d.ts +1 -1
- package/dist/deltas/serialization/base.d.ts.map +1 -1
- package/dist/deltas/serialization/serializer-helpers.d.ts.map +1 -1
- package/dist/deltas/serialization/serializer-helpers.js.map +1 -1
- package/dist/deltas/serialization/types.g.d.ts +58 -57
- package/dist/deltas/serialization/types.g.d.ts.map +1 -1
- package/dist/deserializer.d.ts +5 -4
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +4 -3
- package/dist/deserializer.js.map +1 -1
- package/dist/duplicator.d.ts.map +1 -1
- package/dist/duplicator.js +3 -2
- package/dist/duplicator.js.map +1 -1
- package/dist/id-mapping.d.ts +4 -3
- package/dist/id-mapping.d.ts.map +1 -1
- package/dist/id-mapping.js.map +1 -1
- package/dist/linking.d.ts +3 -2
- package/dist/linking.d.ts.map +1 -1
- package/dist/lionCore_builtins.g.d.ts.map +1 -1
- package/dist/lionCore_builtins.g.js.map +1 -1
- package/dist/serializer.d.ts +2 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +1 -1
- package/dist/serializer.js.map +1 -1
- package/dist/textualizer.d.ts.map +1 -1
- package/dist/textualizer.js +1 -1
- package/dist/textualizer.js.map +1 -1
- package/dist/value-managers/annotations.d.ts.map +1 -1
- package/dist/value-managers/annotations.js +1 -1
- package/dist/value-managers/annotations.js.map +1 -1
- package/dist/value-managers/base.d.ts.map +1 -1
- package/dist/value-managers/base.js.map +1 -1
- package/dist/value-managers/containments.d.ts.map +1 -1
- package/dist/value-managers/containments.js +1 -1
- package/dist/value-managers/containments.js.map +1 -1
- package/dist/value-managers/properties.d.ts +1 -1
- package/dist/value-managers/properties.d.ts.map +1 -1
- package/dist/value-managers/properties.js +1 -1
- package/dist/value-managers/properties.js.map +1 -1
- package/dist/value-managers/references.d.ts.map +1 -1
- package/dist/value-managers/references.js +1 -1
- package/dist/value-managers/references.js.map +1 -1
- package/package.json +4 -2
- package/src/base-types.ts +6 -6
- package/src/convenience.ts +6 -9
- package/src/deltas/appliers.ts +11 -11
- package/src/deltas/handlers.ts +2 -2
- package/src/deltas/inverters.ts +2 -2
- package/src/deltas/serialization/base.ts +2 -2
- package/src/deltas/serialization/serializer-helpers.ts +3 -4
- package/src/deltas/serialization/types.g.ts +58 -57
- package/src/deserializer.ts +12 -14
- package/src/duplicator.ts +8 -6
- package/src/id-mapping.ts +5 -5
- package/src/linking.ts +4 -3
- package/src/lionCore_builtins.g.ts +5 -2
- package/src/serializer.ts +3 -3
- package/src/textualizer.ts +4 -5
- package/src/value-managers/annotations.ts +4 -4
- package/src/value-managers/base.ts +3 -3
- package/src/value-managers/containments.ts +6 -12
- package/src/value-managers/properties.ts +5 -5
- package/src/value-managers/references.ts +6 -11
package/src/deltas/inverters.ts
CHANGED
|
@@ -15,6 +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 { IDelta } from "./base.js"
|
|
18
19
|
import {
|
|
19
20
|
AnnotationAddedDelta,
|
|
20
21
|
AnnotationDeletedDelta,
|
|
@@ -35,8 +36,7 @@ import {
|
|
|
35
36
|
ReferenceMovedDelta,
|
|
36
37
|
ReferenceMovedInSameReferenceDelta,
|
|
37
38
|
ReferenceReplacedDelta
|
|
38
|
-
} from "./types.g.js"
|
|
39
|
-
import {IDelta} from "./base.js";
|
|
39
|
+
} from "./types.g.js"
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { IDelta } from "../base.js"
|
|
19
|
+
import { SerializedDelta } from "./types.g.js"
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {DefaultPrimitiveTypeSerializer, IdOrUnresolved, Property, SingleRef, unresolved} from "@lionweb/core"
|
|
19
|
-
import {INodeBase} from "../../base-types.js"
|
|
18
|
+
import { DefaultPrimitiveTypeSerializer, IdOrUnresolved, Property, SingleRef, unresolved } from "@lionweb/core"
|
|
19
|
+
import { INodeBase } from "../../base-types.js"
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const defaultPrimitiveValueSerializer = new DefaultPrimitiveTypeSerializer(); // (suffices because serializeNodeBases also uses this class)
|
|
21
|
+
const defaultPrimitiveValueSerializer = new DefaultPrimitiveTypeSerializer() // (suffices because serializeNodeBases also uses this class)
|
|
23
22
|
/**
|
|
24
23
|
* A function that serializes the given value of the given {@link Property property},
|
|
25
24
|
* using (an instance of) the same {@link DefaultPrimitiveTypeSerializer} class as the {@link serializeNodeBases} function.
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
// Warning: this file is generated!
|
|
19
19
|
// Modifying it by hand is useless at best, and sabotage at worst.
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import {IdOrUnresolved} from "@lionweb/core";
|
|
22
|
+
import {LionWebId, LionWebJsonMetaPointer, LionWebJsonChunk} from "@lionweb/json";
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
export type SerializedDelta =
|
|
@@ -50,95 +51,95 @@ export type NoOpSerializedDelta = {
|
|
|
50
51
|
|
|
51
52
|
export type PropertyAddedSerializedDelta = {
|
|
52
53
|
kind: "PropertyAdded"
|
|
53
|
-
container:
|
|
54
|
-
property:
|
|
54
|
+
container: LionWebId
|
|
55
|
+
property: LionWebJsonMetaPointer
|
|
55
56
|
value: string
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export type PropertyDeletedSerializedDelta = {
|
|
59
60
|
kind: "PropertyDeleted"
|
|
60
|
-
container:
|
|
61
|
-
property:
|
|
61
|
+
container: LionWebId
|
|
62
|
+
property: LionWebJsonMetaPointer
|
|
62
63
|
oldValue: string
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
export type PropertyChangedSerializedDelta = {
|
|
66
67
|
kind: "PropertyChanged"
|
|
67
|
-
container:
|
|
68
|
-
property:
|
|
68
|
+
container: LionWebId
|
|
69
|
+
property: LionWebJsonMetaPointer
|
|
69
70
|
oldValue: string
|
|
70
71
|
newValue: string
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export type ChildAddedSerializedDelta = {
|
|
74
75
|
kind: "ChildAdded"
|
|
75
|
-
parent:
|
|
76
|
-
containment:
|
|
76
|
+
parent: LionWebId
|
|
77
|
+
containment: LionWebJsonMetaPointer
|
|
77
78
|
index: number
|
|
78
|
-
newChild:
|
|
79
|
-
newNodes:
|
|
79
|
+
newChild: LionWebId
|
|
80
|
+
newNodes: LionWebJsonChunk
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export type ChildDeletedSerializedDelta = {
|
|
83
84
|
kind: "ChildDeleted"
|
|
84
|
-
parent:
|
|
85
|
-
containment:
|
|
85
|
+
parent: LionWebId
|
|
86
|
+
containment: LionWebJsonMetaPointer
|
|
86
87
|
index: number
|
|
87
|
-
deletedChild:
|
|
88
|
-
deletedNodes:
|
|
88
|
+
deletedChild: LionWebId
|
|
89
|
+
deletedNodes: LionWebJsonChunk
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
export type ChildReplacedSerializedDelta = {
|
|
92
93
|
kind: "ChildReplaced"
|
|
93
|
-
parent:
|
|
94
|
-
containment:
|
|
94
|
+
parent: LionWebId
|
|
95
|
+
containment: LionWebJsonMetaPointer
|
|
95
96
|
index: number
|
|
96
|
-
replacedChild:
|
|
97
|
-
replacedNodes:
|
|
98
|
-
newChild:
|
|
99
|
-
newNodes:
|
|
97
|
+
replacedChild: LionWebId
|
|
98
|
+
replacedNodes: LionWebJsonChunk
|
|
99
|
+
newChild: LionWebId
|
|
100
|
+
newNodes: LionWebJsonChunk
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
export type ChildMovedSerializedDelta = {
|
|
103
104
|
kind: "ChildMoved"
|
|
104
|
-
oldParent:
|
|
105
|
-
oldContainment:
|
|
105
|
+
oldParent: LionWebId
|
|
106
|
+
oldContainment: LionWebJsonMetaPointer
|
|
106
107
|
oldIndex: number
|
|
107
|
-
newParent:
|
|
108
|
-
newContainment:
|
|
108
|
+
newParent: LionWebId
|
|
109
|
+
newContainment: LionWebJsonMetaPointer
|
|
109
110
|
newIndex: number
|
|
110
|
-
child:
|
|
111
|
+
child: LionWebId
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
export type ChildMovedInSameContainmentSerializedDelta = {
|
|
114
115
|
kind: "ChildMovedInSameContainment"
|
|
115
|
-
parent:
|
|
116
|
-
containment:
|
|
116
|
+
parent: LionWebId
|
|
117
|
+
containment: LionWebJsonMetaPointer
|
|
117
118
|
oldIndex: number
|
|
118
119
|
newIndex: number
|
|
119
|
-
child:
|
|
120
|
+
child: LionWebId
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
export type ReferenceAddedSerializedDelta = {
|
|
123
124
|
kind: "ReferenceAdded"
|
|
124
|
-
container:
|
|
125
|
-
reference:
|
|
125
|
+
container: LionWebId
|
|
126
|
+
reference: LionWebJsonMetaPointer
|
|
126
127
|
index: number
|
|
127
128
|
newTarget: IdOrUnresolved
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
export type ReferenceDeletedSerializedDelta = {
|
|
131
132
|
kind: "ReferenceDeleted"
|
|
132
|
-
container:
|
|
133
|
-
reference:
|
|
133
|
+
container: LionWebId
|
|
134
|
+
reference: LionWebJsonMetaPointer
|
|
134
135
|
index: number
|
|
135
136
|
deletedTarget: IdOrUnresolved
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
export type ReferenceReplacedSerializedDelta = {
|
|
139
140
|
kind: "ReferenceReplaced"
|
|
140
|
-
container:
|
|
141
|
-
reference:
|
|
141
|
+
container: LionWebId
|
|
142
|
+
reference: LionWebJsonMetaPointer
|
|
142
143
|
index: number
|
|
143
144
|
replacedTarget: IdOrUnresolved
|
|
144
145
|
newTarget: IdOrUnresolved
|
|
@@ -146,19 +147,19 @@ export type ReferenceReplacedSerializedDelta = {
|
|
|
146
147
|
|
|
147
148
|
export type ReferenceMovedSerializedDelta = {
|
|
148
149
|
kind: "ReferenceMoved"
|
|
149
|
-
oldContainer:
|
|
150
|
-
oldReference:
|
|
150
|
+
oldContainer: LionWebId
|
|
151
|
+
oldReference: LionWebJsonMetaPointer
|
|
151
152
|
oldIndex: number
|
|
152
|
-
newContainer:
|
|
153
|
-
newReference:
|
|
153
|
+
newContainer: LionWebId
|
|
154
|
+
newReference: LionWebJsonMetaPointer
|
|
154
155
|
newIndex: number
|
|
155
156
|
target: IdOrUnresolved
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
export type ReferenceMovedInSameReferenceSerializedDelta = {
|
|
159
160
|
kind: "ReferenceMovedInSameReference"
|
|
160
|
-
container:
|
|
161
|
-
reference:
|
|
161
|
+
container: LionWebId
|
|
162
|
+
reference: LionWebJsonMetaPointer
|
|
162
163
|
oldIndex: number
|
|
163
164
|
newIndex: number
|
|
164
165
|
target: IdOrUnresolved
|
|
@@ -166,44 +167,44 @@ export type ReferenceMovedInSameReferenceSerializedDelta = {
|
|
|
166
167
|
|
|
167
168
|
export type AnnotationAddedSerializedDelta = {
|
|
168
169
|
kind: "AnnotationAdded"
|
|
169
|
-
parent:
|
|
170
|
+
parent: LionWebId
|
|
170
171
|
index: number
|
|
171
|
-
newAnnotation:
|
|
172
|
-
newAnnotationNodes:
|
|
172
|
+
newAnnotation: LionWebId
|
|
173
|
+
newAnnotationNodes: LionWebJsonChunk
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
export type AnnotationDeletedSerializedDelta = {
|
|
176
177
|
kind: "AnnotationDeleted"
|
|
177
|
-
parent:
|
|
178
|
+
parent: LionWebId
|
|
178
179
|
index: number
|
|
179
|
-
deletedAnnotation:
|
|
180
|
-
deletedAnnotationNodes:
|
|
180
|
+
deletedAnnotation: LionWebId
|
|
181
|
+
deletedAnnotationNodes: LionWebJsonChunk
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
export type AnnotationReplacedSerializedDelta = {
|
|
184
185
|
kind: "AnnotationReplaced"
|
|
185
|
-
parent:
|
|
186
|
+
parent: LionWebId
|
|
186
187
|
index: number
|
|
187
|
-
replacedAnnotation:
|
|
188
|
-
replacedAnnotationNodes:
|
|
189
|
-
newAnnotation:
|
|
190
|
-
newAnnotationNodes:
|
|
188
|
+
replacedAnnotation: LionWebId
|
|
189
|
+
replacedAnnotationNodes: LionWebJsonChunk
|
|
190
|
+
newAnnotation: LionWebId
|
|
191
|
+
newAnnotationNodes: LionWebJsonChunk
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
export type AnnotationMovedFromOtherParentSerializedDelta = {
|
|
194
195
|
kind: "AnnotationMovedFromOtherParent"
|
|
195
|
-
oldParent:
|
|
196
|
+
oldParent: LionWebId
|
|
196
197
|
oldIndex: number
|
|
197
|
-
newParent:
|
|
198
|
+
newParent: LionWebId
|
|
198
199
|
newIndex: number
|
|
199
|
-
movedAnnotation:
|
|
200
|
+
movedAnnotation: LionWebId
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
export type AnnotationMovedInSameParentSerializedDelta = {
|
|
203
204
|
kind: "AnnotationMovedInSameParent"
|
|
204
|
-
parent:
|
|
205
|
+
parent: LionWebId
|
|
205
206
|
oldIndex: number
|
|
206
207
|
newIndex: number
|
|
207
|
-
movedAnnotation:
|
|
208
|
+
movedAnnotation: LionWebId
|
|
208
209
|
}
|
|
209
210
|
|
package/src/deserializer.ts
CHANGED
|
@@ -16,34 +16,32 @@
|
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
byIdMap,
|
|
20
19
|
Classifier,
|
|
21
20
|
Containment,
|
|
22
21
|
DefaultPrimitiveTypeDeserializer,
|
|
23
22
|
defaultSimplisticHandler,
|
|
24
23
|
Enumeration,
|
|
25
|
-
Id,
|
|
26
24
|
Language,
|
|
27
25
|
MemoisingSymbolTable,
|
|
28
26
|
PrimitiveType,
|
|
29
27
|
PrimitiveTypeDeserializer,
|
|
30
28
|
Property,
|
|
31
29
|
Reference,
|
|
32
|
-
SerializationChunk,
|
|
33
|
-
SerializedNode,
|
|
34
30
|
SimplisticHandler,
|
|
35
31
|
unresolved
|
|
36
|
-
} from "@lionweb/core"
|
|
32
|
+
} from "@lionweb/core"
|
|
33
|
+
import { LionWebId, LionWebJsonChunk, LionWebJsonNode } from "@lionweb/json"
|
|
34
|
+
import { byIdMap } from "@lionweb/ts-utils"
|
|
37
35
|
|
|
38
|
-
import {DeltaHandler, IdMapping, ILanguageBase, INodeBase} from "./index.js"
|
|
39
|
-
import {NodesToInstall} from "./linking.js"
|
|
36
|
+
import { DeltaHandler, IdMapping, ILanguageBase, INodeBase } from "./index.js"
|
|
37
|
+
import { NodesToInstall } from "./linking.js"
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
/**
|
|
43
41
|
* A type for deserializer functions that are parametrized in their return type.
|
|
44
42
|
*/
|
|
45
43
|
export type Deserializer<T> = (
|
|
46
|
-
serializationChunk:
|
|
44
|
+
serializationChunk: LionWebJsonChunk,
|
|
47
45
|
dependentNodes?: INodeBase[],
|
|
48
46
|
primitiveTypeDeserializer?: PrimitiveTypeDeserializer,
|
|
49
47
|
problemHandler?: SimplisticHandler
|
|
@@ -74,7 +72,7 @@ export type RootsWithIdMapping = { roots: INodeBase[], idMapping: IdMapping };
|
|
|
74
72
|
|
|
75
73
|
/**
|
|
76
74
|
* @return a {@link Deserializer} function for the given languages (given as {@link ILanguageBase}s) that returns a {@link RootsWithIdMapping}.
|
|
77
|
-
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link
|
|
75
|
+
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link LionWebJsonChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
78
76
|
* @param handleDelta an optional {@link DeltaHandler} that will be injected in all {@link INodeBase nodes} created.
|
|
79
77
|
*/
|
|
80
78
|
export const nodeBaseDeserializerWithIdMapping = (languageBases: ILanguageBase[], handleDelta?: DeltaHandler): Deserializer<RootsWithIdMapping> => {
|
|
@@ -84,7 +82,7 @@ export const nodeBaseDeserializerWithIdMapping = (languageBases: ILanguageBase[]
|
|
|
84
82
|
const factoryFor = factoryLookupFor(languageBases, handleDelta);
|
|
85
83
|
|
|
86
84
|
return (
|
|
87
|
-
serializationChunk:
|
|
85
|
+
serializationChunk: LionWebJsonChunk,
|
|
88
86
|
dependentNodes: INodeBase[] = [],
|
|
89
87
|
primitiveTypeDeserializer: PrimitiveTypeDeserializer = new DefaultPrimitiveTypeDeserializer(),
|
|
90
88
|
problemsHandler: SimplisticHandler = defaultSimplisticHandler
|
|
@@ -92,7 +90,7 @@ export const nodeBaseDeserializerWithIdMapping = (languageBases: ILanguageBase[]
|
|
|
92
90
|
|
|
93
91
|
const nodesToInstall: NodesToInstall[] = [];
|
|
94
92
|
|
|
95
|
-
const createNode = ({id, classifier: classifierMetaPointer, properties, containments, references, annotations}:
|
|
93
|
+
const createNode = ({id, classifier: classifierMetaPointer, properties, containments, references, annotations}: LionWebJsonNode) => {
|
|
96
94
|
const languageMessage = `language ${classifierMetaPointer.language} (${classifierMetaPointer.version})`;
|
|
97
95
|
const classifier = symbolTable.entityMatching(classifierMetaPointer);
|
|
98
96
|
if (classifier === undefined || !(classifier instanceof Classifier)) {
|
|
@@ -161,7 +159,7 @@ export const nodeBaseDeserializerWithIdMapping = (languageBases: ILanguageBase[]
|
|
|
161
159
|
|
|
162
160
|
const dependentNodesById = byIdMap(dependentNodes)
|
|
163
161
|
|
|
164
|
-
const lookupNodeById = (id:
|
|
162
|
+
const lookupNodeById = (id: LionWebId) =>
|
|
165
163
|
nodesById[id] ?? dependentNodesById[id];
|
|
166
164
|
|
|
167
165
|
nodesToInstall.forEach(([node, feature, ids]) => {
|
|
@@ -218,13 +216,13 @@ export const nodeBaseDeserializerWithIdMapping = (languageBases: ILanguageBase[]
|
|
|
218
216
|
|
|
219
217
|
/**
|
|
220
218
|
* @return a {@link Deserializer} function for the languages (given as {@link ILanguageBase}s) that returns the roots (of type {@link INodeBase}) of the deserialized model.
|
|
221
|
-
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link
|
|
219
|
+
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link LionWebJsonChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
222
220
|
* @param handleDelta an optional {@link DeltaHandler} that will be injected in all {@link INodeBase nodes} created.
|
|
223
221
|
*/
|
|
224
222
|
export const nodeBaseDeserializer = (languageBases: ILanguageBase[], handleDelta?: DeltaHandler): Deserializer<INodeBase[]> => {
|
|
225
223
|
const deserializerWithIdMapping = nodeBaseDeserializerWithIdMapping(languageBases, handleDelta);
|
|
226
224
|
return (
|
|
227
|
-
serializationChunk:
|
|
225
|
+
serializationChunk: LionWebJsonChunk,
|
|
228
226
|
dependentNodes: INodeBase[] = [],
|
|
229
227
|
primitiveTypeDeserializer: PrimitiveTypeDeserializer = new DefaultPrimitiveTypeDeserializer(),
|
|
230
228
|
problemsHandler: SimplisticHandler = defaultSimplisticHandler
|
package/src/duplicator.ts
CHANGED
|
@@ -15,12 +15,14 @@
|
|
|
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 { Containment, Feature, idOf, Link, Property, Reference, SingleRef, unresolved } from "@lionweb/core"
|
|
19
|
+
import { LionWebId } from "@lionweb/json"
|
|
20
|
+
import { asArray } from "@lionweb/ts-utils"
|
|
19
21
|
|
|
20
|
-
import {INodeBase} from "./base-types.js"
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
22
|
+
import { INodeBase } from "./base-types.js"
|
|
23
|
+
import { allNodesFrom } from "./convenience.js"
|
|
24
|
+
import { NodesToInstall } from "./linking.js"
|
|
25
|
+
import { getFeatureValue } from "./serializer.js"
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -45,7 +47,7 @@ export const deepDuplicateWith = (duplicateNode: NodeDuplicator): Duplicator =>
|
|
|
45
47
|
|
|
46
48
|
const nodesToInstall: NodesToInstall[] = [];
|
|
47
49
|
|
|
48
|
-
const visit = (node: INodeBase): [id:
|
|
50
|
+
const visit = (node: INodeBase): [id: LionWebId, duplicatedNode: INodeBase] => {
|
|
49
51
|
const [duplicatedNode, featuresToDuplicate] = duplicateNode(node);
|
|
50
52
|
const duplicateFeatureValue = (feature: Feature) => {
|
|
51
53
|
const value = getFeatureValue(node, feature);
|
package/src/id-mapping.ts
CHANGED
|
@@ -15,12 +15,12 @@
|
|
|
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 { IdOrUnresolved, SingleRef, unresolved } from "@lionweb/core"
|
|
19
|
+
import { LionWebId } from "@lionweb/json"
|
|
19
20
|
|
|
20
|
-
import {INodeBase} from "./index.js"
|
|
21
|
+
import { INodeBase } from "./index.js"
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
type NodesById = { [id: Id]: INodeBase};
|
|
23
|
+
type NodesById = { [id: LionWebId]: INodeBase }
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -35,7 +35,7 @@ export class IdMapping {
|
|
|
35
35
|
this.nodesById = {...nodesById};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
fromId(id:
|
|
38
|
+
fromId(id: LionWebId): INodeBase {
|
|
39
39
|
if (!(id in this.nodesById)) {
|
|
40
40
|
throw new Error(`node with id=${id} not in ID mapping`);
|
|
41
41
|
}
|
package/src/linking.ts
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { Link } from "@lionweb/core"
|
|
19
|
+
import { LionWebId } from "@lionweb/json"
|
|
20
|
+
import { INodeBase } from "./index.js"
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -35,5 +36,5 @@ import {INodeBase} from "./index.js";
|
|
|
35
36
|
* Note: **DON'T** export this types from the package,
|
|
36
37
|
* as these are only used to align the deserializer and deep-cloner.
|
|
37
38
|
*/
|
|
38
|
-
export type NodesToInstall = [ container: INodeBase, feature: Link | null, nodesIds:
|
|
39
|
+
export type NodesToInstall = [ container: INodeBase, feature: Link | null, nodesIds: LionWebId[], originalReferenceTargets?: INodeBase[] ];
|
|
39
40
|
|
|
@@ -31,13 +31,16 @@ import {
|
|
|
31
31
|
Classifier,
|
|
32
32
|
Concept,
|
|
33
33
|
EnumerationLiteral,
|
|
34
|
-
Id,
|
|
35
34
|
Interface,
|
|
36
35
|
Language,
|
|
37
36
|
PrimitiveType,
|
|
38
37
|
Property
|
|
39
38
|
} from "@lionweb/core";
|
|
40
39
|
|
|
40
|
+
import {
|
|
41
|
+
LionWebId
|
|
42
|
+
} from "@lionweb/json";
|
|
43
|
+
|
|
41
44
|
import {
|
|
42
45
|
DeltaHandler,
|
|
43
46
|
ILanguageBase,
|
|
@@ -108,7 +111,7 @@ export class LionCore_builtinsBase implements ILanguageBase {
|
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
factory(_handleDelta?: DeltaHandler): NodeBaseFactory {
|
|
111
|
-
return (classifier: Classifier, _id:
|
|
114
|
+
return (classifier: Classifier, _id: LionWebId) => {
|
|
112
115
|
const {language} = classifier;
|
|
113
116
|
throw new Error(`can't instantiate ${classifier.name} (key=${classifier.key}): classifier is not known in language ${language.name} (key=${language.key}, version=${language.version})`);
|
|
114
117
|
}
|
package/src/serializer.ts
CHANGED
|
@@ -25,9 +25,9 @@ import {
|
|
|
25
25
|
Property,
|
|
26
26
|
Reference,
|
|
27
27
|
serializeNodes
|
|
28
|
-
} from "@lionweb/core"
|
|
28
|
+
} from "@lionweb/core"
|
|
29
29
|
|
|
30
|
-
import {INodeBase, LionCore_builtinsBase} from "./index.js"
|
|
30
|
+
import { INodeBase, LionCore_builtinsBase } from "./index.js"
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -79,7 +79,7 @@ export const nodeBaseReader: ExtractionFacade<INodeBase> = {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
* @return a serialization of the given nodes (of type {@link INodeBase}) as a {@link
|
|
82
|
+
* @return a serialization of the given nodes (of type {@link INodeBase}) as a {@link LionWebJsonChunk}.
|
|
83
83
|
*/
|
|
84
84
|
export const serializeNodeBases = (nodes: INodeBase[]) =>
|
|
85
85
|
serializeNodes(nodes, nodeBaseReader, { serializeEmptyFeatures: false });
|
package/src/textualizer.ts
CHANGED
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import {INodeBase} from "./base-types.js";
|
|
22
|
-
import {LionCore_builtinsBase} from "./lionCore_builtins.g.js";
|
|
18
|
+
import { allFeaturesOf, Containment, Feature, Property, Reference, unresolved } from "@lionweb/core"
|
|
19
|
+
import { asString, indentWith, Template } from "littoral-templates"
|
|
23
20
|
|
|
21
|
+
import { INodeBase } from "./base-types.js"
|
|
22
|
+
import { LionCore_builtinsBase } from "./lionCore_builtins.g.js"
|
|
24
23
|
|
|
25
24
|
const indent = indentWith(" ")(1)
|
|
26
25
|
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {action, observable} from "mobx"
|
|
18
|
+
import { action, observable } from "mobx"
|
|
19
19
|
|
|
20
|
-
import {INodeBase, removeFromParent} from "../base-types.js"
|
|
21
|
-
import {checkIndex, ValueManager} from "./base.js";
|
|
20
|
+
import { INodeBase, removeFromParent } from "../base-types.js"
|
|
22
21
|
import {
|
|
23
22
|
AnnotationAddedDelta,
|
|
24
23
|
AnnotationDeletedDelta,
|
|
25
24
|
AnnotationMovedFromOtherParentDelta,
|
|
26
25
|
AnnotationMovedInSameParentDelta,
|
|
27
26
|
AnnotationReplacedDelta
|
|
28
|
-
} from "../deltas/index.js"
|
|
27
|
+
} from "../deltas/index.js"
|
|
28
|
+
import { checkIndex, ValueManager } from "./base.js"
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Feature, featureMetaType, Link} from "@lionweb/core"
|
|
19
|
-
import {INodeBase} from "../base-types.js"
|
|
20
|
-
import {IDelta} from "../deltas/index.js"
|
|
18
|
+
import { Feature, featureMetaType, Link } from "@lionweb/core"
|
|
19
|
+
import { INodeBase } from "../base-types.js"
|
|
20
|
+
import { IDelta } from "../deltas/index.js"
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -15,18 +15,12 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Containment} from "@lionweb/core"
|
|
19
|
-
import {action, observable} from "mobx"
|
|
20
|
-
|
|
21
|
-
import {INodeBase, removeFromParent} from "../base-types.js"
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
ChildAddedDelta,
|
|
25
|
-
ChildDeletedDelta,
|
|
26
|
-
ChildMovedDelta,
|
|
27
|
-
ChildMovedInSameContainmentDelta,
|
|
28
|
-
ChildReplacedDelta
|
|
29
|
-
} from "../deltas/index.js";
|
|
18
|
+
import { Containment } from "@lionweb/core"
|
|
19
|
+
import { action, observable } from "mobx"
|
|
20
|
+
|
|
21
|
+
import { INodeBase, removeFromParent } from "../base-types.js"
|
|
22
|
+
import { ChildAddedDelta, ChildDeletedDelta, ChildMovedDelta, ChildMovedInSameContainmentDelta, ChildReplacedDelta } from "../deltas/index.js"
|
|
23
|
+
import { checkIndex, FeatureValueManager } from "./base.js"
|
|
30
24
|
|
|
31
25
|
|
|
32
26
|
/**
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Property} from "@lionweb/core"
|
|
19
|
-
import {action, IObservableValue, observable} from "mobx"
|
|
18
|
+
import { Property } from "@lionweb/core"
|
|
19
|
+
import { action, IObservableValue, observable } from "mobx"
|
|
20
|
+
import { INodeBase } from "../base-types.js"
|
|
21
|
+
import { PropertyAddedDelta, PropertyChangedDelta, PropertyDeletedDelta } from "../deltas/index.js"
|
|
20
22
|
|
|
21
|
-
import {FeatureValueManager} from "./base.js"
|
|
22
|
-
import {INodeBase} from "../base-types.js";
|
|
23
|
-
import {PropertyAddedDelta, PropertyChangedDelta, PropertyDeletedDelta} from "../deltas/index.js";
|
|
23
|
+
import { FeatureValueManager } from "./base.js"
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -15,17 +15,12 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Reference, SingleRef} from "@lionweb/core"
|
|
19
|
-
import {action, observable} from "mobx"
|
|
20
|
-
|
|
21
|
-
import {INodeBase} from "../base-types.js"
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
ReferenceAddedDelta,
|
|
25
|
-
ReferenceDeletedDelta,
|
|
26
|
-
ReferenceMovedInSameReferenceDelta,
|
|
27
|
-
ReferenceReplacedDelta
|
|
28
|
-
} from "../deltas/index.js";
|
|
18
|
+
import { Reference, SingleRef } from "@lionweb/core"
|
|
19
|
+
import { action, observable } from "mobx"
|
|
20
|
+
|
|
21
|
+
import { INodeBase } from "../base-types.js"
|
|
22
|
+
import { ReferenceAddedDelta, ReferenceDeletedDelta, ReferenceMovedInSameReferenceDelta, ReferenceReplacedDelta } from "../deltas/index.js"
|
|
23
|
+
import { checkIndex, FeatureValueManager } from "./base.js"
|
|
29
24
|
|
|
30
25
|
|
|
31
26
|
/**
|