@lionweb/core 0.7.0-beta.20 → 0.7.0-beta.21
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/dist/m3/feature-resolvers.d.ts.map +1 -1
- package/dist/m3/feature-resolvers.js +16 -0
- package/dist/m3/feature-resolvers.js.map +1 -1
- package/dist/m3/symbol-table.d.ts +7 -2
- package/dist/m3/symbol-table.d.ts.map +1 -1
- package/dist/m3/symbol-table.js +12 -7
- package/dist/m3/symbol-table.js.map +1 -1
- package/dist/serializer.d.ts +1 -1
- package/dist/serializer.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/writing.js +1 -1
- package/package.json +3 -3
- package/src/m3/feature-resolvers.ts +17 -0
- package/src/m3/symbol-table.ts +8 -2
- package/src/serializer.ts +1 -1
- package/src/version.ts +1 -1
- package/src/writing.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-resolvers.d.ts","sourceRoot":"","sources":["../../src/m3/feature-resolvers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"feature-resolvers.d.ts","sourceRoot":"","sources":["../../src/m3/feature-resolvers.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAI5F;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,EAAE,SAAS,OAAO,IAAI,CAAC,WAAW,EAAE,sBAAsB,EAAE,UAAU,EAAE,UAAU,KAAK,EAAE,CAAA;AAErH;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B,oBAAoB,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IAC/C,uBAAuB,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;IACrD,qBAAqB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;CACpD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,WAAW,QAAQ,EAAE,KAAG,gBA0B3D,CAAA"}
|
|
@@ -1,3 +1,19 @@
|
|
|
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
|
|
1
17
|
import { Containment, Property, Reference } from "./types.js";
|
|
2
18
|
import { MemoisingSymbolTable } from "./symbol-table.js";
|
|
3
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-resolvers.js","sourceRoot":"","sources":["../../src/m3/feature-resolvers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"feature-resolvers.js","sourceRoot":"","sources":["../../src/m3/feature-resolvers.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;AAItC,OAAO,EAAc,WAA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AAC,SAAS,CAAC;KACvD,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -19,11 +19,16 @@ interface SymbolTable {
|
|
|
19
19
|
* Looks up the {@link Feature}, as pointed to by the {@link LionWebJsonMetaPointer} given second,
|
|
20
20
|
* as a feature of the {@link Classifier}, as pointed to by the {@link LionWebJsonMetaPointer} given first,
|
|
21
21
|
* or {@code undefined} it it couldn't be found.
|
|
22
|
-
*
|
|
22
|
+
* *Note* that the {@code language} and {@code version} values of both {@link LionWebJsonMetaPointer}-typed arguments should coincide,
|
|
23
23
|
* although this is typically not checked!
|
|
24
24
|
*/
|
|
25
25
|
featureMatching(entityMetaPointer: LionWebJsonMetaPointer, featureMetaPointer: LionWebJsonMetaPointer): Feature | undefined;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A {@link SymbolTable} implementation that *memoises* the items it has looked up.
|
|
29
|
+
* This helps with performance, because otherwise lookup might be linear in the (max.) number of languages,
|
|
30
|
+
* entities in a language, features in classifiers — taking inheritance into account.
|
|
31
|
+
*/
|
|
27
32
|
declare class MemoisingSymbolTable implements SymbolTable {
|
|
28
33
|
private readonly languages;
|
|
29
34
|
constructor(languages: Language[]);
|
|
@@ -37,7 +42,7 @@ declare class MemoisingSymbolTable implements SymbolTable {
|
|
|
37
42
|
* and @returns all its {@link Feature features} or an empty array if it couldn't be found.
|
|
38
43
|
*/
|
|
39
44
|
allFeaturesOfEntityMatching: (entityMetaPointer: LionWebJsonMetaPointer) => Feature[];
|
|
40
|
-
featureMatching(classifierMetaPointer: LionWebJsonMetaPointer, featureMetaPointer: LionWebJsonMetaPointer)
|
|
45
|
+
featureMatching: (classifierMetaPointer: LionWebJsonMetaPointer, featureMetaPointer: LionWebJsonMetaPointer) => Feature | undefined;
|
|
41
46
|
}
|
|
42
47
|
export type { SymbolTable };
|
|
43
48
|
export { MemoisingSymbolTable };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-table.d.ts","sourceRoot":"","sources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O,CAAC,QAAQ,CAAC,4BAA4B,CAAqE;IAElH,gBAAgB,GAAI,aAAa,UAAU,EAAE,SAAS,MAAM,KAAG,QAAQ,GAAG,SAAS,CAQ9E;IAGL,OAAO,CAAC,QAAQ,CAAC,wCAAwC,CAAkH;IAE3K,OAAO,CAAC,kBAAkB,CAmBrB;IAEL,cAAc,GAAI,mBAAmB,sBAAsB,KAAG,cAAc,GAAG,SAAS,CAClC;IAEtD;;;OAGG;IACH,2BAA2B,GAAI,mBAAmB,sBAAsB,KAAG,OAAO,EAAE,CACnB;IAEjE,eAAe,GAAI,uBAAuB,sBAAsB,EAAE,oBAAoB,sBAAsB,KAAG,OAAO,GAAG,SAAS,CAUjI;CAEJ;AAGD,YAAY,EACR,WAAW,EACd,CAAA;AAED,OAAO,EACH,oBAAoB,EACvB,CAAA"}
|
package/dist/m3/symbol-table.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { lazyMapGet } from "@lionweb/ts-utils";
|
|
2
2
|
import { allFeaturesOf } from "./functions.js";
|
|
3
3
|
import { Classifier } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* A {@link SymbolTable} implementation that *memoises* the items it has looked up.
|
|
6
|
+
* This helps with performance, because otherwise lookup might be linear in the (max.) number of languages,
|
|
7
|
+
* entities in a language, features in classifiers — taking inheritance into account.
|
|
8
|
+
*/
|
|
4
9
|
class MemoisingSymbolTable {
|
|
5
10
|
constructor(languages) {
|
|
6
11
|
this.languageKey2version2language = {};
|
|
@@ -24,15 +29,15 @@ class MemoisingSymbolTable {
|
|
|
24
29
|
* and @returns all its {@link Feature features} or an empty array if it couldn't be found.
|
|
25
30
|
*/
|
|
26
31
|
this.allFeaturesOfEntityMatching = (entityMetaPointer) => this.entityInfoMatching(entityMetaPointer)?.allFeatures ?? [];
|
|
32
|
+
this.featureMatching = (classifierMetaPointer, featureMetaPointer) => {
|
|
33
|
+
const entityInfo = this.entityInfoMatching(classifierMetaPointer);
|
|
34
|
+
if (entityInfo === undefined || !(entityInfo.entity instanceof Classifier)) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return lazyMapGet(entityInfo.featureKey2feature, featureMetaPointer.key, () => entityInfo.allFeatures.find((feature) => feature.key === featureMetaPointer.key));
|
|
38
|
+
};
|
|
27
39
|
this.languages = languages;
|
|
28
40
|
}
|
|
29
|
-
featureMatching(classifierMetaPointer, featureMetaPointer) {
|
|
30
|
-
const entityInfo = this.entityInfoMatching(classifierMetaPointer);
|
|
31
|
-
if (entityInfo === undefined || !(entityInfo.entity instanceof Classifier)) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
return lazyMapGet(entityInfo.featureKey2feature, featureMetaPointer.key, () => entityInfo.allFeatures.find((feature) => feature.key === featureMetaPointer.key));
|
|
35
|
-
}
|
|
36
41
|
}
|
|
37
42
|
export { MemoisingSymbolTable };
|
|
38
43
|
//# sourceMappingURL=symbol-table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-table.js","sourceRoot":"","sources":["../../src/m3/symbol-table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAqC,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"symbol-table.js","sourceRoot":"","sources":["../../src/m3/symbol-table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAqC,MAAM,YAAY,CAAA;AAwC1E;;;;GAIG;AACH,MAAM,oBAAoB;IAItB,YAAY,SAAqB;QAIhB,iCAA4B,GAAmE,EAAE,CAAA;QAElH,qBAAgB,GAAG,CAAC,WAAuB,EAAE,OAAe,EAAwB,EAA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AEtD;;;WAGG;QACH,gCAA2B,GAAG,CAAC,iBAAyC,EAAa,EAAE,CACnF,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,EAAE,WAAW,IAAI,EAAE,CAAA;QAEjE,oBAAe,GAAG,CAAC,qBAA6C,EAAE,kBAA0C,EAAuB,EAAE;YACjI,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,CAAA;YACjE,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,YAAY,UAAU,CAAC,EAAE,CAAC;gBACzE,OAAO,SAAS,CAAA;YACpB,CAAC;YACD,OAAO,UAAU,CACb,UAAU,CAAC,kBAAkB,EAC7B,kBAAkB,CAAC,GAAG,EACtB,GAAG,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,KAAK,kBAAkB,CAAC,GAAG,CAAC,CACzF,CAAA;QACL,CAAC,CAAA;QA3DG,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC9B,CAAC;CA4DJ;AAOD,OAAO,EACH,oBAAoB,EACvB,CAAA"}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare const metaPointerFor: (feature: Feature) => LionWebJsonMetaPointe
|
|
|
43
43
|
export declare const nodeSerializer: <NT extends Node>(reader: Reader<NT>, serializationOptions?: SerializationOptions) => (nodes: NT[]) => LionWebJsonChunk;
|
|
44
44
|
/**
|
|
45
45
|
* @return a {@link LionWebJsonChunk} of the given model (i.e., an array of {@link Node nodes} - the first argument) to the LionWeb serialization JSON format.
|
|
46
|
-
*
|
|
46
|
+
* *Note:* this function will be deprecated and removed later — use {@link nodeSerializer} instead.
|
|
47
47
|
*/
|
|
48
48
|
export declare const serializeNodes: <NT extends Node>(nodes: NT[], reader: Reader<NT>, propertyValueSerializerOrOptions?: PropertyValueSerializer | SerializationOptions) => LionWebJsonChunk;
|
|
49
49
|
//# sourceMappingURL=serializer.d.ts.map
|
package/dist/serializer.js
CHANGED
|
@@ -138,7 +138,7 @@ export const nodeSerializer = (reader, serializationOptions) => {
|
|
|
138
138
|
};
|
|
139
139
|
/**
|
|
140
140
|
* @return a {@link LionWebJsonChunk} of the given model (i.e., an array of {@link Node nodes} - the first argument) to the LionWeb serialization JSON format.
|
|
141
|
-
*
|
|
141
|
+
* *Note:* this function will be deprecated and removed later — use {@link nodeSerializer} instead.
|
|
142
142
|
*/
|
|
143
143
|
export const serializeNodes = (nodes, reader, propertyValueSerializerOrOptions) => nodeSerializer(reader, isPropertyValueSerializer(propertyValueSerializerOrOptions)
|
|
144
144
|
? {
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/dist/writing.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Link } from "./m3/types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* @return a {@link SettingsUpdater} that uses the given “meta key” – which is a property/key on the {@link Feature} type –
|
|
4
4
|
* to look up what key to look a feature’s value up on a settings object.
|
|
5
|
-
*
|
|
5
|
+
* *Note:* for internal use only — use with some care!
|
|
6
6
|
*/
|
|
7
7
|
const settingsUpdater = (metaKey) => (settings, feature, value) => {
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/core",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.21",
|
|
4
4
|
"description": "LionWeb core for {Java|Type}Script",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"release": "npm publish"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@lionweb/json": "0.7.0-beta.
|
|
31
|
-
"@lionweb/ts-utils": "0.7.0-beta.
|
|
30
|
+
"@lionweb/json": "0.7.0-beta.21",
|
|
31
|
+
"@lionweb/ts-utils": "0.7.0-beta.21"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,3 +1,20 @@
|
|
|
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
|
+
|
|
1
18
|
import { LionWebJsonMetaPointer } from "@lionweb/json"
|
|
2
19
|
|
|
3
20
|
import { Classifier, Containment, Feature, Language, Property, Reference } from "./types.js"
|
package/src/m3/symbol-table.ts
CHANGED
|
@@ -26,7 +26,7 @@ interface SymbolTable {
|
|
|
26
26
|
* Looks up the {@link Feature}, as pointed to by the {@link LionWebJsonMetaPointer} given second,
|
|
27
27
|
* as a feature of the {@link Classifier}, as pointed to by the {@link LionWebJsonMetaPointer} given first,
|
|
28
28
|
* or {@code undefined} it it couldn't be found.
|
|
29
|
-
*
|
|
29
|
+
* *Note* that the {@code language} and {@code version} values of both {@link LionWebJsonMetaPointer}-typed arguments should coincide,
|
|
30
30
|
* although this is typically not checked!
|
|
31
31
|
*/
|
|
32
32
|
featureMatching(entityMetaPointer: LionWebJsonMetaPointer, featureMetaPointer: LionWebJsonMetaPointer): Feature | undefined
|
|
@@ -40,6 +40,12 @@ type EntityInfo = {
|
|
|
40
40
|
featureKey2feature: { [featureKey: LionWebKey]: Feature } // populated through memoisation
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A {@link SymbolTable} implementation that *memoises* the items it has looked up.
|
|
46
|
+
* This helps with performance, because otherwise lookup might be linear in the (max.) number of languages,
|
|
47
|
+
* entities in a language, features in classifiers — taking inheritance into account.
|
|
48
|
+
*/
|
|
43
49
|
class MemoisingSymbolTable implements SymbolTable {
|
|
44
50
|
|
|
45
51
|
private readonly languages: Language[]
|
|
@@ -94,7 +100,7 @@ class MemoisingSymbolTable implements SymbolTable {
|
|
|
94
100
|
allFeaturesOfEntityMatching = (entityMetaPointer: LionWebJsonMetaPointer): Feature[] =>
|
|
95
101
|
this.entityInfoMatching(entityMetaPointer)?.allFeatures ?? []
|
|
96
102
|
|
|
97
|
-
featureMatching(classifierMetaPointer: LionWebJsonMetaPointer, featureMetaPointer: LionWebJsonMetaPointer): Feature | undefined {
|
|
103
|
+
featureMatching = (classifierMetaPointer: LionWebJsonMetaPointer, featureMetaPointer: LionWebJsonMetaPointer): Feature | undefined => {
|
|
98
104
|
const entityInfo = this.entityInfoMatching(classifierMetaPointer)
|
|
99
105
|
if (entityInfo === undefined || !(entityInfo.entity instanceof Classifier)) {
|
|
100
106
|
return undefined
|
package/src/serializer.ts
CHANGED
|
@@ -226,7 +226,7 @@ export const nodeSerializer = <NT extends Node>(reader: Reader<NT>, serializatio
|
|
|
226
226
|
|
|
227
227
|
/**
|
|
228
228
|
* @return a {@link LionWebJsonChunk} of the given model (i.e., an array of {@link Node nodes} - the first argument) to the LionWeb serialization JSON format.
|
|
229
|
-
*
|
|
229
|
+
* *Note:* this function will be deprecated and removed later — use {@link nodeSerializer} instead.
|
|
230
230
|
*/
|
|
231
231
|
export const serializeNodes = <NT extends Node>(
|
|
232
232
|
nodes: NT[],
|
package/src/version.ts
CHANGED
package/src/writing.ts
CHANGED
|
@@ -49,7 +49,7 @@ export type SettingsUpdater = (settings: Record<string, unknown>, feature: Featu
|
|
|
49
49
|
/**
|
|
50
50
|
* @return a {@link SettingsUpdater} that uses the given “meta key” – which is a property/key on the {@link Feature} type –
|
|
51
51
|
* to look up what key to look a feature’s value up on a settings object.
|
|
52
|
-
*
|
|
52
|
+
* *Note:* for internal use only — use with some care!
|
|
53
53
|
*/
|
|
54
54
|
const settingsUpdater = (metaKey: keyof Feature): SettingsUpdater =>
|
|
55
55
|
(settings: Record<string, unknown>, feature: Feature, value: unknown): void => {
|