@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,124 @@
1
+ import { KritzelImage } from "../objects/image.class";
2
+ import { KritzelLine } from "../objects/line.class";
3
+ import { KritzelPath } from "../objects/path.class";
4
+ import { KritzelShape } from "../objects/shape.class";
5
+ import { KritzelSelectionGroup } from "../objects/selection-group.class";
6
+ import { KritzelGroup } from "../objects/group.class";
7
+ import { KritzelText } from "../objects/text.class";
8
+ import { KritzelBrushTool } from "../tools/brush-tool.class";
9
+ import { KritzelEraserTool } from "../tools/eraser-tool.class";
10
+ import { KritzelImageTool } from "../tools/image-tool.class";
11
+ import { KritzelLineTool } from "../tools/line-tool.class";
12
+ import { KritzelSelectionTool } from "../tools/selection-tool.class";
13
+ import { KritzelTextTool } from "../tools/text-tool.class";
14
+ import { KritzelShapeTool } from "../tools/shape-tool.class";
15
+ import { KritzelDynamicObject } from "../objects/dynamic-object.class";
16
+ import { KritzelWorkspace } from "./workspace.class";
17
+ /**
18
+ * Handles deserialization/revival of Kritzel objects from plain JavaScript objects.
19
+ * This class uses a pattern similar to JSON.parse reviver to reconstruct class instances
20
+ * from their serialized representations, preserving the object's prototype chain and methods.
21
+ */
22
+ export class KritzelReviver {
23
+ /** Reference to the KritzelCore instance for creating objects */
24
+ _core;
25
+ /**
26
+ * Creates a new KritzelReviver instance.
27
+ * @param core - The KritzelCore instance used to create revived objects
28
+ */
29
+ constructor(core) {
30
+ this._core = core;
31
+ }
32
+ /**
33
+ * Recursively revives a plain JavaScript object (or array) into typed Kritzel instances.
34
+ * Uses the `__class__` property to determine the correct class to instantiate.
35
+ * Objects without `__class__` are recursively processed to revive nested objects.
36
+ *
37
+ * Supported classes:
38
+ * - Objects: KritzelPath, KritzelLine, KritzelText, KritzelShape, KritzelImage,
39
+ * KritzelDynamicObject, KritzelSelectionGroup, KritzelGroup
40
+ * - Workspace: KritzelWorkspace
41
+ * - Tools: KritzelBrushTool, KritzelEraserTool, KritzelImageTool, KritzelSelectionTool,
42
+ * KritzelTextTool, KritzelLineTool, KritzelShapeTool
43
+ *
44
+ * @typeParam T - The expected return type after revival
45
+ * @param obj - The plain object to revive, typically from JSON deserialization
46
+ * @returns The revived object with proper class instances, or the original value if not an object
47
+ */
48
+ revive(obj) {
49
+ if (obj && typeof obj === 'object') {
50
+ if (obj.__class__) {
51
+ let revivedObj;
52
+ switch (obj.__class__) {
53
+ case 'KritzelPath':
54
+ revivedObj = KritzelPath.create(this._core).deserialize(obj);
55
+ break;
56
+ case 'KritzelLine':
57
+ revivedObj = KritzelLine.create(this._core).deserialize(obj);
58
+ break;
59
+ case 'KritzelText':
60
+ revivedObj = KritzelText.create(this._core, obj.fontSize, obj.fontFamily).deserialize(obj);
61
+ break;
62
+ case 'KritzelShape':
63
+ revivedObj = KritzelShape.create(this._core, {
64
+ shapeType: obj.shapeType,
65
+ fillColor: obj.fillColor,
66
+ strokeColor: obj.strokeColor,
67
+ strokeWidth: obj.strokeWidth,
68
+ fontSize: obj.fontSize,
69
+ fontFamily: obj.fontFamily,
70
+ fontColor: obj.fontColor,
71
+ }).deserialize(obj);
72
+ break;
73
+ case 'KritzelImage':
74
+ revivedObj = KritzelImage.create(this._core).deserialize(obj);
75
+ break;
76
+ case 'KritzelDynamicObject':
77
+ revivedObj = KritzelDynamicObject.create(this._core).deserialize(obj);
78
+ break;
79
+ case 'KritzelSelectionGroup':
80
+ revivedObj = KritzelSelectionGroup.create(this._core).deserialize(obj);
81
+ break;
82
+ case 'KritzelGroup':
83
+ revivedObj = KritzelGroup.create(this._core).deserialize(obj);
84
+ break;
85
+ case 'KritzelWorkspace':
86
+ revivedObj = KritzelWorkspace.create(this._core, obj).deserialize(obj);
87
+ break;
88
+ case 'KritzelBrushTool':
89
+ revivedObj = new KritzelBrushTool(this._core);
90
+ break;
91
+ case 'KritzelEraserTool':
92
+ revivedObj = new KritzelEraserTool(this._core);
93
+ break;
94
+ case 'KritzelImageTool':
95
+ revivedObj = new KritzelImageTool(this._core);
96
+ break;
97
+ case 'KritzelSelectionTool':
98
+ revivedObj = new KritzelSelectionTool(this._core);
99
+ break;
100
+ case 'KritzelTextTool':
101
+ revivedObj = new KritzelTextTool(this._core);
102
+ break;
103
+ case 'KritzelLineTool':
104
+ revivedObj = new KritzelLineTool(this._core);
105
+ break;
106
+ case 'KritzelShapeTool':
107
+ revivedObj = new KritzelShapeTool(this._core);
108
+ break;
109
+ default:
110
+ revivedObj = obj;
111
+ }
112
+ return revivedObj;
113
+ }
114
+ const newObj = Array.isArray(obj) ? [] : {};
115
+ for (const key in obj) {
116
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
117
+ newObj[key] = this.revive(obj[key]);
118
+ }
119
+ }
120
+ return newObj;
121
+ }
122
+ return obj;
123
+ }
124
+ }
@@ -0,0 +1,337 @@
1
+ import { KritzelSelectionGroup } from "../objects/selection-group.class";
2
+ import { KritzelSelectionBox } from "../objects/selection-box.class";
3
+ import { KritzelText } from "../objects/text.class";
4
+ import { KritzelShape } from "../objects/shape.class";
5
+ import { KritzelPath } from "../objects/path.class";
6
+ import { KritzelLine } from "../objects/line.class";
7
+ import { KritzelClassHelper } from "../../helpers/class.helper";
8
+ import { KritzelObjectMap } from "../structures/object-map.structure";
9
+ /**
10
+ * Central state management store for the Kritzel engine.
11
+ * Provides reactive state management with change listeners, caching for frequently
12
+ * accessed objects, and computed properties for viewport and selection state.
13
+ */
14
+ export class KritzelStore {
15
+ /** Internal state object containing all engine state properties */
16
+ _state;
17
+ /** Map of property keys to their registered change listeners */
18
+ _listeners = new Map();
19
+ // Cached references for O(1) access to frequently accessed special objects
20
+ _cachedSelectionBox = null;
21
+ _cachedSelectionGroup = null;
22
+ _selectionBoxCacheValid = false;
23
+ _selectionGroupCacheValid = false;
24
+ _localUserId = null;
25
+ /**
26
+ * Gets the current engine state.
27
+ * @returns The mutable engine state object
28
+ */
29
+ get state() {
30
+ return this._state;
31
+ }
32
+ /**
33
+ * Gets the map of all objects in the workspace.
34
+ * Throws an error if the objects map is not initialized, as it is required for all object management.
35
+ * @returns The KritzelObjectMap containing all objects
36
+ * @throws Error if the objects map is not initialized in the state
37
+ */
38
+ get objects() {
39
+ if (!this._state.objects) {
40
+ throw new Error('Objects map is not initialized.');
41
+ }
42
+ return this._state.objects;
43
+ }
44
+ /**
45
+ * Gets the host element for the Kritzel editor.
46
+ * Throws an error if the host is not set, as it is required for many operations.
47
+ * @returns The host HTMLElement
48
+ * @throws Error if the host element is not set in the state
49
+ */
50
+ get host() {
51
+ if (!this._state.host) {
52
+ throw new Error('Host element is not set.');
53
+ }
54
+ return this._state.host;
55
+ }
56
+ /**
57
+ * Gets the next available z-index for new objects.
58
+ * Calculates the maximum z-index among all non-selection objects and adds 1.
59
+ * @returns The next z-index value to use for new objects
60
+ */
61
+ get currentZIndex() {
62
+ return Math.max(0, ...this.objects.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KritzelSelectionBox)).map(o => o.zIndex)) + 1;
63
+ }
64
+ /**
65
+ * Returns true if viewport boundaries are set to finite values (not Infinity).
66
+ */
67
+ get hasViewportBoundaries() {
68
+ return (Number.isFinite(this._state.viewportBoundaryLeft) ||
69
+ Number.isFinite(this._state.viewportBoundaryRight) ||
70
+ Number.isFinite(this._state.viewportBoundaryTop) ||
71
+ Number.isFinite(this._state.viewportBoundaryBottom));
72
+ }
73
+ /**
74
+ * Returns the viewport boundary bounds for querying objects.
75
+ * Uses the configured boundaries, defaulting to Infinity for unset values.
76
+ */
77
+ get viewportBoundaryBounds() {
78
+ const left = this._state.viewportBoundaryLeft;
79
+ const right = this._state.viewportBoundaryRight;
80
+ const top = this._state.viewportBoundaryTop;
81
+ const bottom = this._state.viewportBoundaryBottom;
82
+ return {
83
+ x: Number.isFinite(left) ? left : -Infinity,
84
+ y: Number.isFinite(top) ? top : -Infinity,
85
+ z: 0,
86
+ width: Number.isFinite(left) && Number.isFinite(right) ? right - left : Infinity,
87
+ height: Number.isFinite(top) && Number.isFinite(bottom) ? bottom - top : Infinity,
88
+ };
89
+ }
90
+ /**
91
+ * Gets the total count of objects in the workspace.
92
+ * When viewport boundaries are set, returns only objects within those boundaries.
93
+ * @returns The total number of objects
94
+ */
95
+ get totalObjectCount() {
96
+ if (this.hasViewportBoundaries) {
97
+ return this.allObjects.length;
98
+ }
99
+ return this.objects.totalCount;
100
+ }
101
+ /**
102
+ * Gets all objects in the workspace.
103
+ * When viewport boundaries are set, returns only objects within those boundaries.
104
+ * @returns Array of all canvas objects
105
+ */
106
+ get allObjects() {
107
+ if (this.hasViewportBoundaries) {
108
+ return this.objects.query(this.viewportBoundaryBounds);
109
+ }
110
+ return this.objects.allObjects();
111
+ }
112
+ /**
113
+ * Gets all objects currently visible in the viewport.
114
+ * Uses spatial querying for efficient retrieval and sorts by z-index.
115
+ * @returns Array of objects within the current viewport, sorted by z-index ascending
116
+ */
117
+ get objectsInViewport() {
118
+ const viewportBounds = {
119
+ x: -this._state.translateX / this._state.scale,
120
+ y: -this._state.translateY / this._state.scale,
121
+ z: this._state.scale,
122
+ width: this._state.viewportWidth / this._state.scale,
123
+ height: this._state.viewportHeight / this._state.scale,
124
+ depth: 100,
125
+ };
126
+ return this.objects.query(viewportBounds).sort((a, b) => a.zIndex - b.zIndex);
127
+ }
128
+ /**
129
+ * Gets all objects excluding selection-related objects (selection group and selection box).
130
+ * @returns Array of all regular canvas objects
131
+ */
132
+ get allNonSelectionObjects() {
133
+ return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KritzelSelectionBox));
134
+ }
135
+ /**
136
+ * Gets all currently selected objects (excluding the selection group itself).
137
+ * @returns Array of selected objects
138
+ */
139
+ get selectedObjects() {
140
+ return this.allObjects.filter(o => !(o instanceof KritzelSelectionGroup) && !(o instanceof KritzelSelectionBox)).filter(o => o.isSelected);
141
+ }
142
+ /**
143
+ * Gets the current selection box if one exists.
144
+ * Uses caching for O(1) access after initial lookup.
145
+ * @returns The selection box or null if none exists
146
+ */
147
+ get selectionBox() {
148
+ if (this._selectionBoxCacheValid) {
149
+ return this._cachedSelectionBox;
150
+ }
151
+ const selectionBoxes = this.objects.filter(o => o instanceof KritzelSelectionBox);
152
+ this._cachedSelectionBox = selectionBoxes.length > 0 ? selectionBoxes[0] : null;
153
+ this._selectionBoxCacheValid = true;
154
+ return this._cachedSelectionBox;
155
+ }
156
+ /**
157
+ * Gets the current local user's selection group if one exists.
158
+ * When a local user ID is set, returns only the selection group belonging to that user.
159
+ * Uses caching for O(1) access after initial lookup.
160
+ * @returns The local user's selection group or null if none exists
161
+ */
162
+ get selectionGroup() {
163
+ if (this._selectionGroupCacheValid) {
164
+ return this._cachedSelectionGroup;
165
+ }
166
+ const selectionGroups = this.objects.filter(o => o instanceof KritzelSelectionGroup);
167
+ if (this._localUserId) {
168
+ this._cachedSelectionGroup = selectionGroups.find(sg => sg.userId === this._localUserId) ?? null;
169
+ }
170
+ else {
171
+ this._cachedSelectionGroup = selectionGroups.length > 0 ? selectionGroups[0] : null;
172
+ }
173
+ this._selectionGroupCacheValid = true;
174
+ return this._cachedSelectionGroup;
175
+ }
176
+ /**
177
+ * Invalidate cached selection objects. Call this when selection objects are inserted or removed.
178
+ */
179
+ invalidateSelectionCache() {
180
+ this._selectionBoxCacheValid = false;
181
+ this._selectionGroupCacheValid = false;
182
+ }
183
+ /**
184
+ * Directly set the cached selection box reference for O(1) access.
185
+ * Use this when creating the selection box to avoid a filter lookup.
186
+ * @param box - The selection box to cache, or null to clear the cache
187
+ */
188
+ setSelectionBox(box) {
189
+ this._cachedSelectionBox = box;
190
+ this._selectionBoxCacheValid = true;
191
+ }
192
+ /**
193
+ * Directly set the cached selection group reference for O(1) access.
194
+ * Use this when creating the selection group to avoid a filter lookup.
195
+ * @param group - The selection group to cache, or null to clear the cache
196
+ */
197
+ setSelectionGroup(group) {
198
+ this._cachedSelectionGroup = group;
199
+ this._selectionGroupCacheValid = true;
200
+ }
201
+ /**
202
+ * Sets the local user ID for scoping selection group lookups.
203
+ * When set, the selectionGroup getter returns only the group owned by this user.
204
+ * @param userId - The local user's ID, or null for non-collaborative mode
205
+ */
206
+ setLocalUserId(userId) {
207
+ this._localUserId = userId;
208
+ this.invalidateSelectionCache();
209
+ }
210
+ /**
211
+ * Gets the currently active text object being edited.
212
+ * @returns The text object in editing mode, or null if none
213
+ */
214
+ get activeText() {
215
+ const activeTexts = this.objects.filter(o => o instanceof KritzelText && o.isEditing);
216
+ return activeTexts.length > 0 ? activeTexts[0] : null;
217
+ }
218
+ /**
219
+ * Gets the currently active shape object being edited.
220
+ * @returns The shape object in editing mode, or null if none
221
+ */
222
+ get activeShape() {
223
+ const activeShapes = this.objects.filter(o => o instanceof KritzelShape && o.isEditing);
224
+ return activeShapes.length > 0 ? activeShapes[0] : null;
225
+ }
226
+ /**
227
+ * Gets the currently selected dynamic object whose focused descendant is an input-like element.
228
+ * @returns The interactive dynamic object with focused input-like content, or null if none matches
229
+ */
230
+ get activeInteractiveDynamicObject() {
231
+ const interactiveDynamicObject = this.selectedObjects.find(object => KritzelClassHelper.isInstanceOf(object, 'KritzelDynamicObject') && object.hasFocusedInputElement());
232
+ return interactiveDynamicObject ?? null;
233
+ }
234
+ /**
235
+ * Gets the path currently being drawn (not yet completed).
236
+ * @returns The incomplete path object, or null if no path is being drawn
237
+ */
238
+ get currentPath() {
239
+ const drawingPaths = this.objects.filter(o => o instanceof KritzelPath && o.isCompleted === false);
240
+ return drawingPaths.length > 0 ? drawingPaths[0] : null;
241
+ }
242
+ /**
243
+ * Gets the line currently being drawn (not yet completed).
244
+ * @returns The incomplete line object, or null if no line is being drawn
245
+ */
246
+ get currentLine() {
247
+ const drawingLines = this.objects.filter(o => o instanceof KritzelLine && o.isCompleted === false);
248
+ return drawingLines.length > 0 ? drawingLines[0] : null;
249
+ }
250
+ /**
251
+ * Gets the horizontal offset of the host element from the viewport.
252
+ * @returns The left position of the host element in client coordinates
253
+ */
254
+ get offsetX() {
255
+ return this.host.getBoundingClientRect().left;
256
+ }
257
+ /**
258
+ * Gets the vertical offset of the host element from the viewport.
259
+ * @returns The top position of the host element in client coordinates
260
+ */
261
+ get offsetY() {
262
+ return this.host.getBoundingClientRect().top;
263
+ }
264
+ /**
265
+ * Checks if the engine is currently disabled.
266
+ * The engine is disabled when not enabled, not ready, or no active workspace exists.
267
+ * @returns True if the engine is disabled and should not process interactions
268
+ */
269
+ get isDisabled() {
270
+ return this._state.isEnabled === false || this._state.isReady === false || this._state.activeWorkspace === null;
271
+ }
272
+ /**
273
+ * Checks if any pointer is currently down (active).
274
+ * @returns True if at least one pointer is currently active
275
+ */
276
+ get isPointerDown() {
277
+ return this._state.pointers.size > 0;
278
+ }
279
+ /**
280
+ * Creates a new KritzelStore instance.
281
+ * @param state - The initial engine state configuration
282
+ */
283
+ constructor(state) {
284
+ this._state = {
285
+ ...state,
286
+ contextMenuItems: [...state.contextMenuItems],
287
+ debugInfo: { ...state.debugInfo },
288
+ pointers: new Map(state.pointers),
289
+ workspaces: [...state.workspaces],
290
+ cursor: { ...state.cursor },
291
+ };
292
+ this._state.objects = new KritzelObjectMap();
293
+ }
294
+ /**
295
+ * Registers a listener for changes to a specific state property.
296
+ * The listener will be called whenever the property value changes.
297
+ * @typeParam K - The state property key type
298
+ * @param property - The property key to listen for changes on
299
+ * @param listener - The callback function to invoke on changes
300
+ */
301
+ onStateChange(property, listener) {
302
+ if (!this._listeners.has(property)) {
303
+ this._listeners.set(property, new Set());
304
+ }
305
+ const listenersForProperty = this._listeners.get(property);
306
+ if (!listenersForProperty) {
307
+ throw new Error(`Listeners set for property ${String(property)} was not initialized.`);
308
+ }
309
+ listenersForProperty.add(listener);
310
+ }
311
+ /**
312
+ * Gets the current value of a state property as readonly.
313
+ * @typeParam K - The state property key type
314
+ * @param property - The property key to retrieve
315
+ * @returns The current value of the property
316
+ */
317
+ getState(property) {
318
+ return this._state[property];
319
+ }
320
+ /**
321
+ * Sets a state property value and notifies registered listeners.
322
+ * Only triggers listeners if the value actually changed.
323
+ * @typeParam K - The state property key type
324
+ * @param property - The property key to set
325
+ * @param value - The new value to assign
326
+ */
327
+ setState(property, value) {
328
+ const oldValue = this._state[property];
329
+ if (oldValue !== value) {
330
+ this._state[property] = value;
331
+ const listenersForProperty = this._listeners.get(property);
332
+ if (listenersForProperty) {
333
+ listenersForProperty.forEach(listener => listener(value, oldValue, String(property)));
334
+ }
335
+ }
336
+ }
337
+ }