@lionweb/class-core 0.6.13-beta.0 → 0.6.13-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/base-types.d.ts +9 -1
- package/dist/base-types.d.ts.map +1 -1
- package/dist/base-types.js +18 -3
- package/dist/base-types.js.map +1 -1
- package/dist/utils.d.ts +6 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +22 -0
- package/dist/utils.js.map +1 -0
- package/package.json +3 -3
- package/src/base-types.ts +31 -5
- package/src/utils.ts +24 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.6.13
|
|
4
|
+
|
|
5
|
+
* Add a getter `referenceTargets` to `INodeBase` that – like the `children` getter for containments – returns an array of all nodes targeted by reference features (direct and inherited) of the classifier of the node.
|
|
6
|
+
*Note* that these getters are (in principle) meant *for internal use only*!
|
|
7
|
+
|
package/dist/base-types.d.ts
CHANGED
|
@@ -97,9 +97,16 @@ export interface INodeBase extends Node {
|
|
|
97
97
|
get setFeatures(): Feature[];
|
|
98
98
|
/**
|
|
99
99
|
* @return all children – not all descendants! – of this node, including directly-contained annotations.
|
|
100
|
-
*
|
|
100
|
+
* Children appear uniquely, but their order is *not* guaranteed.
|
|
101
|
+
* *Note* that this is (in principle) **for internal use only**!
|
|
101
102
|
*/
|
|
102
103
|
get children(): INodeBase[];
|
|
104
|
+
/**
|
|
105
|
+
* @return all nodes targeted by reference values on this node.
|
|
106
|
+
* Reference targets appear uniquely, but their order is *not* guaranteed.
|
|
107
|
+
* *Note* that this is (in principle) **for internal use only**!
|
|
108
|
+
*/
|
|
109
|
+
get referenceTargets(): INodeBase[];
|
|
103
110
|
/**
|
|
104
111
|
* An optionally-installed {@link DeltaHandler}.
|
|
105
112
|
*/
|
|
@@ -136,6 +143,7 @@ export declare abstract class NodeBase implements INodeBase {
|
|
|
136
143
|
getFeatureValueManager(feature: Feature): FeatureValueManager<Feature>;
|
|
137
144
|
get setFeatures(): Feature[];
|
|
138
145
|
get children(): INodeBase[];
|
|
146
|
+
get referenceTargets(): INodeBase[];
|
|
139
147
|
readonly annotationsValueManager: AnnotationsValueManager;
|
|
140
148
|
get annotations(): INodeBase[];
|
|
141
149
|
addAnnotation(annotation: INodeBase): void;
|
package/dist/base-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-types.d.ts","sourceRoot":"","sources":["../src/base-types.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEH,UAAU,EAGV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,EAAE,EACF,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,SAAS,EACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,
|
|
1
|
+
{"version":3,"file":"base-types.d.ts","sourceRoot":"","sources":["../src/base-types.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEH,UAAU,EAGV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,EAAE,EACF,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,SAAS,EACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,EAGnB,oBAAoB,EACpB,qBAAqB,EAGxB,MAAM,YAAY,CAAA;AAInB;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,GAAG,IAAI,CAAE,CAAC;AAGrF;;;;;GAKG;AACH,MAAM,WAAW,SAAU,SAAQ,IAAI;IAEnC,UAAU,EAAE,UAAU,CAAC;IAEvB;;;;OAIG;IACH,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAE9B;;;;OAIG;IACH,WAAW,EAAE,WAAW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C,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;IAI5D,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAIjD,wBAAwB,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;IAI7D,gBAAgB,CAAC,UAAU,EAAE,SAAS;CAIzC;AAGD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,SAAS,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,CAAC,WAAW,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC;IACrD,eAAe,CAAC,CAAC,EAAE,kBAAkB,EAAE,kBAAkB,GAAG,CAAC,CAAC;CACjE;AAGD;;GAEG;AACH,eAAO,MAAM,gBAAgB,WAAY,SAAS,GAAG,SAAS,SAAS,SAAS,KAAG,MAmBlF,CAAA"}
|
package/dist/base-types.js
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
import { allFeaturesOf, Containment, Property, Reference } from "@lionweb/core";
|
|
18
18
|
import { makeObservable } from "mobx";
|
|
19
|
-
import { AnnotationsValueManager, MultiContainmentValueManager, SingleContainmentValueManager } from "./index.js";
|
|
19
|
+
import { AnnotationsValueManager, MultiContainmentValueManager, MultiReferenceValueManager, SingleContainmentValueManager, SingleReferenceValueManager } from "./index.js";
|
|
20
|
+
import { uniquesAmong } from "./utils.js";
|
|
20
21
|
/**
|
|
21
22
|
* The base type for any node that's managed by a, potentially delta-emitting, API.
|
|
22
23
|
*
|
|
@@ -84,7 +85,7 @@ export class NodeBase {
|
|
|
84
85
|
.filter((feature) => this.getFeatureValueManager(feature).isSet());
|
|
85
86
|
}
|
|
86
87
|
get children() {
|
|
87
|
-
return [
|
|
88
|
+
return uniquesAmong([
|
|
88
89
|
...(this.setFeatures
|
|
89
90
|
.filter((feature) => feature instanceof Containment)
|
|
90
91
|
.flatMap((feature) => {
|
|
@@ -98,7 +99,21 @@ export class NodeBase {
|
|
|
98
99
|
throw new Error(`don't know how to obtain value of feature ${feature.name} of classifier ${this.classifier.name} in language ${this.classifier.language.name}`);
|
|
99
100
|
})),
|
|
100
101
|
...this.annotations
|
|
101
|
-
];
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
get referenceTargets() {
|
|
105
|
+
return uniquesAmong(this.setFeatures
|
|
106
|
+
.filter((feature) => feature instanceof Reference)
|
|
107
|
+
.flatMap((feature) => {
|
|
108
|
+
const valueManager = this.getReferenceValueManager(feature);
|
|
109
|
+
if (valueManager instanceof SingleReferenceValueManager) {
|
|
110
|
+
return valueManager.isSet() ? [valueManager.getDirectly()] : [];
|
|
111
|
+
}
|
|
112
|
+
if (valueManager instanceof MultiReferenceValueManager) {
|
|
113
|
+
return valueManager.get();
|
|
114
|
+
}
|
|
115
|
+
throw new Error(`don't know how to obtain value of feature ${feature.name} of classifier ${this.classifier.name} in language ${this.classifier.language.name}`);
|
|
116
|
+
}));
|
|
102
117
|
}
|
|
103
118
|
get annotations() {
|
|
104
119
|
return this.annotationsValueManager.get();
|
package/dist/base-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-types.js","sourceRoot":"","sources":["../src/base-types.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,EACH,aAAa,EAIb,WAAW,EAMX,QAAQ,EACR,SAAS,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,cAAc,EAAC,M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@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
/**
|
|
18
|
+
* @return a view of the given array of items with duplicates removed.
|
|
19
|
+
* *Note*: verbatim copy of a function in @lionweb/utilities/utils/array.ts!
|
|
20
|
+
*/
|
|
21
|
+
export const uniquesAmong = (ts) => [...new Set(ts)];
|
|
22
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.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;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,EAAO,EAAO,EAAE,CAC5C,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/class-core",
|
|
3
|
-
"version": "0.6.13-beta.
|
|
3
|
+
"version": "0.6.13-beta.2",
|
|
4
4
|
"description": "Generic, language-aspecific base types for generated TypeScript APIs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"clean": "rm -rf dist/ node_modules/",
|
|
18
|
+
"clean": "rm -rf dist/ node_modules/ lionweb-class-core-*.tgz",
|
|
19
19
|
"build": "rm -rf dist && tsc",
|
|
20
20
|
"lint": "eslint src",
|
|
21
21
|
"pre-release-either": "npm run clean && npm install && npm run build",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"release-beta": "npm publish --tag beta"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lionweb/core": "0.6.13-beta.
|
|
28
|
+
"@lionweb/core": "0.6.13-beta.2",
|
|
29
29
|
"littoral-templates": "0.3.0",
|
|
30
30
|
"mobx": "6.13.7"
|
|
31
31
|
},
|
package/src/base-types.ts
CHANGED
|
@@ -37,10 +37,13 @@ import {
|
|
|
37
37
|
DeltaHandler,
|
|
38
38
|
FeatureValueManager,
|
|
39
39
|
MultiContainmentValueManager,
|
|
40
|
+
MultiReferenceValueManager,
|
|
40
41
|
PropertyValueManager,
|
|
41
42
|
ReferenceValueManager,
|
|
42
|
-
SingleContainmentValueManager
|
|
43
|
-
|
|
43
|
+
SingleContainmentValueManager,
|
|
44
|
+
SingleReferenceValueManager
|
|
45
|
+
} from "./index.js"
|
|
46
|
+
import {uniquesAmong} from "./utils.js"
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
/**
|
|
@@ -163,10 +166,17 @@ export interface INodeBase extends Node {
|
|
|
163
166
|
|
|
164
167
|
/**
|
|
165
168
|
* @return all children – not all descendants! – of this node, including directly-contained annotations.
|
|
166
|
-
*
|
|
169
|
+
* Children appear uniquely, but their order is *not* guaranteed.
|
|
170
|
+
* *Note* that this is (in principle) **for internal use only**!
|
|
167
171
|
*/
|
|
168
172
|
get children(): INodeBase[];
|
|
169
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @return all nodes targeted by reference values on this node.
|
|
176
|
+
* Reference targets appear uniquely, but their order is *not* guaranteed.
|
|
177
|
+
* *Note* that this is (in principle) **for internal use only**!
|
|
178
|
+
*/
|
|
179
|
+
get referenceTargets(): INodeBase[];
|
|
170
180
|
|
|
171
181
|
/**
|
|
172
182
|
* An optionally-installed {@link DeltaHandler}.
|
|
@@ -262,7 +272,7 @@ export abstract class NodeBase implements INodeBase {
|
|
|
262
272
|
}
|
|
263
273
|
|
|
264
274
|
get children(): INodeBase[] {
|
|
265
|
-
return [
|
|
275
|
+
return uniquesAmong([
|
|
266
276
|
...(this.setFeatures
|
|
267
277
|
.filter((feature) => feature instanceof Containment)
|
|
268
278
|
.flatMap((feature) => {
|
|
@@ -276,9 +286,25 @@ export abstract class NodeBase implements INodeBase {
|
|
|
276
286
|
throw new Error(`don't know how to obtain value of feature ${feature.name} of classifier ${this.classifier.name} in language ${this.classifier.language.name}`);
|
|
277
287
|
})),
|
|
278
288
|
...this.annotations
|
|
279
|
-
];
|
|
289
|
+
]);
|
|
280
290
|
}
|
|
281
291
|
|
|
292
|
+
get referenceTargets(): INodeBase[] {
|
|
293
|
+
return uniquesAmong(
|
|
294
|
+
this.setFeatures
|
|
295
|
+
.filter((feature) => feature instanceof Reference)
|
|
296
|
+
.flatMap((feature) => {
|
|
297
|
+
const valueManager = this.getReferenceValueManager(feature as Reference);
|
|
298
|
+
if (valueManager instanceof SingleReferenceValueManager) {
|
|
299
|
+
return valueManager.isSet() ? [valueManager.getDirectly()] : [];
|
|
300
|
+
}
|
|
301
|
+
if (valueManager instanceof MultiReferenceValueManager) {
|
|
302
|
+
return valueManager.get();
|
|
303
|
+
}
|
|
304
|
+
throw new Error(`don't know how to obtain value of feature ${feature.name} of classifier ${this.classifier.name} in language ${this.classifier.language.name}`);
|
|
305
|
+
})
|
|
306
|
+
);
|
|
307
|
+
}
|
|
282
308
|
|
|
283
309
|
readonly annotationsValueManager: AnnotationsValueManager = new AnnotationsValueManager(this);
|
|
284
310
|
get annotations(): INodeBase[] {
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* @return a view of the given array of items with duplicates removed.
|
|
20
|
+
* *Note*: verbatim copy of a function in @lionweb/utilities/utils/array.ts!
|
|
21
|
+
*/
|
|
22
|
+
export const uniquesAmong = <T>(ts: T[]): T[] =>
|
|
23
|
+
[...new Set(ts)]
|
|
24
|
+
|