@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,380 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { KritzelPath } from "../../classes/objects/path.class";
|
|
3
|
+
import { KritzelLine } from "../../classes/objects/line.class";
|
|
4
|
+
const STALE_THRESHOLD_MS = 10_000;
|
|
5
|
+
const REMOVE_THRESHOLD_MS = 30_000;
|
|
6
|
+
const CLEANUP_INTERVAL_MS = 3_000;
|
|
7
|
+
export class KritzelAwarenessCursors {
|
|
8
|
+
core;
|
|
9
|
+
showEdgeIndicators = true;
|
|
10
|
+
edgeIndicatorPadding = 8;
|
|
11
|
+
remoteCursors = new Map();
|
|
12
|
+
objectVersion = 0;
|
|
13
|
+
cleanupIntervalId;
|
|
14
|
+
objectChangeRafId = null;
|
|
15
|
+
removeAwarenessChangeListener;
|
|
16
|
+
removeObjectsChangeListener;
|
|
17
|
+
componentDidLoad() {
|
|
18
|
+
this.removeAwarenessChangeListener = this.core.store.objects?.onAwarenessChange(states => {
|
|
19
|
+
this.handleAwarenessChange(states);
|
|
20
|
+
});
|
|
21
|
+
this.removeObjectsChangeListener = this.core.store.objects?.onObjectsChange(() => {
|
|
22
|
+
this.handleRemoteObjectChange();
|
|
23
|
+
});
|
|
24
|
+
this.cleanupIntervalId = setInterval(() => {
|
|
25
|
+
this.cleanupStaleCursors();
|
|
26
|
+
}, CLEANUP_INTERVAL_MS);
|
|
27
|
+
if (this.cleanupIntervalId && typeof this.cleanupIntervalId.unref === 'function') {
|
|
28
|
+
this.cleanupIntervalId.unref();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
if (this.removeAwarenessChangeListener) {
|
|
33
|
+
this.removeAwarenessChangeListener();
|
|
34
|
+
this.removeAwarenessChangeListener = undefined;
|
|
35
|
+
}
|
|
36
|
+
if (this.removeObjectsChangeListener) {
|
|
37
|
+
this.removeObjectsChangeListener();
|
|
38
|
+
this.removeObjectsChangeListener = undefined;
|
|
39
|
+
}
|
|
40
|
+
if (this.cleanupIntervalId && typeof globalThis.clearInterval === 'function') {
|
|
41
|
+
globalThis.clearInterval(this.cleanupIntervalId);
|
|
42
|
+
this.cleanupIntervalId = undefined;
|
|
43
|
+
}
|
|
44
|
+
if (this.objectChangeRafId !== null && typeof globalThis.cancelAnimationFrame === 'function') {
|
|
45
|
+
globalThis.cancelAnimationFrame(this.objectChangeRafId);
|
|
46
|
+
this.objectChangeRafId = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
handleAwarenessChange(states) {
|
|
50
|
+
const localClientId = this.core.store.objects?.localClientId;
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
const updated = new Map(this.remoteCursors);
|
|
53
|
+
// Track which clientIds are still present
|
|
54
|
+
const activeClientIds = new Set();
|
|
55
|
+
states.forEach((state, clientId) => {
|
|
56
|
+
if (clientId === localClientId)
|
|
57
|
+
return;
|
|
58
|
+
if (!state.user)
|
|
59
|
+
return;
|
|
60
|
+
activeClientIds.add(clientId);
|
|
61
|
+
const user = state.user;
|
|
62
|
+
const cursor = state.cursor;
|
|
63
|
+
const activeObjectId = state.activeObjectId || null;
|
|
64
|
+
const selectionBox = state.selectionBox || null;
|
|
65
|
+
const existing = updated.get(clientId);
|
|
66
|
+
const cursorMoved = !existing ||
|
|
67
|
+
!existing.cursor !== !cursor ||
|
|
68
|
+
(cursor && existing.cursor && (cursor.x !== existing.cursor.x || cursor.y !== existing.cursor.y));
|
|
69
|
+
updated.set(clientId, {
|
|
70
|
+
clientId,
|
|
71
|
+
user,
|
|
72
|
+
cursor,
|
|
73
|
+
activeObjectId,
|
|
74
|
+
selectionBox,
|
|
75
|
+
lastUpdated: now,
|
|
76
|
+
lastCursorMove: cursorMoved ? now : (existing?.lastCursorMove ?? now),
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
// Remove cursors for disconnected clients
|
|
80
|
+
for (const clientId of updated.keys()) {
|
|
81
|
+
if (!activeClientIds.has(clientId)) {
|
|
82
|
+
updated.delete(clientId);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
this.remoteCursors = updated;
|
|
86
|
+
}
|
|
87
|
+
cleanupStaleCursors() {
|
|
88
|
+
const now = Date.now();
|
|
89
|
+
let changed = false;
|
|
90
|
+
const updated = new Map(this.remoteCursors);
|
|
91
|
+
for (const [clientId, cursor] of updated) {
|
|
92
|
+
if (now - cursor.lastUpdated > REMOVE_THRESHOLD_MS) {
|
|
93
|
+
updated.delete(clientId);
|
|
94
|
+
changed = true;
|
|
95
|
+
}
|
|
96
|
+
else if (!changed && now - cursor.lastCursorMove > STALE_THRESHOLD_MS) {
|
|
97
|
+
changed = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (changed) {
|
|
101
|
+
this.remoteCursors = updated;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
isStale(cursor) {
|
|
105
|
+
return Date.now() - cursor.lastCursorMove > STALE_THRESHOLD_MS;
|
|
106
|
+
}
|
|
107
|
+
hasActiveDrawingCursors() {
|
|
108
|
+
for (const cursor of this.remoteCursors.values()) {
|
|
109
|
+
if (cursor.activeObjectId)
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
handleRemoteObjectChange() {
|
|
115
|
+
if (!this.hasActiveDrawingCursors())
|
|
116
|
+
return;
|
|
117
|
+
// Debounce via rAF to batch multiple rapid Yjs updates into a single re-render
|
|
118
|
+
if (this.objectChangeRafId !== null)
|
|
119
|
+
return;
|
|
120
|
+
this.objectChangeRafId = requestAnimationFrame(() => {
|
|
121
|
+
this.objectChangeRafId = null;
|
|
122
|
+
this.objectVersion++;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
getActiveObjectTip(objectId) {
|
|
126
|
+
const obj = this.core.store.objects?.findById(objectId);
|
|
127
|
+
if (!obj)
|
|
128
|
+
return null;
|
|
129
|
+
if (obj instanceof KritzelPath && !obj.isCompleted) {
|
|
130
|
+
const lastPoint = obj.points[obj.points.length - 1];
|
|
131
|
+
if (!lastPoint)
|
|
132
|
+
return null;
|
|
133
|
+
return {
|
|
134
|
+
x: (lastPoint[0] - obj.x) / obj.scale + obj.translateX,
|
|
135
|
+
y: (lastPoint[1] - obj.y) / obj.scale + obj.translateY,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (obj instanceof KritzelLine && !obj.isCompleted) {
|
|
139
|
+
return {
|
|
140
|
+
x: (obj.endX - obj.x) / obj.scale + obj.translateX,
|
|
141
|
+
y: (obj.endY - obj.y) / obj.scale + obj.translateY,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// Shapes normalize their bounding box (x/y always top-left, width/height
|
|
145
|
+
// always positive), so we can't determine which corner the user is actively
|
|
146
|
+
// dragging. Fall back to the throttled awareness cursor position instead.
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
worldToScreen(worldX, worldY) {
|
|
150
|
+
const { scale, translateX, translateY } = this.core.store.state;
|
|
151
|
+
return {
|
|
152
|
+
x: worldX * scale + translateX,
|
|
153
|
+
y: worldY * scale + translateY,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
isInViewport(screenX, screenY) {
|
|
157
|
+
const { viewportWidth, viewportHeight } = this.core.store.state;
|
|
158
|
+
return screenX >= 0 && screenX <= viewportWidth && screenY >= 0 && screenY <= viewportHeight;
|
|
159
|
+
}
|
|
160
|
+
clampToEdge(screenX, screenY) {
|
|
161
|
+
const { viewportWidth, viewportHeight } = this.core.store.state;
|
|
162
|
+
const padding = this.edgeIndicatorPadding; // 8px
|
|
163
|
+
// Clamp symmetrically
|
|
164
|
+
const clampedX = Math.max(padding, Math.min(viewportWidth - padding, screenX));
|
|
165
|
+
const clampedY = Math.max(padding, Math.min(viewportHeight - padding, screenY));
|
|
166
|
+
// Determine nearest edge to position avatar inside
|
|
167
|
+
const distLeft = clampedX - padding;
|
|
168
|
+
const distRight = (viewportWidth - padding) - clampedX;
|
|
169
|
+
const distTop = clampedY - padding;
|
|
170
|
+
const distBottom = (viewportHeight - padding) - clampedY;
|
|
171
|
+
let edge = 'top';
|
|
172
|
+
const minDist = Math.min(distLeft, distRight, distTop, distBottom);
|
|
173
|
+
if (minDist === distLeft)
|
|
174
|
+
edge = 'left';
|
|
175
|
+
else if (minDist === distRight)
|
|
176
|
+
edge = 'right';
|
|
177
|
+
else if (minDist === distTop)
|
|
178
|
+
edge = 'top';
|
|
179
|
+
else
|
|
180
|
+
edge = 'bottom';
|
|
181
|
+
const angle = Math.atan2(screenY - clampedY, screenX - clampedX);
|
|
182
|
+
return { x: clampedX, y: clampedY, angle, edge };
|
|
183
|
+
}
|
|
184
|
+
getUserDisplayName(user) {
|
|
185
|
+
if (user.displayName)
|
|
186
|
+
return user.displayName;
|
|
187
|
+
if (user.firstName || user.lastName) {
|
|
188
|
+
return [user.firstName, user.lastName].filter(Boolean).join(' ');
|
|
189
|
+
}
|
|
190
|
+
return 'Unknown';
|
|
191
|
+
}
|
|
192
|
+
getInitials(name) {
|
|
193
|
+
const parts = name.trim().split(/\s+/);
|
|
194
|
+
if (parts.length === 0 || (parts.length === 1 && parts[0].length <= 1)) {
|
|
195
|
+
return name;
|
|
196
|
+
}
|
|
197
|
+
if (parts.length === 1) {
|
|
198
|
+
return parts[0][0].toUpperCase();
|
|
199
|
+
}
|
|
200
|
+
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
|
201
|
+
}
|
|
202
|
+
render() {
|
|
203
|
+
// Read reactive viewport state so Stencil re-renders on pan/zoom
|
|
204
|
+
const _scale = this.core.store.state.scale;
|
|
205
|
+
const _tx = this.core.store.state.translateX;
|
|
206
|
+
const _ty = this.core.store.state.translateY;
|
|
207
|
+
// Suppress unused variable warnings — these reads trigger Stencil reactivity
|
|
208
|
+
void _scale;
|
|
209
|
+
void _tx;
|
|
210
|
+
void _ty;
|
|
211
|
+
void this.objectVersion;
|
|
212
|
+
const cursors = Array.from(this.remoteCursors.values());
|
|
213
|
+
return (h(Host, { key: 'cf00004efc0c60e81bd6b2f19ecb7ca066396980' }, cursors.map(remoteCursor => {
|
|
214
|
+
if (!remoteCursor.cursor)
|
|
215
|
+
return null;
|
|
216
|
+
// When a remote user is actively drawing, derive cursor position from
|
|
217
|
+
// the object's latest coordinates (synced via Yjs) instead of the
|
|
218
|
+
// throttled awareness cursor position
|
|
219
|
+
let screen;
|
|
220
|
+
let trackingObject = false;
|
|
221
|
+
if (remoteCursor.activeObjectId) {
|
|
222
|
+
const tip = this.getActiveObjectTip(remoteCursor.activeObjectId);
|
|
223
|
+
if (tip) {
|
|
224
|
+
trackingObject = true;
|
|
225
|
+
screen = this.worldToScreen(tip.x, tip.y);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
screen = this.worldToScreen(remoteCursor.cursor.x, remoteCursor.cursor.y);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
screen = this.worldToScreen(remoteCursor.cursor.x, remoteCursor.cursor.y);
|
|
233
|
+
}
|
|
234
|
+
const inViewport = this.isInViewport(screen.x, screen.y);
|
|
235
|
+
const stale = this.isStale(remoteCursor);
|
|
236
|
+
const color = remoteCursor.user.color || '#6B7280';
|
|
237
|
+
if (inViewport) {
|
|
238
|
+
return this.renderCursor(remoteCursor, screen.x, screen.y, color, stale, trackingObject);
|
|
239
|
+
}
|
|
240
|
+
if (this.showEdgeIndicators) {
|
|
241
|
+
return this.renderEdgeIndicator(remoteCursor, screen.x, screen.y, color, stale, trackingObject);
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
}), cursors.map(remoteCursor => {
|
|
245
|
+
if (!remoteCursor.selectionBox)
|
|
246
|
+
return null;
|
|
247
|
+
const color = remoteCursor.user.color || '#6B7280';
|
|
248
|
+
const box = remoteCursor.selectionBox;
|
|
249
|
+
const topLeft = this.worldToScreen(box.x, box.y);
|
|
250
|
+
const { scale } = this.core.store.state;
|
|
251
|
+
const screenWidth = box.width * scale;
|
|
252
|
+
const screenHeight = box.height * scale;
|
|
253
|
+
return (h("div", { key: `selection-box-${remoteCursor.clientId}`, class: "remote-selection-box", style: {
|
|
254
|
+
transform: `translate(${topLeft.x}px, ${topLeft.y}px)`,
|
|
255
|
+
width: `${screenWidth}px`,
|
|
256
|
+
height: `${screenHeight}px`,
|
|
257
|
+
backgroundColor: `color-mix(in srgb, ${color} 20%, transparent)`,
|
|
258
|
+
borderColor: `color-mix(in srgb, ${color} 50%, transparent)`,
|
|
259
|
+
} }));
|
|
260
|
+
})));
|
|
261
|
+
}
|
|
262
|
+
renderCursor(cursor, screenX, screenY, color, stale, trackingObject) {
|
|
263
|
+
return (h("div", { key: `cursor-${cursor.clientId}`, class: { 'awareness-cursor': true, stale, 'tracking-object': trackingObject }, style: { transform: `translate(${screenX}px, ${screenY}px)` } }, h("svg", { class: "cursor-arrow", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M5 3L19 12L12 13L9 20L5 3Z", fill: color, stroke: "#ffffff", "stroke-width": "1.5", "stroke-linejoin": "round" })), h("span", { class: "cursor-label", style: { backgroundColor: color } }, this.getUserDisplayName(cursor.user))));
|
|
264
|
+
}
|
|
265
|
+
renderEdgeIndicator(cursor, screenX, screenY, color, stale, trackingObject) {
|
|
266
|
+
const clamped = this.clampToEdge(screenX, screenY);
|
|
267
|
+
const arrowDeg = (clamped.angle * 180) / Math.PI + 90;
|
|
268
|
+
// Position the username label opposite to the edge
|
|
269
|
+
const labelOffset = 20;
|
|
270
|
+
let labelX = 0;
|
|
271
|
+
let labelY = 0;
|
|
272
|
+
// Default transform origin is somewhat arbitrary without explicit layout
|
|
273
|
+
// We'll calculate simple translations relative to center point
|
|
274
|
+
if (clamped.edge === 'left') {
|
|
275
|
+
labelX = labelOffset;
|
|
276
|
+
}
|
|
277
|
+
else if (clamped.edge === 'right') {
|
|
278
|
+
labelX = -labelOffset;
|
|
279
|
+
}
|
|
280
|
+
else if (clamped.edge === 'top') {
|
|
281
|
+
labelY = labelOffset;
|
|
282
|
+
}
|
|
283
|
+
else if (clamped.edge === 'bottom') {
|
|
284
|
+
labelY = -labelOffset;
|
|
285
|
+
}
|
|
286
|
+
const displayName = this.getUserDisplayName(cursor.user);
|
|
287
|
+
return (h("div", { key: `edge-${cursor.clientId}`, class: { 'edge-indicator': true, stale, 'tracking-object': trackingObject }, style: {
|
|
288
|
+
transform: `translate(${clamped.x}px, ${clamped.y}px)`,
|
|
289
|
+
} }, h("svg", { class: { 'edge-arrow': true, stale }, width: "16", height: "16", viewBox: "0 0 16 16", style: { transform: `rotate(${arrowDeg}deg)` } }, h("path", { d: "M8 1L14 13H2L8 1Z", fill: color, stroke: "#ffffff", "stroke-width": "1.5", "stroke-linejoin": "round" })), h("span", { class: "edge-label", style: {
|
|
290
|
+
backgroundColor: color,
|
|
291
|
+
transform: `translate(${labelX}px, ${labelY}px)`,
|
|
292
|
+
} }, this.getInitials(displayName))));
|
|
293
|
+
}
|
|
294
|
+
static get is() { return "kritzel-awareness-cursors"; }
|
|
295
|
+
static get encapsulation() { return "shadow"; }
|
|
296
|
+
static get originalStyleUrls() {
|
|
297
|
+
return {
|
|
298
|
+
"$": ["kritzel-awareness-cursors.css"]
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
static get styleUrls() {
|
|
302
|
+
return {
|
|
303
|
+
"$": ["kritzel-awareness-cursors.css"]
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
static get properties() {
|
|
307
|
+
return {
|
|
308
|
+
"core": {
|
|
309
|
+
"type": "unknown",
|
|
310
|
+
"mutable": false,
|
|
311
|
+
"complexType": {
|
|
312
|
+
"original": "KritzelCore",
|
|
313
|
+
"resolved": "KritzelCore",
|
|
314
|
+
"references": {
|
|
315
|
+
"KritzelCore": {
|
|
316
|
+
"location": "import",
|
|
317
|
+
"path": "../../classes/core/core.class",
|
|
318
|
+
"id": "src/classes/core/core.class.ts::KritzelCore",
|
|
319
|
+
"referenceLocation": "KritzelCore"
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
"required": true,
|
|
324
|
+
"optional": false,
|
|
325
|
+
"docs": {
|
|
326
|
+
"tags": [],
|
|
327
|
+
"text": ""
|
|
328
|
+
},
|
|
329
|
+
"getter": false,
|
|
330
|
+
"setter": false
|
|
331
|
+
},
|
|
332
|
+
"showEdgeIndicators": {
|
|
333
|
+
"type": "boolean",
|
|
334
|
+
"mutable": false,
|
|
335
|
+
"complexType": {
|
|
336
|
+
"original": "boolean",
|
|
337
|
+
"resolved": "boolean",
|
|
338
|
+
"references": {}
|
|
339
|
+
},
|
|
340
|
+
"required": false,
|
|
341
|
+
"optional": false,
|
|
342
|
+
"docs": {
|
|
343
|
+
"tags": [],
|
|
344
|
+
"text": ""
|
|
345
|
+
},
|
|
346
|
+
"getter": false,
|
|
347
|
+
"setter": false,
|
|
348
|
+
"reflect": false,
|
|
349
|
+
"attribute": "show-edge-indicators",
|
|
350
|
+
"defaultValue": "true"
|
|
351
|
+
},
|
|
352
|
+
"edgeIndicatorPadding": {
|
|
353
|
+
"type": "number",
|
|
354
|
+
"mutable": false,
|
|
355
|
+
"complexType": {
|
|
356
|
+
"original": "number",
|
|
357
|
+
"resolved": "number",
|
|
358
|
+
"references": {}
|
|
359
|
+
},
|
|
360
|
+
"required": false,
|
|
361
|
+
"optional": false,
|
|
362
|
+
"docs": {
|
|
363
|
+
"tags": [],
|
|
364
|
+
"text": ""
|
|
365
|
+
},
|
|
366
|
+
"getter": false,
|
|
367
|
+
"setter": false,
|
|
368
|
+
"reflect": false,
|
|
369
|
+
"attribute": "edge-indicator-padding",
|
|
370
|
+
"defaultValue": "8"
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
static get states() {
|
|
375
|
+
return {
|
|
376
|
+
"remoteCursors": {},
|
|
377
|
+
"objectVersion": {}
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { KritzelMouseButton } from "../../enums/event-button.enum";
|
|
3
|
+
export class KritzelCursorTrail {
|
|
4
|
+
core;
|
|
5
|
+
cursorTrailPoints = [];
|
|
6
|
+
isLeftButtonDown = false;
|
|
7
|
+
handleMouseDown(ev) {
|
|
8
|
+
if (ev.pointerType === 'mouse') {
|
|
9
|
+
if (ev.button === KritzelMouseButton.Left) {
|
|
10
|
+
this.isLeftButtonDown = true;
|
|
11
|
+
this.cursorTrailPoints = [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (ev.pointerType === 'touch') {
|
|
15
|
+
if (this.core.store.state.pointers.size === 1) {
|
|
16
|
+
this.isLeftButtonDown = true;
|
|
17
|
+
this.cursorTrailPoints = [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
handlePointerMove(ev) {
|
|
22
|
+
if (!this.isLeftButtonDown) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const newPoint = { x: ev.clientX, y: ev.clientY, timestamp: Date.now() };
|
|
26
|
+
const updatedTrail = [newPoint, ...this.cursorTrailPoints];
|
|
27
|
+
if (updatedTrail.length > this.MAX_TRAIL_POINTS) {
|
|
28
|
+
this.cursorTrailPoints = updatedTrail.slice(0, this.MAX_TRAIL_POINTS);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.cursorTrailPoints = updatedTrail;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
handlePointerUp(ev) {
|
|
35
|
+
if (ev.pointerType === 'mouse') {
|
|
36
|
+
if (ev.button === KritzelMouseButton.Left) {
|
|
37
|
+
this.isLeftButtonDown = false;
|
|
38
|
+
this.cursorTrailPoints = [];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (ev.pointerType === 'touch') {
|
|
42
|
+
if (this.core.store.state.pointers.size === 0) {
|
|
43
|
+
this.isLeftButtonDown = false;
|
|
44
|
+
this.cursorTrailPoints = [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
trailCleanupIntervalId;
|
|
49
|
+
TRAIL_DURATION_MS = 100;
|
|
50
|
+
MAX_TRAIL_POINTS = 50;
|
|
51
|
+
componentDidLoad() {
|
|
52
|
+
this.trailCleanupIntervalId = window.setInterval(() => {
|
|
53
|
+
const now = Date.now();
|
|
54
|
+
const newTrailPoints = this.cursorTrailPoints.filter(p => now - p.timestamp < this.TRAIL_DURATION_MS);
|
|
55
|
+
if (newTrailPoints.length !== this.cursorTrailPoints.length) {
|
|
56
|
+
this.cursorTrailPoints = newTrailPoints;
|
|
57
|
+
}
|
|
58
|
+
}, 50);
|
|
59
|
+
}
|
|
60
|
+
disconnectedCallback() {
|
|
61
|
+
if (this.trailCleanupIntervalId) {
|
|
62
|
+
window.clearInterval(this.trailCleanupIntervalId);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
return (h(Host, { key: '707e81b135931233131a830d6fc63e721e381287' }, this.cursorTrailPoints.length > 1 && (h("svg", { key: 'b262b0e3a0cf3b1887ee6acedb2f00d72e95db7e', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
left: '0',
|
|
69
|
+
top: '0',
|
|
70
|
+
width: '100%',
|
|
71
|
+
height: '100%',
|
|
72
|
+
pointerEvents: 'none',
|
|
73
|
+
opacity: 'var(--kritzel-cursor-trail-opacity, 0.6)',
|
|
74
|
+
zIndex: '9000',
|
|
75
|
+
} }, this.cursorTrailPoints.slice(1).map((point, index) => {
|
|
76
|
+
const prevPoint = this.cursorTrailPoints[index];
|
|
77
|
+
const now = Date.now();
|
|
78
|
+
const age = now - point.timestamp;
|
|
79
|
+
const progress = Math.max(0, Math.min(1, age / this.TRAIL_DURATION_MS));
|
|
80
|
+
if (progress >= 1)
|
|
81
|
+
return null;
|
|
82
|
+
const baseStrokeWidth = Math.max(2, 15 * (1 - progress));
|
|
83
|
+
return (h("line", { key: `trail-segment-${point.timestamp}`, x1: prevPoint.x.toString(), y1: prevPoint.y.toString(), x2: point.x.toString(), y2: point.y.toString(), stroke: "var(--kritzel-cursor-trail-color, rgb(228, 228, 228))", "stroke-width": baseStrokeWidth.toString(), "stroke-linecap": "round" }));
|
|
84
|
+
})))));
|
|
85
|
+
}
|
|
86
|
+
static get is() { return "kritzel-cursor-trail"; }
|
|
87
|
+
static get encapsulation() { return "shadow"; }
|
|
88
|
+
static get originalStyleUrls() {
|
|
89
|
+
return {
|
|
90
|
+
"$": ["kritzel-cursor-trail.css"]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
static get styleUrls() {
|
|
94
|
+
return {
|
|
95
|
+
"$": ["kritzel-cursor-trail.css"]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
static get properties() {
|
|
99
|
+
return {
|
|
100
|
+
"core": {
|
|
101
|
+
"type": "unknown",
|
|
102
|
+
"mutable": false,
|
|
103
|
+
"complexType": {
|
|
104
|
+
"original": "KritzelCore",
|
|
105
|
+
"resolved": "KritzelCore",
|
|
106
|
+
"references": {
|
|
107
|
+
"KritzelCore": {
|
|
108
|
+
"location": "import",
|
|
109
|
+
"path": "../../classes/core/core.class",
|
|
110
|
+
"id": "src/classes/core/core.class.ts::KritzelCore",
|
|
111
|
+
"referenceLocation": "KritzelCore"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"required": true,
|
|
116
|
+
"optional": false,
|
|
117
|
+
"docs": {
|
|
118
|
+
"tags": [],
|
|
119
|
+
"text": ""
|
|
120
|
+
},
|
|
121
|
+
"getter": false,
|
|
122
|
+
"setter": false
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
static get states() {
|
|
127
|
+
return {
|
|
128
|
+
"cursorTrailPoints": {},
|
|
129
|
+
"isLeftButtonDown": {}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
static get listeners() {
|
|
133
|
+
return [{
|
|
134
|
+
"name": "pointerdown",
|
|
135
|
+
"method": "handleMouseDown",
|
|
136
|
+
"target": "window",
|
|
137
|
+
"capture": false,
|
|
138
|
+
"passive": true
|
|
139
|
+
}, {
|
|
140
|
+
"name": "pointermove",
|
|
141
|
+
"method": "handlePointerMove",
|
|
142
|
+
"target": "window",
|
|
143
|
+
"capture": false,
|
|
144
|
+
"passive": true
|
|
145
|
+
}, {
|
|
146
|
+
"name": "pointerup",
|
|
147
|
+
"method": "handlePointerUp",
|
|
148
|
+
"target": "window",
|
|
149
|
+
"capture": false,
|
|
150
|
+
"passive": true
|
|
151
|
+
}];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
position: relative;
|
|
4
|
+
height: 100%;
|
|
5
|
+
width: 100%;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
isolation: isolate;
|
|
8
|
+
background-color: var(--kritzel-engine-background-color, #ffffff);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:host,
|
|
12
|
+
:host * {
|
|
13
|
+
touch-action: none;
|
|
14
|
+
user-select: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ProseMirror {
|
|
18
|
+
outline: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
p, h1, h2, h3, h4, h5, h6, blockquote, pre {
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.debug-panel {
|
|
27
|
+
position: absolute;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
top: 0;
|
|
30
|
+
right: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.origin {
|
|
34
|
+
position: relative;
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
height: 0;
|
|
38
|
+
width: 0;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
-webkit-transform-origin: top left;
|
|
41
|
+
-moz-transform-origin: top left;
|
|
42
|
+
transform-origin: top left;
|
|
43
|
+
overflow: visible;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.object {
|
|
47
|
+
overflow: visible;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.kritzel-image-object--first-reveal {
|
|
51
|
+
animation: kritzel-image-first-reveal 180ms ease-out both;
|
|
52
|
+
will-change: filter;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@keyframes kritzel-image-first-reveal {
|
|
56
|
+
from {
|
|
57
|
+
filter: opacity(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
to {
|
|
61
|
+
filter: opacity(1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@media (prefers-reduced-motion: reduce) {
|
|
66
|
+
.kritzel-image-object--first-reveal {
|
|
67
|
+
animation: none;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.PlaygroundEditorTheme__quote {
|
|
72
|
+
margin: 0;
|
|
73
|
+
margin-left: 20px;
|
|
74
|
+
margin-bottom: 10px;
|
|
75
|
+
font-size: 15px;
|
|
76
|
+
color: rgb(101, 103, 107);
|
|
77
|
+
border-left-color: rgb(206, 208, 212);
|
|
78
|
+
border-left-width: 4px;
|
|
79
|
+
border-left-style: solid;
|
|
80
|
+
padding-left: 16px;
|
|
81
|
+
}
|