@kritzel/engine 0.4.31

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 (373) hide show
  1. package/LICENSE.md +50 -0
  2. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  3. package/dist/cjs/engine.constants-CakmdKMW.js +28206 -0
  4. package/dist/cjs/index-BbbWU2aN.js +1742 -0
  5. package/dist/cjs/index.cjs.js +4232 -0
  6. package/dist/cjs/kritzel-awareness-cursors_5.cjs.entry.js +28004 -0
  7. package/dist/cjs/loader.cjs.js +13 -0
  8. package/dist/cjs/stencil.cjs.js +25 -0
  9. package/dist/collection/classes/core/core.class.js +1389 -0
  10. package/dist/collection/classes/core/reviver.class.js +124 -0
  11. package/dist/collection/classes/core/store.class.js +337 -0
  12. package/dist/collection/classes/core/viewport.class.js +794 -0
  13. package/dist/collection/classes/core/workspace.class.js +112 -0
  14. package/dist/collection/classes/handlers/base.handler.js +20 -0
  15. package/dist/collection/classes/handlers/context-menu.handler.js +170 -0
  16. package/dist/collection/classes/handlers/hover.handler.js +35 -0
  17. package/dist/collection/classes/handlers/key.handler.js +162 -0
  18. package/dist/collection/classes/handlers/line-handle.handler.js +475 -0
  19. package/dist/collection/classes/handlers/move.handler.js +295 -0
  20. package/dist/collection/classes/handlers/resize.handler.js +327 -0
  21. package/dist/collection/classes/handlers/rotation.handler.js +174 -0
  22. package/dist/collection/classes/handlers/selection.handler.js +526 -0
  23. package/dist/collection/classes/managers/anchor.manager.js +1476 -0
  24. package/dist/collection/classes/managers/browser-permission.manager.js +64 -0
  25. package/dist/collection/classes/managers/clipboard.manager.js +346 -0
  26. package/dist/collection/classes/managers/clipboard.types.js +1 -0
  27. package/dist/collection/classes/managers/cursor.manager.js +139 -0
  28. package/dist/collection/classes/managers/license.manager.js +341 -0
  29. package/dist/collection/classes/managers/localization.manager.js +227 -0
  30. package/dist/collection/classes/managers/theme.manager.js +206 -0
  31. package/dist/collection/classes/objects/base-object.class.js +462 -0
  32. package/dist/collection/classes/objects/dynamic-object.class.js +437 -0
  33. package/dist/collection/classes/objects/group.class.js +590 -0
  34. package/dist/collection/classes/objects/image.class.js +500 -0
  35. package/dist/collection/classes/objects/line.class.js +789 -0
  36. package/dist/collection/classes/objects/path.class.js +578 -0
  37. package/dist/collection/classes/objects/selection-box.class.js +32 -0
  38. package/dist/collection/classes/objects/selection-group.class.js +752 -0
  39. package/dist/collection/classes/objects/shape.class.js +628 -0
  40. package/dist/collection/classes/objects/text.class.js +461 -0
  41. package/dist/collection/classes/providers/assets/asset-resolver.class.js +536 -0
  42. package/dist/collection/classes/providers/assets/http-asset-provider.class.js +111 -0
  43. package/dist/collection/classes/providers/assets/indexeddb-asset-provider.class.js +241 -0
  44. package/dist/collection/classes/providers/assets/presigned-asset-provider.class.js +86 -0
  45. package/dist/collection/classes/providers/paste-intent/event-paste-intent.provider.js +48 -0
  46. package/dist/collection/classes/providers/paste-intent/ios-paste-intent.provider.js +16 -0
  47. package/dist/collection/classes/providers/paste-intent/navigator-paste-intent.provider.js +86 -0
  48. package/dist/collection/classes/providers/sync/broadcast-sync-provider.class.js +100 -0
  49. package/dist/collection/classes/providers/sync/hocuspocus-sync-provider.class.js +333 -0
  50. package/dist/collection/classes/providers/sync/in-memory-sync-provider.class.js +69 -0
  51. package/dist/collection/classes/providers/sync/indexeddb-sync-provider.class.js +39 -0
  52. package/dist/collection/classes/providers/sync/websocket-sync-provider.class.js +110 -0
  53. package/dist/collection/classes/registries/dynamic-object-renderer.registry.js +52 -0
  54. package/dist/collection/classes/registries/font-registry.class.js +161 -0
  55. package/dist/collection/classes/registries/icon-registry.class.js +118 -0
  56. package/dist/collection/classes/registries/paste-intent-provider.registry.js +26 -0
  57. package/dist/collection/classes/registries/tool.registry.js +69 -0
  58. package/dist/collection/classes/structures/app-state-map.structure.js +461 -0
  59. package/dist/collection/classes/structures/object-map.structure.js +1103 -0
  60. package/dist/collection/classes/structures/quadtree.structure.js +251 -0
  61. package/dist/collection/classes/tools/base-tool.class.js +88 -0
  62. package/dist/collection/classes/tools/brush-tool.class.js +236 -0
  63. package/dist/collection/classes/tools/eraser-tool.class.js +133 -0
  64. package/dist/collection/classes/tools/image-tool.class.js +152 -0
  65. package/dist/collection/classes/tools/line-tool.class.js +249 -0
  66. package/dist/collection/classes/tools/selection-tool.class.js +611 -0
  67. package/dist/collection/classes/tools/shape-tool.class.js +251 -0
  68. package/dist/collection/classes/tools/text-tool.class.js +179 -0
  69. package/dist/collection/collection-manifest.json +17 -0
  70. package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.css +115 -0
  71. package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.js +380 -0
  72. package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.css +10 -0
  73. package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.js +153 -0
  74. package/dist/collection/components/kritzel-engine/kritzel-engine.css +81 -0
  75. package/dist/collection/components/kritzel-engine/kritzel-engine.js +6345 -0
  76. package/dist/collection/components/kritzel-icon/kritzel-icon.css +18 -0
  77. package/dist/collection/components/kritzel-icon/kritzel-icon.js +93 -0
  78. package/dist/collection/components/kritzel-watermark/kritzel-watermark.css +29 -0
  79. package/dist/collection/components/kritzel-watermark/kritzel-watermark.js +83 -0
  80. package/dist/collection/configs/default-asset-storage.config.js +9 -0
  81. package/dist/collection/configs/default-brush-tool.config.js +9 -0
  82. package/dist/collection/configs/default-engine-config.js +73 -0
  83. package/dist/collection/configs/default-line-tool.config.js +12 -0
  84. package/dist/collection/configs/default-shape-tool.config.js +15 -0
  85. package/dist/collection/configs/default-sync.config.js +6 -0
  86. package/dist/collection/configs/default-text-tool.config.js +12 -0
  87. package/dist/collection/constants/color-palette.constants.js +40 -0
  88. package/dist/collection/constants/core.constants.js +1 -0
  89. package/dist/collection/constants/engine.constants.js +4 -0
  90. package/dist/collection/constants/license.constants.js +25 -0
  91. package/dist/collection/constants/schema.constants.js +4 -0
  92. package/dist/collection/constants/storage.constants.js +1 -0
  93. package/dist/collection/constants/stroke-size.constants.js +2 -0
  94. package/dist/collection/constants/text-tool-fonts.constants.js +18 -0
  95. package/dist/collection/constants/version.js +6 -0
  96. package/dist/collection/enums/alignment.enum.js +9 -0
  97. package/dist/collection/enums/event-button.enum.js +6 -0
  98. package/dist/collection/enums/handle-type.enum.js +7 -0
  99. package/dist/collection/enums/shape-type.enum.js +6 -0
  100. package/dist/collection/events/active-workspace-change.event.js +1 -0
  101. package/dist/collection/events/editor-is-ready.event.js +1 -0
  102. package/dist/collection/events/login.event.js +1 -0
  103. package/dist/collection/helpers/alignment.helper.js +73 -0
  104. package/dist/collection/helpers/class.helper.js +5 -0
  105. package/dist/collection/helpers/color.helper.js +106 -0
  106. package/dist/collection/helpers/cursor.helper.js +57 -0
  107. package/dist/collection/helpers/devices.helper.js +28 -0
  108. package/dist/collection/helpers/event.helper.js +58 -0
  109. package/dist/collection/helpers/geometry.helper.js +149 -0
  110. package/dist/collection/helpers/html.helper.js +116 -0
  111. package/dist/collection/helpers/image-file.helper.js +6 -0
  112. package/dist/collection/helpers/keyboard.helper.js +55 -0
  113. package/dist/collection/helpers/localization.helper.js +25 -0
  114. package/dist/collection/helpers/math.helper.js +8 -0
  115. package/dist/collection/helpers/migration.helper.js +45 -0
  116. package/dist/collection/helpers/object.helper.js +29 -0
  117. package/dist/collection/helpers/svg-export.helper.js +655 -0
  118. package/dist/collection/helpers/theme.helper.js +77 -0
  119. package/dist/collection/helpers/tool-config.helper.js +63 -0
  120. package/dist/collection/helpers/wheel.helper.js +113 -0
  121. package/dist/collection/index.js +107 -0
  122. package/dist/collection/interfaces/anchor.interface.js +1 -0
  123. package/dist/collection/interfaces/arrow-head.interface.js +1 -0
  124. package/dist/collection/interfaces/asset-provider.interface.js +1 -0
  125. package/dist/collection/interfaces/asset-storage-config.interface.js +1 -0
  126. package/dist/collection/interfaces/asset.interface.js +1 -0
  127. package/dist/collection/interfaces/bounding-box.interface.js +1 -0
  128. package/dist/collection/interfaces/clonable.interface.js +1 -0
  129. package/dist/collection/interfaces/context-menu-item.interface.js +1 -0
  130. package/dist/collection/interfaces/context-menu-state.interface.js +1 -0
  131. package/dist/collection/interfaces/debug-info.interface.js +1 -0
  132. package/dist/collection/interfaces/dialog.interface.js +1 -0
  133. package/dist/collection/interfaces/document-metadata.interface.js +1 -0
  134. package/dist/collection/interfaces/dynamic-object-renderer.interface.js +1 -0
  135. package/dist/collection/interfaces/engine-state.interface.js +1 -0
  136. package/dist/collection/interfaces/font.interface.js +1 -0
  137. package/dist/collection/interfaces/localization.interface.js +1 -0
  138. package/dist/collection/interfaces/login-config.interface.js +1 -0
  139. package/dist/collection/interfaces/master-detail.interface.js +1 -0
  140. package/dist/collection/interfaces/menu-item.interface.js +1 -0
  141. package/dist/collection/interfaces/migration.interface.js +1 -0
  142. package/dist/collection/interfaces/notification.interface.js +1 -0
  143. package/dist/collection/interfaces/object-change-event.interface.js +1 -0
  144. package/dist/collection/interfaces/object-export.interface.js +1 -0
  145. package/dist/collection/interfaces/object.interface.js +1 -0
  146. package/dist/collection/interfaces/paste-intent-provider.interface.js +1 -0
  147. package/dist/collection/interfaces/point.interface.js +1 -0
  148. package/dist/collection/interfaces/polygon.interface.js +1 -0
  149. package/dist/collection/interfaces/remote-cursor.interface.js +1 -0
  150. package/dist/collection/interfaces/selection-state.interface.js +1 -0
  151. package/dist/collection/interfaces/serializable.interface.js +1 -0
  152. package/dist/collection/interfaces/settings.interface.js +1 -0
  153. package/dist/collection/interfaces/share.interface.js +1 -0
  154. package/dist/collection/interfaces/shortcut.interface.js +1 -0
  155. package/dist/collection/interfaces/sync-config.interface.js +21 -0
  156. package/dist/collection/interfaces/sync-provider.interface.js +1 -0
  157. package/dist/collection/interfaces/theme.interface.js +1 -0
  158. package/dist/collection/interfaces/tool-config.interface.js +1 -0
  159. package/dist/collection/interfaces/tool-type.interface.js +1 -0
  160. package/dist/collection/interfaces/tool.interface.js +1 -0
  161. package/dist/collection/interfaces/toolbar-item.interface.js +1 -0
  162. package/dist/collection/interfaces/undo-state.interface.js +1 -0
  163. package/dist/collection/interfaces/user.interface.js +1 -0
  164. package/dist/collection/interfaces/viewport-state.interface.js +1 -0
  165. package/dist/collection/locales/de-locale.js +119 -0
  166. package/dist/collection/locales/en-locale.js +120 -0
  167. package/dist/collection/locales/fr-locale.js +119 -0
  168. package/dist/collection/migrations/app-state.migrations.js +47 -0
  169. package/dist/collection/migrations/workspace.migrations.js +67 -0
  170. package/dist/collection/themes/dark-theme.js +340 -0
  171. package/dist/collection/themes/light-theme.js +346 -0
  172. package/dist/collection/types/deep-readonly.type.js +1 -0
  173. package/dist/collection/types/state.types.js +1 -0
  174. package/dist/components/index.d.ts +47 -0
  175. package/dist/components/index.js +4143 -0
  176. package/dist/components/kritzel-awareness-cursors.d.ts +11 -0
  177. package/dist/components/kritzel-awareness-cursors.js +6 -0
  178. package/dist/components/kritzel-cursor-trail.d.ts +11 -0
  179. package/dist/components/kritzel-cursor-trail.js +6 -0
  180. package/dist/components/kritzel-engine.d.ts +11 -0
  181. package/dist/components/kritzel-engine.js +52641 -0
  182. package/dist/components/kritzel-icon.d.ts +11 -0
  183. package/dist/components/kritzel-icon.js +6 -0
  184. package/dist/components/kritzel-watermark.d.ts +11 -0
  185. package/dist/components/kritzel-watermark.js +6 -0
  186. package/dist/components/p-B2Htv9ou.js +49 -0
  187. package/dist/components/p-BvRGQvVI.js +3456 -0
  188. package/dist/components/p-CfSx6HU_.js +1469 -0
  189. package/dist/components/p-YP8wAcF4.js +122 -0
  190. package/dist/components/p-fx6msYHJ.js +167 -0
  191. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  192. package/dist/esm/engine.constants-Bl5-pbq-.js +28143 -0
  193. package/dist/esm/index-BU9Mv7y0.js +1715 -0
  194. package/dist/esm/index.js +4134 -0
  195. package/dist/esm/kritzel-awareness-cursors_5.entry.js +27978 -0
  196. package/dist/esm/loader.js +11 -0
  197. package/dist/esm/stencil.js +21 -0
  198. package/dist/index.cjs.js +1 -0
  199. package/dist/index.js +1 -0
  200. package/dist/stencil/index.esm.js +4134 -0
  201. package/dist/stencil/p-BU9Mv7y0.js +1702 -0
  202. package/dist/stencil/p-Bl5-pbq-.js +28143 -0
  203. package/dist/stencil/p-DQuL1Twl.js +3 -0
  204. package/dist/stencil/p-f0a8b7af.entry.js +27978 -0
  205. package/dist/stencil/stencil.esm.js +21 -0
  206. package/dist/types/classes/core/core.class.d.ts +532 -0
  207. package/dist/types/classes/core/reviver.class.d.ts +32 -0
  208. package/dist/types/classes/core/store.class.d.ts +198 -0
  209. package/dist/types/classes/core/viewport.class.d.ts +256 -0
  210. package/dist/types/classes/core/workspace.class.d.ts +95 -0
  211. package/dist/types/classes/handlers/base.handler.d.ts +18 -0
  212. package/dist/types/classes/handlers/context-menu.handler.d.ts +67 -0
  213. package/dist/types/classes/handlers/hover.handler.d.ts +23 -0
  214. package/dist/types/classes/handlers/key.handler.d.ts +44 -0
  215. package/dist/types/classes/handlers/line-handle.handler.d.ts +115 -0
  216. package/dist/types/classes/handlers/move.handler.d.ts +94 -0
  217. package/dist/types/classes/handlers/resize.handler.d.ts +95 -0
  218. package/dist/types/classes/handlers/rotation.handler.d.ts +50 -0
  219. package/dist/types/classes/handlers/selection.handler.d.ts +153 -0
  220. package/dist/types/classes/managers/anchor.manager.d.ts +513 -0
  221. package/dist/types/classes/managers/browser-permission.manager.d.ts +41 -0
  222. package/dist/types/classes/managers/clipboard.manager.d.ts +71 -0
  223. package/dist/types/classes/managers/clipboard.types.d.ts +23 -0
  224. package/dist/types/classes/managers/cursor.manager.d.ts +66 -0
  225. package/dist/types/classes/managers/license.manager.d.ts +147 -0
  226. package/dist/types/classes/managers/localization.manager.d.ts +145 -0
  227. package/dist/types/classes/managers/theme.manager.d.ts +112 -0
  228. package/dist/types/classes/objects/base-object.class.d.ts +266 -0
  229. package/dist/types/classes/objects/dynamic-object.class.d.ts +148 -0
  230. package/dist/types/classes/objects/group.class.d.ts +231 -0
  231. package/dist/types/classes/objects/image.class.d.ts +246 -0
  232. package/dist/types/classes/objects/line.class.d.ts +285 -0
  233. package/dist/types/classes/objects/path.class.d.ts +220 -0
  234. package/dist/types/classes/objects/selection-box.class.d.ts +19 -0
  235. package/dist/types/classes/objects/selection-group.class.d.ts +267 -0
  236. package/dist/types/classes/objects/shape.class.d.ts +322 -0
  237. package/dist/types/classes/objects/text.class.d.ts +197 -0
  238. package/dist/types/classes/providers/assets/asset-resolver.class.d.ts +141 -0
  239. package/dist/types/classes/providers/assets/http-asset-provider.class.d.ts +79 -0
  240. package/dist/types/classes/providers/assets/indexeddb-asset-provider.class.d.ts +69 -0
  241. package/dist/types/classes/providers/assets/presigned-asset-provider.class.d.ts +69 -0
  242. package/dist/types/classes/providers/paste-intent/event-paste-intent.provider.d.ts +8 -0
  243. package/dist/types/classes/providers/paste-intent/ios-paste-intent.provider.d.ts +6 -0
  244. package/dist/types/classes/providers/paste-intent/navigator-paste-intent.provider.d.ts +9 -0
  245. package/dist/types/classes/providers/sync/broadcast-sync-provider.class.d.ts +23 -0
  246. package/dist/types/classes/providers/sync/hocuspocus-sync-provider.class.d.ts +163 -0
  247. package/dist/types/classes/providers/sync/in-memory-sync-provider.class.d.ts +39 -0
  248. package/dist/types/classes/providers/sync/indexeddb-sync-provider.class.d.ts +25 -0
  249. package/dist/types/classes/providers/sync/websocket-sync-provider.class.d.ts +63 -0
  250. package/dist/types/classes/registries/dynamic-object-renderer.registry.d.ts +32 -0
  251. package/dist/types/classes/registries/font-registry.class.d.ts +19 -0
  252. package/dist/types/classes/registries/icon-registry.class.d.ts +39 -0
  253. package/dist/types/classes/registries/paste-intent-provider.registry.d.ts +10 -0
  254. package/dist/types/classes/registries/tool.registry.d.ts +53 -0
  255. package/dist/types/classes/structures/app-state-map.structure.d.ts +171 -0
  256. package/dist/types/classes/structures/object-map.structure.d.ts +403 -0
  257. package/dist/types/classes/structures/quadtree.structure.d.ts +128 -0
  258. package/dist/types/classes/tools/base-tool.class.d.ts +72 -0
  259. package/dist/types/classes/tools/brush-tool.class.d.ts +68 -0
  260. package/dist/types/classes/tools/eraser-tool.class.d.ts +38 -0
  261. package/dist/types/classes/tools/image-tool.class.d.ts +74 -0
  262. package/dist/types/classes/tools/line-tool.class.d.ts +63 -0
  263. package/dist/types/classes/tools/selection-tool.class.d.ts +188 -0
  264. package/dist/types/classes/tools/shape-tool.class.d.ts +90 -0
  265. package/dist/types/classes/tools/text-tool.class.d.ts +66 -0
  266. package/dist/types/components/kritzel-awareness-cursors/kritzel-awareness-cursors.d.ts +29 -0
  267. package/dist/types/components/kritzel-cursor-trail/kritzel-cursor-trail.d.ts +19 -0
  268. package/dist/types/components/kritzel-engine/kritzel-engine.d.ts +695 -0
  269. package/dist/types/components/kritzel-icon/kritzel-icon.d.ts +6 -0
  270. package/dist/types/components/kritzel-watermark/kritzel-watermark.d.ts +20 -0
  271. package/dist/types/components.d.ts +981 -0
  272. package/dist/types/configs/default-asset-storage.config.d.ts +8 -0
  273. package/dist/types/configs/default-brush-tool.config.d.ts +2 -0
  274. package/dist/types/configs/default-engine-config.d.ts +2 -0
  275. package/dist/types/configs/default-line-tool.config.d.ts +2 -0
  276. package/dist/types/configs/default-shape-tool.config.d.ts +2 -0
  277. package/dist/types/configs/default-sync.config.d.ts +5 -0
  278. package/dist/types/configs/default-text-tool.config.d.ts +2 -0
  279. package/dist/types/constants/color-palette.constants.d.ts +31 -0
  280. package/dist/types/constants/core.constants.d.ts +0 -0
  281. package/dist/types/constants/engine.constants.d.ts +4 -0
  282. package/dist/types/constants/license.constants.d.ts +25 -0
  283. package/dist/types/constants/schema.constants.d.ts +4 -0
  284. package/dist/types/constants/storage.constants.d.ts +1 -0
  285. package/dist/types/constants/stroke-size.constants.d.ts +2 -0
  286. package/dist/types/constants/text-tool-fonts.constants.d.ts +3 -0
  287. package/dist/types/constants/version.d.ts +6 -0
  288. package/dist/types/enums/alignment.enum.d.ts +8 -0
  289. package/dist/types/enums/event-button.enum.d.ts +5 -0
  290. package/dist/types/enums/handle-type.enum.d.ts +6 -0
  291. package/dist/types/enums/shape-type.enum.d.ts +5 -0
  292. package/dist/types/events/active-workspace-change.event.d.ts +7 -0
  293. package/dist/types/events/editor-is-ready.event.d.ts +18 -0
  294. package/dist/types/events/login.event.d.ts +3 -0
  295. package/dist/types/helpers/alignment.helper.d.ts +21 -0
  296. package/dist/types/helpers/class.helper.d.ts +3 -0
  297. package/dist/types/helpers/color.helper.d.ts +34 -0
  298. package/dist/types/helpers/cursor.helper.d.ts +22 -0
  299. package/dist/types/helpers/devices.helper.d.ts +8 -0
  300. package/dist/types/helpers/event.helper.d.ts +6 -0
  301. package/dist/types/helpers/geometry.helper.d.ts +38 -0
  302. package/dist/types/helpers/html.helper.d.ts +8 -0
  303. package/dist/types/helpers/image-file.helper.d.ts +3 -0
  304. package/dist/types/helpers/keyboard.helper.d.ts +6 -0
  305. package/dist/types/helpers/localization.helper.d.ts +18 -0
  306. package/dist/types/helpers/math.helper.d.ts +4 -0
  307. package/dist/types/helpers/migration.helper.d.ts +30 -0
  308. package/dist/types/helpers/object.helper.d.ts +9 -0
  309. package/dist/types/helpers/svg-export.helper.d.ts +231 -0
  310. package/dist/types/helpers/theme.helper.d.ts +42 -0
  311. package/dist/types/helpers/tool-config.helper.d.ts +4 -0
  312. package/dist/types/helpers/wheel.helper.d.ts +9 -0
  313. package/dist/types/index.d.ts +109 -0
  314. package/dist/types/interfaces/anchor.interface.d.ts +147 -0
  315. package/dist/types/interfaces/arrow-head.interface.d.ts +27 -0
  316. package/dist/types/interfaces/asset-provider.interface.d.ts +88 -0
  317. package/dist/types/interfaces/asset-storage-config.interface.d.ts +40 -0
  318. package/dist/types/interfaces/asset.interface.d.ts +43 -0
  319. package/dist/types/interfaces/bounding-box.interface.d.ts +8 -0
  320. package/dist/types/interfaces/clonable.interface.d.ts +3 -0
  321. package/dist/types/interfaces/context-menu-item.interface.d.ts +25 -0
  322. package/dist/types/interfaces/context-menu-state.interface.d.ts +16 -0
  323. package/dist/types/interfaces/debug-info.interface.d.ts +7 -0
  324. package/dist/types/interfaces/dialog.interface.d.ts +4 -0
  325. package/dist/types/interfaces/document-metadata.interface.d.ts +6 -0
  326. package/dist/types/interfaces/dynamic-object-renderer.interface.d.ts +40 -0
  327. package/dist/types/interfaces/engine-state.interface.d.ts +82 -0
  328. package/dist/types/interfaces/font.interface.d.ts +15 -0
  329. package/dist/types/interfaces/localization.interface.d.ts +143 -0
  330. package/dist/types/interfaces/login-config.interface.d.ts +24 -0
  331. package/dist/types/interfaces/master-detail.interface.d.ts +14 -0
  332. package/dist/types/interfaces/menu-item.interface.d.ts +27 -0
  333. package/dist/types/interfaces/migration.interface.d.ts +16 -0
  334. package/dist/types/interfaces/notification.interface.d.ts +10 -0
  335. package/dist/types/interfaces/object-change-event.interface.d.ts +31 -0
  336. package/dist/types/interfaces/object-export.interface.d.ts +20 -0
  337. package/dist/types/interfaces/object.interface.d.ts +53 -0
  338. package/dist/types/interfaces/paste-intent-provider.interface.d.ts +10 -0
  339. package/dist/types/interfaces/point.interface.d.ts +4 -0
  340. package/dist/types/interfaces/polygon.interface.d.ts +7 -0
  341. package/dist/types/interfaces/remote-cursor.interface.d.ts +18 -0
  342. package/dist/types/interfaces/selection-state.interface.d.ts +7 -0
  343. package/dist/types/interfaces/serializable.interface.d.ts +5 -0
  344. package/dist/types/interfaces/settings.interface.d.ts +25 -0
  345. package/dist/types/interfaces/share.interface.d.ts +9 -0
  346. package/dist/types/interfaces/shortcut.interface.d.ts +10 -0
  347. package/dist/types/interfaces/sync-config.interface.d.ts +41 -0
  348. package/dist/types/interfaces/sync-provider.interface.d.ts +66 -0
  349. package/dist/types/interfaces/theme.interface.d.ts +553 -0
  350. package/dist/types/interfaces/tool-config.interface.d.ts +24 -0
  351. package/dist/types/interfaces/tool-type.interface.d.ts +1 -0
  352. package/dist/types/interfaces/tool.interface.d.ts +8 -0
  353. package/dist/types/interfaces/toolbar-item.interface.d.ts +66 -0
  354. package/dist/types/interfaces/undo-state.interface.d.ts +6 -0
  355. package/dist/types/interfaces/user.interface.d.ts +22 -0
  356. package/dist/types/interfaces/viewport-state.interface.d.ts +7 -0
  357. package/dist/types/locales/de-locale.d.ts +5 -0
  358. package/dist/types/locales/en-locale.d.ts +6 -0
  359. package/dist/types/locales/fr-locale.d.ts +5 -0
  360. package/dist/types/migrations/app-state.migrations.d.ts +11 -0
  361. package/dist/types/migrations/workspace.migrations.d.ts +11 -0
  362. package/dist/types/stencil-public-runtime.d.ts +1873 -0
  363. package/dist/types/themes/dark-theme.d.ts +5 -0
  364. package/dist/types/themes/light-theme.d.ts +5 -0
  365. package/dist/types/types/deep-readonly.type.d.ts +7 -0
  366. package/dist/types/types/state.types.d.ts +3 -0
  367. package/loader/cdn.js +1 -0
  368. package/loader/index.cjs.js +1 -0
  369. package/loader/index.d.ts +24 -0
  370. package/loader/index.es2017.js +1 -0
  371. package/loader/index.js +2 -0
  372. package/package.json +101 -0
  373. package/readme.md +11 -0
@@ -0,0 +1,266 @@
1
+ import { KritzelBoundingBox } from '../../interfaces/bounding-box.interface';
2
+ import { KritzelObject } from '../../interfaces/object.interface';
3
+ import { KritzelPolygon } from '../../interfaces/polygon.interface';
4
+ import { KritzelSerializable } from '../../interfaces/serializable.interface';
5
+ import { KritzelCore } from '../core/core.class';
6
+ import { KritzelClonable } from '../../interfaces/clonable.interface';
7
+ import { ThemeAwareColor } from '../../constants/color-palette.constants';
8
+ /**
9
+ * Base class for all objects that can be rendered on the Kritzel canvas.
10
+ * Provides common functionality for positioning, transformation, hit testing,
11
+ * serialization, and lifecycle management.
12
+ * @template T - The type of the underlying DOM element (HTMLElement or SVGElement)
13
+ */
14
+ export declare class KritzelBaseObject<T extends Element = HTMLElement | SVGElement> implements KritzelObject<T>, KritzelSerializable, KritzelClonable<KritzelBaseObject<T>> {
15
+ __class__: string;
16
+ _core: KritzelCore;
17
+ _elementRef: T;
18
+ id: string;
19
+ workspaceId: string;
20
+ x: number;
21
+ y: number;
22
+ translateX: number;
23
+ translateY: number;
24
+ height: number;
25
+ width: number;
26
+ backgroundColor?: ThemeAwareColor;
27
+ borderColor?: ThemeAwareColor;
28
+ borderWidth: number;
29
+ opacity: number;
30
+ padding: number;
31
+ scale?: number;
32
+ resizing: boolean;
33
+ rotation: number;
34
+ markedForRemoval: boolean;
35
+ zIndex: number;
36
+ userId?: string;
37
+ isVisible: boolean;
38
+ isSelected: boolean;
39
+ isHovered: boolean;
40
+ isMounted: boolean;
41
+ isEditable: boolean;
42
+ isInteractive: boolean;
43
+ isResizable: boolean;
44
+ isRotatable: boolean;
45
+ /**
46
+ * Gets the total width of the object including padding.
47
+ * @returns The width plus double the padding value
48
+ */
49
+ get totalWidth(): number;
50
+ /**
51
+ * Gets the total height of the object including padding.
52
+ * @returns The height plus double the padding value
53
+ */
54
+ get totalHeight(): number;
55
+ /**
56
+ * Sets the underlying DOM element reference for this object.
57
+ * @param element - The DOM element to associate with this object
58
+ */
59
+ set elementRef(element: T);
60
+ /**
61
+ * Gets the underlying DOM element reference for this object.
62
+ * @returns The associated DOM element
63
+ */
64
+ get elementRef(): T;
65
+ /**
66
+ * Gets the axis-aligned bounding box of the object without rotation.
67
+ * @returns The bounding box with position, scale, and dimensions
68
+ */
69
+ get boundingBox(): KritzelBoundingBox;
70
+ /**
71
+ * Gets the axis-aligned bounding box that encompasses the rotated object.
72
+ * Calculates the smallest rectangle that contains all four rotated corners.
73
+ * @returns The bounding box accounting for rotation
74
+ */
75
+ get rotatedBoundingBox(): KritzelBoundingBox;
76
+ /**
77
+ * Gets the four corners of the object as a polygon, accounting for rotation.
78
+ * Uses optimized trigonometric calculations with precomputed cos/sin values.
79
+ * @returns A polygon with topLeft, topRight, bottomRight, and bottomLeft coordinates
80
+ */
81
+ get rotatedPolygon(): KritzelPolygon;
82
+ /**
83
+ * Gets the minimum X coordinate among all rotated corners.
84
+ * @returns The leftmost X coordinate of the rotated object
85
+ */
86
+ get minXRotated(): number;
87
+ /**
88
+ * Gets the minimum Y coordinate among all rotated corners.
89
+ * @returns The topmost Y coordinate of the rotated object
90
+ */
91
+ get minYRotated(): number;
92
+ /**
93
+ * Gets the maximum X coordinate among all rotated corners.
94
+ * @returns The rightmost X coordinate of the rotated object
95
+ */
96
+ get maxXRotated(): number;
97
+ /**
98
+ * Gets the maximum Y coordinate among all rotated corners.
99
+ * @returns The bottommost Y coordinate of the rotated object
100
+ */
101
+ get maxYRotated(): number;
102
+ /**
103
+ * Gets the CSS transformation matrix string for positioning and scaling.
104
+ * @returns A CSS matrix() function string combining scale and translation
105
+ */
106
+ get transformationMatrix(): string;
107
+ /**
108
+ * Gets the rotation angle converted from radians to degrees.
109
+ * @returns The rotation angle in degrees
110
+ */
111
+ get rotationDegrees(): number;
112
+ /**
113
+ * Gets the X coordinate of the object's center point.
114
+ * @returns The center X position in world coordinates
115
+ */
116
+ get centerX(): number;
117
+ /**
118
+ * Gets the Y coordinate of the object's center point.
119
+ * @returns The center Y position in world coordinates
120
+ */
121
+ get centerY(): number;
122
+ /**
123
+ * Creates a new KritzelBaseObject instance with a generated unique ID.
124
+ */
125
+ constructor();
126
+ /**
127
+ * Factory method to create a new KritzelBaseObject with core context.
128
+ * Automatically assigns the current z-index and active workspace ID.
129
+ * @param core - The KritzelCore instance providing context and state
130
+ * @returns A new KritzelBaseObject instance configured with core context
131
+ */
132
+ static create(core: KritzelCore): KritzelBaseObject<Element>;
133
+ /**
134
+ * Mounts the object to a DOM element. Only executes once; subsequent calls are ignored.
135
+ * Sets the element reference and marks the object as mounted.
136
+ * @param element - The DOM element to mount this object to
137
+ */
138
+ mount(element: T): void;
139
+ /**
140
+ * Generates a unique identifier for the object.
141
+ * @returns A UUID string
142
+ */
143
+ generateId(): string;
144
+ /**
145
+ * Checks whether the object is currently visible within the viewport.
146
+ * Objects smaller than 0.5 square pixels (when scaled) are considered invisible.
147
+ * Uses the rotated bounding box for accurate intersection testing.
148
+ * @returns True if the object intersects with the visible viewport area
149
+ */
150
+ isInViewport(): boolean;
151
+ /**
152
+ * Moves the object to the center of the current viewport.
153
+ * Calculates the offset needed to align the object's center with the viewport's center.
154
+ */
155
+ centerInViewport(): void;
156
+ /**
157
+ * Notifies the store that this object has been updated.
158
+ * Triggers a re-render of the object in the canvas.
159
+ */
160
+ update(): void;
161
+ /**
162
+ * Moves the object based on the delta between start and end coordinates.
163
+ * The movement is scaled according to the current viewport scale.
164
+ * @param startX - The starting X coordinate in screen space
165
+ * @param startY - The starting Y coordinate in screen space
166
+ * @param endX - The ending X coordinate in screen space
167
+ * @param endY - The ending Y coordinate in screen space
168
+ */
169
+ move(startX: number, startY: number, endX: number, endY: number): void;
170
+ /**
171
+ * Resizes the object to new dimensions and position.
172
+ * Ignores resize requests that would make the object smaller than 1x1 pixels.
173
+ * Also updates any lines anchored to this object after resizing.
174
+ * @param x - The new X position (translateX)
175
+ * @param y - The new Y position (translateY)
176
+ * @param width - The new width (must be > 1)
177
+ * @param height - The new height (must be > 1)
178
+ */
179
+ resize(x: number, y: number, width: number, height: number): void;
180
+ /**
181
+ * Sets the rotation angle of the object.
182
+ * @param value - The rotation angle in radians
183
+ */
184
+ rotate(value: number): void;
185
+ /**
186
+ * Creates a shallow clone of this object with the same ID.
187
+ * The clone shares the same prototype and copies all properties.
188
+ * @returns A new instance with identical properties including the same ID
189
+ */
190
+ clone(): KritzelBaseObject<T>;
191
+ /**
192
+ * Creates a copy of this object with a new unique ID.
193
+ * Unlike clone(), this creates an independent object suitable for duplication.
194
+ * The copied object is not mounted by default.
195
+ * @returns A new instance with copied properties and a new unique ID
196
+ */
197
+ copy(): KritzelBaseObject<T>;
198
+ /**
199
+ * Serializes the object to a plain JavaScript object for persistence.
200
+ * Excludes internal references (_core, _elementRef) and computed properties.
201
+ * Subclasses should override to handle domain-specific serialization (e.g., HTML elements).
202
+ * @returns A serializable object containing all persistent properties
203
+ */
204
+ serialize(): any;
205
+ /**
206
+ * Restores the object's state from a serialized plain object.
207
+ * Merges all properties from the input object into this instance.
208
+ * @template T - The expected return type
209
+ * @param object - The serialized object data to restore from
210
+ * @returns This instance cast to type T
211
+ */
212
+ deserialize<T>(object: any): T;
213
+ /**
214
+ * Copies transient (non-persisted) state from a previous local instance
215
+ * onto this freshly-revived instance. Called when a remote Yjs update
216
+ * replaces an existing object so that local-only fields (e.g. asset
217
+ * load state, resolved blob URLs) survive across remote position
218
+ * updates and don't visually flicker.
219
+ *
220
+ * Default implementation is a no-op; subclasses with transient fields
221
+ * should override.
222
+ * @param previous - The previous local instance being replaced.
223
+ */
224
+ adoptTransientStateFrom(_previous: KritzelBaseObject<any>): void;
225
+ /**
226
+ * Type guard to check if this object is of a specific class type.
227
+ * Compares against the __class__ property.
228
+ * @template T - The expected class type extending KritzelBaseObject
229
+ * @param className - The class name to check against
230
+ * @returns True if this object's __class__ matches the given class name
231
+ */
232
+ isClass<T extends KritzelBaseObject>(this: T, className: string): this is T;
233
+ /**
234
+ * Handles edit actions on the object. Override in subclasses to implement
235
+ * custom edit behavior (e.g., entering text edit mode).
236
+ * @param _event - Optional pointer event that triggered the edit
237
+ */
238
+ edit(_event?: PointerEvent): void;
239
+ /**
240
+ * Lifecycle hook called after properties are updated via updateObject.
241
+ * Override in subclasses to perform custom logic when specific properties change.
242
+ * @param _changedProperties - Array of property names that were changed
243
+ */
244
+ onAfterUpdate(_changedProperties: string[]): void;
245
+ /**
246
+ * Tests if a point intersects with this object.
247
+ * Override in subclasses for precise hit detection (e.g., path-based objects).
248
+ * @param _x - The X coordinate to test in world space
249
+ * @param _y - The Y coordinate to test in world space
250
+ * @returns True if the point hits the object (default always returns true)
251
+ */
252
+ hitTest(_x: number, _y: number): boolean;
253
+ /**
254
+ * Tests if this object's rotated polygon intersects with another polygon.
255
+ * Useful for lasso selection and collision detection.
256
+ * @param polygon - The polygon to test intersection against
257
+ * @returns True if the polygons intersect
258
+ */
259
+ hitTestPolygon(polygon: KritzelPolygon): boolean;
260
+ /**
261
+ * Updates the object's position and notifies the store.
262
+ * @param x - The new X position (translateX)
263
+ * @param y - The new Y position (translateY)
264
+ */
265
+ updatePosition(x: number, y: number): void;
266
+ }
@@ -0,0 +1,148 @@
1
+ import { KritzelCore } from '../core/core.class';
2
+ import { KritzelBaseObject } from './base-object.class';
3
+ /**
4
+ * Configuration options for creating a KritzelDynamicObject instance.
5
+ */
6
+ export interface KritzelDynamicObjectConfig {
7
+ element?: HTMLElement;
8
+ rendererKey?: string;
9
+ rendererData?: unknown;
10
+ translateX?: number;
11
+ translateY?: number;
12
+ rotation?: number;
13
+ scale?: number;
14
+ height?: number;
15
+ width?: number;
16
+ }
17
+ /**
18
+ * Represents a custom HTML element that can be placed and manipulated on the Kritzel canvas.
19
+ * Extends KritzelBaseObject to inherit common object functionality like positioning,
20
+ * scaling, and lifecycle management.
21
+ */
22
+ export declare class KritzelDynamicObject extends KritzelBaseObject<HTMLElement> {
23
+ __class__: string;
24
+ /** The HTML element to be rendered on the canvas. */
25
+ element: HTMLElement;
26
+ /**
27
+ * Optional identifier for a registered renderer (e.g., 'angular-component', 'react-default').
28
+ * When set, mount() resolves the renderer from a global registry and delegates lifecycle.
29
+ * If null, falls back to DOM element mounting.
30
+ */
31
+ rendererKey: string | null;
32
+ /**
33
+ * Custom data payload for the renderer (e.g., Angular component inputs, React props, Vue data).
34
+ * Only meaningful when rendererKey is set. Captured on unmount and restored on rehydrate.
35
+ */
36
+ rendererData?: unknown;
37
+ /**
38
+ * Creates a new KritzelDynamicObject instance.
39
+ * @param config - Optional configuration object for the dynamic object.
40
+ * @param config.element - The HTML element to wrap.
41
+ * @param config.translateX - Initial X position offset. Defaults to 0.
42
+ * @param config.translateY - Initial Y position offset. Defaults to 0.
43
+ * @param config.scale - Initial scale factor. Defaults to 1.
44
+ * @param config.height - Initial height in pixels. Defaults to 0.
45
+ * @param config.width - Initial width in pixels. Defaults to 0.
46
+ */
47
+ constructor(config?: KritzelDynamicObjectConfig);
48
+ /**
49
+ * Factory method to create a new KritzelDynamicObject with proper core binding.
50
+ * Generates a unique ID and assigns the element to the active workspace.
51
+ * @param core - The KritzelCore instance for state management and ID generation.
52
+ * @param config - Optional configuration object for the dynamic object.
53
+ * @param config.element - The HTML element to wrap.
54
+ * @param config.translateX - Initial X position offset.
55
+ * @param config.translateY - Initial Y position offset.
56
+ * @param config.scale - Initial scale factor.
57
+ * @param config.height - Initial height in pixels.
58
+ * @param config.width - Initial width in pixels.
59
+ * @returns A new KritzelBaseObject instance bound to the core.
60
+ */
61
+ static create(core: KritzelCore, config?: KritzelDynamicObjectConfig): KritzelBaseObject<Element>;
62
+ /**
63
+ * Mounts the dynamic object to a container element in the DOM.
64
+ * If a renderer is registered for this.rendererKey, delegates to the renderer.
65
+ * Otherwise, uses the standard DOM element mounting fallback.
66
+ * Skips mounting if already mounted to the same container with content attached.
67
+ * @param element - The container HTML element to mount this dynamic object into.
68
+ */
69
+ mount(element: HTMLElement): void;
70
+ /**
71
+ * Updates interactivity state for embedded HTML content.
72
+ * When disabling interactivity, any focused descendant is blurred so
73
+ * keyboard input is released immediately.
74
+ */
75
+ setIsInteractive(isInteractive: boolean): void;
76
+ private applyInteractiveState;
77
+ private blurFocusedDescendant;
78
+ /**
79
+ * Returns true when a text-input-like element inside this dynamic object
80
+ * currently owns focus.
81
+ */
82
+ hasFocusedInputElement(): boolean;
83
+ private getFocusHosts;
84
+ /**
85
+ * Returns true when the given host (or, via the flat tree, one of its shadow descendants)
86
+ * currently contains a focused input-like element.
87
+ */
88
+ private hasFocusedInputDescendant;
89
+ /**
90
+ * Walks the `:focus` chain from a tree scope, descending into open shadow roots, and returns
91
+ * the focused element when it is input-like.
92
+ */
93
+ private findFocusedInputLikeElement;
94
+ private matchesFocus;
95
+ private isInputLikeElement;
96
+ private isNodeInsideHost;
97
+ private getDeepActiveElement;
98
+ /**
99
+ * Unmounts the dynamic object and performs cleanup.
100
+ * If a renderer is registered, delegates to renderer.onUnmount and captures returned state.
101
+ * Otherwise, simply removes from DOM.
102
+ * Called when object is deleted, viewport culled, or editor is unloading.
103
+ */
104
+ unmount(): void;
105
+ /**
106
+ * Returns whether the rendered content contains a scrollable element.
107
+ * Traverses light DOM, open shadow roots, and slotted content so nested
108
+ * framework components are detected as well.
109
+ */
110
+ isElementScrollable(): boolean;
111
+ /**
112
+ * Creates a placeholder element when HTML deserialization fails.
113
+ * Used as fallback to ensure element is always defined.
114
+ * @returns A div element with placeholder styling
115
+ */
116
+ private createPlaceholder;
117
+ /**
118
+ * Resizes and repositions the dynamic object on the canvas.
119
+ * Updates both the internal state and the DOM element's inline styles.
120
+ * Syncs changes to Yjs for collaborative editing and cross-tab propagation.
121
+ * @param x - The new X position (translateX) in canvas coordinates.
122
+ * @param y - The new Y position (translateY) in canvas coordinates.
123
+ * @param width - The new width in pixels. Must be greater than 1.
124
+ * @param height - The new height in pixels. Must be greater than 1.
125
+ */
126
+ resize(x: number, y: number, width: number, height: number): void;
127
+ /**
128
+ * Creates a deep copy of this dynamic object.
129
+ * The copy receives a new unique ID, is marked as unmounted,
130
+ * and contains a cloned copy of the underlying HTML element.
131
+ * @returns A new KritzelDynamicObject instance with copied properties and a cloned DOM element.
132
+ */
133
+ copy(): KritzelDynamicObject;
134
+ /**
135
+ * Serializes the dynamic object to a plain JavaScript object for persistence.
136
+ * Stores HTML as a string (safe for JSON/Yjs) and captures dimension metadata.
137
+ * @returns A serializable object with htmlString and dimension snapshots
138
+ */
139
+ serialize(): any;
140
+ /**
141
+ * Deserializes the dynamic object from a plain object.
142
+ * Reconstructs the element from stored HTML string with fallback to placeholder.
143
+ * @template T - The expected return type
144
+ * @param object - The serialized object data to restore from
145
+ * @returns This instance cast to type T
146
+ */
147
+ deserialize<T>(object: any): T;
148
+ }
@@ -0,0 +1,231 @@
1
+ import { KritzelCore } from '../core/core.class';
2
+ import { KritzelBaseObject } from './base-object.class';
3
+ import { KritzelPolygon } from '../../interfaces/polygon.interface';
4
+ /**
5
+ * Configuration options for creating a KritzelGroup instance.
6
+ */
7
+ export interface KritzelGroupConfig {
8
+ rotation?: number;
9
+ }
10
+ /**
11
+ * KritzelGroup represents a permanent grouping of objects that act as a single unit.
12
+ *
13
+ * Unlike KritzelSelectionGroup (which is ephemeral and used for temporary multi-selection),
14
+ * KritzelGroup is persisted and saved with the workspace. Grouped objects move, resize,
15
+ * rotate, copy, and delete together as one unit.
16
+ *
17
+ * Key features:
18
+ * - Supports nested groups (groups can contain other groups)
19
+ * - Clicking any child selects the entire group
20
+ * - Can be ungrouped to restore children to top-level objects
21
+ */
22
+ export declare class KritzelGroup extends KritzelBaseObject<HTMLElement> {
23
+ __class__: string;
24
+ constructor(config?: KritzelGroupConfig);
25
+ /**
26
+ * IDs of child objects within this group.
27
+ * Children can be any KritzelBaseObject, including other KritzelGroups for nesting.
28
+ */
29
+ childIds: string[];
30
+ /**
31
+ * Holds child objects that have been added via addChild() before the group
32
+ * is added to the engine. Once the group is added (and _core is set),
33
+ * these are flushed into the store and this array is cleared.
34
+ */
35
+ _pendingChildren: KritzelBaseObject<any>[];
36
+ /**
37
+ * Snapshots of child states for transformation operations (resize, rotate).
38
+ * Similar pattern to KritzelSelectionGroup.
39
+ */
40
+ private unchangedChildSnapshots;
41
+ private snapshotRotation;
42
+ private snapshotTranslateX;
43
+ private snapshotTranslateY;
44
+ private snapshotTotalWidth;
45
+ private snapshotTotalHeight;
46
+ private snapshotScale;
47
+ /**
48
+ * Retrieves the actual child objects from the store by their IDs.
49
+ * Filters out any IDs that no longer exist in the store.
50
+ * @returns An array of KritzelBaseObject instances representing the group's children.
51
+ */
52
+ get children(): KritzelBaseObject<any>[];
53
+ /**
54
+ * Returns the number of children in this group.
55
+ * @returns The count of child IDs stored in this group.
56
+ */
57
+ get length(): number;
58
+ /**
59
+ * Factory method to create a new empty KritzelGroup with core integration.
60
+ * Initializes the group with default values and links it to the core store.
61
+ * @param core - The KritzelCore instance providing access to store and state management.
62
+ * @returns A new KritzelGroup instance configured with the core context.
63
+ */
64
+ static create(core: KritzelCore, config?: {
65
+ rotation?: number;
66
+ }): KritzelGroup;
67
+ /**
68
+ * Creates a KritzelGroup from an array of existing objects.
69
+ * The objects are added as children and the group's bounding box is calculated
70
+ * to encompass all children. Child snapshots are captured for transformation operations.
71
+ * @param core - The KritzelCore instance providing access to store and state management.
72
+ * @param objects - An array of KritzelBaseObject instances to group together.
73
+ * @returns A new KritzelGroup containing the specified objects as children.
74
+ */
75
+ static createFromObjects(core: KritzelCore, objects: KritzelBaseObject<any>[]): KritzelGroup;
76
+ /**
77
+ * Finds the parent KritzelGroup that contains the given object as a direct child.
78
+ * Searches through all groups in the store to find one containing the specified object ID.
79
+ * @param core - The KritzelCore instance providing access to the object store.
80
+ * @param objectId - The unique identifier of the object to find the parent group for.
81
+ * @returns The parent KritzelGroup if found, or null if the object is not a child of any group.
82
+ */
83
+ static findParentGroup(core: KritzelCore, objectId: string): KritzelGroup | null;
84
+ /**
85
+ * Recursively collects the IDs of all descendants of the given group (children,
86
+ * grandchildren, etc.). Useful for detecting when a selection contains both an
87
+ * ancestor group and one of its descendants — a configuration that would otherwise
88
+ * cause the descendant to be transformed twice (once via the ancestor, once directly).
89
+ * @param group - The group whose descendants should be collected.
90
+ * @param out - A set that will be populated with all descendant object IDs.
91
+ */
92
+ static collectDescendantIds(group: KritzelGroup, out?: Set<string>): Set<string>;
93
+ /**
94
+ * Adds a child object to this group.
95
+ * If the object is already a child, no action is taken.
96
+ * Automatically refreshes the bounding box and captures child snapshots.
97
+ * @param object - The KritzelBaseObject instance to add as a child.
98
+ */
99
+ addChild(object: KritzelBaseObject<any>): void;
100
+ /**
101
+ * Removes a child object from this group by its ID.
102
+ * If the object is not a child, no action is taken.
103
+ * Automatically refreshes the bounding box and captures child snapshots.
104
+ * @param objectId - The unique identifier of the child object to remove.
105
+ */
106
+ removeChild(objectId: string): void;
107
+ /**
108
+ * Ungroups this group, returning all children to top-level objects.
109
+ * The group itself should be removed from the store after calling this method.
110
+ * @returns An array of all child objects that were part of this group.
111
+ */
112
+ ungroup(): KritzelBaseObject<any>[];
113
+ /**
114
+ * Finalizes the group after children have been positioned (e.g., after paste).
115
+ * Refreshes the bounding box to encompass all children and captures
116
+ * child snapshots for subsequent transformation operations.
117
+ *
118
+ * Recursively finalizes nested child groups first, so that when a transform
119
+ * (rotate/resize) cascades through nested groups, every group's snapshots are
120
+ * aligned with the current visual state. Without this, a nested group's
121
+ * `snapshotRotation` could be stale, causing the inner group to be offset
122
+ * relative to its parent during rotation.
123
+ */
124
+ finalize(): void;
125
+ /**
126
+ * Moves the group and all its children to the center of the viewport.
127
+ * Overrides the base implementation to ensure children move with the group.
128
+ */
129
+ centerInViewport(): void;
130
+ /**
131
+ * Recalculates the group's bounding box based on its children.
132
+ * Handles three cases: empty group (zero dimensions), single child (inherit its bounds),
133
+ * and multiple children (calculate encompassing bounds with rotation support).
134
+ * Updates translateX, translateY, width, and height properties.
135
+ */
136
+ refreshBoundingBox(): void;
137
+ /**
138
+ * Captures snapshots of all child states for transformation operations.
139
+ * Stores position, rotation, dimensions, and scale for each child.
140
+ * Also captures the group's current state for relative calculations.
141
+ */
142
+ private captureChildSnapshots;
143
+ /**
144
+ * Moves the group and all its children by the delta between start and end positions.
145
+ * Updates are wrapped in a transaction for atomic persistence.
146
+ * Also updates any lines anchored to child objects.
147
+ * @param startX - The starting x coordinate in screen space.
148
+ * @param startY - The starting y coordinate in screen space.
149
+ * @param endX - The ending x coordinate in screen space.
150
+ * @param endY - The ending y coordinate in screen space.
151
+ */
152
+ move(startX: number, startY: number, endX: number, endY: number): void;
153
+ /**
154
+ * Resizes the group and proportionally transforms all children.
155
+ * Children are scaled and repositioned relative to the group's center,
156
+ * accounting for rotation. Updates are wrapped in a transaction.
157
+ * @param x - The new x translation coordinate for the group.
158
+ * @param y - The new y translation coordinate for the group.
159
+ * @param width - The new width of the group's content area.
160
+ * @param height - The new height of the group's content area.
161
+ */
162
+ resize(x: number, y: number, width: number, height: number): void;
163
+ /**
164
+ * Rotates the group and all its children around the group's center.
165
+ * Children maintain their relative positions and are individually rotated.
166
+ * Uses captured snapshots to calculate rotation deltas.
167
+ * @param value - The new absolute rotation angle in radians.
168
+ */
169
+ rotate(value: number): void;
170
+ /**
171
+ * Calculates the horizontal offset from the group's center to a child's center
172
+ * using the captured snapshot values.
173
+ * @param snapshot - The captured state of the child object.
174
+ * @returns The x-axis offset from the group center to the child center.
175
+ */
176
+ private getOffsetXToCenterFromSnapshot;
177
+ /**
178
+ * Calculates the vertical offset from the group's center to a child's center
179
+ * using the captured snapshot values.
180
+ * @param snapshot - The captured state of the child object.
181
+ * @returns The y-axis offset from the group center to the child center.
182
+ */
183
+ private getOffsetYToCenterFromSnapshot;
184
+ /**
185
+ * Tests if a point lies within any of the group's children.
186
+ * The group is considered hit if any child passes the hit test.
187
+ * @param x - The x coordinate to test in world space.
188
+ * @param y - The y coordinate to test in world space.
189
+ * @returns True if the point is inside any child, false otherwise.
190
+ */
191
+ hitTest(x: number, y: number): boolean;
192
+ /**
193
+ * Tests if a polygon intersects with any of the group's children.
194
+ * Used for lasso selection and area-based hit detection.
195
+ * @param polygon - The polygon to test intersection against.
196
+ * @returns True if the polygon intersects any child, false otherwise.
197
+ */
198
+ hitTestPolygon(polygon: KritzelPolygon): boolean;
199
+ /**
200
+ * Creates a deep copy of this group and all its children.
201
+ * Children are copied but not added to the store; they are stored
202
+ * in a temporary _pendingChildren property for paste() to handle.
203
+ * @returns A new KritzelGroup with copied children and properties.
204
+ */
205
+ copy(): KritzelGroup;
206
+ /**
207
+ * Serializes the group to a plain object for persistence.
208
+ * Excludes runtime references (_core, _elementRef, element) and
209
+ * converts the unchangedChildSnapshots Map to a plain object.
210
+ * @returns A serializable plain object representation of this group.
211
+ */
212
+ serialize(): any;
213
+ /**
214
+ * Deserializes a plain object back into this KritzelGroup instance.
215
+ * Restores the unchangedChildSnapshots Map from the serialized object format.
216
+ * @param object - The serialized plain object containing group data.
217
+ * @returns This group instance after deserialization, cast to type T.
218
+ */
219
+ deserialize<T>(object: any): T;
220
+ /**
221
+ * Persists the current state of this group to the store.
222
+ * Triggers synchronization with y.js for collaborative editing.
223
+ */
224
+ update(): void;
225
+ /**
226
+ * Updates the workspace ID for this group and all its children recursively.
227
+ * Handles nested groups by recursively calling this method on child groups.
228
+ * @param workspaceId - The new workspace ID to assign to this group and its children.
229
+ */
230
+ updateWorkspaceId(workspaceId: string): void;
231
+ }