@lionweb/utilities 0.6.7 → 0.6.8-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/README.md +4 -0
- package/dist/serialization/annotation-remover.d.ts +14 -0
- package/dist/serialization/annotation-remover.d.ts.map +1 -0
- package/dist/serialization/annotation-remover.js +30 -0
- package/dist/serialization/annotation-remover.js.map +1 -0
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +1 -0
- package/dist/serialization/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,6 +24,10 @@ It contains utilities on top of the `core` package, such as:
|
|
|
24
24
|
|
|
25
25
|
## Changelog
|
|
26
26
|
|
|
27
|
+
### 0.6.8
|
|
28
|
+
|
|
29
|
+
* Add a `withoutAnnotations` function that removes all annotations, and all their descendatns, from a serialization chunk.
|
|
30
|
+
|
|
27
31
|
### 0.6.7
|
|
28
32
|
|
|
29
33
|
* (Depend on `@lionweb/core` version 0.6.7.)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SerializationChunk } from "@lionweb/core";
|
|
2
|
+
/**
|
|
3
|
+
* Removes all annotations from the given {@link SerializationChunk}, i.e.:
|
|
4
|
+
* * all annotations on nodes in the form of the {@code annotations} property,
|
|
5
|
+
* * all nodes that can be identified as instances of an {@link Annotation} by being referred to from {@code annotations}.
|
|
6
|
+
* It also removes all descendants of all annotations.
|
|
7
|
+
* @param serializationChunk - The {@link SerializationChunk}
|
|
8
|
+
*/
|
|
9
|
+
export declare const withoutAnnotations: (serializationChunk: SerializationChunk) => {
|
|
10
|
+
serializationFormatVersion: string;
|
|
11
|
+
languages: import("@lionweb/core").SerializedLanguageReference[];
|
|
12
|
+
nodes: import("@lionweb/core").SerializedNode[];
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=annotation-remover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-remover.d.ts","sourceRoot":"","sources":["../../src/serialization/annotation-remover.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,kBAAkB,EACrB,MAAM,eAAe,CAAA;AAEtB;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,uBAAwB,kBAAkB;;;;CAsBxE,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { byIdMap } from "@lionweb/core";
|
|
2
|
+
/**
|
|
3
|
+
* Removes all annotations from the given {@link SerializationChunk}, i.e.:
|
|
4
|
+
* * all annotations on nodes in the form of the {@code annotations} property,
|
|
5
|
+
* * all nodes that can be identified as instances of an {@link Annotation} by being referred to from {@code annotations}.
|
|
6
|
+
* It also removes all descendants of all annotations.
|
|
7
|
+
* @param serializationChunk - The {@link SerializationChunk}
|
|
8
|
+
*/
|
|
9
|
+
export const withoutAnnotations = (serializationChunk) => {
|
|
10
|
+
const { serializationFormatVersion, languages, nodes } = serializationChunk;
|
|
11
|
+
const id2node = byIdMap(nodes);
|
|
12
|
+
const childIds = (id) => id2node[id].containments.flatMap((containment) => containment.children);
|
|
13
|
+
const descendantIds = (id) => [id, ...childIds(id).flatMap(descendantIds)];
|
|
14
|
+
const annotationIds = nodes.flatMap((node) => node.annotations); // (are unique, because of parent-child relation)
|
|
15
|
+
const idsOfNodesToDelete = [
|
|
16
|
+
...annotationIds,
|
|
17
|
+
...[...annotationIds].flatMap(descendantIds)
|
|
18
|
+
];
|
|
19
|
+
return {
|
|
20
|
+
serializationFormatVersion,
|
|
21
|
+
languages,
|
|
22
|
+
nodes: nodes
|
|
23
|
+
.filter((node) => !idsOfNodesToDelete.includes(node.id)) // removes instances of annotations
|
|
24
|
+
.map((node) => {
|
|
25
|
+
node.annotations = []; // removes annotations attached to nodes that are instances of concepts
|
|
26
|
+
return node;
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=annotation-remover.js.map
|
|
@@ -0,0 +1 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ACf,CAAC,CAAC;KACT,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { withoutAnnotations } from "./annotation-remover.js";
|
|
1
2
|
export { looksLikeSerializedLanguages, readSerializationChunk, tryReadAllAsLanguages, tryReadAsLanguages } from "./chunk.js";
|
|
2
3
|
export { measure } from "./measurer.js";
|
|
3
4
|
export { orderedSerializationChunk } from "./ordering.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAA;AAC1H,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAA;AACvD,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAC,4BAA4B,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAA;AAC1H,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAA;AACvD,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { withoutAnnotations } from "./annotation-remover.js";
|
|
1
2
|
export { looksLikeSerializedLanguages, readSerializationChunk, tryReadAllAsLanguages, tryReadAsLanguages } from "./chunk.js";
|
|
2
3
|
export { measure } from "./measurer.js";
|
|
3
4
|
export { orderedSerializationChunk } from "./ordering.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAA;AAC1H,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAA;AACvD,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAC,4BAA4B,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAA;AAC1H,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,yBAAyB,EAAC,MAAM,eAAe,CAAA;AACvD,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/utilities",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8-beta.0",
|
|
4
4
|
"description": "LionWeb utilities",
|
|
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
|
"dependencies": {
|
|
18
|
-
"@lionweb/core": "0.6.
|
|
18
|
+
"@lionweb/core": "0.6.8-beta.0",
|
|
19
19
|
"littoral-templates": "0.2.2",
|
|
20
20
|
"nanoid": "4.0.2"
|
|
21
21
|
},
|