@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,513 @@
|
|
|
1
|
+
import { AnchorIndexEntry, AnchorLinesRenderData, AnchorVisualization, LineAnchor, SnapCandidate, SnapIndicatorRenderData, SnapPreviewCandidate, SnapTarget } from '../../interfaces/anchor.interface';
|
|
2
|
+
import { KritzelCore } from '../core/core.class';
|
|
3
|
+
import { KritzelLine } from '../objects/line.class';
|
|
4
|
+
import { KritzelBaseObject } from '../objects/base-object.class';
|
|
5
|
+
type AnchorClipInfo = {
|
|
6
|
+
localX: number;
|
|
7
|
+
localY: number;
|
|
8
|
+
worldX: number;
|
|
9
|
+
worldY: number;
|
|
10
|
+
t?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Manages anchor connections between line endpoints and other objects.
|
|
14
|
+
* Maintains a runtime index for efficient reverse lookups and handles
|
|
15
|
+
* snap detection during line endpoint dragging.
|
|
16
|
+
*/
|
|
17
|
+
export declare class KritzelAnchorManager {
|
|
18
|
+
private readonly _core;
|
|
19
|
+
/**
|
|
20
|
+
* Runtime index mapping objectId to the lines anchored to it.
|
|
21
|
+
* This is derived from the anchor properties on lines and rebuilt as needed.
|
|
22
|
+
*/
|
|
23
|
+
private readonly _anchorIndex;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new KritzelAnchorManager instance.
|
|
26
|
+
* @param core - The KritzelCore instance that provides access to the store and other managers.
|
|
27
|
+
*/
|
|
28
|
+
constructor(core: KritzelCore);
|
|
29
|
+
/**
|
|
30
|
+
* Sets an anchor from a line endpoint to a target object's center.
|
|
31
|
+
* Updates both the line's anchor property and the internal index.
|
|
32
|
+
* Prevents anchoring both endpoints of the same line to the same object.
|
|
33
|
+
*
|
|
34
|
+
* @param lineId - The unique identifier of the line to anchor.
|
|
35
|
+
* @param endpoint - Which endpoint of the line to anchor ('start' or 'end').
|
|
36
|
+
* @param targetObjectId - The unique identifier of the object to anchor to.
|
|
37
|
+
*/
|
|
38
|
+
setAnchor(lineId: string, endpoint: 'start' | 'end', targetObjectId: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Removes an anchor from a line endpoint.
|
|
41
|
+
* Updates both the line's anchor property and the internal index.
|
|
42
|
+
*
|
|
43
|
+
* @param lineId - The unique identifier of the line.
|
|
44
|
+
* @param endpoint - Which endpoint's anchor to remove ('start' or 'end').
|
|
45
|
+
*/
|
|
46
|
+
removeAnchor(lineId: string, endpoint: 'start' | 'end'): void;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the anchor for a specific line endpoint.
|
|
49
|
+
*
|
|
50
|
+
* @param lineId - The unique identifier of the line.
|
|
51
|
+
* @param endpoint - Which endpoint to get the anchor for ('start' or 'end').
|
|
52
|
+
* @returns The LineAnchor object if an anchor exists, null otherwise.
|
|
53
|
+
*/
|
|
54
|
+
getAnchor(lineId: string, endpoint: 'start' | 'end'): LineAnchor | null;
|
|
55
|
+
/**
|
|
56
|
+
* Gets all lines that have an endpoint anchored to the specified object.
|
|
57
|
+
* Uses the internal anchor index for efficient reverse lookup.
|
|
58
|
+
*
|
|
59
|
+
* @param objectId - The unique identifier of the object to query.
|
|
60
|
+
* @returns An array of AnchorIndexEntry objects containing lineId and endpoint information.
|
|
61
|
+
*/
|
|
62
|
+
getLinesAnchoredTo(objectId: string): AnchorIndexEntry[];
|
|
63
|
+
/**
|
|
64
|
+
* Updates all line endpoints that are anchored to the specified object.
|
|
65
|
+
* Should be called when an object moves to keep anchored lines in sync.
|
|
66
|
+
*
|
|
67
|
+
* @param objectId - The unique identifier of the object that has moved.
|
|
68
|
+
*/
|
|
69
|
+
updateAnchorsForObject(objectId: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Snaps a line endpoint to an object's center position.
|
|
72
|
+
* Converts world coordinates to the line's local coordinate system before updating.
|
|
73
|
+
*
|
|
74
|
+
* @param line - The KritzelLine object to update.
|
|
75
|
+
* @param endpoint - Which endpoint to snap ('start' or 'end').
|
|
76
|
+
* @param targetObjectId - The unique identifier of the target object to snap to.
|
|
77
|
+
*/
|
|
78
|
+
private snapEndpointToObject;
|
|
79
|
+
/**
|
|
80
|
+
* Converts world coordinates to a line's local coordinate system.
|
|
81
|
+
* Applies inverse rotation and scale transformations to translate
|
|
82
|
+
* from global canvas coordinates to the line's internal SVG coordinates.
|
|
83
|
+
*
|
|
84
|
+
* @param line - The KritzelLine object providing the transformation context.
|
|
85
|
+
* @param worldX - The X coordinate in world/canvas space.
|
|
86
|
+
* @param worldY - The Y coordinate in world/canvas space.
|
|
87
|
+
* @returns An object containing the local x and y coordinates.
|
|
88
|
+
*/
|
|
89
|
+
private worldToLineLocal;
|
|
90
|
+
/**
|
|
91
|
+
* Finds an object that can be snapped to when the cursor is sufficiently close to its center.
|
|
92
|
+
* Snap is only triggered when the cursor is inside the object's bounds AND within 1/5 of the
|
|
93
|
+
* shorter side from the center, so snapping activates only as the user approaches the center
|
|
94
|
+
* and releases quickly as they move away.
|
|
95
|
+
* Returns null if no suitable snap target is found.
|
|
96
|
+
*
|
|
97
|
+
* @param worldX - X coordinate in world space
|
|
98
|
+
* @param worldY - Y coordinate in world space
|
|
99
|
+
* @param excludeLineId - ID of the line being edited (to exclude from snap targets)
|
|
100
|
+
* @param otherEndpointAnchorId - ID of object anchored to the other endpoint (to prevent same-object anchoring)
|
|
101
|
+
* @param pointerType - The pointer type driving the drag interaction.
|
|
102
|
+
*/
|
|
103
|
+
findSnapTarget(worldX: number, worldY: number, excludeLineId: string, otherEndpointAnchorId?: string, pointerType?: string): SnapTarget | null;
|
|
104
|
+
/**
|
|
105
|
+
* Finds the topmost anchorable object currently containing the dragged endpoint.
|
|
106
|
+
* Used to drive preview UI before an actual snap engages.
|
|
107
|
+
*/
|
|
108
|
+
findSnapPreviewTarget(worldX: number, worldY: number, excludeLineId: string, otherEndpointAnchorId?: string): SnapTarget | null;
|
|
109
|
+
private findBestSnapTarget;
|
|
110
|
+
private getSnapRadius;
|
|
111
|
+
/**
|
|
112
|
+
* Sets the current snap candidate for visual feedback during line endpoint dragging.
|
|
113
|
+
* Updates the store state and triggers a rerender to show the snap indicator.
|
|
114
|
+
*
|
|
115
|
+
* @param candidate - The SnapCandidate object containing snap target info, or null to clear.
|
|
116
|
+
*/
|
|
117
|
+
setSnapCandidate(candidate: SnapCandidate | null): void;
|
|
118
|
+
/**
|
|
119
|
+
* Sets the current snap preview candidate for early visual feedback during line dragging.
|
|
120
|
+
* Preview state must remain separate from active snap state so line clipping and anchor
|
|
121
|
+
* commit semantics only react to actual snaps.
|
|
122
|
+
*
|
|
123
|
+
* @param candidate - The preview candidate object, or null to clear.
|
|
124
|
+
*/
|
|
125
|
+
setSnapPreviewCandidate(candidate: SnapPreviewCandidate | null): void;
|
|
126
|
+
/**
|
|
127
|
+
* Gets the current snap candidate from the store state.
|
|
128
|
+
*
|
|
129
|
+
* @returns The current SnapCandidate object if one exists, null otherwise.
|
|
130
|
+
*/
|
|
131
|
+
getSnapCandidate(): SnapCandidate | null;
|
|
132
|
+
/**
|
|
133
|
+
* Gets the current snap preview candidate from the store state.
|
|
134
|
+
*
|
|
135
|
+
* @returns The current preview candidate if one exists, null otherwise.
|
|
136
|
+
*/
|
|
137
|
+
getSnapPreviewCandidate(): SnapPreviewCandidate | null;
|
|
138
|
+
/**
|
|
139
|
+
* Clears the snap candidate from the store state and triggers a rerender.
|
|
140
|
+
* Should be called when snapping is cancelled or completed.
|
|
141
|
+
*/
|
|
142
|
+
clearSnapCandidate(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Clears the snap preview candidate from the store state and triggers a rerender.
|
|
145
|
+
*/
|
|
146
|
+
clearSnapPreviewCandidate(): void;
|
|
147
|
+
/**
|
|
148
|
+
* Gets render data for anchor lines visualization.
|
|
149
|
+
* Computes stroke widths, dash patterns, and indicator sizes scaled to the current viewport.
|
|
150
|
+
*
|
|
151
|
+
* @returns AnchorLinesRenderData object containing visualization parameters and anchor
|
|
152
|
+
* visualization data for both endpoints, or null if there's no selected line
|
|
153
|
+
* with anchors.
|
|
154
|
+
*/
|
|
155
|
+
getAnchorLinesRenderData(): AnchorLinesRenderData | null;
|
|
156
|
+
/**
|
|
157
|
+
* Gets render data for snap indicator visualization.
|
|
158
|
+
* Computes all visual parameters needed to render the snap preview including
|
|
159
|
+
* indicator radius, stroke widths, dash patterns, and arrow geometry.
|
|
160
|
+
*
|
|
161
|
+
* @returns SnapIndicatorRenderData object containing all visualization parameters,
|
|
162
|
+
* or null if there's no active snap candidate.
|
|
163
|
+
*/
|
|
164
|
+
getSnapIndicatorRenderData(): SnapIndicatorRenderData | null;
|
|
165
|
+
/**
|
|
166
|
+
* Gets render data for snap preview visualization.
|
|
167
|
+
*
|
|
168
|
+
* @returns SnapIndicatorRenderData for the active preview candidate, or null if none exists.
|
|
169
|
+
*/
|
|
170
|
+
getSnapPreviewRenderData(): SnapIndicatorRenderData | null;
|
|
171
|
+
private getIndicatorRenderDataForCandidate;
|
|
172
|
+
/**
|
|
173
|
+
* Handles cleanup when an object is deleted from the canvas.
|
|
174
|
+
* Detaches all lines that were anchored to the deleted object and
|
|
175
|
+
* removes the object from the internal anchor index.
|
|
176
|
+
*
|
|
177
|
+
* @param objectId - The unique identifier of the deleted object.
|
|
178
|
+
*/
|
|
179
|
+
handleObjectDeleted(objectId: string): void;
|
|
180
|
+
/**
|
|
181
|
+
* Handles cleanup when a line is deleted from the canvas.
|
|
182
|
+
* Removes all anchor index entries for the deleted line.
|
|
183
|
+
*
|
|
184
|
+
* @param lineId - The unique identifier of the deleted line.
|
|
185
|
+
*/
|
|
186
|
+
handleLineDeleted(lineId: string): void;
|
|
187
|
+
/**
|
|
188
|
+
* Rebuilds the anchor index from all lines in the object map.
|
|
189
|
+
* Iterates through all KritzelLine objects and indexes their anchor connections.
|
|
190
|
+
* Should be called after loading/deserializing objects or when the index may be stale.
|
|
191
|
+
*/
|
|
192
|
+
rebuildIndex(): void;
|
|
193
|
+
/**
|
|
194
|
+
* Adds an entry to the anchor index.
|
|
195
|
+
* Creates a new Set for the object if it doesn't exist in the index.
|
|
196
|
+
* Prevents duplicate entries by checking for existing matches.
|
|
197
|
+
*
|
|
198
|
+
* @param objectId - The unique identifier of the anchored-to object.
|
|
199
|
+
* @param lineId - The unique identifier of the line with the anchor.
|
|
200
|
+
* @param endpoint - Which endpoint of the line is anchored ('start' or 'end').
|
|
201
|
+
*/
|
|
202
|
+
private addToIndex;
|
|
203
|
+
/**
|
|
204
|
+
* Removes an entry from the anchor index.
|
|
205
|
+
* Cleans up empty Sets from the index to prevent memory leaks.
|
|
206
|
+
*
|
|
207
|
+
* @param objectId - The unique identifier of the anchored-to object.
|
|
208
|
+
* @param lineId - The unique identifier of the line with the anchor.
|
|
209
|
+
* @param endpoint - Which endpoint of the line is anchored ('start' or 'end').
|
|
210
|
+
*/
|
|
211
|
+
private removeFromIndex;
|
|
212
|
+
/**
|
|
213
|
+
* Gets a KritzelLine object by its unique identifier.
|
|
214
|
+
*
|
|
215
|
+
* @param lineId - The unique identifier of the line to retrieve.
|
|
216
|
+
* @returns The KritzelLine object if found and is a line, null otherwise.
|
|
217
|
+
*/
|
|
218
|
+
private getLineById;
|
|
219
|
+
/**
|
|
220
|
+
* Gets any KritzelBaseObject by its unique identifier.
|
|
221
|
+
*
|
|
222
|
+
* @param objectId - The unique identifier of the object to retrieve.
|
|
223
|
+
* @returns The KritzelBaseObject if found, null otherwise.
|
|
224
|
+
*/
|
|
225
|
+
private getObjectById;
|
|
226
|
+
/**
|
|
227
|
+
* Finds the target object that a line endpoint is anchored to.
|
|
228
|
+
* Searches among all non-selection objects in the store.
|
|
229
|
+
*
|
|
230
|
+
* @param line - The KritzelLine object to check.
|
|
231
|
+
* @param endpoint - Which endpoint to check ('start' or 'end').
|
|
232
|
+
* @returns The target KritzelBaseObject if the anchor exists and target is found, null otherwise.
|
|
233
|
+
*/
|
|
234
|
+
findAnchorTarget(line: KritzelLine, endpoint: 'start' | 'end'): KritzelBaseObject<Element> | null;
|
|
235
|
+
/**
|
|
236
|
+
* Computes anchor visualization data for a specific endpoint of a line with anchors.
|
|
237
|
+
* Calculates edge intersection points for rendering dashed lines from edge to center.
|
|
238
|
+
*
|
|
239
|
+
* @param line - The KritzelLine object to compute visualization for.
|
|
240
|
+
* @param endpoint - Which endpoint to compute visualization for ('start' or 'end').
|
|
241
|
+
* @returns AnchorVisualization object containing edge and center coordinates plus
|
|
242
|
+
* optional path data for curved lines, or null if no anchor exists.
|
|
243
|
+
*/
|
|
244
|
+
computeAnchorVisualization(line: KritzelLine, endpoint: 'start' | 'end'): AnchorVisualization | null;
|
|
245
|
+
/**
|
|
246
|
+
* Computes a clipped line path that stops at anchor edges instead of going to anchor centers.
|
|
247
|
+
* When arrows are present on anchored ends, the line is shortened so the arrow tip appears at the edge.
|
|
248
|
+
* Handles both straight lines and curved (quadratic Bezier) lines.
|
|
249
|
+
*
|
|
250
|
+
* @param line - The KritzelLine object to compute the clipped path for.
|
|
251
|
+
* @param offsetByViewBox - If true, subtracts line.x and line.y from coordinates (for selection UI).
|
|
252
|
+
* @returns The SVG path 'd' attribute string, or the original path if no clipping is needed.
|
|
253
|
+
*/
|
|
254
|
+
computeClippedLinePath(line: KritzelLine, offsetByViewBox?: boolean): string;
|
|
255
|
+
/**
|
|
256
|
+
* Computes anchor clipping information for a line endpoint connected to a target object.
|
|
257
|
+
* Dispatches to either curved or straight line computation based on line type.
|
|
258
|
+
*
|
|
259
|
+
* @param line - The KritzelLine object.
|
|
260
|
+
* @param endpoint - Which endpoint to compute clip info for ('start' or 'end').
|
|
261
|
+
* @param targetObject - The object the line is anchored to.
|
|
262
|
+
* @returns AnchorClipInfo containing local and world coordinates of the clip point,
|
|
263
|
+
* plus parameter t for curved lines, or null if computation fails.
|
|
264
|
+
*/
|
|
265
|
+
computeAnchorClipInfo(line: KritzelLine, endpoint: 'start' | 'end', targetObject: KritzelBaseObject<Element>): AnchorClipInfo | null;
|
|
266
|
+
/**
|
|
267
|
+
* Computes clip information for a straight line anchored to a target object.
|
|
268
|
+
* Uses ray-casting from the opposite endpoint through the target's edge.
|
|
269
|
+
*
|
|
270
|
+
* @param line - The KritzelLine object (must be a straight line, no control point).
|
|
271
|
+
* @param endpoint - Which endpoint is anchored ('start' or 'end').
|
|
272
|
+
* @param targetObject - The object the line is anchored to.
|
|
273
|
+
* @returns AnchorClipInfo with intersection coordinates and parameter t, or null if no intersection.
|
|
274
|
+
*/
|
|
275
|
+
private computeStraightClipInfo;
|
|
276
|
+
/**
|
|
277
|
+
* Computes clip information for a curved (quadratic Bezier) line anchored to a target object.
|
|
278
|
+
* Samples along the curve to find where it exits the target object's bounds.
|
|
279
|
+
*
|
|
280
|
+
* @param line - The KritzelLine object (must have controlX and controlY defined).
|
|
281
|
+
* @param endpoint - Which endpoint is anchored ('start' or 'end').
|
|
282
|
+
* @param targetObject - The object the line is anchored to.
|
|
283
|
+
* @returns AnchorClipInfo with intersection coordinates and parameter t, or null if no intersection.
|
|
284
|
+
*/
|
|
285
|
+
private computeCurvedClipInfo;
|
|
286
|
+
/**
|
|
287
|
+
* Finds the point where a curved line exits a polygon boundary.
|
|
288
|
+
* Samples along the curve from the anchored endpoint outward, detecting
|
|
289
|
+
* the transition from inside to outside the polygon, then refines the result.
|
|
290
|
+
*
|
|
291
|
+
* @param line - The KritzelLine object (curved line with control point).
|
|
292
|
+
* @param endpoint - Which endpoint is anchored inside the polygon ('start' or 'end').
|
|
293
|
+
* @param polygonPoints - Array of points defining the polygon boundary.
|
|
294
|
+
* @returns AnchorClipInfo with the exit point coordinates and parameter t, or null if no exit found.
|
|
295
|
+
*/
|
|
296
|
+
private findCurveExitPoint;
|
|
297
|
+
/**
|
|
298
|
+
* Finds the exit point for a curved line going to a Path object.
|
|
299
|
+
* Uses distance-to-stroke sampling instead of polygon containment
|
|
300
|
+
* to detect when the line exits the path's stroke width boundary.
|
|
301
|
+
*
|
|
302
|
+
* @param line - The KritzelLine object (curved line with control point).
|
|
303
|
+
* @param endpoint - Which endpoint is anchored to the path ('start' or 'end').
|
|
304
|
+
* @param path - The KritzelPath object the line is anchored to.
|
|
305
|
+
* @returns AnchorClipInfo with the exit point coordinates and parameter t, or null if no exit found.
|
|
306
|
+
*/
|
|
307
|
+
private findCurveExitPointForPath;
|
|
308
|
+
/**
|
|
309
|
+
* Refines the curve exit parameter for a Path object using binary search.
|
|
310
|
+
* Narrows down the exact parameter t where the curve exits the path's stroke.
|
|
311
|
+
*
|
|
312
|
+
* @param line - The KritzelLine object being evaluated.
|
|
313
|
+
* @param pathPoints - Array of adjusted path points [[x, y], ...].
|
|
314
|
+
* @param halfStroke - Half of the path's stroke width for distance checks.
|
|
315
|
+
* @param insideT - Parameter t known to be inside the stroke.
|
|
316
|
+
* @param outsideT - Parameter t known to be outside the stroke.
|
|
317
|
+
* @returns The refined parameter t at the stroke boundary.
|
|
318
|
+
*/
|
|
319
|
+
private refineCurveExitParameterForPath;
|
|
320
|
+
/**
|
|
321
|
+
* Gets the adjusted world-space points for a Path object.
|
|
322
|
+
* Wrapper that delegates to computePathAdjustedPoints.
|
|
323
|
+
*
|
|
324
|
+
* @param path - The KritzelPath object to get points for.
|
|
325
|
+
* @returns Array of [x, y] coordinate pairs in world space.
|
|
326
|
+
*/
|
|
327
|
+
private getPathAdjustedPoints;
|
|
328
|
+
/**
|
|
329
|
+
* Computes world-space adjusted points for a Path object.
|
|
330
|
+
* Applies rotation and scale transformations to convert the path's
|
|
331
|
+
* internal points to world coordinates.
|
|
332
|
+
*
|
|
333
|
+
* @param path - The KritzelPath object to compute points for.
|
|
334
|
+
* @returns Array of [x, y] coordinate pairs in world space, or empty array if path has no points.
|
|
335
|
+
*/
|
|
336
|
+
private computePathAdjustedPoints;
|
|
337
|
+
/**
|
|
338
|
+
* Checks if a point is within the stroke width of a Path.
|
|
339
|
+
* Tests distance from the point to each segment of the path.
|
|
340
|
+
*
|
|
341
|
+
* @param x - X coordinate in world space.
|
|
342
|
+
* @param y - Y coordinate in world space.
|
|
343
|
+
* @param pathPoints - Array of [x, y] coordinate pairs defining the path.
|
|
344
|
+
* @param halfStroke - Half of the stroke width (the distance threshold).
|
|
345
|
+
* @returns True if the point is within halfStroke distance of any path segment.
|
|
346
|
+
*/
|
|
347
|
+
private isPointInPathStroke;
|
|
348
|
+
/**
|
|
349
|
+
* Calculates the shortest distance from a point to a line segment.
|
|
350
|
+
* Uses projection to find the nearest point on the segment, clamped to segment bounds.
|
|
351
|
+
*
|
|
352
|
+
* @param px - X coordinate of the point.
|
|
353
|
+
* @param py - Y coordinate of the point.
|
|
354
|
+
* @param x1 - X coordinate of segment start.
|
|
355
|
+
* @param y1 - Y coordinate of segment start.
|
|
356
|
+
* @param x2 - X coordinate of segment end.
|
|
357
|
+
* @param y2 - Y coordinate of segment end.
|
|
358
|
+
* @returns The distance from the point to the nearest point on the segment.
|
|
359
|
+
*/
|
|
360
|
+
private pointToSegmentDistance;
|
|
361
|
+
/**
|
|
362
|
+
* Refines the curve exit parameter using binary search.
|
|
363
|
+
* Narrows down the exact parameter t where the curve exits a polygon.
|
|
364
|
+
*
|
|
365
|
+
* @param line - The KritzelLine object being evaluated.
|
|
366
|
+
* @param polygonPoints - Array of points defining the polygon boundary.
|
|
367
|
+
* @param insideT - Parameter t known to be inside the polygon.
|
|
368
|
+
* @param outsideT - Parameter t known to be outside the polygon.
|
|
369
|
+
* @returns The refined parameter t at the polygon boundary.
|
|
370
|
+
*/
|
|
371
|
+
private refineCurveExitParameter;
|
|
372
|
+
/**
|
|
373
|
+
* Approximates the curve parameter t for a given world point by sampling.
|
|
374
|
+
* Finds the t value that produces a point closest to the target.
|
|
375
|
+
*
|
|
376
|
+
* @param line - The KritzelLine object to evaluate.
|
|
377
|
+
* @param target - The target point with x and y coordinates in world space.
|
|
378
|
+
* @returns The parameter t (0 to 1) that produces the closest point on the line.
|
|
379
|
+
*/
|
|
380
|
+
private approximateParameterForWorldPoint;
|
|
381
|
+
/**
|
|
382
|
+
* Evaluates a line at parameter t to get both local and world coordinates.
|
|
383
|
+
* For curved lines, uses quadratic Bezier interpolation.
|
|
384
|
+
* For straight lines, uses linear interpolation.
|
|
385
|
+
*
|
|
386
|
+
* @param line - The KritzelLine object to evaluate.
|
|
387
|
+
* @param t - The parameter value (0 = start, 1 = end).
|
|
388
|
+
* @returns Object containing clamped t, local coordinates, and world coordinates.
|
|
389
|
+
*/
|
|
390
|
+
private evaluateLineAtT;
|
|
391
|
+
/**
|
|
392
|
+
* Calculates the derivative speed (magnitude of tangent vector) at parameter t.
|
|
393
|
+
* For quadratic Bezier: |B'(t)| = |2(1-t)(P1-P0) + 2t(P2-P1)|
|
|
394
|
+
* For straight lines: constant length of the line segment.
|
|
395
|
+
*
|
|
396
|
+
* @param line - The KritzelLine object to evaluate.
|
|
397
|
+
* @param t - The parameter value (0 to 1).
|
|
398
|
+
* @returns The magnitude of the derivative (units per parameter unit).
|
|
399
|
+
*/
|
|
400
|
+
private evaluateDerivativeSpeedAtT;
|
|
401
|
+
/**
|
|
402
|
+
* Extracts a sub-segment from a quadratic Bezier curve.
|
|
403
|
+
* Uses de Casteljau's algorithm to split the curve at the specified t values.
|
|
404
|
+
*
|
|
405
|
+
* @param start - The start point of the original curve.
|
|
406
|
+
* @param control - The control point of the original curve.
|
|
407
|
+
* @param end - The end point of the original curve.
|
|
408
|
+
* @param tStart - The parameter value for the new start (0 to 1).
|
|
409
|
+
* @param tEnd - The parameter value for the new end (0 to 1).
|
|
410
|
+
* @returns A new QuadraticSegment representing the sub-curve from tStart to tEnd.
|
|
411
|
+
*/
|
|
412
|
+
private extractQuadraticSegment;
|
|
413
|
+
/**
|
|
414
|
+
* Splits a quadratic Bezier segment at parameter t using de Casteljau's algorithm.
|
|
415
|
+
*
|
|
416
|
+
* @param segment - The original QuadraticSegment to split.
|
|
417
|
+
* @param t - The parameter value to split at (0 to 1).
|
|
418
|
+
* @returns An object containing left and right QuadraticSegments.
|
|
419
|
+
*/
|
|
420
|
+
private splitQuadraticSegment;
|
|
421
|
+
/**
|
|
422
|
+
* Linearly interpolates between two points.
|
|
423
|
+
*
|
|
424
|
+
* @param a - The start point.
|
|
425
|
+
* @param b - The end point.
|
|
426
|
+
* @param t - The interpolation factor (0 = a, 1 = b).
|
|
427
|
+
* @returns A new QuadraticPoint at the interpolated position.
|
|
428
|
+
*/
|
|
429
|
+
private lerpPoint;
|
|
430
|
+
/**
|
|
431
|
+
* Builds an SVG path for the anchor visualization from clip point to target center.
|
|
432
|
+
* For straight lines, returns a simple line path. For curved lines, extracts and
|
|
433
|
+
* transforms the appropriate Bezier segment.
|
|
434
|
+
*
|
|
435
|
+
* @param line - The KritzelLine object.
|
|
436
|
+
* @param endpoint - Which endpoint is anchored ('start' or 'end').
|
|
437
|
+
* @param clipInfo - The computed clip information including coordinates and parameter t.
|
|
438
|
+
* @param targetObject - The target object the line is anchored to.
|
|
439
|
+
* @returns SVG path 'd' attribute string, or null if path cannot be built.
|
|
440
|
+
*/
|
|
441
|
+
private buildAnchorPath;
|
|
442
|
+
/**
|
|
443
|
+
* Builds an SVG quadratic Bezier path in world coordinates from a segment.
|
|
444
|
+
* Applies line transformations to convert local segment coordinates to world space.
|
|
445
|
+
*
|
|
446
|
+
* @param line - The KritzelLine providing transformation context.
|
|
447
|
+
* @param segment - The QuadraticSegment to convert to a path.
|
|
448
|
+
* @param reverse - If true, draws the path from end to start.
|
|
449
|
+
* @returns SVG path 'd' attribute string with M and Q commands.
|
|
450
|
+
*/
|
|
451
|
+
private buildWorldQuadraticPath;
|
|
452
|
+
/**
|
|
453
|
+
* Converts a KritzelPolygon to an array of corner points.
|
|
454
|
+
*
|
|
455
|
+
* @param polygon - The KritzelPolygon with topLeft, topRight, bottomRight, bottomLeft corners.
|
|
456
|
+
* @returns Array of KritzelPoint in clockwise order starting from topLeft.
|
|
457
|
+
*/
|
|
458
|
+
private getPolygonPoints;
|
|
459
|
+
/**
|
|
460
|
+
* Gets the custom clip polygon for an object if it has one.
|
|
461
|
+
* Used for non-rectangular shapes like ellipses and triangles that need
|
|
462
|
+
* special edge detection instead of using the default bounding box.
|
|
463
|
+
*
|
|
464
|
+
* @param object - The object to check for a custom clip polygon.
|
|
465
|
+
* @returns Array of KritzelPoint defining the clip boundary, or null for default behavior.
|
|
466
|
+
*/
|
|
467
|
+
private getClipPolygonForObject;
|
|
468
|
+
/**
|
|
469
|
+
* Gets the clip point for a Path object by finding the stroke edge intersection.
|
|
470
|
+
* Path objects don't use polygon-based clipping; they use distance-to-stroke calculations.
|
|
471
|
+
*
|
|
472
|
+
* @param object - The object to check (only processes KritzelPath objects).
|
|
473
|
+
* @param outsidePoint - A reference point outside the path to cast a ray from.
|
|
474
|
+
* @returns The intersection point on the path's stroke edge, or null if not a path or no intersection.
|
|
475
|
+
*/
|
|
476
|
+
private getPathClipPoint;
|
|
477
|
+
/**
|
|
478
|
+
* Converts local line coordinates to world coordinates.
|
|
479
|
+
* Applies the line's rotation, scale, and translation transformations
|
|
480
|
+
* to convert from internal SVG coordinates to canvas world space.
|
|
481
|
+
*
|
|
482
|
+
* @param line - The KritzelLine providing transformation context.
|
|
483
|
+
* @param localX - X coordinate in the line's local SVG space.
|
|
484
|
+
* @param localY - Y coordinate in the line's local SVG space.
|
|
485
|
+
* @returns Object with x and y coordinates in world space.
|
|
486
|
+
*/
|
|
487
|
+
private lineLocalToWorld;
|
|
488
|
+
/**
|
|
489
|
+
* Converts world coordinates to line's local SVG coordinates.
|
|
490
|
+
* Applies inverse transformations (scale, rotation, translation) to convert
|
|
491
|
+
* from canvas world space to the line's internal SVG coordinate system.
|
|
492
|
+
*
|
|
493
|
+
* @param line - The KritzelLine providing transformation context.
|
|
494
|
+
* @param worldX - X coordinate in world/canvas space.
|
|
495
|
+
* @param worldY - Y coordinate in world/canvas space.
|
|
496
|
+
* @returns Object with x and y coordinates in the line's local SVG space.
|
|
497
|
+
*/
|
|
498
|
+
private lineWorldToLocal;
|
|
499
|
+
private getSafeScale;
|
|
500
|
+
private areFiniteNumbers;
|
|
501
|
+
private isFiniteAnchorVisualization;
|
|
502
|
+
private isFinitePathData;
|
|
503
|
+
/**
|
|
504
|
+
* Checks if an object can be used as an anchor target.
|
|
505
|
+
* Excludes selection-related objects (SelectionBox, SelectionGroup) and
|
|
506
|
+
* line objects (lines cannot anchor to other lines).
|
|
507
|
+
*
|
|
508
|
+
* @param object - The object to check for anchorability.
|
|
509
|
+
* @returns True if the object can be anchored to, false otherwise.
|
|
510
|
+
*/
|
|
511
|
+
private isAnchorable;
|
|
512
|
+
}
|
|
513
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { KritzelCore } from '../core/core.class';
|
|
2
|
+
type BrowserPermissionHandler = () => Promise<PermissionState> | PermissionState;
|
|
3
|
+
/**
|
|
4
|
+
* Manages browser permission checks and prompts for a core instance.
|
|
5
|
+
*
|
|
6
|
+
* Permission-specific prompt logic is routed through a handler registry so new
|
|
7
|
+
* permissions can be added without changing the core control flow.
|
|
8
|
+
*/
|
|
9
|
+
export declare class KritzelBrowserPermissionManager {
|
|
10
|
+
private readonly _isFirefox;
|
|
11
|
+
private readonly _isSafari;
|
|
12
|
+
private readonly _requestHandlers;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new KritzelBrowserPermissionManager instance.
|
|
15
|
+
* @param core - The KritzelCore instance this manager belongs to
|
|
16
|
+
*/
|
|
17
|
+
constructor(_core: KritzelCore);
|
|
18
|
+
/**
|
|
19
|
+
* Registers a custom request handler for a browser permission name.
|
|
20
|
+
* Existing handlers are replaced, which makes the registry easy to extend.
|
|
21
|
+
*
|
|
22
|
+
* @param permissionName - The browser permission name to handle
|
|
23
|
+
* @param handler - The request implementation for that permission
|
|
24
|
+
*/
|
|
25
|
+
registerRequestPermissionHandler(permissionName: string, handler: BrowserPermissionHandler): void;
|
|
26
|
+
/**
|
|
27
|
+
* Checks the current state for a browser permission via the Permissions API.
|
|
28
|
+
*
|
|
29
|
+
* @param permissionName - The browser permission name to inspect
|
|
30
|
+
*/
|
|
31
|
+
checkPermission(permissionName: string): Promise<PermissionState>;
|
|
32
|
+
/**
|
|
33
|
+
* Requests a browser permission using the registered handler for the given
|
|
34
|
+
* permission name, then falls back to a permission check when no handler is
|
|
35
|
+
* registered.
|
|
36
|
+
*
|
|
37
|
+
* @param permissionName - The browser permission name to request
|
|
38
|
+
*/
|
|
39
|
+
requestPermission(permissionName: string): Promise<PermissionState>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { KritzelCore } from '../core/core.class';
|
|
2
|
+
import { KritzelClipboardPayload } from './clipboard.types';
|
|
3
|
+
export type { PasteIntent } from './clipboard.types';
|
|
4
|
+
/**
|
|
5
|
+
* Manages clipboard operations (copy/cut/paste) for a core instance.
|
|
6
|
+
*
|
|
7
|
+
* The system clipboard is the preferred source of truth: copy serializes the current
|
|
8
|
+
* selection into a Kritzel payload, paste reads + revives it.
|
|
9
|
+
*
|
|
10
|
+
* A copy also mirrors the payload into an in-memory session buffer. On platforms where
|
|
11
|
+
* eventless programmatic clipboard access is unavailable (notably iOS Safari, where the
|
|
12
|
+
* context menu triggers copy/paste without a native ClipboardEvent), the session buffer
|
|
13
|
+
* is used as the fallback source so internal object copy/paste keeps working.
|
|
14
|
+
*/
|
|
15
|
+
export declare class KritzelClipboardManager {
|
|
16
|
+
private readonly _core;
|
|
17
|
+
private readonly _pasteIntentRegistry;
|
|
18
|
+
/**
|
|
19
|
+
* In-memory mirror of the most recent copy payload. Acts as the fallback clipboard
|
|
20
|
+
* source when the system clipboard cannot be read programmatically (e.g. iOS Safari
|
|
21
|
+
* context-menu paste). Reset is not required; a new copy overwrites it.
|
|
22
|
+
*/
|
|
23
|
+
private _sessionClipboardPayload;
|
|
24
|
+
/**
|
|
25
|
+
* In-memory cascade offset (world units) applied to successive pastes of the same
|
|
26
|
+
* clipboard content so they don't stack exactly on top of each other. Reset on copy/cut.
|
|
27
|
+
*/
|
|
28
|
+
private _pasteOffset;
|
|
29
|
+
constructor(core: KritzelCore);
|
|
30
|
+
/**
|
|
31
|
+
* The most recent copy payload mirrored in memory, used as a fallback clipboard
|
|
32
|
+
* source when the system clipboard cannot be read programmatically.
|
|
33
|
+
*/
|
|
34
|
+
get sessionClipboardPayload(): KritzelClipboardPayload | null;
|
|
35
|
+
/**
|
|
36
|
+
* Serializes an object for the clipboard payload. Groups additionally embed their
|
|
37
|
+
* (recursively serialized) children under `__children__` so the payload is self-contained.
|
|
38
|
+
*/
|
|
39
|
+
private serializeForClipboard;
|
|
40
|
+
private serializeClipboardPayload;
|
|
41
|
+
private writeBrowserClipboardPayload;
|
|
42
|
+
/**
|
|
43
|
+
* Revives a single serialized clipboard object (and its embedded group children).
|
|
44
|
+
* IDs are NOT regenerated here; see regenerateIdsAndRemapAnchors.
|
|
45
|
+
*/
|
|
46
|
+
private reviveClipboardObject;
|
|
47
|
+
/**
|
|
48
|
+
* Assigns fresh unique IDs to every revived object (including nested group children),
|
|
49
|
+
* keeping group.childIds in sync and remapping line anchors that reference copied
|
|
50
|
+
* siblings to their new IDs. Anchors pointing at objects outside the pasted set are
|
|
51
|
+
* left untouched so they stay connected to the existing object.
|
|
52
|
+
*/
|
|
53
|
+
private regenerateIdsAndRemapAnchors;
|
|
54
|
+
/**
|
|
55
|
+
* Copies currently selected objects into internal clipboard state.
|
|
56
|
+
*/
|
|
57
|
+
copy(event?: ClipboardEvent): void;
|
|
58
|
+
/**
|
|
59
|
+
* Cuts currently selected objects (copy then delete).
|
|
60
|
+
*/
|
|
61
|
+
cut(event?: ClipboardEvent): void;
|
|
62
|
+
private materializeKritzelObjects;
|
|
63
|
+
private materializeImageFiles;
|
|
64
|
+
private prepareImageFile;
|
|
65
|
+
private materializePlainText;
|
|
66
|
+
/**
|
|
67
|
+
* Pastes objects from clipboard with optional explicit world coordinates.
|
|
68
|
+
*/
|
|
69
|
+
paste(x?: number, y?: number, event?: ClipboardEvent): Promise<void>;
|
|
70
|
+
private insertMaterializedObjects;
|
|
71
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const CLIPBOARD_PAYLOAD_PREFIX = "kritzel-clipboard/v1:";
|
|
2
|
+
export interface SerializedClipboardObject {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
__class__?: string;
|
|
5
|
+
__children__?: SerializedClipboardObject[];
|
|
6
|
+
}
|
|
7
|
+
export interface KritzelClipboardPayload {
|
|
8
|
+
version: 1;
|
|
9
|
+
sourceWorkspaceId?: string;
|
|
10
|
+
objects: SerializedClipboardObject[];
|
|
11
|
+
}
|
|
12
|
+
export type PasteIntent = {
|
|
13
|
+
type: 'kritzel_objects';
|
|
14
|
+
payload: KritzelClipboardPayload;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'image_files';
|
|
17
|
+
files: File[];
|
|
18
|
+
} | {
|
|
19
|
+
type: 'plain_text';
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'unknown';
|
|
23
|
+
};
|