@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,206 @@
1
+ import { lightTheme } from "../../themes/light-theme";
2
+ import { darkTheme } from "../../themes/dark-theme";
3
+ import { ThemeHelper } from "../../helpers/theme.helper";
4
+ /** Key used to store the settings object in localStorage. */
5
+ const SETTINGS_STORAGE_KEY = 'kritzel-settings';
6
+ /** Default theme used when no stored preference exists. */
7
+ const DEFAULT_THEME = 'light';
8
+ /**
9
+ * Manages theme state and application across the Kritzel editor.
10
+ * Reads the persisted theme from the settings object in localStorage but does not write to it.
11
+ * Persistence is handled exclusively by the KritzelSettings component.
12
+ *
13
+ * The theme manager is responsible for:
14
+ * - Reading the stored theme preference from the settings object
15
+ * - Applying CSS custom properties to target elements
16
+ * - Switching between light and dark themes at runtime
17
+ */
18
+ export class KritzelThemeManager {
19
+ _core;
20
+ _currentTheme = DEFAULT_THEME;
21
+ _targetElement = null;
22
+ _storageKey;
23
+ _themeRegistry = new Map();
24
+ /**
25
+ * Creates a new KritzelThemeManager instance.
26
+ * Initializes the current theme from the settings object in localStorage or uses the default theme.
27
+ *
28
+ * @param core - The KritzelCore instance this manager belongs to
29
+ */
30
+ constructor(core) {
31
+ this._core = core;
32
+ this._storageKey = core.editorId ? `${SETTINGS_STORAGE_KEY}-${core.editorId}` : SETTINGS_STORAGE_KEY;
33
+ this._themeRegistry.set('light', lightTheme);
34
+ this._themeRegistry.set('dark', darkTheme);
35
+ this._currentTheme = this.getStoredTheme();
36
+ void this._core;
37
+ }
38
+ /**
39
+ * Gets the current active theme name.
40
+ *
41
+ * @returns The name of the currently active theme ('light' or 'dark')
42
+ */
43
+ get currentTheme() {
44
+ return this._currentTheme;
45
+ }
46
+ /**
47
+ * Sets the target element where theme CSS variables will be applied.
48
+ * If an element is provided, the current theme is immediately applied to it.
49
+ *
50
+ * @param element - The HTML element to apply theme styles to, or null to clear
51
+ */
52
+ setTargetElement(element) {
53
+ this._targetElement = element;
54
+ if (this._targetElement) {
55
+ this.applyTheme(this._currentTheme);
56
+ }
57
+ }
58
+ /**
59
+ * Gets the current target element where theme CSS variables are applied.
60
+ *
61
+ * @returns The current target HTML element, or null if none is set
62
+ */
63
+ getTargetElement() {
64
+ return this._targetElement;
65
+ }
66
+ /**
67
+ * Gets the theme configuration object by its name.
68
+ * Falls back to the first registered theme if the requested name is not found.
69
+ *
70
+ * @param themeName - The name of the theme to retrieve
71
+ * @returns The KritzelTheme object containing all theme CSS variable values
72
+ */
73
+ getThemeByName(themeName) {
74
+ return this._themeRegistry.get(themeName) ?? this._themeRegistry.values().next().value;
75
+ }
76
+ /**
77
+ * Registers the provided themes to this theme manager instance.
78
+ *
79
+ * @param themes - The complete list of themes to make available
80
+ */
81
+ registerThemes(themes) {
82
+ if (themes.length === 0) {
83
+ console.warn('[KritzelThemeManager] registerThemes called with an empty array. The theme registry will be empty.');
84
+ }
85
+ this._themeRegistry.clear();
86
+ for (const theme of themes) {
87
+ this._themeRegistry.set(theme.name, theme);
88
+ }
89
+ }
90
+ /**
91
+ * Pre-emptively applies the stored theme's CSS variables to the closest editor or document.
92
+ * This prevents a "Flash of Unstyled Content" (FOUC) while Stencil web components are hydrating.
93
+ *
94
+ * @param element - The HTML element to apply the theme to
95
+ */
96
+ injectThemeEarly(element) {
97
+ let targetElement = element;
98
+ if (!targetElement && typeof document !== 'undefined') {
99
+ targetElement = document.documentElement;
100
+ }
101
+ if (!targetElement)
102
+ return;
103
+ const themeName = this.getStoredTheme();
104
+ const theme = this.getThemeByName(themeName);
105
+ ThemeHelper.applyThemeToElement(targetElement, theme);
106
+ }
107
+ /**
108
+ * Gets all registered themes.
109
+ *
110
+ * @returns An array of all registered theme objects
111
+ */
112
+ getAllThemes() {
113
+ return Array.from(this._themeRegistry.values());
114
+ }
115
+ /**
116
+ * Gets the stored theme name from the settings object in localStorage using this instance's namespaced key.
117
+ *
118
+ * @returns The stored theme name if valid, or 'light' as the default
119
+ */
120
+ getStoredTheme() {
121
+ if (typeof localStorage === 'undefined') {
122
+ return DEFAULT_THEME;
123
+ }
124
+ const stored = localStorage.getItem(this._storageKey);
125
+ if (!stored) {
126
+ return DEFAULT_THEME;
127
+ }
128
+ try {
129
+ const parsed = JSON.parse(stored);
130
+ if (typeof parsed?.theme === 'string') {
131
+ return parsed.theme;
132
+ }
133
+ }
134
+ catch {
135
+ // Invalid JSON, use default
136
+ }
137
+ return DEFAULT_THEME;
138
+ }
139
+ /**
140
+ * Gets the stored theme from the default (non-namespaced) settings object in localStorage.
141
+ * Used by static utility helpers that don't have access to a core instance.
142
+ *
143
+ * @returns The stored theme name if valid, or 'light' as the default
144
+ */
145
+ static getStoredTheme() {
146
+ if (typeof localStorage === 'undefined') {
147
+ return DEFAULT_THEME;
148
+ }
149
+ const stored = localStorage.getItem(SETTINGS_STORAGE_KEY);
150
+ if (!stored) {
151
+ return DEFAULT_THEME;
152
+ }
153
+ try {
154
+ const parsed = JSON.parse(stored);
155
+ if (typeof parsed?.theme === 'string') {
156
+ return parsed.theme;
157
+ }
158
+ }
159
+ catch {
160
+ // Invalid JSON, use default
161
+ }
162
+ return DEFAULT_THEME;
163
+ }
164
+ /**
165
+ * Sets the current theme and applies it to the target element.
166
+ * Does not persist the theme — persistence is handled by the KritzelSettings component.
167
+ *
168
+ * @param themeName - The theme name to set ('light' or 'dark')
169
+ */
170
+ setTheme(themeName) {
171
+ this._currentTheme = themeName;
172
+ if (this._targetElement) {
173
+ this.applyTheme(themeName);
174
+ }
175
+ }
176
+ /**
177
+ * Checks if the current theme is the dark theme.
178
+ *
179
+ * @returns True if the current theme is 'dark', false otherwise
180
+ */
181
+ isDarkTheme() {
182
+ return this._currentTheme === 'dark';
183
+ }
184
+ /**
185
+ * Applies a theme to the target element by setting CSS custom properties.
186
+ * Uses the ThemeHelper utility to automatically derive CSS variable names
187
+ * from the theme interface structure and apply them to the element's style.
188
+ * Does nothing if no target element is set.
189
+ *
190
+ * @param themeName - The name of the theme to apply ('light' or 'dark')
191
+ */
192
+ applyTheme(themeName) {
193
+ if (!this._targetElement) {
194
+ return;
195
+ }
196
+ const theme = this.getThemeByName(themeName);
197
+ ThemeHelper.applyThemeToElement(this._targetElement, theme);
198
+ }
199
+ /**
200
+ * Cleans up the theme manager state by clearing the target element reference.
201
+ * Should be called when the manager is no longer needed to prevent memory leaks.
202
+ */
203
+ cleanup() {
204
+ this._targetElement = null;
205
+ }
206
+ }
@@ -0,0 +1,462 @@
1
+ import { ObjectHelper } from "../../helpers/object.helper";
2
+ import { KritzelGeometryHelper } from "../../helpers/geometry.helper";
3
+ /**
4
+ * Base class for all objects that can be rendered on the Kritzel canvas.
5
+ * Provides common functionality for positioning, transformation, hit testing,
6
+ * serialization, and lifecycle management.
7
+ * @template T - The type of the underlying DOM element (HTMLElement or SVGElement)
8
+ */
9
+ export class KritzelBaseObject {
10
+ __class__ = 'KritzelBaseObject';
11
+ _core;
12
+ _elementRef;
13
+ id;
14
+ workspaceId;
15
+ x;
16
+ y;
17
+ translateX;
18
+ translateY;
19
+ height;
20
+ width;
21
+ backgroundColor;
22
+ borderColor;
23
+ borderWidth = 0;
24
+ opacity = 1;
25
+ padding = 0;
26
+ scale;
27
+ resizing = false;
28
+ rotation = 0;
29
+ markedForRemoval = false;
30
+ zIndex = 0;
31
+ userId;
32
+ isVisible = true;
33
+ isSelected = false;
34
+ isHovered = false;
35
+ isMounted = false;
36
+ isEditable = false;
37
+ isInteractive = false;
38
+ isResizable = true;
39
+ isRotatable = true;
40
+ /**
41
+ * Gets the total width of the object including padding.
42
+ * @returns The width plus double the padding value
43
+ */
44
+ get totalWidth() {
45
+ return this.width + this.padding * 2;
46
+ }
47
+ /**
48
+ * Gets the total height of the object including padding.
49
+ * @returns The height plus double the padding value
50
+ */
51
+ get totalHeight() {
52
+ return this.height + this.padding * 2;
53
+ }
54
+ /**
55
+ * Sets the underlying DOM element reference for this object.
56
+ * @param element - The DOM element to associate with this object
57
+ */
58
+ set elementRef(element) {
59
+ this._elementRef = element;
60
+ }
61
+ /**
62
+ * Gets the underlying DOM element reference for this object.
63
+ * @returns The associated DOM element
64
+ */
65
+ get elementRef() {
66
+ return this._elementRef;
67
+ }
68
+ /**
69
+ * Gets the axis-aligned bounding box of the object without rotation.
70
+ * @returns The bounding box with position, scale, and dimensions
71
+ */
72
+ get boundingBox() {
73
+ return {
74
+ x: this.translateX,
75
+ y: this.translateY,
76
+ z: this.scale,
77
+ width: this.totalWidth / this.scale,
78
+ height: this.totalHeight / this.scale,
79
+ };
80
+ }
81
+ /**
82
+ * Gets the axis-aligned bounding box that encompasses the rotated object.
83
+ * Calculates the smallest rectangle that contains all four rotated corners.
84
+ * @returns The bounding box accounting for rotation
85
+ */
86
+ get rotatedBoundingBox() {
87
+ const polygon = this.rotatedPolygon;
88
+ const xValues = [polygon.topLeft.x, polygon.topRight.x, polygon.bottomRight.x, polygon.bottomLeft.x];
89
+ const yValues = [polygon.topLeft.y, polygon.topRight.y, polygon.bottomRight.y, polygon.bottomLeft.y];
90
+ const minX = Math.min(...xValues);
91
+ const maxX = Math.max(...xValues);
92
+ const minY = Math.min(...yValues);
93
+ const maxY = Math.max(...yValues);
94
+ return {
95
+ x: minX,
96
+ y: minY,
97
+ z: this.scale,
98
+ width: maxX - minX,
99
+ height: maxY - minY,
100
+ };
101
+ }
102
+ /**
103
+ * Gets the four corners of the object as a polygon, accounting for rotation.
104
+ * Uses optimized trigonometric calculations with precomputed cos/sin values.
105
+ * @returns A polygon with topLeft, topRight, bottomRight, and bottomLeft coordinates
106
+ */
107
+ get rotatedPolygon() {
108
+ const cx = this.translateX + this.totalWidth / 2 / this.scale;
109
+ const cy = this.translateY + this.totalHeight / 2 / this.scale;
110
+ const angle = this.rotation;
111
+ // Optimization: Precomputes cos/sin once
112
+ const cos = Math.cos(angle);
113
+ const sin = Math.sin(angle);
114
+ const adjustedWidth = this.totalWidth / this.scale;
115
+ const adjustedHeight = this.totalHeight / this.scale;
116
+ const x1 = this.translateX;
117
+ const y1 = this.translateY;
118
+ const x2 = x1 + adjustedWidth;
119
+ const y2 = y1 + adjustedHeight;
120
+ // Helper to rotate a point around center
121
+ const rotate = (x, y) => ({
122
+ x: cos * (x - cx) - sin * (y - cy) + cx,
123
+ y: sin * (x - cx) + cos * (y - cy) + cy,
124
+ });
125
+ return {
126
+ topLeft: rotate(x1, y1),
127
+ topRight: rotate(x2, y1),
128
+ bottomRight: rotate(x2, y2),
129
+ bottomLeft: rotate(x1, y2),
130
+ };
131
+ }
132
+ /**
133
+ * Gets the minimum X coordinate among all rotated corners.
134
+ * @returns The leftmost X coordinate of the rotated object
135
+ */
136
+ get minXRotated() {
137
+ const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];
138
+ return Math.min(...corners);
139
+ }
140
+ /**
141
+ * Gets the minimum Y coordinate among all rotated corners.
142
+ * @returns The topmost Y coordinate of the rotated object
143
+ */
144
+ get minYRotated() {
145
+ const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];
146
+ return Math.min(...corners);
147
+ }
148
+ /**
149
+ * Gets the maximum X coordinate among all rotated corners.
150
+ * @returns The rightmost X coordinate of the rotated object
151
+ */
152
+ get maxXRotated() {
153
+ const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];
154
+ return Math.max(...corners);
155
+ }
156
+ /**
157
+ * Gets the maximum Y coordinate among all rotated corners.
158
+ * @returns The bottommost Y coordinate of the rotated object
159
+ */
160
+ get maxYRotated() {
161
+ const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];
162
+ return Math.max(...corners);
163
+ }
164
+ /**
165
+ * Gets the CSS transformation matrix string for positioning and scaling.
166
+ * @returns A CSS matrix() function string combining scale and translation
167
+ */
168
+ get transformationMatrix() {
169
+ const scale = 1 / this.scale;
170
+ const translateX = this.translateX;
171
+ const translateY = this.translateY;
172
+ return `matrix(${scale}, 0, 0, ${scale}, ${translateX}, ${translateY})`;
173
+ }
174
+ /**
175
+ * Gets the rotation angle converted from radians to degrees.
176
+ * @returns The rotation angle in degrees
177
+ */
178
+ get rotationDegrees() {
179
+ return this.rotation * (180 / Math.PI);
180
+ }
181
+ /**
182
+ * Gets the X coordinate of the object's center point.
183
+ * @returns The center X position in world coordinates
184
+ */
185
+ get centerX() {
186
+ return this.translateX + this.totalWidth / 2 / this.scale;
187
+ }
188
+ /**
189
+ * Gets the Y coordinate of the object's center point.
190
+ * @returns The center Y position in world coordinates
191
+ */
192
+ get centerY() {
193
+ return this.translateY + this.totalHeight / 2 / this.scale;
194
+ }
195
+ /**
196
+ * Creates a new KritzelBaseObject instance with a generated unique ID.
197
+ */
198
+ constructor() {
199
+ this.id = this.generateId();
200
+ }
201
+ /**
202
+ * Factory method to create a new KritzelBaseObject with core context.
203
+ * Automatically assigns the current z-index and active workspace ID.
204
+ * @param core - The KritzelCore instance providing context and state
205
+ * @returns A new KritzelBaseObject instance configured with core context
206
+ */
207
+ static create(core) {
208
+ const object = new KritzelBaseObject();
209
+ object._core = core;
210
+ object.zIndex = core.store.currentZIndex;
211
+ object.workspaceId = core.store.state.activeWorkspace.id;
212
+ object.userId = core.user?.id;
213
+ return object;
214
+ }
215
+ /**
216
+ * Mounts the object to a DOM element. Only executes once; subsequent calls are ignored.
217
+ * Sets the element reference and marks the object as mounted.
218
+ * @param element - The DOM element to mount this object to
219
+ */
220
+ mount(element) {
221
+ if (this.isMounted) {
222
+ return;
223
+ }
224
+ this.elementRef = element;
225
+ this.isMounted = true;
226
+ }
227
+ /**
228
+ * Generates a unique identifier for the object.
229
+ * @returns A UUID string
230
+ */
231
+ generateId() {
232
+ return ObjectHelper.generateUUID();
233
+ }
234
+ /**
235
+ * Checks whether the object is currently visible within the viewport.
236
+ * Objects smaller than 0.5 square pixels (when scaled) are considered invisible.
237
+ * Uses the rotated bounding box for accurate intersection testing.
238
+ * @returns True if the object intersects with the visible viewport area
239
+ */
240
+ isInViewport() {
241
+ const viewportScale = this._core.store.state.scale;
242
+ const scaledWidth = this.boundingBox.width * viewportScale;
243
+ const scaledHeight = this.boundingBox.height * viewportScale;
244
+ if (scaledWidth * scaledHeight < 0.5) {
245
+ return false;
246
+ }
247
+ const viewportBounds = {
248
+ x: -this._core.store.state.translateX / this._core.store.state.scale,
249
+ y: -this._core.store.state.translateY / this._core.store.state.scale,
250
+ z: this._core.store.state.scale,
251
+ width: this._core.store.state.viewportWidth / this._core.store.state.scale,
252
+ height: this._core.store.state.viewportHeight / this._core.store.state.scale,
253
+ };
254
+ return (this.rotatedBoundingBox.x < viewportBounds.x + viewportBounds.width &&
255
+ this.rotatedBoundingBox.x + this.rotatedBoundingBox.width > viewportBounds.x &&
256
+ this.rotatedBoundingBox.y < viewportBounds.y + viewportBounds.height &&
257
+ this.rotatedBoundingBox.y + this.rotatedBoundingBox.height > viewportBounds.y);
258
+ }
259
+ /**
260
+ * Moves the object to the center of the current viewport.
261
+ * Calculates the offset needed to align the object's center with the viewport's center.
262
+ */
263
+ centerInViewport() {
264
+ const { viewportWidth, viewportHeight, translateX: viewportTranslateX, translateY: viewportTranslateY, scale: viewportScale } = this._core.store.state;
265
+ const { x, y, width, height } = this.rotatedBoundingBox;
266
+ const objectCenterX = x + width / 2;
267
+ const objectCenterY = y + height / 2;
268
+ const targetCenterX = (viewportWidth / 2 - viewportTranslateX) / viewportScale;
269
+ const targetCenterY = (viewportHeight / 2 - viewportTranslateY) / viewportScale;
270
+ const deltaX = targetCenterX - objectCenterX;
271
+ const deltaY = targetCenterY - objectCenterY;
272
+ this.updatePosition(this.translateX + deltaX, this.translateY + deltaY);
273
+ }
274
+ /**
275
+ * Notifies the store that this object has been updated.
276
+ * Triggers a re-render of the object in the canvas.
277
+ */
278
+ update() {
279
+ this._core.store.objects.update(this);
280
+ }
281
+ /**
282
+ * Moves the object based on the delta between start and end coordinates.
283
+ * The movement is scaled according to the current viewport scale.
284
+ * @param startX - The starting X coordinate in screen space
285
+ * @param startY - The starting Y coordinate in screen space
286
+ * @param endX - The ending X coordinate in screen space
287
+ * @param endY - The ending Y coordinate in screen space
288
+ */
289
+ move(startX, startY, endX, endY) {
290
+ const deltaX = (startX - endX) / this._core.store.state.scale;
291
+ const deltaY = (startY - endY) / this._core.store.state.scale;
292
+ this.translateX += deltaX;
293
+ this.translateY += deltaY;
294
+ this._core.store.objects.update(this);
295
+ }
296
+ /**
297
+ * Resizes the object to new dimensions and position.
298
+ * Ignores resize requests that would make the object smaller than 1x1 pixels.
299
+ * Also updates any lines anchored to this object after resizing.
300
+ * @param x - The new X position (translateX)
301
+ * @param y - The new Y position (translateY)
302
+ * @param width - The new width (must be > 1)
303
+ * @param height - The new height (must be > 1)
304
+ */
305
+ resize(x, y, width, height) {
306
+ if (width <= 1 || height <= 1) {
307
+ return;
308
+ }
309
+ this.width = width;
310
+ this.height = height;
311
+ this.translateX = x;
312
+ this.translateY = y;
313
+ this._core.store.objects.update(this);
314
+ // Update any lines that are anchored to this object (after position is updated)
315
+ this._core.anchorManager.updateAnchorsForObject(this.id);
316
+ }
317
+ /**
318
+ * Sets the rotation angle of the object.
319
+ * @param value - The rotation angle in radians
320
+ */
321
+ rotate(value) {
322
+ this.rotation = value;
323
+ this._core.store.objects.update(this);
324
+ }
325
+ /**
326
+ * Creates a shallow clone of this object with the same ID.
327
+ * The clone shares the same prototype and copies all properties.
328
+ * @returns A new instance with identical properties including the same ID
329
+ */
330
+ clone() {
331
+ const clone = Object.create(Object.getPrototypeOf(this));
332
+ Object.assign(clone, this);
333
+ clone.id = this.id;
334
+ return clone;
335
+ }
336
+ /**
337
+ * Creates a copy of this object with a new unique ID.
338
+ * Unlike clone(), this creates an independent object suitable for duplication.
339
+ * The copied object is not mounted by default.
340
+ * @returns A new instance with copied properties and a new unique ID
341
+ */
342
+ copy() {
343
+ const copiedObject = Object.create(Object.getPrototypeOf(this));
344
+ Object.assign(copiedObject, this);
345
+ copiedObject.id = this.generateId();
346
+ copiedObject.isMounted = false;
347
+ copiedObject.isSelected = false;
348
+ copiedObject.isHovered = false;
349
+ copiedObject.isInteractive = false;
350
+ copiedObject.resizing = false;
351
+ copiedObject.markedForRemoval = false;
352
+ copiedObject.isVisible = true;
353
+ return copiedObject;
354
+ }
355
+ /**
356
+ * Serializes the object to a plain JavaScript object for persistence.
357
+ * Excludes internal references (_core, _elementRef) and computed properties.
358
+ * Subclasses should override to handle domain-specific serialization (e.g., HTML elements).
359
+ * @returns A serializable object containing all persistent properties
360
+ */
361
+ serialize() {
362
+ const { _core, _elementRef, element, totalWidth, totalHeight, isSelected, isHovered, isMounted, isInteractive, resizing, markedForRemoval, isVisible, ...remainingProps } = this;
363
+ // No longer clone raw elements—let subclasses handle serializable payloads
364
+ return structuredClone(remainingProps);
365
+ }
366
+ /**
367
+ * Restores the object's state from a serialized plain object.
368
+ * Merges all properties from the input object into this instance.
369
+ * @template T - The expected return type
370
+ * @param object - The serialized object data to restore from
371
+ * @returns This instance cast to type T
372
+ */
373
+ deserialize(object) {
374
+ Object.assign(this, object);
375
+ // Selection/interactivity state is transient UI state and must not survive revival.
376
+ this.isSelected = false;
377
+ this.isHovered = false;
378
+ this.isMounted = false;
379
+ this.isInteractive = false;
380
+ this.resizing = false;
381
+ this.markedForRemoval = false;
382
+ this.isVisible = true;
383
+ // Reset known transient geometry caches if present on subclasses.
384
+ if ('_adjustedPoints' in this) {
385
+ this._adjustedPoints = null;
386
+ }
387
+ if ('_clipInfo' in this) {
388
+ this._clipInfo = null;
389
+ }
390
+ return this;
391
+ }
392
+ /**
393
+ * Copies transient (non-persisted) state from a previous local instance
394
+ * onto this freshly-revived instance. Called when a remote Yjs update
395
+ * replaces an existing object so that local-only fields (e.g. asset
396
+ * load state, resolved blob URLs) survive across remote position
397
+ * updates and don't visually flicker.
398
+ *
399
+ * Default implementation is a no-op; subclasses with transient fields
400
+ * should override.
401
+ * @param previous - The previous local instance being replaced.
402
+ */
403
+ adoptTransientStateFrom(_previous) {
404
+ // no-op by default
405
+ }
406
+ /**
407
+ * Type guard to check if this object is of a specific class type.
408
+ * Compares against the __class__ property.
409
+ * @template T - The expected class type extending KritzelBaseObject
410
+ * @param className - The class name to check against
411
+ * @returns True if this object's __class__ matches the given class name
412
+ */
413
+ isClass(className) {
414
+ return this.__class__ === className;
415
+ }
416
+ /**
417
+ * Handles edit actions on the object. Override in subclasses to implement
418
+ * custom edit behavior (e.g., entering text edit mode).
419
+ * @param _event - Optional pointer event that triggered the edit
420
+ */
421
+ edit(_event) {
422
+ // This method can be overridden by subclasses to handle edit actions.
423
+ }
424
+ /**
425
+ * Lifecycle hook called after properties are updated via updateObject.
426
+ * Override in subclasses to perform custom logic when specific properties change.
427
+ * @param _changedProperties - Array of property names that were changed
428
+ */
429
+ onAfterUpdate(_changedProperties) {
430
+ // Default implementation does nothing
431
+ }
432
+ /**
433
+ * Tests if a point intersects with this object.
434
+ * Override in subclasses for precise hit detection (e.g., path-based objects).
435
+ * @param _x - The X coordinate to test in world space
436
+ * @param _y - The Y coordinate to test in world space
437
+ * @returns True if the point hits the object (default always returns true)
438
+ */
439
+ hitTest(_x, _y) {
440
+ return true; // Default implementation, can be overridden by subclasses
441
+ }
442
+ /**
443
+ * Tests if this object's rotated polygon intersects with another polygon.
444
+ * Useful for lasso selection and collision detection.
445
+ * @param polygon - The polygon to test intersection against
446
+ * @returns True if the polygons intersect
447
+ */
448
+ hitTestPolygon(polygon) {
449
+ const objectPolygon = this.rotatedPolygon;
450
+ return KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, polygon);
451
+ }
452
+ /**
453
+ * Updates the object's position and notifies the store.
454
+ * @param x - The new X position (translateX)
455
+ * @param y - The new Y position (translateY)
456
+ */
457
+ updatePosition(x, y) {
458
+ this.translateX = x;
459
+ this.translateY = y;
460
+ this._core.store.objects.update(this);
461
+ }
462
+ }