@lionweb/class-core 0.7.2 → 0.8.0-beta.1
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 +15 -0
- package/dist/base-types.d.ts +10 -1
- package/dist/base-types.d.ts.map +1 -1
- package/dist/deltas/serialization/base.d.ts +8 -0
- package/dist/deltas/serialization/base.d.ts.map +1 -1
- package/dist/deltas/serialization/base.js +8 -1
- package/dist/deltas/serialization/base.js.map +1 -1
- package/dist/deltas/serialization/serializer.g.d.ts.map +1 -1
- package/dist/deltas/serialization/serializer.g.js +2 -1
- package/dist/deltas/serialization/serializer.g.js.map +1 -1
- package/dist/deltas/serialization/types.g.d.ts +1 -1
- package/dist/deltas/serialization/types.g.d.ts.map +1 -1
- package/dist/deserializer.d.ts +29 -4
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +14 -20
- package/dist/deserializer.js.map +1 -1
- package/dist/forest.d.ts +67 -0
- package/dist/forest.d.ts.map +1 -0
- package/dist/forest.js +109 -0
- package/dist/forest.js.map +1 -0
- package/dist/id-mapping.d.ts +5 -3
- package/dist/id-mapping.d.ts.map +1 -1
- package/dist/id-mapping.js +2 -1
- package/dist/id-mapping.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/linking.d.ts +2 -2
- package/dist/references.d.ts +12 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/{deltas/serialization/serializer-helpers.js → references.js} +3 -10
- package/dist/references.js.map +1 -0
- package/package.json +4 -4
- package/src/base-types.ts +12 -1
- package/src/deltas/serialization/base.ts +10 -0
- package/src/deltas/serialization/serializer.g.ts +2 -1
- package/src/deltas/serialization/types.g.ts +1 -1
- package/src/deserializer.ts +44 -22
- package/src/forest.ts +173 -0
- package/src/id-mapping.ts +6 -4
- package/src/index.ts +3 -0
- package/src/linking.ts +2 -2
- package/src/{deltas/serialization/serializer-helpers.ts → references.ts} +8 -8
- package/dist/deltas/serialization/serializer-helpers.d.ts +0 -15
- package/dist/deltas/serialization/serializer-helpers.d.ts.map +0 -1
- package/dist/deltas/serialization/serializer-helpers.js.map +0 -1
package/dist/id-mapping.js
CHANGED
|
@@ -63,7 +63,8 @@ export class IdMapping {
|
|
|
63
63
|
this.nodesById = nodesById;
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
|
-
* Merges the given `that` {@link IdMapping} **in**to `this
|
|
66
|
+
* Merges the given `that` {@link IdMapping} **in**to `this`,
|
|
67
|
+
* overwriting any previous mappings in `this`.
|
|
67
68
|
*/
|
|
68
69
|
this.mergeIn = (that) => {
|
|
69
70
|
for (const id in that.nodesById) {
|
package/dist/id-mapping.js.map
CHANGED
|
@@ -1 +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,
|
|
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,EAAa,UAAU,EAAE,MAAM,eAAe,CAAA;AAarD;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAGlB,YAAY,SAAoB;QAGhC,iEAAiE;QAEjE;;;WAGG;QACH,WAAM,GAAG,CAAC,EAAa,EAAa,EAAE;YAClC,IAAI,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC9B,CAAC,CAAA;QAED;;;WAGG;QACH,cAAS,GAAG,CAAC,EAAa,EAA2B,EAAE,CACnD,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAEvB;;;WAGG;QACH,cAAS,GAAG,CAAC,cAA8B,EAAwB,EAAE,CACjE,cAAc,KAAK,UAAU;YACzB,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,UAAU,CAAC,CAAC;QAEzD;;WAEG;QACH,eAAU,GAAG,CAAC,IAAe,EAAE,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAG,4BAA4B;iBACvC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,iGAAiG;QACrG,CAAC,CAAA;QAED;;;;WAIG;QACH,qBAAgB,GAAG,CAAC,SAAoB,EAAE,EAAE;YACxC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC/B,CAAC,CAAA;QAED;;;WAGG;QACH,YAAO,GAAG,CAAC,IAAe,EAAE,EAAE;YAC1B,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC9B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC,CAAA;QA1DG,IAAI,CAAC,SAAS,GAAG,EAAC,GAAG,SAAS,EAAC,CAAC;IACpC,CAAC;CA2DJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,10 @@ export * from "./deserializer.js";
|
|
|
5
5
|
export { deepDuplicateWith } from "./duplicator.js";
|
|
6
6
|
export * from "./id-mapping.js";
|
|
7
7
|
export { combinedFactoryFor } from "./factory.js";
|
|
8
|
+
export { Forest, ObservableForest } from "./forest.js";
|
|
8
9
|
export * from "./LionCore_builtins.g.js";
|
|
10
|
+
export type { IdOrUnresolved } from "./references.js";
|
|
11
|
+
export { idFrom } from "./references.js";
|
|
9
12
|
export { propertyValueSerializerWith, serializeNodeBases } from "./serializer.js";
|
|
10
13
|
export { asTreeTextWith } from "./textualizer.js";
|
|
11
14
|
export * from "./value-managers/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
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,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvD,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,8 +21,10 @@ export * from "./deserializer.js";
|
|
|
21
21
|
export { deepDuplicateWith } from "./duplicator.js";
|
|
22
22
|
export * from "./id-mapping.js";
|
|
23
23
|
export { combinedFactoryFor } from "./factory.js";
|
|
24
|
+
export { Forest, ObservableForest } from "./forest.js";
|
|
24
25
|
// skip linking.js: see comment there
|
|
25
26
|
export * from "./LionCore_builtins.g.js";
|
|
27
|
+
export { idFrom } from "./references.js";
|
|
26
28
|
export { propertyValueSerializerWith, serializeNodeBases } from "./serializer.js";
|
|
27
29
|
export { asTreeTextWith } from "./textualizer.js";
|
|
28
30
|
export * from "./value-managers/index.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,qCAAqC;AACrC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
|
|
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,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvD,qCAAqC;AACrC,cAAc,0BAA0B,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
|
package/dist/linking.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ import { INodeBase } from "./index.js";
|
|
|
11
11
|
* 2. `feature` — the {@link Link link} feature to install on, or `null` to indicate that it's an annotation.
|
|
12
12
|
* 3. `nodesIds` — are the IDs of the nodes to install.
|
|
13
13
|
* 4. *optional* `originalReferenceTargets` — are the original reference targets of a {@link Reference reference} feature.
|
|
14
|
-
* This element is only present when the feature is a {@link Reference reference}
|
|
14
|
+
* This element is only present when the feature is a {@link Reference reference}.
|
|
15
15
|
* The `nodesIds` and `originalReferenceTargets` match up per index.
|
|
16
16
|
*
|
|
17
17
|
* Note: **DON'T** export this types from the package,
|
|
18
|
-
* as these are only used to align the deserializer and deep-
|
|
18
|
+
* as these are only used to align the deserializer and deep-duplicator.
|
|
19
19
|
*/
|
|
20
20
|
export type NodesToInstall = [container: INodeBase, feature: Link | null, nodesIds: LionWebId[], originalReferenceTargets?: INodeBase[]];
|
|
21
21
|
//# sourceMappingURL=linking.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SingleRef, unresolved } from "@lionweb/core";
|
|
2
|
+
import { LionWebId } from "@lionweb/json";
|
|
3
|
+
import { INodeBase } from "./base-types.js";
|
|
4
|
+
/**
|
|
5
|
+
* A type that expresses a value is either an {@link LionWebId} or a value to indicate that resolution to a node previously failed.
|
|
6
|
+
*/
|
|
7
|
+
export type IdOrUnresolved = LionWebId | typeof unresolved;
|
|
8
|
+
/**
|
|
9
|
+
* @return the ID of a given reference to a {@link INodeBase}, or {@link unresolved} if that reference was previously unresolved.
|
|
10
|
+
*/
|
|
11
|
+
export declare const idFrom: (ref: SingleRef<INodeBase>) => IdOrUnresolved;
|
|
12
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG3C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,UAAU,CAAC;AAG3D;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,CAAC,SAAS,CAAC,KAAG,cACP,CAAA"}
|
|
@@ -14,16 +14,9 @@
|
|
|
14
14
|
//
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
-
import {
|
|
18
|
-
import { propertyValueSerializerWith } from "../../serializer.js";
|
|
19
|
-
/**
|
|
20
|
-
* A function that serializes the given value of the given {@link Property property},
|
|
21
|
-
* using the same {@link builtinPropertyValueSerializer} instance as the {@link serializeNodeBases} function,
|
|
22
|
-
* and the same treatment of enumeration values.
|
|
23
|
-
*/
|
|
24
|
-
export const defaultPropertyValueSerializer = propertyValueSerializerWith({ primitiveValueSerializer: builtinPropertyValueSerializer });
|
|
17
|
+
import { unresolved } from "@lionweb/core";
|
|
25
18
|
/**
|
|
26
19
|
* @return the ID of a given reference to a {@link INodeBase}, or {@link unresolved} if that reference was previously unresolved.
|
|
27
20
|
*/
|
|
28
|
-
export const idFrom = (ref) => ref === unresolved ?
|
|
29
|
-
//# sourceMappingURL=
|
|
21
|
+
export const idFrom = (ref) => ref === unresolved ? unresolved : ref.id;
|
|
22
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.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,EAAa,UAAU,EAAE,MAAM,eAAe,CAAA;AAYrD;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAyB,EAAkB,EAAE,CAChE,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/class-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.1",
|
|
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",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"release": "npm publish"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@lionweb/core": "0.
|
|
31
|
-
"@lionweb/json": "0.
|
|
32
|
-
"@lionweb/ts-utils": "0.
|
|
30
|
+
"@lionweb/core": "0.8.0-beta.1",
|
|
31
|
+
"@lionweb/json": "0.8.0-beta.1",
|
|
32
|
+
"@lionweb/ts-utils": "0.8.0-beta.1",
|
|
33
33
|
"littoral-templates": "0.5.1",
|
|
34
34
|
"mobx": "6.13.7"
|
|
35
35
|
}
|
package/src/base-types.ts
CHANGED
|
@@ -335,7 +335,7 @@ export abstract class NodeBase implements INodeBase {
|
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
337
|
* A type for functions that acts as factories, creating an instance of {@link INodeBase}
|
|
338
|
-
* matching the given {@link Classifier classifier} and the given ID (of type {@link
|
|
338
|
+
* matching the given {@link Classifier classifier} and the given ID (of type {@link LionWebId}).
|
|
339
339
|
*/
|
|
340
340
|
export type NodeBaseFactory = (classifier: Classifier, id: LionWebId) => INodeBase;
|
|
341
341
|
|
|
@@ -351,3 +351,14 @@ export interface ILanguageBase {
|
|
|
351
351
|
enumLiteralFrom<T>(enumerationLiteral: EnumerationLiteral): T;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* The configuration required to be able to instantiate a {@link NodeBaseFactory factory} for a set of languages.
|
|
357
|
+
*/
|
|
358
|
+
export type FactoryConfiguration = {
|
|
359
|
+
/** The {@link ILanguageBase}s for (at least) all the languages used, minus LionCore M3 and built-ins. */
|
|
360
|
+
languageBases: ILanguageBase[],
|
|
361
|
+
/** An optional {@link DeltaReceiver} that will be injected in all {@link INodeBase nodes} created. */
|
|
362
|
+
receiveDelta?: DeltaReceiver
|
|
363
|
+
};
|
|
364
|
+
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
+
import { builtinPropertyValueSerializer } from "@lionweb/core"
|
|
18
19
|
import { IDelta } from "../base.js"
|
|
19
20
|
import { SerializedDelta } from "./types.g.js"
|
|
21
|
+
import { propertyValueSerializerWith } from "../../serializer.js"
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -24,3 +26,11 @@ import { SerializedDelta } from "./types.g.js"
|
|
|
24
26
|
*/
|
|
25
27
|
export type DeltaDeserializer = (delta: SerializedDelta) => IDelta;
|
|
26
28
|
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A function that serializes the given value of the given {@link Property property},
|
|
32
|
+
* using the same {@link builtinPropertyValueSerializer} instance as the {@link serializeNodeBases} function,
|
|
33
|
+
* and the same treatment of enumeration values.
|
|
34
|
+
*/
|
|
35
|
+
export const defaultPropertyValueSerializer = propertyValueSerializerWith({ primitiveValueSerializer: builtinPropertyValueSerializer })
|
|
36
|
+
|
|
@@ -89,7 +89,8 @@ import {
|
|
|
89
89
|
ReferenceDeletedSerializedDelta,
|
|
90
90
|
SerializedDelta
|
|
91
91
|
} from "./types.g.js";
|
|
92
|
-
import {
|
|
92
|
+
import { defaultPropertyValueSerializer } from "./base.js";
|
|
93
|
+
import { idFrom } from "../../references.js";
|
|
93
94
|
import { serializeNodeBases } from "../../serializer.js";
|
|
94
95
|
|
|
95
96
|
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
// Warning: this file is generated!
|
|
19
19
|
// Modifying it by hand is useless at best, and sabotage at worst.
|
|
20
20
|
|
|
21
|
-
import { IdOrUnresolved } from "@lionweb/core";
|
|
22
21
|
import { LionWebId, LionWebJsonMetaPointer, LionWebJsonChunk } from "@lionweb/json";
|
|
22
|
+
import { IdOrUnresolved } from "../../references.js";
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
export type SerializedDelta =
|
package/src/deserializer.ts
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import { LionWebId, LionWebJsonChunk, LionWebJsonNode } from "@lionweb/json"
|
|
33
33
|
import { byIdMap, keepDefineds } from "@lionweb/ts-utils"
|
|
34
34
|
|
|
35
|
-
import { DeltaReceiver, IdMapping, ILanguageBase, INodeBase } from "./index.js"
|
|
35
|
+
import { DeltaReceiver, IdMapping, ILanguageBase, INodeBase, FactoryConfiguration } from "./index.js"
|
|
36
36
|
import { combinedLanguageBaseLookupFor } from "./factory.js"
|
|
37
37
|
import { NodesToInstall } from "./linking.js"
|
|
38
38
|
|
|
@@ -41,11 +41,10 @@ import { NodesToInstall } from "./linking.js"
|
|
|
41
41
|
* A type for deserializer functions that are parametrized in their return type.
|
|
42
42
|
*/
|
|
43
43
|
export type Deserializer<T> = (
|
|
44
|
+
/** The {@link LionWebJsonChunk serialization chunk} to deserialize. */
|
|
44
45
|
serializationChunk: LionWebJsonChunk,
|
|
45
|
-
|
|
46
|
-
idMapping?: IdMapping
|
|
47
|
-
propertyValueDeserializer?: PropertyValueDeserializer,
|
|
48
|
-
problemHandler?: SimplisticHandler
|
|
46
|
+
/** The {@link IdMapping ID mapping} of existing nodes that the given `serializationChunk` may link to. */
|
|
47
|
+
idMapping?: IdMapping
|
|
49
48
|
) => T;
|
|
50
49
|
|
|
51
50
|
|
|
@@ -56,22 +55,40 @@ export type Deserializer<T> = (
|
|
|
56
55
|
export type RootsWithIdMapping = { roots: INodeBase[], idMapping: IdMapping };
|
|
57
56
|
|
|
58
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Configuration parameters for a deserializer that are unchanging per invocation of the deserializer
|
|
60
|
+
* (and partially optional).
|
|
61
|
+
*/
|
|
62
|
+
export type DeserializerConfiguration = {
|
|
63
|
+
/** Default: {@link builtinPropertyValueDeserializer}. */
|
|
64
|
+
propertyValueDeserializer?: PropertyValueDeserializer,
|
|
65
|
+
/** Default: {@link defaultSimplisticHandler}. */
|
|
66
|
+
problemsHandler?: SimplisticHandler
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
|
|
59
70
|
/**
|
|
60
71
|
* @return a {@link Deserializer} function for the given languages (given as {@link ILanguageBase}s) that returns a {@link RootsWithIdMapping}.
|
|
72
|
+
* Deprecated:
|
|
61
73
|
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link LionWebJsonChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
62
74
|
* @param receiveDelta an optional {@link DeltaReceiver} that will be injected in all {@link INodeBase nodes} created.
|
|
63
75
|
*/
|
|
64
|
-
|
|
76
|
+
function nodeBaseDeserializerWithIdMapping(languageBases: ILanguageBase[], receiveDelta?: DeltaReceiver): Deserializer<RootsWithIdMapping>;
|
|
77
|
+
/**
|
|
78
|
+
* @param configuration a {@link DeserializerConfiguration configuration object} for the deserializer.
|
|
79
|
+
*/
|
|
80
|
+
function nodeBaseDeserializerWithIdMapping(configuration: FactoryConfiguration & DeserializerConfiguration): Deserializer<RootsWithIdMapping>;
|
|
81
|
+
function nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration: ILanguageBase[] | (FactoryConfiguration & DeserializerConfiguration), mayBeReceiveDelta?: DeltaReceiver): Deserializer<RootsWithIdMapping> {
|
|
82
|
+
const [languageBases, receiveDelta, propertyValueDeserializer, problemsHandler] = Array.isArray(languageBasesOrConfiguration)
|
|
83
|
+
? [languageBasesOrConfiguration, mayBeReceiveDelta, builtinPropertyValueDeserializer, defaultSimplisticHandler]
|
|
84
|
+
: [languageBasesOrConfiguration.languageBases, languageBasesOrConfiguration.receiveDelta, languageBasesOrConfiguration.propertyValueDeserializer ?? builtinPropertyValueDeserializer, languageBasesOrConfiguration.problemsHandler ?? defaultSimplisticHandler];
|
|
65
85
|
|
|
66
86
|
const symbolTable = new MemoisingSymbolTable(languageBases.map(({language}) => language));
|
|
67
87
|
const languageBaseFor = combinedLanguageBaseLookupFor(languageBases);
|
|
68
88
|
|
|
69
89
|
return (
|
|
70
90
|
serializationChunk,
|
|
71
|
-
|
|
72
|
-
idMapping,
|
|
73
|
-
propertyValueDeserializer = builtinPropertyValueDeserializer,
|
|
74
|
-
problemsHandler = defaultSimplisticHandler
|
|
91
|
+
idMapping
|
|
75
92
|
): RootsWithIdMapping => {
|
|
76
93
|
|
|
77
94
|
const nodesToInstall: NodesToInstall[] = [];
|
|
@@ -145,10 +162,8 @@ export const nodeBaseDeserializerWithIdMapping = (languageBases: ILanguageBase[]
|
|
|
145
162
|
)
|
|
146
163
|
);
|
|
147
164
|
|
|
148
|
-
const dependentNodesById = byIdMap(dependentNodes);
|
|
149
|
-
|
|
150
165
|
const lookupNodeById = (id: LionWebId): (INodeBase | undefined) =>
|
|
151
|
-
nodesById[id] ??
|
|
166
|
+
nodesById[id] ?? idMapping?.tryFromId(id);
|
|
152
167
|
|
|
153
168
|
nodesToInstall.forEach(([node, feature, ids]) => {
|
|
154
169
|
if (feature instanceof Containment) {
|
|
@@ -195,27 +210,34 @@ export const nodeBaseDeserializerWithIdMapping = (languageBases: ILanguageBase[]
|
|
|
195
210
|
return {
|
|
196
211
|
roots: Object.values(nodesById)
|
|
197
212
|
.filter(({parent}) => parent === undefined),
|
|
198
|
-
idMapping: new IdMapping(
|
|
213
|
+
idMapping: new IdMapping(nodesById)
|
|
199
214
|
};
|
|
200
215
|
|
|
201
216
|
};
|
|
202
|
-
}
|
|
217
|
+
}
|
|
203
218
|
|
|
204
219
|
|
|
205
220
|
/**
|
|
206
221
|
* @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.
|
|
222
|
+
* Deprecated:
|
|
207
223
|
* @param languageBases the {@link ILanguageBase}s for (at least) all the languages used in the {@link LionWebJsonChunk} to deserialize, minus LionCore M3 and built-ins.
|
|
208
224
|
* @param receiveDelta an optional {@link DeltaReceiver} that will be injected in all {@link INodeBase nodes} created.
|
|
209
225
|
*/
|
|
210
|
-
|
|
211
|
-
|
|
226
|
+
function nodeBaseDeserializer(languageBases: ILanguageBase[], receiveDelta?: DeltaReceiver): Deserializer<INodeBase[]>;
|
|
227
|
+
/**
|
|
228
|
+
* @param configuration a {@link DeserializerConfiguration configuration object} for the deserializer.
|
|
229
|
+
*/
|
|
230
|
+
function nodeBaseDeserializer(configuration: FactoryConfiguration & DeserializerConfiguration): Deserializer<INodeBase[]>;
|
|
231
|
+
function nodeBaseDeserializer(languageBasesOrConfiguration: ILanguageBase[] | (FactoryConfiguration & DeserializerConfiguration), receiveDelta?: DeltaReceiver): Deserializer<INodeBase[]> {
|
|
212
232
|
return (
|
|
213
233
|
serializationChunk,
|
|
214
|
-
|
|
215
|
-
idMapping,
|
|
216
|
-
propertyValueDeserializer = builtinPropertyValueDeserializer,
|
|
217
|
-
problemsHandler = defaultSimplisticHandler
|
|
234
|
+
idMapping
|
|
218
235
|
): INodeBase[] =>
|
|
219
|
-
|
|
236
|
+
Array.isArray(languageBasesOrConfiguration)
|
|
237
|
+
? nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration, receiveDelta)(serializationChunk, idMapping).roots
|
|
238
|
+
: nodeBaseDeserializerWithIdMapping(languageBasesOrConfiguration)(serializationChunk, idMapping).roots
|
|
220
239
|
}
|
|
221
240
|
|
|
241
|
+
|
|
242
|
+
export { nodeBaseDeserializerWithIdMapping, nodeBaseDeserializer };
|
|
243
|
+
|
package/src/forest.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
import { isPartition } from "@lionweb/core"
|
|
19
|
+
import { LionWebJsonChunk } from "@lionweb/json"
|
|
20
|
+
import { action, makeObservable, observable } from "mobx"
|
|
21
|
+
|
|
22
|
+
import { FactoryConfiguration, ILanguageBase, INodeBase, NodeBaseFactory } from "./base-types.js"
|
|
23
|
+
import {
|
|
24
|
+
applyDeltaWithLookup,
|
|
25
|
+
DeltaReceiver,
|
|
26
|
+
IDelta,
|
|
27
|
+
PartitionAddedDelta,
|
|
28
|
+
PartitionDeletedDelta,
|
|
29
|
+
updateIdMappingWithDelta
|
|
30
|
+
} from "./deltas/index.js"
|
|
31
|
+
import {
|
|
32
|
+
Deserializer,
|
|
33
|
+
DeserializerConfiguration,
|
|
34
|
+
nodeBaseDeserializerWithIdMapping,
|
|
35
|
+
RootsWithIdMapping
|
|
36
|
+
} from "./deserializer.js"
|
|
37
|
+
import { combinedFactoryFor } from "./factory.js"
|
|
38
|
+
import { IdMapping } from "./id-mapping.js"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An instance of this class encompasses a complete model (=“forest”), to conveniently encapsulate that.
|
|
43
|
+
* (Essentially, it’s a sort of in-memory repository.)
|
|
44
|
+
*/
|
|
45
|
+
export class Forest {
|
|
46
|
+
|
|
47
|
+
private readonly languageBases: ILanguageBase[]
|
|
48
|
+
|
|
49
|
+
private readonly receiveDelta?: DeltaReceiver
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The partitions contained in `this` forest.
|
|
53
|
+
*/
|
|
54
|
+
readonly partitions: INodeBase[]
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The {@link IdMapping ID mapping} mapping to all nodes in any of the partitions in `this` forest from the IDs of those nodes **plus** *unattached* nodes.
|
|
58
|
+
* A node is attached if it’s a partition – i.e., its classifier is marked as a partition –, or if it’s – directly, or indirectly – contained by a partition.
|
|
59
|
+
* This may happen as a result of deleting nodes, or of unattached nodes being deserialized into `this` forest through the `deserializeInto` or `applyDelta[s]` methods.
|
|
60
|
+
*/
|
|
61
|
+
readonly idMapping: IdMapping // We need to expose this to be able to instantiate an EventToDeltaTranslator!
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A {@link NodeBaseFactory factory} for nodes with classifiers from the {@link ILanguageBase language bases} passed during instantiation of `this` forest.
|
|
65
|
+
* This factory method installs the {@link DeltaReceiver} that may be passed during instantiation of `this` forest.
|
|
66
|
+
*/
|
|
67
|
+
readonly createNode: NodeBaseFactory
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A {@link Deserializer deserializer} that returns roots/partitions together with an ID mapping for all nodes in those.
|
|
71
|
+
* *Note*: this is primarily for internal use — specifically: to create an event-to-delta translator with.
|
|
72
|
+
* (That translator uses type from `delta-protocol-common` so we don’t want to have it here.)
|
|
73
|
+
* Using this method does *not* change `this` forest’s state.
|
|
74
|
+
*/
|
|
75
|
+
readonly deserializeWithIdMapping: Deserializer<RootsWithIdMapping>
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
constructor(configuration: FactoryConfiguration & DeserializerConfiguration) {
|
|
79
|
+
this.languageBases = configuration.languageBases
|
|
80
|
+
this.receiveDelta = configuration.receiveDelta
|
|
81
|
+
this.partitions = []
|
|
82
|
+
this.idMapping = new IdMapping({})
|
|
83
|
+
this.createNode = combinedFactoryFor(this.languageBases, this.receiveDelta)
|
|
84
|
+
this.deserializeWithIdMapping = nodeBaseDeserializerWithIdMapping(configuration)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
private emitDelta = (thunk: () => IDelta) => {
|
|
89
|
+
if (this.receiveDelta) {
|
|
90
|
+
this.receiveDelta(thunk())
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Adds the given `partition` to the partitions of `this` forest – provided it’s not already part of it –,
|
|
96
|
+
* and emits the corresponding {@link PartitionAddedDelta}.
|
|
97
|
+
*/
|
|
98
|
+
addPartition = (partition: INodeBase) => {
|
|
99
|
+
if (!isPartition(partition.classifier)) {
|
|
100
|
+
throw new Error(`node with ID ${partition.id} is a ${partition.classifier.name} which is not a <<partition>> concept`)
|
|
101
|
+
}
|
|
102
|
+
if (this.partitions.indexOf(partition) === -1) {
|
|
103
|
+
this.partitions.push(partition)
|
|
104
|
+
this.idMapping.updateWith(partition)
|
|
105
|
+
this.emitDelta(() => new PartitionAddedDelta(partition))
|
|
106
|
+
} // else: ignore; already done
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Deletes the indicated `partition` from the partitions of `this` forest – provided it’s part of it –,
|
|
111
|
+
* and emits the corresponding {@link PartitionDeletedDelta}.
|
|
112
|
+
*/
|
|
113
|
+
deletePartition = (partition: INodeBase) => {
|
|
114
|
+
const index = this.partitions.indexOf(partition)
|
|
115
|
+
if (index > -1) {
|
|
116
|
+
this.partitions.splice(index, 1)
|
|
117
|
+
this.emitDelta(() => new PartitionDeletedDelta(partition))
|
|
118
|
+
} else {
|
|
119
|
+
throw new Error(`node with id "${partition.id}" is not an added partition`)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Deserializes the given `serializationChunk` and adds any partitions in it to the partitions of `this` forest,
|
|
125
|
+
* It also updates the ID mapping, including with mappings for deserialized unattached nodes.
|
|
126
|
+
*/
|
|
127
|
+
deserializeInto = (serializationChunk: LionWebJsonChunk): INodeBase[] => {
|
|
128
|
+
const { roots: newRoots, idMapping: newIdMapping } = this.deserializeWithIdMapping(serializationChunk, this.idMapping)
|
|
129
|
+
this.partitions.push(...newRoots.filter((newRoot) => isPartition(newRoot.classifier)))
|
|
130
|
+
this.idMapping.mergeIn(newIdMapping) // also merge in new unattached, non-partition roots
|
|
131
|
+
return newRoots
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Applies the given `delta`, taking care of updating the state of the internal ID mapping.
|
|
136
|
+
*/
|
|
137
|
+
applyDelta = (delta: IDelta) => {
|
|
138
|
+
applyDeltaWithLookup(this.idMapping, delta, () => this.partitions)
|
|
139
|
+
updateIdMappingWithDelta(this.idMapping, delta)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Applies the given `deltas`, taking care of updating the state of the internal ID mapping.
|
|
144
|
+
*/
|
|
145
|
+
applyDeltas = (deltas: IDelta[]) => {
|
|
146
|
+
deltas.forEach((delta) => this.applyDelta(delta))
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* “Mobx-ified” version of the {@link Forest} class.
|
|
154
|
+
*/
|
|
155
|
+
export class ObservableForest extends Forest {
|
|
156
|
+
|
|
157
|
+
constructor(configuration: FactoryConfiguration & DeserializerConfiguration) {
|
|
158
|
+
super(configuration)
|
|
159
|
+
makeObservable(
|
|
160
|
+
this,
|
|
161
|
+
{
|
|
162
|
+
partitions: observable,
|
|
163
|
+
addPartition: action,
|
|
164
|
+
deserializeInto: action,
|
|
165
|
+
applyDelta: action,
|
|
166
|
+
applyDeltas: action
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
// (but also see: https://mobx.js.org/subclassing.html)
|
|
173
|
+
|
package/src/id-mapping.ts
CHANGED
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { SingleRef, unresolved } from "@lionweb/core"
|
|
19
19
|
import { LionWebId } from "@lionweb/json"
|
|
20
20
|
|
|
21
|
-
import { INodeBase } from "./
|
|
21
|
+
import { INodeBase } from "./base-types.js"
|
|
22
|
+
import { IdOrUnresolved } from "./references.js"
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -70,7 +71,7 @@ export class IdMapping {
|
|
|
70
71
|
/**
|
|
71
72
|
* Updates this {@link IdMapping} with the given `node` *and all its descendants* (recursively).
|
|
72
73
|
*/
|
|
73
|
-
updateWith= (node: INodeBase) => {
|
|
74
|
+
updateWith = (node: INodeBase) => {
|
|
74
75
|
this.nodesById[node.id] = node;
|
|
75
76
|
node.children // recurse into all children
|
|
76
77
|
.forEach((child) => this.updateWith(child));
|
|
@@ -87,7 +88,8 @@ export class IdMapping {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
|
-
* Merges the given `that` {@link IdMapping} **in**to `this
|
|
91
|
+
* Merges the given `that` {@link IdMapping} **in**to `this`,
|
|
92
|
+
* overwriting any previous mappings in `this`.
|
|
91
93
|
*/
|
|
92
94
|
mergeIn = (that: IdMapping) => {
|
|
93
95
|
for (const id in that.nodesById) {
|
package/src/index.ts
CHANGED
|
@@ -22,8 +22,11 @@ export * from "./deserializer.js";
|
|
|
22
22
|
export { deepDuplicateWith } from "./duplicator.js";
|
|
23
23
|
export * from "./id-mapping.js";
|
|
24
24
|
export { combinedFactoryFor } from "./factory.js";
|
|
25
|
+
export { Forest, ObservableForest } from "./forest.js";
|
|
25
26
|
// skip linking.js: see comment there
|
|
26
27
|
export * from "./LionCore_builtins.g.js";
|
|
28
|
+
export type { IdOrUnresolved } from "./references.js";
|
|
29
|
+
export { idFrom } from "./references.js";
|
|
27
30
|
export { propertyValueSerializerWith, serializeNodeBases } from "./serializer.js";
|
|
28
31
|
export { asTreeTextWith } from "./textualizer.js";
|
|
29
32
|
export * from "./value-managers/index.js";
|
package/src/linking.ts
CHANGED
|
@@ -30,11 +30,11 @@ import { INodeBase } from "./index.js"
|
|
|
30
30
|
* 2. `feature` — the {@link Link link} feature to install on, or `null` to indicate that it's an annotation.
|
|
31
31
|
* 3. `nodesIds` — are the IDs of the nodes to install.
|
|
32
32
|
* 4. *optional* `originalReferenceTargets` — are the original reference targets of a {@link Reference reference} feature.
|
|
33
|
-
* This element is only present when the feature is a {@link Reference reference}
|
|
33
|
+
* This element is only present when the feature is a {@link Reference reference}.
|
|
34
34
|
* The `nodesIds` and `originalReferenceTargets` match up per index.
|
|
35
35
|
*
|
|
36
36
|
* Note: **DON'T** export this types from the package,
|
|
37
|
-
* as these are only used to align the deserializer and deep-
|
|
37
|
+
* as these are only used to align the deserializer and deep-duplicator.
|
|
38
38
|
*/
|
|
39
39
|
export type NodesToInstall = [ container: INodeBase, feature: Link | null, nodesIds: LionWebId[], originalReferenceTargets?: INodeBase[] ];
|
|
40
40
|
|
|
@@ -15,21 +15,21 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
18
|
+
import { SingleRef, unresolved } from "@lionweb/core"
|
|
19
|
+
import { LionWebId } from "@lionweb/json"
|
|
20
|
+
|
|
21
|
+
import { INodeBase } from "./base-types.js"
|
|
22
|
+
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
* A
|
|
24
|
-
* using the same {@link builtinPropertyValueSerializer} instance as the {@link serializeNodeBases} function,
|
|
25
|
-
* and the same treatment of enumeration values.
|
|
25
|
+
* A type that expresses a value is either an {@link LionWebId} or a value to indicate that resolution to a node previously failed.
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export type IdOrUnresolved = LionWebId | typeof unresolved;
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @return the ID of a given reference to a {@link INodeBase}, or {@link unresolved} if that reference was previously unresolved.
|
|
32
32
|
*/
|
|
33
33
|
export const idFrom = (ref: SingleRef<INodeBase>): IdOrUnresolved =>
|
|
34
|
-
ref === unresolved ?
|
|
34
|
+
ref === unresolved ? unresolved : ref.id
|
|
35
35
|
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { IdOrUnresolved, SingleRef } from "@lionweb/core";
|
|
2
|
-
import { INodeBase } from "../../base-types.js";
|
|
3
|
-
/**
|
|
4
|
-
* A function that serializes the given value of the given {@link Property property},
|
|
5
|
-
* using the same {@link builtinPropertyValueSerializer} instance as the {@link serializeNodeBases} function,
|
|
6
|
-
* and the same treatment of enumeration values.
|
|
7
|
-
*/
|
|
8
|
-
export declare const defaultPropertyValueSerializer: {
|
|
9
|
-
serializeValue: (value: unknown, property: import("@lionweb/core").Property) => string | null;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @return the ID of a given reference to a {@link INodeBase}, or {@link unresolved} if that reference was previously unresolved.
|
|
13
|
-
*/
|
|
14
|
-
export declare const idFrom: (ref: SingleRef<INodeBase>) => IdOrUnresolved;
|
|
15
|
-
//# sourceMappingURL=serializer-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer-helpers.d.ts","sourceRoot":"","sources":["../../../src/deltas/serialization/serializer-helpers.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkC,cAAc,EAAE,SAAS,EAAc,MAAM,eAAe,CAAA;AACrG,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAG/C;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;CAA4F,CAAA;AAGvI;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,CAAC,SAAS,CAAC,KAAG,cACb,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer-helpers.js","sourceRoot":"","sources":["../../../src/deltas/serialization/serializer-helpers.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,EAAE,8BAA8B,EAA6B,UAAU,EAAE,MAAM,eAAe,CAAA;AAErG,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AAEjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,2BAA2B,CAAC,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,CAAC,CAAA;AAGvI;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAyB,EAAkB,EAAE,CAChE,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA"}
|