@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,180 @@
|
|
|
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
|
+
* Delta that does nothing.
|
|
19
|
+
* Warning: should only be used for development purposes!
|
|
20
|
+
*/
|
|
21
|
+
export class NoOpDelta {
|
|
22
|
+
}
|
|
23
|
+
export class PropertyAddedDelta {
|
|
24
|
+
constructor(container, property, value) {
|
|
25
|
+
this.container = container;
|
|
26
|
+
this.property = property;
|
|
27
|
+
this.value = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class PropertyDeletedDelta {
|
|
31
|
+
constructor(container, property, oldValue) {
|
|
32
|
+
this.container = container;
|
|
33
|
+
this.property = property;
|
|
34
|
+
this.oldValue = oldValue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class PropertyChangedDelta {
|
|
38
|
+
constructor(container, property, oldValue, newValue) {
|
|
39
|
+
this.container = container;
|
|
40
|
+
this.property = property;
|
|
41
|
+
this.oldValue = oldValue;
|
|
42
|
+
this.newValue = newValue;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class ChildAddedDelta {
|
|
46
|
+
constructor(parent, containment, index, newChild) {
|
|
47
|
+
this.parent = parent;
|
|
48
|
+
this.containment = containment;
|
|
49
|
+
this.index = index;
|
|
50
|
+
this.newChild = newChild;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export class ChildDeletedDelta {
|
|
54
|
+
constructor(parent, containment, index, deletedChild) {
|
|
55
|
+
this.parent = parent;
|
|
56
|
+
this.containment = containment;
|
|
57
|
+
this.index = index;
|
|
58
|
+
this.deletedChild = deletedChild;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class ChildReplacedDelta {
|
|
62
|
+
constructor(parent, containment, index, replacedChild, newChild) {
|
|
63
|
+
this.parent = parent;
|
|
64
|
+
this.containment = containment;
|
|
65
|
+
this.index = index;
|
|
66
|
+
this.replacedChild = replacedChild;
|
|
67
|
+
this.newChild = newChild;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class ChildMovedDelta {
|
|
71
|
+
constructor(oldParent, oldContainment, oldIndex, newParent, newContainment, newIndex, child) {
|
|
72
|
+
this.oldParent = oldParent;
|
|
73
|
+
this.oldContainment = oldContainment;
|
|
74
|
+
this.oldIndex = oldIndex;
|
|
75
|
+
this.newParent = newParent;
|
|
76
|
+
this.newContainment = newContainment;
|
|
77
|
+
this.newIndex = newIndex;
|
|
78
|
+
this.child = child;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export class ChildMovedInSameContainmentDelta {
|
|
82
|
+
constructor(parent, containment, oldIndex, newIndex, child) {
|
|
83
|
+
this.parent = parent;
|
|
84
|
+
this.containment = containment;
|
|
85
|
+
this.oldIndex = oldIndex;
|
|
86
|
+
this.newIndex = newIndex;
|
|
87
|
+
this.child = child;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export class ReferenceAddedDelta {
|
|
91
|
+
constructor(container, reference, index, newTarget) {
|
|
92
|
+
this.container = container;
|
|
93
|
+
this.reference = reference;
|
|
94
|
+
this.index = index;
|
|
95
|
+
this.newTarget = newTarget;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export class ReferenceDeletedDelta {
|
|
99
|
+
constructor(container, reference, index, deletedTarget) {
|
|
100
|
+
this.container = container;
|
|
101
|
+
this.reference = reference;
|
|
102
|
+
this.index = index;
|
|
103
|
+
this.deletedTarget = deletedTarget;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Note: corresponds to "reference changed" in delta proposal!
|
|
108
|
+
*/
|
|
109
|
+
export class ReferenceReplacedDelta {
|
|
110
|
+
constructor(container, reference, index, replacedTarget, newTarget) {
|
|
111
|
+
this.container = container;
|
|
112
|
+
this.reference = reference;
|
|
113
|
+
this.index = index;
|
|
114
|
+
this.replacedTarget = replacedTarget;
|
|
115
|
+
this.newTarget = newTarget;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Note: corresponds to "entry moved from other reference" in delta proposal!
|
|
120
|
+
*/
|
|
121
|
+
export class ReferenceMovedDelta {
|
|
122
|
+
constructor(oldContainer, oldReference, oldIndex, newContainer, newReference, newIndex, target) {
|
|
123
|
+
this.oldContainer = oldContainer;
|
|
124
|
+
this.oldReference = oldReference;
|
|
125
|
+
this.oldIndex = oldIndex;
|
|
126
|
+
this.newContainer = newContainer;
|
|
127
|
+
this.newReference = newReference;
|
|
128
|
+
this.newIndex = newIndex;
|
|
129
|
+
this.target = target;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export class ReferenceMovedInSameReferenceDelta {
|
|
133
|
+
constructor(container, reference, oldIndex, newIndex, target) {
|
|
134
|
+
this.container = container;
|
|
135
|
+
this.reference = reference;
|
|
136
|
+
this.oldIndex = oldIndex;
|
|
137
|
+
this.newIndex = newIndex;
|
|
138
|
+
this.target = target;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export class AnnotationAddedDelta {
|
|
142
|
+
constructor(parent, index, newAnnotation) {
|
|
143
|
+
this.parent = parent;
|
|
144
|
+
this.index = index;
|
|
145
|
+
this.newAnnotation = newAnnotation;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export class AnnotationDeletedDelta {
|
|
149
|
+
constructor(parent, index, deletedAnnotation) {
|
|
150
|
+
this.parent = parent;
|
|
151
|
+
this.index = index;
|
|
152
|
+
this.deletedAnnotation = deletedAnnotation;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export class AnnotationReplacedDelta {
|
|
156
|
+
constructor(parent, index, replacedAnnotation, newAnnotation) {
|
|
157
|
+
this.parent = parent;
|
|
158
|
+
this.index = index;
|
|
159
|
+
this.replacedAnnotation = replacedAnnotation;
|
|
160
|
+
this.newAnnotation = newAnnotation;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export class AnnotationMovedFromOtherParentDelta {
|
|
164
|
+
constructor(oldParent, oldIndex, newParent, newIndex, movedAnnotation) {
|
|
165
|
+
this.oldParent = oldParent;
|
|
166
|
+
this.oldIndex = oldIndex;
|
|
167
|
+
this.newParent = newParent;
|
|
168
|
+
this.newIndex = newIndex;
|
|
169
|
+
this.movedAnnotation = movedAnnotation;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export class AnnotationMovedInSameParentDelta {
|
|
173
|
+
constructor(parent, oldIndex, newIndex, movedAnnotation) {
|
|
174
|
+
this.parent = parent;
|
|
175
|
+
this.oldIndex = oldIndex;
|
|
176
|
+
this.newIndex = newIndex;
|
|
177
|
+
this.movedAnnotation = movedAnnotation;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=types.g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.g.js","sourceRoot":"","sources":["../../src/deltas/types.g.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAgBtC;;;GAGG;AACH,MAAM,OAAO,SAAS;CACrB;AAED,MAAM,OAAO,kBAAkB;IAC3B,YACoB,SAAoB,EACpB,QAAkB,EAClB,KAAQ;QAFR,cAAS,GAAT,SAAS,CAAW;QACpB,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAG;IAE5B,CAAC;CACJ;AAED,MAAM,OAAO,oBAAoB;IAC7B,YACoB,SAAoB,EACpB,QAAkB,EAClB,QAAW;QAFX,cAAS,GAAT,SAAS,CAAW;QACpB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAG;IAE/B,CAAC;CACJ;AAED,MAAM,OAAO,oBAAoB;IAC7B,YACoB,SAAoB,EACpB,QAAkB,EAClB,QAAW,EACX,QAAW;QAHX,cAAS,GAAT,SAAS,CAAW;QACpB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAG;QACX,aAAQ,GAAR,QAAQ,CAAG;IAE/B,CAAC;CACJ;AAED,MAAM,OAAO,eAAe;IACxB,YACoB,MAAiB,EACjB,WAAwB,EACxB,KAAa,EACb,QAAmB;QAHnB,WAAM,GAAN,MAAM,CAAW;QACjB,gBAAW,GAAX,WAAW,CAAa;QACxB,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAW;IAEvC,CAAC;CACJ;AAED,MAAM,O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TypeDeserializer, SerializationChunk, SimplisticHandler } from "@lionweb/core";
|
|
2
|
+
import { DeltaHandler, IdMapping, ILanguageBase, INodeBase } from "./index.js";
|
|
3
|
+
/**
|
|
4
|
+
* A type for deserializer functions that are parametrized in their return type.
|
|
5
|
+
*/
|
|
6
|
+
export type Deserializer<T> = (serializationChunk: SerializationChunk, dependentNodes?: INodeBase[], primitiveTypeDeserializer?: PrimitiveTypeDeserializer, problemHandler?: SimplisticHandler) => T;
|
|
7
|
+
/**
|
|
8
|
+
* A quasi-tuple of the roots (of type {@link INodeBase}) of a model,
|
|
9
|
+
* and its {@link IdMapping} instance.
|
|
10
|
+
*/
|
|
11
|
+
export type RootsWithIdMapping = {
|
|
12
|
+
roots: INodeBase[];
|
|
13
|
+
idMapping: IdMapping;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @return a {@link Deserializer} function for the given languages (given as {@link ILanguageBase}s) that returns a {@link RootsWithIdMapping}.
|
|
17
|
+
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link SerializationChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
18
|
+
* @param handleDelta an optional {@link DeltaHandler} that will be injected in all {@link INodeBase nodes} created.
|
|
19
|
+
*/
|
|
20
|
+
export declare const nodeBaseDeserializerWithIdMapping: (languageBases: ILanguageBase[], handleDelta?: DeltaHandler) => Deserializer<RootsWithIdMapping>;
|
|
21
|
+
/**
|
|
22
|
+
* @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.
|
|
23
|
+
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link SerializationChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
24
|
+
* @param handleDelta an optional {@link DeltaHandler} that will be injected in all {@link INodeBase nodes} created.
|
|
25
|
+
*/
|
|
26
|
+
export declare const nodeBaseDeserializer: (languageBases: ILanguageBase[], handleDelta?: DeltaHandler) => Deserializer<INodeBase[]>;
|
|
27
|
+
//# sourceMappingURL=deserializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../src/deserializer.ts"],"names":[],"mappings":"AAiBA,OAAO,EAWH,yBAAyB,EAGzB,kBAAkB,EAElB,iBAAiB,EAEpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAI7E;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAC1B,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,CAAC,EAAE,SAAS,EAAE,EAC5B,yBAAyB,CAAC,EAAE,yBAAyB,EACrD,cAAc,CAAC,EAAE,iBAAiB,KACjC,CAAC,CAAC;AAkBP;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAG9E;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,kBAAmB,aAAa,EAAE,gBAAgB,YAAY,KAAG,aAAa,kBAAkB,CAwI7I,CAAC;AAGF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,kBAAmB,aAAa,EAAE,gBAAgB,YAAY,KAAG,aAAa,SAAS,EAAE,CASzH,CAAA"}
|
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
import { byIdMap, Classifier, Containment, DefaultPrimitiveTypeDeserializer, defaultSimplisticHandler, Enumeration, MemoisingSymbolTable, PrimitiveType, Property, Reference, unresolved } from "@lionweb/core";
|
|
18
|
+
import { IdMapping } from "./index.js";
|
|
19
|
+
const languageBaseLookupFor = (languageBases) => (language) => {
|
|
20
|
+
const languageBase = languageBases.find((languageBase) => languageBase.language === language);
|
|
21
|
+
if (languageBase === undefined) {
|
|
22
|
+
throw new Error(`language ${language.name} (with key=${language.key} and version=${language.version}) not known`);
|
|
23
|
+
}
|
|
24
|
+
return languageBase;
|
|
25
|
+
};
|
|
26
|
+
const factoryLookupFor = (languageBases, handleDelta) => {
|
|
27
|
+
const lookup = languageBaseLookupFor(languageBases);
|
|
28
|
+
return (language) => lookup(language).factory(handleDelta);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @return a {@link Deserializer} function for the given languages (given as {@link ILanguageBase}s) that returns a {@link RootsWithIdMapping}.
|
|
32
|
+
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link SerializationChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
33
|
+
* @param handleDelta an optional {@link DeltaHandler} that will be injected in all {@link INodeBase nodes} created.
|
|
34
|
+
*/
|
|
35
|
+
export const nodeBaseDeserializerWithIdMapping = (languageBases, handleDelta) => {
|
|
36
|
+
const symbolTable = new MemoisingSymbolTable(languageBases.map(({ language }) => language));
|
|
37
|
+
const languageBaseFor = languageBaseLookupFor(languageBases);
|
|
38
|
+
const factoryFor = factoryLookupFor(languageBases, handleDelta);
|
|
39
|
+
return (serializationChunk, dependentNodes = [], primitiveTypeDeserializer = new DefaultPrimitiveTypeDeserializer(), problemsHandler = defaultSimplisticHandler) => {
|
|
40
|
+
const nodesToInstall = [];
|
|
41
|
+
const createNode = ({ id, classifier: classifierMetaPointer, properties, containments, references, annotations }) => {
|
|
42
|
+
const languageMessage = `language ${classifierMetaPointer.language} (${classifierMetaPointer.version})`;
|
|
43
|
+
const classifier = symbolTable.entityMatching(classifierMetaPointer);
|
|
44
|
+
if (classifier === undefined || !(classifier instanceof Classifier)) {
|
|
45
|
+
problemsHandler.reportProblem(`can't deserialize node with id=${id}: can't find the classifier with key ${classifierMetaPointer.key} in ${languageMessage} - skipping`);
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const node = factoryFor(classifier.language)(classifier, id);
|
|
49
|
+
properties.forEach(({ property: propertyMetaPointer, value }) => {
|
|
50
|
+
const feature = symbolTable.featureMatching(classifierMetaPointer, propertyMetaPointer);
|
|
51
|
+
if (feature === undefined) {
|
|
52
|
+
problemsHandler.reportProblem(`can't deserialize value for feature with key ${propertyMetaPointer.key} in ${languageMessage}: feature not found on classifier ${classifierMetaPointer.key} in language (${classifierMetaPointer.language}, ${classifierMetaPointer.version}) - skipping`);
|
|
53
|
+
}
|
|
54
|
+
else if (feature instanceof Property) {
|
|
55
|
+
if (feature.type instanceof PrimitiveType) {
|
|
56
|
+
node.getPropertyValueManager(feature).setDirectly(value === null ? undefined : primitiveTypeDeserializer.deserializeValue(value, feature));
|
|
57
|
+
}
|
|
58
|
+
else if (feature.type instanceof Enumeration) {
|
|
59
|
+
if (value !== undefined) {
|
|
60
|
+
const literal = feature.type.literals.find((literal) => literal.key === value);
|
|
61
|
+
if (literal === undefined) {
|
|
62
|
+
problemsHandler.reportProblem(`can't deserialize literal encoded as: ${value}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
node.getPropertyValueManager(feature).setDirectly(languageBaseFor(feature.type.language).enumLiteralFrom(literal));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
problemsHandler.reportProblem(`can't deserialize value for feature with key ${propertyMetaPointer.key} in ${languageMessage}: feature is not a property - skipping`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
containments.forEach(({ containment: containmentMetaPointer, children }) => {
|
|
75
|
+
const feature = symbolTable.featureMatching(classifierMetaPointer, containmentMetaPointer);
|
|
76
|
+
if (feature === undefined) {
|
|
77
|
+
problemsHandler.reportProblem(`can't deserialize value for feature with key ${containmentMetaPointer.key} in ${languageMessage}: feature not found on classifier ${classifierMetaPointer.key} in language (${classifierMetaPointer.language}, ${classifierMetaPointer.version}) - skipping`);
|
|
78
|
+
}
|
|
79
|
+
else if (feature instanceof Containment) {
|
|
80
|
+
nodesToInstall.push([node, feature, children]);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
problemsHandler.reportProblem(`can't deserialize value for feature with key ${containmentMetaPointer.key} in ${languageMessage}: feature is not a containment - skipping`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
references.forEach(({ reference: referenceMetaPointer, targets }) => {
|
|
87
|
+
const feature = symbolTable.featureMatching(classifierMetaPointer, referenceMetaPointer);
|
|
88
|
+
if (feature === undefined) {
|
|
89
|
+
problemsHandler.reportProblem(`can't deserialize value for feature with key ${referenceMetaPointer.key} in ${languageMessage}: feature not found on classifier ${classifierMetaPointer.key} in language (${classifierMetaPointer.language}, ${classifierMetaPointer.version}) - skipping`);
|
|
90
|
+
}
|
|
91
|
+
else if (feature instanceof Reference) {
|
|
92
|
+
nodesToInstall.push([node, feature, targets.map(({ reference }) => reference)]);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
problemsHandler.reportProblem(`can't deserialize value for feature with key ${referenceMetaPointer.key} in ${languageMessage}: feature is not a reference - skipping`);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (annotations.length > 0) {
|
|
99
|
+
nodesToInstall.push([node, null, annotations]);
|
|
100
|
+
}
|
|
101
|
+
return node;
|
|
102
|
+
};
|
|
103
|
+
const nodesById = byIdMap(serializationChunk.nodes
|
|
104
|
+
.map(createNode)
|
|
105
|
+
.filter((nodeOrUndef) => nodeOrUndef !== undefined));
|
|
106
|
+
const dependentNodesById = byIdMap(dependentNodes);
|
|
107
|
+
const lookupNodeById = (id) => nodesById[id] ?? dependentNodesById[id];
|
|
108
|
+
nodesToInstall.forEach(([node, feature, ids]) => {
|
|
109
|
+
if (feature instanceof Containment) {
|
|
110
|
+
const valueManager = node.getContainmentValueManager(feature);
|
|
111
|
+
ids.forEach((id) => {
|
|
112
|
+
const nodeToInstall = lookupNodeById(id);
|
|
113
|
+
if (nodeToInstall === undefined) {
|
|
114
|
+
problemsHandler.reportProblem(`couldn't resolve the child with id=${id} of the "${feature.name}" containment feature on the node with id=${node.id}`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
valueManager.addDirectly(nodeToInstall);
|
|
118
|
+
nodeToInstall.attachTo(node, feature);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (feature instanceof Reference) {
|
|
124
|
+
const valueManager = node.getReferenceValueManager(feature);
|
|
125
|
+
ids.forEach((id) => {
|
|
126
|
+
const nodeToInstall = lookupNodeById(id);
|
|
127
|
+
if (nodeToInstall === undefined) {
|
|
128
|
+
problemsHandler.reportProblem(`couldn't resolve the target with id=${id} of the "${feature.name}" reference feature on the node with id=${node.id}`);
|
|
129
|
+
valueManager.addDirectly(unresolved);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
valueManager.addDirectly(nodeToInstall);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (feature === null) {
|
|
138
|
+
const valueManager = node.annotationsValueManager;
|
|
139
|
+
ids.forEach((id) => {
|
|
140
|
+
const nodeToInstall = lookupNodeById(id);
|
|
141
|
+
if (nodeToInstall === undefined) {
|
|
142
|
+
problemsHandler.reportProblem(`couldn't resolve the annotation with id=${id} on the node with id=${node.id}`);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
valueManager.addDirectly(nodeToInstall);
|
|
146
|
+
nodeToInstall.attachTo(node, feature);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
roots: Object.values(nodesById)
|
|
154
|
+
.filter(({ parent }) => parent === undefined),
|
|
155
|
+
idMapping: new IdMapping({ ...nodesById, ...dependentNodesById })
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* @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.
|
|
161
|
+
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link SerializationChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
162
|
+
* @param handleDelta an optional {@link DeltaHandler} that will be injected in all {@link INodeBase nodes} created.
|
|
163
|
+
*/
|
|
164
|
+
export const nodeBaseDeserializer = (languageBases, handleDelta) => {
|
|
165
|
+
const deserializerWithIdMapping = nodeBaseDeserializerWithIdMapping(languageBases, handleDelta);
|
|
166
|
+
return (serializationChunk, dependentNodes = [], primitiveTypeDeserializer = new DefaultPrimitiveTypeDeserializer(), problemsHandler = defaultSimplisticHandler) => deserializerWithIdMapping(serializationChunk, dependentNodes, primitiveTypeDeserializer, problemsHandler).roots;
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=deserializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deserializer.js","sourceRoot":"","sources":["../src/deserializer.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AAC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AAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;iBAC1B,MAAM,CAAC,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,MAAM,KAAK,SAAS,CAAC;YAC/C,SAAS,EAAE,IAAI,SAAS,CAAC,EAAE,GAAG,SAAS,EAAE,GAAG,kBAAkB,EAAE,CAAC;SACpE,CAAC;IAEN,CAAC,CAAC;AACN,CAAC,CAAC;AAGF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,aAA8B,EAAE,WAA0B,EAA6B,EAAE;IAC1H,MAAM,yBAAyB,GAAG,iCAAiC,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAChG,OAAO,CACH,kBAAsC,EACtC,iBAA8B,EAAE,EAChC,4BAAuD,IAAI,gCAAgC,EAAE,EAC7F,kBAAqC,wBAAwB,EAClD,EAAE,CACb,yBAAyB,CAAC,kBAAkB,EAAE,cAAc,EAAE,yBAAyB,EAAE,eAAe,CAAC,CAAC,KAAK,CAAA;AACvH,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Feature } from "@lionweb/core";
|
|
2
|
+
import { INodeBase } from "./base-types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Type definition for functions that duplicate a node.
|
|
5
|
+
*/
|
|
6
|
+
export type NodeDuplicator = (originalNode: INodeBase) => [duplicatedNode: INodeBase, featuresToDuplicate: Feature[]];
|
|
7
|
+
/**
|
|
8
|
+
* Type definition for functions that duplicate the (variadically) given nodes.
|
|
9
|
+
*/
|
|
10
|
+
export type Duplicator = (...nodes: INodeBase[]) => INodeBase[];
|
|
11
|
+
/**
|
|
12
|
+
* @return a function that deep-duplicates a given forest of {@link INodeBase nodes}.
|
|
13
|
+
* The result is an array of the deep-duplicated versions of the given nodes *in the same order*.
|
|
14
|
+
*
|
|
15
|
+
* @param duplicateNode a function that returns a – possibly transformed – duplicate of the passed `originalNode`.
|
|
16
|
+
* ***Note***: it's assumed that the classifiers of the original and duplicated nodes coincide exactly!
|
|
17
|
+
*/
|
|
18
|
+
export declare const deepDuplicateWith: (duplicateNode: NodeDuplicator) => Duplicator;
|
|
19
|
+
//# sourceMappingURL=duplicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicator.d.ts","sourceRoot":"","sources":["../src/duplicator.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAuB,OAAO,EAA6D,MAAM,eAAe,CAAC;AAExH,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAM1C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,SAAS,KAAK,CAAC,cAAc,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAC,CAAC;AAEtH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,KAAK,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,kBAAmB,cAAc,KAAG,UAmE7D,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
import { asArray, Containment, idOf, Link, Property, Reference, unresolved } from "@lionweb/core";
|
|
18
|
+
import { getFeatureValue } from "./serializer.js";
|
|
19
|
+
import { allNodesFrom } from "./convenience.js";
|
|
20
|
+
/**
|
|
21
|
+
* @return a function that deep-duplicates a given forest of {@link INodeBase nodes}.
|
|
22
|
+
* The result is an array of the deep-duplicated versions of the given nodes *in the same order*.
|
|
23
|
+
*
|
|
24
|
+
* @param duplicateNode a function that returns a – possibly transformed – duplicate of the passed `originalNode`.
|
|
25
|
+
* ***Note***: it's assumed that the classifiers of the original and duplicated nodes coincide exactly!
|
|
26
|
+
*/
|
|
27
|
+
export const deepDuplicateWith = (duplicateNode) => (...nodes) => {
|
|
28
|
+
const nodesToInstall = [];
|
|
29
|
+
const visit = (node) => {
|
|
30
|
+
const [duplicatedNode, featuresToDuplicate] = duplicateNode(node);
|
|
31
|
+
const duplicateFeatureValue = (feature) => {
|
|
32
|
+
const value = getFeatureValue(node, feature);
|
|
33
|
+
if (feature instanceof Property) {
|
|
34
|
+
duplicatedNode.getPropertyValueManager(feature).setDirectly(value);
|
|
35
|
+
}
|
|
36
|
+
else if (feature instanceof Link) {
|
|
37
|
+
const values = asArray(value);
|
|
38
|
+
const resolvedValues = values.filter((value) => value !== unresolved);
|
|
39
|
+
if (resolvedValues.length > 0) {
|
|
40
|
+
nodesToInstall.push([
|
|
41
|
+
duplicatedNode,
|
|
42
|
+
feature,
|
|
43
|
+
resolvedValues.map(idOf),
|
|
44
|
+
feature instanceof Reference
|
|
45
|
+
? resolvedValues
|
|
46
|
+
: undefined
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
featuresToDuplicate.forEach(duplicateFeatureValue);
|
|
52
|
+
if (node.annotations.length > 0) {
|
|
53
|
+
nodesToInstall.push([duplicatedNode, null, node.annotations.map(idOf)]);
|
|
54
|
+
}
|
|
55
|
+
return [node.id, duplicatedNode];
|
|
56
|
+
};
|
|
57
|
+
const duplicatedNodesByOriginalId = Object.fromEntries(nodes.flatMap(allNodesFrom).map(visit));
|
|
58
|
+
nodesToInstall.forEach(([copiedNode, feature, ids, originalReferenceTargets]) => {
|
|
59
|
+
if (feature instanceof Containment) {
|
|
60
|
+
const valueManager = copiedNode.getContainmentValueManager(feature);
|
|
61
|
+
ids.forEach((id) => {
|
|
62
|
+
const nodeToInstall = duplicatedNodesByOriginalId[id];
|
|
63
|
+
valueManager.addDirectly(nodeToInstall);
|
|
64
|
+
nodeToInstall.attachTo(copiedNode, feature);
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (feature instanceof Reference) {
|
|
69
|
+
const valueManager = copiedNode.getReferenceValueManager(feature);
|
|
70
|
+
ids.forEach((id, index) => {
|
|
71
|
+
const nodeToInstall = duplicatedNodesByOriginalId[id] ?? originalReferenceTargets[index];
|
|
72
|
+
valueManager.addDirectly(nodeToInstall);
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (feature === null) {
|
|
77
|
+
const valueManager = copiedNode.annotationsValueManager;
|
|
78
|
+
ids.forEach((id) => {
|
|
79
|
+
const nodeToInstall = duplicatedNodesByOriginalId[id];
|
|
80
|
+
valueManager.addDirectly(nodeToInstall);
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return nodes.map(({ id }) => duplicatedNodesByOriginalId[id]);
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=duplicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicator.js","sourceRoot":"","sources":["../src/duplicator.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,i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AG,2BAA2B,CAAC,EAAE,CAAC,IAAI,wBAAyB,CAAC,KAAK,CAAC,CAAC;gBAC1F,YAAY,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAC;YACH,OAAO;QACX,CAAC;QACD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,YAAY,GAAG,UAAU,CAAC,uBAAuB,CAAC;YACxD,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;gBACf,MAAM,aAAa,GAAG,2BAA2B,CAAC,EAAE,CAAC,CAAC;gBACtD,YAAY,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAA;YACF,OAAO;QACX,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC;AAEhE,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Id, IdOrUnresolved, SingleRef } from "@lionweb/core";
|
|
2
|
+
import { INodeBase } from "./index.js";
|
|
3
|
+
type NodesById = {
|
|
4
|
+
[id: Id]: INodeBase;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Maintains a mapping ID → node,
|
|
8
|
+
* which is primarily used for efficiently applying {@link IDelta deltas}.
|
|
9
|
+
* Instances are produced by the {@link nodeBaseDeserializerWithIdMapping} function.
|
|
10
|
+
*/
|
|
11
|
+
export declare class IdMapping {
|
|
12
|
+
nodesById: NodesById;
|
|
13
|
+
constructor(nodesById: NodesById);
|
|
14
|
+
fromId(id: Id): INodeBase;
|
|
15
|
+
fromRefId(idOrUnresolved: IdOrUnresolved): SingleRef<INodeBase>;
|
|
16
|
+
updateWith(node: INodeBase): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=id-mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-mapping.d.ts","sourceRoot":"","sources":["../src/id-mapping.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,EAAE,EAAE,cAAc,EAAE,SAAS,EAAa,MAAM,eAAe,CAAC;AAExE,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAGrC,KAAK,SAAS,GAAG;IAAE,CAAC,EAAE,EAAE,EAAE,GAAG,SAAS,CAAA;CAAC,CAAC;AAGxC;;;;GAIG;AACH,qBAAa,SAAS;IAElB,SAAS,EAAE,SAAS,CAAC;gBACT,SAAS,EAAE,SAAS;IAIhC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,SAAS;IAOzB,SAAS,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC;IAM/D,UAAU,CAAC,IAAI,EAAE,SAAS;CAM7B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
import { unresolved } from "@lionweb/core";
|
|
18
|
+
/**
|
|
19
|
+
* Maintains a mapping ID → node,
|
|
20
|
+
* which is primarily used for efficiently applying {@link IDelta deltas}.
|
|
21
|
+
* Instances are produced by the {@link nodeBaseDeserializerWithIdMapping} function.
|
|
22
|
+
*/
|
|
23
|
+
export class IdMapping {
|
|
24
|
+
constructor(nodesById) {
|
|
25
|
+
this.nodesById = { ...nodesById };
|
|
26
|
+
}
|
|
27
|
+
fromId(id) {
|
|
28
|
+
if (!(id in this.nodesById)) {
|
|
29
|
+
throw new Error(`node with id=${id} not in ID mapping`);
|
|
30
|
+
}
|
|
31
|
+
return this.nodesById[id];
|
|
32
|
+
}
|
|
33
|
+
fromRefId(idOrUnresolved) {
|
|
34
|
+
return idOrUnresolved === null
|
|
35
|
+
? null
|
|
36
|
+
: (this.nodesById[idOrUnresolved] ?? unresolved);
|
|
37
|
+
}
|
|
38
|
+
updateWith(node) {
|
|
39
|
+
this.nodesById[node.id] = node;
|
|
40
|
+
node.children // recurse into all children
|
|
41
|
+
.forEach((child) => this.updateWith(child));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=id-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-mapping.js","sourceRoot":"","sources":["../src/id-mapping.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EAAgC,UAAU,EAAC,MAAM,eAAe,CAAC;AAQxE;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAGlB,YAAY,SAAoB;QAC5B,IAAI,CAAC,SAAS,GAAG,EAAC,GAAG,SAAS,EAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,EAAM;QACT,IAAI,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,cAA8B;QACpC,OAAO,cAAc,KAAK,IAAI;YAC1B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,UAAU,CAAC,CAAC;IACzD,CAAC;IAED,UAAU,CAAC,IAAe;QACtB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,QAAQ,CAAG,4BAA4B;aACvC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;CAEJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./base-types.js";
|
|
2
|
+
export * from "./convenience.js";
|
|
3
|
+
export * from "./deltas/index.js";
|
|
4
|
+
export * from "./deserializer.js";
|
|
5
|
+
export { deepDuplicateWith } from "./duplicator.js";
|
|
6
|
+
export * from "./id-mapping.js";
|
|
7
|
+
export * from "./lionCore_builtins.g.js";
|
|
8
|
+
export { serializeNodeBases } from "./serializer.js";
|
|
9
|
+
export * from "./value-managers/index.js";
|
|
10
|
+
export { asTreeTextWith } from "./textualizer.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,cAAc,iBAAiB,CAAC;AAEhC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
export * from "./base-types.js";
|
|
18
|
+
export * from "./convenience.js";
|
|
19
|
+
export * from "./deltas/index.js";
|
|
20
|
+
export * from "./deserializer.js";
|
|
21
|
+
export { deepDuplicateWith } from "./duplicator.js";
|
|
22
|
+
export * from "./id-mapping.js";
|
|
23
|
+
// skip linking.js: see comment there
|
|
24
|
+
export * from "./lionCore_builtins.g.js";
|
|
25
|
+
export { serializeNodeBases } from "./serializer.js";
|
|
26
|
+
export * from "./value-managers/index.js";
|
|
27
|
+
export { asTreeTextWith } from "./textualizer.js";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,cAAc,iBAAiB,CAAC;AAChC,qCAAqC;AACrC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC"}
|