@contrail/documents 2.4.0-alpha.06c579a → 2.4.0-alpha.1202a29
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.
|
@@ -10,7 +10,6 @@ export declare class DocumentContainerIndex {
|
|
|
10
10
|
memberIdsByContainerId: Map<string, string[]>;
|
|
11
11
|
containerIdsByElementType: Map<string, string[]>;
|
|
12
12
|
});
|
|
13
|
-
static empty(): DocumentContainerIndex;
|
|
14
13
|
getContainer(containerId: string): DocumentContainer | null;
|
|
15
14
|
containersOf(documentElementId: string, elementType: ContainerElementType): DocumentContainer[];
|
|
16
15
|
containerIdsOf(documentElementId: string, elementType: ContainerElementType): readonly string[];
|
|
@@ -6,15 +6,6 @@ class DocumentContainerIndex {
|
|
|
6
6
|
constructor(data) {
|
|
7
7
|
this.data = data;
|
|
8
8
|
}
|
|
9
|
-
static empty() {
|
|
10
|
-
return new DocumentContainerIndex({
|
|
11
|
-
documentElementsById: new Map(),
|
|
12
|
-
containersById: new Map(),
|
|
13
|
-
containerPathsByDocumentElementId: new Map(),
|
|
14
|
-
memberIdsByContainerId: new Map(),
|
|
15
|
-
containerIdsByElementType: new Map(),
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
9
|
getContainer(containerId) {
|
|
19
10
|
var _a;
|
|
20
11
|
return (_a = this.data.containersById.get(containerId)) !== null && _a !== void 0 ? _a : null;
|
|
@@ -8,13 +8,7 @@ const document_container_1 = require("./document-container");
|
|
|
8
8
|
class DocumentContainerService {
|
|
9
9
|
static buildIndex(documentElements, kinds = container_kind_1.CONTAINER_KINDS) {
|
|
10
10
|
var _a, _b;
|
|
11
|
-
const
|
|
12
|
-
const containerElementTypes = new Set(kinds.map((kind) => kind.elementType));
|
|
13
|
-
if (!elements.some((element) => containerElementTypes.has(element === null || element === void 0 ? void 0 : element.type))) {
|
|
14
|
-
return document_container_index_1.DocumentContainerIndex.empty();
|
|
15
|
-
}
|
|
16
|
-
const documentElementsById = new Map(elements.map((element) => [element.id, element]));
|
|
17
|
-
const measuredDocumentElements = this.measureDocumentElements(elements, documentElementsById);
|
|
11
|
+
const measuredDocumentElements = this.measureDocumentElements(documentElements !== null && documentElements !== void 0 ? documentElements : []);
|
|
18
12
|
const containersByElementType = new Map(kinds.map((kind) => [kind.elementType, this.collectContainers(measuredDocumentElements, kind)]));
|
|
19
13
|
const containersById = new Map();
|
|
20
14
|
const containerIdsByElementType = new Map();
|
|
@@ -30,6 +24,12 @@ class DocumentContainerService {
|
|
|
30
24
|
}
|
|
31
25
|
pathsByMeasured.set(measured, byElementType);
|
|
32
26
|
}
|
|
27
|
+
const measuredById = new Map();
|
|
28
|
+
for (const measured of measuredDocumentElements) {
|
|
29
|
+
if (!measuredById.has(measured.documentElement.id)) {
|
|
30
|
+
measuredById.set(measured.documentElement.id, measured);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
33
|
const containerPathsByDocumentElementId = new Map();
|
|
34
34
|
const memberIdsByContainerId = new Map();
|
|
35
35
|
for (const measured of measuredDocumentElements) {
|
|
@@ -50,7 +50,7 @@ class DocumentContainerService {
|
|
|
50
50
|
containerPathsByDocumentElementId.set(documentElementId, pathsByElementType);
|
|
51
51
|
}
|
|
52
52
|
return new document_container_index_1.DocumentContainerIndex({
|
|
53
|
-
documentElementsById,
|
|
53
|
+
documentElementsById: new Map([...measuredById].map(([id, measured]) => [id, measured.documentElement])),
|
|
54
54
|
containersById,
|
|
55
55
|
containerPathsByDocumentElementId,
|
|
56
56
|
memberIdsByContainerId,
|
|
@@ -60,7 +60,8 @@ class DocumentContainerService {
|
|
|
60
60
|
static isContainer(documentElement, kinds = container_kind_1.CONTAINER_KINDS) {
|
|
61
61
|
return kinds.some((kind) => kind.elementType === (documentElement === null || documentElement === void 0 ? void 0 : documentElement.type));
|
|
62
62
|
}
|
|
63
|
-
static measureDocumentElements(documentElements
|
|
63
|
+
static measureDocumentElements(documentElements) {
|
|
64
|
+
const documentElementsById = new Map(documentElements.map((documentElement) => [documentElement.id, documentElement]));
|
|
64
65
|
return documentElements.map((documentElement, drawOrder) => ({
|
|
65
66
|
documentElement,
|
|
66
67
|
drawOrder,
|