@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.
Files changed (257) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/README.md +11 -7
  3. package/dist/agent-activity.d.ts +61 -0
  4. package/dist/agent-activity.d.ts.map +1 -0
  5. package/dist/agent-activity.js +224 -0
  6. package/dist/agent-activity.js.map +1 -0
  7. package/dist/catalog.d.ts.map +1 -1
  8. package/dist/catalog.js +2 -2
  9. package/dist/catalog.js.map +1 -1
  10. package/dist/cleanup-reporter.d.ts.map +1 -1
  11. package/dist/cleanup-reporter.js.map +1 -1
  12. package/dist/components/fills.d.ts +3 -1
  13. package/dist/components/fills.d.ts.map +1 -1
  14. package/dist/components/fills.js +74 -0
  15. package/dist/components/fills.js.map +1 -1
  16. package/dist/components/frame.d.ts +2 -2
  17. package/dist/components/frame.d.ts.map +1 -1
  18. package/dist/components/frame.js +1 -0
  19. package/dist/components/frame.js.map +1 -1
  20. package/dist/components/group.d.ts +9 -21
  21. package/dist/components/group.d.ts.map +1 -1
  22. package/dist/components/group.js +188 -84
  23. package/dist/components/group.js.map +1 -1
  24. package/dist/components/oval.d.ts +2 -2
  25. package/dist/components/oval.d.ts.map +1 -1
  26. package/dist/components/oval.js +3 -1
  27. package/dist/components/oval.js.map +1 -1
  28. package/dist/components/rectangle.d.ts +2 -2
  29. package/dist/components/rectangle.d.ts.map +1 -1
  30. package/dist/components/rectangle.js +3 -1
  31. package/dist/components/rectangle.js.map +1 -1
  32. package/dist/components/shape-hit-area.d.ts.map +1 -1
  33. package/dist/components/shape-hit-area.js.map +1 -1
  34. package/dist/components/text.d.ts +9 -0
  35. package/dist/components/text.d.ts.map +1 -0
  36. package/dist/components/text.js +61 -0
  37. package/dist/components/text.js.map +1 -0
  38. package/dist/components/vector-compound-fill.d.ts +8 -0
  39. package/dist/components/vector-compound-fill.d.ts.map +1 -0
  40. package/dist/components/vector-compound-fill.js +149 -0
  41. package/dist/components/vector-compound-fill.js.map +1 -0
  42. package/dist/components/vector.d.ts.map +1 -1
  43. package/dist/components/vector.js +85 -565
  44. package/dist/components/vector.js.map +1 -1
  45. package/dist/composition/error.d.ts.map +1 -1
  46. package/dist/composition/error.js.map +1 -1
  47. package/dist/composition/profile-provider.d.ts +2 -1
  48. package/dist/composition/profile-provider.d.ts.map +1 -1
  49. package/dist/composition/profile-provider.js +8 -2
  50. package/dist/composition/profile-provider.js.map +1 -1
  51. package/dist/composition/resolve.d.ts +2 -0
  52. package/dist/composition/resolve.d.ts.map +1 -1
  53. package/dist/composition/resolve.js +30 -6
  54. package/dist/composition/resolve.js.map +1 -1
  55. package/dist/defaults/install.d.ts.map +1 -1
  56. package/dist/defaults/install.js +2 -1
  57. package/dist/defaults/install.js.map +1 -1
  58. package/dist/defaults/installation.d.ts.map +1 -1
  59. package/dist/defaults/installation.js +2 -0
  60. package/dist/defaults/installation.js.map +1 -1
  61. package/dist/defaults/modules/selection.d.ts.map +1 -1
  62. package/dist/defaults/modules/selection.js.map +1 -1
  63. package/dist/defaults/modules/vector-editing.d.ts.map +1 -1
  64. package/dist/defaults/modules/vector-editing.js.map +1 -1
  65. package/dist/defaults/owned-state.d.ts.map +1 -1
  66. package/dist/defaults/owned-state.js.map +1 -1
  67. package/dist/defaults/private-manager.d.ts.map +1 -1
  68. package/dist/defaults/private-manager.js +2 -1
  69. package/dist/defaults/private-manager.js.map +1 -1
  70. package/dist/events/preset-event-names.d.ts +2 -0
  71. package/dist/events/preset-event-names.d.ts.map +1 -1
  72. package/dist/events/register-events.d.ts.map +1 -1
  73. package/dist/events/register-events.js +4 -2
  74. package/dist/events/register-events.js.map +1 -1
  75. package/dist/group-bounds.d.ts +36 -0
  76. package/dist/group-bounds.d.ts.map +1 -0
  77. package/dist/group-bounds.js +141 -0
  78. package/dist/group-bounds.js.map +1 -0
  79. package/dist/index.d.ts +3 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +2 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/preset.d.ts.map +1 -1
  84. package/dist/preset.js +22 -4
  85. package/dist/preset.js.map +1 -1
  86. package/dist/props/components/anchor-points-component.d.ts.map +1 -1
  87. package/dist/props/components/anchor-points-component.js.map +1 -1
  88. package/dist/props/components/children-map-property-component.d.ts.map +1 -1
  89. package/dist/props/components/children-map-property-component.js.map +1 -1
  90. package/dist/props/components/fills-component.d.ts.map +1 -1
  91. package/dist/props/components/fills-component.js +3 -2
  92. package/dist/props/components/fills-component.js.map +1 -1
  93. package/dist/props/components/position-component.js +1 -1
  94. package/dist/props/components/position-component.js.map +1 -1
  95. package/dist/props/components/strokes-component.d.ts.map +1 -1
  96. package/dist/props/components/strokes-component.js +4 -3
  97. package/dist/props/components/strokes-component.js.map +1 -1
  98. package/dist/props/components/text-component.d.ts +67 -0
  99. package/dist/props/components/text-component.d.ts.map +1 -0
  100. package/dist/props/components/text-component.js +128 -0
  101. package/dist/props/components/text-component.js.map +1 -0
  102. package/dist/props/components/vector-networks-component.d.ts.map +1 -1
  103. package/dist/props/components/vector-networks-component.js.map +1 -1
  104. package/dist/props/components/vector-points-component.d.ts.map +1 -1
  105. package/dist/props/components/vector-points-component.js.map +1 -1
  106. package/dist/props/components/vector-segments-component.d.ts.map +1 -1
  107. package/dist/props/components/vector-segments-component.js.map +1 -1
  108. package/dist/props/register-property-schemas.d.ts.map +1 -1
  109. package/dist/props/register-property-schemas.js +6 -0
  110. package/dist/props/register-property-schemas.js.map +1 -1
  111. package/dist/render-layers/selection-overlay-render-layer.d.ts.map +1 -1
  112. package/dist/render-layers/selection-overlay-render-layer.js +7 -2
  113. package/dist/render-layers/selection-overlay-render-layer.js.map +1 -1
  114. package/dist/render-layers/vector-path-editing-render-layer.d.ts.map +1 -1
  115. package/dist/render-layers/vector-path-editing-render-layer.js.map +1 -1
  116. package/dist/selection/ids.d.ts.map +1 -1
  117. package/dist/selection/ids.js.map +1 -1
  118. package/dist/selection/register-default-selections.d.ts.map +1 -1
  119. package/dist/selection/register-default-selections.js +4 -2
  120. package/dist/selection/register-default-selections.js.map +1 -1
  121. package/dist/spatial/assets/binary.d.ts +22 -0
  122. package/dist/spatial/assets/binary.d.ts.map +1 -0
  123. package/dist/spatial/assets/binary.js +132 -0
  124. package/dist/spatial/assets/binary.js.map +1 -0
  125. package/dist/spatial/assets/decode.d.ts +23 -0
  126. package/dist/spatial/assets/decode.d.ts.map +1 -0
  127. package/dist/spatial/assets/decode.js +102 -0
  128. package/dist/spatial/assets/decode.js.map +1 -0
  129. package/dist/spatial/assets/preview-worker.d.ts +13 -0
  130. package/dist/spatial/assets/preview-worker.d.ts.map +1 -0
  131. package/dist/spatial/assets/preview-worker.js +188 -0
  132. package/dist/spatial/assets/preview-worker.js.map +1 -0
  133. package/dist/spatial/assets/scene.d.ts +13 -0
  134. package/dist/spatial/assets/scene.d.ts.map +1 -0
  135. package/dist/spatial/assets/scene.js +99 -0
  136. package/dist/spatial/assets/scene.js.map +1 -0
  137. package/dist/spatial/assets/schema.d.ts +22 -0
  138. package/dist/spatial/assets/schema.d.ts.map +1 -0
  139. package/dist/spatial/assets/schema.js +93 -0
  140. package/dist/spatial/assets/schema.js.map +1 -0
  141. package/dist/spatial/bounds.d.ts +15 -0
  142. package/dist/spatial/bounds.d.ts.map +1 -0
  143. package/dist/spatial/bounds.js +94 -0
  144. package/dist/spatial/bounds.js.map +1 -0
  145. package/dist/spatial/camera-controls.d.ts +53 -0
  146. package/dist/spatial/camera-controls.d.ts.map +1 -0
  147. package/dist/spatial/camera-controls.js +208 -0
  148. package/dist/spatial/camera-controls.js.map +1 -0
  149. package/dist/spatial/components.d.ts +20 -0
  150. package/dist/spatial/components.d.ts.map +1 -0
  151. package/dist/spatial/components.js +83 -0
  152. package/dist/spatial/components.js.map +1 -0
  153. package/dist/spatial/editing.d.ts +51 -0
  154. package/dist/spatial/editing.d.ts.map +1 -0
  155. package/dist/spatial/editing.js +152 -0
  156. package/dist/spatial/editing.js.map +1 -0
  157. package/dist/spatial/emissive-bloom.d.ts +22 -0
  158. package/dist/spatial/emissive-bloom.d.ts.map +1 -0
  159. package/dist/spatial/emissive-bloom.js +197 -0
  160. package/dist/spatial/emissive-bloom.js.map +1 -0
  161. package/dist/spatial/graphics.d.ts +9 -0
  162. package/dist/spatial/graphics.d.ts.map +1 -0
  163. package/dist/spatial/graphics.js +119 -0
  164. package/dist/spatial/graphics.js.map +1 -0
  165. package/dist/spatial/lazy-engine.d.ts +6 -0
  166. package/dist/spatial/lazy-engine.d.ts.map +1 -0
  167. package/dist/spatial/lazy-engine.js +92 -0
  168. package/dist/spatial/lazy-engine.js.map +1 -0
  169. package/dist/spatial/lighting.d.ts +28 -0
  170. package/dist/spatial/lighting.d.ts.map +1 -0
  171. package/dist/spatial/lighting.js +103 -0
  172. package/dist/spatial/lighting.js.map +1 -0
  173. package/dist/spatial/opaque-frame.d.ts +11 -0
  174. package/dist/spatial/opaque-frame.d.ts.map +1 -0
  175. package/dist/spatial/opaque-frame.js +131 -0
  176. package/dist/spatial/opaque-frame.js.map +1 -0
  177. package/dist/spatial/pose.d.ts +22 -0
  178. package/dist/spatial/pose.d.ts.map +1 -0
  179. package/dist/spatial/pose.js +83 -0
  180. package/dist/spatial/pose.js.map +1 -0
  181. package/dist/spatial/presentation.d.ts +16 -0
  182. package/dist/spatial/presentation.d.ts.map +1 -0
  183. package/dist/spatial/presentation.js +66 -0
  184. package/dist/spatial/presentation.js.map +1 -0
  185. package/dist/spatial/reflection-environment.d.ts +13 -0
  186. package/dist/spatial/reflection-environment.d.ts.map +1 -0
  187. package/dist/spatial/reflection-environment.js +63 -0
  188. package/dist/spatial/reflection-environment.js.map +1 -0
  189. package/dist/spatial/registration.d.ts +6 -0
  190. package/dist/spatial/registration.d.ts.map +1 -0
  191. package/dist/spatial/registration.js +82 -0
  192. package/dist/spatial/registration.js.map +1 -0
  193. package/dist/spatial/shadow-frame.d.ts +13 -0
  194. package/dist/spatial/shadow-frame.d.ts.map +1 -0
  195. package/dist/spatial/shadow-frame.js +60 -0
  196. package/dist/spatial/shadow-frame.js.map +1 -0
  197. package/dist/spatial/spatial-contract.d.ts +10 -0
  198. package/dist/spatial/spatial-contract.d.ts.map +1 -0
  199. package/dist/spatial/spatial-contract.js +414 -0
  200. package/dist/spatial/spatial-contract.js.map +1 -0
  201. package/dist/spatial/spatial-layer.d.ts +47 -0
  202. package/dist/spatial/spatial-layer.d.ts.map +1 -0
  203. package/dist/spatial/spatial-layer.js +224 -0
  204. package/dist/spatial/spatial-layer.js.map +1 -0
  205. package/dist/spatial/surface-contract.d.ts +4 -0
  206. package/dist/spatial/surface-contract.d.ts.map +1 -0
  207. package/dist/spatial/surface-contract.js +40 -0
  208. package/dist/spatial/surface-contract.js.map +1 -0
  209. package/dist/spatial/surface-textures.d.ts +8 -0
  210. package/dist/spatial/surface-textures.d.ts.map +1 -0
  211. package/dist/spatial/surface-textures.js +46 -0
  212. package/dist/spatial/surface-textures.js.map +1 -0
  213. package/dist/spatial/three-engine.d.ts +91 -0
  214. package/dist/spatial/three-engine.d.ts.map +1 -0
  215. package/dist/spatial/three-engine.js +1127 -0
  216. package/dist/spatial/three-engine.js.map +1 -0
  217. package/dist/spatial/transmission-capture.d.ts +13 -0
  218. package/dist/spatial/transmission-capture.d.ts.map +1 -0
  219. package/dist/spatial/transmission-capture.js +215 -0
  220. package/dist/spatial/transmission-capture.js.map +1 -0
  221. package/dist/spatial-assets.d.ts +4 -0
  222. package/dist/spatial-assets.d.ts.map +1 -0
  223. package/dist/spatial-assets.js +4 -0
  224. package/dist/spatial-assets.js.map +1 -0
  225. package/dist/spatial-contract.d.ts +3 -0
  226. package/dist/spatial-contract.d.ts.map +1 -0
  227. package/dist/spatial-contract.js +3 -0
  228. package/dist/spatial-contract.js.map +1 -0
  229. package/dist/spatial-engine.d.ts +5 -0
  230. package/dist/spatial-engine.d.ts.map +1 -0
  231. package/dist/spatial-engine.js +5 -0
  232. package/dist/spatial-engine.js.map +1 -0
  233. package/dist/spatial.d.ts +9 -0
  234. package/dist/spatial.d.ts.map +1 -0
  235. package/dist/spatial.js +9 -0
  236. package/dist/spatial.js.map +1 -0
  237. package/dist/subscriptions/data-channel.d.ts.map +1 -1
  238. package/dist/subscriptions/data-channel.js +372 -124
  239. package/dist/subscriptions/data-channel.js.map +1 -1
  240. package/dist/subscriptions/render-system.d.ts.map +1 -1
  241. package/dist/subscriptions/render-system.js +4 -2
  242. package/dist/subscriptions/render-system.js.map +1 -1
  243. package/dist/subscriptions/shared-channels.d.ts.map +1 -1
  244. package/dist/subscriptions/shared-channels.js +4 -2
  245. package/dist/subscriptions/shared-channels.js.map +1 -1
  246. package/dist/subscriptions/vector-selection.d.ts +4 -0
  247. package/dist/subscriptions/vector-selection.d.ts.map +1 -0
  248. package/dist/subscriptions/vector-selection.js +175 -0
  249. package/dist/subscriptions/vector-selection.js.map +1 -0
  250. package/dist/types.d.ts +2 -0
  251. package/dist/types.d.ts.map +1 -1
  252. package/dist/ui/register-properties.d.ts.map +1 -1
  253. package/dist/ui/register-properties.js +3 -2
  254. package/dist/ui/register-properties.js.map +1 -1
  255. package/dist/vector/synthetic-handle.d.ts.map +1 -1
  256. package/dist/vector/synthetic-handle.js.map +1 -1
  257. package/package.json +44 -12
@@ -1,4 +1,4 @@
1
- import type { ComponentDefinition, RenderStrategy } from '@asyra/core';
1
+ import type { ComponentDefinition, EngineNeutralRenderStrategy } from '@asyra/core';
2
2
  export declare const FRAME_COMPONENT_DEFINITION: ComponentDefinition;
3
- export declare const FRAME_RENDER_STRATEGY: RenderStrategy;
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,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAStE,eAAO,MAAM,0BAA0B,EAAE,mBAuBxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,cAkBnC,CAAA"}
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"}
@@ -40,5 +40,6 @@ export const FRAME_RENDER_STRATEGY = (graphic, data) => {
40
40
  applyRenderableFill(graphic, data.fills, { replayPath });
41
41
  graphic.x = data.x;
42
42
  graphic.y = data.y;
43
+ graphic.rotation = data.rotation ?? 0;
43
44
  };
44
45
  //# sourceMappingURL=frame.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/components/frame.ts"],"names":[],"mappings":"AACA,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;IAC7D,IAAI,EAAE,WAAW,CAAC,KAAK;IACvB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,OAAO;IACnB,YAAY,EAAE,mBAAmB;IACjC,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE;QACV;YACE,IAAI,EAAE,aAAa,CAAC,QAAQ;YAC5B,IAAI,EAAE,aAAa,CAAC,QAAQ;YAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC;SAC9B;QACD;YACE,IAAI,EAAE,aAAa,CAAC,SAAS;YAC7B,IAAI,EAAE,aAAa,CAAC,SAAS;YAC7B,KAAK,EAAE,CAAC,OAAO,EAAE,QA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derStrategy } from '@asyra/core';
2
- import { type EVENT_OPTIONS, type MoveHierarchyRequest, type MoveHierarchyResult, type RemoveSubtreeResult, type SceneTreeRawData } from '@asyra/utils';
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: RenderStrategy;
5
+ export declare const GROUP_RENDER_STRATEGY: EngineNeutralRenderStrategy;
5
6
  export interface GroupHierarchyReadCore {
6
- sceneTreeSaveData: () => SceneTreeRawData;
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) => readonly string[];
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 interface GroupBounds {
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 declare const deriveGroupBounds: (rectangles: readonly Pick<ElementRectangle, "x" | "y" | "width" | "height">[]) => GroupBounds;
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,O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M,sBAAsB,EAC5B,YAAY,SAAS,MAAM,EAAE,KAC5B,sBAAwE,CAAA;AAE3E,eAAO,MAAM,uBAAuB,GAClC,MAAM,sBAAsB,EAC5B,SAAS,MAAM,KACd,wBA+BF,CAAA;AAED,eAAO,MAAM,aAAa,GACxB,MAAM,kBAAkB,EACxB,YAAY,SAAS,MAAM,EAAE,EAC7B,UAAU,aAAa,KACtB,oBAkDF,CAAA;AAED,eAAO,MAAM,cAAc,GACzB,MAAM,kBAAkB,EACxB,SAAS,MAAM,EACf,UAAU,aAAa,KACtB,sBAyCF,CAAA;AAED,eAAO,MAAM,0BAA0B,GACrC,MAAM,kBAAkB,EACxB,YAAY,SAAS,MAAM,EAAE,EAC7B,UAAU,aAAa,KACtB,SAAS,qBAAqB,EAchC,CAAA;AAED,eAAO,MAAM,6BAA6B,GACxC,MAAM,kBAAkB,EACxB,SAAS,oBAAoB,EAC7B,UAAU,aAAa,KACtB,mBA0GF,CAAA"}
@@ -1,3 +1,4 @@
1
+ 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
- // No visual rendering for group itself besides updating position
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.elements[parentId];
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.elements[groupId];
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 + childBounds.x,
75
- y: groupRectangle.y + childBounds.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 getElementWorldPosition = (projection, data, elementId) => {
191
+ const createHierarchyPointTransform = (projection, data, elementId, inverse) => {
161
192
  let currentId = elementId;
162
- let x = 0;
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.elements[currentId];
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
- const position = readPosition(projection, currentId);
178
- x += position.x;
179
- y += position.y;
207
+ poses.push(readRectangle(projection, currentId));
180
208
  currentId = element.parentId ?? '';
181
209
  }
182
- return Object.freeze({ x, y });
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.elements[elementId];
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.elements[element.parentId];
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.elements[elementId];
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
- const parent = data.elements[element.parentId];
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.sceneTreeSaveData();
364
+ const data = createGroupHierarchyReader(core);
263
365
  groupGeometryElementIds.forEach((elementId) => {
264
- if (data.elements[elementId]?.type !== EntityTypes.GROUP) {
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 const deriveGroupBounds = (rectangles) => {
283
- if (rectangles.length === 0) {
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.sceneTreeSaveData();
400
+ const data = createGroupHierarchyReader(core);
317
401
  const elements = elementIds.map((elementId) => {
318
- const element = data.elements[elementId];
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 Object.freeze({
336
- kind: 'group',
337
- parentId,
338
- groupIndex: children.indexOf(canonicalIds[0]),
339
- elementIds: Object.freeze([...canonicalIds])
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.sceneTreeSaveData();
344
- const group = data.elements[groupId];
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 = prepareGroupOperation(core, elementIds);
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
- ? readPosition(geometryProjection, groupId)
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.sceneTreeSaveData();
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.sceneTreeSaveData();
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.sceneTreeSaveData();
451
- const sourceIsGroup = beforeData.elements[sourceParentId]?.type === EntityTypes.GROUP;
452
- const targetIsGroup = afterData.elements[targetParentId]?.type === EntityTypes.GROUP;
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
- ...getElementWorldPosition(geometryProjection, beforeData, elementId)
459
- }));
460
- const targetOrigin = afterData.elements[targetParentId]?.type === EntityTypes.WORKSPACE
461
- ? { x: 0, y: 0 }
462
- : getElementWorldPosition(geometryProjection, afterData, targetParentId);
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
- stageGeometryValues(geometryProjection, elementId, {
465
- x: x - targetOrigin.x,
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.elements[parentId];
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) -