@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,53 @@
|
|
|
1
|
+
import { Feature } from "@lionweb/core";
|
|
2
|
+
import { INodeBase } from "../base-types.js";
|
|
3
|
+
import { IDelta } from "../deltas/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Abstract super/base type for managers of values on classifiers.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class ValueManager {
|
|
8
|
+
protected readonly container: INodeBase;
|
|
9
|
+
protected constructor(container: INodeBase);
|
|
10
|
+
/**
|
|
11
|
+
* Emits a delta if a {@link DeltaHandler} is registered with the container.
|
|
12
|
+
* @param deltaThunk a thunk that generates the delta, and is only called when a delta handler is registered with the container.
|
|
13
|
+
*/
|
|
14
|
+
emitDelta(deltaThunk: () => IDelta): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Abstract super/base type for managers of values of features on classifiers.
|
|
18
|
+
* All subtypes have "<requiredness><multiplicity>ValueManager" as names,
|
|
19
|
+
* where <requiredness> = "" (for abstract “inter-types”) or "Optional" or "Required",
|
|
20
|
+
* and <multiplicity> = "Single" or "Multiple".
|
|
21
|
+
*/
|
|
22
|
+
export declare abstract class FeatureValueManager<FT extends Feature> extends ValueManager {
|
|
23
|
+
protected readonly feature: FT;
|
|
24
|
+
protected constructor(feature: FT, container: INodeBase);
|
|
25
|
+
/**
|
|
26
|
+
* Checks whether the feature's requiredness matches the expected one.
|
|
27
|
+
*/
|
|
28
|
+
checkRequired(expectRequired: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Checks whether the feature's multiplicity matches the expected one.
|
|
31
|
+
*/
|
|
32
|
+
checkMultiple(expectMultiple: boolean): void;
|
|
33
|
+
/**
|
|
34
|
+
* @return whether the feature's value is (has been) set.
|
|
35
|
+
*/
|
|
36
|
+
abstract isSet(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @throws when the feature's value is unset, but has been attempted to read.
|
|
39
|
+
*/
|
|
40
|
+
throwOnReadOfUnset(): never;
|
|
41
|
+
/**
|
|
42
|
+
* @throws when the feature's value has been attempted to unset, but the feature is required.
|
|
43
|
+
*/
|
|
44
|
+
throwOnUnset(): never;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether the given index is valid within the given parameters of the context.
|
|
48
|
+
* @param index the supposed index of an element to retrieve/insert at/to
|
|
49
|
+
* @param nElements the number of elements in an array
|
|
50
|
+
* @param inserting whether the intention is to insert an element to the array
|
|
51
|
+
*/
|
|
52
|
+
export declare const checkIndex: (index: number, nElements: number, inserting: boolean) => void;
|
|
53
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/value-managers/base.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,OAAO,EAAwB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAG1C;;GAEG;AACH,8BAAsB,YAAY;IAER,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS;IAA7D,SAAS,aAAgC,SAAS,EAAE,SAAS;IAG7D;;;OAGG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,MAAM;CAMrC;AAGD;;;;;GAKG;AACH,8BAAsB,mBAAmB,CAAC,EAAE,SAAS,OAAO,CAAE,SAAQ,YAAY;IAExD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE;IAApD,SAAS,aAAgC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS;IAK1E;;OAEG;IACH,aAAa,CAAC,cAAc,EAAE,OAAO;IAMrC;;OAEG;IACH,aAAa,CAAC,cAAc,EAAE,OAAO;IAOrC;;OAEG;IACH,QAAQ,CAAC,KAAK,IAAI,OAAO;IAEzB;;OAEG;IACH,kBAAkB,IAAI,KAAK;IAI3B;;OAEG;IACH,YAAY,IAAI,KAAK;CAIxB;AAGD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,UAAW,MAAM,aAAa,MAAM,aAAa,OAAO,SAkB9E,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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 { featureMetaType } from "@lionweb/core";
|
|
18
|
+
/**
|
|
19
|
+
* Abstract super/base type for managers of values on classifiers.
|
|
20
|
+
*/
|
|
21
|
+
export class ValueManager {
|
|
22
|
+
constructor(container) {
|
|
23
|
+
this.container = container;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Emits a delta if a {@link DeltaHandler} is registered with the container.
|
|
27
|
+
* @param deltaThunk a thunk that generates the delta, and is only called when a delta handler is registered with the container.
|
|
28
|
+
*/
|
|
29
|
+
emitDelta(deltaThunk) {
|
|
30
|
+
if (this.container.handleDelta) {
|
|
31
|
+
this.container.handleDelta(deltaThunk());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Abstract super/base type for managers of values of features on classifiers.
|
|
37
|
+
* All subtypes have "<requiredness><multiplicity>ValueManager" as names,
|
|
38
|
+
* where <requiredness> = "" (for abstract “inter-types”) or "Optional" or "Required",
|
|
39
|
+
* and <multiplicity> = "Single" or "Multiple".
|
|
40
|
+
*/
|
|
41
|
+
export class FeatureValueManager extends ValueManager {
|
|
42
|
+
constructor(feature, container) {
|
|
43
|
+
super(container);
|
|
44
|
+
this.feature = feature;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether the feature's requiredness matches the expected one.
|
|
48
|
+
*/
|
|
49
|
+
checkRequired(expectRequired) {
|
|
50
|
+
if (this.feature.optional === expectRequired) { // (double negation)
|
|
51
|
+
throw new Error(`${featureMetaType(this.feature).toLowerCase()} "${this.feature.name}" (with key="${this.feature.key}") should be ${expectRequired ? "required" : "optional"}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Checks whether the feature's multiplicity matches the expected one.
|
|
56
|
+
*/
|
|
57
|
+
checkMultiple(expectMultiple) {
|
|
58
|
+
if (this.feature.multiple !== expectMultiple) {
|
|
59
|
+
throw new Error(`${featureMetaType(this.feature).toLowerCase()} "${this.feature.name}" (with key="${this.feature.key}") should be ${expectMultiple ? "multi" : "single"}-valued`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @throws when the feature's value is unset, but has been attempted to read.
|
|
64
|
+
*/
|
|
65
|
+
throwOnReadOfUnset() {
|
|
66
|
+
throw new Error(`can't read required ${featureMetaType(this.feature).toLowerCase()} "${this.feature.name}" that's unset on instance of ${this.container.classifier.language.name}.${this.container.classifier.name} with id=${this.container.id}`);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @throws when the feature's value has been attempted to unset, but the feature is required.
|
|
70
|
+
*/
|
|
71
|
+
throwOnUnset() {
|
|
72
|
+
throw new Error(`can't unset required ${featureMetaType(this.feature).toLowerCase()} "${this.feature.name}" on instance of ${this.container.classifier.language.name}.${this.container.classifier.name} with id=${this.container.id}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Checks whether the given index is valid within the given parameters of the context.
|
|
77
|
+
* @param index the supposed index of an element to retrieve/insert at/to
|
|
78
|
+
* @param nElements the number of elements in an array
|
|
79
|
+
* @param inserting whether the intention is to insert an element to the array
|
|
80
|
+
*/
|
|
81
|
+
export const checkIndex = (index, nElements, inserting) => {
|
|
82
|
+
if (!Number.isInteger(index)) {
|
|
83
|
+
throw new Error(`an array index must be an integer, but got: ${index}`);
|
|
84
|
+
}
|
|
85
|
+
if (index < 0) {
|
|
86
|
+
throw new Error(`an array index must be a non-negative integer, but got: ${index}`);
|
|
87
|
+
}
|
|
88
|
+
if (inserting) {
|
|
89
|
+
if (index > nElements) {
|
|
90
|
+
throw new Error(`the largest valid insert index for an array with ${nElements} element${nElements === 1 ? "" : "s"} is ${nElements}, but got: ${index}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (nElements === 0) {
|
|
95
|
+
throw new Error(`an empty array has no valid indices (got: ${index})`);
|
|
96
|
+
}
|
|
97
|
+
else if (index + 1 > nElements) {
|
|
98
|
+
throw new Error(`the largest valid index for an array with ${nElements} element${nElements === 1 ? "" : "s"} is ${nElements - 1}, but got: ${index}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/value-managers/base.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAC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2DAA2D,KAAK,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACZ,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,oDAAoD,SAAS,WAAW,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,CAAC,GAAG,OAAO,SAAS,cAAc,KAAK,EAAE,CAAC,CAAC;QAC5J,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,6CAA6C,KAAK,GAAG,CAAC,CAAC;QAC3E,CAAC;aAAM,IAAI,KAAK,GAAG,CAAC,GAAG,SAAS,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,6CAA6C,SAAS,WAAW,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,CAAC,GAAG,OAAO,SAAS,GAAG,CAAC,cAAc,KAAK,EAAE,CAAC,CAAC;QACzJ,CAAC;IACL,CAAC;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Containment } from "@lionweb/core";
|
|
2
|
+
import { INodeBase } from "../base-types.js";
|
|
3
|
+
import { FeatureValueManager } from "./base.js";
|
|
4
|
+
/**
|
|
5
|
+
* An instance manages the value of a particular containment feature on a particular instance of a classifier.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class ContainmentValueManager<T extends INodeBase> extends FeatureValueManager<Containment> {
|
|
8
|
+
get containment(): Containment;
|
|
9
|
+
abstract getDirectly(): T | undefined | (T | undefined)[];
|
|
10
|
+
/**
|
|
11
|
+
* Adds the given child to the containment.
|
|
12
|
+
* For a single-valued containment, this assumes that it contained no child before,
|
|
13
|
+
* or else it throws.
|
|
14
|
+
*/
|
|
15
|
+
abstract addDirectly(newChild: T): void;
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class SingleContainmentValueManager<T extends INodeBase> extends ContainmentValueManager<T> {
|
|
18
|
+
protected constructor(containment: Containment, container: INodeBase);
|
|
19
|
+
private readonly child;
|
|
20
|
+
getDirectly(): T | undefined;
|
|
21
|
+
isSet(): boolean;
|
|
22
|
+
setDirectly(newChild: T | undefined): void;
|
|
23
|
+
addDirectly(newChild: T): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class OptionalSingleContainmentValueManager<T extends INodeBase> extends SingleContainmentValueManager<T> {
|
|
26
|
+
constructor(containment: Containment, container: INodeBase);
|
|
27
|
+
get(): T | undefined;
|
|
28
|
+
set(newChild: T | undefined): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class RequiredSingleContainmentValueManager<T extends INodeBase> extends SingleContainmentValueManager<T> {
|
|
31
|
+
constructor(containment: Containment, container: INodeBase);
|
|
32
|
+
get(): T;
|
|
33
|
+
set(newChild: T | undefined): void;
|
|
34
|
+
}
|
|
35
|
+
export declare abstract class MultiContainmentValueManager<T extends INodeBase> extends ContainmentValueManager<T> {
|
|
36
|
+
protected constructor(containment: Containment, container: INodeBase);
|
|
37
|
+
private readonly children;
|
|
38
|
+
getDirectly(): T[];
|
|
39
|
+
get(): T[];
|
|
40
|
+
isSet(): boolean;
|
|
41
|
+
addDirectly(newChild: T): void;
|
|
42
|
+
add(newChild: T): void;
|
|
43
|
+
insertAtIndexDirectly(newChild: T, index: number): void;
|
|
44
|
+
insertAtIndex(newChild: T, index: number): void;
|
|
45
|
+
removeDirectly(childToRemove: T): number;
|
|
46
|
+
moveDirectly(oldIndex: number, newIndex: number): T | undefined;
|
|
47
|
+
move(oldIndex: number, newIndex: number): void;
|
|
48
|
+
}
|
|
49
|
+
export declare class OptionalMultiContainmentValueManager<T extends INodeBase> extends MultiContainmentValueManager<T> {
|
|
50
|
+
constructor(containment: Containment, container: INodeBase);
|
|
51
|
+
remove(childToRemove: T): void;
|
|
52
|
+
}
|
|
53
|
+
export declare class RequiredMultiContainmentValueManager<T extends INodeBase> extends MultiContainmentValueManager<T> {
|
|
54
|
+
constructor(containment: Containment, container: INodeBase);
|
|
55
|
+
get(): T[];
|
|
56
|
+
remove(childToRemove: T): void;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=containments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containments.d.ts","sourceRoot":"","sources":["../../src/value-managers/containments.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAC,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAa,mBAAmB,EAAC,MAAM,WAAW,CAAC;AAU1D;;GAEG;AACH,8BAAsB,uBAAuB,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,mBAAmB,CAAC,WAAW,CAAC;IAEvG,IAAI,WAAW,IAAI,WAAW,CAE7B;IAED,QAAQ,CAAC,WAAW,IAAI,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE;IAEzD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI;CAE1C;AAGD,8BAAsB,6BAA6B,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,uBAAuB,CAAC,CAAC,CAAC;IAEvG,SAAS,aAAa,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS;IAKpE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2D;IAEjF,WAAW,IAAI,CAAC,GAAG,SAAS;IAI5B,KAAK,IAAI,OAAO;IAIR,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,SAAS;IAInC,WAAW,CAAC,QAAQ,EAAE,CAAC;CAQlC;AAGD,qBAAa,qCAAqC,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,6BAA6B,CAAC,CAAC,CAAC;gBAEhG,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS;IAK1D,GAAG,IAAI,CA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AQ,4BAA4B,CAAC,CAAC,CAAC;gBAE9F,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS;IAK1D,GAAG,IAAI,CAAC,EAAE;IAQF,MAAM,CAAC,aAAa,EAAE,CAAC;CAalC"}
|
|
@@ -0,0 +1,408 @@
|
|
|
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
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
18
|
+
var useValue = arguments.length > 2;
|
|
19
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
20
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
21
|
+
}
|
|
22
|
+
return useValue ? value : void 0;
|
|
23
|
+
};
|
|
24
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
25
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
26
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
27
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
28
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
29
|
+
var _, done = false;
|
|
30
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
31
|
+
var context = {};
|
|
32
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
33
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
34
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
35
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
36
|
+
if (kind === "accessor") {
|
|
37
|
+
if (result === void 0) continue;
|
|
38
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
39
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
40
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
41
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
42
|
+
}
|
|
43
|
+
else if (_ = accept(result)) {
|
|
44
|
+
if (kind === "field") initializers.unshift(_);
|
|
45
|
+
else descriptor[key] = _;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
49
|
+
done = true;
|
|
50
|
+
};
|
|
51
|
+
import { action, observable } from "mobx";
|
|
52
|
+
import { removeFromParent } from "../base-types.js";
|
|
53
|
+
import { checkIndex, FeatureValueManager } from "./base.js";
|
|
54
|
+
import { ChildAddedDelta, ChildDeletedDelta, ChildMovedDelta, ChildMovedInSameContainmentDelta, ChildReplacedDelta } from "../deltas/index.js";
|
|
55
|
+
/**
|
|
56
|
+
* An instance manages the value of a particular containment feature on a particular instance of a classifier.
|
|
57
|
+
*/
|
|
58
|
+
export class ContainmentValueManager extends FeatureValueManager {
|
|
59
|
+
get containment() {
|
|
60
|
+
return this.feature;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
let SingleContainmentValueManager = (() => {
|
|
64
|
+
var _a;
|
|
65
|
+
let _classSuper = ContainmentValueManager;
|
|
66
|
+
let _instanceExtraInitializers = [];
|
|
67
|
+
let _setDirectly_decorators;
|
|
68
|
+
let _addDirectly_decorators;
|
|
69
|
+
return _a = class SingleContainmentValueManager extends _classSuper {
|
|
70
|
+
constructor(containment, container) {
|
|
71
|
+
super(containment, container);
|
|
72
|
+
this.child = (__runInitializers(this, _instanceExtraInitializers), observable.box(undefined, { deep: false }));
|
|
73
|
+
this.checkMultiple(false);
|
|
74
|
+
}
|
|
75
|
+
getDirectly() {
|
|
76
|
+
return this.child.get();
|
|
77
|
+
}
|
|
78
|
+
isSet() {
|
|
79
|
+
return this.child.get() !== undefined;
|
|
80
|
+
}
|
|
81
|
+
setDirectly(newChild) {
|
|
82
|
+
this.child.set(newChild);
|
|
83
|
+
}
|
|
84
|
+
addDirectly(newChild) {
|
|
85
|
+
const oldChild = this.getDirectly();
|
|
86
|
+
if (oldChild !== undefined) {
|
|
87
|
+
throw new Error(`replacing a child using addDirectly on a value manager for a single-valued containment isn't allowed`); // FIXME unit test this
|
|
88
|
+
}
|
|
89
|
+
this.child.set(newChild);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
(() => {
|
|
93
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
94
|
+
_setDirectly_decorators = [action];
|
|
95
|
+
_addDirectly_decorators = [action];
|
|
96
|
+
__esDecorate(_a, null, _setDirectly_decorators, { kind: "method", name: "setDirectly", static: false, private: false, access: { has: obj => "setDirectly" in obj, get: obj => obj.setDirectly }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
97
|
+
__esDecorate(_a, null, _addDirectly_decorators, { kind: "method", name: "addDirectly", static: false, private: false, access: { has: obj => "addDirectly" in obj, get: obj => obj.addDirectly }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
98
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
99
|
+
})(),
|
|
100
|
+
_a;
|
|
101
|
+
})();
|
|
102
|
+
export { SingleContainmentValueManager };
|
|
103
|
+
let OptionalSingleContainmentValueManager = (() => {
|
|
104
|
+
var _a;
|
|
105
|
+
let _classSuper = SingleContainmentValueManager;
|
|
106
|
+
let _instanceExtraInitializers = [];
|
|
107
|
+
let _set_decorators;
|
|
108
|
+
return _a = class OptionalSingleContainmentValueManager extends _classSuper {
|
|
109
|
+
constructor(containment, container) {
|
|
110
|
+
super(containment, container);
|
|
111
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
112
|
+
this.checkRequired(false);
|
|
113
|
+
}
|
|
114
|
+
get() {
|
|
115
|
+
return this.getDirectly();
|
|
116
|
+
}
|
|
117
|
+
set(newChild) {
|
|
118
|
+
const oldChild = this.getDirectly();
|
|
119
|
+
if (oldChild === undefined) {
|
|
120
|
+
if (newChild === undefined) {
|
|
121
|
+
// do nothing: nothing's changed
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (newChild.parent && newChild.containment) {
|
|
125
|
+
const oldParent = newChild.parent;
|
|
126
|
+
removeFromParent(oldParent, newChild);
|
|
127
|
+
this.emitDelta(() => new ChildMovedDelta(oldParent, newChild.containment, 0, this.container, this.feature, 0, newChild));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.emitDelta(() => new ChildAddedDelta(this.container, this.feature, 0, newChild));
|
|
131
|
+
}
|
|
132
|
+
this.setDirectly(newChild);
|
|
133
|
+
newChild.attachTo(this.container, this.feature);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
if (newChild === undefined) {
|
|
138
|
+
oldChild.detach();
|
|
139
|
+
this.setDirectly(undefined);
|
|
140
|
+
this.emitDelta(() => new ChildDeletedDelta(this.container, this.feature, 0, oldChild));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
if (oldChild === newChild) {
|
|
144
|
+
// do nothing: nothing's changed
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
if (oldChild.parent && oldChild.containment && oldChild.parent === this.container && oldChild.containment === this.feature) {
|
|
148
|
+
// FIXME oldChild.parent COULD be this.container
|
|
149
|
+
this.emitDelta(() => new ChildDeletedDelta(this.container, this.feature, 0, oldChild));
|
|
150
|
+
}
|
|
151
|
+
oldChild.detach();
|
|
152
|
+
if (newChild.parent && newChild.containment) {
|
|
153
|
+
removeFromParent(newChild.parent, newChild);
|
|
154
|
+
}
|
|
155
|
+
this.setDirectly(newChild);
|
|
156
|
+
newChild.attachTo(this.container, this.feature);
|
|
157
|
+
this.emitDelta(() => new ChildReplacedDelta(this.container, this.feature, 0, oldChild, newChild));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
(() => {
|
|
164
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
165
|
+
_set_decorators = [action];
|
|
166
|
+
__esDecorate(_a, null, _set_decorators, { kind: "method", name: "set", static: false, private: false, access: { has: obj => "set" in obj, get: obj => obj.set }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
167
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
168
|
+
})(),
|
|
169
|
+
_a;
|
|
170
|
+
})();
|
|
171
|
+
export { OptionalSingleContainmentValueManager };
|
|
172
|
+
let RequiredSingleContainmentValueManager = (() => {
|
|
173
|
+
var _a;
|
|
174
|
+
let _classSuper = SingleContainmentValueManager;
|
|
175
|
+
let _instanceExtraInitializers = [];
|
|
176
|
+
let _set_decorators;
|
|
177
|
+
return _a = class RequiredSingleContainmentValueManager extends _classSuper {
|
|
178
|
+
constructor(containment, container) {
|
|
179
|
+
super(containment, container);
|
|
180
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
181
|
+
this.checkRequired(true);
|
|
182
|
+
}
|
|
183
|
+
get() {
|
|
184
|
+
const child = this.getDirectly();
|
|
185
|
+
if (child === undefined) {
|
|
186
|
+
this.throwOnReadOfUnset();
|
|
187
|
+
}
|
|
188
|
+
return child;
|
|
189
|
+
}
|
|
190
|
+
set(newChild) {
|
|
191
|
+
const oldChild = this.getDirectly();
|
|
192
|
+
if (oldChild === undefined) {
|
|
193
|
+
if (newChild === undefined) {
|
|
194
|
+
// do nothing: nothing's changed
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
if (newChild.parent && newChild.containment) {
|
|
198
|
+
const oldParent = newChild.parent;
|
|
199
|
+
removeFromParent(oldParent, newChild);
|
|
200
|
+
this.emitDelta(() => new ChildMovedDelta(oldParent, newChild.containment, 0, this.container, this.feature, 0, newChild));
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this.emitDelta(() => new ChildAddedDelta(this.container, this.feature, 0, newChild));
|
|
204
|
+
}
|
|
205
|
+
this.setDirectly(newChild);
|
|
206
|
+
newChild.attachTo(this.container, this.feature);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
if (newChild === undefined) {
|
|
211
|
+
this.throwOnUnset();
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
if (oldChild === newChild) {
|
|
215
|
+
// do nothing: nothing's changed
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
if (oldChild.parent && oldChild.containment && oldChild.parent === this.container && oldChild.containment === this.feature) {
|
|
219
|
+
// FIXME oldChild.parent COULD be this.container
|
|
220
|
+
this.emitDelta(() => new ChildDeletedDelta(this.container, this.feature, 0, oldChild));
|
|
221
|
+
}
|
|
222
|
+
oldChild.detach();
|
|
223
|
+
if (newChild.parent && newChild.containment) {
|
|
224
|
+
removeFromParent(newChild.parent, newChild);
|
|
225
|
+
}
|
|
226
|
+
this.setDirectly(newChild);
|
|
227
|
+
newChild.attachTo(this.container, this.feature);
|
|
228
|
+
this.emitDelta(() => new ChildReplacedDelta(this.container, this.feature, 0, oldChild, newChild));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
(() => {
|
|
235
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
236
|
+
_set_decorators = [action];
|
|
237
|
+
__esDecorate(_a, null, _set_decorators, { kind: "method", name: "set", static: false, private: false, access: { has: obj => "set" in obj, get: obj => obj.set }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
238
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
239
|
+
})(),
|
|
240
|
+
_a;
|
|
241
|
+
})();
|
|
242
|
+
export { RequiredSingleContainmentValueManager };
|
|
243
|
+
let MultiContainmentValueManager = (() => {
|
|
244
|
+
var _a;
|
|
245
|
+
let _classSuper = ContainmentValueManager;
|
|
246
|
+
let _instanceExtraInitializers = [];
|
|
247
|
+
let _addDirectly_decorators;
|
|
248
|
+
let _add_decorators;
|
|
249
|
+
let _insertAtIndexDirectly_decorators;
|
|
250
|
+
let _insertAtIndex_decorators;
|
|
251
|
+
let _removeDirectly_decorators;
|
|
252
|
+
let _moveDirectly_decorators;
|
|
253
|
+
let _move_decorators;
|
|
254
|
+
return _a = class MultiContainmentValueManager extends _classSuper {
|
|
255
|
+
constructor(containment, container) {
|
|
256
|
+
super(containment, container);
|
|
257
|
+
this.children = (__runInitializers(this, _instanceExtraInitializers), observable.array([], { deep: false }));
|
|
258
|
+
this.checkMultiple(true);
|
|
259
|
+
}
|
|
260
|
+
getDirectly() {
|
|
261
|
+
return this.children;
|
|
262
|
+
}
|
|
263
|
+
get() {
|
|
264
|
+
return this.getDirectly().slice();
|
|
265
|
+
}
|
|
266
|
+
isSet() {
|
|
267
|
+
return this.children.length > 0;
|
|
268
|
+
}
|
|
269
|
+
addDirectly(newChild) {
|
|
270
|
+
this.children.push(newChild);
|
|
271
|
+
}
|
|
272
|
+
add(newChild) {
|
|
273
|
+
this.insertAtIndex(newChild, this.getDirectly().length);
|
|
274
|
+
}
|
|
275
|
+
insertAtIndexDirectly(newChild, index) {
|
|
276
|
+
checkIndex(index, this.children.length, true);
|
|
277
|
+
this.children.splice(index, 0, newChild);
|
|
278
|
+
}
|
|
279
|
+
insertAtIndex(newChild, index) {
|
|
280
|
+
this.insertAtIndexDirectly(newChild, index);
|
|
281
|
+
if (newChild.parent === undefined && newChild.containment === undefined) {
|
|
282
|
+
this.emitDelta(() => new ChildAddedDelta(this.container, this.containment, index, newChild));
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
const oldIndex = removeFromParent(newChild.parent, newChild);
|
|
286
|
+
this.emitDelta(() => new ChildMovedDelta(newChild.parent, newChild.containment, oldIndex, this.container, this.containment, index, newChild));
|
|
287
|
+
newChild.detach();
|
|
288
|
+
}
|
|
289
|
+
newChild.attachTo(this.container, this.containment);
|
|
290
|
+
}
|
|
291
|
+
removeDirectly(childToRemove) {
|
|
292
|
+
const children = this.getDirectly();
|
|
293
|
+
const index = children.findIndex((child) => child === childToRemove);
|
|
294
|
+
if (index > -1) {
|
|
295
|
+
children.splice(index, 1);
|
|
296
|
+
return index;
|
|
297
|
+
}
|
|
298
|
+
return -1;
|
|
299
|
+
}
|
|
300
|
+
moveDirectly(oldIndex, newIndex) {
|
|
301
|
+
checkIndex(oldIndex, this.children.length, false);
|
|
302
|
+
checkIndex(newIndex, this.children.length, false);
|
|
303
|
+
if (oldIndex !== newIndex) {
|
|
304
|
+
const [child] = this.children.splice(oldIndex, 1);
|
|
305
|
+
this.children.splice(newIndex, 0, child);
|
|
306
|
+
return child;
|
|
307
|
+
}
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
move(oldIndex, newIndex) {
|
|
311
|
+
const child = this.moveDirectly(oldIndex, newIndex);
|
|
312
|
+
if (child !== undefined) {
|
|
313
|
+
this.emitDelta(() => new ChildMovedInSameContainmentDelta(this.container, this.containment, oldIndex, newIndex, child));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
(() => {
|
|
318
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
319
|
+
_addDirectly_decorators = [action];
|
|
320
|
+
_add_decorators = [action];
|
|
321
|
+
_insertAtIndexDirectly_decorators = [action];
|
|
322
|
+
_insertAtIndex_decorators = [action];
|
|
323
|
+
_removeDirectly_decorators = [action];
|
|
324
|
+
_moveDirectly_decorators = [action];
|
|
325
|
+
_move_decorators = [action];
|
|
326
|
+
__esDecorate(_a, null, _addDirectly_decorators, { kind: "method", name: "addDirectly", static: false, private: false, access: { has: obj => "addDirectly" in obj, get: obj => obj.addDirectly }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
327
|
+
__esDecorate(_a, null, _add_decorators, { kind: "method", name: "add", static: false, private: false, access: { has: obj => "add" in obj, get: obj => obj.add }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
328
|
+
__esDecorate(_a, null, _insertAtIndexDirectly_decorators, { kind: "method", name: "insertAtIndexDirectly", static: false, private: false, access: { has: obj => "insertAtIndexDirectly" in obj, get: obj => obj.insertAtIndexDirectly }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
329
|
+
__esDecorate(_a, null, _insertAtIndex_decorators, { kind: "method", name: "insertAtIndex", static: false, private: false, access: { has: obj => "insertAtIndex" in obj, get: obj => obj.insertAtIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
330
|
+
__esDecorate(_a, null, _removeDirectly_decorators, { kind: "method", name: "removeDirectly", static: false, private: false, access: { has: obj => "removeDirectly" in obj, get: obj => obj.removeDirectly }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
331
|
+
__esDecorate(_a, null, _moveDirectly_decorators, { kind: "method", name: "moveDirectly", static: false, private: false, access: { has: obj => "moveDirectly" in obj, get: obj => obj.moveDirectly }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
332
|
+
__esDecorate(_a, null, _move_decorators, { kind: "method", name: "move", static: false, private: false, access: { has: obj => "move" in obj, get: obj => obj.move }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
333
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
334
|
+
})(),
|
|
335
|
+
_a;
|
|
336
|
+
})();
|
|
337
|
+
export { MultiContainmentValueManager };
|
|
338
|
+
let OptionalMultiContainmentValueManager = (() => {
|
|
339
|
+
var _a;
|
|
340
|
+
let _classSuper = MultiContainmentValueManager;
|
|
341
|
+
let _instanceExtraInitializers = [];
|
|
342
|
+
let _remove_decorators;
|
|
343
|
+
return _a = class OptionalMultiContainmentValueManager extends _classSuper {
|
|
344
|
+
constructor(containment, container) {
|
|
345
|
+
super(containment, container);
|
|
346
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
347
|
+
this.checkRequired(false);
|
|
348
|
+
}
|
|
349
|
+
remove(childToRemove) {
|
|
350
|
+
const children = this.getDirectly();
|
|
351
|
+
const index = children.findIndex((child) => child === childToRemove);
|
|
352
|
+
if (index > -1) {
|
|
353
|
+
children.splice(index, 1);
|
|
354
|
+
childToRemove.detach();
|
|
355
|
+
this.emitDelta(() => new ChildDeletedDelta(this.container, this.containment, index, childToRemove));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
(() => {
|
|
360
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
361
|
+
_remove_decorators = [action];
|
|
362
|
+
__esDecorate(_a, null, _remove_decorators, { kind: "method", name: "remove", static: false, private: false, access: { has: obj => "remove" in obj, get: obj => obj.remove }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
363
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
364
|
+
})(),
|
|
365
|
+
_a;
|
|
366
|
+
})();
|
|
367
|
+
export { OptionalMultiContainmentValueManager };
|
|
368
|
+
let RequiredMultiContainmentValueManager = (() => {
|
|
369
|
+
var _a;
|
|
370
|
+
let _classSuper = MultiContainmentValueManager;
|
|
371
|
+
let _instanceExtraInitializers = [];
|
|
372
|
+
let _remove_decorators;
|
|
373
|
+
return _a = class RequiredMultiContainmentValueManager extends _classSuper {
|
|
374
|
+
constructor(containment, container) {
|
|
375
|
+
super(containment, container);
|
|
376
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
377
|
+
this.checkRequired(true);
|
|
378
|
+
}
|
|
379
|
+
get() {
|
|
380
|
+
const children = this.getDirectly();
|
|
381
|
+
if (children.length === 0) {
|
|
382
|
+
this.throwOnReadOfUnset();
|
|
383
|
+
}
|
|
384
|
+
return children;
|
|
385
|
+
}
|
|
386
|
+
remove(childToRemove) {
|
|
387
|
+
const children = this.getDirectly();
|
|
388
|
+
const index = children.findIndex((child) => child === childToRemove);
|
|
389
|
+
if (index > -1) {
|
|
390
|
+
if (children.length === 1) {
|
|
391
|
+
this.throwOnUnset();
|
|
392
|
+
}
|
|
393
|
+
children.splice(index, 1);
|
|
394
|
+
childToRemove.detach();
|
|
395
|
+
this.emitDelta(() => new ChildDeletedDelta(this.container, this.containment, index, childToRemove));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
(() => {
|
|
400
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
401
|
+
_remove_decorators = [action];
|
|
402
|
+
__esDecorate(_a, null, _remove_decorators, { kind: "method", name: "remove", static: false, private: false, access: { has: obj => "remove" in obj, get: obj => obj.remove }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
403
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
404
|
+
})(),
|
|
405
|
+
_a;
|
|
406
|
+
})();
|
|
407
|
+
export { RequiredMultiContainmentValueManager };
|
|
408
|
+
//# sourceMappingURL=containments.js.map
|