@asyra/preset 0.5.7 → 0.6.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/CHANGELOG.md +128 -0
- package/README.md +11 -7
- package/dist/agent-activity.d.ts +61 -0
- package/dist/agent-activity.d.ts.map +1 -0
- package/dist/agent-activity.js +224 -0
- package/dist/agent-activity.js.map +1 -0
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +2 -2
- package/dist/catalog.js.map +1 -1
- package/dist/cleanup-reporter.d.ts.map +1 -1
- package/dist/cleanup-reporter.js.map +1 -1
- package/dist/components/fills.d.ts +3 -1
- package/dist/components/fills.d.ts.map +1 -1
- package/dist/components/fills.js +74 -0
- package/dist/components/fills.js.map +1 -1
- package/dist/components/frame.d.ts +2 -2
- package/dist/components/frame.d.ts.map +1 -1
- package/dist/components/frame.js +1 -0
- package/dist/components/frame.js.map +1 -1
- package/dist/components/group.d.ts +9 -21
- package/dist/components/group.d.ts.map +1 -1
- package/dist/components/group.js +188 -84
- package/dist/components/group.js.map +1 -1
- package/dist/components/oval.d.ts +2 -2
- package/dist/components/oval.d.ts.map +1 -1
- package/dist/components/oval.js +3 -1
- package/dist/components/oval.js.map +1 -1
- package/dist/components/rectangle.d.ts +2 -2
- package/dist/components/rectangle.d.ts.map +1 -1
- package/dist/components/rectangle.js +3 -1
- package/dist/components/rectangle.js.map +1 -1
- package/dist/components/shape-hit-area.d.ts.map +1 -1
- package/dist/components/shape-hit-area.js.map +1 -1
- package/dist/components/text.d.ts +9 -0
- package/dist/components/text.d.ts.map +1 -0
- package/dist/components/text.js +61 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/vector-compound-fill.d.ts +8 -0
- package/dist/components/vector-compound-fill.d.ts.map +1 -0
- package/dist/components/vector-compound-fill.js +149 -0
- package/dist/components/vector-compound-fill.js.map +1 -0
- package/dist/components/vector.d.ts.map +1 -1
- package/dist/components/vector.js +85 -565
- package/dist/components/vector.js.map +1 -1
- package/dist/composition/error.d.ts.map +1 -1
- package/dist/composition/error.js.map +1 -1
- package/dist/composition/profile-provider.d.ts +2 -1
- package/dist/composition/profile-provider.d.ts.map +1 -1
- package/dist/composition/profile-provider.js +8 -2
- package/dist/composition/profile-provider.js.map +1 -1
- package/dist/composition/resolve.d.ts +2 -0
- package/dist/composition/resolve.d.ts.map +1 -1
- package/dist/composition/resolve.js +30 -6
- package/dist/composition/resolve.js.map +1 -1
- package/dist/defaults/install.d.ts.map +1 -1
- package/dist/defaults/install.js +2 -1
- package/dist/defaults/install.js.map +1 -1
- package/dist/defaults/installation.d.ts.map +1 -1
- package/dist/defaults/installation.js +2 -0
- package/dist/defaults/installation.js.map +1 -1
- package/dist/defaults/modules/selection.d.ts.map +1 -1
- package/dist/defaults/modules/selection.js.map +1 -1
- package/dist/defaults/modules/vector-editing.d.ts.map +1 -1
- package/dist/defaults/modules/vector-editing.js.map +1 -1
- package/dist/defaults/owned-state.d.ts.map +1 -1
- package/dist/defaults/owned-state.js.map +1 -1
- package/dist/defaults/private-manager.d.ts.map +1 -1
- package/dist/defaults/private-manager.js +2 -1
- package/dist/defaults/private-manager.js.map +1 -1
- package/dist/events/preset-event-names.d.ts +2 -0
- package/dist/events/preset-event-names.d.ts.map +1 -1
- package/dist/events/register-events.d.ts.map +1 -1
- package/dist/events/register-events.js +4 -2
- package/dist/events/register-events.js.map +1 -1
- package/dist/group-bounds.d.ts +36 -0
- package/dist/group-bounds.d.ts.map +1 -0
- package/dist/group-bounds.js +141 -0
- package/dist/group-bounds.js.map +1 -0
- 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/preset.d.ts.map +1 -1
- package/dist/preset.js +22 -4
- package/dist/preset.js.map +1 -1
- package/dist/props/components/anchor-points-component.d.ts.map +1 -1
- package/dist/props/components/anchor-points-component.js.map +1 -1
- package/dist/props/components/children-map-property-component.d.ts.map +1 -1
- package/dist/props/components/children-map-property-component.js.map +1 -1
- package/dist/props/components/fills-component.d.ts.map +1 -1
- package/dist/props/components/fills-component.js +3 -2
- package/dist/props/components/fills-component.js.map +1 -1
- package/dist/props/components/position-component.js +1 -1
- package/dist/props/components/position-component.js.map +1 -1
- package/dist/props/components/strokes-component.d.ts.map +1 -1
- package/dist/props/components/strokes-component.js +4 -3
- package/dist/props/components/strokes-component.js.map +1 -1
- package/dist/props/components/text-component.d.ts +67 -0
- package/dist/props/components/text-component.d.ts.map +1 -0
- package/dist/props/components/text-component.js +128 -0
- package/dist/props/components/text-component.js.map +1 -0
- package/dist/props/components/vector-networks-component.d.ts.map +1 -1
- package/dist/props/components/vector-networks-component.js.map +1 -1
- package/dist/props/components/vector-points-component.d.ts.map +1 -1
- package/dist/props/components/vector-points-component.js.map +1 -1
- package/dist/props/components/vector-segments-component.d.ts.map +1 -1
- package/dist/props/components/vector-segments-component.js.map +1 -1
- package/dist/props/register-property-schemas.d.ts.map +1 -1
- package/dist/props/register-property-schemas.js +6 -0
- package/dist/props/register-property-schemas.js.map +1 -1
- package/dist/render-layers/selection-overlay-render-layer.d.ts.map +1 -1
- package/dist/render-layers/selection-overlay-render-layer.js +7 -2
- package/dist/render-layers/selection-overlay-render-layer.js.map +1 -1
- package/dist/render-layers/vector-path-editing-render-layer.d.ts.map +1 -1
- package/dist/render-layers/vector-path-editing-render-layer.js.map +1 -1
- package/dist/selection/ids.d.ts.map +1 -1
- package/dist/selection/ids.js.map +1 -1
- package/dist/selection/register-default-selections.d.ts.map +1 -1
- package/dist/selection/register-default-selections.js +4 -2
- package/dist/selection/register-default-selections.js.map +1 -1
- package/dist/spatial/assets/binary.d.ts +22 -0
- package/dist/spatial/assets/binary.d.ts.map +1 -0
- package/dist/spatial/assets/binary.js +132 -0
- package/dist/spatial/assets/binary.js.map +1 -0
- package/dist/spatial/assets/decode.d.ts +23 -0
- package/dist/spatial/assets/decode.d.ts.map +1 -0
- package/dist/spatial/assets/decode.js +102 -0
- package/dist/spatial/assets/decode.js.map +1 -0
- package/dist/spatial/assets/preview-worker.d.ts +13 -0
- package/dist/spatial/assets/preview-worker.d.ts.map +1 -0
- package/dist/spatial/assets/preview-worker.js +188 -0
- package/dist/spatial/assets/preview-worker.js.map +1 -0
- package/dist/spatial/assets/scene.d.ts +13 -0
- package/dist/spatial/assets/scene.d.ts.map +1 -0
- package/dist/spatial/assets/scene.js +99 -0
- package/dist/spatial/assets/scene.js.map +1 -0
- package/dist/spatial/assets/schema.d.ts +22 -0
- package/dist/spatial/assets/schema.d.ts.map +1 -0
- package/dist/spatial/assets/schema.js +93 -0
- package/dist/spatial/assets/schema.js.map +1 -0
- package/dist/spatial/bounds.d.ts +15 -0
- package/dist/spatial/bounds.d.ts.map +1 -0
- package/dist/spatial/bounds.js +94 -0
- package/dist/spatial/bounds.js.map +1 -0
- package/dist/spatial/camera-controls.d.ts +53 -0
- package/dist/spatial/camera-controls.d.ts.map +1 -0
- package/dist/spatial/camera-controls.js +208 -0
- package/dist/spatial/camera-controls.js.map +1 -0
- package/dist/spatial/components.d.ts +20 -0
- package/dist/spatial/components.d.ts.map +1 -0
- package/dist/spatial/components.js +83 -0
- package/dist/spatial/components.js.map +1 -0
- package/dist/spatial/editing.d.ts +51 -0
- package/dist/spatial/editing.d.ts.map +1 -0
- package/dist/spatial/editing.js +152 -0
- package/dist/spatial/editing.js.map +1 -0
- package/dist/spatial/emissive-bloom.d.ts +22 -0
- package/dist/spatial/emissive-bloom.d.ts.map +1 -0
- package/dist/spatial/emissive-bloom.js +197 -0
- package/dist/spatial/emissive-bloom.js.map +1 -0
- package/dist/spatial/graphics.d.ts +9 -0
- package/dist/spatial/graphics.d.ts.map +1 -0
- package/dist/spatial/graphics.js +119 -0
- package/dist/spatial/graphics.js.map +1 -0
- package/dist/spatial/lazy-engine.d.ts +6 -0
- package/dist/spatial/lazy-engine.d.ts.map +1 -0
- package/dist/spatial/lazy-engine.js +92 -0
- package/dist/spatial/lazy-engine.js.map +1 -0
- package/dist/spatial/lighting.d.ts +28 -0
- package/dist/spatial/lighting.d.ts.map +1 -0
- package/dist/spatial/lighting.js +103 -0
- package/dist/spatial/lighting.js.map +1 -0
- package/dist/spatial/opaque-frame.d.ts +11 -0
- package/dist/spatial/opaque-frame.d.ts.map +1 -0
- package/dist/spatial/opaque-frame.js +131 -0
- package/dist/spatial/opaque-frame.js.map +1 -0
- package/dist/spatial/pose.d.ts +22 -0
- package/dist/spatial/pose.d.ts.map +1 -0
- package/dist/spatial/pose.js +83 -0
- package/dist/spatial/pose.js.map +1 -0
- package/dist/spatial/presentation.d.ts +16 -0
- package/dist/spatial/presentation.d.ts.map +1 -0
- package/dist/spatial/presentation.js +66 -0
- package/dist/spatial/presentation.js.map +1 -0
- package/dist/spatial/reflection-environment.d.ts +13 -0
- package/dist/spatial/reflection-environment.d.ts.map +1 -0
- package/dist/spatial/reflection-environment.js +63 -0
- package/dist/spatial/reflection-environment.js.map +1 -0
- package/dist/spatial/registration.d.ts +6 -0
- package/dist/spatial/registration.d.ts.map +1 -0
- package/dist/spatial/registration.js +82 -0
- package/dist/spatial/registration.js.map +1 -0
- package/dist/spatial/shadow-frame.d.ts +13 -0
- package/dist/spatial/shadow-frame.d.ts.map +1 -0
- package/dist/spatial/shadow-frame.js +60 -0
- package/dist/spatial/shadow-frame.js.map +1 -0
- package/dist/spatial/spatial-contract.d.ts +10 -0
- package/dist/spatial/spatial-contract.d.ts.map +1 -0
- package/dist/spatial/spatial-contract.js +414 -0
- package/dist/spatial/spatial-contract.js.map +1 -0
- package/dist/spatial/spatial-layer.d.ts +47 -0
- package/dist/spatial/spatial-layer.d.ts.map +1 -0
- package/dist/spatial/spatial-layer.js +224 -0
- package/dist/spatial/spatial-layer.js.map +1 -0
- package/dist/spatial/surface-contract.d.ts +4 -0
- package/dist/spatial/surface-contract.d.ts.map +1 -0
- package/dist/spatial/surface-contract.js +40 -0
- package/dist/spatial/surface-contract.js.map +1 -0
- package/dist/spatial/surface-textures.d.ts +8 -0
- package/dist/spatial/surface-textures.d.ts.map +1 -0
- package/dist/spatial/surface-textures.js +46 -0
- package/dist/spatial/surface-textures.js.map +1 -0
- package/dist/spatial/three-engine.d.ts +91 -0
- package/dist/spatial/three-engine.d.ts.map +1 -0
- package/dist/spatial/three-engine.js +1127 -0
- package/dist/spatial/three-engine.js.map +1 -0
- package/dist/spatial/transmission-capture.d.ts +13 -0
- package/dist/spatial/transmission-capture.d.ts.map +1 -0
- package/dist/spatial/transmission-capture.js +215 -0
- package/dist/spatial/transmission-capture.js.map +1 -0
- package/dist/spatial-assets.d.ts +4 -0
- package/dist/spatial-assets.d.ts.map +1 -0
- package/dist/spatial-assets.js +4 -0
- package/dist/spatial-assets.js.map +1 -0
- package/dist/spatial-contract.d.ts +3 -0
- package/dist/spatial-contract.d.ts.map +1 -0
- package/dist/spatial-contract.js +3 -0
- package/dist/spatial-contract.js.map +1 -0
- package/dist/spatial-engine.d.ts +5 -0
- package/dist/spatial-engine.d.ts.map +1 -0
- package/dist/spatial-engine.js +5 -0
- package/dist/spatial-engine.js.map +1 -0
- package/dist/spatial.d.ts +9 -0
- package/dist/spatial.d.ts.map +1 -0
- package/dist/spatial.js +9 -0
- package/dist/spatial.js.map +1 -0
- package/dist/subscriptions/data-channel.d.ts.map +1 -1
- package/dist/subscriptions/data-channel.js +372 -124
- package/dist/subscriptions/data-channel.js.map +1 -1
- package/dist/subscriptions/render-system.d.ts.map +1 -1
- package/dist/subscriptions/render-system.js +4 -2
- package/dist/subscriptions/render-system.js.map +1 -1
- package/dist/subscriptions/shared-channels.d.ts.map +1 -1
- package/dist/subscriptions/shared-channels.js +4 -2
- package/dist/subscriptions/shared-channels.js.map +1 -1
- package/dist/subscriptions/vector-selection.d.ts +4 -0
- package/dist/subscriptions/vector-selection.d.ts.map +1 -0
- package/dist/subscriptions/vector-selection.js +175 -0
- package/dist/subscriptions/vector-selection.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/register-properties.d.ts.map +1 -1
- package/dist/ui/register-properties.js +3 -2
- package/dist/ui/register-properties.js.map +1 -1
- package/dist/vector/synthetic-handle.d.ts.map +1 -1
- package/dist/vector/synthetic-handle.js.map +1 -1
- package/package.json +44 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentDefinition,
|
|
1
|
+
import type { ComponentDefinition, EngineNeutralRenderStrategy } from '@asyra/core';
|
|
2
2
|
export declare const FRAME_COMPONENT_DEFINITION: ComponentDefinition;
|
|
3
|
-
export declare const FRAME_RENDER_STRATEGY:
|
|
3
|
+
export declare const FRAME_RENDER_STRATEGY: EngineNeutralRenderStrategy;
|
|
4
4
|
//# sourceMappingURL=frame.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/components/frame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/components/frame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,aAAa,CAAA;AASpB,eAAO,MAAM,0BAA0B,EAAE,mBAuBxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,2BAwBnC,CAAA"}
|
package/dist/components/frame.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/components/frame.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/components/frame.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EACX,aAAa,EACb,6BAA6B,EAC9B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD,MAAM,CAAC,MAAM,0BAA0B,GAAwB;IA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AG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAA;AACvC,CAAC,CAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type GroupBounds } from '../group-bounds.js';
|
|
2
|
+
import { type ComponentDefinition, type ElementPropertyValuesUpdate, type PropertyMutationReceipt, type EngineNeutralRenderStrategy } from '@asyra/core';
|
|
3
|
+
import { type EVENT_OPTIONS, type MoveHierarchyRequest, type MoveHierarchyResult, type RemoveSubtreeResult, type ElementRawData } from '@asyra/utils';
|
|
3
4
|
export declare const GROUP_COMPONENT_DEFINITION: ComponentDefinition;
|
|
4
|
-
export declare const GROUP_RENDER_STRATEGY:
|
|
5
|
+
export declare const GROUP_RENDER_STRATEGY: EngineNeutralRenderStrategy;
|
|
5
6
|
export interface GroupHierarchyReadCore {
|
|
6
|
-
|
|
7
|
+
getElementData: (elementId: string) => ElementRawData | undefined;
|
|
7
8
|
}
|
|
8
9
|
export interface GroupGeometryProjectionCore extends GroupHierarchyReadCore {
|
|
9
|
-
getElementComputedData: (elementId: string) => Record<string, unknown> | undefined;
|
|
10
|
+
getElementComputedData: (elementId: string, fields?: readonly string[]) => Record<string, unknown> | undefined;
|
|
10
11
|
}
|
|
11
12
|
export interface GroupOperationCore extends GroupGeometryProjectionCore {
|
|
12
13
|
createElementInParent: (data: {
|
|
@@ -17,7 +18,7 @@ export interface GroupOperationCore extends GroupGeometryProjectionCore {
|
|
|
17
18
|
height: number;
|
|
18
19
|
}, parentId: string, index?: number, options?: EVENT_OPTIONS) => string;
|
|
19
20
|
moveElements: (request: MoveHierarchyRequest, options?: EVENT_OPTIONS) => MoveHierarchyResult;
|
|
20
|
-
updateElementProperties: (updates: readonly ElementPropertyValuesUpdate[], options?: EVENT_OPTIONS) =>
|
|
21
|
+
updateElementProperties: (updates: readonly ElementPropertyValuesUpdate[], options?: EVENT_OPTIONS) => PropertyMutationReceipt;
|
|
21
22
|
removeSubtree: (elementId: string, options?: EVENT_OPTIONS) => RemoveSubtreeResult;
|
|
22
23
|
}
|
|
23
24
|
export interface PreparedGroupOperation {
|
|
@@ -33,12 +34,7 @@ export interface PreparedUngroupOperation {
|
|
|
33
34
|
readonly groupIndex: number;
|
|
34
35
|
readonly elementIds: readonly string[];
|
|
35
36
|
}
|
|
36
|
-
export
|
|
37
|
-
readonly x: number;
|
|
38
|
-
readonly y: number;
|
|
39
|
-
readonly width: number;
|
|
40
|
-
readonly height: number;
|
|
41
|
-
}
|
|
37
|
+
export type { GroupBounds } from '../group-bounds.js';
|
|
42
38
|
export interface GroupOperationResult {
|
|
43
39
|
readonly groupId: string;
|
|
44
40
|
readonly elementIds: readonly string[];
|
|
@@ -53,20 +49,12 @@ export interface NormalizedGroupBounds {
|
|
|
53
49
|
readonly groupId: string;
|
|
54
50
|
readonly bounds: GroupBounds;
|
|
55
51
|
}
|
|
56
|
-
interface ElementRectangle {
|
|
57
|
-
readonly id: string;
|
|
58
|
-
readonly x: number;
|
|
59
|
-
readonly y: number;
|
|
60
|
-
readonly width: number;
|
|
61
|
-
readonly height: number;
|
|
62
|
-
}
|
|
63
52
|
export declare const projectGroupGeometryPropertyUpdates: (core: GroupGeometryProjectionCore, initialUpdates: readonly ElementPropertyValuesUpdate[], explicitGroupElementIds?: readonly string[]) => readonly ElementPropertyValuesUpdate[];
|
|
64
|
-
export
|
|
53
|
+
export { deriveGroupBounds } from '../group-bounds.js';
|
|
65
54
|
export declare const prepareGroupOperation: (core: GroupHierarchyReadCore, elementIds: readonly string[]) => PreparedGroupOperation;
|
|
66
55
|
export declare const prepareUngroupOperation: (core: GroupHierarchyReadCore, groupId: string) => PreparedUngroupOperation;
|
|
67
56
|
export declare const groupElements: (core: GroupOperationCore, elementIds: readonly string[], options?: EVENT_OPTIONS) => GroupOperationResult;
|
|
68
57
|
export declare const ungroupElement: (core: GroupOperationCore, groupId: string, options?: EVENT_OPTIONS) => UngroupOperationResult;
|
|
69
58
|
export declare const normalizeGroupsForElements: (core: GroupOperationCore, elementIds: readonly string[], options?: EVENT_OPTIONS) => readonly NormalizedGroupBounds[];
|
|
70
59
|
export declare const moveElementsWithGroupGeometry: (core: GroupOperationCore, request: MoveHierarchyRequest, options?: EVENT_OPTIONS) => MoveHierarchyResult;
|
|
71
|
-
export {};
|
|
72
60
|
//# sourceMappingURL=group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/components/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/components/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EACjC,MAAM,aAAa,CAAA;AACpB,OAAO,EAIL,KAAK,aAAa,EAElB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,cAAc,CAAA;AAIrB,eAAO,MAAM,0BAA0B,EAAE,mBA4BxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,2BAWnC,CAAA;AAED,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAA;CAClE;AAED,MAAM,WAAW,2BAA4B,SAAQ,sBAAsB;IACzE,sBAAsB,EAAE,CACtB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,KACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CACzC;AAED,MAAM,WAAW,kBAAmB,SAAQ,2BAA2B;IACrE,qBAAqB,EAAE,CACrB,IAA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import { deriveGroupBounds, transformGroupOffset } from '../group-bounds.js';
|
|
1
2
|
import { runTransaction } from '@asyra/core';
|
|
2
3
|
import { EntityTypes, PropertyTypes, createDefaultFills } from '@asyra/utils';
|
|
3
4
|
import { DEFAULT_GROUP_STROKES } from './stroke-defaults.js';
|
|
@@ -12,7 +13,7 @@ export const GROUP_COMPONENT_DEFINITION = {
|
|
|
12
13
|
{
|
|
13
14
|
name: PropertyTypes.POSITION,
|
|
14
15
|
type: PropertyTypes.POSITION,
|
|
15
|
-
alias: ['x', 'y', 'rotation']
|
|
16
|
+
alias: ['x', 'y', 'rotation', 'scaleX', 'scaleY']
|
|
16
17
|
},
|
|
17
18
|
{
|
|
18
19
|
name: PropertyTypes.DIMENSION,
|
|
@@ -33,9 +34,22 @@ export const GROUP_COMPONENT_DEFINITION = {
|
|
|
33
34
|
};
|
|
34
35
|
export const GROUP_RENDER_STRATEGY = (graphic, data) => {
|
|
35
36
|
graphic.clear();
|
|
36
|
-
|
|
37
|
+
graphic.transformGroup = true;
|
|
38
|
+
// Group geometry is non-painting; project its complete canonical pose.
|
|
37
39
|
graphic.x = data.x;
|
|
38
40
|
graphic.y = data.y;
|
|
41
|
+
graphic.rotation = data.rotation ?? 0;
|
|
42
|
+
graphic.scale.set(data.scaleX ?? 1, data.scaleY ?? 1);
|
|
43
|
+
};
|
|
44
|
+
// A read scope never crosses a canonical mutation. Do not serialize the scene.
|
|
45
|
+
const createGroupHierarchyReader = (core) => {
|
|
46
|
+
const elements = new Map();
|
|
47
|
+
return (elementId) => {
|
|
48
|
+
if (!elements.has(elementId)) {
|
|
49
|
+
elements.set(elementId, core.getElementData(elementId));
|
|
50
|
+
}
|
|
51
|
+
return elements.get(elementId);
|
|
52
|
+
};
|
|
39
53
|
};
|
|
40
54
|
const createGroupGeometryProjection = (core) => ({
|
|
41
55
|
core,
|
|
@@ -47,22 +61,23 @@ const failGroupPreparation = (message) => {
|
|
|
47
61
|
throw new Error(`[Preset] Cannot prepare official Group operation: ${message}`);
|
|
48
62
|
};
|
|
49
63
|
const getContainerChildren = (data, parentId) => {
|
|
50
|
-
const parent = data
|
|
64
|
+
const parent = data(parentId);
|
|
51
65
|
if (!parent || !Array.isArray(parent.children)) {
|
|
52
66
|
return failGroupPreparation(`parent "${parentId}" is not a canonical container`);
|
|
53
67
|
}
|
|
54
68
|
return parent.children;
|
|
55
69
|
};
|
|
56
70
|
const normalizeGroupBoundsInTransaction = (projection, data, groupId) => {
|
|
57
|
-
const group = data
|
|
71
|
+
const group = data(groupId);
|
|
58
72
|
if (!group ||
|
|
59
73
|
group.type !== EntityTypes.GROUP ||
|
|
60
74
|
!Array.isArray(group.children)) {
|
|
61
75
|
return failGroupPreparation(`"${groupId}" is not an official Group`);
|
|
62
76
|
}
|
|
63
77
|
const groupRectangle = readRectangle(projection, groupId);
|
|
64
|
-
const childRectangles = group.children.map((elementId) => readRectangle(projection, elementId));
|
|
78
|
+
const childRectangles = group.children.map((elementId) => readRectangle(projection, elementId, data(elementId)?.type));
|
|
65
79
|
const childBounds = deriveGroupBounds(childRectangles);
|
|
80
|
+
const offset = transformGroupOffset(groupRectangle, childBounds, false);
|
|
66
81
|
const nextBounds = childRectangles.length === 0
|
|
67
82
|
? Object.freeze({
|
|
68
83
|
x: groupRectangle.x,
|
|
@@ -71,8 +86,8 @@ const normalizeGroupBoundsInTransaction = (projection, data, groupId) => {
|
|
|
71
86
|
height: 0
|
|
72
87
|
})
|
|
73
88
|
: Object.freeze({
|
|
74
|
-
x: groupRectangle.x +
|
|
75
|
-
y: groupRectangle.y +
|
|
89
|
+
x: groupRectangle.x + offset.x,
|
|
90
|
+
y: groupRectangle.y + offset.y,
|
|
76
91
|
width: childBounds.width,
|
|
77
92
|
height: childBounds.height
|
|
78
93
|
});
|
|
@@ -105,7 +120,17 @@ const getComputedData = (projection, elementId) => {
|
|
|
105
120
|
if (projectedValues) {
|
|
106
121
|
return projectedValues;
|
|
107
122
|
}
|
|
108
|
-
const data = projection.core.getElementComputedData(elementId
|
|
123
|
+
const data = projection.core.getElementComputedData(elementId, [
|
|
124
|
+
'x',
|
|
125
|
+
'y',
|
|
126
|
+
'width',
|
|
127
|
+
'height',
|
|
128
|
+
'rotation',
|
|
129
|
+
'scaleX',
|
|
130
|
+
'scaleY',
|
|
131
|
+
'skewX',
|
|
132
|
+
'skewY'
|
|
133
|
+
]);
|
|
109
134
|
if (!data) {
|
|
110
135
|
return failGroupGeometry(`element "${elementId}" has no computed data`);
|
|
111
136
|
}
|
|
@@ -140,10 +165,16 @@ const applyGeometryProjection = (core, projection, options) => {
|
|
|
140
165
|
}
|
|
141
166
|
core.updateElementProperties(getProjectedPropertyUpdates(projection), options);
|
|
142
167
|
};
|
|
143
|
-
const readRectangle = (projection, elementId) => {
|
|
168
|
+
const readRectangle = (projection, elementId, type) => {
|
|
144
169
|
const data = getComputedData(projection, elementId);
|
|
145
170
|
return Object.freeze({
|
|
146
171
|
id: elementId,
|
|
172
|
+
type,
|
|
173
|
+
rotation: typeof data.rotation === 'number' ? data.rotation : 0,
|
|
174
|
+
skewX: typeof data.skewX === 'number' ? data.skewX : 0,
|
|
175
|
+
skewY: typeof data.skewY === 'number' ? data.skewY : 0,
|
|
176
|
+
scaleX: typeof data.scaleX === 'number' ? data.scaleX : 1,
|
|
177
|
+
scaleY: typeof data.scaleY === 'number' ? data.scaleY : 1,
|
|
147
178
|
x: readFiniteNumber(data, 'x', elementId),
|
|
148
179
|
y: readFiniteNumber(data, 'y', elementId),
|
|
149
180
|
width: readFiniteNumber(data, 'width', elementId),
|
|
@@ -157,51 +188,67 @@ const readPosition = (projection, elementId) => {
|
|
|
157
188
|
y: readFiniteNumber(data, 'y', elementId)
|
|
158
189
|
});
|
|
159
190
|
};
|
|
160
|
-
const
|
|
191
|
+
const createHierarchyPointTransform = (projection, data, elementId, inverse) => {
|
|
161
192
|
let currentId = elementId;
|
|
162
|
-
|
|
163
|
-
let y = 0;
|
|
193
|
+
const poses = [];
|
|
164
194
|
const visited = new Set();
|
|
165
195
|
while (currentId) {
|
|
166
196
|
if (visited.has(currentId)) {
|
|
167
197
|
return failGroupGeometry(`hierarchy cycle reaches "${currentId}"`);
|
|
168
198
|
}
|
|
169
199
|
visited.add(currentId);
|
|
170
|
-
const element = data
|
|
200
|
+
const element = data(currentId);
|
|
171
201
|
if (!element) {
|
|
172
202
|
return failGroupGeometry(`element "${currentId}" is missing`);
|
|
173
203
|
}
|
|
174
204
|
if (element.type === EntityTypes.WORKSPACE) {
|
|
175
205
|
break;
|
|
176
206
|
}
|
|
177
|
-
|
|
178
|
-
x += position.x;
|
|
179
|
-
y += position.y;
|
|
207
|
+
poses.push(readRectangle(projection, currentId));
|
|
180
208
|
currentId = element.parentId ?? '';
|
|
181
209
|
}
|
|
182
|
-
|
|
210
|
+
if (inverse) {
|
|
211
|
+
poses.reverse();
|
|
212
|
+
}
|
|
213
|
+
return (point) => poses.reduce((value, pose) => {
|
|
214
|
+
if (inverse) {
|
|
215
|
+
return transformGroupOffset(pose, { x: value.x - pose.x, y: value.y - pose.y }, true);
|
|
216
|
+
}
|
|
217
|
+
const offset = transformGroupOffset(pose, value, false);
|
|
218
|
+
return { x: pose.x + offset.x, y: pose.y + offset.y };
|
|
219
|
+
}, point);
|
|
183
220
|
};
|
|
184
221
|
const getHierarchyDepth = (data, elementId) => {
|
|
185
222
|
let depth = 0;
|
|
186
|
-
let element = data
|
|
223
|
+
let element = data(elementId);
|
|
224
|
+
const visited = new Set();
|
|
187
225
|
while (element?.parentId) {
|
|
226
|
+
if (visited.has(element.id)) {
|
|
227
|
+
return failGroupPreparation(`hierarchy cycle reaches "${element.id}"`);
|
|
228
|
+
}
|
|
229
|
+
visited.add(element.id);
|
|
188
230
|
depth += 1;
|
|
189
|
-
element = data
|
|
231
|
+
element = data(element.parentId);
|
|
190
232
|
}
|
|
191
233
|
return depth;
|
|
192
234
|
};
|
|
193
235
|
const getAffectedGroupIds = (data, elementIds) => {
|
|
194
236
|
const groupIds = new Set();
|
|
195
237
|
elementIds.forEach((elementId) => {
|
|
196
|
-
let element = data
|
|
238
|
+
let element = data(elementId);
|
|
197
239
|
if (!element) {
|
|
198
240
|
return failGroupPreparation(`element "${elementId}" is missing`);
|
|
199
241
|
}
|
|
200
242
|
if (element.type === EntityTypes.GROUP) {
|
|
201
243
|
groupIds.add(element.id);
|
|
202
244
|
}
|
|
245
|
+
const visited = new Set();
|
|
203
246
|
while (element.parentId) {
|
|
204
|
-
|
|
247
|
+
if (visited.has(element.id)) {
|
|
248
|
+
return failGroupPreparation(`hierarchy cycle reaches "${element.id}"`);
|
|
249
|
+
}
|
|
250
|
+
visited.add(element.id);
|
|
251
|
+
const parent = data(element.parentId);
|
|
205
252
|
if (!parent) {
|
|
206
253
|
return failGroupPreparation(`parent "${element.parentId}" of "${element.id}" is missing`);
|
|
207
254
|
}
|
|
@@ -241,6 +288,61 @@ const stageInitialPropertyUpdates = (projection, updates) => {
|
|
|
241
288
|
});
|
|
242
289
|
return Object.freeze(geometryElementIds);
|
|
243
290
|
};
|
|
291
|
+
// Derive live dimensions bottom-up before assigning proportional local boxes.
|
|
292
|
+
const resizeGroupContents = (projection, data, groupId, requested) => {
|
|
293
|
+
const nodes = [groupId];
|
|
294
|
+
const seen = new Set();
|
|
295
|
+
const groups = [];
|
|
296
|
+
for (const id of nodes) {
|
|
297
|
+
const node = data(id);
|
|
298
|
+
if (!node || seen.has(id)) {
|
|
299
|
+
return failGroupGeometry(`invalid subtree at "${id}"`);
|
|
300
|
+
}
|
|
301
|
+
seen.add(id);
|
|
302
|
+
if (node.type === EntityTypes.FRAME ||
|
|
303
|
+
node.type === EntityTypes.WORKSPACE) {
|
|
304
|
+
throw new RangeError('Frame and Workspace size edits are unavailable');
|
|
305
|
+
}
|
|
306
|
+
if (node.type === EntityTypes.GROUP) {
|
|
307
|
+
groups.push(id);
|
|
308
|
+
for (const child of getContainerChildren(data, id)) {
|
|
309
|
+
nodes.push(child);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
for (const id of groups.reverse()) {
|
|
314
|
+
normalizeGroupBoundsInTransaction(projection, data, id);
|
|
315
|
+
}
|
|
316
|
+
const current = readRectangle(projection, groupId);
|
|
317
|
+
const ratio = (key) => {
|
|
318
|
+
const value = requested[key];
|
|
319
|
+
if (value === undefined || value === current[key]) {
|
|
320
|
+
return 1;
|
|
321
|
+
}
|
|
322
|
+
if (typeof value !== 'number' ||
|
|
323
|
+
!Number.isFinite(value) ||
|
|
324
|
+
value < 0 ||
|
|
325
|
+
current[key] === 0) {
|
|
326
|
+
throw new RangeError(`Cannot resize ${groupId}.${key} from ${current[key]} to ${value}`);
|
|
327
|
+
}
|
|
328
|
+
return value / current[key];
|
|
329
|
+
};
|
|
330
|
+
const sx = ratio('width');
|
|
331
|
+
const sy = ratio('height');
|
|
332
|
+
for (const id of nodes) {
|
|
333
|
+
const rect = readRectangle(projection, id);
|
|
334
|
+
const values = {
|
|
335
|
+
x: id === groupId ? rect.x : rect.x * sx,
|
|
336
|
+
y: id === groupId ? rect.y : rect.y * sy,
|
|
337
|
+
width: rect.width * sx,
|
|
338
|
+
height: rect.height * sy
|
|
339
|
+
};
|
|
340
|
+
if (!Object.values(values).every(Number.isFinite)) {
|
|
341
|
+
throw new RangeError(`Resized bounds overflow at "${id}"`);
|
|
342
|
+
}
|
|
343
|
+
stageGeometryValues(projection, id, values);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
244
346
|
export const projectGroupGeometryPropertyUpdates = (core, initialUpdates, explicitGroupElementIds = []) => {
|
|
245
347
|
if (!Array.isArray(initialUpdates)) {
|
|
246
348
|
return failGroupPreparation('property updates must be an array');
|
|
@@ -259,9 +361,9 @@ export const projectGroupGeometryPropertyUpdates = (core, initialUpdates, explic
|
|
|
259
361
|
groupGeometryElementIds.some((elementId) => !geometryElementIdSet.has(elementId))) {
|
|
260
362
|
return failGroupPreparation('explicit Group ids must be unique geometry update targets');
|
|
261
363
|
}
|
|
262
|
-
const data = core
|
|
364
|
+
const data = createGroupHierarchyReader(core);
|
|
263
365
|
groupGeometryElementIds.forEach((elementId) => {
|
|
264
|
-
if (data
|
|
366
|
+
if (data(elementId)?.type !== EntityTypes.GROUP) {
|
|
265
367
|
return failGroupPreparation(`explicit geometry target "${elementId}" is not an official Group`);
|
|
266
368
|
}
|
|
267
369
|
});
|
|
@@ -274,37 +376,19 @@ export const projectGroupGeometryPropertyUpdates = (core, initialUpdates, explic
|
|
|
274
376
|
...stagedGeometryValues
|
|
275
377
|
});
|
|
276
378
|
});
|
|
379
|
+
for (const id of groupGeometryElementIds) {
|
|
380
|
+
const values = projection.updatesByElementId.get(id);
|
|
381
|
+
if (values && ('width' in values || 'height' in values)) {
|
|
382
|
+
resizeGroupContents(projection, data, id, values);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
277
385
|
getAffectedGroupIds(data, groupGeometryElementIds).forEach((groupId) => {
|
|
278
386
|
normalizeGroupBoundsInTransaction(projection, data, groupId);
|
|
279
387
|
});
|
|
280
388
|
return getProjectedPropertyUpdates(projection);
|
|
281
389
|
};
|
|
282
|
-
export
|
|
283
|
-
|
|
284
|
-
return Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
|
|
285
|
-
}
|
|
286
|
-
let minX = Infinity;
|
|
287
|
-
let minY = Infinity;
|
|
288
|
-
let maxX = -Infinity;
|
|
289
|
-
let maxY = -Infinity;
|
|
290
|
-
rectangles.forEach(({ x, y, width, height }) => {
|
|
291
|
-
const values = [x, y, width, height];
|
|
292
|
-
if (values.some((value) => !Number.isFinite(value))) {
|
|
293
|
-
return failGroupGeometry('direct-child rectangle is invalid');
|
|
294
|
-
}
|
|
295
|
-
minX = Math.min(minX, x, x + width);
|
|
296
|
-
minY = Math.min(minY, y, y + height);
|
|
297
|
-
maxX = Math.max(maxX, x, x + width);
|
|
298
|
-
maxY = Math.max(maxY, y, y + height);
|
|
299
|
-
});
|
|
300
|
-
return Object.freeze({
|
|
301
|
-
x: minX,
|
|
302
|
-
y: minY,
|
|
303
|
-
width: maxX - minX,
|
|
304
|
-
height: maxY - minY
|
|
305
|
-
});
|
|
306
|
-
};
|
|
307
|
-
export const prepareGroupOperation = (core, elementIds) => {
|
|
390
|
+
export { deriveGroupBounds } from '../group-bounds.js';
|
|
391
|
+
const readGroupOperation = (core, elementIds) => {
|
|
308
392
|
if (!Array.isArray(elementIds) ||
|
|
309
393
|
elementIds.length === 0 ||
|
|
310
394
|
elementIds.some((elementId) => typeof elementId !== 'string' || elementId.length === 0)) {
|
|
@@ -313,9 +397,9 @@ export const prepareGroupOperation = (core, elementIds) => {
|
|
|
313
397
|
if (new Set(elementIds).size !== elementIds.length) {
|
|
314
398
|
return failGroupPreparation('element ids must be unique');
|
|
315
399
|
}
|
|
316
|
-
const data = core
|
|
400
|
+
const data = createGroupHierarchyReader(core);
|
|
317
401
|
const elements = elementIds.map((elementId) => {
|
|
318
|
-
const element = data
|
|
402
|
+
const element = data(elementId);
|
|
319
403
|
if (!element) {
|
|
320
404
|
return failGroupPreparation(`element "${elementId}" is missing`);
|
|
321
405
|
}
|
|
@@ -332,16 +416,20 @@ export const prepareGroupOperation = (core, elementIds) => {
|
|
|
332
416
|
if (canonicalIds.length !== elementIds.length) {
|
|
333
417
|
return failGroupPreparation('element ids must each have one canonical parent membership');
|
|
334
418
|
}
|
|
335
|
-
return
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
419
|
+
return {
|
|
420
|
+
data,
|
|
421
|
+
operation: Object.freeze({
|
|
422
|
+
kind: 'group',
|
|
423
|
+
parentId,
|
|
424
|
+
groupIndex: children.indexOf(canonicalIds[0]),
|
|
425
|
+
elementIds: Object.freeze([...canonicalIds])
|
|
426
|
+
})
|
|
427
|
+
};
|
|
341
428
|
};
|
|
429
|
+
export const prepareGroupOperation = (core, elementIds) => readGroupOperation(core, elementIds).operation;
|
|
342
430
|
export const prepareUngroupOperation = (core, groupId) => {
|
|
343
|
-
const data = core
|
|
344
|
-
const group = data
|
|
431
|
+
const data = createGroupHierarchyReader(core);
|
|
432
|
+
const group = data(groupId);
|
|
345
433
|
if (!group ||
|
|
346
434
|
group.type !== EntityTypes.GROUP ||
|
|
347
435
|
!Array.isArray(group.children)) {
|
|
@@ -362,9 +450,9 @@ export const prepareUngroupOperation = (core, groupId) => {
|
|
|
362
450
|
});
|
|
363
451
|
};
|
|
364
452
|
export const groupElements = (core, elementIds, options) => {
|
|
365
|
-
const preparedGroup =
|
|
453
|
+
const { operation: preparedGroup, data } = readGroupOperation(core, elementIds);
|
|
366
454
|
const geometryProjection = createGroupGeometryProjection(core);
|
|
367
|
-
const rectangles = preparedGroup.elementIds.map((elementId) => readRectangle(geometryProjection, elementId));
|
|
455
|
+
const rectangles = preparedGroup.elementIds.map((elementId) => readRectangle(geometryProjection, elementId, data(elementId)?.type));
|
|
368
456
|
const bounds = deriveGroupBounds(rectangles);
|
|
369
457
|
const groupId = runTransaction(() => {
|
|
370
458
|
const createdGroupId = core.createElementInParent({
|
|
@@ -398,7 +486,7 @@ export const ungroupElement = (core, groupId, options) => {
|
|
|
398
486
|
const preparedUngroup = prepareUngroupOperation(core, groupId);
|
|
399
487
|
const geometryProjection = createGroupGeometryProjection(core);
|
|
400
488
|
const groupPosition = preparedUngroup.elementIds.length > 0
|
|
401
|
-
?
|
|
489
|
+
? readRectangle(geometryProjection, groupId)
|
|
402
490
|
: undefined;
|
|
403
491
|
const childPositions = preparedUngroup.elementIds.map((elementId) => ({
|
|
404
492
|
elementId,
|
|
@@ -412,9 +500,10 @@ export const ungroupElement = (core, groupId, options) => {
|
|
|
412
500
|
targetIndex: preparedUngroup.groupIndex
|
|
413
501
|
}, options);
|
|
414
502
|
childPositions.forEach(({ elementId, x, y }) => {
|
|
503
|
+
const offset = transformGroupOffset(groupPosition, { x, y }, false);
|
|
415
504
|
stageGeometryValues(geometryProjection, elementId, {
|
|
416
|
-
x: x + groupPosition.x,
|
|
417
|
-
y: y + groupPosition.y
|
|
505
|
+
x: offset.x + groupPosition.x,
|
|
506
|
+
y: offset.y + groupPosition.y
|
|
418
507
|
});
|
|
419
508
|
});
|
|
420
509
|
applyGeometryProjection(core, geometryProjection, options);
|
|
@@ -428,7 +517,7 @@ export const ungroupElement = (core, groupId, options) => {
|
|
|
428
517
|
});
|
|
429
518
|
};
|
|
430
519
|
export const normalizeGroupsForElements = (core, elementIds, options) => {
|
|
431
|
-
const data = core
|
|
520
|
+
const data = createGroupHierarchyReader(core);
|
|
432
521
|
const geometryProjection = createGroupGeometryProjection(core);
|
|
433
522
|
const deepestFirstGroupIds = getAffectedGroupIds(data, elementIds);
|
|
434
523
|
return runTransaction(() => {
|
|
@@ -438,8 +527,26 @@ export const normalizeGroupsForElements = (core, elementIds, options) => {
|
|
|
438
527
|
});
|
|
439
528
|
};
|
|
440
529
|
export const moveElementsWithGroupGeometry = (core, request, options) => {
|
|
441
|
-
const beforeData = core
|
|
530
|
+
const beforeData = createGroupHierarchyReader(core);
|
|
442
531
|
const geometryProjection = createGroupGeometryProjection(core);
|
|
532
|
+
const beforePositions = new Map();
|
|
533
|
+
if (Array.isArray(request?.elementIds)) {
|
|
534
|
+
const toWorldByParent = new Map();
|
|
535
|
+
request.elementIds.forEach((elementId) => {
|
|
536
|
+
const element = beforeData(elementId);
|
|
537
|
+
const sourceIsGroup = element?.parentId &&
|
|
538
|
+
beforeData(element.parentId)?.type === EntityTypes.GROUP;
|
|
539
|
+
const targetIsGroup = beforeData(request.targetParentId)?.type === EntityTypes.GROUP;
|
|
540
|
+
if (element?.parentId && (sourceIsGroup || targetIsGroup)) {
|
|
541
|
+
let toWorld = toWorldByParent.get(element.parentId);
|
|
542
|
+
if (!toWorld) {
|
|
543
|
+
toWorld = createHierarchyPointTransform(geometryProjection, beforeData, element.parentId, false);
|
|
544
|
+
toWorldByParent.set(element.parentId, toWorld);
|
|
545
|
+
}
|
|
546
|
+
beforePositions.set(elementId, toWorld(readPosition(geometryProjection, elementId)));
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}
|
|
443
550
|
return runTransaction(() => {
|
|
444
551
|
const result = core.moveElements(request, options);
|
|
445
552
|
if (result.moves.length === 0) {
|
|
@@ -447,36 +554,33 @@ export const moveElementsWithGroupGeometry = (core, request, options) => {
|
|
|
447
554
|
}
|
|
448
555
|
const sourceParentId = result.moves[0].before.parentId;
|
|
449
556
|
const targetParentId = result.moves[0].after.parentId;
|
|
450
|
-
const afterData = core
|
|
451
|
-
const sourceIsGroup = beforeData
|
|
452
|
-
const targetIsGroup = afterData
|
|
557
|
+
const afterData = createGroupHierarchyReader(core);
|
|
558
|
+
const sourceIsGroup = beforeData(sourceParentId)?.type === EntityTypes.GROUP;
|
|
559
|
+
const targetIsGroup = afterData(targetParentId)?.type === EntityTypes.GROUP;
|
|
453
560
|
if (!sourceIsGroup && !targetIsGroup) {
|
|
454
561
|
return result;
|
|
455
562
|
}
|
|
456
|
-
const worldPositions = result.elementIds.map((elementId) =>
|
|
457
|
-
elementId
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
563
|
+
const worldPositions = result.elementIds.map((elementId) => {
|
|
564
|
+
const position = beforePositions.get(elementId);
|
|
565
|
+
if (!position) {
|
|
566
|
+
return failGroupGeometry(`missing before position for "${elementId}"`);
|
|
567
|
+
}
|
|
568
|
+
return { elementId, ...position };
|
|
569
|
+
});
|
|
570
|
+
const toParent = createHierarchyPointTransform(geometryProjection, afterData, targetParentId, true);
|
|
463
571
|
worldPositions.forEach(({ elementId, x, y }) => {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
y: y - targetOrigin.y
|
|
467
|
-
});
|
|
572
|
+
const local = toParent({ x, y });
|
|
573
|
+
stageGeometryValues(geometryProjection, elementId, local);
|
|
468
574
|
});
|
|
469
575
|
const groupIds = new Set();
|
|
470
576
|
const affectedParentIds = [sourceParentId, targetParentId];
|
|
471
577
|
affectedParentIds.forEach((parentId) => {
|
|
472
|
-
let element = afterData
|
|
578
|
+
let element = afterData(parentId);
|
|
473
579
|
while (element) {
|
|
474
580
|
if (element.type === EntityTypes.GROUP) {
|
|
475
581
|
groupIds.add(element.id);
|
|
476
582
|
}
|
|
477
|
-
element = element.parentId
|
|
478
|
-
? afterData.elements[element.parentId]
|
|
479
|
-
: undefined;
|
|
583
|
+
element = element.parentId ? afterData(element.parentId) : undefined;
|
|
480
584
|
}
|
|
481
585
|
});
|
|
482
586
|
const deepestFirstGroupIds = [...groupIds].sort((first, second) => getHierarchyDepth(afterData, second) -
|