@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.
- package/LICENSE.md +50 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/engine.constants-CakmdKMW.js +28206 -0
- package/dist/cjs/index-BbbWU2aN.js +1742 -0
- package/dist/cjs/index.cjs.js +4232 -0
- package/dist/cjs/kritzel-awareness-cursors_5.cjs.entry.js +28004 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/stencil.cjs.js +25 -0
- package/dist/collection/classes/core/core.class.js +1389 -0
- package/dist/collection/classes/core/reviver.class.js +124 -0
- package/dist/collection/classes/core/store.class.js +337 -0
- package/dist/collection/classes/core/viewport.class.js +794 -0
- package/dist/collection/classes/core/workspace.class.js +112 -0
- package/dist/collection/classes/handlers/base.handler.js +20 -0
- package/dist/collection/classes/handlers/context-menu.handler.js +170 -0
- package/dist/collection/classes/handlers/hover.handler.js +35 -0
- package/dist/collection/classes/handlers/key.handler.js +162 -0
- package/dist/collection/classes/handlers/line-handle.handler.js +475 -0
- package/dist/collection/classes/handlers/move.handler.js +295 -0
- package/dist/collection/classes/handlers/resize.handler.js +327 -0
- package/dist/collection/classes/handlers/rotation.handler.js +174 -0
- package/dist/collection/classes/handlers/selection.handler.js +526 -0
- package/dist/collection/classes/managers/anchor.manager.js +1476 -0
- package/dist/collection/classes/managers/browser-permission.manager.js +64 -0
- package/dist/collection/classes/managers/clipboard.manager.js +346 -0
- package/dist/collection/classes/managers/clipboard.types.js +1 -0
- package/dist/collection/classes/managers/cursor.manager.js +139 -0
- package/dist/collection/classes/managers/license.manager.js +341 -0
- package/dist/collection/classes/managers/localization.manager.js +227 -0
- package/dist/collection/classes/managers/theme.manager.js +206 -0
- package/dist/collection/classes/objects/base-object.class.js +462 -0
- package/dist/collection/classes/objects/dynamic-object.class.js +437 -0
- package/dist/collection/classes/objects/group.class.js +590 -0
- package/dist/collection/classes/objects/image.class.js +500 -0
- package/dist/collection/classes/objects/line.class.js +789 -0
- package/dist/collection/classes/objects/path.class.js +578 -0
- package/dist/collection/classes/objects/selection-box.class.js +32 -0
- package/dist/collection/classes/objects/selection-group.class.js +752 -0
- package/dist/collection/classes/objects/shape.class.js +628 -0
- package/dist/collection/classes/objects/text.class.js +461 -0
- package/dist/collection/classes/providers/assets/asset-resolver.class.js +536 -0
- package/dist/collection/classes/providers/assets/http-asset-provider.class.js +111 -0
- package/dist/collection/classes/providers/assets/indexeddb-asset-provider.class.js +241 -0
- package/dist/collection/classes/providers/assets/presigned-asset-provider.class.js +86 -0
- package/dist/collection/classes/providers/paste-intent/event-paste-intent.provider.js +48 -0
- package/dist/collection/classes/providers/paste-intent/ios-paste-intent.provider.js +16 -0
- package/dist/collection/classes/providers/paste-intent/navigator-paste-intent.provider.js +86 -0
- package/dist/collection/classes/providers/sync/broadcast-sync-provider.class.js +100 -0
- package/dist/collection/classes/providers/sync/hocuspocus-sync-provider.class.js +333 -0
- package/dist/collection/classes/providers/sync/in-memory-sync-provider.class.js +69 -0
- package/dist/collection/classes/providers/sync/indexeddb-sync-provider.class.js +39 -0
- package/dist/collection/classes/providers/sync/websocket-sync-provider.class.js +110 -0
- package/dist/collection/classes/registries/dynamic-object-renderer.registry.js +52 -0
- package/dist/collection/classes/registries/font-registry.class.js +161 -0
- package/dist/collection/classes/registries/icon-registry.class.js +118 -0
- package/dist/collection/classes/registries/paste-intent-provider.registry.js +26 -0
- package/dist/collection/classes/registries/tool.registry.js +69 -0
- package/dist/collection/classes/structures/app-state-map.structure.js +461 -0
- package/dist/collection/classes/structures/object-map.structure.js +1103 -0
- package/dist/collection/classes/structures/quadtree.structure.js +251 -0
- package/dist/collection/classes/tools/base-tool.class.js +88 -0
- package/dist/collection/classes/tools/brush-tool.class.js +236 -0
- package/dist/collection/classes/tools/eraser-tool.class.js +133 -0
- package/dist/collection/classes/tools/image-tool.class.js +152 -0
- package/dist/collection/classes/tools/line-tool.class.js +249 -0
- package/dist/collection/classes/tools/selection-tool.class.js +611 -0
- package/dist/collection/classes/tools/shape-tool.class.js +251 -0
- package/dist/collection/classes/tools/text-tool.class.js +179 -0
- package/dist/collection/collection-manifest.json +17 -0
- package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.css +115 -0
- package/dist/collection/components/kritzel-awareness-cursors/kritzel-awareness-cursors.js +380 -0
- package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.css +10 -0
- package/dist/collection/components/kritzel-cursor-trail/kritzel-cursor-trail.js +153 -0
- package/dist/collection/components/kritzel-engine/kritzel-engine.css +81 -0
- package/dist/collection/components/kritzel-engine/kritzel-engine.js +6345 -0
- package/dist/collection/components/kritzel-icon/kritzel-icon.css +18 -0
- package/dist/collection/components/kritzel-icon/kritzel-icon.js +93 -0
- package/dist/collection/components/kritzel-watermark/kritzel-watermark.css +29 -0
- package/dist/collection/components/kritzel-watermark/kritzel-watermark.js +83 -0
- package/dist/collection/configs/default-asset-storage.config.js +9 -0
- package/dist/collection/configs/default-brush-tool.config.js +9 -0
- package/dist/collection/configs/default-engine-config.js +73 -0
- package/dist/collection/configs/default-line-tool.config.js +12 -0
- package/dist/collection/configs/default-shape-tool.config.js +15 -0
- package/dist/collection/configs/default-sync.config.js +6 -0
- package/dist/collection/configs/default-text-tool.config.js +12 -0
- package/dist/collection/constants/color-palette.constants.js +40 -0
- package/dist/collection/constants/core.constants.js +1 -0
- package/dist/collection/constants/engine.constants.js +4 -0
- package/dist/collection/constants/license.constants.js +25 -0
- package/dist/collection/constants/schema.constants.js +4 -0
- package/dist/collection/constants/storage.constants.js +1 -0
- package/dist/collection/constants/stroke-size.constants.js +2 -0
- package/dist/collection/constants/text-tool-fonts.constants.js +18 -0
- package/dist/collection/constants/version.js +6 -0
- package/dist/collection/enums/alignment.enum.js +9 -0
- package/dist/collection/enums/event-button.enum.js +6 -0
- package/dist/collection/enums/handle-type.enum.js +7 -0
- package/dist/collection/enums/shape-type.enum.js +6 -0
- package/dist/collection/events/active-workspace-change.event.js +1 -0
- package/dist/collection/events/editor-is-ready.event.js +1 -0
- package/dist/collection/events/login.event.js +1 -0
- package/dist/collection/helpers/alignment.helper.js +73 -0
- package/dist/collection/helpers/class.helper.js +5 -0
- package/dist/collection/helpers/color.helper.js +106 -0
- package/dist/collection/helpers/cursor.helper.js +57 -0
- package/dist/collection/helpers/devices.helper.js +28 -0
- package/dist/collection/helpers/event.helper.js +58 -0
- package/dist/collection/helpers/geometry.helper.js +149 -0
- package/dist/collection/helpers/html.helper.js +116 -0
- package/dist/collection/helpers/image-file.helper.js +6 -0
- package/dist/collection/helpers/keyboard.helper.js +55 -0
- package/dist/collection/helpers/localization.helper.js +25 -0
- package/dist/collection/helpers/math.helper.js +8 -0
- package/dist/collection/helpers/migration.helper.js +45 -0
- package/dist/collection/helpers/object.helper.js +29 -0
- package/dist/collection/helpers/svg-export.helper.js +655 -0
- package/dist/collection/helpers/theme.helper.js +77 -0
- package/dist/collection/helpers/tool-config.helper.js +63 -0
- package/dist/collection/helpers/wheel.helper.js +113 -0
- package/dist/collection/index.js +107 -0
- package/dist/collection/interfaces/anchor.interface.js +1 -0
- package/dist/collection/interfaces/arrow-head.interface.js +1 -0
- package/dist/collection/interfaces/asset-provider.interface.js +1 -0
- package/dist/collection/interfaces/asset-storage-config.interface.js +1 -0
- package/dist/collection/interfaces/asset.interface.js +1 -0
- package/dist/collection/interfaces/bounding-box.interface.js +1 -0
- package/dist/collection/interfaces/clonable.interface.js +1 -0
- package/dist/collection/interfaces/context-menu-item.interface.js +1 -0
- package/dist/collection/interfaces/context-menu-state.interface.js +1 -0
- package/dist/collection/interfaces/debug-info.interface.js +1 -0
- package/dist/collection/interfaces/dialog.interface.js +1 -0
- package/dist/collection/interfaces/document-metadata.interface.js +1 -0
- package/dist/collection/interfaces/dynamic-object-renderer.interface.js +1 -0
- package/dist/collection/interfaces/engine-state.interface.js +1 -0
- package/dist/collection/interfaces/font.interface.js +1 -0
- package/dist/collection/interfaces/localization.interface.js +1 -0
- package/dist/collection/interfaces/login-config.interface.js +1 -0
- package/dist/collection/interfaces/master-detail.interface.js +1 -0
- package/dist/collection/interfaces/menu-item.interface.js +1 -0
- package/dist/collection/interfaces/migration.interface.js +1 -0
- package/dist/collection/interfaces/notification.interface.js +1 -0
- package/dist/collection/interfaces/object-change-event.interface.js +1 -0
- package/dist/collection/interfaces/object-export.interface.js +1 -0
- package/dist/collection/interfaces/object.interface.js +1 -0
- package/dist/collection/interfaces/paste-intent-provider.interface.js +1 -0
- package/dist/collection/interfaces/point.interface.js +1 -0
- package/dist/collection/interfaces/polygon.interface.js +1 -0
- package/dist/collection/interfaces/remote-cursor.interface.js +1 -0
- package/dist/collection/interfaces/selection-state.interface.js +1 -0
- package/dist/collection/interfaces/serializable.interface.js +1 -0
- package/dist/collection/interfaces/settings.interface.js +1 -0
- package/dist/collection/interfaces/share.interface.js +1 -0
- package/dist/collection/interfaces/shortcut.interface.js +1 -0
- package/dist/collection/interfaces/sync-config.interface.js +21 -0
- package/dist/collection/interfaces/sync-provider.interface.js +1 -0
- package/dist/collection/interfaces/theme.interface.js +1 -0
- package/dist/collection/interfaces/tool-config.interface.js +1 -0
- package/dist/collection/interfaces/tool-type.interface.js +1 -0
- package/dist/collection/interfaces/tool.interface.js +1 -0
- package/dist/collection/interfaces/toolbar-item.interface.js +1 -0
- package/dist/collection/interfaces/undo-state.interface.js +1 -0
- package/dist/collection/interfaces/user.interface.js +1 -0
- package/dist/collection/interfaces/viewport-state.interface.js +1 -0
- package/dist/collection/locales/de-locale.js +119 -0
- package/dist/collection/locales/en-locale.js +120 -0
- package/dist/collection/locales/fr-locale.js +119 -0
- package/dist/collection/migrations/app-state.migrations.js +47 -0
- package/dist/collection/migrations/workspace.migrations.js +67 -0
- package/dist/collection/themes/dark-theme.js +340 -0
- package/dist/collection/themes/light-theme.js +346 -0
- package/dist/collection/types/deep-readonly.type.js +1 -0
- package/dist/collection/types/state.types.js +1 -0
- package/dist/components/index.d.ts +47 -0
- package/dist/components/index.js +4143 -0
- package/dist/components/kritzel-awareness-cursors.d.ts +11 -0
- package/dist/components/kritzel-awareness-cursors.js +6 -0
- package/dist/components/kritzel-cursor-trail.d.ts +11 -0
- package/dist/components/kritzel-cursor-trail.js +6 -0
- package/dist/components/kritzel-engine.d.ts +11 -0
- package/dist/components/kritzel-engine.js +52641 -0
- package/dist/components/kritzel-icon.d.ts +11 -0
- package/dist/components/kritzel-icon.js +6 -0
- package/dist/components/kritzel-watermark.d.ts +11 -0
- package/dist/components/kritzel-watermark.js +6 -0
- package/dist/components/p-B2Htv9ou.js +49 -0
- package/dist/components/p-BvRGQvVI.js +3456 -0
- package/dist/components/p-CfSx6HU_.js +1469 -0
- package/dist/components/p-YP8wAcF4.js +122 -0
- package/dist/components/p-fx6msYHJ.js +167 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/engine.constants-Bl5-pbq-.js +28143 -0
- package/dist/esm/index-BU9Mv7y0.js +1715 -0
- package/dist/esm/index.js +4134 -0
- package/dist/esm/kritzel-awareness-cursors_5.entry.js +27978 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/stencil.js +21 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil/index.esm.js +4134 -0
- package/dist/stencil/p-BU9Mv7y0.js +1702 -0
- package/dist/stencil/p-Bl5-pbq-.js +28143 -0
- package/dist/stencil/p-DQuL1Twl.js +3 -0
- package/dist/stencil/p-f0a8b7af.entry.js +27978 -0
- package/dist/stencil/stencil.esm.js +21 -0
- package/dist/types/classes/core/core.class.d.ts +532 -0
- package/dist/types/classes/core/reviver.class.d.ts +32 -0
- package/dist/types/classes/core/store.class.d.ts +198 -0
- package/dist/types/classes/core/viewport.class.d.ts +256 -0
- package/dist/types/classes/core/workspace.class.d.ts +95 -0
- package/dist/types/classes/handlers/base.handler.d.ts +18 -0
- package/dist/types/classes/handlers/context-menu.handler.d.ts +67 -0
- package/dist/types/classes/handlers/hover.handler.d.ts +23 -0
- package/dist/types/classes/handlers/key.handler.d.ts +44 -0
- package/dist/types/classes/handlers/line-handle.handler.d.ts +115 -0
- package/dist/types/classes/handlers/move.handler.d.ts +94 -0
- package/dist/types/classes/handlers/resize.handler.d.ts +95 -0
- package/dist/types/classes/handlers/rotation.handler.d.ts +50 -0
- package/dist/types/classes/handlers/selection.handler.d.ts +153 -0
- package/dist/types/classes/managers/anchor.manager.d.ts +513 -0
- package/dist/types/classes/managers/browser-permission.manager.d.ts +41 -0
- package/dist/types/classes/managers/clipboard.manager.d.ts +71 -0
- package/dist/types/classes/managers/clipboard.types.d.ts +23 -0
- package/dist/types/classes/managers/cursor.manager.d.ts +66 -0
- package/dist/types/classes/managers/license.manager.d.ts +147 -0
- package/dist/types/classes/managers/localization.manager.d.ts +145 -0
- package/dist/types/classes/managers/theme.manager.d.ts +112 -0
- package/dist/types/classes/objects/base-object.class.d.ts +266 -0
- package/dist/types/classes/objects/dynamic-object.class.d.ts +148 -0
- package/dist/types/classes/objects/group.class.d.ts +231 -0
- package/dist/types/classes/objects/image.class.d.ts +246 -0
- package/dist/types/classes/objects/line.class.d.ts +285 -0
- package/dist/types/classes/objects/path.class.d.ts +220 -0
- package/dist/types/classes/objects/selection-box.class.d.ts +19 -0
- package/dist/types/classes/objects/selection-group.class.d.ts +267 -0
- package/dist/types/classes/objects/shape.class.d.ts +322 -0
- package/dist/types/classes/objects/text.class.d.ts +197 -0
- package/dist/types/classes/providers/assets/asset-resolver.class.d.ts +141 -0
- package/dist/types/classes/providers/assets/http-asset-provider.class.d.ts +79 -0
- package/dist/types/classes/providers/assets/indexeddb-asset-provider.class.d.ts +69 -0
- package/dist/types/classes/providers/assets/presigned-asset-provider.class.d.ts +69 -0
- package/dist/types/classes/providers/paste-intent/event-paste-intent.provider.d.ts +8 -0
- package/dist/types/classes/providers/paste-intent/ios-paste-intent.provider.d.ts +6 -0
- package/dist/types/classes/providers/paste-intent/navigator-paste-intent.provider.d.ts +9 -0
- package/dist/types/classes/providers/sync/broadcast-sync-provider.class.d.ts +23 -0
- package/dist/types/classes/providers/sync/hocuspocus-sync-provider.class.d.ts +163 -0
- package/dist/types/classes/providers/sync/in-memory-sync-provider.class.d.ts +39 -0
- package/dist/types/classes/providers/sync/indexeddb-sync-provider.class.d.ts +25 -0
- package/dist/types/classes/providers/sync/websocket-sync-provider.class.d.ts +63 -0
- package/dist/types/classes/registries/dynamic-object-renderer.registry.d.ts +32 -0
- package/dist/types/classes/registries/font-registry.class.d.ts +19 -0
- package/dist/types/classes/registries/icon-registry.class.d.ts +39 -0
- package/dist/types/classes/registries/paste-intent-provider.registry.d.ts +10 -0
- package/dist/types/classes/registries/tool.registry.d.ts +53 -0
- package/dist/types/classes/structures/app-state-map.structure.d.ts +171 -0
- package/dist/types/classes/structures/object-map.structure.d.ts +403 -0
- package/dist/types/classes/structures/quadtree.structure.d.ts +128 -0
- package/dist/types/classes/tools/base-tool.class.d.ts +72 -0
- package/dist/types/classes/tools/brush-tool.class.d.ts +68 -0
- package/dist/types/classes/tools/eraser-tool.class.d.ts +38 -0
- package/dist/types/classes/tools/image-tool.class.d.ts +74 -0
- package/dist/types/classes/tools/line-tool.class.d.ts +63 -0
- package/dist/types/classes/tools/selection-tool.class.d.ts +188 -0
- package/dist/types/classes/tools/shape-tool.class.d.ts +90 -0
- package/dist/types/classes/tools/text-tool.class.d.ts +66 -0
- package/dist/types/components/kritzel-awareness-cursors/kritzel-awareness-cursors.d.ts +29 -0
- package/dist/types/components/kritzel-cursor-trail/kritzel-cursor-trail.d.ts +19 -0
- package/dist/types/components/kritzel-engine/kritzel-engine.d.ts +695 -0
- package/dist/types/components/kritzel-icon/kritzel-icon.d.ts +6 -0
- package/dist/types/components/kritzel-watermark/kritzel-watermark.d.ts +20 -0
- package/dist/types/components.d.ts +981 -0
- package/dist/types/configs/default-asset-storage.config.d.ts +8 -0
- package/dist/types/configs/default-brush-tool.config.d.ts +2 -0
- package/dist/types/configs/default-engine-config.d.ts +2 -0
- package/dist/types/configs/default-line-tool.config.d.ts +2 -0
- package/dist/types/configs/default-shape-tool.config.d.ts +2 -0
- package/dist/types/configs/default-sync.config.d.ts +5 -0
- package/dist/types/configs/default-text-tool.config.d.ts +2 -0
- package/dist/types/constants/color-palette.constants.d.ts +31 -0
- package/dist/types/constants/core.constants.d.ts +0 -0
- package/dist/types/constants/engine.constants.d.ts +4 -0
- package/dist/types/constants/license.constants.d.ts +25 -0
- package/dist/types/constants/schema.constants.d.ts +4 -0
- package/dist/types/constants/storage.constants.d.ts +1 -0
- package/dist/types/constants/stroke-size.constants.d.ts +2 -0
- package/dist/types/constants/text-tool-fonts.constants.d.ts +3 -0
- package/dist/types/constants/version.d.ts +6 -0
- package/dist/types/enums/alignment.enum.d.ts +8 -0
- package/dist/types/enums/event-button.enum.d.ts +5 -0
- package/dist/types/enums/handle-type.enum.d.ts +6 -0
- package/dist/types/enums/shape-type.enum.d.ts +5 -0
- package/dist/types/events/active-workspace-change.event.d.ts +7 -0
- package/dist/types/events/editor-is-ready.event.d.ts +18 -0
- package/dist/types/events/login.event.d.ts +3 -0
- package/dist/types/helpers/alignment.helper.d.ts +21 -0
- package/dist/types/helpers/class.helper.d.ts +3 -0
- package/dist/types/helpers/color.helper.d.ts +34 -0
- package/dist/types/helpers/cursor.helper.d.ts +22 -0
- package/dist/types/helpers/devices.helper.d.ts +8 -0
- package/dist/types/helpers/event.helper.d.ts +6 -0
- package/dist/types/helpers/geometry.helper.d.ts +38 -0
- package/dist/types/helpers/html.helper.d.ts +8 -0
- package/dist/types/helpers/image-file.helper.d.ts +3 -0
- package/dist/types/helpers/keyboard.helper.d.ts +6 -0
- package/dist/types/helpers/localization.helper.d.ts +18 -0
- package/dist/types/helpers/math.helper.d.ts +4 -0
- package/dist/types/helpers/migration.helper.d.ts +30 -0
- package/dist/types/helpers/object.helper.d.ts +9 -0
- package/dist/types/helpers/svg-export.helper.d.ts +231 -0
- package/dist/types/helpers/theme.helper.d.ts +42 -0
- package/dist/types/helpers/tool-config.helper.d.ts +4 -0
- package/dist/types/helpers/wheel.helper.d.ts +9 -0
- package/dist/types/index.d.ts +109 -0
- package/dist/types/interfaces/anchor.interface.d.ts +147 -0
- package/dist/types/interfaces/arrow-head.interface.d.ts +27 -0
- package/dist/types/interfaces/asset-provider.interface.d.ts +88 -0
- package/dist/types/interfaces/asset-storage-config.interface.d.ts +40 -0
- package/dist/types/interfaces/asset.interface.d.ts +43 -0
- package/dist/types/interfaces/bounding-box.interface.d.ts +8 -0
- package/dist/types/interfaces/clonable.interface.d.ts +3 -0
- package/dist/types/interfaces/context-menu-item.interface.d.ts +25 -0
- package/dist/types/interfaces/context-menu-state.interface.d.ts +16 -0
- package/dist/types/interfaces/debug-info.interface.d.ts +7 -0
- package/dist/types/interfaces/dialog.interface.d.ts +4 -0
- package/dist/types/interfaces/document-metadata.interface.d.ts +6 -0
- package/dist/types/interfaces/dynamic-object-renderer.interface.d.ts +40 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +82 -0
- package/dist/types/interfaces/font.interface.d.ts +15 -0
- package/dist/types/interfaces/localization.interface.d.ts +143 -0
- package/dist/types/interfaces/login-config.interface.d.ts +24 -0
- package/dist/types/interfaces/master-detail.interface.d.ts +14 -0
- package/dist/types/interfaces/menu-item.interface.d.ts +27 -0
- package/dist/types/interfaces/migration.interface.d.ts +16 -0
- package/dist/types/interfaces/notification.interface.d.ts +10 -0
- package/dist/types/interfaces/object-change-event.interface.d.ts +31 -0
- package/dist/types/interfaces/object-export.interface.d.ts +20 -0
- package/dist/types/interfaces/object.interface.d.ts +53 -0
- package/dist/types/interfaces/paste-intent-provider.interface.d.ts +10 -0
- package/dist/types/interfaces/point.interface.d.ts +4 -0
- package/dist/types/interfaces/polygon.interface.d.ts +7 -0
- package/dist/types/interfaces/remote-cursor.interface.d.ts +18 -0
- package/dist/types/interfaces/selection-state.interface.d.ts +7 -0
- package/dist/types/interfaces/serializable.interface.d.ts +5 -0
- package/dist/types/interfaces/settings.interface.d.ts +25 -0
- package/dist/types/interfaces/share.interface.d.ts +9 -0
- package/dist/types/interfaces/shortcut.interface.d.ts +10 -0
- package/dist/types/interfaces/sync-config.interface.d.ts +41 -0
- package/dist/types/interfaces/sync-provider.interface.d.ts +66 -0
- package/dist/types/interfaces/theme.interface.d.ts +553 -0
- package/dist/types/interfaces/tool-config.interface.d.ts +24 -0
- package/dist/types/interfaces/tool-type.interface.d.ts +1 -0
- package/dist/types/interfaces/tool.interface.d.ts +8 -0
- package/dist/types/interfaces/toolbar-item.interface.d.ts +66 -0
- package/dist/types/interfaces/undo-state.interface.d.ts +6 -0
- package/dist/types/interfaces/user.interface.d.ts +22 -0
- package/dist/types/interfaces/viewport-state.interface.d.ts +7 -0
- package/dist/types/locales/de-locale.d.ts +5 -0
- package/dist/types/locales/en-locale.d.ts +6 -0
- package/dist/types/locales/fr-locale.d.ts +5 -0
- package/dist/types/migrations/app-state.migrations.d.ts +11 -0
- package/dist/types/migrations/workspace.migrations.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1873 -0
- package/dist/types/themes/dark-theme.d.ts +5 -0
- package/dist/types/themes/light-theme.d.ts +5 -0
- package/dist/types/types/deep-readonly.type.d.ts +7 -0
- package/dist/types/types/state.types.d.ts +3 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +101 -0
- package/readme.md +11 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { KritzelCore } from "../core/core.class";
|
|
2
|
+
import { KritzelBaseTool } from "../tools/base-tool.class";
|
|
3
|
+
/**
|
|
4
|
+
* A per-engine registry for managing drawing tools in the Kritzel library.
|
|
5
|
+
* Each `KritzelCore` owns its own `KritzelToolRegistry` instance so that
|
|
6
|
+
* multiple editors on the same page do not share tool instances or configs.
|
|
7
|
+
*
|
|
8
|
+
* Tools are instantiated and stored by name, allowing retrieval by name or index.
|
|
9
|
+
*/
|
|
10
|
+
export declare class KritzelToolRegistry {
|
|
11
|
+
private readonly core;
|
|
12
|
+
/** Internal storage for registered tools, mapping tool names to their instances. */
|
|
13
|
+
private registry;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new tool registry bound to a specific `KritzelCore` instance.
|
|
16
|
+
* The bound core is used as the constructor argument when registering new tools.
|
|
17
|
+
*
|
|
18
|
+
* @param core - The `KritzelCore` instance this registry is bound to.
|
|
19
|
+
*/
|
|
20
|
+
constructor(core: KritzelCore);
|
|
21
|
+
/**
|
|
22
|
+
* Registers a new tool by instantiating it with the registry's bound core.
|
|
23
|
+
* The tool is stored in the registry under the specified name.
|
|
24
|
+
*
|
|
25
|
+
* @param toolName - The unique identifier for the tool.
|
|
26
|
+
* @param constructor - The tool class constructor that extends `KritzelBaseTool`.
|
|
27
|
+
* @returns The newly created and registered tool instance.
|
|
28
|
+
*/
|
|
29
|
+
registerTool(toolName: string, constructor: new (core: KritzelCore) => KritzelBaseTool): KritzelBaseTool;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if a tool with the given name is registered.
|
|
32
|
+
*
|
|
33
|
+
* @param toolName - The unique identifier of the tool to check.
|
|
34
|
+
* @returns `true` if the tool is registered, `false` otherwise.
|
|
35
|
+
*/
|
|
36
|
+
hasTool(toolName: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves a registered tool by its name.
|
|
39
|
+
* Logs a warning if the tool is not found.
|
|
40
|
+
*
|
|
41
|
+
* @param toolName - The unique identifier of the tool to retrieve.
|
|
42
|
+
* @returns The tool instance if found, or `null` if not registered.
|
|
43
|
+
*/
|
|
44
|
+
getTool(toolName: string): KritzelBaseTool | null;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a registered tool by its index in the registry.
|
|
47
|
+
* The index is based on the order tools were registered.
|
|
48
|
+
*
|
|
49
|
+
* @param index - The zero-based index of the tool in the registry.
|
|
50
|
+
* @returns The tool instance at the specified index, or `null` if the index is out of bounds.
|
|
51
|
+
*/
|
|
52
|
+
getToolByIndex(index: number): KritzelBaseTool | null;
|
|
53
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { KritzelWorkspace } from '../core/workspace.class';
|
|
2
|
+
import type { KritzelCore } from '../core/core.class';
|
|
3
|
+
import { KritzelSyncConfig } from '../../interfaces/sync-config.interface';
|
|
4
|
+
import { KritzelDocumentType } from '../../interfaces/document-metadata.interface';
|
|
5
|
+
/**
|
|
6
|
+
* Manages the application state for workspaces with Yjs-based synchronization support.
|
|
7
|
+
* This class provides a synchronized map of workspaces that can be shared across
|
|
8
|
+
* multiple clients using configurable sync providers (e.g., WebSocket, WebRTC).
|
|
9
|
+
*/
|
|
10
|
+
export declare class KritzelAppStateMap {
|
|
11
|
+
private map;
|
|
12
|
+
private _ydoc;
|
|
13
|
+
private _workspacesMap;
|
|
14
|
+
private _metadataMap;
|
|
15
|
+
private _providers;
|
|
16
|
+
private _core;
|
|
17
|
+
private _isReady;
|
|
18
|
+
private _onRemoteChangeCallback;
|
|
19
|
+
private _workspacesObserver;
|
|
20
|
+
private _networkSyncPromise;
|
|
21
|
+
/**
|
|
22
|
+
* Indicates whether the app state map has been initialized and is ready for use.
|
|
23
|
+
* @returns True if initialized and all providers are connected, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
get isReady(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Settles when network providers finish their initial sync (or fail/time out).
|
|
28
|
+
* Resolves immediately when no network providers are configured.
|
|
29
|
+
*/
|
|
30
|
+
whenNetworkSynced(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Indicates whether any configured sync provider replicates over the network.
|
|
33
|
+
* Used by the engine to warn when a matching remote asset storage
|
|
34
|
+
* provider is missing (images would otherwise only exist locally).
|
|
35
|
+
*/
|
|
36
|
+
get hasNetworkSyncProvider(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new KritzelAppStateMap instance with an empty workspace map.
|
|
39
|
+
*/
|
|
40
|
+
constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Registers a callback function to be invoked when remote changes are received.
|
|
43
|
+
* This allows external code to react to workspace changes from other clients.
|
|
44
|
+
* @param callback - The function to call when remote changes occur.
|
|
45
|
+
*/
|
|
46
|
+
onRemoteChange(callback: () => void): void;
|
|
47
|
+
/**
|
|
48
|
+
* Initializes the app state map with Yjs synchronization.
|
|
49
|
+
* Creates a dedicated Y.Doc for app state, sets up workspace observation,
|
|
50
|
+
* instantiates and connects all configured sync providers, and loads existing workspaces.
|
|
51
|
+
* @param core - The KritzelCore instance for triggering re-renders and accessing the store.
|
|
52
|
+
* @param config - Optional sync configuration specifying providers. Defaults to DEFAULT_SYNC_CONFIG.
|
|
53
|
+
* @returns A promise that resolves when all providers are connected and the state is loaded.
|
|
54
|
+
*/
|
|
55
|
+
initialize(core: KritzelCore, config?: KritzelSyncConfig): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves a stable instance identifier for the app-state document.
|
|
58
|
+
* The id is persisted in localStorage and reused across remounts/reloads.
|
|
59
|
+
* @param core - The core instance used to namespace the storage key by editorId.
|
|
60
|
+
* @returns A stable instance identifier.
|
|
61
|
+
* @throws Error when localStorage is unavailable or inaccessible.
|
|
62
|
+
*/
|
|
63
|
+
private getOrCreateAppStateInstanceId;
|
|
64
|
+
/**
|
|
65
|
+
* Handles changes to the Yjs workspaces map.
|
|
66
|
+
* For local changes, only triggers a re-render. For remote changes, synchronizes
|
|
67
|
+
* the local map with the Yjs state by adding, updating, or deleting workspaces.
|
|
68
|
+
* @param event - The Yjs map event containing information about changed keys.
|
|
69
|
+
*/
|
|
70
|
+
private handleWorkspacesChange;
|
|
71
|
+
/**
|
|
72
|
+
* Reconstructs a KritzelWorkspace instance from its serialized form.
|
|
73
|
+
* Restores all properties including id, name, viewport, and timestamps.
|
|
74
|
+
* Handles both legacy { translateX, translateY } and new { centerWorldX, centerWorldY } viewport formats.
|
|
75
|
+
* @param serialized - The serialized workspace data object.
|
|
76
|
+
* @returns A fully reconstructed KritzelWorkspace instance.
|
|
77
|
+
*/
|
|
78
|
+
private reviveWorkspace;
|
|
79
|
+
/**
|
|
80
|
+
* Initializes document metadata if not already set.
|
|
81
|
+
* Uses 'metadata' transaction origin to avoid triggering remote sync callbacks for local state.
|
|
82
|
+
*/
|
|
83
|
+
private initializeMetadata;
|
|
84
|
+
/**
|
|
85
|
+
* Returns whether the document is publicly accessible.
|
|
86
|
+
*/
|
|
87
|
+
getIsPublic(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Sets whether the document is publicly accessible.
|
|
90
|
+
* This change is synced to all connected clients and the server.
|
|
91
|
+
*/
|
|
92
|
+
setIsPublic(isPublic: boolean): void;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the document type stored in metadata.
|
|
95
|
+
*/
|
|
96
|
+
getDocumentType(): KritzelDocumentType;
|
|
97
|
+
/**
|
|
98
|
+
* Executes a callback within a Yjs transaction marked as 'local'.
|
|
99
|
+
* This allows batching multiple Yjs operations and identifying them as local changes.
|
|
100
|
+
* @param callback - The function containing Yjs operations to execute within the transaction.
|
|
101
|
+
*/
|
|
102
|
+
transaction(callback: () => void): void;
|
|
103
|
+
/**
|
|
104
|
+
* Loads all workspaces from the Yjs map into the local map.
|
|
105
|
+
* Clears the existing local map and repopulates it by reviving each serialized workspace.
|
|
106
|
+
* This is typically called during initialization or when a full sync is needed.
|
|
107
|
+
*/
|
|
108
|
+
loadFromYjs(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Resets the app state by clearing both the local map and the Yjs workspaces map.
|
|
111
|
+
* This operation is performed within a local transaction to avoid triggering remote sync callbacks.
|
|
112
|
+
*/
|
|
113
|
+
reset(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Inserts a new workspace into both the local map and the Yjs map.
|
|
116
|
+
* The workspace is serialized before being stored in Yjs for synchronization.
|
|
117
|
+
* @param workspace - The workspace to insert.
|
|
118
|
+
* @returns True if the workspace was successfully inserted, false if it has no id.
|
|
119
|
+
*/
|
|
120
|
+
insert(workspace: KritzelWorkspace): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Updates an existing workspace in both the local map and the Yjs map.
|
|
123
|
+
* The workspace must already exist in the map to be updated.
|
|
124
|
+
* @param workspace - The workspace with updated data.
|
|
125
|
+
* @returns True if the workspace was successfully updated, false if it doesn't exist or has no id.
|
|
126
|
+
*/
|
|
127
|
+
update(workspace: KritzelWorkspace): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Removes a workspace matching the given predicate from both the local map and the Yjs map.
|
|
130
|
+
* Only the first matching workspace will be removed.
|
|
131
|
+
* @param predicate - A function that returns true for the workspace to remove.
|
|
132
|
+
* @returns True if a matching workspace was found and removed, false otherwise.
|
|
133
|
+
*/
|
|
134
|
+
remove(predicate: (workspace: KritzelWorkspace) => boolean): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves a workspace by its unique identifier.
|
|
137
|
+
* @param id - The unique identifier of the workspace to retrieve.
|
|
138
|
+
* @returns The workspace if found, undefined otherwise.
|
|
139
|
+
*/
|
|
140
|
+
get(id: string): KritzelWorkspace | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Returns all workspaces currently stored in the map.
|
|
143
|
+
* @returns An array containing all workspaces.
|
|
144
|
+
*/
|
|
145
|
+
allWorkspaces(): KritzelWorkspace[];
|
|
146
|
+
/**
|
|
147
|
+
* Filters workspaces based on a predicate function.
|
|
148
|
+
* @param predicate - A function that returns true for workspaces to include.
|
|
149
|
+
* @returns An array of workspaces that match the predicate.
|
|
150
|
+
*/
|
|
151
|
+
filter(predicate: (workspace: KritzelWorkspace) => boolean): KritzelWorkspace[];
|
|
152
|
+
/**
|
|
153
|
+
* Finds the first workspace matching the given predicate.
|
|
154
|
+
* @param predicate - A function that returns true for the workspace to find.
|
|
155
|
+
* @returns The first matching workspace, or undefined if no match is found.
|
|
156
|
+
*/
|
|
157
|
+
find(predicate: (workspace: KritzelWorkspace) => boolean): KritzelWorkspace | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Checks if a workspace with the given id exists in the map.
|
|
160
|
+
* @param id - The unique identifier of the workspace to check.
|
|
161
|
+
* @returns True if a workspace with the given id exists, false otherwise.
|
|
162
|
+
*/
|
|
163
|
+
has(id: string): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Destroys the app state map and releases all resources.
|
|
166
|
+
* Unobserves the Yjs workspaces map, disconnects and destroys all sync providers,
|
|
167
|
+
* clears all maps, destroys the Y.Doc, and resets all internal references.
|
|
168
|
+
* This should be called when the app state map is no longer needed.
|
|
169
|
+
*/
|
|
170
|
+
destroy(): void;
|
|
171
|
+
}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
3
|
+
import { KritzelBaseObject } from '../objects/base-object.class';
|
|
4
|
+
import type { KritzelCore } from '../core/core.class';
|
|
5
|
+
import { KritzelSyncConfig } from '../../interfaces/sync-config.interface';
|
|
6
|
+
import { KritzelUndoState } from '../../interfaces/undo-state.interface';
|
|
7
|
+
import { KritzelDocumentType } from '../../interfaces/document-metadata.interface';
|
|
8
|
+
import { IKritzelUser } from '../../interfaces/user.interface';
|
|
9
|
+
/**
|
|
10
|
+
* A synchronized object map that stores and manages drawable objects on the canvas.
|
|
11
|
+
* This structure integrates with Yjs for real-time collaboration and persistence,
|
|
12
|
+
* uses a quadtree for efficient spatial queries, and provides undo/redo functionality.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of objects stored, must extend KritzelBaseObject
|
|
15
|
+
*/
|
|
16
|
+
export declare class KritzelObjectMap<T extends KritzelBaseObject<any>> {
|
|
17
|
+
private quadtree;
|
|
18
|
+
private _ydoc;
|
|
19
|
+
private _objectsMap;
|
|
20
|
+
private _metadataMap;
|
|
21
|
+
private _providers;
|
|
22
|
+
private _undoManager;
|
|
23
|
+
private _reviver;
|
|
24
|
+
private _core;
|
|
25
|
+
private _workspaceId;
|
|
26
|
+
private _isReady;
|
|
27
|
+
private _temporaryItemsCount;
|
|
28
|
+
private _idMap;
|
|
29
|
+
private _awareness;
|
|
30
|
+
private _networkSyncPromise;
|
|
31
|
+
/** When true this map is a background worker: it never renders, emits, or wires awareness. */
|
|
32
|
+
private _headless;
|
|
33
|
+
private _objectsObserver;
|
|
34
|
+
private _stackItemAddedHandler;
|
|
35
|
+
private _stackItemPoppedHandler;
|
|
36
|
+
private _awarenessChangeHandler;
|
|
37
|
+
private _awarenessChangeCallbacks;
|
|
38
|
+
private _objectsChangeCallbacks;
|
|
39
|
+
private _lastAwarenessEmitTime;
|
|
40
|
+
private _awarenessEmitTimeout;
|
|
41
|
+
private readonly AWARENESS_THROTTLE_INTERVAL;
|
|
42
|
+
/**
|
|
43
|
+
* When true, update() only modifies local state (quadtree + idMap)
|
|
44
|
+
* without writing to Yjs. Used during drag operations to avoid
|
|
45
|
+
* redundant full serializations of every child object per frame.
|
|
46
|
+
*/
|
|
47
|
+
private _localOnlyMode;
|
|
48
|
+
/**
|
|
49
|
+
* Tracks whether we're currently executing inside a `transaction()`
|
|
50
|
+
* callback. While true, `markUndoBoundary()` is a no-op so nested
|
|
51
|
+
* insert/remove calls don't split the in-progress undo step.
|
|
52
|
+
*/
|
|
53
|
+
private _inTransaction;
|
|
54
|
+
/**
|
|
55
|
+
* Indicates whether the object map has been initialized and is ready for use.
|
|
56
|
+
* @returns `true` if providers are connected and the map is operational
|
|
57
|
+
*/
|
|
58
|
+
get isReady(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Promise that settles when network providers finish connecting.
|
|
61
|
+
* Resolves immediately if no network providers. Awaited by the loading overlay.
|
|
62
|
+
*/
|
|
63
|
+
whenNetworkSynced(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Whether this map runs detached from the rendered canvas.
|
|
66
|
+
*/
|
|
67
|
+
get isHeadless(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the Yjs Awareness instance, if a network provider is available.
|
|
70
|
+
*/
|
|
71
|
+
get awareness(): Awareness | null;
|
|
72
|
+
/**
|
|
73
|
+
* Whether a network awareness instance is available.
|
|
74
|
+
*/
|
|
75
|
+
get hasAwareness(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Returns the local client ID from the awareness instance.
|
|
78
|
+
* Used to filter out the local user when rendering remote cursors.
|
|
79
|
+
*/
|
|
80
|
+
get localClientId(): number | null;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the local user identity in the awareness state.
|
|
83
|
+
* This broadcasts the user's identity to all connected peers.
|
|
84
|
+
*/
|
|
85
|
+
setLocalUser(user?: IKritzelUser): void;
|
|
86
|
+
private generateColorFromName;
|
|
87
|
+
/**
|
|
88
|
+
* Updates the local cursor position in the awareness state.
|
|
89
|
+
* This broadcasts the cursor position to all connected peers.
|
|
90
|
+
*/
|
|
91
|
+
updateCursorPosition(x: number, y: number): void;
|
|
92
|
+
/**
|
|
93
|
+
* Clears the local cursor position (e.g., when the pointer leaves the canvas).
|
|
94
|
+
*/
|
|
95
|
+
clearCursorPosition(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Sets the ID of the object currently being drawn by the local user.
|
|
98
|
+
* Remote clients use this to derive cursor position from the object's latest
|
|
99
|
+
* coordinates instead of the throttled awareness cursor, reducing desync.
|
|
100
|
+
* Pass `null` when drawing ends.
|
|
101
|
+
*/
|
|
102
|
+
setActiveDrawingObject(objectId: string | null): void;
|
|
103
|
+
/**
|
|
104
|
+
* Broadcasts the local user's selection box bounds via awareness.
|
|
105
|
+
* Remote clients use this to render the selection rectangle in the user's color.
|
|
106
|
+
*/
|
|
107
|
+
setLocalSelectionBox(box: {
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
112
|
+
}): void;
|
|
113
|
+
/**
|
|
114
|
+
* Clears the local selection box from awareness (e.g., when selection completes or is cancelled).
|
|
115
|
+
*/
|
|
116
|
+
clearLocalSelectionBox(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Removes selection groups whose owner is no longer present in awareness.
|
|
119
|
+
* Called when remote clients disconnect to prevent orphaned selection groups
|
|
120
|
+
* from persisting in the workspace state.
|
|
121
|
+
*/
|
|
122
|
+
removeOrphanedSelectionGroups(): void;
|
|
123
|
+
/** Rerenders the canvas unless this map is running headless. */
|
|
124
|
+
private requestRerender;
|
|
125
|
+
/**
|
|
126
|
+
* Registers a callback to be invoked when the awareness state changes.
|
|
127
|
+
* The callback receives the full awareness states map.
|
|
128
|
+
*/
|
|
129
|
+
onAwarenessChange(callback: (states: Map<number, Record<string, any>>) => void): () => void;
|
|
130
|
+
/**
|
|
131
|
+
* Registers a callback to be invoked when remote object changes are received.
|
|
132
|
+
* Used by the awareness cursors component to re-derive cursor positions
|
|
133
|
+
* from the latest object data when a remote user is actively drawing.
|
|
134
|
+
*/
|
|
135
|
+
onObjectsChange(callback: () => void): () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the Yjs UndoManager instance for managing undo/redo operations.
|
|
138
|
+
* @returns The UndoManager instance, or `null` if not initialized
|
|
139
|
+
*/
|
|
140
|
+
get undoManager(): Y.UndoManager | null;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the unique identifier of the workspace this object map belongs to.
|
|
143
|
+
* @returns The workspace ID, or `null` if not initialized
|
|
144
|
+
*/
|
|
145
|
+
get workspaceId(): string | null;
|
|
146
|
+
/**
|
|
147
|
+
* Returns the current state of the undo/redo system.
|
|
148
|
+
* @returns An object containing undo/redo availability and stack sizes
|
|
149
|
+
*/
|
|
150
|
+
get undoState(): KritzelUndoState;
|
|
151
|
+
/**
|
|
152
|
+
* Returns the total number of objects stored in the map.
|
|
153
|
+
* @returns The count of all objects in the quadtree
|
|
154
|
+
*/
|
|
155
|
+
get totalCount(): number;
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves an object from the map by its ID in O(1) time.
|
|
158
|
+
* @param id - The ID of the object to find
|
|
159
|
+
* @returns The object if found, or undefined
|
|
160
|
+
*/
|
|
161
|
+
findById(id: string): T | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a new KritzelObjectMap instance with an empty quadtree.
|
|
164
|
+
* The map must be initialized with `initialize()` before use.
|
|
165
|
+
*/
|
|
166
|
+
constructor();
|
|
167
|
+
/**
|
|
168
|
+
* Initializes the object map with Yjs document, sync providers, and undo manager.
|
|
169
|
+
* This must be called before using any other methods on the object map.
|
|
170
|
+
*
|
|
171
|
+
* @param core - The KritzelCore instance that owns this object map
|
|
172
|
+
* @param workspaceId - A unique identifier for the workspace, used to namespace the Yjs document
|
|
173
|
+
* @param config - Optional sync configuration; defaults to DEFAULT_SYNC_CONFIG if not provided
|
|
174
|
+
* @param options - Optional behavior flags
|
|
175
|
+
* @param options.headless - Run detached from the rendered canvas (no rerenders, events, or awareness)
|
|
176
|
+
* @param options.workspaceName - Workspace name to write into document metadata; defaults to the active workspace's name
|
|
177
|
+
* @returns A promise that resolves when all providers are connected and the map is ready
|
|
178
|
+
*/
|
|
179
|
+
initialize(core: KritzelCore, workspaceId: string, config?: KritzelSyncConfig, options?: {
|
|
180
|
+
headless?: boolean;
|
|
181
|
+
workspaceName?: string;
|
|
182
|
+
}): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Handles changes to the Yjs objects map, synchronizing remote changes with local state.
|
|
185
|
+
* For local changes, only triggers a re-render. For remote changes, deserializes objects
|
|
186
|
+
* and updates the quadtree, handling SelectionGroups specially to maintain correct dimensions.
|
|
187
|
+
*
|
|
188
|
+
* @param event - The Yjs map event containing information about changed keys and their actions
|
|
189
|
+
*/
|
|
190
|
+
private handleObjectsChange;
|
|
191
|
+
/**
|
|
192
|
+
* Initializes document metadata if not already set.
|
|
193
|
+
* Uses 'metadata' transaction origin which is NOT tracked by the UndoManager.
|
|
194
|
+
*/
|
|
195
|
+
private initializeMetadata;
|
|
196
|
+
/**
|
|
197
|
+
* Returns whether the document is publicly accessible.
|
|
198
|
+
*/
|
|
199
|
+
getIsPublic(): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Sets whether the document is publicly accessible.
|
|
202
|
+
* This change is synced to all connected clients and the server,
|
|
203
|
+
* but is NOT tracked by the UndoManager.
|
|
204
|
+
*/
|
|
205
|
+
setIsPublic(isPublic: boolean): void;
|
|
206
|
+
/**
|
|
207
|
+
* Returns the document type stored in metadata.
|
|
208
|
+
*/
|
|
209
|
+
getDocumentType(): KritzelDocumentType;
|
|
210
|
+
/**
|
|
211
|
+
* Returns the workspace name stored in metadata.
|
|
212
|
+
*/
|
|
213
|
+
getWorkspaceName(): string;
|
|
214
|
+
/**
|
|
215
|
+
* Sets the workspace name in metadata.
|
|
216
|
+
* This change is synced to all connected clients and the server,
|
|
217
|
+
* but is NOT tracked by the UndoManager.
|
|
218
|
+
*/
|
|
219
|
+
setWorkspaceName(name: string): void;
|
|
220
|
+
/**
|
|
221
|
+
* Returns the workspace ID stored in metadata.
|
|
222
|
+
*/
|
|
223
|
+
getMetadataWorkspaceId(): string;
|
|
224
|
+
/**
|
|
225
|
+
* Executes a callback within a Yjs transaction, grouping multiple operations
|
|
226
|
+
* into a single undo step. All changes made within the callback will be
|
|
227
|
+
* tracked as a single 'local' origin transaction.
|
|
228
|
+
*
|
|
229
|
+
* @param callback - The function containing operations to execute within the transaction
|
|
230
|
+
*/
|
|
231
|
+
transaction(callback: () => void): void;
|
|
232
|
+
/**
|
|
233
|
+
* Closes the current undo stack item so the next tracked change starts
|
|
234
|
+
* a new one. Call at gesture/stroke boundaries (e.g. drag/resize/rotate
|
|
235
|
+
* end, brush/line/shape stroke end).
|
|
236
|
+
*
|
|
237
|
+
* No-op while a transaction() is open.
|
|
238
|
+
*/
|
|
239
|
+
stopUndoCapturing(): void;
|
|
240
|
+
/**
|
|
241
|
+
* Internal: closes the current undo stack item. No-op while inside a
|
|
242
|
+
* transaction() so wrapped multi-op work stays a single undo step.
|
|
243
|
+
*/
|
|
244
|
+
private markUndoBoundary;
|
|
245
|
+
/**
|
|
246
|
+
* Executes a callback where all update() calls only modify local state
|
|
247
|
+
* (quadtree + idMap) without writing to Yjs. This avoids expensive full
|
|
248
|
+
* serializations during continuous operations like dragging many objects.
|
|
249
|
+
*
|
|
250
|
+
* Objects updated inside this callback must be persisted later
|
|
251
|
+
* (e.g., via a normal update() call at drag end).
|
|
252
|
+
*
|
|
253
|
+
* @param callback - The function containing operations to execute locally
|
|
254
|
+
*/
|
|
255
|
+
withLocalUpdatesOnly(callback: () => void): void;
|
|
256
|
+
/**
|
|
257
|
+
* Loads all objects from the Yjs objects map into the local quadtree.
|
|
258
|
+
* Clears the existing quadtree and repopulates it by deserializing each
|
|
259
|
+
* object stored in the Yjs map.
|
|
260
|
+
*/
|
|
261
|
+
loadFromYjs(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Resets the object map by clearing both the local quadtree and the Yjs objects map.
|
|
264
|
+
* This removes all objects from the workspace. The operation is tracked as a 'local'
|
|
265
|
+
* transaction for undo/redo purposes.
|
|
266
|
+
*/
|
|
267
|
+
reset(): void;
|
|
268
|
+
/**
|
|
269
|
+
* Inserts a new object into both the local quadtree and the Yjs objects map.
|
|
270
|
+
* The object must have a valid ID. Non-persistable objects (like SelectionBox)
|
|
271
|
+
* are only added to the quadtree, not to Yjs.
|
|
272
|
+
*
|
|
273
|
+
* @param object - The object to insert; must have a valid `id` property
|
|
274
|
+
* @returns `true` if the object was successfully inserted, `false` if the object has no ID
|
|
275
|
+
*/
|
|
276
|
+
insert(object: T): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Updates an existing object in both the local quadtree and the Yjs objects map.
|
|
279
|
+
* The object must already exist in the map. Supports temporary updates that can
|
|
280
|
+
* be consolidated later (e.g., for incremental text input).
|
|
281
|
+
*
|
|
282
|
+
* @param object - The object with updated properties; must have a valid `id` that exists in the map
|
|
283
|
+
* @param options - Optional settings for the update operation
|
|
284
|
+
* @param options.temporary - If `true`, marks this as a temporary change that can be consolidated
|
|
285
|
+
* with other temporary changes into a single undo step
|
|
286
|
+
* @returns `true` if the object was successfully updated, `false` if the object doesn't exist or has no ID
|
|
287
|
+
*/
|
|
288
|
+
update(object: T, options?: {
|
|
289
|
+
temporary?: boolean;
|
|
290
|
+
skipReindex?: boolean;
|
|
291
|
+
}): boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Removes objects matching the given predicate from both the quadtree and Yjs map.
|
|
294
|
+
* Each removal is tracked as a separate 'local' transaction for undo/redo.
|
|
295
|
+
*
|
|
296
|
+
* @param predicate - A function that returns `true` for objects that should be removed
|
|
297
|
+
*/
|
|
298
|
+
remove(predicate: (object: T) => boolean): void;
|
|
299
|
+
/**
|
|
300
|
+
* Filters objects in the quadtree based on a predicate function.
|
|
301
|
+
*
|
|
302
|
+
* @param predicate - A function that returns `true` for objects to include in the result
|
|
303
|
+
* @returns An array of objects that match the predicate
|
|
304
|
+
*/
|
|
305
|
+
filter(predicate: (object: T) => boolean): T[];
|
|
306
|
+
/**
|
|
307
|
+
* Returns all objects stored in the quadtree.
|
|
308
|
+
*
|
|
309
|
+
* @returns An array containing all objects in the map
|
|
310
|
+
*/
|
|
311
|
+
allObjects(): T[];
|
|
312
|
+
/**
|
|
313
|
+
* Queries the quadtree for objects within or intersecting a given 3D range.
|
|
314
|
+
* This is an efficient spatial query that avoids iterating over all objects.
|
|
315
|
+
*
|
|
316
|
+
* @param range - The bounding box to query
|
|
317
|
+
* @param range.x - The x-coordinate of the range's origin
|
|
318
|
+
* @param range.y - The y-coordinate of the range's origin
|
|
319
|
+
* @param range.z - The z-coordinate (layer) of the range's origin
|
|
320
|
+
* @param range.width - The width of the range
|
|
321
|
+
* @param range.height - The height of the range
|
|
322
|
+
* @param range.depth - Optional depth for 3D queries
|
|
323
|
+
* @returns An array of objects within or intersecting the specified range
|
|
324
|
+
*/
|
|
325
|
+
query(range: {
|
|
326
|
+
x: number;
|
|
327
|
+
y: number;
|
|
328
|
+
z: number;
|
|
329
|
+
width: number;
|
|
330
|
+
height: number;
|
|
331
|
+
depth?: number;
|
|
332
|
+
}): T[];
|
|
333
|
+
/**
|
|
334
|
+
* Determines whether an object should be persisted to the Yjs document.
|
|
335
|
+
* Certain objects like SelectionBox are transient and should not be synced.
|
|
336
|
+
*
|
|
337
|
+
* @param object - The object to check for persistability
|
|
338
|
+
* @returns `true` if the object should be persisted, `false` otherwise
|
|
339
|
+
*/
|
|
340
|
+
private isPersistable;
|
|
341
|
+
/**
|
|
342
|
+
* Undoes the last operation if possible.
|
|
343
|
+
* Reverts the most recent change in the undo stack and emits an objects change event.
|
|
344
|
+
*/
|
|
345
|
+
undo(): void;
|
|
346
|
+
/**
|
|
347
|
+
* Redoes the last undone operation if possible.
|
|
348
|
+
* Reapplies the most recent change from the redo stack and emits an objects change event.
|
|
349
|
+
*/
|
|
350
|
+
redo(): void;
|
|
351
|
+
/**
|
|
352
|
+
* Checks whether an undo operation is available.
|
|
353
|
+
*
|
|
354
|
+
* @returns `true` if there are operations in the undo stack, `false` otherwise
|
|
355
|
+
*/
|
|
356
|
+
canUndo(): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Checks whether a redo operation is available.
|
|
359
|
+
*
|
|
360
|
+
* @returns `true` if there are operations in the redo stack, `false` otherwise
|
|
361
|
+
*/
|
|
362
|
+
canRedo(): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Clears all undo and redo history.
|
|
365
|
+
* After calling this, no undo or redo operations will be available.
|
|
366
|
+
* Also resets the temporary items counter.
|
|
367
|
+
*/
|
|
368
|
+
clearHistory(): void;
|
|
369
|
+
/**
|
|
370
|
+
* Consolidates all temporary items in the undo stack into a single undo item.
|
|
371
|
+
* This is useful when you want to merge multiple incremental changes (e.g., individual
|
|
372
|
+
* keystrokes during text editing) into a single undoable action.
|
|
373
|
+
*
|
|
374
|
+
* The method works by undoing all temporary items and then redoing them within
|
|
375
|
+
* a single 'local' transaction, effectively merging them into one undo step.
|
|
376
|
+
* After consolidation, the temporary items counter is reset to zero.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* // After multiple temporary text updates
|
|
380
|
+
* objectMap.update(textObject, { temporary: true }); // keystroke 1
|
|
381
|
+
* objectMap.update(textObject, { temporary: true }); // keystroke 2
|
|
382
|
+
* objectMap.consolidateTemporaryItems(); // merge into single undo step
|
|
383
|
+
*/
|
|
384
|
+
consolidateTemporaryItems(): void;
|
|
385
|
+
/**
|
|
386
|
+
* Removes all temporary items from the undo stack without consolidating them.
|
|
387
|
+
* Use this to discard temporary changes completely when they should not be
|
|
388
|
+
* preserved in the undo history (e.g., when cancelling an operation).
|
|
389
|
+
*
|
|
390
|
+
* Unlike `consolidateTemporaryItems`, this method does not preserve the changes
|
|
391
|
+
* as a single undo step - it simply removes them from history entirely.
|
|
392
|
+
*/
|
|
393
|
+
clearTemporaryItems(): void;
|
|
394
|
+
/**
|
|
395
|
+
* Hot-swaps sync providers on the existing Y.Doc without destroying the document,
|
|
396
|
+
* objects, undo manager, or quadtree. Tears down old awareness subscriptions,
|
|
397
|
+
/**
|
|
398
|
+
* Destroys the object map and releases all resources.
|
|
399
|
+
* This removes all observers, destroys the undo manager, disconnects all providers,
|
|
400
|
+
* and destroys the Yjs document. After calling this, the object map cannot be used.
|
|
401
|
+
*/
|
|
402
|
+
destroy(): void;
|
|
403
|
+
}
|