@vertexvis/viewer 0.18.1 → 0.18.2-testing.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/dist/components/_commonjsHelpers.js +41 -0
- package/dist/components/_commonjsHelpers.js.map +1 -0
- package/dist/components/browser.esm.js +3173 -0
- package/dist/components/browser.esm.js.map +1 -0
- package/dist/components/bundle.esm.js +2250 -0
- package/dist/components/bundle.esm.js.map +1 -0
- package/dist/components/bundle.esm2.js +39740 -0
- package/dist/components/bundle.esm2.js.map +1 -0
- package/dist/components/config.js +81 -0
- package/dist/components/config.js.map +1 -0
- package/dist/components/controller.js +7627 -0
- package/dist/components/controller.js.map +1 -0
- package/dist/components/controller2.js +124 -0
- package/dist/components/controller2.js.map +1 -0
- package/dist/components/controller3.js +111 -0
- package/dist/components/controller3.js.map +1 -0
- package/dist/components/cursors.js +110 -0
- package/dist/components/cursors.js.map +1 -0
- package/dist/components/dom.js +43 -0
- package/dist/components/dom.js.map +1 -0
- package/dist/components/dom2.js +10 -0
- package/dist/components/dom2.js.map +1 -0
- package/dist/components/elementRectObserver.js +25 -0
- package/dist/components/elementRectObserver.js.map +1 -0
- package/dist/components/entities.js +179 -0
- package/dist/components/entities.js.map +1 -0
- package/dist/components/errors.js +80 -0
- package/dist/components/errors.js.map +1 -0
- package/dist/components/events.js +11 -0
- package/dist/components/events.js.map +1 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +365 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index2.js +63 -0
- package/dist/components/index2.js.map +1 -0
- package/dist/components/interactions.js +236 -0
- package/dist/components/interactions.js.map +1 -0
- package/dist/components/mapper.js +9811 -0
- package/dist/components/mapper.js.map +1 -0
- package/dist/components/markup.js +33 -0
- package/dist/components/markup.js.map +1 -0
- package/dist/components/model.js +134 -0
- package/dist/components/model.js.map +1 -0
- package/dist/components/model2.js +157 -0
- package/dist/components/model2.js.map +1 -0
- package/dist/components/overlays.js +76 -0
- package/dist/components/overlays.js.map +1 -0
- package/dist/components/png-decoder.js +2405 -0
- package/dist/components/png-decoder.js.map +1 -0
- package/dist/components/regl-component.js +12582 -0
- package/dist/components/regl-component.js.map +1 -0
- package/dist/components/results.js +24 -0
- package/dist/components/results.js.map +1 -0
- package/dist/components/row.js +32 -0
- package/dist/components/row.js.map +1 -0
- package/dist/components/scene-tree-search.js +146 -0
- package/dist/components/scene-tree-search.js.map +1 -0
- package/dist/components/scene-tree-table-layout.js +928 -0
- package/dist/components/scene-tree-table-layout.js.map +1 -0
- package/dist/components/scene-tree-toolbar.js +35 -0
- package/dist/components/scene-tree-toolbar.js.map +1 -0
- package/dist/components/scene.js +1508 -0
- package/dist/components/scene.js.map +1 -0
- package/dist/components/stencil.js +25 -0
- package/dist/components/stencil.js.map +1 -0
- package/dist/components/streamAttributes.js +40833 -0
- package/dist/components/streamAttributes.js.map +1 -0
- package/dist/components/templates.js +36 -0
- package/dist/components/templates.js.map +1 -0
- package/dist/components/tslib.es6.js +125 -0
- package/dist/components/tslib.es6.js.map +1 -0
- package/dist/components/vertex-scene-tree-search.d.ts +11 -0
- package/dist/components/vertex-scene-tree-search.js +11 -0
- package/dist/components/vertex-scene-tree-search.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-cell.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-cell.js +209 -0
- package/dist/components/vertex-scene-tree-table-cell.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-column.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-column.js +42 -0
- package/dist/components/vertex-scene-tree-table-column.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-header.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-header.js +38 -0
- package/dist/components/vertex-scene-tree-table-header.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-layout.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-layout.js +11 -0
- package/dist/components/vertex-scene-tree-table-layout.js.map +1 -0
- package/dist/components/vertex-scene-tree-table-resize-divider.d.ts +11 -0
- package/dist/components/vertex-scene-tree-table-resize-divider.js +57 -0
- package/dist/components/vertex-scene-tree-table-resize-divider.js.map +1 -0
- package/dist/components/vertex-scene-tree-toolbar-group.d.ts +11 -0
- package/dist/components/vertex-scene-tree-toolbar-group.js +38 -0
- package/dist/components/vertex-scene-tree-toolbar-group.js.map +1 -0
- package/dist/components/vertex-scene-tree-toolbar.d.ts +11 -0
- package/dist/components/vertex-scene-tree-toolbar.js +11 -0
- package/dist/components/vertex-scene-tree-toolbar.js.map +1 -0
- package/dist/components/vertex-scene-tree.d.ts +11 -0
- package/dist/components/vertex-scene-tree.js +803 -0
- package/dist/components/vertex-scene-tree.js.map +1 -0
- package/dist/components/vertex-viewer-box-query-tool.d.ts +11 -0
- package/dist/components/vertex-viewer-box-query-tool.js +352 -0
- package/dist/components/vertex-viewer-box-query-tool.js.map +1 -0
- package/dist/components/vertex-viewer-button.d.ts +11 -0
- package/dist/components/vertex-viewer-button.js +11 -0
- package/dist/components/vertex-viewer-button.js.map +1 -0
- package/dist/components/vertex-viewer-default-toolbar.d.ts +11 -0
- package/dist/components/vertex-viewer-default-toolbar.js +99 -0
- package/dist/components/vertex-viewer-default-toolbar.js.map +1 -0
- package/dist/components/vertex-viewer-dom-element.d.ts +11 -0
- package/dist/components/vertex-viewer-dom-element.js +11 -0
- package/dist/components/vertex-viewer-dom-element.js.map +1 -0
- package/dist/components/vertex-viewer-dom-group.d.ts +11 -0
- package/dist/components/vertex-viewer-dom-group.js +11 -0
- package/dist/components/vertex-viewer-dom-group.js.map +1 -0
- package/dist/components/vertex-viewer-dom-renderer.d.ts +11 -0
- package/dist/components/vertex-viewer-dom-renderer.js +11 -0
- package/dist/components/vertex-viewer-dom-renderer.js.map +1 -0
- package/dist/components/vertex-viewer-hit-result-indicator.d.ts +11 -0
- package/dist/components/vertex-viewer-hit-result-indicator.js +335 -0
- package/dist/components/vertex-viewer-hit-result-indicator.js.map +1 -0
- package/dist/components/vertex-viewer-icon.d.ts +11 -0
- package/dist/components/vertex-viewer-icon.js +11 -0
- package/dist/components/vertex-viewer-icon.js.map +1 -0
- package/dist/components/vertex-viewer-layer.d.ts +11 -0
- package/dist/components/vertex-viewer-layer.js +11 -0
- package/dist/components/vertex-viewer-layer.js.map +1 -0
- package/dist/components/vertex-viewer-markup-arrow.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-arrow.js +11 -0
- package/dist/components/vertex-viewer-markup-arrow.js.map +1 -0
- package/dist/components/vertex-viewer-markup-circle.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-circle.js +11 -0
- package/dist/components/vertex-viewer-markup-circle.js.map +1 -0
- package/dist/components/vertex-viewer-markup-freeform.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-freeform.js +11 -0
- package/dist/components/vertex-viewer-markup-freeform.js.map +1 -0
- package/dist/components/vertex-viewer-markup-tool.d.ts +11 -0
- package/dist/components/vertex-viewer-markup-tool.js +257 -0
- package/dist/components/vertex-viewer-markup-tool.js.map +1 -0
- package/dist/components/vertex-viewer-markup.d.ts +11 -0
- package/dist/components/vertex-viewer-markup.js +362 -0
- package/dist/components/vertex-viewer-markup.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-details.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-details.js +307 -0
- package/dist/components/vertex-viewer-measurement-details.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-distance.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-distance.js +1067 -0
- package/dist/components/vertex-viewer-measurement-distance.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-line.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-line.js +11 -0
- package/dist/components/vertex-viewer-measurement-line.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-overlays.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-overlays.js +11 -0
- package/dist/components/vertex-viewer-measurement-overlays.js.map +1 -0
- package/dist/components/vertex-viewer-measurement-precise.d.ts +11 -0
- package/dist/components/vertex-viewer-measurement-precise.js +362 -0
- package/dist/components/vertex-viewer-measurement-precise.js.map +1 -0
- package/dist/components/vertex-viewer-pin-group.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-group.js +11 -0
- package/dist/components/vertex-viewer-pin-group.js.map +1 -0
- package/dist/components/vertex-viewer-pin-label-line.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-label-line.js +11 -0
- package/dist/components/vertex-viewer-pin-label-line.js.map +1 -0
- package/dist/components/vertex-viewer-pin-label.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-label.js +11 -0
- package/dist/components/vertex-viewer-pin-label.js.map +1 -0
- package/dist/components/vertex-viewer-pin-tool.d.ts +11 -0
- package/dist/components/vertex-viewer-pin-tool.js +430 -0
- package/dist/components/vertex-viewer-pin-tool.js.map +1 -0
- package/dist/components/vertex-viewer-spinner.d.ts +11 -0
- package/dist/components/vertex-viewer-spinner.js +11 -0
- package/dist/components/vertex-viewer-spinner.js.map +1 -0
- package/dist/components/vertex-viewer-toolbar-group.d.ts +11 -0
- package/dist/components/vertex-viewer-toolbar-group.js +11 -0
- package/dist/components/vertex-viewer-toolbar-group.js.map +1 -0
- package/dist/components/vertex-viewer-toolbar.d.ts +11 -0
- package/dist/components/vertex-viewer-toolbar.js +11 -0
- package/dist/components/vertex-viewer-toolbar.js.map +1 -0
- package/dist/components/vertex-viewer-transform-widget.d.ts +11 -0
- package/dist/components/vertex-viewer-transform-widget.js +838 -0
- package/dist/components/vertex-viewer-transform-widget.js.map +1 -0
- package/dist/components/vertex-viewer-view-cube.d.ts +11 -0
- package/dist/components/vertex-viewer-view-cube.js +270 -0
- package/dist/components/vertex-viewer-view-cube.js.map +1 -0
- package/dist/components/vertex-viewer.d.ts +11 -0
- package/dist/components/vertex-viewer.js +3543 -0
- package/dist/components/vertex-viewer.js.map +1 -0
- package/dist/components/viewer-button.js +35 -0
- package/dist/components/viewer-button.js.map +1 -0
- package/dist/components/viewer-dom-element.js +250 -0
- package/dist/components/viewer-dom-element.js.map +1 -0
- package/dist/components/viewer-dom-group.js +214 -0
- package/dist/components/viewer-dom-group.js.map +1 -0
- package/dist/components/viewer-dom-renderer.js +295 -0
- package/dist/components/viewer-dom-renderer.js.map +1 -0
- package/dist/components/viewer-icon.js +87 -0
- package/dist/components/viewer-icon.js.map +1 -0
- package/dist/components/viewer-layer.js +46 -0
- package/dist/components/viewer-layer.js.map +1 -0
- package/dist/components/viewer-markup-arrow.js +235 -0
- package/dist/components/viewer-markup-arrow.js.map +1 -0
- package/dist/components/viewer-markup-circle-components.js +42 -0
- package/dist/components/viewer-markup-circle-components.js.map +1 -0
- package/dist/components/viewer-markup-circle.js +201 -0
- package/dist/components/viewer-markup-circle.js.map +1 -0
- package/dist/components/viewer-markup-freeform.js +251 -0
- package/dist/components/viewer-markup-freeform.js.map +1 -0
- package/dist/components/viewer-measurement-line.js +77 -0
- package/dist/components/viewer-measurement-line.js.map +1 -0
- package/dist/components/viewer-measurement-overlays.js +184 -0
- package/dist/components/viewer-measurement-overlays.js.map +1 -0
- package/dist/components/viewer-pin-group.js +207 -0
- package/dist/components/viewer-pin-group.js.map +1 -0
- package/dist/components/viewer-pin-label-line.js +43 -0
- package/dist/components/viewer-pin-label-line.js.map +1 -0
- package/dist/components/viewer-pin-label.js +427 -0
- package/dist/components/viewer-pin-label.js.map +1 -0
- package/dist/components/viewer-spinner.js +53 -0
- package/dist/components/viewer-spinner.js.map +1 -0
- package/dist/components/viewer-toolbar-group.js +42 -0
- package/dist/components/viewer-toolbar-group.js.map +1 -0
- package/dist/components/viewer-toolbar.js +61 -0
- package/dist/components/viewer-toolbar.js.map +1 -0
- package/dist/components/viewport.js +188 -0
- package/dist/components/viewport.js.map +1 -0
- package/dist/components/wrappers_pb.js +1926 -0
- package/dist/components/wrappers_pb.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { m as matrix4 } from './bundle.esm.js';
|
|
5
|
+
|
|
6
|
+
class TransformController {
|
|
7
|
+
constructor(stream) {
|
|
8
|
+
this.stream = stream;
|
|
9
|
+
this.isTransforming = false;
|
|
10
|
+
this.currentDelta = matrix4.makeIdentity();
|
|
11
|
+
}
|
|
12
|
+
async dispose() {
|
|
13
|
+
if (this.isTransforming) {
|
|
14
|
+
this.endTransform();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async beginTransform(delta = matrix4.makeIdentity()) {
|
|
18
|
+
if (!this.isTransforming) {
|
|
19
|
+
this.currentDelta = delta;
|
|
20
|
+
this.isTransforming = true;
|
|
21
|
+
console.debug('Beginning transform interaction');
|
|
22
|
+
await this.stream.beginInteraction({
|
|
23
|
+
transform: {
|
|
24
|
+
delta: this.toDeltaTransform(delta),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async updateTransform(delta) {
|
|
30
|
+
this.currentDelta = delta;
|
|
31
|
+
await this.stream.updateInteraction({
|
|
32
|
+
transform: {
|
|
33
|
+
delta: this.toDeltaTransform(this.currentDelta, true),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async updateTranslation(delta) {
|
|
38
|
+
this.currentDelta = matrix4.makeTranslation(delta);
|
|
39
|
+
await this.stream.updateInteraction({
|
|
40
|
+
transform: {
|
|
41
|
+
delta: this.toDeltaTransform(this.currentDelta),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getCurrentDelta() {
|
|
46
|
+
return this.currentDelta;
|
|
47
|
+
}
|
|
48
|
+
async endTransform() {
|
|
49
|
+
if (this.isTransforming) {
|
|
50
|
+
console.debug(`Ending transform interaction [delta=${this.currentDelta}]`);
|
|
51
|
+
await this.stream.endInteraction({
|
|
52
|
+
transform: {
|
|
53
|
+
delta: this.toDeltaTransform(this.currentDelta),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
this.isTransforming = false;
|
|
57
|
+
this.currentDelta = matrix4.makeIdentity();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async endInteraction() {
|
|
61
|
+
if (this.isTransforming) {
|
|
62
|
+
await this.stream.endInteraction();
|
|
63
|
+
this.isTransforming = false;
|
|
64
|
+
this.currentDelta = matrix4.makeIdentity();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
clearTransform() {
|
|
68
|
+
this.currentDelta = matrix4.makeIdentity();
|
|
69
|
+
this.endTransform();
|
|
70
|
+
}
|
|
71
|
+
toDeltaTransform(delta, columnMajor = false) {
|
|
72
|
+
const asObject = matrix4.toObject(delta);
|
|
73
|
+
// TODO: update this to pass a single order for the
|
|
74
|
+
// transform matrix after work in https://vertexvis.atlassian.net/browse/PLAT-1582
|
|
75
|
+
const basisX = columnMajor
|
|
76
|
+
? {
|
|
77
|
+
x: asObject.m11,
|
|
78
|
+
y: asObject.m21,
|
|
79
|
+
z: asObject.m31,
|
|
80
|
+
}
|
|
81
|
+
: {
|
|
82
|
+
x: asObject.m11,
|
|
83
|
+
y: asObject.m12,
|
|
84
|
+
z: asObject.m13,
|
|
85
|
+
};
|
|
86
|
+
const basisY = columnMajor
|
|
87
|
+
? {
|
|
88
|
+
x: asObject.m12,
|
|
89
|
+
y: asObject.m22,
|
|
90
|
+
z: asObject.m32,
|
|
91
|
+
}
|
|
92
|
+
: {
|
|
93
|
+
x: asObject.m21,
|
|
94
|
+
y: asObject.m22,
|
|
95
|
+
z: asObject.m23,
|
|
96
|
+
};
|
|
97
|
+
const basisZ = columnMajor
|
|
98
|
+
? {
|
|
99
|
+
x: asObject.m13,
|
|
100
|
+
y: asObject.m23,
|
|
101
|
+
z: asObject.m33,
|
|
102
|
+
}
|
|
103
|
+
: {
|
|
104
|
+
x: asObject.m31,
|
|
105
|
+
y: asObject.m32,
|
|
106
|
+
z: asObject.m33,
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
basisX,
|
|
110
|
+
basisY,
|
|
111
|
+
basisZ,
|
|
112
|
+
xlate: {
|
|
113
|
+
x: asObject.m14,
|
|
114
|
+
y: asObject.m24,
|
|
115
|
+
z: asObject.m34,
|
|
116
|
+
},
|
|
117
|
+
scale: asObject.m44,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { TransformController as T };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=controller2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"controller2.js","mappings":"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","names":["Matrix4"],"sources":["./src/lib/transforms/controller.ts"],"sourcesContent":["import { vertexvis } from '@vertexvis/frame-streaming-protos';\nimport { Matrix4, Vector3 } from '@vertexvis/geometry';\nimport { StreamApi } from '@vertexvis/stream-api';\n\nexport class TransformController {\n private isTransforming = false;\n private currentDelta: Matrix4.Matrix4 = Matrix4.makeIdentity();\n\n public constructor(private stream: StreamApi) {}\n\n public async dispose(): Promise<void> {\n if (this.isTransforming) {\n this.endTransform();\n }\n }\n\n public async beginTransform(\n delta: Matrix4.Matrix4 = Matrix4.makeIdentity()\n ): Promise<void> {\n if (!this.isTransforming) {\n this.currentDelta = delta;\n this.isTransforming = true;\n\n console.debug('Beginning transform interaction');\n\n await this.stream.beginInteraction({\n transform: {\n delta: this.toDeltaTransform(delta),\n },\n });\n }\n }\n\n public async updateTransform(delta: Matrix4.Matrix4): Promise<void> {\n this.currentDelta = delta;\n\n await this.stream.updateInteraction({\n transform: {\n delta: this.toDeltaTransform(this.currentDelta, true),\n },\n });\n }\n\n public async updateTranslation(delta: Vector3.Vector3): Promise<void> {\n this.currentDelta = Matrix4.makeTranslation(delta);\n\n await this.stream.updateInteraction({\n transform: {\n delta: this.toDeltaTransform(this.currentDelta),\n },\n });\n }\n\n public getCurrentDelta(): Matrix4.Matrix4 | undefined {\n return this.currentDelta;\n }\n\n public async endTransform(): Promise<void> {\n if (this.isTransforming) {\n console.debug(\n `Ending transform interaction [delta=${this.currentDelta}]`\n );\n\n await this.stream.endInteraction({\n transform: {\n delta: this.toDeltaTransform(this.currentDelta),\n },\n });\n this.isTransforming = false;\n this.currentDelta = Matrix4.makeIdentity();\n }\n }\n\n public async endInteraction(): Promise<void> {\n if (this.isTransforming) {\n await this.stream.endInteraction();\n this.isTransforming = false;\n this.currentDelta = Matrix4.makeIdentity();\n }\n }\n\n public clearTransform(): void {\n this.currentDelta = Matrix4.makeIdentity();\n this.endTransform();\n }\n\n private toDeltaTransform(\n delta: Matrix4.Matrix4,\n columnMajor = false\n ): vertexvis.protobuf.core.IAffineMatrix4f {\n const asObject = Matrix4.toObject(delta);\n\n // TODO: update this to pass a single order for the\n // transform matrix after work in https://vertexvis.atlassian.net/browse/PLAT-1582\n const basisX = columnMajor\n ? {\n x: asObject.m11,\n y: asObject.m21,\n z: asObject.m31,\n }\n : {\n x: asObject.m11,\n y: asObject.m12,\n z: asObject.m13,\n };\n const basisY = columnMajor\n ? {\n x: asObject.m12,\n y: asObject.m22,\n z: asObject.m32,\n }\n : {\n x: asObject.m21,\n y: asObject.m22,\n z: asObject.m23,\n };\n const basisZ = columnMajor\n ? {\n x: asObject.m13,\n y: asObject.m23,\n z: asObject.m33,\n }\n : {\n x: asObject.m31,\n y: asObject.m32,\n z: asObject.m33,\n };\n\n return {\n basisX,\n basisY,\n basisZ,\n xlate: {\n x: asObject.m14,\n y: asObject.m24,\n z: asObject.m34,\n },\n scale: asObject.m44,\n };\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { S as StreamRequestError } from './bundle.esm2.js';
|
|
5
|
+
import { E as EventDispatcher } from './browser.esm.js';
|
|
6
|
+
|
|
7
|
+
class VolumeIntersectionQueryController {
|
|
8
|
+
constructor(model, viewer) {
|
|
9
|
+
this.model = model;
|
|
10
|
+
this.viewer = viewer;
|
|
11
|
+
this.additionalTransforms = [];
|
|
12
|
+
this.operationInFlight = false;
|
|
13
|
+
this.operationAborted = false;
|
|
14
|
+
this.executeStarted = new EventDispatcher();
|
|
15
|
+
this.executeComplete = new EventDispatcher();
|
|
16
|
+
this.executeAborted = new EventDispatcher();
|
|
17
|
+
this.additionalTransforms = [(op) => op.where((q) => q.all()).deselect()];
|
|
18
|
+
this.operationTransform = (builder) => builder.select();
|
|
19
|
+
}
|
|
20
|
+
setStartPoint(point) {
|
|
21
|
+
this.previousViewerCameraControls = this.viewer.cameraControls;
|
|
22
|
+
this.viewer.cameraControls = false;
|
|
23
|
+
this.model.setStartPoint(point);
|
|
24
|
+
}
|
|
25
|
+
setEndPoint(point) {
|
|
26
|
+
this.model.setEndPoint(point);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Updates the operation that will be applied based on the volume intersection
|
|
30
|
+
* query. Defaults to `(builder) => builder.select()`, which will select any
|
|
31
|
+
* of the results of the query.
|
|
32
|
+
*/
|
|
33
|
+
setOperationTransform(operationTransform) {
|
|
34
|
+
this.operationTransform = operationTransform;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Updates any additional operations that should be performed independent of
|
|
38
|
+
* the volume intersection query. This can be used to perform an operation on
|
|
39
|
+
* the entirety of the scene prior to the operation on the result of the
|
|
40
|
+
* volume intersection query.
|
|
41
|
+
* Defaults to `[(op) => op.where((q) => q.all()).deselect()]`, which will
|
|
42
|
+
* clear any prior selection before the default selection.
|
|
43
|
+
*/
|
|
44
|
+
setAdditionalTransforms(additionalTransforms) {
|
|
45
|
+
this.additionalTransforms = additionalTransforms;
|
|
46
|
+
}
|
|
47
|
+
onExecuteStarted(listener) {
|
|
48
|
+
return this.executeStarted.on(listener);
|
|
49
|
+
}
|
|
50
|
+
onExecuteComplete(listener) {
|
|
51
|
+
return this.executeComplete.on(listener);
|
|
52
|
+
}
|
|
53
|
+
onExecuteAborted(listener) {
|
|
54
|
+
return this.executeAborted.on(listener);
|
|
55
|
+
}
|
|
56
|
+
async execute() {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
const screenBounds = this.model.getScreenBounds();
|
|
59
|
+
const type = this.model.getType();
|
|
60
|
+
if (screenBounds != null && !this.operationInFlight) {
|
|
61
|
+
this.model.complete();
|
|
62
|
+
try {
|
|
63
|
+
this.operationInFlight = true;
|
|
64
|
+
this.executeStarted.emit();
|
|
65
|
+
const additionalTransforms = (op) => this.additionalTransforms.map((t) => t(op)).flat();
|
|
66
|
+
const operationTransforms = (op) => [
|
|
67
|
+
this.operationTransform(op.where((q) => q.withVolumeIntersection(screenBounds, type === 'exclusive'))),
|
|
68
|
+
].flat();
|
|
69
|
+
const scene = await this.viewer.scene();
|
|
70
|
+
await scene
|
|
71
|
+
.items((op) => [
|
|
72
|
+
...additionalTransforms(op),
|
|
73
|
+
...operationTransforms(op),
|
|
74
|
+
])
|
|
75
|
+
.execute();
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (e instanceof StreamRequestError &&
|
|
79
|
+
((_a = e.summary) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase().includes('operation aborted'))) {
|
|
80
|
+
this.executeAborted.emit(e);
|
|
81
|
+
this.operationAborted = true;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.error('Failed to perform volume intersection query', e);
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
this.viewer.cameraControls = (_b = this.previousViewerCameraControls) !== null && _b !== void 0 ? _b : true;
|
|
90
|
+
this.previousViewerCameraControls = undefined;
|
|
91
|
+
this.operationInFlight = false;
|
|
92
|
+
this.executeComplete.emit({
|
|
93
|
+
aborted: this.operationAborted,
|
|
94
|
+
});
|
|
95
|
+
this.operationAborted = false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (this.operationInFlight) {
|
|
99
|
+
this.model.cancel();
|
|
100
|
+
throw new Error(`Unable to perform volume intersection query as there is already one in-flight.`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.model.cancel();
|
|
104
|
+
this.viewer.cameraControls = (_c = this.previousViewerCameraControls) !== null && _c !== void 0 ? _c : true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { VolumeIntersectionQueryController as V };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=controller3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"controller3.js","mappings":"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","names":[],"sources":["./src/lib/volume-intersection/controller.ts"],"sourcesContent":["import { Point } from '@vertexvis/geometry';\nimport { StreamRequestError } from '@vertexvis/stream-api';\nimport { Disposable, EventDispatcher, Listener } from '@vertexvis/utils';\n\nimport {\n SceneItemOperationsBuilder,\n TerminalItemOperationBuilder,\n} from '../scenes';\nimport { SceneItemQueryExecutor } from '../scenes/queries';\nimport { VolumeIntersectionQueryModel } from './model';\n\nexport type OperationTransform = (\n builder: SceneItemOperationsBuilder\n) => TerminalItemOperationBuilder;\nexport type AdditionalTransform = (\n executor: SceneItemQueryExecutor\n) => TerminalItemOperationBuilder;\n\nexport interface CompleteExecutionDetails {\n aborted: boolean;\n}\n\nexport class VolumeIntersectionQueryController {\n private previousViewerCameraControls?: boolean;\n private operationTransform: OperationTransform;\n private additionalTransforms: AdditionalTransform[] = [];\n private operationInFlight = false;\n private operationAborted = false;\n\n private executeStarted = new EventDispatcher<void>();\n private executeComplete = new EventDispatcher<CompleteExecutionDetails>();\n private executeAborted = new EventDispatcher<StreamRequestError>();\n\n public constructor(\n private model: VolumeIntersectionQueryModel,\n private viewer: HTMLVertexViewerElement\n ) {\n this.additionalTransforms = [(op) => op.where((q) => q.all()).deselect()];\n this.operationTransform = (builder) => builder.select();\n }\n\n public setStartPoint(point: Point.Point): void {\n this.previousViewerCameraControls = this.viewer.cameraControls;\n this.viewer.cameraControls = false;\n\n this.model.setStartPoint(point);\n }\n\n public setEndPoint(point: Point.Point): void {\n this.model.setEndPoint(point);\n }\n\n /**\n * Updates the operation that will be applied based on the volume intersection\n * query. Defaults to `(builder) => builder.select()`, which will select any\n * of the results of the query.\n */\n public setOperationTransform(operationTransform: OperationTransform): void {\n this.operationTransform = operationTransform;\n }\n\n /**\n * Updates any additional operations that should be performed independent of\n * the volume intersection query. This can be used to perform an operation on\n * the entirety of the scene prior to the operation on the result of the\n * volume intersection query.\n * Defaults to `[(op) => op.where((q) => q.all()).deselect()]`, which will\n * clear any prior selection before the default selection.\n */\n public setAdditionalTransforms(\n additionalTransforms: AdditionalTransform[]\n ): void {\n this.additionalTransforms = additionalTransforms;\n }\n\n public onExecuteStarted(listener: Listener<void>): Disposable {\n return this.executeStarted.on(listener);\n }\n\n public onExecuteComplete(\n listener: Listener<CompleteExecutionDetails>\n ): Disposable {\n return this.executeComplete.on(listener);\n }\n\n public onExecuteAborted(listener: Listener<StreamRequestError>): Disposable {\n return this.executeAborted.on(listener);\n }\n\n public async execute(): Promise<void> {\n const screenBounds = this.model.getScreenBounds();\n const type = this.model.getType();\n\n if (screenBounds != null && !this.operationInFlight) {\n this.model.complete();\n\n try {\n this.operationInFlight = true;\n this.executeStarted.emit();\n\n const additionalTransforms = (\n op: SceneItemQueryExecutor\n ): SceneItemOperationsBuilder[] =>\n this.additionalTransforms.map((t) => t(op)).flat();\n const operationTransforms = (\n op: SceneItemQueryExecutor\n ): SceneItemOperationsBuilder[] =>\n [\n this.operationTransform(\n op.where((q) =>\n q.withVolumeIntersection(screenBounds, type === 'exclusive')\n )\n ),\n ].flat();\n\n const scene = await this.viewer.scene();\n await scene\n .items((op) => [\n ...additionalTransforms(op),\n ...operationTransforms(op),\n ])\n .execute();\n } catch (e) {\n if (\n e instanceof StreamRequestError &&\n e.summary?.toLocaleLowerCase().includes('operation aborted')\n ) {\n this.executeAborted.emit(e);\n this.operationAborted = true;\n } else {\n console.error('Failed to perform volume intersection query', e);\n throw e;\n }\n } finally {\n this.viewer.cameraControls = this.previousViewerCameraControls ?? true;\n this.previousViewerCameraControls = undefined;\n this.operationInFlight = false;\n this.executeComplete.emit({\n aborted: this.operationAborted,\n });\n this.operationAborted = false;\n }\n } else if (this.operationInFlight) {\n this.model.cancel();\n\n throw new Error(\n `Unable to perform volume intersection query as there is already one in-flight.`\n );\n } else {\n this.model.cancel();\n\n this.viewer.cameraControls = this.previousViewerCameraControls ?? true;\n }\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { E as EventDispatcher } from './browser.esm.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The cursor manager maintains a prioritized list of cursors for the viewer.
|
|
8
|
+
*
|
|
9
|
+
* Cursors with the highest priority will be considered active, where the most
|
|
10
|
+
* recently added cursor will take precedence if there are multiple cursors with
|
|
11
|
+
* the same priority.
|
|
12
|
+
*/
|
|
13
|
+
class CursorManager {
|
|
14
|
+
constructor() {
|
|
15
|
+
/**
|
|
16
|
+
* An event dispatcher that emits an event when a cursor is added or removed.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link CursorManager.add} to add a cursor.
|
|
19
|
+
* @see {@link CursorManager.getActiveCursor} to query the current cursor.
|
|
20
|
+
*/
|
|
21
|
+
this.onChanged = new EventDispatcher();
|
|
22
|
+
this.cursors = [];
|
|
23
|
+
this.nextId = 0;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Adds a cursor to the cursor manager, and returns an identifier that can be
|
|
27
|
+
* used to remove the cursor.
|
|
28
|
+
*
|
|
29
|
+
* @param cursor The cursor to add.
|
|
30
|
+
* @param priority The priority of the cursor. Higher values have higher
|
|
31
|
+
* priority over lower values.
|
|
32
|
+
* @returns An identifier for the cursor.
|
|
33
|
+
* @see {@link CursorManager.getActiveCursor} to query the current cursor.
|
|
34
|
+
*/
|
|
35
|
+
add(cursor, priority = CursorManager.NORMAL_PRIORITY) {
|
|
36
|
+
const id = ++this.nextId;
|
|
37
|
+
const instance = { id, cursor, priority, dispose: () => this.remove(id) };
|
|
38
|
+
this.cursors.push(instance);
|
|
39
|
+
this.onChanged.emit();
|
|
40
|
+
return instance;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Removes a cursor with the given ID, if it exists.
|
|
44
|
+
*
|
|
45
|
+
* @param cursorId The ID of the cursor to remove.
|
|
46
|
+
*/
|
|
47
|
+
remove(cursorId) {
|
|
48
|
+
const index = this.cursors.findIndex(({ id }) => id === cursorId);
|
|
49
|
+
if (index >= 0) {
|
|
50
|
+
this.cursors.splice(index, 1);
|
|
51
|
+
this.onChanged.emit();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the active cursor based on priority and insertion order.
|
|
56
|
+
*
|
|
57
|
+
* @see {@link CursorManager.add} to add a cursor.
|
|
58
|
+
*/
|
|
59
|
+
getActiveCursor() {
|
|
60
|
+
var _a;
|
|
61
|
+
const sorted = this.cursors
|
|
62
|
+
.concat()
|
|
63
|
+
.reverse()
|
|
64
|
+
.sort((a, b) => b.priority - a.priority);
|
|
65
|
+
return (_a = sorted[0]) === null || _a === void 0 ? void 0 : _a.cursor;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A constant representing the lowest priority cursors.
|
|
70
|
+
*/
|
|
71
|
+
CursorManager.LOW_PRIORITY = 0;
|
|
72
|
+
/**
|
|
73
|
+
* A constant representing a priority between `LOW_PRIORITY` and
|
|
74
|
+
* `HIGH_PRIORITY`.
|
|
75
|
+
*/
|
|
76
|
+
CursorManager.NORMAL_PRIORITY = 10;
|
|
77
|
+
/**
|
|
78
|
+
* A constant representing the high priority cursors.
|
|
79
|
+
*/
|
|
80
|
+
CursorManager.HIGH_PRIORITY = 20;
|
|
81
|
+
// CSS SVG images need to be URL encoded: https://yoksel.github.io/url-encoder/
|
|
82
|
+
const measurementCursor = {
|
|
83
|
+
url: "data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M21.5 8h-19a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h19a.5.5 0 00.5-.5v-6a.5.5 0 00-.5-.5zm-.5 6H3V9h3v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2z' stroke='%23fff' stroke-width='1.25' stroke-opacity='0.5' stroke-miterlimit='10' shape-rendering='crispEdges'/%3E%3Cpath d='M21.5 8h-19a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h19a.5.5 0 00.5-.5v-6a.5.5 0 00-.5-.5zm-.5 6H3V9h3v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2z' shape-rendering='crispEdges'/%3E%3C/svg%3E",
|
|
84
|
+
offsetX: -24,
|
|
85
|
+
offsetY: -24,
|
|
86
|
+
};
|
|
87
|
+
const measurementWithArrowCursor = {
|
|
88
|
+
url: "data:image/svg+xml;utf8,%3Csvg id='icons' xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bstroke:%23fff;stroke-miterlimit:10;stroke-width:2px;%7D.cls-2%7Bfill:%23fff;%7D.cls-2,.cls-3%7Bfill-rule:evenodd;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M27.46,21h-19a.5.5,0,0,0-.5.5v6a.5.5,0,0,0,.5.5h19a.5.5,0,0,0,.5-.5v-6A.5.5,0,0,0,27.46,21ZM27,27H9V22h3v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2Z'/%3E%3Cpath d='M27.46,21h-19a.5.5,0,0,0-.5.5v6a.5.5,0,0,0,.5.5h19a.5.5,0,0,0,.5-.5v-6A.5.5,0,0,0,27.46,21ZM27,27H9V22h3v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2Z'/%3E%3Cpath class='cls-2' d='M1,17V1L12.59,12.62H5.81l-.41.12Z'/%3E%3Cpath class='cls-2' d='M10.08,17.69l-3.6,1.53L1.8,8.14,5.48,6.58Z'/%3E%3Cpath class='cls-3' d='M8.75,17l-1.84.77-3.1-7.37,1.84-.78Z'/%3E%3Cpath class='cls-3' d='M2,3.41V14.6l3-2.87.43-.14h4.76Z'/%3E%3C/svg%3E",
|
|
89
|
+
offsetX: -30,
|
|
90
|
+
offsetY: -30,
|
|
91
|
+
};
|
|
92
|
+
const pinCursor = {
|
|
93
|
+
url: "data:image/svg+xml,%3Csvg width='36px' height='36px' viewBox='0 0 24 24' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cdefs%3E%3Cpath d='M12,2 C7.581722,2 4,5.581722 4,10 C4.00435812,11.7714969 4.41127263,13.5188357 5.19,15.11 C6.15517666,17.0237439 7.49502409,18.7240579 9.13,20.11 C9.86916736,20.7592093 10.6620019,21.3446357 11.5,21.86 L12,22.14 L12.5,21.86 C13.8750156,21.0120029 15.1296156,19.9827599 16.23,18.8 C17.2698142,17.7023203 18.1394508,16.4551671 18.81,15.1 C19.5872532,13.5118707 19.9941287,11.7681184 20,10 C20,5.581722 16.418278,2 12,2 Z M12,13 C10.3431458,13 9,11.6568542 9,10 C9,8.34314575 10.3431458,7 12,7 C13.6568542,7 15,8.34314575 15,10 C15,10.7956495 14.6839295,11.5587112 14.1213203,12.1213203 C13.5587112,12.6839295 12.7956495,13 12,13 Z' id='path-1'%3E%3C/path%3E%3C/defs%3E%3Cg id='icons/pin-filled' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cmask id='mask-2' fill='white'%3E%3Cuse xlink:href='%23path-1'%3E%3C/use%3E%3C/mask%3E%3Cuse id='Shape' stroke='%23FAFAFA' fill='%23BDBDBD' fill-rule='nonzero' xlink:href='%23path-1'%3E%3C/use%3E%3C/g%3E%3C/svg%3E",
|
|
94
|
+
offsetX: 17,
|
|
95
|
+
offsetY: 22,
|
|
96
|
+
};
|
|
97
|
+
const labelPinCursor = {
|
|
98
|
+
url: "data:image/svg+xml,%3Csvg width='36px' height='36px' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 16 24' %3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:none;%7D.cls-2%7Bfill:%23616161;%7D.cls-3%7Bclip-path:url(%23clip-path);%7D%3C/style%3E%3CclipPath id='clip-path'%3E%3Ccircle cx='-576.76' cy='-107.26' r='4'/%3E%3C/clipPath%3E%3C/defs%3E%3Cpath d='M8,16H8a.48.48,0,0,1-.42-.23L5.75,13H3.51A1.5,1.5,0,0,1,2,11.5v-8A1.5,1.5,0,0,1,3.51,2h9A1.51,1.51,0,0,1,14,3.5v8a1.5,1.5,0,0,1-1.5,1.5H10.22L8.39,15.81A.5.5,0,0,1,8,16ZM3.51,3a.5.5,0,0,0-.5.5v8a.5.5,0,0,0,.5.5H6a.5.5,0,0,1,.42.23L8,14.61l1.55-2.38A.5.5,0,0,1,10,12h2.56a.5.5,0,0,0,.5-.5v-8a.51.51,0,0,0-.5-.5Z'/%3E%3Ccircle cx='8.01' cy='20' r='2'/%3E%3C/svg%3E%0A",
|
|
99
|
+
offsetX: 17,
|
|
100
|
+
offsetY: 29,
|
|
101
|
+
};
|
|
102
|
+
const boxQueryCursor = {
|
|
103
|
+
url: "data:image/svg+xml;utf8,%3Csvg id='icons' xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bstroke:%23fff;stroke-miterlimit:10;stroke-width:2px;%7D.cls-2%7Bfill:%23fff;%7D.cls-2,.cls-3%7Bfill-rule:evenodd;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-2' d='M1.25,17V1L12.59,12.62H5.81l-.41.12Z'/%3E%3Cpath class='cls-2' d='M10.33,17.69l-3.6,1.53L1.8,8.14,5.48,6.58Z'/%3E %3Cpath class='cls-3' d='M9,17l-1.84.77-3.1-7.37,1.84-.78Z'/%3E%3Cpath class='cls-3' d='M2.25,3.41V14.6l3-2.87.43-.14h4.76Z'/%3E%3Cpath class='cls-1' d='M21.36,22.5H15.5V16.64a.5.5,0,0,0-1,0V22.5H8.64a.5.5,0,0,0,0,1H14.5v5.86a.5.5,0,0,0,1,0V23.5h5.86a.5.5,0,0,0,0-1Z' /%3E %3Cpath d='M21.36,22.5H15.5V16.64a.5.5,0,0,0-1,0V22.5H8.64a.5.5,0,0,0,0,1H14.5v5.86a.5.5,0,0,0,1,0V23.5h5.86a.5.5,0,0,0,0-1Z' /%3E%3C/svg%3E",
|
|
104
|
+
offsetX: -30,
|
|
105
|
+
offsetY: -30,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export { CursorManager as C, measurementWithArrowCursor as a, boxQueryCursor as b, labelPinCursor as l, measurementCursor as m, pinCursor as p };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=cursors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"cursors.js","mappings":";;;;;AAiEA;;;;;;;MAOa,aAAa;EAA1B;;;;;;;IAuBkB,cAAS,GAAG,IAAI,eAAe,EAAQ,CAAC;IAEhD,YAAO,GAAqB,EAAE,CAAC;IAE/B,WAAM,GAAG,CAAC,CAAC;GAiDpB;;;;;;;;;;;EArCQ,GAAG,CACR,MAAc,EACd,QAAQ,GAAG,aAAa,CAAC,eAAe;IAExC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;IACzB,MAAM,QAAQ,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IAC1E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IACtB,OAAO,QAAQ,CAAC;GACjB;;;;;;EAOO,MAAM,CAAC,QAAgB;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,QAAQ,CAAC,CAAC;IAClE,IAAI,KAAK,IAAI,CAAC,EAAE;MACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;MAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;KACvB;GACF;;;;;;EAOM,eAAe;;IACpB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO;OACxB,MAAM,EAAE;OACR,OAAO,EAAE;OACT,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IAE3C,OAAO,MAAA,MAAM,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC;GAC1B;;AA1ED;;;AAGuB,0BAAY,GAAG,CAAC,CAAC;AAExC;;;;AAIuB,6BAAe,GAAG,EAAE,CAAC;AAE5C;;;AAGuB,2BAAa,GAAG,EAAE,CAAC;AA+D5C;MAEa,iBAAiB,GAAG;EAC/B,GAAG,EAAE,irBAAirB;EACtrB,OAAO,EAAE,CAAC,EAAE;EACZ,OAAO,EAAE,CAAC,EAAE;EACZ;MAEW,0BAA0B,GAAG;EACxC,GAAG,EAAE,siCAAsiC;EAC3iC,OAAO,EAAE,CAAC,EAAE;EACZ,OAAO,EAAE,CAAC,EAAE;EACZ;MAEW,SAAS,GAAG;EACvB,GAAG,EAAE,2oCAA2oC;EAChpC,OAAO,EAAE,EAAE;EACX,OAAO,EAAE,EAAE;EACX;MAEW,cAAc,GAAG;EAC5B,GAAG,EAAE,mvBAAmvB;EACxvB,OAAO,EAAE,EAAE;EACX,OAAO,EAAE,EAAE;EACX;MAEW,cAAc,GAAG;EAC5B,GAAG,EAAE,+0BAA+0B;EACp1B,OAAO,EAAE,CAAC,EAAE;EACZ,OAAO,EAAE,CAAC,EAAE;;;;;","names":[],"sources":["./src/lib/cursors.ts"],"sourcesContent":["import { Disposable, EventDispatcher } from '@vertexvis/utils';\n\n/**\n * Represents a built-in [browser CSS\n * cursor](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor).\n */\nexport type CssCursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out'\n | string;\n\n/**\n * Represents a custom cursor that points to an image file and offset.\n */\nexport interface CustomCursor {\n url: string;\n offsetX?: number;\n offsetY?: number;\n}\n\n/**\n * Represents all possible cursor types.\n */\nexport type Cursor = CssCursor | CustomCursor;\n\ninterface CursorInstance extends Disposable {\n id: number;\n cursor: Cursor;\n priority: number;\n}\n\n/**\n * The cursor manager maintains a prioritized list of cursors for the viewer.\n *\n * Cursors with the highest priority will be considered active, where the most\n * recently added cursor will take precedence if there are multiple cursors with\n * the same priority.\n */\nexport class CursorManager {\n /**\n * A constant representing the lowest priority cursors.\n */\n public static readonly LOW_PRIORITY = 0;\n\n /**\n * A constant representing a priority between `LOW_PRIORITY` and\n * `HIGH_PRIORITY`.\n */\n public static readonly NORMAL_PRIORITY = 10;\n\n /**\n * A constant representing the high priority cursors.\n */\n public static readonly HIGH_PRIORITY = 20;\n\n /**\n * An event dispatcher that emits an event when a cursor is added or removed.\n *\n * @see {@link CursorManager.add} to add a cursor.\n * @see {@link CursorManager.getActiveCursor} to query the current cursor.\n */\n public readonly onChanged = new EventDispatcher<void>();\n\n private cursors: CursorInstance[] = [];\n\n private nextId = 0;\n\n /**\n * Adds a cursor to the cursor manager, and returns an identifier that can be\n * used to remove the cursor.\n *\n * @param cursor The cursor to add.\n * @param priority The priority of the cursor. Higher values have higher\n * \tpriority over lower values.\n * @returns An identifier for the cursor.\n * @see {@link CursorManager.getActiveCursor} to query the current cursor.\n */\n public add(\n cursor: Cursor,\n priority = CursorManager.NORMAL_PRIORITY\n ): Disposable {\n const id = ++this.nextId;\n const instance = { id, cursor, priority, dispose: () => this.remove(id) };\n this.cursors.push(instance);\n this.onChanged.emit();\n return instance;\n }\n\n /**\n * Removes a cursor with the given ID, if it exists.\n *\n * @param cursorId The ID of the cursor to remove.\n */\n private remove(cursorId: number): void {\n const index = this.cursors.findIndex(({ id }) => id === cursorId);\n if (index >= 0) {\n this.cursors.splice(index, 1);\n this.onChanged.emit();\n }\n }\n\n /**\n * Returns the active cursor based on priority and insertion order.\n *\n * @see {@link CursorManager.add} to add a cursor.\n */\n public getActiveCursor(): Cursor | undefined {\n const sorted = this.cursors\n .concat()\n .reverse()\n .sort((a, b) => b.priority - a.priority);\n\n return sorted[0]?.cursor;\n }\n}\n\n// CSS SVG images need to be URL encoded: https://yoksel.github.io/url-encoder/\n\nexport const measurementCursor = {\n url: \"data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M21.5 8h-19a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h19a.5.5 0 00.5-.5v-6a.5.5 0 00-.5-.5zm-.5 6H3V9h3v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2z' stroke='%23fff' stroke-width='1.25' stroke-opacity='0.5' stroke-miterlimit='10' shape-rendering='crispEdges'/%3E%3Cpath d='M21.5 8h-19a.5.5 0 00-.5.5v6a.5.5 0 00.5.5h19a.5.5 0 00.5-.5v-6a.5.5 0 00-.5-.5zm-.5 6H3V9h3v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2v2.5a.5.5 0 001 0V9h2z' shape-rendering='crispEdges'/%3E%3C/svg%3E\",\n offsetX: -24,\n offsetY: -24,\n};\n\nexport const measurementWithArrowCursor = {\n url: \"data:image/svg+xml;utf8,%3Csvg id='icons' xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bstroke:%23fff;stroke-miterlimit:10;stroke-width:2px;%7D.cls-2%7Bfill:%23fff;%7D.cls-2,.cls-3%7Bfill-rule:evenodd;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M27.46,21h-19a.5.5,0,0,0-.5.5v6a.5.5,0,0,0,.5.5h19a.5.5,0,0,0,.5-.5v-6A.5.5,0,0,0,27.46,21ZM27,27H9V22h3v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2Z'/%3E%3Cpath d='M27.46,21h-19a.5.5,0,0,0-.5.5v6a.5.5,0,0,0,.5.5h19a.5.5,0,0,0,.5-.5v-6A.5.5,0,0,0,27.46,21ZM27,27H9V22h3v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2v2.5a.5.5,0,0,0,1,0V22h2Z'/%3E%3Cpath class='cls-2' d='M1,17V1L12.59,12.62H5.81l-.41.12Z'/%3E%3Cpath class='cls-2' d='M10.08,17.69l-3.6,1.53L1.8,8.14,5.48,6.58Z'/%3E%3Cpath class='cls-3' d='M8.75,17l-1.84.77-3.1-7.37,1.84-.78Z'/%3E%3Cpath class='cls-3' d='M2,3.41V14.6l3-2.87.43-.14h4.76Z'/%3E%3C/svg%3E\",\n offsetX: -30,\n offsetY: -30,\n};\n\nexport const pinCursor = {\n url: \"data:image/svg+xml,%3Csvg width='36px' height='36px' viewBox='0 0 24 24' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cdefs%3E%3Cpath d='M12,2 C7.581722,2 4,5.581722 4,10 C4.00435812,11.7714969 4.41127263,13.5188357 5.19,15.11 C6.15517666,17.0237439 7.49502409,18.7240579 9.13,20.11 C9.86916736,20.7592093 10.6620019,21.3446357 11.5,21.86 L12,22.14 L12.5,21.86 C13.8750156,21.0120029 15.1296156,19.9827599 16.23,18.8 C17.2698142,17.7023203 18.1394508,16.4551671 18.81,15.1 C19.5872532,13.5118707 19.9941287,11.7681184 20,10 C20,5.581722 16.418278,2 12,2 Z M12,13 C10.3431458,13 9,11.6568542 9,10 C9,8.34314575 10.3431458,7 12,7 C13.6568542,7 15,8.34314575 15,10 C15,10.7956495 14.6839295,11.5587112 14.1213203,12.1213203 C13.5587112,12.6839295 12.7956495,13 12,13 Z' id='path-1'%3E%3C/path%3E%3C/defs%3E%3Cg id='icons/pin-filled' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cmask id='mask-2' fill='white'%3E%3Cuse xlink:href='%23path-1'%3E%3C/use%3E%3C/mask%3E%3Cuse id='Shape' stroke='%23FAFAFA' fill='%23BDBDBD' fill-rule='nonzero' xlink:href='%23path-1'%3E%3C/use%3E%3C/g%3E%3C/svg%3E\",\n offsetX: 17,\n offsetY: 22,\n};\n\nexport const labelPinCursor = {\n url: \"data:image/svg+xml,%3Csvg width='36px' height='36px' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 16 24' %3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:none;%7D.cls-2%7Bfill:%23616161;%7D.cls-3%7Bclip-path:url(%23clip-path);%7D%3C/style%3E%3CclipPath id='clip-path'%3E%3Ccircle cx='-576.76' cy='-107.26' r='4'/%3E%3C/clipPath%3E%3C/defs%3E%3Cpath d='M8,16H8a.48.48,0,0,1-.42-.23L5.75,13H3.51A1.5,1.5,0,0,1,2,11.5v-8A1.5,1.5,0,0,1,3.51,2h9A1.51,1.51,0,0,1,14,3.5v8a1.5,1.5,0,0,1-1.5,1.5H10.22L8.39,15.81A.5.5,0,0,1,8,16ZM3.51,3a.5.5,0,0,0-.5.5v8a.5.5,0,0,0,.5.5H6a.5.5,0,0,1,.42.23L8,14.61l1.55-2.38A.5.5,0,0,1,10,12h2.56a.5.5,0,0,0,.5-.5v-8a.51.51,0,0,0-.5-.5Z'/%3E%3Ccircle cx='8.01' cy='20' r='2'/%3E%3C/svg%3E%0A\",\n offsetX: 17,\n offsetY: 29,\n};\n\nexport const boxQueryCursor = {\n url: \"data:image/svg+xml;utf8,%3Csvg id='icons' xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bstroke:%23fff;stroke-miterlimit:10;stroke-width:2px;%7D.cls-2%7Bfill:%23fff;%7D.cls-2,.cls-3%7Bfill-rule:evenodd;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-2' d='M1.25,17V1L12.59,12.62H5.81l-.41.12Z'/%3E%3Cpath class='cls-2' d='M10.33,17.69l-3.6,1.53L1.8,8.14,5.48,6.58Z'/%3E %3Cpath class='cls-3' d='M9,17l-1.84.77-3.1-7.37,1.84-.78Z'/%3E%3Cpath class='cls-3' d='M2.25,3.41V14.6l3-2.87.43-.14h4.76Z'/%3E%3Cpath class='cls-1' d='M21.36,22.5H15.5V16.64a.5.5,0,0,0-1,0V22.5H8.64a.5.5,0,0,0,0,1H14.5v5.86a.5.5,0,0,0,1,0V23.5h5.86a.5.5,0,0,0,0-1Z' /%3E %3Cpath d='M21.36,22.5H15.5V16.64a.5.5,0,0,0-1,0V22.5H8.64a.5.5,0,0,0,0,1H14.5v5.86a.5.5,0,0,0,1,0V23.5h5.86a.5.5,0,0,0,0-1Z' /%3E%3C/svg%3E\",\n offsetX: -30,\n offsetY: -30,\n};\n"],"version":3}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { p as point } from './bundle.esm.js';
|
|
5
|
+
|
|
6
|
+
function getMouseClientPosition(event, offsets) {
|
|
7
|
+
const pt = point.create(event.clientX, event.clientY);
|
|
8
|
+
if (offsets == null) {
|
|
9
|
+
return pt;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return point.subtract(pt, point.create(offsets.left, offsets.top));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns a CSS transform that will center an element at the given position.
|
|
17
|
+
*/
|
|
18
|
+
function cssTransformCenterAt(position) {
|
|
19
|
+
const { x, y } = position;
|
|
20
|
+
return `translate(-50%, -50%) translate(${x}px, ${y}px)`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns a CSS value for a cursor.
|
|
24
|
+
*/
|
|
25
|
+
function cssCursor(cursor) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
if (typeof cursor === 'string') {
|
|
28
|
+
return cursor;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const parts = [
|
|
32
|
+
`url("${cursor.url}")`,
|
|
33
|
+
(_a = cursor.offsetX) !== null && _a !== void 0 ? _a : 0,
|
|
34
|
+
(_b = cursor.offsetY) !== null && _b !== void 0 ? _b : 0,
|
|
35
|
+
', auto',
|
|
36
|
+
];
|
|
37
|
+
return parts.join(' ');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { cssTransformCenterAt as a, cssCursor as c, getMouseClientPosition as g };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"dom.js","mappings":";;;;;SAIgB,sBAAsB,CACpC,KAAiB,EACjB,OAAiB;EAEjB,MAAM,EAAE,GAAGA,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;EACtD,IAAI,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,EAAE,CAAC;GACX;OAAM;IACL,OAAOA,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAEA,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;GACpE;AACH,CAAC;AAED;;;SAGgB,oBAAoB,CAAC,QAAqB;EACxD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC;EAC1B,OAAO,mCAAmC,CAAC,OAAO,CAAC,KAAK,CAAC;AAC3D,CAAC;AAED;;;SAGgB,SAAS,CAAC,MAAc;;EACtC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAO,MAAM,CAAC;GACf;OAAM;IACL,MAAM,KAAK,GAAG;MACZ,QAAQ,MAAM,CAAC,GAAG,IAAI;MACtB,MAAA,MAAM,CAAC,OAAO,mCAAI,CAAC;MACnB,MAAA,MAAM,CAAC,OAAO,mCAAI,CAAC;MACnB,QAAQ;KACT,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;GACxB;AACH;;;;","names":["Point"],"sources":["./src/lib/dom.ts"],"sourcesContent":["import { Point } from '@vertexvis/geometry';\n\nimport { Cursor } from './cursors';\n\nexport function getMouseClientPosition(\n event: MouseEvent,\n offsets?: DOMRect\n): Point.Point {\n const pt = Point.create(event.clientX, event.clientY);\n if (offsets == null) {\n return pt;\n } else {\n return Point.subtract(pt, Point.create(offsets.left, offsets.top));\n }\n}\n\n/**\n * Returns a CSS transform that will center an element at the given position.\n */\nexport function cssTransformCenterAt(position: Point.Point): string {\n const { x, y } = position;\n return `translate(-50%, -50%) translate(${x}px, ${y}px)`;\n}\n\n/**\n * Returns a CSS value for a cursor.\n */\nexport function cssCursor(cursor: Cursor): string {\n if (typeof cursor === 'string') {\n return cursor;\n } else {\n const parts = [\n `url(\"${cursor.url}\")`,\n cursor.offsetX ?? 0,\n cursor.offsetY ?? 0,\n ', auto',\n ];\n return parts.join(' ');\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"dom2.js","mappings":";;;SAAgB,2BAA2B,CAAC,OAAoB;EAC9D,OAAO,OAAO,CAAC,qBAAqB,EAAE,CAAC;AACzC;;;;","names":[],"sources":["./src/components/viewer-markup/dom.ts"],"sourcesContent":["export function getMarkupBoundingClientRect(element: HTMLElement): DOMRect {\n return element.getBoundingClientRect();\n}\n"],"version":3}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2023 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
class ElementRectObserver {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.observer = new ResizeObserver(() => this.measure());
|
|
7
|
+
}
|
|
8
|
+
observe(element) {
|
|
9
|
+
this.element = element;
|
|
10
|
+
this.observer.observe(element);
|
|
11
|
+
this.measure();
|
|
12
|
+
}
|
|
13
|
+
disconnect() {
|
|
14
|
+
this.element = undefined;
|
|
15
|
+
this.observer.disconnect();
|
|
16
|
+
}
|
|
17
|
+
measure() {
|
|
18
|
+
var _a;
|
|
19
|
+
this.rect = (_a = this.element) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { ElementRectObserver as E };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=elementRectObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"elementRectObserver.js","mappings":";;;MAAa,mBAAmB;EAAhC;IAIU,aAAQ,GAAmB,IAAI,cAAc,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;GAgB7E;EAdQ,OAAO,CAAC,OAAoB;IACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;GAChB;EAEM,UAAU;IACf,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IACzB,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;GAC5B;EAEO,OAAO;;IACb,IAAI,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,OAAO,0CAAE,qBAAqB,EAAE,CAAC;GACnD;;;;;","names":[],"sources":["./src/lib/elementRectObserver.ts"],"sourcesContent":["export class ElementRectObserver {\n private element?: HTMLElement;\n public rect?: DOMRect;\n\n private observer: ResizeObserver = new ResizeObserver(() => this.measure());\n\n public observe(element: HTMLElement): void {\n this.element = element;\n this.observer.observe(element);\n this.measure();\n }\n\n public disconnect(): void {\n this.element = undefined;\n this.observer.disconnect();\n }\n\n private measure(): void {\n this.rect = this.element?.getBoundingClientRect();\n }\n}\n"],"version":3}
|